|
@@ -12,6 +12,7 @@ import { TimingTools } from '../../Misc/timingTools';
|
|
import { InstantiationTools } from '../../Misc/instantiationTools';
|
|
import { InstantiationTools } from '../../Misc/instantiationTools';
|
|
import { Plane } from '../../Maths/math.plane';
|
|
import { Plane } from '../../Maths/math.plane';
|
|
import { StringTools } from '../../Misc/stringTools';
|
|
import { StringTools } from '../../Misc/stringTools';
|
|
|
|
+import { CopyTools } from '../../Misc/copyTools';
|
|
|
|
|
|
declare type CubeTexture = import("../../Materials/Textures/cubeTexture").CubeTexture;
|
|
declare type CubeTexture = import("../../Materials/Textures/cubeTexture").CubeTexture;
|
|
declare type MirrorTexture = import("../../Materials/Textures/mirrorTexture").MirrorTexture;
|
|
declare type MirrorTexture = import("../../Materials/Textures/mirrorTexture").MirrorTexture;
|
|
@@ -28,6 +29,12 @@ export class Texture extends BaseTexture {
|
|
*/
|
|
*/
|
|
public static SerializeBuffers = true;
|
|
public static SerializeBuffers = true;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
|
|
|
|
+ * If no buffer exists, one will be created as base64 string from the internal webgl data.
|
|
|
|
+ */
|
|
|
|
+ public static ForceSerializeBuffers = false;
|
|
|
|
+
|
|
/** @hidden */
|
|
/** @hidden */
|
|
public static _CubeTextureParser = (jsonTexture: any, scene: Scene, rootUrl: string): CubeTexture => {
|
|
public static _CubeTextureParser = (jsonTexture: any, scene: Scene, rootUrl: string): CubeTexture => {
|
|
throw _DevTools.WarnImport("CubeTexture");
|
|
throw _DevTools.WarnImport("CubeTexture");
|
|
@@ -667,12 +674,14 @@ export class Texture extends BaseTexture {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- if (Texture.SerializeBuffers) {
|
|
|
|
|
|
+ if (Texture.SerializeBuffers || Texture.ForceSerializeBuffers) {
|
|
if (typeof this._buffer === "string" && (this._buffer as string).substr(0, 5) === "data:") {
|
|
if (typeof this._buffer === "string" && (this._buffer as string).substr(0, 5) === "data:") {
|
|
serializationObject.base64String = this._buffer;
|
|
serializationObject.base64String = this._buffer;
|
|
serializationObject.name = serializationObject.name.replace("data:", "");
|
|
serializationObject.name = serializationObject.name.replace("data:", "");
|
|
} else if (this.url && StringTools.StartsWith(this.url, "data:") && this._buffer instanceof Uint8Array) {
|
|
} else if (this.url && StringTools.StartsWith(this.url, "data:") && this._buffer instanceof Uint8Array) {
|
|
serializationObject.base64String = "data:image/png;base64," + StringTools.EncodeArrayBufferToBase64(this._buffer);
|
|
serializationObject.base64String = "data:image/png;base64," + StringTools.EncodeArrayBufferToBase64(this._buffer);
|
|
|
|
+ } else if (Texture.ForceSerializeBuffers) {
|
|
|
|
+ serializationObject.base64String = CopyTools.GenerateBase64StringFromTexture(this);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|