@blobscape/engine 0.7.1
Engine docs
How to start with the engine, and everything it exports. The reference is generated with TypeDoc from the doc comments in the package itself, so it can’t drift from the code. Start with Stage, or with the pixel renderer, its own entry; for a longer walk through, take the Build with the engine lessons. It is version 0.x, so the API will change between minor versions.
npm install @blobscape/engine threeGetting started
Install
npm install @blobscape/engine three
three.js is a peer dependency (r187).
A creature on a canvas
import { Stage, makeFox, FOX, recordClip, Swing } from '@blobscape/engine'
const stage = await Stage.start(document.querySelector('canvas')!)
const fox = makeFox(20000) // 20,000 blobs on fourteen bones
const trot = FOX.moves[0]
stage.setActor(fox, recordClip(trot.name, fox.skeleton, trot.pose, trot.seconds, trot.fps))
stage.setSwing(new Swing(fox.skeleton, FOX.swing!)) // the tail swings after the trot
stage.orbit = FOX.view
Stage plays a clip or a poser (setPoser((skeleton, seconds) => ...)), orbits, picks bones (pick(x, y)), shows the bones (setShow('both')), and bakes sprite sheets (bake). Under it, SplatWorld is a three.js object you can add to your own scene.
On any page, with one tag
<blobscape-creature> plays a rigged-splat .glb with no build step and no code: one script, one element.
<script type="module" src="https://blobscape.dev/embed/blobscape-creature.js"></script>
<blobscape-creature src="fox.glb" move="trot" alt="A fox trotting"></blobscape-creature>
The script is one file with three.js inside (about 330 kB compressed). The address above always serves the newest; for a version that stays put, use the file from the package, @blobscape/engine/blobscape-creature.js (in dist/), from your own site or an npm CDN. In an app that already bundles three.js, import '@blobscape/engine/element' defines the same element on your copy. The script sends nothing anywhere; serving it yourself also keeps your visitors' browsers from asking blobscape.dev for it.
src: the file. A creature saved from Splat Creatures or written withwriteRiggedGlb. From another site, that site must allow it (CORS).move: the clip to play. Left out, the file's first.tap: a clip played once when the creature is tapped, or Enter is pressed on it.hover: a clip played while a mouse is over it.look="pointer": its head turns after the pointer. The creature should face +z, and have a bone called head.orbit="none": no turning by drag or arrow keys. On a phone a sideways drag turns it and an up or down drag scrolls the page.azimuth,elevation: where it is seen from, in degrees. It is framed to fit.speed: 1 is real time.poster: a still picture, shown until the creature draws and instead of it where the browser has neither WebGPU nor WebGL 2.alt: what it is, for people who can't see it.
Size it with CSS; it is a square block unless you say otherwise. Nothing is fetched until it nears the screen, it stops drawing when it leaves, and it holds still for visitors who ask for reduced motion. Anything inside the element is shown if it can't draw and has no poster. It fires ready (with detail.moves) and error, and element.stage is the Stage below for anything more.
Your own creature
Shapes are distance functions on a grid of cells; every cell becomes a blob, weighted to the nearest bones so it bends.
import { sculptToCount, ellipsoid, cone, smooth, set, X, type Bone } from '@blobscape/engine'
const bones: Bone[] = [
{ name: 'body', parent: -1, head: [0, 0.5, 0], tail: [0, 0.5, 0.4] },
{ name: 'tail', parent: 0, head: [0, 0.5, -0.3], tail: [0, 0.3, -0.9] },
]
const slug = sculptToCount(() => ({
bones,
blend: 0.05,
parts: [
{ shape: smooth(0.1, ellipsoid([0, 0.5, 0.05], [0.3, 0.25, 0.45]), cone([0, 0.5, -0.3], [0, 0.3, -0.9], 0.18, 0.04)),
color: [0.9, 0.55, 0.3], bones: ['body', 'tail'] },
],
}), 15000)
stage.setActor(slug)
stage.setPoser((sk, t) => { set(sk, 'tail', X, 0.4 * Math.sin(t * 3)); sk.update() })A scene written as data, in pixel art
import { Stage, compileScene, buildVoxels, type SceneDoc } from '@blobscape/engine'
const doc: SceneDoc = { /* how to write one: AGENTS.md in this package */ }
const scene = compileScene(doc) // checks it, then makes bones, poses and lights
const stage = await Stage.start(canvas, { lights: true })
stage.setActor(buildVoxels(scene.spec(0.02)))
stage.setPoser((sk, t) => { scene.pose(sk, t); stage.setLights(scene.lights(t)) })
stage.orbit = scene.orbit
stage.setPixels(scene.look, 4) // palette, dither, outlines, four screen pixels to oneOther looks
Pixel art is one look of several. Each is a call on the stage, and turning one off is the same call with nothing.
stage.setMarks({ kind: 'gouache' }) // or 'oil', 'ink', 'hatch', 'stipple'
stage.setOutline({}) // a pen line round things and between parts
stage.setMarks(); stage.setOutline() // back to soft blobs
setCel (cel shading, on a stage started with lights), setNeon, setGlass (stained glass), setWash (watercolor), setBlocks (cubes on a grid), setGlyphs (the picture as characters) and setGlitch (bursts of broken signal over pixel art) each take their own look: see Pixels and sprites in the reference. A look that lights the picture itself (cel shading, neon, stained glass, blocks) wants the scene cut with no light baked in: wrap the cut in unlit(() => buildVoxels(...)).
Water, lava and fire in a scene
A description's water, lava and fires are simulated, not drawn by hand: one whole loop of each is worked out once and then shown for any moment, so a scene still plays from the time alone. Each is an actor of its own beside the scene's.
import { SceneWater, SceneFire } from '@blobscape/engine'
const pond = scene.water ? new SceneWater(scene) : undefined // `water` or `lava` in the description
const flames = scene.fires.length ? new SceneFire(scene) : undefined // `fires`
const extras = [...(pond ? [pond.surface] : []), ...(flames ? [flames.actor] : [])]
stage.setActor(buildVoxels(scene.spec(0.02)), undefined, extras)
const eye = [0, 1.5, 4] // where the camera is: reflections and glints are worked out for it
stage.setPoser((sk, t) => {
scene.pose(sk, t)
pond?.ride(sk, t) // boats and buoys rock on the water
pond?.show(t, eye)
if (pond) stage.reshape(pond.surface)
flames?.show(t, eye)
if (flames) stage.reshape(flames.actor)
const lights = scene.lights(t)
stage.setLights(flames ? flames.shine(lights, t) : lights) // a fire's light is as bright as it burns
})
Water, LavaHeat and Fire are the solvers underneath, for stepping them yourself.
Lamps, weather and the shared sky
A light, a glowing part or a swarm of specks says when it is lit (lit: 'dark', 'night', 'day' or 'always'), and litFor(doc, dark) gives the description as it stands by day or in the dark, to compile like any other. A description's heavens asks for the shared moon, sun, stars and clouds in place of drawing its own.
Weather is numbers, the same for every scene. skyState turns a weather, a cloud cover and a wind into a SkyState; SkyEase mixes from one to the next, so a storm comes on without cutting the scene again.
import { skyState, SkyEase, lightUnder, windAt, lightningAt } from '@blobscape/engine'
const sky = new SkyEase()
sky.set(skyState('thunderstorm'), performance.now() / 1000)
stage.setPoser((sk, t) => {
const now = sky.at(performance.now() / 1000)
scene.pose(sk, t)
scene.blow(sk, t, windAt(now, t, scene.loop)) // what falls slants, what sways leans
sk.update()
const flash = now.lightning * lightningAt(t, scene.loop)
stage.setLights(scene.lights(t), lightUnder(now, flash))
})
SceneWeather is the rain, snow, clouds and lying snow for one scene, made once and then posed by the time and the sky of the moment:
import { SceneWeather, timeOf, litFor } from '@blobscape/engine'
const weather = new SceneWeather({ loop: scene.loop, view: scene.orbit, ground: scene.ground })
stage.setActor(buildVoxels(scene.spec(0.02)), undefined, weather.actors)
// in the poser, after the scene's own pose:
// weather.pose(t, now)
// if (weather.shade(now)) stage.reshape(weather.actors[0]) // clouds as gray as the sky
const night = timeOf('night') // a time of day: its sky, its light, whether lamps are lit
const byNight = compileScene(litFor({ ...doc, sky: night.sky }, night.dark))
stage.setLights(byNight.lights(0), night.light)
Underneath are weatherDocs and showWeather (the three small descriptions and the share of them a sky shows), skyUnder and hazeUnder (the sky's colors and the haze), makeSnowCover and pileSnow (the snow that lies), and paletteUnder and paletteAt (a pixel palette under a sky or a time of day). WEATHERS, CLOUD_COVERS, WINDS and TIMES list what there is.
Styles as data
Every style's settings are written once, as data: CATALOG holds each one's name, limits, choices and where it starts, so a page can draw its controls from the list, read them from an address and keep them, and every page draws a style the same way. STYLES lists the styles; each look has a function from its settings to what the stage takes.
import { STYLES, CATALOG, drawnStart, shownSettings, lightsItself, celLook, neonLook, washLook } from '@blobscape/engine'
const settings = drawnStart(new URLSearchParams(location.search)) // every look as it starts, with what the address asks
for (const s of shownSettings(CATALOG.neon, settings.neon, { style: 'neon' })) console.log(s.label, s.kind) // what to draw controls for
stage.setNeon(neonLook(settings.neon, scene.loop)) // its light runs a whole number of times a loop
stage.setNeon(); stage.setWash(washLook(settings.watercolor))
lightsItself('cel') // true: cut the scene with `unlit` first, on a stage started with `lights`
const cel = settings.cel
stage.setCel(celLook({ ...cel, line: cel.outline ? cel.pen : 0 }))
console.log(STYLES.map((s) => s.label)) // every style there isA scene from a land and props
A scene can be put together instead of written whole: a SceneProject names a land and props and says where each stands, and composeScene makes one ordinary description of it. Fix a prop and every scene that sets it down has the fix.
import { composeScene, splitScene, markedPicks, compileScene, type SceneProject } from '@blobscape/engine'
// any description whose bones are marked `prop: 'Name'` splits into its land and its props
const { land, props } = splitScene(doc, markedPicks(doc))
const lantern = props[0]
const project: SceneProject = {
kind: 'blobscape-project', version: 1, name: 'Two lanterns', loop: doc.loop, land,
props: [
{ prop: lantern, at: [-0.6, 0, 0], turn: 0, size: 1 },
{ prop: lantern, at: [0.6, 0, 0.2], turn: 90, size: 0.8, phase: 0.5 },
],
}
const both = compileScene(composeScene(project, () => undefined))
Props and lands carry tags from one fixed list (TAGS): what a thing is, for search, and how it behaves, which the shared recipes act on (a leafy prop drops leaves, one that floats rides the water). compileProject compiles a project apart, a piece at a time, which is what an editor wants.
The pixel renderer
New in this release and likely to change: its names and settings may move between minor versions.
@blobscape/engine/pixel is a second renderer for sharp pixel art: a scene is cut into hard surfels, drawn on a bare WebGL 2 context (no three.js) through a camera snapped to the art's pixels, and lit and painted a pixel at a time. It is its own entry and needs no three.js; what it shares with the main entry (the scene compiler, the cutter, Skeleton) is one copy in shared chunks, so an app that uses both loads that code once.
import type { SceneDoc } from '@blobscape/engine'
import { PixelStage, ScenePlay, cutPixelScene, pixelStyle, playableScene } from '@blobscape/engine/pixel'
declare const doc: SceneDoc // a scene description (AGENTS.md); give it `fires` for a fire, `water` for a pond
declare const canvas: HTMLCanvasElement // the stage fills the canvas's parent: give that the view's size
const scene = playableScene(doc, { time: 'night' }) // its lamps and fire lit, a night sky; no time: as written
// a second or more: in an app, call playableScene and cut in a worker, and post the cut back with `pixelSceneBuffers(cut)`
const cut = cutPixelScene(scene.source, { spacing: 0.017 })
const stage = new PixelStage(canvas)
stage.onError = (message) => console.error(message) // a device that can't draw it says so here
stage.setStyle(pixelStyle('pixel')) // or any of PIXEL_STYLES: 'cel', 'oil', 'halftone', 'text'...
stage.setLook({ size: 3 }) // an art pixel is three CSS pixels
const play = new ScenePlay(stage, scene, { weather: 'light-rain', wind: 'breeze' })
play.show(cut) // the scene, its fire, the clouds, the rain on its water
stage.play()
// later: the sky eases there over a few seconds, and the fire goes out in the downpour
play.setSky({ weather: 'thunderstorm', wind: 'gale' })
ScenePlay plays the scene with everything that goes with it: its water (swells, the wind's waves, the rain's rings, foam and spray), its fires (blown by the wind, damped and put out by rain), the weather (WEATHERS, CLOUD_COVERS, WINDS: clouds marched a pixel at a time, rain and snow that land on the scene, snow lying, lightning), the shared moon and stars, and a sky effect (SKY_EFFECTS: an aurora or a meteor shower, out at night under a clear sky). What the scene's setting leaves no room for (rain in a room, wind under water) is left out whatever is asked. show lays the scene's own sun on the stage; to change the style afterward use play.setStyle(style), which keeps that sun under the style's own light. The engine's ScenePlayer does the work each frame; pixelPlayerFor is the same wiring for a page that eases the sky itself, and pixelView(orbit) frames a PixelPlayer written by hand as the scene's own view is framed. pixelStyleSettings(style) lists what a style offers to change, with labels and limits, and styleWith lays chosen values on it.
Names and units. Where both entries have a name it means one thing: Vec3, Rgb (palette colors, 0 to 255), the weathers, winds and times of day are the same exports. Six of this entry's names in 0.7.0 meant something else in the main entry, so they are renamed (and DEFAULT_LOOK with them): PixelLook is now PixelStageLook, DEFAULT_LIGHT and DEFAULT_LOOK are DEFAULT_PIXEL_LIGHT and DEFAULT_PIXEL_LOOK, and Lamp, WaterLook, GlassLook and CutoutLook are PixelLamp, PixelWaterLook, PixelGlassLook and PixelCutoutLook. The old names still work for one release, marked deprecated. On the pixel stage an art pixel is setLook({ size }) CSS pixels; the lengths of lines, strokes, engravings, water, glass and paper cutout are in art pixels, a screen style's sizes in CSS pixels, places and heights in the scene's units; a look's colors are sRGB 0 to 1, while lamps, haze and the light from all round are linear.
Files
writeRiggedGlb saves blobs, bones and clips as a .glb: the KHR_gaussian_splatting standard plus ordinary glTF skins and animation, and a small extension for how a skinned blob turns (the rule). readRiggedGlb opens one. Blender and game engines open the bones and clips; three.js's own loader shows the blobs standing still.
Longer guides
- Your first creature: a lesson you play with, ending in the code for what you made.
- A scene written as data: a lesson you play with, ending in the code for what you made.
- Pixel art that holds still: a lesson you play with, ending in the code for what you made.
- Writing a scene description: every shape, paint and move a scene written as data can use.
- Rigged Gaussian splats in glTF: the rule the .glb files follow.
Core
What every page needs: a stage on a canvas, the world of blobs it draws, the camera, and the bones that move them. Start here.
Stage: a creature or scene on a canvas
MIRROR_PACEvalue
How many times a second a stage draws its mirror's picture again, at most (Stage.setMirror).
24StageActorinterface
What a stage shows: blobs, the skin that ties them to bones, and the skeleton.
Properties
blobsBlobsThe blobs in the rest pose.
skinSkinWhich bones move each blob, and by how much.
skeletonSkeletonThe bones, and their pose.
morphsMorph[]optionalBlend shapes (from an opened .glb): a clip's weights, or
setMorphWeightswhile none play, reshape the blobs on the CPU.glowUint8Array<ArrayBufferLike>optionalHow much of its own light each blob gives, a byte a blob (255 all of it): a flame, a lit window. It only matters under live lights.
laidUint8Array<ArrayBufferLike>optionalBlobs of a face laid over another part (voxel.ts
laid: a pane on its frame), a byte a blob: drawn as blocks, a cell takes their color before the color of what they lie on.softbooleanoptionalStays blobs while the stage draws blocks (
setBlocks): grass and the like, drawn among the cubes. It makes no cubes.flowsbooleanoptionalA surface that moves by itself and is sent up again with
reshape(a pond's): while the stage draws blocks it is columns that follow it, or stays blobs, as the look'sflowsays.weatherbooleanoptionalWeather laid over a scene (its clouds, rain, snow): while the stage draws blocks it is cubes too, or stays blobs among them, as the look's
weathersays.liesbooleanoptionalLies on the scene's surfaces (snow lying): while the stage draws blocks it is raised half a cube, onto the cubes' tops, which stand up to a cube over the surface the blobs lie on.
blockCellnumberoptionalThe side of its cubes while the stage draws blocks (
setBlocks), where it was cut on a grid of its own; left out, the look'scell.gridnumberoptionalThe side of the grid its blobs stand on (voxel.ts
Built.grid): blocks finer than that fill each blob's square, so its rows never show as gaps (blocks.tsBlockSource.grid).holeBlockHoleoptionalWhile the stage draws blocks, the square (x and z, rest units) whose cubes are not drawn, where a finer cut is laid in (blocks.ts
BlockSource.hole).keepCubesbooleanoptionalIts blobs never change in place, so while the stage draws blocks its cubes are made once and kept (blocks.ts
BlockSource.keepCubes).farbooleanoptionalAs big as a world: while the stage draws blocks, its squares far away are drawn with cubes two or four times as big (blocks.ts
BlockSource.far).
Showtype
What the view shows: the blobs, the bones that move them, or both (bones on top).
"blobs" | "bones" | "both"PickedBoneinterface
A bone found under the pointer (or stepped to): what the page says about it.
Properties
bonenumberThe bone's index in the skeleton.
labelstringIts name for people: 'left forearm'.
blobsnumberHow many blobs it moves at all.
StageOptionsinterface
How a Stage starts.
Properties
offscreenbooleanoptionalDraws into a render target and copies each frame to a 2D canvas on request: headless test browsers can render WebGPU but not show it.
lightsbooleanoptionalBuilds each world with live lights (
setLights), as Scan Studio does.shadowDensitynumberoptionalHow dark what stands in a casting light's way makes it (the world's
shadowDensity): left out, soft shadows that thin things let light through.webglbooleanoptionalUses the WebGL 2 backend even where WebGPU would start: for testing the fallback.
cleanCutsbooleanoptionalBuilds each world so cuts (
setEdits) have a clean edge, tested per pixel (setCleanCutsturns it off and on).exactShapesbooleanoptionalBuilds each world to draw blobs in their true shape on screen (
EngineOptions.exactShapes;setExactShapesturns it off and on).peelbooleanoptionalBuilds each world so see-through blobs can be put in order where they cross (
setPeel;EngineOptions.peel).timerbooleanoptionalAsks the GPU to time its own work, so
gpuTimescan say how long a frame takes on the GPU alone. Where the browser offers no timer (WebGL withoutEXT_disjoint_timer_query_webgl2, WebGPU withouttimestamp-query) it does nothing. Off by default: each pass then writes two timestamps.
GpuTimesinterface
How long the GPU spent on one frame, in milliseconds (Stage.gpuTimes).
Properties
computenumberCompute passes: posing, projecting, sorting, lighting. WebGL has none, so 0 there.
rendernumberRender passes: drawing the blobs and every pass after them (pixel art, outlines, the lens).
cpunumberThe CPU's share: posing and handing the frame to the GPU (on WebGL, sorting too). The two overlap, so a frame takes about the larger of this and the GPU's.
Stageclass
The engine's front door: one rigged creature (or a scene) on a canvas, drawn by SplatWorld through three.js's WebGPU renderer, which falls back to WebGL 2 where a browser has no WebGPU. Every blob is moved by its bones on the GPU, so a creature can have hundreds of thousands. It plays a clip or a poser, orbits, picks bones, draws pixel art and bakes sprite sheets.
const stage = await Stage.start(canvas)
stage.setActor(makeFox(20000), recordClip('trot', ...))On blobscape.dev it is the Creature page's view (CreatureStage) and every engine experiment's.
offscreen draws into a render target and copies each frame to a 2D canvas on request: headless test browsers can render WebGPU but not show it.
Properties
rendererWebGPURendererread onlyThe three.js renderer the stage made and draws with.
backend"webgpu" | "webgl"read onlyWhich backend the renderer started on: WebGPU, or WebGL 2 where a browser has none.
orbitOrbitWhere the camera looks from. Set it to move the view.
playingbooleanWhether time moves on. False holds the pose.
speednumberHow fast time runs: 1 is real time, 0.5 half speed.
stepnumberHeld frames: above 0, the pose only moves on every
stepseconds and the picture is left alone in between, like animation drawn at a few frames a second. In pixel mode that is what stops edges crawling.onFirstFrame() => voidoptionalCalled once, after the first frame with a creature in it has been drawn.
blobCountnumberread onlyHow many blobs the creature shown has.
blockCount{ blocks: number; faces: number; levels: number[] } | undefinedread onlyHow many cubes and faces are on show while the scene is drawn as blocks.
sortKind"bins" | "radix"read onlyWhich depth sort the world uses: the counting sort, or the exact radix sort (slower; ties always in one order).
timenumberread onlySeconds into the clip, or the time a poser is showing.
glitchNowGlitchStateoptionalThe glitch laid on the last frame drawn (none while no burst is on).
artSize{ width: number; height: number } | undefinedread onlyPixel mode's art size in pixels, once a frame has been drawn.
timesGpubooleanread onlyWhether
gpuTimescan answer: the stage was started withtimerand the browser lets the GPU time its work.
Methods
setSharpness()How many device pixels to a CSS pixel the stage draws at, at most (2 where never set; the screen's own where that is less). Under 2 on a sharp screen every pass has fewer pixels to fill, for a softer picture: a page may ask for it on a phone while it draws a costly look.
setSharpness(most: number): voidstart()staticStarts a stage on a canvas: makes the renderer (WebGPU, or WebGL 2 where there is none) and begins drawing.
start(display: HTMLCanvasElement, opts?: StageOptions): Promise<Stage>shown()Resolves once a frame drawn from now on is through the GPU: called after
setActor, that is when the new creature is really on screen, which on a phone can be seconds after the call returns (buffers to fill, shaders to build). A page keeps its waiting mark up until then. At once on anoffscreenstage, which draws only when asked.shown(): Promise<void>setActor()Shows a creature, replacing the last one, and plays
clipon it.extrasare more actors drawn in the same world, sorted blob by blob with the first: things that move on their own and not by its bones, such as the surface of a pond (reshapesends one up again after its blobs were changed). Clips, posers, picking, tints and sheets are all about the first actor.setActor(actor: StageActor, clip?: Clip, extras?: StageActor[]): voidsetBlocks()Draws the scene as blocks (blocks.ts): its blobs snapped onto a grid of
look.cell, each filled cell a cube in one flat color, lit face by face, with the shadows blocks cast on each other. Cubes ride the bones their blobs did, so the scene still moves. The stage's lights (setLights) shine on the faces as lamps and its ambient light dims the look's own. It suits blobs with no light baked into them, and scenes more than small creatures. Leave the look out to stop. Kept for the next actor too; the cubes are made again for each. Not in pixel mode, and it comes before every other look.setBlocks(look?: BlockLook): voidtint()Shows the actor in other colors without changing it:
paintgives each blob's color (sRGB, 0–1) from its own and its place in the list, and may give a fourth number, a share of the blob's own opacity (0 hides it). Left out, its own colors come back. It stays through a new actor, until it is taken off;highlightandrefreshsend the actor's own colors again, so call it again after them, and take it off beforebake.tint(paint?: (color: readonly [number, number, number], blob: number) => readonly number[]): voidsetFarDetail()Level of detail by distance (lod.ts
FarRule), kept for every world from now on: pastfromfewer blobs are drawn the further off they are, each grown to cover for the rest, so a world as big as an island draws far ground with fewer, bigger blobs. Leave it out for every blob. The soft actors drawn among blocks keep every blob.setFarDetail(rule?: FarRule): voidsetSort()Changes how blobs are sorted by depth: 'bins' is quick, 'radix' settles every tie the same way each frame, which pixel art with hard edges wants.
setSort(kind: "bins" | "radix"): voiduseLights()Whether worlds are built with live lights (the
lightsoption, changed after the start), from the nextsetActoron: a page turns them on for the one creature that wants them and leaves the rest as light to draw as they were.useLights(on: boolean): voidsetClip()Plays another clip on the creature shown, or none.
fromis the time it starts at, in seconds (left out, time runs on).setClip(clip?: Clip, from?: number): voidsetAfter()Runs
aftereach time the creature is posed, once its clip or poser has set the bones and before loose parts swing: for a change laid on top of any move, such as a head turned to look at something. It must leave the skeleton updated. It stays through a new clip and goes with a new actor.setAfter(after?: (sk: Skeleton, t: number) => void): voidsetPoser()Poses from the time instead of a clip;
tstarts atfromseconds.setPoser(poser?: (sk: Skeleton, t: number) => void, from?: number): voidrecolor()Takes one actor's colors and opacities again after they were changed in place (the one shown or one of its
extras), when nothing moved: a floor that scorches. Givenfromandto, only those of its blobs go up (the light thrown off water, caustics.ts). The shown actor's colors go up throughtint's painter while one is on.recolor(actor: StageActor, from?: number, to?: number): voidsetSwing()Loose parts that swing after the body while a move plays (a
Swingmade for this actor's skeleton), or none.setSwing(swing?: { update: any; reset: any }): voidsetMorphWeights()The morphs' weights while no clip keys them (the clip's own weights win while it plays).
setMorphWeights(w: ArrayLike<number>): voidrefresh()After the actor's blobs were changed in place (a poser may do it each frame): the engine takes them again.
refresh(): voidreshape()After one actor's blobs were changed in place (the one shown or one of its
extras): the engine takes that actor's centers, shapes and colors again and leaves the rest alone, which is what a pond's surface wants each frame. The count must not change, and the blobs must stay about where they were.reshape(actor: StageActor): voidsetMirror()Draws what a flat mirror shows of the scene (
SplatMirror) and hands each picture toseenas it is read back, a frame or two later: for water, or a polished floor, whose blobs color themselves from it (seenIn()). The picture is drawn again when the pose or the view changes, at mostMIRROR_PACEtimes a second.liftleaves out blobs lower than that over the plane (the mirror's own). Offscreen,framewaits for the picture of its own moment before it draws. Left out, the mirror is taken away.setMirror(mirror?: { plane: MirrorPlane; lift?: number; width?: number; seen: (image: MirrorImage) => void }): voidseek()Moves the clock to
secondsand draws that moment: for a page that kept its own time while this stage was paused.seek(seconds: number): voidsetMode()Changes how a blob on several bones takes its shape: see
SkinMode.setMode(m: SkinMode): voidsetLightEase()Eases live light over about
framesframes (the world'slightEase; 0 is none; WebGPU only), kept for the next actor too: a shadow's edge crossing a blob fades instead of popping. For lights that move slowly, like a sun.setLightEase(frames: number): voidsetShadowDensity()How dark what stands in a casting light's way makes it (the world's
shadowDensity), kept for the next actor too: lower for fur and grass, which shade themselves dark at the engine's own.setShadowDensity(density: number | undefined): voidsetFog()Distance fog toward
color(linear) fromneartofarunits from the camera (far0 is none); kept for the next actor too.setFog(color: [number, number, number], near: number, far: number): voidsetEdits()Cuts by shape, live (edit.ts): spheres, boxes or upright cylinders in world space, kept for the next actor too; [] clears them. On a stage made with
cleanCutsthe edge is the shape's own line.setEdits(edits: readonly ShapeEdit[]): voidsetExactShapes()On a stage made with
exactShapes: whether blobs are drawn in their true shape (the default) or flattened from their middles.setExactShapes(on: boolean): voidsetCleanCuts()On a stage made with
cleanCuts: whether cuts have the clean edge (the default) or drop whole blobs.setCleanCuts(on: boolean): voidsetOutline()Draws outlines over the picture as a pen would (inkLines.ts): round the subject, where one thing stands in front of another, and between its parts. Leave the pen out to stop. With any look, or none; pixel mode has its own lines.
setOutline(pen?: OutlinePen): voidsetCel()Cel shading (splat-core/cel.ts), on a stage made with
lights: every blob flat in its own color, the light cut into two or three tones with clean edges, shadows cast by what stands in the light's way, and an even outline. The tones are cut from the look's own light, and the stage's lights (setLights) stay as the scene's lamps: where they reach is one more tone in their color, and the ambient light dims both tones. Its fill takes the place of the stage's marks while it is on; leave the look out to have them back. Kept for the next actor too. It shades the blobs' own colors, so it suits blobs that have no light baked into them. In pixel mode it shades the small picture the pixel art is made from, so the light falls in bands that follow each form a pixel at a time; the outline is the pixel art's own then.setCel(look?: CelLook): voidsetNeon()Neon (splat-core/neon.ts): tubes of glowing light along the outlines, in each thing's own color at full strength or the look's colors, with pulses of light running along them by the stage's clock; the bodies are kept dark and catch the light as it passes. On a stage made with
lights, whatever gives its own light (Actor.glow: a lamp, a lit window, a flame) is filled with it and lights the bodies round it too. Every blob is drawn flat in its own color while it is on, with the stage's lights put by, so it suits blobs that have no light baked into them. Leave the look out to stop. Kept for the next actor too. Not in pixel mode; ASCII and cel shading come first if set, and outlines and the lens wait.setNeon(look?: NeonLook): voidsetWash()Watercolor (splat-core/wash.ts): the picture laid on paper as thin see-through washes whose edges run and dry darker, with the paper's grain showing through, the lightest places left bare, a wash of the look's sky behind and a faint pencil line underneath. The paper covers the canvas. Every blob is drawn flat in its own color while it is on, under the stage's own lights. Leave the look out to stop. Kept for the next actor too. Not in pixel mode; ASCII, cel shading, neon and stained glass come first if set, and outlines and the lens wait.
setWash(look?: WashLook): voidsetHalftone()Halftone screen print (splat-core/halftone.ts): the picture printed in the look's few see-through inks, each as dots on its own turned screen fixed on the paper, the dots growing and running together where the picture is dark in that ink, the plates a little off true and the ink taking unevenly; the subject's sky is printed behind it, or the paper left bare. The paper covers the canvas. Every blob is drawn flat in its own color while it is on, under the stage's own lights. Leave the look out to stop. Kept for the next actor too. Not in pixel mode; ASCII, cel shading, neon, stained glass and watercolor come first if set, and outlines and the lens wait.
setHalftone(look?: HalftoneLook): voidsetFilter()One of the looks laid over the whole picture (splat-core/filters.ts): a thermal camera, an old CRT or tape, a blueprint, a mosaic, paper cutouts or claymation. The look covers the canvas. The blueprint and paper cutouts draw every blob flat in its own color with no lights; the thermal camera draws what gives its own light over white so it runs hot; claymation moves in held frames (
ClayLook.fps) unless the stage holds its own. Leave the look out to stop. Kept for the next actor too. Not in pixel mode; the other looks come first if set, and outlines and the lens wait.setFilter(look?: FilterLook): voidsetKnit()Knitting (splat-core/knit.ts): the picture as a sweater, a grid of stitches fixed on the screen, each a V of yarn in the look's yarn nearest what it shows, with the sweater's own pattern of bands and snow dots knitted round the subject. The knitting covers the canvas. Every blob is drawn flat in its own color while it is on, with the stage's lights put by, so it suits blobs in flat colors with no light baked into them. Leave the look out to stop. Kept for the next actor too. Not in pixel mode; ASCII, cel shading, neon, stained glass and watercolor come first if set, and outlines and the lens wait.
setKnit(look?: KnitLook): voidsetAnaglyph()3D glasses (splat-core/anaglyph.ts): the frame drawn from a left and a right eye either side of the camera and laid over each other in red and cyan, so that through red and cyan glasses the scene stands in depth. What the view looks at sits at the screen (unless the look's
poppushes the screen back), the backdrop behind it. The blobs are drawn as they are (marks, lights), sorted once for each eye. Leave the look out to stop. Kept for the next actor too. Not in pixel mode; the other looks come first if set, and outlines and the lens wait.setAnaglyph(look?: AnaglyphLook): voidsetGlass()Stained glass (splat-core/glass.ts): every surface cut into panes of flat colored glass that stay on it as the view turns, lead between the panes and round every part, the light behind, and the empty picture round the subject glazed too, so the canvas is covered. Every blob is drawn flat in its own color while it is on, with the stage's lights put by, and lead runs wherever that color changes, so it suits blobs in flat colors with no light baked into them. Leave the look out to stop. Kept for the next actor too. Not in pixel mode; ASCII, cel shading and neon come first if set, and outlines and the lens wait.
setGlass(look?: GlassLook): voidsetGlyphs()Draws the picture as characters (glyphPass.ts): a grid of cells fixed on the screen, each with the character whose ink matches how much of the cell there is to show, or a stroke along an edge that runs through it. Leave the look out to stop. Not in pixel mode; outlines and the lens wait while it is on.
setGlyphs(look?: GlyphLook): voidglyphText()The picture as text, a line a row of cells, while it is drawn as characters (
setGlyphs) and once a frame has been.glyphText(): Promise<string | undefined>setLens()Draws the picture through a lens (lens.ts): light spilling round bright things, and blur for whatever is nearer or farther than the distance in focus. Leave the look out to stop. Not in pixel mode, and outlines take its place while they are on.
setLens(look?: OpticsLook): voidsetPeel()On a stage made with
peel: takes the nearestlayersblobs (1 toMAX_PEEL) off the front of each pixel one at a time (peel.ts), so see-through blobs that cross are each in front on their own side; 0 stops. Everything that is not blobs is drawn under them all. Costs a draw of the blobs a layer and one more. Not in pixel mode, and any other look comes first.setPeel(layers: number): voidsetMarks()Draws every blob as a brush mark or an ink stroke, or as soft dots again when left out; kept for the next actor too. The marks belong to the blobs, so they stay put as the view turns.
setMarks(look?: MarkLook): voidsetLights()Live lights on the world (needs the
lightsoption); kept for the next actor too. A light is at a place or from a direction (a sun);ambientis one brightness or a linear color.setLights(lights: Light[], ambient?: number | readonly [number, number, number]): voidsetGlowGain()How many times its own color a blob that gives its own light (
Actor.glow) is drawn under live lights (the world'sglowGain), kept for the next actor too. Over 1 only with a lens (setLens), which lets what is brighter than white glow; drawn straight to the screen it clips.setGlowGain(gain: number): voidsetFloor()A floor
sizeacross in half-unit squares, so the grid shows how big each creature is.setFloor(size: number): voidsetShow()Shows the blobs, the bones, or both.
setShow(s: Show): voidsetPixels()Pixel mode on (with a look) or off.
sizeis how many CSS pixels across one art pixel is; the art is that many times smaller than the view.setPixels(look?: PixelLook, size?: number): voidsetGlitch()Tech glitch over pixel mode's art (splat-core/glitch.ts): now and then a burst of slid rows, split color and corrupted blocks, in steps of the stage's own clock, so a loop drawn frame by frame joins up. The art read back (
pixelFrames) stays clean:glitchArt(art, stage.glitchNow)lays the same glitch on it. Leave the look out to stop. Only in pixel mode.setGlitch(look?: GlitchLook): voidpixelFrames()Pixel mode's last frame as it was drawn small, and as finished art (exactly in the look's colors): for tests and for saving.
pick()The bone under a point on the view (CSS pixels from its top left), as the creature stands now: the bone that holds most of the blob the pointer is on. Undefined when the pointer is off the creature.
pick(x: number, y: number): PickedBone | undefinedrayAt()The line from the camera through a point on the view (CSS pixels from its top left), in world space.
rayAt(x: number, y: number): { origin: [number, number, number]; direction: [number, number, number] } | undefinedscreenAt()Where a point in world space falls on the view, in CSS pixels from its top left, for drawing over the picture; undefined behind the camera.
orbitis the view to use when it is not the stage's own yet.hitAt()The bone under a point on the view (CSS pixels from its top left) and where the pointer meets it, in world space.
hitAt(x: number, y: number): { bone: number; point: [number, number, number] } | undefinedboneInfo()What the page says about a bone.
boneInfo(bone: number): PickedBone | undefinedhighlight()Lights up one bone and the blobs it moves (or none).
highlight(bone?: number): voidinvalidate()Asks for the next
framesframes to be drawn. Call it after changing something the stage can't see, such as itsorbit.invalidate(frames?: number): voidgpuTimes()Poses and draws the frame as it stands
framestimes over and asks the GPU how long it spent: per frame, in milliseconds. Unliketimed, the GPU's own clock, so the browser's late and wandering report of work done does not come into it, and the time is split between compute and drawing. Null where the stage can't time the GPU (timesGpu): start it withtimerand usetimedas the fallback.gpuTimes(frames?: number): Promise<GpuTimes | null>frame()Offscreen only: draws the frame
tseconds into the clip and copies it to the page.frame(t: number): Promise<void>bake()Draws the creature on show as a pixel-art sprite sheet (bakeSheet.ts), with the floor and bones out of the picture and the live view paused, then puts the view back as it was.
bake(moves: SheetMove[], opts: BakeOptions, progress?: (done: number, total: number) => void): Promise<BakedSheet>dispose()Stops drawing and frees what the stage made.
dispose(): void
CreatureStageanother name
The name the site's pages use.
Another name for Stage.
SplatWorld: every blob in one three.js object
Actorinterface
Blobscape's splat engine: one mesh that draws every blob of every object in a scene, so objects that overlap (stems in a vase, a fox in long grass) sort against each other blob by blob, instead of object by object.
Every blob hangs on bones. A still object is one bone; a creature is a skeleton. Each frame:
1. deform (compute): each blob's center and shape go from its rest pose to the world through its bones, as skinBlob() in rig.ts does on the CPU; 2. sort (compute): every blob in the scene by depth, one counting sort; 3. draw: one instanced quad per blob, projected and shaded as in 3DGS.
It draws through three.js's WebGPURenderer, so it shares a depth buffer and a camera with ordinary three.js meshes. On the WebGL backend the deform and sort run on the CPU and the result is uploaded; the drawing is the same.
The projection and shading follow three.js's GaussianSplat (MIT), which in turn follows the 3DGS paper; what's new here is the shared sort and skinning.
Properties
blobsBlobsThe blobs in the rest pose.
skinSkinWhich bones move each blob, and by how much.
skeletonSkeletonThe bones, and their pose.
partOfArrayLike<number>optionalWhich part of the actor each blob belongs to (as
buildBody()andvoxelBodygive it): whatSplatWorld.partsdraws. Left out, the actor is one part.seenUint8Array<ArrayBufferLike>optionalHow much of each of the first four live lights a blob can see, four bytes a blob (255 sees it all): baked lamp shadows (voxel.ts
lamps). The light pass scales light k by byte k, so a flickering lamp's shadows flicker with it. Left out, every light reaches every blob.glowUint8Array<ArrayBufferLike>optionalHow much of its own light each blob gives, a byte a blob (255 all of it): a lit window, a firefly, the moon. Under live lights such a blob is never drawn darker than this share of its own color, so it stays bright when the scene goes dark. Left out, nothing glows.
morphsMorph[]optionalBlend shapes (morph.ts), set with
SplatWorld.setMorphWeights: on WebGPU a pass before the deform reshapes the blobs; on WebGL the CPU does and uploads them.softbooleanoptionalStays blobs while the stage draws blocks (
Stage.setBlocks): grass, flowers and the like, too fine to be cubes, drawn among them and hidden by them where they stand in front. It makes no cubes.flowsbooleanoptionalA surface that moves by itself and is sent up again with
reshape(a pond's): while the stage draws blocks it is columns that follow it, or stays blobs, as the look'sflowsays.weatherbooleanoptionalWeather laid over a scene (its clouds, rain, snow): while the stage draws blocks it is cubes too, or stays blobs among them, as the look's
weathersays.liesbooleanoptionalLies on the scene's surfaces (snow lying): see the stage's
Actor.lies.grownumberoptionalHow many times its blobs' own size a renderer that draws blobs as hard discs should draw this actor's (a soft blob is seen well past its size, a hard disc ends at it: sea spray's droplets are under a pixel otherwise).
blockCellnumberoptionalThe side of its cubes while the stage draws blocks, where it was cut on a grid of its own; left out, the look's
cell.levelsUint8Array<ArrayBufferLike>optionalEach blob's level of detail, a byte a blob (merge.ts
levelCode()), withlevelCell: an actor made bymergeLevels()carries coarser copies of its blobs, and a blob is drawn only while its level suits its distance (levelWeight()). Left out, every blob is drawn at every distance.levelCellnumberoptionalThe side of the grid the finest of
levelswas cut on, in the actor's own units.
MAX_MORPH_TARGETSvalue
How many morph targets a world takes, over all its actors.
32EngineOptionsinterface
How a SplatWorld is built: its sort, how a blob on several bones turns, and whether it lights or paints its blobs.
Properties
binsnumberoptionalDepth buckets for the counting sort. More buckets, fewer ties between blobs that are close in depth.
sort"bins" | "radix"optional'bins' (the default): a counting sort over
binsdepth buckets, small buckets settled into index order. 'radix': a stable radix sort over 2²⁴ depth steps (radix.ts), every tie in index order however many share it.lightsbooleanoptionalLive lights (
setLights): each blob is lit every frame from its normal. Off unless asked for, as it costs a pass.shadowDensitynumberoptionalHow dark what stands in a casting light's way makes it (
SHADOW_DENSITY, 1.5, where left out): low, a shadow is soft and thin things let light through; about 5, a wall one blob thick blocks nearly all of it, which suits solid scenes under a sun.paintbooleanoptionalPaint edits (
setEditswith op 'paint'): needs the same color pass as lights. Cuts work without it.cleanCutsbooleanoptionalCuts with a clean edge: a blob a cut passes through is kept and each of its pixels is tested against the cut, so the edge is the shape's own line and not a row of whole blobs. Costs the draw a test per pixel while there are edits;
cleanCutson the world turns it off and on again.exactShapesbooleanoptionalDraws each blob in its true shape on screen (
exactShapeson the world turns it off and on): each pixel is shaded by the most of the blob along its own line of sight, where otherwise a blob is flattened onto the screen as seen from its middle, which bends blobs close to the camera, large ones and ones seen at a slant out of shape. Costs the draw a little per pixel, the quads of close blobs some size, and on WebGPU the same two buffers clean cuts bind.peelbooleanoptionalLets
SplatPeel(peel.ts) take the nearest blobs off the front of each pixel one at a time, so see-through blobs that cross are each in front on their own side. Costs nothing until a peel draws; the world binds one more texture.
PointLightinterface
A point light for setLights.
Properties
position[number, number, number]Where it is, in world space.
color[number, number, number]Linear RGB, times its strength: [1, 0.6, 0.3] is a torch at full strength.
rangenumberIts reach: about a quarter strength at this distance, and gone by twice it.
shadowbooleanoptionalWhether it casts shadows (
shadow.ts): blobs between a blob and the light take some of it. Off unless set.coneLightConeoptionalIt shines one way only, as a street lamp or a headlight does (
LightCone). The pixel renderer lights only what is inside the cone and draws the light in the air there;SplatWorldtakes no notice and lights all round.
LightConeinterface
The cone a light shines in (PointLight.cone): its tip is at the light.
Properties
toward[number, number, number]The way down its middle, of length 1.
anglenumberFrom its middle to its edge, in degrees (under 90).
softnumberHow much of that angle, from the edge inward, the light fades over: 0 a hard edge, 1 fading all the way from the middle.
airnumberHow much of its light the air in the cone shows: 0 none (only surfaces are lit), 1 a lamp on a damp night.
SunLightinterface
A light from one direction that reaches everything, for setLights: the sun, or the moon. It doesn't fade with distance, and its shadows (with shadow) fall the same way everywhere.
Properties
direction[number, number, number]The way toward the light from anywhere in the scene (any length but zero): [0, 1, 0] is straight overhead.
color[number, number, number]Linear RGB, times its strength: [1.1, 1, 0.9] is a midday sun.
shadowbooleanoptionalWhether it casts shadows (
shadow.ts). Off unless set.
Lighttype
A light setLights takes: one at a place, or one from a direction.
PointLight | SunLightMAX_LIGHTSvalue
How many lights setLights takes; the rest are dropped.
16SplatWorldclass
Every blob of every actor as one three.js mesh, so things that overlap are sorted against each other in one pass. On WebGPU the bones move the blobs, and the blobs are projected and sorted, in compute passes each frame; on WebGL 2 the vertex shader moves them and the CPU sorts. Add it to a scene drawn by three.js's WebGPURenderer, or let Stage do that for you.
Plus everything in Mesh.
Constructor
new SplatWorld(actors: Actor[], options?: EngineOptions)Properties
isSplatWorldtrueread onlyMarks the object as a
SplatWorld, the way three.js marks its own kinds.countnumberread onlyHow many blobs it holds, over every actor.
actorsActor[]read onlyThe actors it was built from.
boneCountnumberread onlyHow many bones it holds, over every actor.
cpuPathbooleanSet by the WebGL backend path, read by tests: did the last frame skin on the CPU?
cpuMsnumberMilliseconds the CPU spent in the last frame (WebGL path only): moving centers, sorting, both.
cpuSkinMsnumberMilliseconds of that spent moving centers.
cpuSortMsnumberMilliseconds of that spent sorting.
holdbooleanWhile true, rendering draws the last frame's blobs without moving or sorting them (for timing the draw alone, and for a second draw of the same frame such as the map of parts).
partsbooleanWhile true, the draw is a map of parts, not a picture: every blob is a hard disc in its part's own flat color (red and green hold the part's number plus one, blue the actor's), with no light, fog or soft edge, so where two parts meet the color changes exactly. Pixel mode draws it for the lines between parts.
depthMapbooleanWhile true, the draw is a depth map: every blob a hard disc (as in the map of parts) whose color is its distance in front of the camera, in units, in all three channels. Drawn after the frame's own render with
hold, the frame's sort puts the nearest disc last, so each pixel keeps the nearest depth.SplatDepth(depth.ts) draws it.depthFromnumberA depth map's depths are counted from this far in front of the camera (0 unless set): a map drawn from far off, as a light's view of the scene is, keeps its half floats for the scene's own depth, not the way to it.
depthSlopedbooleanWhile true, a depth map gives each pixel of a blob its own depth, along the blob's slope to the line of sight (a flat blob's own plane), where it otherwise gives the whole disc the depth of its middle. For a pass that works out where each pixel is in the world, as cel shading's shadows do.
stalebooleanread onlyWhether the blobs must be moved before they are next drawn: bones posed, or blobs changed, since the last draw.
posesnumberHow many times the blobs have been moved: it goes up with each draw that found the world
stale.tonesbooleancelbooleanCel shading, in a world with
lights: while true the lights no longer change the blobs' colors (each is drawn in its own), and each blob's tone under the first light is worked out in their place, for the map of tones (tones). The tone takes the side of a blob the camera sees for its outside, so it is redone as the view moves.lieMapbooleanWhile true, the draw is a map of how the blobs lie on the screen: every blob a hard disc whose color says which way its long axis runs and how much longer than wide it is there (
lieColorin splat-core/glyphs.ts is the CPU twin of the color). A strand of fur or a blade of grass is long and thin from any side; a disc on a surface is only so where the surface is seen nearly edge on. Drawing as characters reads it for strokes along strands.ranksbooleanWhile true, the draw is a map of dither steps: every blob a hard disc (as in the map of parts) whose red is its step of the Bayer pattern (0 to 15, as a byte), from where it sits at rest (
surfaceRanksin splat-core/pixel.ts). Pixel mode draws it for dither that stays on things (PixelLook.surface).solidbooleanWhile true, the draw is the picture with every blob a hard disc (as in the map of parts: solid out to where it has faded to the same share, in the same order), each in its own lit color. Pixel mode draws its picture so (
PixelLook.solid), so a pixel's color always comes from the thing the map of parts says is there, never partly from what is behind a fading edge.autoDetailfalse | DetailRuleLevel of detail: while set, each actor draws a share of its blobs by how big it is on screen (
detailFor()), the rest grown to cover for them. Off (every blob drawn) unless asked for; turning it off draws every blob again.boundsSphereread onlyA sphere round every actor's posed bones, for placing a camera or a shadow grid.
fogFogread onlyDistance fog: blobs fade toward
color(linear RGB) fromneartofarin front of the camera, so a scene can end in mist instead of an edge. Off whilefaris 0.lightingLightingread onlyoptionalLive lighting, when the world was made with
lights: true.glowGainnumberHow many times its own color a blob that gives all its own light (
Actor.glow) is drawn, in a world with lights: 1 to start with, so a lamp is as bright as white paper. A flame is far brighter than anything it lights; with a gain of several its color goes over white, which a picture that holds such light (a half-float target, asSplatLensdraws into) can tell from a pale thing in strong light, and let only the flame glow. Drawn straight to the screen it only clips to white, so leave it at 1 there.lightEasenumberEases the light on every blob over about this many frames (WebGPU; 0, the default, is none): a blob's lit color goes a share of the way to its new one each frame, so a shadow's edge passing over it, or a lamp catching, fades and does not pop. For lights that move slowly, like a sun. A frame is then no longer a function of its moment alone.
settlingbooleanread onlyWhether eased light is still on its way: the scene needs drawing again though nothing else has changed.
shadowDensitynumberHow dark what stands in a casting light's way makes it (
EngineOptions.shadowDensity): a world made without lights has none.peelModenumberSet by
SplatPeelwhile it draws (0 when not): 1 keeps only each pixel's nearest blob behind the last layer, 2 lays all that lies behind it as usual. Needs a world made withpeel.peelFirstbooleanSet by
SplatPeel: whether the layer being drawn is the first, with nothing in front of it.exactShapesbooleanWhether blobs are drawn in their true shape now (
EngineOptions.exactShapes). Only a world made withexactShapescan.cleanCutsbooleanWhether cuts have a clean edge now. Only a world made with
cleanCutscan; setting it there switches between the clean edge and whole blobs.detailnumber[]read onlyThe share of each actor's blobs being drawn.
cullbooleanWhether blobs with nothing to draw (off screen, behind the camera or the clip plane, and on WebGPU also cut away or dropped by the level of detail) are left out of the sort and the draw, which leaves the picture as it was. On by default; for comparing. The radix sort (
sort: 'radix') always sorts and draws every blob.farDetailfalse | FarRuleLevel of detail for blobs too small to see, blob by blob (lod.ts
FarRule): where blobs would come under aboutpixelson screen, fewer are drawn the smaller they get, each grown to cover for the rest, so a world as big as an island draws its far ground with fewer, bigger blobs. On both backends, worked out where blobs are projected, so it follows the camera with no deform; on WebGPU a blob left out is left out of the sort and the draw, on WebGL it is drawn with no size. Off (false) unless asked for. Exact shapes and clean cuts read a blob's own covariance and do not see it grow.clip[number, number, number, number] | nullA plane that hides every blob whose center is behind it, as [nx, ny, nz, d]: a blob at p is drawn while n·p + d is 0 or more. null (the start) draws them all. It acts where blobs are projected, so it can change from one draw to the next in a frame:
SplatMirrorsets it for its mirrored draw and puts it back.sortKind"bins" | "radix"read onlyWhich depth sort this world was built with.
orderUint32Arrayread onlyThe order the last sort produced (drawn first is farthest). Only up to date on the CPU path.
Methods
setMarks()Draws every blob as a brush mark or an ink stroke (marks.ts) in place of a soft dot, or as dots again when left out. A mark is turned and stretched by its blob's own shape on screen and seeded by the blob, so it stays on its blob as the view moves. Maps of parts and depth are drawn as before.
setMarks(look?: MarkLook): voidsetFog()Fades blobs to
color(linear RGB, 0–1) betweennearandfarunits from the camera;far0 turns it off.setFog(color: [number, number, number], near: number, far: number): voidsetLights()Lights the blobs with up to MAX_LIGHTS lights, on top of
ambienttimes their own (baked) color: point lights that fade with distance, and lights from a direction (a sun, a moon) that don't.ambientis one brightness or a linear color, for light from the whole sky. Each blob's normal is its flattest axis, so a light reaches the side of a surface that faces it. Needslights: true.setLights(lights: Light[], ambient?: number | readonly [number, number, number]): voidsetEdits()Cuts and paints by shape, live (edit.ts): up to MAX_EDITS spheres or boxes in world space, tested against where each blob is now. A cut blob gets no size; a painted one is mixed toward the paint before any light (needs
paint: trueorlights: true). Replaces the edits before; [] clears them.setEdits(edits: readonly ShapeEdit[]): voidbuildFor()Builds the draw's shaders for the renderer's backend now, rather than as the world is first drawn: for a pass that draws it with a material of its own made from them (
SplatPeel).buildFor(renderer: Renderer): voidpeelBehind()Set by
SplatPeel: the depth of the layer before, which this layer lies behind.peelBehind(depth: DepthTexture): voidsetMorphWeights()Sets an actor's morph weights (one per morph, 0–1); the blobs are reshaped next frame.
setMorphWeights(actor: number | Actor, weights: ArrayLike<number>): voidmarkPosed()Call after posing any skeleton.
markPosed(): voidsetDetail()Draws
keep(0–1) of an actor's blobs, each grown to cover for the rest. 1 draws them all.autoDetailoverrides it each frame.setDetail(actor: number | Actor, keep: number): voidrefresh()Takes the actors' blobs again after they were changed in place: centers, shapes, colors and opacities, for blobs that something other than a bone moves (a shape shift). The counts, the bones and the weights must be as they were.
refresh(): voidrecolor()Takes one actor's colors and opacities again after they were changed in place, when nothing moved (a floor that scorches): only the color buffer goes up again. Given
fromandto, only those of its blobs (from its first) are taken, and on WebGPU only that stretch of the buffer goes up.recolor(actor: Actor, from?: number, to?: number): voidreshape()Takes one actor's blobs again after they were changed in place: centers, shapes, colors and opacities, as
refreshdoes for every actor, for a surface that moves on its own (water). Its blobs must stay about where its bones' bounds were when the world was made, since those are not measured again.reshape(actor: Actor): voidposedBox()The box that holds every blob as the bones stand now, in the world: closer than
bounds, which is a ball round the bones' reaches. What a light's view of the scene is fitted to. Withsubject, only the first actor's, leaving out its loose things in the air (bones named~…: the sky's sun, moon and stars, specks): the box a blueprint's dimension lines are drawn round.posedBox(subject?: boolean): { lo: [number, number, number]; hi: [number, number, number] }checkShadows()For tests: the GPU's grid of shadows against the CPU twin's, built from the CPU's deform of the same frame (WebGPU, with a light casting). Returns the cells that differ by more than one unit and the total in each.
checkShadows(renderer: Renderer): Promise<{ differ: number; gpuTotal: number; cpuTotal: number }>stages()The frame's GPU work in stages, so a timer can wait between them. Each assumes the ones before it ran: deform (bones → world), then project (world → screen, plus sort keys), then order (the sort itself).
stages(renderer: Renderer, camera: Camera): { deform: () => void; project: () => void; order: () => void }deformCPU()The CPU twin of the deform pass: every blob's world center (4 floats) and covariance (6). It reads the same byte weights the GPU does, so the two agree.
deformCPU(): { center: Float32Array<ArrayBuffer>; cov: Float32Array<ArrayBuffer> }checkAgainstCPU()Reads back what the GPU deform wrote and compares it with the CPU twin. Returns the largest differences in center (world units) and covariance.
checkAgainstCPU(renderer: Renderer): Promise<{ center: number; cov: number; covScale: number }>checkViewColors()Reads back the colors the GPU gave each blob by angle and checks them against
viewColor(sh.ts) for the view last drawn: the largest gap per channel, 0–1. Only meaningful with no lights and no paint (the pass's output is the lit color). WebGPU only.checkViewColors(renderer: Renderer): Promise<number | null>checkSort()Reads the sorted order back from the GPU and counts what is wrong with it: blobs missing, out of order, or in bins left unsettled. For tests.
checkSort(renderer: Renderer): Promise<{ missing: number; outOfOrder: number; unsettled: number; biggest: number; culled: number }>dispose()Frees the GPU-related resources allocated by this instance.
dispose(): void
PEEL_GAPvalue
How far behind the last layer's depth (in the depth buffer's 0 to 1) a pixel must be to be in the next: past the same blob, and past rounding.
1e-7Orbit: where the camera looks from
Orbitinterface
Where the orbit camera is: it circles target at distance, looking at it.
Properties
target[number, number, number]The point it looks at.
distancenumberHow far from the target it is.
azimuthnumberDegrees around the vertical axis; 0 looks from +Z.
elevationnumberDegrees above the horizon.
FOVvalue
The camera's vertical field of view, in degrees.
35STAGE_FOVvalue
The vertical field of view of the engine's Stage camera, in degrees.
40placeCamera()function
Places a three.js camera for an orbit and a canvas aspect.
placeCamera(cam: PerspectiveCamera, o: Orbit, aspect: number): voidlensOf()function
The projection of a placed camera as a Lens, in CSS pixels.
lensOf(cam: PerspectiveCamera, width: number, height: number): LensorbitLens()function
A lens for an orbit without any renderer: for the software views and tests.
orbitLens(o: Orbit, width: number, height: number): LensSnapAnchorinterface
The world point pixel art is held on the art's grid at, and the turn, height and distance of the view it was set for.
Properties
at[number, number, number]The world point held on the grid.
viewstringThe view's turn, height and distance when it was set, as one key.
snapAnchor()function
Where pixel art's snap holds the picture on the art's grid, for the view o, given where it was last (kept()). While the view turns or zooms about its target, the target is the one point that stays put on the screen, so the anchor is the target and the picture never jumps: a point off it (the world's origin, at first) crosses half an art pixel now and then, and the whole scene jumped a pixel at once as a Diorama scene rocked (Matt saw it, 2026-11-23). While only the target moves (a pan, a camera that follows) the anchor stays where it was in the world, so the scene still moves by whole pixels.
snapAnchor(kept: SnapAnchor | undefined, o: Orbit): SnapAnchorBlobs
Blobsclass
A list of Gaussian blobs, kept as flat typed arrays (one entry per blob) so a scene of tens of thousands stays cheap to copy, undo and hand to the GPU.
Each blob is the five kinds of number (14 values) a 3D Gaussian splat is made of: a center, three scales (standard deviations along its own axes), a rotation (unit quaternion x, y, z, w), a color and an opacity. Colors are stored as given to Spark (0–1 per channel), which draws them as sRGB.
Constructor
new Blobs(capacity?: number)Properties
countnumberHow many blobs.
centerFloat32ArrayCenters: x, y, z per blob.
scaleFloat32ArraySizes along each blob's own axes (standard deviations): three per blob.
quatFloat32ArrayRotations as unit quaternions: x, y, z, w per blob.
colorFloat32ArrayColors, 0–1 sRGB: red, green, blue per blob.
opacityFloat32ArrayOpacity, 0–1: one per blob.
shDegreenumberColor by angle, when the blobs have it:
shDegree1–3, and per blobshTermstriples (r, g, b for each spherical harmonic term after the first, in the files' order and signs: seeviewColorin sh.ts). Blobs without it have degree 0 and no array.shFloat32Array<ArrayBufferLike> | nullThe color-by-angle terms themselves, or null when the blobs have none: see
shDegree.capacitynumberread onlyHow many blobs the arrays have room for; they grow as blobs are pushed.
shTermsnumberread onlyRest terms per blob: 0, 3, 8 or 15.
bytesnumberread onlyBytes held by the used part, for capping undo history.
Methods
setSHDegree()Gives the blobs color by angle up to
degree(0 removes it), keeping the terms they already have.setSHDegree(degree: number): voidpush()Adds a blob and returns its index.
push(b: Blob): numberset()Writes blob
i.set(i: number, b: Blob): voidget()Reads blob
i.get(i: number): Blobfilter()Keeps the blobs where
keep(i)is true, in order. Returns how many were removed.filter(keep: (i: number) => boolean): numberclone()A copy that shares nothing with this one.
clone(): Blobs
Vec3type
Three numbers: a point or a direction (x, y, z), or a color (red, green, blue).
[number, number, number]Bones and skins
Boneinterface
A skeleton: bones in a tree, each placed by its head in the rest pose (world space, no rest rotation) and posed by a local rotation about its head plus an optional offset. Bone 0 is usually the root; a still object in a scene is just a skeleton of one bone.
update() turns the pose into what the skinning pass needs per bone: the skin matrix (posed world × inverse rest, column-major 4×4), its rotation as a quaternion, and its uniform scale. A bone's scale carries down to its children, as in glTF.
Properties
Skeletonclass
Bones in a tree, and their pose. Set rotation, offset and size (or use the posing helpers), then call update() to work out what the skinning pass needs; reset() goes back to the rest pose.
Constructor
new Skeleton(bones: Bone[])Properties
bonesBone[]read onlyThe bones, parents before their children.
rotationFloat32Arrayread onlyPose: local rotation per bone (x, y, z, w).
offsetFloat32Arrayread onlyPose: local offset per bone, added to its rest offset from the parent.
sizeFloat32Arrayread onlyPose: local uniform scale per bone, about its head; children inherit it.
rootScalenumberPose: uniform scale of the root (bone 0), on top of its
size.placeFloat32Array<ArrayBuffer>read onlyWhere the actor stands: added to every root bone, and kept by
reset()(a pose isn't a placement).goneFloat32Arrayread onlyPose: how far each bone's own blobs have dissolved, 0 (whole) to 1 (gone); see dissolve.ts. Under 0, how far they rustle instead, as minus that (rustle.ts). Children don't inherit it.
liftFloat32Arrayread onlyPose: how far each bone's blobs drift up as they dissolve, in world units; or, rustling, where in its beat the bone is (0 to 1).
matrixFloat32Arrayread onlyOutput, per bone: skin matrix (16), skin rotation quaternion (4), skin uniform scale (1).
quatFloat32Arrayread onlyOutput, per bone: the skin rotation as a quaternion (4).
scaleFloat32Arrayread onlyOutput, per bone: the skin's uniform scale (1).
posedHeadFloat32Arrayread onlyPosed world position of each bone's head, for drawing the rig.
countnumberread onlyHow many bones.
Methods
index()A bone's index by its name. Throws when there is no such bone.
index(name: string): numbersetRotation()Sets one bone's local rotation (x, y, z, w).
setRotation(bone: number, q: ArrayLike<number>): voidreset()Back to the rest pose.
reset(): voidupdate()Works the pose out: every bone's skin matrix, rotation and scale, parents first. Call it after posing and before drawing.
update(): void
Skininterface
How each blob hangs on the skeleton: up to four bones and weights summing to 1.
Properties
jointsUint8ArrayFour bone indices per blob.
weightsFloat32ArrayFour weights per blob, for those bones, summing to 1.
emptySkin()function
A skin for count blobs with nothing in it yet: four bone indices and four weights per blob. Fill it with setWeights().
emptySkin(count: number): SkinsetWeights()function
Keeps the four largest weights and makes them sum to 1. Given more than four, each of the four first gives up as much as the fifth had, so a bone's weight has run down to nothing by the time it drops out of the four: cut off as it stood, skin shared between many bones tore along every line where the fourth and fifth changed places.
setWeights(skin: Skin, i: number, pairs: [bone: number, weight: number][]): voidpackWeights()function
Four weights to four bytes summing to exactly 255, so a blob never shrinks or grows from rounding: normalized first (files may not be), and whatever rounding leaves over goes to the largest weight. All zero means the first bone.
packWeights(w: ArrayLike<number>, o: number): numberSkinModetype
How a blob on several bones takes its shape: 'linear' pushes it through the blended matrices, which squashes it on a twisting joint; 'quat' averages the bones' rotations and scales, so it only ever turns. See skinBlob().
"linear" | "quat"skinBlob()function
Moves one blob by its bones. Positions blend the skin matrices linearly (as every engine does). The blob's shape then follows one of two rules:
- 'linear': its covariance is pushed through the blended 3×3 matrix. A blend of two rotations is not a rotation, so a blob on a twisting joint gets squashed.
- 'quat': its rotation is the weighted average of the bone rotations (quaternions sign-aligned, summed, renormalized) and its scale the weighted average scale, so the blob only ever turns, never flattens.
Given grad (the blob's nine numbers from weightGradients(), stretch.ts), either rule then adds how the skin stretches between the bones: Σ (where bone k alone puts the center − where the blend does) ⊗ ∇wₖ, applied to the blob's own axes, so a blob on skin pulled out between two bones is pulled out with it. No axis grows by more than MAX_STRETCH times its own length.
Writes the world center (3) and covariance [xx, xy, xz, yy, yz, zz] (6).
skinBlob(center: ArrayLike<number>, scale: ArrayLike<number>, quat: ArrayLike<number>, joints: ArrayLike<number>, weights: ArrayLike<number>, rig: { matrix: ArrayLike<number>; quat: ArrayLike<number>; scale: ArrayLike<number> }, mode: SkinMode, outCenter: Float32Array, oc: number, outCov: Float32Array, ov: number, grad?: ArrayLike<number>, og?: number): voidMAX_STRETCHvalue
The most the stretch between bones may add to one of a blob's axes, in that axis's own length.
3norm4()function
A quaternion scaled to unit length.
norm4(q: ArrayLike<number>): QuatmulQ()function
The product of two quaternions: the turn b, then the turn a.
mulQ(a: ArrayLike<number>, b: ArrayLike<number>): QuataxisAngle()function
The quaternion for a turn of rad radians about axis.
axisAngle(axis: Vec3, rad: number): Quatrotate()function
A vector turned by a quaternion.
rotate(q: ArrayLike<number>, v: ArrayLike<number>): Vec3quatMat3()function
Row-major 3×3 rotation of a unit quaternion.
quatMat3(q: ArrayLike<number>): number[]skinCenters()function
Moves only the centers of many blobs, fast: what the sort needs on the CPU when the GPU does the rest of the skinning. No allocation per blob.
src: rest centers as vec4s, with each blob's first bone (its actor's offset intobones) in w;skin: two words per blob, four joint bytes then four weight bytes summing to 255;bones: 20 floats per bone, the first 16 its column-major skin matrix, with how far the bone has dissolved and its drift (dissolve.ts) in the matrix's unused slots 7 and 11, or, under 0, how far it rustles and its beat (rustle.ts).
Writes xyz into out (3 floats per blob). Matches skinBlob()'s center, plus a dissolving blob's drift.
skinCenters(src: Float32Array, skin: Uint32Array, bones: Float32Array, count: number, out: Float32Array): voidposedPoint()function
A point carried by bone bone's current pose: where its rest position p has moved to.
posedPoint(sk: { matrix: ArrayLike<number> }, bone: number, p: ArrayLike<number>): [number, number, number]Skin that stretches
Skin that stretches. Skinning moves each blob's center by its bones, but a blob's size was only ever turned, so where the skin between two bones is pulled out (a wing's membrane as it opens, the back of a knee) the centers part and the blobs no longer cover the gaps between them.
How the skin stretches at a blob is the gradient of where skinning puts a point, and that has two halves: the blend of the bones' own matrices, and how the weights themselves change from one place to the next, Σ (bone k's place for the point) ⊗ ∇wₖ. The second half is the stretch between bones and was missing. Here each blob gets ∇wₖ for its four bones, found from the weights of the blobs next to it, so any skin has it: a sculpted creature, one opened from a file, a model laid with blobs. skinBlob() and the engine's deform pass add the half it gives.
GRAD_STRIDEvalue
Numbers per blob in what weightGradients() gives: ∇w (x, y, z) for the second, third and fourth of its bones.
9weightGradients()function
How each blob's weights change across the skin, from the blobs next to it: for the second, third and fourth of its bones the gradient of that weight in the rest pose (GRAD_STRIDE numbers a blob; the first bone's is minus their sum, since the weights always add up to 1). Along the surface only: nothing is known across it. Null when no blob hangs on two bones, so nothing can stretch. partOf keeps a blob to neighbors of its own part. The answer is kept for the same skin and blobs.
Movement
Moves written by hand, poses mixed together, feet that find the ground, loose parts that swing after the body, and morphs.
Posing by hand
Small helpers for writing clips by hand, the way an animator thinks: aim a bone at a direction, ease in and out of a move, hold a pose for a while. Clips are functions of time that pose a skeleton; recordClip() turns them into keys for a file.
Xvalue
The x axis.
Vec3Yvalue
The y axis: up.
Vec3Zvalue
The z axis.
Vec3ramp()function
0 → 1 smoothly as t goes from a to b.
ramp(t: number, a: number, b: number): numberenvvalue
Up from a to b, held, then down from c to d.
(t: number, a: number, b: number, c: number, d: number) => numberconjvalue
A unit quaternion's inverse: the same turn, the other way.
(q: ArrayLike<number>) => QuatfromTo()function
The rotation that turns unit vector a onto unit vector b by the shortest way.
worldQuat()function
A bone's world rotation from the local rotations set so far (bones have no rest rotation, so it's the product up the chain).
worldQuat(sk: Skeleton, b: number): Quatdir()function
A vector scaled to length 1.
restDir()function
Where a bone points in the rest pose.
aim()function
Turns bone name so it points along world direction to, blended by amount from where it points now. Set parents first: the result is a local rotation under whatever the parent is doing.
turn()function
Adds a local turn on top of a bone's current rotation.
set()function
Sets a local turn, replacing the bone's rotation.
turns()function
Several turns, applied in order (first is outermost).
turns(...qs: Quat[]): QuatMixing poses
Poseinterface
Mixing moves: what three.js's AnimationMixer does for meshes, for our skeletons. A move here is a function of time that poses a skeleton (as the zoo's moves and the elf's walk are), so a mix poses the skeleton once per move and blends the results.
takePose()/putPose()copy a pose out and back;blendPose()moves the pose now part of the way toward or away from another (rotations by the short way, offsets and sizes straight);addPose()lays a move on top as a change from a reference pose, so a nod or a breath can ride on any walk;Mixerplays named moves with weights and crossfades between them.
Properties
rotationFloat32ArrayEach bone's local rotation (x, y, z, w).
offsetFloat32ArrayEach bone's offset from its rest place (x, y, z).
sizeFloat32ArrayEach bone's size (1 is as built).
takePose()function
A copy of the skeleton's pose as it is now: every bone's rotation, offset and size.
putPose()function
Sets the skeleton's pose from one taken with takePose(). Call the skeleton's update() after.
blendPose()function
Blends from from to the skeleton's pose by w (0 leaves from, 1 keeps the pose as it is). Rotations go the short way and are renormalized, which is close to a slerp for the angles between two poses of one move.
addPose()function
Lays layer on the skeleton's pose as a change from ref, by w: each bone turns by layer·ref⁻¹ on top of what it does now, slides by the offset's change and grows by the size's ratio. A layer equal to ref changes nothing.
MixMoveinterface
A move a Mixer can blend: its name, how long its loop takes and the function that poses it.
Properties
namestringWhat the mixer knows it by.
secondsnumberoptionalSeconds a loop takes; the move's time wraps at it. Leave it out for a move that runs on (a pose held, or a one-off read with
elapsed).pose(sk: Skeleton, t: number) => voidPoses the skeleton
tseconds into the move.
Mixerclass
Plays moves and crossfades between them. play(name, fade) brings one move up to full weight over fade seconds while every other fades out; update(dt) moves the clocks and weights on; apply(sk) poses the skeleton as the weighted blend. Weights always sum to 1 while anything plays, so a blend is never a shrunken pose.
Each move keeps its own time, and speed scales a move's clock: a walk can keep pace with the ground while the idle under it breathes on.
Constructor
new Mixer(moves: MixMove[])Methods
play()Fades
namein overfadeseconds (0: at once) and everything else out.restartsets its clock back to 0.play(name: string, fade?: number, restart?: boolean): voidsetWeights()Sets weights directly (they are scaled to sum to 1), as a run blends with speed. No fade.
setWeights(weights: Record<string, number>): voidweight()How much of a move is in the mix now.
weight(name: string): numbertime()A move's own time, in seconds since it started (wrapped by
secondswhen it loops).time(name: string): numberadvance()Moves a clock on by its own amount (a walk at the pace of the feet; negative backs up).
advance(name: string, dt: number): voidupdate()Moves every clock on by
dt(timesspeed[name]where given) and every weight toward its target.update(dt: number, speed?: Record<string, number>): voidapply()Poses
skas the blend of every move with weight, in the order they were given; each move starts from the rest pose. Doesn't callupdate()on the skeleton.apply(sk: Skeleton): void
Reaching and feet on the ground
Reaching for things: inverse kinematics on our skeletons, the part of a mesh engine's animation tools (three.js's CCDIKSolver, a game engine's foot IK) that creatures need most.
twoBoneIK()bends a limb of two bones (thigh and shin, arm and forearm) so its end lands on a point, keeping the knee on the side it bends now;lookAt()turns one bone so a direction it carries points at a place;plantFeet()lays a walk over uneven ground: hips down to the lower foot, each leg bent to its own patch of ground, each foot tilted to the slope;hipDrop()andstepLegs()put feet where a footstep planner (steps.ts) says.
Bones here have no rest rotation, so a bone's world turn is the product of the local ones up its chain (worldQuat()), and changing a bone's world turn means setting its local turn to parent⁻¹ · wanted.
setWorldQuat()function
Gives bone b the world turn q, under whatever its parent does now.
setWorldQuat(sk: Skeleton, b: number, q: ArrayLike<number>): voidTwoBoneOptionsinterface
Options for twoBoneIK().
Properties
poleVec3optionalWorld direction the knee or elbow should point when the limb gives no bend of its own (it is straight).
amountnumberoptional0 leaves the limb as it is, 1 reaches all the way.
twoBoneIK()function
Bends the chain upper → lower so tip, a point carried by lower (given where it is in the rest pose: an ankle, a wrist, the end of a shin), lands on target, or as near as the limb reaches. The knee stays in the plane it bends in now, so a walk's knees keep pointing the way they did. Leaves the skeleton updated. Returns how far the tip still is from the target.
twoBoneIK(sk: Skeleton, upper: number, lower: number, tip: ArrayLike<number>, target: ArrayLike<number>, options?: TwoBoneOptions): numberLookOptionsinterface
Options for lookAt().
Properties
forwardVec3optionalThe direction the bone looks along at rest, in world space (a creature facing +z looks along +z).
amountnumberoptional0 leaves the bone, 1 turns it all the way.
limitnumberoptionalThe most it turns from where it points now, in radians, so a head never spins round.
lookAt()function
Turns bone name so its forward points at point. Leaves the skeleton updated.
lookAt(sk: Skeleton, name: string, point: ArrayLike<number>, options?: LookOptions): voidLeginterface
One leg for plantFeet(): bone names from the hip down. The ankle is the foot bone's head, or tip (a rest point the lower bone carries) for a leg with no foot bone. pole is where its knee points if the leg is straight.
Properties
Groundtype
The height of the ground under a point on the floor plane.
(x: number, z: number) => numbergroundNormal()function
The ground's way up under (x, z). Each way across is the gentler of the two one-sided slopes, so a foot beside a step's edge stands level on its tread instead of tipping toward the drop.
PlantOptionsinterface
Options for plantFeet().
Properties
amountnumberoptional0 leaves the walk as it is (on flat ground), 1 plants it fully.
hipsbooleanoptionalLower the hips so the lower foot can reach (true), or leave them and let that leg hang.
tiltbooleanoptionalTilt each foot to the slope under it.
Plantedinterface
What plantFeet() did, for a readout or a test.
Properties
hipShiftnumberHow far the hips moved down (negative) or up.
legs{ target: Vec3; miss: number; ground: number }[]Per leg: the ankle's target and how far it ended from it.
plantFeet()function
Lays the pose (made for flat ground at y = 0) over ground. Each ankle keeps its height above the floor from the walk (a lifted foot stays lifted), measured from that leg's own patch of ground instead of from 0. The hips move by the smallest of the legs' changes, so no leg has to stretch past its length, then each leg is bent to its target and each foot turned to the slope. Leaves the skeleton updated.
plantFeet(sk: Skeleton, legs: Leg[], ground: Ground, options?: PlantOptions): PlantedhipDrop()function
How far the hips must come down (meters, 0 or more) so every leg reaches its ankle target with a little bend left (slack of its length): a long stride from straight legs needs the body lower. The skeleton as posed now.
hipShift()function
hipDrop() with its sign kept: under zero is how far the hips could rise (meters) before the straightest leg is down to slack of its length. A body that stands with it stands as tall as its legs allow on whatever is under its feet, where one posed at a fixed height squats when the ground is a little higher than the pose expects.
legShifts()function
hipShift() leg by leg: how far each leg's own hip joint would come down (or, under zero, could rise) to leave that leg slack of its length. They differ when the feet stand at different heights: a leg a centimeter short of straight has its knee well forward, so a body standing on uneven ground tips its pelvis to keep both legs straight.
stepLegs()function
Bends each leg so its ankle lands on its target (from a footstep planner, say), and turns each foot bone level, facing facing[i] (radians from +z toward +x) when given. Leaves the skeleton updated; returns each leg's miss.
Footsteps
Footstep planning: instead of a walk clip moving the legs and the feet being pinned to the ground after, each foot keeps a spot on the ground and only leaves it to step. A foot steps when its spot has fallen too far from where it would stand under the body now (reach), aiming up to reach ahead of the body's motion, so one planner walks, turns on the spot, sidesteps, backs up and stops with every foot still where it landed. Feet in one group step together (a trot's diagonal pair); only one group is ever in the air, and the group furthest behind goes first. Pure, plain numbers: the same motion gives the same steps.
StepFootinterface
One foot for Steps to plan.
Properties
home[number, number]Where the foot stands under the body at rest, in the body's frame: x to its left, z ahead.
StepOptionsinterface
How Steps steps: how far a foot may trail, how long and how high a step is, and which feet go together.
Properties
reachnumberHow far a planted foot may fall from its home under the body before it steps, meters.
durationnumberSeconds a step takes in the air, at most: a body moving fast enough to cover two
reaches in that time steps quicker, so the feet still under it don't fall far behind before the step lands.liftnumberHow high a step lifts the foot at its middle, meters.
groupsnumber[][]optionalWhich feet step together: a list of groups of foot indices (each foot in one). Left out, each foot alone.
leadnumberoptionalHow far ahead along the body's motion a step aims past where home will be when it lands, in seconds of that motion (half a second by default), never more than
reach: a slow walk takes short steps, a fast one lands a wholereachahead so the foot spends its time under the body evenly before and behind.settlenumberoptionalBelow this distance from home a still body's foot is left where it is; above it, it steps home to stand square.
twistnumberoptionalRadians the body may turn from where it faced when a foot landed before that counts as the whole
reach(so turning on the spot steps even when a narrow stance hardly moves the feet).
StepBodyinterface
The body as the planner sees it: where it stands and faces, and how it moves (per second).
Properties
xnumberWhere it stands, along x.
znumberWhere it stands, along z.
headingnumberTurned from +z toward +x, radians.
vxnumberIts speed along x.
vznumberIts speed along z.
turnnumberRadians a second.
FootStateinterface
Where one foot is in its stepping: planted, or part way through a step.
Properties
at[number, number]Where the foot stands, or stood when it lifted.
to[number, number]Where a foot in the air lands.
tnumberHow far through its step, 0 to 1, or −1 while planted.
facingnumberWhich way the body faced (heading) when the foot last landed, or will face where it lands.
facednumberWhich way the foot faced when it lifted, so a foot in the air can turn from it to
facing.spannumberSeconds this step takes in the air.
Stepsclass
A footstep planner. Give it the feet and where the body starts, then call update each frame with where the body is now: each foot stays planted until it falls too far from its home under the body, then steps to where the body is going.
Constructor
new Steps(feet: StepFoot[], body: StepBody, opts: StepOptions)Properties
feetFootState[]read onlyEach foot's state, in the order the feet were given.
optsRequired<StepOptions>read onlyThe options in use, with the defaults filled in.
takennumberSteps taken so far, by every foot.
Methods
home()Where foot i stands under the body,
aheadseconds along its motion.home(i: number, b: StepBody, ahead?: number): [number, number]off()How far foot i has fallen (or will have,
aheadseconds on) from where it should stand under the body: its distance from home plus its turn, as a share oftwisttimesreach.off(i: number, b: StepBody, ahead?: number): numberturned()Which way foot i faces now: as it landed, or partway round to where it lands.
turned(i: number): numberstepping()The foot is in the air.
stepping(i: number): booleanupdate()Moves the plan on by
dtwith the body now atb. Returns each foot's place: x, height above the ground, z.reset()Puts every foot back under the body, planted (after a jump in place, or a new start).
reset(b: StepBody): void
Loose parts that swing
Loose parts that swing after the body: tails, ears, cloaks, plaits. Each chain is a run of bones, each the child of the one before; its points are every bone's head and the last bone's tail. The first point is pinned where the body carries it, and the rest are pulled loosely toward where the move puts them (follow, a compliance: bigger is looser), so they lag, swing and settle (xpbd.ts). Afterwards each bone is turned to point at the next point, so the move still shapes the part and the swing rides on top.
const s = new Swing(sk, FOX_SWING) // once
...pose the move, place the creature...
s.update(sk, dt) // turns the chains' bonesPure and tested.
Chaininterface
One chain of bones that swings: a tail, a plait, one side of a cloak.
Properties
bonesreadonly string[]The chain's bones by name, from the body outward.
follownumber | readonly number[]How loosely each point after the first follows the move: one number for all, or one per point.
bendnumberoptionalA soft link from each point to the one after next, so a chain bends but doesn't fold back (compliance).
SwingSpecinterface
A creature's loose parts, for Swing: the chains that swing and what holds them back.
Properties
partsstringWhat swings, for a sentence: "tail", "cloak and plait".
chainsreadonly Chain[]The chains of bones that swing.
tiesreadonly (readonly [number, number, number, number, number])[]optionalLinks between chains, as [chain, point, chain, point, compliance]: a cloak's two halves, say.
dampingnumberoptionalHow quickly swinging dies away, per second (the solver's 1.5 if left out). Stiff tails driven fast want more, or they ring.
jumpnumberoptionalA pinned point that moves further than this in a frame means the creature was moved, not walked: start still.
after(sk: Skeleton) => voidoptionalRuns after the bones are turned, before the pose is updated: the elf clears its cloak of the legs.
Swingclass
Loose parts swinging after a move. It hangs a SwingSpec's chains on the cloth solver (Xpbd); pose the skeleton, then call update each frame and it turns the chains' bones to follow.
Constructor
Properties
simXpbdread onlyThe solver the chains hang on.
specSwingSpecread onlyThe loose parts it was made for.
Methods
update()Moves the parts on by
dtseconds once the move is posed and the creature placed, and turns their bones. Leaves the pose updated.update(sk: Skeleton, dt: number): voidreset()Forgets the motion: the next update starts still, where the move puts everything.
reset(): void
between()function
A capsule between two bones' posed heads (or a ball at one), for SwingSpec.body.
Morphs
MorphTargetinterface
Morphs (blend shapes) for blobs: a second way to move them, beside bones. A bone carries its blobs rigidly. A morph gives every blob its own small change, and a slider says how much of it to take, so a cheek can puff or a mouth can curl with no bone at all.
A mesh morph only moves points. A blob has a shape too, so each target holds two things per blob:
delta: how far the center moves (3 numbers), as a mesh morph does;grad: how the surface round the blob stretches and turns (9 numbers), the change in the morph's local 3×3 map, J − I.
With weights w the center is p + Σ w·delta and the blob's covariance goes through J = I + Σ w·grad, as Σ′ = J Σ Jᵀ. Both add up, so morphs mix, run backward and overshoot the way mesh morphs do, and Σ′ is always a real covariance whatever the weights.
A morph is a straight line. A part that must travel round something (an eyelid over an eye) gets in-between targets, reached in turn as the weight goes from 0 to 1.
Properties
deltaFloat32ArrayHow far each blob's center moves: x, y, z per blob.
gradFloat32ArrayHow each blob's shape changes: the morph's local 3×3 map minus identity, nine per blob.
Morphinterface
A blend shape for blobs: a named change of shape, reached as its weight goes from 0 to 1.
Properties
namestringThe morph's name, as files and clips know it.
targetsMorphTarget[]Reached in turn, evenly spaced, as the weight goes 0 → 1; the last is the full shape.
targetFrom()function
A target from a map of the rest shape: where each blob's center goes, with the map's local stretch found by nudging the center h each way. to returns null for a blob the morph leaves alone.
targetFrom(rest: Blobs, to: (p: Vec3, i: number) => Vec3 | null, h?: number): MorphTargetshares()function
Where a weight sits among a morph's targets: between from and to (−1 is the rest shape, before the first target), a share u of the way, carried on in a straight line past either end (u below 0 or over 1).
shares(targets: number, w: number): [from: number, to: number, u: number]applyMorphs()function
The rest blobs with the morphs applied, into out (as many blobs as rest; colors and opacities are left alone). 'centers' moves the centers only, as a mesh morph would; 'shape' also pushes each blob's shape through J.
targetCount()function
How many targets the morphs have in all: what a glTF primitive lists, in-betweens included.
targetCount(morphs: Morph[]): numbertargetWeights()function
Each target's weight for the morphs' weights, in the order the morphs list them: what a glTF file animates. A single-target morph's weight is its target's; a morph with in-betweens spreads its weight over the two targets either side of it (shares()). applyMorphs() gives the same blobs as adding up every target times its weight here.
targetWeights(morphs: Morph[], weights: ArrayLike<number>, out?: Float32Array<ArrayBuffer>): Float32Array<ArrayBuffer>morphWeight()function
A morph's weight back from its k targets' weights, starting at from: the inverse of targetWeights(). The last target with any weight says which stretch the morph is on, and that weight says how far along it.
morphWeight(tw: ArrayLike<number>, from: number, k: number): numberCreatures
Cutting a creature out of shapes, hanging it on bones and growing its fur, and the creatures that come ready made.
Sculpting creatures
SculptPartinterface
Creatures cut the way the pixel scenes are (voxel.ts): shapes given as distance functions, one solid disc per surface cell, sun and cast shadows baked in. What a scene does not need and a creature does is bending: here every cell is weighted to the bones named on its part by distance, as body.ts weights its blobs, so a neck or a tail curves without a seam.
Parts in one group are treated as one solid: a cell buried inside a neighbor is never made. Give a part its own group when it swings clear of the rest (a jaw, a wing), or what it uncovers would be missing.
Properties
shapeShapeThe part's shape, as a distance function.
colorVec3 | ((p: Vec3, n: Vec3) => Vec3)Color (0–1, sRGB) or color at a surface point given its outward normal; with
paint, what its'own'stands for.paintCreaturePaintoptionalIts paint as data (creaturePaint.ts): one definition, read into each blob here and a pixel at a time by the pixel renderer.
bonesstring[]The bones that move it: each cell is weighted by its distance to each.
groupstringoptionalParts in one group cut each other where they overlap; a part that swings clear, like a jaw or a wing, wants its own.
glowbooleanoptionalUnlit: the color as given, for eyes and fire.
opacitynumberoptionalHow solid its blobs are, 0–1.
noShadowbooleanoptionalCasts no shadow on other parts.
blendnumberoptionalHow far its weights spread from each bone, if not the creature's
blend().spanbooleanoptionalSkin stretched between its bones (a wing's membrane, a web): each cell is shared out by one over its distance to each bone, squared, in place of
blend(). So it is held fast where it meets a bone, and no gap opens there beside the part that bone carries, while the skin in between is shared smoothly however far apart the bones are.
SculptSpecinterface
A creature to sculpt: its bones, its parts and how far a cell's weight spreads between bones.
Properties
bonesBone[]The creature's bones.
partsSculptPart[]Its parts.
blendnumberHow far (in world units) a cell's weight spreads from a bone.
lightPartial<VoxelLight>optionalThe baked light; what is left out comes from
DEFAULT_LIGHT.skirtnumberoptionalHow deep (world units) a part's skin goes on inside a neighbor of its group. 0 cuts it off at the neighbor's surface; a little keeps a neck closed where it meets a turning head.
Sculptedinterface
A body builder for procedural creatures: a skeleton, plus a list of simple shapes (tapered tubes, ellipsoids, flat sheets, and filled cones for things like flame), each covered in flat surface blobs and weighted to the bones named on it by distance. The fox (creature.ts) was the first creature and builds its own way; the frog, elf and dragon are written in this.
Blobs are spread by area, so a part gets its share of count; density() gives small parts (eyes, claws) more than their share. Lighting is baked into the color from a fixed light, as for the fox, unless a part is glow.
Plus everything in Creature.
Properties
partOfUint16ArrayWhich part each blob came from.
spacingnumberThe grid's cell size it was cut at.
glowUint8Array<ArrayBufferLike>optionalHow much of its own light each blob gives, a byte a blob (the engine's
Actor.glow): 255 forglowparts; left out, nothing glows.paintedPaintedoptionalWhich blobs have a paint worked out a pixel at a time (voxel.ts
painted()).
DISCvalue
A creature's discs are wider than a scene's (voxel.ts disc): a creature is seen as blobs, without pixel mode's alpha cut, and at the scene's size its far side showed through between them.
0.75buildSculpt()function
Cuts the creature on a grid of spacing.
buildSculpt(spec: SculptSpec, spacing: number): SculptedsculptToCount()function
Cuts the creature at the spacing that gives about count blobs. Cells go roughly as 1 / spacing², but not exactly (thin parts are fattened to the grid), so it measures twice: a coarse cut, then one nearer the answer, each a fraction of the final cut's cost. make is handed the spacing so thin parts can be kept at least a cell thick.
sculptToCount(make: (spacing: number) => SculptSpec, count: number, probe?: number): SculptedtoCount()function
cut() at the spacing that gives about count blobs, for anything cut on a grid (a sculpt, a scene's creature).
joinBuilt()function
One creature from two builds on the same bones (a sculpted body and a fuzzy flame, say): b's blobs follow a's.
smooth()function
Shapes melted into each other over a distance k, so a neck runs into a chest without a crease.
flatten()function
A shape squashed front to back (along z) about z = at, to f of its depth: a chest, a foot.
membrane()function
A skin of thickness 2r stretched over triangles: a wing's membrane, a fin.
scales()function
A pattern of scales: space cut into staggered cells of size a. Gives how far the point is from its cell's middle (0 at the middle, 1 at the seam) and a number 0–1 that is the same all over one scale.
scales(p: ArrayLike<number>, a: number): { out: number; id: number }Bodies from tubes and balls
Creatureinterface
A body builder for procedural creatures: a skeleton, plus a list of simple shapes (tapered tubes, ellipsoids, flat sheets, and filled cones for things like flame), each covered in flat surface blobs and weighted to the bones named on it by distance. The fox (creature.ts) was the first creature and builds its own way; the frog, elf and dragon are written in this.
Blobs are spread by area, so a part gets its share of count; density() gives small parts (eyes, claws) more than their share. Lighting is baked into the color from a fixed light, as for the fox, unless a part is glow.
Properties
Partinterface
One part of a body for buildBody(): a shape, its color and the bones that move it.
Properties
shapeShapeA tube, a ball, a sheet or a filled cone.
colorVec3 | ((p: Vec3, n: Vec3, u: number) => Vec3)Color at a point on the surface, given its outward normal and
u, how far along a tube or fill (0–1).bonesstring[]The bones that move it, nearest first is not needed: each blob is weighted by its distance to each.
densitynumberoptionalBlobs per unit area, relative to the rest.
sizenumberoptionalBlob size, relative to the rest.
opacitynumber | ((p: Vec3, u: number) => number)optionalOpacity, or opacity at a point given how far along it is (as for
color).glowbooleanoptionalUnlit: the color as given, for eyes and fire.
blendnumberoptionalHow far its weights spread from each bone, if not the creature's
blend(): wider for a sheet that must stretch smoothly.
BodySpecinterface
A body for buildBody(): its bones, its parts and how far a blob's weight spreads between bones.
Properties
Builtinterface
A body builder for procedural creatures: a skeleton, plus a list of simple shapes (tapered tubes, ellipsoids, flat sheets, and filled cones for things like flame), each covered in flat surface blobs and weighted to the bones named on it by distance. The fox (creature.ts) was the first creature and builds its own way; the frog, elf and dragon are written in this.
Blobs are spread by area, so a part gets its share of count; density() gives small parts (eyes, claws) more than their share. Lighting is baked into the color from a fixed light, as for the fox, unless a part is glow.
Plus everything in Creature.
Properties
partOfUint16ArrayWhich part each blob came from.
seenUint8Array<ArrayBufferLike>optionalHow much of each baked lamp a blob can see, four bytes a blob (voxel.ts
lamps); left out, every lamp is seen.glowUint8Array<ArrayBufferLike>optionalHow much of its own light each blob gives, a byte a blob (the engine's
Actor.glow): 255 for a voxel scene'sglowparts; left out, nothing glows.laidUint8Array<ArrayBufferLike>optionalBlobs of a face laid over another part (voxel.ts
laid: a pane on its frame), a byte a blob: drawn as blocks, a cell takes their color before the color of what they lie on.paintedPaintedoptionalWhich blobs have a paint the pixel renderer works out a pixel at a time, and the paints (voxel.ts
painted()).gridnumberoptionalThe side of the grid it was cut on (voxel.ts), so a look that snaps blobs to cells (Blocks) snaps them to the same grid.
rng()function
A small seeded random number generator: it returns a function that gives the next number from 0 up to 1, the same run for the same seed.
rng(seed: number): () => numberboneTail()function
Where a bone ends in the rest pose: its tail, else its first child's head, else a short way on from its parent.
shapeArea()function
About how much surface a body shape has, which decides its share of the blobs.
shapeArea(s: Shape): numberbuildBody()function
Builds a creature from its spec with about count blobs. The same spec and seed always give the same creature.
segDist()function
Distance from p to the segment ab.
mirrorvalue
Mirrors a point (or a list of them) to the creature's other side.
(p: Vec3) => Vec3spots()function
A cheap, smooth-ish pattern in 0–1 for spots and scales: the same at the same point every time.
spots(p: Vec3, freq: number, seed?: number): numbermixvalue
The point part of the way from a to b: t 0 is a, 1 is b.
(a: Vec3, b: Vec3, t: number) => Vec3Fur
Furinterface
Fur for a sculpted creature (sculpt.ts): strands grown out of its skin.
The cut creature is a shell of round discs, one per grid cell; textured, it reads as bricks. Fur is what a Gaussian is good at: every strand here is one long, thin blob that leaves the skin at a slant and lies the way the coat runs (flow), rooted anywhere inside its cell so the grid never shows. The shell stays underneath, a shade darker, as the undercoat: it keeps the body solid where strands part, and the strands' soft tips make the outline soft.
A strand hangs on its root cell's bones with the same weights, so the fur bends with the body, and it is still a plain blob: files, sprite sheets and Shape Shifter take it as they take any other.
Properties
lengthnumberHow long a strand is, in world units.
flowVec3 | ((p: Vec3, n: Vec3) => Vec3)Which way the coat lies at a surface point. Only its part along the skin counts.
liftnumberoptionalHow far strands stand up from the skin, in radians: 0 lies flat.
wildnumberoptionalHow far strands stray from the flow, in radians either way.
densitynumberoptionalStrands here for each strand on plain fur of the same area (a ruff is thicker).
long(p: Vec3, n: Vec3) => numberoptionalA factor on the length at a surface point: a ruff that grows longer toward the chest.
undernumberoptionalHow dark the undercoat (the shell under the strands) is, as a share of its color.
FurryPartinterface
A part of a sculpted creature that may grow fur.
Plus everything in SculptPart.
Properties
furFuroptionalThe fur that grows on it; left out, bare skin.
quatFromAxes()function
The rotation whose x, y and z axes are the given (orthonormal, right-handed) columns.
growFur()function
The zoo
ZOOvalue
Every creature on the Creature page, simplest first, with the first fox beside the one that took its place.
Species[]Moveinterface
One of a creature's moves, as a function of time, recorded into a clip when the creature is made.
Properties
namestringThe clip's name in a file.
labelstringIts name on the page.
doingstringWhat the creature is doing, for the view's description: "jumping on the spot".
secondsnumberHow long one loop takes.
fpsnumberoptionalKeys a second when it is recorded as a clip.
pose(sk: Skeleton, t: number) => voidPoses the skeleton
tseconds into the move.byLookRecord<string, { label: string; doing: string }>optionalAnother label and description in some looks, by look id: the ice dragon's breath is frost, not fire.
Speciesinterface
A procedural creature the Creature page can show.
Properties
idstringIts id in addresses and lists.
namestring"frog": used in sentences.
blurbstringOne line for the page.
detailnumber[]Blob counts on the detail chips, and the one picked first.
startnumberThe blob count picked first.
looksLook[]Its looks, the first the default.
make(count: number, look: string) => CreatureBuilds it with about
countblobs in a look.movesMove[]Its moves, the first played first.
viewOrbitWhere the camera starts.
seednumberoptionalFor a made-up monster, the seed that makes it again.
swingSwingSpecoptionalLoose parts (a tail, ears, a cloak) that swing after the body when it's played live (swing.ts); files and sheets keep the move as it is.
Fox
makeFox()function
Builds the fox with about count blobs: a sculpted skin under strands of fur, and whiskers. look picks its coat; whisker is how thick a whisker is.
FOXvalue
The fox as a Species: how to build it, its looks, its moves and where the camera starts.
SpeciesFrog
A frog, sitting, facing +z: twenty bones, including a jaw and a tongue of three. The tongue lies along the floor of the mouth, rooted at the back; flicking it grows it straight out between the jaws, so it never stretches its blobs thin.
makeFrog()function
Builds the frog with about count blobs. look picks its colors.
FROGvalue
The frog as a Species: how to build it, its looks, its moves and where the camera starts.
SpeciesElf
An elf, standing, facing +z: a humanoid of 29 bones (a spine of three, a neck and head, arms with hands and fingers, legs with feet and toes, a plait of hair and a cloak of two each side). The Creature page, Forest Walk and Dungeon Run's hero are all this one elf.
makeElf()function
The detailed elf, at exactly count blobs. bones may add to the elf's own (the hero's sword and orb).
ELFvalue
The elf as a Species: how to build it, its looks, its moves and where the camera starts.
SpeciesDragon
A dragon, standing, facing +z, about eight units nose to tail: 44 bones. Its body is cut the way the pixel scenes are (sculpt.ts): every scale, tooth and horn ring is a shape or a pattern on one, lit and shadowed once, and weighted to the bones so the neck and tail still curve. Its wings are skin stretched between an arm and three finger bones, so the membrane follows the fingers as they spread and fold.
Its fire is bones too: a chain of six from inside the mouth. In the rest pose the flame is built FLAME times smaller than life, hidden in the mouth, so a file opened elsewhere shows a dragon with its mouth shut; breathing fire grows the first fire bone by FLAME (a scale key, which glTF has) and the chain unrolls and flickers. Nothing about it is a particle system. What it breathes goes with its look (dragonBreath): fire, frost, or a green venom that burns. One more bone, lungs, swells the ribs as it draws breath.
makeDragon()function
Builds the dragon with about count blobs, a small share of them the breath that waits in its mouth. look picks its colors and what it breathes. glow marks the blobs that give their own light (the breath and the eyes), for a world with live lights.
DRAGONvalue
The dragon as a Species: how to build it, its looks, its moves and where the camera starts.
SpeciesMonsters from a seed
Make me a monster: a creature drawn up from a seed. The seed picks a body plan (two, four or six legs; how long, how round, how tall), a head (one to three eyes, a snout, horns, ears or feelers), a tail, back spikes and a coat and what its hide is (fur in strands, scales, or smooth wet skin), then cuts it with sculpt.ts like the hand-made zoo. Every monster can walk on the spot, stand and breathe, and roar, and the same seed always makes the same monster, so a link can share one.
Monsters face +z and stand on the floor (y = 0) at rest.
makeMonster()function
Builds the monster a seed gives, with about count blobs: the same seed always gives the same monster.
monsterSpecies()function
The seed as a creature for the Creature page and its sprite sheets.
monsterSpecies(seed: number): SpeciesMAX_SEEDvalue
Seeds run from 1 to this; the button picks one and a link may name any.
99999Shapes and scenes
Scenes written as data and the shapes they are cut from: buildings, rock, plants, worn land and weather, scenes put together from a land and props, the weather, clouds and wind every scene shares, and the sun, moon and sky that light them through a day.
Scenes written as data
SceneDocinterface
A pixel-art scene written as data: no code, so it can be typed by hand, kept in a file, or written by Claude from a prompt (docs/scene-descriptions.md). checkScene() says what is wrong with one, in words that point at the place; compileScene() turns a sound one into what the voxel builder, the bones and pixel mode need.
Units: about 1 is a small house, and a whole scene is about 4 across. y is up, the ground is y = 0, and the camera starts on the +z side. Colors are '#rrggbb'.
Properties
namestringThe scene's name.
loopnumberSeconds before everything repeats: 4 to 60.
light{ from?: Vec3; ambient?: number; shadow?: number; ramp?: number; crevice?: number; wear?: number; bounce?: number }optionalThe baked sun:
frompoints toward it.ramp()(0–1, 0.7 when left out) turns shade toward cool violet and full sun toward warm yellow, as a painter's ramp does;crevice(0.5) darkens corners and cracks;wear(0.5) lightens sharp outer edges. 0 turns any of them off.bounce(off unless set) lets surfaces throw their color onto what faces them, as a red wall warms the floor beside it; it costs build time, so use it where it shows.lamps"dark" | "always"optionalIts lamps as a whole: 'always' keeps everything that says
lit: 'dark'shining at any time of day, as in a cave or a dungeon, where it is never day. Left out, each goes by its ownlit.settingSceneSettingoptionalWhere it is, and so how the sky reaches it (setting.ts): 'open' under the sky (when left out), 'enclosed' for a room or a cave (with
outdoors, weather passes outside its opening; without, there is none), 'underwater' (nothing falls and no wind blows, but the day and the weather over the surface dim the light), 'space' (no sky at all).palettestring[]The colors the picture is drawn in, 2 to 32.
sky[string, string]optionalThe sky behind, top and bottom. Left out, the background is clear.
skyReachnumberoptionalHow far down the picture the sky's blend runs before it is all the bottom color: 0.05 to 1, the whole way when left out.
look{ dither?: number; glow?: number; outline?: boolean; edges?: boolean; steps?: boolean; bands?: number; heat?: number; selout?: boolean; cycle?: { colors: string[]; times: number }[] }optionalThe pixel look it asks for: how much dither and glow, and whether to draw an outline and edge lines.
steps()paints the scene in steps of its palette as it is cut (each blob takes one palette color, a step of its own paint from shade to sun), so shade falls in flat bands; left out, shading is smooth and the picture is matched to the palette pixel by pixel. Art-pixel effects (after Ink Studio's, MIT):bands(1 or 2) draws glow in flat rings,heat(1 to 3 pixels) makes the air shimmer above anything glowing,seloutsoftens the outline where it goes round something lit, andcyclesteps scene pixels of a few palette colors round their list a whole number oftimesa loop, as old games ran water, fire and lights.discnumberoptionalHow wide each surface disc is, as a share of the grid: 0.4 to 1, 0.55 when left out. Small discs keep paint crisp but let about a tenth of what lies behind a surface show through; a subject whose far side or inner parts are much darker or lighter than its near side (a head over an open jaw) wants 0.75, as creatures use.
trueShellbooleanoptionalCut every surface one cell deep in true distance, not in the shape's own units: a shape whose distance changes faster than one for one (anything
rough, worn land on a slope) otherwise leaves its skin thinner than a cell in places, and the inside of the far side shows through. Withdisc0.75 it is what keeps solid ground solid from every side (the floating islands are checked for it). It costs a few blobs more.bigbooleanoptionalA big place to walk round rather than a diorama: things may stand up to 8 from the middle, it may carry 128 bones, a part may be about 6 units across and the parts four times the surface between them. It takes about four times as long to cut, so a scene is big only when it needs the room.
hugebooleanoptionalA place far bigger again, to explore on foot (Biome Islands): things may stand up to 40 from the middle and it may carry 230 bones; with its specks it must still stay inside the 255 one byte names. Implies
big.gridnumberoptionalThe grid it is cut on, as a share of the detail's own: 0.5 to 1.5, 1 when left out. A small subject in a scene of open water or sky (the lighthouse on its rock) takes a finer grid, so its bricks and windows get as many cells as a bigger subject's would. It costs blobs: 0.72 is about twice as many. A scene of big surfaces seen from both sides (a room seen as a dollhouse) takes a coarser one, or its finest detail passes what a phone holds.
cameraOrbit & { swing?: number }Where the view starts.
swingrocks it gently from side to side by that many degrees, once a loop.outdoors{ at: [number, number]; half: number; top: number }optionalFor a scene inside a room with a window: the stretch of the outdoors seen through it, a square
at[x, z] withhalfits half side, open to the sky up totop. The shared weather falls and lies only there, so it rains outside the window and never in the room, and the scene keeps its time of day and weather though its land isindoor.bonesBoneDoc[]optionalThings that move. The land itself needs none: parts with no bone stand still.
partsPartDoc[]Everything in the scene, each a shape with its paint.
materialsRecord<string, MaterialDoc>optionalWhat surfaces are made of, by name (materials.ts): a part names one with
materialin place of a paint of its own.movesMoveDoc[]optionalWhat moves, each a whole number of times a loop.
lightsLightDoc[]optionalLive lights, at most four: they light what is near them, frame by frame.
airAirDocoptionalWhat hangs in the air: distance haze, low mist, beams of light and drifting specks.
cover{ kind: "snow" | "moss" | "dust"; color: string; amount: number }optionalSnow, moss or dust laid over everything once it is cut (parts marked
bareand glowing ones keep their paint):snowsettles on tops open to the sky,mosscreeps over shut-in and up-turned faces in patches,dustlies thin on every upturned face.amount0 to 1, from a dusting to most of what faces up.focus{ at: Vec3; r: number }optionalWhere the eye goes: within
rofatthe scene is cut at full detail, further out on a grid twice as coarse, in about a quarter of the blobs.waterWaterDocoptionalA pond whose surface ripples where rain lands on it and where things move through it.
lavaLavaDocoptionalA pool of molten rock that turns over, cools to a crust that cracks into plates, and bubbles (lava.ts): a shared recipe, as water is. A scene has water or lava, not both.
potionPotionDocoptionalA round pool of potion that is stirred, marbles its colors and bubbles up and pops (potion.ts): a shared recipe, as water and lava are. A scene has one pool: water, lava or a potion. A prop may carry one (a cauldron's); it comes with it when set down where the land has none.
firesFireDoc[]optionalFires that burn (fire.ts): hot gas rising off a bed of fuel, worked out as the water's ripples are: a shared recipe. At most
MAX_FIRES.heavensHeavensDocoptionalThe moon, the sun, the stars and how cloudy the sky is, from the shared recipes (heavens.ts): say where and how many, and every scene's moon looks the same, cloud cover puts them out, and time of day brings the right ones. A scene with a sky of its own (an eclipse, a red sun, three moons) draws it as parts instead.
WaterDocinterface
Water that moves (water.ts): a pond, a pool or a puddle. Wherever the still ground inside the box from to to lies under level there is water, standing at that level, and its surface is a grid of heights stepped by the wave equation. Rain that lands (air.specks of rain with land()) falls onto it and each drop leaves its splash where it comes down, so its rings spread from there, cross each other and bounce off the banks and whatever stands in the water. One whole loop of it is worked out when the scene is made (SceneWater), so it repeats with the scene. Dig the pond with a cut() in the ground; float leaves on a bone that moves, since only what stays put holds water back.
Properties
levelnumberThe height its surface stands at.
from[number, number]One corner of the ground looked over for water, [x, z].
to[number, number]The opposite corner.
colorstringThe water's own color, seen looking straight down into it.
sky[string, string]optionalWhat its surface mirrors where nothing stands over it: the sky overhead, then the sky low down. The scene's
skywhen left out.clearnumberoptionalHow solid it is looking straight down, 0 to 1: 0.5 when left out. Lower shows more of the bed and what swims under it.
cellnumberoptionalA cell of its grid: 0.012 to 0.1, 0.022 when left out. The grid may hold 40,000 cells.
speednumberoptionalHow fast a ring travels, units a second: 0.32 when left out.
dampingnumberoptionalThe share of its motion the water loses a second, 0.05 to 0.95: 0.6 when left out.
ripplenumberoptionalHow many times steeper than it is the surface is drawn and lit, so small ripples read: 1 to 12, 4 when left out.
splash{ r: number; depth: number }optionalA raindrop's mark: a crater
racross (half) anddepthdeep with a raised rim. About a cell and a half wide and a fifth of a cell deep when left out.deepnumberoptionalHow deep the water is taken to be for the light a ripple gathers on the bed, which is what shows one from above: 0 to 2, 0.05 when left out. Too deep for the ripples' size and every crest is a white line.
bodies{ bone: string; at: Vec3; r: number; draft?: number }[]optionalWhat swims or floats through the surface, at most twelve: a ball of radius
rround the pointat, ridingbone. Where it breaks the surface it pushes aside the water it takes the place of, so a back that rises leaves a ring and one that moves along leaves a wake.draftis how deep the water it moves is where it crosses: a tenth ofrwhen left out, which suits a fish whose back just shows; a post standing on the bed moves the whole depth.swells{ from: number; height: number; times: number; phase?: number }[]optionalSwells rolling in from the open sea, at most four, made by nothing in the scene: each is a long straight wave train coming from the way
from(degrees round the upright, measured as the camera's azimuth is: 0 from +z, 90 from +x),heightmeters from crest to rest,timescrests a loop, startingphase(0 to 1) of the way through. The water nearest that side is held to the swells as they would come in from beyond the scene, so they roll in straight across the whole width of the water, bend round what stands in it, and what comes back out to that side runs off rather than bouncing. Few, long and low is the sea: crests comespeed× loop /timesapart.floats{ bone: string; at: Vec3; size: number }[]optionalWhat rides the water, at most twelve: the bone
bonerises and falls with the surface at the pointat(where it sits on the water at rest) and tips with the surface's slope acrosssize(half its length), steepened as the surface is drawn (ripple). A boat, a buoy, a lily pad. Its own moves still apply under it.foamnumberoptionalFoam where the water strikes what stands in it (a post, a rock, a bank): it gathers where the surge against a wall runs up fast, spreads a little and fades over a second or two, and the surface is drawn white under it.
foamis how readily it gathers, 0 (none, when left out) to 4; 1 suits swells against posts.causticstrue | { strength?: number; reach?: number }optionalCaustics (caustics.ts, a shared recipe): the light the scene's lamps throw off the moving water onto what stands round it, a net of bright lines that moves with the ripples on walls, posts and the underside of a bridge.
truefor the usual, orstrength(0 to 3, 1 when left out) times as bright andreach(0.1 to 2, 0.7 when left out) how far above the water and out past it blobs take it. Only lamps over the water throw any; drawn on the blobs' own colors, so every style but Blocks shows it.shorenumberoptionalHow deep the water is where the pixel renderer lays pale foam along its banks, in the scene's units: 0 to 0.2. Left out, the stage's own (a pond's shore). 0 for a puddle, which is shallow all over and would be all foam.
mirror{ strength?: number; reach?: number }optionalHow the pixel renderer mirrors what stands over the water:
strengthtimes as much as a pond does (0.2 to 8, 1 when left out; a film of rain on a road mirrors a sign far more than a pond seen from above), and lookingreachtimes as far along the mirrored line for something to mirror (1 to 4, 1 when left out; further costs more looks a pixel).
LavaDocinterface
Lava that moves (lava.ts): molten rock wherever the still ground inside the box from to to lies under level, found as water is (dig the pool with a cut()). Its surface is the water's height field run slow and thick, and over it a field of heat: rock wells up hot at vents and spreads out over the surface, cooling as it goes from white-hot through orange and red to a dark crust, which breaks into plates with glowing cracks between them, piles up along the bank and where two vents' spreads meet, and is broken open by bubbles. One whole loop is worked out when the scene is made, as the water's is, and it glows by itself. Give the scene a light over it for what it lights.
Properties
levelnumberThe height its surface stands at.
from[number, number]One corner of the ground looked over for lava, [x, z].
to[number, number]The opposite corner.
colors[string, string, string, string]optionalIts colors from cold to hot: crust, dull red, orange, white-hot. A dark crust and a red, orange and pale yellow glow when left out.
cellnumberoptionalA cell of its grid: 0.012 to 0.1, 0.022 when left out.
coolnumberoptionalSeconds for the surface to lose two thirds of its heat: 0.5 to 20, 3 when left out. Shorter, and the crust closes in nearer the vents.
flownumberoptionalHow fast the surface moves out from a vent's edge, units a second: 0.005 to 0.5, 0.06 when left out.
platenumberoptionalHow big the crust's plates are, units across: 0.02 to 1, 0.1 when left out.
vents{ at: [number, number]; r?: number; wander?: number; times?: number; phase?: number }[]optionalWhere hot rock wells up, at most six: round
at([x, z]),racross (half; a fifth of the pool's narrower side when left out), wanderingwanderround that spot (0)timesa loop (1) fromphase. One in the middle when left out.bubblesnumberoptionalHow many bubbles burst a loop: 0 to 60, 8 when left out.
popnumberoptionalHow wide a bubble is (half): 0.01 to 0.3, three cells when left out.
speednumberoptionalHow fast a swell travels, units a second: 0.05 to 2, 0.12 when left out.
dampingnumberoptionalThe share of its motion the surface loses a second, 0.05 to 0.95: 0.9 when left out.
ripplenumberoptionalHow many times steeper than it is the surface is drawn: 1 to 12, 3 when left out.
PotionDocinterface
A potion that brews (potion.ts): a round pool of liquid round at ([x, z]) out to r, at level, wherever the still ground there lies under the level (dig the pot with a cut()). Its surface is the water's height field, a little thicker; it is stirred round, which draws its second color out through its own in spirals, small eddies wander in it, and bubbles swell up into domes and pop, sending rings out and leaving froth that the stir carries off. One whole loop is worked out when the scene is made, as the water's is. It glows unless told not to: give the scene a light over it for what it lights.
Properties
at[number, number]The pool's middle, [x, z].
rnumberThe pool's radius: 0.05 to 3.
levelnumberThe height its surface stands at.
colors[string, string, string, string]optionalIts colors: deep (in its hollows), its own, its second (marbled through it), froth. A glowing pink when left out.
glownumberoptionalHow brightly it glows, 0 (lit like anything else) to 1: 0.85 when left out.
cellnumberoptionalA cell of its grid: 0.012 to 0.1, 0.022 when left out.
stirnumberoptionalHow many times a loop it is stirred round, a whole number from −6 to 6 (under 0 the other way): 1 when left out.
eddiesnumberoptionalHow many small eddies wander in it: 0 to 6, 3 when left out.
bubblesnumberoptionalHow many bubbles pop a loop: 0 to 80, 18 when left out.
popnumberoptionalHow wide a bubble is (half): 0.01 to 0.3, three cells when left out.
risenumberoptionalSeconds a bubble swells before it pops: 0.1 to 3, 0.7 when left out.
domenumberoptionalHow high a bubble's dome stands, as a share of its half width: 0 to 1.5, 0.5 when left out.
frothnumberoptionalSeconds froth takes to fade to a third: 0.1 to 10, 1.2 when left out.
speednumberoptionalHow fast a ring travels, units a second: 0.05 to 2, 0.22 when left out.
dampingnumberoptionalThe share of its motion the surface loses a second, 0.05 to 0.95: 0.7 when left out.
ripplenumberoptionalHow many times steeper than it is the surface is drawn: 1 to 12, 3 when left out.
POTION_COLORSvalue
The colors of a potion when a scene names none: deep, its own, its second, froth.
[string, string, string, string]LAVA_COLORSvalue
The colors of lava when a scene names none: crust, dull red, orange, white-hot.
[string, string, string, string]AirDocinterface
A scene's air: haze, mist, shafts of light and specks.
Properties
haze{ color: string; from?: number; to?: number }optionalThings far from the camera fade toward
color: it startsfromunits past the view's target (0 when left out) and would be total atto(4).mistMistDoc[]optionalLow banks of mist that drift slowly to and fro, at most four.
shaftsShaftDoc[]optionalBeams of light, as from a window or a gap in the leaves, at most six: what they land on is lit by them.
windowsWindowDoc[]optionalWindows the sun comes in through, at most four: their beams are not written down or baked into what they land on but worked out from where the sun stands at the moment (a time of day moves them, the dark puts them out), and drawn as light in dusty air with a pool where they land and dust drifting in them (sunbeams.ts
SceneBeams).specksSpeckDoc[]optionalSwarms of small things, each moving on its own, at most eight swarms and 300 specks in all.
MistDocinterface
One bank of mist.
Properties
ShaftDocinterface
One beam of light.
Properties
fromVec3Where it starts (a window, a crack, a lamp) and where it lands.
toVec3Where it lands.
rnumberHow wide it is, as a radius.
colorstringIts color.
strengthnumberoptionalHow bright, 0 to 1 (0.6 when left out).
seennumberoptionalHow much the beam is seen in the air itself, as light through dust, 0 to 1 (0, only what it lands on, when left out): faint blobs along it and a pool of light where it lands, drawn by sunbeams.ts
SceneBeamsbeside the scene (so every style shows them, blocks too), which cloud over the sky puts out.litLitWhenoptionalWhen it shines (rule 14): a beam of sunlight is
'day'. Left out, always.
WindowDocinterface
A window the sun comes in through (AirDoc.windows).
Properties
atVec3Its middle.
half[number, number]Half its width along the wall and half its height.
facing"z" | "x"The axis the wall runs across: 'z' for a wall facing along z (running along x), 'x' for one facing along x.
colorstringThe beams' color.
strengthnumberoptionalHow bright the pool where they land is, 0 to 1 (0.6 when left out).
seennumberoptionalHow much they are seen in the air, 0 to 1 (0.5 when left out).
acrossnumberoptionalHow many beams side by side across it, 1 to 4 (2): one a pane, say.
floornumberoptionalThe height of the floor they land on (0).
motesnumberoptionalHow many motes of dust drift in each beam, 0 to 60 (24 when left out).
litLitWhenoptionalWhen the sun comes in (rule 14):
'day'when left out.
SpeckKindtype
What a swarm does: dust hangs and twinkles, embers rise and fade, rain falls fast as streaks, snow falls slowly and sways, leaves flutter down, fireflies wander and blink, bubbles rise and wobble, smoke rises in a curling column of puffs that swell as they climb and thin away at its top, leaning downwind in a wind.
"dust" | "embers" | "rain" | "snow" | "leaves" | "fireflies" | "bubbles" | "smoke"LitWhentype
When something is lit: a lamp only when it is 'dark' (unless whoever sets the scene says its lamps always burn), what belongs to the night itself only at 'night' (the moon, stars, fireflies: no setting brings them out by day), a sun only by 'day', or 'always' (magic, lava, a crystal). A light, a glowing part or a swarm of glowing specks says it with lit; litFor() is what puts out the ones whose time it is not.
"dark" | "night" | "day" | "always"SpeckDocinterface
One swarm of specks: dust, embers, rain, snow, leaves, fireflies or bubbles.
Properties
kindSpeckKindWhat they are, which sets how they move.
countnumberHow many.
fromVec3Two opposite corners of the box they live in: rain and snow fall from its top to its bottom, embers and bubbles rise from its bottom to its top.
toVec3The box's opposite corner.
colorsstring[]Each speck takes one of these.
sizenumberoptionalA speck's radius; left out, a size that suits the kind.
longnumberoptionalRain only: half a streak's length (0.07 when left out).
glowbooleanoptionalWhether they give off light; left out, embers and fireflies do.
litLitWhenoptionalWhen they are there, for specks that belong to a lamp or a time (a fire's embers, fireflies): gone for the rest. Left out, always.
landbooleanoptionalRain, snow and leaves only: each lands on whatever stands still under it, lies a while and goes, then falls again. One whose spot has nothing under it comes down somewhere that has (the box's floor only when none is found).
wind[number, number]optionalRain, snow and leaves only: how far the wind carries each sideways over its whole fall, [x, z]; rain slants along it.
shakenbooleanoptionalLeaves only: shaken loose by the wind, so none fall in a calm or a breeze. Windy, some come down, straight down, and land; in a gale all of them, carried away downwind before they can lie (
CompiledScene.blow).
BoneDocinterface
One bone of a scene: something for parts to ride on and moves to turn.
Properties
namestringWhat parts and moves call it.
atVec3The point it turns and grows about.
parentstringoptionalAnother bone it rides on (named earlier in the list).
propstringoptionalMarks a thing of its own (a mill, a tree, a sheep): its name as a prop in Scene Creator. The parts on this bone and on the bones under it are the prop, and the scene comes apart into props by these marks with nothing picked by hand. Not on a bone under another marked one.
cutawaybooleanoptionalA wall of a room seen from outside, as a dollhouse's (Matt, 2026-11-29): it is taken away (size 0) whenever the view looks at the room from its side, so the room is open toward the eye however the view turns. Its outside is the way from the view's target to the bone's place, on the level, so put the bone at the wall's middle.
MoveAxistype
An axis a bone turns about: 'x', 'y' or 'z', or any way as [x, y, z] (a prop set down turned writes one).
"x" | "y" | "z" | Vec3moveAxis()function
The way an axis points, of length 1.
PartDocinterface
One part of a scene: a shape, its paint and the bone that carries it.
Properties
shapeShapeDocIts shape.
paintPaintDocoptionalIts paint. May be left out when
materialnames one.materialstringoptionalOne of the scene's
materials, by name: the part takes its paint, ramp and glass, bar what it says for itself.bonestringoptionalThe bone that carries it; left out, it is part of the land.
glowbooleanoptionalGives off light and takes none: lamps, fire, stars, anything that must stay bright.
keepsbooleanoptionalWith
glow: it glows only to keep its own color (a white gull, foam, smoke, a flower, a koi), and is no light. The pixel renderer, which lights every pixel itself, draws it as any surface, with no halo; the blob renderer is unchanged.litLitWhenoptionalWhen it is lit, for a part that is a lamp or part of one (a lantern's panes, a lit window, a flame, a star, the sun): 'dark', 'night', 'day' or 'always'. For the rest of the time it is as
unlit()says. Left out, it never changes: right for anything that only keeps its own color (a flower, a bird, foam), wrong for a lamp.unlitstringoptionalWhat is there while it is not lit: a color (the part in that paint, taking light and shade like any other), or 'gone' for something with nothing left behind (a flame, a star, the sun). Left out, a dull shade of its own paint.
noShadowbooleanoptionalCasts no shadow: thin things in the air.
laidbooleanoptionalLaid on other parts (a pane on its frame): its own face is cut whole, and the face under it is what is left out.
litFor()sets it on a lamp's part it has put out: a glowing pane and the dark frame it lies in would otherwise each lose the face inside the other and leave a hole (Matt saw black windows by day, 2026-11-21).noUndersidebooleanoptionalNever seen from below (a dollhouse's floor slab, a tabletop on legs): cells facing down are left out, as a cutaway wall's outside is (
AWAY_FACING). Light and shadows still go by the whole shape.grimestringoptionalA color that gathers in its corners and cracks, as moss or soot does.
barebooleanoptionalTakes none of the scene's
cover: water, glass, a fresh fire.touchesbooleanoptionalMeets other parts by design as it moves (foam round a bobbing buoy): the check for parts passing through each other lets it.
ink{ kind: "hatch" | "stipple" | "cracks" | "grain" | "tufts" | "scales"; amount?: number; color?: string }optionalLittle drawn marks over it, one in some 4-by-4 blocks of pixels, never repeating:
hatch,stipple,cracks,grain(wood),tufts(grass) orscales().amount(0.5) is the share of blocks marked;colorthe ink, a darker step of the paint when left out.glass{ see?: number; mirror?: number; top?: boolean }optionalWater, ice or glass: it shows what lies behind it (
see, 0.6) and mirrors what is over it (mirror, 0.3, more at a glancing look), painted for the scene's own camera. Its paint tints what shows through, and where the line from the eye leaves it with nothing met, a darker step of it shows, as the bottom of a pond does.topkeeps it to upturned faces, for a pond cut as one slab with earth sides.ramp[string, string]optionalThe part's ramp, for a renderer that lights the scene itself (the pixel renderer): the color its paint leans to in shade, then the color it leans to in full light, as a painter picks a darker color of another hue rather than the same color with less light on it. Grass might go to a deep teal in shade and a yellow green in sun. Left out, shade leans a little cool and light a little warm. Today's renderer takes no notice.
strokesnumberoptionalDabs that follow the form: 0 to 1, how far each cell is drawn as a stroke along the level line round the shape. Shows as brushwork in the Blobs view.
placed{ foot: Vec3; at: Vec3; turn: number; size: number }optionalWhere the prop this part belongs to was set down, when the part was written somewhere else: its shape and paint are as written, moved from
foottoat, turnedturn()degrees about the upright (counterclockwise seen from above) and sizedsizetimes. A scene made of library props (compose.ts) writes it; nobody needs to by hand.
ShapeDoctype
A shape, written as data: kind says which. The guide, docs/scene-descriptions.md in the repository, goes through them all.
{ kind: "sphere"; at: Vec3; r: number } | { kind: "ball"; at: Vec3; r: Vec3 } | { kind: "box"; at: Vec3; half: Vec3; round?: number } | { kind: "cylinder"; at: Vec3; height: number; r: number; rTop?: number } | { kind: "cone"; from: Vec3; to: Vec3; r: number; rTo?: number } | { kind: "ring"; at: Vec3; r: number; tube: number } | { kind: "roof"; at: Vec3; half: [number, number]; height: number } | { kind: "join"; shapes: ShapeDoc[]; blend?: "smooth" | "chamfer" | "stairs"; by?: number; steps?: number } | { kind: "lathe"; at: Vec3; profile: [number, number][] } | { kind: "sweep"; path: Vec3[]; r: number; rTo?: number } | { kind: "text"; at: Vec3; text: string; size: number; depth: number; facing?: "x" | "z" } | { kind: "blocks"; at: Vec3; size: number; layers: string[][] } | { kind: "grow"; style: GrowStyle; at: Vec3; seed: number; size: number; r: number; depth?: number; branches?: number; tips?: number; only?: "twigs" | "tips" } | { kind: "wall"; from: Vec3; to: Vec3; height: number; thick: number; brick?: [number, number]; jitter?: number; ruin?: number; missing?: number; fallen?: number; seed: number } | { kind: "steps"; at: Vec3; dir: [number, number]; count: number; rise: number; run: number; width: number; wear?: number; seed: number } | { kind: "fence"; path: Vec3[]; bay: number; height: number; post: number; rails: number; lean?: number; missing?: number; sag?: number; seed: number } | { kind: "arcade"; from: Vec3; to: Vec3; height: number; thick: number; bays: number; pillar: number; spring?: number; arch?: "round" | "pointed" | "flat"; course?: number; ruin?: number; seed?: number } | { kind: "crystal"; at: Vec3; dir: Vec3; length: number; r: number; sides?: number; tip?: number; chips?: number; seed: number } | { kind: "crystals"; at: Vec3; count: number; size: number; r: number; spread?: number; sides?: number; chips?: number; seed: number } | { kind: "geode"; at: Vec3; r: number; open: Vec3; rind?: number; bands?: number; lining?: number; seed: number } | { kind: "columns"; at: Vec3; r: number; cell: number; height: number; rise?: "dome" | "steps" | "random"; seed: number } | { kind: "drips"; at: Vec3; r: number; roof: number; count: number; length: number; seed: number } | { kind: "flowstone"; at: Vec3; along: [number, number]; width: number; drop: number; folds?: number; seed: number } | { kind: "icicles"; on: ShapeDoc; every: number; length: number; above?: number; seed: number } | { kind: "tree"; at: Vec3; height: number; crown: Vec3; r: number; points?: number; leaves?: number; only?: "limbs" | "leaves"; seed: number } | { kind: "cactus"; at: Vec3; height: number; r: number; ribs?: number; arms?: number; seed: number } | { kind: "rosette"; at: Vec3; r: number; leaves: number; seed: number } | { kind: "brackets"; at: Vec3; facing: [number, number]; r: number; count: number; seed: number } | { kind: "brain"; at: Vec3; r: number; groove?: number; seed: number } | { kind: "shell"; at: Vec3; size: number; turns?: number; spire?: number; facing?: number } | { kind: "horn"; at: Vec3; dir: Vec3; length: number; r: number; curl?: number; twist?: number; ridges?: number } | { kind: "antler"; at: Vec3; dir: Vec3; length: number; r: number; tines: number; seed: number } | { kind: "ribs"; from: Vec3; to: Vec3; count: number; span: number; drop: number; r: number } | { kind: "land"; at: Vec3; half: [number, number]; base?: number; peaks: { at: [number, number]; h: number; r: number }[]; noise?: number; drops?: number; slump?: number; beds?: { thick: number; hard: number }[]; seed: number } | { kind: "butte"; at: Vec3; r: number; height: number; beds?: { thick: number; hard: number }[]; wear?: number; cap?: number; seed: number } | { kind: "hoodoo"; at: Vec3; height: number; r: number; seed: number } | { kind: "arch"; from: Vec3; to: Vec3; height: number; thick: number; soft?: number; beds?: { thick: number; hard: number }[]; seed: number } | { kind: "mud"; at: Vec3; r: number; plate: number; curl?: number; seed: number } | { kind: "pebbles"; path: Vec3[]; width: number; count: number; size: number; seed: number } | { kind: "drift"; at: Vec3; half: [number, number]; depth: number; wind: [number, number]; pile?: number; reach?: number; path?: Vec3[]; pathWidth?: number; seed: number } | { kind: "frost"; at: Vec3; facing: Vec3; r: number; arms?: number; stage?: [number, number]; seed: number } | { kind: "cut"; shape: ShapeDoc; hole: ShapeDoc } | { kind: "rough"; shape: ShapeDoc; by: number; scale?: number }PaintDoctype
A part's paint: one color, or a pattern of several.
string | { kind: "bands"; axis: "x" | "y" | "z"; size: number; colors: string[] } | { kind: "bricks"; size: [number, number]; colors: string[]; line: string } | { kind: "boards"; size: [number, number]; colors: string[]; line: string; axis?: "x" | "z" } | { kind: "hex"; size: number; colors: string[]; line: string; deep?: string } | { kind: "speckle"; size: number; colors: string[] } | { kind: "patches"; size: number; colors: string[] } | { kind: "clumps"; size: number; base: string; colors: string[]; amount?: number; seed?: number } | { kind: "key"; colors: Record<string, string> } | { kind: "faces"; top?: PaintDoc; side: PaintDoc; under?: PaintDoc; up?: number } | { kind: "split"; axis: "x" | "y" | "z"; at: number; below: PaintDoc; above: PaintDoc } | { kind: "pieces"; colors: string[]; line?: string; ordered?: boolean } | { kind: "near"; shape: ShapeDoc; within: number; at?: number; near: PaintDoc; far: PaintDoc } | { kind: "waves"; size: number; colors: [string, string, string] } | { kind: "weathered"; paint: PaintDoc; stain: string; streaks?: number; every?: number; long?: number; mottle?: number; size?: number; damp?: number; seed?: number } | { kind: "decal"; paint: PaintDoc; rows: string[]; colors: Record<string, string>; on: "x" | "y" | "z"; at: Vec3; size: number; side?: 1 | -1; depth?: number }Duringtype
When in the loop a move happens: [from, to] as shares of the loop (0 to 1). The move's times then fit between the two, and for the rest of the loop the bone waits as the move starts and ends: a sprout or drift at nothing, a sway, bob or pulse where its phase leaves it. from may be later than to, for a move that runs across the loop's seam. This is how a scene tells a story: something appears at one moment, waves once at another and is gone.
[number, number]MoveDoctype
Every move repeats a whole number of times in the loop (or in its during), so the scene loops.
{ kind: "spin"; bone: string; axis: MoveAxis; times: number; phase?: number; during?: During; wind?: number } | { kind: "sway"; bone: string; axis: MoveAxis; degrees: number; times: number; phase?: number; during?: During; wind?: number } | { kind: "bob"; bone: string; by: Vec3; times: number; phase?: number; during?: During } | { kind: "drift"; bone: string; by: Vec3; times: number; grow?: [number, number]; phase?: number; during?: During } | { kind: "pulse"; bone: string; size: [number, number]; times: number; phase?: number; during?: During } | { kind: "sprout"; bone: string; times: number; phase?: number; during?: During; rise?: number; fall?: number } | { kind: "pass"; bone: string; by: Vec3; times: number; phase?: number; during?: During } | { kind: "dissolve"; bone: string; times: number; by?: number; phase?: number; during?: During; rise?: number; fall?: number } | { kind: "rustle"; bone: string; by: number; times: number; phase?: number; during?: During; wind?: number }FireDocinterface
A fire that burns (fire.ts): fuel burning on a round bed heats the air over it, which rises, draws air in from the sides and cools as it goes, and the flames are that hot gas. Their shape and height are not drawn: they follow from the bed and from height, which says how long the gas holds its heat. Model the logs, the hearth or the wick as parts; the fire is laid over them. Its light is one of the scene's lights that names it (LightDoc.fire).
Properties
atVec3The middle of the bed the fuel burns on (the top of the logs, a torch's head).
rnumberHow far out from there the bed burns.
heightnumberoptionalAbout how tall the flames stand; 3.6 times
rwhere left out.colors[string, string, string, string]optionalIts colors from its coolest gas to its hottest (deep orange, orange, yellow, white-hot where left out); palette colors, so pixel art can show them.
sparksnumberoptionalSparks thrown a second; 1.5 where left out, 0 for none.
litLitWhenoptionalWhen it burns: 'dark' for a campfire or a torch that is lit when it gets dark, 'always' for one that never goes out. Left out, it always burns.
seednumberoptionalAnother fire of the same size burns differently with another seed.
shelteredbooleanoptionalUnder a roof (a hearth, a lantern): rain, snow and wind never reach it, so it burns as it is whatever the weather.
FIRE_COLORSvalue
The colors of a fire when a scene names none: deep orange, orange, yellow, white-hot.
[string, string, string, string]MAX_FIRESvalue
The most fires a scene can have.
10LightDocinterface
A point light in a scene.
Properties
atVec3Where it is.
colorstringIts color.
litLitWhenoptionalWhen it shines: 'dark' (a lamp, a candle, a lit window, a campfire), 'night' (moonlight), 'day' or 'always' (magic, lava, a crystal). Every light should say; left out, it always shines.
strengthnumber1 is a torch; 3 lights dark ground brightly.
rangenumberHow far it reaches.
flicker{ by: number; times: number }optionalFlickers by this share of its strength,
timesper loop.firenumberoptionalIt is the light of the scene's fire of this number (its place in
fires): where the fire is played (SceneFire), the light's strength follows how hard the fire burns from moment to moment, in place offlicker, which is what a page that does not play the fire falls back on.bonestringoptionalThe bone that carries it: the light moves, turns and grows with that bone as the scene plays (a lantern in a hand, a sun on an orrery's arm),
atbeing where it is in the rest pose. Not withshadows.circle{ r: number; times: number; phase?: number }optionalGoes round a circle of this radius about
at,timesper loop, startingphase(0 to 1) of the way round.shadowsbooleanoptionalCasts shadows, worked out once when the scene is built, so they cost nothing as it plays and flicker with it. Only the first four lights can, and not one that goes round a circle. Give it to a lamp or fire out in the open: a light set inside something (a jar, a window, a hollow) to stand for its glow would shade everything outside.
duringDuringoptionalShines only for this share of the loop, [from, to], coming up over the first fifth of it and dying away over the last: a flash, a spell.
clearnumberoptionalWith
shadows: how much open room there is round the light, 0.15 where left out. Nothing nearer the light than this shades it. A light in a small hollow (a stone lantern's light box) sets it to the hollow's size, or the stone right round it is taken for part of the lamp and lets the light through.cone{ toward: Vec3; angle: number; soft?: number; air?: number }optionalIt shines one way only: a cone with its tip at the light, down the way
towardpoints (any length),angledegrees (5 to 85) from its middle to its edge, fading over the outersoftshare of that (0.35 where left out).airis how much the air in the cone shows of it (1 where left out, 0 for none): a street lamp's cone on a damp night, a headlight's beam. Withbone, the cone turns with the bone. The pixel renderer draws it; the older blob pages and Blocks light all round as if it were not said.
DECAL_MOSTvalue
The most rows a decal has, and letters a row.
48DECAL_FACINGvalue
How squarely a face must be turned toward a decal's axis to take it (the facing's share along the axis).
0.3decalGrid()function
A decal's picture as numbers: each pixel 0 (clear) or one more than its color's place in colors, row by row from the top.
decalPixel()function
Which of a decal's pixels lies at q on a face turned n: its number in the grid (row by row from the top), or -1 where the decal does not reach (off its picture, past its depth, or a face not turned its way). The pixel renderer's reader does the same arithmetic (PAINT.decal in pixel/paint.ts): change both.
checkScene()function
Everything wrong with a scene description, each as where: what. Empty when it is sound. It takes anything, so it can check what came back from a prompt.
checkScene(doc: unknown): string[]stainAt()function
How much of a weathered paint's stain lies at q on a face turned n (0 to 1): streaks down from under each ledge, blotches and a damp line, each a grid cell at a time. Pure, for toPaint and its test.
CompiledSceneinterface
A scene ready to build and play, from compileScene().
Properties
namestringThe scene's name.
loopnumberSeconds the scene takes to repeat.
orbitOrbitWhere the camera starts.
swingnumberDegrees the view rocks to either side, once a loop: 0 holds still.
lookPixelLookThe pixel look the scene asks for.
paletteRgb[]The scene's own palette.
bonesBone[]The scene's bones.
stepsbooleanWhether the scene asks to be painted in steps of its palette (
look.steps).touchingnumber[]The parts (by their place in the list) marked
touches: they meet others by design.paints{ paint: PaintDoc; back?: (p: Vec3) => Vec3; backDir?: (v: Vec3) => Vec3; dressed: boolean; near?: (p: Vec3) => boolean; ramp?: [string, string]; keeps?: boolean }[]Each part's paint as it was written, in the order of the spec's first parts: for a renderer that works paint out itself rather than reading it off each blob.
backtakes a point (or withbackDira direction) of the scene to where the paint was written, for a placed part.dressedsays the blobs carry more than the paint (ink, strokes, or the scene's cover), which only the cutter lays on.nearanswers, for a point of the scene, the firstnearpaint in the part's paint: whether the point is within its shape's reach.haze{ color: Vec3; from: number; to: number }optionalDistance haze, if the scene asks for it: the color (linear) and where it starts and would be total, in units past the view's target.
waterWaterPlanoptionalThe scene's water, if it has any, with its defaults filled in: what
SceneWaterplays.beamsShaftDoc[]Its beams of light seen in the air (
ShaftDoc.seen), those shining as it was compiled: whatSceneBeamsdraws.windowsWindowDoc[]Its windows the sun comes in through (
AirDoc.windows), those shining as it was compiled:SceneBeamsworks their beams out for the sun of the moment.landedWaterDrop[]Raindrops of this scene's that come down on water over one loop (where it, or the
waterit was compiled with, has some): where, when, and the share of its swarm before its speck (0 to 1), so a sky that shows only some of a swarm (skyRecipes.tsshowWeather()) knows which of them are falling. Another scene's water can take them.
Methods
spec()The shapes on a grid of
spacing. Withsteps()(a palette, 0–255), the scene is painted in steps of it as it is cut.empty()The parts (by their place in the list) that came out with no blobs at all, such as a shape whose hole swallows it:
checkScene()can't see those.empty(built: { partOf: ArrayLike<number> }): number[]pose()Poses the bones for
tseconds.pose(sk: Skeleton, t: number): voidblow()After
pose(before the bones are worked out): blows what falls (rain, snow, leaves) by a wind that may change from moment to moment,wind([x, z]) being how far sideways it carries a thing for each unit it falls. Each is moved upwind by that over the fall it has still to come, so it still lands where it was planned to (and rings the water, and lies, there), and rain's streaks lean along it. Snow and leaves are carriedDRIFTtimes further. Withwrap(the square a swarm falls over, its middle and half width), a speck blown out of the square comes in at its other side, so the slanting rain still fills it at every height (one that has landed is always inside). Sways withwindlean downwind and swing wider by the root of how far the wind carries (a breeze a quarter of a gale), so they gust with it, and flutter quicker as the wind rises. Spins withwindturn quicker by its level, carried on from where they had got to as the level changes, so call it every frame, in a calm too (a wind of [0, 0]). Leaves the wind shakes loose (SpeckDoc.shaken) fall only here.levelis the wind's level (SkyState.wind); left out, it is told from how far the wind carries.blow(sk: Skeleton, t: number, wind: readonly [number, number], wrap?: { at: readonly [number, number]; half: number }, level?: number): voidcutAway()Takes away (size 0) each wall marked
cutawaythat stands between the view and the room: the bone's place lies the way the eye is fromtarget(on the level), so a room seen from outside is open toward the eye as a dollhouse's is. Call it after posing and beforesk.update().cutAway(sk: Skeleton, eye: readonly [number, number, number], target: readonly [number, number, number]): voidlights()The scene's live lights at a time, in seconds.
lights(t: number): PointLight[]ground()The height of what stays put under (x, z), looking down from
top, orbottomwhere nothing is: its still parts, or its water's surface where that is what lies open to the sky. What falls from outside the scene lands on it.ground(x: number, z: number, top: number, bottom: number): numberlying()Where snow lies under (x, z): as
ground, but on whatever takes light, moving or not (a swaying crown, a turning sail, a boat on the water, a walker), with the index of the bone that carries it (0 for the land or the water), so the snow lying there can ride that bone (snowCover.tsfollowSnow()). In the rest pose.lying(x: number, z: number, top: number, bottom: number): { y: number; bone: number; under?: number }
WaterDropinterface
A raindrop coming down on water: where, when in the loop, and the share of its swarm before its speck.
Properties
xnumberWhere it comes down, across.
znumberWhere it comes down, along.
atnumberWhen, in seconds into the loop.
WaterPlaninterface
A scene's water made ready (CompiledScene.water): its grid, its look, the rain that lands on it over one loop and what swims through it.
Properties
levelnumberThe height the surface stands at.
x0numberThe grid's corner along x.
z0numberThe grid's corner along z.
nxnumberCells along x.
nznumberCells along z.
cellnumberA cell's side.
speednumberHow fast a ring travels, units a second.
dampingnumberThe share of its motion the water loses a second.
ripplenumberHow many times steeper than it is the surface is drawn and lit.
deepnumberHow deep the water is taken to be for the light a ripple gathers on the bed.
clearnumberHow solid the surface is looking straight down.
splash{ r: number; depth: number }A raindrop's mark: its half width and its depth.
bodyVec3The water's own color, linear.
skyVec3The sky overhead as the surface mirrors it, linear.
horizonVec3The sky low down, linear.
dropsWaterDrop[]Every raindrop that lands on the water in one loop: where, and how many seconds into the loop.
bodies{ bone: number; at: Vec3; r: number; draft: number }[]What moves through the surface: a ball of radius
rround the rest pointat, riding the bone at indexbone, moving waterdraftdeep where it crosses.swells{ from: number; height: number; times: number; phase: number }[]Swells coming in from the open sea: from the way
from(degrees, as the camera's azimuth),heighthigh,timescrests a loop fromphase.floats{ bone: number; at: Vec3; size: number }[]What rides the water: the bone at index
bone, sitting on it atat, tipped by its slope acrosssize.foamnumberHow readily foam gathers where the water strikes something standing in it: 0 for none.
caustics{ strength?: number; reach?: number }optionalHow the lamps' light thrown off the water is laid on what stands round it (
WaterDoc.caustics), when it is.shorenumberoptionalHow deep the water is where the pixel renderer lays foam along its banks (
WaterDoc.shore), when the scene says.mirror{ strength: number; reach: number }optionalHow much more than a pond the pixel renderer mirrors, and how much further it looks (
WaterDoc.mirror), when the scene says.lavaLavaPlanoptionalWhere the pool is molten rock (
SceneDoc.lava): how it turns over, cools and bubbles.potionPotionPlanoptionalWhere the pool is a potion (
SceneDoc.potion): how it is stirred, marbles and bubbles.
Methods
wet()Whether there is water at a point: the still ground there lies under the level. It measures the ground each time, so ask once a cell.
wet(x: number, z: number): booleanstands()Whether something stands out of the water at a dry point (a rock, a bank, a post), rather than there being no ground at all (past the edge of a scene's sea). Measured each time, as
wetis.stands(x: number, z: number): booleandepth()optionalHow deep the water is at a point, in scene units (0 where there is none). Measured each time, as
wetis: ice asks it (ice.ts).depth(x: number, z: number): number
FirePlaninterface
A scene's fire as compiled (CompiledScene.fires).
Properties
atVec3The middle of the bed of fuel.
rnumberThe bed's radius.
heightnumberHow tall the flames stand.
sparksnumberSparks thrown a second.
seednumberWhat tells it from another fire of the same size.
shelteredbooleanoptionalUnder a roof: the weather never reaches it.
lights{ index: number; flicker?: { by: number; times: number } }[]The scene's lights that are this fire's (their places among
lights), each with the flicker it falls back on, which the fire's own burning takes the place of.
DRIFTvalue
How much further than rain the wind carries snow and leaves over the same fall: they fall slowly.
1.8FLUTTERvalue
How much wider a sway with wind swings, as a share of how far it leans.
0.35FLUTTER_BEATSvalue
How many times its own beat a sway with wind flutters in a breeze, a wind and a gale: quicker as it rises.
number[]SHAKEN_AWAYvalue
How much further than a falling leaf drifts a gale carries a leaf it shakes loose: off and away.
2SMOKE_CURLvalue
How far a puff of smoke curls out from its column by the top.
0.05SMOKE_GROWvalue
A puff of smoke's size at its source and at the top of its climb, as shares of the swarm's size.
[number, number]SMOKE_LEANvalue
How far smoke leans downwind: the wind's carry times this, a unit of climb.
0.8sprouted()function
A sprout's size through its life (0 to 1): grows from nothing over the first rise (40%), stands, and shrinks away over the last fall (15%).
sprouted(life: number, rise?: number, fall?: number): numberDISSOLVE_RISEvalue
The shares of a dissolve's time spent gathering and dissolving where it doesn't say.
0.3DISSOLVE_FALLvalue
The shares of a dissolve's time spent gathering and dissolving where it doesn't say.
0.5DISSOLVE_BYvalue
How far a dissolve's blobs drift where it doesn't say.
0.4dissolving()function
Poses a dissolve move life (0 to 1) through its time: how far gone the bone's blobs are, and their drift.
dissolving(sk: Skeleton, b: number, life: number, m: { by?: number; rise?: number; fall?: number }): voidduringAt()function
How far through its during a move is at u of the loop: 0 as it starts, 1 from its end until it starts again. With none, u itself, so the move fills the loop.
duringAt(u: number, d?: During): numberPASS_EDGEvalue
The share of its way at each end over which a passing thing grows in and shrinks away.
0.06passed()function
A pass move at life (0 to 1 along its way) for a thing drawn phase along it: how far it stands from where it is drawn, as a share of the way, and its size, which is 0 at both ends so the jump back is never seen.
passed(life: number, phase: number): [number, number]compileScene()function
ground is the ground what falls lands on, in place of the description's own parts: weather laid over another scene (skyRecipes.ts) lands on that scene's.
compileScene(given: SceneDoc, options?: { puffs?: boolean; ground?: (x: number, z: number, top: number, bottom: number) => number; water?: number }): CompiledScenecarried()function
A point in the rest pose where bone b's skin matrix (column-major, Skeleton.matrix) puts it.
carried(m: ArrayLike<number>, b: number, options: readonly number[]): Vec3turnedBy()function
A direction in the rest pose as bone b's skin matrix turns it, of length 1 (a cone of light a bone carries).
turnedBy(m: ArrayLike<number>, b: number, options: readonly number[]): Vec3flickerAtvalue
How bright a flickering light is u of the way through the loop, beside its own strength: two flickers out of step, so it doesn't beat like a clock, but still loops.
(f: { by: number; times: number } | undefined, u: number) => numberlightsAt()function
Described lights as they shine u of the way through the loop (0 to 1): flickering, going round, coming and going.
lightsAt(lights: readonly LightDoc[], u: number): PointLight[]CONE_SOFTvalue
How much of a cone's angle its light fades over, and how much of it the air shows, where a description leaves them out.
0.35CONE_AIRvalue
How much of a cone's angle its light fades over, and how much of it the air shows, where a description leaves them out.
1coneOf()function
A description's cone as a light carries it: its way made of length 1, and what was left out filled in.
UNLIT_LIGHTvalue
How much of its lightness and of its color a lamp keeps while it is not lit, where its part names no unlit() color.
0.62UNLIT_COLORvalue
How much of its lightness and of its color a lamp keeps while it is not lit, where its part names no unlit() color.
0.3dulled()function
A color as a lamp of it looks while it is not lit: darker and nearly gray, as glass with nothing behind it.
dulled(color: string): stringisLit()function
Whether something lit when is lit: by day or in the dark, with the scene's lamps deciding for those that wait for the dark.
isLit(when: LitWhen | undefined, dark: boolean, lamps?: "dark" | "always"): booleanhasLamps()function
Whether anything in a description is lit only some of the time, so that the time of day changes it.
hasLamps(doc: SceneDoc): booleanlitFor()function
A description as it stands by day (dark false) or in the dark: every light, glowing part and swarm of specks whose lit says it is not lit now is put out. A light shines at strength 0 (it keeps its place in the list, which baked lamp shadows and props' picks go by); a part stops glowing and takes its unlit() color, or a dull shade of its own paint (dulled()), or is left out where it is unlit: 'gone'; specks are left out. lamps (the scene's own where left out) set to 'always' keeps everything that waits for the dark lit. Colors it adds join the palette while there is room. A description nothing changes in comes back as it is, so a caller can tell there is nothing to cut again.
Named materials
Named materials: a paint, its ramp and whether it is glass, written once in a description and named by its parts.
MaterialDocinterface
Named materials: a scene's description may list materials by name (materials: { grass: { paint, ramp } }) and give a part material: 'grass' in place of a paint of its own. One edit to the material then changes every part of it. A material holds what a surface is made of: its paint, the colors it leans to in shade and in full light (ramp()), and whether it is glass. What a part says for itself comes first.
Properties
withMaterials()function
The description with every part's material written out onto the part (paint, ramp, glass; the part's own first) and the names gone, so nothing after this needs to know materials exist: a prop cut out of the scene or set down in another carries its paint with it. The same description comes back when it names no materials.
Where a scene is
SceneSettingtype
Where a scene is, and so how the sky reaches it. A description says it once with setting; every rule that follows from it is one row of one table here, which the scene player, the weather and a page's controls all ask, so no page decides for itself whether rain falls in a cave.
open: under the sky. Everything reaches it.enclosed: a room or a cave. With no opening nothing of the weather is seen, so there is none; with an opening (SceneDoc.outdoors, the square seen through a window or a hole) it issheltered: weather passes outside the opening and never comes indoors.underwater: under a surface that is never looked up at. Nothing falls and no wind blows, but the day still comes down from above, and weather dims and grays it.space: no sky at all.
"open" | "enclosed" | "underwater" | "space"SCENE_SETTINGSvalue
The settings a description may name.
readonly SceneSetting[]Exposureinterface
How the sky reaches a scene: one row of the table.
Properties
kindSceneSetting | "sheltered"The row: a setting, or
shelteredfor an enclosed scene with an opening.timebooleanWhether it can be set in a time of day.
weatherbooleanWhether a weather can be picked for it at all.
falls"none" | "everywhere" | "outdoors"Where rain and snow fall and snow lies: everywhere, only in its square of outdoors, or nowhere.
cloudsbooleanWhether clouds float over it.
windbooleanWhether the wind moves the scene's own things wherever they stand (what sways, turns and falls in it). Where it is false and weather still falls outdoors, only what stands in the square of outdoors is blown.
windPickedbooleanWhether a wind can be picked: where weather falls outside an opening it still slants, though nothing indoors stirs.
answersbooleanWhether its fires and its water answer the weather (rain on a pond, a fire put out by a storm).
skyEffectsbooleanWhether a sky effect (an aurora, meteors) can be behind it. A room with an opening has them over it as any scene does: they are high in the sky, and the view never looks up and out through the window (Matt, 2026-12-02).
whystringOne line for a page to say what the visitor will and will not find, where something is missing.
Settledinterface
What a description (or a land) needs for its setting to be read: the setting it names, its tags and its opening.
Properties
settingSceneSettingoptionalThe setting it names.
outdoorsunknownoptionalIts opening to the sky, if any (
SceneDoc.outdoors).
exposureOf()function
How the sky reaches a scene.
Scene checks
Checks a scene can fail without anyone looking at it: its values (does it still read in grayscale) and its loop (does anything visible snap from one place to another). Pure, for scene tests; issue #165.
Valuesinterface
A scene's spread of values (valuesOf()).
Properties
darknumberOKLab lightness of the 5th percentile blob.
midnumberOKLab lightness of the middle blob.
lightnumberOKLab lightness of the 95th percentile blob.
mudnumberShare of blobs that are mid-gray mud: lightness 0.35 to 0.65 with hardly any color.
MIN_VALUE_RANGEvalue
The least spread from the 5th to the 95th percentile lightness a scene may have: below it, it reads as one tone.
0.24MAX_MUDvalue
The most mid-gray mud a scene may have.
0.25valuesOf()function
A scene's spread of values, from its blobs' baked colors (sRGB).
Snapinterface
A bone that snaps from one place to another while it is seen (loopSnaps()).
Properties
bonestringThe bone's name.
atnumberThe time the snap ends at, in seconds.
bynumberHow far the bone's origin went in that one frame.
loopSnaps()function
Bones that snap while seen: in one frame a bone's origin moves far more than in the frames either side (four times, plus slack), and it is at least a quarter of its biggest size before and after. A fast flap is steady, so it passes; a spark sent back to its start shrinks away first, so it passes; a move that doesn't join up, at the loop's seam or anywhere, fails. Bones named with ~ (specks) are skipped. Sampled perSecond times a second over one loop, wrapping round.
Clashinterface
A part that passes through another while the scene plays.
Properties
partnumberThe part that moves into the other, by its place in the scene's list.
intonumberThe part it passes through.
atnumberThe time it is deepest in, in seconds.
blobsnumberHow many of the moving part's blobs are in the other's surface then.
bonestringThe bone that carries the moving part.
CLASH_SHAREvalue
A part clashes when this share of its blobs (and at least CLASH_LEAST) sit in another part's surface at once.
0.05CLASH_LEASTvalue
The fewest blobs in another part's surface that count as a clash, however small the part.
12partClashes()function
Parts that pass through each other as the scene plays: sails through a tower, a tail through a wall. It works from the blobs alone, so it suits anything built, scene or creature. A blob is in another part's surface when, posed, it lies within about half a grid cell of one of that part's blobs, the two ride different bones, and at rest it stood clear of that part (over two cells from all of it), so a joint, a wheel on its axle and anything that touches by design never count. A part clashes with another when CLASH_SHARE of its blobs (at least CLASH_LEAST) are in the other's surface in one frame; each pair is reported once, at its worst frame.
spacing is the grid the scene was cut on. Bones named with ~ (specks, which land on things) and bones shrunk to under a quarter of their size are skipped, as in loopSnaps(). Sampled perSecond times a second over one loop.
Scenes made of a land and props
Scenes made of props (Scene Creator, docs/scene-editor-plan.md). A **prop** is a scene description that holds one thing (a windmill, a sheep, a witch) standing where it stood in the scene it came from, and the point it stands on. A **project** is a land (a prop that everything stands on, which keeps the scene's sky, air and water) and props set down on it, each moved, turned about the upright and sized.
A placed prop is cut where it is put, so its baked sun and shade are right for the way it faces, and its moves are turned with it. Two ways to cut a project: apart (the land and each prop on their own, so moving one recuts only it: what an editor wants) and merged (one grid for all, so props cast their baked shadows on the land and cull what they stand in: what an export wants). Both are posed and lit by the same functions here.
PropDocinterface
A thing that can be set down in a scene.
Properties
namestringWhat it is called in a list.
docSceneDocIts description: only its own parts, bones, moves and lights, where they stood in the scene it came from.
footVec3The point it stands on, in the description's own coordinates: what a placement moves, and what it turns about.
water{ rides?: { bone: string; at: Vec3; size: number }[]; wakes?: { bone: string; at: Vec3; r: number; draft?: number }[] }optionalHow it meets a land's water, where it is set down in one (
WaterDocfloats and bodies, naming its own bones):ridesbob and tip on the surface (a boat, a buoy),wakespush the water aside as they move through it (a duck, a fish). Left out on dry land; set down in water, they join the land's water.
PropReftype
A library prop by its id, or a prop written out in full (an imported one).
string | PropDocPlacedinterface
One prop set down in a project.
Plus everything in Placement.
Properties
propPropRefWhich prop it is.
stillbooleanoptionalHolds still: its own moves are not played.
phasenumberoptionalIts moves run this share of the loop later (0 to 1), so two of one prop side by side don't sway as one.
lit"dark" | "always"optionalIts lamps, where the project has a time of day: 'always' keeps them lit by day, 'dark' has them wait for the dark whatever the project or the land says. Left out, it goes by the project's
light.lit, then the land's ownlamps.
SceneProjectinterface
A scene made of a land and props: what Scene Creator edits and saves.
Properties
kind"blobscape-project"What says a file is a project.
version1The format's version.
namestringThe scene's name.
loopnumberSeconds before everything repeats: every prop's moves are fitted to it.
landPropRefWhat everything stands on. It is never moved.
propsPlaced[]The props set down on the land.
cameraOrbitoptionalWhere the view starts; the land's own camera when left out.
style{ id: string; settings?: Record<string, unknown> }optionalHow it is drawn: a style's id (Diorama's
STYLES) and its settings, kept as the page gives them.lightProjectLightoptionalThe light, sky and air, where they differ from the land's own.
ProjectLightinterface
A project's light, each left out where the land's own stands. The sun is baked into the cut (so a change cuts again) unless it is live: then everything is cut unlit and the sun, the moon and the sky's own light shine live at the hour (daylight()), with shadows where the device draws them. Lamps are always live, so they move without a cut.
Properties
sun{ turn: number; height: number }optionalThe baked sun:
turn()degrees round from +z (counterclockwise seen from above, as props turn) andheightdegrees up.shadenumberoptionalHow much light reaches what the sun doesn't: 0 to 1.
sky[string, string]optionalThe sky behind, top and bottom.
live{ hour: number }optionalThe sun live, at this hour of the day (0 to 24).
lit"dark" | "always"optionalEvery prop's lamps under a live sun: 'always' keeps them lit by day (a cave, a dungeon), 'dark' has them wait for the dark. Left out, the land's own
lampssays (a cave's land keeps what is set down in it lit). A prop's ownlitcomes first.lampsLightDoc[]optionalLamps the visitor set down, at most
MAX_PROJECT_LAMPS.glownumberoptionalHow strongly glowing things light what is round them and shine in the picture, as Diorama's Glow (0 to 4): the land's own when left out.
hazenumberoptionalFar things fade into the sky's lower color, total this far past the view's target; 0 is clear air.
weather"snow" | "leaves" | "rain"optionalRain or snow falling over the land and lying where it lands, or leaves falling from the leafy props' crowns.
recipeProjectWeatheroptionalA shared weather or cloud cover laid over the scene (skyRecipes.ts: the same recipes every Diorama scene takes), a wind in place of the weather's own, and whether its clouds float over the scene. Nothing is cut again for it.
skyEffectSkyEffectIdoptionalSomething happening in the sky behind the scene (skyEffects.ts: an aurora, a meteor shower), out at night under a clear enough sky.
ProjectWeatherinterface
A project's shared weather (ProjectLight.recipe).
Properties
weatherWeatherIdoptionalA weather, which brings its own clouds and wind.
cloudsCloudIdoptionalA cloud cover alone, where there is no weather.
windWindIdoptionalA wind in place of the weather's own.
overheadbooleanoptionalWhether the clouds float over the scene (left out, they do); without them rain and snow fall in from over the top of the picture.
MAX_PROJECT_LAMPSvalue
Most lamps a project may add of its own.
8sunFromvalue
The way toward a sun turn() degrees round from +z and height degrees up.
(turn: number, height: number) => Vec3sunOf()function
A description's sun as a turn and a height, the default light.from when it has none.
DARK_FROMvalue
How dark the hour must have grown (daylight()'s dark) for lamps that wait for the dark to be lit.
0.5projectDarkvalue
Whether it is dark in a project: by its live sun's hour. With no live sun there is no time of day, and everything is lit as its description has it (undefined).
(l: ProjectLight | undefined) => boolean | undefinedcutLightvalue
What of a project's light the cut depends on: the lamps, the glow and a live sun's hour change nothing that is cut, except that the hour says whether it is dark, which lights or puts out every prop's own lamps (litFor()).
(l: ProjectLight | undefined) => { sun: { turn: number; height: number } | undefined; shade: number | undefined; sky: [string, string] | undefined; live: boolean; haze: number | undefined; weather: "leaves" | "rain" | "snow" | undefined; dark: boolean | undefined; lit: "always" | "dark" | undefined } | undefinedlitLand()function
The land's description under a project's light: its sun, shade and sky, unlit for a live sun, with haze and weather in its air. Props are cut under the land's light, so they follow it.
litLand(doc: SceneDoc, l: ProjectLight | undefined): SceneDocAUTUMNvalue
Falling leaves' colors.
string[]LEAVES_EACHvalue
How many leaves come down under one tree.
12leafyvalue
Whether a prop drops leaves: tagged leafy (tags.ts) and not evergreen.
(prop: { tags?: readonly string[] } | undefined) => booleanleafFall()function
Where a leafy prop's leaves fall, in its own frame: under its crown (the top half of it, drawn in a little), from the crown's underside down to its foot, so they come from the tree and not from the sky (Matt, 2026-11-22).
withLeaves()function
A leafy prop's leaves as a swarm of its own, falling from its crown to its foot, for a project whose weather is leaves.
MAX_PROPSvalue
Most props in one project: each is an actor of its own while editing, and frames slow down as they are added (#330).
40MAX_PROJECT_BONESvalue
Most bones in a merged project: a blob names its bones in a byte.
255MAX_PROJECT_BYTESvalue
Most bytes in a project file.
2000000SIZE_RANGEvalue
The least and most a prop may be sized.
[number, number]Settingtype
What a prop is cut with that comes from where it stands, not from itself: the scene's sun, cover, camera and sky.
Pick<VoxelSpec, "light" | "cover" | "eye" | "sky">settingOfvalue
The setting of a land: what its props are cut under.
(spec: VoxelSpec) => SettingplacedSpec()function
A prop's cut where it is placed, for a detail of spacing in the scene's units (times its description's grid). Its bones are named prefix + their own name (its root bone included). steps() is the palette to paint in steps of, when the scene asks for that.
Posabletype
What PlacedPoser plays: bones as they stand where they were written, a pose for a time, and live lights.
Pick<CompiledScene, "bones" | "pose" | "lights">PlacedPoserclass
Poses a placed prop: its description's own pose, played on a skeleton of its own as it was written, then turned as the prop was (each bone's turn as R q R⁻¹, each slide by R and the size), so a sail that spun about z spins about the mill's turned axle. into says which bone of the target each of the prop's bones is; left out, the same index.
Constructor
Properties
cPosableread onlyThe prop's compiled description, or anything else with bones that poses itself (a creature).
Methods
pose()Writes the prop's pose for
tseconds intosk. Doesn't callsk.update(). Withwind(how far it carries a unit of fall, along the ground, aswindAt()gives it) a description's falling specks and swaying stalks are blown, the way turned into the prop's own.pose(sk: Skeleton, time: number, into?: ArrayLike<number>, wind?: readonly [number, number], level?: number): voidlights()The prop's live lights
tseconds in, where it stands.lights(time: number): PointLight[]
PropPickinterface
Which of a scene's parts make one prop: parts by their place in its list, and every part on the named bones or the bones under them.
Properties
namestringWhat it is called.
partsnumber[]optionalParts by their place in the scene's list.
bonesstring[]optionalBones whose parts (and their children's) come along.
footVec3optionalThe point it stands on; the middle of the bottom of its box when left out.
drop("pass" | "during")[]optionalMoves and lights it leaves behind:
duringdrops whatever happens only in part of the loop (a witch who appears and goes stands there instead),passdrops going by (a billboard Turkey Run slides past stands still).lightsnumber[]optionalThe scene's lights it takes, by their place in its list; left out, those its box holds.
pickedParts()function
The part indices a pick takes from a scene.
markedPicks()function
The picks a description marks itself: one prop for each bone with a prop name, taking what rides on it.
outsideProps()function
What in a scene stands outside every prop it marks, each as where: what: a part on a bone that is no prop's, a light no prop's box holds. A scene is built from components (each thing a prop of its own, which Scene Creator's library then offers), so a new scene leaves only its land outside them: the parts on no bone.
outsideProps(doc: SceneDoc): string[]boxOf()function
A coarse look at where a description's parts are: the box round all of them.
splitScene()function
Lifts props out of a scene description and leaves what is left as its land. A light goes with the first prop whose box holds it (a lantern's flame), else stays with the land. A prop takes the scene's palette, light, look and loop but none of its air, water, cover or focus: those belong to the land.
refit()function
A description fitted to a loop of loop seconds: every move and light keeps as near its own pace as a whole number of times in the new loop allows (never none), so a prop from a 16 s scene still joins up in a 12 s one.
checkProject()function
What is wrong with a project, as where: what, or nothing. known says whether a library id exists. Reads anything, so a file from outside can be handed straight to it.
checkProject(x: unknown, known: (id: string) => boolean): string[]readProject()function
A project file's text read and checked: the project, or what is wrong with it.
readProject(text: string, known: (id: string) => boolean): { project?: SceneProject; problems: string[] }CompiledProjectinterface
A project compiled apart: the land and each prop a scene of its own, with what poses each where it stands.
Properties
namestringThe project's name.
loopnumberSeconds before everything repeats.
land{ prop: PropDoc; c: CompiledScene }The land, compiled.
props{ prop: PropDoc; c: CompiledScene; placed: Placed; poser: PlacedPoser }[]Each prop, compiled, with its placement and the poser that plays its moves where it stands.
paletteRgb[]The palette for pixel art: the land's colors, then each prop's that the land lacks, joined down to 32.
cameraOrbitWhere the view starts.
compileProject()function
Compiles a project apart, the land and each prop on their own, which is what an editor wants: moving one prop cuts only it again. find gives a library prop by its id. composeScene() is the other way, one scene for all.
compileProject(project: SceneProject, find: (id: string) => PropDoc | undefined): CompiledProjectjoinPalettes()function
One palette for colors from several scenes: the first list's colors first, then the others' that are not already there, and while there are more than 32 the two closest are joined (the first scene's color kept where one is).
joinPalettes(lists: string[][]): Rgb[]landSpec()function
The land's cut on a grid of spacing, painted in steps() of a palette where given (the land's own choice when left out).
landSpec(cp: CompiledProject, spacing: number, steps?: Rgb[]): VoxelSpecpropSpec()function
Prop i's cut on its own, where it is placed, under the land's sky: an actor of its own while editing.
propSpec(cp: CompiledProject, i: number, spacing: number, setting?: Setting, steps?: Rgb[]): VoxelSpecmergedSpec()function
The whole project on one grid: the land's bones first (as its own pose expects), then each prop's under them as <i>/<name>, its root folded into the land's, so what stands still culls and shades what it stands on just as one scene would. With it, mergedBones maps each prop's bones into this skeleton.
mergedSpec(cp: CompiledProject, spacing: number): { spec: VoxelSpec; into: number[][] }poseMerged()function
Poses a merged project's one skeleton for t seconds: the land, then every prop on its own bones.
poseMerged(cp: CompiledProject, into: number[][], sk: Skeleton, t: number): voidposeApart()function
Poses one prop's own skeleton, cut apart, for t seconds. Its place (Skeleton.place) is left as it is.
poseApart(cp: CompiledProject, i: number, sk: Skeleton, t: number): voidprojectLights()function
Every live light of the project t seconds in: the land's, then each prop's, in the order a merged cut's baked lamps follow.
projectLights(cp: CompiledProject, t: number): PointLight[]Placementinterface
Where a thing is set down: its foot goes to at, turned turn() degrees about the upright (counterclockwise seen from above), size times as big.
Properties
atVec3Where its foot stands.
turnnumberDegrees it is turned about the upright.
sizenumberHow many times its own size it is.
Placerinterface
A placement worked out: the turn as a quaternion and the point maps both ways.
Properties
qQuatThe turn.
sizenumberHow big.
samebooleanWhether it changes nothing.
Methods
placer()function
Works a placement out for a thing whose foot is at foot in its own description.
A project as one scene
composeScene()function
A scene written as a land and props set down on it (a SceneProject, the same thing Scene Creator saves) made into one ordinary description, so Diorama, every style, the weather and the water draw it as they draw any scene.
The props are named, not copied: a scene that sets down the library's stone lantern gets the lantern as the library has it today, so a change to a prop (its light, its sway) reaches every scene that uses it (Matt, 2026-11-21).
The land comes as it is (its sky, air, water, light, look and camera are the scene's). Each prop's parts keep their shapes and paint as written and say where they were set down (PartDoc.placed); its bones, moves and lights are moved, turned and sized here, and its bones renamed <prop><i>/<bone> so two of one prop never share a name.
composeScene(project: SceneProject, find: (id: string) => PropDoc | undefined): SceneDocTags on props and lands
Tags for props and lands (Matt, 2026-11-22): words from one fixed list, so a search finds a thing by what it is and the shared recipes act on what it is like, rather than guessing from its name. A tag outside the list is a mistake the scene checker names, not a word that quietly does nothing.
Three sorts: a kind says what a prop is (search finds it by that), a land() tag what a land is, and a quality says how it behaves, which a recipe acts on.
TagSorttype
What sort of tag it is: what a prop is, what a land is, or how a thing behaves.
"kind" | "land" | "quality"TagInfointerface
One tag of the list.
Properties
idstringThe word a description writes.
sortTagSortWhich sort it is.
meansstringWhat it means, and for a quality what acts on it.
TAGSvalue
Every tag there is, each with what it means. A description may use no other word.
readonly [{ id: "tree"; sort: "kind"; means: "A tree, a trunk with a crown, or what is left of one" }, { id: "plant"; sort: "kind"; means: "A bush, stalk, leaves or a cactus" }, { id: "flower"; sort: "kind"; means: "In flower" }, { id: "rock"; sort: "kind"; means: "Stone: a boulder, slab, post, steps or stonework" }, { id: "crystal"; sort: "kind"; means: "Crystals" }, { id: "building"; sort: "kind"; means: "A building or a large built thing: a mill, a cottage, a jetty, an arch" }, { id: "wall"; sort: "kind"; means: "A wall or a fence" }, { id: "lamp"; sort: "kind"; means: "Gives light: a lantern, a lighthouse, a lamp on a buoy" }, { id: "farm"; sort: "kind"; means: "Of a farm: a haystack, a windmill, sheep, fields" }, { id: "thing"; sort: "kind"; means: "A small made thing: a mailbox" }, { id: "sign"; sort: "kind"; means: "A sign or a billboard" }, { id: "boat"; sort: "kind"; means: "A boat" }, { id: "animal"; sort: "kind"; means: "An animal, a bird, a fish or a dragon" }, { id: "person"; sort: "kind"; means: "A person: the cook, the witch, the elf" }, { id: "magic"; sort: "kind"; means: "Magic: a witch, a spell circle, a dragon" }, { id: "grassy"; sort: "land"; means: "Mostly grass" }, { id: "rocky"; sort: "land"; means: "Mostly bare rock" }, { id: "sandy"; sort: "land"; means: "Sand or desert" }, { id: "snowy"; sort: "land"; means: "Under snow" }, { id: "sea"; sort: "land"; means: "Stands in the sea" }, { id: "pond"; sort: "land"; means: "Has a pond or a pool" }, { id: "night"; sort: "land"; means: "Written as a night scene" }, { id: "space"; sort: "land"; means: "Out in space: no ground, and no time of day or weather" }, { id: "indoor"; sort: "land"; means: "Inside a room: no sky, so no time of day or weather" }, { id: "leafy"; sort: "quality"; means: "Drops leaves: under falling leaves it lets them fall from under its crown" }, { id: "evergreen"; sort: "quality"; means: "Keeps its needles or leaves: falling leaves pass it by" }, { id: "floats"; sort: "quality"; means: "Sits on water: no stand-in shadow is laid under it" }]Tagtype
A word of TAGS.
typeof TAGS[number]["id"]isTagvalue
Whether a value is a word of TAGS.
(v: unknown) => v is TagtagInfovalue
What a tag is, or undefined for a word that is not one.
(id: string) => TagInfo | undefinedtaggedvalue
Whether a thing has a tag.
(thing: { tags?: readonly string[] } | undefined, tag: Tag) => booleancheckTags()function
Checks a list of tags, naming each fault as where: what.
checkTags(v: unknown, at: string, bad: (at: string, what: string) => void): voidWater in a scene written as data
WAVE_LEVELvalue
How high one level of wind waves stands (the root mean square of the height), as a share of the scene's rain splash depth.
0.12SceneWaterclass
The water of a scene written as data (SceneDoc.water), played as the scene plays: from the time alone.
A scene repeats, and can be shown at any moment of its loop in any order (paused, stepped frame by frame to record it), so its water can't be stepped along with the clock. Instead one whole loop of it is worked out here, once: the pond (water.ts, the wave equation on a grid) is run through the loop with every raindrop of the scene's rain splashing where and when it lands and every body the scene names pushing its own volume aside as its bone carries it through the surface. It is run through a few loops first, so that the rings still crossing the pond when the loop starts are the ones the end of the loop leaves, and the last run is kept as heights at fps moments a second. show then lays the heights for a time back on the pond and shapes and colors the surface's blobs.
Nothing is drawn or keyed by hand: change the rain, the banks or a fish's path and the rings follow.
Constructor
new SceneWater(scene: CompiledScene, options?: { fps?: number; warm?: number })Properties
planWaterPlanread onlyThe scene's water as it was planned.
waterWaterread onlyThe pond: its grid, and its heights at the time last shown.
surfaceWaterSurfaceread onlyThe blobs that draw the surface, for the world (
reshapeit after eachshow).loopnumberread onlySeconds before the water repeats: the scene's loop.
countnumberread onlyHow many moments of the loop are kept.
foamFloat32Arrayread onlyFoam on each cell as last laid by
set(), 0 to 1 (WaterDoc.foam); all 0 where the scene has none.sprayActor | nullread onlySpray thrown up where the water strikes something hard enough (with
WaterDoc.foam): droplets on one still bone, placed for the moment byshow(hand it to the stage beside the surface andreshapeit too). It stays blobs when the scene is drawn as blocks. None when the scene has no foam.burstsBurst[]read onlyEvery burst of spray in the loop: where, when, which way away from what it struck, and how hard (0 to 1).
lavaLavaHeat | nullread onlyThe heat over the pool where the scene's water is lava (
WaterPlan.lava), as it stands after the loop was worked out.potionPotionMix | nullread onlyThe dye and froth over the pool where the scene's water is a potion (
WaterPlan.potion), as they stand after the loop was worked out.glowNowFloat32Array<ArrayBufferLike> | nullread onlyEach cell's glow as last laid by
set(), 0 to 1, where it is lava; a potion's dye, then its froth, a block of cells each.swellFloat32Array<ArrayBufferLike> | nullread onlyHow far each cell is under a bubble swelling to pop, 0 to 1, as last laid by
set(), where it is a potion.wavesnumberHow rough the wind makes the water, in levels (
addWind): 0 for none.rainnumberHow much of the rain from outside the scene (
addRain) is falling: the share of its swarm out, 0 to 1.iceIceField | nullread onlyThe pond's ice (
ice.ts): how frozen each cell is. None over lava or a potion, which never freeze. It is made the first time it is asked for (it measures the water's depth), with no ice on it.iceNowIceField | nullread onlyThe pond's ice where it has been made (snow has fallen on it), without making it.
Methods
ride()Stands each float of the scene (
WaterDoc.floats) on the water as it istseconds into the loop: its bone rises and falls with the surface at its point and tips with the slope across its size, steepened as the surface is drawn, on top of the pose the scene gave it. Call it after the scene's pose; it updates the skeleton.ride(sk: Skeleton, t: number): voidaddRain()Rain from outside the scene (weather laid over it) on the pond, in bands of its swarm:
bandsare the shares of the swarm where each ends (ascending, the last 1), andrain(0 to 1, the share of the swarm out) then says how much of each band falls. Each band's rings are worked out on their own, through the same loops: the wave equation is linear, so the pond with them is the pond without plus their rings. Costs a run of the loop a band.addRain(drops: readonly WaterDrop[], bands: readonly number[]): voidprepare()addRainandaddWindworked out a little at a time,budgetmilliseconds a slice with the page let go between (they cost about a second, which froze the page when weather was first picked). Each band of rain and the wind join the water as each is done. Resolves when all are.prepare(drops: readonly WaterDrop[], bands: readonly number[], way: readonly [number, number], budget?: number): Promise<void>addWind()Waves the wind raises, worked out once (
way: where it blows to, x and z), at the height of one level ofwaves. Wind that presses on the water in long rolls running its way, a few at a time and gusting, each repeating a whole number of times a loop and moving at the water's own speed, so they build into waves the pond carries (and its banks throw back) and the loop still joins. Linear, as rain's rings are:waveslevels of it iswavestimes the field. Costs a run of the loop.addWind(way?: readonly [number, number]): voidiceAt()How frozen the water is at a point, 0 to 1: 0 where it never froze, and without making the ice to find out.
iceAt(x: number, z: number): numberfreeze()Freezes the water under a snowfall of
snow(0 to 1) fordtseconds more, or thaws it when none falls; withdtInfinity it is set at once assecondsof that snowfall leave it (off screen, where no clock runs). Ice stills the waves under it (set()), and what floats rides them less. Returns whether the ice changed.freeze(snow: number, dt: number, seconds?: number): booleanset()Lays the water as it stands
tseconds into the loop back on the pond (water.h), blended between the two kept moments round it.set(t: number): voidat()The water at a moment for a renderer that draws the surface itself (the pixel renderer): its heights (
water.h) and foam (foam) are set and its spray thrown, and the surface's own blobs are left alone.at(t: number): voidshow()Shapes and colors the surface for
tseconds as seen fromeye, mirroringmirrorwhere there is one and glinting bylights, and throws the spray.show(t: number, eye: ArrayLike<number>, options?: { mirror?: MirrorImage | null; lights?: readonly PointLight[] }): void
shadeLava()function
Colors each blob of a lava surface by the glow of the cell it lies in (lavaColor()), solid.
shadePotion()function
Colors each blob of a potion's surface (potionColor()): by the dye and froth of the cell it lies in, deep in the hollows and lit on the crests (by the surface's curvature), and paler and shinier over a bubble about to pop. Solid.
shadePotion(s: WaterSurface, brew: Float32Array, swell: Float32Array, p: PotionPlan): voidBurstinterface
A burst of spray: thrown at at seconds into the loop from (x, z), away from what was struck along (ox, oz).
Properties
xnumberWhere it was thrown from, on the water: x.
znumberWhere it was thrown from, on the water: z.
atnumberSeconds into the loop.
oxnumberThe way out from what was struck, a unit pair: x.
oznumberThe way out from what was struck, a unit pair: z.
strengthnumberHow hard, 0 to 1: how high its droplets go.
Fire in a scene written as data
FireWeathertype
What of the sky a fire answers to (a SkyState has them): how much rain and snow fall, 0 to 1, and the wind's level.
Pick<SkyState, "rain" | "snow" | "wind">FUEL_LOWvalue
How much of its fuel a fire burns when it burns low, on its way out, and as embers with the flames gone (FireShape.fuel; 1 with nothing against it).
0.5FUEL_DYINGvalue
How much of its fuel a fire burns when it burns low, on its way out, and as embers with the flames gone (FireShape.fuel; 1 with nothing against it).
0.36FUEL_EMBERSvalue
How much of its fuel a fire burns when it burns low, on its way out, and as embers with the flames gone (FireShape.fuel; 1 with nothing against it).
0.15RAIN_FINEvalue
The rain (a share of all there can be) a fire still burns well in, burns low in, and is put out by: light rain, rain, and anything heavier.
0.15RAIN_LOWvalue
The rain (a share of all there can be) a fire still burns well in, burns low in, and is put out by: light rain, rain, and anything heavier.
0.4RAIN_OUTvalue
The rain (a share of all there can be) a fire still burns well in, burns low in, and is put out by: light rain, rain, and anything heavier.
0.7SNOW_FINEvalue
The snow a fire burns well in; in the heaviest it burns low.
0.4WIND_FINEvalue
The wind's level a fire still burns in, and the level that blows it out (a gale).
2WIND_OUTvalue
The wind's level a fire still burns in, and the level that blows it out (a gale).
2.8FIRE_WINDvalue
How fast the wind crosses a fire at each of its levels, in bed radii a second.
number[]DIEvalue
Seconds a fire takes to die down from full to out, and to catch again, and to change from one way of burning to another.
3.5CATCHvalue
Seconds a fire takes to die down from full to out, and to catch again, and to change from one way of burning to another.
3CHANGEvalue
Seconds a fire takes to die down from full to out, and to catch again, and to change from one way of burning to another.
1fuelUnder()function
How much of its fuel a fire burns under a sky (Matt, 2026-11-22): all of it in light rain and in snow, half in rain and in heavy snow, none in heavy rain or a thunderstorm, and none in a gale, which blows it out.
fuelUnder(sky: FireWeather): numberburningAt()function
The ways of burning that make up a fire burning fuel of its fuel, each with its share: the two it lies between of burning well, burning low, dying and embers. A fire that is out is its embers, which still warm the air over them.
burningAt(fuel: number): { fuel: number; share: number }[]smokeAt()function
How much smoke a fire burning fuel of its fuel gives, 0 to 1: none burning well, the most burning low, a wisp off its embers.
smokeAt(fuel: number): numbershapeUnder()function
A planned fire's shape under a wind of a level (a whole one) burning a share of its fuel: a harder wind throws more sparks, a lower fire fewer.
fireShape()function
What decides how a planned fire burns, wherever it is.
SceneFireclass
The fires of a scene written as data (SceneDoc.fires), played as the scene plays: from the time alone.
A scene repeats and can be shown at any moment of its loop in any order, so its fires can't be stepped along with the clock. One whole loop of each is worked out here, once (runFire()), and show(t) puts every tracer where the loop has it at that moment. The tracers are blobs of an actor of their own beside the scene's (actor: glowing, and soft, so they stay blobs among a Blocks scene's cubes), which the page hands the stage with the scene and sends up again after each show. shine makes each fire's light as bright as the fire burns at that moment.
Constructor
new SceneFire(scene: Pick<CompiledScene, "fires" | "loop">)Properties
actorActorread onlyEvery fire's tracers as blobs on one still bone: hand it to the stage beside the scene.
plansreadonly FirePlan[]read onlyThe fires it plays.
loopnumberread onlySeconds the scene's loop lasts.
keptFireLoop[]read onlyOne kept loop a fire, burning in still air with nothing against it.
fuelnumber[]read onlyHow much of its fuel each fire burns just now, 1 with nothing against it and 0 when it is out (
under()moves it).
Methods
under()Sets the fires under a sky,
secondsafter the last time it was told (Infinity, or the first time: at once). Rain and wind take the fuel they burn (fuelUnder()) and a fire dies down overDIEseconds, to nothing when it is put out, and catches again overCATCH; the wind's level picks a loop played in that wind, so the flame is really blown over, in the weather's own gusts. A loop not played yet is played a little each call and the fire burns as it did until it is there. Call it beforeshow; never called, the fires burn in still air.under(sky: FireWeather, seconds: number): voidshow()Puts every tracer where it is
tseconds into the loop: between the two kept moments either side, a blob as hot as its gas, drawn longer along the way it is moving, as a lick of flame is, in the color of all the hot gas seen through it fromeye(with no eye, of its own heat).show(t: number, eye?: ArrayLike<number>): voidshine()The scene's lights with each fire's own as bright as the fire burns
tseconds into the loop: its strength times the fire's power at that moment beside its mean, in place of the flicker it was written with.shine(lights: PointLight[], t: number): PointLight[]
Weather, clouds and wind as recipes
Weather and cloud cover as recipes (Matt, 2026-11-21: reusable recipes applied to every scene the same way, so a change to rain changes rain everywhere, and a thunderstorm on the campfire is one switch). Pure and tested.
A recipe is a few numbers (SkyState): how much rain and snow falls, how much of the sky is cloud, what the light is multiplied by, how gray and dark the sky turns, how thick the air is, and whether lightning flashes. Nothing in it knows a scene. What is drawn is laid over a scene, never cut into it: the rain, snow and clouds are three small descriptions of their own (weatherDocs()), compiled against the scene's ground so drops land on it, and the light, sky and haze are numbers a page hands the stage each frame. So going from one weather to another is a change of numbers, eased by SkyEase, and the scene is never cut again for it.
WeatherIdtype
A weather of WEATHERS.
"light-rain" | "rain" | "heavy-rain" | "thunderstorm" | "snow" | "heavy-snow" | "fog"CloudIdtype
A cloud cover of CLOUD_COVERS.
"partly" | "cloudy" | "overcast"WindIdtype
A wind of WINDS.
"calm" | "breeze" | "windy" | "gale"SkyStateinterface
What the sky is doing, as numbers that can be mixed.
Properties
rainnumberHow much of the rain falls, 0 to 1 (a share of
RAIN_MOSTdrops).snownumberHow much of the snow falls, 0 to 1 (a share of
SNOW_MOSTflakes).cloudsnumberHow much of the sky is cloud, 0 to 1 (a share of
CLOUDSclouds).lightVec3What multiplies everything but the scene's own lamps and what glows (linear).
graynumberHow far the sky's colors turn to an overcast gray, 0 to 1.
darknumberHow much darker the sky is drawn, 0 to 1.
hazenumberHow thick the air is, 0 (the scene's own) to 1 (fog).
lightningnumberHow strong the lightning is, 0 for none.
windnumberHow hard the wind blows, in levels from 0 (calm: the scene's own) to
WIND_MOST: it slants what falls and raises waves on water.
CLEARvalue
The sky left as the scene has it.
SkyStateCloudCoverinterface
A cloud cover: how much of the sky is cloud and what that does to the light and the sky's colors.
Properties
idCloudIdThe word an address or a saved scene holds.
labelstringIts name as a page shows it.
cloudsnumberThe share of the clouds that are out.
lightVec3What it multiplies the light by (linear).
graynumberHow far it turns the sky's colors to gray, 0 to 1.
darknumberHow much darker it draws the sky, 0 to 1.
CLOUD_COVERSvalue
The cloud covers, from a few clouds to a sky full of them.
CloudCover[]WeatherRecipeinterface
A weather as numbers: what falls, how thick the air is, the light, the lightning and the wind it comes with.
Properties
idWeatherIdThe word an address or a saved scene holds.
labelstringIts name as a page shows it.
cloudsCloudIdThe least cloud it comes with: rain does not fall from a clear sky.
rainnumberoptionalHow much of the rain falls, 0 to 1.
snownumberoptionalHow much of the snow falls, 0 to 1.
hazenumberHow thick it makes the air, 0 to 1 (fog).
lightVec3optionalWhat it multiplies the light by, on top of its clouds'.
darknumberoptionalHow much darker again it draws the sky.
lightningnumberoptionalHow strong its lightning is; none when left out.
windnumberoptionalThe least wind it comes with, a level of
WINDS(Matt, 2026-11-21: water a level rougher under rain, two under heavy rain, three in a thunderstorm).gloombooleanoptionalWhether it is gloomy enough by day that lamps waiting for the dark come on.
WEATHERSvalue
The weathers every scene shares: change one here and it changes in every scene.
WeatherRecipe[]weatherAskedvalue
The weather a word names (from an address, say), or undefined when it names none.
(q: string | null | undefined) => WeatherId | undefinedcloudsAskedvalue
The cloud cover a word names, or undefined when it names none.
(q: string | null | undefined) => CloudId | undefinedskyState()function
The sky for a weather, a cloud cover and a wind, any left out. Weather brings at least its own clouds; more cloud than that may be asked for, less may not. It brings its own wind too, which any wind asked for replaces.
gloomyvalue
Whether lamps that wait for the dark come on under this weather though it is day.
(weather?: WeatherId) => booleanisClearvalue
Whether a sky is the scene's own, with nothing laid over it.
(s: SkyState) => booleanmixSky()function
A sky k of the way from one to another.
WINDSvalue
How hard the wind blows: a level each, calm first. slant is how far sideways it carries rain for each unit it falls.
{ id: WindId; label: string; slant: number }[]WIND_MOSTvalue
The hardest wind, a level (SkyState.wind).
numberwindAskedvalue
The wind a word names, or undefined when it names none.
(q: string | null | undefined) => WindId | undefinedWIND_WAYvalue
Where the wind blows, x and z (one long), the same in every scene.
readonly [number, number]windAt()function
The wind at t seconds into a loop of loop, for a sky: how far sideways it carries rain a unit of fall, [x, z]. Its level's slant (between levels, between their slants), in gusts a whole number of times a loop so a loop joins.
windAt(s: SkyState, t: number, loop: number): [number, number]gustAtvalue
How hard the wind blows at u of the loop as a share of its level's own: gusts a whole number of times a loop.
(u: number) => numbergustRunvalue
gustAt summed from the loop's start to u (loops), so a thing the wind turns turns a little quicker in each gust and still joins the loop: u at 0 and 1 differ by 1 exactly.
(u: number) => numberwindLevelOf()function
The level of wind (SkyState.wind, 0 to WIND_MOST) that carries as far as carry does a unit of fall, gusts taken as the level's own.
windLevelOf(carry: number): numberSKY_EASEvalue
Seconds a change of weather takes.
3SkyEaseclass
The sky on its way from what it was to what was asked for: set() a new one at a time (seconds on any clock) and at gives the sky for a later time, there after SKY_EASE seconds. A change made while another is under way starts from wherever the sky had got to.
Constructor
new SkyEase(seconds?: number)Properties
secondsnumberread onlySeconds a change takes.
targetSkyStateread onlyThe sky asked for.
Methods
moving()Whether it is still changing at
now.moving(now: number): booleanat()The sky at
now: a mix of the sky it left and the one asked for.at(now: number): SkyState
BOLT_EVERYvalue
Seconds between bolts, about.
6BOLT_SECONDSvalue
Seconds one bolt's light lasts.
0.75lightningAt()function
How bright lightning is t seconds into a loop of loop, 0 to 1: a bolt about every BOLT_EVERY seconds, each at its own moment by a hash, as a flash, a dip and a second flash that dies away. At most two flashes a bolt, so never more than three a second. The same in every loop, so a loop joins.
lightningAt(t: number, loop: number): numberlightningWhere()function
Where in the sky the bolt of the moment is, as a place across the clouds' grid (0 to 1 each way, kept in from its edges): each bolt its own, by the same hash as its moment, so a flash lights the clouds from one spot inside them.
lightningWhere(t: number, loop: number): [number, number]FLASH_LIGHTvalue
How much a full flash adds to the light, a channel: bluish white.
Vec3FLASH_SKYvalue
The sky at the top of a flash (sRGB 0 to 255).
RgblightUnder()function
The light under a sky, with flash (0 to 1) of a bolt in it.
skyUnder()function
A sky color (sRGB 0 to 255) under a sky: turned toward an overcast gray, darkened, and lit by a flash.
seaUnder()function
A color of the water seen from under it, under a sky: weather over the surface darkens it and dulls it a little, but it stays the water's own blue (grayed as a sky is, a sea bed under a storm stood in front of plain gray: Matt, 2026-12-02).
hazeUnder()function
The haze a sky lays on a scene seen from distance, in units past the view's target as a scene's own haze is (from where it starts, to where it would be total), or none where the sky brings none. Thin for rain, a wall for fog.
hazeUnder(s: SkyState, distance: number): { from: number; to: number } | undefinedRAIN_MOSTvalue
The most drops of rain and flakes of snow: each is a bone, and a blob names its bones in a byte.
230SNOW_MOSTvalue
The most drops of rain and flakes of snow: each is a bone, and a blob names its bones in a byte.
230CLOUDSvalue
How many clouds there are at full cover.
16CLOUD_COLORSvalue
The clouds' own colors as written, lightest first: their tops, their sides and their undersides.
string[]WEATHER_COLORSvalue
The colors weather brings: a palette that pixel art snaps to needs them.
string[]CLOUD_HEIGHTvalue
How high over the view's target the clouds float, as a share of the view's distance: near the top of the picture as the view starts.
0.3CLOUD_REACHvalue
How far out the clouds reach round the view's target, beside how far rain and snow do (fallReach).
1.6cloudBasevalue
The height of the clouds' flat undersides for a view: what falls starts there, so rain comes down from under the clouds. High enough that, seen along the view as it starts (its height that of a view of STAGE_FOV), the clouds' nearest edge stands near the top of the picture: a view looking down sees the clouds' plane as a band whose near edge comes down the picture as the view steepens, and at 28° their base at a share of the distance put cloud over the middle of a small scene (Matt saw it, 2026-12-03). Shallow views keep their base.
(camera: View) => numberfallReachvalue
How far round the view's target rain and snow fall: half the side of their square.
(camera: View) => numberaboveView()function
The height rain and snow start from with the clouds left out (Matt, 2026-11-21: clouds close over a small scene looked strange, the koi pond's nearly touching its tree and bamboo): over the top of the picture as the view starts, wherever in their square they come down, so they fall in from above the frame.
aboveView(camera: Orbit & { swing?: number }): numberFALL_FLOORvalue
The lowest the box rain and snow fall through reaches: scenes stand on about 0, and a small scene's air ends at -4.
-3FallSquareinterface
A square of ground [x, z] with its half side, which what falls is kept over (SceneDoc.outdoors: outside a room's window).
Properties
atreadonly [number, number]Its middle, [x, z].
halfnumberHalf its width.
falling()function
Rain or snow over the middle of a view, falling from the clouds' height (or top) onto whatever stands there: one swarm, for any scene. Given a square, it falls over that alone (the outdoors seen through a room's window).
falling(kind: "snow" | "rain", camera: Orbit & { swing?: number }, count?: number, top?: number, square?: FallSquare): SpeckDoccloudAt()function
Where cloud i floats for a view: its flat underside at cloudBase, over the scene.
CloudLookinterface
How a sky's clouds look: their colors from underneath up, and whether they glow to keep them. The recipe's own when left out.
Properties
colorsreadonly [string, string, string]optionalThe clouds' colors from underneath up.
glowbooleanoptionalWhether they glow, which keeps them their own color at night.
weatherDocs()function
The weather for a view, as three descriptions laid over any scene: the clouds, the rain and the snow. Each holds the most there can be; poseWeather shows the share a sky asks for. Rain and snow start at top (the clouds' undersides, or aboveView() for a sky with its clouds left out). Compile them with the scene's ground, so what falls lands on the scene.
shareOutvalue
How much of thing i of n is out when share of them are: all of the first ones, none of the last, one in between.
(i: number, n: number, share: number) => numberWeatherBonesinterface
The bones of a compiled weather description that a sky shows more or fewer of.
Properties
cloudsnumber[]The clouds' bones, in the order they come out.
specksnumber[]The bones of the drops or flakes, in the order they start to fall.
weatherBones()function
Finds a compiled weather description's bones by their names.
weatherBones(names: readonly string[]): WeatherBonesshowWeather()function
After a weather description's own pose (before the bones are worked out): shows falls of its drops or flakes and clouds of its clouds, by size, so a sky on its way from one weather to another has its rain thin out or come on a drop at a time.
showWeather(size: Float32Array, bones: WeatherBones, falls: number, clouds: number): voidWeather over a scene
Weather laid over a scene (skyRecipes.ts has the recipes): the rain, snow and clouds as actors of their own beside the scene's, shown by the numbers of a sky that may be on its way from one weather to another. The scene itself is never cut again for the weather.
WeatherSceneinterface
What the weather needs to know of the scene it is laid over.
Properties
loopnumberSeconds before the scene repeats: the weather's loop too.
viewOrbit & { swing?: number }The view the scene starts from: the clouds are laid out over it, and rain and snow fall over what it shows.
heavensHeavensDocoptionalThe scene's own sky (
SceneDoc.heavens): its clouds' colors, and how many are out whatever the weather.ground(x: number, z: number, top: number, bottom: number) => numberoptionalWhere something falling comes to rest (
CompiledScene.ground). Left out, nothing lands and no snow lies.lying(x: number, z: number, top: number, bottom: number) => LyingoptionalWhere snow lies, on moving things too, with the bone that carries it (
CompiledScene.lying), and the scene's bones it numbers: snow lying then rides what it lies on (SceneWeather.follow). Left out, it lies ongroundonly.bonesreadonly Bone[]optionalThe scene's bones, which
lying's bone numbers index.waterSceneWateroptionalThe scene's water, which rain rings and wind roughens.
sunreadonly [number, number, number]optionalThe way to the scene's sun, which shades snow lying on faces turned from it.
outdoors{ at: readonly [number, number]; half: number; top: number }optionalFor a room with a window (
SceneDoc.outdoors): the square outside it, open to the sky up totop. Rain and snow fall over it alone, from that height, and snow lies only there, so nothing falls or lies in the room.lightsreadonly { position: readonly number[]; color: readonly number[]; range: number }[]optionalThe scene's lights as it starts: snow melts round a warm one.
CloudSkyinterface
A sky's simulated clouds at a moment (cloudField.ts), for a host that draws them itself.
Properties
cellsUint8ArrayHow much cloud stands over each cell of the grid and how tall it heaps there, two bytes a cell,
sizecells a side.sizenumberHow many cells the grid is along a side.
levelnumberCloud stands where a cell is over this (0 to 1), and heaps higher the further over.
at[number, number]The middle of the grid on the ground (x, z).
halfnumberHalf the grid's side, in the scene's units.
basenumberThe height of the clouds' flat undersides.
thicknumberHow tall the tallest heap stands over that.
under[number, number, number]Their color underneath as the sky of the moment leaves it, sRGB 0 to 1.
top[number, number, number]Their color on top, the same way.
flash{ at: [number, number]; much: number }optionalLightning inside the clouds just now: where on the ground it is over (x, z) and how bright, 0 to 1. Left out with no storm.
drift[number, number]optionalWhere a loop must join: how far they drift in a whole loop, in grid sides along x and z. Left out as the scene plays.
SceneWeatherclass
A scene's weather, made once a scene: the clouds, rain, snow and snow lying as actors of their own laid over it, shown by how much of each the sky of the moment has, and the same as moments for a renderer that draws them itself (clouds, falling()).
Constructor
new SceneWeather(d: WeatherScene, options?: { overhead?: boolean })Properties
actorsActor[]read onlyThe clouds, the rain, the snow, then the snow lying: drawn in the scene's world as
extras.readyPromise<void>read onlyResolves once the water's rain and wind are worked out (at once for a scene with no water).
coverSnowCoverread onlyThe snow lying on the scene, which builds up while snow falls (
pile).overheadbooleanread onlyWhether the clouds are drawn over the scene; without them rain and snow come in from over the top of the picture.
Methods
follow()Hands the snow lying the scene's pose, so it stays on what it lies on: call it once the scene's skeleton
skis posed and updated for the frame (after the wind, the water's rocking and pokes).follow(sk: Skeleton): voidpile()Sets how deep the snow lying is, 0 to 1, with the scene's ice where its water has any (
SceneWater.iceNow): snow lies on water only where it has frozen. Returns whether it changed by enough to send up again (Stage.reshape(cover)).pile(depth: number, ice?: { ice: ArrayLike<number>; version: number } | null): booleanshade()Turns the clouds as gray and dark as the sky they are in (
skyUnder()'s gray), so a heavy cover reads as cloud, not as a sky of a scene's own dusk-blue clouds. Returns whether they changed by enough to send up again (Stage.reshape(actors[0])).shade(s: SkyState): booleanclouds()The clouds (cloudField.ts) as they stand at
tseconds under a sky, for a host that draws them itself in place of the cloud actor: nothing where the sky has no cloud or none is drawn overhead. Only the weather's or the cover's clouds: with no weather picked there are none, whatever clouds the scene was written with (Matt, 2026-12-02).clockis the wall clock in seconds and whether the loop must join, by which they drift, and whether less motion is asked for (no lightning then).falling()What falls at
tseconds under a sky, for a host that simulates it itself (fallSim.ts) in place of the rain and snow actors: how much rain and snow (0 to 1), the wind of the moment (how far sideways it carries rain a unit of its fall, along x and z), the square it falls over and the height it comes in at. Whereclock.joined(a loop must join), also the loop, the moment of it and the wind at any moment of it.pose()Poses both for
tseconds under a sky.pose(t: number, s: SkyState): void
paletteUnder()function
A palette for a scene under a sky: its colors as that light leaves them and the sky's own first, then the weather's (cloud, rain, snow) and its own as they were, joined down to what a palette holds. Pixel art snaps to it.
Times of day
TimeIdtype
A time of TIMES.
"morning" | "afternoon" | "night"TimeOfDayinterface
A time of day: its sky, its light, and whether it is dark.
Properties
idTimeIdThe word an address or a saved scene holds.
labelstringIts name as a page shows it.
sky[string, string]The sky, top and bottom, as a description writes one.
lightreadonly [number, number, number]What multiplies everything but the scene's own lamps and what glows (linear).
heightnumberHow high the sun or moon stands, in degrees, for a look that lights the scene itself.
darkbooleanWhether lamps that wait for the dark are lit.
hournumberThe hour a live sun stands at for it (Scene Creator's Light mode sets its clock to this).
sunWayreadonly [number, number, number]optionalThe way toward the sun, in a scene's own frame, for what is worked out from where it stands (sunbeams through a window, sunbeams.ts): behind the scene and a little to its right as it is first seen, low in the morning and high in the afternoon. None by night.
TIMESvalue
The times of day a scene can be set in.
TimeOfDay[]timeAskedvalue
The time asked for by name (?time=night), or none: the scene as it is written.
(q: string | null | undefined) => TimeId | undefinedtimeOfvalue
The time with an id.
(id: TimeId) => TimeOfDayunder()function
A color (sRGB 0–255) as it looks under a light.
under(c: readonly number[], light: readonly number[]): RgbpaletteAt()function
A palette for a scene at a time of day: its own colors as the time's light leaves them, the sky's two, then its own as they were (what its lamps light and what glows keep those), joined down to what a palette holds. Pixel art snaps to it, so a scene made for the day has its night's colors to snap to.
The shared sky: moon, sun, stars and clouds
HeavensDocinterface
The sun, the moon, the stars and a scene's own clouds as shared recipes (Matt, 2026-11-21: scenes use a reusable sun, moon and clouds unless one calls for something of its own, an eclipse, a red sun, three moons). A description says where its moon hangs and how big, how many stars and where, and how cloudy its sky is; what they look like is written here once. Pure and tested.
The moon, sun and stars are cut into the scene (withHeavens(), which compileScene(), litFor() and splitScene() call first), each on a bone of its own named with a ~ (~moon, ~sun, ~star<n>), so cloud cover can put them out by size without the scene being cut again (showHeavens()), and Blocks draws them as small cubes. They wait for their time like any part: the moon and stars are lit: 'night', the sun lit: 'day'. The clouds are not cut into the scene: they are the weather's own clouds (skyRecipes.ts), drawn over the scene in the colors the scene asks for, so a scene's few clouds and a storm's many are one kind of cloud.
Properties
moon{ at: Vec3; r: number; colors?: [string, string] }optionalThe moon: its middle and radius;
colorsits face and its craters.sun{ at: Vec3; r: number; color?: string }optionalThe sun: its middle and radius, and its color.
stars{ count: number; from?: Vec3; to?: Vec3; size?: number; colors?: string[] }optionalStars (at most
MOST_STARS), scattered by a hash through the boxfromtoto, or through the sky behind the view's target when it is left out, never on the moon;sizeis a star's radius,colorstaken in turn by a hash.clouds{ cover: CloudId; colors?: [string, string, string]; glow?: boolean }optionalHow cloudy the sky is as the scene stands, and the clouds' colors from underneath up;
glowkeeps them their own color at night.
MOST_STARSvalue
The most stars a scene's sky may ask for.
40MOON_COLORSvalue
The moon's own colors, its face and its craters, where a scene gives none.
[string, string]SUN_COLORvalue
The sun's own color.
"#fff0b8"STAR_COLORSvalue
The stars' own colors.
string[]starAt()function
Where star i of a scene's stars stands: in their box, or in the sky behind the view's target; off the moon.
withHeavens()function
A scene's moon, sun and stars as parts on bones of their own, after everything else; its clouds are left to the weather.
ownCloudsvalue
The share of the weather's clouds a scene's own sky has out.
(doc: Pick<SceneDoc, "heavens">) => numberHeavenBonesinterface
The bones of a compiled scene that cloud cover puts out.
Properties
moonnumber[]The moon's bone, if the scene has one.
sunnumber[]The sun's bone, if the scene has one.
starsnumber[]The stars' bones, in the order cloud puts them out.
heavenBones()function
Finds a compiled scene's moon, sun and stars by their bones' names.
heavenBones(names: readonly string[]): HeavenBonesSTARS_GOvalue
The cover at which stars start to go, and at which the last is gone; the moon and sun go between BODIES_GO and 1.
[number, number]BODIES_GOvalue
The cover at which the moon and sun start to go; they are gone at 1.
0.8showHeavens()function
After a scene's own pose: with cover of the sky cloud (0 to 1), puts out the stars one at a time (all of them by a cloudy sky) and the moon and sun under heavy cloud, by size, so a sky clouding over puts them out as it comes.
showHeavens(size: Float32Array, bones: HeavenBones, cover: number): voidSunbeams through a window
Sunlight through a window as a recipe (Matt, 2026-11-29: the cabin room's sunbeams through its window and onto the floor): the beams a window lets in for the scene's own sun, worked out from where the window is and where the sun stands, so moving either moves the beams. A scene's air.windows are worked out live for the sun of the moment (Matt, 2026-11-29: simulated, not baked; a time of day moves them, TimeOfDay.sunWay, and none come in by night): light through dust with a pool where they land and motes drifting in them (SceneBeams, drawn beside the scene so every style shows it), going as cloud comes over. sunThrough() also writes beams down as ShaftDocs, which light what they land on as the scene is cut.
Openinginterface
A window or other opening the sun comes in through.
Properties
atVec3Its middle.
half[number, number]Half its width along the wall and half its height.
facing"z" | "x"The axis the wall runs across: 'z' for a wall facing along z (running along x), 'x' for one facing along x.
BeamLookinterface
How the beams look: their color, how bright where they land, how much they are seen in the air, and how many across.
Properties
colorstringTheir color, a palette color.
strengthnumberoptionalHow bright what they land on is lit, 0 to 1 (0.6).
seennumberoptionalHow much they are seen in the air, 0 to 1 (0.5).
acrossnumberoptionalHow many beams side by side across the opening (2): one a pane, say.
floornumberoptionalThe height of the floor they land on (0).
litLitWhenoptionalWhen they shine ('day').
sunThrough()function
The beams the sun lets in through opening: sun is the way toward the sun (a scene's light.from), which must stand above the horizon. Each starts on the opening, side by side across it, and runs away from the sun until it meets the floor. Nothing when the sun is below the horizon.
BEAMS_GOvalue
The cover at which beams seen in the air start to fade, and at which they are gone.
[number, number]beamsUndervalue
How much of a beam is seen under a sky with cover of cloud, 0 to 1.
(cover: number) => numberBeamBlobinterface
One blob of a beam seen in the air, or of the pool of light it leaves where it lands.
Properties
beamBlobs()function
A beam seen in the air (ShaftDoc.seen): faint blobs drawn out along it from where it comes in to where it lands, overlapping by half so it reads as one shaft of light through dust, thinning toward where it lands; then a pool of flat blobs on the floor where it lands, as wide as the beam across and drawn out along the way it goes.
POOL_MOSTvalue
The most a blob of a pool of light covers on its own: under the share the map of parts takes a blob at (engine.ts PART_CUT), like a scene's mist, so pixel art draws no line round the pool (Matt saw the pools outlined where the fire's light is not, 2026-11-29). The pool is as bright as it is by its blobs overlapping.
0.12poolBlobs()function
A pool of light lying on the floor at at: the parallelogram (or with round the ellipse) with half sides a and b, filled with faint flat blobs on a grid that overlap several deep, each at most POOL_MOST, softening over its edge.
openingPool()function
The pool of light the sun leaves on the floor through a whole opening: the opening's own shape cast along the sun's way onto the floor, one shape however many beams cross the air (Matt, 2026-11-29: from that far from the window the light lands as one patch, not one a beam). Nothing when the sun is down.
GroundAttype
A scene's ground (CompiledScene.ground): the height of the first surface under (x, z) from top, else bottom.
(x: number, z: number, top: number, bottom: number) => numberMOTESvalue
How many motes of dust drift in a window's beam when the window leaves it out.
24SceneBeamsclass
The beams a scene has seen in the air, drawn as one soft actor beside the scene's own, with a bone a beam: soft, so it stays light in the air among blocks, and every style draws it. Written beams (CompiledScene.beams) stand where the description put them; a window's (CompiledScene.windows) are worked out here for sun, the way toward the sun of the moment (none: the sun is down or it is night, and the window lets no beam in), and carry motes of dust on bones of their own that drift and twinkle in the light, a function of the scene's time alone so the loop still joins. With the scene's ground, a window's pool keeps only what lands on its floor. show puts it all out as cloud comes over.
Constructor
new SceneBeams(written: readonly ShaftDoc[], opts?: { windows?: readonly WindowDoc[]; sun?: Vec3; loop?: number; ground?: GroundAt })Properties
actorActorread onlyThe actor to hand the stage beside the scene's (
Stage.setActor's extras).
Methods
show()Shows the beams under
coverof cloud (0 clear to 1 overcast) at the scene's timet: the motes drift on. Call it each pose; with no motes it does nothing when nothing changed.show(cover: number, t?: number): void
MOTE_SIZEvalue
The size of a mote of dust.
0.006Snow that lies
Snow that lies and builds up (Matt, 2026-11-21: snow and heavy snow should pile up over time and cover the ground).
A layer of flat white blobs laid once over whatever stays put under a stretch of sky, found the way falling snow finds where it lands (ground, a scene's CompiledScene.ground): the tops of the land, roofs, walls and rocks, on faces no steeper than STEEPEST. Every blob has its turn to come (rank): flat, open ground first and in clumps (value noise over a few cells), so snow starts as patches that spread and join. pileSnow(cover, depth) sets the layer for a depth from 0 (none) to 1 (all of it lying, a little deeper than a blob is thick): a blob whose turn has come grows from nothing, and the whole layer rises as it deepens. How deep it is, is the page's: snow builds up over the time it falls (pileStep()), which no scene's loop knows.
Snow stays on what it lies on (Matt, 2026-11-24): given a scene's bones and a ground that says which bone carries each spot (CompiledScene.lying), every blob rides its bone, so snow on a swaying crown, a turning sail, a boat on the waves or anything that walks goes with it. followSnow() hands the layer each frame's pose; snow on a thing turned past SLIDE_FROM from upright slides off it (shrinks onto its bone) and settles again as it comes back up.
STEEPESTvalue
The steepest face snow lies on: the up part of its normal.
0.55SnowCoverinterface
A layer of snow lying on a scene: an actor of flat white blobs, with what pileSnow() needs to deepen it.
Properties
blobsBlobsThe layer's blobs, one a spot snow can lie on.
skinSkinEvery blob on the one still bone.
skeletonSkeletonThe scene's bones (one still bone when it gave none), posed by
followSnow().softtrueDrawn as blobs while the stage draws blocks, beside the weather.
weathertrueIt is weather, which the Blocks look draws as cubes or leaves as blobs.
liestrueIt lies on things: among blocks it is raised onto the cubes' tops.
rankFloat32ArrayWhen each blob comes, 0 to 1: at depth
rank · (1 − GROW)it starts to grow.atFloat32ArrayWhere each blob lies on the surface, x y z, and the surface's normal there.
normalFloat32ArrayThe surface's normal under each blob, x y z.
sizeFloat32ArrayEach blob's full radius.
depthnumberThe depth the layer was last set for.
overInt32Array<ArrayBufferLike>optionalFor a blob that lies on water, the cell of the water's grid it is over (
makeSnowCover()'swater); -1 on land. Left out where none does.icednumberoptionalThe version of the ice the layer was last set for (
pileSnow()).follows{ from: Skeleton; index: Int16Array }optionalFor each bone of the layer, its index in the skeleton
followSnow()was last given (-1: none), and that skeleton.
Lyingtype
Where a spot of snow lies: the height, and the bone of the scene's that carries it. Where that is something that moves about, under() is the still ground beneath it, which takes snow of its own: the thing moves off and the ground it stood over at rest is as white as the rest (left out where there is none, or the top is the ground).
unknownmakeSnowCover()function
Lays the layer over a disc of radius round (x, z) at spacing between blobs. ground(x, z, top, bottom) is where something falling from top comes to rest (bottom where it meets nothing); dry(x, y, z) leaves out a spot (lava: snow falling on it melts); water(x, y, z) says which cell of a pond's grid a spot on water is over (-1 on land), and snow lies there only while that cell is frozen (pileSnow()'s ice). sun (toward the light) shades faces turned away a little blue.
makeSnowCover(ground: (x: number, z: number, top: number, bottom: number) => number | Lying, options: { x: number; z: number; radius: number; top: number; bottom: number; spacing: number; bones?: readonly Bone[]; sun?: readonly number[]; dry?: (x: number, y: number, z: number) => boolean; water?: (x: number, y: number, z: number) => number; warm?: readonly { at: readonly number[]; reach: number }[] }): SnowCoverSNOW_ON_ICEvalue
How frozen water must be before snow starts to lie on it; it lies whole on water frozen through.
0.6pileSnow()function
Sets the layer for a depth from 0 to 1. Snow over water (SnowCover.over) lies only where the water has frozen: ice is the pond's ice a cell (IceField), and with none the water is open and takes no snow. Returns whether anything changed (then hand it to Stage.reshape).
pileSnow(cover: SnowCover, depth: number, ice?: { ice: ArrayLike<number>; version: number } | null): booleanSLIDE_FROMvalue
Snow slides off a thing turned so its up is no more than this far up (the y of its turned up): gone by level, whole from here.
0.4followSnow()function
Poses the layer as the scene's skeleton sk stands (posed and updated: call it after everything that moves the scene's bones). Each of the layer's bones takes the skin of the scene's bone of its name, so snow rides what it lies on; on a bone turned past SLIDE_FROM its snow shrinks onto the bone's head. Bones the scene lacks stay at rest.
MELT_SHAREvalue
How far round a light snow melts, as a share of its range at a strength of one: a campfire clears the ground round it, a lamp its own cap.
0.3warmthOf()function
The places a scene's lights keep clear of snow: warm ones only (more red than blue), by how strong they are.
warmthOf(lights: readonly { position: readonly number[]; color: readonly number[]; range: number }[]): { at: readonly number[]; reach: number }[]PILE_SECONDSvalue
How fast the snow lying builds up: a whole cover in about this many seconds of heavy snow.
45MELT_SECONDSvalue
How many seconds snow takes to melt away once none falls.
90pileMostvalue
The most a snowfall of snow (0 to 1) lays: heavy snow covers everything, a lighter fall only dusts (Matt, 2026-11-21: light snow covered too quickly).
(snow: number) => numberpileStep()function
The depth after dt seconds more of snow (the share of the swarm falling, 0 to 1): it builds by the square of how much falls, so light snow (0.4) lays about a sixth as fast as heavy, up to pileMost; above that, and when none falls, it melts.
pileStep(depth: number, snow: number, dt: number): numberShapes on a grid
Shapeinterface
A voxel builder for pixel-art scenes: shapes given as distance functions are cut into a grid, and every grid cell on a shape's surface becomes one small, nearly solid blob, a disc lying flat on the surface. Drawn small and snapped to a palette (pixelPass.ts) a scene of these reads as chunky pixel art with real depth.
Where body.ts scatters flat blobs over a creature's skin and blends them between bones, this fills a regular grid and hangs each part on one bone, so parts move rigidly (a lamp turns, a boat bobs) and the grid stays crisp.
Light is baked into the colors: one sun, an ambient floor, and shadows cast by every part on every other, found by marching from each blob toward the sun through the scene's shapes in the rest pose. glow parts keep their color and cast no shadow. Three optional touches a pixel artist would paint (all off unless the light asks): ramp() turns shade cool and light warm instead of only darker, crevice darkens what is shut in by other surfaces, and wear lightens edges. A part's grime collects where it is shut in.
Properties
sdf(x: number, y: number, z: number) => numberDistance to the surface: negative inside.
minVec3A box that holds the whole shape.
maxVec3The far corner of a box that holds it.
pieceAt(p: Vec3) => numberoptionalFor a shape made of many pieces (the bricks of a wall, the posts of a fence, the columns of a basalt causeway): which piece a surface point belongs to, as a whole number 0 or more, or -1 for what lies between them (mortar). The
piecespaint gives every piece a color of its own.
AWAY_FACINGvalue
How squarely a cell must face a part's away way to be left out: the cosine of 45 degrees.
numberVoxelPartinterface
One part of a voxel scene: a shape, its paint and the bone that carries it.
Properties
shapeShapeThe part's shape, as a distance function.
colorVec3 | ((p: Vec3, n: Vec3) => Vec3)Color (0–1, sRGB) or color at a surface point given its outward normal.
bonestringThe bone that carries it.
paintCreaturePaintoptionalIts paint as data (creaturePaint.ts), over
coloras what the paint's'own'stands for: the cutter reads it into each blob's color, and insidepainted()it leaves each blobcoloralone and says which paint it has, for the pixel renderer to work out a pixel at a time.glowbooleanoptionalUnlit and casting no shadow: lamps, windows, beams of light.
laidbooleanoptionalLaid on other parts (a pane on its frame): none of its cells is left out for lying inside a neighbor, so its face is whole and the face under it is what goes.
opacitynumberoptionalHow solid its blobs are, 0–1.
noShadowbooleanoptionalCasts no shadow on other parts (thin things far from the ground, like birds).
awayVec3optionalA way it is never seen from (the outside of a dollhouse wall, which is taken away whenever the view is out there): cells facing that way, by more than
AWAY_FACING, are left out. Light and shadows still go by the whole shape.grimeVec3optionalA color (sRGB, 0–1) that gathers in its hollows and creases, as moss or dirt does. Needs the light's
creviceto find them.barebooleanoptionalTakes none of the scene's
cover: water, glass, anything that moves through it or was just made.inkInkoptionalLittle drawn marks over the surface: see Ink.
glassGlassoptionalWater, ice or glass: see Glass. Needs the spec's
eye.strokesnumberoptionalDabs that follow the form: 0 leaves each cell a round disc; up to 1 draws it as a stroke along the level line round the shape, as a painter's brush goes round a pot or a trunk. Seen as blobs it reads as brushwork; in pixel mode it barely shows.
Glassinterface
A surface you see into and that mirrors what is over it, baked for one place to look from (the spec's eye, the scene's camera): pixel mode cuts anything faint, so instead of being drawn see-through, each cell takes the color of what lies behind it on the line from the eye (see) and of what its mirror line meets (mirror, stronger at a glancing look, as on real water). Seen from far off the scene's own view it is a painting of glass, not glass.
Properties
seenumberoptionalHow much of what is behind shows through: 0 to 1.
mirrornumberoptionalHow much it mirrors, looked at straight on; more at a glancing look. 0 to 1.
topbooleanoptionalOnly its upturned faces: a pond cut as one slab whose sides are earth.
Inkinterface
Inked detail: the surface is taken in blocks of 4×4 cells (one picture pixel each in pixel mode), and a share of the blocks (amount) each carry one small mark of the kind, picked, turned and flipped at random per block and with the blocks of each row shifted, so a big wall never shows a repeat. color is the ink; left out, a darker step of the paint under it.
Properties
InkKindtype
The kinds of mark a part's ink can draw on it.
"hatch" | "stipple" | "cracks" | "grain" | "tufts" | "scales"INK_MARKSvalue
The marks of each kind, 4×4, top row first. Kinds in UPRIGHT only ever flip side to side: grass grows up, wood grain runs along.
Record<InkKind, string[]>inkedAt()function
Whether the cell at grid (gx, gy, gz) with normal n carries ink of this kind: see Ink. seed keeps parts apart.
inkOf()function
The ink a color takes by default: a darker, slightly richer step of it.
Coverinterface
Something laid over the whole scene once it is cut: snow settles on tops that the sky can reach, moss creeps over shut-in and up-turned faces in patches, dust lies thin on every upturned face, under cover or not.
Properties
kind"snow" | "moss" | "dust"What lies on the scene.
colorVec3sRGB, 0–1.
amountnumber0–1: how much of the scene it takes, from a dusting to most of what faces up.
LooseBlobinterface
A blob placed as it is, not cut from a shape: soft, faint things in the air such as mist or a beam of light. Kept under LOOSE_MAX opacity, so pixel mode's map of parts never takes one for a surface.
Properties
Beaminterface
A beam of light falling through the scene, as from a window or a gap in the leaves: surfaces inside it that face back up it are lit by its color, on top of the sun, so the beam shows where it lands.
Properties
LOOSE_MAXvalue
The most a loose blob may cover: under the engine's PART_CUT, so it never shows in the map of parts.
0.13VoxelLightinterface
The light baked into a voxel scene's colors: the sun, the ambient light, cast shadows and the painted touches.
Properties
dirVec3Direction toward the sun.
ambientnumberLight that reaches everywhere, 0–1.
shadownumberHow dark a cast shadow is: 0 leaves no shadow, 1 leaves only the ambient light.
rampnumberoptionalHow far shade turns its hue toward cool violet and full sun toward warm yellow, as a painter's ramp does: 0 only darkens.
crevicenumberoptionalHow much surfaces shut in by others (corners, cracks, the foot of a wall) darken: 0 to 1.
wearnumberoptionalHow much sharp outer edges lighten, as worn stone and wood do: 0 to 1.
bouncenumberoptionalHow much color surfaces throw onto what faces them, as a red wall warms the floor beside it: 0 to 1.
steps{ palette: Vec3[]; mottle?: number }optionalPainted in steps: once a blob's light is worked out, its color is moved onto one color of
palette(sRGB, 0–1), a step of its own paint's ramp (the palette colors that paint passes through from deep shade to full sun), so shade falls in flat bands a pixel pass has nothing left to guess at.mottle(0–1,MOTTLEwhen left out) nudges small patches a little lighter or darker first, so a band's edge is ragged as a brush leaves it, not ruled. Parts thatglowkeep their color.
STEP_Lvalue
How much a difference in lightness counts beside one in hue when a blob picks its step (stepper()): under 1, so hue is kept first.
0.7MOTTLEvalue
How ragged the edge between two steps is, where a scene doesn't say (VoxelLight.steps).
0.35HUE_KEEPvalue
How far round the hue circle (degrees, in OKLab) a palette color may sit from a paint's own and still be a step of its ramp (stepper()), where both have color enough to have a hue (HUE_FROM). A red that has no darker red in the palette stays its own darkest red in shade rather than turning brown or orange, as a hand-made ramp would.
16HUE_FROMvalue
The chroma (OKLab) under which a color counts as a gray for HUE_KEEP: a gray is a step of any paint's ramp.
0.02GRAY_TURNvalue
How far round the hue circle (degrees) a near-gray palette color may sit from the way a gray paint's light tints it (cool in shade, warm in sun) or from the paint's own faint hue, and still be a step of its ramp (stepper()). White sails in shade took the sky's palest blue, which read as holes through to the sky.
40ESCAPEvalue
How many times closer a palette color off a paint's ramp must be before a blob takes it (stepper()): only light of another color carries a blob that far.
9VoxelSpecinterface
A voxel scene for buildVoxels(): its bones, its parts and the grid's cell size.
Properties
bonesBone[]The scene's bones.
partsVoxelPart[]The parts, all cut into one shared grid.
spacingnumberGrid cell size in world units: one blob per surface cell.
lightPartial<VoxelLight>optionalThe baked light; what is left out comes from
DEFAULT_LIGHT.blocksbooleanoptionalSkip blocks of cells far from a surface: much quicker for big smooth shapes, sound only for honest distance functions (sculpt.ts).
trueShellbooleanoptionalKeep the outermost layer one cell thick in true distance, not in the shape's own units. A shape pushed in and out (
displace()) can have a distance that changes faster than one unit per unit; read raw, its layer comes out thinner than a cell and leaves holes you see the far side through. Creatures (sculpt.ts) turn this on.keepBuriednumberoptionalHow deep (world units) a cell may sit inside a neighbor on its bone and still be made: a skirt that keeps a joint closed as parts move.
discnumberoptionalA disc's radius (its blob's scale across the surface) as a share of
spacing. The default leaves the grid crisp for pixel mode, which cuts alpha; drawn smooth, discs that small let about a tenth of what lies behind show between them, so a creature seen as blobs wants them wider.looseLooseBlob[]optionalBlobs placed as they are, after the cut ones: see LooseBlob.
beamsBeam[]optionalBeams of light that fall through the scene.
coverCoveroptionalSnow, moss or dust over every part that isn't
bareorglow: see Cover.focus{ at: Vec3; r: number }optionalWhere the eye goes: within
rofatthe grid is as fine asspacing; further out it is twice as coarse, with discs twice the size, so the subject keeps its detail and the rest is painted broadly in a quarter of the blobs. Only parts at least eight cells across every way go coarse: a thinner one could miss every coarse cell.eyeVec3optionalWhere
glassparts are looked at from: the scene's camera.sky[Vec3, Vec3]optionalThe sky a
glasspart mirrors where its mirror line meets nothing: [overhead, at the horizon]. Dark when left out.lamps(Lamp | null | undefined)[]optionalLamps whose shadows are baked, in the order of the live lights they stand for (at most four; a gap is a light that casts none): for each blob, how much of lamp k it can see goes in byte k of
seen, and the engine's live light pass scales that light by it, so a lamp's shadows flicker with it and cost nothing a frame.
Lampinterface
A light that stays put, whose shadows buildVoxels() works out once for each blob.
Properties
atVec3Where it is.
reachnumberHow far its light reaches: blobs further off are not looked at (their byte stays full).
clearnumberoptionalHow far short of it the look toward it stops, so its own housing doesn't shade everything:
LAMP_CLEARwhere left out. Blobs nearer than this are always lit. Set it to the room round a lamp that sits in a small hollow, or the hollow's own walls and roof let its light through.
MAX_LAMPSvalue
How many lamps' shadows a blob carries, one byte each.
4LIT_MAXvalue
The brightest the baked sun makes a surface, as a share of its color. Only glow parts are built brighter, so pixel mode can tell a lamp from a white wall in the sun (GLOW_FROM in splat-core/pixel.ts sits just over it). Live lights add on top: a surface under a strong one does pass the line and glow.
0.9PAINTEDvalue
The painted touches pixel scenes use unless they say otherwise: hue-turning shade, dark crevices, worn edges.
{ ramp: number; crevice: number; wear: number }DEFAULT_LIGHTvalue
The light a voxel scene gets where it sets none of its own.
VoxelLightsphere()function
A ball of radius r about c.
ellipsoid()function
An ellipsoid with radii along x, y and z (the distance is approximate, exact on the surface).
box()function
A box with half sizes h, its edges rounded by round.
cone()function
A rounded cone from a (radius ra) to b (radius rb); equal radii make a capsule.
cylinder()function
A upright cylinder with flat ends, from y0 to y1; r1 tapers it.
cylinder(c: [x: number, z: number], y0: number, y1: number, r0: number, r1?: number): Shapetorus()function
A ring lying flat (about the y axis): R to the middle of the tube, r the tube's radius.
roof()function
A roof: a ridge along x at top, sloping down to y0 at hz either side.
roof(c: [x: number, z: number], y0: number, top: number, hx: number, hz: number): Shapeunion()function
Several shapes as one: a point inside any of them is inside.
tighten()function
A shape whose distance can overstate by up to 1/k − 1 of itself (a ragged edge, an overhang the side distance doesn't see) made honest for the sun march: exact within near of the surface, where cells are placed, and scaled by k beyond it, so a step never passes through.
many()function
A union of many scattered shapes, sorted into buckets so a point asks only the shapes near it: quick for fences, fallen bricks and twigs.
orientedBox()function
A box turned any way: axes are its three edge directions (unit length, square to each other) and half its half size along each. Fallen bricks, leaning posts, rails between them.
BlendKindtype
How a blend() meets where its shapes touch: a rounded fillet, a flat bevel, or a run of little steps.
"smooth" | "chamfer" | "stairs"blend()function
Shapes joined so the seam between them is filled in: r is how far the fillet, bevel or stairs reach.
lathe()function
A turned shape, as from a lathe: profile is [radius, height] pairs from the bottom up, standing on c, and the outline is spun about the upright axis through it. Vases, bells, bottles, chess pieces, lamp posts.
sweep()function
A tube along a path of points, r0 thick at the start and r1 at the end: vines, pipes, rails, a dragon's tail.
LETTERSvalue
The 3×5 letters pixelText() knows, top row first.
Record<string, string>pixelText()function
Words in blocky 3×5 letters (LETTERS; lower case is read as upper), size tall and depth thick, centered on at and reading along +x, or along -z when facing is 'x'. A letter needs about five grid cells of height to read.
letterGrid()function
A model drawn as letters: layers from the bottom up, each a list of rows from the back (-z) to the front, each row a string read along +x; any character but '.' or a space fills a cube size across. Standing on at, centered on it across. letterAt says which letter a point is in, so a paint can color the model by letter.
cut()function
a with b cut out of it.
displace()function
A shape pushed in or out by f(x, y, z) world units: ripples, rough rock. reach is the most it moves.
coverAt()function
How much of a cover lies on a surface point, 0–1. open is its openness (moss wants it low) and sky how much of the sky straight up it sees (snow wants it high); each is only asked for when the kind needs it.
bakedColor()function
A surface color under the baked light. shade is how bright (0 to LIT_MAX), lit how much straight sun it takes (0–1). With ramp() the color doesn't only darken: shade turns its hue toward violet and gains a little chroma in the middle tones, full sun leans warm, and even a gray goes cool in shadow, so a palette's cool darks get picked over its browns. lift lightens it (a worn edge). Never brighter than LIT_MAX, which keeps it under pixel mode's glow line.
stepper()function
Painting in steps (VoxelLight.steps): gives the function that moves a blob's finished color onto its paint's ramp. A paint's ramp is the palette colors it passes through as its light goes from a deep corner to full sun (found once per paint, to 1/64 a channel); a finished color takes the nearest of them, after mottle has pushed its lightness up or down by patch. Light of another color (a beam, a bounce, a mirror) can carry a blob well off its ramp: when a palette color outside it is ESCAPE times as close or more, that one is taken. A ramp keeps to its paint's own hue (HUE_KEEP). Palette colors over LIT_MAX are held at it, as every lit color is, so nothing painted starts to glow.
unlit()function
Runs make with every buildVoxels() inside it leaving the light out: each blob keeps its paint (with its ink, cover and grime, which are paint), and no sun, shade, cast shadow, ramp, crevice, wear, bounce or beam is baked into it. For a look that lights the blobs itself, such as cel shading (Stage.setCel), which would otherwise shade a shadow twice. It reaches builders that take no light of their own to set, such as a creature's make.
unlit<T>(make: () => T): TclearGlass()function
Runs make with every buildVoxels() inside it leaving glass parts their own paint, with nothing seen through them or mirrored in them painted on: for a renderer that draws glass see-through itself (the pixel renderer's glass layer).
clearGlass<T>(make: () => T): Tsurfaced()function
Runs make with every buildVoxels() inside it setting each disc down on its shape's surface, not at the middle of its grid cell, which lies up to a cell under it. Discs left at their cells stand in steps along a slanted face: seen face on they still cover it, but seen at a slant the steps open rows of gaps between them (Matt saw dashes across pumpkin tops and combed edges in the pixel renderer, zoomed in, 2026-12-02). For a renderer that draws hard discs.
surfaced<T>(make: () => T): Twithin()function
Runs make with every buildVoxels() inside it cutting only the grid points within a box (in the spec's own units, the rest pose): a finer cut of the ground round one place of a scene too big to cut fine whole.
banded()function
Runs make with every buildVoxels() inside it lighting each blob as one texel in n flat bands: the sun's share that reaches a blob (its facing times its cast shadow) is moved onto the nearest of n steps from none to full before its color is worked out, so light and shade fall in whole blobs, crisp along the surface, while each blob keeps its own paint (bricks, planks, ripples). The ambient share is left as it is. 0 or 1 leaves the light smooth.
banded<T>(n: number, make: () => T): Thugged()function
Runs make with every buildVoxels() inside it fitting the discs along a shape's outer edges to the edge: a disc whose surface ends within its reach (the shape falls away from the disc's own plane, as past the top of a fence rail or the rim of a pond) is moved in and squeezed across the edge, long along it, so the row of discs ends in a straight line where the shape does instead of a row of round bumps standing past it. Inner corners are left alone: what meets them covers them. See edgeFit().
hugged<T>(make: () => T): TedgeFit()function
Where the surface of a shape ends within a disc's reach, in the disc's own plane: the way out to the nearest outer edge (a unit vector in the plane) and how far from the disc's middle the edge lies, or undefined when the surface carries on all round. past(q) is how far the shape lies off the disc's plane at q, counted as off past least; it is asked at three distances along EDGE_WAYS ways, the nearer ones only where the farthest finds an edge.
bandOf()function
Moves a sun share (0 to 1) onto the nearest of n steps (banded()).
bandOf(direct: number, n: number): numberpainted()function
Runs make with every buildVoxels() inside it leaving a part's paint to be worked out later: its blobs take the part's own color, and the cut says (Built.painted) which blobs have which paint. For a renderer that reads the paint a pixel at a time (the pixel renderer).
painted<T>(make: () => T): TbuildVoxels()function
Cuts the parts of a spec into blobs (see VoxelSpec).
Built things: walls, steps, fences, arcades
Built things: walls of real bricks, flights of worn steps, fences along a path and arcades cut into equal bays, each one shape however many pieces it has. Pure numbers and distance functions, so the scene builder cuts them like any other shape, and each shape's pieceAt says which brick, block, post or stone a point is on, for the pieces paint.
Every piece is placed by a rule from the shape's own sizes and a seed (the same seed, the same ruin), and sizes are fitted so the pieces come out whole: a wall's length is a whole number of bricks (half bricks at the ends of every other course), a span a whole number of bays, so pillars and posts land exactly at its ends.
The idea comes from Silicon Jungle's Ink Studio built-things kit; this is our own code.
hash()function
A repeatable number in 0..1 from a seed and up to three whole numbers.
hash(seed: number, a: number, b?: number, c?: number): numbernoise1()function
Smooth 1D noise in 0..1 with bumps about size apart.
noise1(seed: number, u: number, size: number): numberWallSpecinterface
A brick wall for wall().
Properties
fromVec3The foot of the wall at one end and at the other; the wall stands on
from's height.toVec3The foot of the wall at its other end.
heightnumberHow high it stands.
thicknumberHow thick it is.
brick[number, number]optionalA brick's length and height (a course), fitted so whole courses and bricks fill the wall.
jitternumberoptionalHow far bricks sit proud or sunk and vary in size, 0 to 1.
ruinnumberoptionalHow much of the top has fallen, 0 (whole) to 1 (down to the ground in places).
missingnumberoptionalThe share of bricks gone from the face, showing the mortar core behind, 0 to 0.5.
fallennumberoptionalBricks lying at the foot of the wall, fallen from its top.
seednumberThe same seed gives the same result.
WALL_BRICKvalue
A brick's length and height where a wall gives none.
[number, number]wallPlan()function
How the bricks of a wall are laid: fitted sizes and which bricks stand.
wallPlan(s: WallSpec): { f: { len: number; ux: number; uz: number; local: (x: number, y: number, z: number) => [number, number, number]; world: (u: number, v: number, w: number) => Vec3 }; rows: number; cols: number; bh: number; bl: number; topAt: (u: number) => number; span: (j: number, c: number) => [number, number]; state: (j: number, c: number) => 0 | 1 | 2 }wall()function
A wall of bricks laid in courses (see WallSpec). cell is the grid spacing, so mortar lines are at least a cell wide.
fallenBricks()function
The bricks lying at a wall's foot: each fell from where the top is lowest, lies flat on the ground at a random turn.
fallenBricks(s: WallSpec, plan?: { f: { len: number; ux: number; uz: number; local: (x: number, y: number, z: number) => [number, number, number]; world: (u: number, v: number, w: number) => Vec3 }; rows: number; cols: number; bh: number; bl: number; topAt: (u: number) => number; span: (j: number, c: number) => [number, number]; state: (j: number, c: number) => 0 | 1 | 2 }): Shape[]StepsSpecinterface
A flight of steps for steps().
Properties
atVec3The middle of the bottom step's front edge, on the ground.
dir[number, number]The way the flight climbs, along the ground: [x, z].
countnumberHow many steps.
risenumberA step's height.
runnumberA step's depth, front to back.
widthnumberHow wide the flight is.
wearnumberoptionalHow worn: rounded noses and a hollow where feet go, 0 to 1.
seednumberThe same seed gives the same result.
steps()function
A flight of steps, each block its own piece, its nose worn round and its tread hollowed in the middle.
bays()function
Where the posts of a span stand: each straight run of the path cut into whole, equal bays, so posts land at every corner.
FenceSpecinterface
A post-and-rail fence for fence().
Properties
pathVec3[]Where it runs, on the ground: 2 to 16 points.
baynumberAbout how far apart the posts stand; each run is cut into whole bays.
heightnumberA post's height.
postnumberHalf a post's thickness.
railsnumberRails between posts, 1 to 4.
leannumberoptionalHow many posts lean and how far, 0 to 1.
missingnumberoptionalThe share of rails gone or hanging from one end, 0 to 1.
sagnumberoptionalHow far rails sag in the middle, 0 to 1.
seednumberThe same seed gives the same result.
fencePosts()function
The posts (feet and tops) of a fence, with their leans.
fence()function
A fence of posts and rails along a path: some posts lean, some rails are gone, hang from one end or sag.
ArcadeSpecinterface
A wall of arches for arcade.
Properties
fromVec3The foot of the wall at one end.
toVec3The foot of the wall at the other end.
heightnumberHow high it stands.
thicknumberHow thick it is.
baysnumberEqual bays the span is cut into: one opening each, with a pillar between.
pillarnumberA pillar's width.
springnumberoptionalThe height the arches spring from; left out, 60% of the wall.
arch"round" | "pointed" | "flat"optional'round', 'pointed' or 'flat' heads to the openings.
coursenumberoptionalHeight of a course of stone; left out, about an eighth of the wall.
ruinnumberoptionalHow much of the top has fallen, in a ragged line, 0 to 1 (never below the arches' springing).
seednumberoptionalThe same seed gives the same result.
ARCHESvalue
The heads an arcade's openings can have.
readonly ["round", "pointed", "flat"]arcadevalue
A wall cut into equal bays with an opening in each: arcades, cloisters, viaducts. Its stones are laid in courses, with wedge stones round each arch. cell is the grid's cell size.
(s: ArcadeSpec, cell: number) => ShapeFormations: crystals, columns, drips
Formations: shapes that come from a rule rather than placing each one by hand. A faceted crystal and clusters of them from one root, a geode broken open, basalt columns on a hex grid, stalactites and stalagmites that join into columns, flowstone down a wall, and icicles under every downward edge of another shape. Pure distance functions, each with a pieceAt for the pieces paint.
The idea comes from Silicon Jungle's Ink Studio formations kit; this is our own code.
CrystalSpecinterface
One crystal for crystal().
Properties
atVec3Its foot, where it grows out of the rock.
dirVec3The way it points.
lengthnumberHow long it is, foot to point.
rnumberIts radius, corner to middle.
sidesnumberoptionalSides, 3 to 8 (6 when left out).
tipnumberoptionalHow much of its length the point takes, 0.1 to 0.8 (0.3).
chipsnumberoptionalHow many chips are knocked off its faces, 0 to 6.
seednumberThe same seed gives the same result.
crystal()function
A sided crystal with a pointed end, chipped here and there.
crystal(s: CrystalSpec): ShapeClusterSpecinterface
A cluster of crystals growing from one root, for cluster().
Properties
atVec3Where they grow from.
countnumberHow many crystals.
sizenumberThe longest, in the middle.
rnumberThe radius of the biggest.
spreadnumberoptionalHow far the outer ones lean, in degrees (50 when left out).
sidesnumberoptionalSides to each crystal, 3 to 8 (6 when left out).
chipsnumberoptionalChips knocked off each crystal's faces, 0 to 6.
seednumberThe same seed gives the same result.
clusterCrystals()function
The crystals of a cluster: the middle one longest and upright, the rest leaning out and shorter the further they lean.
clusterCrystals(s: ClusterSpec): CrystalSpec[]cluster()function
A cluster of crystals from one root (see clusterCrystals); each crystal is a piece.
cluster(s: ClusterSpec): ShapeGeodeSpecinterface
A broken-open geode for geode.
Properties
atVec3Its middle.
rnumberIts radius.
openVec3The way the broken face looks: its outward direction.
rindnumberoptionalThe rind's share of the radius (0.15).
bandsnumberoptionalBanded layers inside the rind (3).
liningnumberoptionalHow long the crystals lining the hollow are, as a share of the radius (0.22).
seednumberThe same seed gives the same result.
ColumnsSpecinterface
A field of six-sided columns, as basalt, for columns().
Properties
atVec3The middle of the field, on the ground.
rnumberHow far the field reaches.
cellnumberA column's width across its flats.
heightnumberThe tallest column.
rise"steps" | "dome" | "random"optionalHow heights run: 'dome' (tallest in the middle, as organ pipes), 'steps' (a causeway stepping down to its edge) or 'random'.
seednumberThe same seed gives the same result.
RISESvalue
The ways the heights of a field of columns can run.
readonly ["dome", "steps", "random"]columns()function
Basalt columns on a hex grid: one shape with a height per column, each column a piece.
columns(s: ColumnsSpec): ShapeDripsSpecinterface
Stalactites and stalagmites for drips().
Properties
atVec3The middle of the floor under them.
rnumberHow far across they spread.
roofnumberThe height of the roof they hang from.
countnumberHow many drips.
lengthnumberThe longest stalactite.
seednumberThe same seed gives the same result.
dripPlan()function
Where each drip falls, and how long its stalactite above and stalagmite below have grown; joined when they met.
dripPlan(s: DripsSpec): { x: number; z: number; down: number; up: number; joined: boolean; wide: number }[]drips()function
Stalactites hanging from a roof, stalagmites where their drips land, joined into columns where they meet.
FlowSpecinterface
A sheet of flowstone for flowstone.
Properties
atVec3The middle of its top, where it leaves the wall.
along[number, number]Along the wall: [x, z]. Its face looks out to the right of this.
widthnumberHow wide it is along the wall.
dropnumberHow far it hangs down.
foldsnumberoptionalFolds across it (5).
seednumberThe same seed gives the same result.
IcicleSpecinterface
Icicles along a shape's edges, for icicles().
Properties
everynumberAbout how far apart they hang.
lengthnumberThe longest.
abovenumberoptionalOnly edges higher than this hang icicles (an edge resting on the ground has none): every edge when left out.
seednumberThe same seed gives the same result.
icicles()function
Icicles under every downward edge of host: its box is looked at from below in columns every apart, and where a column meets the underside of the shape but the column beside it doesn't (or meets it much higher up), an icicle hangs from that edge. Only the icicles are drawn: give the host its own part.
icicles(host: Shape, s: IcicleSpec, thin?: number): Shapegeodevalue
A geode broken open: a rind, banded layers and crystals lining the hollow.
(s: GeodeSpec) => Shapeflowstonevalue
Flowstone: a folded sheet of stone hanging down a wall.
(s: FlowSpec) => ShapeLiving forms: trees, cacti, shells
Living forms: trees grown by space colonization, ribbed cacti, succulent rosettes, bracket fungi, brain coral, shells wound on a log spiral, horns that curl, antlers with tines and a spine of ribs. Pure numbers and distance functions: each lights, shadows, grows (on a bone with a sprout move) and rigs like any other part.
The idea comes from Silicon Jungle's Ink Studio living-forms kit; this is our own code.
TreeSpecinterface
A tree for tree(), grown by space colonization.
Properties
atVec3The foot of the trunk.
heightnumberHow high the trunk rises before the crown.
crownVec3The crown's radii: the space its branches grow to fill.
rnumberThe trunk's radius at its foot; every limb is as thick as what it carries.
pointsnumberoptionalPoints scattered through the crown that the branches grow toward (160). More makes a finer tree.
seednumberThe same seed gives the same result.
TreeNodeinterface
One joint of a grown tree: its place, the joint it grew from and the limb's radius there.
Properties
pVec3Where the joint is.
parentnumberThe joint it grew from, or -1 for the foot.
rnumberThe limb's radius here.
colonize()function
Grows a tree by space colonization: points are scattered through the crown, and every point pulls the nearest branch tip toward it until a branch reaches it. Then each limb is made as thick as what it carries (the pipe rule: a limb's radius to the 2.5 is the sum of its children's), scaled so the trunk's foot is r.
tree()function
A tree grown by space colonization (see colonize): its limbs, and if leaves is set a ball that size at each end.
CactusSpecinterface
A ribbed cactus for cactus().
Properties
atVec3Where it stands.
heightnumberHow tall the trunk is.
rnumberThe trunk's radius.
ribsnumberoptionalRibs round it (8).
armsnumberoptionalArms, 0 to 4.
seednumberThe same seed gives the same result.
cactusArms()function
The arms of a cactus: out from the trunk, a bend, and up.
cactusArms(s: CactusSpec): Vec3[][]cactus()function
A ribbed column of a cactus, with arms that bend up.
cactus(s: CactusSpec): ShapeRosetteSpecinterface
A succulent's rosette of leaves, for rosette().
Properties
atVec3Its middle, on the ground.
rnumberHow far the outer leaves reach.
leavesnumberHow many leaves, 3 to 60.
seednumberThe same seed gives the same result.
rosette()function
A succulent: thick pointed leaves set round a spiral by the golden angle, the inner ones short and upright.
rosette(s: RosetteSpec, thin?: number): ShapeBracketSpecinterface
Bracket fungi up a trunk, for brackets().
Properties
atVec3Where the lowest shelf meets the trunk.
facing[number, number]The way the shelves face out from the trunk: [x, z].
rnumberHow far the biggest shelf stands out.
countnumberHow many shelves.
seednumberThe same seed gives the same result.
brackets()function
Bracket fungi: half-round shelves stacked up a trunk, smaller as they go up, flat below and domed above.
brackets(s: BracketSpec): ShapeBrainSpecinterface
A brain coral for brain().
Properties
atVec3The middle of its foot.
rnumberIts radius.
groovenumberoptionalHow wide a groove is; left out, about a sixth of the radius.
seednumberThe same seed gives the same result.
brain()function
Brain coral: a dome worn into meandering ridges and grooves.
ShellSpecinterface
A coiled shell for shell().
Properties
atVec3The middle of its coil.
sizenumberAbout its width.
turnsnumberoptionalWhorls (3).
spirenumberoptional0 a flat coil (nautilus) to 1 a tall spire (whelk).
facingnumberoptionalWhich way it faces, in degrees about the upright.
shellCoil()function
Points and radii of a shell's coil: a tube wound on a log spiral, growing by the same share each turn.
shell()function
A shell wound on a log spiral; each stretch of the tube is a piece, so pieces paints it in bands.
HornSpecinterface
A horn for horn().
Properties
atVec3The root, on the head.
dirVec3The way it first grows.
lengthnumberHow long it is along its curl.
rnumberAt the root.
curlnumberoptionalTurns of its curl: 0 straight, 1 a full ram's curl.
twistnumberoptionalHow far it winds sideways as it curls, as a corkscrew does, 0 to 1.
ridgesnumberoptionalRings round it (12).
hornPath()function
The path of a horn: a curve that turns curl times in the plane its first way and the sky make, drifting sideways by twist.
horn()function
A horn: a tapering tube that curls and can wind sideways. thin is the least radius it may have, so its tip never slips between grid cells.
AntlerSpecinterface
An antler for antler().
Properties
antler()function
An antler: a main beam that sweeps up, back and round, with tines rising off it, shorter toward the tip.
antler(s: AntlerSpec, thin?: number): ShapeRibsSpecinterface
A rib cage for ribs().
Properties
ribs()function
A spine of vertebrae with ribs curving out and down each side, widest in the middle: a whale's bones on a beach, a beast's chest.
Worn land
Worn land and layered rock: a height field worn by water and slumping (droplets carve gullies and drop what they carry in fans; slopes too steep for their rock slide to scree), rock laid down in beds where soft beds wear back further than hard ones, so ledges, benches and overhangs come by themselves, with hoodoos and natural arches as presets; cracked mud whose plates curl at their edges; and pebbles along a stream bed, bigger where it runs fastest.
Everything runs once, when the scene is built, from its numbers and a seed: the same seed, the same land. Erosion has a budget (MAX_DROPS, a grid of at most MAX_GRID cells a side) so a build stays within a second or so.
The idea comes from Silicon Jungle's Ink Studio erosion kit; this is our own code.
Bedinterface
A bed of rock: how thick it is and how hard (0 soft, worn back far, to 1 hard, standing out as a ledge).
Properties
thicknumberHow thick the bed is.
hardnumberHow hard: 0 is soft and wears back far, 1 is hard and stands out as a ledge.
BEDSvalue
Beds when none are given: soft and hard by turns, a hard one on top.
Bed[]bedAt()function
Which bed a height above the base is in, the beds repeating upward.
bedAt(beds: Bed[], y: number): numberLandSpecinterface
Land worn by water, for land() and wornLand().
Properties
atVec3The middle of its foot.
half[number, number]Half its size along x and z.
peaks{ at: [number, number]; h: number; r: number }[]Hills: each a place, a height and a reach.
noisenumberoptionalRough ground over the hills, as a height.
dropsnumberoptionalWater drops that run down it, each wearing it and dropping what it carries where it slows (0 to MAX_DROPS).
slumpnumberoptionalHow far slopes slump to scree, 0 to 1.
bedsBed[]optionalBeds of rock, from the bottom up, repeating: soft ones wear faster. Left out, all one rock.
seednumberThe same seed gives the same result.
MAX_DROPSvalue
The most water drops a LandSpec may ask for.
30000MAX_GRIDvalue
The most cells along a side of a land's height grid.
112Landinterface
Worn land as a grid of heights, from wornLand().
Properties
nxnumberGrid points along x.
nznumberGrid points along z.
cellnumberThe distance between grid points.
x0numberThe grid's first x.
z0numberThe grid's first z.
heightFloat32ArrayHeights above the foot, nx by nz.
flowFloat32ArrayWhere water ran (a running total of how much and how fast).
laidFloat32ArrayWhat was laid down: fans where water slowed, scree where slopes slid.
thicknumberHow much laid down counts as a fan or scree, not a dusting.
Methods
at()Height at (x, z) in the land's own frame (above its foot), smoothly between grid points.
at(x: number, z: number): number
wornLand()function
The land, built and worn once per spec (the scene asks again at every detail level).
terrace()function
Heights remapped into steps by the beds they fall in: going up a slope, a hard bed rises as a cliff (most of its height over little ground) and then holds level for a bench, while a soft bed rises evenly as a slope.
terrace(beds: Bed[], h: number): numberland()function
Worn land as a shape: its surface from the height field, sides cut straight down, its foot base deep. Pieces: the bed a point is in, or -1 where something was laid down (fans and scree).
ButteSpecinterface
A butte for butte: beds of rock, the soft ones worn back.
Properties
atVec3The middle of its foot.
rnumberIts radius at the foot.
heightnumberHow tall it is.
wearnumberoptionalHow far each soft bed is worn back, as a share of the radius (0.3).
capnumberoptionalA caprock this much wider than the rock under it, as a share (0: none).
seednumberThe same seed gives the same result.
hoodoo()function
A hoodoo: a thin butte of soft rock, waisted where its softest beds are, under a hard cap.
ArchSpecinterface
A rock arch for arch.
Properties
fromVec3The feet of its two legs, on the ground.
toVec3The foot of its other leg.
heightnumberHow tall it is.
thicknumberHow thick the fin of rock is.
softnumberoptionalHow high the soft bed the hole wore through sits: its middle, as a share of the height (0.4).
seednumberThe same seed gives the same result.
MudSpecinterface
A patch of cracked mud for mud.
Properties
atVec3The middle of the patch, on the ground.
rnumberHow far the patch reaches.
platenumberAbout how wide a plate is.
curlnumberoptionalHow far plate edges curl up, 0 to 1.
seednumberThe same seed gives the same result.
PebbleSpecinterface
Pebbles along a stream bed, for pebbles().
Properties
pathVec3[]The stream's line, on the ground.
widthnumberHow wide the stream bed is.
countnumberHow many pebbles.
sizenumberThe biggest pebble, mid-stream.
seednumberThe same seed gives the same result.
pebbleList()function
Pebbles along a stream bed: placed at random along it and across it, bigger toward the middle where water runs fastest.
pebbleList(s: PebbleSpec): { at: Vec3; r: Vec3 }[]pebbles()function
Pebbles along a stream's line, the biggest mid-stream. cell is the grid's cell size, so none comes out smaller than a cell.
pebbles(s: PebbleSpec, cell?: number): Shapebuttevalue
See butteRaw; its wobble and worn beds make the side distance a little ragged.
(s: ButteSpec) => Shapearchvalue
A rock arch: a fin of rock with a hole worn through its soft bed.
(s: ArchSpec) => Shapemudvalue
Cracked mud: plates with curled edges. cell is the grid's cell size, so the cracks are never thinner than a cell.
(s: MudSpec, cell?: number) => ShapeGrowers
Growers: a tree, a coral or a cluster of crystals grown by a branching rule from a seed, so the same seed always gives the same plant. Pure numbers: grow() gives the twigs (round-ended sticks, thick to thin) and the tips, which the scene builder turns into shapes. Each style is a rule: how many branches split from each end, how far they lean out, how much shorter and thinner each step is, and how hard they pull back toward the sky.
GrowStyletype
What a grower grows as.
"tree" | "coral" | "crystal"GROW_STYLESvalue
Every GrowStyle.
GrowStyle[]Growerinterface
A tree, a coral or a cluster of crystals to grow from a seed, for grow().
Properties
styleGrowStyleWhat it grows as.
atVec3Where it stands.
seednumberThe same seed gives the same result.
sizenumberThe trunk's length (a crystal's longest spike).
rnumberThe trunk's radius at the foot.
depthnumberoptionalTimes it splits; left out, what suits the style.
branchesnumberoptionalBranches from each split; left out, what suits the style.
Twiginterface
One branch of a grower: a cone from from, where its radius is r, to to, where it is rTo.
Properties
MAX_TWIGSvalue
No grower makes more twigs than this, whatever its depth and branches.
160grow()function
Grows it: twigs from the foot out, and the tips where the last twigs end.
growBounds()function
How far a grower can reach from its foot: half its box's size along x, y and z, and that box's middle.
Weather that lands
Weather that lands: what falls finds the ground actually under it, snow lies in drifts shaped by the wind and what stands in its way, and frost grows across a pane a branch at a time. Pure and tested.
The idea comes from Silicon Jungle's Ink Studio weather kit; this is our own code.
groundUnder()function
The height of the first surface met going straight down from top at (x, z), or bottom if nothing is met. The shapes' distances are lower bounds, so each step down is as long as the distance says and never steps through.
groundUnder(shapes: Shape[], x: number, z: number, top: number, bottom: number): numberFallingtype
The kinds of thing that fall and land.
"rain" | "snow" | "leaves"fallAt()function
Where a falling thing is in its life (0 to 1, starting again each time it falls): drop, the share of its fall done (0 at the top, 1 landed); lying, whether it has landed; size, from nothing as it appears to nothing as it goes (snow melts, a leaf fades, rain splashes away quickly). Size is 0 at both ends, so a loop joins up.
fallAt(kind: Falling, life: number): { drop: number; lying: boolean; size: number }fallSharevalue
The share of a life spent falling: what a speck's sway is frozen at once it lands.
(kind: Falling) => numberDriftSpecinterface
A field of drifted snow, for drift and driftField().
Properties
atVec3The middle of the snow field, at about ground height.
half[number, number]Half its size along x and z.
depthnumberHow deep snow lies on open, level ground.
wind[number, number]Which way the wind blows, [x, z]; the drift piles downwind of what stands in its way.
pilenumberoptionalThe most it piles up against something (3 × depth).
reachnumberoptionalHow far downwind a wall still shelters, in multiples of its height (4).
pathVec3[]optionalA path trodden through it, where it lies thin.
pathWidthnumberoptionalHow wide the trodden path is (0.2 when left out).
seednumberThe same seed gives the same result.
Driftinterface
Drifted snow as a grid, from driftField().
Properties
nxnumberGrid points along x.
nznumberGrid points along z.
cellnumberThe distance between grid points.
x0numberThe grid's first x.
z0numberThe grid's first z.
groundFloat32ArrayThe ground under the snow.
depthFloat32ArrayHow deep the snow is on it.
DRIFT_GRIDvalue
The most cells along a side of a drift's grid.
96driftField()function
How deep snow lies over the ground under() gives, in a grid: deep where something upwind shelters it (a wall, a rock, a bank), thin where the wind scours (anything higher than the ground upwind, and steep slopes), thinner on a path, then smoothed so it lies in soft drifts.
FrostSpecinterface
A frost fern for frost().
Properties
atVec3Where it starts, on the surface.
facingVec3The way the surface faces.
rnumberHow far it spreads.
armsnumberoptionalMain branches out from the start (5).
stage[number, number]optionalWhich share of its growth to show, [from, to] in 0..1 (all of it): split one fern over parts that sprout in turn and it grows a branch at a time.
seednumberThe same seed gives the same result.
FrostBranchinterface
One stroke of a frost fern: its ends, its radius, which generation of branch it is, and t, when it grows (0 at the start to 1 at the last tip).
Properties
frostPlan()function
A frost fern as straight strokes in the surface's plane: main branches curve out from the start, each throwing side branches at about 60 degrees, every other step on alternate sides, which do the same, smaller, up to three generations. t is when a stroke grows, 0 at the start to 1 at the last tip, by how far along it is.
frostPlan(s: FrostSpec): FrostBranch[]frost()function
A frost fern lying on a surface (see frostPlan), each stroke standing a little proud of it; pieces are the generations, 0 the main branches.
driftvalue
Drifted snow as a shape: deep behind whatever stands in the wind, gone from steep faces, thin on a trodden path. under() gives the height of the ground at a place.
(s: DriftSpec, under: (x: number, z: number) => number, thin?: number) => ShapeThe sky through a day
The sky over a scene through a day: where the sun and the moon stand for a time, a latitude and a day of the year, and the light that follows from it, ready for setLights. The sun's path is the real one (declination by the day, hour angle by the clock); its color comes from how much air its light crosses (red and dim at the horizon, white overhead); the sky's own light, the sky's colors and the stars follow the sun's height. The moon is kept simple: it trails the sun by its age, a full one rides high in winter and low in summer, and it gives light by how much of it is lit. Pure numbers, so a page, a test and a recording get the same sky.
Directions are in the scene's frame: +x east, +y up, +z south. Strengths are set for a picture, not for a light meter: real moonlight is a millionth of sunlight, and an eye (or a camera) opens up at night, so here the night is dim, not black.
SkyPlaceinterface
Where and when the sky is: what daylight() needs besides the hour.
Properties
latitudenumberDegrees north of the equator (south is negative).
daynumberThe day of the year, 1 to 365: 80 is the March equinox, 172 the June solstice.
moonnumberThe moon's age: 0 new, 0.25 first quarter, 0.5 full, 0.75 last quarter.
DEFAULT_PLACEvalue
A temperate place at midsummer under a full moon: what daylight() uses where none is given.
SkyPlaceDaylightinterface
The sky at one moment, from daylight(). Colors are linear RGB; a light's color already holds its strength.
Properties
sunVec3The way toward the sun (a unit vector), below the horizon too.
sunHeightnumberThe sun's height over the horizon, in degrees (negative when it is down).
sunColorVec3The sun's light: white overhead, redder and weaker toward the horizon, nothing once it is down.
moonVec3The way toward the moon (a unit vector).
moonHeightnumberThe moon's height over the horizon, in degrees.
moonColorVec3The moon's light, by how much of it is lit and how dark the sky is: nothing by day.
moonLitnumberHow much of the moon's face is lit, 0 (new) to 1 (full).
ambientVec3Light from the whole sky, which reaches into shade: blue by day, warm at dusk, dim and blue at night.
zenithVec3The sky's color straight up.
horizonVec3The sky's color at the horizon, away from the sun.
sunGlowVec3The warm glow low in the sky round the sun as it rises and sets: nothing while it is high or well down.
starsnumberHow clearly the stars show, 0 by day to 1 in full night (less under a bright moon).
darknumberHow dark it has grown, 0 in daylight to 1 once the sun is well down: when lamps come on.
skyWay()function
The way toward a point of the sky (a unit vector: +x east, +y up, +z south) from its hour angle (degrees west of due south, 15 an hour), its declination (degrees north of the sky's equator) and the latitude it is seen from.
skyWay(hourAngle: number, declination: number, latitude: number): Vec3sunDeclination()function
How far north of the sky's equator the sun is on a day of the year, in degrees: 23.44 at the June solstice.
sunDeclination(day: number): numbersunWay()function
The way toward the sun at an hour of the day (0 to 24 by the sun: 12 is when it is highest).
moonWay()function
The way toward the moon at an hour of the day. It trails the sun across the sky by its age (a full moon is opposite the sun, so it rises as the sun sets), and its declination is the sun's turned by its age, so a full moon is high in winter and low in summer.
moonLit()function
How much of the moon's face is lit at an age: 0 new, 1 full.
moonLit(age: number): numbersunTimes()function
When the sun rises and sets, in hours by the sun, from where its center crosses the horizon. Where it never sets (a polar summer) rise is 0 and set() 24; where it never rises, both are 12.
airMass()function
How much air light crosses on its way down from a height over the horizon (degrees), as a multiple of the air straight overhead: 1 at the zenith, about 38 at the horizon (Kasten and Young's fit).
airMass(height: number): numberdaylight()function
The sky and its light at an hour of the day (0 to 24 by the sun; any number wraps) at a place: where the sun and moon stand, their light, the sky's own light and colors, how clearly stars show and how dark it has grown. Every value changes smoothly through the day, so an hour hand dragged across it never jumps.
skyLights()function
The lights a sky gives a scene, for setLights: the sun and the moon as lights from a direction (each only while it gives light, so a march for shadows is never spent on a light that is down), casting shadows if asked, and the sky's own light as the ambient color.
Pixels and sprites
Drawing a stage as pixel art, as brush and ink marks, as characters, cel shaded, in neon, as stained glass, in watercolor, as a halftone print, knitted, for 3D glasses, as clay, a blueprint, a thermal camera, cut paper, a mosaic or an old television, as blocks or glitching, and baking a creature into a sprite sheet.
Pixel mode
PixelPassclass
Pixel mode: the scene is drawn small into a target, and one full-screen pass turns it into pixel art and scales it up in whole pixels, with no smoothing.
The pass is the GPU twin of pixelArt() in splat-core/pixel.ts (change one, change both): alpha cut, glow from bright pixels, nearest palette color in OKLab with a Bayer dither, edge lines inside the scene, an outline on the empty pixels that touch it, and a sky behind. It runs once per art pixel, into art, which keeps display (sRGB) color so a palette color is stored exactly; the screen then gets a plain copy, scaled up. The art of the frame before is kept too: a look with steady reads it so a pixel between two palette colors does not flip from frame to frame.
A look with fine draws the scene and its map of parts at twice the art's size first, and a step before the pass settles each art pixel from its four samples into small and ids (resolveFine in pixel.ts is its twin), so everything after it is the same either way.
Constructor
new PixelPass(look: PixelLook)Properties
smallRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe scene, drawn small. Linear and premultiplied, as any render target.
idsRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe scene's parts, drawn small (
SplatWorld.parts): where the color changes, one part ends and another begins. Only drawn for a look withparts.ranksRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyEach art pixel's step of the dither pattern, from the blob there (red, a byte), for a look with
surface.fineSmallRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe scene and its map of parts at twice the art's size, for a look with
fine: whatsmallandidsare settled from.fineIdsRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe map of parts at twice the art's size, which four samples a pixel settles from (its first texture), and in the same draw the picture with every blob a hard disc in its own color, as the map cuts it (its second, read with
PixelLook.solid): one draw of every blob for both, which on a phone is most of what either costs.artRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe finished art at its own size, in display color, for reading back (tests, saving) and for the screen.
beforeRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap> | undefinedread onlyThe art of the frame before, when this frame was drawn against it (a look with
steady): whatpixelArt()needs to give the same answer.lookPixelLookThe look in use.
drawnAtnumberread onlyThe time the last frame was drawn for (
setTime): whatpixelArt()needs as itstime.widthnumberread onlyThe art's width, in art pixels.
heightnumberread onlyThe art's height, in art pixels.
anchorVector3read onlyThe world point
snaplands on the art's grid: the point the view turns about (the stage sets its orbit's target). It must stay put on the screen as the view turns, or its place crosses half an art pixel now and then and the whole picture jumps a pixel at once (Matt saw it as a Diorama scene rocked, 2026-11-23, snapped at the world's origin).
Methods
reset()Forgets the frame before: for when what is being drawn is swapped for something else.
reset(): voidsetLook()Changes the look: palette, dither, glow, lines.
setLook(look: PixelLook): voidsetTime()The scene's time for this frame: what heat haze's waves and color cycling step by (
pixelArt()'stime).setTime(t: number): voidsetGlitch()This frame's glitch, laid on as the art goes to the screen (the art itself,
art, stays clean:glitchArt()lays the same on a frame read back). Left out, none.setGlitch(g?: GlitchState): voidsetSize()The art's size in pixels.
setSize(width: number, height: number): voidrender()Draws
sceneas pixel art. Withscreen(the output's size in device pixels and how many of them make one art pixel) it goes to the renderer's current output; without, intoartat one to one.render(renderer: WebGPURenderer, scene: Object3D, camera: Camera, screen?: { width: number; height: number; scale: number }): voiddispose()Frees its render targets.
dispose(): void
Pixel art
The 2D half of Splat to Sprite: everything that happens after the splat has been rendered. Pure functions on RGBA byte arrays so they can be unit tested without a GPU.
Pipeline per frame: supersampled render → box downsample → alpha cut → palette (+dither) → stray-pixel cleanup → outline
Rgbtype
A color as three numbers: red, green and blue, 0 to 255 in a palette.
[number, number, number]Frameinterface
A picture as RGBA bytes.
Properties
widthnumberPixels across.
heightnumberPixels down.
dataUint8ClampedArrayRGBA, row 0 at the top, straight (not premultiplied) alpha.
PixelLookinterface
How a scene is turned into pixel art, live (splat-engine/pixelPass.ts) or here on the CPU.
Properties
paletteRgb[]The colors every pixel snaps to; empty keeps the scene's own colors.
basenumberoptionalHow many of
palette's colors are the palette's own, the rest being its ramp (rampPalette): the sky snaps to these only, so its gradient dithers between the colors it was painted with. All of them when left out.dithernumber0..1, as for
quantize.outlineRgb | nullA 1-pixel line round the scene's silhouette, or none.
ownbooleanoptionalThe outline in a darker tone of whatever it goes round, not one color for the whole scene: each outline pixel takes the palette color nearest a darker step of the scene pixel beside it (
outline's own color where the palette has nothing darker). Needsoutline.finebooleanoptionalFour samples a pixel: the scene is drawn at twice the art's size and each art pixel is settled from its 2×2 samples (
resolveFine) before anything else happens, so a pixel on the edge of a thing shows one thing or the other, never a mix. The live pass does it itself;pixelArt()is given the settled frame.glownumberHow far bright pixels spill light onto their neighbors: 0 is none.
edgesnumberoptionalLines inside the scene, where one color meets a much lighter one: 0 (or left out) is none, 1 the darkest line.
partsbooleanoptionalA line where one part of the scene meets another whose color is too close for
edgesto draw one (two things of one color, one in front of the other), atedges' strength or full strength without it. Needs a map of the parts drawn beside the scene (pixelArt()'sparts; the live pass draws its own).acrossbooleanoptionalLines inside the scene only where one thing meets another: with a map of parts (
parts, orfine, which draws one), a jump in color within one part is its paint (grass, stonework) and takes no line, as a pixel artist outlines things and not their texture. Without a map it does nothing.solidbooleanoptionalThe scene's picture drawn with every blob a hard disc in its own color, cut where the map of parts cuts it, so a thing's edge never shows a little of what is behind it (the stage draws it; the picture handed in is already so).
sky[top: Rgb, bottom: Rgb, reach?: number]optionalA backdrop behind the scene: its color at the top and at the bottom of the picture, blended between and dithered into the palette.
reachis how far down the picture the blend runs before it is all the bottom color (above 0, up to 1; the whole way when left out or not a sound number:skyReach). Left out, empty pixels stay clear.steadynumberoptionalSteady pixels: a pixel keeps the palette color it had in the frame before unless another is closer by more than this (an OKLab distance; 0 or left out is off). Without it, a pixel that sits between two colors flips back and forth as lights flicker and the view turns.
levelsnumberoptionalFull color (a look with no palette): each channel is rounded to this many even steps instead of snapped to a palette, so neighbors of one shade are one color and the cleanup and steady pixels still have colors to match; dither checkers between two steps. Left out, a look with no palette passes colors through as drawn.
tidybooleanoptionalLone-pixel cleanup, as a pixel artist does it: a scene pixel whose color none of its eight neighbors shares, while six or more of them share one other color, takes that color. With a map of parts, only a pixel inside its own part (four or more neighbors of its part) is touched, so a speck, an eye or a firefly in front of something stays. A checkerboard dither keeps its pixels: each has its own color on the diagonals.
calmbooleanoptionalCalmer pixels, in place of
tidy(an idea from Silicon Jungle's Ink Studio, whose cleanup pass this follows in part): a pixel art piece is flat patches of color with dither only where one gives way to the next, while a scene of small blobs comes out speckled. So, reading only the art as drawn: a scene pixel takes the colorCALM_MOSTor more of its eight neighbors share when fewer share its own (with a map of parts, only neighbors of its own part count, so one thing never bleeds into another); a scene pixel with the empty backdrop on three or four sides (a one-pixel bump on a silhouette) takes the backdrop's color beside it, and an empty pixel with the scene on three or four sides (a notch) takes the scene's, so an outline runs clean; and lines are cleaned (lineFix: one-pixel kinks off straight edges, doubled pixels off the corners of dark lines); and a patch of one or two pixels joins its neighbors' color unless it is a highlight or a detail (SPECK_MOST,SPECK_KEEP).calmArtis the CPU twin of the pass.flatbooleanoptionalDither only where a pixel artist puts it: the sky's blend and the light a glow spills onto the scene keep
dither, while the scene's own surfaces are drawn flat, each pixel its nearest palette color, so shade falls in bands. A pixel a glow lights snaps only to a color of its own hue, the light's, or a gray (keptNearest).rimreadonly [number, number]optionalA rim of light: a scene pixel whose neighbor toward the light (this way across the picture, x right and y down;
rimStep) is backdrop takes the palette color a step lighter in its own hue (lighterStep), as a pixel artist picks out the lit edge of a form.shinebooleanoptionalA highlight on the peak of each smooth lit form (
peakAt): that pixel one step lighter in its own hue.surfacebooleanoptionalDither that stays on the things it falls on: each blob takes one step of the Bayer pattern from where it sits in its own rest pose (
ditherRank), not from the pixel it lands on, so the pattern rides with a turning view or a moving creature instead of standing still on the screen while they slide under it. Needs a map of each pixel's step drawn beside the scene (pixelArt()'sranks; the live pass draws its own). The sky keeps the screen's pattern. Left out withflat: there only a glow's spill is dithered, and the map cost a whole extra draw of every blob. After Silicon Jungle's Ink Studio (object-space dither, MIT), with their agreement.snapbooleanoptionalHolds the picture on the art's grid: one world point (
PixelPass.anchor, wheresnapAnchor()in orbit.ts puts it) always lands on a whole art pixel, so when the view slides (a pan, a camera that follows) the scene moves by whole pixels instead of smearing across them, and while it turns about its target nothing jumps. The live pass only (snapShift). After Ink Studio's camera snap, which does it for a flat view; here it holds for a perspective view at the anchor's depth.bandsnumberoptionalGlow in bands (1 or 2): in place of the soft spill round bright pixels, each pixel within
HALO_Rart pixels of a glowing one takes a flat share of its light by how far it is, in rings, as hand-drawn pixel art lights a lamp. After Ink Studio's banded glow (MIT), with their agreement.heat{ pixels: number; pace: number }optionalHeat haze: pixels above anything glowing (within
HEAT_Racross and up toHEAT_UPmore above) are drawn from a pixel or so to one side, the shift running in waves that changepacetimes a second (a whole number a loop, so a recording joins).pixelsis the most a pixel moves, 1 to 3. After Ink Studio's heat effect (MIT).cycle{ colors: Rgb[]; pace: number }[]optionalColor cycling: scene pixels whose palette color is one of
colorsstep along the listpacetimes a second, as old games ran water and fire. Each color is taken to its nearest in the palette, so a visitor's own palette still cycles. Steady pixels leave these colors alone. After Ink Studio's palette cycles (MIT).seloutbooleanoptionalLighter outlines on lit sides ("selout"): an outline beside a scene pixel lighter than
SELOUT_FROMtakes a shade just under that pixel's own color instead of the outline, so the line shows only where the thing is in shade. Needsoutline. After Ink Studio's lit and shadow line colors (MIT).
pixelArt()function
One frame of a scene to pixel art, the CPU twin of the live pixel pass (change one, change both). f is the scene drawn small: straight sRGB.
alpha cut → glow (bright pixels light their neighbors, and empty pixels
beside them) → edge lines (the darker side of a jump in color) →
palette + dither → outline on the empty pixels that touch the scene →
sky on the rest, if the look has onebefore is the art of the frame before, for a look with steady: where it holds a palette color that is nearly as close as the best one, that pixel keeps it. parts is the scene's map of parts for a look with parts: the same view with every part in its own flat color (alpha 0 where there is none).
Brush and ink marks
Marks: every blob drawn as a brush mark or an ink stroke in place of a soft dot, so a scene reads as a painting or a drawing from any side. A mark is a function of where a pixel is on its own blob (along the blob's long and short axes on screen, in standard deviations) and of the blob's seed, and of nothing on the screen: marks belong to their blobs, so they stay put as the view moves, where a filter laid over the finished picture slides across it.
This file is the CPU twin of the engine's draw (markOf in splat-engine/engine.ts): change one, change both.
MarkKindtype
The kinds of mark: flat opaque dabs with bristle streaks, thicker dabs with ridges that catch light, a wash with a pen stroke along each blob, hatching that is denser where it is darker, or a whole disc of the blob's own color with no brushwork at all (flat: the fill under cel shading, where the discs of one surface close up into one color), or stippling: pen dots on bare paper, more of them and bigger where it is darker.
"gouache" | "oil" | "ink" | "hatch" | "flat" | "stipple"MARK_KINDSvalue
The kinds, in the order the GPU numbers them (from 1; 0 is no marks).
readonly MarkKind[]MarkLookinterface
How the blobs are drawn as marks.
Properties
kindMarkKindWhich mark.
sizenumberoptionalHow big a mark is beside its blob: 1 reaches 1.5 standard deviations along the blob (default 1).
inkreadonly [number, number, number]optionalInk, hatch and stipple: the pen's color, sRGB 0–1 (default a blue-black).
paperreadonly [number, number, number]optionalInk, hatch and stipple: the paper's color, sRGB 0–1 (default a warm white). Set the page behind the view to it too.
softbooleanoptionalLay the marks one over another from far to near, with soft edges, as soft blobs are drawn. Without it (the default) each pixel shows the mark nearest to it, so the marks on a thing keep their places as it turns: right for anything cut as discs on a surface. A scan's blobs overlap far more and build a surface between them, and look better laid softly.
lineWeight()function
How strong a drawn outline is, 0–1: heavier round dark things than light ones, swelling and thinning along its length (swell, 0–1, smooth noise), and broken off here and there round the lightest. dark is 1 less the root of the thing's luminance.
lineWeight(dark: number, swell: number): numberOutlinePeninterface
A pen for drawn outlines (Stage.setOutline).
Properties
widthnumberoptionalThe line's width in CSS pixels (default 1.5).
inkreadonly [number, number, number]optionalIts color, sRGB 0–1 (default the same blue-black as
MarkLook.ink).
MarkSampleinterface
What a mark is at one pixel.
Properties
covernumberHow much of the pixel the mark covers, 0–1. Marks are paint: its alpha is this times the blob's opacity times
MARK_SOLID, at most 1.color[number, number, number]The mark's color there, linear RGB.
markAt()function
A mark at (u, v): u along the blob's long axis on screen and v across it, in standard deviations. rgb is the blob's color (linear) and seed its own number, 0–1. ink and paper are linear too.
markAt(kind: MarkKind, u: number, v: number, seed: number, rgb: ArrayLike<number>, size?: number, ink?: ArrayLike<number>, paper?: ArrayLike<number>): MarkSampleDrawn outlines
InkLinesclass
Drawn outlines, as a pen would put them down: round the subject, where one thing passes in front of another, and between its parts. Marks (setMarks) lay each blob down as a stroke, which shades a picture but never draws its edges; a pen and wash drawing is the other way round, contours first.
The frame is drawn three times with the same moved and sorted blobs: the picture, a map of depth (SplatDepth) and a map of parts (SplatWorld.parts). One pass then inks a pixel when, a line's width away, the picture ends, or something is clearly nearer, or another part begins. The line is not even: its weight swells and thins along its length and is heavier against dark things than light ones, where it may break off (lineWeight() in marks.ts, the CPU twin of the weight); and it wobbles a little, as a hand does.
Constructor
new InkLines()Properties
pictureRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe picture, as the stage draws it without lines.
idsRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe map of parts the lines between parts come from.
Methods
setPen()The pen: its color (linear RGB) and how wide its line is, in device pixels.
setPen(ink: readonly number[], width: number): voidsetSize()Sizes the pass's targets, in device pixels.
setSize(width: number, height: number): voidrender()Draws the scene with its lines into the renderer's current target, or onto the screen when it has none.
render(renderer: WebGPURenderer, scene: Object3D, camera: Camera): voiddispose()Frees its targets.
dispose(): void
Characters
Characters: the picture drawn as text, a grid of cells over the view with one character in each. A cell's character is picked by how much of the cell there is to show (its tone: more ink for more of it), or, where an edge runs through the cell, by which way the edge runs: |, -, / or \. The grid is fixed on the screen, so the characters stand in rows and columns and never slide; and a cell keeps the character it had unless another has become clearly closer, so a cell whose tone sits between two characters does not flip back and forth as lights flicker and the view turns.
This file is the CPU twin of the engine's pass (GlyphPass in splat-engine/glyphPass.ts): change one, change both.
RAMPvalue
The characters that show tone, from none to the most ink.
" .:-=+*%8#@"STROKESvalue
The characters that show an edge: upright, level (drawn as a dash the width of the cell), rising and falling.
"|_/\\"GLYPHSvalue
Every character, in the order the engine numbers them.
stringglyphBit()function
Whether a character has ink at a pixel of its cell (x from the left, y from the top).
glyphBit(glyph: number, x: number, y: number): booleanRAMP_INKvalue
How much ink each character of the ramp lays down, as a share of the heaviest one's: what its tone is.
readonly number[]glyphAtlas()function
The font as one strip of bytes, a character after another from the left, 255 where there is ink: what the engine samples.
glyphAtlas(): { width: number; height: number; data: Uint8Array }GlyphLookinterface
How the picture is drawn as characters (Stage.setGlyphs).
Properties
sizenumberoptionalHow tall a cell is in CSS pixels (default 12; a cell is three quarters as wide). It is rounded so every pixel of the font is a whole number of device pixels.
inkreadonly [number, number, number]optionalThe characters' color, sRGB 0–1. Left out, each takes the color of what it stands for.
lightbooleanoptionalFor a light ground: darker things get the heavier characters. Without it (a dark ground) lighter things do.
edgesbooleanoptionalDraw a stroke where an edge runs through a cell: where the picture ends, one thing stands in front of another, two parts meet, or the tone changes sharply (default true).
strandsbooleanoptionalDraw a stroke along what is long and thin on the screen, such as strands of fur and blades of grass, where a cell is mostly that (default true). The stroke is the one of
|,_,/and `` nearest the way they run.steadynumberoptionalHow much closer another character's tone has to be before a cell gives up the one it has, 0–0.5 of the whole range (default
STICK; 0 never keeps one).gainnumberoptionalTones are multiplied by this before a character is picked (default 1): over 1 for a dim scene.
setGlyphSetoptionalWhich characters (default 'ascii'): 'braille' draws each cell as the braille character whose eight dots are on where that eighth of the cell is heavy enough, and 'blocks' as the quarter blocks (▘ ▚ ▙ and so on) or, where a cell is even, one of the shades ░ ▒ ▓. Both show shapes within a cell, so
edgesandstrandsare not used. 'lines' draws only the edges, in box-drawing characters (─ │ ┌ ┼ and so on) that join from cell to cell, with a dot for tone; 'words' writeswordsover and over through the picture, each letter as bright as its cell; and 'typed' is a typewriter's: keys struck once or twice over one another by tone, each strike a little out of line.wordsstringoptionalThe text 'words' writes, in capitals (letters, digits and
EXTRA's signs; anything else is a space).
GlyphSettype
The kinds of characters a picture can be drawn in (GlyphLook.set).
"ascii" | "braille" | "blocks" | "lines" | "words" | "typed"toneOf()function
A cell's tone, 0–1: how heavy a character it wants. rgb is the mean of the picture over the cell, linear and premultiplied, cover its mean alpha: a cell the subject only half fills gets a lighter character, which softens the outline.
toneOf(rgb: ArrayLike<number>, cover: number, look?: GlyphLook): numberrampFor()function
The ramp character for a tone: the one whose ink is nearest, unless the cell had a ramp character the frame before (before, its number) that is no more than steady further off.
rampFor(tone: number, before?: number, steady?: number): numberProbeinterface
What the picture is at one of a cell's probes.
Properties
shownbooleanWhether anything is drawn there.
tonenumberIts tone there (
toneOf()of that one point).depthnumberHow far in front of the camera it is.
partnumberWhich part it is, as any number that differs between parts.
strokeFor()function
The stroke for a cell, as a number in GLYPHS, or -1 for none. The probes are left, right, above, below, then above left, above right, below left and below right of the cell's middle. An edge runs along the one way in which both ends are on the same side while the way across it is not: upright and level are tried first.
strokeFor(p: readonly Probe[]): numberGlyphCellinterface
A cell as drawn: its character and that character's color.
Properties
glyphnumberThe character's number in
GLYPHS(0 is a space).color[number, number, number]Its color, linear RGB.
glyphCell()function
One cell: its character and color from the picture's mean over the cell (rgb linear and premultiplied, cover its alpha), the two rings of probes when edges are wanted (the inner eight, then the outer eight), and the character it had the frame before (-1 for none). ink here is linear. lie is the cell's mean lie (strandFor) when strands are wanted: a cell of strands takes their stroke, lit by its tone, before any edge is looked for.
brailleFor()function
A braille cell's dots from the tones of its eight parts (two across, four down, a row after another from the top): as bits from U+2800. A dot is on where its part's tone reaches its DOT_STEP; one that was on the frame before (before, the same bits, or -1) stays on down to steady under it, so a dot at its step does not blink.
brailleFor(tones: ArrayLike<number>, before?: number, steady?: number): numberQUADSvalue
The quarter blocks, by their bits: above left 1, above right 2, below left 4, below right 8.
" ▘▝▀▖▌▞▛▗▚▐▜▄▙▟█"SHADESvalue
The shades, light to dark, numbered after the quarter blocks.
"░▒▓"blockFor()function
A blocks cell from the tones of its four quarters (above left, above right, below left, below right): an even cell is the shade nearest its mean (kept, like a ramp character, unless another is steady closer), and an uneven one is the quarter block with the quarters over the middle of its tones (kept while no quarter is clearly on the other side).
blockFor(q: ArrayLike<number>, before?: number, steady?: number): numbershapeCell()function
One cell drawn in braille or blocks (GlyphLook.set): parts are the tones of its eighths or quarters (toneOf() of each), the rest as for glyphCell(). The color is the cell's own at the level its heaviest part asks for.
setBit()function
Whether a character of a set has ink at a pixel of its 6 × 8 cell (x from the left, y from the top): what the engine draws. The typewriter's also needs the cell's column and row (cx, cy).
charOf()function
A character of a set as text.
glyphText()function
A grid of characters (their numbers in GLYPHS, or a set's own numbers, a row after another from the top) as lines of text, with spaces at line ends dropped.
glyphScale()function
How many device pixels one pixel of the font is, for a cell size CSS pixels tall: whole, and at least 1.
glyphScale(size: number, pixelRatio: number): numberThe picture as characters
GlyphPassclass
The picture as characters (splat-core/glyphs.ts is the CPU twin: change one, change both). The frame is drawn three times with the same moved and sorted blobs, as for drawn outlines: the picture, a map of depth and a map of parts. One small pass then decides every cell of the grid (its character and that character's color, kept in a target a cell a pixel, beside the one from the frame before so a cell can keep its character), and a second draws the characters from the font, each of the font's pixels a whole number of device pixels.
Constructor
new GlyphPass()Properties
pictureRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe picture, as the stage draws it without characters.
gridRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe grid of the frame just drawn: a pixel a cell, the character's number in alpha.
Methods
setLook()The look;
inkis linear RGB here, or left out for each character to take its own color.setLook(look: GlyphLook, ink?: readonly number[]): voidsetSize()Sizes the pass for a picture in device pixels, with
scaleof them to one pixel of the font.setSize(width: number, height: number, scale: number): voidforget()Forgets the frame before: for when what is being drawn is swapped for something else.
forget(): voidrender()Draws the scene as characters into the renderer's current target, or onto the screen when it has none.
render(renderer: WebGPURenderer, scene: Object3D, camera: Camera): voiddispose()Frees its targets.
dispose(): void
Cel shading
CelPassclass
Cel shading (splat-core/cel.ts). The frame is drawn four times with the same moved and sorted blobs: the picture in the blobs' own flat colors, a map of depth, a map of parts and a map of tones (how each blob faces the light). The scene is also drawn once as the light sees it, as a map of depth (a shadow map), whenever the blobs or the light have moved. One pass then finds, for each pixel, whether the light sees it; a second smooths that and the facing over each surface, cuts them into light and shade, paints the picture with them and draws an even line round the subject, where one thing passes in front of another, and between its parts.
The world must be drawing for it: flat marks, cel on, and its first light the one to shade by (Stage.setCel sets all three). The frame's camera must be a perspective camera.
Constructor
new CelPass()Properties
pictureRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe picture: every blob flat in its own color.
idsRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe map of parts the lines between parts come from.
tonesRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe map of tones (
SplatWorld.tones).shadowRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe scene's depth as the light sees it, counted from the near side of the scene.
Methods
setLook()The look, and how many device pixels a CSS pixel is.
setLook(look: CelLook, ratio: number): voidsetSize()Sizes the pass's targets, in device pixels.
setSize(width: number, height: number): voidrender()Draws the scene cel shaded into the renderer's current target, or onto the screen when it has none.
render(renderer: WebGPURenderer, scene: Object3D, camera: Camera): voiddispose()Frees its targets.
dispose(): void
Cel shading: the arithmetic
Cel shading: the light on a picture cut into a few flat tones with clean edges, as an animation cel is painted, in place of light that fades smoothly round a form.
Nothing is faked on the finished picture. Each blob is drawn flat in its own color (the flat mark), and the engine works out, for each blob, how it faces the light and how much of the light gets to it past what stands in the way (toneAt in splat-engine/light.ts and its shader twin). Those two numbers are drawn as a picture of their own, and smoothed a little over the surface they lie on before they are cut into tones: a blob is a disc some pixels across, and cutting first would leave every shadow with an edge of discs.
This file is the arithmetic of the cut, the CPU twin of the engine's pass (CelPass in splat-engine/celPass.ts): change one, change both.
CelLookinterface
How a picture is cel shaded (Stage.setCel).
Properties
fromRgboptionalThe way to the light, in the world (it needs no length). Default up, to the right and toward the front.
tones3 | 2optionalHow many tones the light is cut into: 2 is light and shade, 3 adds a brighter tone where a surface faces the light squarely (default 2).
shadeRgboptionalWhat shade multiplies a color by, sRGB 0–1: a cool violet gray by default, as shadows are painted on a cel.
brightnumberoptionalHow far the brightest of three tones goes toward white, 0–1 (default 0.2).
shadowsbooleanoptionalWhether things cast shadows on one another (default true). Without them a surface is only lit by how it faces the light.
smoothnumberoptionalHow far the light is smoothed over a surface before it is cut into tones, in CSS pixels (default 8): more gives rounder, simpler shadow shapes.
softnumberoptionalHow soft the edge between two tones is, 0–1 (default 0: as crisp as the screen's pixels allow).
linenumberoptionalThe outline's width in CSS pixels (default 1.5); 0 draws none.
inkRgboptionalThe outline's color, sRGB 0–1 (default near black).
shadowSizenumberoptionalHow many pixels a side the light's view of the scene is, which cast shadows are read from (default and most 2048): fewer is cheaper to draw and gives softer shadow edges.
shadowEverynumberoptionalThe light's view is drawn again at most every this many frames (default 1, every frame something moves): 2 halves its cost and leaves cast shadows a frame behind.
lampsRgboptionalWhat the scene's own lights add to a color where they reach it (linear, added to what the tone multiplies it by). Left out, a
Stageworks it out from the lights set on it (lampTint()); black takes the lamps away.
CEL_FROMvalue
The default way to the light.
RgbCEL_SHADEvalue
The default shade.
RgbCEL_INKvalue
The default outline color.
RgbCEL_TURNvalue
A surface is in the light when it faces the light by more than this: its facing is half the cosine of the angle between its normal and the way to the light, plus a half, so 0.5 is edge on. A little past edge on, as it is drawn by hand: a surface the light only grazes reads as shade.
0.54CEL_BRIGHTvalue
With three tones, a surface facing the light by this much or more takes the brightest.
0.9CEL_CASTvalue
A blob is in a cast shadow when less than this share of the light gets to it.
0.5CEL_LAMPvalue
A surface is in a lamp's light when the scene's lamps reach it by this much or more (toneAt's lamps in splat-engine/light.ts).
0.16CEL_GLOWSvalue
From this much, what reaches a surface is its own light (a flame, a lit pane): it is never darker than its own color.
0.9LAMP_ADDvalue
How strong the color lamps add is, where the lights set no more: the brightest channel of lampTint().
1CEL_EDGEvalue
The least width of a tone's edge, in the units of what is cut (facing and share of light, both 0–1), so the edge is not stepped.
0.02CEL_UNSUREvalue
A blob with no flat side has no facing of its own; where nothing round a pixel has one, it is taken to face the light this much.
0.75celTones()function
The tones at a point: lit is 0 in shade and 1 in the light, bright 1 where the third tone is. facing is how the surface faces the light (0 away, 0.5 edge on, 1 toward) and through the share of the light that reaches it.
celTones(facing: number, through: number, look?: CelLook): { lit: number; bright: number }celColor()function
A color (linear RGB) under the tones celTones() gives: shade (linear) multiplies it in shade, and the brightest tone goes toward white. by is the scene's own light: ambient multiplies both tones, lamps is added where the scene's lamps reach (reach, from toneAt: one more tone, cut at CEL_LAMP), and from CEL_GLOWS the color is never darker than itself.
celColor(rgb: ArrayLike<number>, tones: { lit: number; bright: number }, shade: ArrayLike<number>, bright?: number, by?: { reach: number; lamps?: ArrayLike<number>; ambient?: ArrayLike<number> }): [number, number, number]lampTint()function
The color the scene's lamps add in cel shading (linear): the color of its point lights taken together, each by its brightness, with its strongest channel at LAMP_ADD. Black where there are none.
lampTint(lights: readonly { color: ArrayLike<number>; position?: unknown }[]): [number, number, number]SHADOW_FARvalue
How many times the scene's size away the light's view of it is taken from: far enough that its shadows fall nearly side by side.
6shadowView()function
Where to stand to see the scene as the light does, for a map of what the light reaches: a narrow view from SHADOW_FAR sizes away along the way to the light, round a ball that holds the scene. The ball's middle and size are rounded onto steps of their own, so a scene whose bounds wander as it moves keeps one view, and its shadows keep their pixels. fov is in degrees.
shadowView(center: ArrayLike<number>, radius: number, from: ArrayLike<number>): { eye: [number, number, number]; target: [number, number, number]; up: [number, number, number]; fov: number; near: number; far: number; radius: number }SAME_COLORvalue
Two colors of one part nearer than this in OKLab are gathered into one: the mottle of a painted surface, not a stripe.
0.07gatherColors()function
Flat fills for a cel: each part's colors gathered into a few, so a mottled or textured surface becomes areas of one color and a stripe, a spot or a white chest stays its own. color holds a color a blob (sRGB, 0–1, three numbers each) and partOf each blob's part (left out, the blobs are one part); a part keeps at most most colors, and fewer where they are within SAME_COLOR of one another. The same blobs always give the same colors: the first color of a part is its commonest, and each next the one furthest from those chosen, before a few rounds settle them.
With round (where each blob is, three numbers each, and how far round it to look), a blob then takes the color most of its part's blobs within that reach have, twice over: speckle finer than the reach goes, and anything wider (a stripe, a patch, a checker) keeps its edge.
gatherColors(color: ArrayLike<number>, partOf?: ArrayLike<number>, most?: number, round?: { at: ArrayLike<number>; reach: number }): Float32ArrayNeon
NeonPassclass
Neon (splat-core/neon.ts): tubes of light along the picture's outlines, over bodies kept dark that catch the tubes' light. The frame is drawn three times with the same moved and sorted blobs (the picture in the blobs' own flat colors, a map of depth and a map of parts), as outlines are (inkLines.ts), and the tubes run where those lines would: round the subject, where one thing passes in front of another, and between its parts. A tube takes the color of the thing it goes round at full strength (neonColor()), or one of the look's colors by its part, and shines by where it is in the world: pulses of light run through the scene two ways (shineAt()), so the light travels along the tubes. The tubes' light is then spread at three sizes, and the last pass paints each body in its own color times the light that reaches it, with the glow and the tubes over it. Whatever gives its own light (Actor.glow) is a lamp: filled with its color and spread onto the bodies round it as the tubes' light is.
The world should be drawing flat marks with no light of its own and a glowGain of NEON_EMIT (Stage.setNeon sets all three). The frame's camera must be a perspective camera.
Constructor
new NeonPass()Properties
pictureRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe picture: every blob flat in its own color, with what gives its own light drawn over white (
NEON_EMIT), which is how the pass knows a lamp.idsRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe map of parts the tubes between parts come from.
Methods
setLook()The look, how many device pixels a CSS pixel is, the scene's size in the world (which the pulses are spaced by) and the stage's time in seconds.
setLook(look: NeonLook, ratio: number, size: number, time: number): voidsetSize()Sizes the pass's targets, in device pixels.
setSize(width: number, height: number): voidrender()Draws the scene in neon into the renderer's current target, or onto the screen when it has none.
render(renderer: WebGPURenderer, scene: Object3D, camera: Camera): voiddispose()Frees its targets.
dispose(): void
Neon: the arithmetic
Neon (Matt's idea, 2026-11-19): a scene drawn as tubes of glowing light along its outlines, over bodies kept dark that catch the light as it runs along the tubes. The arithmetic here is pure; splat-engine/neonPass.ts is its shader twin (change both).
NeonLookinterface
How a stage draws neon (Stage.setNeon).
Properties
linenumberoptionalHow wide a tube is, in CSS pixels (2).
glownumberoptionalHow strongly the tubes' light spills round them and onto the bodies: 0 none, 1 as designed, up to 2.
bodynumberoptionalHow lit the bodies are with no tube near, as a share of their own color (
NEON_BODY).colorsreadonly (readonly [number, number, number])[]optionalThe tubes' colors (sRGB 0–1), dealt out part by part. Left out, each tube takes the color of the thing it goes round, at full strength.
periodnumberoptionalHow many seconds a pulse of light takes to come round again; 0 holds the light still (4). A scene that loops wants a whole number of these in its loop.
apartnumberoptionalHow far apart two pulses run, as a share of the scene's size (0.45).
NEON_BODYvalue
Bodies with no tube near keep this share of their own color.
0.05NEON_RESTvalue
A tube between pulses shines this much of its full light.
0.22NEON_TAILvalue
How fast a pulse dies away behind its head: its light is (1 − how far behind, as a share of the way to the next) to this power.
3.5NEON_FLOORvalue
A tube's color keeps at least this much of each channel, so a pure red still has a hot core.
0.06NEON_BLACKvalue
A thing darker than this in every channel (linear) has no hue to speak of, and its tube is white.
0.001NEON_VIVIDvalue
How much stronger than its own a tube's color is made, about its gray.
2.4NEON_EMITvalue
How many times its own color a thing that gives its own light (Actor.glow: a lamp, a lit window, a flame) is drawn into neon's picture, so the pass can tell it from a pale thing: its color goes over white (lampShare()).
4NEON_LAMPvalue
A pixel whose brightest channel is over the first of these is partly a lamp, and over the second wholly one.
readonly [number, number]NEON_LAMP_SHINEvalue
How brightly a lamp shines beside a tube at a pulse's head.
0.85NEON_COLORSvalue
The most colors a look may deal out.
6NEON_WAYSvalue
The two ways pulses run through a scene (not unit: the second set of pulses lies closer together).
readonly [readonly [number, number, number], readonly [number, number, number]]NEON_SECONDvalue
The second set of pulses' share of the first's light.
0.7NEON_SHIFTvalue
How far a part's own number shifts its pulses, in pulses.
1neonColor()function
The color of the tube round a thing of color rgb (linear, 0–1): the same hue at full strength, however dark the thing is. A gray thing gets a white tube.
neonColor(rgb: readonly number[]): [number, number, number]pulse()function
One set of pulses: 1 at a pulse's head, dying away behind it to nothing just before the next. phase counts pulses.
pulse(phase: number): numbershineAt()function
How brightly a tube shines at a place: along is the place measured along each of the two ways, in pulses (its part's shift included), turn() how many pulses have gone by. Never under NEON_REST, 1 at a head.
shineAt(along: readonly [number, number], turn: number): numberlampShare()function
How much of a pixel of neon's picture is a lamp, from its brightest channel (top): nothing up to white, all of it well over. A lamp is filled with its own light, steady, and that light is spread onto the bodies round it as the tubes' is.
lampShare(top: number): numbercolorOfvalue
Which of count colors a part takes, from the part's shift (0–1).
(shift: number, count: number) => numberbodyColor()function
A body's color (linear) under the tubes' light: its own color times what it keeps unlit plus the light that reaches it (light, the tubes' light spread out, linear).
bodyColor(own: readonly number[], light: readonly number[], body?: number, glow?: number): [number, number, number]Stained glass
GlassPassclass
Stained glass (splat-core/glass.ts). The frame is drawn three times with the same moved and sorted blobs (the picture in the blobs' own flat colors, a map of depth and a map of parts), as outlines are (inkLines.ts). One pass then puts each pixel back in the world from its depth and asks which pane it is in: panes are the cells nearest a scatter of points fixed in the world, so they stay on their surfaces as the view turns. A pane's glass is the picture's own color there, made richer and lighter and a little different from the next pane's, with the light behind it. Lead runs between panes, round every part, where one thing passes in front of another, round the subject, and wherever the picture's color changes, so each piece between leads is one color: it wants blobs in flat colors with no light baked in. Pixels the subject leaves empty are panes too, fixed on the screen and colored as the look's sky, so the whole picture is a window.
The world should be drawing flat marks with no light of its own (Stage.setGlass sets both). The frame's camera must be a perspective camera.
Constructor
new GlassPass()Properties
pictureRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe picture: every blob flat in its own color.
idsRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe map of parts the lead between parts comes from.
Methods
setLook()The look, how many device pixels a CSS pixel is, and the scene's size in the world (which panes are sized by).
setLook(look: GlassLook, ratio: number, size: number): voidsetSize()Sizes the pass's targets, in device pixels.
setSize(width: number, height: number): voidrender()Draws the scene as stained glass into the renderer's current target, or onto the screen when it has none.
render(renderer: WebGPURenderer, scene: Object3D, camera: Camera): voiddispose()Frees its targets.
dispose(): void
Stained glass: the arithmetic
Stained glass (Matt picked it, 2026-11-19): a scene drawn as a leaded window. Every surface is cut into panes of flat colored glass that stay on it as the view turns, with lead between the panes, round every part, wherever the color changes and round the subject, and the light comes from behind. The arithmetic here is pure; splat-engine/glassPass.ts is its shader twin (change both).
GlassLookinterface
How a stage draws stained glass (Stage.setGlass).
Properties
panenumberoptionalHow big a pane is, as a share of the scene's size (0.06).
leadnumberoptionalHow wide the lead is, in CSS pixels (3).
inkreadonly [number, number, number]optionalThe lead's color (sRGB 0–1).
skyreadonly [readonly [number, number, number], readonly [number, number, number]]optionalThe window round the subject, top and bottom (sRGB 0–1): empty pixels are panes of these. Left out, pale blue over warm white.
lightreadonly [number, number]optionalWhere the light behind the window is brightest, across and down the picture (0–1; [0.5, 0.3]).
shinenumberoptionalHow much brighter the glass is at the light than far from it: 0 lights the window evenly (0.5).
varynumberoptionalHow much one pane's glass differs from the next's, 0 to 1 (0.5).
GLASS_RICHvalue
Glass is richer than paint: its color is made this much stronger about its gray.
1.45GLASS_LIFTvalue
And lighter, since the light comes through it: its color is raised to this power (under 1 lightens).
0.8GLASS_VARYvalue
One pane's glass is lighter or darker than the next's by up to this share, at full vary.
0.3GLASS_SKY_PANEvalue
The window round the subject is cut into panes this many times a scene pane's size on screen, as a share of the picture's height.
0.11GLASS_JUMPvalue
Lead also runs where the picture's own color (linear) changes by more than this from one pixel to one a lead's width away.
0.18GLASS_LEADvalue
The lead (sRGB 0–1): near black, a little warm.
readonly [number, number, number]GLASS_SKYvalue
The window with no sky of the subject's own, top and bottom (sRGB 0–1).
readonly [readonly [number, number, number], readonly [number, number, number]]cellHash()function
A number from 0 to 1 for a grid cell, different for each salt.
cellHash(x: number, y: number, z: number, salt: number): numberseedOf()function
Where a grid cell's pane has its middle: somewhere in the cell.
seedOf(x: number, y: number, z: number): [number, number, number]paneOf()function
The pane a point is in, with panes one unit across: the grid cell whose seed is nearest (cell, seed) and how far the point is from the nearest other pane (edge: its distance to the plane halfway between the two seeds). Lead is drawn where edge is under half the lead's width.
paneOf(p: readonly number[]): { cell: [number, number, number]; seed: [number, number, number]; edge: number }glassColor()function
A color (linear, 0–1) as glass with the light behind it: richer and lighter.
glassColor(rgb: readonly number[]): [number, number, number]paneTint()function
What a pane's glass is multiplied by: each pane a little lighter or darker than the next, by its cell.
paneTint(cell: readonly number[], vary?: number): numberbackLight()function
How bright the light behind the window is at a place in the picture (at and light across and down, 0–1; aspect is width over height): 1 at the light, falling to 1 − shine far from it.
backLight(at: readonly number[], light: readonly number[], shine?: number, aspect?: number): numberBlocks
BLOCK_LIGHTSvalue
How many of the stage's lights reach the blocks; the rest are dropped.
16EDGE_WIDTHvalue
How far in from a face's edge its line reaches, as a share of the face.
0.045LAMP_WRAPvalue
How much of a lamp's light a face turned away from it still takes: lamps cast no shadows here, so a little wraps round.
0.2BlockActortype
What a view needs of an actor: what blocks are made from, and the posed bones that carry them.
BlockSource & { skeleton: { matrix: Float32Array; scale: Float32Array; bones: readonly { name: string }[] } }BlockViewclass
A scene drawn as blocks (blocks.ts): one mesh for each bone that carries cubes, moved by that bone whole, so cubes never bend. The look's own light is in the corners already; this adds the stage's lamps to each face by where it is and which way it faces now, keeps a block that gives its own light at its own color, and draws a thin line round each face. A surface that moves by itself (an actor with flows: a pond) is columns whose tops follow its blobs (reshape after they change), drawn after the cubes and as see-through as its blobs are. It draws into a target with four samples a pixel and copies that out, since a cube's edges want smoothing that soft blobs never did. An actor as big as a world (far) is cut into squares at each of its levels, and each frame every square is drawn at the level its distance asks for (farLevel()).
Plus everything in Group.
Constructor
new BlockView(actors: readonly BlockActor[], look: BlockLook)Properties
blocksnumberHow many cubes it holds.
facesnumberHow many faces of them it draws: those with no cube of the same bone beside them.
Methods
reshape()After an actor's blobs were changed in place: a surface that moves (
flows) lays its columns to them again. Any other actor's cubes stay as built.reshape(actor: BlockSource): voidsetFog()Distance fog toward
color(linear) fromneartofarin front of the camera, asSplatWorld.setFog(far0 is none).setFog(color: readonly [number, number, number], near: number, far: number): voidsetLights()The stage's lights and ambient light, as
SplatWorld.setLightstakes them;tintmultiplies the ambient (a night's light).setLights(lights: readonly Light[], ambient?: number | readonly [number, number, number], tint?: readonly [number, number, number]): voidpose()Puts every piece where its bone is now.
pose(): voidlevels()How many of a far actor's squares are drawn at each level now: its own cubes first.
levels(): number[]render()Draws the scene (this view in it) into the renderer's current target, or onto the screen when it has none, with its edges smoothed.
render(renderer: WebGPURenderer, scene: Object3D, camera: Camera, width: number, height: number): voiddispose()Frees the meshes and the target.
dispose(): void
Blocks: the arithmetic
BlockLookinterface
Blocks: a scene's blobs snapped onto a grid and drawn as cubes (Stage.setBlocks). Every grid cell that holds a blob becomes one cube in the commonest color among its blobs, on the bone most of them ride, so a scene still moves: its still parts stay on the grid and a moving part carries its cubes with it. The light is worked out here, once, for the rest pose: each face is flat in one tone by which way it faces the light, a face something stands in front of is in shade as a whole, and corners where blocks meet are a little darker. That wants blobs with no light baked into them. This file is the arithmetic (pure, tested); blockView.ts draws it.
Properties
cellnumberA block's side, in the blobs' units: the grid a scene was cut on, or a whole number of it for bigger blocks.
fromreadonly [number, number, number]optionalThe way to the light (any length; default up, right and toward the front).
shadenumberoptionalHow much light a face in shade keeps, 0 to 1 (default 0.45).
shadowsbooleanoptionalWhether blocks cast shadows on the faces behind them (default true).
cornersnumberoptionalHow much darker a face gets in a corner where blocks meet, 0 to 1 (default 0.5).
varynumberoptionalHow much one block's color differs from the next's, 0 to 1 (default 0.35).
edgenumberoptionalHow dark the line round each face is, 0 to 1 (default 0.3); 0 for none.
ambientreadonly [number, number, number]optionalWhat the stage's ambient light is multiplied by, linear (a night's dim blue; default none).
leastnumberoptionalBlobs fainter than this are left out (mist, haze; default 0.3).
flow"blobs" | "blocks"optionalHow a surface that moves by itself is drawn (a source with
flows: a pond): 'blocks', as columns of cubes whose tops rise and fall with it in steps, or 'blobs', left as the blobs it is among the cubes (default 'blobs': Matt found they have more definition, 2026-11-21).weather"blobs" | "blocks"optionalHow weather laid over a scene (an actor with
weather: clouds, rain, snow) is drawn: as cubes too, or left the blobs it is among the cubes (default 'blobs').swellnumberoptionalHow many times higher than it stands a ripple is drawn as blocks (default
FLOW_SWELL); 0 keeps the tops level, so only their color moves.palettereadonly (readonly [number, number, number])[]optionalPaints every block takes its color from (sRGB 0–255): a cell's commonest color is snapped to the nearest in OKLab before light falls on it (
paletteSnap). Left out, blocks keep their own colors. Water columns and soft actors keep theirs.
BLOCK_FROMvalue
The default way to the light.
readonly [number, number, number]BLOCK_SHADEvalue
The default light a face in shade keeps.
0.45CORNER_MOSTvalue
How much of its light a face loses with all of a corner shut in, at corners 1.
0.6VARY_MOSTvalue
How far a block's lightness is from its color's own at most, at vary 1.
0.09SKY_SHAREvalue
A face in shade is this much darker again when it faces straight down, and as much lighter facing up.
0.16SPECK_SIZEvalue
Loose things in the air (rain, sparks, fireflies: bones whose names start with ~) are cubes this share of a block across, on a grid of their own, and take no part in shadows or corners.
0.4FACE_VOTEvalue
How many blobs one blob that glows or is laid over another (laid) counts for when a cell's color is picked: a window is a small pane in a bigger dark frame, and by count the frame took every cell (Matt saw windows as solid black blocks, 2026-11-21).
4GLOW_CLEARvalue
A block that gives this much of its own light or more (the mean of its blobs' glow) casts no shadow.
0.5BlockSourceinterface
What blocks are made from: an actor's blobs, its skin, the names of its bones and the light its blobs give.
Properties
blobsBlobsThe blobs in the rest pose.
skinSkinWhich bones move each blob: a block rides the bone most of its blobs do.
skeleton{ bones: readonly { name: string }[] }The bones, for their names: one whose name starts with
~carries loose specks.glowUint8Array<ArrayBufferLike>optionalHow much of its own light each blob gives, a byte a blob (
Actor.glow).laidUint8Array<ArrayBufferLike>optionalBlobs of a face laid over another part (voxel.ts
laid: a pane on its frame), a byte a blob: drawn as blocks, a cell takes their color before the color of what they lie on.seenUint8Array<ArrayBufferLike>optionalHow much of each of the first four lights each blob sees, four bytes a blob (
Actor.seen): a light some blob sees less than all of is a lamp that stays put, and casts block shadows (lampSight()).flowsbooleanoptionalA surface that moves by itself (a pond): its blobs are sent up again as they change, and its cubes are columns that follow them (
planFlow()).blockCellnumberoptionalThe side of this source's blocks, where it was cut on a grid of its own (a finer cut of the place underfoot); left out, the look's
cell.gridnumberoptionalThe side of the grid its blobs stand on (voxel.ts
Built.grid, times the size it was set down at). Where it is wider than a block, each blob also fills the cells of its own square along its plane (rowFill()), so blocks finer than the cut never show the rows between its blobs as gaps.holeBlockHoleoptionalCubes whose middles stand in this square (x and z, in the source's rest units) are not drawn: where a finer cut of the same ground is laid in their place (a patch round the place looked at). The cubes are still made, and nothing else changes, so moving the square only picks other faces to draw (
holed()).keepCubesbooleanoptionalIts blobs never change in place, so its cubes are kept with them and made once (
keptBlocks()): a stage that makes its cubes again for a new actor beside it (a patch moved underfoot) takes these as they were, not over a second's work again. A source whose colors are changed in place (weather shaded under the sky) must leave it out.farbooleanoptionalA source as big as a world (an island a hundred and fifty meters across): its cubes are also made twice and four times as big (
FAR_LEVELS), every level cut into the same squares (farChunk()), and a square far enough away that its own cubes would come underFAR_BLOCKpixels on screen is drawn with the bigger ones (farLevel()), so the far side of it costs a fraction of its faces. Each square keeps the faces along its edges (walls), so squares of different sizes beside each other leave no slit between them.wallsnumberoptionalFaces between two cubes in different squares of this size (x and z, the source's rest units, from the origin) are kept, so each square is closed on its sides: what a far source's levels are made with (
farChunk()).
BlockHoleinterface
A square of ground, x and z, in a source's rest units.
Properties
minreadonly [number, number]Its least x and z.
maxreadonly [number, number]Its most x and z.
BlockPieceinterface
The cubes on one bone of one actor, as a mesh: four corners a face, two triangles.
Properties
actornumberWhich of the sources it came from.
bonenumberWhich of that source's bones carries it.
blocksnumberHow many cubes.
positionsFloat32ArrayCorner places in the rest pose, three numbers each.
normalsFloat32ArrayEach corner's face normal.
colorsFloat32ArrayEach corner's color, linear, the block's own with no light on it.
lightFloat32ArrayThree numbers a corner: the light its face has from the look's light (shade and shadow in), what is left of any light in its corner, and how much of its own light the block gives.
uvsFloat32ArrayEach corner's place on its face, 0 or 1 each way.
indicesUint32ArrayThree corners a triangle.
faceCellsInt32ArrayEach face's cell and which of the six faces it is, four whole numbers a face in the order of the corners; the face is -1 for a loose speck.
sidenumberThe side of its cubes.
SolidCellstype
What is solid in a source's rest pose, a cell at a time, and the box that holds it all.
(x: number, y: number, z: number) => boolean & { lo?: number[]; hi?: number[] }blockHash()function
A number from 0 to 1 for a cell, the same each time.
blockHash(x: number, y: number, z: number): numberfaceLight()function
How much of the look's light each of a cube's six faces has when nothing is in the way, 0 to 1, in the order +x, -x, +y, -y, +z, -z: by how squarely it faces the light, with the face that faces it most at 1, so no two of the three faces a view shows are alike unless the light lies evenly between them.
faceLight(from?: readonly [number, number, number]): number[]faceTone()function
The light a face has: its shade (a little more of it facing the sky, less facing the ground) and its share of the light where that reaches it.
faceTone(face: number, lit: number, shade: number, sun: readonly number[]): numberfaceLit()function
Whether the look's light reaches the face face of the cell at x, y, z: a walk from the face's middle toward the light, half a cell at a time, until a solid cell is met or the walk is out of the box that holds them all.
faceLit(solid: (x: number, y: number, z: number) => boolean, x: number, y: number, z: number, face: number, from: readonly [number, number, number], lo: readonly number[], hi: readonly number[]): booleanrowFill()function
Where a blob of a cut on grid fills cells of side cell besides its own, as offsets along each of its two widest axes: none while the blocks are as big as the grid's rows or bigger, else steps no more than half a block apart across the square the blob stands for, so the squares of neighboring blobs leave no cell between them empty (Matt saw a gap round every block at size 1 where a scene was cut on a grid coarser than its blocks, 2026-11-29).
rowFill(grid: number | undefined, cell: number): number[] | undefinedbuildBlocks()function
The sources as blocks: a mesh for each bone that carries any (see BlockLook). A cell two bones' blobs share goes to the bone with more of them, so no two cubes ever stand in one place; faces between two cubes on one bone are left out. Shadows and corners are worked out within each source, never from one to another.
buildBlocks(sources: readonly BlockSource[], look: BlockLook): { pieces: BlockPiece[]; blocks: number; faces: number; solids: SolidCells[] }holed()function
A piece's triangles, leaving out every face of a cube whose middle stands in hole: all of them when there is none.
holed(piece: BlockPiece, hole?: BlockHole): Uint32ArraykeptBlocks()function
One source's cubes (buildBlocks() of it alone, which gives the same cubes as among others, since no source shades or joins another), kept with its blobs when it says they never change (keepCubes) and asked for again with the same look (its ambient aside), the same grid and the same skin, glow and lamps.
keptBlocks(source: BlockSource, look: BlockLook): { pieces: BlockPiece[]; blocks: number; faces: number; solids: SolidCells[] }FAR_LEVELSvalue
How many levels of bigger cubes a far source (BlockSource.far) has beside its own: twice and four times as big.
2FAR_BLOCKvalue
A square of a far source whose cubes would be drawn smaller than this many device pixels across takes the next bigger cubes, where there are any.
1.5FAR_CHUNKvalue
How many of a far source's biggest cubes a square is across.
16FAR_HOLDvalue
How far past FAR_BLOCK, as a share of it, a square's cubes must come before it changes level again, so a square at the line does not flicker between two.
0.15farChunk()function
The side of a far source's squares for its own cube side cell (x and z, rest units): FAR_CHUNK of its biggest cubes.
farChunk(cell: number): numberfarLevel()function
Which level a square of a far source is drawn at (0 its own cubes, 1 twice as big, up to most), for px, how many pixels across its own cubes would be on screen, and now, the level it is drawn at: the first whose cubes come to FAR_BLOCK pixels, held within FAR_HOLD of the line either way.
farLevel(px: number, now: number, most?: number): numberBlockChunkinterface
The faces of one square of a piece: their triangles, and the middle and reach (half the box's diagonal) of their corners, in the rest pose.
Properties
keystringThe square, as its place along x and z in squares (
"x,z"), the same for every level of one source.indicesUint32ArrayThree corners a triangle.
middle[number, number, number]The middle of its corners' box.
reachnumberHalf that box's diagonal.
chunkFaces()function
Cuts a piece's triangles (indices, as holed() leaves them) into squares of side chunk from the origin (x and z), by each face's cube (a loose speck's by its own corners), so every face is in exactly one.
chunkFaces(piece: BlockPiece, indices: Uint32Array, chunk: number): BlockChunk[]lampsOf()function
Which of the first four lights are lamps that stay put, by a source's seen: those some blob of it sees less than all of.
lampsOf(seen: Uint8Array<ArrayBufferLike> | undefined): boolean[]faceSeesLamp()function
Whether a lamp at at (in cells) lights the face face of the cell at x, y, z: not when the face is turned away from it, and not when a walk from just outside the face toward the lamp, half a cell at a time, meets a solid cell before it is within a cell of the lamp. The lamp's own cell never counts, since a lamp sits inside its housing.
faceSeesLamp(solid: SolidCells, x: number, y: number, z: number, face: number, at: readonly [number, number, number]): booleanlampSight()function
How much of a lamp each of a piece's faces sees, 1 or 0 a face (faceSeesLamp()), for a lamp at at in the rest pose's own units with a reach of range: faces further than twice its reach are left lit, since its light is gone there anyway, and so are loose specks.
lampSight(piece: BlockPiece, solid: SolidCells, at: readonly [number, number, number], range: number): Float32ArrayFLOW_STEPSvalue
A ripple's height as blocks is snapped to this many steps a block.
4FLOW_SWELLvalue
How many times higher than it stands a ripple is drawn as blocks, when the look does not say.
6FLOW_DROPvalue
How far under its layer's top a surface rests, as a share of a block: the banks beside it stand a little proud, and no two faces lie in one plane.
numberFLOW_MOSTvalue
A column's top is never further than this many blocks from where it rests.
1FLOW_REACHvalue
A blob of a moving surface lies over a cell's middle when it is within this many of its own sizes of it.
1.5FlowPlaninterface
A moving surface as columns on the blocks' grid: which columns there are and which of its blobs each one reads.
Properties
cellnumberA column's side.
countnumberHow many columns.
cellsInt32ArrayEach column's place on the grid: along x then along z, a pair a column.
levelnumberThe height the blobs lay at, on the whole, when the plan was made: a ripple is measured from it.
restnumberWhere a column's top is with the surface at rest.
besideInt32ArrayThe columns beside each one, toward +x, -x, +z and -z: four a column, -1 where there is none.
startInt32ArrayWhere each column's blobs start in
list, and one more for the end.listInt32ArrayThe blobs each column reads, a column after another.
planFlow()function
Plans a moving surface's columns: one for every cell of the grid, seen from above, that holds one of its blobs or whose middle one of them reaches over, so a grid finer than the blobs are spread still has no holes. A column reads every blob in it or over its middle.
flowStep()function
How far from rest a column's top stands for a surface lift over its level there: swell times as high, in whole steps of a block's FLOW_STEPSth, and never more than FLOW_MOST blocks.
flowStep(lift: number, cell: number, swell?: number): numberFlowMeshinterface
A moving surface's columns as a mesh: a top and four sides each, twenty corners a column in that order (top, +x, -x, +z, -z), which shapeFlow() moves and colors.
Properties
positionsFloat32ArrayCorner places, three numbers each:
shapeFlow()writes the heights.normalsFloat32ArrayEach corner's face normal.
colorsFloat32ArrayEach corner's color, linear, and how solid it is: four numbers, written by
shapeFlow().lightFloat32ArrayAs a block's (
BlockPiece.light): the face's light, 1 for no corner, 0 for no light of its own.uvsFloat32ArrayEach corner's place on its face.
indicesUint32ArrayThree corners a triangle.
topsFloat32ArrayEach column's top as
shapeFlow()last left it.
flowMesh()function
The mesh for a plan's columns, level at rest and with no color yet: shapeFlow() it before drawing.
shapeFlow()function
Lays a mesh's columns to the surface as its blobs stand now: each top at its blobs' mean height over the level, in steps (flowStep()); each side from its own top down to the top of the column beside it, so only the risers between columns are drawn (where it is the lower of the two it has no height; where there is no column beside it, it goes a block down, into the bank); and each column in the mean of its blobs' colors, as solid as they make it two deep.
Tech glitch
GlitchLookinterface
What the page's controls make.
Properties
amountnumberHow often a burst comes, 0 (never) to 1 (most of the time).
strengthnumberHow hard a burst is, 0 to 1: how far rows slide, channels split and how many blocks go.
jitterbooleanA burst slides bands of rows sideways.
splitbooleanA burst reads red to one side and blue to the other.
blocksbooleanA burst takes blocks of the art from somewhere else.
pacenumberSteps a second: a burst changes this often, never in between.
loopnumberoptionalThe scene's loop in seconds, where it has one: steps and bursts repeat with it.
stillbooleanoptionalUnder reduced motion: no bursts at all (a flicker is exactly what that asks to be spared).
seednumberoptionalPicks another run of bursts.
GlitchStateinterface
One step's glitch, in art pixels: what the pass is handed each frame. All whole numbers.
Properties
onbooleanA burst is on.
keynumberThe step's own number for
glitchHash(), under 2^24.jitternumberMost a row band slides either way, in art pixels (0: no jitter).
bandnumberRows to a band.
rowsnumberThe share of bands that slide, as a threshold over 2^24.
splitnumberHow far red and blue are read to each side (0: no split).
blocknumberA corrupted block's height in art pixels (it is
BLOCK_WIDEtimes as wide).blocksnumberThe share of blocks corrupted, as a threshold over 2^24 (0: none).
RUN_MOSTvalue
A burst lasts this many steps at most.
4START_MOSTvalue
The share of steps a burst starts on at amount 1.
0.3JITTER_MOSTvalue
At full strength, how far a band of rows slides either way.
14SPLIT_MOSTvalue
At full strength, how far red and blue are read to each side.
3BLOCKS_MOSTvalue
At full strength, the share of blocks corrupted.
0.12GLITCH_PACESvalue
Steps a second the page offers.
readonly [8, 12, 20]MIX_Avalue
Two primes under 2^31 that spread a cell's two numbers before the hash.
739982445MIX_Bvalue
Two primes under 2^31 that spread a cell's two numbers before the hash.
695872825SALTvalue
The salts that keep a cell's draws apart: each is one question about a row band or a block.
{ slides: 1; slide: 2; broken: 3; fromX: 4; fromY: 5; turned: 6; strip: 7 }STRIPSvalue
Broken blocks gather in strips: this share of rows of blocks can break at all (a threshold over 2^24).
5592405BLOCK_WIDEvalue
A broken block is this many times as wide as it is high, as a torn line of a picture is.
3TURNEDvalue
The share of broken blocks whose channels are turned (a threshold over 2^24).
4194304glitchHash()function
The 24-bit hash of a row band or block (a, b, whole and not negative) for one question (salt) in the step key: the GPU's glitchHash() in pixelPass.ts, in the same unsigned 32-bit steps.
glitchHash(a: number, b: number, key: number, salt: number): numberpickOfvalue
A whole number from 0 to m − 1 out of a 24-bit hash, exact on both sides: (h · m) >> 24.
(h: number, m: number) => numberstepsInvalue
How many steps a loop of loop seconds holds at pace a second: whole, and at least one.
(loop: number, pace: number) => numberstepAt()function
The step a moment falls in, and how many steps go round (0 where nothing loops).
stepAt(t: number, look: GlitchLook): { k: number; n: number }glitchAt()function
The glitch at a moment: whether a burst is on and, if so, how it reads the art this step.
glitchAt(t: number, look: GlitchLook): GlitchStatereadFrom()function
Where the art pixel at column x, row y (from the top) reads from, in a picture w wide and h high: x for green, red split to the right of it and blue split to the left, and whether its channels are turned.
readFrom(x: number, y: number, w: number, h: number, g: GlitchState): { x: number; y: number; turned: boolean }wrapXvalue
A column slid off one side comes in at the other.
(x: number, w: number) => numberglitchArt()function
The finished art with this step's glitch laid on: the CPU twin of the live pass's last step (pixelPass.ts toScreen). Off, it is the art itself.
glitchArt(art: Frame, g: GlitchState): FrameWatercolor
WashPassclass
Watercolor (splat-core/wash.ts). The frame is drawn three times with the same moved and sorted blobs (the picture in the blobs' own flat colors, and for the pencil a map of depth and a map of parts). The picture is softened at half and at a quarter of its size, and one pass paints the paper: each pixel reads the softened picture a little to one side (the paper's own wander, fixed on the screen, so a wash's edge runs unevenly), takes its color as pigment, and lays it on the paper as see-through paint (washed()): thinner and thicker from place to place, gathered into the paper's grain, darker where the wash ends or its color changes (the softened picture against the more softened one), and not at all where the picture is lightest. A look's sky is a wash behind the subject that stops short of the paper's edge; a faint pencil line runs where outlines would.
The world should be drawing flat marks (Stage.setWash sets them).
Constructor
new WashPass()Properties
pictureRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe picture: every blob flat in its own color.
idsRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe map of parts the pencil's lines between parts come from.
Methods
setLook()The look, and how many device pixels a CSS pixel is.
setLook(look: WashLook, ratio: number): voidsetSize()Sizes the pass's targets, in device pixels.
setSize(width: number, height: number): voidrender()Draws the scene in watercolor into the renderer's current target, or onto the screen when it has none.
render(renderer: WebGPURenderer, scene: Object3D, camera: Camera): voiddispose()Frees its targets.
dispose(): void
Watercolor: the arithmetic
Watercolor (Matt picked it, 2026-11-19): a scene painted in thin washes on paper. Paint is see-through, so a wash darkens the paper under it and never covers it; its edges run a little and dry darker where the pigment pools; the paper's grain shows through; the lightest places are left as bare paper. The arithmetic here is pure; splat-engine/washPass.ts is its shader twin (change both).
WashLookinterface
How a stage draws watercolor (Stage.setWash).
Properties
bleednumberoptionalHow far a wash's edge runs and wanders, in CSS pixels (4).
poolnumberoptionalHow much darker a wash dries at its edges, 0 to 1 (0.6).
grainnumberoptionalHow much the paper's grain shows in the paint, 0 to 1 (0.55).
strengthnumberoptionalHow strong the paint is, 0 to 1: lower is paler, with more paper showing (0.7).
pencilnumberoptionalA pencil line under the paint, 0 for none to 1 (0.55).
paperreadonly [number, number, number]optionalThe paper (sRGB 0–1).
skyreadonly [readonly [number, number, number], readonly [number, number, number]]optionalA wash behind the subject, top and bottom (sRGB 0–1), laid short of the paper's edge. Left out, the paper is bare.
borderbooleanoptionalWhether the wash behind stops short of the paper's edge, leaving a border of bare paper (true). False lays it to the edge.
WASH_PAPERvalue
The paper (sRGB 0–1): a warm white.
readonly [number, number, number]WASH_PENCILvalue
The pencil (sRGB 0–1).
readonly [number, number, number]WASH_WHITEvalue
A color this light or lighter (its brightest channel, linear) is left as bare paper, and one under the second is painted at full strength.
readonly [number, number]WASH_RICHvalue
Paint is richer wet than the picture's color: made this much stronger about its gray.
1.25WASH_UNEVENvalue
A wash is this much thinner or thicker from place to place, as water carries the pigment about.
0.22WASH_MARGINvalue
The wash behind the subject stops this far short of the paper's edge, as a share of the picture's height, give or take as much again.
0.05WASH_SKYvalue
And is laid this thin beside the subject's own paint.
0.55washed()function
Paper with one wash on it: paint is the pigment's color (linear, 0–1), density() how much of it lies there (0 none, 1 a full wash, more where it pooled). Paint only ever takes light away, so the result is never lighter than the paper.
washed(paper: readonly number[], paint: readonly number[], density: number): [number, number, number]pigment()function
The pigment for a picture's color (linear): a little richer, and never quite black.
pigment(rgb: readonly number[]): [number, number, number]whitenessvalue
How near white a color (linear) is, for kept(): halfway between its brightest and darkest channels. Its brightest alone took a strong orange or yellow (a palette's, say) for white and left it bare paper.
(rgb: readonly number[]) => numberkept()function
How much of a color is painted at all: nothing for the lightest (bare paper stands for it), all of it for the rest. top is its whiteness.
kept(top: number): numberdensity()function
How much paint lies at a place: the wash's cover there (0 off it, 1 well inside), thinned or thickened by the water (water, 0–1), gathered into the paper's grain (tooth, 0–1, by grain), and more where it pooled as it dried (edge, 0–1: how near the wash's edge or a change of color, by pool).
density(cover: number, water: number, tooth: number, edge: number, look?: { strength?: number; grain?: number; pool?: number }): numberHalftone print
HalftonePassclass
Halftone screen print (splat-core/halftone.ts is the CPU twin: change one, change both). The frame is drawn once, every blob flat in its own color under the stage's lights. A small pass then works out every cell of every ink's screen (a texel a cell, one block of rows an ink): the picture read round the cell's middle, over the sky or the paper, separated into the inks (separate()), keeping that ink's share. A second pass prints: each pixel finds its cell on each ink's turned screen, cuts that cell's dot to its share (dotCover()) and lays the inks over the paper (printed()). The print covers the canvas.
The world should be drawing flat marks (Stage.setHalftone sets them).
Constructor
new HalftonePass()Properties
pictureRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe picture: every blob flat in its own color.
Methods
setLook()The look, and how many device pixels a CSS pixel is.
setLook(look: HalftoneLook, ratio: number): voidsetSize()Sizes the pass's targets, in device pixels.
setSize(width: number, height: number): voidrender()Prints the scene in halftone into the renderer's current target, or onto the screen when it has none.
render(renderer: WebGPURenderer, scene: Object3D, camera: Camera): voiddispose()Frees its targets.
dispose(): void
Halftone print: the arithmetic
Halftone screen print (Matt asked for our own, 2026-11-25): the picture printed in a few inks, each laid through its own screen of dots. A screen is a grid of cells fixed on the paper (so on the screen), turned to the ink's own angle; each cell holds one dot whose area is how much of that ink the picture wants there, read at the cell's middle, so a light place is small dots and a dark one dots that run together into a field with small holes. Inks are see-through and print over one another, so where dots of two inks overlap the paper shows through both. Each ink's plate can sit a little off the others (misregistration), and the ink takes unevenly. The arithmetic here is pure; splat-engine/halftonePass.ts is its shader twin (change both).
Rgb01type
An sRGB color, 0–1.
readonly [number, number, number]HalftoneInkinterface
One ink and its screen.
Properties
colorRgb01The ink's color as printed full on white paper (sRGB 0–1).
anglenumberThe screen's angle, in degrees.
keybooleanoptionalThe key ink (black): it takes over the gray the other inks share, as a printer's black does (one a set, at most).
HalftoneLookinterface
How a stage prints in halftone (Stage.setHalftone).
Properties
inksreadonly HalftoneInk[]The inks, printed in this order; at most
HALFTONE_INKS.paperRgb01optionalThe paper (sRGB 0–1).
cellnumberoptionalA cell of the screen, in CSS pixels (7).
shiftnumberoptionalHow far each plate sits off true, in CSS pixels (1).
texturenumberoptionalHow unevenly the ink takes, 0 to 1 (0.4).
HALFTONE_INKSvalue
The most inks a print has.
4HALFTONE_PAPERvalue
The paper (sRGB 0–1): a bright white with a little warmth.
Rgb01SEPARATE_PASSESvalue
How many times the separation goes round the inks.
8KEY_TAKESvalue
How much of the gray the colored inks share a key ink (black) takes over (separate()).
0.9KEY_FROMvalue
Black starts only past this much gray, as a printer's skeleton black: small black dots in a light gray read as dirt, so the lightest grays stay in the colored inks.
0.3SPOT_FITvalue
The dot's spot function is (cos 2πu + cos 2πv) / 2 over a cell (u, v from -½ to ½ about its middle): round dots when small, a checkerboard at half, round holes when large. These turn a dot's area into the level the spot function is cut at, as an odd polynomial in 1 − 2·area (fitted to the spot's own areas, within 0.7%).
readonly number[]SHIFT_WAYSvalue
Each plate's direction off true, by its place in the print (radians): spread so no two lie the same way.
readonly number[]INK_GRAINvalue
How wide a patch of unevenly taken ink is, in CSS pixels.
6INK_UNEVENvalue
How much darker or lighter ink takes from place to place at full texture.
0.35inkLinearvalue
An ink's color in linear light.
(c: Rgb01) => [number, number, number]separate()function
How much of each ink a color wants (each 0 to 1), for a print on paper (both linear). Dots of inks on different screens fall over one another as if at random, so a place with shares a of each ink reflects, on average, paper · Π (1 − aᵢ·(1 − inkᵢ)) in each channel. The shares are found ink by ink with the others held, each step a Gauss–Newton step on the error in log light, again and again. A key ink (black) is left out at first; then it takes KEY_TAKES of the gray the other inks have in common (the least of their shares) past KEY_FROM, as a printer replaces three inks' gray with black, and the others are found again round it. Let in at the start, black took the dark channel of every color and greens came out gray.
separate(color: readonly number[], paper: readonly number[], inks: readonly (readonly number[])[], key?: number): number[]spotLevel()function
The level the spot function is cut at for a dot of this area (0 to 1): 1 for none, −1 for a full field.
spotLevel(area: number): numberspotAtvalue
The spot function at a place in a cell (u, v from -½ to ½ about its middle).
(u: number, v: number) => numberscreenAt()function
Where a point of the paper (in device pixels) falls on a plate's screen: which cell (counted from the one at the screen's turning point, about), the cell's middle on the paper, and the point's place in its cell. cell is in device pixels, angle in degrees, off where the plate sits off true. Screens turn about the picture's middle.
screenAt(x: number, y: number, cell: number, angle: number, off?: readonly [number, number], about?: readonly [number, number]): { at: [number, number]; mid: [number, number]; u: number; v: number }CELL_TAPSvalue
Where a cell's color is read, round its middle, along the screen's own two ways: shares of a cell (the middle and four more).
readonly [number, number][]cellShare()function
How much of ink i a plate's cell holds: the picture read round the cell's middle (mid, device pixels; t from 0 at the top to 1 at the bottom, for the sky), over the sky or the paper, separated into the look's inks.
cellShare(i: number, mid: readonly [number, number], angle: number, cell: number, height: number, picture: (x: number, y: number) => readonly number[], look: HalftoneLook): numberdotCover()function
How much of a pixel a dot of area covers at (u, v) in its cell, softened over one pixel (soft: a device pixel in cell units).
dotCover(u: number, v: number, area: number, soft: number): numberplateOffvalue
Where plate i sits off true, in device pixels, for a look's shift in device pixels.
(i: number, shift: number) => [number, number]printed()function
The paper with inks on it: cover is how much of the pixel each ink's dot covers, thick how heavily it took there (1 as printed). Linear in, linear out.
printed(paper: readonly number[], inks: readonly (readonly number[])[], cover: readonly number[], thick?: readonly number[]): [number, number, number]inkNoise()function
A small, smooth noise over the paper (0 to 1), in CSS pixels, for how unevenly ink takes: the shader's twin.
inkNoise(x: number, y: number): numberhalftoneAt()function
One device pixel of the print. picture(x, y) is the picture there, linear and premultiplied (r, g, b, a), with y counted from the top; width and height are the picture's, ratio device pixels a CSS pixel.
halftoneAt(x: number, y: number, picture: (x: number, y: number) => readonly number[], width: number, height: number, look: HalftoneLook, ratio?: number): [number, number, number]Claymation, blueprint, thermal, paper cutout, mosaic and CRT
FilterPassclass
The six looks laid over the whole picture (splat-core/filters.ts is the CPU twin: change one, change both): a thermal camera, an old CRT or tape, a blueprint, a mosaic, paper cutouts and claymation. The frame is drawn once as the world is set to draw it, and, where the look asks, a map of depth and one of parts with the same moved and sorted blobs (as outlines are, inkLines.ts); then one full-screen pass draws the look over the whole canvas.
Stage.setFilter sets the world for each: the blueprint and paper cutouts draw flat marks with no lights; the thermal camera draws what gives its own light over white (THERMAL_EMIT), so it can tell a lamp from a pale thing; claymation moves in held frames. The frame's camera must be a perspective camera.
Constructor
new FilterPass()Properties
pictureRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe picture, as the world draws it (half floats, so what glows can go over white).
idsRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe map of parts, for the looks that want one.
Methods
setLook()The look, and how many device pixels a CSS pixel is;
sizeis the scene's size in the world,timethe stage's clock.setLook(look: FilterLook, ratio: number, size: number, time: number): voidsetSize()Sizes the pass's targets, in device pixels.
setSize(width: number, height: number): voidrender()Draws the scene in the look into the renderer's current target, or onto the screen when it has none.
box()is the subject's box in the world (the blueprint's dimension lines are drawn round it).render(renderer: WebGPURenderer, scene: Object3D, camera: Camera, box?: { lo: readonly number[]; hi: readonly number[] }): voiddispose()Frees its targets.
dispose(): void
Six filter looks: the arithmetic
Six looks laid over the whole picture (Matt picked them, 2026-11-25): a thermal camera, an old CRT or tape, a blueprint, a mosaic, paper cutouts and claymation. Each is drawn by splat-engine/filterPass.ts from the frame as the blobs draw it (and, where a look asks, a map of depth and one of parts), one full-screen pass a look. The arithmetic here is pure and is the shader's CPU twin: change one, change both.
Places on the screen are device pixels with y counted down from the top; ratio is device pixels a CSS pixel, so a look's sizes (lines, tiles, shadows) are the same size to the eye on every screen.
Sky01type
A sky, top and bottom (sRGB 0–1).
readonly [Rgb01, Rgb01]fractvalue
The fractional part.
(v: number) => numberhash2value
A number from 0 to 1 for a place (the shader's hash(); change both).
(x: number, y: number) => numbernoise2()function
Smooth value noise from 0 to 1 over whole-number cells (the shader's noise; change both).
noise2(x: number, y: number): numberlumavalue
A color's luminance (linear in, linear out).
(c: readonly number[]) => numbertoLinearvalue
sRGB 0–1 to linear light.
(c: Rgb01) => [number, number, number]skyAtvalue
The sky at t, from 0 at the top of the picture to 1 at the bottom (linear in, linear out).
(top: readonly number[], bottom: readonly number[], t: number) => [number, number, number]Picturetype
A picture read at a device pixel: linear light, premultiplied (r, g, b, a).
(x: number, y: number) => readonly number[]ThermalLookinterface
How a stage is drawn as a thermal camera sees it (Stage.setFilter).
Properties
kind"thermal"Which look this is.
rampreadonly Rgb01[]The heat colors from cold to hot (sRGB 0–1), 2 to
THERMAL_STOPSof them, evenly spread.steppedbooleanoptionalEach heat takes the nearest of the ramp's colors, not a mix of two (a palette's colors stay its own).
hotnumberoptionalHow hot what gives its own light runs (a lamp, a fire, breath), 0 to 1.5 (1).
spreadnumberoptionalHow far heat spreads round what gives its own light, in CSS pixels (20).
warmnumberoptionalHow warm lit things are, by how bright they are, 0 to 1 (0.8).
noisenumberoptionalThe sensor's grain, 0 to 1 (0.3).
stillbooleanoptionalThe grain holds still (reduced motion, or a frame that must not change by the clock).
THERMAL_EMITvalue
What gives its own light is drawn this many times its color for the thermal camera, so it can be told from a pale thing (as neon's lamps).
4THERMAL_STOPSvalue
The most colors a heat ramp has.
8THERMAL_TAPSvalue
Where heat is looked for round each pixel, as shares of the look's spread (eight at the full reach, four at half).
readonly [number, number][]THERMAL_SPREAD_GAINvalue
How much of what glows nearby a pixel takes as its own heat.
0.6THERMAL_SKYvalue
How hot the empty sky reads at its top and at the horizon.
readonly [number, number]THERMAL_FPSvalue
How often the grain changes, a second.
15emittedvalue
How much of its color a pixel gives off by itself (linear, not premultiplied): 0 for anything at or under white, 1 at THERMAL_EMIT times.
(c: readonly number[]) => numberhotSharevalue
How much of what glows there counts as hot, by how colored it is: a lamp, a flame or the sun is warm-colored and hot, while a glowing cloud, the moon or a star is white and reads cold, as the sky does to a heat camera.
(c: readonly number[]) => numberTHERMAL_WHITEvalue
How much cooler a white thing reads than a dark one in the same light: white throws the sun back (clouds, snow, white walls).
0.55heatOf()function
A pixel's own heat, 0 to about 1.5, from its color (linear, not premultiplied): warmth by how bright it is lit, and the heat of what glows.
heatOf(c: readonly number[], look: ThermalLook): numberrampAt()function
The color for a heat (0 to 1) along a ramp of linear colors, evenly spread; stepped takes the nearest one.
rampAt(ramp: readonly (readonly number[])[], h: number, stepped?: boolean): [number, number, number]paletteRamp()function
A palette (sRGB 0–255) as a heat ramp: its colors from darkest to lightest, at most THERMAL_STOPS, spread evenly over it.
paletteRamp(colors: readonly (readonly number[])[]): Rgb01[]grainFramevalue
The grain's frame at a time.
(time: number, still?: boolean) => numberthermalAt()function
One device pixel as the thermal camera sees it (linear out).
thermalAt(x: number, y: number, picture: Picture, height: number, look: ThermalLook, ratio?: number, time?: number): [number, number, number]CrtLookinterface
How a stage is drawn as an old television playing a tape (Stage.setFilter).
Properties
kind"crt"Which look this is.
scannumberoptionalHow dark the gaps between scanlines are, 0 to 1 (0.5).
everynumberoptionalHow tall a scanline is, in CSS pixels (3).
bleednumberoptionalHow far color smears to the right of where it belongs, 0 to 1 (0.5).
wobblenumberoptionalHow much the picture's rows wander and a tracking band rolls up the screen, 0 to 1 (0.4).
noisenumberoptionalTape noise, 0 to 1 (0.3).
curvenumberoptionalHow much the glass bulges, with darker corners, 0 to 1 (0.4).
skySky01optionalWhat stands behind the subject, top and bottom (sRGB 0–1).
periodnumberoptionalSeconds the scene takes to come round again: the wobble goes a whole number of times into it, so a recording joins (12).
stillbooleanoptionalThe wobble and noise hold still.
CRT_BACKvalue
Behind a subject with no sky of its own (sRGB 0–1): a dim studio blue.
Sky01CRT_BLEED_PXvalue
How many CSS pixels color smears at full bleed.
6CRT_BLEED_TAPSvalue
How many taps the smear is read with.
6CRT_BAND_PXvalue
How far the tracking band throws rows aside at full wobble, in CSS pixels.
14CRT_BANDvalue
How tall the tracking band is, as a share of the picture.
0.06CRT_ROLLSvalue
How many times a loop the tracking band rolls up the screen.
2CRT_WANDERSvalue
How many times a loop the slow wander of the rows goes round.
3CRT_FPSvalue
How often the tape noise changes, a second.
30yiqvalue
YIQ from linear-ish RGB (the television's own split of brightness and color).
(c: readonly number[]) => [number, number, number]fromYiqvalue
RGB from YIQ.
(c: readonly number[]) => [number, number, number]crtCurve()function
Where a point of the screen (u, v from 0 to 1) reads the picture through the bulging glass, or undefined off its edge.
crtCurve(u: number, v: number, curve: number): [number, number] | undefinedscanShadevalue
How bright a place within a scanline is (f from 0 to 1 down the line): bright in its middle, dark between lines.
(f: number, scan: number) => numberwobbleAt()function
How far the rows at v (0 top, 1 bottom; y in CSS pixels) are thrown aside at a time, in CSS pixels.
wobbleAt(v: number, yCss: number, time: number, look: CrtLook): numbercrtAt()function
One device pixel of the television (linear out). picture is linear and premultiplied.
BlueprintLookinterface
How a stage is drawn as a blueprint (Stage.setFilter).
Properties
kind"blueprint"Which look this is.
paperRgb01optionalThe paper (sRGB 0–1).
inkRgb01optionalThe lines (sRGB 0–1).
linenumberoptionalThe outline's width, in CSS pixels (1.5).
innernumberoptionalHow strong the lines between a thing's parts are beside its outline, 0 to 1 (0.6).
gridnumberoptionalHow far apart the grid's lines are, in CSS pixels; 0 draws none (16).
dimsbooleanoptionalWhether dimension lines are drawn across the subject's width and height (true).
fillnumberoptionalHow strongly the subject is washed in the line color, 0 to 1 (0.25).
BLUEPRINT_PAPERvalue
A blueprint's paper (sRGB 0–1).
Rgb01BLUEPRINT_INKvalue
A blueprint's lines (sRGB 0–1).
Rgb01GRID_MINORvalue
How strong the grid's lines are.
0.16GRID_MAJORvalue
How strong every fifth line of the grid is.
0.32DIM_GAPvalue
How far the dimension lines stand off the subject, in CSS pixels.
16DIM_ARROWvalue
How long the dimension lines' arrowheads are, in CSS pixels.
7DIM_TICKSvalue
How many marks divide a dimension line.
10gridAt()function
How much of the grid's lines cover a pixel (0 to 1); x, y and every in device pixels, ratio for the line's width.
gridAt(x: number, y: number, every: number, ratio?: number): numberScreenBoxtype
A box on the screen, in device pixels: left, top, right, bottom.
readonly [number, number, number, number]dimPlaces()function
Where a box's dimension lines go (device pixels): the line under it (yd) and beside it (xd), each moved over or to the left where there is no room, and where their extension lines run; none for a box too small or off the picture.
dimsAt()function
Dimension lines round a box (device pixels, y down): one under it across its width and one beside it down its height (over it and to its left where there is no room), each with extension lines to the box, an arrowhead at each end and DIM_TICKS marks along it. How much of them covers (x, y), 0 to 1.
MosaicLookinterface
How a stage is drawn as a mosaic (Stage.setFilter).
Properties
kind"mosaic"Which look this is.
tilenumberoptionalA tile's side, in CSS pixels (10).
groutnumberoptionalThe grout between tiles, in CSS pixels (1.5).
groutColorRgb01optionalThe grout's color (sRGB 0–1).
varynumberoptionalHow much tiles differ in color from one to the next, 0 to 1 (0.5).
bevelnumberoptionalHow much each tile's edges catch light and shade, 0 to 1 (0.5).
brickbooleanoptionalRows set over one another like bricks, half a tile along.
skySky01optionalWhat stands behind the subject, top and bottom (sRGB 0–1): tiles in its colors. Left out, plain tiles of
MOSAIC_GROUND.
MOSAIC_GROUTvalue
The grout (sRGB 0–1): a pale mortar.
Rgb01MOSAIC_GROUNDvalue
Tiles behind a subject when no sky is laid (sRGB 0–1): a warm stone.
Rgb01MOSAIC_TAPSvalue
Where a tile's color is read, as shares of the tile about its middle (the middle first).
readonly [number, number][]tileAt()function
The tile a device pixel lies in: its column and row, its middle, and the pixel's place in it (u, v from −½ to ½).
tileAt(x: number, y: number, side: number, brick?: boolean): { cell: [number, number]; mid: [number, number]; u: number; v: number }tileCover()function
How much of a pixel a tile covers (0 to 1): a rounded square inset by half the grout, a little smaller or larger by its own hash so the grout lines wander. side and grout in device pixels.
tileCover(u: number, v: number, cell: readonly [number, number], side: number, grout: number): numbertileTint()function
A tile's own change of color: how much lighter or darker, and a small shift of each channel.
tileTint(cell: readonly [number, number], vary: number): [number, number, number]bevelAt()function
How a tile's face is lit by its bevel at (u, v): lighter toward its top left edge, darker toward its bottom right.
bevelAt(u: number, v: number, bevel: number): numberCutoutLookinterface
How a stage is drawn as layered cut paper (Stage.setFilter).
Properties
kind"cutout"Which look this is.
shadownumberoptionalHow far a layer's shadow falls on what is behind it, in CSS pixels (6).
softnumberoptionalHow soft the shadow's edge is, 0 to 1 (0.5).
lightnumberoptionalWhere the light comes from on the screen, in degrees (0 from the right, 90 from above; 120).
grainnumberoptionalThe paper's fibers, 0 to 1 (0.5).
edgenumberoptionalThe pale cut edge on the side toward the light, in CSS pixels (1).
raggednumberoptionalHow ragged the cut edges are, 0 to 1 (0.4).
skySky01optionalThe card behind everything, top and bottom (sRGB 0–1).
CUTOUT_CARDvalue
The card behind a subject with no sky of its own (sRGB 0–1).
Sky01CUTOUT_SHADEvalue
How dark a shadow is at full.
0.42CUTOUT_LAYERvalue
How much a layer must be nearer than the one under it to cast on it, as a share of the depth.
0.01CUTOUT_TAPSvalue
Where a soft shadow's edge is read, as shares of its softness, across the light's way.
readonly number[]RAGGED_PXvalue
How far a ragged edge wanders at full, in CSS pixels.
1.6RAGGED_GRAINvalue
How far apart a ragged edge's turns are, in CSS pixels.
9lightWayvalue
The way toward the light on the screen (device y down), for a light from deg (0 from the right, 90 from above).
(deg: number) => [number, number]raggedAt()function
Where a pixel reads the picture so cut edges wander a little: an offset in device pixels.
raggedAt(x: number, y: number, ragged: number, ratio?: number): [number, number]grainAt()function
The paper's fibers at a pixel: a brightness from about 0.94 to 1.06 at full grain.
grainAt(x: number, y: number, grain: number, ratio?: number): numbershadowAt()function
How much shadow falls on a pixel (0 to 1): where, a shadow's length toward the light, there is a layer nearer than this one (or anything at all, where this pixel is the card), read at a few places across the light's way for a soft edge. at(x, y) says whether something is there and its depth (0 for nothing) and part.
shadowAt(x: number, y: number, at: (x: number, y: number) => { depth: number; part: number }, look: CutoutLook, ratio?: number): numberClayLookinterface
How a stage is drawn as stop-motion clay (Stage.setFilter).
Properties
kind"clay"Which look this is.
fpsnumberoptionalFrames a second the scene moves at, as stop motion; 0 moves every frame (12).
printsnumberoptionalHow deep the thumbprints are, 0 to 1 (0.6).
sizenumberoptionalHow big a thumbprint is, as a share of the scene's size (0.05).
smoothnumberoptionalHow smooth the clay is: each thing's own colors softened together, 0 to 1 (0.5).
sheennumberoptionalHow much the clay shines, 0 to 1 (0.3).
boilnumberoptionalHow much the thumbprints shift from one frame to the next, as an animator's hands leave them (0.4).
skySky01optionalWhat stands behind the subject, top and bottom (sRGB 0–1).
CLAY_BACKvalue
Behind a subject with no sky of its own (sRGB 0–1): a painted studio backdrop.
Sky01CLAY_KEYvalue
The clay's key light in the view's own frame (x right, y up, z toward the viewer): from the top left, in front.
readonly [number, number, number]PRINT_Rvalue
How far a thumbprint reaches from its middle, in the prints' own size (a cell of the world is 1).
0.42PRINT_TILTvalue
How steeply a thumbprint's walls tip the clay's facing at full depth (its slope per unit of printAt()'s gradient).
0.7PRINT_LIPvalue
How high the clay pushed out of a thumbprint stands round its edge, as a share of the dent's depth.
0.3PRINT_LIP_Wvalue
How wide that lip is, as a share of the print's reach.
0.2PRINT_SHUTvalue
How much darker the bottom of a thumbprint is at full depth, shut in by its own walls.
0.16PRINT_LIGHTvalue
How much more a thumbprint's tipped walls turn toward or away from the light than the clay's soft key alone shows.
0.55PRINT_SHAREvalue
The share of the clay's cells that hold a thumbprint.
0.55CLAY_SMOOTH_PXvalue
How far round each pixel the clay is softened, in CSS pixels at full smoothness.
6CLAY_TAPSvalue
Where it is softened, as shares of that reach (eight ways at the full reach, eight between them at half).
readonly [number, number][]CLAY_SHADE_PXvalue
How far round each pixel the clay looks for nearer clay that shades it, in CSS pixels.
10CLAY_HOLLOWvalue
How dark a pixel shut in on every side by nearer clay gets.
0.4CLAY_DEEPvalue
How much nearer than a pixel its neighbor must be, as a share of its depth, to shade it fully.
0.03hollowOf()function
How shut in a pixel is (0 open to 1 shut in), from its own depth and its neighbors' round it (0 for nothing there): soft shade in the creases between lumps of clay.
hollowOf(depth: number, round: readonly number[]): numberprintHashvalue
A number from 0 to 1 for a cell of the world (the shader's cellHash() in filterPass.ts; change both).
(x: number, y: number, z: number, salt: number) => numberclayFramevalue
The stop-motion frame a time falls in, which the thumbprints shift by.
(time: number, fps: number) => numberPrintinterface
A thumbprint at a point: its height (−1 at the bottom of the dent up to PRINT_LIP on its lip, 0 elsewhere) and that height's slope, per unit of the prints' own size, in the world's frame.
Properties
hnumberThe height: −1 at the bottom of the dent, up to
PRINT_LIPon its lip, 0 away from any print.g[number, number, number]How fast the height rises, each way of the world, per unit of the prints' own size.
printProfile()function
A thumbprint's height across it, from its middle (0) out (PRINT_R is 1), and how fast that changes outward.
printProfile(u: number): [number, number]printAt()function
The thumbprints at a point of the world, in the prints' own size (the world divided by a print's size). A print is a round dent pressed into the clay with a little clay pushed up round its edge; each cell of the world holds one or none, and each frame shifts it a little (boil), as hands do. The dent is lit by tipping the clay's facing (pressed()), so its wall toward the light falls in shade and the far wall catches it.
printAt(p: readonly [number, number, number], frame: number, boil: number): Printpressed()function
Clay facing n (the view's frame, unit length) with a thumbprint pressed in, its slope g already turned into the view's frame: the facing tipped by the print's walls, and how much the light there changes beyond what clayShade() gives that facing (deeper shade on the wall toward the light, the bottom shut in).
pressed(n: readonly [number, number, number], g: readonly [number, number, number], h: number, prints: number): { n: [number, number, number]; light: number }clayShade()function
The clay's own shading for a surface facing n (the view's frame, unit length): a soft wrapped key light and a little sheen.
clayShade(n: readonly [number, number, number], sheen: number): { shade: number; shine: number }FilterLooktype
Any of the looks laid over the whole picture.
ThermalLook | CrtLook | BlueprintLook | MosaicLook | CutoutLook | ClayLookFilterKindtype
Which of them.
FilterLook["kind"]Knitting
KnitPassclass
The picture as knitting (splat-core/knit.ts is the CPU twin: change one, change both). The frame is drawn once, every blob flat in its own color. One small pass decides every stitch of the grid (the yarn nearest what the picture shows there, or the sweater's own pattern where it shows nothing; kept in a target a stitch a pixel, beside the one from the frame before so a stitch can keep its yarn), and a second draws each stitch as a V of yarn. The knitting covers the canvas.
The world should be drawing flat marks with no light of its own (Stage.setKnit sets both).
Constructor
new KnitPass()Properties
pictureRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe picture: every blob flat in its own color.
gridRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe grid of the frame just drawn: a pixel a stitch, the yarn's number in red.
Methods
setLook()The look.
setLook(look: KnitLook): voidsetSize()Sizes the pass for a picture in device pixels, with stitches
widthbyheightof them.setSize(width: number, height: number, stitch: { width: number; height: number }): voidforget()Forgets the frame before: for when what is being drawn is swapped for something else.
forget(): voidrender()Draws the scene as knitting into the renderer's current target, or onto the screen when it has none.
render(renderer: WebGPURenderer, scene: Object3D, camera: Camera): voiddispose()Frees its targets.
dispose(): void
Knitting: the arithmetic
KnitLookinterface
How a stage draws knitting (Stage.setKnit).
Properties
sizenumberoptionalA stitch's width, in CSS pixels (9).
yarnsreadonly Rgb3[]The yarns (sRGB 0–1), at most
KNIT_YARNS: the first is the sweater's body, the second the pattern's main yarn, the third its second. The picture is knitted in every yarn but the body's.bandsreadonly string[]optionalThe pattern round the picture: the bands from the edge inward, each an id of
MOTIFS. Left out or empty, none.snowbooleanoptionalSmall dots of the pattern's yarn over the plain field between the bands.
steadynumberoptionalHow much nearer another yarn must be (OKLab) before a stitch of the picture changes yarn; 0 decides each frame afresh (
KNIT_STEADY).
KNIT_YARNSvalue
The most yarns a look can have.
10STITCH_TALLvalue
A stitch is this many times as tall as wide: knitting is wider than it is tall.
0.8KNIT_COVERvalue
A stitch belongs to the picture when this much of it is covered.
0.5KNIT_STEADYvalue
A stitch of the picture keeps its yarn unless another is this much nearer (OKLab distance).
0.035KNIT_LIGHTvalue
How much lightness counts beside hue when a yarn is picked for a color: a red thing in shade takes the dark red yarn before a brown one as light as it.
0.5BAND_SHAREvalue
The bands at the top take up to this share of the rows, and those at the bottom as much.
0.3SNOW_STEPvalue
Snow dots stand this many stitches apart, each row of them half a step aside from the last.
4PICTURE_MARKvalue
Added to a stitch's yarn number in the grid when it shows the picture, so the next frame can tell.
32LEG_TOPvalue
Where a V's two legs run, in a stitch's own square (x across, y down, both 0 to 1): from LEG_TOP out at the side to LEG_TIP near the middle, which lies a quarter of a stitch into the row below.
readonly [number, number]LEG_TIPvalue
Where a V's leg ends, near the middle and a quarter of a stitch into the row below (see LEG_TOP).
readonly [number, number]YARN_HALFvalue
Half a strand's width, as a share of the stitch's.
0.2GAP_SHADEvalue
How dark the gap between strands is beside the yarn.
0.42YARN_ROUNDvalue
How much darker a strand is at its edges than along its middle.
0.4YARN_VARYvalue
How much one stitch's yarn is lighter or darker than the next's.
0.07stitchAt()function
What is at a point of a stitch (x across, y down, 0 to 1): above when it is the tip of the stitch above, which lies over this one, and shade, what the yarn's color is multiplied by there (a strand is lighter along its middle; between strands is the dark of the gap, in the stitch's own yarn).
stitchAt(x: number, y: number): { above: boolean; shade: number }stitchHash()function
A number from 0 to 1 for a stitch, as the shader makes it.
stitchHash(col: number, row: number): numberyarnFor()function
The yarn nearest a color (sRGB 0–1) in OKLab with lightness counted KNIT_LIGHT, never the body's (yarn 0): its number, and how far off it is. was is the yarn the stitch had, kept unless another is steady nearer.
yarnFor(color: readonly number[], yarns: readonly Rgb3[], was?: number, steady?: number): { yarn: number; off: number }Motifinterface
A small picture knitted over and over along a band: rows of stitches, . the body, x the pattern's main yarn, o its second. Every row is one repeat wide.
Properties
idstringIts name in a look's
bands.rowsreadonly string[]The rows, top first.
uprightbooleanoptionalIt stands on the ground (a tree, a reindeer), so the bottom bands don't turn it over.
MOTIFSvalue
The motifs a band can be.
readonly Motif[]knitChart()function
The sweater's own pattern for a grid of stitches: a yarn number a stitch (0 the body, 1 and 2 the pattern's), rows from the top. The bands are laid from the top edge inward, each with a plain row after it, for as long as they fit in BAND_SHARE of the rows (one too tall is left out), and again from the bottom edge up, turned over unless they stand upright. Every motif is laid so that the middle of the grid is the middle of a repeat, so the pattern is the same on both sides. Snow dots fill the field between.
knitChart(cols: number, rows: number, look: Pick<KnitLook, "bands" | "snow">): Uint8ArraystitchSize()function
How many device pixels a stitch is wide and tall: whole, so every stitch is the same size.
stitchSize(size: number, ratio: number): { width: number; height: number }knitCell()function
One stitch decided: cover is how much of it the picture covers and color what it shows there (sRGB 0–1, straight), beside whether a stitch next to it (left, right, above or below) shows the picture, chart the sweater's own yarn there and was the grid's number for it the frame before (-1 for none). The picture wins; a stitch right beside it is plain body, so the pattern never runs into the picture. Gives the grid's number: the yarn, plus PICTURE_MARK for a stitch of the picture.
knitCell(cover: number, color: readonly number[], beside: boolean, chart: number, yarns: readonly Rgb3[], was?: number, steady?: number): number3D glasses
AnaglyphPassclass
3D glasses (splat-core/anaglyph.ts): the frame drawn twice, from a left and a right eye a little either side of the camera, each looking the same way with its picture slid so that the screen (eyesFor()) lands in the same place for both, then one pass lays them over each other in red and cyan (mixEyes(), the CPU twin: change both). Each eye's picture sits over the look's backdrop, which is the same for both, so it stands at the screen.
Each eye is its own view, so the blobs are sorted for each: two sorts and two draws a frame. Lines and points are drawn in both pictures, as anything else is.
Constructor
new AnaglyphPass()Properties
eyesRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>[]read onlyThe left eye's picture and the right's: linear color times cover, and cover.
Methods
setLook()The look: how deep, where the screen stands, how the pictures are mixed and what is behind.
setLook(look: AnaglyphLook): voidsetSize()Sizes the eyes' pictures, in device pixels.
setSize(width: number, height: number): voidrender()Draws the scene for both eyes and lays them over each other into the renderer's current target, or onto the screen when it has none.
distanceis how far the camera is from what it looks at.render(renderer: WebGPURenderer, scene: Object3D, camera: PerspectiveCamera, distance: number): voiddispose()Frees its pictures.
dispose(): void
3D glasses: the arithmetic
3D glasses (Matt's idea, 2026-11-25): the scene drawn twice, from two eyes a little apart, and the two pictures laid one over the other in red and cyan. Without glasses things stand doubled, a red ghost to one side and a cyan one to the other; through red and cyan glasses each eye sees only its own picture and the scene comes together in depth.
Pure: the eyes' geometry and how the two pictures are mixed, which AnaglyphPass (splat-engine/anaglyphPass.ts) repeats in its shader. Change both.
AnaglyphMixtype
How the two pictures are mixed into one.
"optimized" | "color" | "half" | "gray"AnaglyphLookinterface
How the eyes are set and the pictures mixed. Glasses are red over the left eye and cyan over the right, the usual pair.
Properties
depthnumberoptionalHow far apart the eyes are, as a share of the usual (
EYE_SHAREof the distance to what the view looks at): 0 is flat, 1 the usual, 2 twice as deep.popnumberoptionalWhere the screen stands, past what the view looks at, as a share of the distance to it: 0 puts that at the screen, 0.5 puts the screen half as far again behind it, so more comes out toward you.
mixAnaglyphMixoptionalHow the two pictures are mixed.
backreadonly [Rgb3, Rgb3]optionalWhat is behind the scene, top and bottom (sRGB 0–1), the same in both eyes so it sits at the screen.
EYE_SHAREvalue
The usual eyes: a thirtieth of the distance to what the view looks at, a stereo photographer's rule of thumb.
numberANAGLYPH_BACKvalue
What is behind a scene with no sky of its own (sRGB): a dark gray, which shows the least ghosting through either lens.
readonly [Rgb3, Rgb3]eyesFor()function
The two eyes for a view looking at something distance away: how far each stands to the side of the camera (half, the left eye at −half along the camera's right, the right at +half), and how far away the screen is (screen), where a thing is drawn in the same place for both eyes.
eyesFor(distance: number, look: AnaglyphLook): { half: number; screen: number }eyeSlidevalue
How far an eye's picture is slid across (in clip space, per unit of w) so that a point screen away, straight ahead of the camera, lands in the middle of both: side is the eye's place along the camera's right, p00 the projection's x scale. Add it to the projection matrix's element 8 (x from z) negated, as eyeProjection() does.
(side: number, p00: number, screen: number) => numbereyeProjection()function
An eye's projection matrix (column-major, as three.js keeps it): the camera's own with x slid by eyeSlide.
eyeProjection(p: ArrayLike<number>, side: number, screen: number): number[]eyeX()function
Where a point in the camera's own frame (x right, y up, looking down −z) lands across the picture for an eye, in normalized device coordinates: that eye stands at side along x and uses eyeProjection(). The CPU check of what the shader is given.
eyeX(p: ArrayLike<number>, side: number, screen: number, at: readonly [number, number, number]): numberEYE_MIXvalue
Each mix as two 3×3 matrices, rows for red, green and blue of the result, columns for the left and right pictures' red, green and blue (linear). optimized is Eric Dubois's least-squares red–cyan projection, which keeps most color while each lens passes little of the other eye's picture; color hands the left eye's red and the right eye's green and blue over as they are (bright, but reds ghost); half gives the left eye its gray and the right its color; gray gives both their gray (no color, least ghosting).
Record<AnaglyphMix, { left: readonly Rgb3[]; right: readonly Rgb3[] }>ANAGLYPH_MIXESvalue
The mixes in the order the page offers them.
readonly AnaglyphMix[]mixEyes()function
One pixel of the finished picture (linear, 0–1) from the two eyes' pixels there (linear, over the backdrop).
mixEyes(left: Rgb3, right: Rgb3, mix?: AnaglyphMix): [number, number, number]Baking sprite sheets
BakeTargetinterface
Draws a rigged creature's moves from 4 or 8 sides and turns each frame into pixel art with Splat to Sprite's pipeline (render big, average down, cut the alpha, one palette for the whole sheet, tidy, outline).
The camera circles the creature (which faces +Z) with a narrow lens from far off, so the sprite is close to orthographic, and stays at one distance for every frame, so the creature is the same size in all of them.
Properties
rendererWebGPURendererThe renderer to draw with.
sceneSceneA scene holding only what should be in the sprite (the creature's SplatWorld).
posed() => voidTells the world its skeleton (and, after
morph, its blobs) moved.morph(clip: Clip | undefined, t: number) => voidoptionalReshapes the actor's blobs by a clip's morph weights at a time, on the CPU, for an actor with morphs.
BakeOptionsinterface
How a sprite sheet is baked.
Properties
directions4 | 8Directions each move is drawn from.
sizenumberA frame's width and height, in pixels.
colorsnumberColors in the palette.
outlinebooleanWhether each sprite gets a dark outline.
mapsbooleanoptionalBake a normal map and a depth map beside the sheet, frame for frame (
BakedSheet.normals,depths), for a game that lights its sprites.
BakedSheetinterface
A baked sprite sheet: its frames and how they are laid out.
Properties
planSheetPlanThe rows and columns.
framesFrame[]Every frame, row by row.
sizenumberA frame's width and height, in pixels.
anchorYnumberWhere the feet are: one past the lowest solid row of any frame.
framingFramingThe sphere the camera was fitted to.
png() => Promise<Blob>The whole sheet as one PNG.
normalsFrame[]optionalWith
BakeOptions.maps: each frame's facing as a normal map (x right, y up, z toward the viewer; spriteMaps.ts).depthsFrame[]optionalWith
BakeOptions.maps: each frame's depth, white nearest and black furthest across the creature's framing.mapPng(which: "normals" | "depths") => Promise<Blob>optionalThe normal or depth maps laid out as the sheet is, as one PNG.
bakeSheet()function
Draws every frame of every move from each direction, all at one camera distance, and turns them into pixel art. progress is called as frames are done.
bakeSheet(t: BakeTarget, moves: SheetMove[], o: BakeOptions, progress?: (done: number, total: number) => void): Promise<BakedSheet>Sprite sheet layout
SheetMoveinterface
A rigged creature's moves as a pixel-art sprite sheet: the plan (which row is which move from which side), the framing, and the two JSON files that go with the PNG. Pure, so Node tests can check it; the drawing is bakeSheet.ts.
Rows are move by move, and within a move one row per direction, in the order Splat to Sprite uses: 4 directions follow Tinkerkit (down, left, right, up), 8 go round clockwise from down. Each row holds that move's frames, evenly spaced through one loop of its clip.
Properties
namestringNames the animations:
<name>-<direction>.clipClipoptionalUndefined for a still pose (the rest pose).
framesnumberHow many frames it gets.
SheetRowinterface
One row of a sheet: a move seen from one direction (turn() is that direction's angle).
Properties
moveSheetMoveThe move.
dirstringThe direction's name, such as 'down'.
turnnumberHow far the creature is turned for it, in degrees.
SheetPlaninterface
A sheet's rows, and as many columns as its longest move has frames.
Properties
rowsSheetRow[]The rows, top to bottom.
colsnumberColumns: the longest move's frames.
planSheet()function
Lays a sheet out: a row for each move seen from each direction.
loopSecondsvalue
How long one loop of a move lasts, in seconds (0 for a still pose).
(m: SheetMove) => numberframeTimesvalue
When each frame of a move is taken: evenly through one loop, so the last frame leads back into the first.
(m: SheetMove) => number[]moveFpsvalue
Frames per second that plays a move at its real speed.
(m: SheetMove) => numberFraminginterface
A sphere that holds the creature through every frame of every move.
Properties
center[number, number, number]The sphere's middle.
radiusnumberIts radius.
frameAll()function
A sphere round the creature through every frame of every move, so one camera distance fits them all and the creature is the same size in every frame. Moves a sample of blob centers by their bones on the CPU (the same blend as the GPU), and pads each by its largest scale.
tinkerkitJson()function
Mirrors Tinkerkit's SpriteSheet document (packages/format/src/spritesheet.ts, format version 71). Adds idle-<direction> (the first frame of the first move) when no move is called idle, since Tinkerkit's characters stand on it.
tinkerkitJson(name: string, image: string, plan: SheetPlan, size: number, anchorY?: number): { kind: string; formatVersion: number; id: string; name: string; image: string; imageWidth: number; imageHeight: number; frameWidth: number; frameHeight: number; pixelScale: number; anchor: { x: number; y: number }; footprint: { x: number; y: number; w: number; h: number }; animations: Record<string, { frames: number[]; fps: number; loop: boolean }> }asepriteJson()function
The JSON-array sheet Aseprite writes (and TexturePacker, Phaser and most engines' importers read): one entry per frame, with a tag per animation.
asepriteJson(image: string, plan: SheetPlan, size: number): { frames: object[]; meta: { app: string; version: string; image: string; format: string; size: { w: number; h: number }; scale: string; frameTags: object[] } }Styles
The looks as one catalog: each style's settings with their limits, names and where they start, the value a page holds for them, and the look each makes for the stage. The same definitions every page of this site draws from.
The styles
Styletype
How a scene is drawn: as pixel art (plain or glitching), or as one of Brush and Ink's looks.
typeof PIXEL.id | typeof id | typeof id | typeof id | typeof id | typeof id | typeof id | typeof id | typeof id | typeof id | typeof FILTERS[number]["id"] | typeof LOOKS[number]["id"]STYLESvalue
Blocks first, then pixel art and tech glitch (pixel art too), then the looks in Brush and Ink's own order (the plain blobs last).
{ id: Style; label: string; note: string }[]HIDDEN_STYLESvalue
Styles kept in the code, the address and kept scenes but offered in no picker (Matt, 2026-11-25: claymation is not ready yet).
readonly Style[]offeredvalue
Whether a style is offered in a picker.
(style: string) => booleanPICKED_STYLESvalue
The styles a picker offers: STYLES without the hidden ones.
{ id: Style; label: string; note: string }[]DEFAULT_STYLEvalue
The style a page starts in, and the one a plain address means: blocks. Every other style is named in the address (?style=pixel).
StylestyleAsked()function
The style an address or a kept scene asks for (?style=oil), or the default. Text keeps the id ascii (?style=text means it too), and a Text picture in box drawing or quarter blocks (?style=ascii&chars=lines, kept before 2026-11-25) is Box Art now, so chars is the address's or the kept Text settings' set of characters.
styleAsked(asked: string | null, chars?: string | null): StylestyleWords()function
A style as the end of "drawn …", for the line under the view and the view's own label.
styleWords(style: Style): stringisPixelStylevalue
Whether a style is drawn as pixel art underneath (pixel mode, its palette and finish): pixel art itself and tech glitch.
(style: Style) => style is "pixel" | "glitch"lightsItselfvalue
Whether a style lights the scene itself, so the scene is cut with no light baked in: cel shading, neon, stained glass, blocks, knitting and paper cutout (which want each thing in its own flat colors).
(style: Style | undefined) => booleanThe catalog: every style's settings
The styles API (Matt, 2026-11-22: no page uses a version of a style all its own). Two things, both data:
- the catalog (
CATALOG): every style's settings written once, each with its kind, its choices or range, where it starts and its name in the address. Controls are drawn from it (SettingsControls.tsx), the address is read by it (fromAddress()) and kept settings are checked against it (settingsFrom()), so a setting added here is on every page that offers the style, in its links and in its saved scenes. - the value (
StyleValue): which style, and each style's settings, which a page holds, a saved scene keeps and a link carries.
An experiment tries a setting of its own by adding it to the style here marked trial with the experiment's name: only that page shows it. Folding it in is taking the mark off. Pure, so it is tested.
Unittype
How a number reads beside its slider.
"percent" | "px" | "deg" | "times" | "count"Showsinterface
What a setting's when is told about the page: the style on show and what the subject has.
Properties
styleStyleThe style on show.
waterbooleanoptionalWhether the subject has water.
weatherbooleanoptionalWhether weather is out over the subject.
cyclebooleanoptionalWhether the scene has a color cycle.
colorsnumberoptionalHow many colors the palette on show has (0 is full color).
heatnumberoptionalThe scene's own heat haze, in art pixels.
Tabtype
Where on a page a setting is laid: a style whose settings are spread over two tabs says which (pixel art's Style and Finish; switches is the Finish tab's run of switches).
"style" | "finish" | "switches"Drawn<V>type
How a setting is drawn when not as its own kind: what the control shows for the settings as they are, and what a press changes.
{ kind: "toggle"; at: (v: V) => boolean; set: (to: boolean, on: Shows) => Partial<V> } | { kind: "choice"; options: readonly { id: string; label: string }[]; at: (v: V) => string; set: (id: string) => Partial<V> }RangeSetting<V>interface
A slider.
Plus everything in Base<V>.
Properties
kind"range"What says it is a slider.
minnumberThe least it goes to.
maxnumberThe most it goes to.
stepnumberHow far one step of the slider moves it.
unitUnitHow its number reads beside the slider.
zerostringoptionalWhat 0 reads as ("None").
wholebooleanoptionalHeld to whole steps.
ChoiceSetting<V>interface
One of a few, as chips. open choices are the page's to list (a scene's palettes): any id is kept.
Plus everything in Base<V>.
Properties
kind"choice"What says it is a choice.
optionsreadonly { id: string | number; label: string; about?: string }[]What can be picked: each one's kept value, its name, and a line about it.
openbooleanoptionalThe page lists the choices itself (a scene's palettes), so any id is kept.
ToggleSetting<V>interface
A switch. One that starts null follows its style (auto) until the visitor says. on is the address's word for it when not 1.
Plus everything in Base<V>.
Properties
kind"toggle"What says it is a switch.
auto(style: Style) => booleanoptionalWhat a switch that starts
nulldoes for a style until the visitor says.onstringoptionalThe address's word for on, when it is not 1.
SeedSetting<V>interface
A whole number a button moves on, for another run of something random.
Plus everything in Base<V>.
Properties
kind"seed"What says it is a seed.
TextSetting<V>interface
A line of text the visitor types (the words a picture is written in).
Plus everything in Base<V>.
Properties
kind"text"What says it is text.
mostnumberThe most characters it keeps.
StyleSetting<V>type
A setting of a style: a slider, a choice, a switch, a seed or a line of text.
RangeSetting<V> | ChoiceSetting<V> | ToggleSetting<V> | SeedSetting<V> | TextSetting<V>StyleDef<V>interface
One style's settings (or those of a few styles that share them, as the brush marks do).
Properties
idstringThe name its settings are kept under.
stylesreadonly Style[]The styles that use these settings.
startVWhere every setting starts.
settingsreadonly StyleSetting<V>[]The settings, in the order a page lays them out.
MarkSettingsinterface
The brush marks (gouache, oil, ink and wash, hatching, stipple) and the plain blobs, which can take the pen's outline too.
Properties
sizenumberHow big a mark is beside its blob.
outlineboolean | nullWhether a pen outlines things; null is on for the pen looks and off for paint.
pennumberThe pen's width, in CSS pixels.
paperstringThe paper and ink, an id of
PAPERS.palettestringThe palette the scene is painted from before it is drawn: 'none' keeps its own colors, 'own' is the scene's, else a shared one.
AsciiSettingsinterface
The settings of the picture drawn as characters.
Properties
charsGlyphSetWhich characters: ASCII, braille, words or a typewriter's (Box Art's sets are its own style).
wordsstringThe text the picture is written in, drawn as words.
letternumberA character's height, in CSS pixels.
weightnumberHow heavy the characters are drawn.
strokesbooleanWhether edges are drawn as strokes (| _ / \\).
strandsbooleanWhether fur and grass are drawn as strokes along the way they lie.
ownbooleanWhether each character takes the color of what it shows.
paperstringThe ground and ink, an id of
PAPERS.palettestringThe palette the scene is painted from before it is drawn: 'none' keeps its own colors, 'own' is the scene's, else a shared one.
BoxArtSettingsinterface
The settings of the picture drawn as Box Art: the box-drawing and block characters, apart from Text (Matt, 2026-11-25).
Properties
chars"blocks" | "lines"Which characters: box drawing ('lines') or quarter blocks and shades ('blocks').
letternumberA character's height, in CSS pixels.
weightnumberHow heavy the characters are drawn.
ownbooleanWhether each character takes the color of what it shows.
paperstringThe ground and ink, an id of
PAPERS.palettestringThe palette the scene is painted from before it is drawn: 'none' keeps its own colors, 'own' is the scene's, else a shared one.
CelSettingsinterface
Cel shading's settings.
Properties
turnnumberWhere the light is, in degrees round the subject from the starting view.
heightnumberHow high the light stands, in degrees.
tones2 | 3How many tones the light is cut into.
shadowsbooleanWhether things cast shadows.
smoothnumberHow far the light is smoothed over a surface before it is cut, in pixels.
fillsnumberHow many flat colors each part's own are gathered into; 0 leaves them as painted.
backdropstringWhat stands behind, an id of
BACKDROPS; '' is the subject's own sky where it has one.outlinebooleanWhether an even line is drawn round things.
pennumberThe line's width, in CSS pixels.
palettestringThe palette the scene is painted from before it is lit: 'none' keeps its own colors, 'own' is the scene's, else a shared one.
PixelSettingsinterface
Pixel art's settings, as the Style and Finish controls set them.
Properties
palettestringThe palette's id: 'own' is the scene's, else one of the shared ones.
sizenumberEach art pixel this many device pixels across.
ratenumberFrames a second the scene moves at; 0 is every frame the screen shows.
dithernumberHow much dither, 0 to 1.
glownumberHow strongly glowing things light what is round them and shine into the pixels beside them.
outlinebooleanA line round the scene, and whether it takes a darker tone of each thing it goes round.
ownbooleanWhether the outline takes a darker tone of each thing it goes round.
linesbooleanLines inside the scene: where things meet (and, where the scene asks, where colors jump).
skybooleanWhether the scene's sky is drawn behind it.
heatnumberHeat haze over glowing things, in art pixels; 0 is none.
bandsnumberGlow in flat rings.
seloutbooleanA softer outline on lit sides.
cyclebooleanColor cycling, where the scene has one.
stepsbooleanPainted in steps of the palette as the scene is cut.
texelnumberLight in this many bands a blob, as the scene is cut; 0 is smooth light.
shadebooleanLight worked out a pixel at a time (cel shading in the small picture), with the scene cut unlit.
rockbooleanThe scene's own gentle rocking of the view.
exactbooleanThe exact (radix) sort.
PIXEL_SIZESvalue
The pixel sizes on offer.
number[]PIXEL_RATESvalue
The paces on offer, in frames a second; 0 is smooth.
number[]TEXEL_BANDSvalue
How many steps of sun Light in bands gives (banded()): three, none, half and full, kept the paint's texture best.
3PIXELvalue
Pixel art. Where a scene has a finish of its own it starts these (pixelStart in styleSettings.ts); this start is a scene with none. Its controls are spread over two tabs (tab), and a few are drawn as another kind than they are kept as (draw): the outline's two switches are one choice of three, and the bands and the haze are switches.
StyleDef<PixelSettings>GLITCH_DEFvalue
Tech glitch: pixel art with bursts laid on, so it has pixel art's settings and these.
StyleDef<GlitchChoice>MARKSvalue
The settings the brush marks and the plain blobs share: mark size, outline, pen and paper.
StyleDef<MarkSettings>WORDS_STARTvalue
What a picture drawn as words says until the visitor writes something else.
"Every blob a letter. "ASCIIvalue
The settings of the picture drawn as characters.
StyleDef<AsciiSettings>BOX_SETSvalue
Box Art's sets of characters, which Text drew until 2026-11-25: ?style=ascii&chars=lines is Box Art now.
readonly string[]BOX_ARTvalue
The settings of the picture drawn as Box Art (Matt, 2026-11-25: box drawing and quarter blocks, out of Text).
StyleDef<BoxArtSettings>CEL_DEFvalue
Cel shading's settings.
StyleDef<CelSettings>BLOCKS_DEFvalue
The settings of the Blocks style.
StyleDef<BlockChoice>NEON_DEFvalue
Neon's settings.
StyleDef<NeonChoice>GLASS_DEFvalue
Stained glass's settings.
StyleDef<GlassChoice>WASH_DEFvalue
Watercolor's settings.
StyleDef<WashChoice>HALFTONE_DEFvalue
Halftone screen print's settings.
StyleDef<HalftoneChoice>CLAY_DEFvalue
Claymation's settings.
StyleDef<ClayChoice>BLUEPRINT_DEFvalue
The blueprint's settings.
StyleDef<BlueprintChoice>THERMAL_DEFvalue
The thermal camera's settings.
StyleDef<ThermalChoice>CUTOUT_DEFvalue
Paper cutout's settings.
StyleDef<CutoutChoice>MOSAIC_DEFvalue
The mosaic's settings.
StyleDef<MosaicChoice>CRT_DEFvalue
CRT / VHS's settings.
StyleDef<CrtChoice>KNIT_DEFvalue
Knitting's settings.
StyleDef<KnitChoice>ANAGLYPH_DEFvalue
3D glasses' settings.
StyleDef<AnaglyphChoice>SceneSettingsinterface
The scene's own settings, which every style respects: '' is the scene as it is written (its own weather, its own time), and a detail of '' is the one its style starts at (detailStart). Weather and cloud cover are one choice on the page (a weather brings its own clouds), kept as two so a cover can be told from a weather.
Properties
time"" | TimeIdThe time of day; '' is the scene as written.
weather"" | WeatherId | "none"The weather; '' is the scene's own, 'none' turns a scene's own off.
clouds"" | CloudIdThe cloud cover; '' is the scene's own.
wind"" | WindIdThe wind; '' is what the weather brings.
overheadboolean | nullClouds floating over the scene; null is the scene's own way.
transition"cut" | TransitionKindHow one scene gives way to the next; 'cut' is at once.
detailstringThe detail the scene is cut at, an id of
SCENE_DETAIL; '' is the one its style starts at.
SCENEvalue
The scene's own settings, written as a style's are so the same code reads, keeps and draws them.
StyleDef<SceneSettings>sceneStartvalue
The scene's settings as they start, with what the address asks (?time=night, ?weather=snow, ?wind=gale, ?transition=cut, ?detail=fine).
(q?: URLSearchParams) => SceneSettingsCATALOGvalue
Every style's settings, by the name they are kept under.
{ pixel: StyleDef<PixelSettings>; glitch: StyleDef<GlitchChoice>; marks: StyleDef<MarkSettings>; ascii: StyleDef<AsciiSettings>; boxart: StyleDef<BoxArtSettings>; cel: StyleDef<CelSettings>; blocks: StyleDef<BlockChoice>; neon: StyleDef<NeonChoice>; glass: StyleDef<GlassChoice>; watercolor: StyleDef<WashChoice>; knit: StyleDef<KnitChoice>; anaglyph: StyleDef<AnaglyphChoice>; halftone: StyleDef<HalftoneChoice>; clay: StyleDef<ClayChoice>; blueprint: StyleDef<BlueprintChoice>; thermal: StyleDef<ThermalChoice>; cutout: StyleDef<CutoutChoice>; mosaic: StyleDef<MosaicChoice>; crt: StyleDef<CrtChoice> }StyleKeytype
A name settings are kept under: a key of CATALOG.
keyof typeof CATALOGStylesValueinterface
Each style's settings: what a page holds beside which style is on show.
Properties
pixelPixelSettingsPixel art's.
glitchGlitchChoiceTech glitch's, on top of pixel art's.
marksMarkSettingsThe brush marks' and the plain blobs'.
asciiAsciiSettingsThe characters'.
boxartBoxArtSettingsBox Art's.
celCelSettingsCel shading's.
blocksBlockChoiceThe Blocks style's.
neonNeonChoiceNeon's.
glassGlassChoiceStained glass's.
watercolorWashChoiceWatercolor's.
halftoneHalftoneChoiceHalftone screen print's.
knitKnitChoiceKnitting's.
anaglyphAnaglyphChoice3D glasses'.
clayClayChoiceClaymation's.
blueprintBlueprintChoiceThe blueprint's.
thermalThermalChoiceThe thermal camera's.
cutoutCutoutChoicePaper cutout's.
mosaicMosaicChoiceThe mosaic's.
crtCrtChoiceCRT / VHS's.
DrawnSettingstype
The settings of the looks useDrawnLook draws: every style but pixel art and its glitch.
Omit<StylesValue, "pixel" | "glitch">StyleValueinterface
How a scene is drawn: the style, every style's settings (so going to another style and back loses nothing), and the scene's own.
Properties
styleStyleThe style on show.
stylesStylesValueEvery style's settings.
sceneSceneSettingsThe scene's own settings.
keysOfvalue
The settings a style uses, in the order they are laid on: tech glitch is pixel art's and its own.
(style: Style) => StyleKey[]fromAddress()function
A style's settings as the address asks for them, over start: only settings with an address, and only sound values.
fromAddress<V>(def: StyleDef<V>, start: V, q: URLSearchParams): VsettingsFrom()function
Settings that were kept (a saved scene, a link) read back over start: each one kept only where the catalog finds it sound.
StartForinterface
What a page tells the start about itself.
Properties
coarsebooleanoptionalA phone or tablet: knitting starts two pixels a stitch finer, so its bands fit a small view.
drawnStart()function
The drawn looks' settings as they start, with what the address asks (?block=, ?tones=3, ?chars=braille, ?outline=0, …).
drawnStart(q?: URLSearchParams, on?: StartFor): DrawnSettingsdrawnFrom()function
Kept drawn settings read back over a start: kept() is an object by style ({ cel: {…}, blocks: {…} }), any of it missing or unsound left as it starts.
drawnFrom(start: DrawnSettings, kept: unknown): DrawnSettingsvalueWords()function
A setting's value as words, as its slider shows it.
valueWords<V>(s: RangeSetting<V>, v: number): stringshownSettings()function
The settings a page shows for a style (in one of its tabs, where it has them): those whose when holds, and no other page's trials.
shownSettings<V>(def: StyleDef<V>, value: V, on: Shows, page?: string, tab?: Tab): StyleSetting<V>[]Detail levels
SCENE_DETAILvalue
The detail levels a scene written as data is cut at: the grid's spacing for each, coarsest first.
readonly [{ id: "chunky"; label: "Chunky"; spacing: 0.042 }, { id: "medium"; label: "Medium"; spacing: 0.03 }, { id: "fine"; label: "Fine"; spacing: 0.022 }, { id: "finest"; label: "Finest"; spacing: 0.017 }]Brush and ink, as settings
LookIdtype
How the blobs are drawn: as they are, or as one of the marks.
"blobs" | "ascii" | "boxart" | MarkKindisMarkvalue
Whether a look is one of the marks drawn blob by blob.
(id: LookId) => id is MarkKindLOOKSvalue
The drawn looks a page offers, each with its name and a line about it; the plain blobs last.
{ id: LookId; label: string; note: string }[]PAPERSvalue
Paper and pen for the drawn looks.
{ id: string; label: string; paper: readonly [number, number, number]; ink: readonly [number, number, number] }[]GROUNDvalue
What the painted looks stand on: a dark, warm ground, as a primed board.
"#26221f"SCREENvalue
What the characters stand on, by default: near black, as a terminal.
readonly [number, number, number]Cel shading, as settings
CELvalue
The chip beside the drawn looks (brushLooks.ts).
{ id: "cel"; label: string; note: string }BACKDROPSvalue
What the cel stands on, and the shade and line that go with it.
{ id: string; label: string; back: string; shade: readonly [number, number, number]; ink: readonly [number, number, number] }[]lightFrom()function
The way to a light turn() degrees round the upright (0 is from +z, 90 from +x, as a view's azimuth) and height degrees up.
lightFrom(turn: number, height: number): [number, number, number]CelChoiceinterface
What the page's controls make.
Properties
turnnumberWhere the light is, in degrees round the subject from the starting view.
heightnumberHow high the light stands, in degrees.
tones2 | 3How many tones the light is cut into.
shadowsbooleanWhether things cast shadows.
smoothnumberHow far the light is smoothed over a surface before it is cut, in pixels.
linenumberThe outline's width, in CSS pixels; 0 is none.
backdropstringWhat stands behind, an id of
BACKDROPS.fillsnumberHow many colors each part's own are gathered into (
gatherColors()); 0 leaves them as painted.
CEL_STARTvalue
Where cel shading's settings start.
CelChoicecelLook()function
The look for the stage.
FILL_REACHvalue
Flat fills take out speckle finer than this many of a typical blob's size; an eye or an apple a few blobs across stays.
2.2NIGHT_SKYvalue
A sky this dark or darker (the mean lightness of its top and bottom, sRGB 0–1) is night, and one this light or lighter is day.
0.18DAY_SKYvalue
See NIGHT_SKY.
0.42MOONLIGHTvalue
What a night's light multiplies every tone by (linear): dim and blue, as moonlight is painted.
readonly [number, number, number]nightOf()function
How much a sky (top and bottom, sRGB 0–255) is a night's: 0 by day, 1 at night, between at dusk.
nightOf(sky: readonly [readonly number[], readonly number[]]): numbernightLight()function
What cel shading's tones are multiplied by under a sky that much a night's (CelLook.ambient): nothing by day, MOONLIGHT at night.
nightLight(night: number): [number, number, number]Blocks, as settings
BLOCKSvalue
The chip beside the drawn looks (brushLooks.ts).
{ id: "blocks"; label: string; note: string }BlockChoiceinterface
What the page's controls make.
Properties
sizenumberA block's side, in cells of the grid the subject was cut on.
turnnumberWhere the light is, in degrees round the subject from the starting view.
heightnumberHow high the light stands, in degrees.
shadowsbooleanWhether blocks cast shadows on each other.
cornersnumberHow dark the corners where blocks meet are, 0 to 1.
varynumberHow much a block's color differs from the next, 0 to 1.
edgenumberHow strong the line round each face is, 0 to 1.
backdropstringWhat stands behind: 'scene' for the subject's own sky, or a plain color (
BLOCK_GROUNDS); '' is the subject's own sky where it has one, else daylight.water"blobs" | "blocks"A subject's water: columns of blocks that rise and fall, or the blobs it is among the cubes.
weather"blobs" | "blocks"Weather over the subject (clouds, rain, snow): cubes as the scene is, or the soft blobs it is in the other styles.
swellnumberHow many times higher than it stands a ripple is drawn as blocks.
palettestringThe palette the blocks are painted from: 'none' keeps each block's own color, 'own' is the scene's, else a shared one (Diorama's
PALETTES).
BLOCK_STARTvalue
Where the Blocks style's settings start.
BlockChoiceBLOCK_GROUNDSvalue
What to stand in front of when it is not the subject's own sky: daylight, or a plain color. The time of day is the scene's own setting (timeOfDay.ts), not this look's: it reaches here as the subject's sky and the stage's light.
{ id: string; label: string; back: string }[]BlockBackinterface
What a choice of backdrop comes to: what goes behind the canvas and what light it gives (none is day's).
Properties
idstringWhich backdrop it is.
backstringWhat goes behind the canvas, as CSS.
lightreadonly [number, number, number]optionalThe light it gives; day's when left out.
blockBack()function
The backdrop for a choice. sky is the subject's own sky as CSS and how much it is a night's (nightOf()), where it has one: it is what an empty choice means, and under a dark one the light is a night's, unless the page has set a time of day (timed), whose light is already the stage's.
blockBack(choice: string, sky?: { back: string; night: number }, timed?: boolean): BlockBackSWELL_MOSTvalue
The most a ripple's height is multiplied by.
16BLOCK_SIZESvalue
The sizes on offer, in cells of the subject's grid.
{ min: number; max: number }BLOCK_SPANvalue
A subject cut on no grid gets blocks as if its longest side were this many cells.
96gridOf()function
The side of one cell for a subject: the grid the cut records (Built.grid, from voxel.ts), else the grid the page says it was cut on, else a share of its longest side. The cut's own grid comes first because it is the one the blobs stand on: a scene may be cut finer or coarser than its detail level (SceneDoc.grid, a room of big walls on 1.3), and blocks a cell smaller than the blobs' rows leave a row of empty cells between every two (Matt saw gaps between every block at size 1, 2026-11-29). A guessed cell falls between the rows the same way, so it is the last resort.
gridOf(spacing: number | undefined, centers: ArrayLike<number>, count: number, own?: number): numberblockLook()function
The look for the stage: grid is one cell's side, azimuth the starting view's turn, ambient a night's light.
blockLook(c: BlockChoice, grid: number, azimuth?: number, ambient?: readonly [number, number, number], palette?: readonly (readonly [number, number, number])[]): BlockLookNeon, as settings
NEONvalue
The chip beside the drawn looks (brushLooks.ts).
{ id: "neon"; label: string; note: string }NEON_GROUNDvalue
What neon stands on: near black, a little violet, as a night street.
"#06050b"NEON_SETSvalue
The tubes' colors: each thing's own at full strength, or a set dealt out part by part (sRGB 0–1).
{ id: string; label: string; colors?: readonly (readonly [number, number, number])[] }[]NEON_PACESvalue
How fast the light runs: the seconds a pulse takes to come round again, about (0 holds it still).
{ id: string; label: string; period: number }[]NeonChoiceinterface
What the page's controls make.
Properties
linenumberA tube's width, in CSS pixels.
glownumberHow strongly the tubes' light spreads.
bodynumberHow much of its own color a body keeps in the dark, 0 to 1.
setstringThe tubes' colors, an id of
NEON_SETS.pacestringHow fast the light runs, an id of
NEON_PACES.palettestringThe palette the scene is painted from before it is drawn: 'none' keeps its own colors, 'own' is the scene's, else a shared one.
NEON_STARTvalue
Where neon's settings start.
NeonChoiceperiodIn()function
The period nearest about seconds that goes a whole number of times into a loop of loop seconds, so a recorded loop joins up; about itself where nothing loops.
periodIn(about: number, loop?: number): numberneonLook()function
The look for the stage. Under reduced motion the light holds still.
neonLook(c: NeonChoice, loop?: number, still?: boolean): NeonLookStained glass, as settings
GLASSvalue
The chip beside the drawn looks (brushLooks.ts).
{ id: "glass"; label: string; note: string }GLASS_GROUNDvalue
What shows before the window is drawn: the lead's own color.
"#121010"GLASS_FILLSvalue
How many flat colors each part's own are gathered into (gatherColors()) before it is glazed.
2GlassChoiceinterface
What the page's controls make.
Properties
panenumberA pane's size, as a share of the whole scene.
leadnumberThe lead's width, in CSS pixels.
shinenumberHow strong the light behind the window is, 0 to 1.
varynumberHow much one pane's glass differs from the next, 0 to 1.
palettestringThe palette the scene is painted from before it is drawn: 'none' keeps its own colors, 'own' is the scene's, else a shared one.
GLASS_STARTvalue
Where stained glass's settings start.
GlassChoiceglassLook()function
The look for the stage; sky is the subject's own, top and bottom (sRGB 0–255), where it has one.
glassLook(c: GlassChoice, sky?: readonly [readonly number[], readonly number[]]): GlassLookWatercolor, as settings
WASHvalue
The chip beside the drawn looks (brushLooks.ts).
{ id: "watercolor"; label: string; note: string }WASH_PAPERSvalue
The papers a wash can be laid on (sRGB 0–1). All light: paint only darkens what is under it.
{ id: string; label: string; paper: readonly [number, number, number] }[]WashChoiceinterface
What the page's controls make.
Properties
bleednumberHow far a wash's edge wanders over the paper, in CSS pixels.
poolnumberHow much darker paint gathers where a wash ends, 0 to 1.
grainnumberHow much the paper's tooth shows, 0 to 1.
strengthnumberHow much paint is laid on, 0 to 1.
pencilnumberHow strong the pencil line is, 0 for none.
paperstringThe paper, an id of
WASH_PAPERS.borderbooleanWhether a border of bare paper is left round the wash behind the subject.
palettestringThe palette the scene is painted from before it is drawn: 'none' keeps its own colors, 'own' is the scene's, else a shared one.
WASH_STARTvalue
Where watercolor's settings start.
WashChoicewashGroundvalue
The color to put behind the canvas before the paper is drawn.
(c: WashChoice) => stringWASH_SKY_COLORSvalue
The wash behind a subject with no sky of its own, top and bottom (sRGB 0–1): a pale blue going warm toward the ground, so the paper still has a painted sky on it (Matt, 2026-11-22: bare paper read as no background at all).
readonly [readonly [number, number, number], readonly [number, number, number]]washLook()function
The look for the stage; sky is the subject's own, top and bottom (sRGB 0–255), or WASH_SKY_COLORS where it has none.
washLook(c: WashChoice, sky?: readonly [readonly number[], readonly number[]]): WashLookHalftone print, as settings
HALFTONEvalue
The chip beside the drawn looks (brushLooks.ts).
{ id: "halftone"; label: string; note: string }HALFTONE_SETSvalue
The sets of inks a print can be made in. Black takes the grays first where a set has it.
{ id: string; label: string; about: string; inks: HalftoneInk[] }[]HALFTONE_PAPERSvalue
The papers a print can be pulled on (sRGB 0–1). All light: ink only darkens what is under it.
{ id: string; label: string; paper: Rgb01 }[]HalftoneChoiceinterface
What the page's controls make.
Properties
inksstringThe inks, an id of
HALFTONE_SETS.cellnumberA cell of the screen, in CSS pixels.
shiftnumberHow far each plate sits off true, in CSS pixels.
texturenumberHow unevenly the ink takes, 0 to 1.
paperstringThe paper, an id of
HALFTONE_PAPERS.skybooleanWhether the subject's sky is printed behind it, or the paper left bare there.
palettestringThe palette the scene is painted from before it is printed: 'none' keeps its own colors, 'own' is the scene's, else a shared one.
HALFTONE_STARTvalue
Where halftone's settings start.
HalftoneChoicehalftoneGroundvalue
The color to put behind the canvas before the print is drawn.
(c: HalftoneChoice) => stringHALFTONE_SKYvalue
The sky printed behind a subject with no sky of its own, top and bottom (sRGB 0–1): a pale blue going warm toward the ground.
readonly [Rgb01, Rgb01]halftoneLook()function
The look for the stage; sky is the subject's own, top and bottom (sRGB 0–255), or HALFTONE_SKY where it has none.
halftoneLook(c: HalftoneChoice, sky?: readonly [readonly number[], readonly number[]]): HalftoneLookThe six filter looks, as settings
CLAYvalue
Claymation's chip beside the drawn looks (brushLooks.ts).
{ id: "clay"; label: string; note: string }BLUEPRINTvalue
The blueprint's chip.
{ id: "blueprint"; label: string; note: string }THERMALvalue
The thermal camera's chip.
{ id: "thermal"; label: string; note: string }CUTOUTvalue
Paper cutout's chip.
{ id: "cutout"; label: string; note: string }MOSAICvalue
The mosaic's chip.
{ id: "mosaic"; label: string; note: string }CRTvalue
CRT / VHS's chip.
{ id: "crt"; label: string; note: string }FILTERSvalue
All six, in the order the Style tab lists them.
readonly [{ id: "clay"; label: string; note: string }, { id: "blueprint"; label: string; note: string }, { id: "thermal"; label: string; note: string }, { id: "cutout"; label: string; note: string }, { id: "mosaic"; label: string; note: string }, { id: "crt"; label: string; note: string }]FilterIdtype
Which of them.
typeof FILTERS[number]["id"]isFiltervalue
Whether a style is one of them.
(id: string | undefined) => id is FilterIdTHERMAL_RAMPSvalue
The heat colors a thermal camera can show, cold to hot (sRGB 0–1).
{ id: string; label: string; about: string; ramp: Rgb01[] }[]ThermalChoiceinterface
What the page's controls make.
Properties
colorsstringThe heat colors, an id of
THERMAL_RAMPS.hotnumberHow hot what gives its own light runs, 0 to 1.5.
spreadnumberHow far its heat spreads, in CSS pixels.
warmnumberHow warm lit things are.
noisenumberThe sensor's grain.
palettestringA palette whose colors, darkest to lightest, are the heat colors in place of
colors: 'none' keeps the camera's own.
THERMAL_STARTvalue
Where the thermal camera's settings start.
ThermalChoicethermalLook()function
The look for the stage; palette is the palette picked (sRGB 0–255), if any.
thermalLook(c: ThermalChoice, palette?: readonly (readonly number[])[], still?: boolean): ThermalLookthermalGroundvalue
The color behind the canvas before the camera's picture is drawn.
(c: ThermalChoice) => stringCrtChoiceinterface
What the page's controls make.
Properties
scannumberHow dark the gaps between scanlines are.
everynumberHow tall a scanline is, in CSS pixels.
bleednumberHow far color smears.
wobblenumberHow much rows wander and the tracking band rolls.
noisenumberTape noise.
curvenumberHow much the glass bulges.
palettestringThe palette the scene is painted from first: 'none' keeps its own colors, 'own' is the scene's, else a shared one.
CRT_STARTvalue
Where CRT / VHS's settings start.
CrtChoicecrtLook()function
The look for the stage; sky is the subject's own, top and bottom (sRGB 0–255); loop the seconds it comes round in.
CRT_GROUNDvalue
The color behind the canvas: the screen's black.
"rgb(0 0 0)"BLUEPRINT_PAPERSvalue
The papers a blueprint can be drawn on, each with its lines (sRGB 0–1).
{ id: string; label: string; paper: Rgb01; ink: Rgb01 }[]BlueprintChoiceinterface
What the page's controls make.
Properties
paperstringThe paper and its lines, an id of
BLUEPRINT_PAPERS.linenumberThe outline's width, in CSS pixels.
innernumberHow strong the lines between parts are.
gridnumberHow far apart the grid's lines are, in CSS pixels (0 for none).
dimsbooleanWhether dimension lines are drawn.
fillnumberHow strongly the subject is washed in the line color.
palettestringA palette whose darkest color is the paper and lightest the lines, in place of
paper: 'none' keeps the paper's own.
BLUEPRINT_STARTvalue
Where the blueprint's settings start.
BlueprintChoiceblueprintColors()function
The paper and lines a blueprint is drawn in: the paper's own, or a palette's darkest and lightest (sRGB 0–255).
blueprintColors(c: BlueprintChoice, palette?: readonly (readonly number[])[]): { paper: Rgb01; ink: Rgb01 }blueprintLook()function
The look for the stage.
blueprintLook(c: BlueprintChoice, palette?: readonly (readonly number[])[]): BlueprintLookblueprintGroundvalue
The color behind the canvas: the paper.
(c: BlueprintChoice, palette?: readonly (readonly number[])[]) => stringMOSAIC_GROUTSvalue
The grouts a mosaic can be set in (sRGB 0–1).
{ id: string; label: string; color: Rgb01 }[]MosaicChoiceinterface
What the page's controls make.
Properties
tilenumberA tile's side, in CSS pixels.
groutnumberThe grout's width, in CSS pixels.
groutColorstringThe grout, an id of
MOSAIC_GROUTS.varynumberHow much tiles differ.
bevelnumberHow much each tile's edges catch light.
brickbooleanRows set like bricks.
skybooleanWhether the subject's sky is set behind it in tiles, or plain stone tiles.
palettestringThe palette the scene is painted from first: 'none' keeps its own colors, 'own' is the scene's, else a shared one.
MOSAIC_STARTvalue
Where the mosaic's settings start.
MosaicChoiceMOSAIC_SKYvalue
The sky set in tiles behind a subject with no sky of its own (sRGB 0–1).
Sky01mosaicLook()function
The look for the stage; sky is the subject's own, top and bottom (sRGB 0–255).
mosaicLook(c: MosaicChoice, sky?: Sky255): MosaicLookmosaicGroundvalue
The color behind the canvas: the grout.
(c: MosaicChoice) => stringCutoutChoiceinterface
What the page's controls make.
Properties
shadownumberHow far a layer's shadow falls, in CSS pixels.
softnumberHow soft the shadow is.
lightnumberWhere the light comes from on the screen, in degrees (0 from the right, 90 from above).
grainnumberThe paper's fibers.
edgenumberThe pale cut edge toward the light, in CSS pixels.
raggednumberHow ragged the cut edges are.
fillsnumberHow many flat colors each part's own are gathered into (each a sheet of paper).
skybooleanWhether the subject's sky is the card behind it, or plain card.
palettestringThe palette the paper is cut from: 'none' keeps its own colors, 'own' is the scene's, else a shared one.
CUTOUT_STARTvalue
Where paper cutout's settings start: Matt's defaults (2026-11-28).
CutoutChoicecutoutLook()function
The look for the stage; sky is the subject's own, top and bottom (sRGB 0–255).
cutoutLook(c: CutoutChoice, sky?: Sky255): CutoutLookcutoutGroundvalue
The color behind the canvas: the card.
(c: CutoutChoice, sky?: Sky255) => stringCLAY_RATESvalue
How fast claymation moves, as the page offers it.
{ id: number; label: string; about: string }[]ClayChoiceinterface
What the page's controls make.
Properties
fpsnumberFrames a second; 0 moves every frame.
printsnumberHow deep the thumbprints are.
sizenumberHow big a thumbprint is, as a share of the scene.
smoothnumberHow smooth the clay is.
sheennumberHow much the clay shines.
boilnumberHow much the thumbprints shift from frame to frame.
palettestringThe palette the clay is mixed from: 'none' keeps its own colors, 'own' is the scene's, else a shared one.
CLAY_STARTvalue
Where claymation's settings start.
ClayChoiceclayLook()function
The look for the stage; sky is the subject's own, top and bottom (sRGB 0–255). Under reduced motion it moves smoothly and the prints hold.
clayLook(c: ClayChoice, sky?: Sky255, still?: boolean): ClayLookclayGroundvalue
The color behind the canvas: the backdrop.
(sky?: Sky255) => stringKnitting, as settings
KNITvalue
The chip beside the drawn looks (brushLooks.ts).
{ id: "knit"; label: string; note: string }KNIT_SWEATERSvalue
The sweaters: each one's yarns (sRGB 0–1), the body's first, then the pattern's main yarn and its second, then the rest the picture is knitted in.
{ id: string; label: string; yarns: readonly (readonly [number, number, number])[] }[]KNIT_PATTERNSvalue
The patterns: each one's bands from the edge inward, ids of MOTIFS in knit.ts. A band too tall for the picture is left out.
{ id: string; label: string; bands: readonly string[] }[]KnitChoiceinterface
What the page's controls make.
Properties
sweaterstringThe sweater, an id of
KNIT_SWEATERS.patternstringThe pattern, an id of
KNIT_PATTERNS.stitchnumberA stitch's width, in CSS pixels.
snowbooleanSnow dots over the plain field.
KNIT_STARTvalue
Where knitting's settings start.
KnitChoiceknitGroundvalue
The color to put behind the canvas before the knitting is drawn: the sweater's body.
(c: KnitChoice) => stringknitLook()function
The look for the stage; steady 0 decides every frame afresh (for a frame drawn only when asked for).
knitLook(c: KnitChoice, steady?: number): KnitLook3D glasses, as settings
ANAGLYPHvalue
The chip beside the drawn looks (brushLooks.ts).
{ id: "anaglyph"; label: string; note: string }ANAGLYPH_MIX_CHOICESvalue
The mixes as the page offers them.
{ id: AnaglyphMix; label: string; about: string }[]AnaglyphChoiceinterface
What the page's controls make.
Properties
depthnumberHow deep it looks, as a share of the usual eyes.
popnumberHow far the screen stands behind what the view looks at, as a share of the distance to it.
mixAnaglyphMixHow the two pictures are mixed.
palettestringThe palette the scene is painted from before it is drawn: 'none' keeps its own colors, 'own' is the scene's, else a shared one.
ANAGLYPH_STARTvalue
Where 3D glasses' settings start.
AnaglyphChoiceanaglyphGroundvalue
The color to put behind the canvas before the picture is drawn (the pass covers it): the subject's sky where it has one, else the dark backdrop.
(sky?: readonly [readonly number[], readonly number[]]) => stringanaglyphLook()function
The look for the stage; sky is the subject's own, top and bottom (sRGB 0–255), which stands behind it at the screen.
anaglyphLook(c: AnaglyphChoice, sky?: readonly [readonly number[], readonly number[]]): AnaglyphLookTech glitch, as settings
GLITCHvalue
The chip in the Style tab, after pixel art: it is pixel art with bursts of corruption laid on.
{ id: "glitch"; label: string; note: string }GlitchChoiceinterface
What the page's controls make.
Properties
amountnumberHow often bursts come, 0 to 1.
strengthnumberHow hard a burst breaks the picture, 0 to 1.
jitterbooleanWhether bands of rows slide sideways.
splitbooleanWhether red and blue are read to either side.
blocksbooleanWhether blocks are taken from elsewhere in the picture.
pacenumberSteps a second.
seednumberWhich run of bursts.
GLITCH_STARTvalue
Where tech glitch's settings start.
GlitchChoiceGLITCH_AMOUNTSvalue
How often bursts come, by name.
{ id: string; label: string; amount: number }[]GLITCH_PACE_CHOICESvalue
The steps a second the page offers.
readonly [8, 12, 20]glitchLookvalue
The look for the stage. A scene's loop keeps it joined up; under reduced motion it never bursts.
(c: GlitchChoice, loop?: number, still?: boolean) => GlitchLookSimulation
The solvers under cloth, under sand, snow and goo, under the ripples of a pond, under lava, under a bubbling potion and under a fire, for when you want to step them yourself.
Cloth solver
A small position-based dynamics solver (XPBD, "small steps" form: many substeps, one pass over the constraints in each), for cloth and hair hung on a rig. Points carry an inverse mass (0 = pinned, moved by the caller); links keep two points at a length, goals pull a point toward where the animation puts it, and capsules push points out of the body. Compliance is the inverse of stiffness: 0 is rigid.
It always steps by STEP, carrying what's left of a frame to the next, so the same frames give the same motion and a recorded loop can be played back. Pure and tested.
Capsuleinterface
A segment from a to b with a radius; a and b the same is a ball.
Properties
STEPvalue
Seconds per step, and substeps per step.
numberSUBSTEPSvalue
Substeps the solver takes in each STEP.
4Xpbdclass
A small XPBD solver: points joined by links, pulled toward goals and kept out of capsules. It steps at a fixed STEP, carrying the rest of a frame over, so the same frames always give the same motion.
Constructor
new Xpbd(n: number)Properties
nnumberread onlyHow many points.
posFloat64Arrayread onlyPositions: x, y, z per point.
velFloat64Arrayread onlyVelocities: x, y, z per point.
invMassFloat64Arrayread onlyOne over each point's mass; 0 pins a point where it is.
goalFloat64Arrayread onlyWhere the animation puts each point, and how loosely it follows (Infinity: not at all).
capsulesCapsule[]The capsules the points stay out of. Set it each frame as the body moves.
gravityVec3The pull on every point, per second squared.
dampingnumberShare of velocity lost per second.
Methods
link()Keeps
aandbatrest(their distance now if not given).link(a: number, b: number, compliance?: number, rest?: number): voiddistance()How far apart two points are now.
distance(a: number, b: number): numberplace()Puts point
iatp, still.place(i: number, p: ArrayLike<number>): voidfix()Pins point
i: from now on it moves only wherepinsends it.fix(i: number): voidpin()Where pinned point
ishould be at the end of the nextadvance; it gets there evenly over the frame.pin(i: number, p: ArrayLike<number>): voidfollow()Where the animation wants point
i, and how loosely it follows.follow(i: number, p: ArrayLike<number>, compliance: number): voidadvance()Runs whole steps for
dtseconds (carrying the rest); returns how many ran.advance(dt: number): numberenergy()Kinetic energy, for a unit mass per free point.
energy(): numbersettle()Every point still, where it is (after a jump, say).
settle(): void
closestOnSegment()function
The point on segment a–b nearest (x, y, z).
Sand, snow and goo
Materialtype
What a particle is made of.
"sand" | "snow" | "goo"MATERIALSvalue
Every Material.
readonly Material[]MpmOptionsinterface
Options for an Mpm box.
Properties
cellsnumberoptionalGrid cells a side.
capacitynumberoptionalMost particles it can hold.
dtnumberoptionalSeconds per substep: left out, as long as the grid's cell size allows.
gravitynumberoptionalDownward pull, box sides per second squared.
knobsPartialKnobsoptionalHow each material behaves; what is left out comes from
KNOBS.
Knobsinterface
How each material behaves: the settings a visitor can change while it runs (Mpm.set).
Properties
sand{ friction: number; damp: number }Sand: grains that can't pull on each other.
snow{ stick: number; pack: number }Snow: grains that hold on to each other, break in clumps and pack down.
goo{ thick: number; hold: number }Goo: keeps its volume, not its shape.
PartialKnobstype
Some of Knobs: any material, any of its settings.
{ [M in Material]?: Partial<Knobs[M]> }KNOBSvalue
What each material starts as.
KnobsPER_CELLvalue
Particles per cell a side when filling a shape.
2Mpmclass
A box of sand, snow and goo: a small 3D material point simulation (MLS-MPM) on the CPU. Put particles in with add or fillBox, then move time on with advance.
Constructor
new Mpm(o?: MpmOptions)Properties
nnumberread onlyGrid cells a side.
dxnumberread onlyA cell's size: the box is 1 a side.
capacitynumberread onlyThe most particles it can hold.
dtnumberSeconds per substep.
gravitynumberDownward pull, box sides per second squared.
countnumberHow many particles are in the box.
xFloat64Arrayread onlyParticle state.
tauFloat64Arrayread onlyKirchhoff stress from the last step's F, so each step needs one decomposition.
JpFloat64Arrayread onlyHow well each snow particle still holds on to its neighbors: 1 as it fell, less where it has cracked, more where it was pressed.
packedFloat64Arrayread onlyHow far each snow particle has been packed down for good, as log volume lost.
matUint8Arrayread onlyWhich material each particle is, as an index into
MATERIALS.gvFloat64Arrayread onlyGrid: velocity (momentum while scattering) and mass.
timenumberSeconds simulated so far.
floorGripnumberHow much the floor grips what slides on it: 0 is ice.
solidsSolid[]read onlySolid things in the box: fixed ones the material piles on, and bodies it pushes about. Add with
addSolid.floornumberread onlyThe height material rests at on the floor: a cell and a half up, where the grid's own floor holds it.
lonumberread onlyWhere the near walls hold material: x and z stay above this.
hinumberread onlyWhere the far walls hold material: x and z stay under this.
Methods
set()Changes how the materials behave, from now on: any material, any of its settings.
set(k: PartialKnobs): voidaddSolid()Puts a solid in the box. Particles already inside it are pushed out over the next steps.
removeSolid()Takes a solid out of the box, or every solid when none is named.
removeSolid(s?: Solid): voidadd()Adds one particle, still and unstrained. Returns false when full.
add(p: ArrayLike<number>, m: Material, vel?: ArrayLike<number>): booleanfillBox()Fills a box (corners in box units) with particles on a jittered lattice,
PER_CELLa cell a side. Returns how many went in. Withinside, only where it says yes, so the box can hold any shape.fillBox(lo: ArrayLike<number>, hi: ArrayLike<number>, m: Material, seed?: number, vel?: ArrayLike<number>, inside?: (x: number, y: number, z: number) => boolean): numberpoke()Pushes everything within
rofatbyv(box sides a second) on the next step.poke(at: [number, number, number], r: number, v: [number, number, number]): voidclear()Empties the box.
clear(): voidgridMass()Total mass on the grid after the last scatter, for tests.
gridMass(): numberadvance()Runs whole substeps for
seconds.advance(seconds: number): voidstep()Moves the box on by one substep of
dt.step(): void
svd3()function
Singular values of a 3×3 (row-major) with U and V both rotations: F = U diag(s) V^T. A reflection shows as a negative last singular value. Jacobi on F^T F for V, then U's columns from F V.
svd3(f: ArrayLike<number>, u: Float64Array, s: Float64Array, v: Float64Array): voidslopeOf()function
How steep a heap stands: the angle in degrees from the floor up its side, from where its height falls from 80% to 20% of the top.
slopeOf(sim: Mpm, material?: number): numberSolids for sand, snow and goo
SolidOptionsinterface
Options for a Solid.
Properties
atVec3optionalWhere its middle starts (a body), in the simulation's units.
densitynumberoptionalIts weight for its size, against the material's 1. Left out or 0, it is fixed in place and its shape is read where it is.
frictionnumberoptionalHow much it grips what slides on it: 0 is ice.
cornersVec3[]optionalPoints on its surface to meet the world with, on top of the ones found for it (a cube's corners).
velocityVec3optionalIts starting speed.
roundnumberoptionalFor a ball: its radius. It then meets the world at the exact point under it, not at the nearest of its surface points, so it rolls instead of rocking.
Roominterface
What a body can run into besides the material: the floor, the four walls and the fixed solids.
Properties
floornumberThe floor's height.
lonumberThe near walls: x and z stay above this.
hinumberThe far walls: x and z stay under this.
gravitynumberDownward pull.
fixedSolid[]Fixed solids to stay out of.
Solidclass
A solid thing in a material simulation: fixed, or a rigid body with weight. Its shape is a distance function; a body's shape is given about its own middle and is carried by pos and quat.
Constructor
new Solid(shape: Shape, o?: SolidOptions)Properties
shapeShaperead onlyIts shape: for a body, about its own middle.
fixedbooleanread onlyWhether it stays put.
posFloat64Array<ArrayBuffer>read onlyWhere its middle is (a body).
quatFloat64Array<ArrayBuffer>read onlyHow it is turned (x, y, z, w).
velFloat64Array<ArrayBuffer>read onlyIts speed.
spinFloat64Array<ArrayBuffer>read onlyHow fast it turns, about each axis of the world.
massnumberread onlyIts mass: infinite when fixed.
volumenumberread onlyIts volume.
inertiaVec3read onlyIts resistance to turning about each of its own axes.
reachnumberread onlyNo part of it is further than this from its middle.
frictionnumberHow much it grips.
heldbooleanWhether the material was pressing on it in the last step.
asleepbooleanWhether it has come to rest: a sleeping body is fixed until something pushes it.
Methods
distance()How far a point of the world is from its surface: negative inside.
distance(x: number, y: number, z: number): numbernormal()The way out of it at a point of the world, as a unit vector written to
out.normal(x: number, y: number, z: number, out: number[] | Float64Array<ArrayBufferLike>): voidspeedAt()The speed of the point of it at
rfrom its middle, written toout.speedAt(rx: number, ry: number, rz: number, out: number[] | Float64Array<ArrayBufferLike>): voidkick()Pushes it at the point
rfrom its middle: a kickj(mass times change of speed). Wakes it.kick(rx: number, ry: number, rz: number, jx: number, jy: number, jz: number): voidwake()Wakes a sleeping body.
wake(): voidfall()Gravity for one step: call before the material has pushed on it.
fall(room: Room, dt: number): voidmove()Meets the floor, the walls and the fixed solids, then moves on by
dt: call after the material has pushed on it.heldsays the material is holding it up too, which lets it sleep where it lies.move(room: Room, dt: number, held?: boolean): voidturned()Works out
rotfromquat: call after settingquatby hand.turned(): void
solve6()function
Solves the 6×6 a x = b in place (row-major a), leaving the answer in b. Returns false when it can't.
solve6(a: Float64Array, b: Float64Array): booleanWater that ripples
Still water that moves when something moves through it: a pond as a grid of heights stepped by the wave equation, and the blobs that draw its surface.
Water is the pond itself, in plain numbers so it runs in Node tests. Each wet cell holds how far its surface stands above the level and how fast it is rising. A fixed tick moves every cell toward the mean of its neighbors, which is what makes a ring travel outward at speed; a dry cell gives its neighbor back its own height, so rings bounce off banks, steps and pillars. Nothing draws rings: a body that enters, leaves or wades through the water (body) pushes the water it displaces to the cells round it, and the rings are what the grid does with that.
makeSurface() lays flat blobs over the wet cells, shapeSurface() lifts and tilts each to the water under it, and shadeSurface() colors each from the view: clear looking straight down, a mirror of the sky at a low angle (Fresnel), with a glint where it throws the sun or a lamp at the eye.
WaterSpecinterface
A pond for Water: its grid, where its surface stands and where there is water at all.
Properties
x0numberThe grid's corner along x.
z0numberThe grid's corner along z.
nxnumberCells along x.
nznumberCells along z.
cellnumberA cell's side, in meters.
levelnumberThe height (y) the surface stands at when still.
wet(x: number, z: number) => booleanoptionalWhether there is water at a point. Left out, the whole grid is wet.
speednumberoptionalHow fast a ring travels, meters a second: 0.8 when left out.
dampingnumberoptionalHow quickly the water comes to rest: the share of its motion lost a second, 0.55 when left out.
WATER_TICKvalue
The water's fixed step, seconds: the same frames give the same water.
numberWATER_STILLvalue
Once every cell is within this of the mean height and moving slower than this (meters, meters a second), the water counts as still and isn't stepped.
0.00002BODY_SLACKvalue
How far a body must move (or grow) where it crosses the surface before the water is told, meters: a standing leg's sway is not a wave.
0.004Crossinginterface
Where a body crosses the water's surface: a disc.
Properties
xnumberThe disc's middle, along x.
znumberThe disc's middle, along z.
rnumberThe disc's radius.
crossing()function
Where a capsule from a to b of radius r crosses the level y: the disc it cuts out of the surface, or null when it is wholly above or below. A leg is such a capsule from knee to ankle.
crossing(a: ArrayLike<number>, b: ArrayLike<number>, r: number, y: number): Crossing | nullWaterclass
A pond: heights on a grid, stepped by the wave equation, moved by what wades through it.
Constructor
new Water(spec: WaterSpec)Properties
specRequired<Omit<WaterSpec, "wet">>read onlyThe pond's grid and level, with the defaults filled in.
hFloat32Arrayread onlyEach cell's height above the level, meters.
vFloat32Arrayread onlyEach cell's speed upward, meters a second.
wetUint8Arrayread only1 where a cell holds water.
wetCountnumberread onlyHow many cells hold water.
timenumberSeconds stepped so far.
versionnumberGoes up whenever the heights change, so a view knows to draw again.
stillbooleanread onlyWhether the water is at rest.
energynumberread onlyThe water's energy per wet cell, 0 at rest: its motion (speed squared) plus its tilt (the squared slope between neighbors, times the wave speed squared), which trade places as a wave passes. Waves keep it, damping spends it, and nothing but a body or a drop adds to it.
volumenumberread onlyHow much water stands above the level in all, cubic meters: what a body pushed aside is put back round it, so this stays 0.
Methods
index()The cell holding (x, z), or −1 off the grid.
index(x: number, z: number): numberwetAt()Whether there is water at (x, z).
wetAt(x: number, z: number): booleanroomAt()Whether every point within
rof (x, z) is water: room for a body that wide to stand.roomAt(x: number, z: number, r: number): booleanheightAt()The surface's height above the level at (x, z), blended between the four cells round it; 0 on dry ground.
heightAt(x: number, z: number): numberslopeAt()The surface's slope at (x, z): how much it rises per meter along x and along z. A dry neighbor counts as level with the cell, as it does to the waves.
slopeAt(x: number, z: number): [number, number]body()Tells the water where a body crosses its surface now (
at, fromcrossing(); null when it is out of the water or wholly under it).draftis how deep the body stands in the water there, meters: a leg on the bed takes the place of the whole column, so its draft is the water's depth. Where the body newly stands, the water it takes the place of (a disc of its radius,draftdeep, whatever the grid) is pressed out and put on the cells just round it; where it stood, the water comes back the same way. So stepping in raises a ring, wading pushes a wave ahead and leaves a trough behind, and stepping out lets the water fall back in.idnames the body from call to call.body(id: string, at: Crossing | null, draft?: number): voidpress()Presses on the surface for
dtseconds withpush, an upward pull a cell (meters a second a second; one a cell of the grid, wet or not): what wind does to water. Its mean over the wet cells is taken off first, so the water is pushed about, never made or lost.press(push: ArrayLike<number>, dt: number): voidrest()Lays the water flat and still at once, keeping what it knows of the bodies in it: for the start of a scene, where whoever stands in the pond has always stood there.
rest(): voidforget()Forgets every body, as when the scene is set again: the next
bodycall for each is a fresh entry.forget(): voiddrop()Lets a drop of
volumecubic meters fall at (x, z), spread over a radiusr: a raindrop, a pebble, a tap. Nothing if it lands on dry ground.drop(x: number, z: number, r: number, volume: number): voidsplash()The mark a small fast thing leaves where it hits: a crater
depthmeters deep and aboutracross with a raised rim, holding no water of its own (what the middle loses the rim gains). A raindrop is far smaller than a cell of the grid, but its splash is not; rain given asdrops of that size would fill the pond. Nothing on dry ground.splash(x: number, z: number, r: number, depth: number): voidrelax()Pulls the water toward a given surface where
weightsays, a share a call (0 leaves a cell alone, 1 sets it): each cell's height towardhand its speed upward towardv. Called once a tick along a stretch of open water, with the surface as waves coming in from beyond it would make it, this brings those waves in across the whole stretch and lets what comes back out run off instead of bouncing (a relaxation zone, as a wave tank's paddle and beach).relax(weight: Float32Array, h: Float32Array, v: Float32Array): voidstep()Moves the water on by
dtseconds, in whole ticks (what is left of a frame is carried to the next).step(dt: number): void
WaterSurfaceinterface
The blobs that draw a pond's surface, from makeSurface().
Plus everything in Actor.
Properties
atFloat32ArrayWhere each blob lies on the pond: x then z, a pair a blob.
sizeFloat32ArrayEach blob's size at rest, across the surface.
slopeFloat32ArrayThe surface's slope under each blob as
shapeSurface()last found it: along x then along z, a pair a blob.curveFloat32ArrayThe surface's curvature under each blob as
shapeSurface()last found it: the sum of its second derivatives along x and z, per meter (under zero at a crest).
WaterLookinterface
How a pond's surface looks, for shadeSurface(). Colors are linear RGB, 0 to 1.
Properties
bodyVec3The water's own color, seen looking straight down into it.
skyVec3What the surface mirrors: the sky overhead, or the dark over a night scene.
horizonVec3optionalThe sky low down, where it is lighter: a ripple tips the mirror between the two, which is most of how one is seen. The same as
skywhen left out.clearnumberHow solid it is looking straight down, 0 to 1: the rest of the way to 1 comes with the angle.
sun{ toward: Vec3; color: Vec3; glow?: number }optionalThe way to the sun (or moon), and its color: the surface glints where it throws it at the eye.
glowis the share of that color the sky round it holds, fading over about a sixth of the sky; none when left out.glossnumberoptionalHow tight a glint is: 120 when left out. Lower spreads it into a sheen.
mirrorMirrorImage | nulloptionalWhat the surface mirrors of the scene round it: a picture from
SplatMirrorfor this pond's level. Where the picture shows something, the surface mirrors that and not the sky; a ripple tips the mirrored line of sight, so reflections wobble and break up. Left out, it mirrors the sky alone.reachnumberoptionalHow far off the things mirrored are taken to stand, meters, when a ripple tips the line of sight: farther makes reflections wobble more. 1.5 when left out.
steepnumberoptionalHow many times steeper than it is the surface is drawn and lit, so ripples a few millimeters high read from across a scene: 1 when left out.
deepnumberoptionalHow deep the water is taken to be, meters, for the light its surface gathers: a crest is a lens that draws the light passing down through it together on the bed and a trough spreads it, so the water's own color is brighter under crests and darker under troughs. It is what shows a ripple from above, where the surface mirrors almost nothing.
steepcounts here too. None when left out.
makeSurface()function
Flat blobs over every wet cell of a pond, per to a cell (2 when left out), on one still bone: the surface that shapeSurface() moves and shadeSurface() colors. The count never changes afterward.
makeSurface(water: Water, options?: { per?: number; seed?: number }): WaterSurfaceshapeSurface()function
Lifts each blob of a surface to the water under it and tilts it to the water's slope there. Call after the water moved, then hand the surface to SplatWorld.reshape.
shapeSurface(s: WaterSurface, water: Water, steep?: number): voidGATHER_LEASTvalue
The least and most light a ripple leaves or gathers on the bed, as a share of flat water's: past these the rays have crossed, and the thin-lens sum no longer holds.
0.45GATHER_MOSTvalue
The least and most light a ripple leaves or gathers on the bed, as a share of flat water's: past these the rays have crossed, and the thin-lens sum no longer holds.
2.6gathered()function
How much light reaches the bed under a point of the surface, as a share of what flat water lets through, from the surface's curvature there (the sum of its second derivatives, per meter: under zero at a crest). Light from above bends toward the normal by (n − 1) / n of its tilt (a quarter, for water), so a patch of surface lights a patch of bed 1 + deep · curvature / 4 times as wide each way together. 1 for a look with no deep.
gathered(curve: number, look: Pick<WaterLook, "deep" | "steep">): numbersurfaceColor()function
What a point of the surface sends to an eye: its color (linear) and how solid it is. Clear and its own color seen from above, more of a mirror of the sky the lower the angle (Schlick's Fresnel for water), plus a glint where the mirrored line of sight runs at the sun or at a lamp. Pure, so tests can ask it.
surfaceColor(p: Vec3, normal: Vec3, eye: ArrayLike<number>, look: WaterLook, lights?: readonly PointLight[]): { color: Vec3; opacity: number }shadeSurface()function
Colors every blob of a surface for an eye at eye (surfaceColor()), on the slopes shapeSurface() last left. Call when the water (after shapeSurface()) or the view moved, then hand the surface to SplatWorld.reshape or recolor.
shadeSurface(s: WaterSurface, look: WaterLook, eye: ArrayLike<number>, lights?: readonly PointLight[]): voidLava that flows
Lava that moves (a scene's lava, sceneDoc.ts): a shared recipe, as the water is. The pool's surface is the water's own height field (water.ts), run slow and thick, so a bursting bubble sends out a sluggish swell that dies within a few hands' breadth. Over it lies a field of heat, carried by the way molten rock turns over in a pool:
- hot rock wells up at
vents(each wandering slowly round its spot, a whole number of times a loop) and spreads out over the surface from there, meeting the spread from the next vent along lines where the crust piles up; - the surface loses heat as it goes (
coolseconds to fall to a third), so it dims from white-hot through orange and red to a dark crust the farther it has traveled; - the crust is carried as plates: every cell remembers where its rock came from (
ox,oz, moved along with the heat), and a cellular pattern laid on those first places draws the cracks between plates, which glow faintly while the crust is thin and stretch as the plates are pulled apart; - bubbles of gas break through at hashed places and times: each leaves a crater in the height field and a patch of fresh hot rock.
Everything is a function of the plan and the time, stepped at a fixed rate, so the same plan gives the same lava. SceneWater runs it through the loop with the heights and keeps a glow a cell per moment.
LavaVentinterface
A vent where hot rock wells up: round (x, z), r across (half), wandering wander round that spot times a loop from phase.
Properties
xnumberIts middle, along x.
znumberIts middle, along z.
rnumberHalf its width.
wandernumberHow far it wanders from its middle.
timesnumberHow many times a loop it goes round.
phasenumberWhere in its round it starts, 0 to 1.
LavaBubbleinterface
A bubble bursting at (x, z), at seconds into the loop, r across (half).
Properties
xnumberWhere it bursts, along x.
znumberWhere it bursts, along z.
atnumberWhen it bursts, seconds into the loop.
rnumberHalf its width.
LavaPlaninterface
A scene's lava as compiled (WaterPlan.lava).
Properties
coolnumberSeconds for the surface to lose two thirds of its heat.
flownumberHow fast the surface moves out from a vent's edge, units a second.
platenumberHow big the crust's plates are, units across.
ventsLavaVent[]Where hot rock wells up.
bubblesnumberHow many bubbles burst a loop, and how wide one is (half). Where they burst is drawn from the wet cells (
planBubbles()).popnumberHalf the width of a bubble.
LavaGridinterface
The grid the lava lies on: the pool's own (water.ts WaterSpec and its wet cells).
Properties
nxnumberCells along x.
nznumberCells along z.
x0numberWhere the grid starts, along x.
z0numberWhere the grid starts, along z.
cellnumberA cell's side.
wetUint8Array1 for each cell that holds lava, row by row.
lavaHash()function
A number from 0 to 1 for a whole number, the same everywhere.
lavaHash(i: number): numberventAt()function
Where a vent stands t seconds into a loop of loop.
ventAt(v: LavaVent, t: number, loop: number): [number, number]crackAt()function
How near (x, z) lies to a crack between the crust's plates, 0 (in a plate) to 1 (on the crack): the plates are the cells nearest each of a jittered grid of points plate apart (as stained glass's panes), and a crack runs where the nearest two are nearly as near.
crackAt(x: number, z: number, plate: number): numberglowOf()function
How brightly a cell glows, 0 (cold crust) to 1 (white-hot), from its heat (0 to 1) and how near it lies to a crack between plates (0 to 1): fresh rock glows as it is, and a crack in the crust glows dull red, brighter where the crust round it is still thin.
glowOf(heat: number, crack: number): numberlavaColor()function
The color of lava glowing g (0 to 1) along the ramp (sRGB, as blobs hold colors): crust to 0.3, dull red to 0.62, orange to 1, white-hot at 1.
planBubbles()function
Every bubble that bursts in one loop of loop seconds, count of them at wet places of the grid, from seed.
planBubbles(grid: LavaGrid, loop: number, count: number, r: number, seed?: number): LavaBubble[]LavaHeatclass
The heat over a lava pool and where each cell's rock first came up: stepped by step, read by glow. The pure half of the lava, worked on typed arrays, so Node tests run it as the page does.
Constructor
Properties
heatFloat32Arrayread onlyEach cell's heat, 0 (cold) to 1 (just welled up).
oxFloat32Arrayread onlyWhere each cell's rock first came up, x then z, for the crust's plates.
ozFloat32Arrayread onlyWhere each cell's rock first came up, along z.
uFloat32Arrayread onlyThe surface's way of moving at each cell as last worked out, units a second.
wFloat32Arrayread onlyThe surface's speed along z at each cell, units a second.
bubblesLavaBubble[]read onlyEvery bubble that bursts in the loop, in order.
gridLavaGridread onlyThe grid it lies on.
planLavaPlanread onlyThe plan it runs.
loopnumberread onlySeconds before it all repeats: the scene's loop.
Methods
flowAt()The way the surface moves at
t: out from every vent (as fast asflowat its edge, fading past it), and never into the bank, so the crust piles up along the shore and where two vents' spreads meet.flowAt(t: number): voidstep()Moves the lava on
dtseconds tot + dt: the surface carries its heat and its first places along (each cell takes what was upstream of it), it cools, the vents fill with fresh rock, and every bubble due bursts (burstis told, to mark the height field). Bubbles are taken in loop order; callrewindwhen the loop starts again.step(dt: number, t: number, burst?: (b: LavaBubble) => void): voidrewind()Starts the loop's bubbles again from the first: call as each run through the loop starts.
rewind(): voidglow()How brightly each cell glows now (
glowOf()its heat and its crack), intooutfrom offsetat: 0 to 1 in a float array, 0 to 255 in bytes; 0 on dry cells.glow(out: Float32Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike>, at?: number): voidmeanGlow()The mean glow over the wet cells, 0 to 1: how much light the pool gives off now.
meanGlow(): number
Water that freezes
Water that freezes when it snows (Matt, 2026-12-04: "can we figure out freezing simulated water so that when it snows, the snow can pile on it"). A shared recipe: every scene with water has it, and nothing is written a scene.
IceField holds how frozen each cell of a pond's grid is, 0 (open water) to 1 (ice that carries snow), and steps it by the clock from how much snow falls. Ice starts where water touches something colder than itself, a bank or a thing standing in it, and grows out from there cell by cell: a cell freezes only beside a bank or a neighbor that is mostly ice, at ICE_FRONT units a second in heavy snow, slower the deeper the water under it (ICE_DEEP), and the water's own warmth works against it by its depth (ICE_WARMTH). So a puddle is ice in a quarter of a minute, a pond in a minute or two from its rim inward, and a sea keeps to a shelf along its shore: light snow freezes only the shallows. Nothing freezes within reach of a warm light (warm), which keeps a hole open. When the snow stops the same field runs backward: it thaws from the deep middle out, the rim last.
It is plain numbers, so it runs in Node tests. SceneWater owns one (SceneWater.ice), stills its waves by it and hands it to whatever draws the surface; snowCover.ts lays snow over the cells it has frozen.
ICE_FRONTvalue
How fast the edge of the ice moves out from a bank over shallow water in heavy snow, in scene units a second.
0.012ICE_DEEPvalue
The depth of water that halves how fast it freezes, in scene units.
0.08ICE_WARMTHvalue
How fast the warmth of deep water melts ice from under, a second: what keeps a sea open past its shore.
0.06THAW_SECONDSvalue
How many seconds shallow ice takes to thaw once no snow falls (deeper water thaws sooner).
40ICE_HOLDSvalue
How frozen a cell must be before the cell beside it starts to freeze, and before snow lies on it.
0.6ICE_SETTLEDvalue
The seconds of freezing a scene drawn off screen is given at once (a still or a check, where no clock runs).
240IceGridinterface
What an IceField is laid over: a pond's grid.
Properties
nxnumberCells along x.
nznumberCells along z.
x0numberThe grid's corner along x.
z0numberThe grid's corner along z.
cellnumberA cell's side.
wetArrayLike<number>Which cells hold water: 1 for wet.
IceOptionsinterface
What a field is told about its pond beyond the grid.
Properties
depth(x: number, z: number) => numberoptionalHow deep the water is at a point, in scene units (asked a few times a cell at most; left out, shallow everywhere).
stands(x: number, z: number) => booleanoptionalWhether something stands out of the water at a dry point (a bank, a rock, a post), which ice starts from. Left out, every dry cell inside the grid does. The grid's own edge never does: past it a sea goes on.
warmreadonly { at: readonly number[]; reach: number }[]optionalWarm lights over the water (
warmthOf()): nothing freezes withinreachof one, and ice there melts.levelnumberoptionalThe height of the water's surface, for the distance to a warm light (0 left out).
chillOfvalue
How much a snowfall of snow (0 to 1) chills water: by its square, as snow lying builds (pileStep()).
(snow: number) => numberIceFieldclass
How frozen each cell of a pond is, stepped by the clock: see the top of this file.
Constructor
new IceField(grid: IceGrid, options?: IceOptions)Properties
iceFloat32Arrayread onlyHow frozen each cell is, 0 to 1 (0 in dry cells).
versionnumberGoes up each time
icechanges.depthFloat32Arrayread onlyHow deep the water is under each cell.
shoreUint8Arrayread only1 for a wet cell beside a bank or something standing in the water.
keptUint8Arrayread only1 for a wet cell a warm light keeps open.
Methods
at()How frozen the water is at a point, 0 where there is none.
at(x: number, z: number): numbercellAt()The cell of the grid a point lies in when it is water, -1 otherwise.
cellAt(x: number, z: number): numberstep()Moves the field on
dtseconds under a snowfall ofsnow(0 to 1; 0 thaws it). Returns whether anything changed.step(snow: number, dt: number): booleansettle()The field as it stands after
secondsof a snowfall ofsnowfrom open water, all at once: for a picture drawn with no clock running. Asked again for the same snow and time it does nothing. Returns whether anything changed.settle(snow: number, seconds?: number): boolean
A potion that brews
A potion that brews (a scene's potion, sceneDoc.ts): a shared recipe, as water and lava are. Its surface is the water's own height field (water.ts), a little thicker than water, in a round pool (a cauldron, a bowl, a well). Over it lie two fields carried by the way the brew turns:
dye, 0 to 1, how much of the potion's second color a cell holds: the brew is stirred round the middle (stirturns a loop, faster partway out than at the middle or the wall, as a stirred pot goes) with a few small eddies wandering round it, so the two colors are drawn out into spirals and marbled;fizz, 0 to 1, froth: where a bubble breaks, a ring of froth is left that the turning carries off and that fades overfizzLifeseconds.
Bubbles come up at hashed places and times: each swells the surface into a dome over rise seconds (laid on the heights as they are shown, domeAt), then pops, leaving a crater in the height field whose rings run out over the pool, a patch of the color from below (one or the other by a hash, so the marbling is fed fresh streaks) and froth.
Everything is a function of the plan and the time, stepped at a fixed rate, so the same plan gives the same brew. SceneWater runs it through the loop with the heights and keeps the two fields a byte a cell per moment.
PotionEddyinterface
A small eddy that wanders round the pool: at a share of its radius out, going round times a loop from phase, turning the brew round itself one way or the other.
Properties
outnumberHow far out from the middle it goes round, a share of the pool's radius.
timesnumberHow many times a loop it goes round the pool.
phasenumberWhere in its round it starts, 0 to 1.
spin-1 | 1Which way it turns the brew: 1 with the stir, −1 against it.
PotionPlaninterface
A scene's potion as compiled (WaterPlan.potion).
Properties
xnumberThe pool's middle, along x.
znumberThe pool's middle, along z.
rnumberThe pool's radius.
stirnumberHow many times a loop the brew is stirred round (a whole number; under 0 the other way).
eddiesPotionEddy[]Small eddies wandering round in it.
bubblesnumberHow many bubbles break a loop.
popnumberHalf the width of a bubble.
risenumberSeconds a bubble swells before it pops.
domenumberHow high a bubble's dome stands just before it pops.
fizzLifenumberSeconds froth takes to fade to a third.
ramp[Vec3, Vec3, Vec3, Vec3]Its colors (sRGB, 0 to 1 as blobs hold them): deep (in the hollows), its own, its second (marbled through it), froth.
glownumberHow brightly it glows, 0 (not at all, lit like anything else) to 1.
eddyAt()function
Where an eddy stands t seconds into a loop of loop, in a pool round (x, z) of radius r.
eddyAt(e: PotionEddy, p: Pick<PotionPlan, "x" | "z" | "r">, t: number, loop: number): [number, number]stirSpeed()function
How fast the stirred brew goes round at d from the middle of a pool of radius r, units a second (along the way round, with the stir): still at the middle and at the wall, fastest a little over halfway out, and on average going round stir times a loop.
stirSpeed(d: number, r: number, stir: number, loop: number): numberdomeShape()function
Where a dome stands over a bubble about to pop, as a share of its full height at d from the bubble's middle, u of the way through its swelling (0 to 1): it grows wider and taller together, round on top.
domeShape(d: number, r: number, u: number): numberpotionColor()function
The color of a point of potion (sRGB, 0 to 1): dye of the second color in its own, shade from −1 (deep, in a hollow) to 1 (lit, on a crest), fizz of froth.
PotionMixclass
The dye and froth over a potion's pool: stepped by step, read by write. The pure half of the potion, worked on typed arrays, so Node tests run it as the page does.
Constructor
new PotionMix(grid: LavaGrid, plan: PotionPlan, loop: number)Properties
dyeFloat32Arrayread onlyHow much of the second color each cell holds, 0 to 1.
fizzFloat32Arrayread onlyHow much froth lies on each cell, 0 to 1.
uFloat32Arrayread onlyThe brew's way of moving at each cell as last worked out, along x, units a second.
wFloat32Arrayread onlyAlong z.
bubblesLavaBubble[]read onlyEvery bubble that breaks in the loop, in order.
gridLavaGridread onlyThe grid it lies on.
planPotionPlanread onlyThe plan it runs.
loopnumberread onlySeconds before it all repeats: the scene's loop.
Methods
flowAt()The way the brew moves at
t: round with the stir, round each eddy, and never into the wall.flowAt(t: number): voidstep()Moves the brew on
dtseconds tot + dt: the turning carries the dye and froth along (each cell takes what was upstream of it), froth fades, and every bubble due pops (burstis told, to mark the height field). Bubbles are taken in loop order; callrewindwhen the loop starts again.step(dt: number, t: number, burst?: (b: LavaBubble) => void): voidrewind()Starts the loop's bubbles again from the first: call as each run through the loop starts.
rewind(): voidwrite()Writes the dye then the froth of every cell, 0 to 255, into
outfromat(two blocks of a cell each).write(out: Uint8Array, at?: number): void
Fire that burns
Fire that burns (a scene's fires, sceneDoc.ts): a shared recipe, as the water and the lava are. Nothing here is a flame shape that is scaled and swayed: it is hot gas rising through air, worked out on a small grid over the bed.
- Fuel burns at
spots()on the bed (each waxing and waning a whole number of times a loop, as logs catch and die back), which heats the air there. - Hot air is lighter, so it is pushed up (
BUOYANCYtimes its heat), and the air it leaves behind is replaced from the sides: the flow is kept free of sources and sinks each tick (project), which is what draws air in low down, necks the plume above the bed and rolls its edges over into the licks and curls a flame has. Small swirls are kept from being smoothed away by the grid (SWIRL, vorticity confinement). - The gas loses heat as it goes (
COOLseconds to fall to a third, quicker while it is hottest), so a flame ends where its gas has cooled: its height is not set anywhere, it follows from how fast the gas rises and cools. - What is drawn are tracers: points let go on the bed at hashed places and times and carried by the flow, each as hot as the gas where it is, gone once that has cooled. Sparks are tracers with weight of their own: they are thrown up with the gas, leave the flame and drift on, cooling.
Lengths are in bed radii and the bed's middle is the origin, so one run serves a fire of any size at any place. Everything is a function of the shape and the time, stepped at a fixed rate (FIRE_TICK), so the same shape gives the same fire. runFire() plays it through a scene's loop once and keeps it, as SceneWater keeps a pond's ripples.
FireShapeinterface
What decides how a fire burns, with nothing about where it is or how big: runFire() gives the same loop for the same shape.
Properties
tallnumberHow tall the flames are meant to stand, in bed radii (it sets how much room the gas is given and how fast it cools).
quicknumberHow fast it burns beside a campfire a tenth of a unit across: a bigger fire is slower, as the square root of its size.
sparksnumberSparks thrown a second.
seednumberAnother fire of the same shape burns differently with another seed.
windreadonly [number, number]optionalA wind across the fire, in bed radii a second along x and z. It blows in the weather's own gusts (
gustAt), a whole number of times a loop, and the fire is given more room downwind to be blown into.fuelnumberoptionalHow much of its fuel burns, 1 when left out: wet wood burns low (0.5), a fire going out lower still.
FIRE_TICKvalue
Seconds a tick of the fire.
numberFIRE_CELLSvalue
Grid cells to a bed radius.
3FIRE_FLAMESvalue
Tracers that make up the flame.
520FIRE_SPARKSvalue
Tracers that are sparks, after the flame's in a kept loop.
16FIRE_SMOKEvalue
Tracers that are smoke, after the sparks in a kept loop: carried by the same gas, whether or not it is hot enough to glow.
28FIRE_FPSvalue
Moments a second the loop is kept at.
24Fireclass
The gas over one bed: its flow and its heat on a grid, stepped by tick.
Constructor
new Fire(shape: FireShape, loop: number)Properties
nxnumberread onlyCells across, along x.
nynumberread onlyCells up.
nznumberread onlyCells across, along z.
uFloat32Arrayread onlyThe flow along x, cells a second, a value a cell: x, then z, then up.
vFloat32Arrayread onlyThe flow along z, cells a second.
wFloat32Arrayread onlyThe flow upward, cells a second.
heatFloat32Arrayread onlyThe heat, 0 to about 1.
shapeFireShaperead onlyThe shape it was made for.
loopnumberread onlySeconds a loop: the fuel flares a whole number of times in it.
midXnumberread onlyWhere the bed's middle is on the grid, in cells along x and along z (the grid reaches further downwind).
Methods
burning()How hard a spot burns
tseconds into the loop, 0 to 1: it flares and dies back, never quite out.burning(s: Spot, t: number): numbersample()A field read between its cells at (x, y, z) in cells;
edgeis what lies past the sides and the top (the floor repeats its lowest cells).sample(f: Float32Array, x: number, y: number, z: number, hold: boolean): numberflowAt()The flow at a point, in cells a second.
flowAt(x: number, y: number, z: number, out: number[] | Float32Array<ArrayBufferLike>): voidheatAt()The heat at a point (none outside the grid).
heatAt(x: number, y: number, z: number): numbertick()Moves the fire on a tick;
tis the time into the loop, which says how hard each spot burns.tick(t: number): void
FireLoopinterface
One loop of a fire, kept: where each tracer is, how hot and how big, at FIRE_FPS moments a second. Places are in bed radii from the bed's middle (x, up, z). A tracer that is out has size 0.
Properties
loopnumberSeconds a loop.
framesnumberMoments kept.
countnumberFlame tracers first (
FIRE_FLAMES), then sparks (FIRE_SPARKS).placeFloat32ArrayThree numbers a tracer a moment: x, up, z.
heatFloat32ArrayHeat, 0 to 1, a tracer a moment.
sizeFloat32ArraySize as a share of a tracer's biggest, a tracer a moment.
powerFloat32ArrayHow strongly the whole fire burns at each moment, beside its mean over the loop (about 0.6 to 1.5): what its light flickers by.
meannumberThat mean itself, to set one fire's light beside another's: a fire burning low gives less.
runFire()function
A fire played through a loop of loop seconds and kept. The same fuel flares and the same tracers are let go each loop, but the gas never repeats itself exactly, so the fire is run on past the loop's end for LAP seconds and those moments are mixed into the loop's first ones, from all of the later run at the very start to none: the last kept moment is followed by the first as closely as by the one the fire itself went on to.
playFire()function
runFire() a kept moment at a time, for a page that must keep drawing meanwhile: step it until it is done, which hands back the loop.
powerAt()function
How strongly a kept fire burns t seconds into its loop, beside its mean (smoothed over a few moments, as an eye and a lit wall take it).
FireColorstype
A fire's colors from its coolest to its hottest, 0 to 1 as blobs hold them (sRGB): deep red, orange, yellow, white-hot.
readonly [Vec3, Vec3, Vec3, Vec3]fireColor()function
The color of gas at heat, along the fire's four colors.
fireColor(heat: number, colors: FireColors, out: number[] | Float32Array<ArrayBufferLike>, at?: number): voidPicking, detail and edits
Finding what a tap hit, drawing fewer blobs far away, cutting and painting live, depth for effects after the draw, what a mirror shows, a lens with glow and focus blur, see-through blobs put in order where they cross, and solid shapes to stand on.
Picking
PickHitinterface
Picking: which blob of which actor is under a pointer, as the actor stands posed right now, and which bone and part it belongs to.
Each blob's bones move it by a blend of their skin matrices. That blend, M, carries the blob's rest ellipsoid to where it is drawn (exactly, in the 'linear' rule; to within the rounding of a joint in 'quat'), and a straight line through M is still a straight line with the same distances along it. So the ray is taken back into the blob's rest frame through M⁻¹ and tested against the rest blob there, with rayHit, as a still scene is.
Properties
actornumberIndex into the actors given.
blobnumberThe blob's index in that actor.
tnumberDistance along the ray (in units of the direction's length).
point[number, number, number]Where the ray meets the blob, in world space.
bonenumberThe bone that holds most of the blob.
partnumberIts part (
Actor.partOf), or 0 when the actor has none.
PickOptionsinterface
Options for pickActors().
Properties
knumberoptionalHow far out a blob counts, in standard deviations (2 is about where it fades to nothing).
minOpacitynumberoptionalBlobs fainter than this are looked through.
pickActors()function
The nearest blob a ray hits among posed actors, or null. Call each skeleton's update() first.
pickActors(actors: readonly Actor[], origin: ArrayLike<number>, dir: ArrayLike<number>, options?: PickOptions): PickHit | nullboneShare()function
How much of each blob of an actor moves with bone: its weight on that bone, 0–1.
boneShare(actor: Pick<Actor, "blobs" | "skin">, bone: number): Float32ArrayboneLabel()function
A bone's name for people: 'lForearm' → 'left forearm', 'flUpper' → 'front left upper', 'tail3' → 'tail 3'.
boneLabel(name: string): stringLevel of detail
Level of detail per actor: a creature far away or small on screen draws a share of its blobs, each grown to cover for the ones left out, so it costs less to draw and looks about the same.
Which blobs stay is fixed per blob by lodRank() (a hash of its index), so a creature thinning out loses the same blobs every time and keeps the rest: nothing flickers as the share drifts. A kept blob's covariance is divided by the share kept (each axis grows by 1/√keep), so the covered area stays about the same for the surface discs creatures are cut from.
The GPU (deformBlob in engine.ts) and the CPU twin (SplatWorld.deformCPU) use the same hash; change both.
lodRank()function
A blob's place in line for being dropped, 0–1: blobs ranked below the share dropped are left out. Wang's integer hash.
lodRank(i: number): numberDetailRuleinterface
How many of its blobs an actor keeps for the size it is on screen.
Properties
densitynumberBlobs wanted per pixel of the disc round the actor on screen. The disc is a loose fit (a long creature seen end on fills a third of it), about half the blobs face away, and blobs overlap, so one per disc pixel still looks whole.
minnumberNever fewer than this share of the blobs.
DETAILvalue
The rule to give world.autoDetail: about one blob per pixel, and never under 6% of them.
DetailRuledetailFor()function
The share of an actor's count blobs to draw when it covers a disc radiusPx pixels across on screen.
detailFor(count: number, radiusPx: number, options?: DetailRule): numberscreenRadius()function
How many pixels a sphere of radius reaches on screen, depth units in front of a perspective camera whose projection matrix has p11 as its [1][1] (y focal) term, drawn height pixels tall. Behind the camera it is huge.
screenRadius(radius: number, depth: number, p11: number, height: number): numberFarRuleinterface
Level of detail for blobs too small to see, blob by blob: for one actor as big as a world (an island a hundred and fifty meters across, the camera standing on it), where the actor's own size on screen says nothing. A blob that would come under pixels on screen (its largest standard deviation, far off or just small) is kept by the share of that it would fill, so fewer are drawn the smaller they get, each grown to cover for those left out: far ground is drawn by about as many blobs as the pixels it covers, which also stops far fine detail shimmering, while a big soft cloud at the same distance keeps every blob. Which go is lodRank() again, so the same blobs go each time.
Properties
pixelsnumberThe least a blob's size may come to on screen (its largest standard deviation, in pixels of the picture) before blobs thin out.
leastnumberNever fewer than this share of the blobs, however small.
FARvalue
Blobs thin out where they would come under about a pixel, and never under 5% of them.
FarRuleFAR_BANDvalue
How far before it goes a blob starts to shrink, as a share of the ranks: a blob shrinks away rather than blinks out.
0.1FAR_SPREADvalue
How much more than the area left out the blobs kept grow to cover, when few are kept: blobs thinned at random leave chance gaps between them, which a surface of opaque discs showed as specks of what lies behind (clouds of small blobs came out grainy). Eased in from nothing as blobs start to thin out, so nothing jumps.
2farKeep()function
The share of blobs kept where a blob's largest standard deviation on screen squared is px2 (pixels²).
farKeep(px2: number, options: FarRule): numberfarSize()function
What a blob's covariance is multiplied by, by its rank (lodRank()), where its largest standard deviation on screen squared is px2: 0 left out, else grown by one over the area kept (and FAR_SPREAD), and shrinking toward 0 over FAR_BAND as it nears its turn to go. farSizeNode in engine.ts is its twin (in projectSplat); change both.
farSize(rank: number, px2: number, rule: FarRule): numberMerged blobs for far ground
MERGE_LEVELSvalue
How many coarser levels: cells two and four times the blobs' own.
2MERGE_PXvalue
A level gives way to the next coarser one where its cells come under this many pixels across on screen.
1.5MERGE_BANDvalue
Over how much of MERGE_PX (either side) one level hands over to the next.
0.25MERGE_GROWvalue
How much wider a merged blob is than the spread of what it stands for (standard deviations): the mean and spread of a cell of touching discs is a blob a third the cell wide, which left the far ground see-through between cells.
1.35levelCode()function
The byte a blob carries for its level: 0 for a blob in no level (drawn at every distance), else its level and the coarsest.
levelCode(level: number, top: number): numberlevelWeight()function
How much of a blob is drawn (0 to 1, opacity) where a cell of the finest level is px pixels across on screen (its side over its distance, at the blob), for its levelCode(): a level shows from where its finer level's cells come under MERGE_PX to where its own do, coming in fully over the band before the finer one starts to go.
levelWeight(px: number, code: number): numberMergeableinterface
An actor's blobs and what rides with each, as mergeLevels() takes and gives them.
Properties
blobsBlobsThe blobs in the rest pose.
skinSkinWhich bones move each blob: only a blob wholly on one bone is merged.
partOfArrayLike<number>optionalWhich part each blob belongs to (the engine's
Actor.partOf).seenUint8Array<ArrayBufferLike>optionalHow much of each of the first four lights each blob sees, four bytes a blob (
Actor.seen).glowUint8Array<ArrayBufferLike>optionalHow much of its own light each blob gives, a byte a blob (
Actor.glow).
mergeLevels()function
The blobs with coarser levels added after them: on grids of cell (the side the blobs were cut on) times 2, 4 … (levels of them), cells counted from the origin of the blobs' own frame so a coarse cell holds whole finer ones, one blob a cell and bone from the blobs on that bone alone. A blob on more than one bone, or clear, stays in no level and is drawn at every distance. Each blob counts by its opacity times the area of its two widest axes; a merged blob takes their weighted color, opacity, glow and sight of lamps, the part of the heaviest, and their mean and spread (each blob's own shape plus where it stands), grown by MERGE_GROW. levels is each blob's levelCode().
Cuts and paint
Shape edits: cut or paint every blob inside a sphere or a box, live, without rebuilding anything. The GPU applies them as it moves the blobs (a cut blob gets no size, as level of detail leaves one out) and as it colors them (a painted blob's own color is mixed toward the paint before any light). Edits are tested against where a blob is now, in world space, so a box that cuts a creature's head off keeps cutting as the head moves through it.
This file is the CPU twin (editAt()), also used to bake edits into blobs for a file (bakeEdits()). The GPU side is editsAt in engine.ts; change both.
A cut can also have a clean edge (a world made with cleanCuts): a blob the edge passes through is kept, and each of its pixels is tested on its own, at the point of the blob that pixel shows most of (densestAlong()). A file still gets whole blobs: bakeEdits() keeps or drops each by its center.
ShapeEditinterface
One edit for setEdits: a sphere, a box or an upright cylinder in world space that cuts blobs away or paints them.
Properties
center[number, number, number]World position of the shape's middle.
size[number, number, number]A sphere's radius (the first value), a box's half sizes, or a cylinder's radius and half height (it stands along y).
op"cut" | "paint"Cut the blobs away, or paint them.
outsidebooleanoptionalAct on what's outside the shape instead: a cut that keeps only the inside is a crop.
color[number, number, number]optionalPaint: the color, in sRGB 0–1 like a blob's own.
amountnumberoptionalPaint: how far toward the color, 0–1 (default 1).
softnumberoptionalPaint: how far in from the edge it takes to reach full strength, in units (default 0, a hard edge).
MAX_EDITSvalue
How many edits the GPU takes at once; the rest are dropped.
8shapeDistance()function
Signed distance from p to the shape: negative inside.
shapeDistance(e: ShapeEdit, p: ArrayLike<number>): numberCLEAN_MARGINvalue
Clean cuts: a blob is dropped whole only when its center is this many of its sizes (blobReach()) inside a cut.
2.5blobReach()function
A blob's size for clean cuts: the root of its covariance's trace (xx, xy, xz, yy, yz, zz), at least its longest standard deviation.
blobReach(cov: ArrayLike<number>, at?: number): numberdensestAlong()function
How far along a ray (from + t·dir()) a blob is densest: the point of the blob a pixel on that ray shows most of. For a flat blob that is where the ray meets its plane. cov is xx, xy, xz, yy, yz, zz. A blob seen edge-on, or a needle, has no such point to speak of and gives the point of the ray nearest its center.
densestAlong(from: ArrayLike<number>, dir: ArrayLike<number>, center: ArrayLike<number>, cov: ArrayLike<number>): numbereditAt()function
What the edits do to a blob at p: whether it stays, and the paint mixed over its color (linear RGB and amount). margin is how far inside a cut it must be to go (0 for a point; clean cuts pass CLEAN_MARGIN blob sizes).
editAt(edits: readonly ShapeEdit[], p: ArrayLike<number>, margin?: number): { keep: boolean; paint: [number, number, number]; amount: number }bakeEdits()function
A copy of still blobs with the edits applied: cut blobs left out, painted ones recolored.
exactFalloff()function
Exact shapes (EngineOptions.exactShapes): how much of a blob the line of sight from from along dir() meets, as the Gaussian's falloff at the densest point along it, 1 through the middle. cov is the world covariance (xx, xy, xz, yy, yz, zz) and widen is added to its diagonal first (the draw adds a pixel's KERNEL_2D at the blob's depth, which gives a flat disc a thickness). Measured from the densest point, not as the center's distance less the part along the ray, which a small blob far away loses to rounding. CPU twin of the draw's exactFalloff(); change both.
exactFalloff(from: ArrayLike<number>, dir: ArrayLike<number>, center: ArrayLike<number>, cov: ArrayLike<number>, widen?: number): numberDepth for post effects
SplatDepthclass
A depth map of a scene drawn by the engine, for post effects (fog, outlines, focus): every pixel's distance in front of the camera, in scene units, in all three channels of a half-float target, and 0 where nothing was drawn. The target also carries a depth texture, for passes that want the usual kind (ordinary meshes write it; blobs, being see-through, do not).
Splats have no single depth: a blob fades out from its middle. Here each blob counts as a hard disc out to where it has faded to a sixth (as in the map of parts), and the frame's own sort leaves the nearest disc on top. So draw it right after the frame's own render, with the same camera: it reuses that frame's moved and sorted blobs (SplatWorld.hold) and costs one more draw, nothing more.
Ordinary meshes draw their own depth with a stand-in material; lines and points (grids, helpers) are left out.
Constructor
new SplatDepth(width?: number, height?: number)Properties
targetRenderTargetread onlyThe depth map: each pixel's distance in front of the camera, 0 where nothing is.
Methods
setSize()Sizes the map, in pixels.
setSize(width: number, height: number): voidrender()Draws the depth map of
sceneas just rendered fromcameraintotarget(sized to match the frame first).render(renderer: WebGPURenderer, scene: Object3D, camera: Camera): voidread()For tests and tools: the map read back, one depth a pixel, rows from the top.
read(renderer: WebGPURenderer): Promise<{ width: number; height: number; depth: Float32Array }>dispose()Frees its render target.
dispose(): void
Mirrors: the arithmetic
A flat mirror, and what is seen in it: the plain arithmetic of a planar reflection, apart from any drawing.
The world seen in a mirror is the world itself, flipped through the mirror's plane, seen from where the eye really stands. So SplatMirror (mirror.ts) draws the scene once more with every point flipped (mirrorMatrix()), leaving out what lies behind the mirror, and keeps the picture with the camera it belongs to (MirrorImage). A point of the mirror's surface then finds what it reflects by asking that picture (seenIn()) where its mirrored line of sight lands: for a flat mirror that is the very pixel the surface point itself is drawn at, and for a rippled one (water) the line is tipped by the ripple first, which is what makes reflections wobble.
MirrorPlaneinterface
A plane: the points p with normal·p + offset = 0. normal is one long and points out of the mirror's face.
Properties
normalVec3The way the mirror faces, one long.
offsetnumberMinus how far the plane is from the origin along the normal.
levelPlanevalue
A level mirror at height y, facing up: a pond.
(y: number) => MirrorPlaneinFrontvalue
How far p stands in front of the plane (negative behind it).
(p: ArrayLike<number>, m: MirrorPlane) => numberreflectPoint()function
p flipped through the plane: where it is seen in the mirror.
reflectPoint(p: ArrayLike<number>, m: MirrorPlane): Vec3mirrorMatrix()function
The matrix that flips every point through the plane, 16 numbers by columns (as three.js keeps a Matrix4). It is its own inverse.
mirrorMatrix(m: MirrorPlane): number[]MirrorImageinterface
A picture of the mirrored world, with the camera it was drawn for.
Properties
widthnumberPixels across.
heightnumberPixels down.
pixelsFloat32ArrayRed, green, blue (linear, multiplied by cover) and cover, four numbers a pixel, rows from the top. Cover is 0 where the mirror shows nothing but sky.
viewProjArrayLike<number>The eye's own projection times view matrix when the picture was drawn, 16 numbers by columns: where a point of the mirrored world lands in the picture.
planeMirrorPlaneThe mirror.
seenIn()function
What the picture shows where the world point (x, y, z) is seen in the mirror: writes red, green, blue (times cover) and cover into out and returns true, or returns false (and writes zeros) when the point is behind the eye or off the picture. Blended between the four pixels round it.
seenIn(img: MirrorImage, x: number, y: number, z: number, out: number[] | Float32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>): booleanMirrors: what a flat mirror shows
SplatMirrorclass
What a flat mirror shows of a scene drawn by the engine: the scene drawn once more as its mirror image, from the same eye, into a target of its own. Water, a polished floor or a looking glass then reads it (read, then seenIn() in reflect.ts) to color itself, so whatever stands, moves or burns in the scene is in the reflection, with nothing set up per scene.
Draw it before the frame's own render, with the frame's camera. The mirrored view puts the blobs in another order than the frame's, so it costs a sort and a draw of its own (at the target's size, which can be small: a rippled surface blurs what it mirrors anyway). Blobs whose centers are under the mirror, or within lift over it, are left out through SplatWorld.clip: the bed of a pond is not in its reflection, and neither are the blobs of the water's own surface. Lines and points are left out; ordinary meshes are drawn, but show their back faces (a mirror image turns triangles round).
Constructor
new SplatMirror(width?: number, height?: number)Properties
targetRenderTargetread onlyThe mirrored picture: linear color times cover, and cover.
Methods
setSize()Sizes the picture, in pixels.
setSize(width: number, height: number): voidrender()Draws
sceneas the mirrorplaneshows it tocamera, leaving out blobs less thanliftin front of the plane.render(renderer: WebGPURenderer, scene: Object3D, camera: Camera, plane: MirrorPlane, lift?: number): voidread()The picture last drawn, read back for
seenIn(), with the camera it was drawn for. Reading takes a frame or two; while one read is under way another returns null, so call it every frame and keep the last picture.read(renderer: WebGPURenderer): Promise<MirrorImage | null>dispose()Frees its render target.
dispose(): void
A lens: glow and focus blur
SplatLensclass
A lens in front of a stage: light that spills round bright things, and blur for whatever is nearer or farther than the distance in focus. Both come from what the frame holds, nothing is placed by hand: the glow is the picture's own light over a knee, spread out, so a flame glows and a pale wall does not; the blur is the thin lens's circle of confusion for each pixel's depth (SplatDepth), so it follows the view and the scene as they move. The numbers are splat-core/optics.ts (blurRadius(), glowShare()), the CPU twins of the shader here: change both.
The frame is drawn twice with one sort (the picture into a half-float target, so light over 1 is kept, then the map of depth), and a few small passes follow: the light over the knee at half size, blurred there (the tight halo) and again at quarter size (the wide one); then one pass over the picture that looks at each pixel through TAPS points of the opening, spread as wide as the pixel's own blur or that of something nearer beside it. A point's color counts for a pixel when its own blur reaches it; something sharp in front is not smeared by what is blurred behind it, since a point behind counts no further than the pixel's own blur.
Constructor
new SplatLens()Properties
pictureRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>read onlyThe picture, as the stage draws it without the lens.
Methods
setLook()The lens, for a view
fovdegrees tall.setLook(look: OpticsLook, fov: number): voidsetSize()Sizes the pass's targets, in device pixels.
setSize(width: number, height: number): voidrender()Draws the scene through the lens into the renderer's current target, or onto the screen when it has none.
render(renderer: WebGPURenderer, scene: Object3D, camera: Camera): voiddispose()Frees its targets.
dispose(): void
A lens: the arithmetic
A camera's lens, in plain numbers: how far out of focus a thing at some distance is, and how much of a bright light spills round it. SplatLens (splat-engine/lens.ts) draws with these; they are here apart from any drawing so tests can ask them, and so the shader and the numbers shown on a page come from one place.
Focus is the thin lens: a lens of focal length f, set to be sharp at distance s, draws a point at distance d as a disc (its circle of confusion) of diameter A·f·|d − s| / (d·(s − f)) on the film, where A = f / N is the opening for f-number N. So blur grows with the opening, grows fast for things nearer than the focus, and levels off behind it. The focal length follows from the view's angle and the film's height, taken as a 35 mm frame's 24 mm unless given: a scene a few meters across then blurs as a photograph of a small real place does.
OpticsLookinterface
How a view is finished through a lens. Distances are in the scene's units (meters).
Properties
focusnumberThe distance in front of the camera that is sharp.
fNumbernumberThe f-number: 2 is a wide opening and a thin slice in focus, 16 keeps nearly everything sharp. 0 or less turns focus blur off.
filmnumberoptionalThe film's height, in the scene's units: 0.024 (a 35 mm frame) when left out. A bigger film blurs more at the same f-number. A scene photographed as a model of itself, 1/n of its size, is the same as a film n times as high.
mostnumberoptionalThe widest blur drawn, as a share of the picture's height: 0.02 when left out.
glownumberHow strongly the light over
kneespills round it: 0 for none. A small bright thing's light is spread thin, so about 1 suits a picture that holds light well over white, and several one that stops at white (where a flame is drawn no brighter than paper).kneenumberoptionalHow bright (linear, 0 to 1 and over) a pixel must be before it glows: 0.7 when left out.
shouldernumberoptionalWhere strong light starts to roll off toward white instead of running straight into it, as film does: about 0.7. Left out, light over 1 clips, each of red, green and blue on its own, which turns a fair thing in strong light into a flat pale patch.
focalLengthvalue
A lens's focal length for a view fov degrees tall on film film high, in the film's units.
(fov: number, film?: number) => numberblurScale()function
The number the shader multiplies |d − s| / d by to get a blur radius in pixels: A·f / (s − f), halved (a radius), as a share of the film and so of the picture's height in pixels. 0 when focus blur is off or the focus is inside the lens.
blurScale(look: OpticsLook, fov: number, height: number): numberblurRadius()function
The radius, in pixels, of the disc a point depth in front of the camera is drawn as, for a picture height pixels tall: 0 at the focus, never over most. The CPU twin of the shader's.
blurRadius(depth: number, look: OpticsLook, fov: number, height: number): numbersharpRange()function
The nearest and farthest distances drawn no blurrier than sharp pixels: the slice in focus. far is Infinity when everything behind the focus is that sharp.
sharpRange(look: OpticsLook, fov: number, height: number, sharp?: number): { near: number; far: number }glowShare()function
How much of a pixel's light glows: nothing under the knee, then rising smoothly to all of it a third of the knee higher. The CPU twin of the shader's.
glowShare(brightest: number, knee?: number): numberrolledOff()function
A brightness after the film's shoulder: unchanged up to start, then closing on 1 ever more slowly and never passing it. The lens scales a pixel's whole color by this over its brightest channel, so its hue holds. The CPU twin of the shader's.
rolledOff(brightest: number, start: number): numberSee-through blobs that cross
MAX_PEELvalue
The most layers SplatPeel takes from the front of each pixel.
6Peelableinterface
What a world hands a peel (a SplatWorld made with peel): its draw's material, and the switches its fragment reads.
Properties
materialMaterialThe material it draws with; the peel swaps in its own for the layers and puts this back.
holdbooleanWhile true it draws the last frame's blobs without moving or sorting them again: the layers after the first.
peelModenumber0 off; 1 a layer (only the nearest blob still in front of
previs kept); 2 the rest (only what lies behindprev).peelFirstbooleanWhether this layer is the first, with nothing in front of it to be behind.
Methods
peelBehind()The depth of the layer before, read where each pixel is.
peelBehind(depth: DepthTexture): voidbuildFor()Builds its draw's shaders for the backend, so the peel can draw with them.
buildFor(renderer: WebGPURenderer): void
SplatPeelclass
See-through blobs in the right order where they cross (after Silicon Jungle's Ink Studio's surface order, by agreement; our own method). The engine sorts blobs by their middles and lays them back to front, which is right until two see-through blobs cross: then one is wholly in front of the other where they overlap, and as the view turns past where their middles change places, that flips all at once. Here each pixel's nearest layers blobs are taken off the front one at a time (depth peeling), each at its own depth on its own plane (placeQuad slopes a blob's corners), so where two cross each is in front on its own side; whatever lies behind the last layer is laid as before, and the layers go over it front to back. Costs a draw of the blobs per layer and one more.
Everything else in the scene (a floor, meshes) is drawn first, under all the blobs: it suits a creature or a jellyfish over a floor or a sky, not blobs among solid things.
Constructor
new SplatPeel(layers?: number)Methods
setLayers()How many blobs to take off the front of each pixel, 1 to
MAX_PEEL.setLayers(layers: number): voidsetSize()Sizes the targets, in pixels.
setSize(width: number, height: number): voidrender()Draws
scenefromcamerainto the renderer's current target, with every world in it peeled.render(renderer: WebGPURenderer, scene: Object3D, camera: Camera): voiddispose()Frees its targets and materials.
dispose(): void
Colliders
Colliders: simple solid shapes laid over a scan or a scene, which has none of its own. A scan is a cloud of blobs with nothing to stand on or bump into; a box for the table, a cylinder for the mug and a slab for the floor give feet a ground (groundOf(), the Ground that plantFeet() takes) and bodies something to stay out of (pushOut()).
A shape is a box, a ball or an upright cylinder, turned only about the upright, which is what furniture and floors need and keeps every question (how far, how high, where a ray lands) a few lines. writeColliderGlb() saves them as ordinary glTF nodes with a mesh each, so the file opens anywhere as shapes, and readColliderGlb() reads them back exactly.
Colliderinterface
One solid shape.
Properties
SMALLESTvalue
The smallest a shape's size may be dragged to.
0.02colliderDistance()function
Signed distance from p to the shape's surface: negative inside.
colliderDistance(c: Collider, p: ArrayLike<number>): numbertopAt()function
How high the shape's top is over the point (x, z) of the floor, or undefined where it is not over it.
topAt(c: Collider, x: number, z: number): number | undefinedgroundOf()function
The ground the shapes make, for plantFeet() and anything else that asks how high the floor is at (x, z): the highest top under the point, and base where there is none.
groundOf(colliders: readonly Collider[], base?: number): (x: number, z: number) => numbergroundBelow()function
The same ground, but only tops no more than step above from: a shape too tall to step onto is a wall, not a floor.
groundBelow(colliders: readonly Collider[], from: number, step: number, base?: number): (x: number, z: number) => numberpushOut()function
A ball of radius at p, moved the shortest way out of every shape it is in (a few rounds, for corners).
rayCollider()function
How far along a ray (a unit direction) it first meets the shape, or undefined if it misses within far.
rayCollider(c: Collider, origin: ArrayLike<number>, direction: ArrayLike<number>, far?: number): number | undefinedpickCollider()function
The shape a ray meets first: its index and how far along, or undefined.
pickCollider(colliders: readonly Collider[], origin: ArrayLike<number>, direction: ArrayLike<number>): { index: number; t: number } | undefinedwireOf()function
The shape as lines to draw over a picture: each entry is a run of points to join. A box's twelve edges, a cylinder's two rims and four sides, a ball's three great circles. steps() is how many points a circle gets.
Handleinterface
A handle on a shape: where it is, the way it pulls, and which of the shape's sizes it changes.
Properties
handlesOf()function
The handles that size a shape: one on each face that matters (a box's three, a cylinder's side and top, a ball's side).
resized()function
The shape with one size changed by by (pulling its handle out or in); never smaller than SMALLEST.
placed()function
The shape scaled about the origin and then shifted: for a scan that is resized and stood somewhere else.
guessColliders()function
A first guess for a scan: a slab for the floor (its top at floor, reaching well past the thing) and a box round what was kept (lo to hi, from the floor up). Either is left out when it would have no size.
guessColliders(lo: ArrayLike<number>, hi: ArrayLike<number>, floor: number): Collider[]ColliderFileErrorclass
Thrown when a file holds no shapes we can read.
Plus everything in Error.
Constructor
new ColliderFileError(message?: string)new ColliderFileError(message?: string, options?: ErrorOptions)writeColliderGlb()function
The shapes as a .glb: a node each, placed and turned, with a mesh of its surface so the file opens anywhere, our own exact note in the node's extras, and the Khronos draft extensions for physics shapes (KHR_implicit_shapes, KHR_physics_rigid_bodies; used, not required) so an engine that knows them takes the shapes as colliders.
writeColliderGlb(colliders: readonly Collider[]): Uint8ArrayisColliderGlb()function
Whether these bytes are a .glb of colliders (ours, or another tool's with the physics shape extensions).
isColliderGlb(bytes: Uint8Array): booleanreadColliderGlb()function
Reads the shapes back from a .glb: ours exactly, from each node's own note; another tool's from the physics shape extensions (boxes, spheres and upright cylinders; a turn about the upright is kept, any other is dropped). At most most shapes. Throws ColliderFileError when the file holds none.
readColliderGlb(bytes: Uint8Array, most?: number): Collider[]Files and models
Writing and reading rigged .glb files, and turning an ordinary rigged model into splats.
Rigged .glb files
SKIN_EXTENSIONvalue
Rigged splats in a .glb.
The blobs are a KHR_gaussian_splatting primitive (POINTS, with SCALE, ROTATION, OPACITY and the degree-0 color as extra attributes), so any viewer that knows that extension shows the creature. The rig uses only standard glTF: JOINTS_0 and WEIGHTS_0 on the same primitive, a skin, joint nodes, and animation channels on those nodes.
What glTF doesn't say is how a skinned *splat* turns, since a blob has a rotation and a shape as well as a position. Our extension, BLOBSCAPE_gaussian_skinning, says so: blob centers follow the usual linear blend, and each blob's rotation is the weighted average of its bones' rotations. It's listed as used, not required, so viewers that don't know it still load the file, and most will show the creature standing still. The full rule is written up in docs/rigged-splats.md.
Morphs are standard glTF morph targets on the same primitive (POSITION deltas, animated as the mesh node's weights), and our second extension, BLOBSCAPE_gaussian_morphs, adds what a splat needs beside its center: a SHAPE attribute per target (the morph's local 3×3 map minus identity, morph.ts) and which targets are in-betweens of one morph. Viewers that know glTF morphs but not the extension move the centers right and leave the shapes as they were.
"BLOBSCAPE_gaussian_skinning"MORPH_EXTENSIONvalue
The glTF extension that says how each morph target changes a splat's shape, and which targets are one morph's in-betweens.
"BLOBSCAPE_gaussian_morphs"SHAPE_ATTRIBUTEvalue
The morph target attribute holding each splat's shape change, G = J − I, as a column-major MAT3.
"BLOBSCAPE_gaussian_morphs:SHAPE"SKIN_RULEvalue
How a skinned blob turns and grows: the spec is docs/rigged-splats.md.
{ rotationBlend: "quaternionAverage"; scaleBlend: "weightedAverage" }Clipinterface
An animation: keys for each bone at shared times.
Properties
namestringThe clip's name.
timesFloat32ArraySeconds.
rotationsFloat32Array<ArrayBufferLike>[]Per bone, a rotation key per time (x, y, z, w).
offsets(Float32Array<ArrayBufferLike> | undefined)[]optionalPer bone that moves, an offset key per time (x, y, z) on top of its rest place; missing for bones that never move.
sizes(Float32Array<ArrayBufferLike> | undefined)[]optionalPer bone that grows or shrinks, a uniform scale key per time; missing for bones that keep their size.
weightsFloat32Array<ArrayBufferLike>optionalEach morph's weight per time (times × morphs, a key's weights together); missing for a clip that leaves them at 0.
Riggedinterface
Everything a rigged .glb holds: the blobs, their skin, the skeleton, its clips and any morphs.
Properties
recordClip()function
Records a clip by posing the skeleton at fps across seconds. Rotations are kept for every bone; offsets and sizes only for bones that use them. weights, if given, says each morph's weight at a time, and is keyed too. Leaves the skeleton posed at the end.
sampleWeights()function
Each morph's weight from a clip at time t (looping, interpolating keys), into out. False, with out all 0, when the clip keys no weights.
sampleWeights(clip: Clip | undefined, t: number, out: Float32Array): booleansampleClip()function
Poses the skeleton from a clip at time t (looping), interpolating keys.
writeRiggedGlb()function
Writes blobs, bones, clips and morphs as a .glb: the KHR_gaussian_splatting standard with ordinary glTF skins and animation, plus the two Blobscape extensions. Blender and game engines open its bones and clips.
writeRiggedGlb(r: Rigged): Uint8ArrayMORPH_RULEvalue
How a morph target's shape change is applied: J = I + Σ w·SHAPE, and the splat's covariance becomes J Σ Jᵀ (docs/rigged-splats.md).
{ shapeBlend: "linearMap" }writeRiggedMeshGlb()function
A solid, skinned triangle mesh with the same bones and clips: what Blender, Godot, Unity and three.js open as an ordinary animated model. Colors are per vertex (glTF wants them linear, so they're converted from the blobs' display color); the material is marked unlit, since the blobs' colors already have their lighting baked in. Viewers that don't know KHR_materials_unlit light it as a plain matte surface.
GlbErrorclass
Thrown when a file can't be read as a rigged .glb; its message says why.
Plus everything in Error.
Constructor
new GlbError(message?: string)new GlbError(message?: string, options?: ErrorOptions)readRiggedGlb()function
Reads a .glb written by writeRiggedGlb(), or any KHR_gaussian_splatting file with a skin whose joints have no rest rotation.
readRiggedGlb(bytes: Uint8Array): RiggedRigged models to splats
A rigged model to splats, keeping its rig: an ordinary skinned glTF (a .glb from Blender, Mixamo or a game kit: triangles, JOINTS_0/WEIGHTS_0, a skin and its animations) read into our bones and clips, then its surface covered in flat blobs that hang on the same bones with the weights the mesh gave its corners. Pure: the page decodes texture images and hands them in as Textures.
Our bones have no rest rotation: a bone is its head, posed by a turn about it. A glTF joint carries any rest frame, so each frame of a clip is read as what the skin does, not what the nodes say: joint j's skin matrix is S = G·IBM (its world matrix now times its inverse bind matrix), which takes the bind pose to the posed one. Its linear part is our bone's world turn (times its scale) and it carries the bind head (where IBM⁻¹ puts the joint) to where the joint is now. Local turns, offsets and sizes follow from those, so the blobs land where the mesh's vertices would.
SkinnedModelinterface
An ordinary skinned model as readSkinnedGlb() reads it: its triangles, their bone weights, our bones and its clips.
Properties
namestringThe model's name.
meshMeshThe triangles in the bind pose.
jointsUint8ArrayPer vertex, four of our bone indices and their weights (summing to 1).
weightsFloat32ArrayPer vertex, the weights of those four bones.
bonesBone[]Our bones, parents first.
clipsClip[]Its animations, sampled onto our bones.
imagesMeshImage[]Texture images, still encoded, which
mesh.texpoints at.
MODEL_FPSvalue
Keys a second when a clip is read: glTF keys may sit anywhere in time, ours sit evenly.
30readSkinnedGlb()function
Reads a skinned .glb: the first mesh node with a skin, its triangles in the bind pose with colors and texture coordinates, the skin's joints as our bones (parents first), and every animation sampled as our clips.
readSkinnedGlb(bytes: Uint8Array, name?: string): SkinnedModelSplatOptionsinterface
Options for splatModel().
Properties
countnumberHow many blobs to lay on the surface.
heightnumberoptionalThe model's height once fitted, standing on y = 0 and centered over the origin; left as the file has it when missing.
texturesTexture[]optionalDecoded texture images, in the order of
model.images.baseVec3optionalThe color of a surface with neither vertex colors nor a texture (sRGB).
seednumberoptionalThe same seed scatters the blobs the same way.
splatModel()function
The model as rigged splats: count flat blobs scattered over its triangles by area (the same seed gives the same blobs), each lying on its triangle, colored from the vertex colors or the texture at that point, and hung on the bones the triangle's corners hang on, weighted by how near each corner is. Bones and clips come with it, fitted to height when given.
splatModel(model: SkinnedModel, o: SplatOptions): RiggedPixel renderer
Its own entry: import { … } from '@blobscape/engine/pixel'
A second renderer, its own entry: a scene cut into hard surfels, drawn on a bare WebGL 2 context (no three.js) through a camera snapped to the art's pixels, lit and painted a pixel at a time, with its styles, and the scene player that brings a scene's water, fires, weather and sky to it. New, and likely to change.
PixelStage: sharp pixel art on a canvas
The pixel renderer's front door: a canvas, a cut scene and whatever plays it, a view, a light and a look. Everything a page does goes through this class; the passes, the surfel table and the shaders behind it are the engine's own.
const stage = new PixelStage(canvas)
stage.setScene(cutPixelScene(source, { spacing }), player)
stage.setLight({ sunTurn: 40, sunHeight: 50 })
stage.play()PixelPlayerinterface
What plays a cut scene on the page: its pose from the time alone, its lamps, its sky and where its view starts.
Properties
loopnumberThe loop's length in seconds.
view{ target: Vec3; azimuth: number; elevation: number; distance: number; height: number }Where the view starts: what it looks at (the scene's units), from which way (azimuth and elevation in degrees), how far off the eye stands and how much of the world the picture's height shows (both in the scene's units).
Methods
pose()Poses the scene's bones for a time in the loop.
pose(sk: Skeleton, t: number): voidcutAway()optionalTakes away what would hide the scene from where the eye stands (a room's near walls). The light still sees them.
lights()optionalThe scene's lamps at a time: where (the scene's units), color times strength (linear, not sRGB), and reach (the scene's units).
lights(t: number): PixelLamp[]morphs()optionalA creature's morph weights at a time, one a morph in the order its cut lists them (
cutPixelCreature()); left out, none.morphs(t: number): ArrayLike<number>casts()optionalWhether what rides a bone casts the lamps' shadows now, asked each frame for each stand-in's bone (a crate that has been broken casts none); left out, all do.
casts(bone: number): booleantarget()optionalA point the view follows, for a player that moves through its scene (a walk): asked each frame right after
pose, it becomes the view's target, moved onto whole art pixels so the picture never slides by part of one, and the sun's shadow map is laid about it in place of the world's origin (keep the cut'ssunReachto what is near it). Left out, the view stays where it is put.target(t: number): Vec3camera()optionalThe view itself for a player that steers it (a chase view behind a walker): asked each frame right after
pose(andtarget), and whatever it gives is laid on the view: where it looks, from which way, and with perspective its field of view and how far back the eye stands. Atargethere is followed astarget's is. Left out, the view stays where it is put.camera(t: number): Partial<PixelView> | undefined
PixelLightinterface
The light a stage works out for each art pixel. Every field has a default; setLight takes any of them.
Properties
sunTurnnumberThe sun's way round the upright, in degrees.
sunHeightnumberThe sun's height over the level, in degrees (0 on the horizon, 90 overhead).
sunPowernumberThe sun's strength: 1 as a description's own light.
skyLightnumberThe share of the light that comes from all round, 0 to 1; the sun has the rest.
shadowsnumberHow hard the sun's shadows are, 0 to 1.
shadowSizenumberoptionalHow many texels the sun's shadow map is across, 256 to 2048 (2048 left out): fewer costs a slow graphics card less and gives coarser shadows.
shadowEverynumberoptionalThe sun's shadow map is drawn afresh once in this many frames (1 left out): 2 halves its cost, and a moving thing's shadow is then a frame behind it.
lampsnumberHow strong the scene's own lamps are: 0 for none.
lampShadownumberHow much of a lamp's light what stands in its way takes, 0 to 1.
cornersnumberHow dark corners and creases go, 0 to 1.
stepsnumberSteps the light's strength is moved onto (2 and up); 0 for smooth light.
stepDithernumberHow much of a step the ordered pattern mixes between two steps of light, 0 (hard steps) to 1.
shiftnumberHow far shade leans cool and full light warm, 0 to 1.
rampsnumberHow far a part with a ramp of its own leans to its shade and light colors instead, 0 to 1.
beamsnumberHow strongly the sun's beams show in the air behind the scene's windows.
mistnumberGround mist: how thick, 0 for none.
mistTopnumberThe height of the ground mist's top, in the scene's units.
PixelWeatherinterface
What falls over the scene.
Properties
kind"snow" | "rain"Rain falls as streaks, snow as flakes.
amountnumberHow much falls, 0 to 1.
windnumberHow far the wind carries it sideways, as a share of its fall.
PixelStageLookinterface
How the picture is finished. Every field has a default; setLook takes any of them. Units: size is in CSS pixels; the lengths inside lines, water, glass, cutout, engraving and strokes are in art pixels (an art pixel is size CSS pixels); a screen look's sizes are in CSS pixels; colors are sRGB 0 to 1. (The main entry's PixelLook is the blob stage's pixel pass, another thing.)
Properties
sizenumberAn art pixel's size in CSS pixels (rounded to whole device pixels).
paintbooleanPaint worked out a pixel at a time where a part's paint allows it (true), or every surfel in the one color it was cut with.
flatbooleanFlat paint: each pattern drawn as its commonest color alone, as a cel painter fills a shape.
levelsnumberSteps each color channel is rounded to (2 to 256).
dithernumberHow much of a step the ordered pattern moves a color, 0 to 1.
reachnumberHow far a surfel's disc reaches, in its standard deviations.
settlenumberHow far each disc is pushed back toward its edge, as a share of its reach at its edge, so that where two overlap on a rounded surface the one whose middle is nearer shows (0 leaves each at its own plane, where the further one shows).
thin[number, number]optionalIn a view with perspective, what stands near the eye thins out, a disc at a time: whole from the second share of the eye's distance to what it looks at, gone by the first (
[0.2, 0.5]), so a thing between the eye and what it follows does not hide it. Square faces (a floor, walls) stay whole. Left out, nothing thins.linesLineLookThe lines drawn on the picture: outlines, creases, where parts meet, and shadows' edges (renderer.ts
LineLook).halonumberHow strong the halo round what glows is: 0 for none, 1 as it comes.
waterPixelWaterLookHow the scene's water is drawn.
glassPixelGlassLookHow the scene's glass is drawn.
weatherPixelWeather | undefinedWhat falls, or nothing.
cutoutPixelCutoutLook | undefinedShadows between layers, as cut paper casts, and paper grain; or neither.
engravingEngravingLook | undefinedThe picture as ink on paper in marks attached to the surfaces; or the picture as it is lit.
strokesStrokeLook | undefinedPaint laid in brush strokes along each surface; or paint a pixel at a time.
holdnumberStop motion: the scene is held on this many frames a second; 0 for every frame.
blocks{ size: number } | undefinedBlocks: the scene as cubes on a grid,
sizecells of its cut across each (blocks.ts); or its surfaces as they are. A scene of more than 256 bones is never cubes.screenScreenLook | undefinedA style that is a pass over the finished picture at the screen's own size (dots, letters, tiles, a picture tube); or the art as it is.
PixelViewinterface
A stage's view: what it looks at, the way it looks from in degrees, and how far it is zoomed in (1 as the scene starts).
Properties
targetVec3The point the view looks at, in the scene's units.
azimuthnumberThe way round the upright it looks from, in degrees.
elevationnumberHow far above the level it looks down from, in degrees.
zoomnumberHow far it is zoomed in: 1 as the scene starts, 2 for twice as close.
rollnumberoptionalDegrees the picture is tipped about the way the view looks, so what it shows leans clockwise: a thing picked up and tilted in the hand. Left out or 0, upright. While tipped, the grid of art pixels is tipped with it, so fine detail shimmers until the view is upright again.
fovnumberoptionalPerspective: the field of view up the picture, in degrees; left out or 0, the view is flat (every line of sight runs the same way, and the picture is snapped to whole art pixels so still things never shimmer). With perspective nothing is snapped (it cannot hold still under an eye that moves), so fine detail shimmers as the view moves; a pattern laid by pixel (the dither) is laid on the picture, not on the world. Discs keep their reach in their own standard deviations and are never drawn under a pixel wide, as in a flat view; a disc very near the eye is not drawn.
distancenumberoptionalWith perspective, how far the eye stands back from
target, in the scene's units (zoomnarrows the field of view and leaves the eye where it is: twice the zoom, half the picture's height at the target). Left out, as far as makes the picture's height at the target the player's ownview.heightat zoom 1. A flat view does not use it.
PixelInfointerface
What a stage says about the scene on show and the picture it last drew.
Properties
surfelsnumberSurfels on show.
glassnumberHow many of the surfels on show are glass.
loosenumberLoose things drawn over the scene just now (flames, clouds, flakes, snow lying), as surfels.
paintsnumberHow many paints are worked out a pixel at a time.
waterbooleanWhether the scene has water.
wavesbooleanWhether this device can run the water's waves (it needs to draw into float textures); without, the water is flat.
windowsbooleanWhether the scene has windows for the sun's beams.
art[number, number]The art's size in art pixels, across and up.
unitnumberThe world units one art pixel covers.
shift[number, number]The part of an art pixel the finished picture is slid by, across and up (none with perspective).
distancenumberWith perspective, how far the eye stood from the view's target when last drawn, in the scene's units; 0 for a flat view.
fpsnumberFrames drawn a second while playing.
DEFAULT_PIXEL_LIGHTvalue
The light a stage starts with.
PixelLightDEFAULT_PIXEL_LOOKvalue
The finish a stage starts with.
PixelStageLookPixelAurorainterface
The aurora behind a scene at a moment (PixelStage.setAurora).
Properties
rowsFloat32ArrayEach curtain's foot and brightness, a point round the sky (aurora.ts
auroraAt).outnumberHow much of it is out, 0 to 1: none by day or under cloud.
PixelCloudsinterface
The clouds over a scene at a moment (PixelStage.setClouds): the engine's CloudSky.
Properties
cellsUint8ArrayHow much cloud stands over each cell of a square grid and how tall it heaps there, two bytes a cell.
sizenumberThe grid's cells a side.
levelnumberCloud stands where a cell is over this (0 to 1).
at[number, number]The grid's middle on the ground (x, z), in the scene's units.
halfnumberHalf the grid's side, in the scene's units.
basenumberThe height of the clouds' undersides, in the scene's units.
thicknumberHow tall the tallest heap is, in the scene's units.
underVec3Their color underneath, sRGB 0 to 1.
topVec3Their color on top, sRGB 0 to 1.
flash{ at: [number, number]; much: number }optionalLightning inside the clouds just now: where on the ground it is over (x, z, the scene's units) and how bright, 0 to 1.
drift[number, number]optionalWhere a loop must join: how far the clouds drift in a loop, in grid sides along x and z, so what falls can be told where they stand at other moments of it (
PixelFalling.loop). Left out, they are taken to stand where they are.
PixelFallinginterface
What falls over a scene at a moment (PixelStage.setFalling).
Properties
rainnumberHow much rain falls, 0 to 1.
snownumberHow much snow falls, 0 to 1.
wind[number, number]The wind: how far sideways it carries rain a unit of its fall, along x and z.
at[number, number]The middle of the square it falls over (x, z), in the scene's units.
halfnumberHalf the square's side, in the scene's units.
topnumberThe height it comes in at, in the scene's units.
loop{ length: number; t: number; wind: (t: number) => [number, number] }optionalWhere a loop must join (an export, a frame drawn on demand): the loop's length in seconds, the moment of it, and the wind at any moment of it. What falls is then run once through the loop and laid over itself where it ends (fallSim.ts
FallLoop), so it joins, in place of being stepped by the clock. Left out, it is stepped.
PixelStageclass
A canvas that draws a cut scene as pixel art: see the top of this file.
Constructor
new PixelStage(canvas: HTMLCanvasElement)Properties
canvasHTMLCanvasElementread onlyThe canvas it draws to.
onError((message: string) => void) | undefinedCalled when the stage cannot draw: a shader this device will not take, a buffer it cannot draw into, the graphics context lost. The message ends with the graphics card's name. The stage stops drawing by itself.
onFrame((info: PixelInfo) => void) | undefinedCalled after each frame the stage draws by itself.
cubesnumberHow many cubes the scene is drawn as, where the look is blocks (0 otherwise).
viewPixelViewread onlyThe view as it stands.
infoPixelInforead onlyWhat the stage has on show and the picture it last drew.
timenumberread onlyThe moment of the scene's loop last drawn, in seconds: where a paused scene stands and where
playgoes on from.
Methods
setScene()Puts a cut scene on show with what plays it. With
keepViewthe view stays where it is (the same scene cut again).setScene(scene: PixelScene, player: PixelPlayer, keepView?: boolean): voidsetPlayer()Another player for the cut on show (the same scene under other weather, say): the view stays where it is.
setPlayer(player: PixelPlayer): voidsetExtras()Loose things played over the scene, each an engine
Actor(blobs, the bones that carry them, what glows): a fire's flames, clouds, snow lying, the moon and stars, a sky effect. They are not part of the cut: each frame they are drawn where their bones stand, in their own colors, hidden by what the scene has in front of them. A scene player'sextrasare these (ScenePlayer, made withwater: nullandbeams: null, since the stage has its own).setExtras(actors: readonly LooseActor[]): voidreshape()A scene player's host: an actor it has changed is drawn again (loose things are read afresh every frame).
reshape(actor?: LooseActor): voidrecolorSurfels()Gives some of the cut's surfels new colors:
surfelsare their places in the cut (a creature's cut says which blob each came from,PixelScene.from),colorsthree numbers each in the same order, sRGB 0 to 1 as a blob's are. Only the rows from the first surfel named to the last are sent up again, so name surfels that lie together (a floor's). The cut handed tosetSceneis changed in place. Where the look is blocks the cubes are made again.glow, one number a surfel from 0 to 1, also sets how much each gives its own light (stone that burns); left out, that is kept.recolorSurfels(surfels: ArrayLike<number>, colors: ArrayLike<number>, glow?: ArrayLike<number>): voidsetLights()A scene player's host: the lamps of the moment (in place of the player's
lights; colors linear) and the light from all round, a number or a linear color, which dims the sun and the sky's light as a time of day or a storm does (1 for full).setSceneforgets them.setLights(lights: readonly PixelLamp[], ambient?: number | readonly number[]): voidsetLight()The light, any of its settings;
nulldraws the cut's own baked colors with no light worked out.setLight(light: Partial<PixelLight> | null): voidsetStyle()Puts a style on: the light and the finish go back to how a stage starts and the style's own settings are laid over them (styles.ts
PIXEL_STYLES, or one of a page's own). A style is settings and nothing more, sosetLightandsetLookafter it adjust it.setStyle(style: PixelStyle): voidsetLook()The finish, any of its settings.
setLook(look: Partial<PixelStageLook>): voidsetPalette()A themed palette laid on as a grade (colors sRGB 0 to 255),
strength0 to 1; no colors for none.setPalette(colors?: readonly (readonly [number, number, number])[], strength?: number): voidsetView()Moves the view: any of its target, the way it looks from and its zoom.
setView(v: Partial<PixelView>): voidsetSwing()Rocks the view
degreesto either side of where it stands, once every loop (0 holds it still). Fine detail lands on new pixels at every angle, so a rocking view shimmers where a still one does not: a page offers it, never forces it.setSwing(degrees: number): voidsetHaze()Haze: what lies far off fades into
color(linear, 0 to 1), fromfromtoto(the scene's units) past the view's target along the way it looks (negative for nearer than the target).undefinedfor clear air. Fog is this, brought close.setHaze(haze: { color: Vec3; from: number; to: number } | undefined): voidsetMelt()A melt as it stands now (melt.ts: the wax of a lava lamp, any soft shapes joined smoothly), drawn by marching each art pixel's line of sight through its distance, so its surface is round to the pixel and changes every frame with nothing cut again. It is lit, tinted by glass in front of it and drawn in every style as any surface is, and its hot parts glow. Set it whenever it moves; kept until set again (
undefinedfor none), whatever scene is on show.setMelt(melt: PixelMelt | undefined): voidsetAurora()The aurora behind the scene as it stands now, worked out by what plays the scene (aurora.ts, a scene player's
aurora): drawn softly on the backdrop, turning with the view. Set every frame;undefinedorout0 for none.setAurora(aurora: PixelAurora | undefined): voidsetMeteors()The meteors in the sky just now, worked out by what plays the scene (meteors.ts, a scene player's
meteors): six numbers each, how many, and how much of the shower is out. Drawn on the backdrop. Set every frame;undefinedfor none.setMeteors(meteors: { streaks: Float32Array; count: number; out: number } | undefined): voidsetFalling()What falls over the scene just now, worked out by what plays the scene (a scene player's
falling()): the stage simulates every drop and flake itself (fallSim.ts), in the air of the moment, landing on the scene's own shapes and its water. Set every frame;undefinedfor none.setFalling(falling: PixelFalling | undefined): voidsetClouds()The clouds over the scene as they stand now, worked out by what plays the scene (cloudField.ts, a scene player's
clouds): marched a pixel at a time over the picture. Set every frame;undefinedfor none.setClouds(clouds: PixelClouds | undefined): voidsetWaterField()The scene's own water as it stands now, worked out by what plays the scene (
SceneWater: swells from the open sea, the wind's waves, the rain's rings, what swims in it, the foam where it breaks): a height a cell of the water's grid (in the scene's units, over the water's level), and how much foam lies there (0 to 1). The stage draws its surface from this, with a tap's rings stepped over it, and no longer presses bodies or lands rain on the water itself. The arrays are read at the next frame, so the same ones may be handed in every frame as they change.undefinedgoes back to the stage's own water.Where the pool is lava or a potion (the cut's water says so), hand in
glowtoo: a lava's glow a cell, 0 to 1 (SceneWater.glowNow), or a potion's dye of every cell followed by its froth, and a potion'sswellunder bubbles about to pop (SceneWater.swell). The stage then draws the pool's surface opaque and glowing, a pixel at a time.iceis how frozen each cell of plain water is, 0 to 1 (SceneWater.iceNow): the stage draws ice there, pale and matte, with little mirrored in it and no caustics under it, and stills a tap's rings.setWaterField(field: { heights: Float32Array; foam?: Float32Array<ArrayBufferLike>; glow?: Float32Array<ArrayBufferLike>; swell?: Float32Array<ArrayBufferLike>; ice?: Float32Array<ArrayBufferLike> } | undefined): voidzoomAbout()Zooms to
zoomkeeping what is under a point of the page (client coordinates: a cursor, the middle of a pinch) where it is, in place of zooming about the picture's middle.zoomAbout(zoom: number, clientX: number, clientY: number): voidpan()Slides the view by CSS pixels (not art pixels) across and down the picture, as a drag does.
pan(dx: number, dy: number): voidturn()Turns the view to the next whole step round, one way (1) or the other (-1).
turn(way: -1 | 1, step?: number): voiddrop()Lands a drop on the scene's water where a point of the page (client coordinates) looks at it.
drop(clientX: number, clientY: number): voidrayAt()The line of sight under a point of the page (client coordinates), as a point on it and the way it runs (of unit length). In a flat view every pixel's line runs the view's own way and the point is at the view's target's depth; with perspective (
PixelView.fov) the point is the eye, and each pixel's line runs its own way from it.screenAt()Where a point of the world is on the page (client coordinates), for things a page lays over the picture.
screenAt(p: readonly number[]): { x: number; y: number } | undefinedpick()What is under a point of the page (client coordinates): the nearest solid surfel the line of sight passes through (meeting the disc's own plane within its reach, or a cube's face within its square), as the scene was last posed. It gives the surfel's part and its heaviest bone (in a scene joined from pieces,
joinPixelScenes()says whose those are) and where it is in the world. Worked out on the CPU, on a tap, not a frame.pick(clientX: number, clientY: number): { part: number; bone: number; at: Vec3 } | undefinedplay()Starts the stage drawing by itself: every frame while the scene plays, and after any change.
play(): voidpause()Holds the scene still at the moment last drawn (
time); the stage still draws after a change.pause(): voidstop()Stops the stage drawing by itself altogether: frames come only from
frame.stop(): voidinvalidate()Marks the picture as wanting to be drawn again (the stage's box changed size).
invalidate(): voidframe()Draws one frame now: the scene at
tseconds into its loop, with the water left as it is (step it withstepWater).frame(t?: number): voidstepWater()Moves the water on by
secondsin fixed ticks, withdropsseeded raindrops landing as it starts: for checks.stepWater(seconds: number, drops?: number): voidread()The art as it was last drawn: RGBA bytes, rows from the bottom.
read(): Uint8Arraydispose()Lets go of the canvas's graphics context.
dispose(): void
Playing a scene on a pixel stage
A scene played on a PixelStage with everything that goes with it: its water, its fires, the weather over it (clouds, rain, snow, snow lying, wind, lightning), its moon and stars and a sky effect (an aurora, a meteor shower). The engine's ScenePlayer works those out each frame; what is here hands them to the stage, so a page does not have to.
const scene = playableScene(doc, { time: 'night' })
const cut = cutPixelScene(scene.source, { spacing: 0.017 }) // in a worker, in an app
const play = new ScenePlay(stage, scene, { weather: 'rain' })
play.show(cut)
stage.play()Three layers, each usable alone: playableScene() makes a description ready to cut and play (set in a time of day where asked); pixelPlayerFor() is one PixelPlayer wired to one ScenePlayer for a sky that something else eases (what blobscape.dev's Diorama uses); ScenePlay keeps the sky itself and makes the players again when the weather asks for it.
pixelView()function
Where a PixelPlayer's view starts, from a scene's own view (CompiledScene.orbit, a PlayedScene's first view): the picture's height shows as much of the world as the engine's Stage camera shows there, so a scene is framed as written.
backdropOf()function
A backdrop as a PixelPlayer takes it (sRGB 0 to 1) from a scene's sky, top and bottom, given 0 to 255 (a description's) or already 0 to 1; anything after the two (a sky's reach) is let be.
sunAngles()function
A way toward the sun as a PixelLight's turn round the upright and height, in degrees.
sunAngles(options: readonly number[]): { sunTurn: number; sunHeight: number }PlayableSceneinterface
What playableScene() makes: a description ready to cut and to play.
Properties
docSceneDocThe description as it is cut: set in its time of day where one was asked for (lamps lit or out, its sky).
compiledCompiledSceneThat description compiled.
sourcePixelCutSourceWhat
cutPixelScene()takes to cut it.playedPlayedSceneThe scene as something that plays (
ScenePlayer,pixelPlayerFor(),ScenePlay).sunVec3The way toward its sun: the time of day's, else its description's own light.
lightPartial<PixelLight>The light as the scene has it, to lay on a stage with
setLight(its sun's place, and as much light from all round as its baked shade keeps, at most 0.45).
PlayableOptionsinterface
How playableScene() makes a scene.
Properties
playableScene()function
A scene description made ready to cut and play on a PixelStage: compiled, with what cutPixelScene() needs and the scene as something that plays. With time it is set in that time of day as blobscape.dev's Diorama sets one: its sky, a light that dims everything but its lamps, its lamps and fires lit only in the dark, and at night what glows only to keep its color (a cloud, a flower) lit by the night like the rest. Compiling takes a moment; cut in a worker.
playableScene(doc: SceneDoc, options?: PlayableOptions): PlayableSceneEasedSkyinterface
A sky on its way somewhere (a SkyEase): the sky at a moment on the wall clock, and the sky asked for.
Properties
targetSkyStateread onlyThe sky asked for.
Methods
at()The sky at
now, in seconds on the wall clock (Infinity: where it is going).at(now: number): SkyState
PixelPlayOptionsinterface
How pixelPlayerFor() plays a scene.
Properties
weatherbooleanWhether the weather plays (rain, snow, clouds, wind on the scene, the scene dimmed and grayed under the sky): true for any sky not clear. A scene with clouds of its own has them either way.
overheadbooleanoptionalWhether clouds stand over the scene (true when left out) or only what falls is drawn.
skyEffectSkyEffectIdoptionalThe sky effect behind the scene, if any: out only at night under a clear enough sky, and only where the scene is under the open sky.
calmbooleanoptionalTrue where the visitor asks for less motion: a storm's lightning is left out.
offscreenbooleanoptionalTrue where frames are drawn on demand (
PixelStage.frame, for a check or an export): nothing eases and snow lies at once.pilenumberoptionalOff screen, how far snow lying and the water's ice have come, 0 to 1 (all of it where left out).
glownumberoptionalThe Glow setting: the scene's own (
finish.glow) leaves its lights as written.stepsPlayerStepsoptionalMore to do each frame (
ScenePlayer's steps).
PixelPlaying<T extends PlayedScene>interface
One scene playing on a stage: what pixelPlayerFor() makes.
Properties
playerPixelPlayerThe player to hand the stage (
setScene, orsetPlayerfor the cut on show).scenePlayerScenePlayerThe engine's player that works out the water, fires, weather and sky effects; its
extrasgo toPixelStage.setExtras.dressedTThe scene as it is posed and lit: under the sky of the moment where the weather plays.
pixelPlayerFor()function
A PixelPlayer for a scene on a stage, with a ScenePlayer worked from its pose each frame: it poses the scene and moves its fires, weather, snow lying, moon and stars and sky effect, lights it, and hands the stage the backdrop of the moment, the haze, the clouds, what falls, the aurora, the meteors and the scene's water (its swells, the wind's waves, the rain's rings, foam and spray). bones are the cut's (PixelScene.bones). Hand the stage both:
const p = pixelPlayerFor(stage, scene, cut.bones, { sky, weather: true })
stage.setScene(cut, p.player)
stage.setExtras(p.scenePlayer.extras)The stage draws the water's surface, the sunbeams through windows, the clouds, the rain and snow and the sky effects itself, and takes a room's near walls away itself, so the sun still sees them. A pool of lava or potion is drawn the same way, from its glow (or its dye, froth and swell) a cell.
pixelPlayerFor<T extends PlayedScene>(stage: PixelStage, scene: T, bones: readonly Bone[], options: PixelPlayOptions): PixelPlaying<T>ScenePlaySkyinterface
The weather and sky a ScenePlay plays a scene under. Anything left out is none (or, for overhead, true).
Properties
cloudsCloudIdoptionalA cloud cover (
CLOUD_COVERS), where no weather is asked for.overheadbooleanoptionalWhether clouds stand over the scene (true when left out) or only what falls is drawn.
skyEffectSkyEffectIdoptionalA sky effect (
SKY_EFFECTS): out only at night under a clear enough sky.
ScenePlayOptionsinterface
How a ScenePlay plays: its sky, and the page's own facts.
Plus everything in ScenePlaySky.
Properties
calmbooleanoptionalTrue where the visitor asks for less motion: the sky changes at once and a storm's lightning is left out.
offscreenbooleanoptionalTrue where frames are drawn on demand (
PixelStage.frame, for a check or an export): nothing eases.stepsPlayerStepsoptionalMore to do each frame (
ScenePlayer's steps).
ScenePlayclass
A scene played on a stage under a weather that can change: it keeps the sky (eased over a few seconds from one weather to the next) and makes the players again when the weather comes or goes. What the scene's setting leaves no room for (weather in a room, wind under water) is left out whatever is asked, as it is on blobscape.dev.
const play = new ScenePlay(stage, playableScene(doc), { weather: 'snow' })
play.show(cut) // the cut of that scene: cutPixelScene(scene.source, ...)
play.setSky({ weather: 'thunderstorm', wind: 'gale' })Constructor
new ScenePlay(stage: PixelStage, scene: PlayableScene | PlayedScene, options?: ScenePlayOptions)Properties
stagePixelStageread onlyThe stage it plays on.
scenePlayedSceneread onlyThe scene as something that plays.
lightPartial<PixelLight>read onlyThe scene's light (its sun's place and its shade), laid on the stage by
showand bysetStyle, under what the style says.playerPixelPlayer | undefinedread onlyThe stage's player for the cut on show (none before
show).scenePlayerScenePlayer | undefinedread onlyThe engine's player for the cut on show: its water, fires, weather and sky effect (none before
show).targetSkyStateread onlyThe sky asked for.
Methods
show()Puts a cut of the scene on the stage, with its loose things and its light.
keepViewkeeps the view where it is (the same scene cut again).show(cut: PixelScene, keepView?: boolean): voidsetStyle()Puts a style on the stage (
PixelStage.setStyle) and lays the scene's sun on it again, which a style on its own takes back to the stage's default. The style's own light settings win over the scene's shade; a style with no light worked out (light: null) is left so.setStyle(style: PixelStyle): voidsetSky()Plays the scene under another sky: the sky eases there, and the players are made again where the weather comes or goes.
setSky(sky: ScenePlaySky): void
The scene player
What plays a scene. A scene is more than its own blobs and pose: its water, its fires, its sunbeams, the weather over it, the sky effect behind it, the shared moon and stars, the snow that lies on it and the taps that poke it are each made once and each moved every frame, in an order that matters (the wind blows after the pose, floats ride the water after the bones are worked out, lights follow the flames). A ScenePlayer makes them for one cut of one scene and runs that order, so a page gives it a stage to draw on and the facts of the moment and need know no more.
const player = new ScenePlayer(scene, built, { weather: true })
stage.setActor(built, undefined, player.extras)
stage.setPoser((sk, t) => player.frame(sk, t, { sky, target, eye, wall: performance.now() / 1000, glow }))A page or an experiment adds to the routine through steps(), never by copying it: posed runs once the scene and the wind have set the bones' turns and sizes and before they are worked out, worked once they are (pieces of the scene that are actors of their own are posed there, as Scene Creator's props are). A step that proves its worth becomes a part of frame itself. Whatever a page already holds (water or weather made for a composed scene) is handed in through the options in place of what the player would make.
It keeps two clocks of its own, both the wall's: how deep snow lies, and how the fires burn under the weather. No loop of the scene knows how long it has been snowing.
PlayerHostinterface
What a player needs of whatever draws the scene.
Methods
reshape()Sends an actor's shapes and colors up again after the player changed them.
reshape(actor: Actor): voidsetLights()Sets the lights and the light from all round.
setLights(lights: PointLight[], ambient: number | readonly [number, number, number]): voidrecolor()optionalSends a stretch of an actor's colors up again: where the lamps' light thrown off the water lands (
glints).recolor(actor: Actor, from?: number, to?: number): void
PlayerOptionsinterface
What a player is made with.
Properties
dressedPlayedSceneoptionalThe scene as it stands under the sky of the moment (
underSky()), where weather is on: its pose, wind, lights and sky are asked of this one. The scene itself when left out.weatherboolean | SceneWeather | nulloptionalWhether weather is wanted at all (a scene with clouds of its own has them either way); or the weather itself where the page has made it for a scene put together from pieces,
nullfor none.overheadbooleanoptionalWhether clouds stand over the scene (true when left out) or only what falls is drawn.
surfacebooleanoptionalFalse where the host draws the water's surface itself from the water's own heights (the pixel renderer): the surface's blobs are then not among the extras, and
wetsets the heights, the foam and the spray without shading them.skyEffectSkyEffectIdoptionalThe sky effect behind the scene, if any.
effectDrawnbooleanoptionalTrue where the host draws the sky effect itself from
aurora()andmeteors()(the pixel stage's backdrop): its blobs are then left out ofextras.cloudsDrawnbooleanoptionalTrue where the host draws the clouds itself from
clouds()(the pixel stage marches them): the cloud actor is then left out ofextras.fallsDrawnbooleanoptionalTrue where the host simulates what falls itself from
falling()(the pixel stage, fallSim.ts): the rain and snow actors are then left out ofextras.waterSceneWater | nulloptionalThe scene's water where the page has made it itself (for a scene put together from pieces):
nullfor none, left out for the player to make the scene's own.fireSceneFire | nulloptionalIts fires, likewise.
beamsSceneBeams | nulloptionalIts sunbeams, likewise.
cloudsnumberoptionalHow much cloud the scene has of its own, 0 to 1, where the page knows better than the scene's
heavens.floatsbooleanoptionalWhether what floats rides the water on the scene's own bones (true when left out): false where the water was made for other bones than the ones posed.
pokesbooleanoptionalWhether taps poke the scene (true when left out).
lightsbooleanoptionalWhether the player sets the lights (true when left out): false where the page gathers them from several pieces itself.
stepsPlayerStepsoptionalMore to do each frame, at two moments of the routine.
glintsActoroptionalThe scene's own cut, where its water asks for
caustics: the lamps' light thrown back off the ripples is laid on its colors near the water each time the water is shaped (wet), through the host'srecolor. Left out, none.
StepFactsinterface
What a step is told: the moment's wind as it carries what falls, its level, the cloud over the scene (0 to 1) and the frame's own facts.
Properties
windreadonly [number, number]The wind on the scene as it carries what falls: how far sideways a unit of fall, along x and z.
levelnumberThe wind's level (
WINDS, 0 calm).covernumberHow much cloud is over the scene, 0 to 1.
framePlayerFrameThe frame's own facts.
gust{ wind: readonly [number, number]; level: number }The wind out of doors, where it differs from the wind on the scene: seen from a room, what stands outside its opening is blown though nothing indoors is.
Methods
outside()Whether a spot on the ground is out of doors: everywhere under the open sky, a room's square of outdoors, nowhere where no weather reaches.
outside(x: number, z: number): boolean
PlayerStepsinterface
Steps a page or an experiment adds to the routine.
Methods
posed()optionalAfter the scene's pose and the wind, before the bones are worked out: turn or size the scene's own bones here.
PlayerFrameinterface
The facts of one frame.
Properties
skySkyStateThe sky of the moment, on its way to
target.targetSkyStateThe sky asked for.
eyereadonly [number, number, number]Where the eye is.
wallnumberThe wall clock, in seconds.
glownumberThe Glow setting (the scene's own
finish.glowleaves its lights as written).shadowsbooleanoptionalWhether lights that cast live shadows are wanted.
heldbooleanoptionalHeld for an export: the scene's own loop and nothing else, so no pokes, and snow and fires stay as they stand.
offscreenbooleanoptionalOff screen, for a check: nothing eases, and snow lies
piledeep at once while it falls.pilenumberoptionalHow deep snow lies off screen while it falls, 0 to 1 (all of it when left out).
posebooleanoptionalFalse holds the scene's own bones as they are (a cut that does not match the scene yet); everything else still plays.
ScenePlayerclass
Plays one cut of one scene with its water, fires, sunbeams, weather, sky effect, moon and stars: see the top of this file.
Constructor
new ScenePlayer(scene: PlayedScene, built: Pick<Built, "skeleton">, options?: PlayerOptions)Properties
scenePlayedSceneread onlyThe scene.
dressedPlayedSceneread onlyThe scene as it is posed and lit: under the sky of the moment where weather is on.
waterSceneWater | undefinedread onlyIts water, where it has some.
fireSceneFire | undefinedread onlyIts fires, where it has some burning.
beamsSceneBeams | undefinedread onlyIts sunbeams in the air, where it has some.
weatherSceneWeather | undefinedread onlyThe weather over it (rain, snow, clouds, snow lying), where any plays.
effectSceneSkyEffect | undefinedread onlyThe sky effect behind it, where one is asked for.
extrasActor[]read onlyEvery actor to draw beside the scene's own, in the order they are drawn.
pokesPokesread onlyTaps on the scene.
Methods
frame()One frame: poses the scene's bones for
tseconds into its loop and moves everything that goes with it, then sets the lights.skis the scene's skeleton, which is left worked out (updated). The order is the scene's pose, the weather, snow lying, rain and wind on the water, the wind on the scene, the moon and stars, the sky effect, sunbeams, cut-away walls, the bones worked out, floats, pokes, snow riding what moves, fires, lights.frame(sk: Skeleton, t: number, f: PlayerFrame, host: PlayerHost): voidclouds()The clouds as they stand just now, for a host that draws them itself (
cloudsDrawn). Nothing where none are out.calmleaves a storm's lightning out of them.clouds(calm?: boolean): CloudSky | undefinedfalling()What falls just now and the wind that carries it, for a host that simulates it itself (
fallsDrawn). Nothing where there is no weather. Where a loop must join (held,offscreen) it says so, with the loop and its wind, so the host can make what falls join too.falling(): { rain: number; snow: number; wind: [number, number]; at: [number, number]; half: number; top: number; loop?: { length: number; t: number; wind: (t: number) => [number, number] } } | undefinedaurora()The aurora as it stands just now, for a host that draws it itself (
effectDrawn): each curtain's foot and brightness round the sky, how much of it is out and the share of its loop gone by. Nothing where there is no aurora.aurora(): { rows: Float32Array; out: number; share: number } | undefinedmeteors()The meteors in the sky just now, for a host that draws them itself (
effectDrawn), with how much of the shower is out. Nothing where there is no shower.meteors(): { streaks: Float32Array; count: number; out: number } | undefinedeffectLights()The light the sky effect throws just now, for a page that gathers the lights itself.
effectLights(): PointLight[]light()Sets the scene's lights for a time and a Glow setting: its own, its fires' as bright as they burn, the sky effect's.
light(t: number, glow: number, host: PlayerHost, shadows?: boolean): voidrelease()Puts the cut's own colors back where caustics were laid on them: when the player is done with it.
release(): voidwet()Shapes and colors the water's surface for a time, an eye and the last picture of what it mirrors: after a pose, a turn of the view, or a new picture in the mirror.
wet(t: number, eye: readonly [number, number, number], host: PlayerHost, mirror?: MirrorImage | null): void
What the scene player plays
PlayedSceneinterface
A scene as something that plays: what a ScenePlayer (scenePlayer.ts) needs of it each frame, and nothing a page shows about it (its name, its list of views, its statistics). A page's own scene type holds these fields and more.
Properties
loopnumberSeconds before everything repeats.
views{ orbit: Orbit }[]Its views, the first the one it starts in: weather and sky effects are placed by it.
finish{ glow: number }How strongly its own description glows: the Glow setting is measured against it.
swingnumberDegrees the view rocks to either side once a loop (0 for none).
ambientnumber | readonly [number, number, number]optionalThe light from all round: a share or a color (linear).
ambientAt(t: number) => number | [number, number, number]optionalThe same by the time, for a scene whose light changes as it plays: used in place of
ambient.shadowDensitynumberoptionalHow fast blobs in the way dim a live light.
haze{ color: [number, number, number]; from: number; to: number }optionalIts haze: its color (linear) and where it starts and would be total, in units past the view's target.
hazeAt(distance: number) => { color: [number, number, number]; from: number; to: number } | undefinedoptionalIts haze seen from a distance, for a scene whose air changes (weather over it): used in place of
haze.heavensHeavensDocoptionalThe shared moon, sun, stars and clouds it asks for.
ground(x: number, z: number, top: number, bottom: number) => numberoptionalThe height of the still ground under a point, looking down from
top(bottomwhere nothing is): what weather lands on.lying(x: number, z: number, top: number, bottom: number) => { y: number; bone: number }optionalWhere snow lies under a point, on moving things too, with the bone that carries it.
bonesreadonly Bone[]optionalIts bones as compiled, which
lyingnumbers.sunreadonly [number, number, number]optionalThe way to its sun.
outdoors{ at: [number, number]; half: number; top: number }optionalA room's square of outdoors, where the weather falls.
exposureExposureoptionalHow the sky reaches it (setting.ts): where weather falls, whether wind moves it, whether its fires and water answer the weather. Open when left out.
cutAway(sk: Skeleton, eye: readonly [number, number, number]) => voidoptionalTakes away what would hide the scene from where the eye stands.
water() => SceneWateroptionalIts water, made once when first asked.
fire() => SceneFireoptionalIts fires, made once when first asked.
beams() => SceneBeamsoptionalIts sunbeams, made once when first asked.
Methods
pose()Poses its bones for a time in the loop.
pose(sk: Skeleton, t: number): voidblow()optionalBlows what the wind moves, after the pose: what falls, what sways, what turns.
blow(sk: Skeleton, t: number, wind: readonly [number, number], wrap?: { at: readonly [number, number]; half: number }, level?: number): voidlights()Its lights at a time;
shadowsasks for the ones that cast live shadows.lights(t: number, shadows?: boolean): PointLight[]
PlayedWeatherclass
The engine's SceneWeather for a played scene: its rain, snow and clouds, made once and posed by time and sky.
Plus everything in SceneWeather.
Constructor
new PlayedWeather(d: PlayedScene, options?: { overhead?: boolean })underSky()function
A scene as it stands under a sky that sky() gives for the moment: its light multiplied, its sky grayed and darkened, lightning in both, and haze by the view's distance. Everything else is the scene's own, so it is drawn as any scene whose sky and light change as it plays.
underSky<T extends PlayedScene>(d: T, sky: () => SkyState, calm?: boolean): TSceneSkyEffectclass
A sky effect laid behind a scene (skyEffects.ts has the recipes): an actor of its own beside the scene's, made once a scene and effect, and shown by how much a night the sky is and how clear. The scene itself is never cut again for it.
Constructor
new SceneSkyEffect(d: PlayedScene, id: SkyEffectId)Properties
idSkyEffectIdread onlyWhich effect it is.
actorActorread onlyThe effect's blobs, to draw beside the scene's: cut when first asked for.
Methods
pose()Poses it for
tseconds withoutof it showing (effectOut); its blobs only where they have been asked for.pose(t: number, out: number): voidcurtains()The aurora simulated (aurora.ts) as it stands at the moment last posed: each curtain's foot and brightness round the sky, and the share of the loop gone by. For a host that draws the aurora itself in place of its blobs; nothing for another effect. The loop is played when first asked for.
curtains(): { rows: Float32Array; share: number } | undefinedstreaks()The meteor shower simulated (meteors.ts) as it stands at the moment last posed: the meteors in the sky, the brightest first (
METEOR_FLOATSnumbers each), and how many. For a host that draws them itself; nothing for another effect.streaks(): { streaks: Float32Array; count: number } | undefinedlights()The light it throws onto the scene, if any: brighter and dimmer with a simulated aurora.
lights(out: number): PointLight[]
Sky effects: an aurora and meteors
Sky effects (Matt, 2026-11-22: the lantern grove's aurora as a scene effect of its own, which lives in the sky behind a scene rather than falling on it as weather does; a meteor shower is the second): recipes any scene takes the same way, laid behind it and never cut into it. Pure and tested.
An effect is a small description of its own (skyEffectDoc), placed by the scene's starting view so it fills the sky behind whatever scene it is laid over, and shown only at night under a clear enough sky (effectOut), going out with the stars as clouds come over.
SkyEffectIdtype
A sky effect's name: an aurora or a meteor shower.
"aurora" | "meteors"SKY_EFFECTSvalue
The sky effects there are, each with its name, a label and a line for a page.
readonly SkyEffect[]Cutting a scene into surfels
PixelSceneinterface
A scene cut for the pixel renderer: plain data, made once (in a worker, as a rule) and handed to a PixelStage. Its big arrays can be moved between threads rather than copied (pixelSceneBuffers()).
Properties
countnumberHow many surfels there are.
solidnumberHow many of them are solid surfaces: the first
solid; the rest are glass.reachnumberHow far the furthest surfel is from the origin, in the scene's units.
sunReachnumberoptionalHow far about the origin the sun's shadow map reaches, where that is less than
reach: a creature on a wide floor keeps the map fitted to itself, so its shadow is crisp (what lies outside the map is in the sun). Left out,reach.spacingnumberoptionalThe grid's spacing it was cut on, in the scene's units (blocks are whole cells of it).
bonesBone[]The scene's bones in their rest pose.
windowsWindowBeam[]The windows the sun's beams show behind.
secondsnumberHow long the cut took, in seconds.
fromInt32Array<ArrayBufferLike>optionalA creature's cut only (
cutPixelCreature()): which of the creature's blobs each surfel came from, by its index among them (below 0 for a floor's tile: −1 less the tile's number, counted along x and then z), in the surfel table's order. A page that recolors blobs (a floor that burns) finds their surfels by it and hands them toPixelStage.recolorSurfels. Placing or joining the cut leaves it out.
PixelCutSourceinterface
What is cut: a builder of the scene's blobs at a spacing and, where it was written as a description, the compiled description.
Properties
compiledCompiledSceneoptionalThe compiled description: its parts say what is glass, its shapes cast the lamps' shadows, and its water and windows are drawn.
loopnumberoptionalHow long the scene's loop is, in seconds:
poseis looked at across it.
Methods
PixelCutOptionsinterface
How a scene is cut for the pixel renderer.
Properties
spacingnumberThe grid's spacing, in the scene's units: about half an art pixel or less.
livebooleanoptionalTrue (as a rule) cuts the scene with no light in its colors, for the stage to light; false keeps the description's baked light.
cutPixelScene()function
Cuts a scene for the pixel renderer: its blobs as surfels (glass after the solid ones, each turned to face out of its part), its bones, and from a compiled description the distance field, the water and the windows. Slow (seconds): run it in a worker and hand the result over with pixelSceneBuffers().
cutPixelScene(src: PixelCutSource, options: PixelCutOptions): PixelScenePixelPondinterface
A pond a page works out for itself (water.ts Water, stepped on the page, moved by whatever wades through it), to lay on a cut that has no water of its own. Lengths are in the scene's units; colors are linear.
Properties
x0numberThe grid's corner along x.
z0numberThe grid's corner along z.
nxnumberCells along x.
nznumberCells along z.
cellnumberA cell's side.
levelnumberThe height its still surface stands at.
floornumberThe height of its lowest bed: seen from the side, the water lies between this and its level.
wetArrayLike<number>Not 0 where a cell holds water, a number a cell, x fastest.
speednumberoptionalHow fast a ring travels, units a second (a tap's rings, which the stage steps itself).
dampingnumberoptionalThe share of its motion the water loses a second (a tap's rings).
ripplenumberoptionalHow many times steeper than it is the surface is drawn: ripples a few millimeters high hardly show at their true slope.
splash{ r: number; depth: number }optionalA tap's mark: its half width and depth.
body[number, number, number]optionalThe water's own color.
sky[number, number, number]optionalThe sky it mirrors overhead.
horizon[number, number, number]optionalThe sky it mirrors low down.
withPixelWater()function
A cut with a pond laid on it that the page steps itself: hand its heights to the stage each frame with PixelStage.setWaterField (a height a cell over level, on this grid), and the stage draws its surface, what lies under it and what it mirrors. Any water the cut had is replaced. The cut handed in is left as it was.
withPixelWater(scene: PixelScene, pond: PixelPond): PixelScenepixelSceneBuffers()function
The buffers of a cut scene to move, not copy, when it is posted from a worker.
pixelSceneBuffers(s: PixelScene): ArrayBuffer[]Cutting a creature into surfels
PixelCreatureinterface
A rigged body to cut: an engine Creature, with what some carry.
Plus everything in Creature.
Properties
partOfArrayLike<number>optionalWhich part each blob came from (lines between parts, and what a tap picks).
glowArrayLike<number>optionalHow much of its own light each blob gives, a byte a blob (the dragon's eyes and breath).
morphsMorph[]optionalIts blend shapes, on its rest blobs.
spacingnumberoptionalThe grid it was cut on, where it was sculpted (blocks are whole cells of it).
jointsUint16Array<ArrayBufferLike>optionalIts bones' numbers, four a blob, in place of the skin's own (which are bytes), for a body of more than 256 bones: many rigs joined into one, as a walk through a forest is. The skin's weights still say how much each counts.
paintedPaintedoptionalWhich blobs have a paint written as data, and the paints (voxel.ts
painted(), creaturePaint.ts): the renderer works those out a pixel at a time in the rest pose. The rest keep their blobs' own colors.
PixelFloorinterface
A floor of flat surfels under a creature, in tiles of two colors or each of a color of its own.
Properties
halfnumberHalf its side, in the creature's units.
tilenumberoptionalA tile's side; 0 for one color.
colors[[number, number, number], [number, number, number]]optionalIts two colors, sRGB 0 to 1.
colorAt(x: number, z: number, xi: number, zi: number) => [number, number, number]optionalA tile's own color in place of the two (sRGB 0 to 1), asked once a tile: its middle, and which tile it is along x and along z, counted from the floor's low corner. Needs
tile.ynumberoptionalIts height.
PixelFaceinterface
A flat square laid by hand beside a creature's own surfels (a wall's brick, a ceiling's slab): drawn square to the edge as a floor's tile is, and seen only from the side its u × v points to.
Properties
at[number, number, number]Its middle.
u[number, number, number]Its two half sides: it reaches each one's length each way from the middle, and its outside is the way
u×vpoints.v[number, number, number]The other half side.
color[number, number, number]Its color, sRGB 0 to 1.
bonenumberoptionalThe bone of the creature's that carries it; left out, the floor's own (which never moves).
PixelCreatureOptionsinterface
How a creature is cut for the pixel renderer.
Properties
livebooleanoptionalTrue (as a rule) cuts it with no light in its colors, for the stage to light; false keeps the light it was made with.
floorPixelFlooroptionalA floor to stand it on, on a bone of its own after the creature's.
facesreadonly PixelFace[]optionalSquares laid by hand, after the floor's tiles in the surfel table: in
PixelScene.fromfacekis −1 less the floor's tiles lessk. One with noboneneeds afloor.castsArrayLike<number>optionalA byte a bone of the creature, 1 where what the bone carries casts the lamps' shadows through a stand-in. A cut of more than 256 bones has stand-ins only for the bones named here (a hall's hero among hundreds of pooled bones); a smaller one has them for every moving bone unless this names some. Bones that share a number over 1 cast as one thing: one stand-in round all they carry, riding the first of them (a crate cut into pieces on bones of their own, a slime's body on three). With this given a cut keeps up to 96 stand-ins, of which the stage's lamps look at the nearest few each frame.
stillArrayLike<number>optionalA byte a bone of the creature, 1 where the bone never moves (a hall's walls, its floor): the surfels that ride only such bones are made into a distance field, through which the stage's lamps cast shadows. Left out, there is none.
cutPixelCreature()function
Cuts a rigged creature for the pixel renderer: make builds it (run with no light baked in, and with sculpted discs set down on their shapes' surfaces), and its blobs become surfels that bend with all four of their bones, stretch between them, and take its morphs. The cut's bones are the creature's, a PixelPlayer poses them as the creature's moves do, and gives its morphs' weights with morphs. Picking gives the bone a surfel leans on most.
A creature's skin names its bones in a byte each, so 256 at most (with a floor, 255), unless it gives their numbers in full (joints): then up to 2048. A cut of more than 256 bones is never drawn as cubes and has no stand-ins for the lamps' shadows, since a surfel's own record names two bones in a byte each.
cutPixelCreature(make: () => PixelCreature, options?: PixelCreatureOptions): PixelScenemorphTargetWeights()function
Each morph target's weight for the morphs' weights (in-betweens shared as morph.ts targetWeights() shares them), from how many targets each morph has.
morphTargetWeights(targets: readonly number[], weights: ArrayLike<number>, out?: Float32Array<ArrayBuffer>): Float32ArrayCuts kept as files
BAKED_MAGICvalue
What a baked cut's bytes begin with; the digit is the file's version.
"BPIX1\n"packPixelScene()function
A cut as a baked file's bytes. Reading them back with unpackPixelScene() gives the same cut, number for number.
packPixelScene(scene: PixelScene): Promise<Uint8Array<ArrayBufferLike>>unpackPixelScene()function
The cut a baked file holds. Throws when the bytes are not a baked cut this version reads, or are cut short.
unpackPixelScene(bytes: Uint8Array): Promise<PixelScene>inMortonOrder()function
The same cut with its solid surfels, and then its glass ones, in order along a space-filling curve through their middles. A cut that names surfels by their place (a skin, morphs, from) is handed back as it is.
inMortonOrder(scene: PixelScene): PixelSceneroundedCut()function
The same cut with its numbers rounded to steps far finer than can be seen: each middle to a 64th of the cut's spacing or finer, each half-axis to a 256th, glow and a surfel's two own numbers to a 256th. The steps are powers of two, so the low bits of every such float are zero and a baked file of it is a third to a quarter the size (the lighthouse at three times Standard: 30 MB exact, 6.9 MB rounded). A cut with no spacing is rounded by a 3,000th of its reach. Whole numbers in the record (bones, paint, ids, kind) are never touched, nor is a skin or a morph.
roundedCut(scene: PixelScene): PixelSceneMelted shapes drawn by marching
A melt (pure): soft shapes joined smoothly into one surface that changes every frame, such as the wax of a lava lamp, drawn by the pixel renderer by marching each art pixel's line of sight through its distance (renderer.ts MELT_FRAG), so it is round to the pixel with no surfels to cut again. It is written into the picture's buffers before the light, as any surface is: lit a pixel at a time, behind glass and tinted by it, and glowing where it is hot. meltDistance() is the CPU twin of the shader's distance (change both).
Shapes are MELT_FLOATS numbers each, in the melt's own frame (PixelMelt.at is its origin in the scene):
ellipsoid (kind 0): middle xyz, kind | the way it is drawn out xyz (unit), its radius that way |
its radius across, how far its join reaches, its heat (0 to 1), its wobble's phase
tube (kind 1): one end xyz, kind | the other end xyz, its radius at the first |
its radius at the second, how far its join reaches, its heat, 0Every shape is joined to those before it by a smooth minimum over its own reach (the pool first; a cubic one, so the surface's curvature runs on smoothly across a join and no band of light shows where the join starts), and the whole is kept inside an upright container (a radius a height, container).
MAX_MELT_SHAPESvalue
The most shapes a melt has.
32MELT_FLOATSvalue
Numbers a shape.
12MELT_RADIIvalue
How many radii the container's profile is given as, evenly from its floor to its top.
24MELT_WOBBLEvalue
How deep a shape's wobble runs, as a share of its radius across, and how fine it is (waves a unit).
0.07PixelMeltinterface
A melt as it stands at a moment (PixelStage.setMelt). Lengths are in the scene's units, in the melt's own frame.
Properties
atVec3Where the melt's own frame stands in the scene (its floor's middle).
shapesFloat32ArrayThe shapes,
MELT_FLOATSnumbers each (see melt.ts).countnumberHow many shapes there are, at most
MAX_MELT_SHAPES.pool{ depth: number; heat: number; swell: number; edge?: number }optionalA layer of it on the container's floor: how deep it lies, how hot it is (0 to 1), how much its top swells, and how far in from the wall its top rounds down to meet the wall (left out or 0, it meets it square). Left out, none.
container{ height: number; radii: ArrayLike<number>; inset: number }The upright container it is kept in: its height, its radius at
MELT_RADIIeven heights from its floor to its top, and how far in from the wall the melt stops.coolVec3Its color where it is cold (sRGB, 0 to 1).
hotVec3Its color where it is hottest (sRGB, 0 to 1).
glownumberHow much of its own light its hottest part gives, 0 to 1.
corenumberHow thick (the scene's units) it must be along a line of sight for that line to see its hot core.
timenumberThe seconds its skin's wobble and the pool's swell are at.
partnumberoptionalThe part number its pixels carry, for the lines drawn between things. Left out, one no scene uses.
wobblenumberoptionalHow deep its skin's wobble runs, as a share of a shape's radius across. Left out,
MELT_WOBBLE.shinenumberoptionalHow far its hot core whitens it where a line of sight runs through it thickly, 0 to 1. Left out, 0.45.
rimnumberoptionalHow much darker it is where its skin is seen at a slant, 0 to 1. Left out, 0.3.
meltRadius()function
The container's radius at a height over its floor.
meltRadius(m: PixelMelt, y: number): numbermeltDistance()function
How far a point (in the melt's own frame) is from the melt's surface, negative inside, and how hot the nearest shape is.
meltDistance(m: PixelMelt, x: number, y: number, z: number): { distance: number; heat: number }Joining cut scenes
JoinedSceneinterface
Several cuts joined into one for a stage, and where each piece's bones, parts and surfels are in it.
Properties
scenePixelSceneThe one scene a stage draws.
pieces{ bone: number; bones: number; part: number; parts: number }[]For each piece, in the order given: its first bone in the joined scene, how many it has, and its first part.
joinPixelScenes()function
Joins cuts made apart (a land and each prop set down on it) into one scene for a PixelStage. Nothing is cut again: each piece keeps its own bones (the first piece's under their own names, so a pose written for it finds them; the others' as <piece>/<bone>), so a piece is moved, turned or sized by posing its root bones, and its paint, which is worked out where a pixel lies in the piece's rest pose, rides with it. The distance field (what stands in a lamp's way) is the first piece's that has one with every other piece's still surfels laid into it (surfelField, on that field's grid), so props set down cast the lamps' shadows too; the moving things' stand-ins are every piece's, the biggest kept. The water and the windows are the first piece's that has them (the land's), and the grid's spacing (which blocks are whole cells of) is the first piece's.
A creature's skin and morphs (creature.ts) come with it: where any piece has a skin, every surfel has a skin record.
A surfel names its bones in a byte each and its part in MAX_IDS, so the pieces together may have at most 255 bones.
joinPixelScenes(pieces: readonly PixelScene[]): JoinedSceneSetting a cut scene down elsewhere
placePixelScene()function
A cut set down somewhere else: every surfel and bone moved, turned and sized by a placement (placer() in place.ts), and every paint's map back to where it was written carried through it, so paint worked out a pixel at a time stays on the thing. Nothing is cut again, so a prop cut once where it was written is set down, turned and moved for the cost of a copy; a creature's skin and morphs (creature.ts) go with it. The cut handed in is left as it was. What belongs to a place and not to a thing (the distance field, water, windows) is kept only by a placement that changes nothing; a stage that joins placed pieces makes a field of their surfels (joinPixelScenes()). Its grid's spacing is sized with it, so blocks stay whole cells of the cut.
With whole the cut is a whole place (a scene written at one size and stood larger, say) that is only moved and sized, not turned: its distance field, water and windows are moved and sized with it and kept. A placement that turns it keeps none of them, whole or not, since the field's grid and the water's lie along the world's axes.
placePixelScene(scene: PixelScene, t: Placer, options?: { whole?: boolean }): PixelScenePixel styles
PixelStyleinterface
Styles for the pixel renderer. A style is data: the settings of the light and of the finish that make its look, laid over a stage's defaults by PixelStage.setStyle. Nothing here draws; a style that needs something the renderer cannot yet do gets that added to the renderer as a setting first, which every other style can then use.
Properties
idstringIts name in an address or a saved scene.
labelstringWhat a person calls it.
aboutstringOne line on what it looks like.
lightPartial<PixelLight> | nulloptionalThe light's settings it changes;
nullfor no light worked out at all (the cut's own colors).lookPartial<PixelStageLook>optionalThe finish's settings it changes.
PIXEL_STYLESvalue
The styles, the first the one a stage starts in.
PixelStyle[]pixelStylevalue
The style called id, or the first.
(id: string | null | undefined) => PixelStylePixel styles' settings
PixelSettingtype
Each style's own settings, as data. A style is the light's and the finish's settings (styles.ts); a setting names one of those numbers by where it is in the style (at: 'look.screen.dot', 'light.steps'), with a label and its limits. So a page draws a style's controls from this list, keeps what a visitor changed as plain values by at, and styleWith() lays them on the style before it goes to PixelStage.setStyle. Nothing here draws.
{ at: string; label: string; hint?: string } & ({ kind: "range"; min: number; max: number; step: number; unit?: "share" | "px" | "degrees" } | { kind: "choice"; options: readonly { id: string; label: string }[] } | { kind: "toggle" } | { kind: "color" } | { kind: "text"; most: number })PixelSettingValuetype
What a setting holds: a number, a choice's id or some words, a switch, or a color as red, green and blue from 0 to 1.
number | string | boolean | readonly [number, number, number]PixelStyleValuestype
What a visitor has changed in one style, by each setting's at.
Record<string, PixelSettingValue>pixelStyleSettings()function
The settings a style offers, in the order a page lays them out.
pixelStyleSettings(style: PixelStyle): PixelSetting[]pixelSettingStart()function
What a setting is at in a style before anyone changes it.
pixelSettingStart(style: PixelStyle, setting: PixelSetting): PixelSettingValuesoundSetting()function
A value as its setting allows it, or undefined for one it does not (an old link, a kept scene from another version).
soundSetting(setting: PixelSetting, v: unknown): PixelSettingValue | undefinedstyleWith()function
A style with a visitor's values laid on it: what goes to PixelStage.setStyle. Values for settings the style lacks are left out.
styleWith(style: PixelStyle, values: PixelStyleValues | undefined): PixelStylesettingText()function
A setting's value as text for an address, and back (undefined for text that is no value of it).
settingText(setting: PixelSetting, v: PixelSettingValue): stringsettingFromText()function
Reads settingText() back.
settingFromText(setting: PixelSetting, text: string): PixelSettingValue | undefinedLines, water, glass, paint and lamps
PixelLampinterface
A lamp the pixel stage lights the scene by: where, its color times its strength (linear), and its reach, the shape of the engine's PointLight. (Not the main entry's Lamp, a lamp whose shadows the cutter bakes.)
Properties
positionreadonly number[]Where it stands, in the scene's units.
colorreadonly number[]Its color times its strength, linear.
rangenumberHow far its light reaches, in the scene's units.
cone{ toward: readonly number[]; angle: number; soft: number; air: number }optionalIt shines one way only (the engine's
LightCone): what is outside the cone getsCONE_SPILLof it, and the air inside shows it.
WindowBeaminterface
A window the sun comes in through (a description's air.windows): its middle, half its width and height, the way its wall faces, the floor its beams land on, their color (linear) and how much they are seen.
Properties
atreadonly number[]The window's middle.
halfreadonly [number, number]Half its width and half its height.
facing"z" | "x"The way its wall faces.
floornumberThe height of the floor its beams land on.
colorreadonly number[]The beams' color, linear.
seennumberHow much the beams are seen in the air, 0 to 1.
PixelWaterLookinterface
How the pixel stage draws the scene's water; every amount is 0 for none. Lengths are in art pixels. (Not the main entry's WaterLook, which colors the blob stage's water surface.)
Properties
refractnumberHow far a ripple bends what is seen through it, in art pixels a unit of slope and of depth.
murknumberHow fast the water takes the color of what is under it, a unit of the way through it.
mirrornumberHow much more than a real surface it mirrors (a real one seen from above mirrors a few parts in a hundred).
foamnumberHow deep the water is where foam still lies along a shore, in the scene's units.
causticsnumberHow strongly ripples gather the sun on the bed.
LineLookinterface
The lines every style draws through: four kinds found from the picture's own buffers, each with its own strength (0 for none, 1 for a full line), a pixel wide on the art's grid, so they ride with the scene as the view slides.
Properties
outlinenumberWhere a thing ends in front of something further off, or of the backdrop: drawn on the near thing's last pixel.
creasesnumberWhere a surface turns sharply (two neighbors' facings further apart than
creaseAngle).partsnumberWhere two parts meet at one depth: drawn on the lower-numbered part's side, so the line keeps its side.
shadowsnumberAlong the edge of a shadow, on its dark side.
creaseAnglenumberoptionalDegrees two facings must differ by for a crease: 40 when left out.
inkreadonly number[]optionalThe ink, sRGB 0 to 1; left out, each line is a darker shade of what it is drawn on.
StrokeLookinterface
Brush strokes: each surface is ruled into strokes that run along it, and a stroke is one color, the paint found at its middle, so paint gathers into masses as a painter lays it.
Properties
kind"gouache" | "oil"Gouache: matte, flat strokes that break up toward their ends. Oil: a ridge down each stroke and a bead along its edges.
lengthnumberA stroke's length, in art pixels.
widthnumberA stroke's width, in art pixels.
varynumberHow much one stroke differs from the next in lightness and warmth, 0 to 1.
ridgesnumberHow strong oil's ridges are, 0 to 1.
ENGRAVINGSvalue
The kinds of engraving, in the order the surfel pass numbers them from 1.
readonly ["hatching", "crosshatching", "stipple", "woodcut"]EngravingLookinterface
Ink on paper: the lit picture's brightness decides, pixel by pixel, whether a mark attached to the surface there takes ink. Darker light brings more of each mark out, so tone is carried by how much ink lies on the paper.
Properties
kind"stipple" | "hatching" | "crosshatching" | "woodcut"Lines round the form, lines crossed by a second set in deep shade, dots, or white lines cut out of black.
spacingnumberHow far apart the lines (or how big the dots' cells) are, in art pixels.
inkreadonly number[]The ink's color, sRGB 0 to 1.
paperreadonly number[]The paper's color, sRGB 0 to 1.
colornumberHow much of each thing's own color shows in its ink and on its paper, 0 (two colors only) to 1.
weightnumberHow much ink there is overall: 1 as it comes, more for a darker print.
PixelCutoutLookinterface
Layers of cut paper (the pixel stage's; the main entry's CutoutLook is the blob stage's filter, sized in CSS pixels, where this one is in art pixels): whatever stands nearer than a pixel, a little way toward the light on the picture, lays a shadow on it, as one sheet of paper does on the sheet behind. The backdrop takes shadows too.
Properties
shadownumberHow far a shadow reaches, in art pixels (up to 16).
strengthnumberHow dark it is, 0 to 1.
softnumberHow soft its far edge is, 0 (one flat shadow) to 1 (fading out).
fromnumberThe way the light comes from on the picture, in degrees: 0 from the right, 90 from above.
grainnumberHow much paper grain shows, 0 to 1.
PixelGlassLookinterface
How the pixel stage draws glass; every amount is 0 for none. Lengths are in art pixels. (Not the main entry's GlassLook, the stained glass look.)
Properties
bendnumberHow far a tilted pane bends what is seen through it, in art pixels.
tintnumberHow much of its own color the glass lays on what is behind it: 1 as its parts say.
shinenumberHow bright the sun's and the lamps' glints on it are.
rimnumberHow bright the line along its edges is.
shadenumberoptionalHow much the glass colors the sun's light that passes through it, 0 to 1: 1 when left out.
Screens: styles drawn over the finished picture
HalftoneScreeninterface
A printed picture: dots of ink on paper, a screen an ink, each at its own angle.
Properties
kind"halftone"Which screen this is.
dotnumberA dot's cell, in CSS pixels.
inks"cmyk" | "mono"Four process inks, or one ink alone.
inkRgb1The one ink's color, sRGB 0 to 1 (with
mono).paperRgb1The paper's color, sRGB 0 to 1.
shiftnumberHow far each plate is off true, in CSS pixels.
TextScreeninterface
The picture as characters in rows: letters by how much ink each lays down, braille dots, or quarter blocks.
Properties
kind"text"Which screen this is.
set"blocks" | "ascii" | "braille" | "words" | "typed"Letters by how much ink each lays down; braille dots; quarter blocks;
wordswritten along every row; a typewriter's strikes, one key or two over one another, a little off line.strokesbooleanoptionalWith
ascii: a cell an edge runs through takes | _ / or \\ instead.wordsstringoptionalWith
words: what is written (capitals, digits and a few signs; at most 64 characters).sizenumberA font pixel, in CSS pixels (a character is 6 by 8 of them).
colornumberHow much of each thing's own color its characters take, 0 (all in
ink) to 1.inkRgb1The characters' own color, sRGB 0 to 1.
groundRgb1The color behind the characters, sRGB 0 to 1.
MosaicScreeninterface
The picture as small tiles set in grout.
Properties
kind"mosaic"Which screen this is.
tilenumberA tile's side, in CSS pixels.
groutnumberThe grout's width between tiles, in CSS pixels.
groutColorRgb1The grout's color, sRGB 0 to 1.
varynumberHow much tiles differ from one another, 0 to 1.
bevelnumberHow deep each tile's bevel is, 0 (flat) to 1.
brickbooleanRows set off by half a tile, as bricks are laid.
CrtScreeninterface
The picture on a picture tube: curved glass, scanlines, color smeared along each line, noise and a rolling band.
Properties
kind"crt"Which screen this is.
curvenumberHow much the glass curves the picture at its corners, 0 (flat) to 1.
scannumberHow dark the gaps between scanlines are, 0 to 1.
bleednumberHow far color smears along each line, 0 to 1.
noisenumberHow much tape noise there is, 0 to 1.
wobblenumberHow much rows wander sideways, 0 to 1; 0 holds still.
ThermalScreeninterface
The picture as a heat camera shows it: what is brightly lit or glows is hot.
Properties
kind"thermal"Which screen this is.
ramp"iron" | "rainbow" | "white"The colors heat is shown in, coolest to hottest: a camera's iron ramp, a rainbow, or black to white.
spreadnumberHow far heat spreads round a thing, in CSS pixels.
noisenumberHow much sensor noise there is, 0 to 1.
BlueprintScreeninterface
The picture as a drawing on blueprint paper: lines where things end and meet, over a ruled grid.
Properties
kind"blueprint"Which screen this is.
paperRgb1The paper's color, sRGB 0 to 1.
inkRgb1The lines' color, sRGB 0 to 1.
gridnumberThe grid's squares, in CSS pixels (every fifth line is heavier); 0 for none.
fillnumberHow much of each thing's own light and dark is washed in under the lines, 0 to 1.
WashScreeninterface
The picture as watercolor: thin paint that runs, pools at its edges and gathers in the paper's tooth, bare paper for the lights.
Properties
kind"wash"Which screen this is.
bleednumberHow far paint runs, in CSS pixels.
edgesnumberHow much darker paint dries where a wash ends, 0 to 1.
grainnumberHow much the paper's tooth shows, 0 to 1.
strengthnumberHow strong the paint is: 1 as it comes, more for deeper color.
pencilnumberA drawn line where things end and meet, 0 (none) to 1, in
line.paperRgb1The paper's color, sRGB 0 to 1.
lineRgb1The drawn line's color, sRGB 0 to 1.
NeonScreeninterface
The picture as tubes of light round every thing, glowing onto dark bodies, a brightness running along them.
Properties
kind"neon"Which screen this is.
reachnumberHow far the tubes' light reaches, in CSS pixels.
glownumberHow strong the tubes' light is: 1 as it comes.
bodynumberHow much of each body's own color shows, 0 to 1.
pacenumberHow fast the brightness runs along the tubes; 0 holds still.
groundRgb1The color behind the scene, sRGB 0 to 1.
KnitScreeninterface
The picture knitted: a stitch a cell, each a V of yarn lying over the one below.
Properties
kind"knit"Which screen this is.
stitchnumberA stitch's width, in CSS pixels.
yarnsreadonly Rgb1[]The yarns, at most 10: the sweater's body, the pattern's main yarn and its second, then the rest. The picture is knitted in the nearest of every yarn but the body's.
bandsreadonly string[]The bands of pattern from the top and bottom edges inward, ids of splat-core/knit.ts
MOTIFS; none for a plain body.patternstringoptionalOne of the named patterns (
KNIT_PATTERNS: nordic, forest, reindeer, hearts, none), whose bands are knitted in place ofbands.snowbooleanSmall dots of the pattern's yarn over the plain body.
GlitchScreeninterface
Pixel art with a bad signal: rows slid sideways, colors split apart, blocks read from elsewhere, in bursts.
Properties
kind"glitch"Which screen this is.
burstsnumberThe share of the time a burst is on, 0 to 1.
strengthnumberHow strong a burst is, 0 to 1.
splitnumberHow far red and blue part, in art pixels.
blocksnumberHow many blocks break in a burst, 0 to 1.
pacenumberSteps a second.
AnaglyphScreeninterface
The picture for red and cyan glasses: each eye's view slid apart by how far a thing is from the screen's own depth.
Properties
kind"anaglyph"Which screen this is.
depthnumberHow far apart the eyes' pictures slide at most, in CSS pixels.
popnumberHow much of the scene comes out of the screen toward the eye, 0 (all behind it) to 1.
colors"half" | "gray" | "balanced" | "full"How the two eyes' pictures are mixed into red and cyan: Dubois's least squares (
balanced), full color, half color, or gray.
RisoScreeninterface
A risograph print: a few bright spot inks, each laid as grain and a little off true, one over another on paper.
Properties
kind"riso"Which screen this is.
inksreadonly Rgb1[]The inks, at most three, sRGB 0 to 1: each takes the share of the picture's dark that it can make.
paperRgb1The paper's color, sRGB 0 to 1.
grainnumberHow grainy the ink lies, 0 (an even tint) to 1.
shiftnumberHow far each drum is off true, in CSS pixels.
strengthnumberHow strong the inks are: 1 as they come.
LinoScreeninterface
A linocut: one ink where the picture is dark, the lights carved away in gouges, with flecks of ink left where the cutter skipped.
Properties
kind"lino"Which screen this is.
inkRgb1The ink's color, sRGB 0 to 1.
paperRgb1The paper's color, sRGB 0 to 1.
cutnumberHow dark a place must be to be left uncut, 0 to 1.
gougenumberThe gouges' spacing, in CSS pixels.
chatternumberHow many flecks of ink are left in what was cut away, 0 to 1.
undernumberA second block printed under the first: how dark a place must be for it, 0 (no second block) to 1.
underInkRgb1The second block's ink, sRGB 0 to 1.
PencilScreeninterface
A drawing in pencil or charcoal: hatching that comes in set by set as the picture darkens, catching on the paper's tooth.
Properties
kind"pencil"Which screen this is.
spacingnumberThe hatching's spacing, in CSS pixels.
softnumber0 a sharp pencil's lines, 1 charcoal: broad smudged tone.
linesnumberHow strong the drawn outlines are, 0 to 1.
colornumberHow much of each thing's own color the marks take, 0 (all in
lead) to 1.leadRgb1The pencil's or charcoal's color, sRGB 0 to 1.
paperRgb1The paper's color, sRGB 0 to 1.
CrossStitchScreeninterface
Cross-stitch: a cross of thread a square of cloth, in a few shades a color.
Properties
kind"crossstitch"Which screen this is.
stitchnumberA stitch's square, in CSS pixels.
shadesnumberShades of thread a color channel (2 and up).
clothRgb1The cloth's color, sRGB 0 to 1.
fillbooleanWhether the backdrop is stitched too, or left as bare cloth.
ChalkScreeninterface
A chalk drawing on a board: dusty lines round every thing, the lights rubbed in with the side of the stick.
Properties
kind"chalk"Which screen this is.
boardRgb1The board's color, sRGB 0 to 1.
widthnumberHow wide the lines are, in CSS pixels.
fillnumberHow much of the lights is rubbed in with the side of the stick, 0 to 1.
colornumberHow much of each thing's own color the chalk takes, 0 (white chalk) to 1.
StainedGlassScreeninterface
A stained glass window: the picture cut into panes of colored glass held in lead. The panes are cells fixed in the world (a Voronoi of a jittered grid, measured along each surface rather than through it), so they stay on their surfaces as the view turns and slides; each is one color, the picture's at the pane's own middle, made richer and lit from behind. The backdrop is glass too, in larger panes fixed on the screen.
Properties
kind"glass"Which screen this is.
panenumberA pane's size, as a share of how far the scene reaches.
leadnumberThe lead's width, in CSS pixels.
behindnumberHow bright the light behind the window is toward its middle, 0 to 1.
varynumberHow much panes differ from one another and how uneven the glass inside each one is, 0 to 1.
skynumberThe backdrop's panes, in CSS pixels.
leadColorRgb1The lead's color, sRGB 0 to 1.
ScreenLooktype
A style that is a pass over the finished picture at the screen's own size.
StainedGlassScreen | RisoScreen | LinoScreen | PencilScreen | CrossStitchScreen | ChalkScreen | HalftoneScreen | TextScreen | MosaicScreen | CrtScreen | ThermalScreen | BlueprintScreen | WashScreen | NeonScreen | KnitScreen | GlitchScreen | AnaglyphScreenSCREENSvalue
The kinds of screen there are.
readonly ["halftone", "text", "mosaic", "crt", "thermal", "blueprint", "wash", "neon", "knit", "glitch", "anaglyph", "riso", "lino", "pencil", "crossstitch", "chalk", "glass"]The snapped camera
IsoViewinterface
Where the view looks from and how big an art pixel is in the world.
Properties
targetVec3The point in the middle of the picture.
azimuthnumberDegrees around the upright; 0 looks from +z (as the engine's
Orbit).elevationnumberDegrees above the level.
unitnumberWorld units one art pixel covers.
rollnumberoptionalDegrees the picture is tipped about the way the view looks, clockwise as seen; left out, upright.
Basisinterface
The view's three ways: across the picture, up it, and into it (away from the eye).
Properties
basisOf()function
The ways of a view turned azimuth round the upright and elevation above the level, in degrees, and tipped roll degrees about the way it looks (what it shows leans clockwise).
basisOf(azimuth: number, elevation: number, roll?: number): Basissnapped()function
The view snapped to the art's grid: origin is the point the picture is drawn about (the target moved by less than a pixel onto the grid) and shift how far, in art pixels across and up, the target lies from it (each within half a pixel). The page slides the picture by shift the other way. cell is which pixel of the world's grid the origin is: a pattern laid by pixel (the dither) is laid from it, so the pattern stays on the surfaces as the view slides.
pixelOf()function
Where a world point lands, in art pixels across and up from the middle of a picture drawn about origin.
pixelOf(p: readonly number[], origin: readonly number[], b: Basis, unit: number): [number, number]panned()function
The view slid by art pixels across and up the picture.
eyeOf()function
The eye of a view distance back from its target: what a room's cutaway walls are judged from.
turnStep()function
The next whole step of step degrees round from azimuth, one way (1) or the other (-1).
turnStep(azimuth: number, way: -1 | 1, step?: number): numberPerspectiveinterface
A view with perspective: the eye stands distance back from the target along the view's way, and the picture's height at the target is 2 · distance · tan(fov / 2). The arithmetic below is written for both kinds of view at once: a world point along past the target's plane (along the view's way) is drawn unit + persp · along world units an art pixel, where persp is 0 for a flat view and unit / distance with perspective (so at the eye, along = −distance, a pixel covers nothing). Every pass that puts a pixel back in the world goes by this (renderer.ts VIEW_GLSL is its shader twin), and the depth buffer holds along as it does for a flat view, so depth stays even in the world.
Properties
unitnumberWorld units an art pixel covers at the target's plane.
perspnumberHow much more an art pixel covers a unit further off:
unit / distance(0 for a flat view).distancenumberHow far the eye stands back from the target.
perspectiveOf()function
A perspective view's numbers: a vertical field of view fov (degrees), the eye distance back, a picture artHeight art pixels tall.
perspectiveOf(fov: number, distance: number, artHeight: number): PerspectiveprojectView()function
Where a world point is drawn (the twin of viewOf in the shaders): art pixels across and up from the picture's middle, and how far along the view's way it lies past origin's plane. persp 0 is a flat view (pixelOf(), with the third number).
projectView(p: readonly number[], origin: readonly number[], b: Basis, unit: number, persp?: number): [number, number, number]unprojectView()function
The world point drawn at art pixel s (across and up from the middle) whose depth is along past origin's plane: the twin of worldOf in the shaders, which is how the light pass, the lines and the water put a pixel back in the world.
sightOf()function
The way a pixel's line of sight runs (s across and up from the middle), scaled so it goes one unit along the view's way for every unit it is followed: a flat view's is the view's own way. The twin of sightOf() in the shaders.
Loose things over the scene
MAX_PIXEL_MORPH_TARGETSvalue
The most morph targets (in-betweens counted) a creature's cut may carry: the renderer's weights are uniforms.
16LooseActorinterface
What a loose thing is made of, as the stage takes it: blobs in their rest pose, the bones that carry them, and how much each glows (a byte a blob). An engine Actor is one.
Properties
blobs{ count: number; center: ArrayLike<number>; scale: ArrayLike<number>; quat: ArrayLike<number>; color: ArrayLike<number>; opacity: ArrayLike<number> }The blobs in their rest pose: centers and scales (three numbers each), turns (four), colors (three, linear 0 to 1) and opacities.
skin{ joints: ArrayLike<number>; weights: ArrayLike<number> }Each blob's four bones and their weights; a blob is carried whole by its heaviest bone.
skeleton{ matrix: ArrayLike<number> }The bones' skin matrices as they stand now, sixteen numbers a bone.
glowArrayLike<number>optionalHow much each blob glows, a byte a blob (0 to 255); left out, none does.
weatherbooleanoptionalWeather (clouds, rain, snow): it glows only to keep its own color, so it gives no light.
liesbooleanoptionalWhat lies on the scene (snow lying): it glows only to keep its own color, and is read afresh less often.
grownumberoptionalHow many times its blobs' own size each is drawn (1 when left out).
Shared with the main entry
Vec3shared
The main entry's own: one declaration, imported from either entry.
Its card: Vec3, in the main entry’s parts.
Rgbshared
The main entry's own: one declaration, imported from either entry.
Its card: Rgb, in the main entry’s parts.
CLOUD_COVERSshared
The main entry's own: one declaration, imported from either entry.
Its card: CLOUD_COVERS, in the main entry’s parts.
SkyEaseshared
The main entry's own: one declaration, imported from either entry.
Its card: SkyEase, in the main entry’s parts.
WEATHERSshared
The main entry's own: one declaration, imported from either entry.
Its card: WEATHERS, in the main entry’s parts.
WINDSshared
The main entry's own: one declaration, imported from either entry.
Its card: WINDS, in the main entry’s parts.
isClearshared
The main entry's own: one declaration, imported from either entry.
Its card: isClear, in the main entry’s parts.
skyStateshared
The main entry's own: one declaration, imported from either entry.
Its card: skyState, in the main entry’s parts.
CloudIdshared
The main entry's own: one declaration, imported from either entry.
Its card: CloudId, in the main entry’s parts.
SkyStateshared
The main entry's own: one declaration, imported from either entry.
Its card: SkyState, in the main entry’s parts.
WeatherIdshared
The main entry's own: one declaration, imported from either entry.
Its card: WeatherId, in the main entry’s parts.
WindIdshared
The main entry's own: one declaration, imported from either entry.
Its card: WindId, in the main entry’s parts.
TIMESshared
The main entry's own: one declaration, imported from either entry.
Its card: TIMES, in the main entry’s parts.
timeOfshared
The main entry's own: one declaration, imported from either entry.
Its card: timeOf, in the main entry’s parts.
TimeIdshared
The main entry's own: one declaration, imported from either entry.
Its card: TimeId, in the main entry’s parts.
TimeOfDayshared
The main entry's own: one declaration, imported from either entry.
Its card: TimeOfDay, in the main entry’s parts.
Old names, kept for one release
PixelLooktype
Old name of PixelStageLook, kept for one release: the main entry's PixelLook is the blob stage's pixel pass, another thing.
PixelStageLookDEFAULT_LIGHTvalue
Old name of DEFAULT_PIXEL_LIGHT, kept for one release: the main entry's DEFAULT_LIGHT is the cutter's baked light.
PixelLightDEFAULT_LOOKvalue
Old name of DEFAULT_PIXEL_LOOK, kept for one release, renamed with PixelStageLook.
PixelStageLookLamptype
Old name of PixelLamp, kept for one release: the main entry's Lamp is a lamp whose shadows the cutter bakes.
PixelLampWaterLooktype
Old name of PixelWaterLook, kept for one release: the main entry's WaterLook is how the blob stage colors a water surface.
PixelWaterLookGlassLooktype
Old name of PixelGlassLook, kept for one release: the main entry's GlassLook is the stained glass look.
PixelGlassLookCutoutLooktype
Old name of PixelCutoutLook, kept for one release: the main entry's CutoutLook is the paper cutout filter.
PixelCutoutLook