Playground Guide
The interactive playground provides:
- live code editing
- live parameter controls
- instant rerendering to a Three.js canvas
- deep-linkable URL state for selected preset, code edits, and parameter overrides
Published URL:
https://kasparsj.github.io/triode/playground/index.html
How it works
- Each example defines:
- Parameter changes trigger debounced reruns.
- Runtime behavior is mode-driven:
- The page URL is synced to current state:
Reset Sketchrestores the selected example code+params.Reset Runtimeclears the active runtime and re-runs current code.Copy Linkwrites a shareable URL for the current state.
- editable sketch code - a parameter schema (name, min, max, step, value)
- Continuous (default) keeps one runtime and evaluates into it. - Restart disposes/recreates runtime on every run.
- ?example=<id> for preset selection - ?code=... for code overrides - ?params={...} for non-default parameter values
Files
site/playground/index.htmlsite/playground/playground.jssite/playground/examples.js
Add a new playground example
- Add an object to
playgroundExamplesinsite/playground/examples.js. - Define its
paramsschema. - Write sketch code using the injected
paramsobject (prefer canonical helpers likestage(...),.render(),.clear(), and friendly namespaces such asgeom/mat/tex). - Run
npm run site:buildand verify behavior in the generated site.
Recipe deep links
- Textured box:
?example=textured-box - Points trail:
?example=points-trail - Scene texture bridge:
?example=scene-texture-bridge - Terrain displacement:
?example=terrain-displacement
Runtime note
The playground runtime is initialized with makeGlobal: false and evaluates snippets against triode.synth scope (with (H) { ... }) so helper globals are not installed on window.
Mode: Continuouskeeps a persistent runtime and evaluates into it.Mode: Restartdisposes/recreates runtime on every run.
For host applications and multi-instance integration, prefer non-global mode.
Related guide: Livecoding Workflow.