How to get vertices of a rotated line

Hey guys I have a straight line mesh rorated in an angle around the Z axis so the mesh is rotated in the x and y axis, however if I access the positionKind from mesh.getVerticesData after the rotation, I’m still getting the original positions. Whats the method to get and update their vertices?

You can either call mesh.bakeCurrentTransformIntoVertices before calling getVerticesData or transform the vertex positions by the transformation matrix of the mesh (mesh.computeWorldMatrix(true)) yourself.

Here’s how bakeCurrentTransformIntoVertices is doing it:

var transform = this.computeWorldMatrix(true);
var data = <FloatArray>this.getVerticesData(VertexBuffer.PositionKind);

var temp = new Array<number>();
var index: number;
for (index = 0; index < data.length; index += 3) {
    Vector3.TransformCoordinates(Vector3.FromArray(data, index), transform).toArray(temp, index);
1 Like

Hey @Evgeni_Popov, I’ve tried the bakeCurrentTransformIntoVertices but I’m getting the same results. here’s my playground :
old and new positions in the console are still the same

You forgot the parenthesis: clone.bakeCurrentTransformIntoVertices; => clone.bakeCurrentTransformIntoVertices();

1 Like

oh thanks, but now it looks like it actually changed the geometry to something else. It’s not on the same angle as it was before.

All clones share the same geometry, so changing the geometry for one (as bakeCurrentTransformIntoVertices does) changes for all.

You should call clone.makeGeometryUnique(); to make unique geometry for your clone.


thank you so much :slight_smile: