# Cube Wave — `cube-wave@1.0.0`

A field of glossy cubes rising and sinking in rings, crossing diagonals or a spiral, coloured by height. Loops perfectly.

A field of cubes that rise and sink in waves. Each cube's height is a function of its position — rings spreading from the middle, crossing diagonals, a spiral arm or travelling rows — and its size and colour follow its height, so the field looks like a pulsing landscape of glossy blocks. Choose the number of cubes, the pattern (ripple, cross, spiral or rows), the colours (aurora, sunset, candy or mono), how tall the waves are, how many wave cycles pass per loop, the backdrop colour and whether the camera sways.

- Kind: object; status: published; digest sha256:bbb6fba1ad43e1fa556ad8207b10394aa0b982bfbb142de270bafa804ffe212a
- Role: Object (3D, three.js): the classic wave-field loop, glossy and colourful, for tech, music and abstract content.
- Implementation: three; entry `src/cube-wave.js`
- Files: https://aipixelwizard.com/registry/cube-wave/1.0.0/<path> (`LICENSE`, `asset.json`, `demo.js`, `index.html`, `src/cube-wave.js`)
- Manifest JSON: https://aipixelwizard.com/api/v1/visuals/cube-wave/versions/1.0.0
- Runnable demo: https://aipixelwizard.com/registry/cube-wave/1.0.0/index.html (open over http; it imports sibling packages by relative path)
- Dependencies (exact): `three@0.185.1` (source) — Renderer, geometry and shader materials.; `chrome-material@1.1.0` (demo) — Studio environment light, backdrop and contact shadow.; `apw-runtime@1.0.0` (demo) — Demo harness.

## Exports
- `createCubeWave({ grid?, pattern?, palette?, height?, speed? }) => { group, setProgress(progress), dispose() }` — The field of instanced cubes, about 14 across, resting on y = 0; needs an environment map.
- `PALETTES: { aurora, sunset, candy, mono }` — Colour ramps from the lowest to the highest cube.

## Parameters
- `grid` (integer 9–41, default 25) — Cubes per side
- `pattern` (select one of ripple | cross | spiral | rows, default "ripple") — Pattern
- `palette` (select one of aurora | sunset | candy | mono, default "aurora") — Colours
- `height` (number 0.4–2, default 1) — Wave height
- `speed` (integer 1–4, default 2) — Waves per loop
- `background` (color, default "#10141f") — Backdrop
- `orbit` (boolean, default true) — Camera sway

## Composition
- Inputs: Time within the loop; the cubes, pattern, colours, height, waves per loop, backdrop and camera sway.
- Outputs: A full frame rendered in 3D with a studio environment.
- Coordinates: The field is centred on the origin on y = 0, about 14 across; cubes grow from y = 0 up to about 3.7 tall.
- Lighting: A warm key light with a shadow map, a shadow-catching floor and the studio environment.
- Timing: setProgress(progress) sets every cube's height, size and colour; frames render in any order.
- Works with: chrome-material, orbit-camera, kinetic-title, number-reveal
- One instanced mesh with instance colours from a four-stop ramp.

## Output and loop
- 1080×1080, 30 fps, 12 s, procedural
- Seamless loop: yes — Each wave advances a whole number of cycles per loop and the camera sway is a sine of the loop, so the last frame meets the first.
- Verified 2026-10-05 in Chrome 154.0.8037.97 headless on Linux 7.0.0-38-generic (x64), Node 22.14.0 (WebGL 2 via SwiftShader (software)); deterministic: yes; loop check: Frame 0 vs end state (progress 1): mean |Δ| 0.0000, max |Δ| 0 of 255.

## Use it
New project: Create a WebGLRenderer with a studio environment and a shadow-casting light, add createCubeWave().group and call field.setProgress(progress) each frame.

Existing project: Copy src/cube-wave.js; add the group to your scene with an environment map.

Reuse ideas:
- Tech launch: Aurora ripple.
- Warm: Sunset spiral.
- Playful: Candy cross, fine.

## Limitations
- Heights come from a formula; to chart data replace the field function.
- At the finest grids neighbouring cubes nearly touch.

## License
MIT. Copyright (c) 2026 AI Pixel Wizard. Released under the MIT License. See LICENSE in this folder.

Provenance: Adapted from the owner's threejs-sketches/geometry-math/cube-wave (MIT) and rebuilt for AI Pixel Wizard in October 2026 as an original studio object: instanced glossy cubes on a grid with four closed-form wave patterns, size and colour following height, on an exact loop.

