const routeProgressRef: RefNumberType = useRef(0);
const SINE_INOUT = "sine.inOut";
const DampVector3 = (
target: Vector3,
to: Vector3,
step: number,
delta: number,
): void => {
target.x = MathUtils.damp(target.x, to.x, step, delta);
target.y = MathUtils.damp(target.y, to.y, step, delta);
target.z = MathUtils.damp(target.z, to.z, step, delta);
};
const animateRouteProgress = (
targetRef: RefNumberType,
from: number,
to: number,
duration: number,
onUpdate: () => void,
) => {
gsap.fromTo(
targetRef,
{ current: from },
{
current: to,
overwrite: true,
duration: duration,
onUpdate: onUpdate,
ease: SINE_INOUT,
},
);
};
animateRouteProgress(
routeProgressRef,
direction ? 0 : 1,
direction ? 1 : 0,
duration,
() => {
playerCameraActivePosition.copy(
route.getPointAt(routeProgressRef.current),
);
},
);
useFrame((state, delta) => {
DampVector3(
playerCameraReference.position,
playerCameraActivePosition,
1,
delta,
);
})
I can’t really share more than this code, but based on this I’m wondering what I’m doing wrong to get “shaky” or “stuttery” camera jumping while it’s interpolating along the bezier curve. I have the gsap easing + dampening.
My frame rate sometimes can jump from 57 to 63 quickly - but I should be getting smooth interpolation. the “1” step. I’ve changed around a bunch.