Hello, I’m rather new to Babylon so forgive me if I’ve gotten myself in over my head and just don’t realize it yet, but what I’m trying to do is to import a GLB that has no collision framework generated for it outside of Babylon and react physically realistically when dropped into the scene.
I’ve piggybacked off of someone else’s PG to create an example of the system that detects the collision, but then the impostor that is generated for the Palm (in this case) is imperfect and doesn’t react correctly. It also fails to be rendered by physicsViewer.
I appreciate any suggestions anyone has, even if it’s “read up on topic more.”
Hello! I see the palm is composed of multiple meshes with a single parent, which the mesh impostor unfortunately isn’t able to correctly instantiate. You’d have to create a mesh impostor for each child, then create a compound for them: Compound Bodies | Babylon.js Documentation (babylonjs.com).
If you don’t need to use Ammo, our new Physics architecture with Havok is MUCH better at handling compounds, you just need to create a mesh shape with the
includeChildMeshes option and pass the parent: Imported Mesh Auto Collision | Babylon.js Playground (babylonjs.com)
On a separate note, I restructured your example a bit to use the
addContainerTask instead of the
addMeshTask, the nice thing about using Asset Containers | Babylon.js Documentation (babylonjs.com) is that you don’t need to worry about setting the meshes you don’t want as not visible, you only add what you want to the scene
Interesting! I had no idea the model was composed of multiple meshes. I never opened it in an editor, I just started trying to achieve my proof of concept with the assets in the existing playground.
Incidentally, how were you able to tell that was the case? Is there a property I should have been able to review to have known that or would I have had to open it in an editor to find that out?
Thanks for the quick and concise response. You’ve saved me a ton of time chasing my tail, I’m sure.
No external editor needed, we have the trusty Inspector for that: The Inspector | Babylon.js Documentation (babylonjs.com) Very much recommend getting acquainted with the Inspector and its features, because they save a tooon of time when debugging! You can open the Inspector in any Playground by clicking this button here:
Doing that allows us to see how the tree is composed of multiple meshes:
Another useful alternative to quickly check models is the Babylon.js Sandbox - View glTF, glb, obj and babylon files (babylonjs.com). The nice thing with it is that you don’t need to write any code - you can just drag and drop your model and see it how it looks. The Sandbox also has the Inspector, so you can also do quick adjustments there, like changing a material’s color, etc, to see how it looks.
Hope these tools are helpful in your Babylon journey!
D’oh! That seems super obvious now. I am generally working on a local server (using notepad, as I am a bit old-school) and never played with it in the playground or incorporated the inspector into my local setup. It sounds like I should be using this tool more.
Thanks for answering a question some might see as obvious or dumb with patience!