In there, they have extended the ArcRotateCamera by BABYLON.ArcRotateCamera.prototype.spinTo= ...
but I couldn’t get it working with TS, here is my code:
import * as BABYLON from "babylonjs";
// this also doesn't work
//declare namespace BABYLON {
declare module "babylonjs" {
export interface UniversalCamera {
moveTo: (...args: any[]) => any,
}
}
// extend babylon UniversalCamera
BABYLON.UniversalCamera.prototype.moveTo = function (whichprop, targetval, speed) {
const ease = new BABYLON.CubicEase();
ease.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT);
BABYLON.Animation.CreateAndStartAnimation(
"UniversalCamera-moveTo",
this, whichprop,
speed, 120,
this[whichprop], targetval,
0, ease
);
};
(P.S. TS is sooooo annoying, I feel like half of my time is spent on pleasing the compiler than actually building stuff, would appreciate if there is a better workflow, e.g. is JS + JSDoc a potential better solution?)
Your best bet would probably be to write a new class that extends UniversalCamera, and adds this additional method moveTo. Then you can just use that class as a type.
if you cut&past this code into newly created playgroung typescript scene, the moveTo is not recognized/accepted at all by the compiler. So the augmentation is not take in account… i guess it’s because reaching the point the Babylon is not longer in TS but in JS… and the compiler is looking for the d.ts type definition, and the module name is wrong… i do not know how it’s configured behind the scene… any tricks ???