20

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.

1 Answer 1

21

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.