# Klein Bottle — `klein-bottle@1.0.0`

A glossy Klein bottle with no inside or outside, turning while a cutting plane sweeps through it to show how the tube threads itself. Loops perfectly.

The Klein bottle: a surface with no inside and no outside, whose neck bends back and passes through its own wall to join its base. Shown in its figure-eight form as a glossy shell turning in studio light while a cutting plane sweeps through it again and again, opening the surface so you can see how the tube threads itself. Choose the finish (iridescent, chrome, glass or gold), whether a net of curves lies on the surface, the mesh fineness, how far the cut sweeps (or none), the turns per loop, the size of the ring, the backdrop colour and whether the camera sways.

- Kind: object; status: published; digest sha256:31a33f1c68ab941e64dbbe6788e8679beb7720c23d3522c0068cdf4196fffa3e
- Role: Object (3D, three.js): a topology showpiece for maths, science and design content.
- Implementation: three; entry `src/klein-bottle.js`
- Files: https://aipixelwizard.com/registry/klein-bottle/1.0.0/<path> (`LICENSE`, `asset.json`, `demo.js`, `index.html`, `src/klein-bottle.js`)
- Manifest JSON: https://aipixelwizard.com/api/v1/visuals/klein-bottle/versions/1.0.0
- Runnable demo: https://aipixelwizard.com/registry/klein-bottle/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
- `createKleinBottle({ finish?, lines?, detail?, cut?, turns?, waist? }) => { group, setProgress(progress), dispose() }` — The bottle (about 5 across, centred on the origin) with its cutting plane; the renderer needs localClippingEnabled = true; needs an environment map.
- `FINISHES: { iridescent, chrome, glass, gold }` — Surface finishes: colour, metalness, roughness, iridescence and film index.

## Parameters
- `finish` (select one of iridescent | chrome | glass | gold, default "iridescent") — Finish
- `lines` (boolean, default true) — Surface lines
- `detail` (number 0.6–1.4, default 1) — Mesh detail
- `cut` (number 0–1, default 1) — Cutting plane: How far the plane sweeps; 0 leaves the bottle whole.
- `turns` (integer 0–3, default 1) — Turns per loop
- `waist` (number 1.6–3, default 2) — Ring size
- `background` (color, default "#141824") — Backdrop
- `orbit` (boolean, default true) — Camera sway

## Composition
- Inputs: Time within the loop; the finish, lines, detail, cut, turns, ring size, backdrop and camera sway.
- Outputs: A full frame rendered in 3D with a studio environment.
- Coordinates: The bottle is centred on the origin, about 5 across, hung 3.3 above the floor; the cutting plane is perpendicular to x in world space and starts clear of the bottle and sweeps in to cut away about two-thirds of it, twice per loop.
- Lighting: A warm key light with a shadow map and the studio environment.
- Timing: setProgress(progress) sets the turn and the plane; frames render in any order.
- Works with: chrome-material, orbit-camera, kinetic-title, number-reveal
- The mesh is built once; clipping happens on the GPU.

## Output and loop
- 1080×1080, 30 fps, 16 s, procedural
- Seamless loop: yes — The surface turns a whole number of times per loop, the cutting plane's position is a sine 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 localClippingEnabled = true and a studio environment, add createKleinBottle().group and call bottle.setProgress(progress) each frame.

Existing project: Copy src/klein-bottle.js; enable localClippingEnabled on your renderer and add the group to your scene with an environment map.

Reuse ideas:
- Maths explainer: Iridescent, cut.
- Product-style: Chrome, whole.
- Calm: Glass, two turns.

## Limitations
- A Klein bottle cannot exist in three dimensions without passing through itself: the figure-eight form intersects itself along a circle.
- The glass finish is transparent without true refraction.

## 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/klein-bottle (MIT) and rebuilt for AI Pixel Wizard in October 2026 as an original studio object: the figure-eight immersion as a static mesh with seam-averaged normals, a world-space cutting plane sweeping in a sine of the loop and an iridescent finish, on an exact loop.

