I just have to update a line that have 2 vertices, and i trying to use these things above that are changed in r58, but the lines cant move, i just made this to initialize:
var geometry = new THREE.BufferGeometry();
geometry.addAttribute('position', Float32Array, 2, 3);
geometry.dynamic = true;
var position = geometry.attributes.position;
position.needsUpdate = true;
var p = position.array;
var i = 0;
p[i++] = vertex1.position.x;
p[i++] = vertex1.position.y;
p[i++] = vertex1.position.z;
p[i++] = vertex2.position.x;
p[i++] = vertex2.position.y;
p[i] = vertex2.position.z;
var color = new THREE.Color();
color.g = color.b = 1 - this.value;
var material = new THREE.LineBasicMaterial({
color: color.getHex(),
linewidth: 5 // THIS DON'T WORKS IN WINDOWS?
});
this.model = new THREE.Line(geometry, material);
and in update rendering i´m just doing this:
var p = this.model.geometry.attributes.position.array;
var i = 0;
p[i++] = vertex1.position.x;
p[i++] = vertex1.position.y;
p[i++] = vertex1.position.z;
p[i++] = vertex2.position.x;
p[i++] = vertex2.position.y;
p[i] = vertex2.position.z;
but the lines didn´t move or render itself.
In your case, you need to add the following in your render loop when you update vertices:
this.model.geometry.attributes.position.needsUpdate = true;
You can remove the line position.needsUpdate = true
when you create the geometry.
I would also suggest that you update to the current version.
three.js r.63
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With