Strata - v1.4.10
    Preparing search index...

    Function calculateLookAhead

    • Calculate velocity-based look-ahead offset for dynamic cameras.

      Points the camera slightly ahead of a moving target based on its velocity. Creates a more responsive feel in third-person or follow cameras.

      Parameters

      • velocity: Vector3

        Current target velocity (units/sec)

      • lookAheadDistance: number

        How far ahead to look in world units

      • lookAheadSmoothing: number

        Smoothing time for look-ahead changes

      • currentLookAhead: Vector3

        Current look-ahead vector (mutated)

      • deltaTime: number

        Time elapsed since last frame (seconds)

      Returns Vector3

      New look-ahead offset vector

      const lookAhead = calculateLookAhead(
      targetVelocity,
      3.0, // Look 3 units ahead
      0.4, // Smooth over 0.4 seconds
      currentLookAhead,
      deltaTime
      );
      camera.lookAt(targetPos.clone().add(lookAhead));