Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLTFLoader: Prevent load exception for assets that animation.target.node is undefined #24770

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions examples/jsm/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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 ) );
Expand Down Expand Up @@ -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 );

} );

Expand Down