user3648721
user3648721

Reputation: 157

Autodesk Forge Viewer getting fragment position

I'm trying to get the position of separate meshes in a model (translated from a revit file). What I'm doing is to get fragmentProxy, then use getOriginalWorldMatrix() to get the THREE.Matrix4(). Then from the Matrix4, call getPosition() to get the THREE.Vector3 world position of the fragment. However, every mesh returns the same position value. Is that because of how the model is built originally? Or I have to get the fragment position using a different method?

Upvotes: 1

Views: 719

Answers (1)

Petr Broz
Petr Broz

Reputation: 9909

Your process of retrieving the fragment transform is correct. Alternatively, you could use something like this:

function getFragmentTransform(model, fragid) {
    const frags = model.getFragmentList();
    let xform = new THREE.Matrix4();
    frags.getOriginalWorldMatrix(fragid, xform);
    return xform;
}

I'm afraid you are correct that, in some cases, the transform may be baked directly into the mesh vertices.

Upvotes: 3

Related Questions