Browse Source

Texture.UseSerializedUrlIfAny

David Catuhe 7 years ago
parent
commit
c61884b959
2 changed files with 12 additions and 1 deletions
  1. 1 0
      dist/preview release/what's new.md
  2. 11 1
      src/Materials/Textures/babylon.texture.ts

+ 1 - 0
dist/preview release/what's new.md

@@ -19,6 +19,7 @@
 ## Updates
 ## Updates
 
 
 - Tons of functions and classes received the code comments they deserved (All the community)
 - Tons of functions and classes received the code comments they deserved (All the community)
+- New `Texture.UseSerializedUrlIfAny` static property to let textures serialize complete URL instead of using side by side loading ([deltakosh](https://github.com/deltakosh))
 - Added `particleSystem.reset()` to clear a particle system ([deltakosh](https://github.com/deltakosh))
 - Added `particleSystem.reset()` to clear a particle system ([deltakosh](https://github.com/deltakosh))
 - Added support for all RGBA orders (BGR, RGB, etc..) for the DDS loader ([deltakosh](https://github.com/deltakosh))
 - Added support for all RGBA orders (BGR, RGB, etc..) for the DDS loader ([deltakosh](https://github.com/deltakosh))
 - Improved [SceneOptimizer](http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer) to provide better adaptability ([deltakosh](https://github.com/deltakosh))
 - Improved [SceneOptimizer](http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer) to provide better adaptability ([deltakosh](https://github.com/deltakosh))

+ 11 - 1
src/Materials/Textures/babylon.texture.ts

@@ -35,6 +35,11 @@
         public static WRAP_ADDRESSMODE = 1;
         public static WRAP_ADDRESSMODE = 1;
         public static MIRROR_ADDRESSMODE = 2;
         public static MIRROR_ADDRESSMODE = 2;
 
 
+        /**
+         * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
+         */
+        public static UseSerializedUrlIfAny = false;
+
         // Members
         // Members
         @serialize()
         @serialize()
         public url: Nullable<string>;
         public url: Nullable<string>;
@@ -449,7 +454,12 @@
                     if (parsedTexture.base64String) {
                     if (parsedTexture.base64String) {
                         texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
                         texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
                     } else {
                     } else {
-                        texture = new Texture(rootUrl + parsedTexture.name, scene, !generateMipMaps);
+                        let url = rootUrl + parsedTexture.name; 
+
+                        if (Texture.UseSerializedUrlIfAny && parsedTexture.url ) {
+                            url = parsedTexture.url;
+                        }
+                        texture = new Texture(url, scene, !generateMipMaps);
                     }
                     }
 
 
                     return texture;
                     return texture;