Jump to content

Detect if animation is playing


Numa
 Share

Recommended Posts

Hi there, I'm back :D

Is there a way to detect if a mesh has animations playing and cancel them?

I'm using the following code to animate the emissive color of my meshes on mouse over, but it doesn't seem to be pushing the animation to mesh.animations:

BABYLON.Animation.CreateAndStartAnimation('fadingIn', objectUnderPointer, "material.emissiveColor", 30, 10, objectUnderPointer.material.emissiveColor, fullEmissive, 0);

Also the Animation class doesn't seem to have a stop method so I'm not sure where to go from there.

Thanks!

Link to comment
Share on other sites

@Numa - Perhaps there is a more efficient or function to provide more key info; however you can always mesh.getAbsolutePosition() for any mesh and measure the delta at any time in miliseconds. I know there was a request for mesh.getAbsoluteRotation(), however I don't believe this has been implimented yet.;) But if any object rotating has a child, you can use mesh.getAbsolutePosition for the child to know if animation is occuring. And if your object is not a skeleton or doesnt have a child, then parent a primitve object to the object which has animation, and set it's visibility to false or 0.0 - depending on which visibility function you use.

DB

Link to comment
Share on other sites

Thanks for the suggestion dbawel, but that's assuming the animated property is the position ^^ what if it's the color or something else? 

Anyway I found a way by going through the scene's animatables, looping through them and searching for the animatable containing an animation with a matching name, then stopping the animatable (not the animation). It seems like a very convoluted way of doing things but hey it works.

 

Also while digging I found the strangest function, what in the 7 gods is Animation.getHighestFrame() ? The doc doesn't say anything, did you mean getLastFrame() as in getFrameWithTheHighestFrameNumber ? :D

Thanks guys.

Link to comment
Share on other sites

Animation.getHighestFrame() was added by me.  Probably not that usable in application level code.  It is for copying named animation ranges from skeleton to another.  If the range in the source skeleton was 1 to 50, but there were already frames up to 500 in the destination skeleton, you would want the copy to go in frames 501 - 550.  getHighestFrame() returns 500.

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