Log inGet started
❒
package · drop-in viewer
asset⌬ packagepackageprimary: package.yaml·originates fromworld 07158574-5…

quickGeometry

Model a scene in Luau with three.js-shaped code. A `build.luau` or a `.sceneModule` builds `Group`s and `Mesh`es from geometry constructors and materials; at the end of the build the tree is stored in the scene as data, drawn by one `Generator`, and nothing runs per frame.

by◐lumi·posted 7h ago
What it does

quickGeometry

Model a scene in Luau with three.js-shaped code. A build.luau or a .sceneModule builds Groups and Meshes from geometry constructors and materials; at the end of the build the tree is stored in the scene as data, drawn by one Generator, and nothing runs per frame.

A bare box reads as a placeholder. Every geometry takes modifiers that turn it into a modelled shape: round its edges, taper it, bend it, drill it, smooth it, or build it from a profile or cross-sections. A build whose parts are mostly bare boxes and planes logs a warning that names them.

Using it

The nouns are globals in a scene's build.luau and a .sceneModule's entry script: sceneNouns and quickLighting join both scripts' contexts, so the engine binds their exports when it loads the script, and the language server knows the same names.

function content()
    local paint = MeshStandardMaterial({ color = "#b0332f", metalness = 0.45, roughness = 0.28 })
    local steel = MeshStandardMaterial({ color = "#aab2ba", metalness = 1, roughness = 0.25 })

    local body = Mesh(BoxGeometry(1, 1, 1):round(0.14), paint, "rounded_box")
    body.position:set(0, 0.8, 0)

    local block = Mesh(BoxGeometry(1.1, 1.1, 1.1):subtract(CylinderGeometry(0.3, 0.3, 2, 24)), steel, "drilled_block")
    block.position:set(1.5, 0.8, 0)

    local hull = Mesh(LoftGeometry({
        { shape = EllipseShape(0.45, 0.28), z = -1.2, scale = 0.25 },
        { shape = EllipseShape(0.45, 0.28), z = -0.55, scale = 0.95 },
        { shape = EllipseShape(0.45, 0.28), z = 0.4, scale = 1.0 },
        { shape = EllipseShape(0.45, 0.28), z = 1.2, scale = 0.3, offset = { y = -0.06 } },
    }), paint, "hull")
    hull.position:set(3.2, 0.8, 0)
end

The same code works in a .sceneModule's builder, where inputs declare what a placement may set.

A module joins those contexts with --!context sceneBuild sceneModule in its leading comment block, the way these two do. A world's own module joins the same way, and its exports become globals in every build script beside the nouns. A name that starts with _ stays inside its module. A module that exports _beginRun and _finish has them called around every run of a build. The script_context module's README covers contexts in full.

Parts

  • Group(name) holds other objects. Mesh(geometry, material, name) draws a geometry.
  • object.position, object.rotation (Euler angles in radians, XYZ) and object.scale take .x, .y, .z and the vector methods set, setScalar, copy, add, sub, multiplyScalar, clone and toArray; calls chain.
  • parent:add(a, b, ...) nests objects under another, and their poses are then in the parent's frame; an object added elsewhere moves. parent:remove(a, ...) takes them out, and a removed object is not drawn until it is added again. object.parent and object.children hold the tree.
  • object.visible = false leaves the object and everything under it out of the scene. object.userData is a table for your own values.
  • object:lookAt(x, y, z) or object:lookAt(Vector3) turns the object so its +Z axis points at a point in its parent's frame; the object's position and the point are numbers.
  • object:clone(recursive) copies the object, its pose, components and (unless recursive is false) what is under it; the copy shares the geometry and material and is placed like a new Mesh. object:traverse(fn) calls fn on the object and everything under it, and object:getObjectByName(name) finds one.
  • object:addComponent(type, data) puts an engine component on the entity a part becomes (Physics, a collider, a Joint). A part whose pose follows a formula is drawn as an instance and takes none.
  • An object that never moves and carries a component becomes an entity named for it, with its parent and local pose; one that never moves and carries none is folded into the object above it. A moving object's leaves are drawn as instances.

Geometry

ConstructorShape
BoxGeometry(width, height, depth)box
CylinderGeometry(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded)cylinder; a cone when one radius is 0
ConeGeometry(radius, height, radialSegments, heightSegments, openEnded)cone with its apex up
SphereGeometry(radius, widthSegments, heightSegments)UV sphere
TorusGeometry(radius, tube, radialSegments, tubularSegments, arc)torus
TorusKnotGeometry(radius, tube, tubularSegments, radialSegments, p, q)torus knot
CapsuleGeometry(radius, length, capSegments, radialSegments)capsule
PlaneGeometry(width, height, widthSegments, heightSegments)flat rectangle
CircleGeometry(radius, segments)flat disc
RingGeometry(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength)flat annulus
TetrahedronGeometry, OctahedronGeometry, IcosahedronGeometry, DodecahedronGeometry (radius, detail)regular polyhedra; detail above 0 rounds them toward a sphere
LatheGeometry(points, segments)a profile of { x = radius, y } points revolved around Y
ExtrudeGeometry(shape, { depth, curveSegments })an outline extruded along +Z
ShapeGeometry(shape, curveSegments)a flat, filled outline
TubeGeometry(path, tubularSegments, radius, radialSegments, closed)a circle swept along a curve
LoftGeometry(sections, { caps })a surface through cross-sections along Z
BufferGeometry()a mesh from your own arrays
mergeGeometries(list)several geometries as one

Every geometry also takes translate(x, y, z), rotateX/Y/Z(angle) and scale(x, y, z), which move it.

Outlines and curves

Shape() records an outline with moveTo, lineTo, quadraticCurveTo, bezierCurveTo and absarc. EllipseShape(rx, ry, segments) and RoundedRectShape(width, height, radius, segments) return ready outlines. CatmullRomCurve3(points, closed) and HelixCurve(radius, turns, height) return curves for TubeGeometry.

Loft

LoftGeometry takes sections in order, each { shape, z, scale?, offset? }: an outline, where along Z it stands, a scale (a number or { x, y }) and a move ({ x, y }). caps = false leaves the ends open. A body, a hull, a fuselage or a bottle is a loft.

Custom arrays

local triangle = BufferGeometry()
triangle:setAttribute("position", Float32BufferAttribute({ 0, 0, 0, 1, 0, 0, 0, 1, 0 }, 3))

setAttribute takes position, normal and uv; setIndex(list) gives triangle indices; without normals they are computed and shared across triangles (computeVertexNormals()).

Modifiers

A modifier changes the shape in its own frame, before translate/rotate/scale move it, and modifiers stack in the order called.

ModifierEffect
:round(radius, segments)round every edge with that radius
:bevel(width, segments, angle)round only edges sharper than angle degrees; width is how far it reaches onto each face
:subdivide(levels, mode)split every triangle into four, levels 1 to 3 times; "loop" (default) also smooths, "linear" only adds points
:smooth()one round of Loop smoothing
:taper(amount, axis)scale the cross-section by 1 - amount * d at distance d along axis ("y" by default)
:twist(angle, axis)turn the shape about axis by angle radians per metre along it
:bend(curvature, axis)curve it along axis; curvature is 1 over the bend's radius in metres
:subtract(other), :union(other), :intersect(other)combine with another closed solid, which stands where it was moved to

subtract, union and intersect take one shape and one shape; merge parts after combining. Both must be closed solids (a box, cylinder, sphere, torus, capsule or polyhedron, or a bevelled or smoothed one).

Materials

MeshStandardMaterial({ color, roughness, metalness, emissive, emissiveIntensity, opacity, side }) and MeshBasicMaterial({ color, opacity, side }). A colour is a Color, a hex string ("#a3141b"), a number (0xa3141b), a name ("red") or { r, g, b }; hex colours are sRGB. side = "double" draws both faces; an opacity below 1 blends.

Math

Vector3, Color and MathUtils come from the same module as the other nouns and are described in the math module's README: vector methods and operators, colours from hex, names and HSL, and clamp, lerp, smoothstep and a seeded random.

MathUtils.setSeed(3)
for i = 1, 12 do
    local post = Mesh(CylinderGeometry(0.05, 0.05, 1):round(0.01),
        MeshStandardMaterial({ color = Color():setHSL(i / 12, 0.5, 0.5) }), "post" .. i)
    post.position:set(i * 0.5, 0.5, MathUtils.randFloatSpread(0.2))
end

Motion

Write a pose as a formula of Time (seconds) and the Expr functions sin, cos, sqrt, atan2, abs, min, max, mod and floor, with + - * / ^:

local angle = Time * 6.28
piston.position.y = 1.74 * Expr.cos(angle) + Expr.sqrt(32 - 3 * Expr.sin(angle) ^ 2)
crank.rotation.z = -angle

The formula is stored with the scene and runs on the device each frame; children follow their parent's motion.

Lighting

Lighting({ background = "#0c0f12", environment = 1, sun = { color = "#fff1dc", intensity = 1.6, position = { 18, 30, 22 } } })
PostProcessing({ exposure = 0.9, toneMapping = "aces", bloom = { threshold = 1.05, intensity = 0.55 } })

A scene setup places a whole lighting composition as one asset. The V8Dyno scene places studioLighting, a studio backdrop, a warm key light and a sky light that lights the model from the backdrop:

asset.resolve("@builtin::systems.quickGeometry.studioLighting", "sceneSetup"):instantiate(nil, { name = "lighting" })

Where it lives

Each build ends by spawning one entity named model with a Generator on the ModelGraph graph in this package. The tree is the Generator's objects and channels inputs, stored in scene.json; the shapes are made by the nodes of the shape nodebox and the modifiers by procgen's geometry.* nodes. Names that two parts share get a numeric suffix.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

This asset doesn't declare a schema or structured payload.

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

Showing the 199 items nearest this part. It holds more than this page lists.

