Guide · 05 of 09
Three dimensions
A scene space3 draws in 3D. It needs a z: [min, max] alongside x and y, and it projects orthographically the way a textbook draws a solid — no perspective, so parallel edges stay parallel and lengths along an axis stay comparable. Axes, arrowheads and unit ticks are drawn for you. Point the camera: at a param and the learner can spin the figure, which is the only reliable way to resolve what is in front of what. The 3D objects below are only legal inside a space3 scene, and the 2D ones (curve, rect, circle, ...) are not.
space3#
camera: takes two angles in degrees: azimuth spins around the vertical z axis, elevation lifts the eye above the xy plane. Both are expressions, so binding either to a param gives you a turntable. Defaults to [55, 26].
scene space3 { x: [..] y: [..] z: [..] [camera: [azimuth, elevation]] }
| prop | type | description |
|---|---|---|
| z | [min, max] | the third domain — required |
| camera | [expr, expr] | azimuth and elevation in degrees; bind to state to let the learner spin it |
| axes | flag | set axes: false to hide the drawn axes |
Example
point3#
A point in space. guides drops the dashed rails down to the xy plane and along to each axis, which is what makes an isolated dot readable — without them a projected point is genuinely ambiguous.
point3 <id> = (x, y, z) { [props] }
| prop | type | description |
|---|---|---|
| label | string | text beside the point, ${} interpolates |
| guides | flag | dashed rails to the coordinate planes |
| r | number | radius in pixels |
| open | flag | hollow marker |
Example
segment3#
A straight piece of a line between two points in space. Add arrow to make it a vector.
segment3 <id> = (x1, y1, z1) -> (x2, y2, z2) { [arrow] [props] }
| prop | type | description |
|---|---|---|
| arrow | flag | draw an arrowhead at the far end |
| label | string | text at the midpoint |
Example
polygon3#
A flat face through three or more points. Faces are painted back to front by their average depth, so overlapping faces stack in a believable order.
polygon3 <id> = [(x, y, z), (x, y, z), ...] { [props] }
| prop | type | description |
|---|---|---|
| fill | color | fill color (defaults to the stroke color) |
| opacity | number | fill opacity, default 0.22 |
Example
plane3#
A plane, drawn as a square patch of itself centred on through and perpendicular to normal. A plane is infinite, so size: only controls how much of it you draw. The normal cannot be the zero vector.
plane3 <id> { normal: (a, b, c), through: (x, y, z), [size: <n>] }
| prop | type | description |
|---|---|---|
| normal | (a, b, c) | the normal vector — required |
| through | (x, y, z) | a point on the plane — required |
| size | number | half-width of the drawn patch, default 3 |
| label | string | text at the centre |
Example
label3#
Free text anchored at a point in space. ${} interpolates live values.
label3 [<id>] at (x, y, z) = "text" { [props] }
| prop | type | description |
|---|---|---|
| fontSize | number | text size in pixels |
| tex | flag | render as LaTeX |
Example