New camera position with the animation (transition) to the click of a button

My pleasure. You are welcome.

itEnded() is a function with a name that I made-up.

onAnimationEnd is NOT a function NAME, but it COULD be called a function TYPE, I suppose.

Better-stated… onAnimationEnd is a description of what the 6th parameter “slot” is used-for.

So, “onAnimationEnd” is a parameter name and not a function name.

scene.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent);
[ the above names are called parameter names ]

I put the FUNCTION named ‘itEnded’ into the ‘onAnimationEnd’ parameter slot. (the 6th parameter). You can put ANY function name into the onAnimationEnd parameter slot. That function will be called… when the animation ends.

itEnded() needed to be ‘declared’ earlier in the code. That is why itEnded() is declared BEFORE the animation section begins. After it is declared, it can be used in this line…

scene.beginAnimation(camera, 0, 100, false, 1, itEnded);

Above, I put the FUNCTION name itEnded into the onAnimationEnd PARAMETER slot. The 6th slot.

It is easy to get parameter-slot names, and function names… confused. That confusion will disappear… after more experience with BabylonJS.

Again, the term onAnimationEnd is NOT a function name. It is a parameter name. See more comments in #12 playground below.


Yes. It ‘returns’ a COPY-OF (or clone-of) the current camera position - a vector3 value.

PERHAPS you could use camera.position instead. THEN… you would be using a REFERENCE-TO camera.position… and not a COPY-OF camera.position.

MOST times/situations… we can use a REFERENCE-TO. Other times… we will need to use a COPY-OF. More experience == more knowledge.


There ya go. I added the global (wide-scope) variable ‘freelook’ in line 5. It starts TRUE.

It is set FALSE in line 111, just before the animation begins.

It is set TRUE again in line 69, when the animation ends.

Now, camera works properly before animation, and after animation. Lots of work, yes? nod.

I wish to find a better way than camera.rebuildAnglesAndRadius().

I will try to keep searching. I hope others will help. Be well.

2 Likes