-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fix glTF animations in tileset #8983
Conversation
Thanks for the pull request @ErixenCruz!
Reviewers, don't forget to make sure that:
|
@ErixenCruz here are some tilesets to test with. BatchedAnimated.zip - place in Local sandcastle for viewing these Add two tests to
Let me know how this goes! |
@lilleyse How's that? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @ErixenCruz, just one small suggestion for the instanced tileset code.
this._model.readyPromise.then(function (model) { | ||
model.activeAnimations | ||
.addAll({ | ||
loop: ModelAnimationLoop.REPEAT, | ||
}) | ||
.otherwise(function (error) { | ||
that._state = LoadState.FAILED; | ||
that._readyPromise.reject(error); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The otherwise
should be chained after .then
rather than after .addAll
. This .then
/.otherwise
chain allows the promise to be handled correctly whether the promise is resolved or rejected.
Chaining it after addAll
wouldn't end up catching an error since addAll
does not return a promise. My mistake for missing this earlier, I think I got lost in the indendation.
this._model.readyPromise.then(function (model) { | |
model.activeAnimations | |
.addAll({ | |
loop: ModelAnimationLoop.REPEAT, | |
}) | |
.otherwise(function (error) { | |
that._state = LoadState.FAILED; | |
that._readyPromise.reject(error); | |
}); | |
this._model.readyPromise | |
.then(function (model) { | |
model.activeAnimations.addAll({ | |
loop: ModelAnimationLoop.REPEAT, | |
}); | |
}) | |
.otherwise(function (error) { | |
that._state = LoadState.FAILED; | |
that._readyPromise.reject(error); | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite this code suggestion, I've been thinking more about the overall design here and think it makes sense to bring the functionality to Instanced3DModel3DTileContent
instead. I didn't noticed until reviewing that ModelInstanceCollection
already has an activeAnimations
getter and it's the caller's responsibility whether to add animations or not.
So the change will be something like this: in Instanced3DModel3DTileContent
, after ModelInstanceCollection
is created, add the animations when the collection is ready. It'll look just like the Batched3DModel3DTileContent
code in this PR except that model will be a model instance collection.
@@ -637,6 +641,35 @@ describe( | |||
}); | |||
}); | |||
|
|||
function checkAnimation(url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests looks great
Looks like CI has some test failures. #8983 (comment) seems to be the cause. Once that's addressed there shouldn't be any issues. |
…ise check to i3dm content.
Even after the fixes, some tests still fail. In particular, |
.otherwise(function (error) { | ||
//content._state = 3; | ||
content._readyPromise.reject(error); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that Batched3DModel3DTileContent
does not have a _readyPromise
property, the readyPromise
getter is actually just content._model.readyPromise
. This otherwise block is not necessary and can be removed.
.otherwise(function (error) { | ||
//content._state = 3; | ||
content._readyPromise.reject(error); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment to above - this .otherwise
block is not needed.
.then(function (model) { | ||
model.activeAnimations.addAll({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps rename model
to collection
var that = this; | ||
this._model.readyPromise.otherwise(function (error) { | ||
that._state = LoadState.FAILED; | ||
that._readyPromise.reject(error); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is still required, otherwise the collection's own ready promise won't get rejected if there's a problem when loading the model.
@lilleyse Tests pass! Like I mentioned, I have to rely on TravisCI for testing. Unreliable to run on my browser. |
Local tests work for me. There's some test failures on Mac/Chrome but none introduced in this branch. Thanks @ErixenCruz |
Fixes #8962
Fixed issue where tileset was not playing glTF animations.