Преглед изворни кода

Custom Texture Serialization

= пре 9 година
родитељ
комит
d78baa9cd1

+ 1 - 0
src/Materials/Textures/babylon.colorGradingTexture.ts

@@ -214,6 +214,7 @@ module BABYLON {
             var serializationObject: any = {};
             serializationObject.name = this.name;
             serializationObject.level = this.level;
+            serializationObject.customType = "BABYLON.ColorGradingTexture";
 
             return serializationObject;
         }

+ 1 - 0
src/Materials/Textures/babylon.hdrcubetexture.ts

@@ -410,6 +410,7 @@ module BABYLON {
             serializationObject.generateHarmonics = this._generateHarmonics;
             serializationObject.usePMREMGenerator = this._usePMREMGenerator;
             serializationObject.isBABYLONPreprocessed = this._isBABYLONPreprocessed;
+            serializationObject.customType = "BABYLON.HDRCubeTexture";
 
             return serializationObject;
         }

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

@@ -260,7 +260,10 @@
             }
 
             var texture = SerializationHelper.Parse(() => {
-                if (parsedTexture.mirrorPlane) {
+                if (parsedTexture.customType) {
+                    var customTexture = Tools.Instantiate(parsedTexture.customType);
+                    return customTexture.Parse(parsedTexture, scene, rootUrl);
+                } else if (parsedTexture.mirrorPlane) {
                     var mirrorTexture = new MirrorTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
                     mirrorTexture._waitingRenderList = parsedTexture.renderList;
                     mirrorTexture.mirrorPlane = Plane.FromArray(parsedTexture.mirrorPlane);