Strata - v1.4.10
    Preparing search index...

    Function smoothDampScalar

    • 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.

      Parameters

      • current: number

        Current value

      • target: number

        Target value

      • velocity: { value: number }

        Velocity reference object (mutated)

      • smoothTime: number

        Approximate time to reach target (seconds)

      • deltaTime: number

        Time elapsed since last frame (seconds)

      • maxSpeed: number = Infinity

        Optional maximum speed limit

      Returns number

      New smoothed value

      const velocity = { value: 0 };
      const smoothZoom = smoothDampScalar(currentZoom, targetZoom, velocity, 0.3, deltaTime);