When loading a glb file with the new 4.x alpha version, the physics imposter seems to not get saved correctly:
To reproduce open this:
Open the debug tools, navigate through the nodes tree to the mesh and open it’s physics section. An undefined/nullpointer error will be thrown:
This only happens when using a glb or gltf file. Obj files work fine.
I suspect that this is the reason the collision detection is not working reliably for a more complex model in my project if I save it as glb. If I, however, save it as obj. everything works fine. Sadly I couldn’t reproduce the collision detection bug with this simple file.
EDIT: This example also has a collision detection bug. In around 1 of 10 times the sphere slips through the heart.
I was able to reproduce the mentioned bug about the non working collisions in a simplified version:
I modified this example: Babylon.js Playground from the docs to reproduce it.
Here is the non working example:
I copied the method makePhysicsObject and adjusted it slightly for the ground box.
The glb file was exported from Blender 2.8 with the Khronos exporter. A link to the original Blender file is in the comments.
Physics impostors only can exist on meshes that have no parent or are part of a compound object (eg. parent is also a physicis impostor). If the parent of the imported cube is set to null it will collide:
eg. https://playground.babylonjs.com/#66PS52#20. Setting the parent to null might change the look as gltfs will have a -1 z scale applied due to gltf using a different handedness than babylon so let me know if you run into more issues but the way the weird shape is imported in the playground you linked should work.
Thank you very much, that resolves the collision problem.
The undefined errors still happen.
Is there a valid use case for having an object with an physics imposter which does not ignore the parent but whichs parent has no imposter (that situation i thought was a bug)?
If not than I think we should at least display a warning or even better redesign the api in a way that it doesn’t allow creating such an invalid state. I spent quite some hours trying to debug that problem and think others will run into the same situation.
When creating a compound impostor the child mesh impostors are added before the parent so adding an error message here might be a bit tricky.