Cannon js for bounding box

Hello!) I`m trying to apply physics to my 3d model - in loader I added this -

let loader = new THREE.GLTFLoader();
loader.load(
“./mazda_rx8/sceneUpdated_withWheels and front rims QUALITY.gltf”,
function (gltf) {
scene.add(gltf.scene);
car = gltf.scene.children[0];
car.traverse(function (child) {
if (child instanceof THREE.Mesh) {
child.geometry.computeBoundingBox();
gltf.bBox = child.geometry.boundingBox; //<-- Actually get the variable
}
});
car.castShadow = true;
car.receiveShadow = true;
console.clear();
console.log(car);
console.log(gltf.bBox);

…But what are the next steps?) I don`t understand how to use bounding box to my model and apply physics to this…in cannon tutors there are examples with cubes and spheres already made as cannon meshes. Thanks for any help!

1 Like

I’ve got a simple car physics example you can refer to where the physics shapes roughly encapsulate a mesh
Car Physics - Three.js Tutorials (sbcode.net)


press the <> inthe working example to view the js source

3 Likes

Thank you so much!

Box3 is what’s up :blush: