# Product Turntable

A flat black earbud case sits on a white background. Light comes up across it, it turns in space from front to side to back and to a three-quarter view, the lid opens to show two earbuds and a green status light, and the case slides left beside the Drift lockup.

- Position in a launch film: Product reveal
- Slug: product-turntable
- Preview video: https://media.motionboard.app/turntable.mp4
- Recipe page: https://motionboard.app/recipes/product-turntable/
- License: MIT. Free to use in your own projects, including commercial launch films. https://github.com/krisyangdev/motionboard/blob/main/LICENSE

## How to use this recipe

You are a coding agent. The user wants this shot for their own product. Follow these steps.

1. **Know the product.** If the product is clear from the user's repo or conversation, ask nothing and start. Otherwise ask once for: product name, logo file, brand colors.
2. **Pick the output.** If the user's message says a video or their website, do that. Otherwise ask once which one they want.
   - **Video (HyperFrames).** Create a folder named `turntable`. Download every file under "Source files" below with the curl commands, keeping relative paths. Adapt `index.html` (see "What to adapt"). Run `npx --yes hyperframes@0.8.209 check` on the untouched copy first and note its result. Preview with `npx --yes hyperframes@0.8.209 preview`, render an MP4 with `npx --yes hyperframes@0.8.209 render` (into `renders/`, named with a timestamp). The same commands are in `package.json` as `dev`, `check`, `render`; pass flags after `--`, as in `npm run render -- --quality draft`. Rendering needs network access for web fonts and GSAP.
   - **Website motion.** Port the GSAP timeline in `index.html` into the user's site, using their stack (React, Vue, Svelte, plain HTML). Build the same DOM structure, keep the timeline's durations, delays and easings exactly, and start it when the element scrolls into view (IntersectionObserver or ScrollTrigger). Respect `prefers-reduced-motion: reduce`: show the final frame as a static state and skip the movement.
3. **What to adapt.**
   - **Brand layer** (product name, logo, colors, fonts, copy): replace directly with the user's.
   - **UI layer** (the product screens, cards, windows, controls shown in the shot): rebuild the user's real UI as clean DOM, from their codebase (components, design tokens) or from a screenshot used as reference only. Never paste a screenshot into the shot.
   - **Motion** (timing, easing, camera moves, layering, stagger, order of events): keep exactly as in the source. This is what the recipe is.
   - The timeline targets UI elements by id and class, and camera moves land on fixed coordinates. Keep the ids the timeline uses, keep row counts and text lengths close to the source, and when the layout moves, update the target coordinates without changing the times.
4. **Fonts.** HyperFrames fetches Google Fonts such as Inter on its own. Some sources use macOS local fonts (PingFang, Songti via `local()`). Use the user's brand font when it can be bundled; for a system font such as SF Pro, use Inter. Check that text still fits its boxes.
5. **Verify.** Compare the render with the preview video above at the beat times in the Timing row. The beats, timing and camera should match; only brand and UI content differ.

## Spec

| Item | Value |
| --- | --- |
| Timing | Film 10.8s. Black silhouette 0–0.4s; light sweeps up left to right 0.4–2.7s (2.3s); turn 1.9–6.0s (4.1s, yaw 8°→394°: front, side, back, side, front three-quarter); camera pitch 10°→15° over the turn, then to 21° at 5.9–7.0s; lid opens 0°→46° at 6.0–7.1s; status light turns green at 6.05–6.55s; case slides left at 6.9–7.9s (1.0s) and stays still; lockup mark 7.5s (0.8s), wordmark 7.6s (0.9s), tagline 7.8s (0.8s), all settled by 8.6s and held to the end |
| Easing | Light sweep and pitch change power2.inOut; the turn sine.inOut (peak about 148°/s, average 94°/s); lid opening power3.out; slide power3.inOut; status light smoothstep; lockup rises expo.out |
| Camera | Locked frame with no zoom, perspective distance 2800px, looking down at the case: pitch 10° at the start, 15° at the end of the turn, 21° with the lid open. The case is centred at (960, 520) until it slides to x=700 and scales 1→0.9 |
| Subject | Pebble case 700x530x300px (superellipsoid, exponent 0.5 in profile and 0.8 in plan) cut by a seam 79.5px above centre into a base and a lid, groove 5px deep over 8px on each side; hinge barrel radius 22px and half-length 95px on the back wall; status light radius 8px, 46px below the seam; pairing button radius 21px on the back, 74px below the seam; two earbuds with 116x104x120px heads and 40px-wide stems lying toward the hinge, each with a 14px-radius mid-grey grille. About 17,000 cells, 112 around |
| Sync | Gloss and highlights appear only once a region is past half lit, so the material arrives after the shape; the turn starts at 1.9s, 0.8s before the light finishes; the status light turns green inside the lid opening (6.05–6.55s within 6.0–7.1s); the slide starts at 6.9s, 0.2s before the lid is fully open, and the lockup starts at 7.5s when the case is past the middle of its slide, so the two never overlap |
| Style | White seamless `#f5f6f8` (radial gradient `#fcfcfd` to `#eef0f3`), ink `#0f1115`, grey `#6b7079`, one accent green `#1fc98a` used only on the status light and the dot in the mark; the silhouette is flat black `rgb(14,14,17)`; Inter 700 wordmark at 208px with -0.055em tracking and a 48px tagline; soft floor shadow and a faint vignette, no grain |

## Why it works

The silhouette makes the viewer read the shape before the material: a flat black pebble on white has no detail, so the light that comes up across it is the first event of the film. Gloss and highlights only start once a region is more than half lit, so the form appears first as soft grey and the plastic appears after it. The turn is a real 3D rotation: the case is a mesh that is rotated and projected every frame, so the silhouette changes (a 700px-wide case becomes a 300px-deep edge at the side), the highlights slide across the surface and the groove at the seam moves with the angle. The back view shows the hinge and the pairing button, which tells the viewer the object is solid all the way round. The camera sits 10° above the case and rises to 21°, so the open lid and the two earbuds inside are visible from above. The lid opens only after the turn has ended, and the status light turns green during that opening, so the single accent colour marks the moment the product comes alive. Then the case slides left and holds still, and the lockup arrives beside it, which keeps the product on screen to the end.

