user2016641
user2016641

Reputation: 79

threejs tubegeometry getpointat does not rotate

When I create a TubeGeometry object, I can call getPointAt(t) to get the points along the object. Once I rotate the TubeGeometry however, when I then call getPointAt(t), the points are NOT rotated with the model? The geometry DOES rotate and looks right, but the getPointAt function returns the original, unrotated points. Is there a way to get them to rotate with the geometry?

Upvotes: 1

Views: 205

Answers (1)

WestLangley
WestLangley

Reputation: 104833

You created a TubeGeometry from a path, and a mesh from the TubeGeometry.

Now you want to call getPointAt( t ) to get points along the tube mesh.

If the mesh has been rotated, then you need to apply the same transformation to the returned value from getPointAt( t ) that is applied to the mesh.

var point = path.getPointAt( t ).applyMatrix4( mesh.matrixWorld );

mesh.matrixWorld() will be updated for you in the render loop. If there have been changes since the previous render, you will have to call mesh.updateMatrixWorld() yourself first.

three.js r.76

Upvotes: 1

Related Questions