-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add animation controls to Babylon preview. #97
Conversation
@emackey Do you mind if I make changes to this? It will be a lot easier to explain how to do it by actually writing the code. |
Please, by all means, make a branch off this one. Just be aware that AGI requires an emailed CLA to accept direct code contributions. |
I created a playground: http://playground.babylonjs.com/#3D23K4#2 that show how I would expect things to work. Start/Stop should work, pausing should not be necessary. |
That alien head creeps me out. But the code looks cleaner now. |
pages/babylonView.js
Outdated
@@ -50,6 +64,10 @@ window.BabylonView = function() { | |||
scene = new BABYLON.Scene(engine); | |||
scene.useRightHandedSystem = true; // This is needed for correct glTF normal maps. | |||
|
|||
BABYLON.SceneLoader.OnPluginActivatedObservable.add(function (plugin) { | |||
plugin.animationStartMode = BABYLON.GLTFLoaderAnimationStartMode.NONE; | |||
}); |
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.
Might consider doing this also:
BABYLON.SceneLoader.OnPluginActivatedObservable.add(function (plugin) {
plugin.animationStartMode = BABYLON.GLTFLoaderAnimationStartMode.NONE;
}, undefined, undefined, undefined, true);
This will make the observable unregister itself after it fires.
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.
other than a small comment, LGTM
Thanks @bghgary! |
Version 2.1.9 is published. |
Fixes #87.
@bghgary This is the strategy used here:
At startup, I iterate the list of
scene.animationGroups
to collect the names, I start any that aren't started (because I don't have a reference to the glTF loader to set the "all" flag), and I immediatelypause()
andreset()
all the started animations (so they are "stopped" from a user point of view, but Babylon just thinks they're paused).When the user toggles the UI, I call
animationGroup.pause(); animationGroup.reset();
oranimationGroup.restart();
to get the animation paused or restarted.In my experiments, I was never able to restart an animation after calling
stop
on it. So, I get them all into a started-but-paused state and just un-pause them or re-pause and reset them when the UI changes.