Mesh transformation set in debug layer renders different with setting programmatically?

I tried to set position and rotation for a plane, when I do it with debug layer, it will look like this. The plan will be set on the right, with the given transforms value.

But when I tried to use those transformed value as code, I got something else instead, which I don’t understand why.

            wall.rotation = new BABYLON.Vector3(0, 90, 0)
            wall.position = new BABYLON.Vector3(2.5, 2.5, 0)

This is the playground to reproduce:

Do I need to apply transformation in specific order? Is there any difference with debug layer and code?

Rotation is in radians. I changed your PG:

Notice that I also moved the PhysicsImpostor to after positioning.


Ah I see, I understand what I have missed now. Thanks!

I notice that if I moved the PhysicsImpostor before positioning, the position will be wrong again. Shouldn’t the PhysicsImpostor follow the position of the mesh, if I haven’t disable bidirectional transformation?

That is strange, yes, although there is an explanation.

There is a characteristic on BJS which is, if you change rotation vector (euler angles) directly instead of using rotate(), it does clear rotationQuaternion (quaternion) and starts using only the euler angles. That might be related to the problem with physics being initialized before changing rotation euler angles.

When you change rotation before, maybe the physics initializes using the euler angles as well, which explains why it still works.

Now, if instead of touching rotation vector we use rotate(), then it works as you expected, that is, you can still initialize physics before positioning and rotating:

Maybe there is some internal qirk related to rotation and rotationQuaternion and physics, but I would not spend too much time trying to explain that, I would just initialize physics last and go on.

Hope this made sense.


Given the complexity of BJS, it definitely makes sense to me there. Thank you so much for your explanation!