ソースを参照

Implement data URL encoded texture loading

Scott Ramsby 7 年 前
コミット
b75706902d
1 ファイル変更6 行追加7 行削除
  1. 6 7
      src/Engine/babylon.nativeEngineWrapper.ts

+ 6 - 7
src/Engine/babylon.nativeEngineWrapper.ts

@@ -751,18 +751,17 @@
                     texture.onLoadedObservable.clear();
                 };
 
-                if (!fromData || isBase64) {
+                if (buffer instanceof ArrayBuffer) {
+                    onload(buffer);
+                } else if (buffer instanceof Blob) {
+                    throw new Error("Loading texture from Blob not yet implemented.");
+                } else if (!fromData) {
                     let onLoadFileError = (request?: XMLHttpRequest, exception?: any) => {
                         onInternalError("Failed to retrieve " + url + ".", exception);
                     }
                     Tools.LoadFile(url, onload, undefined, undefined, /*useArrayBuffer*/true, onLoadFileError);
-                } else if (buffer instanceof ArrayBuffer) {
-                    onload(buffer);
-                } else if (typeof buffer === "string" || buffer instanceof Blob) {
-                    throw new Error("Loading texture from string/Blob not yet implemented.");
-                    //Tools.LoadImage(buffer, onload, onInternalError, null);
                 } else {
-                    throw new Error("Unexpected texture source type.");
+                    onload(Tools.DecodeBase64(buffer as string));
                 }
             }