Strata - v1.4.10
    Preparing search index...

    Class LookAtController

    Look-At Controller with Constraints and Smoothing.

    Rotates objects to face targets with natural motion, angular limits, dead zones, and smooth damping. Perfect for character heads, eyes, cameras, turrets, or any tracking behavior.

    Features:

    • Maximum angle constraints (prevent unrealistic rotations)
    • Dead zone (ignore small movements)
    • Smooth damping (no instant snapping)
    • Exponential smoothing for natural feel

    Use Cases:

    • Character head tracking player
    • Eyes following cursor
    • Camera smooth follow
    • Turret tracking enemies
    • NPCs watching interesting objects
    // Character head tracking player
    const headController = new LookAtController({
    maxAngle: Math.PI / 3, // Can't turn head more than 60°
    speed: 5, // Tracking speed
    deadzone: 0.05, // Ignore tiny movements
    smoothing: 0.1 // Smooth interpolation
    });

    // In update loop
    function animate(deltaTime: number) {
    const playerPos = player.position;
    const headRotation = headController.update(head, playerPos, deltaTime);
    head.quaternion.copy(headRotation);
    }
    // Lazy eye tracking (slow, large deadzone)
    const eyeController = new LookAtController({
    maxAngle: Math.PI / 4, // Limited range
    speed: 2, // Slow tracking
    deadzone: 0.2, // Large deadzone
    smoothing: 0.15 // Very smooth
    });
    // Snappy turret tracking (fast, no deadzone)
    const turretController = new LookAtController({
    maxAngle: Math.PI, // Full rotation
    speed: 10, // Fast
    deadzone: 0, // No deadzone
    smoothing: 0.05 // Minimal smoothing
    });
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Parameters

      • object: Object3D
      • target: Vector3
      • deltaTime: number

      Returns Quaternion