Parameter Reference Tables

This page summarizes frequently used parameters and defaults for core public APIs. For behavior-level edge cases (units, precedence, and internal/public boundaries), see docs/reference/semantic-clarifications.md.

Triode constructor options

OptionTypeDefaultNotes
widthnumber1280Initial canvas width.
heightnumber720Initial canvas height.
canvasHTMLCanvasElementauto-createdProvide your own canvas for embedding.
makeGlobalbooleanfalseInstalls globals like osc, stage, geom, etc. Use liveGlobals(true) to opt in at runtime (legacy: true defaults this to true).
autoLoopbooleantrueStarts internal RAF loop automatically.
detectAudiobooleanfollows makeGlobalInitializes audio analyzer (a bins). Defaults to false in non-global mode unless explicitly set.
errorPolicy{ maxPerSecond?, dedupeWindowMs?, verbose?, pauseOnError? }{4,1000,false,false}Runtime error dedupe/rate policy for update/afterUpdate/tick/compile contexts.
argPolicy{ invalid?, nanFallback? }{ invalid: "warn", nanFallback: 0 }Argument coercion policy container (current runtime stores and exposes this policy for host tooling).
arrayHelpers`"prototype" \"module"`"prototype"Controls whether Array prototype helpers are installed globally.
cssRenderers`"lazy" \"eager" \false`"lazy"CSS2D/CSS3D renderer creation mode. lazy defers DOM/renderer creation until requested by render options.
numSourcesnumber4Number of source slots s0..sN.
numOutputsnumber4Number of output slots o0..oN.
webgl`1 \2`2Select WebGL renderer backend.
precision`"lowp" \"mediump" \"highp"`platform-dependentShader precision hint.
onError(error, context) => voidunsetRuntime hook for update/afterUpdate/tick failures.
liveMode`"restart" \"continuous"`"continuous"Eval behavior: rebuild on each run vs persistent scene reconciliation (legacy: true defaults this to "restart").
legacybooleanfalseCompatibility mode: restores legacy constructor defaults and suppresses deprecation warnings for rotate(...) and underscore scene methods.
enableStreamCapturebooleantrueEnables vidRecorder capture setup.
extendTransformsobject/array{}Registers custom transforms at startup.
css2DElementHTMLElementautoTarget element for CSS2D renderer if used.
css3DElementHTMLElementautoTarget element for CSS3D renderer if used.
pbunknownnullLegacy/peer stream source integration input.

Scene composition methods

MethodPurposeTypical usage
stage()Create scene handle (reuse: true for name-based lookup)stage({ name: "main", key: "main" })
scene()Alias of stage()scene({ name: "main", key: "main" })
.box(mat?, options)Add default box mesh.box(osc().phong(), { key: "hero" })
.sphere(mat?, options)Add default sphere mesh.sphere(osc().lambert(), { key: "planet" })
.mesh(geom, mat, options)Add mesh geometry.mesh(geom.box(), osc().phong(), { key: "hero" })
.instanced(geom, mat, count, options)Add instanced mesh and return it.instanced(geom.box(), mat.meshPhong(), 4096, { key: "crowd" })
.points(geom, mat, options)Add points primitive.points([100, 100], mat.dots())
.lines(...)Add line segments.lines([100], mat.lines())
.lineStrip(...)Add connected line strip.lineStrip([200], mat.linestrip())
.lineLoop(...)Add closed line loop.lineLoop([200], mat.lineloop())
.lights(options)Configure runtime lights group.lights({ all: true })
.world(options)Configure sky/ground/fog helpers.world({ ground: true, fog: true })
.group(attrs)Create/attach subgroupstage({ key: "main" }).group({ name: "cluster", key: "cluster" })
.render(output, options)Bind scene to output pipeline.render(o0)
.out(output, options)Alias of .render(...).out(o0)
.texture(output, options)Alias of .tex(...).texture(o1)
.clear(amount, color)Set accumulation clear behavior.clear(0.2)
.autoClear(amount, color)Alias of .clear(...).autoClear(0.2)
.obj(index)Alias of .at(index).obj(0)

Legacy aliases linestrip(...) and lineloop(...) remain available for compatibility.

Deprecation guidance:

  • rotate(...) still works, but warns once and points to rotateDeg(...) / rotateRad(...).
  • Direct underscore scene helpers (for example _mesh(...)) warn once and point to public equivalents.
  • Set constructor option legacy: true to suppress these compatibility warnings.

Identity note for live coding:

  • stage({ key: "main" }) (or scene({ key: "main" })), .group({ key: "cluster" }), and primitive options.key provide stable object reuse keys in liveMode: "continuous" when line order changes between evals.
  • Cross-function/cross-file structural rewrites are intentionally not inferred for identity; use explicit key when you need hard identity guarantees.
  • Name-based reuse is explicit: pass reuse: true on scenes/groups/primitives when you intentionally want name to resolve existing objects.
  • Migration helper: docs/reference/live-key-migration.md and npm run migrate:report-live-keys.

