damp3 (for Vector3) is currently handed by 3 separated damps.
|
const v3d = /*@__PURE__*/ new Vector3(); |
|
export function damp3( |
|
current: Vector3, |
|
target: number | [x: number, y: number, z: number] | Vector3, |
|
smoothTime?: number, |
|
delta?: number, |
|
maxSpeed?: number, |
|
easing?: (t: number) => number, |
|
eps?: number |
|
) { |
|
if (typeof target === "number") v3d.setScalar(target); |
|
else if (Array.isArray(target)) v3d.set(target[0], target[1], target[2]); |
|
else v3d.copy(target); |
|
a = damp(current, "x", v3d.x, smoothTime, delta, maxSpeed, easing, eps); |
|
b = damp(current, "y", v3d.y, smoothTime, delta, maxSpeed, easing, eps); |
|
c = damp(current, "z", v3d.z, smoothTime, delta, maxSpeed, easing, eps); |
|
return a || b || c; |
|
} |
but it can't be separated and should use the "magnitude (length) of the vector" for the maxSpeed.
e.g.
If maxSpeed is 1:
speed x can be 0.999 and speed y can be 0.999.
It means vec3( 0.999, 0.999, 0 ), and diagonal of 0.999 x 0.999.
thus:
Math.sqrt( Math.pow( 0.9999, 2 ) + Math.pow( 0.9999, 2 ) );
// = 1.4140721410168577
the result is larger than 1.
damp3(for Vector3) is currently handed by 3 separateddamps.maath/packages/maath/src/easing.ts
Lines 131 to 148 in 9031707
but it can't be separated and should use the "magnitude (length) of the vector" for the
maxSpeed.e.g.
If
maxSpeedis1:speed x can be 0.999 and speed y can be 0.999.
It means
vec3( 0.999, 0.999, 0 ), and diagonal of 0.999 x 0.999.thus:
Math.sqrt( Math.pow( 0.9999, 2 ) + Math.pow( 0.9999, 2 ) );
// = 1.4140721410168577
the result is larger than
1.