Splitting mesh instances into model entities

I have forked @yaustar’s example for splitting mesh instances (from another thread) into their own model components and have changed it to make separate entities out of each mesh instance and then offsets the original a few units in X so we can see both of them together - https://playcanvas.com/editor/scene/1142563

The code works fine for the existing ABC model as shown below:

But it does not work for a custom fbx that i imported.

My model for some reason has localScale of 100,100,100 but when applying that in the code that gives even weirder results.

I have tried many variants but cant figure out how to fix their transforms when converting from a mesh instance of single-model entity to split-entity that has its own model with a single mesh instance.

Any ideas how to fix this @yaustar?

The issue is that the individual parts localPosition is scaled by the parent’s scale as part of the model transformation.

Easiest thing to do here is to use the world position and rotation or rebuild the hierarchy
Using world Position and Rotation https://playcanvas.com/editor/scene/1142830

Also, if you would like, you can trial the beta feature of importing FBX’s with hierarchy as shown here: https://youtu.be/64fcCy9lvq8?t=4737

Send me a DM and I can add you to it. Warning: It is a beta feature so documentation doesn’t exist yet and there may be bugs/missing functionality.

1 Like