Explorar o código

fix: prevent exception when loading glTF files that use KHR_animation_pointer extension (#24770)

fix: don't return, instead just skip the animations that aren't supported

remove warning when node is undefined, just continue
hybridherbst %!s(int64=2) %!d(string=hai) anos
pai
achega
bee8eaf1b0
Modificáronse 1 ficheiros con 4 adicións e 3 borrados
  1. 4 3
      examples/jsm/loaders/GLTFLoader.js

+ 4 - 3
examples/jsm/loaders/GLTFLoader.js

@@ -3777,6 +3777,7 @@ class GLTFParser {
 		const json = this.json;
 		const json = this.json;
 
 
 		const animationDef = json.animations[ animationIndex ];
 		const animationDef = json.animations[ animationIndex ];
+		const animationName = animationDef.name ? animationDef.name : 'animation_' + animationIndex;
 
 
 		const pendingNodes = [];
 		const pendingNodes = [];
 		const pendingInputAccessors = [];
 		const pendingInputAccessors = [];
@@ -3793,6 +3794,8 @@ class GLTFParser {
 			const input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input;
 			const input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input;
 			const output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output;
 			const output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output;
 
 
+			if ( target.node === undefined ) continue;
+
 			pendingNodes.push( this.getDependency( 'node', name ) );
 			pendingNodes.push( this.getDependency( 'node', name ) );
 			pendingInputAccessors.push( this.getDependency( 'accessor', input ) );
 			pendingInputAccessors.push( this.getDependency( 'accessor', input ) );
 			pendingOutputAccessors.push( this.getDependency( 'accessor', output ) );
 			pendingOutputAccessors.push( this.getDependency( 'accessor', output ) );
@@ -3930,9 +3933,7 @@ class GLTFParser {
 
 
 			}
 			}
 
 
-			const name = animationDef.name ? animationDef.name : 'animation_' + animationIndex;
-
-			return new AnimationClip( name, undefined, tracks );
+			return new AnimationClip( animationName, undefined, tracks );
 
 
 		} );
 		} );