Playground Guide
See the Playground Component Reference for JSX components, props, and runnable presets.
The generated site serves the JSX Playground at playground/index.html. It uses WebGPU when available and falls back to WebGL 2. If initialization or the device fails, the draft and Copy Link stay available. Use Reload renderer to retry with the current draft. Run and Alt+Enter apply the selection or current block. Ctrl+Enter applies the selection or physical line, and Ctrl+Shift+Enter applies the entire buffer. A blank line separates top-level blocks. Use // @cue to mark a boundary near incomplete JSX and // @cue writes=o2,display to declare destinations that the editor cannot infer.
Typing and changing parameters update the draft and share link. Code and setup values such as params.grid take effect when the cue that reads them runs. The parameter status names values that are waiting for Run. To read a live value, declare const spin = liveParam("spin", o2) in the cue for o2. Call spin() from a frame callback or pass spin as a dynamic signal input. The reader follows its published cue. Changing the slider updates its live readers immediately. If another output uses the same value during setup, run that output’s cue to apply the change there. A link with inline code opens an unevaluated draft. Select a shipped example to run its complete cue. When switching away from an edited sketch, confirm the switch or keep editing. Use Back to return to the previous draft. Opening a sketch from Examples keeps the original editor tab available.
The editor colors JavaScript and JSX. Use Fullscreen to put source code over the live stage. The Examples viewer shows the preset source and the Playground keeps the editor and Run available. On narrow screens, use Code to edit and Preview to view the stage and parameters. Switching panels or entering and exiting fullscreen keeps the same draft and rendering session.
Use .out(oN) for shader chains, renderScene(tree, oN, options) for JSX, src(oN) to sample an output, and render(oN) to select the displayed output. TriodeMaterial accepts a Hydra chain through signal or samples a live output with mipmaps through mipmappedSource={o1}. Add lighting="phong" for lit surfaces. DisplacedMaterial reads raw red-channel height from source and optional paint from colorSource, using the source textures' filtering and flipping V for render targets. Turn on flatShading to light the faces of the displaced surface.
Inside a scene component, useOutputTexture(o1, { flipY: true }) gives a TSL node that samples the live output with its existing filtering. flipY controls the V coordinate and defaults to true for render targets. Apply any display color conversion in the material. For displaced terrain, <HeightShadows source={o2} light={sun} /> updates a shadow-casting light ref when the height cue changes. Static height updates the shadow once and animated height updates it each frame.
Use cameraPosition, orthographic and controls to set up the view. Set fov for a perspective camera, cameraZoom for initial framing, and near and far for the clipping planes. An orthographic camera can use pixel units with orthographic: "pixels", the window's aspect ratio with orthographic: "viewport", or square texture coordinates with orthographic: "texture". Use autoRotate: true with controls: true for an orbit, shadows: true for scenes with shadow-casting lights and meshes, or staticScene: true for a fixed-camera scene that serves as a texture. useFrame runs scene animation on the shared clock. Compatible edits to a direct, ref-bound intrinsic mesh preserve its pose. Changing the mesh's key, geometry constructor or scene structure can replace it.
Use <Instances count={count} capacity={capacity} pose={pose}> around one geometry and material to draw many copies. capacity defaults to count. The pose(instance, index, mesh, frame) callback sets the instance transform and can set a color with mesh.setColorAt(index, color). For animated instances, animate(mesh, delta) runs before all poses and passes its return value to pose as frame. Delta is in seconds.
Clear Scene clears the selected output. Reset Sketch immediately restores the selected example's source and parameters. Use Back to recover a draft from before the reset. Shutdown ends the rendering session, and reloading starts another. A failed cue preserves the last working managed graph. Fix the draft and run the affected cue again. Arbitrary JavaScript effects outside the managed bindings run when evaluated.
Run npm run build and npm run site:build to build the site locally. With the local archive configured, Open GLSL archive transfers the current source and parameters to the final GLSL JSX Playground. The Original sketches links open the earlier imperative archive.
Use screencap() to download a PNG. Run vidRecorder.start() and vidRecorder.stop() in separate cues to download a WebM recording. s0.initScreen() requests a display source through the browser picker.
Use await s0.initExtension(url, readParameters) to sample frames from a compatible hosted sketch. The optional callback returns the sketch's parameters as an object of scalar values. The Playground requests a new frame when those values change. The sketch must keep the same frame size until it reconnects. Once the source is ready, use src(s0).out(o0). Run s0.clear() to close the sketch.
In the Mandelbrot example, scroll over the preview to zoom at the pointer and drag to pan. In the Playground, the Zoom, Center X, and Center Y controls follow the view. The example uses the standalone Triode Extensions sketch, licensed under CC BY-NC-SA 4.0.
The Texture Layout example wraps a seeded mosaic around a rotating box. Seed and Grid density update the texture while the box keeps spinning. The standalone Triode Extensions sketch uses the same generator and is licensed under CC BY-NC-SA 4.0.
The Waveform Scope example uses a blend of two sine waves as a texture in a feedback loop. Frequency ratio, Amplitude mix, and Phase (degrees) reshape the trace while the trail keeps moving. The standalone Triode Extensions viewer shows the trace by itself and is licensed under CC BY-NC-SA 4.0.
The Fluid Blue example displays an animated dye simulation from Triode Extensions. The preset sends elapsed time in 1/30-second increments so the sketch keeps moving with steady controls. Speed scales how fast the simulation runs. Viscosity smooths the flow as it evolves. Change Reset (toggle) in either direction to restart from the same pattern with your current settings. Set Speed to 0 to hold the pattern. Run s0.clear() to close the hosted sketch if you no longer need its source. Standalone Fluid Blue viewer · CC BY-NC-SA 4.0.
All original 3D preset IDs and gallery URLs resolve to source and runnable demos from d8a4d2c. The JSX ports of those presets use the original ID with a -jsx suffix. Feedback Kaleid keeps its original ID.
The build verifies site/archives/legacy-d8a4d2c-site.tar.gz against SHA-256 01be8d0bf3b2caa09a9e7f0a4db8588f646a7dead4427cee60537d020f59d164 and extracts it under legacy-playground/. To rehearse a rollback locally, extract the same archive into a fresh document root and serve its playground/ route.
Drawing
Use the short forms for a drawing that has its own sampling pattern.
| Drawing | JSX |
|---|---|
| Point field on a rectangular lattice | <PointField width={50} height={50} position={position} size={3} /> |
| Open path with both endpoints sampled | <Path count={100} position={position} /> |
| Closed path with periodic samples | <Path count={5} closed position={position} /> |
| Independent row or column segments | <Segments rows={20} columns={12} position={position} /> |
position is a signal evaluated at each sample. color accepts a signal or a TSL callback that returns RGBA from the original sample coordinates. It defaults to white. Point fields also accept shape="square", a number or signal for size, a number or TSL node for sizeScale, and depthTest={false} to disable depth testing.
Use samples() when multiple drawings need identical ordered coordinates and expressions. An ordered source samples both endpoints by default. Set endpoint: false for periodic positions so there is one sample at the seam. The path joins the last sample to the first with closed, and the point field draws one marker per sample. A path and its markers can share positions and colors even when their position signal moves them away from the original sample coordinates. The sampling and connectivity distinction follows Grid POP and Connectivity POP.
Rehearse the seam in the Shared Ring preset.
- Change
cornersfrom 3 to 5. With the cursor on that line, press Alt+Enter to run the drawing block. - Remove
closedfrom<Path source={ring} closed />and press Alt+Enter on that line. The final edge opens while all five markers stay in place. - Restore
closedand run the block again to rejoin the last sample to the first. Keepsource={ring}on both components andendpoint: falsefor all three edits.
const corners = 3;
const position = solid(sin(1, 0.32).add(0.5), cos(1, 0.32).add(0.5));
const ring = samples(corners, {
position,
color: (st) => TSL.vec4(st.x, 0.9, 0.85, 1),
endpoint: false,
});
renderScene(
<>
<Path source={ring} closed />
<PointField source={ring} size={12} />
</>,
o1,
{ orthographic: "texture" },
);
render(o1);
Use draw("loop", 5, { position, color }).out(o1) for a closed path or draw("dots", [50, 50], { position, size, color }).out(o1) for a point field. Send the drawing through trail(o1, { fade: 0.05 }).out(o2) to retain fading marks between frames. See the Polygon Rings rehearsal.
Inline sketches using TriodeGrid need an edit before they can run in the current Playground. Use PointField for dots and squares with shape="square" for squares. Use Path for strip and loop with closed for loops, and change width to count. Use Segments for lines and rename width and height to columns and rows. Rename positionSignal and colorSignal to position and color.
For an old strip or loop with height greater than one, use separate Path components for independent rows. For a path that connected vertices across rows, define the traversal as one ordered source or supply custom geometry for the vertex order you need.
Terrain Component Pilot
Open Terrain Component Pilot in Examples or the Playground. Two <TerrainSurface /> elements share the Hydra paint output o1 and the baked Hydra height output o2. They draw into the same Three.js scene at o0. The feedback cue layers src(o0) over the previous o3 frame and displays o3.
- Change Ridge → Relief while the sketch plays and compare it with Basin. Change Ridge's Subdivisions, then place the caret in the Terrain cue and press Alt+Enter to apply that geometry change.
- Change
fbm(0.7, …)tofbm(1.3, …)and run the Height cue alone. The shared input changes under both surfaces while the feedback continues. - Give Ridge a round footprint using the replacement below, then rerun the Terrain cue.
- Set distinct values for Ridge and Basin. Copy Link, open it in a fresh tab, then press Ctrl+Shift+Enter to run the shared draft. After switching presets, Back restores the draft so you can run it again.
<TerrainSurface
name="Ridge" height={o2} paint={o1} position={[-1.17, 0, 0]}
geometry={sides => <circleGeometry args={[0.95, sides]} />}
/>
The instance name keys its controls within the draft and scene output. A geometry factory changes the mesh shape while keeping those controls and inputs. Use declarative Three.js geometry with positions, normals, and normalized local UVs. The component displaces along local normals with the height texture's red channel and uses paint RGB for its opaque material. It flips V for managed render targets through the existing sampler. The scene owns the geometry and material. The input textures remain owned by their outputs in the same Playground session. Terrain surface source
Instanced Columns
Open Instanced Columns and choose a Height rule. The cue shows the noise programs, lights, material, and camera for Shaded Landscape, City, and Oscillator Columns. The Columns parameter group owns the layout and height controls. Press Ctrl+Shift+Enter to apply those changes. The stock Oscillator Columns surface uses Hydra osc(...).
<ColumnField> builds on <Instances> and keys its controls by the field name and the scene output. The default centered layout centers rows and spaces each axis by its box size. fractional uses sqrt(count) as the index width, with 0.02-unit cubes and steps. City uses this layout with its fixed height rule. spaced steps by 1.4 times the larger box dimension and offsets both axes by half the index width. If camera framing depends on the field size, pass the same field configuration to columnFieldLayout(field, o0) and to the JSX element in that cue.
The sample(x, z, { heightMin, heightMax, noiseScale }) callback returns a height multiplier or { height, color }. A material goes inside the element, and geometry={layout => ...} can supply geometry using the layout's box dimensions. ColumnField source
In the Column Field Rehearsal, two fields each have their own scene and controls. The Compose cue layers both outputs through Hydra.
- Change Ridge → Count. The stage stays put until Run. Put the caret in the Ridge cue and press Alt+Enter. Only the left field changes.
- Replace Ridge's sample callback with
sample={() => 0.6}and run the Ridge cue again. Towers keeps its own height rule and moving Hydra material. - Give Towers → Count a different value and run its cue. Use Copy Link to open the draft in a fresh tab, then press Ctrl+Shift+Enter to see both saved values.
Older stock links still open Instanced Columns with the saved Height rule and Texture Freq. Reapply any old Count, Width, Depth, Low Field Min, Height Max, and Noise Scale overrides in the Columns group. Links that include older custom source still open that source for editing. Replace its old params reads for those controls with component bindings or local constants before running it.
Three.js r157 ports
In Examples, look for the Three.js adaptation label on a sketch card. Its viewer shows the upstream credit and links to the original r157 example source and the bundled MIT license. In the Playground, find the same presets under Three.js adaptations in the Example picker.
Live controls take effect while the preset runs. Run the containing cue for path, geometry or other pending setup changes. In Dynamic Water Geometry, click the preview, move with WASD or the arrow keys, and drag to turn. In Spline Extrusion, choose the closed Granny Knot or the open Pipe, set the tube segments and sides, and use Ride camera to follow the path. Run the tube cue to publish these selections. The ride loops on the knot and stops at the end of the pipe.
In BufferGeometry Draw Range, change Link distance and the connection limit while the scene runs. ParticleLinks reuses fixed-size vertex buffers and calls geometry.setDrawRange(0, used / 3) each frame to draw the vertices written for the current links. ParticleLinks source
Dynamic Instancing and Dynamic Water Geometry load their geometry and texture from the pinned upstream revision. An internet connection is required to load those two examples. The adapted example code retains the Three.js r157 MIT notice.
Locally pinned GLSL Playground
The GLSL archive uses revision 9c9603c79159d315a487dbcfda5f6b5a09d194e4 and the local tag glsl-final-9c9603c. Prepare it separately from your TSL checkout.
git worktree add --detach ../triode-glsl 9c9603c79159d315a487dbcfda5f6b5a09d194e4
(cd ../triode-glsl && npm ci && npm run build && npm run site:build)
TRIODE_GLSL_ARCHIVE_DIR="$(cd ../triode-glsl/site-dist && pwd)" npm run site:build
The site builder verifies the saved JSX page, its JavaScript and CSS, and the library bundle before copying them to glsl-playground/. Open the current Playground and follow Open GLSL archive with your draft and parameters. To rehearse rollback, serve the verified GLSL site directory directly and open its playground/ route. See the custom TSL transform guide for new sketches.