Browse Source

Use TextDecoder when available in glTF loader

Gary Hsu 6 years ago
parent
commit
382ff56322
1 changed files with 4 additions and 0 deletions
  1. 4 0
      loaders/src/glTF/glTFFileLoader.ts

+ 4 - 0
loaders/src/glTF/glTFFileLoader.ts

@@ -796,6 +796,10 @@ export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISc
     }
 
     private static _decodeBufferToText(buffer: Uint8Array): string {
+        if (typeof TextDecoder !== "undefined") {
+            return new TextDecoder().decode(buffer);
+        }
+
         let result = "";
         const length = buffer.byteLength;