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

Add animation controls to Babylon preview. #97

Merged
merged 4 commits into from
Mar 28, 2018
Merged

Conversation

emackey
Copy link
Member

@emackey emackey commented Mar 27, 2018

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 immediately pause() and reset() 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(); or animationGroup.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.

@bghgary
Copy link
Contributor

bghgary commented Mar 27, 2018

@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.

@emackey
Copy link
Member Author

emackey commented Mar 27, 2018

Please, by all means, make a branch off this one. Just be aware that AGI requires an emailed CLA to accept direct code contributions.

@bghgary
Copy link
Contributor

bghgary commented Mar 27, 2018

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.

@emackey
Copy link
Member Author

emackey commented Mar 28, 2018

That alien head creeps me out. But the code looks cleaner now.

@@ -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;
});
Copy link
Contributor

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.

Copy link
Contributor

@bghgary bghgary left a 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

@emackey emackey merged commit 13ca0fb into master Mar 28, 2018
@emackey emackey deleted the babylon-animation-ui branch March 28, 2018 00:49
@emackey
Copy link
Member Author

emackey commented Mar 28, 2018

Thanks @bghgary!

@emackey
Copy link
Member Author

emackey commented Mar 28, 2018

Version 2.1.9 is published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants