/**
 * Base class for camera controllers.
 *
 * Provides a common lifecycle and event-handling surface for concrete camera controllers
 * (e.g., orbit, fly, FPS). Subclasses implement protected handler methods to react to
 * mouse/keyboard input, and update camera transforms in `update()`.
 *
 * Responsibilities:
 * - Holds a reference to a `Camera` and resets internal state when the camera changes.
 * - Offers a `lookAt(from, to, up)` helper that delegates to the camera.
 * - Exposes public event entry points (`onMouseDown`, `onMouseUp`, `onMouseMove`,
 *   `onMouseWheel`, `onKeyDown`, `onKeyUp`) that forward to protected handlers which
 *   subclasses can override.
 * - Defines `reset()` and `update()` lifecycle methods for state initialization and per-frame updates.
 *
 * Event handling contract:
 * - Each public `onXxx` method returns a boolean that indicates whether the event
 *   was handled by the controller. Returning `true` allows upstream dispatchers to
 *   stop propagation if desired.
 *
 * Subclassing guidelines:
 * - Override the protected `_onXxx` handlers rather than the public `onXxx` methods.
 * - Override `reset()` to reinitialize controller state when a new camera is attached.
 * - Override `update()` to advance state each frame (e.g., apply accumulated deltas with damping).
 *
 * Lifecycle:
 * 1. A camera is attached via internal `_setCamera(camera)`, which calls `reset()`.
 * 2. Input events are passed in through the public `onXxx` methods.
 * 3. Per-frame, `update()` is called to apply state changes to the camera.
 *
 * Thread-safety/assumptions:
 * - Designed for use on the main thread in a browser environment.
 * - Pointer events are used for mouse input; keyboard events for key input.
 *
 * @public
 */ class BaseCameraController {
    /** @internal */ _camera;
    /** @internal */ _enabled;
    /**
   * Create a base camera controller.
   *
   * The controller starts without an attached camera. Call the internal `_setCamera`
   * to attach a camera (performed by the owning system), which triggers `reset()`.
   */ constructor(){
        this._camera = null;
        this._enabled = true;
    }
    /**
   * Get the attached camera.
   *
   * @returns The current camera or `null` if none is attached.
   */ _getCamera() {
        return this._camera;
    }
    /**
   * Attach a camera to the controller.
   *
   * If the camera changes, the controller will call `reset()` so subclasses can
   * reinitialize state that depends on the camera.
   *
   * @param camera - The camera to attach.
   */ _setCamera(camera) {
        if (this._camera !== camera) {
            this._camera = camera;
            this.reset();
        }
    }
    /**
   * Check if the controller is enabled.
   */ get enabled() {
        return this._enabled;
    }
    set enabled(value) {
        this._enabled = value;
    }
    /**
   * Convenience method that delegates to `camera.lookAt`.
   *
   * @param from - Camera position.
   * @param to - Look-at target.
   * @param up - Up direction.
   */ lookAt(from, to, up) {
        this._camera?.lookAt(from, to, up);
    }
    /**
   * Reset the controller's internal state.
   *
   * Called automatically when a camera is attached via `_setCamera`. Subclasses
   * should override this to reset accumulators, velocities, targets, etc.
   */ reset() {}
    /**
   * Handle pointer down (mouse/touch/pen) events.
   *
   * @param evt - The pointer event.
   * @returns `true` if handled and should stop further processing; otherwise `false`.
   */ onMouseDown(evt) {
        return this._enabled ? this._onMouseDown(evt) : false;
    }
    /**
   * Handle pointer up events.
   *
   * @param evt - The pointer event.
   * @returns `true` if handled; otherwise `false`.
   */ onMouseUp(evt) {
        return this._enabled ? this._onMouseUp(evt) : false;
    }
    /**
   * Handle mouse wheel (scroll) events.
   *
   * Typical usage: zoom/dolly control, FOV adjustments.
   *
   * @param evt - The wheel event.
   * @returns `true` if handled; otherwise `false`.
   */ onMouseWheel(evt) {
        return this._enabled ? this._onMouseWheel(evt) : false;
    }
    /**
   * Handle pointer move events.
   *
   * Typical usage: orbit, pan, or look controls based on button/modifier state.
   *
   * @param evt - The pointer event.
   * @returns `true` if handled; otherwise `false`.
   */ onMouseMove(evt) {
        return this._enabled ? this._onMouseMove(evt) : false;
    }
    /**
   * Handle key down events.
   *
   * Typical usage: WASD navigation, modifiers for speed, toggling modes.
   *
   * @param evt - The keyboard event.
   * @returns `true` if handled; otherwise `false`.
   */ onKeyDown(evt) {
        return this._enabled ? this._onKeyDown(evt) : false;
    }
    /**
   * Handle key up events.
   *
   * @param evt - The keyboard event.
   * @returns `true` if handled; otherwise `false`.
   */ onKeyUp(evt) {
        return this._enabled ? this._onKeyUp(evt) : false;
    }
    /**
   * Per-frame update.
   *
   * Subclasses should override this to:
   * - Integrate velocities/accelerations and apply damping.
   * - Smoothly interpolate camera transforms.
   * - Clamp angles/distances/FOV, etc.
   *
   * Called once per frame by the owning system.
   */ update() {
        if (this._enabled) {
            this._onUpdate();
        }
    }
    /**
   * Mouse down event handler
   * @param evt - Mouse event
   * @returns Boolean value indices whether this event was handled
   */ _onMouseDown(_evt) {
        return false;
    }
    /**
   * Pointer up handler for subclasses to override.
   *
   * @param _evt - Pointer event.
   * @returns `true` if handled; otherwise `false`.
   */ _onMouseUp(_evt) {
        return false;
    }
    /**
   * Mouse wheel handler for subclasses to override.
   *
   * @param _evt - Wheel event.
   * @returns `true` if handled; otherwise `false`.
   */ _onMouseWheel(_evt) {
        return false;
    }
    /**
   * Pointer move handler for subclasses to override.
   *
   * @param _evt - Pointer event.
   * @returns `true` if handled; otherwise `false`.
   */ _onMouseMove(_evt) {
        return false;
    }
    /**
   * Key down handler for subclasses to override.
   *
   * @param _evt - Keyboard event.
   * @returns `true` if handled; otherwise `false`.
   */ _onKeyDown(_evt) {
        return false;
    }
    /**
   * Key up handler for subclasses to override.
   *
   * @param _evt - Keyboard event.
   * @returns `true` if handled; otherwise `false`.
   */ _onKeyUp(_evt) {
        return false;
    }
    /**
   * Per-frame update handler for subclasses to override.
   */ _onUpdate() {
    // Subclasses can override this for per-frame updates.
    }
}

export { BaseCameraController };
//# sourceMappingURL=base.js.map
