How to see collision shapes on an object in babylon.js "MeshImpostor doesn't work"

Hello everyone I am doing a practice with babylon.js with physics and collisions, the issue is that when importing a Blender3D model with the official plugin and babylon I cannot create a “MeshImpostor”.
I mean when importing the mesh collisions and everything works, but the collision shape seems to be a box, I would like to see the collision shapes and know why the collision shape doesn’t work.

Code example scene:

var createScene = function () {
    var scene = new BABYLON.Scene(engine);
    scene.clearColor = BABYLON.Color3.Blue();
    
    CrearCamaraRotadora();
    CrearIluminacion();

    // Esto activa la física en la escena y es muy importante para que los objetos se muevan y reaccionen a las colisiones
    scene.enablePhysics(new BABYLON.Vector3(0,-9.81 * 6, 1), new BABYLON.OimoJSPlugin());
    
    CrearScenaBlenderBabylonImport(scene);
    
    // Esto es para instanciar objetos a la escena
    instanciarCadaCiertoTiempo(100);//recibe como parametro cantidad de objetos

    return scene;
}

Code example importScene:

function CrearScenaBlenderBabylonImport(scene)
{
    BABYLON.SceneLoader.ImportMesh("",
         "./",
          "contenedor.babylon",
           scene, 
           function(meshes){
            const root = meshes.find(function (mesh) {return mesh.name === "caja"});
            root.checkCollisions = true;
            root.material = materialMadera();
            root.physicsImpostor = new BABYLON.PhysicsImpostor(root, BABYLON.PhysicsImpostor.MeshImpostor, { mass: 0}, scene);
    }); 
}

Mesh export From Blender 2.8 with plugin oficial babylon
contenedor.zip (117.0 KB)

I still can not see the collision forms, I could detect collisions, according to the official documentation for the MeshImpostor to work in physics, you have to use “cannon.js”.
However I see quite a few irregularities in the collisions,
I notice that a meshImpostor collides with SphereImpostor
but it doesn’t collide with BoxImpostor
Link info oficial documentation MeshImpostor

Code example:

    scene.enablePhysics(
    new BABYLON.Vector3(0,-9.81 * 6, 1),
    new BABYLON.CannonJSPlugin());//MeshImpostor no work with OimoJSPlugin

CannonJS’ MeshImpostor only works with spheres. If you need other Impostor types I would choose AmmoJS instead.

1 Like

Thanks for the clarification

Final Solution:

OimoJSPlugin() //no work with MeshImpostor and BoxImpostor

CannonJSPlugin() //no work with MeshImpostor and BoxImpostor

AmmoJSPlugin() //work with MeshImpostor and BoxImpostor

Project source code on github

Test instance showing the physics working correctly.

1 Like