javascript - Drawing a line between moving objects -
i'm trying draw line between 2 moving vertices. vertex's drawing stored in variable called object
, has position
, three.vector3
.
the line created thusly:
var line = function(scene, source, target){ var geometry = new three.geometry(); geometry.dynamic = true; geometry.vertices.push(source.object.position); geometry.vertices.push(target.object.position); geometry.verticesneedupdate = true; var material = new three.linebasicmaterial({ color: 0x000000 }); var line = new three.line( geometry, material ); scene.add(line); return line; };
..., source , target vertices , vertices updated via:
vertex.object.position.add(vertex.velocity);
now, assigned source.object.position
, target.object.position
line.geometry.vertices[0]
, line.geometry.vertices[1]
because wanted 1 update other. instead, vertex positions vary wildly line positions. vertices are, lines don't connect vertices.
how can make lines move vertices?
in animation loop have set line.geometry.verticesneedupdate = true
. because every time after rendering becomes false
. jsfiddle example
Comments
Post a Comment