p5.tree/constants
The constants and the math helpers p5.tree exposes on p5.Tree.
Everything here lives on p5.Tree: the space names WORLD, EYE, NDC,
SCREEN and MODEL that mapLocation and mapDirection accept, the
results of visibility, the basis vectors, the createHandle constraint
kinds, and the bit sets that tell axes, viewFrustum, trackPath,
helmRig and the Handle drawers what to draw. Bit sets belong to one
gizmo each: the same number means different things to different gizmos, so
never mix them. Reach for this page whenever a call asks for a space, a
shape or a bit set.
It also carries the quaternion helpers (qMul, qSlerp, qFromAxisAngle,
qToMat4, …), the ray intersections a custom Handle constraint builds on,
and the input helpers oneEuro and poseDelta for a PoseHelm or
CameraHelm.
p5.Tree
| Name | Type | Description |
|---|---|---|
VERSION |
string |
Library version string. |
NONE |
number |
The empty bit set — pass as a gizmo's bits to draw nothing. |
WORLD |
string |
World space. The default to of mapLocation / mapDirection. |
EYE |
string |
Eye (camera) space. The default from of mapLocation / mapDirection. |
SELF |
string |
A PoseHelm's own current pose, so motion applies relative to the body.
A from of createPoseHelm only; not a mapping space. |
NDC |
string |
Normalized device coordinates: x, y ∈ [−1, 1]; z per WEBGL / WEBGPU. |
SCREEN |
string |
Screen space — the surface's logical pixels: x ∈ [0, width], y ∈ [0, height],
origin top-left, z ∈ [0, 1] normalized depth; what p5's mouseX / mouseY
and beginHUD count. fragCoord and drawingBufferSize answer in its
counterpart, window space — the drawing buffer's device pixels, bottom-left, y up. |
MODEL |
string |
The live model matrix's local space, resolved at call time. |
OBJECT |
string |
Alias of MODEL. |
WEBGL |
number |
The depth range of a WEBGL canvas: z ∈ [−1, 1]. Pass as the depth-range
argument of mat4Persp / mat4Ortho. |
WEBGPU |
number |
The depth range of a WEBGPU canvas: z ∈ [0, 1]. Pass as the depth-range
argument of mat4Persp / mat4Ortho. |
INVISIBLE |
number |
visibility result: fully outside the frustum. |
VISIBLE |
number |
visibility result: fully inside the frustum. |
SEMIVISIBLE |
number |
visibility result: straddles at least one frustum plane. |
ORIGIN |
number[] |
[0, 0, 0] — the default point of mapLocation. |
i |
number[] |
[1, 0, 0] — the +X unit vector. |
j |
number[] |
[0, 1, 0] — the +Y unit vector. |
k |
number[] |
[0, 0, 1] — the +Z unit vector. |
_i |
number[] |
[−1, 0, 0] — the −X unit vector. |
_j |
number[] |
[0, −1, 0] — the −Y unit vector. |
_k |
number[] |
[0, 0, −1] — the −Z unit vector, the look direction; the default
direction of mapDirection. |
X |
number |
axes bit: the +X half-axis. |
_X |
number |
axes bit: the −X half-axis. |
Y |
number |
axes bit: the +Y half-axis. |
_Y |
number |
axes bit: the −Y half-axis. |
Z |
number |
axes bit: the +Z half-axis. |
_Z |
number |
axes bit: the −Z half-axis. |
LABELS |
number |
axes bit: the X / Y / Z letter glyphs at the axis tips. |
CIRCLE |
number |
bullsEye / pointerHit shape: circular. |
SQUARE |
number |
bullsEye / pointerHit shape: square. |
NEAR |
number |
viewFrustum bit: the near plane (outline, or textured quad).
Also the near-plane key of the bounds object. |
FAR |
number |
viewFrustum bit: the far plane (outline, or textured quad).
Also the far-plane key of the bounds object. |
LEFT |
number |
Left-plane key of the bounds object. |
RIGHT |
number |
Right-plane key of the bounds object. |
BOTTOM |
number |
Bottom-plane key of the bounds object. |
TOP |
number |
Top-plane key of the bounds object. |
BODY |
number |
viewFrustum bit: the four edges joining near to far corners. |
APEX |
number |
viewFrustum bit: perspective only — lines from the eye to the
near corners. |
PATH |
number |
trackPath bit: the sampled polyline along the target path. |
CENTER |
number |
trackPath bit, CameraTrack only: the gaze line from each
keyframe's eye to its center, with a dot at the center. |
CONTROLS |
number |
trackPath bit: the straight control polygon along the target path. |
TANGENTS_IN |
number |
trackPath bit: the incoming tangent arrow at each keyframe. |
TANGENTS_OUT |
number |
trackPath bit: the outgoing tangent arrow at each keyframe. |
TANGENTS |
number |
TANGENTS_IN | TANGENTS_OUT. |
HANDLES |
number |
trackPath bit: the keyframe dots of a track created with the
handles option (its TrackHandles, track.handles); draws nothing otherwise. |
TRANSLATE |
number |
helmRig bit: the three translation arrows (Tx / Ty / Tz). |
ROTATE |
number |
helmRig bit: the three rotation rings (pitch / yaw / roll). |
SPHERE |
number |
createHandle constraint: a heading on a sphere (2 DOF). |
PLANE |
number |
createHandle constraint: a point on a fixed plane (2 DOF). |
AXIS |
number |
createHandle constraint: a point on a line (1 DOF, signed scalar). |
DIAL |
number |
createHandle constraint: an accumulated angle on a circle — the
rotation handle (1 DOF). |
VIEW |
number |
createHandle constraint: a camera-facing plane re-aimed every
frame — screen-parallel drag at constant depth, reported as a world position. |
POINT |
number |
createHandle report mode: a position. |
DIRECTION |
number |
createHandle report mode: a unit direction. |
HANDLE |
number |
Handle draw bit: the draggable dot. |
AIM |
number |
Handle draw bit: the anchor → point line (a DIAL's spoke). |
LOCUS |
number |
Handle draw bit: the constraint surface — sphere wire, plane quad, axis
segment, dial ring, or view square. |
RING |
number |
Handle draw bit: the SPHERE view-facing limb / the PLANE border. |
qSet |
Function |
qSet(out, x, y, z, w) — set the four components. |
qCopy |
Function |
qCopy(out, a). |
qDot |
Function |
qDot(a, b) — four-component dot product. |
qNormalize |
Function |
qNormalize(out) — in place. |
qNegate |
Function |
qNegate(out, a) — the same rotation on the other hemisphere. |
qConjugate |
Function |
qConjugate(out, a) — the inverse of a unit quaternion. |
qMul |
Function |
qMul(out, a, b) — Hamilton product; alias-safe (out may be a or b). |
qRotateVec3 |
Function |
qRotateVec3(out, q, v) — rotate a vec3 by a unit quaternion. |
qSlerp |
Function |
qSlerp(out, a, b, t) — spherical linear interpolation. |
qNlerp |
Function |
qNlerp(out, a, b, t) — normalized linear interpolation. |
qFromUnitVectors |
Function |
qFromUnitVectors(out, a, b) — the shortest arc taking unit a to unit b. |
qFromAxisAngle |
Function |
qFromAxisAngle(out, ax, ay, az, angle) — axis need not be unit; radians. |
qFromLookDir |
Function |
qFromLookDir(out, dir, [up]) — −Z forward, up defaults to +Y. |
qFromRotMat3x3 |
Function |
qFromRotMat3x3(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) — nine
row-major scalars. |
qFromMat4 |
Function |
qFromMat4(out, m) — from the rotation part (the upper-left 3×3) of a
mat4 such as mat4Model gives. |
qToMat4 |
Function |
qToMat4(out, q) — a rotation mat4 ready for applyMatrix. |
qToAxisAngle |
Function |
qToAxisAngle(q, [out]) → { axis, angle } in radians. |
raySphere |
Function |
Ray–sphere intersection — a building block of a custom Handle constraint's solve(). |
rayPlane |
Function |
Ray–plane intersection — a building block of a custom Handle constraint's solve(). |
rayClosestPointOnAxis |
Function |
Closest point on an axis to a ray — a building block of a custom
Handle constraint's solve(). |
dirFromAzEl |
Function |
Unit direction from azimuth / elevation. |
azElFromDir |
Function |
Azimuth / elevation from a unit direction. |
oneEuro |
Function |
oneEuro([opts]) — a stateful 1€ filter f(out, raw, dt) / f(raw, dt);
assign it to the filter of a PoseHelm or CameraHelm. |
poseDelta |
Function |
Turns an absolute pose stream into the rate stream a PoseHelm or
CameraHelm's feed() wants, guarding against quaternion double cover. |