فهرست منبع

Merge pull request #2521 from julien-moreau/master

Fixing PBR environment texture serialization. Override serialise in T…
David Catuhe 8 سال پیش
والد
کامیت
386cf76162
2فایلهای تغییر یافته به همراه12 افزوده شده و 1 حذف شده
  1. 11 0
      src/Materials/Textures/babylon.texture.ts
  2. 1 1
      src/Tools/babylon.textureTools.ts

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

@@ -303,6 +303,17 @@
             return this._onLoadObservable;
         }
 
+        public serialize(): any {
+            var serializationObject = super.serialize();
+            
+            if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
+                serializationObject.base64String = this._buffer;
+                serializationObject.name = serializationObject.name.replace("data:", "");
+            }
+
+            return serializationObject;
+        }
+
         // Statics
         public static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE, onLoad: () => void = null, onError: () => void = null, format: number = Engine.TEXTUREFORMAT_RGBA): Texture {
             return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);

+ 1 - 1
src/Tools/babylon.textureTools.ts

@@ -60,7 +60,7 @@
 
 		public static GetEnvironmentBRDFTexture(scene: Scene) {
 			if (!scene._environmentBRDFTexture) {
-				var texture = new BABYLON.Texture(this._environmentBRDFBase64Texture, scene, true, false, BABYLON.Texture.BILINEAR_SAMPLINGMODE);
+				var texture = Texture.CreateFromBase64String(this._environmentBRDFBase64Texture, "EnvironmentBRDFTexture", scene, true, false, Texture.BILINEAR_SAMPLINGMODE);
 
 				texture.wrapU = Texture.CLAMP_ADDRESSMODE;
 				texture.wrapV = Texture.CLAMP_ADDRESSMODE;