Skip to content

Updating mesh of TubeGeometry object #1965

@themaninblue

Description

@themaninblue

Hi, I'm trying to create an animated tube, like a line that's being drawn live. This involves adding new points to an existing path and then redrawing the object so that it looks like it's being drawn.

However, I've struck a problem with the tube object I'm using: when I update the path points the mesh object doesn't update on the screen, so it seems like I can't modify it after it's been created.

My 3d object creation is roughly like this:

var curve = new THREE.SplineCurve3([new THREE.Vector3(x, y, z)]);
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 add to the path I'm doing it like this (but it seems a bit hacky so I'm open to other ways):

tubeMesh.children[0].geometry.path.points.push(new THREE.Vector3(x, y, z));
tubeMesh.children[0].geometry.verticesNeedUpdate = true;

However, when I make changes the object doesn't seem to update on screen. Is it possible to do this with a Tube?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions