I know through Physijs.BoxMesh Can let three.js The model has a physical effect

new Physijs.BoxMesh(Geometry, material, 1)

But now my model is imported through objloader. How can I make it have physical effect

var objLoader = new THREE.OBJLoader();
objLoader.load(baseUrl+"sofa/1/file.obj", function(mesh){
    mesh.scale.set(0.115, 0.115, 0.115);
    mesh.rotateY(-Math.PI/2);
    mesh.position.set(-105, 0, 80);
    scene.add(mesh);
})
1

There are 1 best solutions below

3
On

You could extract the geometry from the loaded mesh and use it to create your own Physijs.BoxMesh:

var objLoader = new THREE.OBJLoader();
var boxMesh;
objLoader.load(baseUrl+"sofa/1/file.obj", function(mesh){
    boxMesh = new Physijs.BoxMesh(mesh.geometry, mesh.material);
    boxMesh.scale.set(0.115, 0.115, 0.115);
    boxMesh.rotateY(-Math.PI/2);
    boxMesh.position.set(-105, 0, 80);
    scene.add(boxMesh);
})