Appearance
@bendyline/molen-client/aircraft
Molen rendering client: three.js wrapper, snapshot sync, interpolation.
ts
import { /* … */ } from '@bendyline/molen-client/aircraft';Classes
AircraftPointerAxes
Transient pointer axes are mixed with keyboard/gamepad axes without latching after release.
Constructors
Constructor
ts
new AircraftPointerAxes(): AircraftPointerAxes;Returns
Properties
pitch
ts
pitch: number;roll
ts
roll: number;yaw
ts
yaw: number;Methods
clear()
ts
clear(): void;Returns
void
set()
ts
set(change): void;Parameters
change
Returns
void
PilotMotion
The pilot's body in the seat. Feed it the vehicle's motion once a frame with update and pass the pose it returns to aircraftCameraPose as motion.
What the pilot feels is the specific force in the seat frame: the vehicle's acceleration less gravity, 1 g straight up through the seat when parked or in level flight. The body is three damped springs driven by how far that is from 1 g up, and the head three more.
Constructors
Constructor
ts
new PilotMotion(settings?): PilotMotion;Parameters
settings?
boolean | PilotMotionOverrides
Returns
Properties
load
ts
readonly load: [number, number, number];The load last felt, in g, in the seat frame (+X left, +Y up, +Z forward): [0, 1, 0] parked or in level flight, [0, 4, 0] in a 4 g pull. For a HUD or for tuning.
tuning
ts
tuning: PilotMotionTuning;Live tuning: change a field and the next update uses it.
Accessors
pose
Get Signature
ts
get pose(): PilotMotionPose;The pose as of the last update.
Returns
Methods
configure()
ts
configure(settings): void;Change some of the tuning; true and false switch the whole effect.
Parameters
settings
boolean | PilotMotionOverrides
Returns
void
reset()
ts
reset(): void;Forget the motion so far: for a new seat. The next sample starts settled in it.
Returns
void
update()
ts
update(sample): PilotMotionPose;Advance to sample.time and return where the pilot's eyes now are.
Parameters
sample
Returns
Interfaces
AircraftCameraPose
Extends
Properties
lookAt
ts
lookAt: [number, number, number];Inherited from
pitch
ts
pitch: number;Inherited from
position
ts
position: [number, number, number];Inherited from
rotation
ts
rotation: [number, number, number, number];yaw
ts
yaw: number;Inherited from
AircraftCockpit
Properties
controls
ts
controls: readonly AircraftCockpitControl[];interior
ts
interior: VehicleInteriorSpec | undefined;Adapted interior bindings give each physical throttle its own engine signal.
Methods
pick()
ts
pick(ray): AircraftCockpitControl | undefined;Parameters
ray
Ray
Returns
AircraftCockpitControl | undefined
AircraftCockpitControl
Properties
action
ts
action: AircraftControlAction;engine?
ts
optional engine?: string;Omitted for the common throttle or engine master.
id
ts
id: string;label
ts
label: string;nodes
ts
nodes: string[];Named physical controls; an empty array indicates an unmodeled control.
AircraftCockpitPointer
Methods
dispose()
ts
dispose(): void;Returns
void
update()
ts
update(): void;Call every frame; also hides the panel and cancels input when the pilot leaves.
Returns
void
AircraftCockpitPointerOptions
Capture only actual cockpit-control hits; ordinary canvas drags remain camera gestures.
Properties
camera
ts
camera: Camera;companionPanel?
ts
optional companionPanel?: boolean;Show optional HTML controls for accessibility or models with incomplete cockpit geometry.
container?
ts
optional container?: HTMLElement;Optional host for the accessible companion controls. Defaults to the canvas parent.
element
ts
element: HTMLElement;Methods
session()
ts
session(): AircraftCockpitSession | undefined;Returns
AircraftCockpitSession | undefined
AircraftCockpitSession
Properties
cockpit
ts
cockpit: AircraftCockpit;id
ts
id: string;input
ts
input: AircraftInputData;spec
ts
spec: AircraftSpec;state?
ts
optional state?: AircraftStateData;Methods
change()
ts
change(change): void;Parameters
change
Returns
void
release()
ts
release(): void;Release spring-loaded stick/pedal input on blur, exit or pointer cancellation.
Returns
void
AircraftControlChange
Properties
control
ts
control: AircraftCockpitControl;pitch?
ts
optional pitch?: number;Pitch for a two-axis stick; value is roll.
value
ts
value: number;AircraftControlNode
glTF node extras for authored cockpit controls. Motion is relative to the exported rest pose.
Properties
action
ts
action: AircraftControlAction;engine?
ts
optional engine?: string;motion?
ts
optional motion?: object;axis
ts
axis: "x" | "y" | "z";offset?
ts
optional offset?: number;property
ts
property: "position" | "rotation";scale
ts
scale: number;AircraftObstacleScene
Properties
aircraft
ts
aircraft: readonly [number, number, number][];Other aircraft body centers. The host excludes the queried aircraft.
cars
ts
cars: readonly object[];octree
ts
octree: object;getSphereTriangles()?
ts
optional getSphereTriangles(sphere, triangles): unknown;Parameters
sphere
Sphere
triangles
Triangle[]
Returns
unknown
sphereIntersect()
ts
sphereIntersect(sphere):
| false
| {
depth: number;
normal: Vector3;
};Parameters
sphere
Sphere
Returns
| false | { depth: number; normal: Vector3; }
origin
ts
origin: Vector3;Collision tree origin and query, e.g. WalkCollision.
AircraftVisual
Properties
animation?
ts
optional animation?: ModelSignalVisual;The spec's exterior animation bindings (gear legs and doors, control surfaces).
cockpit
ts
cockpit: AircraftCockpit;interior?
ts
optional interior?: ModelSignalVisual;object
ts
object: Object3D;Methods
dispose()
ts
dispose(): void;Returns
void
setLivery()
ts
setLivery(data): void;Parameters
data
LiveryData | undefined
Returns
void
update()
ts
update(
state,
input,
altitude,
signals?,
timeSeconds?
): void;Parameters
state
AircraftStateData
input
AircraftInputData
altitude
number
signals?
Readonly<Record<string, number | undefined>>
timeSeconds?
number
Returns
void
updateShadows()
ts
updateShadows(texel): void;The sun shadow map's texel size in meters (Renderer.shadowTexelSize) for the aircraft a view is built around: the one flown or followed. Hosts pass undefined for every other aircraft. While texels are too coarse to resolve the aircraft's own parts (over 0.15 m), it casts no sun shadow until they are 0.12 m or finer. Its shadows on itself and on the ground below go, and it still receives shadows from terrain, buildings and clouds.
Parameters
texel
number | undefined
Returns
void
updateView()
ts
updateView(camera): void;The camera, in the coordinates of object.position. Cabin nodes (the spec's interior and the generated flight controls) are drawn only near it: from farther away a cockpit is a few pixels behind the canopy, yet it held most of an aircraft's draw calls, and as many again in the shadow pass. Boarded and chase views are always near enough, but within the cabin a part too small to see from the camera (CABIN_DETAIL_ANGLE) leaves the frame through its render layers, so a binding's or damage's own visible is never overridden.
Parameters
camera
readonly [number, number, number]
Returns
void
PilotMotionAxisTuning
One direction the seated body moves in, as a damped spring driven by the load along it.
Properties
brace
ts
brace: number;Share of a sustained load the pilot braces against, 0..1. The body gives way at the onset, then recovers this much of the travel over braceTime, and is left leaning the other way for a moment when the load comes off.
damping
ts
damping: number;Damping ratio: 1 settles without overshoot, lower rebounds past rest first.
frequency
ts
frequency: number;Natural frequency of the body on this axis, Hz: higher is tighter.
limit
ts
limit: readonly [number, number];Furthest travel in the negative and positive direction, meters, approached softly: the seat pan, seat back and harness. Axes are +X left, +Y up, +Z forward.
travel
ts
travel: number;Eye travel per g of load along the axis, meters. The body moves against the load.
PilotMotionHeadTuning
The head on its neck: small rotations, each a damped spring.
Properties
damping
ts
damping: number;Damping ratio of the head.
frequency
ts
frequency: number;Natural frequency of the head, Hz.
horizonLean
ts
horizonLean: number;The head leveling toward the horizon in a bank, radians of tilt per radian of bank at small angles. It peaks at 45° of bank (half this value) and is gone at knife-edge and inverted.
lag
ts
lag: number;How far the head is left behind when the airframe starts to turn, seconds squared: radians of lag per rad/s² of roll, pitch or yaw acceleration.
limit
ts
limit: number;Largest rotation about any one axis, radians, approached softly.
neck
ts
neck: number;Height of the eyes above the neck's pivot, meters: a tilted head also moves the eye.
nod
ts
nod: number;Chin drop per g above 1, radians: the head is heavy in a pull and light in a pushover.
surgeNod
ts
surgeNod: number;Chin drop per g of deceleration, radians: thrown forward, the head goes with the body. Pressed back under thrust it meets the headrest and does not tip.
swayTilt
ts
swayTilt: number;Head roll per g of sideways load, radians: toward the side the body is thrown.
PilotMotionPose
Where the pilot's eyes are, relative to the authored eye point and the airframe.
Properties
offset
ts
offset: [number, number, number];Eye displacement in the seat frame, meters: +X left, +Y up, +Z forward.
pitch
ts
pitch: number;Head pitch, radians, chin up positive.
roll
ts
roll: number;Head roll, radians, right ear down positive.
yaw
ts
yaw: number;Head yaw, radians, to the left positive.
PilotMotionSample
One reading of the seat the pilot is strapped to.
Properties
position
ts
position: readonly [number, number, number];World position of the vehicle, to tell a teleport or a respawn from an acceleration.
rotation
ts
rotation: Quat$1;Orientation of the vehicle: +X left, +Y up, +Z forward.
time
ts
time: number;Simulation time, seconds (world.tick * world.dt). The body moves in this time, so a paused simulation holds it still and asking twice in one tick gives the same pose.
travelScale?
ts
optional travelScale?: number;Factor by which velocity and travel are scaled up from the flown speed (boost mode).
velocity
ts
velocity: readonly [number, number, number];World velocity, m/s.
PilotMotionTuning
Every knob of PilotMotion. Defaults are DEFAULT_PILOT_MOTION.
Properties
braceTime
ts
braceTime: number;Seconds the pilot takes to brace against a sustained load (see the axes' brace).
enabled
ts
enabled: boolean;The global switch: off, the eye stays at the authored eye point.
head
ts
head: PilotMotionHeadTuning;heave
ts
heave: PilotMotionAxisTuning;Vertical: sinking into the seat under positive g, rising against the straps unloaded.
intensity
ts
intensity: number;Scales every displacement and rotation before its limit. 1 is the tuned amount.
maxLoad
ts
maxLoad: number;Loads beyond this many g on an axis are clipped: an impact jolts, it does not launch.
surge
ts
surge: PilotMotionAxisTuning;Fore-aft: pressed into the seat back under thrust, thrown onto the straps by braking.
sway
ts
sway: PilotMotionAxisTuning;Sideways: thrown to the outside of a skid or a turn on the ground.
Type Aliases
AircraftControlAction
ts
type AircraftControlAction =
| "speedBrake"
| "tailHook"
| "canopy"
| "wipers"
| "headlights"
| "power"
| "mixture"
| "propeller"
| "stick"
| "yaw"
| "gear"
| "flaps"
| "engine"
| "brake"
| "thrustVector";PilotMotionOverrides
ts
type PilotMotionOverrides = { [K in keyof PilotMotionTuning]?: PilotMotionTuning[K] extends object ? Partial<PilotMotionTuning[K]> : PilotMotionTuning[K] };A partial PilotMotionTuning: unset fields keep their current value.
Variables
DEFAULT_PILOT_MOTION
ts
const DEFAULT_PILOT_MOTION: Readonly<PilotMotionTuning>;The tuned defaults, sized to be felt more than seen. Flown through the kernel's flight model: a 6 g pull in the P-51 lowers the eye 3 cm, presses it over 1 cm back and drops the chin 1.5°, and on release the pilot comes up nearly 1 cm past rest before settling; 8.5 g in an F-16 sinks 3.8 cm. Full brakes at 0.75 g throw the pilot nearly 3 cm forward, half of which they recover as they brace; full power presses them 1 cm back. A 60° bank tilts the head 3° toward the horizon.
Functions
aircraftCameraPose()
ts
function aircraftCameraPose(
transform,
spec,
options
): AircraftCameraPose;Parameters
transform
pos
[number, number, number]
rot
[number, number, number, number]
spec
AircraftSpec
options
Returns
aircraftControlValue()
ts
function aircraftControlValue(input, control): number;Parameters
input
AircraftInputData
control
Returns
number
applyAircraftControl()
ts
function applyAircraftControl(
input,
change,
spec,
state?
): AircraftInputData;Immutable pilot input update; hosts still submit it through flyAircraft's seat/authority checks.
Parameters
input
AircraftInputData
change
spec
AircraftSpec
state?
AircraftStateData
Returns
AircraftInputData
bindAircraftCockpitPointer()
ts
function bindAircraftCockpitPointer(options): AircraftCockpitPointer;Parameters
options
Returns
createAircraftCockpit()
ts
function createAircraftCockpit(model, spec): AircraftCockpit;Discover moving controls from their authored input bindings, never from instrument needles.
Parameters
model
Object3D
spec
AircraftSpec
Returns
createAircraftVisual()
ts
function createAircraftVisual(
model,
spec,
livery?
): AircraftVisual;Takes ownership of a loaded library GLB. The named nodes remain editable in a DCC.
The gear and flaps follow state.gearPosition and state.flapPosition as they travel, or the selection in input when the state has no positions (helicopters, hosts that animate only).
Parameters
model
Object3D
spec
AircraftSpec
livery?
LiveryData
Returns
pilotMotionSample()
ts
function pilotMotionSample(
time,
transform,
state
): PilotMotionSample;A PilotMotionSample from a vehicle's transform and state.
Parameters
time
number
transform
pos
readonly [number, number, number]
rot
readonly [number, number, number, number]
state
boosted?
boolean
velocity
readonly [number, number, number]
Returns
pilotMotionTuning()
ts
function pilotMotionTuning(settings?, base?): PilotMotionTuning;A complete tuning: base (the defaults when omitted) with settings over it. true and false only switch the effect; an object changes the fields it names.
Parameters
settings?
boolean | PilotMotionOverrides
base?
Returns
References
aircraftObstacleContacts
Renames and re-exports vehicleObstacleContacts