Objects passing through imported glb blender model

Hi guys , I am planning to drop a sphere over the path I created on blender.
it is supposed to roll over the surface and fall into the torus at the end of it but instead it is passing through , like the image:
image

Is there some property I need to add from blender ?
This the class that renders the ground , the path and the sphere:


import { MeshBuilder, PhysicsAggregate, PhysicsShapeType, Scene, SceneLoader } from '@babylonjs/core'
import "@babylonjs/loaders";

export class Ramps {
    constructor(private scene: Scene) {

        this.createGround();
        this.createRamps();
        this.dropBall();
    }

    createGround(): void {
        const { scene } = this
        const mesh = MeshBuilder.CreateGround('ground', { width: 20, height: 20 }, scene)
        new PhysicsAggregate(mesh, PhysicsShapeType.BOX, { mass: 0 }, scene)
    }

    async createRamps(): Promise<void> {
        const ramps = await SceneLoader.ImportMeshAsync(
            "",
            "./model/",
            "rampa.glb",
            this.scene

        );

    }

    dropBall(): void {
        const ball = MeshBuilder.CreateSphere('myBall', { diameter: 2, segments: 32 }, this.scene)
        ball.position._y = 30;
        ball.position._x = -9;
        ball.position._z = 3;
        new PhysicsAggregate(ball, PhysicsShapeType.SPHERE, { mass: 1, restitution: 0.75 }, this.scene)

    }

}

btw :
1 - The sphere bounces ok on the ground.
2 - I would like to reproduce it on sandbox so I can share , but I dont know how to upload my glb model … is it possible ?

You need to add code to create physics objects. I believe it will be possible to do everything in Blender + GLTF physics extension but it’s not released yet. I think @RaananW will know more but its current state.

This extension is not yet available (probably coming in a month or two). In the meantime, it would be the best to create a body for the entire loaded model.
You can host the model in a github repository (for example), or share a project (with debuggable code) so we can see exacly what doesn’t work

Thanks guys !
I tried to re-create my idea on sandbox:
my idea on sandbox

unfortunatelly github is having some cors issues so I can not download my glb file from there, I will try to find another place to host the file.
Anyway , I can also provide the github link for this:
my hithub repo

So in case it is not possible to reutilze the glb environment I created on blender … should I create it in precedural way coding it ?

Thanks !!

@Cedric , will you be able to check what is wrong with the physics body?

There is this one: glTF + Physics + Babylon

There are no problems with Github, you just need to pass the right URL as described here - Babylon.js docs

Hi guys , you are so kind.
Here you can check the updated playground:
updated playground

You need to define the physicsAggregate for each mesh you need to have physics.
In order to do this you need to iterate over model meshes.
Here is the quick example - https://playground.babylonjs.com/#PCC8KV#2
I believe you may need not only boxes, but other BABYLON.PhysicsShapeType as well - it depends on the mesh shape.

1 Like

you solved it !!!

2 Likes