Rotate Environment Texture

Hi, I am setting environment Texture to the scene using below function
BABYLON.CubeTexture.CreateFromPrefilteredData(‘environment.env’,scene);
I need to rotate that environment texture. How to achieve this?

Actually the skybox is just a mesh -
var skybox = BABYLON.MeshBuilder.CreateBox("skyBox", {size:1000.0}, scene);
So you can rotate it as any other mesh in the scene - https://playground.babylonjs.com/#UU7RQ#1207

scene.registerBeforeRender(function () {
        skybox.rotation.y += 0.001;
    });

Also, if you assign an environment texture to scene.environmentTexture, you can rotate it by using the uAng / vAng / wAng properties.

2 Likes

any examples for this, Because, I am trying to use this property but Couldn’t . @Evgeni_Popov

Here is another example - Babylon.js Playground
scene.registerBeforeRender(function () {
hdrTexture.rotationY += 0.003;
});

My bad, @labris is right, there’s no uAng/vAng/wAng properties because it is a cube texture. You should use the rotationY property instead.

If you want more control than the Y rotation only you can pass your own rotation matrix to setReflectionTextureMatrix.

2 Likes