Open zoneblaze opened 6 years ago
Check https://github.com/spite/THREE.MeshLine/blob/master/demo/js/main-spinner.js#L223, you have to call .setGeometry again when you change your vertices. THREE.MeshLine needs to run some operations on your geometry.
I need to change the points at runtime. Which means I'm calling .setGeometry every render cycle. Any performance downsides on that part?
Also, a question, can the geometry that is used later, be larger than the initial geometry set on the MeshLine? Meaning, can it later have more vertices?
Is it possible to change the existing vertices? If possible, how can I add, remove or modify the vertices?
you have to call .setGeometry again when you change your vertices
I'm calling .setGeometry every render cycle. Any performance downsides on that part?
@ffpetrovic
Yes, MeshLine
creates a new internal positions
array every time (with this.positions = []
then fill sit up again), instead of reusing the same array, so the previous arrays will all need to be garbage collected.
can the geometry that is used later, be larger than the initial geometry set on the MeshLine? Meaning, can it later have more vertices?
Yes, because look at the code here:
As you can see there (click on it to see the code that isn't visible above), it assigns a new array to this.positions
, then copies all the Geometry's vertices into the array (wasteful, but works).
Is it possible to change the existing vertices? If possible, how can I add, remove or modify the vertices?
@Hari-KrishnanV Yes, read the comments above. ^
@spite It'd be great if it would re-use the same array, or even better, just iterate on the geometry's own vertices without using more memory.
Hi there, I'm new to 3JS, I managed to draw a simple straight line ok with MeshLine, next I need the start point and endpoint to animate in different directions.
geometry.vertices.push(new THREE.Vector3( 0, 0, 0)); geometry.vertices.push(new THREE.Vector3( 30, -30, -130 ));
I tried e.g "geometry.vertices[0].x += 1" on render udate with "this.geometry.verticesNeedUpdate = true"
But nothing happens, am I missing a trick or is it not possible to change a line shape once it has been initialized?