0

I am trying to draw svg/pointcloud points on individual elements in Autodesk Forge. How to get (x,y,z) coordinates of elements.

Is there a way to extract positions of individual object so that we have the position vector in world space.

What I tried so far:

  • I cant seem to understand how to use the positions array as described in this thread using frags = viewer.impl.getRenderProxy( viewer.model, fragId )

    positions = frags.geometry.vb

  • Autodesk.ADN.Viewing.Extension.MeshData.js gives me the vertices of triangles (meshes/fragments) the element is made of.

anahom
  • 69
  • 4

1 Answers1

1

I've created a self-contained extension that you can add to your viewer and illustrates how to get the component position: enter image description here

Check this repo and the TransformationExplorerExtension

The code responsible for extracting the transformation matrix is:

getFragmentWorldMatrixByNodeId(nodeId) {
        let result = {
            fragId: [],
            matrix: [],
        };
        let viewer = this.viewer;
        this.tree.enumNodeFragments(nodeId, function (frag) {

            let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
            let matrix = new THREE.Matrix4();

            fragProxy.getWorldMatrix(matrix);

            result.fragId.push(frag);
            result.matrix.push(matrix);
        });
        return result;
    }
denis-grigor
  • 505
  • 5
  • 9