aeronautic

Components

<Airframe>, <ControlSurfaces>, <FighterControls>, <Engine>, <Drive>, <Clip>, <Attach> and the hooks.

All from @aeronautic/controls/react.

<Airframe>

A model's moving parts. It makes a ControlRig for the model and moves it every frame, but drives nothing by itself: put the parts that should move inside it.

proptypedefaultwhat it does
objectObject3D | null—The model, as a loaded glTF's scene. Required.
animationsAnimationClip[]—Its clips, for the gear, the nozzles and anything else to scrub.
sourceFlight | nullnearest providerThe flight its parts read. null moves only what is set by hand.
ratesPartial<ControlRates>—How fast each kind moves, over the defaults.
settlebooleantrueJump to the flight's pose on the first read, rather than move there.
forward, up[x, y, z]-Z, +YWhich way the model faces, for fitting hinges and placing sides.
rigbooleantrueRead CTRL_ nodes' extras.
namesbooleantrueFind parts by name where there is no rig, putting pivots in.
filter(node: Object3D) => boolean—Leave nodes out.
prioritynumber0The frame callback's priority, as useFrame's.
refControlRig—The rig, to move parts by hand or read where they are.

object, animations, rig, names, filter, forward and up make the rig: changing one makes a new one. The rest apply live.

<ControlSurfaces>

An <Airframe> with <FighterControls> inside it: every prop of both, and its children go inside the airframe.

<FighterControls>

Every part, driven the way a fighter's are, and an <Engine> for each side with a nozzle or an exhaust anchor.

proptypedefaultwhat it does
pitchSharenumber0.6How much of an elevon's or a stabilator's throw is pitch.
engineEngineOptions but side, anchor—Given to each engine.
exhaustReactNode—Put inside each engine, as an <Afterburner />.

The parts

Each takes PartOptions, and drives every part of its kind unless told which:

componentmovesextra props
<Ailerons>ailerons, with roll
<Elevators>elevators, with pitch
<Elevons>elevons, with pitch and rollpitchShare
<Stabilators>all-moving tails, with pitch and rollpitchShare
<Canards>canards, with pitch
<Rudders>rudders, with yaw
<Flaps>trailing-edge flaps
<LeadingEdgeFlaps>leading-edge flaps, with angle of attackstartDeg, perDeg
<Airbrakes>air brakes
<Spoilers>spoilers, with the air brake
<DragRudders>split drag rudders, braking and yawing
<Cockpit>stick, pedals, throttle leverthrottle
<Gear>legs, doors, lever, retraction clipsee GearOptions

<Engine>

One engine's nozzle and gimbal. Takes EngineOptions, and a ref to the Engine. Its children sit in its context: an <Afterburner> inside it sits on its exhaust and runs at its throttle.

<Drive>

A drive of your own. Takes DriveOptions: which parts, and from, where each should be for a flight.

<Drive parts={["CTRL_Radar_Array_C"]} from={(flight) => flight.pitch * 10} />

<Clip>

Scrubs a clip from the flight. Takes ClipDriveOptions.

<Clip clip="ANIM_Bay_Open" from={(flight) => flight.airbrake} />

<Attach>

Puts its children in a part's or an anchor's frame.

proptypewhat it does
partstringA part, by name: the children move with it.
anchorstringOr an anchor, by name.

Hooks

hookreturns
useAirframe()The nearest <Airframe>'s ControlRig, or null before it is made.
usePart(name)A ControlSurface, or null.
useAnchor(name)A ControlAnchor, or null.
useEngine()The nearest <Engine>'s Engine, or null.

Options given to a part, a <Drive> or a <Clip> are read in place, so an inline from is fine: a new function each render costs nothing.

On this page