Three.js TubeGeometry object grid update

I am trying to create a handset and the ability to interact with this handset, for example by dragging the mouse to change the start point / end point of the handset. To do this, I change the values ​​of the vertices directly at the vertices, and I would like to update the object in the scene

However, I ran into a problem with the tube item that I use: when I update the waypoints, the mesh object does not update on the screen, so it seems like I cannot modify it after it has been created.

Creating my 3D object is something like this:

var curve = new THREE.SplineCurve3([new THREE.Vector3(x, y, z), new THREE.Vector3(x2, y2, z2)]);
var geometry = new THREE.TubeGeometry(curve, segments, 2, radiusSegments, closed);
geometry.dynamic = true;
var tubeMesh = THREE.SceneUtils.createMultiMaterialObject(geometry, [new THREE.MeshBasicMaterial({color: 0xffffff, opacity: 1, transparent: true})]);
scene.add(tubeMesh);    

And when I want to update the points. I do it like this:

tubeMesh.children[0].geometry.path.points[0] = new THREE.Vector3(x4, y4, z4));
tubeMesh.children[0].geometry.path.points[1] = new THREE.Vector3(x3, y3, z3));
tubeMesh.children[0].geometry.verticesNeedUpdate = true;

However, when I make changes, the object does not update on the screen. Is it possible to do this with a tube?

+5
source share
1 answer

, , ,

geometry.verticesNeedUpdate = true;

geometry.dynamic = true;

Three.js , WebGLRenderer.

https://github.com/mrdoob/three.js/wiki/Updates

+5

All Articles