How can I see when a FramingBehavior animation has finished?

Is there a way to check when a FramingBehavior animation has finished, like the example animation the docs have here?


Hey there. :slightly_smiling_face: setTarget doesn’t have a callback, but the function used to zoom on the mesh can be called directly and does have a callback parameter.

So for example, you can create the FramingBehavior object, attach it to the camera and then call zoomOnMesh manually with a callback parameter, like on the below playground. :beers:

Edit: it’s a little easier now that the PR is live (a hard page refresh might be needed thou). :slight_smile:


This is perfect, thank you so much!


@Blake has already shared a great solution, so I just wanted to chime in and say welcome to the Babylon community, and happy developing :slight_smile: Let us know if you have more questions!


Thank you! The community has been really helpful in figuring out Babylon.


I wonder if it would be good to add a callback property to FramingBehavior that gets passed to zoomOnMesh when the target is changed?

It was only a few lines of code so I jumped in and did it with a PR, which could be used like below for example:

// setup framing behavior
camera.useFramingBehavior = true;
camera.framingBehavior.onTargetFramingAnimationEnd = () => {
    alert("Finished framing!");

// set target

PS, let me know if an observable would be better and I can rework it. :slightly_smiling_face:

Edit: hurray the patch is live with a new observable! :beers:

1 Like