TypeError: Cannot read properties of undefined (reading 'calculateWorldAABB') when using Cannon.js

I tried to init the physics with AmmoJS but it was giving another weird error.

Run this playground and then open the developer console to see the error.
My model loads, but none of the physics starts (balls spawn, table rotates).

https://playground.babylonjs.com/#S7E00P#193

Welcome to the forum !!!

cc @Cedric for the physics part

Hi @krpaul

movingMeshes[0] and fixedMeshes[0] do not point to meshes but to the __root__ transform.
Create impostors with child meshes.
BTW, you will have to merge down visible meshes or create 1 impostor per mesh.

2 Likes

What Cedric said, here’s a version creating 1 impostor per mesh: MeshImposter physics broken + Cannon not working | Babylon.js Playground (babylonjs.com)

This gave me some ideas about adding some warnings when someone tries to create a MeshImpostor for a node that doesn’t have vertices so I’ll do that

2 Likes

Add warnings and early return when trying to create a mesh impostor i… by carolhmj · Pull Request #12158 · BabylonJS/Babylon.js (github.com) PR up

2 Likes

I just did a test with Ammo, and it works differently, for the better : MeshImposter physics broken + Ammo working | Babylon.js Playground (babylonjs.com)

1 Like

You see, I tried that, but if you run the simulation the balls pass straight through my model. They don’t do that when create impostors for the __root__ node so I’m a little confused as to why we don’t want to assign the root node a physics imposter.