-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
GLTFLoader: Prevent load exception for assets that animation.target.node is undefined #24770
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
Conversation
177a714 to
ab6d6d3
Compare
|
@donmccurdy any opinion/objections here? |
|
@hybridherbst the core specification states —
I'd support a change doing that, but the current PR causes the entire animation (and all channels it contains) to be ignored. Could we ignore just the affected channel? I'm also fine with merging your other PRs instead, though I think there is an issue to be addressed in #24193 (comment). |
ab6d6d3 to
1d98d60
Compare
|
I think this change is good because @donmccurdy The spec describes that "When (target.node is) undefined, the animated object MAY be defined by an extension." If target.node is undefined and an extension defines it, should the extension be in |
I think the extension itself could decide one way or another here, e.g. to mandate |
I started to feel that it would be good to return a clip with tracks with empty target name. If Returning a clip with tracks with emptry target name will help the extension handlers like // a certain extension plugin
async loadAnimation(animationIndex) {
const animationDef = this.parser.json.animations[animationIndex];
const extensionDef = animationDef.extensions[this.name];
const clip = await this.parser.loadAnimation(animationIndex);
for (const track of clip.tracks) {
track.name = this._getTargetName(extensionDef) + track.name;
}
return clip;
}Another option may be adding a new hook for animation target like |
|
@takahirox the animation hooks that would be needed for KHR_animation_pointer are the ones in I just didn't get to respond yet... |
…_pointer extension fix: don't return, instead just skip the animations that aren't supported remove warning when node is undefined, just continue
|
Rebased on latest, I think this PR was already approved - would be great to get it merged :) |
2060505 to
a981cfa
Compare

Related issue: #24108
Description
Unfortunately there hasn't been much movement on merging my PRs for
KHR_animation_pointer(#24252, #24193 in preparation for #24108). In the meantime, people have starting using the extension and are bringing files to three.js that then fail with an exception.This PR fixes the exception and makes sure people can at least load files that have
KHR_animation_pointermarked as optional extension (according to glTF spec: when an extension is marked as optional implementations are fine to ignore it but should still display the rest of the file).An open question would be whether to return "null" AnimationClips, thus potentially breaking external code that assumes that whenever an animation is loaded an AnimationClip is returned, or returning a clip with no tracks:
I went with the latter here. There will be a log in the console that the extension isn't supported and people get empty tracks back instead of the current exception that looks like this:

My preference would definitely be KHR_animation_pointer support in three but in the meantime at least it shouldn't crash anymore for people.
This contribution is funded by Needle