triode

Playground Component Reference

Use these JSX bindings inside a Triode Playground cue. The editor provides React, THREE, and TSL in the same scope. Open a linked preset to run its full cue and see the props in context. The Playground guide explains how to run an individual cue, and the Core Materials reference covers the material behavior shared with the runtime.

Scenes and live values

renderScene

renderScene(tree, output = o0, options = {}) publishes a JSX scene to a Triode output. Use render(output) to display it, or sample it with src(output). Each scene follows the Playground clock and renderer. Run the cue to apply scene or camera setup changes. See the Playground guide for the camera, shadow, and static-scene options.

useFrame

Call useFrame((state, delta, frame) => { … }) inside a JSX component. delta is in seconds. Use state.clock.elapsedTime for elapsed time and state.camera for the scene camera. The callback also runs during a trial draw, so it should keep changes local to the scene and allow for the third argument to be undefined. Once the scene is published, the callback runs while its cue is active. Points Waves uses the hook to advance a wave uniform.

liveParam

liveParam(name, output = o0) returns a function that reads the named slider for the published cue. Declare it in the cue that writes to that output. Pass the getter to a dynamic prop, call it in useFrame, or use it as a Hydra signal input. Read from params for setup values that take effect when the cue runs again. See Textured Box for live spin speeds and oscillator frequency.

Materials and output textures

TriodeMaterial

Attach <TriodeMaterial signal={osc(8)} /> inside a mesh. See TriodeMaterial in Core Materials for props, lifecycle, and a complete cue.

DisplacedMaterial

Attach <DisplacedMaterial source={o2} colorSource={o1} amount={0.6} /> inside a mesh. See DisplacedMaterial in Core Materials for props, texture sampling, and a runnable preset.

useOutputTexture

useOutputTexture(source, { flipY } = {}) returns a TSL node that samples the current texture of a Triode output. Call it inside a JSX component. The node follows live output updates before each draw and keeps the source filtering. flipY defaults to true for render-target textures and false for ordinary textures. Render to Texture uses the hook to paint instanced spheres.

HeightShadows

<HeightShadows source={o2} light={sun} /> keeps a shadow-casting light's shadow in sync with a height output. Pass the light ref as light and enable shadows on the scene. The helper updates the shadow once for a published static height texture and each frame for an animated height source. Try switching the height cue in Terrain Displacement.

Drawing

Each drawing takes a Hydra position signal and an optional color signal or TSL callback that returns RGBA from the sample coordinates. The default color is white. Run the drawing cue to change topology or sample counts. The position and color signals can animate while the cue plays.

PointField

<PointField width={50} height={50} position={position} /> draws a rectangular sample grid. width and height each default to 1. Set shape="square" for square markers. The default is "dot". size accepts a number or signal and defaults to 1. sizeScale accepts a number or TSL node and defaults to 1. Set depthTest={false} to disable depth testing. If you pass an ordered source from samples(), the component uses its coordinates, position, and color. Grid demonstrates square markers.

Path

<Path count={100} position={position} /> draws a single ordered path. count defaults to 10. When you use count, an open path samples both ends and a closed path samples a periodic interval. An ordered source from samples() supplies the coordinates, position, and color and uses that source’s endpoint setting. With either input, closed joins the last vertex to the first. Try opening and closing the path in Shared Ring.

Segments

<Segments columns={12} rows={20} position={position} /> draws independent pairs, with a vertical segment for each column and a horizontal segment for each row. Both counts default to 0. Drawing Mix layers a set of segments over a Hydra signal.

samples

samples(count, { position, color, endpoint = true }) creates an ordered source for Path and PointField. Use a positive integer count and a position signal. Set endpoint: false for a periodic shape so the first and last samples occupy different positions along the interval. Shared Ring uses the same samples to draw a path and place its markers.

Layout and instancing

Stack

<Stack gap={0}>…</Stack> measures the bounds of its children and stacks them along Y starting at the group's floor. It measures the scene on setup. Run the cue after changing child geometry or gap. Pass ref or standard group props to access or place the resulting group. Try a larger gap in Stack and Circle.

Circle

<Circle radius={1}>…</Circle> places children evenly around the group's XZ plane and keeps their Y positions. Run the cue to apply a different radius or set of children. Accepts ref and other group props. In Stack and Circle, replace the Stack wrapper with Circle and run the scene.

Place

<Place position={(index, time) => [x, y, z]}>…</Place> evaluates each child's position on the cue clock. Return three finite numbers. Pass optional bounds={[[minX, minY, minZ], [maxX, maxY, maxZ]]} to clamp each axis. Accepts ref and other group props. Change the bounds or time offsets in Bounded Noise.

Instances

