I am not very skilled in ThreeJS.
I am trying to create bounding box to wrap a 3D model. The model is loaded well because I can see it on the scene
const loader = new GLTFLoader();
loader.load(
modelsPath[ 0 ],
( gltf ) => {
mesh = gltf.scene;
mesh.visible = false;
mesh.matrixAutoUpdate = false;
scene.add( mesh );
box1 = new THREE.Box3().setFromObject( mesh.asset );
group.add( box1 );
},
null,
function ( error ) {
console.log( error );
}
);
but when I use box1 = new THREE.Box3().setFromObject( mesh.asset ); I got the following error:
TypeError: Cannot read properties of undefined (reading 'updateWorldMatrix')
at Box3.expandByObject (Box3.js:160:1)
Do you have any idea?
Try this one
https://threejs.org/docs/#api/en/helpers/BoxHelper
and BTW how can you see mesh, when you set visibility property to mesh in
false? O_o