Jump to content

beginAnimation, callback function and multiple animations


amorgan
 Share

Recommended Posts

I have a Blender exported mesh with animation that has different animations in the same animation sequence, but at different frames. For example, animation_1 is at 0 - 40 frames and animation_2 is at 100 - 105 frames. I am calling them and getting the animatable object back from the scene.beginAnimation function.

For example:

scene.mesh.playAnimation1 = function () {
    if (scene.mesh.animatable) {
        scene.mesh.animatable.stop();
    }
    scene.mesh.animatable = {};
    scene.mesh.animatable = scene.beginAnimation(scene.bowMesh.skeletons, 0, 40, false, 1, function () {
        // do something
    });
}

I do this also for my other animation. Then I call scene.mesh.playAnimation1 to play it.

 

The problem I am having is that the callback function from both are playing, no matter which one I call, though the correct animation is playing? Is this a bug or am I using it in an unintended way. It seems as if I should take the beginAnimation out of this function, but I don't want it to play on load.

 

Thanks in advance for the help.

 

PS: Was about to post this without a playground example: http://www.babylonjs-playground.com/#24CTKX Click the FPS Label in the scene to start/toggle animation

-amorgan

Link to comment
Share on other sites

Blender exporter now supports actions.  If you make it into multiple actions you may still have issues when you call your named animation ranges, but felt it would help you.  Calling using this actions may avoid it.

var skeleton = scene.getSkeletonByName("my_skeleton");
skeleton.beginAnimation("actionName");

 

Link to comment
Share on other sites

Thanks for that update. This is good to know, I think the last time I was trying to get multiple animations on one mesh, BJS did not support this.

 

Though, I guess what I really want/need would be able to get an animatable object before calling beginAnimation and still be able to set up the specific animation (frames).

 

Am I missing something? There still seems to be either a bug, or I'm doing this the wrong way.

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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