Prism
GuideCookbookExamplesErrorsPlayground

Guide

01Lessons & Slides02Exercises03Scene & State04Objects05Three dimensions06Controls07Timeline08Loops & Logic09Expressions & Math

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]] }
proptypedescription
z[min, max]the third domain — required
camera[expr, expr]azimuth and elevation in degrees; bind to state to let the learner spin it
axesflagset axes: false to hide the drawn axes

Example

xyzA
spin55
0360

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] }
proptypedescription
labelstringtext beside the point, ${} interpolates
guidesflagdashed rails to the coordinate planes
rnumberradius in pixels
openflaghollow marker

Example

xyzP(3, 2, 2)
spin55
0360

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] }
proptypedescription
arrowflagdraw an arrowhead at the far end
labelstringtext at the midpoint

Example

xyzv
spin55
0360

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] }
proptypedescription
fillcolorfill color (defaults to the stroke color)
opacitynumberfill opacity, default 0.22

Example

xyz
spin55
0360

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>] }
proptypedescription
normal(a, b, c)the normal vector — required
through(x, y, z)a point on the plane — required
sizenumberhalf-width of the drawn patch, default 3
labelstringtext at the centre

Example

xyz
spin55
0360

label3#

Free text anchored at a point in space. ${} interpolates live values.

label3 [<id>] at (x, y, z) = "text" { [props] }
proptypedescription
fontSizenumbertext size in pixels
texflagrender as LaTeX

Example

xyzA
spin55
0360
← PreviousObjectsNext →Controls

On this page

space3point3segment3polygon3plane3label3