Browse Source

Serialized Environment Texture Rotation

Added support for serialized cubeTexture.rotationY
MackeyK24 7 years ago
parent
commit
d4501023a5
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/Loading/Plugins/babylon.babylonFileLoader.ts

+ 6 - 2
src/Loading/Plugins/babylon.babylonFileLoader.ts

@@ -682,13 +682,17 @@
                 if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
                     if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
                         var hdrSize:number = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
-                        var hdrTexture:BABYLON.HDRCubeTexture = new BABYLON.HDRCubeTexture(rootUrl + parsedData.environmentTexture, scene, hdrSize);
+                        var hdrTexture = new HDRCubeTexture(rootUrl + parsedData.environmentTexture, scene, hdrSize);
                         if (parsedData.environmentTextureRotationY) {
                             hdrTexture.rotationY = parsedData.environmentTextureRotationY;
                         }
                         scene.environmentTexture = hdrTexture;
                     } else {
-                        scene.environmentTexture = CubeTexture.CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
+                        var cubeTexture = CubeTexture.CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
+                        if (parsedData.environmentTextureRotationY) {
+                            cubeTexture.rotationY = parsedData.environmentTextureRotationY;
+                        }
+                        scene.environmentTexture = cubeTexture;                        
                     }
                     if (parsedData.createDefaultSkybox === true) {
                         var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;