How reality404studio/emotion-sculpture works
Purpose and Entry Points
Emotion Trophy is a Vite-delivered, browser-only 3D experience that records viewer reactions during a video as a deterministic glass trophy and optionally commits its hash to Solana devnet. The HTML shell and UI start at index.html; application orchestration, render loop, phase transitions, and mint flow live in src/main.js.
Application Orchestrator and Phases
src/main.js coordinates scene setup, UI state, camera choreography, the three-minute session lifecycle, casting, completion, comparison, and minting. src/cinematic.js supplies camera/visual timing behavior for the foundry-to-finished-trophy presentation. src/style.css defines the interface layer around the WebGL scene.
Control flow is phase-oriented: enter foundry → collect emotional input into an open mould → cast automatically or on request → expose the cooled trophy and rotation interaction → optionally commit its deterministic record.
Input and Emotion Interpretation
src/input.js maps keyboard and on-screen gestures into distinct interaction semantics: rapid tapping, single taps, and holds. src/emotions.js converts those events into the three emotional material types and their intensity dynamics. This is an intentional boundary: gesture recognition produces emotion events; trophy generation consumes the resulting ordered material history rather than raw DOM input.
Deterministic Session Record
src/session.js owns the session data model, persistence, ordered input history, and SHA-256 sculpture hash. src/noise.js provides seeded deterministic placement and flow variation, avoiding Math.random(). The seed plus input index/history must reproduce bead placement, ribbon flow, color order, and the committed hash. src/seed-data.js supplies a precomputed rival session/sculpture for the comparison view.
Trophy Generation and Rendering
src/trophy.js is the visual core. During collection it creates a bounded set of temporary colored glass beads in a mould. At casting, bead records become deterministic color seeds for an internal ribbon field/texture atlas; bead meshes are removed rather than retained in the final object. A fixed trophy silhouette and physical glass rendering preserve a calm outer form while internal ribbons encode chronology, placement, clear gaps, and color quantity.
src/atmosphere.js provides surrounding scene ambience, while src/polyfills.js supports browser/runtime compatibility needed by the client bundle.
On-Chain Boundary
src/onchain.js isolates blockchain behavior behind an OnChainAdapter. The mock implementation supports the experience without wallet or network access. The devnet implementation generates an ephemeral keypair, requests SOL, and submits a Solana Memo transaction containing the sculpture hash and match reference, returning transaction/explorer state to the UI.
The renderer and sculpture pipeline do not depend on Solana; chain commitment is an optional post-cast persistence layer.
Runtime and Verification
The runtime is Vite, vanilla JavaScript, three.js/WebGL, and @solana/web3.js, configured by package.json and vite.config.js. The only material external services are the embedded video provider and Solana devnet RPC/Memo program. Determinism and audio behavior have dedicated executable checks in scripts/verify-determinism.mjs and scripts/verify-sound.mjs.
Main entry points: main.js App orchestrator · session.js Session record · trophy.js Trophy generator · onchain.js OnChain adapter
Components 19
Browser Experience
- HTML shell
index.html - App orchestrator · Owns phases, render loop, UI, casting, comparison, and minting.
src/main.js - Interface styles
src/style.css - Camera choreography
src/cinematic.js - Gesture recognition · Distinguishes rapid taps, taps, and holds.
src/input.js - Scene ambience
src/atmosphere.js - Runtime compatibility
src/polyfills.js
Deterministic Trophy Pipeline
- Emotion mapping · Converts gestures into material events and intensities.
src/emotions.js - Session record · Persists ordered inputs and computes the sculpture SHA-256 hash.
src/session.js - Seeded variation · Reproducible placement and flow variation without random values.
src/noise.js - Trophy generator · Turns material history into temporary beads and final internal glass ribbons.
src/trophy.js - Rival session · Precomputed comparison sculpture.
src/seed-data.js
Optional Chain Commitment
- OnChain adapter · Selects mock or devnet commitment without coupling rendering to Solana.
src/onchain.js - Solana devnet · Receives hash and match reference in a Memo transaction.
Other components
- Embedded video provider
- Vite client runtime
vite.config.js - Dependencies · Provides Vite, three.js, and Solana web3.
package.json - Determinism check
scripts/verify-determinism.mjs - Sound check
scripts/verify-sound.mjs
Connections 21
- HTML shell → App orchestrator: starts
- Interface styles → App orchestrator: styles UI
- Vite client runtime → App orchestrator: delivers
- Dependencies → Vite client runtime: configures dependencies
- Runtime compatibility → App orchestrator: supports runtime
- App orchestrator → Gesture recognition: captures interactions
- Gesture recognition → Emotion mapping: gesture events
- Emotion mapping → Session record: ordered material history
- Session record → Trophy generator: seed and history
- Seeded variation → Trophy generator: seeded placement and flow
- App orchestrator → Trophy generator: collection and cast phases
- Camera choreography → App orchestrator: phase timing
- Scene ambience → App orchestrator: scene ambience
- Embedded video provider → App orchestrator: session media
- Rival session → App orchestrator: comparison view
- Session record → OnChain adapter: sculpture hash and match
- App orchestrator → OnChain adapter: optional mint request
- OnChain adapter → Solana devnet: devnet Memo transaction
- Determinism check → Session record: verifies reproducibility
- Determinism check → Trophy generator: verifies generated sculpture
- Sound check → App orchestrator: verifies audio behavior