Sign in to follow this  
fateriddle

How to play gltf animation with a trigger action?

Recommended Posts

Here's the demo

https://codesandbox.io/s/zl6vxmlw8m

I load the gltf file, and then find in a github issue to stop the animation when loaded.

But now I want to play the animation, say, when I click a button / at certain time. How do I do that?  (couldn't find in documentation the part of how to work with a loaded modal. Don't know how to even get the modal instance)

Share this post


Link to post
Share on other sites

9 hours ago, Deltakosh said:

The animation blending demo should be the right one (it is loading a .babylon but code is the same for any file format): https://www.babylonjs-playground.com/#BCU1XR#0

Do you recommend .babylon over .gltf ?

I noticed the callback function in SceneLoader.ImportMesh

function (newMeshes, particleSystems, skeletons) {}

While in SceneLoader.append

function (scene) { }

1. I tried to use Sceneloader.ImportMesh in my codesandbox example, it showed a blank screen. But if I use SceneLoader.append, it is not gonna give me the newMeshes as arguments, so I can't use Scene.beginAnimation because I don't know the target of my animation.
2. Also I imaging the asset I load consists of several meshes, say if I what to do scale animation (of them all of course), what is the target of the animation? 

Share this post


Link to post
Share on other sites

1. Both functions should work. But you are right importMesh is better in your case because you get the list of meshes. With Append, you can also uses scene.meshes

2. YOu can create a dummy TransformNode and make all your meshes child of this node

Also, I recommend using the playground for easier experiments (and it is easier for us to help).

babylon or gltf: Both are fine. glTF is not proprietary but has less features 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.