Is there a way to check when a FramingBehavior animation has finished, like the example animation the docs have here?
Hey there. 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.
https://playground.babylonjs.com/#6FBD14#1473
Edit: itâs a little easier now that the PR is live (a hard page refresh might be needed thou).
https://playground.babylonjs.com/#5T0H6Q
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 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
camera.setTarget(box);
PS, let me know if an observable would be better and I can rework it.
Edit: hurray the patch is live with a new observable!
https://playground.babylonjs.com/#5T0H6Q