Get rotations of object in Physics simulations

When I have a sphere in Physics animation. The ball changes position and also rotates. In SceneExplorer I see a change in position, but I do not see a change in rotation. How do I get the X, Y, Z axis of rotation of a simulated object? What code should I use for mentioned task? Thanks for your time.

When using a physics engine, a quaternion is instead used for orientation. So the .rotationQuaternion property holds the orientation.

I tried it but the result did not come. A simple line of code down. One object should rotate like the other object. The result of this code is nothing. The object does not rotate according to its template.

object1.rotationQuaternion = object2.rotationQuaternion;

I don’t know how to get changes in the rotation of a body that is in motion simulation thanks to a Physics simulation.

are you looking for the angular velocity? Or are you trying to copy the rotation?

copy the rotation.

before you spin up the physics imposter on it go ahead and do
nodeA.rotationQuaternion = BABYLON.Quaternion. RotationYawPitchRoll(nodeA.position.x, nodeA.position.y, nodeA.position.z)

Then initialize the imposter.

Afterwards do an observable for afterPhysics or beforeRender or what have you and have it do clone the quat there, should work.

nodeA.rotationQuaternion = nodeB.rotationQuaternion.clone()

See if that works, it should.


Yeah, it looks that it really works, thanks!