# Glazed Galaxy — `glazed-galaxy@1.0.0`

Dozens of rainbow-glazed donuts spiral round a big one at the centre like a galaxy, tumbling as they go. Loops perfectly.

A galaxy made of donuts: dozens of small glazed donuts swirl round a big one at the centre along the arms of a spiral, the inner ones racing and the outer ones drifting, each tumbling as it goes and every glaze a different colour of the rainbow. Choose the number of donuts, the number of spiral arms, how strong the glaze colours are, how many laps the outermost donuts make per loop, the seed, the backdrop colour and whether the camera sways.

- Kind: object; status: published; digest sha256:323062582b53f6d67776355e208805946f7a3f7e4c5c9461ee7bdd107957cf89
- Role: Object (3D, three.js): a playful, colourful scene for food, party and kids' content with a galaxy twist.
- Implementation: three; entry `src/glazed-galaxy.js`
- Files: https://aipixelwizard.com/registry/glazed-galaxy/1.0.0/<path> (`LICENSE`, `asset.json`, `demo.js`, `index.html`, `src/glazed-galaxy.js`)
- Manifest JSON: https://aipixelwizard.com/api/v1/visuals/glazed-galaxy/versions/1.0.0
- Runnable demo: https://aipixelwizard.com/registry/glazed-galaxy/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
- `createGlazedGalaxy({ count?, arms?, saturation?, laps?, seed? }) => { group, setProgress(progress), dispose() }` — The donut galaxy as two instanced meshes (dough and frosting), about 14 across; needs an environment map.

## Parameters
- `count` (integer 16–120, default 64) — Donuts
- `arms` (integer 1–6, default 3) — Spiral arms
- `saturation` (number 0.2–1, default 0.9) — Glaze colour
- `laps` (integer 1–3, default 1) — Outer laps per loop
- `seed` (integer 1–999, default 8) — Seed
- `background` (color, default "#1a1630") — Backdrop
- `orbit` (boolean, default true) — Camera sway

## Composition
- Inputs: Time within the loop; the count, arms, glaze colour, laps, seed, backdrop and camera sway.
- Outputs: A full frame rendered in 3D with a studio environment.
- Coordinates: The big donut sits at the origin (height 1.1); small donuts orbit at radius 2.6–7.2 in the xz plane; the camera looks down at about 52°.
- Lighting: A warm key light with a shadow map, a shadow-catching floor and the studio environment.
- Timing: setProgress(progress) places every donut on its orbit; frames render in any order.
- Works with: chrome-material, orbit-camera, kinetic-title, number-reveal
- All donuts share one frosting shape; each is tinted by an instance colour from the rainbow along the spiral.

## Output and loop
- 1080×1080, 30 fps, 16 s, procedural
- Seamless loop: yes — Every donut makes a whole number of laps per loop and turns a whole number of times, its tilts and bob are sines of whole cycles 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 createGlazedGalaxy().group and call galaxy.setProgress(progress) each frame.

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

Reuse ideas:
- Playful brand: Three arms, rainbow.
- Soft: Pastel, many.
- Energetic: Fast laps, two arms.

## Limitations
- All frostings share one shape, tinted differently.
- Donuts may overlap where arms cross near the centre.

## 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/objects-scenes/glazed-galaxy (MIT) and rebuilt for AI Pixel Wizard in October 2026 as an original studio object: instanced baked-dough donuts with a shared wavy frosting strip orbiting along logarithmic spiral arms with whole laps per loop.

