Unity-style smooth damping for scalar values.
Produces natural, spring-like motion toward a target without overshooting. Perfect for camera zoom, FOV transitions, or any value that needs organic movement.
Current value
Target value
Velocity reference object (mutated)
Approximate time to reach target (seconds)
Time elapsed since last frame (seconds)
Optional maximum speed limit
New smoothed value
const velocity = { value: 0 };const smoothZoom = smoothDampScalar(currentZoom, targetZoom, velocity, 0.3, deltaTime); Copy
const velocity = { value: 0 };const smoothZoom = smoothDampScalar(currentZoom, targetZoom, velocity, 0.3, deltaTime);
Unity-style smooth damping for scalar values.
Produces natural, spring-like motion toward a target without overshooting. Perfect for camera zoom, FOV transitions, or any value that needs organic movement.