Reputation: 2793
When I push points to my geometry after (!) renderer.render()
was called, the new lines are not displayed. I am setting geometry.verticesNeedUpdate
to true, as suggested.
Minimal example: https://jsfiddle.net/y2374dr1/9/
Note: Remove the first renderer.render() call to see all lines.
Is this a bug in THREE.js, or am I doing something wrong?
Upvotes: 1
Views: 43
Reputation: 31026
This is not a three.js
bug. First of all, you are using an outdated version of three.js
(R60
) which is several years old. I've updated the fiddle so it uses the latest version R113
and the latest supported API. Besides, it's important to know that THREE.Geometry
is somewhat deprecated. It is internally converted to THREE.BufferGeometry
. During this process, vertex buffer of a certain size are allocated. Since these buffers are fixed size (it's not possible to resize them), you see no effect of your vertex additions. You have to create a new geometry instead, so the renderer internally creates a new instance of THREE.BufferGeometry
.
For beginners, this is quite confusing. Hence, I recommend to completely avoid THREE.Geometry
and focus on THREE.BufferGeometry
instead. The restriction of using fixed-sized buffers becomes more obvious then. When working with THREE.BufferGeometry
, you have to create sufficiently sized buffers in the first place that are large enough to hold all upcoming vertex additions. Otherwise you have to delete and recreate buffers which is however an expensive operation.
https://jsfiddle.net/nqveab8y/1/
three.js R113
Upvotes: 1