Renderer · interface

WaterBounds

Where a bounded body sits, how far it reaches and which way it faces.

Explained in Hello world.

interface WaterBounds
import type { WaterBounds } from '@driftengine/core';

In depth

Extents are measured along the body's own axes, x across and z along forward, which is how addOrientedBox measures a box: one convention for an oriented thing in this engine, so a reader who has met one has met both.

Properties

NameTypeDescription
centreXnumber
centreZnumber
halfMoptionalnumberHalf-extent along both axes, metres: the shorthand for a square.
More

A pool, a tank and a puddle are square often enough to be worth one number, and this is that number. halfX and halfZ override it per axis, so { halfM: 9, halfX: 2 } is two metres across and nine along. The cost is two ways to say one square; the rule is stated here and applied in exactly one place, resolveWater.

halfXoptionalnumberHalf-extent across the body, metres. A channel is narrow in this one.
halfZoptionalnumberHalf-extent along forward, metres. A channel is long in this one.
forwardXoptionalnumberWhich way the body's own +z points, in world XZ. Unset, it points along world +z.
More

A direction and not an angle, because a consumer bounding a channel, a ditch or a gutter arrives holding the direction the run takes — from a road graph, a spline's tangent, two endpoints — and converting that to radians and back is arithmetic nobody needs. It is normalised on the way in, so a length here is not a scale, and a direction of no length at all is read as unturned instead of producing a sheet at NaN.

forwardZoptionalnumber