autodesk forge – How to fix ‘n.computeBoundingBox is not a function’ error while using THREE.Mesh?


fragIds.forEach(function(fragId){ 

            var fragProxy = Viewer.impl.getFragmentProxy(
                Viewer.model,
            fragId)

            fragProxy.getAnimTransform()
            
            //fragProxy.parameters

            console.log('frag position in LCS before transform:' + 
                            fragProxy.position.x + ','+
                            fragProxy.position.y + ','+ 
                            fragProxy.position.z);

            var wcsMatrix = new THREE.Matrix4(); 
            fragProxy.getWorldMatrix(wcsMatrix);
            var wcsPos = wcsMatrix.getPosition();
            console.log('frag position in wcs matrix  before transform: ' + 
            wcsPos.x + ' ' + wcsPos.y + ' ' + wcsPos.z);
            

            
            //fragProxy.position.set(wcsPos.x/2, wcsPos.y/2, wcsPos.z/2);
            const material = new THREE.MeshPhongMaterial({ color: 0xff0000 });
            const mesh = new THREE.Mesh(fragProxy, material);
            //mesh.position.y=wcsPos.y/2;
            mesh.scale.y=2;
            console.log( mesh.matrixWorld);
            mesh.matrixWorld.setPosition(100,0,0);
           
            Viewer.impl.scene.add(mesh);
            fragProxy.updateAnimTransform()  ;
            mesh.updateMatrixWorld();
        }); 
        Viewer.impl.sceneUpdated(true) 
297Viewer3DImpl.js:3566 Uncaught TypeError: n.computeBoundingBox is not a function
    at Viewer3DImpl.js:3566:30
    at K.Mesh.traverse (three.js:7986:3)
    at K.Scene.traverse (three.js:7990:23)
    at xt (Viewer3DImpl.js:3537:16)
    at _e.getVisibleBounds (Viewer3DImpl.js:3603:13)
    at Ze (Viewer3DImpl.js:619:31)
    at _e.tick (Viewer3DImpl.js:695:13)
    at e (Viewer3DImpl.js:1993:27)

while using const mesh = new THREE.Mesh(fragProxy, material); I am getting this type of error which I tried to solve in many ways

Can someone share their thoughts to help me with this situation ?

Read more here: Source link