Strata - v1.4.10
    Preparing search index...

    Function dampedSpring

    • Damped spring interpolation for scalar values.

      Smoothly interpolates a value toward a target using spring physics. Useful for camera smoothing, UI animations, or any single-value spring behavior.

      Parameters

      • current: number

        Current value

      • target: number

        Target value to reach

      • velocity: { value: number }

        Velocity object (modified in place)

      • stiffness: number

        Spring stiffness (higher = faster)

      • damping: number

        Damping factor (higher = less oscillation)

      • deltaTime: number

        Time step in seconds

      Returns number

      New interpolated value

      // Smooth camera zoom
      const velocity = { value: 0 };
      let currentZoom = 5;
      const targetZoom = 10;

      // In update loop
      currentZoom = dampedSpring(
      currentZoom,
      targetZoom,
      velocity,
      10, // stiffness
      5, // damping
      deltaTime
      );
      camera.position.z = currentZoom;