# Kaleidoscope Tunnel — `kaleidoscope-tunnel@1.0.0`

A tunnel lined with kaleidoscope mirrors: petals bloom in mirrored wedges and race towards you in rainbow colours. Loops perfectly.

A tunnel lined with kaleidoscope mirrors. Round the tunnel the picture is folded into mirrored wedges, down it the pattern repeats in rings that race towards you, and in every cell of the pattern a bloom of petals opens in colours that slide through the rainbow. The wedges turn by whole wedges, the rings pass in whole numbers and the colours make whole trips per loop. Choose the number of wedges, the colours (rainbow, neon, fire or ocean), the swirl, the rush, the colour cycle and the number of rings.

- Kind: background; status: published; digest sha256:245b62120ecfb44e1cb70ffc2e5daeaba03b2b2ae65e4ab07db179fcf58b8d23
- Role: Shader background (three.js): a high-energy kaleidoscope for music, party and psychedelic content.
- Implementation: three; entry `src/kaleidoscope-tunnel.js`
- Files: https://aipixelwizard.com/registry/kaleidoscope-tunnel/1.0.0/<path> (`LICENSE`, `asset.json`, `demo.js`, `index.html`, `src/kaleidoscope-tunnel.js`)
- Manifest JSON: https://aipixelwizard.com/api/v1/visuals/kaleidoscope-tunnel/versions/1.0.0
- Runnable demo: https://aipixelwizard.com/registry/kaleidoscope-tunnel/1.0.0/index.html (open over http; it imports sibling packages by relative path)
- Dependencies (exact): `three@0.185.1` (source) — Renderer and a full-screen shader material.; `apw-runtime@1.0.0` (demo) — Demo harness.

## Exports
- `createKaleidoscopeTunnel({ segments?, palette?, swirl?, rush?, cycle?, density? }) => { scene, camera, setSize(width, height), update(time, loopSeconds), dispose() }` — The tunnel as one full-screen shader; render its scene with its camera, ideally through createBloomPass.
- `createBloomPass(renderer, { width, height, glow?, exposure?, grain? }) => { render(scene, camera, output?), dispose() }` — A small bloom with tone mapping and a fixed grain.
- `PALETTES: { rainbow, neon, fire, ocean }` — Four-colour ramps cycled through the petals.

## Parameters
- `segments` (integer 4–16, default 8) — Mirrored wedges
- `palette` (select one of rainbow | neon | fire | ocean, default "rainbow") — Colours
- `swirl` (integer -3–3, default 1) — Swirl: Whole wedges the pattern turns per loop; negative reverses it.
- `rush` (integer 1–6, default 3) — Rush: Rings passing per loop.
- `cycle` (integer 0–3, default 1) — Colour cycle: Whole trips round the colour ramp per loop.
- `density` (number 0.5–2, default 1) — Ring density

## Composition
- Inputs: Time within the loop; the wedges, colours, swirl, rush, colour cycle and ring density.
- Outputs: A full-frame shader image through a bloom pass.
- Coordinates: Screen-centred, ±1 vertically; the tunnel's axis points into the screen at the centre; distance down it is 0.42 / radius.
- Lighting: Self-lit; the bloom gives the glow.
- Timing: update(time, loopSeconds) sets the loop phase; frames render in any order.
- Works with: kinetic-title, number-reveal
- Each cell is mirrored across the wedge so neighbouring wedges are reflections of one another.

## Output and loop
- 1080×1080, 30 fps, 12 s, procedural
- Seamless loop: yes — The pattern turns by whole wedges, the rings pass in whole numbers, the colours make whole trips round their ramp and the wedge count is even, so the last frame meets the first.
- Verified 2026-10-06 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, createKaleidoscopeTunnel() and createBloomPass(renderer, { width, height }); call tunnel.setSize(w, h) and each frame tunnel.update(time, loopSeconds) then bloom.render(tunnel.scene, tunnel.camera).

Existing project: Copy src/kaleidoscope-tunnel.js and render tunnel.scene with tunnel.camera into your own target.

Reuse ideas:
- Party visual: Rainbow, eight wedges.
- Club: Neon, twelve wedges.
- Calmer: Fire, slow.

## Limitations
- Fast kaleidoscopic motion can be uncomfortable for some viewers; keep the rush low for sensitive audiences.
- The centre is darkened rather than resolving into a point.

## 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/shaders-backgrounds/kaleidoscope-tunnel (MIT) and rebuilt for AI Pixel Wizard in October 2026 as an original shader: mirrored wedges with petal cells repeating down a perspective tunnel, whole-wedge swirl, whole-ring rush and whole-trip colour cycle, on an exact loop.

