# Resonance

Paste song lyrics, then walk the world they evoke.

- Case: N° 02.02 · Open source
- Disciplines: IA (AI integration), AW (Web applications)
- Stack: TypeScript, React Three Fiber, Vite, zod, Vitest, Claude
- Repository: https://github.com/nsalloums/resonance
- URL: https://micodigo.cl/en/work/resonance

## Summary

Resonance turns text you bring, such as song lyrics or a short passage, into a 3D world you explore in first person. There are no goals and no score: the reward is walking through a place that embodies the work, with fragments of the text built into the architecture itself.

The core idea is that the model composes rather than sculpts. The engine ships a fixed vocabulary of primitives, layouts, skies, particles, typography styles and audio beds. The model reads the text, pulls out its concrete images and emotional arc, and returns a World Spec: a JSON document that selects and tunes that vocabulary. Every catalog is a closed enum, so the output validates against zod and a bad answer gets caught instead of rendered. When validation fails, the generator retries with the error as feedback, and a minimal valid spec always exists, so you never get a blank screen.

The same spec always builds the same world, because layout comes from a seeded PRNG and `Math.random` is banned inside the engine. The frame budget lives in the schema too. There are three interchangeable generators: an offline heuristic one that's the default, a mock, and real Claude behind a server-side proxy, with cost, latency and tokens shown in a debug panel.

Accessibility is part of the MVP: adjustable field of view, a motion vignette, teleport movement and a reading menu with the full text, so you can take in the piece without moving through 3D at all. The README is plain about what's missing: the real Claude path is tested against simulated responses, and visual checks are done by hand in a browser.

## Problem

Ask a language model to emit raw geometry and you get output you can't render, validate or reproduce.

## Decision

The model composes from a closed vocabulary; it never generates geometry.

### Code excerpt

src/schema/worldSpec.ts @ dcc0522 — https://github.com/nsalloums/resonance/blob/dcc052265994252a8fe61744d4aa61ea08ed05ac/src/schema/worldSpec.ts#L186-L193

```ts
  .strictObject({
    version: z.union([z.literal(1), z.literal(2)]),
    meta: MetaSchema,
    environment: EnvironmentSchema,
    playerStart: PlayerStartSchema,
    zones: z.array(ZoneSchema).min(1).max(6), // perf cap: 6 zones
  })
  .superRefine((spec, ctx) => {
```
- Line 186: strictObject: any field the model makes up triggers a retry instead of slipping through.
- Line 191: The frame budget lives in the schema: 6 zones at most.

## Numbers

- 128 automated tests
- 3 attempts before the fallback world
- 6 zones at most, by schema
- 0 API keys needed to try it

## Architecture

- Pasted text → Normalize
- Normalize → WorldGenerator: heuristic · mock · Claude
- WorldGenerator: heuristic · mock · Claude → World Spec
- World Spec → zod validation
- zod validation → WorldGenerator: heuristic · mock · Claude (invalid: retry)
- zod validation → Minimal fallback spec (three failures)
- zod validation → WorldRenderer (valid)
- Minimal fallback spec → WorldRenderer
- WorldRenderer → Seeded procedural scene

micodigo.cl: https://micodigo.cl

---

- Page: https://micodigo.cl/en/work/resonance
- En español: https://micodigo.cl/trabajo/resonance.md
- Index for agents: https://micodigo.cl/llms.txt
