# Chain Links — `chain-links@1.0.0`

A heavy polished chain hangs between two posts and sways in a slow wave. Loops perfectly.

A chain of polished links hanging between two posts in a catenary curve, swaying gently: a slow wave runs along it from post to post, each link turning a little as it goes, every second link at right angles to its neighbours as in a real chain, the whole thing breathing in and out of its sag. Choose the number of links, the metal (steel, brass, copper or black), how deep the chain hangs, how much it sways, the backdrop and whether the camera drifts.

- Kind: object; status: published; digest sha256:7d743501890d71e411a23269aef0e236099cca9911ddfaad92925a89905ff765
- Role: Object (3D, three.js): a strong, tactile hero object for security, connection, industry and strength content.
- Implementation: three; entry `src/chain-links.js`
- Files: https://aipixelwizard.com/registry/chain-links/1.0.0/<path> (`LICENSE`, `asset.json`, `demo.js`, `index.html`, `src/chain-links.js`)
- Manifest JSON: https://aipixelwizard.com/api/v1/visuals/chain-links/versions/1.0.0
- Runnable demo: https://aipixelwizard.com/registry/chain-links/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
- `createChain({ links?, metal?, sag?, sway? }) => { group, setProgress(progress), dispose() }` — The chain (one instanced mesh of links) and its two posts as a group; the posts are 10 apart, the chain hangs from y = 5; add it with an environment map and a shadow-casting light.
- `METALS: { steel, brass, copper, black }` — Metal finishes.

## Parameters
- `links` (integer 12–40, default 24) — Links
- `metal` (select one of steel | brass | copper | black, default "steel") — Metal
- `sag` (number 0.5–1.6, default 1) — Sag
- `sway` (number 0–2, default 1) — Sway
- `background` (color, default "#1c2430") — Backdrop
- `orbit` (boolean, default true) — Camera drift

## Composition
- Inputs: Time within the loop; the links, metal, sag, sway, backdrop and camera drift.
- Outputs: A full frame rendered in 3D with soft shadows and a studio environment.
- Coordinates: Posts at x = ±5.2; the chain runs between y = 5 on the posts and sags to about y = 2.4; it sways along z.
- Lighting: A warm key light with a shadow map and the studio environment on the polished metal.
- Timing: setProgress(progress) places every link; frames render in any order.
- Works with: chrome-material, orbit-camera, kinetic-title, number-reveal
- The links are spaced evenly by arc length along a catenary re-solved for each frame's sag; each link's orientation follows the tangent with an extra quarter-turn on alternate links.

## Output and loop
- 1080×1080, 30 fps, 12 s, procedural
- Seamless loop: yes — The sag breathes in a sine of the loop and a wave of sway runs along the chain as sines of whole cycles of the loop (two and three), 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 with shadows and a studio environment (see chrome-material), add createChain().group and call chain.setProgress(progress) each frame.

Existing project: Copy src/chain-links.js; add chain.group to your scene with an environment map and a shadow-casting light.

Reuse ideas:
- Industrial or security title: Steel, twenty-four links.
- Luxury accent: Brass, deep sag.
- Heavy impact scene: Copper, heavy swing.

## Limitations
- The links are placed along a curve rather than simulated: they do not collide or interlock physically.
- The chain's length is fixed by its link count, so a deep sag stretches the spacing a little.

## 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/chain-links (MIT) and rebuilt for AI Pixel Wizard in October 2026 as an original object: stadium-shaped links on a re-solved catenary with alternating orientation, a travelling sway wave and an exact loop.

