WaterWakeFeed
Since next
What a script tells the water effects about its hull ({@link EntityHandle.setWaterWake}).
A field left out is left to the engine.
Signature
export interface WaterWakeFeed {
/** How hard its thrust pushes, 0..1: it churns the trail behind the stern. */
thrust?: number
/** How far onto the plane it is, 0..1: it churns the trail, and holds the wake while the hull skips. */
planing?: number
/** How much of the hull is in the water, 0..1. */
immersion?: number
/** Where its thrust goes into the water, a point on the entity, metres: a jet's plume starts here. */
thrustAt?: Vec3
/** Its bow, a point on the entity, metres: the bow's spray starts under it. */
bow?: Vec3
}
Import: import type { WaterWakeFeed } from "@argus/api"
Members
| Member | Signature | Description |
|---|---|---|
thrust | thrust?: number | How hard its thrust pushes, 0..1: it churns the trail behind the stern. |
planing | planing?: number | How far onto the plane it is, 0..1: it churns the trail, and holds the wake while the hull skips. |
immersion | immersion?: number | How much of the hull is in the water, 0..1. |
thrustAt | thrustAt?: Vec3 | Where its thrust goes into the water, a point on the entity, metres: a jet's plume starts here. |
bow | bow?: Vec3 | Its bow, a point on the entity, metres: the bow's spray starts under it. |
Example
The tested fixture fixtures/host/hover.ts.
import type { Behavior, Ctx, Vec3 } from "@argus/api"
// docs/API.md, "Forces, torques and impulses": a body that hovers (thrust = m·g), and the same lift
// as four rotors in the airframe's own frame plus a yaw torque. Typechecked by packages/api's tests.
const HUBS: Vec3[] = [[0.3, 0, 0.3], [-0.3, 0, 0.3], [0.3, 0, -0.3], [-0.3, 0, -0.3]]
function hover(ctx: Ctx) {
const body = ctx.body
if (!body) return
if (ctx.props["rotors"] !== true) {
body.addForce([0, body.mass * 9.81, 0])
return
}
for (const h of HUBS) body.addForceAtPoint([0, (body.mass * 9.81) / 4, 0], h, "local")
body.addTorque([0, (ctx.props["yaw"] as number | undefined) ?? 0, 0], "local")
}
export default {
// The first physics step runs before the first update; this is its thrust.
init(ctx) { hover(ctx) },
update(ctx) { hover(ctx) },
} satisfies Behavior