Search code examples
javascriptthree.jspoint-clouds

Three.js how to get PointCloud vertices with global positions


I have a PointCloud in my scene. The PointCloud is translated and rotated.

Now I want to export all pointCloud vertices with gloabalWorld positions.

PointCloud.geometry.__vertexArray

returns all vertices at the local positions. In which way I can get the global positions?

Thanks


Solution

  • You can do someting like this for meshes, I think it works for point clouds, too.

    var vertices = mesh.geometry.vertices;
    for ( var i = 0; i < vertices.length; i++ ) {
        var vertex = vertices[ i ].clone();
        vertex.applyMatrix4( mesh.matrixWorld );
        // do something with the transformed vertex
    }