소스 검색

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 2 년 전
부모
커밋
bee8eaf1b0
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  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 animationDef = json.animations[ animationIndex ];
+		const animationName = animationDef.name ? animationDef.name : 'animation_' + animationIndex;
 
 		const pendingNodes = [];
 		const pendingInputAccessors = [];
@@ -3793,6 +3794,8 @@ class GLTFParser {
 			const input = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.input ] : sampler.input;
 			const output = animationDef.parameters !== undefined ? animationDef.parameters[ sampler.output ] : sampler.output;
 
+			if ( target.node === undefined ) continue;
+
 			pendingNodes.push( this.getDependency( 'node', name ) );
 			pendingInputAccessors.push( this.getDependency( 'accessor', input ) );
 			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 );
 
 		} );