Toggling framingBehavior

I am using framingBehavior to automatically show all the objects in the mesh when they are loaded. However, I would like to have the framing behavior and bounds disabled after the objects are loaded for the first time.

I have tried:

var framingBehavior = new BABYLON.FramingBehavior();

framingBehavior.attach(renderer.camera);
framingBehavior.zoomOnMesh(myMesh, false, () => {
    framingBehavior.detach();
});

and

renderer.camera.useFramingBehavior = true;
renderer.camera.framingBehavior.framingTime = 1;
renderer.camera.setTarget(myMesh);
renderer.camera.useFramingBehavior = false;

In both cases, when zooming manually, the framing bounds are still enforced and zooming is limited to keep the whole mesh visible. Is there a way to completely remove them, as if framingBehavior was never set to true to start with?

Thank you!

you can change the camera upperRadiusLimit and lowerRadiusLimit in you zoomOnMesh callback and place them back to what you want

2 Likes

Thanks @sebavan. That worked.

P.S. Your response time is amazing! :slight_smile: :+1:

1 Like