Module namespace aliases

Long-form aliases are available alongside short module names:

Canonical shortFriendly aliasNotes
txtexTexture loaders/FBO/data helpers.
gmgeomGeometry constructors/utilities.
mtmatMaterial constructors/utilities.
cmpcomposeComposition/pipeline utilities.
rndrandomRandom helpers.
nsenoiseUtilNoise utility module alias; noise() remains the shader generator function.

Runtime scope note:

  • Use runtime-bound module APIs (H.mat, H.geom, H.tex, etc. or global helpers when enabled) instead of unscoped internal module imports, so helper calls resolve to the intended Hydra runtime instance.

Stage helper config

stage(config) is a readability-first scene bootstrap helper. It calls scene(...) under the hood and applies optional presets:

stage optionTypeNotes
reusebooleanEnables name-based scene reuse when name is provided.
camera`false \"perspective" \"ortho" \"orthographic" \object`Camera preset or full camera config (type, eye, target, camera options).
lights`false \"basic" \"studio" \object`basic uses default lights, studio maps to { all: true }.
world`false \"ground" \"atmosphere" \object`ground enables ground, atmosphere enables ground + fog.
clear / autoClear`number \{ amount, color, ... }`Configures scene accumulation clear behavior.
outputunknownOptional output target when rendering from config.
render / out`boolean \{ to?, target?, css?, fx?, ... }`If true, stage invokes .render(...); object form maps to render({ ... }).
cssRenderer, renderTarget, fx, layersvariedForwarded to render options when auto-render is enabled.

Camera helper options

MethodInputsNotes
perspective(eye, target, options)tuple eye/target + camera optionsGood default for 3D exploration.
ortho(eye, target, options)tuple eye/target + ortho bounds hintsUseful for design, line art, and grids.
screenCoords(w, h)width/heightPixel-space style coordinate framing.
normalizedCoords()none0..1 style framing helper.
cartesianCoords(w, h)width/heightCentered cartesian framing helper.

Camera controls options

perspective(..., options) and ortho(..., options) accept options.controls as either:

  • true to enable defaults (alt modifier required for pointer/wheel orbit controls).
  • false to disable/dispose controls on the camera.
  • object config for explicit behavior.

stage({ camera: { controls: true } }) defaults modifier to "none" for helper ergonomics; direct camera helpers retain "alt" unless configured.

Control optionTypeDefaultNotes
controls.enabledbooleantrueSet false to disable controls explicitly.
controls.modifier`"none" \"alt" \"shift" \"meta"`"alt"Keyboard modifier for pointer/wheel input.
controls.domElementHTMLElementdocument.bodyDOM target receiving pointer/wheel events.
top-level control attributesunknownn/aBackward-compatible; still forwarded to orbit controls.

Transform chain material helpers

MethodOutputNotes
.basic(options)MeshBasic-style Hydra materialLighting-independent shading path.
.lambert(options)MeshLambert-style Hydra materialDiffuse light response.
.phong(options)MeshPhong-style Hydra materialSpecular + shininess response.
.material(typeOrOptions, options?)custom material propertiesUse "basic", "lambert", "phong" presets or pass object props directly.
.tex(output, options)TextureRender chain to texture for reuse.
.texture(output, options)TextureAlias of .tex(...).
.texMat(output, options)MaterialMaterial with rendered map attached.

Output render options

OptionScopeNotes
cssRenderer.render(..., options)"2d", "3d", renderer aliases, or false.
renderTargetcompiled pass optionsRoute pass output into explicit target.
autoClearoutput/scene/chain1 = clear, <1 = accumulation fade.
fxoutput/scene/chainAdds post-processing passes.

Object-style render shorthand is also supported:

  • render({ to, target, css, fx, ... })
  • out({ to, target, css, fx, ... })

Mappings:

  • to -> render output
  • target -> renderTarget
  • css -> cssRenderer

Runtime hooks

HookPurpose
update(dt)user animation/update function each frame interval
onFrame((dt, time) => void)convenience helper to bind update with time
afterUpdate(dt)post-render callback
click, mousedown, mouseup, mousemoveinput event hooks routed from canvas
keydown, keyupkeyboard hooks routed from document
onError(error, { context, time })centralized runtime error handling
liveGlobals(enable?)toggles runtime global helper installation

Runtime control helpers

MethodPurpose
eval(code, options?)Evaluate live code with per-call mode/reset/hush controls.
reset(options?)Alias to resetRuntime with granular flags (scene/time/hooks/outputs/sources).
freeze(time?)Pause time progression at current or explicit time.
step(dtMs?)Advance a single deterministic frame step (works with frozen runtime).
resume()Resume realtime clock progression after freeze.