# Differential Gear — `differential-gear@1.0.1`

A car differential at work: ring gear, carrier, spider and side gears with the two shafts speeding apart and back. Loops perfectly.

The mechanism that lets the two wheels of a car turn at different speeds in a corner: a ring gear driven by a pinion, a carrier drum turning with it, a cross-pin with two spider gears and two bevel side gears on the axle shafts. The carrier turns a whole number of times per loop while the two shafts speed up and slow down against each other and the spider gears spin on their pin by exactly the difference. Choose the metal, the turns per loop, how far the shafts slip apart, the backdrop colour and whether the camera sways.

- Kind: object; status: published; digest sha256:93cf2bf54e6e43e8d9a83e95b80dd38787f2240a083d7c1637412b3fdb58ccbc
- Role: Object (3D, three.js): a mechanical showpiece for engineering, automotive and how-it-works content.
- Implementation: three; entry `src/differential-gear.js`
- Files: https://aipixelwizard.com/registry/differential-gear/1.0.1/<path> (`LICENSE`, `asset.json`, `demo.js`, `index.html`, `src/differential-gear.js`)
- Manifest JSON: https://aipixelwizard.com/api/v1/visuals/differential-gear/versions/1.0.1
- Runnable demo: https://aipixelwizard.com/registry/differential-gear/1.0.1/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
- `createDifferential({ metal?, turns?, slip? }) => { group, setProgress(progress), dispose() }` — The differential (ring gear, pinion, carrier, spider and side gears, shafts) as a group with the axle along x; needs an environment map.
- `METALS: { steel, brass, copper, blackened }` — Metal finishes with colour and roughness.

## Parameters
- `metal` (select one of steel | brass | copper | blackened, default "steel") — Metal
- `turns` (integer 1–3, default 1) — Turns per loop
- `slip` (number 0–1.5, default 1) — Shaft slip
- `background` (color, default "#1a2330") — Backdrop
- `orbit` (boolean, default true) — Camera sway

## Composition
- Inputs: Time within the loop; the metal, turns, slip, backdrop and camera sway.
- Outputs: A full frame rendered in 3D with a studio environment.
- Coordinates: The axle runs along x through the origin; the ring gear (radius 2.8) and carrier are centred on it; the pinion sits below at y ≈ −3.3.
- Lighting: A warm key light with a shadow map and the studio environment.
- Timing: setProgress(progress) sets every angle in closed form; frames render in any order.
- Works with: chrome-material, orbit-camera, kinetic-title, number-reveal
- Bevel gears are 45° cones with instanced teeth along the slant; spiders spin by the shafts' slip.

## Output and loop
- 1080×1080, 30 fps, 16 s, procedural
- Seamless loop: yes — The carrier turns a whole number of times per loop, the shaft slip and the spider spin are sines of the loop and the camera sway is a sine of the loop, so the last frame meets the first.
- Verified 2026-10-08 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, add createDifferential().group and call diff.setProgress(progress) each frame.

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

Reuse ideas:
- Explainer: Steel, one turn.
- Vintage workshop: Brass, warm.
- Energetic loop: Fast, copper.

## Limitations
- Gear teeth are visual, not meshed exactly; the teeth of different gears may pass through each other.
- The pinion drives the ring gear as a spur gear for clarity.

## 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/differential-gear (MIT) and rebuilt for AI Pixel Wizard in October 2026 as an original studio object: bevel gears from cones with instanced teeth, a toothed ring gear and pinion, and carrier and shaft angles in closed form on an exact loop.