## Prompt

> Build a 10.8-second, 1920x1080, 30 fps product turntable film called Product Turntable for a fictional product, Drift (wireless earbuds in a charging case). The frame is a white seamless: a radial gradient #fcfcfd to #f5f6f8 to #eef0f3 with a faint vignette, ink #0f1115, grey #6b7079 and one accent green #1fc98a. WebGL is not available on the render box, so draw the 3D product with a software renderer on one 1920x1080 canvas 2D, redrawn in one render(t) function from the timeline time (one linear proxy tween, no CSS animations, no random). Model the case as a superellipsoid pebble 700px wide, 530px tall and 300px deep (half sizes 350, 265, 150; exponent 0.5 in profile, 0.8 in plan), split by a seam 79.5px above the centre into a base and a lid. Inset both lips by up to 5px over 8px to cut a groove, add a hinge barrel along x (radius 22px, half-length 95px) on the back wall at seam height, a status light (radius 8px) 46px below the seam on the front and a pairing button (radius 21px) on the back. Tessellate 112 segments around and about 60 rows per half, with extra rows near the seam, and compute vertex normals from the grid. Each frame: rotate the vertices (yaw, then pitch; the lid also rotates about the hinge axis), project with a perspective distance of 2800px, cull back faces, sort cells back to front and fill each cell with a linear gradient between its left and right edge colours, stroked at 1.6px with the same gradient so no seams show. Shade every vertex: a key light from upper left, a weaker fill from the right, a cool shadow tone rgb(168,176,194) up to rgb(244,245,248), a Fresnel term, a reflected environment made of a top strip, a key softbox, a right kicker and two dark side cards for crisp edge reflections, darker edges and a darker groove. Timeline: 0–0.4s a flat black silhouette rgb(14,14,17) with no shadow; 0.4–2.7s the light sweeps from left to right with power2.inOut, each region going from black to grey diffuse first and to gloss and highlights once it is more than half lit, while a soft floor shadow fades in; 1.9–6.0s the case turns from 8° to 394° of yaw with sine.inOut (front, side, back, side, front three-quarter) while the camera pitch rises from 10° to 15°; 5.9–7.0s the pitch goes to 21°; 6.0–7.1s the lid opens 46° about the hinge with power3.out, showing two earbuds (116x104x120px heads, 40px stems pointing to the hinge, a 14px mid-grey grille on each head), and the status light fades from grey to green over 6.05–6.55s; 6.9–7.9s the case slides to x=700 and scales to 0.9 with power3.inOut, then stays still; the lockup sits to the right of it: a 104px mark at 7.5s, the wordmark Drift at 208px in Inter 700 at 7.6s and the tagline Quiet you can carry. at 48px at 7.8s, each rising 18–26px with expo.out over 0.8–0.9s, settled by 8.6s and held to 10.8s. For your own product, replace the case proportions, the seam height, the small features and the lockup; keep the order of beats: silhouette, light, turn, open, slide, lockup.

## Often confused with