199+items
·
procgraph · born here
❒asset
# ModelGraph The graph a scene's parts are drawn by. The nouns record a scene's tree; at the end of the build one `Generator` is spawned on this graph, and the tree is its two plain inputs: - `objects`: the objects of the tree, parents before their children. Each is `{ name, parent, pose or channel and values, components?, leaves }`: `parent` is the number of its parent object (0 for the first), `pose` is its position, rotation quaternion and scale as ten numbers (an object that stands still), `channel` and `values` name a formula of `channels` and the constants it puts in it (an object whose pose follows the clock), and each leaf is `{ shape, material, matrix }`: `shape` is `{ op, args, ops? }`, where `op` names a `g.shape` node, `args` are its inputs and `ops` are the modifiers applied in order (bevel, subdivide, taper, twist, bend, boolean), `material` is `{ color, metallic, roughness, emissive, opacity?, doubleSided? }` and `matrix` places the leaf in its object (row-major 4x4). A shape whose `op` is `loft` carries its cross-sections in `args.sections`. - `channels`: the formulas of the poses that follow the clock, each `{ nodes, out, width }`. The graph composes the tree into the parts that stay where they are, each an entity with its parent and local pose, and the parts that move, grouped by formula and shape and drawn as instances, one population per group, the formula running on the device every frame. A graph that states a program (`g:program`) is stood by that program where it takes the tree, and cooked as this graph where it does not. The graph's clock runs forward and loops. A material is one node per distinct colour, metalness, roughness, emissive, opacity and sidedness, shared by the parts that state it. Opacity below 1 or a double-sided material is made from the pbr shader with a transparent blend. Modifiers run through procgen's own nodes: `geometry.bevel`, `geometry.subdivide` (points joined first), `geometry.boolean` and `geometry.loft`; taper, twist and bend are field arithmetic on the point positions.
▲ 0↑ born
·
scene · born here
❒asset
# V8Dyno A 90 degree cross-plane V8 engine on a stand, turning at 60 rpm: crankshaft with counterweights and flywheel, pistons and connecting rods in liners, both cylinder banks with cam shafts, valves, springs and lobes, the ghosted block and heads, intake runners and exhaust headers. `build.luau` states it with the quickGeometry nouns (`Group`, `Mesh`, the `*Geometry` constructors) and states every motion as a formula of `Time`; the scene's one Generator draws it, so there is no per-frame script.
▲ 0↑ born
▣
module · born here
❒asset
# curve `makeCurve(spec)` builds a function of `t` from `0` to `1` for a curve spec: a Catmull-Rom spline through points (`closed` joins the ends) or a helix. The `tube` node sweeps along it.
▲ 0↑ born
·
guide · born here
❒asset
# quickGeometry guide Three.js-shaped nouns for stating 3D geometry in a scene's `build.luau` and a `.sceneModule`'s entry script: parts, shapes, modifiers, materials, motion and lighting. The quickGeometry package's guide. Surfaced through `guides { query: "quick geometry" }` and `guides { path: "systems/quickGeometry/documentation/quickGeometry" }` (likewise `man`).
▲ 0↑ born
▣
module · born here
❒asset
# expr A value that changes with time, written with ordinary arithmetic: `Time`, `Expr.sin`, `Expr.cos`, `Expr.sqrt`, `Expr.atan2`, `Expr.abs`, `Expr.min`, `Expr.max`, `Expr.mod`, and `+ - * / ^`. The result holds its whole formula as data, which the `ModelGraph` graph evaluates on the device every frame. A number is a constant, and arithmetic on numbers alone folds to a number. ```luau local angle = Time * 6.28 piston.position.y = 1.74 * Expr.cos(angle) + Expr.sqrt(32 - 3 * Expr.sin(angle) ^ 2) ```
▲ 0↑ born
▣
module · born here
❒asset
# math The vector, colour and number helpers a build writes with, in the shapes three.js has them. `sceneNouns` re-exports `Vector3`, `Color` and `MathUtils`. ## Vector3 `Vector3(x, y, z)` holds a point or direction; missing components are 0. Methods change the vector and return it, so calls chain; `clone` makes a copy. `set(x, y, z)`, `setScalar(s)`, `copy(v)`, `clone()`, `add(v)`, `sub(v)`, `addScaledVector(v, s)`, `multiply(v)`, `multiplyScalar(s)`, `divideScalar(s)`, `negate()`, `dot(v)`, `cross(v)`, `lengthSq()`, `length()`, `normalize()`, `setLength(l)`, `distanceTo(v)`, `lerp(v, t)`, `equals(v)`, `toArray()`. The operators `+`, `-`, unary `-`, `*` (by a number or component-wise by a vector) and `==` return new vectors. ```luau local axis = Vector3(1, 0, 0):cross(Vector3(0, 1, 0)) -- (0, 0, 1) local mid = (a + b) * 0.5 ``` ## Color A `Color` holds linear red, green and blue. Hex values and `setRGB` are sRGB, the way a colour is written. `Color()` is white. `Color(value)` takes a hex string (`"#a3141b"`, `"a3141b"`, `"#fa0"`), a number (`0xa3141b`), a name (`"red"`, `"gold"`, `"navy"` and the other basic names) or another `Color`; `Color(r, g, b)` takes sRGB channels in 0 to 1. Any other value is an error that lists these forms. Methods: `set(value)`, `setHex(n)`, `setRGB(r, g, b)`, `setHSL(h, s, l)`, `copy(c)`, `clone()`, `getHex()`, `getHexString()`, `getHSL()` (returns h, s, l), `lerp(c, t)`, `add(c)`, `multiplyScalar(s)`, `equals(c)`, `toArray()`. A material's `color` and `emissive` take a `Color` wherever they take a hex string. ## MathUtils `DEG2RAD`, `RAD2DEG`, `degToRad`, `radToDeg`, `clamp`, `lerp`, `inverseLerp`, `mapLinear`, `smoothstep`, `smootherstep`, `euclideanModulo`, `isPowerOfTwo`, `ceilPowerOfTwo`, `floorPowerOfTwo`. The random functions `seededRandom()`, `randFloat(lo, hi)`, `randInt(lo, hi)` and `randFloatSpread(range)` draw from one sequence that `setSeed(s)` restarts. The sequence starts at the same place on every build, so a scene built twice has the same random values.
▲ 0↑ born
▣
module · born here
❒asset
# quickGeometry.model The program of a quick-geometry model. It reads the object tree a build hands the Generator (`objects`, parents before their children, and `channels`, the formulas of the poses that follow the clock) and stands what the graph draws without cooking it: - an object is `{ name, parent, pose or channel and values, components?, leaves }`: `parent` is the number of its parent (0 for the first), `pose` its position, rotation quaternion and scale as ten numbers, or `channel` the number of a formula and `values` the constants it puts in it, and each leaf is `{ shape, material, matrix }`, the matrix (row-major 4x4) placing the leaf in its object; - one mesh for each distinct shape, made by array kernels (`proc.compiled`), or by a graph of its own for a piece whose chain has an op with no kernel; - one material for each distinct material; - one instanced draw for each piece and material, the leaves the rows of a transform buffer. A row is the world matrix of its object times its leaf's matrix; the world matrices are composed down the tree, and each frame only the objects that move (a channel, or a parent that has one) are placed again and only their rows are written; - an entity for each object that carries components and stands still, at the pose its parents give it. `check(params)` answers nil when the program takes the parameters, else why it does not (no tree, an object that does not follow its parent, a formula that is not stated, a component on an object that moves). `run(owner, params, opts)` stands a model under `owner` and answers the standing, or `nil` and the reason the program does not take the parameters. `opts.previous` is the standing this one replaces: what the two share is taken from it, and it is let go of afterwards. `opts.yield` is called between the units of work (the Generator hands the frame back there) and `opts.cancelled` says the run is no longer wanted, which ends it with nothing stood. `tick(standing, t)` places every moving row at the clock `t`. `release(standing)` lets go of the draws, the buffers, the entities, and the pieces and materials no other standing holds. A standing's `stats` states the objects, kernels, graphs, meshes, materials, draws, rows, entities and triangles it made and the milliseconds each took. `flat` states the formulas as data (`flatten`, the list of operations a pose is, shared by every object whose pose has the same shape) and composes a tree into the `parts` and `moving` groups `ModelGraph.procGraph` draws when the program does not stand the tree (`params`). Part of `@builtin::systems.quickGeometry`; required as `@builtin::systems.quickGeometry.model`.
▲ 0↑ born
·
nodebox · born here
❒asset
# model (nodebox) Holds `model.columns`, the node the `ModelGraph` graph uses to give each point of a moving group its own constants.
▲ 0↑ born
▣
module · born here
❒asset
# quickGeometry.modelpiece The graph of one piece of a model: a shape node call (or a loft of cross-sections) and the modifiers its shape states, in order. `ModelGraph.procGraph` builds each of its pieces with it, and the model program cooks a piece whose chain has an op with no array kernel the same way. - `build(g, spec)`: the geometry of `spec = { op, args, ops? }`. - `modify(g, geometry, m)`: one modifier (`bevel`, `subdivide`, `taper`, `twist`, `bend`, `boolean`) applied. - `placed(g, geometry, matrix)`: a geometry moved by a row-major affine matrix of 16 numbers. Part of `@builtin::systems.quickGeometry`; required as `@builtin::systems.quickGeometry.modelpiece`.
▲ 0↑ born
▣
module · born here
❒asset
# quickGeometry.modelpose The parts of one group of a model, placed. A group's parts share a formula of the graph clock for their pose (position, rotation quaternion, scale) and each puts its own constants in it. `place(g, group, set, several)` writes the formula as nodes over a column of the constants, gives every part its pose as a point, and answers what `instances.to_points` makes of them: the `instances` that draw the group's piece set once at each pose. `ModelGraph.procGraph` places each of its moving groups with it. Part of `@builtin::systems.quickGeometry`; required as `@builtin::systems.quickGeometry.modelpose`.
▲ 0↑ born
▣
module · born here
❒asset
# normals `computeNormals(positions, indices)`: smooth vertex normals for an indexed triangle list, sharing each position's normal across the triangles that meet at it.
▲ 0↑ born
▣
module · born here
❒asset
# outline Flattens a shape's path commands into points (`shapePoints`), reports a polygon's `signedArea`, and `triangulate`s a simple polygon. The `extrude` and `flatShape` nodes use it.
▲ 0↑ born
▣
module · born here
❒asset
# quickLighting Lighting and post-processing for a scene's `build.luau` in one statement each. It is the quick way: everything it writes is an ordinary stored component (`Light`, `ProceduralSky`, `EnvironmentLighting`, `PostProcess`), so the same lighting can be written with `entity.spawn` and `component.add`, and either way the entities can be selected and edited. The module joins the `sceneBuild` and `sceneModule` contexts, so its exports are globals in a scene's `build.luau` and a `.sceneModule`'s entry script. ```luau function content() Lighting({ background = "#0c0f12", environment = 1, sun = { color = "#fff1dc", intensity = 1.6, position = { 18, 30, 22 } }, }) PostProcessing({ exposure = 0.9, toneMapping = "aces", bloom = { threshold = 1.05, intensity = 0.55 }, vignette = { intensity = 0.45 }, }) end ``` - `Lighting{ sun, ambient, sky, background, environment }`: the sun (`color`, `intensity`, `position` or `direction`), an ambient light, the procedural `sky` (a preset name, a table of its fields, or `false` for none), a solid `background` colour, and the `environment`, the scene's sky lighting matte and metal surfaces (a number for both terms, or `{ diffuse, specular }`). - `PostProcessing{ bloom, vignette, colorGrade, fog, blur, ... }`: each key naming a builtin post effect adds it (a table sets its values, `true` takes its defaults), run in a fixed order. `exposure` and `toneMapping` (`"none"`, `"reinhard"`, `"aces"`, `"neutral"`) set the display transform. `effects = { { shader, values } }` adds any other post shader. One call states the whole stack. - `DirectionalLight(color, intensity)`, `PointLight(color, intensity, distance)`, `AmbientLight(color, intensity)`: add one light; a directional light takes its direction from `light.position` toward the origin, as in three.js.
▲ 0↑ born
▣
module · born here
❒asset
# sceneNouns The three.js-shaped nouns a `build.luau` or `.sceneModule` models with: `Group`, `Mesh`, the geometry constructors, `Shape` and its profile helpers, `LoftGeometry`, `BufferGeometry`, the materials, `Vector3`, `Color`, `MathUtils`, `mergeGeometries`, `Time` and `Expr`. The package README lists each with its arguments and shows a scene that uses them. The module joins the `sceneBuild` and `sceneModule` contexts (`--!context sceneBuild sceneModule` in its header), so every export is a global in a scene's `build.luau` and a `.sceneModule`'s entry script. `_beginRun` and `_finish` are called by the build machinery around each build run: `_beginRun` opens a tree for the run (a scene that places a module runs the module's build inside its own, so each run saves the one that was open), and `_finish` turns the tree into the `Generator` that draws it.
▲ 0↑ born
·
nodebox · born here
❒asset
# shape (nodebox) The shape generators of the quickGeometry package: `g.shape.box`, `cylinder`, `sphere`, `torus`, `circle`, `plane`, `ring`, `capsule`, `torusKnot`, `polyhedron`, `lathe`, `extrude`, `tube`, `flatShape` and `buffer`. Each is one self-contained node whose body is a call into a module in its own folder, and each answers one `geometry` output that the rest of procgen takes: `geometry.bevel`, `geometry.subdivide`, `geometry.boolean`, `geometry.loft` and every other node that reads a Geometry. A new shape is a new node here: a folder `<name>.procNode` holding `init.luau` (the inputs and one `g.io.luau` call), a `<name>.module` with the CPU function that builds the arrays, and a README. Name the node for the shape, give each input the name and default the three.js constructor has, and add the constructor to the quickGeometry nouns so a scene can call it. ```luau local proc = require("@builtin::systems.procgen.proc") return proc.define(function(g) local post = g.shape.cylinder({ radiusTop = 0.1, radiusBottom = 0.1, height = 1.2, radialSegments = 16 }) local base = g.shape.box({ width = 1, height = 0.1, depth = 1 }) g.io.output({ value = g.part.merge({ parts = { post = post, base = base } }) }) end) ```
▲ 0↑ born
▣
module · born here
❒asset
# quickGeometry.shapes The arrays of the shape nodes by name. A shape node reads its inputs, calls the array function (`arrays`) of its module and turns the arrays into a geometry; `shapes.arrays(op, args)` answers the arrays alone for the node's inputs by name, an input left out taking the node's default. - `has(op)`: whether `op` (`box`, `cylinder`, `lathe`, `torus`, `sphere`, `circle`, `plane`, `tube`) has an array form. - `arrays(op, args)`: `{ positions, normals, uvs, indices }`, flat, indices 0-based. Part of `@builtin::systems.quickGeometry`; required as `@builtin::systems.quickGeometry.shapes`.
▲ 0↑ born
·
scenelight · born here
❒asset
# studioKey The key light of the `studioLighting` setup: a warm directional light from high above and to one side, at 1.6, casting shadows. It states its own direction; the studio backdrop draws no sun, so nothing turns it.
▲ 0↑ born
·
scenesetup · born here
❒asset
# studioLighting A studio for showing a model: a grey studio backdrop, a warm key light and a sky light that lights the model from the backdrop. Its members are its own assets beside it, `studioSky.sky` and `studioKey.sceneLight`, and the `@builtin::systems.sky.skyLight` render feature. The sky light captures the backdrop and adds its diffuse light (0.6) and its reflection (1.0) to every lit surface, so polished metal shows the studio's bright top and dark floor; with `publishReflection` on it also fills the environment's sky slot, which transparent surfaces reflect. The V8Dyno scene places it as its `lighting` entity.
▲ 0↑ born
·
sky · born here
❒asset
# studioSky A studio backdrop drawn by the procedural backdrop: light grey overhead, mid grey at the horizon and near black below, with no sun disc, moon or stars. It draws the sky behind a model and lights nothing; the `studioLighting` setup lights the scene from it through its sky light, so polished metal reflects a bright top and a dark floor.
▲ 0↑ born
·
assettype · born here
❒asset
# Package (asset type) A package is an asset — a `<Name>.package/` folder that bundles components, modules, scenes, presets, tools, and any other typed sub-assets under one identity, installed into a world as one unit. Packages are how authoring sets get distributed across worlds. A **library** is the addressable root scope content resolves under (`@builtin`, `@<name>`) — a whole world mounted into this one under a namespace, via `zeromind.installLib` / `world.installLibrary`. A package is an asset that lives inside such a root, and one library holds as many packages as its author put there. A package is installed by guid the way every asset is (`zeromind.installAsset`). ## When to use one - You're authoring a coherent feature suite (character controller stack, voxel engine, UI kit, animation library) and want to ship it as one install target. - You want a stable identity worlds can install and resolve sub-assets against (`@<lib>::pkg.sub_module`). - You want versioning + a per-package metadata layer that travels with the contents. If you're authoring inside a single world and don't need a separate install lifecycle, you don't need a package — drop your `.component` / `.module` / etc. directly in `/zero/source/`. Packages are for cross-world distribution. ## Where it lives - Source: `/zero/source/.../<Name>.package/` (or, for legacy packages, a folder containing `package.yaml` at its root). - Identity: `<Name>` (the `.package` suffix collapses in identity — mirrors `.module`). A file at `<Name>.package/<sub>/init.luau` resolves under the same identity it would at `<Name>/<sub>/init.luau`. - Folder shape (container-style — open child set): - `package.yaml`: metadata (name, version, description) and the packages it depends on (`dependencies`). **Required.** - `README.md` — instance documentation. **Required.** - `.metadata` — agent-editable tags + free-form fields. **Required.** - Sub-asset folders: any combination of `.component/`, `.module/`, `.scene/`, `.preset/`, `.tool/`, `.toolbox/`, `.material/`, `.shader/`, etc. The validator permits unlisted children (`allow_unlisted: true`) by design — packages are open containers. ## How to create one ```luau asset.create("package", "<Name>") -- Creates: /zero/source/<Name>.package/ -- package.yaml (metadata scaffold) -- README.md (instance README template) -- `folder` places it in a subfolder of /source instead of the root: asset.create("package", "<Name>", { folder = "systems" }) ``` Then scaffold sub-assets inside it: ```luau local pkg = asset.resolve("<Name>.package") asset.create("component", "Spinner", { into = pkg }) asset.create("module", "util", { into = pkg }) ``` ## `package.yaml` ```yaml name: inkBlocks # optional; the folder stem when absent version: "1.0.3" description: "Ink and paper style blocks" dependencies: - { name: starterBlocks, version: "1.0.8" } - styleKit # a bare name states no version ``` `dependencies` lists the packages this package needs. Each entry's `name` is a reference the package records, the same kind of reference a `require` or an asset name in a data file makes: - **It resolves in the author's world.** Install the dependency here first (`zeromind.installAsset`); the entry then names the copy this world holds. A push refuses a package whose dependency resolves to nothing, naming it. - **An install brings it along.** Installing the package installs every dependency it lists, at the version this world holds when the package is pushed, under `/source/deps/<owner world>/`, deduplicated against what the installing world already holds. `zeromind.preview` lists each one before anything is written, and the install's `deps` lists what it brought. Uninstalling the package leaves a dependency that another installed package still uses. - **`version` is checked, not chosen.** A stated `version` has to equal the `version` the dependency's own `package.yaml` states in this world; `asset.validate` (and so the push) refuses the package naming both when they differ. To depend on another version, install that version here. An install lands one release of each dependency its closure names, so in a world the package is installed into, itself or as a dependency of the package installed, it runs the release the install placed, and `asset.validate` names a stated `version` that release does not state as a warning. ## How it operates 1. **Registration.** Writing `package.yaml` indexes the package with the package registry. 2. **Install.** A package is read before it is installed: `zm ls-tree @<guid>` in the shell lists what it contains, and `zm show @<guid>:<path>` and `zm grep <pattern> @<guid>` read it, so candidates are compared by what they do. The one that fits is installed by guid, the way every asset is: `zeromind_install` over the engine's MCP, or `tools.use("zeromind", "installAsset", <guid>)` inside the engine. The install writes the package's files (and the deps its `.refs` record, the packages its `package.yaml` lists under `dependencies` included) into this world's source, so its sub-assets resolve here. `tools.use("zeromind", "preview", <guid>)` reports what an install would write before it writes anything. 3. **Sub-asset resolution.** Because `.package` collapses in identity, sub-asset paths work whether the package folder is suffixed (`<Name>.package/<sub>`) or not (`<Name>/<sub>`). 4. **Updates.** `tools.use("zeromind", "updates")` lists installed content with upstream changes available; re-running the install pulls them. 5. **Metadata.** `package.yaml::name` overrides the folder stem if present (rare); `version` + `description` are surfaced in the package index. 6. **Hot reload.** Edits to sub-assets hot-reload as normal; edits to `package.yaml` reload package metadata. ## Discovery - `asset.list("package")` — every registered package. - `asset.inspect("<name>")` — sub-asset catalog, source, this type README. - `ls /zero/source/<Name>.package` lists the files the folder holds. - `library.list()` — the library assets registered in this world, including the ones packages under an installed library contribute. ## Authoring conventions - Name packages by their feature (`voxels`, `cameraRigs`, `dialogSystem`), not by their owner — the host library is the `@<lib>::` scope prefix. - Cluster cohesive sub-assets together. A "character controller" package should ship the controller component, its preset configs, its supporting modules, and a demo scene — not just the component. - Document the package's surface in `README.md` — what install installs, what each sub-asset does, how they relate. Agents reading `cat /zero/source/<Name>.package/README.md` get the full picture in one shot. - Version conservatively — breaking a package means breaking every world that installed it. Use semantic version bumps. ## Common pitfalls - **Missing `package.yaml`.** Without it the folder isn't recognized as a package even if it has a `.package/` suffix. - **A dependency named only by a string the code builds.** A package whose files reach another package only through a name assembled at runtime records no reference to it, so an install arrives without it. List that package under `dependencies` in `package.yaml`. - **Identity collapse.** Sub-asset paths skip the `.package` suffix. Don't include `.package` in `require` strings. ## Referencing inside a package: the `~` rule `~` means **this package**, resolved structurally from the referring file's own location. It is the only package-specific syntax. It is rename-safe (no package name is ever written) and library-agnostic (it never names the host library, so it survives `@builtin` being renamed or the package being mounted elsewhere). `~.tail` maps to `<pkg>.package/tail` from anywhere inside the package. | Referencing from | Use | Example | |---|---|---| | An asset/module **inside this package** | `~.tail` | `require("~.modules.myThing")`, `shader: "~.shaders.myThingBlend"` | | A **different package** under the same root | root-relative identity | `require("@root::systems.otherPkg.modules.x")` | | A **different library's** public API (a deliberate external dependency) | `@otherlib::…` | `require("@physics::modules.rigidbody")` | **Never write `@builtin::` (or any host-library name) to reference your own package** — that couples the package to the library it currently lives in and breaks if the library is renamed or the files move. Use `~.`. It works from Luau `require()` and from asset-reference strings in data files (a material's `mat.yaml` `shader:` field, a component's default asset ref); the engine resolves it against the referring file's own package. `asset.resolve` takes a `~.` name the same way, against the package of the file that calls it: `asset.resolve("~.materials.myThingStandard", "material")`. `~.` is the package-relative self-reference; `@root::` is the root-relative one (the library root, or the world source tree for non-library content). The `core/requiring-modules` guide covers the root model in full. A package that ships substantial functionality should include a `.guide` asset (a `<name>.guide/guide.md` folder anywhere under the package); the `guides` tool discovers it live, so collaborators find the system the way they find built-in guides. A package's test suite reaches the shared `Test` framework through its enclosing asset: `local Test = asset.containing(__FILE__).modules.shared` (`asset.containing` returns the deepest enclosing typed asset, the `.testSuite`, not the outer `.package`). ## Related types - Any of `.component`, `.module`, `.scene`, `.preset`, `.tool`, `.toolbox`, `.material`, `.shader`, `.style`, `.service`, `.importer` — packages bundle these. ## In the Inspector Package: the name, version and description package.yaml declares, how many things the package holds and what they are, and **Open** for package.yaml. A package.yaml that does not decode is listed under Problems with the decoder's error.
▲ 0↑ born
·
assettype · born here
❒asset
# procGraph (asset type) A `.procGraph` asset is a **procedural graph**: a description of how to make something, written as code, that can be evaluated over and over with different numbers. Its `init.luau` returns `proc.define(...)` — that source IS the asset, the way a `.procNode`'s `init.luau` is. ## Shape A `<name>.procGraph/` folder containing: - `init.luau`: the graph's definition. Returns `proc.define(function(g) … end)`, the graph named by its asset folder. - `graph.json` — the compiled form (`proc.graph.v1`), written by this type from `init.luau`. Generated, never hand-edited. - `README.md`, `.metadata` — the universal asset files. The type writes the graph's description and kind into `.metadata` on every compile. - `layout.json` (optional) — where the Inspector's node editor draws each node. - `preview.png` (optional) — the graph's rendered still, which search shows. `asset.create("procGraph", name)` scaffolds `init.luau` (a box with a `size` input, shown through `g.io.output` and returned as `mesh`), `README.md` and `.metadata`, and the first compile writes `graph.json`. ## Authoring Edit `init.luau`. The type recompiles on the write, rewrites `graph.json`, and every live `Generator` bound to the asset re-cooks from it — there is no build step between saving and seeing the result. A graph is built from more than its `init.luau`: a module the source requires while it builds (`onDependencyChange`), a file it reads with `vfs.read`, and a file a module it calls reads with `proc.read` are part of it, and so is every node it calls. When one of them changes, every `Generator` standing on the graph builds it again and cooks it on its next frame; nothing is written to the world for it. A recompile is cheap however large the graph: node results are keyed by content, so recompiling an unchanged node reuses its cooked output, and an edit invalidates only that node and the ones downstream of it. Changing the last step of a landscape does not re-run the erosion above it. Two words worth keeping apart, because both happen here: - **compile** — `init.luau` → `graph.json`. Produces the graph. - **cook** — each node performing its operation to produce a value. Runs the graph. Driven by a `Generator`, reported by `procgen.cooks`. ## Using one Through the ref rather than a path string: `ref:eval("mesh")` evaluates an output (`"output:mesh"` and `"node:<id>"` are targets too, and `ref:eval("mesh", { inputs = { size = 3 } })` overrides inputs for the call), `ref:inputs()` lists the knobs a Generator can override by name (`{ [name] = { type, default, min?, max?, ... } }`), `ref:outputs()` the sorted output names, `ref:validate()` type-checks it (an empty list when it is well-typed), and `ref:asOp()` wraps it so another graph can composite it as a node. `ref:graph()` builds the graph from `init.luau`; `ref:compile()` compiles it now and answers `{ id?, nodes, out }`; `ref:instantiate(target?, { params?, output?, ... })` puts it in the scene on a `Generator`; `ref:promote(opts?)` makes it a `.procNode`; `ref:preview(opts?)` renders its still and `ref:stillTime()` names the moment that still shows. Generated outputs (meshes, materials, textures, bundles) are persisted through their own asset types. ## Related - `@builtin::systems.procgen.proc` — the authoring + evaluation model. - `procgen.toolbox` — `preview`, `spawn`, `bake`, `validate`, `searchNodes`, `describeNode` and the wider tool family. ## In the Inspector The Inspector shows the graph as nodes and wires, and edits it there. Every graph input, op, graph used as a node and output is a node; each input port that nothing is wired into carries the value that drives it, and a click on a value edits it where it stands (typing, dragging a number, flipping a switch, choosing from a list). Drag a node to move it, drag from a port to another port to connect, drag a connected input away to take its wire off, Delete removes the selection. A node is added from the op search under the graph, or from the procGraph assets, which stand as nodes that open their own asset on a double click. The graph's inputs and outputs are nodes too: their name, type, default and range, and an output's domain, are values on them, and the Inputs and outputs section declares new ones. Describes is the sentence search finds the graph by. The Graph section also carries **Compile**, which compiles the graph now, and a link that opens `init.luau`. Every edit is written into `init.luau` with `proc.saveSource` and compiled by the type, so a live Generator re-cooks on it; the node positions are kept beside the graph in `layout.json`. The Result section scrubs the timeline of a graph that has one and shows what the selected node makes (`procgen.preview` with the target `node:<id>`), and the Preview section above it shows what the graph makes, live. The Node section describes the selected node.
▲ 0↑ born
·
assettype · born here
❒asset
# Scene (asset type) A scene is a saved, loadable snapshot of an entity scenegraph inside a world: the entity hierarchy, transforms, components, lighting, and a declared `player` intent, plus an auto-discovered startup script. A scene is the unit of "level" or "screen" — a title screen, a lobby, a gameplay area, and an end-of-game summary each get their own scene. Scenes load as **layers**. One root scene is active at a time; additional scenes can load additively as overlays on top of it. Each scene owns its own multiplayer relay room. Switching scenes is a local call: the client that makes it leaves the old scene's room and joins the new scene's room. ## When to use one - You want a savable, re-loadable snapshot of an entity scenegraph plus its lighting and player setup. - You want a runnable starting state for a level or screen. - You want a scenes-as-data flow: `layers.load("lobby")`, edit live, then `layers.active:save()` to publish the edits back to the scene. For a reusable entity assembly (a prop, a vehicle, a UI panel) that many scenes spawn into themselves, use a `.bundle`. A scene is a whole-world snapshot; a bundle is one prefab that lives inside scenes. ## Folder shape A scene asset is a folder ending in `.scene`. Its identity is the folder name with the suffix stripped (`Lobby.scene` → `Lobby`). - `scene.json` — the scenegraph: `entities[]`, lighting, and the top-level `player` intent. **Required.** Written by the engine — a build, a save, a human dragging something in. Not hand-edited. - `build.luau` — what the scene is made of, written as code. Runs while you author; saving bakes its result into `scene.json` (see Building a scene). - `entrypoint.luau`: the startup script. **Required.** Auto-discovered as a sibling of `scene.json`; define lifecycle callbacks here (see The entrypoint). - `<name>.<type>/` — an asset the build makes, authored here by `build.asset` (see The assets a build makes), alongside `.build.assets`, which records which `build.luau` produced each of them. - `prefabs/` — optional subfolder for scene-local bundles. - `scripts/` — optional subfolder for scene-local Luau helpers, required from `entrypoint.luau`. - `README.md`: notes about THIS scene: what it shows or plays and what it is for. **Required.** The general scene model lives here, in `guides { path: "types/scene" }`. - `.metadata`: **Required.** `scene.json` is version 7. It carries `"format": "scene"`, `"version": 7`, an `entities[]` array, and a top-level `"player"` string intent. ## The `player` intent Every scene declares how it handles players with a top-level `player` field in `scene.json`: - `"spawns"` — the scene carries an authored player setup, and the engine spawns a player for each connecting user from it. This is the default for a freshly created scene. - `"none"` — the scene spawns no player and authors no camera. Author your own Camera entity for the view (menus, UI-only screens, cinematics). ### How `"spawns"` works A `"spawns"` scene authors two things in `scene.json`: 1. A **PlayerPrototype** — an entity carrying the `PlayerPrototype` component, whose `body` field names a child entity (the body). The body carries an avatar (an `Asset` pointing at an avatar, e.g. `@builtin::avatars.humanoid`). A `CameraRig` child carries a `Camera` with a camera behavior (e.g. `orbital_follow`). The prototype root is authored `PrototypeOnly` so it exists as a clonable template. 2. A **PlayerSpawn** — an entity carrying the `PlayerSpawn` component, whose `prototype` field names the PlayerPrototype to instantiate and whose transform is where players appear. The scaffolded scene groups these under two organizing entities, `PlayerSetups` (holding the prototype) and `Spawns` (holding the spawn), so the authoring tree stays legible. On each user join — entering play, and each subsequent connect — the engine runs the spawn for that user: - It clones the PlayerPrototype subtree. - The clone root becomes the user's **internal identity** — a registry-only entity named `user` carrying the `UserIdentity` component. The identity is the anchor for who the player is; it has no world presence. - The body named by `PlayerPrototype.body` is adopted as the user's **avatar** — their visible presence in the world — and placed at the PlayerSpawn's world transform. Move the PlayerSpawn (or drag it in the editor) to set where players appear. - The `CameraRig`'s Camera follows the bound avatar. The player prototype is live in edit mode so you can see and adjust it. In play mode it is deactivated and marked internal — it stays a clonable source while each user gets their own clone. ### Reaching the live player The player surface lives on the root scene's registry, `layers.active.players`: - `players.localPlayer` — this client's player, a curated handle. - `players.localReady` — `true` once the local player's avatar is bound (or the scene opted its avatar out). - `players:list()` / `players:count()` — the players connected in this scene's room. - `players:get(userId)` — a connected player by account id. - `players:ownerOf(avatar)` — the player whose body is a given avatar. A player handle is a data record about who the player is, plus a link to their body: - `player.avatar` — the body's entity ref. Act on the body through it (`player.avatar.position`, raycasts, rig access). - `player.isLocal` — whether this client owns the player. - `player.ready` — whether a live avatar is bound. - `player.userId` / `player.identity` / `player.displayName` — the player's account identity. - `player.avatar = ref` — bind a live body entity as the player's body (assign nil to clear). To use a `.bundle` / `.avatar` asset, spawn it into the world first, then bind the resulting entity. The player's identity entity is the internal anchor; the handle exposes the body (`player.avatar`) and the player's data, and reaching for `.entity` / `.id` / `.component` raises with a redirect to `player.avatar`. ## Building a scene `build.luau` declares what the scene holds. It is ordinary engine code — `entity.spawn`, `component.add`, transform writes, `for` loops, a `require` of a module that computes a layout — and what it creates is what ends up in the scene. ```lua function content() for i = 0, 4 do local crate = entity.spawn("crate") crate.localPosition = { i * 2, 0.5, 0 } crate.component.add("Model", { model = asset.resolve("cube", "mesh") }) end end ``` The build runs while you author, in **edit** mode, and what it created lands in the live scene. Saving the scene bakes it into `scene.json`, which is what makes the entities durable content: a human can select and inspect them, they replicate, and they are there when the world opens without `build.luau` running at all. Play mode never runs it — in play the entities load from `scene.json` like anything else the scene holds. **Editing the file rebuilds the scene in place.** Writing `build.luau` is the signal; there is nothing to reload, and the rebuild saves. An entity keeps the id it had, so a reference to it — a spawn naming a prototype, another entity's component naming this one — survives every rebuild. Add a crate to the loop and the other four do not move. A write through `write_file`, `edit_file` or the engine's `bash` answers once the rebuild it started has finished, so what the rebuild landed and kept comes back on that answer as a notice, whose `message` is the report's summary line: ``` [info] a write to build.luau rebuilt the scene { content="6", scene="scenes.main", editorOnly="1", kept="1", message="build.luau against the scene: kept 1 value on 1 entity (crate_3); ..." } ``` A rebuild still running when the write's wait ends is named under the answer's `startedWork`, and its notice arrives on a later call. An edit saved while a rebuild is still running is an edit to code that rebuild has already read, so it gets a rebuild of its own once that one finishes, and says which it was: ``` [info] a write to build.luau arrived during a rebuild and was rebuilt after it { content="7", scene="scenes.main", editorOnly="1" } ``` Several edits saved during the same rebuild get the one run after it, which reads the file as it stands then. A scene that declares a build also runs it when it **loads** in edit, so the scene shows what the code says now, including an edit made while the world was closed. A load whose `.build.state` records the current script reads `scene.json` as the build and runs nothing. When the load does run it, a world's own scene saves the result, unless the scene holds unsaved edits: those stay the author's to keep or discard, and the file write waits for their save. A library scene (one under `/libs/`, the `@builtin` library included) is read by its load: the build lands in the live scene and its files stay as the library states them. Play reads `scene.json`, so it comes up without that build until `:build()` saves it. ### The two surfaces - `content()` — the scene's own entities. Present in play. - `editorOnly()` — entities present while authoring and absent in play. They carry the `EditorOnly` participation the runtime deactivates and hides when play begins, and they are baked too, so a collaborator opening the world sees the same ones. Anything an author needs to see and a player does not goes here — an alignment guide, a spacing marker, a debug volume. Both are optional. A scene with neither has no build. ### What a rebuild touches Only the entities the build itself placed. Anything a human dragged in, or a tool placed directly, is invisible to a rebuild and never moved or removed. Within what it owns, the build is authoritative: an entity the code stopped emitting is despawned, a component it stopped adding is removed. A plain rebuild keeps a hand edit to an entity the build placed: a value `build.luau` states the way the last build stated it is left as the scene holds it, so a move, a rename, an attribute, the active flag, the lifecycle mode, the replication scope or a component field changed since survives the rebuild, the one a write starts included. To see every such edit, ask the build for its report: ```lua local report = layers.active.asset:build({ save = false }) print(report.message) -- opens with one line counting all four lists ``` On a scene already holding what the build states it leaves nothing to save, and it answers `kept` (hand edits to entities the build placed), `driven` (fields another component writes at runtime, such as a sky orienting the sun), `handAdded` (components and attributes added by hand to built entities) and `handPlaced` (entities no build placed). An entity's render layer and its `hide()` switch are runtime state no build sets, so the lists leave them out; the answer states what the scene holds on both for the entities a build placed instead, in `renderLayers` (`{ entity, name, layer }`) and `hidden` (`{ entity, name }`), and its message counts them ("render layer set on 3 (...); hidden by hide() 0"). It also names the scene it compared: `client` is the client of the world it ran in (`user`, or a sub-client's id), since every client holds its own live scene, and `unsaved` lists the edits that scene held beyond the saved `scene.json` (the entries `sceneAuthoring.changes` lists), so an empty `unsaved` makes the report a statement about `scene.json`. To land `build.luau`'s values over the kept ones: ```lua layers.active.asset:build({ restate = true }) ``` A restate writes exactly the values `kept` names, so the scene's diff after one is the report. To bring a `handPlaced` entity into the build, delete the hand-made one and save the scene, then write it into `build.luau`: the write rebuilds at once in every client and the writing client saves its rebuild, so a delete left unsaved in another client can come back. A hand-made entity still standing under a name the build now places is reported with `builtTwin`, a second copy beside the build's, and the message names the calls that settle it. The message also compares the report against `scene.json` as saved: it names each unsaved edit and what it changed, and any entity whose live state differs from the scene's files with no unsaved edit behind it (a write this client has not taken), with the calls that take that client back to `scene.json` before anything saves from it. `guides { path: "core/scenes-as-code" }`, "What a rebuild touches", gives the shape of every entry and how `driven` and `restate` meet. The build writes its own name and each entity's place in the hierarchy onto the entity, and `scene.json` records that pair beside the entity's name and transform — which is why a rebuild after a reload, in a later session, lands on exactly the entities it placed the first time without anything having been remembered. ### When the file did not change `:build()` runs the build against what it resolves right now — for the case where something the builder *reads* changed and the file did not: a module it requires, an asset it resolves. After a write it is unnecessary; the write has already run it. ```lua layers.active.asset:build() -- rebuild and save layers.active.asset:build({ save = false }) ``` It answers with how many entities each surface placed — `{ content = 6, editorOnly = 1 }` — and with nil for a scene that has no `build.luau`. Called while a build for that scene is already running, it returns at once with `{ inFlight = true, scene, trigger, startedBy, message }` naming that build instead of starting a second one; `inFlight` is what tells the two answers apart. An operation the bake cannot hold is **refused** rather than applied. A build accepts what its records carry: entity lifecycle, transforms, hierarchy, names, visibility, active state, participation mode, network scope, attributes, and components with their public data. Anything else raises while the build runs, naming the operation and the build it answered to, instead of leaving the scene depending on something no reload brings back. When that happens the previous build stays exactly as it was. A runtime resource a build needs — a mesh it generates, a texture it writes — is made as an asset instead, below. Everything else a refusal names goes outside the builder, or into a component the builder attaches, which runs at play. ### The assets a build makes `build.asset(type, name, produce)` makes an asset the build's content names — a mesh a lathe produces, a texture a pattern writes. `produce` takes nothing and returns the creation parameters `asset.create` takes for that type; the call returns the asset's `AssetRef`, which is what a component field holds. ```lua function content() local tower = build.asset("mesh", "tower", function() local positions, indices = lathe(profile, 16) return { positions = positions, indices = indices } end) entity.spawn("tower").component.add("Model", { model = tower }) end ``` The asset is authored inside the scene's own folder — `Lobby.scene/tower.mesh` — and the scene records which `build.luau` produced it in `.build.assets`. So `produce` runs when the build script changed and never otherwise: a reload re-runs the build and reuses the asset, while editing the profile re-authors `tower.mesh` **in place**, keeping its path and its guid. That is what holds the reference — `scene.json` names assets by guid. For a part of a scene that several scenes place — or that one scene places many times with different settings — see `guides { path: "types/sceneModule" }`, which is the same idea with declared `inputs` a placement sets. `guides { path: "core/scenes-as-code" }` covers both. ## The entrypoint `entrypoint.luau` is the scene's **runtime** — what happens while the game is being played. What the scene *is* comes from `build.luau` above; nothing here has to construct it. `entrypoint.luau` is auto-discovered as a sibling of `scene.json`. The loader runs it in a fresh environment and folds its top-level `function name(...)` declarations into the matching scene lifecycle event. Define the callbacks the scene needs — the recognised set: - `onLoad()` — the scene loaded in **play** mode. Gameplay-start hook, runs on every connected client. - `onHostLoad()` — the scene loaded in **play** mode, on the client that owns the scene's synced content (the relay room creator; offline and single-player count as host). Fires once. Entities spawned here — and anywhere downstream — become synced automatically, so this is where shared world content is spawned: it runs on exactly one peer, and every other peer receives the entities from the relay snapshot. - `onEditLoad()` — the scene loaded in **edit** mode. Custom per-scene authoring tools. Writing this file while the scene is loaded in edit mode reloads its layer, so the new `onEditLoad` runs after the previous load's `onUnload`. - `onUnload()` — before the scene's entities are torn down. Extra cleanup; engine-managed teardown (entity despawn, resource release) runs separately. - `update(dt)` — per frame in play mode, while the gameplay clock runs. - `editorUpdate(dt)` — per frame in edit mode, running or paused. Play-paused ticks neither hook. The scene loader partitions these strictly on mode; a component's hooks of the same name read `engine.paused` instead, so the two rules differ — `man components` has that table. - `localPlayerReady(player)` — once the local player's avatar is ready. Gameplay wiring for the local player: attach state, bind UI, swap the avatar. The avatar is already placed at the PlayerSpawn, so this is for behavior, not positioning. - `playerJoined(player)` — a remote player joined this scene's room. Use for per-player UI (nameplates, greetings). The local player arrives through `localPlayerReady`. - `playerLeft(eid)` — a remote player left this scene's room. Receives the departed entity's id (the entity is already despawned). Each scene's entrypoint runs in its own environment, so two scenes can declare the same top-level names without clashing. Keep each callback short; push per-scene logic into `scripts/` modules and `require` them. ## Layers Scenes load through the `layers` namespace. - `layers.load(ref, opts?)` — load a scene. `ref` is a scene AssetRef or identity string. Without `opts.additive`, this is a **root** load: it replaces the current root scene. `opts`: - `additive` — load as an overlay alongside the current root instead of replacing it. - `persistent` — keep an additive overlay mounted across mode flips and root swaps. - `origin` — a `{x, y, z}` world offset for the overlay's entities. - `deferred` — spread the entity spawn across frames (for thousand-entity scenes); the load signals complete only once the scene has settled. - `layers.active` — the current root scene proxy (nil before any load). - `layers.list()` — every loaded layer (root + additive overlays). - `layers.find(ref)` / `layers.is_loaded(ref)` — look up a loaded layer by ref. - `layers.onLoad(cb)` / `layers.onUnload(cb)` / `layers.onBeforeLoad(cb)` — subscribe to every scene load / unload (distinct from a scene proxy's own `:on_load` / `:on_unload`, which fire only for that scene). A root scene carries the `players`, `camera`, and `settings` surfaces; additive overlays inherit the root's players and lighting and do not carry their own. ### The scene proxy `layers.active` (and `layers.find` / `layers.list` entries) returns a scene proxy: - Fields: `.guid` (canonical identity), `.name`, `.path`, `.asset`, `.additive`, `.visible`, `.state` (`"loading"` → `"loaded"` → `"ready"` → `"unloading"`), `.ready`, `.players`, `.camera`, `.settings`, `.entrypoint`. - `.camera` — a proxy over the scene's primary camera entity; read and write the live Camera component through it, and `.camera.behaviors._list()` enumerates the available camera behaviors. - `:save(opts?)` — publish the live scenegraph to canonical `scene.json` (see Saving). A convenience that forwards to the scene ASSET's `save` (`self.asset:save(opts)`): the proxy is the runtime view and owns nothing on disk, so persistence lives on the asset. - `:reload()`: unload and reload the same scene (a runtime respawn). A scene with a `build.luau` runs its build again and saves the scene, so `scene.json` holds what the reload built and the next play loads it; a library scene's rebuild lands in the live scene alone. - `:clearDirty()` — discard unsaved edits and respawn from canonical. Forwards to the scene asset's `discard` (`self.asset:discard(opts)`). - `:sceneAsset()` — the durable `AssetRef<scene>` this live layer maps to. - `:promoteDirty()` / `:writeDirty()` / `:hasDirty()` — manage the dirty overlay directly. - `:unload()` — despawn the layer and free its slot. - `:onReady(cb)` — fire once the scene reaches `ready` (latched: a late subscriber fires immediately). ## Multiplayer & relay rooms Every scene has its own relay room, keyed by the world guid, the boot profile, the mode, and the scene guid. Switching scenes with `layers.load` runs a room transition — leave the old room, tear down, join the destination scene's room — all on the client that made the call. Teardown of the old scene never leaks to peers in the new one. In play mode connected to a relay, the scene's entities are host-authoritative: only the room creator instantiates them (marked synced), and every joiner receives them from the relay snapshot rather than spawning their own. This is why shared world content belongs in `onHostLoad` — spawning it in `onLoad` would run on every peer and duplicate it. Each player's own avatar spawns per-user from the PlayerSpawn on every client. Edit mode and offline boots spawn locally and never auto-sync. ## Loading and saving **Loading** — `layers.load(ref)` for a root scene: 1. Despawns the current root scene's non-persistent entities. 2. Instantiates the entities from `scene.json` (including the player prototype and spawn for a `"spawns"` scene). 3. Applies lighting and sky. 4. Runs `entrypoint.luau` and fires lifecycle callbacks as their events occur. **Saving** — persistence lives on the scene ASSET. `sceneRef:save()` writes the scene's current state back to canonical `scene.json`; when the scene is loaded it captures the live scenegraph, and when it is not loaded it promotes the pending dirty overlay. `layers.active:save()` is the convenience form — it forwards to the active layer's mapped asset (`layers.active.asset:save()`). Writing canonical is the only path that does so: edit ↔ play cycles never save, so hitting play to test never overwrites the scene. Between saves, live edits accumulate in a per-scene dirty overlay that the loader merges on top of canonical. `sceneRef:discard()` throws the overlay away and restores the saved state — deleting the overlay, and respawning the live layer when the scene is loaded. It works whether or not the scene is loaded, because the overlay belongs to the asset, not the runtime layer. `layers.active:clearDirty()` forwards here. Saves capture entity data, not the entrypoint script — edits to `entrypoint.luau` and `scripts/` are always preserved. `opts.to` on `save`/`discard` targets a different scene ("save as"), taking either a bare name (`"level_2"`) or a full VFS path. **What a record states.** A component's record in `scene.json` holds the fields that instance's configuration states: the keys of the table it was added with (a `build.luau` call's own init table, or the record it was loaded from) and every field written since, through code, a tool or the inspector. A field nothing set stays out of the record and takes the component's declared default each time the scene loads, so changing that default reaches every entity that left the field to it. To have an entity follow the default again, remove the field from its record. A field set on a live entity after its record was made is a change the scene review names (`sceneAuthoring.changes` lists it as `+ Type.field = value`), and accepting it writes the field into the record. A stored value cannot be told apart from one an author chose, so a stored value loads and saves as it is, and a hot reload that changes a default one of them shadows names it. A stored field the component no longer declares is named by a `[component.add]` warning when the record loads and left out of the next save. ## Lighting Lights are ordinary entities: a directional light, an ambient light, and a sky are entities carrying `Light` / `ProceduralSky` components in `scene.json`. Author, move, and tune them like any other entity. If a scene is missing any of {directional light, ambient light, sky}, the loader adds a temporary default for the absent one so a scene never loads dark or skyless; the defaults are never saved into the scene. Scene-level lighting state that is not an entity — clear color and sky descriptor — lives under `layers.active.settings.lighting` (`clear_color`, `sky`); writing those fields updates the engine live. ## Modes Scenes load in both edit and play mode (see `man modes`). The mode governs behavior: - An entrypoint's `update(dt)` runs in play while the gameplay clock runs, and its `editorUpdate(dt)` runs in edit. A component's hooks of the same name follow the clock rather than the mode — `man components` has the four states that produces. - Player prototypes are live in edit and deactivated + internal in play, where each user instead gets a clone. `EditorOnly` entities follow the same edit-live / play-internal toggle. - `onLoad` / `onHostLoad` fire on a play-mode load; `onEditLoad` fires on an edit-mode load. ## How to create one ```luau asset.create("scene", "<Name>") -- Creates /zero/source/<Name>.scene/ with: -- build.luau where this scene's content is written. A new one starts -- with the sun / ambient / sky lighting and the "spawns" -- player setup, commented for editing — everything else the -- scene comes to hold is written here too. -- scene.json what that code produces, baked. -- entrypoint.luau commented lifecycle-callback stubs. ``` A freshly created scene has a player with a following camera on the first press of play. It carries no ground, so the first thing to author is what the player stands on — a `content()` line away in `build.luau`. ## Discovery - `asset.list("scene")` — every registered scene. - `asset.inspect("<name>")` — entity count, lighting summary, source path, and this type README. ## Authoring conventions - Keep static layout in `scene.json` — geometry, lights, props, the player prototype and spawn. - Keep dynamic setup in `entrypoint.luau` lifecycle callbacks — event listeners, gameplay state, services attached to spawned entities. - Spawn shared, synced world content from `onHostLoad`; spawn each player's own gameplay wiring from `localPlayerReady`. - Set the world's startup scene in `/.world_settings` — that is the scene the world boots into. - Y is up; -Z is forward. - Renaming the folder changes the scene's identity. References to the scene are recorded against the scene itself, so renaming or moving it does not break them. ## Related types - `.bundle` — reusable entity hierarchies that scenes spawn into themselves. - `.service`: a declarative content generator a scene can draw on. - `.world_settings` — picks the startup scene and world-level renderer / physics options. ## In the Inspector Selecting a scene opens its **Scene** section, read from `scene.json` without loading the scene: how many entities it holds, how many of them are roots (and their names), how players join and the file's format version when it states them, and whether the scene has edits not yet saved.
▲ 0↑ born
·
assettype · born here
❒asset
# Module (asset type) A module is a reusable, stateless (or globally-stateful) Luau library that other code pulls in with `require()`. Modules are the unit of factored-out logic in a world: helpers, math libraries, format parsers, registries, shared algorithms. ## When to use one - You have logic you want to share across multiple components, services, scenes, or tools. - You have a registry, lookup table, or shared cache that callers all read from / write to. - You want a stable API surface (`M.fn`) other code can depend on. If the logic is bound to one entity, use a `.component`. If you want a named UI of fields rather than functions, use a `.preset`. ## Where it lives - Source: `/zero/source/.../<name>.module/` - Identity: the source path with `/` written as `.` and each segment's type suffix dropped — `/zero/source/demo/beats.module` is `demo.beats`, and `/zero/source/kit.package/beats.module` is `kit.beats`, the container's name kept and its `.package` suffix gone. `asset.create` returns this string, `asset.resolve(...).identity` reads it back, and the `require` forms below write it as `<identity>`. - Folder shape: - `init.luau` (or `init.lua`) — module body. **Required.** Returns a table (conventionally named `M`). - `README.md` — instance-level documentation. **Required.** - `.metadata` — agent-editable tags + free-form fields. **Required.** ## How to create one ```luau asset.create("module", "<name>") -- Creates: /zero/source/<name>.module/ -- init.luau (canonical `local M = {} … return M`) -- README.md (instance README template) -- `folder` places it in a subfolder of /source, and that subfolder -- leads the identity: `{ folder = "lib" }` produces `lib.<name>`. -- `into` authors it inside a resolved container (a package, a toolbox), -- whose own identity leads the same way: asset.create("module", "<name>", { folder = "lib" }) asset.create("module", "<name>", { into = asset.resolve("myPkg.package") }) ``` ## How it operates 1. **Registration.** Writing `init.luau` into a `.module/` folder indexes the asset and registers the module path with the resolver. 2. **Loading.** The first `require("<identity>")` runs the file's body and caches the returned table. Subsequent requires from anywhere return the **same table** — this is the shared-state lever for "module-local" registries. The body runs in an environment of the module's own: a name it declares without `local` is readable by the module's own functions and by no other script, so an export reaches its callers through the returned table and nothing else. Requiring a component's folder runs its chunk the same way, once, and its `update`, `start` and `public` stay in that environment; a component runs on an entity through `entity(id).component.add(name)`. 3. **Hot reload.** Editing the file re-runs the module body and folds what it returns into the table already loaded, so that table keeps its identity: a caller that captured it with `require` reads the new source's functions and values through the reference it already holds, and a later `require` returns that same table. A key the new source drops goes away; a key something set at runtime stays. The body's own `local`s start again from their initial values, so state that must outlive an edit lives in `modules.state()` (`guides { path: "core/scripting-and-tasks" }`). 4. **Identity resolution.** A module is reached by its `<identity>`, and where the caller lives decides which spelling of it resolves. For a module in a **world**, from a caller in that same world — another module, a component, a scene entrypoint, or an `execute` chunk: - `require("<identity>")` — the identity on its own, resolved against the caller's own root. It carries every folder segment, so a module created with `{ folder = "demo" }` is `require("demo.beats")`. - `require("@root::<identity>")` — the same root-relative resolution, written out. - `require(".sibling")` — a module in the same folder, by its bare name; `..name` steps up one folder, `...name` two. Logs, stack traces and hot-reload notices name that same module `@local.source.<identity>` — its key under the world source root. The `<identity>` tail of that key is the form above, so a trace reading `@local.source.demo.beats` is `require("demo.beats")`. For a module in a **library** — content under `/zero/source/libs/@<lib>/` — `@<lib>::` addresses that library's root from anywhere: `require("@builtin::modules.transform")`. Mounting a world as a library moves its files under such a root and flips the caller root to `@<lib>::`, which is what keeps the root-relative forms above resolving across the move. ## Discovery - `asset.list("module")` — every registered module. - `asset.inspect("<name>")` — public functions, source path, this type README. - `ls /zero/source/<name>.module` lists the files the folder holds. ## Authoring conventions - Return a single `M` table from `init.luau`. Top-level statements with side effects run on first require — useful for one-time initialization, dangerous if they touch the engine before it's ready. - Write exported functions as `typed function`, not `function`: the argument types are enforced at the call and the checker knows the signature, so a caller's mistake is reported where they made it. - Annotate exported functions with `--!desc` / `--!arg` / `--!return` / `--!example` so the LSP, `tools.list`, and `asset.inspect` surface them. A function with no `--!desc` is reachable only by someone already reading this file. - Declare a VALUE with `Field.<kind>(default, mode, description)`, and a table whose members are reached through a metatable with `--!members <TypeName>` — the latter gives the surface its accepted member set, its type, and its documentation from one table. See `guides { path: "core/authoring" }` for all four rules and `modules/api/engine/entity.module/members.module` for a worked member table. - Keep module state in module-local upvalues or in `modules.state()`. A name the body declares without `local` lives in the module's environment, which every run of the module shares: a function the previous run left in place reads what the reload assigned. Module-locals start again from their initial values with each hot reload; the table `modules.state()` returns is the same table on both sides of every reload. - Prefer focused modules over kitchen-sink modules. If two halves of a module have no shared state, split them. ## Common pitfalls - **Cyclic requires.** A `require` chain that loops will return the partial table (the half built before the cycle was detected). Design for one-way dependencies. - **Engine-time side effects.** Don't `entity.spawn` at module top-level — the engine may not be ready. Expose an `M.init` and call it from a scene entrypoint. - **Hot-reload + module-local cache.** A module that caches expensive computation in upvalues loses that cache on reload — fine for dev, but be aware in performance work. - **`init.lua` vs `init.luau`.** Either works, `.luau` is canonical. - **Writing one while play runs.** A `/source` write made while play is running lands on the play shadow, and a guarded play-exit discards it unless it is kept. One `.module` write shadows `init.luau`, the `README.md` and the `.metadata` together. `vfs.write(path, bytes, { durable = true })` skips the shadow, and `vfs.promotePlayShadow` keeps what is already on it — the `core/vfs` guide has the model and what each route costs. ## Related types - `.component` — for entity-bound state + lifecycle hooks. - `.service` — generates content you don't have yet (a mesh, sound, texture, …) via a metered provider. - `.tool` — for a single agent-callable function with a YAML schema. - `.package` — to group several modules + components + scenes into one shippable folder. ## In the Inspector Exports: what the module exports (name, kind, signature), parsed from its source without running it, with **Check** (the LSP's diagnostics for its entry file) and **Open**.
▲ 0↑ born
·
assettype · born here
❒asset
# guide A guide is a single-file documentation asset: a `<name>.guide/` folder whose body is `guide.md`, surfaced through the `guides` MCP tool, the `man` shell builtin and the Docs panel. Drop one anywhere under `/zero/source/`, a `.package` included, and it shows beside the built-in guides. ## Linking guides together A markdown link in a guide is followed when it is clicked in the Docs panel: `[Bindings](controls-guide)` opens another guide by any name `guides read` takes, `[Slots](#save-slots)` a heading of the same guide (its text in lower case, punctuation removed, spaces turned into `-`), `[Slots](save-kit#save-slots)` a heading of another, and `[the module](../saveKit.module)` a file or asset, relative to the guide's own folder. A link the panel cannot follow says why above the guide. ## In the Inspector Guide: the guide's word count, its headings, and **Open in Docs**, which opens it in the Docs panel.
▲ 0↑ born
·
procnode · born here
❒asset
# model.columns `count` points at the origin, each carrying a `variant` number and the constant columns `c1` to `c<width>`, read from `values` one row of `width` numbers per point. The `ModelGraph` graph reads each column as a field, so a pose formula takes one constant per instance without a node per instance. | Input | Default | Meaning | |-------|---------|---------| | `count` | 1 | How many points. | | `width` | 0 | How many constant columns each point carries. | | `values` | `{}` | The constants, one row of `width` numbers per point. | | `variant` | `{}` | The piece number of each point, counted from 0; empty gives every point 0. | The node answers `points`.
▲ 0↑ born
·
assettype · born here
❒asset
# Nodebox (asset type) A nodebox is a namespace folder that groups related `.procNode/` children, the way a toolbox groups `.tool/` children. A node's name is its folder name inside its box: `points.nodebox/disc.procNode` is called `points.disc`, and nothing inside the node states that name. Moving or renaming a node is a VFS move that keeps its guid. ## Where it lives - Source: `<anywhere>/<family>.nodebox/`, usually inside a `.package`, an effect or a world's content. - Identity: the folders above it and `<family>` (`fx.points` for `fx/points.nodebox`; the `.nodebox` suffix strips). A graph calls its nodes by `<family>.<node>` alone. - Folder shape (open child set): - `README.md`: what the family is for. Required. - `.metadata`: description and tags. Required. It also states where the box's nodes work: `context` (one of `proc.registry.contexts()`: `geometry`, `field`, `value`, `sim`, `raster`, `material`, `prefab`) and, when every node of the box reads the scene or assets beside its inputs or writes them beside its outputs, `pulls` / `pushes` (`scene` or `asset`). A node that works elsewhere states its own in its `.metadata`. `procgen` `describeNode` and the `context`, `pulls` and `pushes` filters of `searchNodes` read them. - `<node>.procNode/`: any number of nodes. ## How a graph reaches a node `g.<family>.<node>(args)` resolves the node by its asset identity: the box and the folder name together (`g.points.disc`), a path (`g["/zero/source/fx/ring.procNode"]`), `~` (the nearest enclosing package, effect or world root: `g["~/ring"]`) or a short name the asset system resolves (`g.disc`). A name that matches two nodes is an error naming both; a name that matches none is an error naming the closest nodes. Each call is recorded in the graph's reference table by the node's guid. ## How to create one ```luau asset.create("nodebox", "points", { folder = "fx" }) local box = asset.resolve("points.nodebox") asset.create("procNode", "disc", { into = box }) ``` ## Discovery - `asset.list("nodebox")`: every box. - `asset.inspect("points")`: the nodes in it and what each does. - `asset.list("procNode")`: every node, in or out of a box. ## In the Inspector Nodes: how many nodes the box holds, each node's full name and what it does, and a link to each.
▲ 0↑ born
·
procnode · born here
❒asset
# shape.box A box centred on the origin with flat faces. In a scene: `BoxGeometry(width, height, depth)`. | Input | Default | Meaning | |-------|---------|---------| | `width` | 1 | Its size along X. | | `height` | 1 | Its size along Y. | | `depth` | 1 | Its size along Z. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau BoxGeometry(2, 1, 1.2):round(0.1) ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.buffer A mesh from arrays: positions, optional triangle indices, optional normals and uvs. Without normals they are computed, smooth or flat. Indices out of range and lists of the wrong length are refused by name. In a scene: `BufferGeometry() with setAttribute('position' | 'normal' | 'uv', Float32BufferAttribute(array, itemSize)), setIndex(list) and computeVertexNormals()`. | Input | Default | Meaning | |-------|---------|---------| | `positions` | {} | Flat list of vertex positions, three numbers per vertex. | | `indices` | {} | Flat list of triangle corner indices from 0, three per triangle; empty takes the vertices in order, three at a time. | | `normals` | {} | Flat list of vertex normals, three per vertex; empty computes them. | | `uvs` | {} | Flat list of texture coordinates, two per vertex; empty gives none. | | `smooth` | true | With no normals given: true shares each vertex's normal across the triangles that meet at it, false gives every triangle its own. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau local geometry = BufferGeometry() geometry:setAttribute('position', Float32BufferAttribute({ 0, 0, 0, 1, 0, 0, 0, 1, 0 }, 3)) ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.capsule A capsule along Y: a cylinder of `length` with a hemisphere on each end. In a scene: `CapsuleGeometry(radius, length, capSegments, radialSegments)`. | Input | Default | Meaning | |-------|---------|---------| | `radius` | 0.5 | The radius of the cylinder and the caps. | | `length` | 1 | The length of the straight middle part. | | `capSegments` | 4 | Segments along each cap's arc. | | `radialSegments` | 16 | Segments around. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau CapsuleGeometry(0.35, 0.9, 6, 20) ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.circle A flat disc in the XY plane facing +Z. In a scene: `CircleGeometry(radius, segments)`. | Input | Default | Meaning | |-------|---------|---------| | `radius` | 1 | Its radius. | | `segments` | 32 | Segments round its edge. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau CircleGeometry(0.5, 48) ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.cylinder A cylinder along Y, capped, with different radii at its two ends: a cone when one is 0. The fifth argument of `CylinderGeometry` and the fourth of `ConeGeometry` is `heightSegments`, in the place three.js has it; the side is one band. In a scene: `CylinderGeometry(radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded) and ConeGeometry(radius, height, radialSegments, heightSegments, openEnded)`. | Input | Default | Meaning | |-------|---------|---------| | `radiusTop` | 1 | The radius of its top. | | `radiusBottom` | 1 | The radius of its bottom. | | `height` | 1 | Its length along Y. | | `radialSegments` | 32 | How many sides it has round. | | `openEnded` | false | Whether the top and bottom are left open, as a pipe or a liner. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau CylinderGeometry(0.3, 0.5, 1.4, 24):bend(0.5) ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.extrude A 2D shape path extruded along +Z with flat caps. In a scene: `ExtrudeGeometry(shape, { depth, curveSegments })`. | Input | Default | Meaning | |-------|---------|---------| | `shape` | {} | The outline as path commands: `{ 'moveTo', x, y }`, `{ 'lineTo', x, y }`, `{ 'arc', cx, cy, r, a0, a1, clockwise }` and the rest. A `Shape` writes them. | | `depth` | 1 | How far it extrudes along +Z. | | `curveSegments` | 12 | Segments used for curved path commands. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau ExtrudeGeometry(RoundedRectShape(1, 0.6, 0.1), { depth = 0.2 }) ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.flatShape A flat, filled 2D shape in the XY plane facing +Z, from path commands. In a scene: `ShapeGeometry(shape, curveSegments)`. | Input | Default | Meaning | |-------|---------|---------| | `shape` | {} | The outline as path commands, as for `extrude`. | | `curveSegments` | 12 | Segments used for curved path commands. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau ShapeGeometry(EllipseShape(0.5, 0.3)) ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.lathe A surface of revolution: a profile of `{ radius, y }` points revolved around Y. In a scene: `LatheGeometry(points, segments)`. | Input | Default | Meaning | |-------|---------|---------| | `points` | {} | The profile: a list of `{ radius, y }` pairs. | | `segments` | 12 | Segments around the axis. | | `phiStart` | 0 | Where the revolution starts, in radians. | | `phiLength` | 2 pi | How far it revolves, in radians. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau LatheGeometry({ Vector3(0, 0), Vector3(0.4, 0.1), Vector3(0.3, 0.8), Vector3(0, 1) }, 32) ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.plane A flat rectangle in the XY plane facing +Z, centred on the origin. In a scene: `PlaneGeometry(width, height, widthSegments, heightSegments)`. | Input | Default | Meaning | |-------|---------|---------| | `width` | 1 | Its size along X. | | `height` | 1 | Its size along Y. | | `widthSegments` | 1 | Segments along X. | | `heightSegments` | 1 | Segments along Y. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau PlaneGeometry(2, 2, 16, 16):bend(0.3) ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.polyhedron A regular polyhedron inscribed in a sphere. With `detail` 0 its faces are flat; above 0 each face is split and the surface rounds toward the sphere. In a scene: `TetrahedronGeometry, OctahedronGeometry, IcosahedronGeometry and DodecahedronGeometry (radius, detail)`. | Input | Default | Meaning | |-------|---------|---------| | `kind` | icosahedron | Which solid: tetrahedron, octahedron, icosahedron or dodecahedron. | | `radius` | 1 | The radius of the sphere it is inscribed in. | | `detail` | 0 | How many extra points each edge gets. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau IcosahedronGeometry(0.6, 1):smooth() ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.ring A flat annulus in the XY plane facing +Z. In a scene: `RingGeometry(innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength)`. | Input | Default | Meaning | |-------|---------|---------| | `innerRadius` | 0.5 | The radius of the hole. | | `outerRadius` | 1 | The outer radius. | | `thetaSegments` | 32 | Segments around. | | `phiSegments` | 1 | Segments from the inner to the outer radius. | | `thetaStart` | 0 | Where the arc starts, in radians. | | `thetaLength` | 2 pi | How far the arc runs, in radians. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau RingGeometry(0.3, 0.5, 48) ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.sphere A UV sphere. In a scene: `SphereGeometry(radius, widthSegments, heightSegments)`. | Input | Default | Meaning | |-------|---------|---------| | `radius` | 1 | Its radius. | | `widthSegments` | 32 | Segments around its equator. | | `heightSegments` | 16 | Segments from pole to pole. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau SphereGeometry(0.5, 32, 16):taper(0.4) ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.torus A torus in the XY plane around Z. In a scene: `TorusGeometry(radius, tube, radialSegments, tubularSegments, arc)`. | Input | Default | Meaning | |-------|---------|---------| | `radius` | 1 | The radius of the ring. | | `tube` | 0.4 | The radius of the tube. | | `radialSegments` | 12 | Segments around the tube. | | `tubularSegments` | 48 | Segments around the ring. | | `arc` | 2 pi | How much of the ring, in radians. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau TorusGeometry(0.255, 0.105, 14, 32) ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.torusKnot A (p, q) torus knot: a tube swept along a knot that winds `p` times around its axis and `q` times through the hole. In a scene: `TorusKnotGeometry(radius, tube, tubularSegments, radialSegments, p, q)`. | Input | Default | Meaning | |-------|---------|---------| | `radius` | 1 | The radius of the knot's overall torus. | | `tube` | 0.3 | The radius of the tube. | | `tubularSegments` | 64 | Segments along the knot. | | `radialSegments` | 8 | Segments around the tube. | | `p` | 2 | How many times it winds around its axis. | | `q` | 3 | How many times it winds through the hole. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau TorusKnotGeometry(0.45, 0.14, 96, 10, 2, 3) ```
▲ 0↑ born
·
procnode · born here
❒asset
# shape.tube A circle swept along a curve: pipes, springs, hoses and headers. In a scene: `TubeGeometry(path, tubularSegments, radius, radialSegments, closed)`. | Input | Default | Meaning | |-------|---------|---------| | `curve` | {} | The curve: `{ type = 'catmullrom', points = {...} }` or `{ type = 'helix', radius, turns, height }`. `CatmullRomCurve3` and `HelixCurve` write them. | | `tubularSegments` | 64 | Segments along the curve. | | `radius` | 1 | The radius of the tube. | | `radialSegments` | 8 | Segments around the tube. | | `closed` | false | Whether the curve closes on itself. | The node answers `geometry`: a mesh with positions, normals and uvs. Its body is a call into the module in its own folder, so a graph of many parts cooks without a device dispatch per shape. ```luau TubeGeometry(CatmullRomCurve3({ Vector3(0, 0, 0), Vector3(1, 0.4, 0), Vector3(2, 0, 0) }), 48, 0.05, 8) ```
▲ 0↑ born
·
assettype · born here
❒asset
# Scene light (asset type) A scene light is one light that reaches the whole scene alike, as an asset. It is one position-independent `Light` (`directional`, `ambient` or `distant`, the kinds `lighting.isPositionIndependent` answers for) described in `sceneLight.yaml`, and it implements `applicable`: applying it puts that light in force for the applier. ## Where it lives - Source: `<name>.sceneLight/` - Identity: `<name>` (the `.sceneLight` suffix strips from the identity) - Folder shape: - `sceneLight.yaml`: the light. **Required.** - `README.md`: what light it puts on a scene. **Required.** - `.metadata`: `description` and `tags`. **Required.** ```yaml # moonFill.sceneLight / sceneLight.yaml kind: distant direction: [0.3, -0.5, 0.4] color: [0.6, 0.7, 1.0] intensity: 0.3 ``` ## Parameters Its parameters are the `Light` component's own fields for the light, with their descriptors (`intensity`, `colorR`/`colorG`/`colorB`, `directionX`/`Y`/`Z`, `castsShadows`, `lightChannels`, `mobility`), defaulting to what `sceneLight.yaml` states, and three of its own: - `followSky`: whether the sky orients this light (a `directional` or `distant` one). A sky that drives the sun (a procedural backdrop) then writes the light's direction from its hour, and its colour and intensity as the stated ones multiplied by the curve of the sun's elevation: the stated `intensity` is the noon peak, reached from 30° up; toward the horizon the light dims and warms (about 0.3 of the peak at 7°), and below it the intensity is 0. A sun that should follow the sky states `followSky: true` and no direction. - `skyOffset`: where a following light stands from the sun, `[yaw, pitch]` in degrees. Yaw turns it about the vertical, so `[180, 0]` is a fill from the side opposite the sun at the sun's elevation; pitch raises it above the sun. The curve is the sun's, so a fill dims with the sun and is out at night. - `followSkyIntensity` (default `true`): whether a following light takes its intensity from the sky as well as its direction and colour. `true` puts the sun's curve on the stated intensity, as above. `false` keeps the stated intensity while the light stands above the horizon (its own elevation, after `skyOffset`) and 0 below it; the direction and the colour still come from the sky. A sun follows with it `true`; a fill or a rim that should hold its strength through dusk states it `false`. After dark a following light stands at the moon the sky draws, opposite the sun: with `true` it is out, with `false` it is moonlight at the intensity it states. A cool fill for a dusk scene: it stands opposite the sun, a little higher, takes the sky's direction and its warm-to-cool colour, and lands at the 0.9 it states at 17:42, where with `followSkyIntensity` true it would land near 0.18. ```yaml # harbourFill.sceneLight / sceneLight.yaml kind: distant color: [0.5, 0.6, 1.0] intensity: 0.9 castsShadows: false followSky: true followSkyIntensity: false skyOffset: [180, 12] ``` What a following light lands at is not what it states. A placed setup's `SceneSetup:members()` reports, for such a member, `landed` (its intensity, colour and direction now) beside `stated`, and `SceneSetup:get(path)` carries `landed` beside `value` for each of those parameters; `SceneSetup:set(path, value)` returns that read, so setting `fill/intensity` answers what it lands at straight away, and the setup's card shows it on the row (`0.9 → lands at 0.18 at 17:42`). `ref:landed(owner)` is the same answer for one application. ## Applying it Each application spawns a temporary entity of its own (`ref:entityOf(owner)`) and puts a `Light` of the asset's kind on it; it publishes itself as the sun or the ambient term the way every `Light` does, and the last to publish holds it. Dropping the application removes the `Light` and the entity. The `ApplyState` reports `held` while another light holds its kind (`heldBy` names that application's owner, or the holding entity), and a notice when an ambient term is as bright as half the sun or more, which flattens the scene's shading. A write the lighting API makes to the light (`lighting.setSun`, `lighting.setAmbient`, `sky.setSunDirection`) lands on the application, through its owner's writer when it handed one. A kind that lights from where its entity stands (`point`, `spot`) is refused by name (`sceneLight.kind`).
▲ 0↑ born
·
assettype · born here
❒asset
# Scene setup (asset type) A scene setup configures a scene as a whole in one asset: its sun and ambient light, its fog, its render features and post effects, or any other effect that applies to a scene. It is an ordered list of **members**, each an asset whose type implements `applicable`, with the values the setup states for them. Placed in a scene, it applies every member; selecting the placement shows every parameter of every member, and an edit made there is that placement's own. ## Where it lives - Source: `<name>.sceneSetup/` - Identity: `<name>` (the `.sceneSetup` suffix strips from the identity) - Folder shape: - `sceneSetup.yaml`: the definition. **Required.** - `README.md`: what the setup puts on a scene. **Required.** - `.metadata`: `description` and `tags`. **Required.** - `preview.png`: its picture. Optional. ## The definition ```yaml members: - id: sun # required, ^[a-z][A-Za-z0-9_]*$, unique source: "./sun.sceneLight" # any asset that implements applicable - id: ambient source: "./fill.sceneLight" values: { intensity: 0.12 } # values for the member's parameters - id: fog source: "<a fog render feature>" enabled: false # optional, default true - id: grade source: "./grade.postEffect" values: { saturation: 0.82, contrast: 1.12 } ``` A member's `values` are the values this setup states for that member; the member asset keeps its own, and another holder of it states its own. A member's `source` is one of: - an identity: `lighting.harbour_fill`, `@builtin::<library>.<name>`. It resolves among the assets that can be members, so a name another kind of asset also answers to reaches the member; - a path with its type suffix: absolute (`/source/lighting/harbour_fill.sceneLight`), from the folder holding this setup (`harbour_fill.sceneLight`, `./harbour_fill.sceneLight`, `../shared/fill.sceneLight`), or from the world's source folder (`lighting/harbour_fill.sceneLight`). A path starting `./` or `../` is read from the setup's folder alone. An identity drops the type suffix, so `harbour_dusk.sky` and `harbour_dusk.sceneSetup` in one folder share `lighting.harbour_dusk`; a member naming that identity is skipped as `sceneSetup.member.ambiguous`, which names both assets, and its path names the one meant. A source that names nothing is `sceneSetup.member.missing`, and its values and overrides are kept until it resolves. A member whose type does not implement `applicable` is refused by name (`sceneSetup.member.unsupported`). A key the engine does not read is a warning. ## Parameters and paths A setup's parameters are its members': `<member id>/<name>` (`fog/density`), a nested member's under its path (`look/reflections/intensity`), and `<member id>/@enabled` for every member. `@lit` (true by default) says whether the scene renders lit; off, every surface shows its own colour with no light on it, for a stylised game or a menu. `asset.schema(setupRef)` lists every path with the member's own Field descriptor. A setup that nests another names its parameters through the member id it gives the nested setup: a setup whose member `base` is another setup has `base/fog/density` for that setup's `fog/density`, and a placement sets `base/fog/density`. A path that is no parameter is refused naming the paths that end in it. The value a member receives, for each parameter, first present wins: the placement's override, the outermost setup's `values`, each inner setup's `values`, the member asset's live value, then its saved value. ## Placing and tuning ```lua -- A world's setup by its identity (`lighting/harbour_dusk.sceneSetup` is -- `lighting.harbour_dusk`), or by its absolute path, `/source/lighting/harbour_dusk.sceneSetup`. local root = asset.resolve("lighting.harbour_dusk", "sceneSetup"):instantiate(nil, { name = "lighting" }) local setup = root.component.get("SceneSetup") setup:set("fog/density", 0.05) -- this placement's override setup:set("fog/density", { scale = 3.75 }) -- relative: the setup's density times 3.75 setup:set("fog/heightFalloff", { offset = -0.06 }) -- relative: the setup's value plus -0.06 setup:set("ao/@enabled", true) -- turns a member on for this placement setup:reset("fog/density") -- back to what the setup says for path, m in pairs(setup:members()) do print(path, m.state.status) end ``` The placed root holds the `Asset` component (its `source` is the setup) and the `SceneSetup` component (this placement's `overrides`); the scene stores nothing of any member. Removing the `Asset` removes the `SceneSetup`, and every member's application goes with it. A relative override (`{ scale = n }` or `{ offset = n }`, numeric parameters only) lands at the value the setup supplies times `scale` or plus `offset`, checked against the parameter's descriptor, and follows that value: edit the setup's fog density and every placement scaling it moves with it. It is saved and synced like any override, and the Inspector shows it as relative. **Where each value comes from.** `setup:get(path)` and each member's `values` in `setup:members()` say it: `origin` is `override` (this placement's, with `relative` and `supplied` for a relative one), `definition` (with `definedBy`, the setup stating it, and `definedAt`, the path it states it at there, so a value inherited through a nested setup names that setup), `live` (the member asset's live value) or `saved`. One line proves what a placement shares: ```lua for name, v in pairs(setup:members()["fog"].values) do print(name, v.value, v.origin, v.definedBy) end ``` **A light that follows the sky lands at what the sky makes of it.** A sun, a fill or a rim that follows the sky (`followSky`) states its intensity as its noon peak: the sky gives it that intensity with the sun 30° up or higher and dims it toward the horizon, to about a third at 7° and 0 below it. So a dusk sun stated at 3.2 at 17:51 lands near 0.4. `setup:get(path).landed` (and `setup:set(path, value)`, which returns the same read) is what it lands at now, beside `value`, what it states; the card shows `3.2 → lands at 0.4 at 17:51` on the row. The member's `state.notice` in `setup:members()` names a light the sky dims to under a third of what it states, a distant fill that lands brighter than the sun it is meant to support, and an ambient term at half the sun or more. Raise the stated intensity, move the hour, or, for a fill or a rim, set `followSkyIntensity` to `false` so it keeps what it states. **`set` in edit mode is a scene edit.** In edit mode on a world scene, a `set` is an authored edit of the scene, recorded and saved: it holds over what `build.luau` states until it is reset or released (`sceneAuthoring` `releaseAuthored`). A `reset` that leaves the placement with no override records nothing and releases the edit an earlier `set` recorded. Overrides stated in `build.luau` are the build's own. ## Auditioning another setup Two placements, or a placement and an application from code, each apply their own sun, ambient term and fog; the effect decides which is in force (the light-tie rule for lights), so an application beside a placed setup reports the members another application holds as `held`, with `heldBy`, and its `ApplyState.notice` names each held member, its asset and its holder. To see a setup in place of the placed one: - audition it on the placement, a preview for the session: `setup:audition(asset.resolve("lighting.harbour_night", "sceneSetup"))` applies it in the placed setup's place and records nothing; `setup:endAudition()` (or the card's End audition, a flip, a reload) puts the placement's own setup back. `set` and `reset` are refused while it lasts; - apply it from code (below): it holds over the placement across flips until it is dropped; - read its preview: `preview.png` lights the reference subject `@builtin::preview.subjects.lookdev` with the setup alone, its exposure fit so a night setup reads (below); - point the placement's `Asset` source at it (a scene edit that stays; `releaseAuthored` returns the placement to `build.luau`'s setup); - or apply it in a scene with no setup placed, such as a scratch scene. ## Applying it from code A setup implements `applicable` itself, so it can be applied for an owner like any member: `setupRef:as("applicable"):apply(owner, values)` starts an application and `setupRef:as("applicable"):drop(owner)` ends it. Each member is applied with the owner `"<owner>/<member id>"`. - **It takes the effects that hold one at a time.** The scene's sun, its ambient term, its sky and each render feature's settings are held by one application at a time: of the applications standing, the newest to state something holds it, so an application made over a placed setup holds them while it stands, and the placement's members report `held` by it. - **It stays in force until it is dropped,** across edit/play flips and device rebuilds. - **Its drop hands every effect back** to the application before it: the placement's own, or the scene's own lights. Which of two suns or two fogs is in force is the effect's own to decide; the setup decides nothing about its members. An audition (above) is a preview for the session that a flip ends; an application from code stands until it is dropped. ```lua local night = asset.resolve("lighting.harbour_night", "sceneSetup") night:as("applicable"):apply("myGame:time", {}) -- night holds over the placement -- … flips, rebuilds … night:as("applicable"):drop("myGame:time") -- the placement's lighting is back ``` ## Checking one `asset.validate(setupRef)` (an engine API function) reads the definition and every value and returns `{ ok, problems }`: each diagnostic (`sceneSetup.member.missing` and the rest) with its code, severity, path and message. A problem of severity `error` refuses a push. ## Its picture A setup's `preview.png` shows its own lighting on a fixed reference subject, `@builtin::preview.subjects.lookdev` (a grey ground, a white diffuse sphere, a chrome sphere and a grey card). The preview studio stands the subject and applies the setup to the world with the owner `preview` for the shot, so its sun, sky and effects are the ones in force, then drops it, which hands every effect back to the scene's own holder. A frame that reads darker than mid grey (a night setup) is shot with its exposure opened up for the picture alone, by up to eight stops, so the night look reads without the setup changing. For those frames the world shows the setup's lighting, so the picture renders only on an explicit request (`preview.writePreview`, `assets.generatePreviews`, staging) and never from the preview queue or a live preview; the last picture stands otherwise. ## Make one ```lua asset.create("sceneSetup", "dusk", { members = { { id = "sun", source = "./sun.sceneLight" }, { id = "ambient", source = "./fill.sceneLight", values = { intensity = 0.1 } }, } }) ```
▲ 0↑ born
·
assettype · born here
❒asset
# Sky (asset type) A sky is the sky of a scene in one asset: a composition of **members**, each an asset whose type implements `applicable`, with the values the sky states for them. One of them is a **backdrop**, a render feature that writes the scene's `Sky` row (`@builtin::systems.sky.backdrops.procedural`, `@builtin::systems.sky.backdrops.material`, or a creator's own); the others are whatever else belongs to the sky, such as clouds. A sky has no parameter of its own: its parameters are its members', by path (`backdrop/timeOfDay`, `clouds/coverage`, `clouds/@enabled`). A member whose parameters follow from content its values name has those too: a material backdrop's parameters are its own (`material`, `exposure`, `rotation`) and the shader properties of the material it names (`backdrop/zenith`, `backdrop/glow_size`), each with the material's value as its default. ## Where it lives - Source: `<name>.sky/` - Identity: `<name>` (the `.sky` suffix strips from the identity) - Folder shape: - `sky.yaml`: the definition. **Required.** - `README.md`: what the sky draws. **Required.** - `.metadata`: `description` and `tags`. **Required.** - `preview.png`: its picture. Optional. ## The definition ```yaml members: - id: backdrop source: "@builtin::systems.sky.backdrops.procedural" values: { timeOfDay: 18.5, zenithColor: [0.2, 0.1, 0.3], horizonColor: [0.9, 0.4, 0.2], horizonHeight: 2 } - id: clouds source: "@builtin::systems.volumetrics.volumetricSky" # Omitted values use the package's complete default weather preset. ``` It is read the way a scene setup's is: the same member grammar, the same diagnostics, nested compositions under their member id. A member's `source` is an identity (`skies.parts.haze`, `@builtin::systems.sky.backdrops.procedural`) or a path with its type suffix: absolute (`/source/skies/parts/haze.renderFeature`), from the folder holding this sky (`haze.renderFeature`, `./haze.renderFeature`, `../parts/haze.renderFeature`) or from the world's source folder (`skies/parts/haze.renderFeature`). An identity drops the type suffix, so a sky and a scene setup of one name in one folder share it; their paths name each apart. The scene setup type's README has the whole grammar. A volumetric cloud member's weather is its `preset` table, and a value for it states the whole table. ## Using one A sky implements `applicable`: applied, it applies every member for the owner: ```lua local dusk = asset.resolve("my-dusk", "sky") dusk:as("applicable"):apply("myEntity:sky", { ["backdrop/timeOfDay"] = 19 }) local drawn = sky.drawn() -- { entity, source = dusk, description } dusk:as("applicable"):drop("myEntity:sky") ``` `sky.drawn().description` (the sky's own `describeSky`) is `{ material, timeOfDay, sunDirection, members, notice? }`, built from what is drawn; `notice` is what a member states about the settings it runs, by member path. A procedural backdrop draws its base colours (`zenithColor`, `horizonColor`, `groundColor`) in the shape `horizonHeight` gives them: the elevation in degrees where the sky is halfway from the horizon colour to the zenith colour (default 7.933). A palette whose horizon colour is a band, such as a sunset's orange under a violet sky, lowers it (to 2, say) so the zenith colour shows at eye level. The backdrop draws them while the sun is high and its night and dawn tint sets as the sun sinks, as far as `nightStrength` and `dawnStrength` say; a sky that holds one hour states its look in the base colours with both strengths at 0, and the notice names a set that masks the base colours at the hour drawn. The backdrop's README has the table of which set shows at which hour. A light that follows the sky (`lighting.followSky`) is oriented by a procedural backdrop's hour. **Moon and moonlight.** A procedural backdrop draws its moon opposite its sun, at the hour it draws. After dark a light that follows the sky stands at that moon: a sun that takes its intensity from the sky is out, and a light that keeps its own (`followSkyIntensity: false`) is moonlight at the intensity it states, from where the moon is drawn. A night setup keeps the two together by giving its moonlight `followSky: true`, `followSkyIntensity: false` and a moonlight intensity and colour (a setup nesting a day setup sets its sun's `followSkyIntensity` to `false` and its intensity to the moon's), so the light stands where the moon is drawn. ## A material sky's shader values A sky drawn by a material takes that material's shader properties as parameters, so a sky, a setup nesting it, or a placement states them by path like any other value, and a setup's card lists them: ```yaml # night_variant.sceneSetup/sceneSetup.yaml: the base setup, its sky's glow raised members: - id: base source: "./base.sceneSetup" values: "sky/backdrop/glow_intensity": 2.5 "sky/backdrop/zenith": [0.02, 0.01, 0.08, 1] ``` The backdrop draws the material itself while every value stated for it is the material's own, and a runtime copy of the material with the stated values laid over its own once one differs; the material asset is not written. Two applications of one backdrop are arbitrated the way every render feature's are: the newest that states something new is in force, and dropping it brings back the values of the one before it. ## Making one ```lua asset.create("sky", "aurora", { members = { { id = "backdrop", source = "@builtin::systems.sky.backdrops.material", values = { material = "my-aurora-material", exposure = 1.2 } }, } }) ```
▲ 0↑ born
·
assettype · born here
❒asset
# assetType (asset type) An asset type says what a kind of asset is: the files an asset of the kind is made of, the code that gives it behaviour, the interface a person uses to work with it, and how it is found, pictured and checked. A `<typename>.assetType/` folder declares a type called `<typename>`, and every `<name>.<typename>/` folder is an asset of it. `assetType` is itself a type, so a type is an asset like any other: it is created, versioned, installed and contributed the same way. ## Making a type `asset.create("assetType", "<typename>")` scaffolds a type. The type registers the moment its folder is written, anywhere under `/zero/source/`, and from then on `<name>.<typename>/` folders are its assets. An asset of a type that is not registered yet is not an asset, so make the type first. A type folder is a root: `~.x` in any file inside it names the type's own `x`, wherever the type is installed. Keep the type's whole implementation inside its folder and reach it that way. What a type folder must hold is set by this type's own `type.yaml`, the same way every type's `type.yaml` sets what its assets hold. `asset.validate` on a type reports anything missing, and the scaffold produces a folder that passes. ## What sets your type's schema (`type.yaml`) `type.yaml` is the structural contract every asset of the type is checked against. The keys below are the ones the engine reads; a key not listed here is ignored. | Key | What it controls | |---|---| | `suffix` | The folder suffix of the type's assets. Defaults to `.<typename>`. | | `primary` | The file or files that are the asset's content: what the asset resolves to when it is used. | | `entry_files`, `primary_aliases` | Further files that load as the asset or share its identity. | | `is_container` | Whether the suffix stays in the identities of what the asset holds. | | `is_opaque_walker` | Whether a walk of the tree stops at the asset and registers only its primary. | | `plural_dir`, `classify_exts` | Loose files in a folder of this name, or with these extensions, are assets of the type. | | `is_text_default` | Whether the asset's files are text unless stated otherwise. | | `broadcasts_subassets` | Whether assets nested inside an asset of the type are found by their own short name. | | `root` | `true` makes every asset of the type a root, so `~.x` inside one names that asset's own `x`. | | `contract_ref: { field, category }` | A key of the primary file that names another asset the asset is built on. | | `files: { required, optional }` | The files an asset holds (below). | | `allow_unlisted` | `false` reports every file the type does not declare. | | `aliases_from: [{ file, key }]` | Further names an asset answers to, read from its own files. | | `settings:` | Typed per-asset settings (below). | | `inspector:` | The interface people use for the type and its assets (below). | | `preview:` | How an asset is pictured (below). | | `references:` | Names of other assets the type's files carry (below). | | `indexing:` | What search reads for each asset (below). | | `describe:` | How a missing description is generated (below). | ### The files an asset holds Each entry under `files.required` or `files.optional` is `{ path, kind: file | folder, one_of_group?, content? }`. `*` in a path matches within one segment. Entries that share a `one_of_group` are satisfied by any one of them. `content` lists checks on the file's bytes: | Check | Passes when | |---|---| | `non_empty` | the file has content | | `json_field { key, type?, non_empty?, accept? }` | the JSON holds the key (a dotted path) with that shape | | `yaml_field { key, type?, non_empty?, accept? }` | the same for YAML | | `described { keys?, headings?, message? }` | the file says what the asset is (see "Ask your assets to say what they are") | Each check takes a `message`, which is what the author is told when it fails. ### Settings `settings: { values, schema: { type | instance, export? } }` gives every asset typed settings. `values` names the file an asset's values live in; `schema.type` declares one schema for the whole type, and `schema.instance` names a file each asset declares its own in. `asset.create` writes the resolved values, and a write to the values file reaches `onChange` with what changed. ## The human side (`inspector.luau`) A type is used by people through its Inspector, and without one the type is usable only from code. The Inspector is the type's interface for a person: for a procedural graph it is the graph editor, for a kit it is the tracking view of what the kit holds and what is still missing. Writing it is part of writing the type. `inspector: { type, instance? }` in `type.yaml` names the files. `type` is the interface for the type itself and for its assets; `instance` names a file an asset may ship to add its own. Each returns: ```luau return { sections = { { id = "graph", title = "Graph", build = function(ctx) ... end } }, replace = { contents = { ... } }, -- replace a default section by id order = { "graph", "contents" }, -- section order } ``` `build(ctx)` receives the asset and builds the section. A section's `title`, and the text its rows carry, is a string or an `i18n.text` value read from a catalog (`i18n.text("inspectors.mesh.title")`), which follows the editor's language. `asset.create("assetType", ...)` scaffolds a working `inspector.luau` to start from. `asset.validate` on a type that names no inspector, or names one that does not load, reports it. ## Say what your type is for (`about.yaml`) Every type carries an `about.yaml` that says what the type is for, in three plain-language texts: ```yaml intent: "Sets the typeface of the text in your game: UI, labels, signs and 3D lettering." function: "A font, from a TTF, OTF or WOFF file, made available to all of Zero's text, including 3D text." usage: "You choose it by name for your UI or your text, and the text appears in that typeface." ``` - **`intent`** is what the type is for in someone's game, in the words a game maker uses. Up to 800 bytes. - **`function`** is how it works today: what an asset of it is made of and what the engine does with it. Up to 1500 bytes. - **`usage`** is what a person or an agent does with one. Up to 1200 bytes. Write about the type as a whole, not one asset of it, and say what it does now. Agents read these texts to learn when to reach for the type and how; people searching find the type by them. The scaffold starts each text with `[[describe]]` and a note on what to write; a text that still starts that way counts as not written. `services describe` can write them. They show up in `asset.inspect` as `detail.about`, in `assetTypeRef:getAbout()`, at the end of the type's `types/<typename>` guide, and at the top of the type's Inspector. ## Ask your assets to say what they are A type can require each asset to carry a description: a file, written by the author or generated, saying what the asset is and what it is for. Declare it with a `described` check: ```yaml files: required: - path: "README.md" kind: "file" content: - { check: "described", message: "Say what this widget is for and where it goes." } ``` A file that is missing, empty or still has a line starting with `[[describe]]` fails the check, and so does a YAML file whose named `keys` are missing or over their `max_bytes`, or a Markdown file missing a named heading. `asset.validate` names the asset, and a push that carries it is refused with `message`. `services describe` finds such assets and writes their descriptions. `describe:` steers what is generated: ```yaml describe: guidance: "Say what the widget shows, what input it reacts to, and where it fits in a UI." examples: - "<identity of an asset of this type whose description reads well>" ``` An example is an asset of your type whose description is a true, written one, never a placeholder and never the asset being described; with none, leave `examples` empty. A type whose assets the model cannot perceive (a sound, a motion) says so in `guidance`, and the description is drawn only from what the asset's own files state. Start the file unwritten in your `template/`: a heading and one line starting with `[[describe]]`, never example content, which every new asset would carry verbatim. A type whose assets say what they are through their own content (a mesh, a texture) declares no check. ## The type's code (`behavior.luau`) `behavior.luau` returns one table. These are the keys the engine reads from it; anything else on the table is the type's own. ### What the type's assets can do | Key | Shape | What the engine does with it | |---|---|---| | `ref` | `{ [name] = function(self, ...) }` | Every function becomes a method on every asset of the type: `ref:name(...)`. | | `modules` | `{ [name] = require(".x") }` | Code the type's assets reach with `asset.containing(__FILE__).modules.<name>`. | | `events` | an events schema | Events an asset fires. Readers subscribe through `ref.events.<name>:connect(...)`; the type fires them. | | `refShapes` | `{ [method] = function(self) -> (typeExpr, source?) }` | The result type of a `ref` method for one particular asset (below). | | `namePattern` | a Lua pattern | The names `asset.create` accepts for the type's assets. Default `^[A-Za-z][A-Za-z0-9_]*$`. | | `derive` | `{ output, module, compute, fingerprint, matches?, required?, timeout? }` | A file computed from the asset when it is committed; a `required` one holds the commit until it lands. | Some `ref` names mean the same for every type, and the engine calls them: - **`instantiate(self, target?, opts?) -> (root, idMap)`**: puts the asset in a scene. Defining it is what makes the type scene-instantiable. Its return is a contract (below). - **`inspect(self) -> detail`**: what `asset.inspect` reports for the asset beyond the common record (below). - **`preview(self, opts)`**: renders the asset's picture; it wins over the type's `preview:` recipe. - **`previewMaterial(self) -> { material }`**: the material a `surface` preview paints. - **`saveDefinition(self)`**: writes the asset's in-memory edits back to its files in edit mode. Some names are answered for every asset before the type is asked, so a `ref` entry of the same name is never reached: `getSource`, `getBytes`, `getText`, `exists`, `deps`, `canInstantiate`, `canPreview`, `preview` (which calls yours when you define one), `meta`, `runtime`, `events`, `typeRef`, `modules`, and the residency flags `has_backing_asset`, `has_runtime_changes`, `cpu_resident`, `gpu_resident`. ### When the engine calls the type | Hook | Signature | When it runs | |---|---|---| | `onCreate` | `(name, opts) -> { [path] = contents }` | On `asset.create`. Returns the files of the new asset, laid over the type's `template/`. Annotate `opts`: its type is the schema `asset.create` checks the caller's arguments against. A `""` key writes a single loose file. | | `onReplace` | `(dest, files) -> files` | On an `asset.create` over an asset already at `dest`, after `onCreate`, so what the author added can be carried into the replacement. | | `onRegister` | `(self)` | Once per asset, when it first registers: when the world loads, on a live `asset.create`, and when an asset arrives later (installed, pulled, synced). This is what makes an asset take effect the moment it is written. | | `onChange` | `(ref, change)` | On every write to a file inside an asset of the type. `change` is `{ path, asset, type, kind, origin }`, plus `settings` and `settingsChanged` for a write to the settings values file; `kind` is `edited` or `seeded`, `origin` is `local` or `remote`. Filter on `change.path`. Writes to one asset arrive in order, each after the hook for the one before has finished, and the hook may wait on what it reads. A write the hook makes inside its own asset arrives later like any other, so keep the hook convergent. | | `onDependencyChange` | `(ref, change)` | When a module the asset's code requires is re-run, or a name the asset carries starts resolving. `change.kind` is `dependency`. | | `onDelete` | `(ref)` | When an asset of the type leaves the world: deleted, or the world it is in is swapped away. | | `validate` | `(ref) -> { { code, message, severity?, path? } }` | On `asset.validate`, after the `type.yaml` checks, for the type's own rules. `severity` defaults to `error`. Runs on every push, so a type's rules hold at publish. A hook that fails reports `validate.hook_failed`. | ### Settings hooks | Hook | When it runs | |---|---| | `settingsDefaults(name, opts, asked) -> table` | Once per `asset.create`, for values the schema's defaults do not give. | | `settingsCorrections(values, name, opts) -> (corrections?, reasons?)` | On every settings write. A correction to a field the writer named refuses the write, giving the reason. | | `settingsDerivedDefaults(values, explicit, changed)` | On a settings write, for fields derived from others. | | `normalizeSettings(values, stored?)` | On every read and write, to map an earlier spelling of a field to the current one. | | `settingsHealed(values, stored)` | On a read, to repair stored values. | | `settingsSchemaProblem(schema, ref) -> string?` | When an asset's own schema is read; a returned string refuses the schema. | `creationInputs` (`{ [opt] = true | selectorOpt }`) names `asset.create` options that are inputs to the type rather than settings. ### Reloading An edit to `behavior.luau` reaches existing assets with no restart. ## How an asset is pictured (`preview:`) | `kind` | The picture is | The type provides | |---|---|---| | `instantiate` | the asset placed in the preview studio through its `instantiate` | `ref.instantiate` | | `image` | a file the asset holds, fitted to the frame | `source: { files }`, the candidate files in order | | `surface` | the asset painted on a mesh | `mesh`, and `ref.previewMaterial` | | `custom` | whatever `ref.preview` returns | `ref.preview` | ```yaml preview: kind: surface mesh: sphere ``` `angle: [yaw, pitch]` turns the camera. The studio owns the light, the backdrop and the framing, so an asset pictures the same in every world. A type with no `preview:` that defines `instantiate` still answers `ref:preview()`. A picture is rendered when something asks to view it (the editor showing the asset, `ref:preview()`), when previews are generated on request (`assets.generatePreviews`), and when the asset is staged. An edit alone renders nothing. The picture records what it was made from, so a stale one is told from a current one. ## The names your type's assets hold (`references:`) Where your type's own format or API carries the name of another asset, declare it here: ```yaml references: keys: # a top-level key of the type's files that holds a name, or a table of them - { key: "shader", type: "shader" } args: # an argument of a call, counting from 1 - { call: "g:node", position: 2, type: "procNode" } fields: # a field of the options table a call takes - { call: "fx.beam", field: "material", type: "material" } ``` `type` is the category the name resolves in. `asset.declareReferenceKey`, `asset.declareReferenceArg` and `asset.declareReferenceField` declare the same from a script. ## What search reads (`indexing:`) `indexing:` is how assets are found. Search reaches an asset only through what its type's `indexing:` names, and adds nothing of its own. That includes you: an asset indexed badly is one you cannot find later, when you are making something else and need it. A type whose assets are never looked for says `indexing: none`. ```yaml indexing: data: # text, read from the asset's files - role: identity extractor: verbatim source: { file: "README.md" } - role: interface extractor: symbols source: { files: ["init.luau"] } - role: implementation extractor: verbatim source: { files: ["init.luau"] } content: # the picture - role: identity modality: image source: { file: "preview.png" } facets: # what a query filters and re-ranks by file: ".metadata" rigged: { type: bool, from: { components: { contains: SkinnedModel } } } roughness: { type: number, filter: range, from: { file: "mat.yaml", field: "floats.roughness" } } ``` **Roles.** Each `data` and `content` entry has a `role`, and a query matches in two slots: - **`identity`**: what an asset is. For anything you look at, the picture; for anything else, the text that says what it is. - **`capability`**: what it does and how it is made. `interface` (the signatures or shape a caller uses) and `implementation` (the body) both count as capability, and a type with code usually declares both. Ask what a person would recognise an asset of the type by, and what it does, and point each role at the file that says it. For text, that is the asset's description: the file your template starts with a `[[describe]]` block, which the author writes or `services describe` fills in (see "Ask your assets to say what they are"). **`data`.** `extractor: verbatim` embeds a file's text as it is; `symbols` embeds the declared signatures of code. `source` is `{ file }` or `{ files: [...] }`. Never index a file name (`source: { field: name }`): one or two words carry nothing to match. **`content`.** `modality: image` embeds the picture itself, so a text query matches what the asset looks like. A type whose assets are looked at makes the picture its identity. **`facets`.** What a query narrows and re-ranks the matches by. `file` is embedded whole, so keys nobody declared in it are still found. Each further key is computed for every asset and states a value for every one, including `false`: a file can imply "not rigged" but never say it, and a query separates rigged from unrigged only because the unrigged ones say `rigged: false`. A key is `{ type: bool | number | enum, filter?: range, from }`, where `from` is `{ file, field }` (a field of one of the asset's files, dotted for nesting), `{ metadata: key }`, or `{ components: { contains | any_outside } }` (what the asset's entities carry). ## What blocks a push A push checks every asset it carries against its type. These refuse it: - a required file that is missing, a `content` check that fails, a `described` file not written yet; - an error from the type's `validate`. Unlisted files and warnings do not. A `described` file blocks only a push that changes the asset. When a push is refused, the message names each asset and what it lacks. `world.publishBlockers()` and `zm status` read the same list without pushing. ## Typing a result from the asset (`refShapes`) A `ref` method whose result depends on the asset (one entry per child folder, per row of a config, per control a map declares) can only be annotated as `{ [string]: Thing }`, which accepts any key. `refShapes` states the result for each asset instead: a function returning a Luau type expression for that asset, and the module whose types the expression uses. Read the asset; never run it. ```lua -- inputMap.assetType/behavior.luau M.refShapes = { activate = function(self): (string, string) local names = {} for _, control in ipairs(M.ref.controls(self)) do table.insert(names, control.name .. ": Handle") end if #names == 0 then return "", "" end return "{ " .. table.concat(names, ", ") .. " }", "@builtin::modules.zinput.scheme" end, } ``` With it, `map.jump:onPressed(fn)` is checked and `map.noexisting` is reported. A per-asset type applies where the call site names which asset: a component field whose default names it, or an annotation `AssetRef<"inputMap", "<identity>">`. `asset.resolve(name, category)` carries only the category, and a name computed at runtime carries nothing, so calls on those keep the declared return. The type belongs to the call's result: index it there, or bind what you need from it there, and the names stay checked. `require("@builtin::assetTypes.assetType.shared.refShapes").published()` shows what was published: `categories` (each type's method surface) and `returns` (per-asset results by identity, then method). An identity missing from `returns` was never published. Results are recomputed when an asset is written; at most 64 assets of one type are read. ## Putting an asset in a scene (`ref.instantiate`) A caller writes one piece of code against every instantiable type, so what `instantiate` returns is fixed: ```lua local Instantiable = require("@builtin::assetTypes.assetType.shared.instantiable") M.ref = { instantiate = function(self, target, opts) local root = Instantiable.root(self, target, opts) -- compose the asset under `root`, now return Instantiable.result(self, root, idMap) end, } ``` **In.** `target` is the entity the asset lands under, or onto for a hierarchy type; with none, the type spawns a new root. `position`, `rotation` (three numbers in degrees, or a quaternion), `scale`, `name` and `temporary` mean the same for every type: `Instantiable.root` applies them to a root you make, `Instantiable.place` to one you adopt. Document any options of your own in the hook's `--!arg` docs. **Out.** `(root, idMap)`. `root` is the composed root, live when you return: build synchronously, never defer to a component's `awake`. `idMap` maps each original id to the spawned one, so a component that composes the asset again on every load can pass it back in and keep references into the composition. Every call goes through `Instantiable.result`, which refuses a root that is not live and turns a missing `idMap` into `{}`. ## Inspecting an asset (`ref.inspect`) `asset.inspect(ref)` builds a record every asset shares (`identity`, `name`, `guid`, `source`, `typeName`, `typeDefinitionPath`, `scope`, `origin`, `description`, `tags`), then calls `ref.inspect(self)` for the type's own `detail`: ```lua M.ref = { inspect = function(self) -- read the asset's own files, never runtime state: inspect works on an asset -- that has not been compiled, uploaded or registered return { --[[ what makes this asset what it is ]] } end, } ``` Without it, the record is the shared part alone, and an agent inspecting the asset learns nothing of what it is. A hook that raises leaves `detail` empty and sets `record.warning`. ## Discovery - `asset.list("assetType")`: every registered type. - `asset.inspect("<typename>")`: the type, its README and its `about.yaml` texts. - `asset.resolve("<typename>", "assetType")`: the type itself.
▲ 0↑ born
·
procnode · born here
❒asset
# material.pbrMat (procNode) A physically-based metallic-roughness material made from its maps, each with the factor the shader multiplies it by: base colour (`baseColor`, `baseColorMap`), metallic and roughness (`metallic`, `roughness`, `metallicRoughnessMap` in the glTF packing, green roughness and blue metallic), normal (`normalMap`, `normalScale`), occlusion (`occlusionMap`, `occlusionStrength`) and emissive (`emissive`, `emissiveMap`, `emissiveIntensity`). A map left out reads as its factor alone. The material draws with the standard metallic-roughness shader; `material.shader` makes a material of any other. It answers one element whose `Material` attribute holds the material record, with the material kind stated on the detail attribute `records`. Any input that takes a material takes it (`geometry.set_material`, `instances.set_material`, `elements.entity`, `instances.pack`, `instances.to_points`), `io.output` shows it and `io.export` saves it as a `.material`, writing a Texture a map holds as a texture beside it. ```luau local look = g.material.pbrMat({ baseColorMap = asset.resolve("@builtin::models.Sample.AnisotropyBarnLamp.bundle.texture.Lamp_Metal_albedo", "texture"), normalMap = asset.resolve("@builtin::models.Sample.AnisotropyBarnLamp.bundle.texture.Lamp_Metal_normal", "texture"), occlusionMap = g.texture.noise({ width = 256, height = 256 }), roughness = 0.8, }) local ball = g.geometry.set_material({ geometry = g.mesh.sphere({}), material = look }) ``` ## Outputs - `material`: one element holding the material record.
▲ 0↑ born
·
procnode · born here
❒asset
▲ 0↑ born
·
procnode · born here
❒asset
# io.output (procNode) Show a value in the world through the translation layer: a Geometry as a mesh, points that carry components (a Mesh, a Material, a light) as one entity each, the copies `instances.to_points` made as instanced draws (one per piece and material), primitives as entities with `class` "primitive", a Texture, Material, Raster or Part as what each is, and a Prefab as the entities its records describe. What the show makes hangs under the entity the graph stands on and goes with it. Answers a Handle that the runtime releases when the output goes away. An element whose `Mesh` holds a geometry with no triangles (a piece `instances.pack` made of points alone, or of nothing) stands as nothing: no mesh is made of it, the rest of the value stands, and the Handle's `stats.drawn.empty` counts the elements left out (`proc.translate.drawn`). Built from the Luau node (`io.luau`) over `show.module`, which sits in this node's folder: its `show` function registers what the value needs and answers the Handle. A graph is pulled from its output nodes. What a show stands is spawned under the entity the graph stands on from the frame it stands. Shown during a present of a play, a show is prepared while the play cooks and stands, with every other show of that present, once the present's cooks are done; what it replaces goes in the same frame. The next show of an output reconciles onto the entities the last one stood under the same place: the entity the graph stands on, or for a graph on no entity the play that shows it (`proc.eval.standingPlace`). ```luau g.io.output({ value = mesh }) g.io.output({ value = rocks, class = "point" }) ``` ## Inputs - `value` (Value). The value to show: Geometry, Points, Part, Texture, Material, Field, Raster or Prefab. - `class` (String, default "", one of "", "point", "primitive"). What one element of a Geometry stands for in the world. Empty shows a geometry with primitives whole as one mesh and stands each point of a set of points that carries components as an entity and a marker at each point of a set that carries none; "point" or "primitive" stands each element of that class as its own. - `layer` (String, default ""). For a Raster, the layer drawn; empty draws `height` when the raster has it, else its first layer. - `name` (String, default "output"). The base name of the entities and assets the show makes. Two outputs of one graph take names of their own. ## Outputs - `handle`: the Handle of what was registered.
▲ 0↑ born
·
procnode · born here
❒asset
▲ 0↑ born
·
procnode · born here
❒asset
▲ 0↑ born
✦
shader · born here
❒asset
# pbr The engine's standard physically-based material — the full glTF metallic-roughness workflow lit by the shared `@builtin::shaderModules.pbr_shading` model. This is the default surface shader a model uses when its material doesn't specify another, and it is also registered under the legacy alias **`standard`** (the name many materials reference). It is a `surface()` shader: it fills a `PbrSurface` and the engine generates every pipeline entry point and lights it. Every parameter defaults to a neutral value, so a material that sets nothing renders as a clean dielectric; the advanced lobes only cost anything when a material opts into them. ## Properties | Property | Type | Default | Meaning | |---|---|---|---| | `base_color` | color | `[1,1,1,1]` | Albedo tint, multiplied by `base_color_texture` and vertex colour. | | `emissive` | color | `[0,0,0,1]` | Emissive tint, multiplied by `emissive_texture` and `emissive_intensity`. | | `emissive_intensity` | float | `1.0` | HDR multiplier on the emissive output. | | `roughness` | range | `0.5` | Perceptual roughness, multiplied by the green channel of `roughness_metallic_texture`. | | `metallic` | range | `0.0` | Metalness, multiplied by the blue channel of `roughness_metallic_texture`. | | `reflectance` | range | `0.5` | Dielectric reflectance knob (neutral 0.5 → 4% F0). | | `ior` | float | `1.5` | Index of refraction → dielectric F0 and the refraction direction. | | `normal_scale` | float | `1.0` | Strength of the tangent-space `normal_texture`. | | `occlusion_strength` | range | `1.0` | Blend of the `occlusion_texture` (R) into the ambient term. | | `clearcoat` | range | `0.0` | Strength of a second dielectric clearcoat specular lobe. | | `clearcoat_roughness` | range | `0.0` | Roughness of the clearcoat lobe. | | `anisotropy` | float | `0.0` | Anisotropic highlight stretch along the tangent ([-1,1]). | | `sheen_color` | color | `[0,0,0,1]` | Tint of the sheen lobe — the retroreflective rim of velvet, satin and brushed fabric. Black leaves the base untouched. | | `sheen_roughness` | range | `0.3` | Width of the sheen lobe. | | `iridescence` | range | `0.0` | Blend toward the thin-film response, the hue that shifts with view angle. | | `iridescence_thickness` | float | `400.0` | Film thickness in nanometres — which wavelengths cancel and which reinforce. | | `iridescence_ior` | float | `1.3` | Index of refraction of the film. | | `subsurface_color` | color | `[0,0,0,1]` | Tint of the light that entered the surface, scattered beneath it and left again. Black leaves the base untouched. | | `subsurface_radius` | float | `0.5` | How far the diffuse falloff wraps past the terminator, taken per channel against `subsurface_color`. | | `fibre_color` | color | `[0,0,0,1]` | Tint of the second of the two highlights a hair or fur strand gives. Black leaves the base untouched. | | `fibre_specular` | range | `0.35` | Strength of the first strand highlight, in the light's own colour. | | `fibre_shift` | float | `0.06` | How far apart the two strand highlights sit along the fibre. | | `fibre_roughness` | range | `0.1` | Width of the first strand highlight. | | `transmission` | range | `0.0` | Specular transmission — refracts the environment through the surface. | | `thickness` | float | `0.0` | Volume thickness for Beer–Lambert transmission absorption. | | `attenuation_color` | color | `[1,1,1,1]` | Transmission absorption tint. | | `attenuation_distance` | float | large | Beer–Lambert absorption distance. | | `uv_scale` | float2 | `[1,1]` | UV tiling applied before every texture sample. | | `uv_offset` | float2 | `[0,0]` | UV offset applied before every texture sample. | | `alpha_cutoff` | range | `0.0` | Mask threshold — fragments with `alpha <` this are discarded (0 = no cutoff). | | `double_sided` | bool | `false` | Flip the shading normal on back faces. | | `receives_fog` | bool | `true` | Whether the screen-space fog passes (height fog, aerial perspective) reach this surface. `false` leaves an opaque deferred draw at the colour it shaded to, however deep in the medium it stands — see below. | | `instance_color_lane` | float | `-1` | Which of the instance's four shader-data lanes colours it (rgb colour, a coverage). `-1` reads none. See below. | | `instance_emission` | float | `0` | How brightly the lane colour glows where it covers. | | `parallax_depth_scale` | float | `0.0` | Depth of the relief `height_texture` describes, in UV units: the furthest the parallax march moves a UV. 0 draws the flat face. See below. | | `max_parallax_layer_count` | float | `32` | The parallax march's steps at a grazing view; straight down takes 40% of them, the self-shadow half. | | `parallax_fade_start` | float | `20` | World distance from the camera at which the relief starts to flatten. | | `parallax_fade_end` | float | `40` | World distance past which the relief is flat and no march runs. | | `height_map_is_depth` | bool | `false` | Which way `height_texture` runs: `false` reads R as height, white highest; `true` reads it as depth, white deepest. | ### Emissive authoring The glow output is `emissive × emissive_intensity` (× the `emissive_texture`). The glow **colour** is `emissive`, a vec; the **intensity** over it is `emissive_intensity`, a scalar. So `{ emissive = {0.1, 0.9, 1, 1}, emissive_intensity = 5 }` is a cyan glow at 5×, and it is these two names that `getProperties()` lists and `setProperty` writes. A spelling another engine's convention uses for the same role — `emissive_color`, `emission`, `emissive_tint` — is resolved onto `emissive` when the material is authored, so content carried in from glTF, Unity or Godot reaches the property under the name this shader declares. Where two such spellings meet on one of the two names, the shape of each value says which of them it is: a vec is the colour and a number is the intensity, so `{ emissive_color = {0.2, 0.8, 1, 1}, emissive = 5 }` is the same cyan glow at 5x. Two values of one shape are one property's, and the one written under the name the shader declares applies while the other is named in a warning. A bare positive scalar `emissive` with no colour beside it is the "turn emission on" shorthand and means a white glow at that intensity, so `emissive = 20` on a white material lights up. ### Parallax occlusion A material that binds a `height_texture` (the relief's height map, R channel) and sets `parallax_depth_scale` above 0 draws the relief that height map describes on the flat face. The map is read as **height, white highest** (the stones white, the mortar black); a map authored as **depth, white deepest** is read by setting `height_map_is_depth = true`, with no need to invert the image. A relief that reads inside out (cobbles sunk below their gaps, carving standing proud) is a map read the wrong way round: flip `height_map_is_depth`. The module and `pbr_parallax_occlusion` state the same switch under the same name. The view is marched into it, every map is read where the view met the relief (through the derivatives of the face's own UV, so the relief's edges pick no coarser mip and the picture holds still under temporal anti-aliasing), and the relief takes its own share of the sun, marched only on the fragments the sun lights. The relief flattens with distance between `parallax_fade_start` and `parallax_fade_end`, and toward a grazing view, so the silhouette of a curved mesh keeps its shape. A UV that tiles (`uv_scale`) keeps every tile. The depth the surface writes and the shadow it casts are those of the flat face. The code is the `PBR_PARALLAX` feature, in a material's program only where `parallax_depth_scale` stands above 0. A shader of your own gets the same relief from `@builtin::shaderModules.parallax`, which this feature calls. `guides { path = "topics/rendering-geometry" }` has the rendering guide's section on relief. ```lua asset.create("material", "cobbles", { shader = "@builtin::shaders.pbr", base_color_texture = { __ref = colour.guid, type = "texture" }, height_texture = { __ref = height.guid, type = "texture" }, -- white highest parallax_depth_scale = 0.05, uv_scale = { 6, 6 }, }) ``` ### The lobes over the base layer Beyond metallic-roughness, the shading model carries six layers this material declares. Each is gated on its own neutral value, so a material that sets none of them shades as a plain dielectric and each one costs only where it is asked for. | Layer | Turned on by | What it looks like | |---|---|---| | Clearcoat | `clearcoat > 0` | A second dielectric specular lobe on top — car paint, lacquer, a varnished surface. | | Anisotropy | `anisotropy ~= 0` | The highlight stretches along the tangent — brushed metal, a vinyl record. | | Sheen | `sheen_color` above black | A retroreflective rim that brightens toward grazing angles — velvet, satin, dusty cloth. | | Iridescence | `iridescence > 0` | The specular hue shifts with view angle — an oil slick, a soap film, anodised metal, a beetle shell. Thickness picks the colours. | | Subsurface | `subsurface_color` above black | Light wraps past the terminator and glows through thin geometry lit from behind — skin, wax, marble, a leaf. `thickness` gates how much reaches the far side. | | Fibre | `fibre_color` above black | The two offset highlights a strand gives instead of the one a surface gives — hair, fur. Taken around the world tangent as the fibre axis. | All six are evaluated inside the engine's own light loop, once for every light that reaches the surface, so each one is shadowed, attenuated and cone-masked with the base layer it sits over. Each layer, and specular transmission beside them, is a shader feature its gating property switches on (`features:` in `properties.yaml`: `PBR_CLEARCOAT`, `PBR_ANISOTROPY`, `PBR_SHEEN`, `PBR_IRIDESCENCE`, `PBR_SUBSURFACE`, `PBR_FIBRE`, `PBR_TRANSMISSION`; the per-instance colour below is `PBR_INSTANCE_COLOR`). A material that sets the property away from its neutral value draws a program holding that layer; one that leaves every layer at rest draws a program holding none of them, so the default material pays only for the metallic-roughness model it shades as. Setting a property with `renderer.material.setProperty` moves the material between the two programs, and `renderer.shaderVariants()` lists the ones a scene has asked for. An oil-slicked wet surface is `iridescence = 1`, an `iridescence_thickness` around 300-500 nm and a low `roughness` over a dark `base_color`. Skin is a warm `subsurface_color` with a `subsurface_radius` near 0.5. Velvet is a `sheen_color` at the fabric's own hue over a dark base. ### Standing outside the fog `receives_fog = 0` declares that the screen-space fog passes — `heightFog` and `aerialPerspective` in `@builtin::systems.atmosphere` — leave this surface at the colour it shaded to. The declaration travels to those passes as a per-pixel surface flag written into the alpha of the G-buffer normal (`@builtin::shaderModules.surface_flags`). Only the deferred G-buffer fragment entry writes that channel, so the declaration reaches the fog from an **opaque** draw on the **deferred** path. A draw the renderer sends through the forward fragment entry — every draw on the forward path, and the transparent phase on either path — writes no G-buffer channel to carry it, and its pixels take the fog like any other. ### Per-instance colour `instance_color_lane` names one of the four shader-data lanes every drawn instance carries (`renderer.instanceData.set` for an entity, the `instanceDataBuffer` of `renderer.mesh.drawInstanced` for a population). The lane's `rgb` is this instance's colour and its `a` is how much of it covers the material's own base colour and emission, 0 none through 1 all, so one material draws every member of a structure, a crowd or a population in a colour of its own: a stress map, a heat map, damage tints, team colours, a selection highlight. A lane never written reads zero and leaves the material's own look. ```luau local mat = renderer.material.create({ shader = "@builtin::shaders.pbr", properties = { instance_color_lane = 2, roughness = 0.6 } }, "beams") beam.component.add("Model", { model = "cube", material = mat }) -- the handle renderer.instanceData.set(beam, 2, 1, 0.2, 0, 1) -- this beam orange-red ``` The colour replaces the base colour before lighting, so the surface still shades and the `albedo` capture pass reads the lane colour. `instance_emission` adds the lane colour as emission where it covers. Lanes 0 and 1 carry a baked lightmap's rect and layer, so a lit material takes lane 2 or 3. The read is the `PBR_INSTANCE_COLOR` feature, so a material that leaves `instance_color_lane` at `-1` draws a program without it. `@builtin::materials.instance_color` is this material ready made, reading lane 2. A write is local to the engine that makes it and replicates nothing, which is what makes it cheap enough to recolour hundreds of members every frame; `Model.tint` is the synced tint every participant sees. ## Textures (glTF metallic-roughness set) | Slot | Default | Channels | |---|---|---| | `base_color_texture` | white | RGBA albedo (sRGB). | | `roughness_metallic_texture` | white | G = roughness, B = metallic (glTF packing). | | `emissive_texture` | white | RGB emissive (sRGB). | | `normal_texture` | flat-normal | Tangent-space normal map. | | `occlusion_texture` | white | R = ambient occlusion. | | `height_texture` | white | R = height of the relief, white highest (white deepest under `height_map_is_depth`). Read by parallax occlusion (`PBR_PARALLAX`, where `parallax_depth_scale` > 0). | A program samples the maps its material binds and no other. Each slot is a shader feature switched on by the material binding a texture there (`PBR_BASE_COLOR_MAP`, `PBR_ROUGHNESS_METALLIC_MAP`, `PBR_NORMAL_MAP`, `PBR_EMISSIVE_MAP`, `PBR_OCCLUSION_MAP`): a slot left unbound, or bound to its own default (`default:white`, `default:normal`), reads as the value that default stands for, times the slot's factor, with no texture sample, and an unbound normal map leaves the geometric normal exactly as it is. A solid-colour material takes no texture sample at all. A material binding one image as both `roughness_metallic_texture` and `occlusion_texture` (glTF's packed occlusion-roughness-metallic image) draws `PBR_OCCLUSION_IN_ROUGHNESS_METALLIC`, which reads occlusion from the R of the metallic-roughness texel and samples the image once. Because the engine holds the full `PbrSurface`, the capture tool's debug passes (albedo / roughness / metallic / AO / emissive / world-normal / shadow / depth / motion) all read real material data.
▲ 0↑ born
·
procnode · born here
❒asset
▲ 0↑ born
▣
module · born here
❒asset
# proc Code-authored, graph-backed procedural generation for the Zero engine. A graph is one function of `g`: `proc.define(function(g) ... end)`. Nodes are called by family and name (`g.<family>.<name>({ ... })`), inputs are declared with `g:input(name, default, opts)`, the returned table is the graph's outputs, and `io.output` is how the graph stands in the world. `builder.module/README.md` holds every rule of that form. This module owns the whole procedural model: the graph builder + data model, the operation registry, the type system, the lazy cached evaluator, deterministic scoped hashing, and the node-family op implementations. Authored `.procGraph` graphs are persisted via `procGraph.assetType`; the `procgen.preview` / `procgen.spawn` operations live in `procgen.toolbox` and are invoked as tools: `tools.use("procgen", "preview", args)` from a script or an agent's `tool_exec` script, or `zero procgen preview` in the shell. Generated meshes/materials/textures/bundles are persisted through their own `.assetType`. An op family can also come from outside this package: a `.procPack` asset registers its ops in the same registry, called as `g.op.<id>(...)` exactly like the ones shipped here (`proc.registerPack(name, ops)` is what it registers through, and what a test or a tool calls to hold a family for the life of one VM). `terrain.*` is one such pack, shipped in `terrainSystem.package/procPacks/` and covering a whole landscape; `guides { path = "systems/terrainSystem/documentation/terrain" }` is its guide. To find out what the registry holds, use the `procgen` toolbox: `searchNodes` searches it and `describeNode` describes one node or op. `proc.search_ops(query)` and `proc.schema(id)` are the same answers in-process, for a graph builder looking something up while it runs.
▲ 0↑ born
·
procnode · born here
❒asset
▲ 0↑ born
·
procnode · born here
❒asset
▲ 0↑ born
❒
package · born here
❒asset
▲ 0↑ born
✦
shader · born here
❒asset
▲ 0↑ born
◇
component · born here
❒asset
# Generator A live procedural generator: it binds a `.procGraph`, plays the graph's timeline and stands each of the graph's outputs in the scene as children of the entity it is on. Change a param and the output is made again in place; in edit and in play alike, nothing it makes is written to the world's source. ```lua local graph = asset.create("procGraph", "crate") -- a box with a `size` input; edit its init.luau local e = entity.spawn("crate") e.component.add("Generator", { graph = graph }) e.component.get("Generator").params = { size = 2 } ``` ## Fields | Field | What it does | |---|---| | `graph` | The `.procGraph` it plays. | | `params` | Overrides for the graph's declared inputs, by name. | | `output` | One declared output to stand; empty, the default, stands every output, one root each. | | `playOn` | What starts its clock in play mode: `"auto"` (default) plays a timeline with no end as soon as it binds and holds any other on its first frame; `"load"` plays on bind; `"manual"` waits for `play()`. In edit mode a Generator is not set to play, whatever `playOn` says: it shows the frame it is on until it is played. | | `ending` | `"graph"` (default) does what the timeline declares; `"loop"` plays the range round and round; `"hold"` plays it once and stays on its last frame. | | `speed` | How fast its clock runs: 1 its own rate, 0 still, negative plays a timeline with an end backwards. | | `diskCache` | Whether the outputs the graph caches load from, and are written to, the world's disk cache. On by default. | | `cookBudgetMs` | Milliseconds of cook work a frame before a cook yields to the next frame. 5 by default. | ## Methods `play()`, `pause()`, `seek(seconds)`, `seekFrame(frame)`, `loop()`, `hold()`, `setFps(fps)`, `setRange(first, last)` and `setWallTime(on)` drive its clock, on every peer. `getFrame()`, `getTime()`, `describeGraph()` and `playback()` read it; `playback()` also says what running the graph costs and how each output is drawn. `cancelCook()` stops a cook in flight and leaves the last output standing. `apply()` swaps the generator for the asset it makes: the frame being presented becomes a bundle, and an `Asset` component standing it takes the Generator's place. The `onFinished` event fires when a range played once reaches its end. A timeline that runs in real time (`realTime = true`) has an end when its graph states `frames` beside it (`g:timeline({ realTime = true, fps = 60, frames = 180 })`) or when `setRange` gives it one; with neither it runs on and never finishes. When the playhead of one with an end reaches its last frame, `ending` applies as it does to any timeline: `"graph"` loops where the graph declares `loop` and otherwise holds on the last frame and fires `onFinished` once; `"loop"` plays it again from the start, a fresh simulation each time, without firing it; `"hold"` stays on the last frame. `play()` plays a held one again from its start. `playback().ends` is whether the timeline has an end, and `last` is its last frame. A real-time timeline begins again, by `seek(0)`, a loop or `play()`, in the runs its solvers hold on the device: a restart costs a rewrite like any other present, and opens no cook. ## Under an effect An effect's play runs each graph of its entry on a Generator, a child of the play's entity. `effectRef:play(entry, opts)` and the `Effect` component make them and drive their clocks together, so a shot, an impact or a cast is a play of an effect (`guides { path = "systems/effects/documentation/visual-effects" }`). The play's own `playback()` adds its Generators' costs together. Every play of one graph with the same params plays the frames the first one cooked. A Generator of a graph with `playOn = "manual"` cooks every frame of the timeline while it waits, and `playback().cookedThrough` reaching `playback().last` says every frame is cooked. ## Related - `guides { path = "systems/procgen/documentation/procgen" }`: graphs, ops, timelines, effects and the live generator in full. - The `procgen` toolbox: `spawn`, `adjust`, `apply`, `generators`, `cooks`, `frames` and `onPresent` work on generators by entity, and `play` plays a graph on the preview stage.
▲ 0↑ born
◇
component · born here
❒asset
# SceneSetup The per-instance state of a placed scene setup. A setup's `instantiate` adds it to the placed root beside the `Asset` component whose `source` is the setup. It holds this placement's `overrides`, by parameter path, and applies the setup with them; the setup's members are applications of their assets, so the scene records the root, its `Asset` and these overrides alone. ```luau local setup = entity(root).component.get("SceneSetup") setup:members() -- { [path]: { source, state } }, every depth setup:get("fog/density") -- { value, origin, definedBy?, desc } setup:set("fog/density", 0.05) -- this placement's override setup:set("ao/@enabled", false) -- turns a member off here setup:reset("fog/density") -- back to what the setup says setup:orphans() -- overrides that address nothing ``` It applies the setup when it wakes and when it is enabled, applies a change of `overrides`, turns the setup off when it is disabled and drops it when it is removed; removing the `Asset` removes it. While it is disabled, a change of its overrides applies the setup off. Across an edit/play flip the setup stays applied: the instance that ends hands its application to the one that wakes on the same root, so no frame is drawn without its sky, sun or fog. It runs nothing per frame. A system API's write of a parameter this placement states (`fog.set`) becomes this placement's override. Its application is one of the scene's applications: the effects that hold one at a time (the sun, the ambient term, the sky, each render feature's settings) go to the newest application standing. Another setup applied from code (`setupRef:as("applicable"):apply(owner)`) holds them over this placement until it is dropped, across flips, and its drop hands them back to this placement. `audition(setup)` shows another setup in this placement's place as a preview for the session; `endAudition()`, a flip or a reload ends it.
▲ 0↑ born
◇
component · born here
❒asset
# Asset Promote the bundle's spawned children from temporary to permanent scene state and remove the Asset component, "baking" the bundle's contents directly into the owning scene. Subsequent saves persist the baked entities verbatim and stop replaying the bundle template. Location: `src/lua/lib/components/Asset.component`
▲ 0↑ born
✦
shader · born here
❒asset
# `bloom` post-process shader The light a bright surface spills into the pixels around it. A half-resolution `bright` pass extracts what the picture shows above `threshold`, a pyramid of `downsample` passes carries it down to 1/64 of the view, and a chain of `upsample` passes carries it back up, blending each octave into the one above it. `composite` adds the result to the scene. `tools.use("pp", "add", "glow", "bloom")` registers it — the shader declares `space: light`, so the effect takes the scene layer: the rendered picture before the UI is drawn, over the scene's own light in a float target, which is where a bloom belongs. What blooms is judged in exposed light: the scene's light times the exposure in force (`zero_display_exposure()`, the gain `__display__` applies before its curve). The same scene shown brighter or darker blooms the same highlights, and a scene lit four times brighter and exposed four times lower is one picture with one glow. Below the threshold nothing blooms, so a diffuse surface the picture shows under its highlights lifts no shadow. Above it the glow is carried in the scene's own light and grows in proportion to the light a source stands above the threshold with, so the brightest things in a frame keep their order through their glow. ## Passes | Pass | Scale | What it does | |---|---|---| | `bright` | 0.5 | Extracts what each texel of a 2x2 block of the scene shows above `threshold`, soft-kneed by `softKnee`, and averages the four. A texel holding more light than the half-float targets carry (an infinity a shader overflowed to) is taken at the largest light they hold, and one holding no number is taken as none, so one texel spreads glow and never a value that blacks out the octaves it reaches. | | `down1`…`down5` | 0.25 … 0.015625 | Each halves the previous octave's resolution with a 13-tap filter; `down1` also Karis-averages its five groups, each weighed against the plain average of the five, so a group standing far above its neighbours (a firefly) weighs little while groups alike average plainly at every brightness. | | `up4`…`up0` | 0.03125 … 0.5 | Each carries the smaller octave up with a 3x3 tent and blends it into the next one by `scatter`. | | `composite` | (view size) | Adds the bloomed image to the scene, scaled by `intensity`. | ## Properties | Property | Default | Range | Meaning | |---|---|---|---| | `threshold` | 4.0 | 0–16 | The exposed brightness (light times the exposure in force) the `bright` pass extracts above. 1 is what a linear display shows as white; the default 4 sits two stops over it, where the display's curve is in its shoulder, so diffuse surfaces stay out of the glow and emitters, sun glints and the sky by the sun bloom. | | `softKnee` | 0.5 | 0–1 | How wide the roll-in is around `threshold`, as a share of it, so a surface crossing it brightens rather than pops: at the defaults the roll-in runs from 2 to 6. | | `intensity` | 0.6 | 0–4 | How much of the bloomed image the `composite` pass adds back to the scene. | | `scatter` | 0.7 | 0–1 | How much of each octave an `upsample` pass blends into the one above it, and so how far the halo carries. | | `levels` | 6 | 1–8 | How many octaves of the pyramid draw. | `levels` and the 8-texel floor an octave's short side must clear are both read per pass, not baked into the pass list: an octave past either one returns the larger image it was handed unchanged, so a slider drag on `levels` changes what the twelve passes DO and never how many there are. Eleven scratch targets in the scene format, the largest at half the view — about 11 MB at 1080p.
▲ 0↑ born
◇
component · born here
❒asset
# PostProcess Component Applies a **stack of post-process effects** to the scene, declaratively, from a single entity. Each effect references a `.shader` asset (`@domain: post-process`) and carries its own **configurable property values** — tuned like material properties, with no shader edit required. This is the load-time **reproducer** for post-processing: where an agent's live `postprocess.add(...)` + `postprocess.setProperty(...)` calls produce effects that vanish on reload, a `PostProcess` component re-registers the exact same stack — with the exact same tuning — every time the scene loads. The persist freeze converts live execute-origin effects into `.shader` assets + one entity carrying this component, so **what you see is what you get** across save/reload. ## Properties | Field | Type | Description | |---|---|---| | `effects` | array | The effect stack. Each entry: `{ shader, priority?, enabled?, layer?, values?, textures? }`. | | `shape` | `"global"` \| `"box"` \| `"sphere"` | Where the stack applies. Default `"global"` (unbounded). | | `extents` | vec3 | Box region half-extents, world units. Default `{5, 5, 5}`. | | `radius` | number | Sphere region radius, world units. Default `5`. | | `falloff` | number | Soft-edge distance outside the volume the stack fades over. Default `0`. | | `priority` | number | Order of this region against other `PostProcess` regions, added to each effect's own priority. Default `0`. | | `display` | struct `{ curve, exposure }` | The display transform this region sets while it is live — `curve` (0 linear, 1 Reinhard, 2 ACES, 3 Khronos PBR Neutral, default `3`) and `exposure` (multiplier on the scene's light before the curve, default `1`). Takes effect only when `setsDisplay` is `true` and `shape` is `"global"`. | | `setsDisplay` | boolean | Whether this region writes `display` to the chain's `__display__` transform while it is live. Default `false`. | Each effect entry: | Key | Type | Description | |---|---|---| | `shader` | asset reference | The `.shader` asset (a `@domain: post-process` shader) this effect runs. Builtin shaders (`@builtin::shaders.post.vignette`, …) or scene-authored custom shaders both work. | | `priority` | number | Chain order within this region — lower runs earlier. Default `100`. | | `enabled` | boolean | Per-effect toggle. Default `true`. | | `layer` | `"all"` \| `"scene"` | Which composited image this effect grades: `"scene"` is the rendered picture before the UI reaches it, in the scene's own light; `"all"` is the picture fitted to the screen with every widget on it. Left empty, the entry follows its shader's `space` — a `light` shader grades `"scene"`, a `display` shader grades `"all"`. | | `values` | table | Named property overrides `{ [prop] = value }`, applied via `postprocess.setProperty` after the effect is added — the configurable tuning. | | `textures` | table | Texture bindings `{ [prop] = path }`, applied via `postprocess.setTexture` after the effect is added. | The component-level `enabled` flag (engine-managed, not declared here) toggles the **whole stack**: disabling the component removes every effect (and restores the chain's own display transform if this region set one); enabling it re-registers them (`onEnable` / `onDisable`). ## Usage ```lua entity.find("fx").component.add("PostProcess", { effects = { { shader = "@builtin::shaders.post.vignette", priority = 0, values = { intensity = 0.6 } }, { shader = "@builtin::shaders.post.grayscale", priority = 10, values = { intensity = 1.0 } }, }, }) ``` Setting the display transform from a `global` region: ```lua entity.find("look").component.add("PostProcess", { setsDisplay = true, display = { curve = 2, exposure = 1.5 }, -- ACES }) ``` Two `global` regions with `setsDisplay = true` both write `__display__` — whichever registers last wins the frame. The regions setting it share one ordered record of who is live, so they come off in any order: removing the newer of two leaves the older one's display standing, removing the older leaves the newer one's, and removing the last leaves whatever stood before any of them wrote. The exposure package drives `__display__.exposure` on its own, from a GPU readback each tick it meters. A region arriving or leaving sets the exposure and the package's next readback sets it again, so with auto-exposure running the exposure a region asks for holds for a frame while its curve holds for as long as the region does. ## Methods - `pp:getEffectNames()` — the live effect names currently registered, in stack order. - `pp:setProperty(index, prop, value)` — tune a property of one effect at runtime (forwards to `postprocess.setProperty`), like editing a material property.
▲ 0↑ born
▣
module · born here
❒asset
# scene runtime What a `.scene` folder does when it is loaded, saved, built, or swapped. A `<name>.scene/` carries `scene.json` (the entity arrangement), an optional `build.luau` (the code author's half), an optional `entrypoint.luau`, and a `scene_dirty/` overlay of unsaved edits. Reading, composing and writing all four is the scene type's own behaviour, so it lives in the type. ## Sub-modules | Module | Responsibility | |---|---| | `loader.module` | Reads scene.json v6 and v7, refuses versions it does not know, composes canonical + dirty overlay, spawns the entities, and runs the entrypoint. | | `saver.module` | Persists scene state as a delta overlay against the canonical file, promotes that overlay on save, and answers which edits are still pending. | | `build.module` | Runs a `build.luau` inside an entity capture scope and composes what it spawned into scene records. | | `observe.module` | The read side — the per-scene counts and costs `layers` and `loader` write. | | `swapOrchestrator.module` | Drives multiplayer room transitions and the scene-swap gate, so a local swap does not leak despawns to peers in the old room. | ## Reaching it ```luau local rt = require("@builtin::assetTypes.scene.shared") rt.saver.hasPendingSceneEdits(layers.active.name) ``` Fields resolve lazily. The prelude installs `swapOrchestrator` and starts `saver`'s dirty writer in a fixed order, which a table that required all five on load would take away from it.
▲ 0↑ born
▣
module · born here
❒asset
# columns The CPU code behind `model.columns`: builds the points and their `variant` and `c<n>` columns as a procgen Geometry.
▲ 0↑ born
·
assettype · born here
❒asset
# procNode: one reusable step of procedural generation A `.procNode` is a node authored as content: a folder whose `init.luau` is the node. It returns `proc.define(function(g) ... end)`, the same function-of-`g` form a `.procGraph` is written in, so a node is a small graph that other graphs call. Its `g:describe` text says what it makes and when to use it, its `g:input` declarations are what a call passes, and what it returns (or declares with `g:output`) is what the call gives back. ``` MyNode.procNode/ init.luau -- the node README.md -- what it produces, its inputs, its outputs .metadata -- description and tags ``` ## What a node states - **`g:describe(text)`**: what the node produces and when to use it. It is the text search, the node catalogue and the Inspector show. - **`g:input(name, default, opts)`**: one input of the node. The default types it (`Float`, `String`, `Bool`, `Vec3`, `Color`, `List<T>`, `Record`); `opts` adds `type` (for a default that does not state one, or none), `description`, `options`, `min`, `max` and `optional`. A call names inputs in a table, or passes them in declaration order. - **Outputs**: the returned table names them (`return { geometry = geometry }`), and `g:output(name, value)` declares one as the node builds. A node with one output answers that value to its caller; a node with several answers a record by output name; a node with none answers nothing. - **Written as literals.** What a node takes and gives is read from its source without running it, the way search and description read it here and the way ZeroMind reads it, so each declaration states its values as written: `g:describe` and each `g:input` once, at the top level of the function, with a literal name, default and options (a file constant holding a literal, or `asset.resolve("<identity>", "<type>")`, reads as one); outputs named by the table the function returns, or by `g:output`, the same names on every branch of a condition and never inside a loop. `asset.interface(node)` answers what the source declares, with each part it cannot read as a problem, and a push refuses a node with such a problem (`interface.unreadable`). - **The body** is the node's work: calls to other nodes, arithmetic over sockets, `for`, folds, steps and state, as the builder README (`proc.module/builder.module/README.md`) describes. A node that uses another node is recorded in the graph that calls it, so a node can be built from nodes. ## How a graph calls a node A node inside a `<family>.nodebox` is called by its box and folder name: `points.nodebox/disc.procNode` is `g.points.disc({ ... })`, and nothing inside the node states that name. A node is also reached by: - its path (`g["/zero/source/fx/ring.procNode"]`), - `~`, the nearest enclosing package, effect or world root (`g["~/ring"]`), - its guid, - a short name only one node answers to (`g.disc`). A name that matches two nodes and a name that matches none are errors that name the candidates. Each call is recorded in the calling graph by the node's guid, so the node travels with every graph that uses it, and a rename or a move keeps the reference. A `.procGraph` is called the same way and answers what it returns. ## Nodeboxes A nodebox is the family a node lives in: a namespace folder grouping related nodes (`points`, `mesh`, `field`, `terrain`). `nodebox.assetType` describes it. A node placed in a box takes the box's name as its prefix; a node outside any box is reached by path, `~` or guid. `asset.create("nodebox", family)` makes a box and `asset.create("procNode", name, { into = box })` makes a node in it. ## Finding nodes `asset.list("procNode")` lists every node. The `procgen` toolbox's `searchNodes` finds them by meaning across every published node, and with no query lists the ones this engine holds grouped by family; its `describeNode` answers one node's inputs, their types and defaults, and its outputs. Both read what each node's source declares and run no node. The type's `indexing` recipe embeds a node's README and its source, so a search by meaning finds a node by what its description and README say it is for: write them in the words someone looking for the node would use. ## Registration Every node the asset index lists is known to the procgen registry by what its source declares, read when it is asked for and read again when the source changes; nothing runs a node to list it. Its code loads the first time a build runs it. After that, the lifecycle hooks keep it current: `onChange` loads it again and hot-reloads on an edit, `onDelete` removes it. Editing `init.luau` cooks again every graph that reaches the node, and only the nodes downstream of the change do work. `init.luau` is compiled from its current source on each load, so a module it pulls in uses an absolute require (`require("@builtin::systems.procgen.proc")`). What a node is built from is more than its own file. A module its `init.luau` requires while it builds, at any depth of requires, is part of it: when that module changes, `onDependencyChange` loads the node again from the module as it now stands. A file its `init.luau` reads with `vfs.read` while it builds is part of it too, and so is a file a module it calls reads with `proc.read` (a module's own `vfs.read` is its own and makes no dependency). Writing such a file loads the node again (`proc.sourceChanged`). Either way the node's definition moves, so every graph and Generator reaching it cooks again, from one version of everything it was built from. `proc.builder.readsOf("<node>.procNode/init.luau")` lists the files its last build read. A graph that references a node which is not registered errors at load, naming the missing guid. A graph that reaches itself, directly or through other nodes, errors at cook. ## Content requirements `README.md` carries real text: what the node produces, its inputs and its outputs. `.metadata` carries a `description` (what the node computes and the value type it answers) and `tags` (the family, so search finds it). It may state where the node works: `context`, `pulls` and `pushes` (the values `proc.registry.contexts()`, `"scene"` and `"asset"` name). A node in a nodebox that states none takes its box's; `procgen` `describeNode` and `searchNodes` answer them. A node written with `proc.graph` and `g:node` (the `procNodes/` of the procgen package) is called only by a `proc.graph` graph, through `g:node`. A graph built with `proc.define` does not call it: `g.op.<name>` of it is refused where it is written, naming the node written in the call form that answers to the same name. ## In the Inspector Operation: the node's id and what it does, its cost and caching when it declares them, and its inputs and outputs, from the procgen registry's schema for it. A node that did not register says so.
▲ 0↑ born
◇
component · born here
❒asset
# Light Adds a light source to an entity. The entity's world transform determines the light's position (point) or direction (directional). Point light positions are auto-synced from that world transform, so a light on a child entity burns where the entity stands — the position `entity.position` reports. A point light's `intensity` is on one scale with the `SpotLight` component's `intensity`/`brightness`: the same number at the same `radius`/`range` puts the same light on a surface either kind faces from the same place, and a spot spends it on the cone it opens on rather than all around itself. Kinds: `"point"`, `"spot"`, `"directional"` (the scene's sun), `"ambient"`, `"distant"` (a parallel light beside the sun). Public fields: `kind`, `colorR/G/B`, `intensity`, `radius`, `directionX/Y/Z`, `castsShadows`, `lightChannels`, `mobility`. `range`, `color` and `direction` are aliases accepting the composite/renamed forms. Methods: `:setColor(color)` (color: `{r, g, b}` array or `{r=, g=, b=}` map), `:setIntensity(i)`, `:setRadius(r)`, `:setDirection(dir)`, `:setKind(lightKind)`. `kind = "spot"` opens a cone along the entity's forward axis, at the engine's default 30° outer and 20° inner half-angles; the `SpotLight` component is the one that carries the cone angles and the `face` axis as fields. `"directional"` and `"distant"` are parallel lights: they arrive from the same direction at every point in the world and no distance attenuates them, so their `intensity` reads against the sun's rather than against a point light's. The `SpotLight` README carries the rest of how to balance a mixed point-and-spot rig. ```luau entity(id).component.add("Light", { kind = "point", intensity = 2, radius = 10 }) entity(id).component.add("Light", { kind = "directional", direction = {-0.5, -1, -0.3} }) ```
▲ 0↑ born
▣
module · born here
❒asset
# box The CPU code behind the `shape.box` node: it takes the node's inputs and returns the mesh as a procgen Geometry (`proc.substrate.fromArrays`). The node's README lists the inputs.
▲ 0↑ born
▣
module · born here
❒asset
# buffer The CPU code behind the `shape.buffer` node: it takes the node's inputs and returns the mesh as a procgen Geometry (`proc.substrate.fromArrays`). The node's README lists the inputs.
▲ 0↑ born
▣
module · born here
❒asset
# capsule The CPU code behind the `shape.capsule` node: it takes the node's inputs and returns the mesh as a procgen Geometry (`proc.substrate.fromArrays`). The node's README lists the inputs.
▲ 0↑ born
▣
module · born here
❒asset
# circle The CPU code behind the `shape.circle` node: it takes the node's inputs and returns the mesh as a procgen Geometry (`proc.substrate.fromArrays`). The node's README lists the inputs.
▲ 0↑ born
▣
module · born here
❒asset
# cylinder The CPU code behind the `shape.cylinder` node: it takes the node's inputs and returns the mesh as a procgen Geometry (`proc.substrate.fromArrays`). The node's README lists the inputs.
▲ 0↑ born
▣
module · born here
❒asset
# extrude The CPU code behind the `shape.extrude` node: it takes the node's inputs and returns the mesh as a procgen Geometry (`proc.substrate.fromArrays`). The node's README lists the inputs.
▲ 0↑ born
backing path · systems/quickGeometry.package

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported on this asset or on the parts this page shows. Parts it leaves out are not counted here.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.