Target framing animation end observable does not exist

Hi,

I found a method on the API documentation that I need to use but when I try to use it I got the typescript error message that Property ‘onTargetFramingAnimationEndObservable’ does not exist on type ‘FramingBehavior’.

Im not sure why. Im on the version 4.1.1 of the babylonjs/core npm package

If the method is deprecated or doesn’t exist anymore I need something to tell me when the animation of the framing has ended.

here is my code:

camera.framingBehavior.onTargetFramingAnimationEndObservable.add(() => {
				alert('Finished framing!');
			});

the type of camera is ArcRotateCamera imported from ‘@babylonjs/core’ package.

thanks in advance,

Marc-André

It works in the PG - https://playground.babylonjs.com/#6FBD14#1836
So it is not deprecated :slight_smile:

But in Typescript I also have the same error with

    camera.framingBehavior.onTargetFramingAnimationEndObservable.add(() => {
        alert('Finished framing!');
    });

TS2339 (TS) Property ‘onTargetFramingAnimationEndObservable’ does not exist on type ‘ArcRotateCamera’.

If I change it to

    camera._framingBehavior.onTargetFramingAnimationEndObservable.add(() => {
        alert('Finished framing!');
    });

I’ve got another error:
TS2341 (TS) Property ‘_framingBehavior’ is private and only accessible within class ‘ArcRotateCamera’.

1 Like

Wouldn’t casting the camera to any help get rid of the second error? Quite dirty, but should work :roll_eyes:

With camera:any there are no more TS errors in VS but the example still doesn’t work.
I have the same error in both cases, camera._framingBehavior and camera.framingBehavior

Property exist on the github repo on the master branch but doesn’t on the 4.2.1 branch.

1 Like

Well, this really strange :slight_smile:

Upgrading to 5.0 solves this problem.

3 Likes

Yes but sadly I cannot use a beta version of babylonJs in production for my project. I will wait for the official release and find another way for now.

Thank you for your time!

Have a great day!

2 Likes

Heya, this was added from a PR I made a few months ago so is only available on V5… But for version 4 you can create the FramingBehavior and call zoomOnMesh manually like below to get the same callback as a work-around until V5 is released. :slight_smile:

3 Likes

It works in Typsescript too on V5 but the framing behavior is part of the ArcRotateCamera, so on the default PG it needs to be changed from FreeCamera to work, like below. :slight_smile:

EDIT: ooh I see you used ArcRotateCamera too, can you post the PG where it didn’t work on V5 with TS please and I’ll try to fix it?

1 Like

It works fine with 5.0.
I was a bit confused thinking that is have been working in 4.2.0 but not in 4.2.1.
Now the mystery revealed. so it works ONLY with 5.0, as I understand.

3 Likes

A big thank you it does exactly what I wanted!

Have a good day!

2 Likes