- [Light Reveal](https://motionboard.app/r/light-reveal.md): Light Reveal uses a sweeping light to bring out the material of a product on black; here the light first lifts a flat black silhouette on white, and the product then turns through a full 3D rotation and opens.
- [Exploded View Animation](https://motionboard.app/r/exploded-view-animation.md): Exploded View separates the layers of a device and flies the camera into them; the Product Turntable keeps the product whole, turns it through 394° and opens only its lid.

## Source files

Runnable HyperFrames project, 3 files.

- https://motionboard.app/source/turntable/hyperframes.json (318 B)
- https://motionboard.app/source/turntable/index.html (27.7 KB)
- https://motionboard.app/source/turntable/package.json (298 B)

Download all of them:

```sh
curl -fsSL --create-dirs -o "turntable/hyperframes.json" "https://motionboard.app/source/turntable/hyperframes.json"
curl -fsSL --create-dirs -o "turntable/index.html" "https://motionboard.app/source/turntable/index.html"
curl -fsSL --create-dirs -o "turntable/package.json" "https://motionboard.app/source/turntable/package.json"
```

## index.html

```html
<!doctype html>
<html lang="en" data-resolution="landscape">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=1920, height=1080" />
    <script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
    <style>
      :root {
        --bg: #f5f6f8;
        --ink: #0f1115;
        --sub: #6b7079;
        --acc: #1fc98a;
        --font-ui: "Inter", -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
      }
      * { margin: 0; padding: 0; box-sizing: border-box; }
      html, body { width: 1920px; height: 1080px; overflow: hidden; background: var(--bg); }
      #root {
        position: relative; width: 1920px; height: 1080px; overflow: hidden; background: var(--bg);
        font-family: var(--font-ui); color: var(--ink); -webkit-font-smoothing: antialiased;
      }
      .full { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; }
      svg { display: block; flex: none; }
      canvas { display: block; }

      #bg { background: radial-gradient(ellipse 78% 70% at 50% 44%, #fcfcfd 0%, #f5f6f8 62%, #eef0f3 100%); }
      #vig { pointer-events: none; background: radial-gradient(ellipse 80% 84% at 50% 50%, rgba(0,0,0,0) 62%, rgba(40,48,66,0.07) 100%); }

      #lock { display: flex; flex-direction: column; justify-content: center; padding-left: 1140px; }
      #mark { width: 104px; height: 104px; opacity: 0; }
      #wm { margin-top: 30px; font-size: 208px; line-height: 200px; font-weight: 700; letter-spacing: -0.055em; opacity: 0; }
      #tg { margin-top: 26px; font-size: 48px; line-height: 58px; font-weight: 500; letter-spacing: -0.02em; color: var(--sub); opacity: 0; }
    </style>
  </head>
  <body>
    <div id="root" data-composition-id="main" data-start="0" data-duration="10.8" data-width="1920" data-height="1080">
      <div id="bg" class="clip full" data-start="0" data-duration="10.8" data-track-index="0" data-layout-allow-overlap data-layout-ignore></div>
      <div id="stage" class="clip full" data-start="0" data-duration="10.8" data-track-index="1" data-layout-allow-overlap data-layout-ignore><canvas id="cv" width="1920" height="1080"></canvas></div>
      <div id="vig" class="clip full" data-start="0" data-duration="10.8" data-track-index="2" data-layout-allow-overlap data-layout-ignore></div>

      <div id="lock" class="clip full" data-start="0" data-duration="10.8" data-track-index="3" data-layout-allow-overlap>
        <svg id="mark" viewBox="0 0 48 48"><rect width="48" height="48" rx="13" fill="#0f1115"/><path d="M9 29C15 20 21 20 25 26S34 32 39 21" stroke="#ffffff" stroke-width="3.8" stroke-linecap="round" stroke-linejoin="round" fill="none"/><circle cx="39" cy="21" r="3.6" fill="#1fc98a"/></svg>
        <div id="wm">Drift</div>
        <div id="tg">Quiet you can carry.</div>
      </div>
    </div>

    <script>
      const DUR = 10.8;
      const DEG = Math.PI / 180;
      const clamp = (x, a, b) => Math.min(b, Math.max(a, x));
      const mixf = (a, b, k) => a + (b - a) * k;
      const ss = (a, b, x) => { const t = clamp((x - a) / (b - a), 0, 1); return t * t * (3 - 2 * t); };
      const seg = (t, a, b) => clamp((t - a) / (b - a), 0, 1);
      const eSine = (k) => -(Math.cos(Math.PI * k) - 1) / 2;
      const eP2 = (k) => (k < 0.5 ? 2 * k * k : 1 - Math.pow(-2 * k + 2, 2) / 2);
      const eP3 = (k) => (k < 0.5 ? 4 * k * k * k : 1 - Math.pow(-2 * k + 2, 3) / 2);
      const eOut3 = (k) => 1 - Math.pow(1 - k, 3);
      const sp = (x, e) => (x < 0 ? -1 : 1) * Math.pow(Math.abs(x), e);

      /* ---------- the case: superellipsoid pebble, lid above a seam ---------- */
      const A = 350, B = 265, C = 150, E1 = 0.5, E2 = 0.8;
      const YS = 0.3 * B, YNS = 0.3;
      const HZ = -146;           /* hinge axis z */
      const NU = 112;
      const F = 2800;            /* camera distance */

      const cvp = (yn, e1) => Math.pow(Math.max(0, 1 - Math.pow(Math.abs(yn), 2 / e1)), e1 / 2);
      const grooveD = (y) => 5 * Math.pow(Math.max(0, 1 - Math.abs(y - YS) / 8), 2);
      function surf(o, yn, u) {
        const cv = cvp(yn, o.e1);
        let x = o.a * cv * sp(Math.cos(u), o.e2), z = o.c * cv * sp(Math.sin(u), o.e2);
        const y = o.b * yn;
        if (o.groove) {
          const d = grooveD(y);
          if (d > 0) { const R = Math.hypot(x, z) || 1; const k = Math.max(0, 1 - d / R); x *= k; z *= k; }
        }
        return [x, y, z];
      }
      function surfNormal(o, yn, u) {
        const e = 1e-3, p = surf(o, yn, u);
        const a = surf(o, yn, u + e), b = surf(o, yn, u - e), c = surf(o, yn + e, u), d = surf(o, yn - e, u);
        const pu = [a[0] - b[0], a[1] - b[1], a[2] - b[2]], py = [c[0] - d[0], c[1] - d[1], c[2] - d[2]];
        let n = [pu[1] * py[2] - pu[2] * py[1], pu[2] * py[0] - pu[0] * py[2], pu[0] * py[1] - pu[1] * py[0]];
        if (n[0] * p[0] + n[2] * p[2] < 0) n = n.map((v) => -v);
        const l = Math.hypot(n[0], n[1], n[2]) || 1;
        return n.map((v) => v / l);
      }
      function rowList(o) {
        const v0 = Math.asin(clamp(sp(o.yn0, 1 / o.e1), -1, 1)), v1 = Math.asin(clamp(sp(o.yn1, 1 / o.e1), -1, 1));
        const arr = [];
        for (let i = 0; i <= o.nv; i++) arr.push(sp(Math.sin(mixf(v0, v1, i / o.nv)), o.e1));
        arr[0] = o.yn0; arr[arr.length - 1] = o.yn1;
        (o.extra || []).forEach((y) => { const yn = y / o.b; if (yn > o.yn0 + 1e-4 && yn < o.yn1 - 1e-4) arr.push(yn); });
        arr.sort((p, q) => p - q);
        const out = [arr[0]];
        for (let i = 1; i < arr.length; i++) if (arr[i] - out[out.length - 1] > 2e-4) out.push(arr[i]);
        return out;
      }

      const nrm3 = (x, y, z) => { const l = Math.hypot(x, y, z); return [x / l, y / l, z / l]; };
      const parts = [];
      let POOL = 0, CELLS = 0;
      function finishPart(p) {
        p.base = POOL; POOL += p.nr * p.nu;
        CELLS += (p.nr - 1) * p.nu;
        parts.push(p);
      }
      const I3 = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
      function xform(P, N, rot, pos) {
        const n = P.length / 3;
        for (let k = 0; k < n; k++) {
          const x = P[3 * k], y = P[3 * k + 1], z = P[3 * k + 2];
          P[3 * k] = rot[0][0] * x + rot[0][1] * y + rot[0][2] * z + pos[0];
          P[3 * k + 1] = rot[1][0] * x + rot[1][1] * y + rot[1][2] * z + pos[1];
          P[3 * k + 2] = rot[2][0] * x + rot[2][1] * y + rot[2][2] * z + pos[2];
          const nx = N[3 * k], ny = N[3 * k + 1], nz = N[3 * k + 2];
          N[3 * k] = rot[0][0] * nx + rot[0][1] * ny + rot[0][2] * nz;
          N[3 * k + 1] = rot[1][0] * nx + rot[1][1] * ny + rot[1][2] * nz;
          N[3 * k + 2] = rot[2][0] * nx + rot[2][1] * ny + rot[2][2] * nz;
        }
      }
      function buildSurface(o) {
        const rows = rowList(o), nr = rows.length, nu = o.nu;
        const P = new Float32Array(nr * nu * 3), N = new Float32Array(nr * nu * 3);
        for (let i = 0; i < nr; i++) {
          for (let j = 0; j < nu; j++) {
            const q = surf(o, rows[i], (2 * Math.PI * j) / nu), k = 3 * (i * nu + j);
            P[k] = q[0]; P[k + 1] = q[1]; P[k + 2] = q[2];
          }
        }
        /* area-weighted vertex normals from the quads */
        for (let i = 0; i < nr - 1; i++) {
          for (let j = 0; j < nu; j++) {
            const j1 = (j + 1) % nu;
            const a = 3 * (i * nu + j), b = 3 * (i * nu + j1), c = 3 * ((i + 1) * nu + j1), d = 3 * ((i + 1) * nu + j);
            const d1x = P[c] - P[a], d1y = P[c + 1] - P[a + 1], d1z = P[c + 2] - P[a + 2];
            const d2x = P[d] - P[b], d2y = P[d + 1] - P[b + 1], d2z = P[d + 2] - P[b + 2];
            const nx = d1y * d2z - d1z * d2y, ny = d1z * d2x - d1x * d2z, nz = d1x * d2y - d1y * d2x;
            [a, b, c, d].forEach((q) => { N[q] += nx; N[q + 1] += ny; N[q + 2] += nz; });
          }
        }
        let mx = 0, my = 0, mz = 0; const nv = nr * nu;
        for (let k = 0; k < nv; k++) { mx += P[3 * k]; my += P[3 * k + 1]; mz += P[3 * k + 2]; }
        mx /= nv; my /= nv; mz /= nv;
        let s = 0;
        for (let k = 0; k < nv; k++) s += N[3 * k] * (P[3 * k] - mx) + N[3 * k + 1] * (P[3 * k + 1] - my) + N[3 * k + 2] * (P[3 * k + 2] - mz);
        const sg = s < 0 ? -1 : 1;
        for (let k = 0; k < nv; k++) {
          let nx = N[3 * k] * sg, ny = N[3 * k + 1] * sg, nz = N[3 * k + 2] * sg;
          const l = Math.hypot(nx, ny, nz);
          if (l < 1e-9) { nx = 0; ny = 1; nz = 0; } else { nx /= l; ny /= l; nz /= l; }
          N[3 * k] = nx; N[3 * k + 1] = ny; N[3 * k + 2] = nz;
        }
        /* groove tag per cell (local y, before any transform) */
        const G = new Float32Array((nr - 1) * nu);
        if (o.groove) {
          for (let i = 0; i < nr - 1; i++) {
            for (let j = 0; j < nu; j++) {
              const yc = (P[3 * (i * nu + j) + 1] + P[3 * ((i + 1) * nu + j) + 1]) * 0.5;
              G[i * nu + j] = Math.pow(Math.max(0, 1 - Math.abs(yc - YS) / 3.5), 1.5);
            }
          }
        }
        xform(P, N, o.rot || I3, o.pos || [0, 0, 0]);
        const part = { P, N, G, nr, nu, mat: o.mat || 0, lid: !!o.lid, interior: !!o.interior, onlyOpen: !!o.onlyOpen, inLo: o.inLo, inHi: o.inHi };
        finishPart(part);
        return part;
      }
      function buildRing(sign, lid) {
        const nu = NU, P = new Float32Array(2 * nu * 3), N = new Float32Array(2 * nu * 3);
        for (let j = 0; j < nu; j++) {
          const q = surf(BASE, YNS, (2 * Math.PI * j) / nu), R = Math.hypot(q[0], q[2]) || 1, k = Math.max(0, 1 - 13 / R);
          P[3 * j] = q[0]; P[3 * j + 1] = q[1]; P[3 * j + 2] = q[2];
          const m = 3 * (nu + j);
          P[m] = q[0] * k; P[m + 1] = q[1]; P[m + 2] = q[2] * k;
        }
        for (let k = 0; k < 2 * nu; k++) { N[3 * k + 1] = sign; }
        const part = { P, N, G: new Float32Array(nu), nr: 2, nu, mat: 3, lid, interior: false, onlyOpen: true };
        finishPart(part);
      }

      const extraY = [];
      [0.5, 1.2, 2.2, 3.5, 5, 6.5, 8.2].forEach((d) => { extraY.push(YS + d, YS - d); });
      const BASE = { a: A, b: B, c: C, e1: E1, e2: E2, nu: NU, yn0: -1, yn1: YNS, nv: 60, extra: extraY, groove: true, mat: 0, interior: true, inLo: [108, 114, 126], inHi: [226, 229, 234] };
      const LIDO = { a: A, b: B, c: C, e1: E1, e2: E2, nu: NU, yn0: YNS, yn1: 1, nv: 52, extra: extraY, groove: true, mat: 0, lid: true, interior: true, inLo: [176, 181, 191], inHi: [232, 234, 239] };
      buildSurface(BASE);
      buildSurface(LIDO);
      buildRing(1, false);
      buildRing(-1, true);
      /* hinge barrel along x, half in the back wall */
      buildSurface({ a: 22, b: 95, c: 22, e1: 0.3, e2: 1, nu: 28, yn0: -1, yn1: 1, nv: 18, rot: [[0, -1, 0], [1, 0, 0], [0, 0, 1]], pos: [0, YS, HZ], mat: 1 });
      /* earbuds */
      const sprites = [];
      function addBud(sx, side) {
        /* stem points back toward the hinge, slightly down and inward; local +y is opposite the stem */
        const dir = nrm3(-0.12 * side, -0.35, -0.92), u = [-dir[0], -dir[1], -dir[2]];
        const exl = Math.hypot(u[1], u[0]) || 1, ex = [u[1] / exl, -u[0] / exl, 0];
        const ez = [ex[1] * u[2] - ex[2] * u[1], ex[2] * u[0] - ex[0] * u[2], ex[0] * u[1] - ex[1] * u[0]];
        const R = [[ex[0], u[0], ez[0]], [ex[1], u[1], ez[1]], [ex[2], u[2], ez[2]]];
        const rm = (v) => [R[0][0] * v[0] + R[0][1] * v[1] + R[0][2] * v[2], R[1][0] * v[0] + R[1][1] * v[1] + R[1][2] * v[2], R[2][0] * v[0] + R[2][1] * v[1] + R[2][2] * v[2]];
        const rt = (v) => [R[0][0] * v[0] + R[1][0] * v[1] + R[2][0] * v[2], R[0][1] * v[0] + R[1][1] * v[1] + R[2][1] * v[2], R[0][2] * v[0] + R[1][2] * v[1] + R[2][2] * v[2]];
        const hp = [sx, YS + 4, 52];
        const sv = rm([0, -86, -6]);
        buildSurface({ a: 58, b: 52, c: 60, e1: 1, e2: 1, nu: 40, yn0: -1, yn1: 1, nv: 22, rot: R, pos: hp, mat: 2, onlyOpen: true });
        buildSurface({ a: 20, b: 70, c: 19, e1: 0.6, e2: 1, nu: 28, yn0: -1, yn1: 1, nv: 16, rot: R, pos: [hp[0] + sv[0], hp[1] + sv[1], hp[2] + sv[2]], mat: 2, onlyOpen: true });
        /* small speaker grille on the upper outer side of the head (world direction, converted to head space) */
        const dl = rt(nrm3(0.4 * side, 0.85, 0.3));
        const t = 1 / Math.sqrt(Math.pow(dl[0] / 58, 2) + Math.pow(dl[1] / 52, 2) + Math.pow(dl[2] / 60, 2));
        const q = [dl[0] * t, dl[1] * t, dl[2] * t];
        let nn = [q[0] / (58 * 58), q[1] / (52 * 52), q[2] / (60 * 60)];
        const nl = Math.hypot(nn[0], nn[1], nn[2]); nn = nn.map((v) => v / nl);
        const qp = rm(q), np = rm(nn);
        sprites.push({ kind: "grille", p: [qp[0] + hp[0], qp[1] + hp[1], qp[2] + hp[2]], n: np, r: 14, onlyOpen: true });
      }
      addBud(-98, -1);
      addBud(98, 1);
      /* status light on the front below the seam, pairing button on the back */
      sprites.push({ kind: "led", p: surf(BASE, (YS - 46) / B, Math.PI / 2), n: surfNormal(BASE, (YS - 46) / B, Math.PI / 2), r: 8 });
      sprites.push({ kind: "btn", p: surf(BASE, (YS - 74) / B, -Math.PI / 2), n: surfNormal(BASE, (YS - 74) / B, -Math.PI / 2), r: 21 });

      /* per-frame pools */
      const WX = new Float32Array(POOL), WY = new Float32Array(POOL), WZ = new Float32Array(POOL);
      const SX = new Float32Array(POOL), SY = new Float32Array(POOL);
      const NX = new Float32Array(POOL), NY = new Float32Array(POOL), NZ = new Float32Array(POOL);
      const IA = new Int32Array(CELLS), IB = new Int32Array(CELLS), IC = new Int32Array(CELLS), ID = new Int32Array(CELLS);
      const KEY = new Float32Array(CELLS), ORD = new Int32Array(CELLS), ICOL = new Array(CELLS), ICOL1 = new Array(CELLS), ICOL2 = new Array(CELLS), IKIND = new Uint8Array(CELLS);
      const VR = new Float32Array(POOL), VG = new Float32Array(POOL), VB = new Float32Array(POOL);

      /* ---------- studio lighting ---------- */
      const LK = nrm3(-0.55, 0.75, 0.55), LF = nrm3(0.7, 0.15, 0.5);
      const MUL = [1.0, 0.93, 1.02, 0.96], SPEC = [1.0, 0.8, 1.0, 0.25];
      const BLACK = [14, 14, 17];
      const rgb = (r, g, b) => "rgb(" + (r | 0) + "," + (g | 0) + "," + (b | 0) + ")";

      function shade(nx, ny, nz, mat, g, Lc, out) {
        const dk = clamp((nx * LK[0] + ny * LK[1] + nz * LK[2] + 0.3) / 1.3, 0, 1);
        const df = clamp((nx * LF[0] + ny * LF[1] + nz * LF[2] + 0.45) / 1.45, 0, 1);
        const up = ny * 0.5 + 0.5;
        const lum = (0.6 + 0.22 * dk + 0.1 * df + 0.1 * up) * MUL[mat];
        const t = clamp((lum - 0.48) / 0.52, 0, 1);
        let r = 168 + 76 * t, g2 = 176 + 69 * t, b = 194 + 54 * t;
        const nzc = clamp(nz, 0, 1);
        const F0 = 0.04 + 0.96 * Math.pow(1 - nzc, 4);
        const rx = 2 * nzc * nx, ry = 2 * nzc * ny, rz = 2 * nzc * nzc - 1;
        let eb = ry > 0 ? 0.9 + 0.1 * ry : 0.9 - 0.44 * Math.min(1, -ry * 1.5);
        if (rz < 0) eb += 0.05 * Math.min(1, -rz);
        const dark = 0.5 * (ss(0.78, 0.93, -0.92 * rx + 0.05 * ry + 0.38 * rz) + ss(0.78, 0.93, 0.92 * rx - 0.05 * ry + 0.38 * rz));
        eb *= 1 - dark;
        const h = Math.min(1, ss(0.86, 0.965, -0.45 * rx + 0.62 * ry + 0.64 * rz) + 0.9 * ss(0.9, 0.985, 0.15 * rx + 0.96 * ry + 0.23 * rz) + 0.6 * ss(0.88, 0.97, 0.84 * rx + 0.25 * ry + 0.48 * rz));
        const kg = ss(0.5, 1, Lc) * SPEC[mat];
        const ks = F0 * 0.7 * kg;
        r = r * (1 - ks) + eb * 246 * ks; g2 = g2 * (1 - ks) + eb * 248 * ks; b = b * (1 - ks) + eb * 252 * ks;
        const hh = h * kg * 0.9;
        r += (255 - r) * hh; g2 += (255 - g2) * hh; b += (255 - b) * hh;
        const ed = 1 - 0.17 * ss(0.5, 0, nz);
        const gd = ed * (1 - 0.5 * g);
        r *= gd; g2 *= gd; b *= gd;
        out[0] = BLACK[0] + (r - BLACK[0]) * Lc; out[1] = BLACK[1] + (g2 - BLACK[1]) * Lc; out[2] = BLACK[2] + (b - BLACK[2]) * Lc;
      }

      /* ---------- renderer ---------- */
      const cv = document.getElementById("cv");
      const ctx = cv.getContext("2d");
      const ocv = document.createElement("canvas"); ocv.width = 1920; ocv.height = 1080;
      const octx = ocv.getContext("2d");
      const col = [0, 0, 0];

      function blob(fx, fy, rx, ry, a0) {
        ctx.save();
        ctx.translate(fx, fy);
        ctx.scale(1, ry / rx);
        const gr = ctx.createRadialGradient(0, 0, 0, 0, 0, rx);
        gr.addColorStop(0, "rgba(32,38,52," + a0.toFixed(3) + ")");
        gr.addColorStop(0.5, "rgba(32,38,52," + (a0 * 0.42).toFixed(3) + ")");
        gr.addColorStop(1, "rgba(32,38,52,0)");
        ctx.fillStyle = gr;
        ctx.beginPath();
        ctx.arc(0, 0, rx, 0, Math.PI * 2);
        ctx.fill();
        ctx.restore();
      }

      function drawSprite(s, M, scx, scy, ssc, light, led) {
        const wx = M[0][0] * s.p[0] + M[0][1] * s.p[1] + M[0][2] * s.p[2];
        const wy = M[1][0] * s.p[0] + M[1][1] * s.p[1] + M[1][2] * s.p[2];
        const wz = M[2][0] * s.p[0] + M[2][1] * s.p[1] + M[2][2] * s.p[2];
        const nx = M[0][0] * s.n[0] + M[0][1] * s.n[1] + M[0][2] * s.n[2];
        const ny = M[1][0] * s.n[0] + M[1][1] * s.n[1] + M[1][2] * s.n[2];
        const nz = M[2][0] * s.n[0] + M[2][1] * s.n[1] + M[2][2] * s.n[2];
        const vx = -wx, vy = -wy, vz = F - wz, vl = Math.hypot(vx, vy, vz);
        const f = (nx * vx + ny * vy + nz * vz) / vl;
        if (f < 0.08) return;
        const k = F / (F - wz), sx = scx + wx * k * ssc, sy = scy - wy * k * ssc, r = s.r * k * ssc;
        const al = ss(0.55, 1, light) * ss(0.08, 0.3, f);
        if (al <= 0.001) return;
        ctx.save();
        ctx.globalAlpha = al;
        ctx.translate(sx, sy);
        if (s.kind === "led" && led > 0.001) {
          const gl = ctx.createRadialGradient(0, 0, 0, 0, 0, r * 5);
          gl.addColorStop(0, "rgba(31,201,138," + (0.42 * led).toFixed(3) + ")");
          gl.addColorStop(1, "rgba(31,201,138,0)");
          ctx.fillStyle = gl;
          ctx.beginPath(); ctx.arc(0, 0, r * 5, 0, Math.PI * 2); ctx.fill();
        }
        ctx.rotate(Math.atan2(-ny, nx));
        ctx.scale(Math.max(f, 0.12), 1);
        if (s.kind === "led") {
          ctx.fillStyle = "rgba(60,66,76,0.55)";
          ctx.beginPath(); ctx.arc(0, 0, r + 2.4, 0, Math.PI * 2); ctx.fill();
          ctx.fillStyle = rgb(mixf(176, 52, led), mixf(182, 226, led), mixf(190, 152, led));
          ctx.beginPath(); ctx.arc(0, 0, r, 0, Math.PI * 2); ctx.fill();
        } else if (s.kind === "grille") {
          const gr = ctx.createRadialGradient(0, 0, 0, 0, 0, r);
          gr.addColorStop(0, "rgb(146,152,160)"); gr.addColorStop(1, "rgb(116,122,131)");
          ctx.fillStyle = gr;
          ctx.beginPath(); ctx.arc(0, 0, r, 0, Math.PI * 2); ctx.fill();
          ctx.strokeStyle = "rgba(96,102,112,0.55)"; ctx.lineWidth = 1.4;
          ctx.beginPath(); ctx.arc(0, 0, r * 0.62, 0, Math.PI * 2); ctx.stroke();
          ctx.beginPath(); ctx.arc(0, 0, r * 0.28, 0, Math.PI * 2); ctx.stroke();
          ctx.strokeStyle = "rgba(235,238,243,0.95)"; ctx.lineWidth = 2;
          ctx.beginPath(); ctx.arc(0, 0, r + 1, 0, Math.PI * 2); ctx.stroke();
        } else {
          const gr = ctx.createRadialGradient(0, 0, 0, 0, 0, r);
          gr.addColorStop(0, "rgb(236,238,242)"); gr.addColorStop(1, "rgb(200,204,212)");
          ctx.fillStyle = gr;
          ctx.beginPath(); ctx.arc(0, 0, r, 0, Math.PI * 2); ctx.fill();
          ctx.strokeStyle = "rgba(140,148,162,0.75)"; ctx.lineWidth = 2;
          ctx.beginPath(); ctx.arc(0, 0, r, 0, Math.PI * 2); ctx.stroke();
        }
        ctx.restore();
      }

      function render(t) {
        const light = eP2(seg(t, 0.4, 2.7));
        const turnP = eSine(seg(t, 1.9, 6.0));
        const yaw = (8 + 386 * turnP) * DEG;
        const pitch = (mixf(10, 15, turnP) + 6 * eP2(seg(t, 5.9, 7.0))) * DEG;
        const lid = 46 * DEG * eOut3(seg(t, 6.0, 7.1));
        const led = ss(6.05, 6.55, t);
        const slide = eP3(seg(t, 6.9, 7.9));
        const scx = mixf(960, 700, slide), ssc = mixf(1, 0.9, slide), scy = 520;
        const open = lid > 0.003;

        ctx.clearRect(0, 0, 1920, 1080);

        /* floor shadow */
        const Lsh = ss(0.1, 0.85, light);
        if (Lsh > 0.001) {
          const cy_ = Math.abs(Math.cos(yaw)), sy_ = Math.abs(Math.sin(yaw));
          const half = 0.88 * (A * cy_ + C * sy_), depth = 0.88 * (A * sy_ + C * cy_);
          const fz = -B * Math.sin(pitch), k = F / (F - fz);
          const fx = scx + 0.05 * half * ssc, fy = scy + B * Math.cos(pitch) * k * ssc;
          const rx = half * k * ssc, ry = Math.max(depth * Math.sin(pitch) * k * ssc, 16 * ssc);
          blob(fx, fy + 4 * ssc, rx * 1.22, ry * 1.7 + 12, 0.17 * Lsh);
          blob(fx, fy, rx * 0.92, ry * 1.05 + 6, 0.3 * Lsh);
        }

        /* matrices */
        const c = Math.cos(yaw), s = Math.sin(yaw), cp = Math.cos(pitch), spn = Math.sin(pitch);
        const M = [[c, 0, s], [spn * s, cp, -spn * c], [-cp * s, spn, cp * c]];
        const co = Math.cos(lid), si = Math.sin(lid);
        const Rl = [[1, 0, 0], [0, co, si], [0, -si, co]];
        const ML = [[0, 0, 0], [0, 0, 0], [0, 0, 0]];
        for (let i = 0; i < 3; i++) for (let j = 0; j < 3; j++) ML[i][j] = M[i][0] * Rl[0][j] + M[i][1] * Rl[1][j] + M[i][2] * Rl[2][j];
        const pv = [0, YS, HZ];
        const rp = [Rl[0][0] * pv[0] + Rl[0][1] * pv[1] + Rl[0][2] * pv[2], Rl[1][0] * pv[0] + Rl[1][1] * pv[1] + Rl[1][2] * pv[2], Rl[2][0] * pv[0] + Rl[2][1] * pv[1] + Rl[2][2] * pv[2]];
        const dv = [pv[0] - rp[0], pv[1] - rp[1], pv[2] - rp[2]];
        const TL = [M[0][0] * dv[0] + M[0][1] * dv[1] + M[0][2] * dv[2], M[1][0] * dv[0] + M[1][1] * dv[1] + M[1][2] * dv[2], M[2][0] * dv[0] + M[2][1] * dv[1] + M[2][2] * dv[2]];

        const bx0 = scx - 360 * ssc, bw = 720 * ssc, by0 = scy - 300 * ssc, bh = 600 * ssc;
        /* transform + project + shade every vertex */
        for (let pi = 0; pi < parts.length; pi++) {
          const p = parts[pi];
          if (p.onlyOpen && !open) continue;
          const m = p.lid ? ML : M, tr = p.lid ? TL : [0, 0, 0];
          const n = p.nr * p.nu, P = p.P, N = p.N, base = p.base;
          for (let k = 0; k < n; k++) {
            const x = P[3 * k], y = P[3 * k + 1], z = P[3 * k + 2];
            const wx = m[0][0] * x + m[0][1] * y + m[0][2] * z + tr[0];
            const wy = m[1][0] * x + m[1][1] * y + m[1][2] * z + tr[1];
            const wz = m[2][0] * x + m[2][1] * y + m[2][2] * z + tr[2];
            const q = base + k, kf = F / (F - wz);
            WX[q] = wx; WY[q] = wy; WZ[q] = wz;
            SX[q] = scx + wx * kf * ssc; SY[q] = scy - wy * kf * ssc;
            const nx = N[3 * k], ny = N[3 * k + 1], nz = N[3 * k + 2];
            NX[q] = m[0][0] * nx + m[0][1] * ny + m[0][2] * nz;
            NY[q] = m[1][0] * nx + m[1][1] * ny + m[1][2] * nz;
            NZ[q] = m[2][0] * nx + m[2][1] * ny + m[2][2] * nz;
            /* the light sweep is a smooth screen-space overlay (below), so every cell is shaded fully lit */
            const Lv = 1;
            {
              const vl2 = Math.hypot(NX[q], NY[q], NZ[q]) || 1;
              shade(NX[q] / vl2, NY[q] / vl2, NZ[q] / vl2, p.mat, 0, Lv, col);
              VR[q] = col[0]; VG[q] = col[1]; VB[q] = col[2];
            }
          }
        }

        /* shade visible cells */
        let cnt = 0;
        for (let pi = 0; pi < parts.length; pi++) {
          const p = parts[pi];
          if (p.onlyOpen && !open) continue;
          const nr = p.nr, nu = p.nu, base = p.base, P = p.P, G = p.G;
          for (let i = 0; i < nr - 1; i++) {
            for (let j = 0; j < nu; j++) {
              const j1 = (j + 1) % nu;
              const a = base + i * nu + j, b = base + i * nu + j1, cc = base + (i + 1) * nu + j1, d = base + (i + 1) * nu + j;
              let nx = NX[a] + NX[b] + NX[cc] + NX[d], ny = NY[a] + NY[b] + NY[cc] + NY[d], nz = NZ[a] + NZ[b] + NZ[cc] + NZ[d];
              const nl = Math.hypot(nx, ny, nz);
              if (nl < 1e-6) continue;
              nx /= nl; ny /= nl; nz /= nl;
              const gx = (WX[a] + WX[b] + WX[cc] + WX[d]) * 0.25, gy = (WY[a] + WY[b] + WY[cc] + WY[d]) * 0.25, gz = (WZ[a] + WZ[b] + WZ[cc] + WZ[d]) * 0.25;
              const vx = -gx, vy = -gy, vz = F - gz, vl = Math.hypot(vx, vy, vz);
              const fc = (nx * vx + ny * vy + nz * vz) / vl;
              let kind = 0;
              if (fc > 0) {
                const gk = 1 - 0.5 * G[i * nu + j];
                col[0] = (VR[a] + VR[b] + VR[cc] + VR[d]) * 0.25 * gk; col[1] = (VG[a] + VG[b] + VG[cc] + VG[d]) * 0.25 * gk; col[2] = (VB[a] + VB[b] + VB[cc] + VB[d]) * 0.25 * gk;
                ICOL1[cnt] = rgb((VR[a] + VR[d]) * 0.5 * gk, (VG[a] + VG[d]) * 0.5 * gk, (VB[a] + VB[d]) * 0.5 * gk);
                ICOL2[cnt] = rgb((VR[b] + VR[cc]) * 0.5 * gk, (VG[b] + VG[cc]) * 0.5 * gk, (VB[b] + VB[cc]) * 0.5 * gk);
                kind = 1;
              } else if (p.interior && open) {
                const yo = (P[3 * (i * nu + j) + 1] + P[3 * ((i + 1) * nu + j1) + 1]) * 0.5;
                const tt = p.lid ? ss(B, YS, yo) : ss(-B * 0.85, YS, yo);
                col[0] = mixf(p.inLo[0], p.inHi[0], tt); col[1] = mixf(p.inLo[1], p.inHi[1], tt); col[2] = mixf(p.inLo[2], p.inHi[2], tt);
              } else continue;
              IKIND[cnt] = kind;
              ICOL[cnt] = rgb(col[0], col[1], col[2]);
              IA[cnt] = a; IB[cnt] = b; IC[cnt] = cc; ID[cnt] = d; KEY[cnt] = gz;
              cnt++;
            }
          }
        }
        for (let k = 0; k < cnt; k++) ORD[k] = k;
        const ord = ORD.subarray(0, cnt);
        ord.sort((p, q) => KEY[p] - KEY[q]);
        octx.clearRect(0, 0, 1920, 1080);
        octx.lineWidth = 1.6;
        octx.lineJoin = "round";
        for (let k = 0; k < cnt; k++) {
          const id = ord[k], ia = IA[id], ib = IB[id], ic = IC[id], idd = ID[id];
          let st = ICOL[id];
          if (IKIND[id]) {
            const x0 = (SX[ia] + SX[idd]) * 0.5, y0 = (SY[ia] + SY[idd]) * 0.5, x1 = (SX[ib] + SX[ic]) * 0.5, y1 = (SY[ib] + SY[ic]) * 0.5;
            if (Math.abs(x1 - x0) + Math.abs(y1 - y0) > 0.5) {
              const gr = octx.createLinearGradient(x0, y0, x1, y1);
              gr.addColorStop(0, ICOL1[id]); gr.addColorStop(1, ICOL2[id]);
              st = gr;
            }
          }
          octx.fillStyle = st; octx.strokeStyle = st;
          octx.beginPath();
          octx.moveTo(SX[ia], SY[ia]);
          octx.lineTo(SX[ib], SY[ib]);
          octx.lineTo(SX[ic], SY[ic]);
          octx.lineTo(SX[idd], SY[idd]);
          octx.closePath();
          octx.fill();
          octx.stroke();
        }

        /* light sweep: darken the lit object toward the silhouette colour with a smooth gradient (no per-cell steps) */
        if (light < 1) {
          const gx = 0.7 / bw, gy = 0.3 / bh, g2 = gx * gx + gy * gy;
          const dA = light * 1.5 - 0.5, dB = light * 1.5;
          const gr = octx.createLinearGradient(bx0 + gx * dA / g2, by0 + gy * dA / g2, bx0 + gx * dB / g2, by0 + gy * dB / g2);
          for (let k = 0; k <= 16; k++) { const w = k / 16; gr.addColorStop(w, `rgba(${BLACK[0]},${BLACK[1]},${BLACK[2]},${(w * w * (3 - 2 * w)).toFixed(4)})`); }
          octx.globalCompositeOperation = "source-atop";
          octx.fillStyle = gr; octx.fillRect(0, 0, 1920, 1080);
          octx.globalCompositeOperation = "source-over";
        }
        ctx.drawImage(ocv, 0, 0);

        /* small features: status light, pairing button, speaker grilles */
        for (let i = 0; i < sprites.length; i++) {
          const sp_ = sprites[i];
          if (sp_.onlyOpen && !open) continue;
          drawSprite(sp_, M, scx, scy, ssc, light, led);
        }
      }

      /* ---------- timeline ---------- */
      window.__timelines = window.__timelines || {};
      const tl = gsap.timeline({ paused: true });
      tl.to({ v: 0 }, { v: 1, duration: DUR, ease: "none", onUpdate: () => render(tl.time()) }, 0);

      /* lockup, beside the product once it has slid left */
      tl.set("#mark", { y: 20 }, 0);
      tl.set("#wm", { y: 26 }, 0);
      tl.set("#tg", { y: 18 }, 0);
      tl.to("#mark", { opacity: 1, y: 0, duration: 0.8, ease: "expo.out" }, 7.5);
      tl.to("#wm", { opacity: 1, y: 0, duration: 0.9, ease: "expo.out" }, 7.6);
      tl.to("#tg", { opacity: 1, y: 0, duration: 0.8, ease: "expo.out" }, 7.8);

      tl.set({}, {}, DUR);
      window.__timelines["main"] = tl;
      render(0);
    </script>
  </body>
</html>
```
