setAbsolutePosition after parenting

Hello here !

I do not understand what is going on here?
https://playground.babylonjs.com/#AZIGC1#1

If someone can explain to me why the spheres are not at the same position?
What if I reverse lines 27 and 28 it works ??

Thank you!

Hello and welcome!
This is because the setAbsolutePosition is not triggering the matrix computation
This is done by line #30 here:
https://playground.babylonjs.com/#AZIGC1#2

1 Like

Okay! Thanks for answering!
I understand well!
So why is it not done automatically?

And so, after the fact, I was wondering what was the right behavior if the hierarchy was deeper? Should the computeWorldMatrix be applied across the entire chain?
Example:
https://playground.babylonjs.com/#AZIGC1#4
I have commented on lines that are not useful … In fact, one in two works … and vice versa
Is this normal?

Thanks again to you and have a nice day!

As far as I understand it, and I am no expert, it is done automatically but during the rendering phase not the interpretation phase.

using computeWorldMatrix forces when the calculation is done.

@JohnK is right. It will be done during the next frame rendering
We try to reduce all expensive operations. Computing matrices is one of them.