Browse Source

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

David Catuhe 7 years ago
parent
commit
9bfd24e32e
1 changed files with 19 additions and 0 deletions
  1. 19 0
      src/Materials/Textures/babylon.dynamicTexture.ts

+ 19 - 0
src/Materials/Textures/babylon.dynamicTexture.ts

@@ -178,6 +178,25 @@
             return newTexture;
             return newTexture;
         }
         }
 
 
+        /**
+         * Serializes the dynamic texture.  The scene should be ready before the dynamic texture is serialized
+         * @returns a serialized dynamic texture object
+         */
+        public serialize(): any {
+            const scene = this.getScene();
+            if (scene && !scene.isReady()) {
+                Tools.Warn("The scene must be ready before serializing the dynamic texture");
+            }
+
+            const serializationObject = super.serialize();
+            serializationObject.base64String = this._canvas.toDataURL();
+
+            serializationObject.invertY = this._invertY;
+            serializationObject.samplingMode = this.samplingMode;
+
+            return serializationObject;
+        }
+
         /** @hidden */
         /** @hidden */
         public _rebuild(): void {
         public _rebuild(): void {
             this.update();
             this.update();