Is Typescript Still Incomplete? rotateLocal Parameter Missing

@Stefan @Ilya.Shkuratov @techleapnz

Is rotateLocal for 3d objects missing the “duration” parameter that is in the docs?

If I add the third parameter as a number (as specified) I get an error:(

If I add the third parameter as a number as specified I get an error:(

1 Like

What does the error say?

Just a red warning signal in the editor. It switches to twin Vector3 option for offset and axis. None of the other options include the “duration” parameter. It doesn’t seem to exist at all.

The docs show an entry for rotateLocal(axis: Vector3, angleInRadians: Number, duration: Number). In practice “duration” does not seem to be available. See the example below that should turn 1.5 radians in 5 seconds but doesn’t.

Here is a “cheesy” work around until somebody suggests something better…

const rotate1 = Scene.getItem("ffIkaxgE") as Cylinder;

rotateDurationHack(rotate1, new Vector3(0, 0, -1), 6.3, 2);

// Make rotateLocal duration work
function rotateDurationHack(obj: object, axis: Vector3, angle: number, duration: number) {
    duration *= 25;                     // 25fps
    for (let i = 0; i < duration; i++) {
        Time.schedule(() => {
            obj.transform.rotateLocal(axis, angle / duration);
        }, 0.04 * i)        // 1 sec / 25 = 0.04

Hi @jlfjlf!

There is actually two different set of rotateLocal methods.

The one with duration parameter is located in transition namespace, that namespace contains all the methods that is “moving” or “transition” the transform of the object with time.

The another one is located in transform itself. It changes the transform “immediately” and do not have duration parameter.

So you can use transition.rotateTransform with duration parameter or, if for some reason you do not satisfied how this methods “animates” transition you can do something similar that you did in rotateDurationHack and animate the transition as you wish with transform.rotateLocal.

1 Like

Thank you @Ilya.Shkuratov

That explains it.