From a981cfa1e99589fef042849e9e38b26f913e9c53 Mon Sep 17 00:00:00 2001 From: Felix Herbst Date: Mon, 10 Oct 2022 11:52:35 +0200 Subject: [PATCH] fix: prevent exception when loading glTF files that use KHR_animation_pointer extension fix: don't return, instead just skip the animations that aren't supported remove warning when node is undefined, just continue --- examples/jsm/loaders/GLTFLoader.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/jsm/loaders/GLTFLoader.js b/examples/jsm/loaders/GLTFLoader.js index b10a7425804b00..d784d811117241 100644 --- a/examples/jsm/loaders/GLTFLoader.js +++ b/examples/jsm/loaders/GLTFLoader.js @@ -3776,6 +3776,7 @@ class GLTFParser { const json = this.json; const animationDef = json.animations[ animationIndex ]; + const animationName = animationDef.name ? animationDef.name : 'animation_' + animationIndex; const pendingNodes = []; const pendingInputAccessors = []; @@ -3792,6 +3793,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 ) ); @@ -3929,9 +3932,7 @@ class GLTFParser { } - const name = animationDef.name ? animationDef.name : 'animation_' + animationIndex; - - return new AnimationClip( name, undefined, tracks ); + return new AnimationClip( animationName, undefined, tracks ); } );