Jump to content

How to play gltf animation with a trigger action?


Recommended Posts

Here's the demo


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)

Link to comment
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? 

Link to comment
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 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...