/** * CameraController.ts * * Camera modes: follow, orbit, free-look, top-down. * Includes smoothing, dead zones, zoom, and bounds clamping. * * @module camera */ type Vec3 = [number, number, number]; export type CameraMode = 'follow' | 'orbit' | 'free' | 'topDown' | 'fixed'; export interface CameraState { position: [number, number, number]; rotation: Vec3; zoom: number; fov: number; } export interface CameraConfig { mode: CameraMode; smoothing: number; followOffset: Vec3; orbitDistance: number; orbitMinDistance: number; orbitMaxDistance: number; orbitSpeed: number; zoomSpeed: number; minZoom: number; maxZoom: number; deadZone: { x: number; y: number; }; bounds: { min: Vec3; max: Vec3; } | null; fov: number; freeSpeed: number; } /** * Camera controller for managing various camera behaviors in 3D space. * * Supports multiple camera modes: * - **follow**: Camera smoothly follows a target with configurable offset and dead zone * - **orbit**: Camera orbits around a target point at configurable distance and speed * - **free**: Camera movement controlled externally via moveCamera() calls * - **topDown**: Camera maintains a top-down view of the target with smooth tracking * - **fixed**: Camera remains stationary at its current position * * The controller handles smooth interpolation, zoom controls, boundary clamping, * and provides a unified interface for camera state management across different modes. * * @example * ```typescript * const camera = new CameraController({ * mode: 'orbit', * orbitDistance: 15, * smoothing: 0.1 * }); * * camera.setTarget(5, 0, 5); * camera.rotateOrbit(0.1, 0); * camera.update(deltaTime); * * const state = camera.getState(); * console.log(state.position); // Current camera position * ``` */ export declare class CameraController { private config; private state; private target; private orbitAngle; private orbitPitch; /** * Creates a new camera controller with optional configuration. * * @param config - Optional camera configuration overrides. Merged with defaults. * @example * ```typescript * const camera = new CameraController({ * mode: 'follow', * smoothing: 0.2, * followOffset: [0, 3, -8 ] * }); * ``` */ constructor(config?: Partial); /** * Updates camera position and rotation based on current mode and delta time. * * Call this every frame to animate camera movement. Different modes handle * updates differently: * - **follow**: Smoothly interpolates toward target + offset * - **orbit**: Updates position based on orbit angle and pitch * - **topDown**: Maintains overhead view with smooth target tracking * - **free/fixed**: No automatic movement (controlled externally) * * @param dt - Delta time in seconds since last update * @example * ```typescript * // In game loop * const deltaTime = (now - lastTime) / 1000; * camera.update(deltaTime); * ``` */ update(dt: number): void; private updateFollow; private updateOrbit; private updateTopDown; private clampToBounds; /** * Sets the target point that the camera should focus on or track. * * Used by 'follow', 'orbit', and 'topDown' modes. In 'follow' mode, camera * maintains offset from this target. In 'orbit' mode, camera rotates around * this point. In 'topDown' mode, camera looks down at this location. * * @param x - Target X coordinate in world space * @param y - Target Y coordinate in world space * @param z - Target Z coordinate in world space * @example * ```typescript * // Track a moving player * camera.setTarget(player[0], player[1], player[2]); * ``` */ setTarget(x: number, y: number, z: number): void; /** * Gets the current target position. * * @returns Copy of the current target coordinates */ getTarget(): Vec3; /** * Rotates the camera in orbit mode by the specified angles. * * Only affects camera behavior when mode is set to 'orbit'. Angles are * clamped to prevent the camera from flipping or going too extreme. * * @param deltaAngle - Horizontal rotation change (yaw) in radians * @param deltaPitch - Vertical rotation change (pitch) in radians, clamped to [-1.4, 1.4] * @example * ```typescript * // Rotate based on mouse movement * camera.rotateOrbit(mouseX * 0.01, mouseY * 0.01); * ``` */ rotateOrbit(deltaAngle: number, deltaPitch: number): void; /** * Adjusts camera zoom by the specified delta amount. * * Zoom affects distance in 'orbit' mode, height in 'topDown' mode, and FOV scaling. * Value is clamped between configured minZoom and maxZoom limits. * * @param delta - Amount to change zoom by (positive = zoom in, negative = zoom out) * @example * ```typescript * // Zoom in on mouse wheel * camera.zoom(-wheelDelta * 0.1); * ``` */ zoom(delta: number): void; /** * Directly moves camera position by specified amounts. * * Primarily used in 'free' camera mode for manual camera control. * Movement is scaled by the configured freeSpeed multiplier. * * @param dx - Change in X position (world units) * @param dy - Change in Y position (world units) * @param dz - Change in Z position (world units) * @example * ```typescript * // WASD movement in free camera mode * if (wPressed) camera.moveCamera(0, 0, 1); * if (sPressed) camera.moveCamera(0, 0, -1); * ``` */ moveCamera(dx: number, dy: number, dz: number): void; /** * Changes the camera's behavior mode. * * @param mode - New camera mode ('follow' | 'orbit' | 'free' | 'topDown' | 'fixed') * @example * ```typescript * camera.setMode('orbit'); // Switch to orbital camera * ``` */ setMode(mode: CameraMode): void; /** * Gets the current camera mode. * * @returns Current camera mode */ getMode(): CameraMode; /** * Gets a copy of the current camera state. * * Returns position, rotation, zoom, and FOV values. All objects are cloned * to prevent external modification of internal state. * * @returns Current camera state with position, rotation, zoom, and FOV * @example * ```typescript * const state = camera.getState(); * renderer.setCamera(state.position, state.rotation); * renderer.setFOV(state.fov); * ``` */ getState(): CameraState; /** * Directly sets the camera zoom level. * * Unlike zoom(), this sets an absolute value rather than a delta. * Value is clamped to configured min/max zoom limits. * * @param z - New zoom level (clamped to minZoom/maxZoom) * @example * ```typescript * camera.setZoom(1.0); // Reset to default zoom * ``` */ setZoom(z: number): void; /** * Sets the camera's field of view. * * @param fov - New field of view in degrees * @example * ```typescript * camera.setFOV(90); // Wide angle * camera.setFOV(30); // Telephoto * ``` */ setFOV(fov: number): void; /** * Adjusts camera smoothing factor for interpolated movement modes. * * Affects 'follow' and 'topDown' modes. Higher values = more responsive, * lower values = smoother but more delayed movement. * * @param s - Smoothing factor between 0.0 (no movement) and 1.0 (instant) * @example * ```typescript * camera.setSmoothing(0.1); // Very smooth * camera.setSmoothing(0.8); // Very responsive * ``` */ setSmoothing(s: number): void; private lerp; } export {}; //# sourceMappingURL=CameraController.d.ts.map