The SDK reference's tables had 1,476 empty cells. Each prop, field and class member the pages table now has a doc
comment in its source, or Bevy's own field doc where the SDK mirrors a Bevy type:
- doc comments on 773 declarations across 84 SDK files (song maps, goo and rigid bodies, matchmove, the clock and
timeline, state machines, materials and their extensions, the 2D shapes, bevy_ui and feathers wrappers, colours)
- inline prop types pulled out as named, documented interfaces (EchoesProps, DaylightProps, UiScaleProps, ...), so
each prop can carry its own doc
- types raea-bevy-sdk generates from raea's crates (/** raea_core_animate::spec::AnimKey */) take their field docs
from the Rust source, shown as raea's ("Rust: ..."), not Bevy's; core/animate's spec.rs gains the missing ///
- a props type (StandardMaterialProps) takes its component's @bevy fields; the colour classes gain their @bevy tags
- tools/manual-ref/sdk.ts check now fails on any prop, field or member without a description, as cli.ts does for
flags; tools/manual-ref.sh links an export's node_modules (RAEA_MODULES) so it can run in L1's lane export
2.5 KiB
title, summary, order, sources
| title | summary | order | sources | |
|---|---|---|---|---|
| raea/picking | What the pointer is over: the nearest part under it, and the ray it casts. | 69 |
|
pick finds the nearest part under the pointer, given the camera and the parts, and pointerRay gives the ray the
pointer casts into the scene. Both are pure functions, so a game's step function can use them and still replay
exactly.
import { pick, pointerRay } from "raea/picking"
raea/picking exports 2 functions, 3 types. Bevy's counterpart: bevy_picking. Source: sdk/raea/src/picking.ts.
Functions
pick
The nearest part under the pointer, or null. size is the frame's (useVideoConfig's width and height), whose
pixels the pointer is in.
function pick(pointer: { x: number; y: number; }, camera: PickCamera, parts: readonly Pickable[], size: { width: number; height: number; }): Hit | null
pointerRay
The pointer's ray: from the camera through the pointer (x, y in the frame's pixels, y down), as the engine draws it (Bevy's looking_at, with +Z for up when the camera looks straight up or down, as rdb does).
function pointerRay(pointer: { x: number; y: number; }, camera: PickCamera, size: { width: number; height: number; }): { origin: Vec3; direction: Vec3; }
Types
Hit
| Field | Type | What it is |
|---|---|---|
name (required) |
string |
the pickable it hit |
distance (required) |
number |
metres from the camera (from its near plane's point, for an orthographic one) along the ray |
point (required) |
Vec3 |
where the ray first meets it, in world space |
Pickable
Something the pointer can hit: an axis-aligned box or a sphere, in world space.
type Pickable = { name: string; box: { min: Vec3; max: Vec3 } } | { name: string; sphere: { center: Vec3; radius: number } }
PickCamera
The camera as a scene sets it: a PerspectiveCamera's props (fov in degrees, vertical) or an OrthographicCamera's.
| Field | Type | What it is |
|---|---|---|
position |
Vec3 |
where it stands, metres (x, y, z) |
lookAt |
Vec3 |
the point it faces |
fov |
number |
vertical field of view in degrees (50 by default); ignored when height is set |
height |
number |
an orthographic camera's view height in metres |
up |
Vec3 |
which way is up for it (+Y) |