Skip to content

Commit

Permalink
fix: prevent exception when loading glTF files that use KHR_animation…
Browse files Browse the repository at this point in the history
…_pointer extension

fix: don't return, instead just skip the animations that aren't supported
  • Loading branch information
hybridherbst committed Nov 24, 2022
1 parent ddbfd26 commit 1d98d60
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions examples/jsm/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3625,6 +3625,7 @@ class GLTFParser {
const json = this.json;

const animationDef = json.animations[ animationIndex ];
const animationName = animationDef.name ? animationDef.name : 'animation_' + animationIndex;

const pendingNodes = [];
const pendingInputAccessors = [];
Expand All @@ -3641,6 +3642,17 @@ 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 ) {

if ( target.extensions && target.extensions[ 'KHR_animation_pointer' ] ) {

console.warn( 'THREE.GLTFLoader: KHR_animation_pointer is not yet supported.' );

}

continue;
}

pendingNodes.push( this.getDependency( 'node', name ) );
pendingInputAccessors.push( this.getDependency( 'accessor', input ) );
pendingOutputAccessors.push( this.getDependency( 'accessor', output ) );
Expand Down Expand Up @@ -3778,9 +3790,7 @@ class GLTFParser {

}

const name = animationDef.name ? animationDef.name : 'animation_' + animationIndex;

return new AnimationClip( name, undefined, tracks );
return new AnimationClip( animationName, undefined, tracks );

} );

Expand Down

0 comments on commit 1d98d60

Please sign in to comment.