Submeshes and scaling. How to move submeshes to the new correct relative position?

Again, I’m doing some tests with some MakeHuman character.
Now I can import them and, before to move to more complicated manipulation, I tried the most basic one: scaling the character.

With some surprise I noticed that, when I scale the loaded mesh with
a.scaling = new BABYLON.Vector3(x, y, z);
the eyes are not scaled and, even worse, they don’t move to the new relative position.
So they stay at the same height and depth they were before (ie: the eyes appear on the forehead if the mesh is scaled down; on the mouth or on the neck if the mesh is scaled up)

Any indication of why this happens?

Edit: I import the character passing via Blender and then via the exporter plugin, so directly in the Babylon-friendly format.

1 Like

Hi Dr.Hell,

Definitely sounds like a problem. Can you confirm that the eyes and mouth are parented under the node you’re scaling? Probably the easiest way to do that would be to use the Inspector to manipulate the scaling in real-time while also looking at the hierarchy.

If that doesn’t work, or if it does and the problem still isn’t apparent, is there a way you can upload your model so we can look at it in a Playground?

2 Likes

To start I can add a screen of the model.
In the screenschot I’ve collapsed the code, so it is easier to follow it.
The eyes are at line 175 (the 1 was cut in the scree, so it seems line 75), immediately below the “subMeshes” that I underlined. So maybe there are exported as 2 meshes belonging to the same object?

I apply the trasformations to the whole object, though, and the positioning works (meaning that eyes and body are moved coherently to the same place), while the scaling doesn’t.

It is a very low poly version, so it’s only 56k and I can even post it somewhere, if needed for a more complete analysis.

Edit: this is what happens, scaling the body around 2x in height, the eyes remain at their original position (so they look like they are just under the breast)

Screenshot from 2021-09-24 22-03-27

1 Like

It would be great if you could share a repro in the playground ? It is pretty hard to infer what it is from the discussion only for this case

1 Like

Good idea, using the Playground.
Copying the same piece of code, it does work as intended.
So clearly there must happen something wrong between… somewhere in my code. Which means that it is a problem totally on my side.
Sorry for using your time, my friends.

Screenshot from 2021-09-24 22-31-07

1 Like

Ok, I seem to have pinpointed it: in playground I removed the base64String variables and their use in the model (I didn’t want to copy 100s of kb of textures for a test).
Since that was the only change, I did the same on the code on my side, and the scaling did work.

I will investigate it more.

Edit: not even that, I readded them and the scaling keep working. I have no idea of the magic that happend, but I will live with it.

1 Like

Glad you’ve got a solution! As something else to consider, I installed MakeHuman, exported a model as FBX, then used Blender to convert that FBX to a glTF 2.0 model. This imported excellently, and scaling worked as I would have expected out of the box.

2 Likes

Yes, now that I readded them, the scaling does work to me too, indeed.
No idea… maybe my tsc wasn’t compiling the updated version of some file that I touched?

1 Like

On tablet, so not checking anything. MH does not parent everything to the body. You need to do that in Blender.

Submeshes are only used meaningfully when there are multiple materials. Your export screen shot clearly shows that you still have multiple meshes. Join meshes in Blender to use multiple materials.

1 Like