Guide · 06 of 15
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, and grid numbers the ticks, as on a plane. 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 |
| grid | flag | number the unit ticks on each axis |
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.
A pointer cannot pick a depth, so a dragged point3 moves along one world axis (drag: z -> c) or across one axis plane through it (drag: xy -> (a, b), also xz and yz), writing the params in order. Draw it at exactly those params; snap rounds them as on a plane point.
point3 <id> = (x, y, z) { [drag: x -> a | xy -> (a, b)], [snap: <n>|(n1,n2)|grid], [props] }
| prop | type | description |
|---|---|---|
| label | string | text beside the point, ${} interpolates |
| labelOffset | (x, y) | nudge the label by (dx, dy) screen pixels after projection, y down |
| guides | flag | dashed rails to the coordinate planes |
| drag | axes -> param(s) | drag along an axis or across a plane |
| snap | number | round the dragged params to a step |
| 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, and ${} interpolates live values. With fixed it is pinned to the frame and stays put while the figure spins, the place for a readout: at (u, v) is then fractions of the frame from its top-left corner, and the text grows away from the nearer side.
label3 [<id>] at (x, y, z) = "text" { [props] } | label3 [<id>] at (u, v) = "text" { fixed }
| prop | type | description |
|---|---|---|
| fontSize | number | text size in pixels |
| tex | flag | render as LaTeX |
| fixed | flag | pin to the frame, at (u, v) from 0 to 1 |
Example
arc3#
The angle at the middle point between the rays to the other two, drawn as an arc in the plane they span, so it turns with the figure. r: is the radius in scene units (a third of the shorter arm by default), label: is TeX set beside the middle of the arc, and right draws a square corner.
arc3 <id> = [(ax, ay, az), (vx, vy, vz), (bx, by, bz)] { [r: <n>], [label: "" ], [right] }
| prop | type | description |
|---|---|---|
| r | expr | radius in scene units |
| label | string | TeX at the middle of the arc, ${} live |
| right | flag | a square corner instead of an arc |
Example