Rotation Environment Texture

Hi everyone, I set an environment Texture to the scene and I try to rotate it on X and Y axes with these functions :

For RotationY →

scene.environmentTexture.setReflectionTextureMatrix(
BABYLON.Matrix.RotationY(
BABYLON.Tools.ToRadians(190)
)
);

And for RotationX →

scene.environmentTexture.setReflectionTextureMatrix(
BABYLON.Matrix.RotationX(
BABYLON.Tools.ToRadians(90)
)
);

But when I execute this two functions in a row, the first one works well and rotates the axis, but the second one resets the first changes (Y axis) but changes X axis as wanted. Do u know if I can do RotationY and RotationX whitout one or the other being reset ?

Best regards.

Hi @Miguel,

yes, it does seem like they will reset, as you are setting it a second time. You could combine the two rotations into one matrix (multiply mat1 with mat2), but we could only know for sure if you can share a (non) working playground. This way we can all play with the code and understand the flow.

Would you be able to share a playground with us?

Thank you for your reply.
I tested what you said about multiplying two matrix and it worked perfectly :

scene.environmentTexture.setReflectionTextureMatrix(BABYLON.Matrix.RotationY(BABYLON.Tools.ToRadians(190)).multiply(BABYLON.Matrix.RotationX(BABYLON.Tools.ToRadians(90))));

Many thanks !
Best regards.

3 Likes