import type { AxisBinding } from "../input/axisInput.js"; import type { ChaseCameraTuning } from "../runtime/cameraDirector.js"; import { type GravityField } from "./gravityField.js"; /** Three-dimensional world-space vector used by the flight model. */ export type FlightVector = readonly [number, number, number]; /** Supported aerodynamic/propulsion families. */ export type AircraftKind = "fixedWing" | "rotorcraft" | "vtol"; /** Normalized pilot inputs for one flight-simulation tick. */ export interface FlightControlInput { throttle: number; pitch: number; roll: number; yaw: number; collective?: number; airbrake?: number; afterburner?: number; vectoring?: number; } /** Angular authority, response, damping, and self-leveling configuration. */ export interface FlightControlRates { pitch: number; roll: number; yaw: number; response: number; damping: number; stability: number; } /** Axes an aircraft can bind — which actions drive each flight control. */ export type AircraftAxis = "pitch" | "roll" | "yaw" | "throttle" | "collective" | "airbrake" | "afterburner" | "vectoring"; /** * Data-first physical tuning shared by all aircraft instances of one catalog type. * @deprecated Rotation is commanded from rates with pitch clamped to ±0.49π, so it can't loop, and mass and stall angle are fixed. Use `createRigidAircraft` (`physics/aircraftDynamics`), whose rotation comes from surface forces on an inertia tensor. */ export interface AircraftTuning { kind: AircraftKind; mass: number; gravity?: number; maxThrust: number; maxSpeed: number; drag: number; sideDrag: number; lift: number; stallSpeed: number; controls: FlightControlRates; afterburnerMultiplier?: number; hoverThrust?: number; rotorResponse?: number; groundEffectHeight?: number; vtolTransitionSpeed?: number; groundClearance?: number; /** Per-axis bindings for this aircraft — which actions drive each control. Unlisted axes keep the defaults (WASD + flightThrottleUp/Down etc.). */ bindings?: Partial>; /** Camera POV while this aircraft is piloted — chase tuning overlay applied on mount, cleared on dismount. */ camera?: ChaseCameraTuning | null; } /** Spawn state and injectable world-field samplers for an aircraft instance. */ export interface AircraftOptions { position?: FlightVector; velocity?: FlightVector; rotation?: FlightVector; wind?: (position: FlightVector) => FlightVector; groundHeight?: (x: number, z: number) => number; gravityField?: GravityField; } /** Pose and aerodynamic telemetry returned after one flight tick. */ export interface AircraftStep { position: FlightVector; velocity: FlightVector; rotation: FlightVector; forwardSpeed: number; airspeed: number; verticalSpeed: number; angleOfAttack: number; liftFraction: number; stalled: boolean; grounded: boolean; gForce: number; } /** Serializable integrator state of an {@link AircraftDynamics}: what `restore` needs to resume bit-for-bit. */ export interface AircraftDynamicsState { position: FlightVector; velocity: FlightVector; rotation: FlightVector; angular: FlightVector; rotor: number; lastVerticalSpeed: number; } /** Stateful six-degree-of-freedom aircraft simulation. */ export interface AircraftDynamics { tick(dt: number, input: FlightControlInput): AircraftStep; pose(): { position: FlightVector; rotation: FlightVector; }; velocity(): FlightVector; resetTo(position: FlightVector, rotation?: FlightVector): void; setVelocity(velocity: FlightVector): void; /** Swap tuning in place (damage, upgrades, a live tuning panel) without losing pose or momentum. */ retune(next: AircraftTuning): void; snapshot(): AircraftDynamicsState; restore(state: AircraftDynamicsState): void; } /** * Six-degree-of-freedom arcade flight model for fixed-wing, helicopter, and VTOL aircraft. * @deprecated Rotation is commanded from rates with pitch clamped to ±0.49π, so it can't loop, and mass and stall angle are fixed. Use `createRigidAircraft` (`physics/aircraftDynamics`), whose rotation comes from surface forces on an inertia tensor. */ export declare function createAircraftDynamics(initialTuning: AircraftTuning, options?: AircraftOptions): AircraftDynamics;