Browse Source

When the decoder isn't specified or WebAssembly isn't supported, skip decoding

This makes sure that files with EXT_meshopt_compression used as a
non-required extension don't fail to load.
Arseny Kapoulkine 4 years ago
parent
commit
a93688a741
2 changed files with 4 additions and 4 deletions
  1. 2 2
      examples/js/loaders/GLTFLoader.js
  2. 2 2
      examples/jsm/loaders/GLTFLoader.js

+ 2 - 2
examples/js/loaders/GLTFLoader.js

@@ -742,9 +742,9 @@ THREE.GLTFLoader = ( function () {
 			var buffer = this.parser.getDependency( 'buffer', extensionDef.buffer );
 			var decoder = this.parser.options.meshoptDecoder;
 
-			if ( !decoder ) {
+			if ( !decoder || !decoder.supported ) {
 
-				throw new Error( 'THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files' );
+				return null; // will use the fallback buffer if present
 
 			}
 

+ 2 - 2
examples/jsm/loaders/GLTFLoader.js

@@ -805,9 +805,9 @@ var GLTFLoader = ( function () {
 			var buffer = this.parser.getDependency( 'buffer', extensionDef.buffer );
 			var decoder = this.parser.options.meshoptDecoder;
 
-			if ( !decoder ) {
+			if ( !decoder || !decoder.supported ) {
 
-				throw new Error( 'THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files' );
+				return null; // will use the fallback buffer if present
 
 			}