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/hydra-three/playground/index.html
How it works
- Each example defines:
- Parameter changes trigger debounced reruns.
- The runtime is recreated per run for predictable state and easier experimentation.
- The page URL is synced to current state:
Copy Linkwrites a shareable URL for the current state.
- editable sketch code - a parameter schema (name, min, max, step, value)
- ?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. - 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 currently uses makeGlobal: true inside a controlled page context to keep eval ergonomics simple. For host applications and multi-instance integration, prefer non-global mode.