David `Deltakosh` Catuhe 5 years ago
parent
commit
796effd889

+ 3 - 1
serializers/src/glTF/2.0/glTFMaterialExporter.ts

@@ -536,7 +536,7 @@ export class _GLTFMaterialExporter {
                             else {
                             else {
                                 reject("gltfMaterialExporter: Failed to get blob from image canvas!");
                                 reject("gltfMaterialExporter: Failed to get blob from image canvas!");
                             }
                             }
-                        });
+                        }, mimeType);
                     }
                     }
                 }
                 }
                 else {
                 else {
@@ -1199,6 +1199,8 @@ export class _GLTFMaterialExporter {
                 }
                 }
                 const size = babylonTexture.getSize();
                 const size = babylonTexture.getSize();
 
 
+                mimeType = (babylonTexture as Texture).mimeType || mimeType;
+
                 return this._createBase64FromCanvasAsync(pixels, size.width, size.height, mimeType).then((base64Data) => {
                 return this._createBase64FromCanvasAsync(pixels, size.width, size.height, mimeType).then((base64Data) => {
                     const textureInfo = this._getTextureInfoFromBase64(base64Data, babylonTexture.name.replace(/\.\/|\/|\.\\|\\/g, "_"), mimeType, babylonTexture.coordinatesIndex, samplerIndex);
                     const textureInfo = this._getTextureInfoFromBase64(base64Data, babylonTexture.name.replace(/\.\/|\/|\.\\|\\/g, "_"), mimeType, babylonTexture.coordinatesIndex, samplerIndex);
                     if (textureInfo) {
                     if (textureInfo) {

+ 5 - 0
src/Materials/Textures/texture.ts

@@ -225,6 +225,11 @@ export class Texture extends BaseTexture {
     private _delayedOnError: Nullable<() => void> = null;
     private _delayedOnError: Nullable<() => void> = null;
     private _mimeType?: string;
     private _mimeType?: string;
 
 
+    /** Returns the texture mime type if it was defined by a loader (undefined else) */
+    public get mimeType() {
+        return this._mimeType;
+    }
+
     /**
     /**
      * Observable triggered once the texture has been loaded.
      * Observable triggered once the texture has been loaded.
      */
      */