Strata - v1.4.10
    Preparing search index...

    Function calculateScreenShakeIntensity

    • Calculate screen shake intensity based on impact and distance.

      Automatically scales shake trauma with distance falloff, creating realistic responses where nearby impacts shake harder than distant ones.

      Parameters

      • impactForce: number

        Force magnitude (arbitrary units, typically 0-5)

      • distance: number

        Distance from impact to camera

      • falloffStart: number = 5

        Distance where falloff begins. Default: 5

      • falloffEnd: number = 50

        Distance where shake reaches zero. Default: 50

      Returns ScreenShakeIntensity

      Shake intensity configuration

      // Explosion at position
      const explosionPos = new THREE.Vector3(10, 0, 10);
      const distance = camera.position.distanceTo(explosionPos);

      const intensity = calculateScreenShakeIntensity(
      2.5, // Strong explosion
      distance,
      5, // Falloff starts at 5 units
      40 // No shake beyond 40 units
      );

      cameraShake.addTrauma(intensity.trauma);