<Instances count={count} capacity={count} pose={pose}>…</Instances> draws copies of one geometry and material. count must fit in capacity, which defaults to count. In pose(instance, index, mesh, frame), set the instance transform or call mesh.setColorAt(index, color). Each pose starts with a reset transform. Optional animate(mesh, delta) runs before posing each frame and its return value becomes frame. Without it, poses run during setup. Pass ref or standard instanced mesh props. Dynamic Instancing keeps rotating while its speed changes. Run the cue to apply a new visible count.

writeInstances

writeInstances(mesh, count, pose) updates the visible count, transforms, and bounds of an existing Three.js instanced mesh. Its pose(instance, index) receives a reset object for each copy. Call it from a scene component after the mesh ref is available. Use Instances to let the Playground manage setup and optional animation. Dynamic Instancing uses Instances, which calls the same writer to apply its pose callback.

ColumnField

<ColumnField name="Ridge" sample={sample} /> builds an instanced field with named controls. Supply a stable name and a sample(x, z, { heightMin, heightMax, noiseScale }) callback that returns a finite height multiplier or { height, color }. Set layout to "centered" (default), "fractional", or "spaced". Optional position places the field. geometry(layout) defaults to a box using layout.box. Supply a material as a child or use the default Lambert material.

The component controls default to count: 50000, width: 0.02, depth: 0.02, heightMin: -2, heightMax: 5, and noiseScale: 1. Use defaults to override them for one field. Controls are scoped to the field name and scene output. Run that field's cue to apply a change. See the Column Field Rehearsal and implementation.

columnFieldLayout

columnFieldLayout({ name, layout, defaults }, output = o0) measures a field with its current setup values. It returns dimensions such as fieldWidth, fieldDepth, and box for framing or geometry. Pass the same configuration and output to ColumnField and the helper. Instanced Columns uses it to frame the field.

Motion and camera

Spin

<Spin target={ref} x={0} y={0} z={0} /> adds rotation to the object at a React ref. Each axis is a rate in radians per second. Each accepts a number or a getter called on every frame. Textured Box shows how to bind two rates to sliders.

Motion

<Motion spinX={0} spinY={0} rotationX={0} scale={1}>…</Motion> animates a group. Spin rates are in radians per second. rotationX adds an angle in radians to the accumulated X spin. scale sets uniform scale. Each value accepts a number or a function of elapsed time. Supply an optional name for the group. A compatible edit to a unique top-level Motion with one matching child can preserve its accumulated spin. Try the live spin and scale controls in Torus Pulse.

PointerFollow

<PointerFollow height={0} scale={0.01} /> eases the active scene camera's X and Y positions toward the pointer offset and aims it at the origin. height adds a vertical offset and scale sets pointer sensitivity. Both accept numbers or live getters. Try the View height slider in Points Waves.

WalkCamera

<WalkCamera speed={5} /> enables WASD, arrow keys, and drag-to-turn for the displayed scene. speed accepts a finite number or a live getter. Use one per scene. Click the preview to focus it, and press Tab to leave it. Input is released when the cue retires or the output is no longer selected. Try it in Dynamic Water Geometry.

Terrain and particles

TerrainSurface

<TerrainSurface name="Ridge" height={o2} paint={o1} /> requires both a height output and a paint output owned by the same Playground session. Each input must be separate from the terrain scene output. name identifies the component's controls and optional position places it. geometry(subdivisions) defaults to a two-by-two plane and must supply position, normal, and UV attributes.

Relief defaults to 0.6 world units and updates live. Subdivisions default to 64 and take effect when the scene cue runs. In Terrain Component Pilot, change one surface's relief and then rerun the shared height cue to affect both surfaces. See the implementation.

useHeightSurface and deformHeight

Call useHeightSurface(ref, speed = 1) inside a component with a ref to a mesh with a position buffer. Use one height surface per scene. speed accepts a finite number or a live getter and controls the phase advance on each frame. deformHeight((index, phase) => height).out(output) publishes a finite Y-coordinate rule for that scene. Run the rule cue to replace it at the current phase. Try changing the wave formula in Dynamic Water Geometry.

<ParticleLinks> animates particles and draws links between nearby pairs. Supply an integer count from 0 to 1000. Run the scene cue to change the count.

Pass getters for linkDistance (maximum link distance), limitLinks (whether to cap each particle's connections), neighborLimit (the cap), showDots, and showLines. For fixed props, use functions such as () => true. For sliders, use liveParam. The component advances on the cue clock, reuses vertex buffers, and updates the draw range each frame. In BufferGeometry Draw Range, set Link distance to zero and restore it while the particles move. See the implementation and upstream credit.

Source docs/reference/playground-components.md