Skip to content

A toolbox of film styles made in code for Claude Code: 66 ready to use, and your own. Each style is a style prompt plus a demo film made entirely in code by Claude Opus 5.5, with no video model. By Lemomo. · 一套用代码做片的风格工具箱:66 种现成风格,也能做出你自己的

Desktop Flythrough: app cards on a sunlit desk and one camera flying after what moves between them, with narration and bilingual subtitles

lemomo-ai9d9d24b8c461
diff --git a/styles/desktop-flythrough/DEMO.md b/styles/desktop-flythrough/DEMO.md
new file mode 100644
index 0000000..5f5bdff
--- /dev/null
+++ b/styles/desktop-flythrough/DEMO.md
@@ -0,0 +1,72 @@
+# Desktop Flythrough 桌面穿梭 — our demo
+
+One example among many. Don't reuse its story, arc, shots, props or timings.
+
+Demo: *叮之前 · Before the Ding* (59.95 s) · `desktop-flythrough.mp4` · source in [`demo/`](demo/)
+
+## Story & structure
+
+You send a friend a cat photo and their phone dings at once, but the photo did not fly straight there. The film follows it: step 1, the app shrinks it (4.2 MB → 300 KB, an illustrative figure); stop 2, it waits on the chat app's server; step 3, the server sends a notification; then the friend's phone fetches the photo, and on a slow connection it shows up blurry before it turns sharp. The ending: unless you ticked "Original", your friend has a compressed copy; the original never left your phone.
+
+Four stops on one desk: your phone, the compress card, the server tower, your friend's phone (小林, fictional), joined by a cobalt dotted route. The hero is the cat photo itself, a 16×16 voxel toy that blinks, waits on the beat, gets squashed into its 8×8 copy and hops the whole route. The opening and closing titles are objects on the desk. Every claim and its source is in [`demo/FACTS.md`](demo/FACTS.md); no app or company is named.
+
+## Shots
+
+| # | Time | Shot | Camera | Native move |
+|---|---|---|---|---|
+| 1 | 0–4.6 | your phone (full chat interface, the photo attached) and the title tent 叮之前 / BEFORE THE DING; 1.0 the cat pops; 2.0 send; 2.25 the friend's phone dings, banner and photo appear at once | low three-quarter on the phone and tent; a whip that arcs up over the desk to the friend's phone | sticker pop |
+| 2 | 4.6–7.6 | that instant rewinds; a grey straight line between the phones is crossed out; the cobalt route draws through the compress card and the server | rise to a wide view, the four objects filling the frame | UI rises |
+| 3 | 7.6–10.6 | the cat leaps to the compress card; badge 1 压小 | the whip rides the leap | card hop |
+| 4 | 10.6–17.2 | 10.5 the press drops (the cat squints); 28 pixel cubes burst out and roll away; the 8×8 copy pops out in the dashed box and bounces; the counter runs 4.2 MB → 300 KB; ≈ between original and copy | near top-down on the card, held | press |
+| 5 | 17.2–20.3 | three hops along the route to the server tower; badge 2 服务器 | ride along, settle on the tower | card hop |
+| 6 | 20.3–26.0 | 云端中转站: the cat waits bouncing on the roof; yellow data cubes hop into the windows; the drawer slides out, the cat hops in, it closes, one window lights cobalt; the antenna blinks on the beat | half an orbit round the tower | drawer |
+| 7–8 | 26.0–32.1 | badge 3 通知; the bell rises, flies to the friend's phone leaving a dotted trail, taps twice; the banner 你 · 新照片 drops | tilt up, follow the flight, settle on the phone | messenger |
+| 9 | 32.1–34.6 | the ring: the bell swings, the phone jolts, vibration marks either side, a cobalt ring spreads | phone close | slam and ring |
+| 10 | 34.6–39.6 | after the notification the phone goes to the server: the route lights back, yellow data cubes run along it, a loading spinner, the drawer opens, the cat hops home | pull out to both, then ride the hops | data run |
+| 11 | 39.6–44.8 | 网慢: one red signal bar; the bubble shows a blurry preview; 43.1 the cat drops into the bubble and it snaps sharp | near top-down on the screen, held | blurry, then sharp |
+| 12 | 44.8–48.4 | the whole relay; the route glows in a wave | pull back to a top view | desk pull-back |
+| 13 | 48.4–52.6 | unless you ticked "Original": the friend's chunky copy, tag 300 KB | push in | |
+| 14 | 52.6–55.4 | your album: the fine original, tag 4.2 MB | whip back, arcing up over the desk | |
+| 15 | 55.4–59.95 | the closing shot: rise and pull back until all four stops and the route are in frame; the route glows; each stop hops once, left to right; the two cats pop up and bow; 56.25 the title card 叮之前 / BEFORE THE DING drops into the middle of the desk and bounces (the small tent folds away); 57.0 the sign-off | long pull-back, slow orbit | curtain call |
+
+## Voice-over
+
+Fourteen lines, Chinese, voiced with edge-tts `zh-CN-XiaoxiaoNeural` at `+15 %` (line 5 at `+8 %`), checked line by line with Whisper; 0.8 s lead, 0.3–0.6 s between lines. Subtitles: one cue per line, Chinese over English ([`desktop-flythrough.srt`](desktop-flythrough.srt)).
+
+| # | Start | 中文 | English |
+|---|---|---|---|
+| 1 | 0.8 | 你给朋友发了张猫,叮的一声,对面马上就收到了。 | You send a friend a cat photo. Ding, it arrives right away. |
+| 2 | 4.8 | 可这张照片,并没有直接飞过去。 | But the photo didn't fly straight there. |
+| 3 | 7.8 | 按下发送的那一刻,第一步,是压小。 | The moment you hit send, step one: make it smaller. |
+| 4 | 10.9 | 原图太大、传得太慢,软件会先把它悄悄压缩,体积小了,看着却差不多。 | The original is too big and slow to send, so the app quietly compresses it: smaller, yet it looks about the same. |
+| 5 | 17.5 | 接着,照片来到第二站,服务器。 | Next, the photo reaches stop two: the server. |
+| 6 | 20.6 | 也就是聊天软件的云端中转站,照片先存放在这儿,等着对面来取。 | That's the chat app's relay station in the cloud. The photo waits here to be picked up. |
+| 7 | 26.2 | 第三步,才轮到发通知。 | Only then comes step three: the notification. |
+| 8 | 28.4 | 服务器拍了拍朋友的手机,嘿,有张照片找你。 | The server taps your friend's phone: "Hey, a photo for you." |
+| 9 | 32.3 | 这时候,手机才响了一声。 | That's when the phone goes ding. |
+| 10 | 34.9 | 收到通知后,朋友的手机才真正去服务器,把照片取回来。 | After the notification, your friend's phone goes to the server and fetches the photo. |
+| 11 | 39.6 | 所以网慢的时候,你会看到它先糊一下,再瞬间变清楚。 | So on a slow connection, you see it blurry for a moment, then suddenly sharp. |
+| 12 | 44.8 | 一声叮的背后,其实是一场无声的接力。 | Behind that one ding is a silent relay. |
+| 13 | 48.1 | 如果你没勾原图,朋友收到的,只是那只猫的压缩版。 | Unless you ticked "Original", what your friend gets is just a compressed copy of the cat. |
+| 14 | 52.3 | 而真正的原图,一直都在你的手机里。 | The real original has been on your phone all along. |
+
+**English version** (`sh demo/build.sh en` → `desktop-flythrough-en.mp4`): the English lines are voiced with `en-US-AvaNeural` at `+10 %` and start on the same seconds as the Chinese ones; lines 3, 4 and 7 at `+15 %`, line 5 at `+13 %`, line 13 at `+25 %`; line 7 is spoken as "Step three: the notification." to fit before line 8 (the subtitle keeps the full sentence); lines 1, 8, 9 and 11 carry spoken punctuation only. Picture, subtitles and length do not change.
+
+## Score structure
+
+120 BPM, D major, a bar = 2 s from 0.0, one chord per bar. Under the voice: string pad, contrabass pizzicato on 1 and 3, a soft synthetic kick, shaker in eighths, a two-note marimba figure from the chord; the music ducks 16 dB while someone speaks and comes back up in the gaps. The marimba head (F♯–A B–D'–C♯') opens the film and returns, with claps, under the pull-back and the closing shot, resolving on a held D chord with horns and vibraphone; four glockenspiel notes on the four curtain-call hops. Accents: glockenspiel on the cat's pop, the badges, the ring and the sharp photo; timpani on the press and the close; a thump and two bell notes as the title lands. Foley comes from the page's events (pitched from `music/harmony.json`); whooshes from the measured camera speed. Mix before the master: −16.0 LUFS, true peak −3.1 dBFS.
+
+## Palette & props
+
+Paper mat #e2e8f5 with dots #c4cde3 on light oak; cards and screens near-white, ink #171c2e, accent cobalt #2f5bff (route, badges, send button, the lit window, the drawer), mustard for the bell and the data cubes, the photo's own orange, blue and green, red only for the weak signal bar. Set: two phone cards with full chat interfaces, the compress card with its press, a four-slab server tower with a drawer and an antenna, a title tent, name plates (in the wide shots), the closing title card; props: a pen, a sticky-note pad, a mug of coffee, earbuds with their cable, an eraser.
+
+## End card
+
+Over the closing wide view, under the title card in the middle of the desk, from 57.0 s: LemoLab × Claude Opus 5.5 in a light plate at the subtitle position, to the end, over the held final chord. The "LemoLab × Claude Opus 5.5" sign-off belongs to this library's demo only; a user's film carries no LemoLab credit and no copy of this card.
+
+## Build notes
+
+- `sh styles/desktop-flythrough/demo/build.sh` (Chinese voice, the library demo) or `… build.sh en` (English voice): fonts (downloaded from Google Fonts and subset) → voice (`core/tts/tts_zh.py`, checked with `core/tts/asr_check.py`) → `audio/vo_timeline.py` (writes `src/vo.js` and `vo/timeline.json`) → events and camera speed → `audio/compose.py` → `audio/foley.py` → `audio/mix.py` → `core/render/video.mjs` → `core/render/mux.sh` → `readcheck.mjs` → poster and style frame. The voice step needs the internet (edge-tts).
+- Code: `index.html` → `src/main.js` (page contract, speed-capped shutter, `TEXTS`) → `src/film.js` (cards, tower, props, cast, timeline cued to the voice, sound events, reading boxes) and `src/shots.js` (camera keys); `src/captions.js` (subtitles, sign-off, `?nosub=1` for clean stills).
+- Reading time: `TEXTS` reports the title tent, the two sizes on the compress card, the server's name, the banner, 网慢, the two size tags, the closing title and the sign-off; subtitle cues follow the voice.
+- Pitfalls of these props: name plates show only in the wide shots; badges stay 3.4 s and leave before the camera moves on; the cat waits beside the photo bubble, not under the subtitle bar; the eraser sits clear of the closing title card.
diff --git a/styles/desktop-flythrough/STYLE.md b/styles/desktop-flythrough/STYLE.md
new file mode 100644
index 0000000..4d1cb5f
--- /dev/null
+++ b/styles/desktop-flythrough/STYLE.md
@@ -0,0 +1,132 @@
+# Desktop Flythrough 桌面穿梭 — Style Prompt
+
+> App screens and tools lie on a sunlit desk as printed paper cards; small pixel characters, popped up into voxel toys, carry the work from card to card, while one unbroken camera flies after them, whips between stops and finally pulls back over the whole desk.
+> References (grammar only): one-take desktop tours in software launch films (windows laid flat as places, a small helper as the guide); macro toy photography (low warm sun, long soft shadows); pixel-art sprites (the cast's look). Never copy their characters, layouts, icons or music.
+
+## 1. Essence, and what it is not
+
+- **The desk is the world.** A matte paper mat with a regular dot grid lies on a light wooden desk, lit by one low warm sun through a window. Everything sits on it and casts a long, soft shadow. A few everyday desk things (a pen, sticky notes, a mug, earbuds) sit around the edges as foreground and background layers.
+- **Interfaces are paper cards.** Phones, tools and dashboards are rounded slabs a few millimetres thick with the interface printed on top. They are places: characters stand and hop on them, and parts of the interface rise out of them as small 3D objects.
+- **The cast are pixel sprites made solid.** One bevelled cube per pixel, thicker inside than at the edge, eyes standing proud. They lie on a card as flat stickers and pop up into toys; they blink, wait on the beat, get squashed and spring back.
+- **Every stop is busy.** At each station something small moves besides the main action: debris bursts, data cubes hop, a lamp blinks, marks vibrate.
+- **One take.** No cuts. The camera glides, orbits, cranes and whips between stops; it closes on the whole desk.
+- **Everything lands on the beat.** Hops, pops, ticks and slams sit on the 16th-note grid of one steady tempo, and every action has a sound.
+
+Not a screen recording (no cursor, no glowing monitor, no real app chrome or logos); not a brick or clay toy film (pixel voxels on printed paper); not an isometric infographic (perspective camera, real light); not flat motion graphics (everything has thickness and a shadow).
+
+## 2. Materials & rendering
+
+- three.js, physically based, neutral tone mapping. Scale: a card is 0.3–0.7 units wide (1000 canvas px per unit); a character is 1/6–1/10 of a card's width; dots 0.03 apart.
+- **Light**: one directional sun low from the back-left (about 20° up, so a toy's shadow is two or three times its height), a 4096 soft shadow map that follows the camera target and resizes with distance; a cool-sky / warm-ground hemisphere fill, so shadows read blue and lit faces warm; a faint room environment for highlights; exponential fog thinned as the camera pulls back.
+- **Desk**: a dotted paper mat (a thin rounded slab whose size is a multiple of two dot spacings, so the printed dots line up with any 3D dots) on a procedural light-oak plane (planks, long soft grain). Soft window-light patches (blurred four-pane shapes, warm, additive, low opacity) lie under the cards. Props are plain primitives in matte or satin materials, placed so each close shot has something soft in front of or behind its subject.
+- **Cards and screens**: a rounded slab plus a canvas texture on top with a faint deterministic grain. Print is flat: one ink, mono labels in spaced caps, bold numerals, thin rules; a card head carries two lines (English mono caps over the other language in bold). A phone is a card with a dark bezel and a whole interface: status bar, a header with a name, a few message bubbles, an input field and a send button. Redraw a canvas only when its state changes; quantise continuous changes.
+- **Voxel cast**: instanced bevelled cubes per pixel; depth grows with distance from the silhouette; pure-black pixels are eyes, which protrude and blink (they take the colour of the pixel above). Rig: root (feet, yaw) → hinge (lying flat ↔ standing) → squash (scaled at the feet) → spin. State: `e` (0 flat sticker … 1 full toy), `hinge`, `sq`. The same picture at half resolution is the same character, smaller and chunkier.
+- **Props**: the same voxel recipe (crosses, ticks, bells) or plain rounded primitives (bricks, presses, drawers, towers, tent cards, stamps). Data that rises out of a card is extruded from its printed shape, so it still reads from above.
+- **Impact ring**: a thin accent-coloured ring spreads over the paper from an impact and fades in about a second.
+- **Post, per frame**: 16–24 sub-frames with Halton sub-pixel jitter (anti-aliasing, and a little motion blur on fast moves) → depth of field on each sub-frame, behind the focus plane only → bloom on highlights only → grade (light vignette, slight warmth, a little contrast and saturation). Subtitles are DOM on top.
+
+## 3. Colour logic
+
+- **One light ground** (the mat) with a slightly darker dot, cool-tinted so the warm sun leaves it fresh; a warm wooden desk around it; cards in a near-white of the same temperature; **one dark ink** for print; **one accent reserved for what matters now**: the route, the current step's badge, the send button, the lit window, the key word.
+- Two or three support hues for the cast and props, mid-saturated, never neon; one warm cast colour against the cool ground. **Red only for failure or trouble** (an error, a weak signal), **green only for success**; data in motion may take one bright support hue so it reads apart from the route.
+- Judge the rendered frame: avoid grey on grey; keep the vignette light and the shadows tinted by the sky fill.
+- Brand use: the brand colour becomes the accent; the brand's interface colours print on the cards; the ground stays light.
+
+## 4. Type & subtitles
+
+- **In the world, only keywords and numbers**: step badges (a camera-facing accent pill with a digit and one word), sizes, a name on a screen, a banner, a title card. Text meant to be read is framed above the subtitle area, held still for its reading time, and large enough at the angle it is seen: flat print reads from 55–70° down; a low camera reads a standing tent card.
+- **Titles are objects on the desk**: an opening tent card beside the first stop; at the end a large paper card dropped into the empty middle of the desk.
+- Every face on screen comes from the film's own font files (cards, pills, subtitles); the mono stack falls back to the film's CJK face, never to a system face.
+
+### Voice-over and subtitles
+
+- When the film explains something, a voice tells it: short spoken lines, one idea each; the picture shows what the voice is saying at that moment, and the words on cards are only the keywords of the line.
+- **One subtitle cue per spoken line**, in a quiet bar at the bottom centre (a rounded ink box at about 72 % opacity, about 64 px above the frame edge): the spoken language on the first line (bold, about 40 px), a whole-sentence translation on the second (about 26 px). One language per line, never wrapped. The cue appears with the line and leaves with it.
+- The camera keeps its subject about 110 px above centre (a fixed vertical view offset), so nothing that matters sits under the bar.
+- A version voiced in another language starts each line on the same second, so picture, subtitles and timing do not change.
+
+## 5. Motion quality
+
+- 30 fps. One steady tempo (110–130 BPM); every action on the 16th grid, big moments on downbeats.
+- **Hops**: an arc with squash and stretch (stretch about 14 % in the air, squash about 30 % for 0.2 s on landing, a small anticipation squash before take-off). Groups move follow-the-leader, each a 16th behind the one ahead, so they never close up.
+- **Characters act**: they blink every couple of seconds, bounce on the beat while they wait, squint when they are squashed, lean towards what they look at.
+- **Pop**: sticker → toy in 0.25–0.5 s (hinge up with overshoot, cells extrude from the centre, a small jump, squash on landing). **Reverse pop**: toy → sticker or print when it is stored, delivered or taped down.
+- **Slam**: drops from above with ease-in, lands on a downbeat, squashes, jolts the card, sends out a ring.
+- **UI comes alive in sequence**: digits, bars, ticks, typed characters appear on 16ths with an overshooting ease.
+- Idle is a small bounce or a blink, never a dead hold of more than about 1.5 s. Paper and cards never move except for a jolt or a curtain-call hop.
+
+## 6. Camera grammar
+
+| Move | What it expresses | Can serve |
+|---|---|---|
+| Macro glide with a slow orbit (close, 20–45° down) | being there, small scale | a character at work; one detail of an interface; a title standing on the desk |
+| Whip from card to card (0.3–0.5 s, banking into the turn) | the next step, cause → effect | a process moving on; a hand-off between tools |
+| Rise to near top-down (55–70° down) | reading, one card as a whole | a screen, a counter, a table; any verdict |
+| Ride along, low behind the subject | travel, momentum, pursuit | a route; a delivery; a download |
+| Pull back over the desk | the whole system, scale | a recap; the route so far; many stations at once |
+| Hold with a shake | impact | a press, a stamp, a ring |
+
+- One take, no cuts, no dissolves. Targets are live subjects; between keys the target follows a Hermite path with live end points; drift is a breath, not a handheld wobble.
+- At a key where a whip starts, the target rests first (or the camera stutters). A character's take-off is the natural start of a whip. A whip between far-apart stops arcs up mid-way so the stops in between stay in frame.
+- Wide shots frame the stations to fill at least 70 % of the frame width. **The film closes on the whole desk**: every stop and the route in one frame, everything moving once, the title landing in the middle.
+
+## 7. Sound palette
+
+- **Score**: bright and warm, acoustic in feel: marimba (with vibraphone under long notes), plucked bass, a soft synthetic kick (a short sine sweep), claps, shaker, a quiet string pad. One key, diatonic chords, about one chord per bar. Under a voice the score is a light bed ducked about 16 dB while someone speaks; the full mallet theme plays where nobody speaks.
+- **Foley**: every action has a sound. Pop: a marimba note from the current chord plus an upward sweep. Hop: a soft tick. Landing: a felt thump. Press or stamp: a low thump with a crumble. Typing: dry key clicks. Ding: two bell notes from the chord. Camera whip: a whoosh sized by the measured camera speed. Pitched foley takes its notes from the score's chord table and sits on the 16th grid.
+- **Mix**: the voice leads (about −16 LUFS before delivery, −14 after); music 15–18 dB under the voice and lifted in the gaps; foley under the voice; true peak at or below −1.5 dBFS. The final chord holds to the last half-second.
+
+## 8. Native moves
+
+- **Sticker pop.** A flat pixel sticker on a card stands up and extrudes into a toy on a 16th. *Fits content like:* a new user, file or job appearing; a feature switched on; an order placed.
+- **Reverse pop.** A toy lies back down into a sticker or a print. *Fits content like:* a photo delivered into a chat; a snapshot saved; a task archived.
+- **Press.** A heavy plate drops on a toy; pixel debris bursts out and rolls away; the same character pops out at half resolution beside a counter that runs down. *Fits content like:* compression; a budget cut; a summary of a long report.
+- **Drawer.** A slab of a stacked tower slides open, a toy hops in, it closes and one window lights; small data cubes hop into the windows. *Fits content like:* storing something in the cloud; a queue; an archive.
+- **Messenger.** A small voxel object (a bell, an envelope) flies an arc between two cards leaving a dotted trail, taps the target twice, and a banner drops on its screen. *Fits content like:* a notification; a hand-off; an alert.
+- **Data run.** A stream of small bright cubes runs along the route between two stations. *Fits content like:* a download; a sync; a payment going through.
+- **Blurry, then sharp.** A picture on a screen card is printed blurred, then snaps sharp as the toy lands in it. *Fits content like:* loading; focus; a draft becoming final.
+- **UI rises.** Part of the printed interface grows into 3D out of its printed shape. *Fits content like:* progress; a metric climbing; a step badge.
+- **Curtain call.** The closing pull-back frames every stop; each hops once, left to right, the characters pop back up, and a title card drops into the middle. *Fits content like:* a recap; a team; a pipeline shown whole.
+
+## 9. Pitfalls of the medium
+
+- **Softness**: depth of field and motion blur easily turn a subject or its words to mush. Blur only what lies behind a focus plane set a little beyond the subject, lightly (≤ 5 px), never anything in front; let the shutter shrink with camera speed so a streak never exceeds about 8 px; draw card and screen canvases at 3–3.4× (pills at 3×) so print stays crisp when a card fills the frame; no CSS or canvas blur on anything meant to be read.
+- **Flat print read at a low angle**: text on a card seen from 20° is unreadable. Rise to 55–70° to read a card; put text the low camera must read on a standing object.
+- **A standing toy hides the row behind it**: place characters beside or behind the text being read, or off the card, and check every reading frame for overlap.
+- **Text under the subtitle bar or cut at the frame edge**: keep the fixed vertical offset; show name plates and labels only in the shots that frame them whole; take camera-facing pills away before the camera moves on.
+- **Screens that read as blank**: a phone card without a whole interface reads as an empty white slab in close-up.
+- **Whips over bare paper**: a fast move between far-apart cards crosses empty desk; arc it up so the stops in between pass through frame.
+- **Dead stations**: a stop where only the main action happens looks static; give it one or two small moving things that do not compete with what the voice says.
+- **Bars and ticks seen from above**: upright 3D bars and standing checkmarks turn into blobs in a top-down view; extrude them along the card or lay them flat.
+- **Interpenetration**: characters at the same depth overlap; followers move one 16th apart; a knocked-flat pile goes back to sticker thickness before it stacks; check props against card edges, gates and drawers.
+- **Ripples as pegs**: lifted 3D dots read as pegs from above; use a flat expanding ring.
+- **Slow renders**: canvas redraws on every sub-frame; redraw on state change only.
+- **A score made of fragments**: write whole phrases and put the accents on top.
+
+## 10. Engine
+
+In `demo/` (three.js r170 + Canvas 2D; page contract `render(t)`, `DUR`, `EV`, `TEXTS`):
+
+- `src/world.js`: renderer, sun, fog and the desk (`makeWorld({ mat: [w, h] })` lays a dotted mat on light oak); `card(world, canvas, w, h, thick)`, `dotPatch()`, `pill()` (camera-facing label), `rbox()`.
+- `src/cards.js`: palette, canvas helpers (`canvas`, `txt`, `tag`, `cardBase` with a two-line head, `grain`, `dotTile`, `tick`, `cross`).
+- `src/voxel.js`: `makeMonster(art, cell, name, depthK)` → `set({pos, yaw, e, hinge, sq, tiltX, tiltZ, scale, vis})`, `blink(on)`.
+- `src/anim.js`: `hops`, `squash`, `pop`, `beatBounce`, eases.
+- `src/camera.js`: `makeRig(ctx, camera, KEYS, SHAKES)`, the live-target rig with resting keys, banking, shakes and the vertical view offset; `src/shots.js` holds the demo's keys.
+- `src/post.js`: sub-frame accumulation, back-only depth of field, bloom, grade. `src/main.js`: the page, the speed-capped shutter and `TEXTS` (subtitle-free reading boxes projected from the world).
+- `src/captions.js`: subtitle cues from the voice clock (`src/vo.js`, written by `audio/vo_timeline.py`) and the sign-off; `?nosub=1` hides both for clean stills.
+- `src/film.js`: the demo's cards, tower, props, cast and timeline.
+- `audio/`: `vo_timeline.py` (lines on the clock), `compose.py` (score with the library sampler), `foley.py` (foley from events, pitched from the chord table, whooshes from `tools/camspeed.mjs`), `mix.py` (voice, ducked music, foley).
+
+Minimal start: a to-do card and a calendar card; a ticket sticker pops on beat 1, blinks, hops to the calendar on beat 3 while the camera whips after it, and drops into a day as a printed tag.
+
+## 11. Variation space
+
+The agent decides for each film: which apps or tools the cards are and how they lie on the desk, the cast (a mascot drawn as pixel art), the route, the props at each stop, the palette within §3, the tempo within §5, the language of the voice.
+
+- **Structures**: one item travels card to card and changes at each stop; the same job on two halves of the desk, slow against fast; one tiny detail that grows out to a desk of many cards.
+- **Openings**: a terminal types a command and its cursor becomes a character; the camera falls onto the desk and lands on beat 1; a title tent stands beside the first card while the hero pops up.
+- **Endings**: the curtain call over the whole desk; the cast reverse-pops into a saved record; the camera rises until the cards become part of the dot pattern.
+
+---
+
+How our demo was made (story, shots, voice, score, build): [DEMO.md](DEMO.md). Read it after your treatment exists.
diff --git a/styles/desktop-flythrough/demo/CREDITS b/styles/desktop-flythrough/demo/CREDITS
new file mode 100644
index 0000000..c30024e
--- /dev/null
+++ b/styles/desktop-flythrough/demo/CREDITS
@@ -0,0 +1,17 @@
+Desktop Flythrough 桌面穿梭 — demo film 叮之前 · Before the Ding
+
+Code: written for this film. src/post.js depth-of-field shaders are adapted from the Lemo-Opuscar library (core/three/post.js, MIT, LemoLab).
+The page contract, renderer, reading-time check, TTS and speech-check wrappers, sampler and procedural foley helpers come from the library's core/ (MIT).
+three.js (MIT), loaded from the library's node_modules.
+
+Fonts (SIL Open Font License 1.1; licence texts in fonts/; downloaded by build.sh from github.com/google/fonts):
+ Instrument Sans (fonts/InstrumentSans.ttf), IBM Plex Mono Medium and SemiBold, Noto Sans SC (subset to the characters on screen, fonts/NotoSansSC-sub.ttf).
+
+Voice-over: Microsoft neural text-to-speech via edge-tts, zh-CN-XiaoxiaoNeural (Chinese) and en-US-AvaNeural (English); an online service, check Microsoft's terms before commercial use.
+
+Music samples (CC0 1.0, no attribution required; acknowledged): VS Chamber Orchestra: Community Edition (Versilian Studios), Versilian Community Sample Library (Versilian Studios).
+ Instruments: marimba, vibraphone, glockenspiel, contrabass, contrabass pizz, cellos, cellos pizz, violas, violins pizz, horn, timpani, suspended cymbal, claps, shaker. Fetched with tools/fetch.sh.
+Kick drum and all foley: synthesised in code (audio/compose.py, audio/foley.py, core/audio/sfx.py).
+
+Pixel art (the cat photo and its compressed copy, the bell), phone interfaces, cards, the server tower, desk props, wood and paper textures: drawn in code. No photographs, no generated images.
+Facts and their sources: FACTS.md. Fictional: 小林, the chat, the photo; the sizes 4.2 MB and 300 KB are illustrative.
diff --git a/styles/desktop-flythrough/demo/FACTS.md b/styles/desktop-flythrough/demo/FACTS.md
new file mode 100644
index 0000000..507fa27
--- /dev/null
+++ b/styles/desktop-flythrough/demo/FACTS.md
@@ -0,0 +1,14 @@
+# FACTS — 叮之前 / Before the Ding
+
+What the voice-over says about how a chat photo travels, checked against public sources. The film names no app or company; the sources below are only where the facts come from. 小林, the cat photo and every screen on the desk are fiction.
+
+| # | Line (voice-over) | Claim | Source | Quoted wording | Verdict |
+|---|---|---|---|---|---|
+| 1 | 3–4「第一步,是压小……软件会先把它悄悄压缩,体积小了,看着却差不多」 | Chat apps compress photos before sending, by default | MacRumors, *WhatsApp Gets 'HD Photos' Option* (18 Aug 2023): https://www.macrumors.com/2023/08/18/whatsapp-hd-photos-send-high-res-images/ | "Tapping the HD button brings up a pop-up allowing users to switch from the default Standard Quality to HD Quality." / "Previously, WhatsApp users sending photos would see the images automatically compressed…" | holds (default quality; a user can choose a higher quality, which still compresses less) |
+| 2 | 5–6「来到第二站,服务器……云端中转站,照片先存放在这儿,等着对面来取」 | The photo is uploaded to the service's storage; the recipient's phone fetches it from there; messages can be sent while the recipient is offline | WhatsApp Encryption Overview (whitepaper, 2026-02), https://www.whatsapp.com/security/WhatsApp-Security-Whitepaper.pdf , section on attachments | "3. The sender uploads the encrypted attachment to a blob store." … "5. All receiving devices decrypt the message, retrieve the encrypted blob from the blob store" … "start sending messages to the recipient, even if the recipient is offline." | holds |
+| 3 | 7–9「第三步,才轮到发通知。服务器拍了拍朋友的手机……手机才响了一声」 | The app's server sends a message through the phone platform's push service, which delivers it to the app on the phone | Firebase Cloud Messaging overview: https://firebase.google.com/docs/cloud-messaging | "A trusted environment such as Cloud Functions for Firebase or an app server on which to build, target, and send messages." / "An Apple, Android, or web (JavaScript) client app that receives messages" "via the corresponding platform-specific transport service." | holds as a simplification: the server goes through the phone system's push channel, it does not reach the phone directly |
+| 4 | 10「收到通知后,朋友的手机才真正去服务器,把照片取回来」 | The recipient's phone fetches the attachment from the server after the message (notification) arrives | WhatsApp Encryption Overview (as 2); WhatsApp Help Center, *How to configure auto-download*: https://faq.whatsapp.com/en/iphone/28041114 | "5. All receiving devices decrypt the message, retrieve the encrypted blob from the blob store" | holds (with auto-download on, this happens as soon as the message arrives; with it off, when the photo is tapped) |
+| 5 | 11「所以网慢的时候,你会看到它先糊一下,再瞬间变清楚」 | A tiny low-resolution preview travels with the message and is shown while the full photo downloads | Telegram API, Files, stripped thumbnails: https://core.telegram.org/api/files | "A photoStrippedSize (with type i) is an extremely low-res thumbnail, embedded directly inside media location objects." "It should be shown to the user in chat message previews, or while still downloading the most appropriately sized photoSize" | holds (the preview is visible while the download is slow) |
+| 6 | 13–14「如果你没勾原图,朋友收到的,只是那只猫的压缩版……原图一直都在你的手机里」 | By default the recipient gets the compressed copy; apps let you choose to send the original or a higher quality; the original stays on the sender's phone | as 1 (the HD / quality option) and 2 | "Tapping the HD button brings up a pop-up allowing users to switch from the default Standard Quality to HD Quality." | holds |
+
+**Illustrative numbers.** The sizes on screen (原图 4.2 MB → 压缩后 300 KB) are an illustration, not a measurement of any app: a phone photo of a few megabytes and a compressed chat copy of a few hundred kilobytes are typical orders of magnitude, and the exact figures vary by phone, app and setting. The voice-over gives no number.
diff --git a/styles/desktop-flythrough/demo/audio/compose.py b/styles/desktop-flythrough/demo/audio/compose.py
new file mode 100644
index 0000000..aea7b78
--- /dev/null
+++ b/styles/desktop-flythrough/demo/audio/compose.py
@@ -0,0 +1,68 @@
+"""Score for 叮之前 / Before the Ding (Desktop Flythrough demo). about 60 s (read from vo/timeline.json), 120 BPM, D major, a bar = 2 s from 0.0.
+A light bed under the voice-over: plucked bass, soft kick, shaker, a string pad and a sparse marimba figure; the marimba theme is
+played in full only where nobody speaks (the opening second, the pull-back, the end). Accents on the picture's hits.
+Run from the library root: .venv/bin/python -I styles/desktop-flythrough/demo/audio/compose.py"""
+import sys, os, json
+HERE = os.path.dirname(os.path.abspath(__file__)); ROOT = os.path.abspath(os.path.join(HERE, '..')); LIB = os.path.abspath(os.path.join(ROOT, '../../..'))
+sys.path.insert(0, LIB)
+import numpy as np, soundfile as sf
+from core.audio import sampler as S
+from core.audio.sfx import SR, add, limit, t_, env_exp
+
+S.seed(11)
+TL = json.load(open(os.path.join(ROOT, 'vo/timeline.json'))); DUR = TL['dur']; FIN = round(TL['dur'] - 3.3, 2) # FIN: the last line is over, the closing shot begins
+BAR = 2.0; BEAT = .5
+CH = ['D', 'G', 'D', 'A', 'Bm', 'G', 'D', 'A', 'G', 'D', 'Em', 'A', 'Bm', 'G', 'A', 'D', 'G', 'A', 'Bm', 'G', 'Em', 'A', 'D', 'G', 'D', 'A', 'G', 'A', 'D', 'D']
+PAD = {'D': ['A3', 'D4', 'F#4'], 'G': ['G3', 'B3', 'D4'], 'A': ['A3', 'C#4', 'E4'], 'Bm': ['B3', 'D4', 'F#4'], 'Em': ['G3', 'B3', 'E4']}
+ROOT_ = {'D': 'D2', 'G': 'G2', 'A': 'A2', 'Bm': 'B2', 'Em': 'E2'}
+HEAD = [(0, 'F#5', 1), (1, 'A5', .5), (1.5, 'B5', .5), (2, 'D6', 1.5), (3.5, 'C#6', .5)]
+# the theme where nobody speaks; elsewhere a two-note marimba figure on beats 1 and 3 (chord tones, soft)
+MEL = {0: HEAD, 22: [(1, 'D6', 1), (2, 'A5', 1), (3, 'B5', 1)], 23: [(0, 'B5', 1), (1, 'D6', .5), (1.5, 'B5', .5), (2, 'G5', 2)],
+ 27: [(0, 'E6', 1), (1, 'C#6', .5), (1.5, 'A5', .5), (2, 'E6', 2)], 28: HEAD, 29: [(0, 'D6', 2.5)]}
+ev = []
+def E(t, inst, p, d, v, pan=0., **kw): ev.append(dict(t=t, inst=inst, pitch=p, dur=d, vel=v, pan=pan, **kw))
+for b, ch in enumerate(CH):
+ t0 = b * BAR
+ if t0 >= DUR: break
+ for i, p in enumerate(PAD[ch]): E(t0, 'violas' if i else 'cellos', p, BAR + .1, .24, [-.3, 0, .3][i], attack=.35, release=.6)
+ if b in MEL:
+ for (bt, n, d) in MEL[b]: E(t0 + bt * BEAT, 'marimba', n, max(.18, d * BEAT), .74, .05); (d >= 1.5) and E(t0 + bt * BEAT, 'vibraphone', n, d * BEAT, .3, -.1)
+ else:
+ tones = sorted(S.midi(p) + 12 for p in PAD[ch])
+ E(t0, 'marimba', S.name(tones[2]), .4, .42, .1); E(t0 + 2 * BEAT, 'marimba', S.name(tones[1]), .4, .36, .1)
+ rt = ROOT_[ch]
+ if b < 29:
+ E(t0, 'contrabass_pizz', rt, .45, .74, 0); E(t0 + 2 * BEAT, 'contrabass_pizz', rt, .4, .58, 0)
+ for k in range(8): E(t0 + k * BEAT / 2, 'shaker', 'down' if k % 2 == 0 else 'up', None, .18 + (.06 if k % 2 == 0 else 0), .35)
+ if 22 <= b < 29:
+ for k in (1, 3): E(t0 + k * BEAT, 'claps', 'solo', None, .36, -.2)
+def chordhit(t, ch, v=.5):
+ for p in PAD[ch]: E(t, 'violins_pizz', S.name(S.midi(p) + 12), .3, v, .2)
+E(1.0, 'glockenspiel', 'D6', 1.0, .4, .2)
+E(10.5, 'timpani', 'D2', 1.2, .55, 0); E(10.5, 'cellos_pizz', 'D3', .4, .55)
+E(19.0, 'glockenspiel', 'A5', .8, .3, .2); E(26.5, 'glockenspiel', 'B5', .8, .3, .2)
+E(33.5, 'glockenspiel', 'F#6', 1.0, .38, .2); chordhit(33.5, 'D', .4)
+E(43.3, 'glockenspiel', 'A6', 1.0, .38, .2); chordhit(43.3, 'Em', .35)
+E(45.0, 'sus_cymbal', 'hit', None, .22)
+E(FIN, 'timpani', 'D2', 2.5, .45); E(FIN, 'sus_cymbal', 'hit', None, .25)
+for p in ['D4', 'F#4', 'A4', 'D5']: E(FIN, 'vibraphone', p, DUR - FIN - .4, .28, 0)
+for p in ['D3', 'A3']: E(FIN, 'horn', p, DUR - FIN - .4, .26, 0, attack=.3, release=.5)
+E(FIN, 'contrabass', 'D2', DUR - FIN - .4, .38, 0, attack=.2, release=.5)
+for k, p in enumerate(['A5', 'D6', 'F#6', 'A6']): E(FIN + .85 + k * .14, 'glockenspiel', p, .8, .3, -.3 + .2 * k) # the four stations hop
+mus = S.render(ev, dur=DUR)
+# soft kick: a short sine sweep (not an 808 tail), on 1 and 3; on 1 only while the square is judged; none in the comic stop
+def kick(v):
+ d = .22; tt = t_(d); f = 62 + 70 * np.exp(-tt / .03)
+ return (np.sin(2 * np.pi * np.cumsum(f) / SR) * env_exp(d, .07) * v).astype(np.float32)
+for b in range(28):
+ for k in (0, 2): add(mus, kick(.36 if k == 0 else .26), b * BAR + k * BEAT, 1, 0)
+for t in (1.0, 10.5, 33.5, 43.3, FIN): add(mus, kick(.5), t, 1, 0)
+mus = S.room(mus, size=.32, mix=.12)
+fade = int(.5 * SR); mus[-fade:] *= np.linspace(1, 0, fade)[:, None] ** 2
+mus *= .5 / max(1e-9, np.abs(mus).max())
+os.makedirs(os.path.join(ROOT, 'music'), exist_ok=True)
+sf.write(os.path.join(ROOT, 'music/score.wav'), mus[:int(DUR * SR)], SR, subtype='PCM_24')
+har = [{'bar': b, 't0': b * BAR, 'chord': ch, 'notes': [S.midi(p) for p in PAD[ch]], 'root': S.midi(ROOT_[ch])} for b, ch in enumerate(CH)]
+json.dump(har, open(os.path.join(ROOT, 'music/harmony.json'), 'w'))
+print('score', mus.shape, 'peak', float(np.abs(mus).max()))
+print(S.credits(sorted({e['inst'] for e in ev})))
diff --git a/styles/desktop-flythrough/demo/audio/foley.py b/styles/desktop-flythrough/demo/audio/foley.py
new file mode 100644
index 0000000..2664945
--- /dev/null
+++ b/styles/desktop-flythrough/demo/audio/foley.py
@@ -0,0 +1,122 @@
+"""Foley for 明年没有这一天 (Desktop Flythrough demo): every on-screen action gets a sound; pitched sounds take their notes from the score's harmony.json,
+camera whips get whooshes sized by the measured camera speed. Usage: sfx.py <events.json> <camspeed.json> <harmony.json> <out.wav>"""
+import sys, os, json
+import numpy as np
+sys.path.insert(0, os.path.join(os.environ.get('LIB', os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../..'))), 'core/audio'))
+from sfx import SR, t_, env_exp, bp, lp, hp, noise, norm, whoosh, thump, click, step, add
+
+ev = json.load(open(sys.argv[1]))['ev']; cam = json.load(open(sys.argv[2])); HAR = json.load(open(sys.argv[3]))
+DUR = float(os.environ.get("DUR", 59.95)); N = int(DUR * SR); out = np.zeros((N, 2))
+hz = lambda m: 440 * 2 ** ((m - 69) / 12)
+def chord(t):
+ b = max(0, min(len(HAR) - 1, int(t // 2))); return HAR[b]['notes']
+def note(t, deg, octv=1): # the deg-th chord tone at time t, octave-shifted
+ ns = sorted(n % 12 + 60 for n in chord(t)); return ns[deg % len(ns)] + 12 * (octv + deg // len(ns))
+
+def marimba(f, d=.7, v=1.0):
+ tt = t_(d)
+ x = np.sin(2 * np.pi * f * tt) * env_exp(d, .28) + .3 * np.sin(2 * np.pi * f * 3.93 * tt) * env_exp(d, .045) + .1 * np.sin(2 * np.pi * f * 9.2 * tt) * env_exp(d, .01)
+ return norm(x + hp(noise(d), 3000) * env_exp(d, .002) * .25) * v
+def bell(f, d=1.2, v=1.0):
+ tt = t_(d); x = sum(a * np.sin(2 * np.pi * f * r * tt) * env_exp(d, tau) for r, a, tau in [(1, 1, .5), (2.01, .45, .3), (3.0, .25, .18), (4.2, .15, .1)])
+ return norm(x) * v
+def blip(f, d=.12, v=1.0):
+ tt = t_(d); return norm(np.sin(2 * np.pi * f * tt) * env_exp(d, .025) * (1 - np.exp(-tt / .002))) * v
+def poppy(f0=500, f1=1400, d=.16, v=1.0):
+ tt = t_(d); f = f0 + (f1 - f0) * tt / d; return norm(np.sin(2 * np.pi * np.cumsum(f) / SR) * env_exp(d, .045)) * v
+def boing(v=1.0):
+ d = .6; tt = t_(d); f = 180 + 260 * np.exp(-tt / .25) * (1 + .5 * np.sin(2 * np.pi * 14 * tt) * np.exp(-tt / .2))
+ return norm(np.sin(2 * np.pi * np.cumsum(f) / SR) * env_exp(d, .2)) * v
+def rise(d, v=1.0, lo=300, hi=3000):
+ tt = t_(d); n = noise(d); o = np.zeros_like(n)
+ for i in range(0, len(n), 480):
+ f = lo * (hi / lo) ** (i / len(n)); seg = bp(n[max(0, i - 2000):i + 480], f * .8, f * 1.25); o[i:i + 480] = seg[-len(o[i:i + 480]):]
+ return norm(o) * (tt / d) ** 1.5 * v
+def fall(d=.35, v=1.0): # descending whistle for things dropping from above
+ tt = t_(d); f = 1800 * (1 - .7 * tt / d); return norm(np.sin(2 * np.pi * np.cumsum(f) / SR) * np.sin(np.pi * tt / d) ** 2) * v
+def crumble(d=.4, v=1.0, n=26, pitch=1.0):
+ o = np.zeros(int((d + .1) * SR)); r = np.random.default_rng(int(d * 1000 + n))
+ for k in range(n):
+ c = click(pitch * (.7 + r.random() * .8), .3 + r.random() * .7); s = int(r.random() ** 1.3 * d * SR); o[s:s + len(c)] += c[:len(o) - s]
+ return norm(o) * v
+def build(d=1.0, v=1.0, n=40): # cubes stacking up: ticks rising in pitch
+ o = np.zeros(int((d + .1) * SR))
+ for k in range(n):
+ c = click(.8 + k / n * 1.2, .5); s = int(k / n * d * SR); o[s:s + len(c)] += c[:len(o) - s]
+ return norm(o) * v
+def slam(v=1.0, f=55):
+ d = 1.2; tt = t_(d)
+ sub = np.sin(2 * np.pi * f * tt * (1 - .2 * tt)) * env_exp(d, .22)
+ body = lp(noise(d), 500) * env_exp(d, .06); crack = hp(noise(d), 2500) * env_exp(d, .012)
+ paper = bp(noise(d), 1500, 7000) * env_exp(d, .25) * .25
+ return norm(sub + body * .8 + crack * .5 + paper) * v
+def stampS(v=1.0):
+ d = .5; tt = t_(d); return norm(lp(noise(d), 900) * env_exp(d, .03) + np.sin(2 * np.pi * 90 * tt) * env_exp(d, .07) + hp(noise(d), 3000) * env_exp(d, .006) * .6) * v
+def swish(d=.3, v=1.0):
+ return norm(bp(noise(d), 2000, 8000) * np.sin(np.pi * t_(d) / d) ** 2) * v
+def key(v=1.0):
+ d = .05; tt = t_(d); return norm(hp(noise(d), 2000) * env_exp(d, .004) + np.sin(2 * np.pi * 3200 * tt) * env_exp(d, .003) * .4) * v
+
+R = np.random.default_rng(5)
+q16 = lambda t: round(t * 8) / 8
+used = set()
+def onslot(kind, t):
+ k = (kind, round(t * 8))
+ if k in used: return None
+ used.add(k); return q16(t)
+def wrong(v=1.0):
+ """the film's one 'bad' sound (failures and the verdict): a muted low two-note fall, F3 → E3, a semitone that isn't in D major's I chord"""
+ o = np.zeros(int(.6 * SR))
+ for k, (f, s0, d) in enumerate([(174.6, 0, .16), (164.8, .14, .42)]):
+ tt = t_(d); x = sum(a * np.sin(2 * np.pi * f * h * tt) for h, a in [(1, 1), (2, .5), (3, .32), (4, .18), (5, .1)])
+ x = lp(x * env_exp(d, .16 if k else .07) * (1 - np.exp(-tt / .006)), 1400)
+ i = int(s0 * SR); o[i:i + len(x)] += x[:len(o) - i]
+ return norm(o) * v
+def buzz(d, v=1.0): # moth wings: a soft fluttering noise, amplitude-modulated at wing rate
+ tt = t_(d); return norm(bp(noise(d), 300, 2400) * (.5 + .5 * np.sin(2 * np.pi * 26 * tt)) ** 2) * v
+for e in sorted(ev, key=lambda e: e['t']):
+ t, ty = e['t'], e['type']; pan = float(R.uniform(-.3, .3)); k = e.get('k', 0)
+ if ty == 'pop': g = 1.2 if e.get('big') else 1.0; add(out, marimba(hz(note(q16(t), k % 7, 0)), .5, .25 * g), q16(t), 1, pan); add(out, poppy(400 + 40 * (k % 7), 1300, .12, .12 * g), t, 1, pan)
+ elif ty == 'send': add(out, click(1.1, .2), t, 1, .1); add(out, swish(.3, .1), t + .05, 1, .2)
+ elif ty == 'ding': add(out, bell(hz(note(t, 2, 2)), 1.2, .2), t, 1, .4); add(out, bell(hz(note(t, 0, 2)), 1.2, .14), t + .07, 1, .4)
+ elif ty == 'rewind': add(out, rise(.35, .06, 3000, 400), t, 1)
+ elif ty == 'dash':
+ if (tq := onslot('dash', t)) is not None: add(out, click(.9 + .05 * k, .08), tq, 1, -.4 + .15 * k)
+ elif ty == 'nope': add(out, thump(.25, 90), t, 1); add(out, poppy(900, 500, .12, .06), t, 1)
+ elif ty == 'dot':
+ if (tq := onslot('dot', t)) is not None: add(out, blip(hz(note(tq, k % 4, 2)), .08, .045), tq, 1, -.4 + k * .1)
+ elif ty == 'hop': add(out, swish(.12, .05), t, 1, pan); add(out, blip(hz(note(q16(t), k % 3, 1)), .08, .06), q16(t), 1, pan)
+ elif ty == 'jump': add(out, swish(.25, .09), t, 1, pan)
+ elif ty == 'land': add(out, thump(.3 * e.get('v', 1), 105), t, 1); add(out, step(.1 * e.get('v', 1)), t, 1, pan)
+ elif ty == 'badge': add(out, poppy(500, 1300, .1, .08), t, 1, .2); add(out, blip(hz(note(t, k % 3, 2)), .1, .06), q16(t), 1, .2)
+ elif ty == 'drop': add(out, fall(.25, .1), t, 1)
+ elif ty == 'titleLand': add(out, thump(.55, 75), t, 1); add(out, step(.18), t, 1); add(out, bell(hz(note(t, 0, 2)), 1.6, .16), t + .02, 1, 0); add(out, bell(hz(note(t, 2, 2)), 1.4, .1), t + .1, 1, 0)
+ elif ty == 'press': add(out, slam(.6, 60), t, 1); add(out, crumble(.25, .08, 14, 1.2), t + .02, 1)
+ elif ty == 'tickdown': add(out, click(1.3 - .05 * k, .1), t, 1, .2)
+ elif ty == 'drawer': d = .3; add(out, norm(bp(noise(d), 300, 2500) * np.sin(np.pi * t_(d) / d)) * .07, t, 1, .1); add(out, click(.7, .1), t + d, 1, .1)
+ elif ty == 'lit': add(out, bell(hz(note(t, 1, 2)), .8, .1), t, 1, .1)
+ elif ty == 'fly': add(out, rise(.7, .06, 600, 2500), t, 1, .3); add(out, swish(.6, .07), t, 1, .3)
+ elif ty == 'tap': add(out, click(1.0, .18), t, 1, .4)
+ elif ty == 'banner': add(out, poppy(600, 1200, .12, .07), t, 1, .4)
+ elif ty == 'ring': add(out, bell(hz(note(t, 2, 2)), 1.4, .24), t, 1, .4); add(out, bell(hz(note(t, 0, 2)), 1.4, .18), t + .08, 1, .4); add(out, bell(hz(note(t, 2, 2)), 1.0, .12), t + .26, 1, .4)
+ elif ty == 'fetch': add(out, rise(1.0, .05, 400, 2200), t, 1, -.2)
+ elif ty == 'weak': add(out, blip(hz(note(t, 0, 1)), .12, .05), t, 1, .3); add(out, blip(hz(note(t, 0, 1)) * .94, .12, .05), t + .18, 1, .3)
+ elif ty == 'sharp': add(out, rise(.25, .07, 2000, 7000), t - .2, 1, .2); add(out, bell(hz(note(t, 2, 2)), .8, .1), t, 1, .2)
+ elif ty == 'credit': add(out, bell(hz(note(t, 0, 2)), 1.6, .08), t, 1, .3)
+# camera whips: one whoosh per burst of fast motion, length and level from the measured speed
+sp = np.array([c[1] + .25 * c[2] for c in cam]); ts = np.array([c[0] for c in cam]); i = 0
+while i < len(sp):
+ if sp[i] > .9:
+ j = i
+ while j < len(sp) and sp[j] > .5: j += 1
+ a = max(0, i - 4); pk = sp[i:j].max(); d = max(.25, (j - a) / 30 + .1)
+ add(out, whoosh(d, min(.7, .18 + pk * .14)), ts[a], 1, float(R.uniform(-.4, .4))); i = j + 3
+ else: i += 1
+
+out *= .9
+peak = np.abs(out).max(); print('sfx peak', round(peak, 3))
+if peak > .98: out *= .98 / peak
+import wave
+with wave.open(sys.argv[4], 'wb') as w:
+ w.setnchannels(2); w.setsampwidth(2); w.setframerate(SR); w.writeframes((np.clip(out, -1, 1) * 32767).astype('<i2').tobytes())
+print('wrote', sys.argv[4])
diff --git a/styles/desktop-flythrough/demo/audio/mix.py b/styles/desktop-flythrough/demo/audio/mix.py
new file mode 100644
index 0000000..9a325cc
--- /dev/null
+++ b/styles/desktop-flythrough/demo/audio/mix.py
@@ -0,0 +1,48 @@
+"""Voice-over + music + foley → one stereo mix, 48 kHz, exactly the film's length, about −16 LUFS, true peak under −1.5 dBFS.
+The voice leads; the music ducks 16 dB under it and comes back up where nobody speaks; the foley sits under the voice. Usage: mix.py <score.wav> <sfx.wav> <out.wav> [sfx_gain_db] (the voice comes from vo/ and vo/timeline.json)"""
+import sys, os, wave
+import numpy as np
+sys.path.insert(0, os.path.join(os.environ.get('LIB', os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../..'))), 'core/audio'))
+from sfx import SR, limit
+
+def read(p): # any PCM width (the score is 24-bit): let ffmpeg decode to float
+ import subprocess
+ raw = subprocess.run(['ffmpeg', '-v', 'error', '-i', p, '-f', 'f32le', '-ac', '2', '-ar', str(SR), '-'], capture_output=True, check=True).stdout
+ return np.frombuffer(raw, '<f4').astype(np.float64).reshape(-1, 2)
+m, f = read(sys.argv[1]), read(sys.argv[2]); g = 10 ** (float(sys.argv[4] if len(sys.argv) > 4 else -3) / 20)
+N = int(float(os.environ.get('DUR', 59.95)) * SR); mix = np.zeros((N, 2))
+f = f[:N] * g
+for c in range(2): f[:, c] = limit(f[:, c], .35) # tame the slams so they sit in the music, not on top of it
+# the voice track, placed on the film clock
+import json, soundfile as sf
+ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+TL = json.load(open(os.path.join(ROOT, 'vo/timeline.json')))['lines']; vo = np.zeros((N, 2)); act = np.zeros(N)
+for l in TL:
+ x, sr = sf.read(os.path.join(ROOT, os.environ.get('VO_DIR', 'vo'), l['id'] + '.wav')); # VO_DIR=vo_en for the English mix: same start times as the Chinese lines
+ if x.ndim > 1: x = x.mean(1)
+ x = np.interp(np.arange(int(len(x) * SR / sr)) * sr / SR, np.arange(len(x)), x)
+ s = int(l['t0'] * SR); n = min(len(x), N - s); vo[s:s + n] += x[:n, None]; act[s:s + n] = 1
+# ducking envelope: −16 dB while the voice speaks (attack 0.15 s before, release 0.4 s after), 0 dB in the gaps
+duck = np.ones(N); k = np.where(act > 0)[0]
+from scipy.ndimage import maximum_filter1d, uniform_filter1d
+a = maximum_filter1d(act, size=int(.5 * SR)); a = uniform_filter1d(a, size=int(.3 * SR)); duck = 1 - a * (1 - 10 ** (-16 / 20))
+m = m[:N] if len(m) >= N else np.vstack([m, np.zeros((N - len(m), 2))])
+vo *= 10 ** (-20.5 / 20) / max(1e-9, np.sqrt(np.mean(vo[act > 0] ** 2))) # voice RMS ≈ −20.5 dBFS while speaking
+mix += m * duck[:, None] * 1.75 + f * (1 - .45 * a)[:, None] + vo
+
+fade = int(.08 * SR); mix[-fade:] *= np.linspace(1, 0, fade)[:, None]
+for c in range(2): mix[:, c] = limit(mix[:, c], .8)
+# bring the mix to about −16 LUFS (mux.sh lifts it to −14) and keep the peaks under −3 dBFS
+def lufs(x):
+ import subprocess, tempfile, re
+ with tempfile.NamedTemporaryFile(suffix='.wav') as tf:
+ with wave.open(tf.name, 'wb') as w: w.setnchannels(2); w.setsampwidth(2); w.setframerate(SR); w.writeframes((np.clip(x, -1, 1) * 32767).astype('<i2').tobytes())
+ err = subprocess.run(['ffmpeg', '-nostats', '-i', tf.name, '-af', 'ebur128', '-f', 'null', '-'], capture_output=True, text=True).stderr
+ return float(re.findall(r'I:\s+(-?[\d.]+) LUFS', err)[-1])
+for _ in range(2):
+ mix *= 10 ** ((-16.0 - lufs(mix)) / 20)
+ for c in range(2): mix[:, c] = limit(limit(mix[:, c], .7, .004), .72, .0015)
+print('mix loudness', lufs(mix), 'LUFS')
+with wave.open(sys.argv[3], 'wb') as w:
+ w.setnchannels(2); w.setsampwidth(2); w.setframerate(SR); w.writeframes((np.clip(mix, -1, 1) * 32767).astype('<i2').tobytes())
+print('wrote', sys.argv[3], 'peak', round(np.abs(mix).max(), 3))
diff --git a/styles/desktop-flythrough/demo/audio/vo_timeline.py b/styles/desktop-flythrough/demo/audio/vo_timeline.py
new file mode 100644
index 0000000..4b12777
--- /dev/null
+++ b/styles/desktop-flythrough/demo/audio/vo_timeline.py
@@ -0,0 +1,34 @@
+"""Lay the voice-over lines on the film's clock and write src/vo.js (start/end of each line, Chinese text, English subtitle).
+Run from anywhere: python3 audio/vo_timeline.py. Reads vo/lines.json and vo/dur.json."""
+import json, os
+ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+L = json.load(open(os.path.join(ROOT, 'vo/lines.json'))); D = json.load(open(os.path.join(ROOT, 'vo/dur.json')))
+EN = [
+ 'You send a friend a cat photo. Ding, it arrives right away.',
+ "But the photo didn't fly straight there.",
+ 'The moment you hit send, step one: make it smaller.',
+ 'The original is too big and slow to send, so the app quietly compresses it: smaller, yet it looks about the same.',
+ 'Next, the photo reaches stop two: the server.',
+ "That's the chat app's relay station in the cloud. The photo waits here to be picked up.",
+ 'Only then comes step three: the notification.',
+ 'The server taps your friend\'s phone: "Hey, a photo for you."',
+ "That's when the phone goes ding.",
+ "After the notification, your friend's phone goes to the server and fetches the photo.",
+ 'So on a slow connection, you see it blurry for a moment, then suddenly sharp.',
+ 'Behind that one ding is a silent relay.',
+ 'Unless you ticked "Original", what your friend gets is just a compressed copy of the cat.',
+ 'The real original has been on your phone all along.',
+]
+LEAD = .8
+GAP = [.4, .5, .3, .6, .3, .6, .3, .3, .6, .3, .6, .35, .3, .3]
+TARGET = 59.95 # the film's length is fixed; whatever the last line leaves is the closing shot
+t = LEAD; out = []
+for i, l in enumerate(L):
+ d = D[l['id']]; out.append({'id': l['id'], 't0': round(t, 3), 't1': round(t + d, 3), 'zh': l['text'], 'en': EN[i]}); t += d + GAP[i]
+dur = TARGET; CREDIT = TARGET - t
+js = '// Voice-over lines on the film clock (generated by audio/vo_timeline.py from vo/). t0/t1 = speech start/end.\n'
+js += f'export const DUR = {dur};\nexport const CREDIT_T = {round(t, 2)};\nexport const VO = ' + json.dumps(out, ensure_ascii=False, indent=1) + ';\n'
+open(os.path.join(ROOT, 'src/vo.js'), 'w').write(js)
+json.dump({'dur': dur, 'lines': out}, open(os.path.join(ROOT, 'vo/timeline.json'), 'w'), ensure_ascii=False, indent=1)
+print('dur', dur, 'credit at', round(t, 2))
+for o in out: print(o['id'], o['t0'], o['t1'], o['zh'])
diff --git a/styles/desktop-flythrough/demo/build.sh b/styles/desktop-flythrough/demo/build.sh
new file mode 100755
index 0000000..8cff353
--- /dev/null
+++ b/styles/desktop-flythrough/demo/build.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+# One command: 《叮之前》 Before the Ding (Desktop Flythrough demo)
+# sh styles/desktop-flythrough/demo/build.sh Chinese voice-over, the library demo → styles/desktop-flythrough/desktop-flythrough.mp4
+# sh styles/desktop-flythrough/demo/build.sh en English voice-over (same picture, same clock) → desktop-flythrough-en.mp4
+# Steps: fonts → voice (edge-tts, checked with Whisper) → voice clock → events → score, foley, mix → picture → master → reading-time check → stills.
+# Fonts and sample packs are not in git: fonts come from github.com/google/fonts (OFL), samples from tools/fetch.sh (CC0).
+# edge-tts is an online service: the voice step needs the internet.
+set -e
+HERE=$(cd "$(dirname "$0")" && pwd) # .../<slug>/demo
+FILM=$(cd "$HERE/.." && pwd) # .../<slug>
+LIB=${LIB:-$(cd "$HERE/../../.." && pwd)} # styles/<slug>/demo -> library root
+export LIB
+[ -f "$LIB/core/render/video.mjs" ] || { echo "set LIB to the library folder"; exit 1; }
+PY="$LIB/.venv/bin/python"
+NAME=desktop-flythrough
+VOLANG=${1:-zh}
+FPS=30
+FRAME=56.85 # the closing wide view, title landed, before the sign-off: poster and README frame
+STILL=15.8 # the compress card: gallery style frame (rendered without the subtitle bar)
+cd "$LIB"
+mkdir -p "$HERE/out" "$HERE/fonts"
+
+# fonts (gitignored)
+GF=https://github.com/google/fonts/raw/main/ofl
+[ -f "$HERE/fonts/InstrumentSans.ttf" ] || curl -sfL -o "$HERE/fonts/InstrumentSans.ttf" "$GF/instrumentsans/InstrumentSans%5Bwdth,wght%5D.ttf"
+[ -f "$HERE/fonts/IBMPlexMono-Medium.ttf" ] || curl -sfL -o "$HERE/fonts/IBMPlexMono-Medium.ttf" "$GF/ibmplexmono/IBMPlexMono-Medium.ttf"
+[ -f "$HERE/fonts/IBMPlexMono-SemiBold.ttf" ] || curl -sfL -o "$HERE/fonts/IBMPlexMono-SemiBold.ttf" "$GF/ibmplexmono/IBMPlexMono-SemiBold.ttf"
+[ -f "$HERE/tools/NotoSansSC-VF.ttf" ] || curl -sfL -o "$HERE/tools/NotoSansSC-VF.ttf" "$GF/notosanssc/NotoSansSC%5Bwght%5D.ttf"
+"$PY" "$HERE/tools/subset.py" # fonts/NotoSansSC-sub.ttf: every character on screen and in the subtitles
+for l in vcsl vsco2ce; do [ -d "core/audio/instruments/$l" ] || sh tools/fetch.sh instruments $l; done
+
+# voice: the Chinese lines set the film's clock (src/vo.js); the English lines start on the same seconds
+"$PY" core/tts/tts_zh.py "$HERE/vo/lines.json" "$HERE/vo" --voice zh-CN-XiaoxiaoNeural --rate +15%
+"$PY" core/tts/asr_check.py "$HERE/vo/lines.json" "$HERE/vo" --lang zh
+python3 "$HERE/audio/vo_timeline.py"
+VODIR=vo; OUT=$NAME
+if [ "$VOLANG" = en ]; then
+ "$PY" core/tts/tts_zh.py "$HERE/vo/lines_en.json" "$HERE/vo_en" --voice en-US-AvaNeural --rate +10%
+ "$PY" core/tts/asr_check.py "$HERE/vo/lines_en.json" "$HERE/vo_en" --lang en
+ VODIR=vo_en; OUT=$NAME-en
+fi
+DUR=$(python3 -c "import json;print(json.load(open('$HERE/vo/timeline.json'))['dur'])"); export DUR
+
+# events and camera speed from the page, then the score, the foley and the mix (about -16 LUFS before the master)
+node core/render/events.mjs "$HERE" --out "$HERE/out/events.json"
+node "$HERE/tools/camspeed.mjs" "$HERE/out/camspeed.json"
+"$PY" -I "$HERE/audio/compose.py"
+"$PY" -I "$HERE/audio/foley.py" "$HERE/out/events.json" "$HERE/out/camspeed.json" "$HERE/music/harmony.json" "$HERE/out/sfx.wav"
+VO_DIR=$VODIR "$PY" -I "$HERE/audio/mix.py" "$HERE/music/score.wav" "$HERE/out/sfx.wav" "$HERE/out/mix_$VOLANG.wav" -4
+
+# picture and master (mux.sh brings the mix to -14 LUFS)
+node core/render/video.mjs "$HERE" --fps $FPS --workers 3 --out "$HERE/out/video.mp4"
+sh core/render/mux.sh "$HERE/out/video.mp4" "$HERE/out/mix_$VOLANG.wav" "$FILM/$OUT.mp4" $FPS 0
+
+# reading time of the words in the world and the sign-off (window.TEXTS)
+node core/render/readcheck.mjs "$HERE" > "$HERE/out/readcheck.txt" && echo "readcheck ok" || { tail -20 "$HERE/out/readcheck.txt"; exit 1; }
+
+# poster (from the film) and the gallery style frame (from the page, without the subtitle bar)
+if [ "$VOLANG" = zh ]; then
+ ffmpeg -v error -y -ss $FRAME -i "$FILM/$OUT.mp4" -frames:v 1 -q:v 2 "$FILM/poster.jpg"
+ node core/render/still.mjs "$HERE" $STILL --size 1920x1080 --q nosub=1 --out "$HERE/stills" --prefix sf_
+ mv "$HERE/stills/sf_$STILL.jpg" "$HERE/stills/styleframe.jpg"
+fi
+echo "done: $FILM/$OUT.mp4"
diff --git a/styles/desktop-flythrough/demo/fonts/OFL-IBMPlexMono.txt b/styles/desktop-flythrough/demo/fonts/OFL-IBMPlexMono.txt
new file mode 100644
index 0000000..c35c4c6
--- /dev/null
+++ b/styles/desktop-flythrough/demo/fonts/OFL-IBMPlexMono.txt
@@ -0,0 +1,93 @@
+Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+
+This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/styles/desktop-flythrough/demo/fonts/OFL-InstrumentSans.txt b/styles/desktop-flythrough/demo/fonts/OFL-InstrumentSans.txt
new file mode 100644
index 0000000..26bd2f9
--- /dev/null
+++ b/styles/desktop-flythrough/demo/fonts/OFL-InstrumentSans.txt
@@ -0,0 +1,93 @@
+Copyright 2022 The Instrument Sans Project Authors (https://github.com/Instrument/instrument-sans)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/styles/desktop-flythrough/demo/fonts/OFL-NotoSansSC.txt b/styles/desktop-flythrough/demo/fonts/OFL-NotoSansSC.txt
new file mode 100644
index 0000000..1c9f432
--- /dev/null
+++ b/styles/desktop-flythrough/demo/fonts/OFL-NotoSansSC.txt
@@ -0,0 +1,93 @@
+Copyright 2014-2021 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/styles/desktop-flythrough/demo/index.html b/styles/desktop-flythrough/demo/index.html
new file mode 100644
index 0000000..9080d90
--- /dev/null
+++ b/styles/desktop-flythrough/demo/index.html
@@ -0,0 +1,21 @@
+<!doctype html><html><head><meta charset="utf-8"><title>Desktop Flythrough · Before the Ding</title>
+<style>
+@font-face{font-family:IS;font-weight:400 700;src:url(fonts/InstrumentSans.ttf) format('truetype')}
+@font-face{font-family:PM;font-weight:500;src:url(fonts/IBMPlexMono-Medium.ttf) format('truetype')}
+@font-face{font-family:PM;font-weight:600;src:url(fonts/IBMPlexMono-SemiBold.ttf) format('truetype')}
+@font-face{font-family:SC;font-weight:100 900;src:url(fonts/NotoSansSC-sub.ttf) format('truetype')}
+:root{--paper:#e2e8f5;--ink:#171c2e;--accent:#2f5bff}
+html,body{margin:0;background:#e6e3e0;overflow:hidden;width:1920px;height:1080px}
+canvas{display:block;position:absolute;left:0;top:0}
+#sub{position:absolute;left:50%;bottom:64px;transform:translateX(-50%);display:none;flex-direction:column;align-items:center;gap:6px;
+ max-width:1720px;padding:14px 34px 16px;border-radius:18px;background:rgba(23,28,46,.72);pointer-events:none}
+#sub .zh{font:700 40px/1.25 IS,SC;color:#fff;letter-spacing:.02em;white-space:nowrap}
+#sub .en{font:500 26px/1.25 IS;color:#d6dcea;white-space:nowrap}
+#credit{position:absolute;left:50%;bottom:72px;transform:translateX(-50%);display:none;font:700 44px IS;color:var(--ink);letter-spacing:.02em;
+ padding:12px 34px;border-radius:18px;background:rgba(251,252,255,.82)}
+</style></head><body>
+<div id="sub"><div class="zh"></div><div class="en"></div></div>
+<div id="credit">LemoLab × Claude Opus 5.5</div>
+<script type="importmap">{"imports":{"three":"/node_modules/three/build/three.module.js","three/addons/":"/node_modules/three/examples/jsm/"}}</script>
+<script type="module" src="./src/main.js"></script>
+</body></html>
diff --git a/styles/desktop-flythrough/demo/music/harmony.json b/styles/desktop-flythrough/demo/music/harmony.json
new file mode 100644
index 0000000..8a09915
--- /dev/null
+++ b/styles/desktop-flythrough/demo/music/harmony.json
@@ -0,0 +1 @@
+[{"bar": 0, "t0": 0.0, "chord": "D", "notes": [57.0, 62.0, 66.0], "root": 38.0}, {"bar": 1, "t0": 2.0, "chord": "G", "notes": [55.0, 59.0, 62.0], "root": 43.0}, {"bar": 2, "t0": 4.0, "chord": "D", "notes": [57.0, 62.0, 66.0], "root": 38.0}, {"bar": 3, "t0": 6.0, "chord": "A", "notes": [57.0, 61.0, 64.0], "root": 45.0}, {"bar": 4, "t0": 8.0, "chord": "Bm", "notes": [59.0, 62.0, 66.0], "root": 47.0}, {"bar": 5, "t0": 10.0, "chord": "G", "notes": [55.0, 59.0, 62.0], "root": 43.0}, {"bar": 6, "t0": 12.0, "chord": "D", "notes": [57.0, 62.0, 66.0], "root": 38.0}, {"bar": 7, "t0": 14.0, "chord": "A", "notes": [57.0, 61.0, 64.0], "root": 45.0}, {"bar": 8, "t0": 16.0, "chord": "G", "notes": [55.0, 59.0, 62.0], "root": 43.0}, {"bar": 9, "t0": 18.0, "chord": "D", "notes": [57.0, 62.0, 66.0], "root": 38.0}, {"bar": 10, "t0": 20.0, "chord": "Em", "notes": [55.0, 59.0, 64.0], "root": 40.0}, {"bar": 11, "t0": 22.0, "chord": "A", "notes": [57.0, 61.0, 64.0], "root": 45.0}, {"bar": 12, "t0": 24.0, "chord": "Bm", "notes": [59.0, 62.0, 66.0], "root": 47.0}, {"bar": 13, "t0": 26.0, "chord": "G", "notes": [55.0, 59.0, 62.0], "root": 43.0}, {"bar": 14, "t0": 28.0, "chord": "A", "notes": [57.0, 61.0, 64.0], "root": 45.0}, {"bar": 15, "t0": 30.0, "chord": "D", "notes": [57.0, 62.0, 66.0], "root": 38.0}, {"bar": 16, "t0": 32.0, "chord": "G", "notes": [55.0, 59.0, 62.0], "root": 43.0}, {"bar": 17, "t0": 34.0, "chord": "A", "notes": [57.0, 61.0, 64.0], "root": 45.0}, {"bar": 18, "t0": 36.0, "chord": "Bm", "notes": [59.0, 62.0, 66.0], "root": 47.0}, {"bar": 19, "t0": 38.0, "chord": "G", "notes": [55.0, 59.0, 62.0], "root": 43.0}, {"bar": 20, "t0": 40.0, "chord": "Em", "notes": [55.0, 59.0, 64.0], "root": 40.0}, {"bar": 21, "t0": 42.0, "chord": "A", "notes": [57.0, 61.0, 64.0], "root": 45.0}, {"bar": 22, "t0": 44.0, "chord": "D", "notes": [57.0, 62.0, 66.0], "root": 38.0}, {"bar": 23, "t0": 46.0, "chord": "G", "notes": [55.0, 59.0, 62.0], "root": 43.0}, {"bar": 24, "t0": 48.0, "chord": "D", "notes": [57.0, 62.0, 66.0], "root": 38.0}, {"bar": 25, "t0": 50.0, "chord": "A", "notes": [57.0, 61.0, 64.0], "root": 45.0}, {"bar": 26, "t0": 52.0, "chord": "G", "notes": [55.0, 59.0, 62.0], "root": 43.0}, {"bar": 27, "t0": 54.0, "chord": "A", "notes": [57.0, 61.0, 64.0], "root": 45.0}, {"bar": 28, "t0": 56.0, "chord": "D", "notes": [57.0, 62.0, 66.0], "root": 38.0}, {"bar": 29, "t0": 58.0, "chord": "D", "notes": [57.0, 62.0, 66.0], "root": 38.0}]
\ No newline at end of file
diff --git a/styles/desktop-flythrough/demo/src/anim.js b/styles/desktop-flythrough/demo/src/anim.js
new file mode 100644
index 0000000..3566fc2
--- /dev/null
+++ b/styles/desktop-flythrough/demo/src/anim.js
@@ -0,0 +1,56 @@
+// Motion helpers shared by every segment. Time in seconds; 120 BPM → beat = 0.5 s, bar = 2 s.
+import * as THREE from 'three';
+import { clamp, lerp, seg, ss, eio, eo, ei, back, hash } from '/core/lib.js';
+export const BEAT = .5, BAR = 2;
+export const V = (x, y, z) => new THREE.Vector3(x, y, z);
+export const arc = p => 4 * p * (1 - p);
+
+// a squash/stretch envelope from a list of landings and take-offs
+export function squash(t, lands = [], takeoffs = [], air = null, k = 1) {
+ let sq = 1;
+ if (air !== null && air > 0 && air < 1) sq += .14 * k * Math.sin(Math.PI * air);
+ for (const tl of lands) { const d = t - tl; if (d >= 0 && d < .2) sq -= .32 * k * Math.sin(Math.PI * d / .2) * (1 - d / .2); }
+ for (const ta of takeoffs) { const d = ta - t; if (d > 0 && d < .09) sq -= .18 * k * Math.sin(Math.PI * d / .09); }
+ return sq;
+}
+
+// hops along a list [{t0, t1, from:Vector3, to:Vector3, h}] → {pos, air, lands, takeoffs, dir}
+export function hops(t, list, rest) {
+ let pos = rest.clone(), air = null, dir = null;
+ for (const hp of list) {
+ if (t >= hp.t1) { pos = hp.to.clone(); continue; }
+ if (t >= hp.t0) {
+ const p = seg(t, hp.t0, hp.t1), e = hp.ease ? hp.ease(p) : lerp(p, ss(p), .5);
+ pos = hp.from.clone().lerp(hp.to, e); pos.y += (hp.h ?? .03) * arc(p); air = p;
+ dir = hp.to.clone().sub(hp.from);
+ }
+ break;
+ }
+ return { pos, air, dir, lands: list.map(h => h.t1), takeoffs: list.map(h => h.t0) };
+}
+
+// bounce on every beat between t0 and t1 (a little dance); returns {y, sq}
+export function beatBounce(t, t0, t1, amp = .018, phase = 0) {
+ if (t < t0 || t > t1) return { y: 0, sq: 1 };
+ const u = ((t - t0 + phase) % BEAT) / BEAT;
+ const air = u < .55 ? u / .55 : null; // airborne for the first 55 % of each beat
+ const y = air !== null ? amp * arc(air) : 0;
+ let sq = 1;
+ if (air !== null) sq += .12 * Math.sin(Math.PI * air);
+ else { const d = (u - .55) / .45; sq -= .22 * Math.sin(Math.PI * d) * (1 - d); }
+ return { y, sq };
+}
+
+// the "pop": a flat sticker stands up and extrudes into a toy, with a jump. Returns {e, hinge, y, sq}
+export function pop(t, t0, dur = .4, jump = .045) {
+ const p = seg(t, t0, t0 + dur);
+ if (t < t0) return { e: 0, hinge: 0, y: 0, sq: 1 };
+ const hinge = back(seg(t, t0, t0 + dur * .45), 2.2), e = seg(t, t0 + dur * .1, t0 + dur);
+ const y = p < 1 ? jump * arc(p) : 0;
+ let sq = p < 1 ? 1 + .25 * Math.sin(Math.PI * p) : 1;
+ const d = t - (t0 + dur); if (d >= 0 && d < .22) sq -= .3 * Math.sin(Math.PI * d / .22) * (1 - d / .22);
+ return { e, hinge, y, sq };
+}
+
+export const yawTo = (from, to) => Math.atan2(to.x - from.x, to.z - from.z);
+export { clamp, lerp, seg, ss, eio, eo, ei, back, hash };
diff --git a/styles/desktop-flythrough/demo/src/camera.js b/styles/desktop-flythrough/demo/src/camera.js
new file mode 100644
index 0000000..af3b7d2
--- /dev/null
+++ b/styles/desktop-flythrough/demo/src/camera.js
@@ -0,0 +1,42 @@
+// One continuous camera. Target keys may name a live subject (ctx.subj[name](t)); orbit keys are [log dist, azimuth, elevation, fov].
+// Between target keys: Hermite with live end points, so the camera keeps tracking moving subjects while it travels.
+// keys: [t, target (Vector3 | subject name), dist, az, el, fov, target offset?, {ease}?]
+// ease: the target comes to rest at this key (zero tangent), so a whip that starts here doesn't first drift backwards
+// shakes: [t, amplitude (world units), decay]
+import * as THREE from 'three';
+import { track, vnoise, clamp } from '/core/lib.js';
+import { V } from './anim.js';
+
+const ln = Math.log;
+export function makeRig(ctx, camera, KEYS, SHAKES) {
+ const keys = KEYS.map(k => ({ t: k[0], tg: k[1], off: k[6], ease: k[7]?.ease }));
+ const orb = track(KEYS.map(k => [k[0], [ln(k[2]), k[3], k[4], k[5]]]));
+ const ev = (k, t) => typeof k.tg === 'string' ? ctx.subj[k.tg](t).clone().add(k.off || V(0, 0, 0)) : k.tg.clone();
+ function target(t) {
+ const n = keys.length; if (t <= keys[0].t) return ev(keys[0], t); if (t >= keys[n - 1].t) return ev(keys[n - 1], t);
+ let i = 0; while (t > keys[i + 1].t) i++;
+ const a = keys[i], b = keys[i + 1], h = b.t - a.t, u = (t - a.t) / h;
+ const pa = ev(a, t), pb = ev(b, t);
+ const tan = j => { const p = keys[Math.max(0, j - 1)], q = keys[Math.min(n - 1, j + 1)]; if (p === q || keys[j].ease) return V(0, 0, 0); return ev(q, t).sub(ev(p, t)).multiplyScalar(1 / (q.t - p.t)); };
+ const ma = tan(i).multiplyScalar(h * .85), mb = tan(i + 1).multiplyScalar(h * .85);
+ const u2 = u * u, u3 = u2 * u;
+ return pa.multiplyScalar(2 * u3 - 3 * u2 + 1).add(ma.multiplyScalar(u3 - 2 * u2 + u)).add(pb.multiplyScalar(-2 * u3 + 3 * u2)).add(mb.multiplyScalar(u3 - u2));
+ }
+ const tmp = new THREE.Vector3();
+ function apply(t, jx = 0, jy = 0) {
+ const tg = target(t), [ld, az, el, fov] = orb(t), d = Math.exp(ld);
+ const n = k => vnoise(t * 1.3 + k * 17.3) - .5;
+ const pos = tg.clone().add(V(Math.cos(el) * Math.sin(az), Math.sin(el), Math.cos(el) * Math.cos(az)).multiplyScalar(d));
+ pos.add(V(n(1), n(2), n(3)).multiplyScalar(d * .006)); // a breath of drift, not a handheld wobble
+ let sh = 0; for (const [ts, a, dk] of SHAKES) { const dt = t - ts; if (dt > 0 && dt < 1) sh += a * Math.exp(-dt * dk); }
+ if (sh) { pos.add(V(Math.sin(t * 91), Math.sin(t * 77 + 1), Math.sin(t * 83 + 2)).multiplyScalar(sh)); tg.add(V(Math.sin(t * 67), Math.sin(t * 73), 0).multiplyScalar(sh * .5)); }
+ ctx.world.scene.fog.density = .075 / Math.max(1, d * .9);
+ camera.position.copy(pos); camera.fov = fov; camera.up.set(0, 1, 0); camera.lookAt(tg);
+ // bank into fast lateral moves: roll ∝ the turning rate of the azimuth
+ const daz = (orb(t + .05)[1] - orb(t - .05)[1]) / .1;
+ camera.rotateZ(n(4) * .01 + clamp(daz * -.04, -.12, .12));
+ camera.setViewOffset(1920, 1080, jx, jy + 110, 1920, 1080); // the subject sits 110 px above centre: the subtitle bar owns the bottom of the frame camera.updateProjectionMatrix();
+ return { tg, d };
+ }
+ return { apply, target };
+}
diff --git a/styles/desktop-flythrough/demo/src/captions.js b/styles/desktop-flythrough/demo/src/captions.js
new file mode 100644
index 0000000..3d25f41
--- /dev/null
+++ b/styles/desktop-flythrough/demo/src/captions.js
@@ -0,0 +1,24 @@
+// Subtitles (DOM, always crisp): one cue per voice-over line, Chinese on the first line, English on the second, in a quiet bar at the bottom.
+// The sign-off sits in the same place after the last line. texts() reports what is meant to be read (the sign-off; subtitle cues are timed by the voice).
+import { seg, eo } from '/core/lib.js';
+
+export function makeSubs(VO, END) {
+ const host = document.getElementById('sub'), zh = host.querySelector('.zh'), en = host.querySelector('.en'), credit = document.getElementById('credit');
+ let cur = -2;
+ const clean = new URLSearchParams(location.search).has('nosub');
+ function render(t) {
+ if (clean) { host.style.display = 'none'; credit.style.display = 'none'; return; }
+ let i = -1; for (let k = 0; k < VO.length; k++) { const next = VO[k + 1] ? VO[k + 1].t0 - .12 : END.credit - .2; if (t >= VO[k].t0 - .12 && t < Math.min(next, VO[k].t1 + .5)) i = k; }
+ if (i !== cur) { cur = i; if (i >= 0) { zh.textContent = VO[i].zh; en.textContent = VO[i].en; } }
+ if (i >= 0) { const a = Math.min(eo(seg(t, VO[i].t0 - .12, VO[i].t0 + .05)), 1 - seg(t, VO[i].t1 + .35, VO[i].t1 + .5)); host.style.opacity = a; host.style.display = 'flex'; }
+ else host.style.display = 'none';
+ const c = t >= END.credit; credit.style.display = c ? 'block' : 'none';
+ if (c) { const p = eo(seg(t, END.credit, END.credit + .4)); credit.style.opacity = p; credit.style.transform = `translate(-50%, ${(1 - p) * 20}px)`; }
+ }
+ function texts(t) {
+ const out = [];
+ if (t >= END.credit) { const r = credit.getBoundingClientRect(); out.push({ id: 'credit', text: credit.innerText.trim(), x0: r.left, y0: r.top, x1: r.right, y1: r.bottom }); }
+ return out;
+ }
+ return { render, texts };
+}
diff --git a/styles/desktop-flythrough/demo/src/cards.js b/styles/desktop-flythrough/demo/src/cards.js
new file mode 100644
index 0000000..f5ed29d
--- /dev/null
+++ b/styles/desktop-flythrough/demo/src/cards.js
@@ -0,0 +1,65 @@
+// Card art drawn with Canvas 2D: paper, one ink, one accent, mono labels. Logical size in px (1000 px = 1 world unit), canvases at 2×.
+// COL is this film's palette (an example: the style fixes the logic, not the hues). Cool grey-blue paper, cobalt for what matters now, red only for failure.
+import { hash } from '/core/lib.js';
+export const COL = {
+ paper: '#e2e8f5', card: '#fbfcff', dot: '#c4cde3', ink: '#171c2e', mute: '#7d8597', line: '#dfe3ec', faint: '#eef0f6',
+ accent: '#2f5bff', red: '#e2483d', owl: '#a8744a', green: '#3fa57a', mustard: '#f2c14e', term: '#1f2535', termInk: '#d9deea', termMute: '#7f889e',
+};
+export const MONO = 'PM, SC, monospace', SANS = 'IS, SC, sans-serif', CJK = 'SC, sans-serif';
+
+export function canvas(w, h, s = 2) {
+ const c = document.createElement('canvas'); c.width = w * s; c.height = h * s;
+ const x = c.getContext('2d'); x.scale(s, s); return [c, x];
+}
+export const rr = (c, x, y, w, h, r) => { c.beginPath(); c.roundRect(x, y, w, h, r); };
+export function txt(c, s, x, y, o = {}) {
+ c.font = `${o.wt || 500} ${o.size || 20}px ${o.font || MONO}`; c.fillStyle = o.col || COL.ink;
+ c.textAlign = o.align || 'left'; c.textBaseline = 'middle';
+ c.letterSpacing = (o.ls || 0) + 'px'; c.fillText(s, x, y); c.letterSpacing = '0px';
+ return c.measureText(s).width;
+}
+// mono section label: accent square + spaced caps
+export function tag(c, s, x, y, size = 18, col = COL.accent, ink = COL.ink) {
+ c.fillStyle = col; c.fillRect(x, y - size * .45, size * .9, size * .9);
+ txt(c, s.toUpperCase(), x + size * 1.5, y + 1, { size, col: ink, wt: 600, ls: size * .2 });
+}
+// fine paper grain, deterministic (so every render of a card is the same)
+export function grain(c, w, h, seed = 1, n = null, dark = 'rgba(30,36,51,.035)', light = 'rgba(255,255,255,.5)') {
+ n = n || Math.round(w * h / 55);
+ for (let i = 0; i < n; i++) {
+ const x = hash(i * 1.37 + seed) * w, y = hash(i * 2.11 + seed * 3.7) * h, r = .6 + hash(i * 5.3 + seed) * 1.1;
+ c.fillStyle = hash(i * 7.7 + seed) < .5 ? dark : light; c.fillRect(x, y, r, r);
+ }
+}
+// card face: near-white, thin rule, a two-line head (English mono caps over a Chinese bold line)
+export function cardBase(c, w, h, en, cn, o = {}) {
+ const bg = o.bg || COL.card, ink = o.ink || COL.ink, sub = o.sub || COL.mute;
+ c.clearRect(0, 0, w, h);
+ c.fillStyle = bg; rr(c, 0, 0, w, h, 16); c.fill();
+ c.save(); rr(c, 0, 0, w, h, 16); c.clip(); grain(c, w, h, w * .37 + h, null, o.dark ? 'rgba(0,0,0,.08)' : undefined, o.dark ? 'rgba(255,255,255,.03)' : undefined); c.restore();
+ c.strokeStyle = o.rule || COL.line; c.lineWidth = 3; rr(c, 1.5, 1.5, w - 3, h - 3, 15); c.stroke();
+ if (en) {
+ tag(c, en, 28, 34, o.tagSize || 17, o.tagCol || COL.accent, ink);
+ if (cn) txt(c, cn, 28, 66, { size: o.cnSize || 21, wt: 700, font: CJK, col: sub });
+ c.fillStyle = o.rule || COL.line; c.fillRect(20, o.headH || 90, w - 40, 2);
+ }
+}
+// the paper's dot texture: a tile of n×n dots with a faint grain (the tile repeats every n dots)
+export function dotTile(px = 1024, n = 8, r = 6.5) {
+ const [c, x] = canvas(px, px, 1);
+ x.fillStyle = COL.paper; x.fillRect(0, 0, px, px);
+ grain(x, px, px, 7, 26000, 'rgba(30,36,51,.025)', 'rgba(255,255,255,.22)');
+ const st = px / n;
+ x.fillStyle = COL.dot;
+ for (let i = 0; i < n; i++) for (let j = 0; j < n; j++) { x.beginPath(); x.arc((i + .5) * st, (j + .5) * st, r, 0, 7); x.fill(); }
+ return c;
+}
+// a hand-set tick (✓) and cross (✗), stroked
+export function tick(c, x, y, s, col, lw = 6) {
+ c.strokeStyle = col; c.lineWidth = lw; c.lineCap = 'round'; c.lineJoin = 'round';
+ c.beginPath(); c.moveTo(x - s * .45, y); c.lineTo(x - s * .12, y + s * .32); c.lineTo(x + s * .5, y - s * .38); c.stroke();
+}
+export function cross(c, x, y, s, col, lw = 6) {
+ c.strokeStyle = col; c.lineWidth = lw; c.lineCap = 'round';
+ c.beginPath(); c.moveTo(x - s / 2, y - s / 2); c.lineTo(x + s / 2, y + s / 2); c.moveTo(x + s / 2, y - s / 2); c.lineTo(x - s / 2, y + s / 2); c.stroke();
+}
diff --git a/styles/desktop-flythrough/demo/src/film.js b/styles/desktop-flythrough/demo/src/film.js
new file mode 100644
index 0000000..40595fd
--- /dev/null
+++ b/styles/desktop-flythrough/demo/src/film.js
@@ -0,0 +1,430 @@
+// 叮之前 / Before the Ding — the Lemo-Opuscar library demo of Desktop Flythrough. One take over a dotted paper mat on a light oak desk.
+// You send a friend a cat photo. It doesn't fly straight there: it is shrunk (step 1), parked on the chat app's server (stop 2),
+// the server sends a notification (step 3), and only then does the friend's phone fetch it (blurry first on a slow connection).
+// The voice-over clock is in vo.js; every action below is cued to its words.
+import * as THREE from 'three';
+import { card, dotPatch, pill, rbox } from './world.js';
+import { makeMonster } from './voxel.js';
+import * as K from './cards.js';
+import { clamp, lerp, seg, ss, eo, ei, eio, back, hash, V, arc, pop, beatBounce, squash, hops } from './anim.js';
+import { VO, DUR as VDUR, CREDIT_T } from './vo.js';
+
+export const DUR = VDUR;
+export const END = { credit: VDUR - 2.95 }; // the sign-off lands after the closing title has dropped
+export { VO };
+const C = K.COL, TOP = .005, YAX = V(0, 1, 0);
+
+// ── timeline (film seconds; cued to the words of the voice-over) ──
+export const T = {
+ catPop: 1.0, send: 2.0, ding0: 2.25, rewind: 5.3, straight: [4.9, 5.6], cross: 5.75, route: [6.0, 7.2], straightOut: [7.3, 7.8],
+ jump1: [8.25, 8.75], badge1: 9.2, press: 10.5, counter: [11.0, 14.6], compare: 15.6,
+ hopsS: [[17.3, 17.75], [17.9, 18.4], [18.6, 19.4]], badge2: 19.0, drawerOut: 22.7, catIn: [23.1, 23.5], drawerIn: [23.6, 24.0], lit: 24.1,
+ bellRise: 26.4, badge3: 26.5, bellFly: [28.3, 29.0], taps: [29.05, 29.3], banner: 30.6, ring: 33.5, bellGone: 35.0,
+ notif: 35.2, fetch: [36.2, 37.3], drawerOut2: [37.3, 37.6], hopsB: [[37.65, 38.15], [38.25, 38.75], [38.85, 39.45]],
+ weak: 40.2, blur: 40.3, intoBubble: [42.85, 43.2], sharp: 43.3,
+ routeLit: [46.2, 47.8], tag300: VO[12].t1 - 1.7, album: VO[13].t0 + .2, tag42: VO[13].t0 + .86, finale: CREDIT_T,
+};
+// every Chinese glyph the page draws (font subset + loading)
+export const GLYPHS = '叮之前你给朋友发了张猫的一声对面马上就收到可这照片并没有直接飞过去按下送那刻第步是压小原图太大传得慢软件会先把它悄悄缩体积看着却差不多接来二站服务器也聊天云端中转存放在儿等取三才轮通知拍手机嘿有找时候响后真正回所以网瞬间变清楚背其实场无接力只版而一直都里小林相册新输入消息干嘛早给看我家刚拍';
+
+// ── the desk ──
+export const MAT = [3.0, 1.8];
+export const CARDS = {
+ phoneA: { c: V(-.95, 0, .12), w: .30, h: .56, yaw: .05 },
+ compress: { c: V(-.38, 0, -.36), w: .46, h: .32, yaw: -.04 },
+ phoneB: { c: V(.88, 0, .12), w: .30, h: .56, yaw: -.05 },
+};
+export const at = (n, u, v, y = TOP) => { const d = CARDS[n]; return V(u / 1000 - d.w / 2, y, v / 1000 - d.h / 2).applyAxisAngle(YAX, d.yaw).add(d.c); };
+const onPaper = p => V(p.x, 0, p.z);
+const SERVER = { c: V(.22, 0, -.42), yaw: .08, w: .32, d: .24, slab: .05, step: .056 };
+const SRV_TOP = 4 * SERVER.step - .006;
+const srvAt = (x, y, z) => V(x, y, z).applyAxisAngle(YAX, SERVER.yaw).add(SERVER.c);
+
+// ── pixel art: the cat photo (16×16 with a white border) and its compressed copy (2×2 blocks → 8×8), the bell ──
+const CAT = [
+ 'WWWWWWWWWWWWWWWW', 'WBBBBBBBBBBBBBBW', 'WBBOBBBBBBBBOBBW', 'WBBOOBBBBBBOOBBW', 'WBBOOOOOOOOOOBBW', 'WBOOOOOOOOOOOOBW',
+ 'WBOOKKOOOOKKOOBW', 'WBOOKKOOOOKKOOBW', 'WBOOOOOPPOOOOOBW', 'WBOOMMMMMMMMOOBW', 'WBBOOMMMMMMOOBBW', 'WBBBOOOOOOOOBBBW',
+ 'WGGGGOOOOOOGGGGW', 'WGGGGGGGGGGGGGGW', 'WWWWWWWWWWWWWWWW', 'WWWWWWWWWWWWWWWW'];
+const PAL = { W: '#fbfcff', B: '#bcd3f2', O: '#f0913a', K: '#0d0d0d', P: '#f2a3b3', M: '#fff3e2', G: '#8cc77a' };
+const SMALL = []; for (let j = 0; j < 16; j += 2) { let r = ''; for (let i = 0; i < 16; i += 2) { const b = [CAT[j][i], CAT[j][i + 1], CAT[j + 1][i], CAT[j + 1][i + 1]]; if (b.includes('K')) r += 'K'; else { const n = {}; b.forEach(c => n[c] = (n[c] || 0) + 1); r += Object.entries(n).sort((a, b) => b[1] - a[1])[0][0]; } } SMALL.push(r); }
+const toArt = (rows, pal) => { const cells = []; rows.forEach((r, j) => [...r].forEach((ch, i) => { if (ch !== '.') cells.push([i, j, pal[ch]]); })); return { w: rows[0].length, h: rows.length, cells }; };
+const BELL = ['....y....', '...YYY...', '..YYYYY..', '..YYYYY..', '.YYYYYYY.', '.YYYYYYY.', 'YYYYYYYYY', '....D....'];
+const CROSS = ['G...G', '.G.G.', '..G..', '.G.G.', 'G...G'];
+// print a pixel grid onto a canvas (optionally blurred)
+function pix(c, rows, x, y, s, blur = 0) { c.save(); if (blur) c.filter = `blur(${blur}px)`; rows.forEach((r, j) => [...r].forEach((ch, i) => { c.fillStyle = PAL[ch]; c.fillRect(x + i * s, y + j * s, s + .6, s + .6); })); c.restore(); }
+
+// ── phone screens (300 × 560 canvas px; the top of the screen points away from the camera) ──
+function phone(c, st, me) {
+ const w = 300, h = 560, other = me === 'A' ? '小林' : '你';
+ c.clearRect(0, 0, w, h);
+ c.fillStyle = C.ink; K.rr(c, 0, 0, w, h, 36); c.fill();
+ c.fillStyle = '#f6f8fc'; K.rr(c, 11, 11, w - 22, h - 22, 27); c.fill();
+ c.fillStyle = C.ink; K.rr(c, w / 2 - 36, 20, 72, 14, 7); c.fill();
+ // status bar: time, signal, battery
+ K.txt(c, '08:30', 30, 30, { size: 17, wt: 600 });
+ const bars = st.weak ? 1 : 4; for (let i = 0; i < 4; i++) { c.fillStyle = i < bars ? (st.weak ? C.red : C.ink) : '#c9cfdb'; c.fillRect(214 + i * 7, 36 - (i + 1) * 4, 5, (i + 1) * 4); }
+ c.strokeStyle = C.ink; c.lineWidth = 2; K.rr(c, 246, 24, 26, 13, 3); c.stroke(); c.fillStyle = C.ink; c.fillRect(249, 27, 18, 7);
+ if (st.album) {
+ K.txt(c, '相册', 30, 78, { size: 28, wt: 800, font: K.CJK });
+ pix(c, CAT, 30, 108, 15);
+ for (let i = 0; i < 3; i++) { c.fillStyle = ['#dfe6f2', '#efe3d2', '#dbe9dd'][i]; K.rr(c, 30 + i * 82, 368, 74, 74, 8); c.fill(); }
+ for (let i = 0; i < 3; i++) { c.fillStyle = ['#e9e3f0', '#dfeaf2', '#f1e6dc'][i]; K.rr(c, 30 + i * 82, 450, 74, 74, 8); c.fill(); }
+ return;
+ }
+ // header: back arrow, avatar, name
+ K.txt(c, '‹', 26, 76, { size: 34, wt: 600, col: C.accent });
+ c.fillStyle = me === 'A' ? '#f2c14e' : '#7aa2ff'; c.beginPath(); c.arc(70, 76, 17, 0, 7); c.fill();
+ K.txt(c, other, 98, 77, { size: 26, wt: 800, font: K.CJK });
+ c.fillStyle = C.line; c.fillRect(20, 104, w - 40, 2);
+ // bubbles: an earlier exchange, then the photo
+ const bub = (txt, mine, y) => { c.font = `700 22px ${K.CJK}`; const tw = c.measureText(txt).width + 28; const x = mine ? w - 24 - tw : 24; c.fillStyle = mine ? C.accent : '#e5e9f2'; K.rr(c, x, y, tw, 42, 16); c.fill(); K.txt(c, txt, x + 14, y + 22, { size: 22, wt: 700, font: K.CJK, col: mine ? '#fff' : C.ink }); };
+ bub('早,在干嘛?', me === 'B', 124);
+ bub('给你看我家猫', me === 'A', 178);
+ if (st.img) { // the photo bubble: mine on the right (A), theirs on the left (B)
+ const mine = me === 'A', s = mine ? 8.5 : 17, rows = mine ? CAT : SMALL, size = rows.length * s, x = mine ? w - 30 - size : 30, y = 236;
+ c.fillStyle = mine ? C.accent : '#e5e9f2'; K.rr(c, x - 8, y - 8, size + 16, size + 16, 16); c.fill();
+ if (st.img === 'loading') { c.fillStyle = '#d3d9e6'; c.fillRect(x, y, size, size); c.strokeStyle = C.accent; c.lineWidth = 6; c.beginPath(); c.arc(x + size / 2, y + size / 2, 22, -1.57, -1.57 + 6.28 * (st.load || 0)); c.stroke(); }
+ else pix(c, rows, x, y, s, st.img === 'blur' ? 9 : 0);
+ }
+ // input bar (with the photo attached before it is sent, on A)
+ c.fillStyle = '#e9edf5'; K.rr(c, 22, h - 84, w - 112, 50, 25); c.fill();
+ if (st.attach) pix(c, CAT, 32, h - 78, 2.4); else K.txt(c, '输入消息', 42, h - 58, { size: 20, wt: 600, font: K.CJK, col: '#98a1b3' });
+ c.fillStyle = st.press ? '#1d3fcc' : C.accent; K.rr(c, w - 82, h - 84, 60, 50, 25); c.fill();
+ K.txt(c, '发送', w - 52, h - 58, { size: 20, wt: 800, font: K.CJK, col: '#fff', align: 'center' });
+ // notification banner over the top of the screen
+ if (st.banner > 0) {
+ const y = -70 + 104 * st.banner;
+ c.fillStyle = 'rgba(23,28,46,.94)'; K.rr(c, 18, y, w - 36, 80, 18); c.fill();
+ c.fillStyle = C.accent; K.rr(c, 32, y + 16, 48, 48, 12); c.fill(); K.txt(c, '✓', 56, y + 41, { size: 26, wt: 800, col: '#fff', align: 'center' });
+ K.txt(c, '你', 94, y + 27, { size: 22, wt: 800, font: K.CJK, col: '#fff' }); K.txt(c, '新照片', 94, y + 57, { size: 22, wt: 700, font: K.CJK, col: '#c8d2ea' });
+ }
+}
+
+function drawCompress(c, st) {
+ K.cardBase(c, 460, 320, 'shrink', '压小', { headH: 92 });
+ pix(c, CAT, 34, 116, 7); // the original, printed
+ K.txt(c, '原图', 34, 248, { size: 22, wt: 800, font: K.CJK }); K.txt(c, '4.2 MB', 34, 284, { size: 26, wt: 600 });
+ K.txt(c, '→', 200, 170, { size: 40, wt: 600, col: C.mute, align: 'center' });
+ if (st.cmp) K.txt(c, '≈', 200, 214, { size: 34, wt: 600, col: C.accent, align: 'center' });
+ c.save(); c.setLineDash([8, 7]); c.strokeStyle = '#c2c9d8'; c.lineWidth = 2.5; K.rr(c, 252, 108, 176, 128, 14); c.stroke(); c.restore();
+ K.txt(c, '压缩后', 252, 248, { size: 22, wt: 800, font: K.CJK, col: C.accent });
+ if (st.kb) K.txt(c, st.kb, 252, 284, { size: 26, wt: 600, col: C.accent });
+}
+
+export function build(ctx) {
+ const { world, ev } = ctx, scene = world.scene;
+ ctx.fx = { flash: 0 };
+ const mat = (col, r = .5, extra = {}) => new THREE.MeshStandardMaterial({ color: col, roughness: r, ...extra });
+
+ // cards
+ const cv = {}, cd = {}, state = {};
+ // canvases at 3.4× so screen and card text stays crisp in full-frame close-ups
+ const mk = (n, draw, init, thick) => { const d = CARDS[n], [c, x] = K.canvas(d.w * 1000, d.h * 1000, 3.4); cv[n] = x; draw(x, init); state[n] = JSON.stringify(init); const g = card(world, c, d.w, d.h, thick); g.position.copy(d.c); g.rotation.y = d.yaw; scene.add(g); cd[n] = g; };
+ const re = (n, draw, st) => { const k = JSON.stringify(st); if (k === state[n]) return; state[n] = k; draw(cv[n], st); cd[n].userData.redraw(); };
+ const drawA = (c, st) => phone(c, st, 'A'), drawB = (c, st) => phone(c, st, 'B');
+ mk('phoneA', drawA, { attach: 1 }, .009); mk('phoneB', drawB, {}, .009); mk('compress', drawCompress, {});
+ const PH = .009;
+
+ // name plates on the paper below each phone
+ const plates = []; // shown only in the wide shots (close shots would crop them at the frame edge)
+ const plate = (zh, en, p, yaw) => { const [c, x] = K.canvas(300, 84, 2); K.txt(x, zh, 4, 28, { size: 30, wt: 800, font: K.CJK }); K.txt(x, en, 6, 66, { size: 18, wt: 600, col: C.mute, ls: 3 });
+ const m = new THREE.Mesh(new THREE.PlaneGeometry(.3, .084), new THREE.MeshStandardMaterial({ map: world.tex(c), transparent: true, roughness: .9 })); m.rotation.set(-Math.PI / 2, 0, yaw); m.position.copy(p); m.position.y = .0004; scene.add(m); plates.push(m); };
+ plate('你的手机', 'YOUR PHONE', at('phoneA', 150, 640, 0), -CARDS.phoneA.yaw);
+ plate('小林的手机', "XIAOLIN'S PHONE", at('phoneB', 150, 640, 0), -CARDS.phoneB.yaw);
+
+ // the server: four slabs with windows, a drawer in the second slab, a printed top
+ const srv = new THREE.Group(); srv.position.copy(SERVER.c); srv.rotation.y = SERVER.yaw; scene.add(srv);
+ const win = [];
+ for (let k = 0; k < 4; k++) {
+ const y = SERVER.slab / 2 + k * SERVER.step;
+ const slab = new THREE.Mesh(rbox(SERVER.w, SERVER.slab, SERVER.d, .008), mat(C.card, .7)); slab.position.y = y; slab.castShadow = slab.receiveShadow = true; srv.add(slab);
+ const [c, x] = K.canvas(320, 50, 2), tex = world.tex(c);
+ const face = new THREE.Mesh(new THREE.PlaneGeometry(SERVER.w, SERVER.slab), new THREE.MeshStandardMaterial({ map: tex, transparent: true, roughness: .6, emissive: 0xffffff, emissiveMap: tex, emissiveIntensity: 0 })); face.position.set(0, y, SERVER.d / 2 + .0006); srv.add(face);
+ win.push({ x, tex, face, state: '' });
+ }
+ const drawer = new THREE.Group(); srv.add(drawer);
+ { const tray = new THREE.Mesh(rbox(.12, .036, .1, .004), mat('#dfe5f1', .6)); tray.position.y = SERVER.slab / 2 + SERVER.step; tray.castShadow = tray.receiveShadow = true; drawer.add(tray);
+ const front = new THREE.Mesh(rbox(.13, .042, .006, .003), mat(C.accent, .45)); front.position.set(0, SERVER.slab / 2 + SERVER.step, .05); front.castShadow = true; drawer.add(front); }
+ { const [c, x] = K.canvas(320, 240, 3.4); K.cardBase(x, 320, 240, 'server', '服务器', { headH: 92, tagSize: 20, cnSize: 30 }); K.txt(x, '云端中转站', 28, 160, { size: 34, wt: 800, font: K.CJK, col: C.accent });
+ const top = new THREE.Mesh(new THREE.PlaneGeometry(SERVER.w, SERVER.d), new THREE.MeshStandardMaterial({ map: world.tex(c), transparent: true, roughness: .8 })); top.rotation.x = -Math.PI / 2; top.position.y = 4 * SERVER.step - .0055; srv.add(top); }
+ const drawWin = (lit, phase) => win.forEach((w, k) => {
+ const key = lit + ':' + phase; if (w.state === key) return; w.state = key; w.x.clearRect(0, 0, 320, 50);
+ for (let i = 0; i < 8; i++) { const on = (i * 3 + k * 5 + phase) % 7 < 2; w.x.fillStyle = lit && k === 1 && i === 3 ? C.accent : on ? '#ffe7b0' : '#cfd6e6'; K.rr(w.x, 22 + i * 36, 16, 24, 18, 4); w.x.fill(); }
+ w.tex.needsUpdate = true; w.face.material.emissiveIntensity = .18;
+ });
+
+ // title tent card by your phone
+ const tent = new THREE.Group(); scene.add(tent);
+ const TENT = { w: .16, h: .058, lean: .2 };
+ { const [c, x] = K.canvas(640, 232, 1); x.fillStyle = C.card; x.fillRect(0, 0, 640, 232); K.grain(x, 640, 232, 9, 3000); x.fillStyle = C.accent; x.fillRect(0, 0, 16, 232);
+ K.txt(x, '叮之前', 56, 96, { size: 104, wt: 800, font: K.CJK, ls: 12 }); K.txt(x, 'BEFORE THE DING', 60, 184, { size: 38, wt: 600, col: C.accent, ls: 8 });
+ const face = new THREE.MeshStandardMaterial({ map: world.tex(c), roughness: .8 }), plain = new THREE.MeshStandardMaterial({ color: C.card, roughness: .85 });
+ const f = new THREE.Mesh(new THREE.BoxGeometry(TENT.w, TENT.h, .0012), [plain, plain, plain, plain, face, plain]), b = new THREE.Mesh(new THREE.BoxGeometry(TENT.w, TENT.h, .0012), plain);
+ const dz = Math.sin(TENT.lean) * TENT.h / 2, hy = Math.cos(TENT.lean) * TENT.h / 2;
+ f.position.set(0, hy, dz); f.rotation.x = -TENT.lean; b.position.set(0, hy, -dz); b.rotation.x = TENT.lean; f.castShadow = b.castShadow = f.receiveShadow = true; tent.add(f, b);
+ tent.position.set(-.62, 0, .34); tent.rotation.y = .3; }
+
+ // desk props (background / foreground layers): a pen, a sticky-note pad, a mug, earbuds, a paper clip
+ {
+ const pen = new THREE.Group(); const body = new THREE.Mesh(new THREE.CylinderGeometry(.0065, .0065, .15, 20), mat('#2a3042', .35)); body.rotation.z = Math.PI / 2; pen.add(body);
+ const tip = new THREE.Mesh(new THREE.ConeGeometry(.0065, .02, 20), mat('#c9ccd4', .3, { metalness: .6 })); tip.rotation.z = -Math.PI / 2; tip.position.x = .085; pen.add(tip);
+ const clip = new THREE.Mesh(rbox(.05, .002, .004, .001), mat('#c9ccd4', .3, { metalness: .6 })); clip.position.set(-.04, .007, 0); pen.add(clip);
+ pen.position.set(-1.32, .0065, .5); pen.rotation.y = .7; pen.traverse(o => o.castShadow = true); scene.add(pen);
+ for (let i = 0; i < 4; i++) { const n = new THREE.Mesh(rbox(.11, .0016, .11, .002), mat(i === 3 ? '#f4d27a' : '#f2c14e', .85)); n.position.set(-.86, .0008 + i * .0016, -.66); n.rotation.y = .25 + i * .03; n.castShadow = n.receiveShadow = true; scene.add(n); }
+ const mug = new THREE.Group(); const cup = new THREE.Mesh(new THREE.CylinderGeometry(.052, .048, .1, 40, 1, true), mat('#f3efe7', .45, { side: THREE.DoubleSide })); cup.position.y = .05; mug.add(cup);
+ const bottom = new THREE.Mesh(new THREE.CircleGeometry(.048, 40), mat('#f3efe7', .45)); bottom.rotation.x = -Math.PI / 2; bottom.position.y = .002; mug.add(bottom);
+ const coffee = new THREE.Mesh(new THREE.CircleGeometry(.049, 40), mat('#6b4a32', .25)); coffee.rotation.x = -Math.PI / 2; coffee.position.y = .085; mug.add(coffee);
+ const handle = new THREE.Mesh(new THREE.TorusGeometry(.026, .007, 12, 24, Math.PI), mat('#f3efe7', .45)); handle.rotation.z = -Math.PI / 2; handle.position.set(.052, .05, 0); mug.add(handle);
+ mug.position.set(.72, 0, -.7); mug.rotation.y = 2.4; mug.traverse(o => o.castShadow = o.receiveShadow = true); scene.add(mug);
+ const bud = x => { const g = new THREE.Group(); const head = new THREE.Mesh(new THREE.SphereGeometry(.012, 20, 14), mat('#fbfbfb', .3)); head.scale.set(1, .8, 1); head.position.y = .01; g.add(head);
+ const stem = new THREE.Mesh(new THREE.CapsuleGeometry(.0045, .03, 6, 12), mat('#fbfbfb', .3)); stem.rotation.z = Math.PI / 2; stem.position.set(.022, .006, 0); g.add(stem); g.position.copy(x); g.traverse(o => o.castShadow = true); scene.add(g); return g; };
+ const b1 = bud(V(1.18, 0, .52)), b2 = bud(V(1.25, 0, .6)); b1.rotation.y = .6; b2.rotation.y = 2.2;
+ const wire = new THREE.CatmullRomCurve3([V(1.2, .004, .52), V(1.28, .003, .45), V(1.36, .003, .52), V(1.3, .003, .64), V(1.24, .004, .6)]);
+ const wm = new THREE.Mesh(new THREE.TubeGeometry(wire, 60, .0018, 6), mat('#fbfbfb', .35)); wm.castShadow = true; scene.add(wm);
+ const er = new THREE.Mesh(rbox(.05, .014, .022, .004), mat('#f0a7b3', .7)); er.position.set(.6, .007, .66); er.rotation.y = .5; er.castShadow = true; scene.add(er); // an eraser
+ }
+
+ // soft window light on the desk (warm, additive, under the cards)
+ { const [c, x] = K.canvas(512, 512, 1); x.filter = 'blur(26px)'; x.fillStyle = 'rgba(255,236,205,1)';
+ for (const [a, b] of [[60, 60], [270, 60], [60, 270], [270, 270]]) x.fillRect(a, b, 180, 180); x.filter = 'none';
+ const lm = new THREE.MeshBasicMaterial({ map: world.tex(c), transparent: true, opacity: .2, blending: THREE.AdditiveBlending, depthWrite: false, fog: false });
+ for (const [px, pz, s, r] of [[-.15, .32, 1.1, .5], [1.05, -.45, .8, .5]]) { const m = new THREE.Mesh(new THREE.PlaneGeometry(s, s * .8), lm); m.rotation.set(-Math.PI / 2, 0, r); m.position.set(px, .0003, pz); m.renderOrder = 1; scene.add(m); } }
+
+ // the route: cobalt dots through the stops; the straight line it does NOT take (grey, crossed out)
+ const ROUTE = [at('phoneA', 150, 40, 0), V(-.68, 0, -.2), at('compress', 230, 330, 0), at('compress', 460, 200, 0), V(-.02, 0, -.3), srvAt(-.1, 0, .14), srvAt(.1, 0, .14), V(.56, 0, -.2), at('phoneB', 150, 40, 0)];
+ const route = new THREE.CatmullRomCurve3(ROUTE.map(p => V(p.x, .0016, p.z)));
+ const NR = 110, rp = [...Array(NR)].map((_, k) => route.getPointAt((k + .5) / NR));
+ const under = (x, z, pad = .012) => Object.values(CARDS).some(d => { const q = V(x - d.c.x, 0, z - d.c.z).applyAxisAngle(YAX, -d.yaw); return Math.abs(q.x) < d.w / 2 + pad && Math.abs(q.z) < d.h / 2 + pad; })
+ || (() => { const q = V(x - SERVER.c.x, 0, z - SERVER.c.z).applyAxisAngle(YAX, -SERVER.yaw); return Math.abs(q.x) < SERVER.w / 2 + .01 && Math.abs(q.z) < SERVER.d / 2 + .01; })();
+ const routeIdx = rp.map((p, k) => under(p.x, p.z) ? -1 : k).filter(k => k >= 0);
+ const dotGeo = new THREE.CylinderGeometry(.0068, .0068, .0026, 18);
+ const routeMesh = new THREE.InstancedMesh(dotGeo, new THREE.MeshStandardMaterial({ color: C.accent, roughness: .45, emissive: C.accent, emissiveIntensity: 0 }), routeIdx.length); routeMesh.castShadow = true; scene.add(routeMesh);
+ const sA = at('phoneA', 300, 300, 0), sB = at('phoneB', 0, 300, 0);
+ const straight = new THREE.InstancedMesh(rbox(.032, .0022, .009, .002), mat('#aab2c3', .6), 26); scene.add(straight);
+ const grayX = makeMonster(toArt(CROSS, { G: '#8f98ad' }), .009, 'x', .6); scene.add(grayX.root);
+ const bellTrail = new THREE.InstancedMesh(new THREE.SphereGeometry(.0055, 12, 8), new THREE.MeshStandardMaterial({ color: C.mustard, roughness: .4, emissive: C.mustard, emissiveIntensity: .25 }), 30); scene.add(bellTrail);
+
+ // dot ripples around the impacts
+ const RIP = [{ t: T.ding0, x: CARDS.phoneB.c.x, z: CARDS.phoneB.c.z, amp: .012, speed: .7 }, { t: T.press, x: CARDS.compress.c.x, z: CARDS.compress.c.z, amp: .014, speed: .8 }, { t: T.ring, x: CARDS.phoneB.c.x, z: CARDS.phoneB.c.z, amp: .016, speed: .8 }];
+ // impact rings: a thin cobalt ring spreads over the paper from the phone (ding, ring) and the compress card (press)
+ const rings = RIP.map(r => { const m = new THREE.Mesh(new THREE.RingGeometry(.97, 1, 96), new THREE.MeshBasicMaterial({ color: C.accent, transparent: true, depthWrite: false, fog: false })); m.rotation.x = -Math.PI / 2; m.position.set(r.x, .0006, r.z); m.renderOrder = 2; scene.add(m); return { m, r }; });
+
+ // the press that shrinks the photo
+ const press = new THREE.Group(); scene.add(press);
+ { const plateM = new THREE.Mesh(rbox(.15, .03, .15, .008), mat(C.ink, .4)); plateM.castShadow = true; press.add(plateM);
+ const rod = new THREE.Mesh(new THREE.CylinderGeometry(.008, .008, .6, 16), mat('#aab2c3', .3, { metalness: .5 })); rod.position.y = .31; press.add(rod); }
+
+ // step badges (camera-facing pills): 1 压小, 2 服务器, 3 通知
+ const badges = [['1 压小', at('compress', 400, 60, .06), T.badge1], ['2 服务器', srvAt(.12, .3, 0), T.badge2], ['3 通知', srvAt(-.14, .36, .02), T.badge3]].map(([s, p, t0]) => { const m = pill(world, s, { h: .036, size: 44, font: K.SANS, wt: 800 }); m.renderOrder = 3; return { m, p, t0 }; });
+ const slow = pill(world, '网慢', { h: .03, size: 40, bg: C.ink, font: K.SANS, wt: 800 });
+ const tag300 = pill(world, '300 KB', { h: .03, size: 40, bg: C.accent }), tag42 = pill(world, '4.2 MB', { h: .03, size: 40, bg: C.ink });
+
+ // cast
+ const catBig = makeMonster(toArt(CAT, PAL), .0062, 'cat', .9), catSmall = makeMonster(toArt(SMALL, PAL), .0074, 'cat8', .9), bell = makeMonster(toArt(BELL, { Y: C.mustard, y: '#e0a93a', D: '#a8744a' }), .0068, 'bell');
+ for (const m of [catBig, catSmall, bell]) scene.add(m.root);
+
+ // places
+ const PL = {
+ catA: at('phoneA', 150, 330, PH), catCmp: at('compress', 340, 205, TOP), catCmpBig: at('compress', 250, 205, TOP),
+ srvTop: srvAt(.11, SRV_TOP, -.095), drawerIn: srvAt(0, SERVER.slab / 2 + SERVER.step + .018, 0), drawerOut: srvAt(0, SERVER.slab / 2 + SERVER.step + .018, .13),
+ bellUp: srvAt(-.06, SRV_TOP + .1, .02), bellB: at('phoneB', 150, 60, PH + .05), waitB: at('phoneB', 252, 335, PH), bubbleB: at('phoneB', 98, 302, PH),
+ };
+ const srvHop = [PL.catCmp, V(-.08, 0, -.32), V(.06, 0, -.24), PL.srvTop];
+ const backHop = [PL.drawerOut.clone().setY(0), V(.47, 0, -.18), V(.66, 0, -.04), PL.waitB];
+ const catSmallHops = [
+ ...T.hopsS.map(([a, b], i) => ({ t0: a, t1: b, from: srvHop[i], to: srvHop[i + 1], h: i === 2 ? .3 : .07 })),
+ { t0: T.catIn[0], t1: T.catIn[1], from: PL.srvTop, to: PL.drawerOut, h: .06 },
+ ...T.hopsB.map(([a, b], i) => ({ t0: a, t1: b, from: i ? backHop[i] : PL.drawerOut, to: backHop[i + 1], h: i ? .07 : .09 })),
+ { t0: T.intoBubble[0], t1: T.intoBubble[1], from: PL.waitB, to: PL.bubbleB, h: .06 },
+ ];
+
+ // ── text in the world meant to be read: [id, text, t0, t1, corners()] ──
+ const uv = (n, u0, v0, u1, v1, y = TOP) => () => [at(n, u0, v0, y), at(n, u1, v0, y), at(n, u0, v1, y), at(n, u1, v1, y)];
+ const tentBox = (y0, y1) => () => { const f = tent.children[0]; f.updateMatrixWorld(); return [[-.5, y0], [.5, y0], [-.5, y1], [.5, y1]].map(([x, y]) => V(x * TENT.w, (.5 - y) * TENT.h, .0007).applyMatrix4(f.matrixWorld)); };
+ const pillBox = m => () => { m.updateMatrixWorld(); const hw = m.w / 2, hh = m.geometry.parameters.height / 2; return [[-hw, -hh], [hw, -hh], [-hw, hh], [hw, hh]].map(([x, y]) => V(x, y, 0).applyMatrix4(m.matrixWorld)); };
+ ctx.read = [
+ ['title-zh', '叮之前', 0, 4.4, tentBox(.12, .58)],
+ ['title-en', 'BEFORE THE DING', 0, 4.4, tentBox(.66, .9)],
+ ['orig', '原图 4.2 MB', T.counter[1], 17.2, uv('compress', 30, 232, 160, 300, PH)],
+ ['comp', '压缩后 300 KB', T.counter[1], 17.2, uv('compress', 250, 232, 380, 300, PH)],
+ ['srv', '服务器 云端中转站', 20.3, 26.0, () => [srvAt(-.15, SRV_TOP, -.1), srvAt(.15, SRV_TOP, -.1), srvAt(-.15, SRV_TOP, .08), srvAt(.15, SRV_TOP, .08)]],
+ ['banner', '你 新照片', T.banner + .3, T.notif + .5, uv('phoneB', 18, 34, 282, 114, PH)],
+ ['slow', '网慢', T.weak + .2, T.sharp, pillBox(slow)],
+ ['t300', '300 KB', T.tag300 + .2, VO[13].t0 + .05, pillBox(tag300)],
+ ['t42', '4.2 MB', T.tag42 + .2, CREDIT_T - .14, pillBox(tag42)],
+ ];
+
+ // ── sound events ──
+ ev.push({ t: T.catPop, type: 'pop', k: 0, big: 1 }, { t: T.send, type: 'send' }, { t: T.ding0, type: 'ding' }, { t: T.rewind, type: 'rewind' },
+ ...[0, 1, 2, 3, 4, 5].map(i => ({ t: T.straight[0] + i * .125, type: 'dash', k: i })), { t: T.cross, type: 'nope' },
+ ...[...Array(10)].map((_, i) => ({ t: T.route[0] + i * .125, type: 'dot', k: i })),
+ { t: T.jump1[0], type: 'jump' }, { t: T.jump1[1], type: 'land', v: .7 }, { t: T.badge1, type: 'badge', k: 0 },
+ { t: T.press - .25, type: 'drop' }, { t: T.press, type: 'press' }, { t: T.press + .3, type: 'pop', k: 2 },
+ ...[...Array(8)].map((_, i) => ({ t: T.counter[0] + i * .45, type: 'tickdown', k: i })), { t: T.compare, type: 'badge', k: 1 },
+ ...T.hopsS.flatMap(([a, b], i) => [{ t: a, type: i === 2 ? 'jump' : 'hop' }, { t: b, type: 'land', v: i === 2 ? .7 : .4 }]), { t: T.badge2, type: 'badge', k: 1 },
+ { t: T.drawerOut, type: 'drawer' }, { t: T.catIn[1], type: 'land', v: .35 }, { t: T.drawerIn[0], type: 'drawer' }, { t: T.lit, type: 'lit' },
+ { t: T.bellRise, type: 'pop', k: 4 }, { t: T.badge3, type: 'badge', k: 2 }, { t: T.bellFly[0], type: 'fly' }, ...T.taps.map(t => ({ t, type: 'tap' })), { t: T.banner, type: 'banner' },
+ { t: T.ring, type: 'ring' }, { t: T.notif, type: 'badge', k: 3 }, { t: T.fetch[0], type: 'fetch' }, { t: T.drawerOut2[0], type: 'drawer' },
+ ...T.hopsB.flatMap(([a, b]) => [{ t: a, type: 'hop' }, { t: b, type: 'land', v: .4 }]), { t: T.weak, type: 'weak' },
+ { t: T.intoBubble[0], type: 'hop' }, { t: T.sharp, type: 'sharp' },
+ ...[...Array(8)].map((_, i) => ({ t: T.routeLit[0] + i * .2, type: 'dot', k: i })), { t: T.tag300, type: 'badge', k: 1 }, { t: T.tag42, type: 'badge', k: 0 }, { t: END.credit, type: 'credit' });
+
+ // subjects for the camera
+ const mid = (m, k = .5) => () => m.root.position.clone().add(V(0, m.height * k, 0));
+ Object.assign(ctx.subj, {
+ A: () => at('phoneA', 150, 300, .02), Atent: () => at('phoneA', 230, 330, .03).lerp(tent.position.clone().setY(.03), .35), Aup: () => at('phoneA', 150, 200, .02), Aalbum: () => at('phoneA', 150, 250, .02),
+ B: () => at('phoneB', 150, 300, .02), Btop: () => at('phoneB', 150, 215, .02), Bbubble: () => at('phoneB', 120, 290, .02),
+ cmp: () => at('compress', 230, 190, .02), cmpWide: () => at('compress', 230, 170, .02), srv: () => srvAt(0, .12, 0), srvTop: () => srvAt(0, .2, 0),
+ cat: () => (catBig.root.visible ? catBig : catSmall).root.position.clone().add(V(0, .03, 0)), bell: mid(bell), wide: () => V(-.04, 0, .02), wide2: () => V(-.12, 0, .02), final: () => V(-.04, 0, .0),
+ leg2: () => V(.5, 0, -.02),
+ });
+
+ ev.push(...[...Array(7)].map((_, k) => ({ t: 22.9 + k * .18, type: 'dot', k })), ...[0, 1, 2, 3].map(k => ({ t: T.finale + .55 + k * .14 + .45, type: 'land', v: .35 })),
+ { t: T.finale + .55 + .7, type: 'pop', k: 0 }, { t: T.finale + .55 + .82, type: 'pop', k: 2 }, { t: T.finale + .55 + .3, type: 'drop' }, { t: T.finale + .55 + .55, type: 'titleLand' });
+ // ── more life at every stop ──
+ // pixels squeezed out by the press: 28 little cubes in the photo's colours burst out and roll away (the data that compression throws away)
+ const DEB = [...Array(28)].map((_, k) => { const a = k / 28 * Math.PI * 2 + hash(k) * .4, sp = .18 + hash(k * 3.1) * .22; return { dir: V(Math.cos(a), 0, Math.sin(a) * .7), sp, up: .35 + hash(k * 7.7) * .45, col: Object.values(PAL)[k % 7] }; });
+ const debris = new THREE.InstancedMesh(rbox(.0062, .0062, .0062, .0012), new THREE.MeshStandardMaterial({ roughness: .5 }), DEB.length); debris.castShadow = true; scene.add(debris);
+ DEB.forEach((d, k) => debris.setColorAt(k, new THREE.Color(d.col)));
+ // data packets: little cobalt cubes hop into the server while the photo is stored, and run along the route to B during the fetch
+ const PK = 14, packets = new THREE.InstancedMesh(rbox(.02, .02, .02, .004), new THREE.MeshStandardMaterial({ color: C.mustard, roughness: .4, emissive: C.mustard, emissiveIntensity: .2 }), PK); packets.castShadow = true; scene.add(packets);
+ // an antenna on the server with a blinking light
+ const ant = new THREE.Group(); srv.add(ant);
+ { const rod = new THREE.Mesh(new THREE.CylinderGeometry(.0025, .0025, .07, 10), mat('#aab2c3', .3, { metalness: .5 })); rod.position.set(.12, 4 * SERVER.step + .035, -.08); ant.add(rod);
+ const lamp = new THREE.Mesh(new THREE.SphereGeometry(.008, 16, 12), new THREE.MeshStandardMaterial({ color: C.accent, emissive: C.accent, emissiveIntensity: 0 })); lamp.position.set(.12, 4 * SERVER.step + .072, -.08); ant.add(lamp); ant.userData.lamp = lamp; }
+ // vibration marks either side of B on the ring: short voxel arcs
+ const vib = [-1, 1].flatMap(sd => [0, 1].map(n => { const m = new THREE.Mesh(new THREE.TorusGeometry(.04 + n * .022, .0035, 8, 24, 1.2), mat(C.accent, .4)); m.rotation.set(-Math.PI / 2, 0, sd > 0 ? -.6 : Math.PI - .6); m.position.copy(at('phoneB', sd > 0 ? 330 : -30, 280, .01)); scene.add(m); return { m, sd, n }; }));
+ // the end: two cats come back for a bow, the original on your phone and the copy on the friend's
+ const bowBig = makeMonster(toArt(CAT, PAL), .0062, 'bowBig', .9), bowSmall = makeMonster(toArt(SMALL, PAL), .0074, 'bowSmall', .9); scene.add(bowBig.root, bowSmall.root);
+ const stations = [cd.phoneA, cd.compress, srv, cd.phoneB];
+ // the closing title: a big paper card in the empty middle of the desk (same print as the opening tent), dropped after the hops
+ const BIG = { w: .78, h: .34, c: V(-.03, 0, .33), yaw: .03 };
+ const bigTitle = new THREE.Group(); scene.add(bigTitle);
+ { const [c, x] = K.canvas(780, 340, 3); x.fillStyle = C.card; K.rr(x, 0, 0, 780, 340, 22); x.fill(); K.grain(x, 780, 340, 13, 6000);
+ x.fillStyle = C.accent; x.fillRect(0, 0, 20, 340);
+ K.txt(x, '叮之前', 64, 150, { size: 168, wt: 800, font: K.CJK, ls: 24 }); K.txt(x, 'BEFORE THE DING', 70, 276, { size: 50, wt: 600, col: C.accent, ls: 12 });
+ const g = card(world, c, BIG.w, BIG.h, .007); bigTitle.add(g); bigTitle.position.copy(BIG.c); bigTitle.rotation.y = BIG.yaw; }
+ const bigAt = (u, v, y = .0075) => V(u / 1000 - BIG.w / 2, y, v / 1000 - BIG.h / 2).applyAxisAngle(YAX, BIG.yaw).add(BIG.c);
+ ctx.read.push(['big-zh', '叮之前', END.credit - .1, VDUR + 1, () => [bigAt(60, 64), bigAt(600, 64), bigAt(60, 236), bigAt(600, 236)]],
+ ['big-en', 'BEFORE THE DING', END.credit - .1, VDUR + 1, () => [bigAt(66, 250), bigAt(700, 250), bigAt(66, 302), bigAt(700, 302)]]);
+
+ // ── per frame ──
+ const m4 = new THREE.Matrix4(), q = new THREE.Quaternion();
+ return t => {
+ // phone A: compose with the photo attached → sent (bubble) → album at the end
+ const pressA = t > T.send - .05 && t < T.send + .2;
+ re('phoneA', drawA, t >= T.album ? { album: 1 } : { attach: t < T.send + .1 ? 1 : 0, press: pressA ? 1 : 0, img: t >= T.send + .15 ? 'sharp' : 0 });
+ // phone B: the instant the viewer imagines (2.3–5.3), rewound; then banner, loading, blurry, sharp
+ let bs = {};
+ if (t >= T.ding0 && t < T.rewind) bs = { banner: Math.min(1, eo(seg(t, T.ding0, T.ding0 + .25))), img: 'sharp' };
+ else if (t >= T.rewind && t < T.rewind + .3) bs = { banner: 1 - seg(t, T.rewind, T.rewind + .3) };
+ else if (t >= T.banner) {
+ const banner = t < T.notif + .8 ? Math.min(1, eo(seg(t, T.banner, T.banner + .25))) * (1 - seg(t, T.notif + .5, T.notif + .8)) : 0;
+ const img = t < T.fetch[0] ? 0 : t < T.blur ? 'loading' : t < T.sharp ? 'blur' : 'sharp';
+ bs = { banner: Math.round(banner * 12) / 12, img, load: Math.round(seg(t, T.fetch[0], T.blur + 2.6) * 16) / 16 * .7, weak: t >= T.weak && t < T.sharp + .4 ? 1 : 0 };
+ }
+ re('phoneB', drawB, bs);
+ re('compress', drawCompress, { kb: t < T.press + .4 ? '' : (() => { const p = eo(seg(t, T.counter[0], T.counter[1])); const kb = Math.round((4200 - 3900 * p) / 50) * 50; return kb >= 1000 ? (kb / 1000).toFixed(1) + ' MB' : kb + ' KB'; })(), cmp: t >= T.compare ? 1 : 0 });
+
+ // tent; name plates in the wide shots only
+ tent.visible = true;
+ { const a = Math.max(seg(t, 4.9, 5.4) * (1 - seg(t, 7.5, 7.8)), seg(t, 45.4, 45.9) * (1 - seg(t, 48.4, 48.6)), seg(t, CREDIT_T + .3, CREDIT_T + .8)); plates.forEach(m => { m.visible = a > .01; m.material.opacity = a; }); }
+ // straight line + grey cross (4.9–7.8)
+ { const fade = 1 - ss(seg(t, ...T.straightOut));
+ for (let k = 0; k < 26; k++) { const p = sA.clone().lerp(sB, (k + .5) / 26), on = seg(t, T.straight[0] + k * .026, T.straight[0] + k * .026 + .1) * fade; q.setFromAxisAngle(YAX, -Math.atan2(sB.z - sA.z, sB.x - sA.x)); m4.compose(p.setY(.0012), q, V(1, 1, 1).multiplyScalar(Math.max(1e-4, on))); straight.setMatrixAt(k, m4); }
+ straight.instanceMatrix.needsUpdate = true;
+ const P0 = back(seg(t, T.cross, T.cross + .25), 2.2); grayX.set({ pos: sA.clone().lerp(sB, .5).setY(.002), hinge: 0, e: 1, scale: Math.max(.001, P0 * fade), vis: t >= T.cross && fade > .01 }); }
+ // route dots: drawn 6.0–7.2, lit in a wave at 46.2–47.8 and during the fetch (36.2–37.3, from B back to the server)
+ routeIdx.forEach((k, j) => {
+ const s = back(seg(t, T.route[0] + j / routeIdx.length * (T.route[1] - T.route[0]), T.route[0] + j / routeIdx.length * (T.route[1] - T.route[0]) + .15), 2);
+ m4.compose(rp[k], q.identity(), V(1, 1, 1).multiplyScalar(Math.max(1e-4, s))); routeMesh.setMatrixAt(j, m4);
+ });
+ routeMesh.instanceMatrix.needsUpdate = true;
+ routeMesh.material.emissiveIntensity = .5 * (Math.max(0, 1 - Math.abs(t - (T.fetch[0] + T.fetch[1]) / 2) / .9) + Math.max(0, 1 - Math.abs(t - (T.routeLit[0] + T.routeLit[1]) / 2) / 1.2));
+ // badges and tags
+ for (const b of badges) { const p = back(seg(t, b.t0, b.t0 + .25), 2.2); b.m.visible = t >= b.t0 && t < b.t0 + 3.4; b.m.scale.setScalar(Math.max(.001, p * (1 - ss(seg(t, b.t0 + 3.1, b.t0 + 3.4))))); b.m.position.copy(b.p); b.m.face(ctx.camera); }
+ { const p = back(seg(t, T.weak, T.weak + .25), 2.2); slow.visible = t >= T.weak && t < T.sharp + .3; slow.scale.setScalar(Math.max(.001, p * (1 - ss(seg(t, T.sharp, T.sharp + .3))))); slow.position.copy(at('phoneB', 236, 214, .03)); slow.face(ctx.camera); }
+ { const p = back(seg(t, T.tag300, T.tag300 + .25), 2.2); tag300.visible = t >= T.tag300 && t < VO[13].t0 + .2; tag300.scale.setScalar(Math.max(.001, p)); tag300.position.copy(at('phoneB', 232, 250, .03)); tag300.face(ctx.camera); }
+ { const p = back(seg(t, T.tag42, T.tag42 + .25), 2.2); tag42.visible = t >= T.tag42 && t < CREDIT_T - .04; tag42.scale.setScalar(Math.max(.001, p)); tag42.position.copy(at('phoneA', 222, 128, .03)); tag42.face(ctx.camera); }
+ // server: windows flicker on 8ths, the drawer slides
+ drawWin(t >= T.lit ? 1 : 0, Math.floor(t * 4) % 7);
+ { const out1 = ss(seg(t, T.drawerOut, T.drawerOut + .35)) * (1 - ss(seg(t, ...T.drawerIn))), out2 = ss(seg(t, ...T.drawerOut2)) * (1 - ss(seg(t, T.hopsB[0][1] + .1, T.hopsB[0][1] + .5)));
+ drawer.position.z = .13 * Math.max(out1, out2); }
+ // the press: drops on the big cat at T.press, lifts again
+ { const down = ei(seg(t, T.press - .25, T.press)), up = eo(seg(t, T.press + .25, T.press + .7));
+ press.visible = t > T.press - .6 && t < T.press + 1.0; press.position.copy(PL.catCmpBig).add(V(0, .055 + .5 * (1 - down) + .5 * up, 0)); }
+ // big cat: sticker on A's screen → pops → leaps to the compress card → squashed by the press → gone
+ {
+ const P0 = pop(t, T.catPop, .45, .05), send = t > T.send - .1 && t < T.send + .25 ? -.15 * Math.sin(Math.PI * seg(t, T.send - .1, T.send + .25)) : 0;
+ const h = hops(t, [{ t0: T.jump1[0], t1: T.jump1[1], from: PL.catA, to: PL.catCmpBig, h: .2 }], PL.catA);
+ const squashed = t > T.press - .02 ? 1 - .82 * eo(seg(t, T.press - .02, T.press + .06)) : 1;
+ const wait = t > T.catPop + .5 && t < T.jump1[0] ? beatBounce(t, T.catPop + .5, T.jump1[0] - .1, .012) : { y: 0, sq: 1 };
+ const pos = h.pos.clone(); pos.y += P0.y + wait.y;
+ catBig.set({ pos, vis: t < T.press + .12, e: P0.e, hinge: P0.hinge, sq: Math.max(.12, squash(t, h.lands, h.takeoffs, h.air) * P0.sq * wait.sq * (1 + send) * squashed), yaw: t > T.jump1[1] ? .15 : .1 });
+ }
+ // small cat: pops out of the press, hops to the server, into the drawer, back out, along the route to B, into the photo bubble
+ {
+ const P0 = pop(t, T.press + .3, .35, .05), h = hops(t, catSmallHops, PL.catCmp);
+ let pos = h.pos.clone(); pos.y += P0.y;
+ const inDrawer = t >= T.catIn[1] && t < T.hopsB[0][0];
+ if (inDrawer) pos = srvAt(0, SERVER.slab / 2 + SERVER.step + .018, drawer.position.z);
+ const hidden = inDrawer && drawer.position.z < .05;
+ const flat = ss(seg(t, T.intoBubble[1] - .05, T.intoBubble[1] + .1));
+ const idle = t > T.hopsB[2][1] && t < T.intoBubble[0] ? beatBounce(t, T.hopsB[2][1] + .1, T.intoBubble[0] - .05, .012) : t > T.press + .8 && t < T.hopsS[0][0] ? beatBounce(t, T.press + .8, T.hopsS[0][0] - .1, .01) : t > T.hopsS[2][1] + .2 && t < T.catIn[0] ? beatBounce(t, T.hopsS[2][1] + .2, T.catIn[0] - .05, .012) : { y: 0, sq: 1 };
+ pos.y += idle.y;
+ const dir = h.dir && h.air !== null ? clamp(Math.atan2(h.dir.x, h.dir.z) * .35, -.5, .5) : .1;
+ catSmall.set({ pos, vis: t >= T.press + .3 && !hidden && t < T.sharp + .05, e: Math.min(P0.e, 1 - .9 * flat), hinge: Math.min(P0.hinge, 1 - flat), sq: squash(t, h.lands, h.takeoffs, h.air) * P0.sq * idle.sq, yaw: dir });
+ }
+ // the bell: rises from the server, flies to B leaving a trail, taps twice, swings on the ring, leaves
+ {
+ const P0 = pop(t, T.bellRise, .4, .05);
+ let pos = PL.srvTop.clone().lerp(PL.bellUp, eo(seg(t, T.bellRise, T.bellRise + .5)));
+ pos.y += .008 * Math.sin(t * 6) * seg(t, T.bellRise + .5, T.bellFly[0]);
+ const f = seg(t, ...T.bellFly);
+ if (t >= T.bellFly[0]) { pos = PL.bellUp.clone().lerp(PL.bellB, eio(f)); pos.y += .22 * arc(f); }
+ for (const tp of T.taps) { const d = t - tp; if (d > 0 && d < .2) pos.y -= .03 * Math.sin(Math.PI * d / .2); }
+ if (t > T.bellFly[1]) pos.y += .006 * Math.sin(t * 5);
+ const swing = t > T.ring && t < T.ring + 1.2 ? .5 * Math.sin((t - T.ring) * 22) * Math.exp(-(t - T.ring) * 2.5) : 0;
+ const gone = ss(seg(t, T.bellGone, T.bellGone + .3));
+ bell.set({ pos, vis: t >= T.bellRise && gone < 1, e: P0.e, hinge: P0.hinge, sq: P0.sq, tiltZ: swing + (f > 0 && f < 1 ? .3 * Math.sin(f * Math.PI) : 0), scale: 1 - gone });
+ for (let k = 0; k < 30; k++) { const u = (k + .5) / 30, p = PL.bellUp.clone().lerp(PL.bellB, eio(u)); p.y += .22 * arc(u); const on = t >= T.bellFly[0] + u * .7 && t < T.ring + 1.0 ? 1 - ss(seg(t, T.ring + .6, T.ring + 1.0)) : 0; m4.compose(p, q.identity(), V(1, 1, 1).multiplyScalar(Math.max(1e-4, on * (.6 + .4 * u)))); bellTrail.setMatrixAt(k, m4); }
+ bellTrail.instanceMatrix.needsUpdate = true;
+ }
+ // phone B jolts on the ding and on the ring
+ { let j = 0; for (const tr of [T.ding0, T.ring]) { const d = t - tr; if (d > 0 && d < .3) j += .003 * Math.sin(d * 60) * (1 - d / .3); } cd.phoneB.position.x = CARDS.phoneB.c.x + j; }
+ // cats blink every couple of seconds (and squint under the press)
+ { const bl = (t % 2.3) < .12 || (t > T.press - .05 && t < T.press + .15); catBig.blink(bl); catSmall.blink((t + .7) % 2.1 < .12); }
+ // debris from the press
+ { const m4d = new THREE.Matrix4(), qd = new THREE.Quaternion();
+ DEB.forEach((d, k) => { const dt = t - T.press; if (dt < 0 || dt > 2.2) { m4d.compose(V(0, -1, 0), qd, V(1e-4, 1e-4, 1e-4)); debris.setMatrixAt(k, m4d); return; }
+ const fl = Math.min(dt, .5), p = PL.catCmpBig.clone().addScaledVector(d.dir, d.sp * fl + .05 * Math.max(0, dt - .5) * d.sp); p.y += .02 + d.up * fl - 1.6 * fl * fl; p.y = Math.max(TOP + .003, p.y);
+ qd.setFromEuler(new THREE.Euler(dt * 6 * hash(k), dt * 4, 0)); const sc = 1 - ss(seg(dt, 1.6, 2.2)); m4d.compose(p, qd, V(sc, sc, sc).addScalar(1e-4)); debris.setMatrixAt(k, m4d); });
+ debris.instanceMatrix.needsUpdate = true; }
+ // packets: hop into the server's windows (22.9–24.2), run along the route to B in the fetch (36.2–39.6)
+ { const m4p = new THREE.Matrix4(), qp = new THREE.Quaternion();
+ for (let k = 0; k < PK; k++) {
+ let p = null, s = 0;
+ const a0 = 22.9 + k * .09; if (t > a0 && t < a0 + .55) { const u = seg(t, a0, a0 + .45); p = srvAt(-.12 + (k % 7) * .04, .02 + arc(u) * .12 + u * (SERVER.slab / 2 + (k % 4) * SERVER.step - .02), .2 - u * .08); s = 1 - ss(seg(t, a0 + .4, a0 + .55)); }
+ const b0 = T.fetch[0] + k * .2; if (t > b0 && t < b0 + 2.6) { const u = seg(t, b0, b0 + 2.4), j = Math.floor((1 - u) * (routeIdx.length - 1)); p = rp[routeIdx[Math.max(0, j)]].clone(); p.y += .012 + .02 * Math.abs(Math.sin(u * 30)); s = Math.min(seg(t, b0, b0 + .1), 1 - seg(t, b0 + 2.4, b0 + 2.6)); }
+ m4p.compose(p || V(0, -1, 0), qp, V(1, 1, 1).multiplyScalar(Math.max(1e-4, p ? s : 0))); packets.setMatrixAt(k, m4p);
+ }
+ packets.instanceMatrix.needsUpdate = true; }
+ // antenna lamp blinks on the beat while the server holds the photo; vibration marks on the ring
+ ant.userData.lamp.material.emissiveIntensity = t > T.lit && Math.floor(t * 2) % 2 === 0 ? 1.2 : .1;
+ vib.forEach(({ m, sd, n }) => { const d = t - T.ring - n * .08; const on = d > 0 && d < .9; m.visible = on; if (on) { m.scale.setScalar(.8 + .5 * d); m.material.opacity = 1; m.position.copy(at('phoneB', sd > 0 ? 330 + d * 40 : -30 - d * 40, 280, .01)); } });
+ // the finale: every station hops once, left to right, then the two cats pop up and bow
+ { const F0 = T.finale + .55;
+ stations.forEach((g, k) => { const d = t - (F0 + k * .14); const y = d > 0 && d < .45 ? .03 * arc(d / .45) : 0; g.position.y = (g === srv ? 0 : 0) + y; });
+ const pb = pop(t, F0 + .7, .4, .06), ps = pop(t, F0 + .82, .4, .05), bb = beatBounce(t, F0 + 1.2, DUR, .012), bs = beatBounce(t, F0 + 1.2, DUR, .012, .25);
+ bowBig.set({ pos: at('phoneA', 150, 230, PH).add(V(0, pb.y + bb.y, 0)), vis: t >= F0 + .7, e: pb.e, hinge: pb.hinge, sq: pb.sq * bb.sq, yaw: .25 });
+ bowSmall.set({ pos: at('phoneB', 150, 300, PH).add(V(0, ps.y + bs.y, 0)), vis: t >= F0 + .82, e: ps.e, hinge: ps.hinge, sq: ps.sq * bs.sq, yaw: -.25 });
+ bowBig.blink((t + .3) % 1.9 < .12); bowSmall.blink((t + 1.1) % 1.7 < .12);
+ // the big title drops from above, squashes a little and settles; the small opening tent folds away as it lands
+ const td = F0 + .3, land = td + .25, p = seg(t, td, land), d = t - land;
+ bigTitle.visible = t >= td; bigTitle.position.y = (1 - ei(p)) * .6 + (d > 0 && d < .35 ? .012 * Math.sin(Math.PI * d / .35) * (1 - d / .35) : 0);
+ const sq = d > 0 && d < .2 ? 1 - .25 * Math.sin(Math.PI * d / .2) : 1; bigTitle.scale.set(1 / Math.sqrt(sq), sq, 1 / Math.sqrt(sq));
+ tent.scale.setScalar(Math.max(.001, 1 - ss(seg(t, land, land + .3))));
+ if (t > F0 - .2) routeMesh.material.emissiveIntensity = Math.max(routeMesh.material.emissiveIntensity, .45 * (1 - Math.abs(t - F0 - .5) / 1.0)); }
+ rings.forEach(({ m, r }) => { const d = t - r.t, on = d > 0 && d < 1.1; m.visible = on; if (on) { const s = .2 + d * .55; m.scale.setScalar(s); m.material.opacity = .55 * (1 - d / 1.1); } });
+ };
+}
diff --git a/styles/desktop-flythrough/demo/src/main.js b/styles/desktop-flythrough/demo/src/main.js
new file mode 100644
index 0000000..dc2a500
--- /dev/null
+++ b/styles/desktop-flythrough/demo/src/main.js
@@ -0,0 +1,65 @@
+// Desktop Flythrough — 叮之前 / Before the Ding. One take over a dotted paper mat on an oak desk, with voice-over and subtitles. Page contract: render(t), DUR, EV, TEXTS.
+import * as THREE from 'three';
+import { makeWorld } from './world.js';
+import { makePost } from './post.js';
+import { makeRig } from './camera.js';
+import { makeSubs } from './captions.js';
+import { KEYS, SHAKES } from './shots.js';
+import * as F from './film.js';
+
+const FPS = 30, SHUTTER = .3; // light motion blur: only fast camera moves streak, and only a little
+const Q = new URLSearchParams(location.search);
+window.DUR = F.DUR;
+await Promise.all([document.fonts.load('500 20px PM'), document.fonts.load('600 20px PM'), document.fonts.load('700 40px IS'), document.fonts.load('600 40px IS'), document.fonts.load('700 40px SC', F.GLYPHS)]);
+
+const world = makeWorld({ mat: F.MAT, haze: '#e6e3e0' }), { renderer, scene, camera, sun, SUNDIR } = world;
+const ev = [];
+const ctx = { world, subj: {}, ev, camera };
+const update = F.build(ctx);
+const rig = makeRig(ctx, camera, KEYS, SHAKES);
+const caps = makeSubs(F.VO, F.END);
+const post = makePost(renderer, scene, camera, 1920, 1080);
+post.grade.uniforms.amt.value = .12; post.grade.uniforms.warm.value = .04; post.grade.uniforms.lift.value.set(0, 0, 0); post.grade.uniforms.contrast.value = .1; post.grade.uniforms.sat.value = 1.1;
+post.bloom.strength = .12; post.bloom.threshold = 1.1;
+
+function applyAt(t, jx, jy) {
+ update(t);
+ const { tg, d } = rig.apply(t, jx, jy);
+ sun.target.position.copy(tg); sun.position.copy(tg).addScaledVector(SUNDIR, 4);
+ const hs = Math.min(4, Math.max(.35, d * 1.1));
+ Object.assign(sun.shadow.camera, { left: -hs, right: hs, top: hs, bottom: -hs, near: .1, far: 10 }); sun.shadow.camera.updateProjectionMatrix();
+ const fp = tg.clone().applyMatrix4(camera.matrixWorldInverse); post.dof.focus = Math.max(.05, -fp.z) * 1.25; post.dof.aper = 2.0; post.dof.maxCoc = 5; // the focus plane sits a little behind the subject: subject and midground stay sharp, only the far background softens
+ renderer.toneMappingExposure = 1 + 1.6 * ctx.fx.flash;
+}
+const halton = (i, b) => { let f = 1, r = 0; while (i > 0) { f /= b; r += f * (i % b); i = Math.floor(i / b); } return r; };
+let TC = 0;
+post.accum.N = +(Q.get('n') || 20);
+// the shutter adapts to the camera's speed: a streak never exceeds ~8 px, so even a whip keeps its subject legible
+let SH = SHUTTER;
+const probe = new THREE.Vector3(), q0 = new THREE.Quaternion(), p0 = new THREE.Vector3();
+function shutterAt(t) {
+ const h = .02; applyAt(t - h, 0, 0); q0.copy(camera.quaternion); p0.copy(camera.position); const d0 = rig.target(t - h).distanceTo(p0);
+ applyAt(t + h, 0, 0); const ang = q0.angleTo(camera.quaternion) + camera.position.distanceTo(p0) / Math.max(.05, d0);
+ const pxPerSec = ang / (2 * h) * 1080 / (camera.fov * Math.PI / 180);
+ return Math.max(.02, Math.min(SHUTTER, 8 * FPS / Math.max(1, pxPerSec)));
+}
+post.accum.setSub = (i, n) => applyAt(TC + ((i + .5) / n - .5) * SH / FPS, halton(i + 1, 2) - .5, halton(i + 1, 3) - .5);
+
+window.render = t => { TC = t; SH = shutterAt(t); caps.render(t); post.composer.render(); };
+// what the viewer is meant to read: the captions (DOM) plus the in-world text listed in ctx.read, projected to screen boxes
+const proj = new THREE.Vector3();
+window.TEXTS = t => {
+ caps.render(t); const out = caps.texts(t);
+ applyAt(t, 0, 0); camera.updateMatrixWorld();
+ for (const [id, text, t0, t1, corners] of ctx.read) {
+ if (t < t0 || t >= t1) continue;
+ let x0 = 1e9, y0 = 1e9, x1 = -1e9, y1 = -1e9, behind = false;
+ for (const p of corners()) { proj.copy(p).project(camera); if (proj.z > 1) behind = true; const x = (proj.x + 1) / 2 * 1920, y = (1 - proj.y) / 2 * 1080; x0 = Math.min(x0, x); x1 = Math.max(x1, x); y0 = Math.min(y0, y); y1 = Math.max(y1, y); }
+ if (!behind) out.push({ id, text, x0, y0, x1, y1 });
+ }
+ return out;
+};
+window.EV = ev;
+applyAt(0, 0, 0); renderer.compile(scene, camera);
+window.READY = true;
+window.DBG = (t, names = []) => { applyAt(t, 0, 0); const r = { cam: camera.position.toArray().map(v => +v.toFixed(3)), tg: rig.target(t).toArray().map(v => +v.toFixed(3)) }; for (const n of names) r[n] = ctx.subj[n](t).toArray().map(v => +v.toFixed(3)); return r; };
diff --git a/styles/desktop-flythrough/demo/src/post.js b/styles/desktop-flythrough/demo/src/post.js
new file mode 100644
index 0000000..8887501
--- /dev/null
+++ b/styles/desktop-flythrough/demo/src/post.js
@@ -0,0 +1,113 @@
+// Post for the flythrough look: every output frame = N sub-frames (each: scene → physical DOF), averaged → bloom → grade/vignette → tone map.
+// Sub-frames spread over the shutter (true motion blur) and carry sub-pixel jitter (anti-aliasing for free).
+// DOF shaders are copied from $LIB/core/three/post.js.
+import * as THREE from 'three';
+import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
+import { Pass, FullScreenQuad } from 'three/addons/postprocessing/Pass.js';
+import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
+import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';
+import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';
+
+const VS = `varying vec2 vUv; void main(){ vUv = uv; gl_Position = vec4(position.xy, 0., 1.); }`;
+const cocShader = {
+ uniforms: { tColor: { value: null }, tDepth: { value: null }, focus: { value: .3 }, aper: { value: 4 }, maxCoc: { value: 18 }, near: { value: .01 }, far: { value: 50 } },
+ vertexShader: VS,
+ fragmentShader: `
+ #include <packing>
+ varying vec2 vUv; uniform sampler2D tColor, tDepth; uniform float focus, aper, maxCoc, near, far;
+ void main(){
+ float d = texture2D(tDepth, vUv).x;
+ float z = -perspectiveDepthToViewZ(d, near, far);
+ float c = clamp(aper * (1.0/focus - 1.0/z), 0.0, maxCoc); // background only: nothing nearer than the focus plane is ever blurred
+ gl_FragColor = vec4(texture2D(tColor, vUv).rgb, c);
+ }`
+};
+const gatherShader = {
+ uniforms: { tIn: { value: null }, res: { value: new THREE.Vector2(1920, 1080) }, maxCoc: { value: 18 } },
+ vertexShader: VS,
+ fragmentShader: `
+ varying vec2 vUv; uniform sampler2D tIn; uniform vec2 res; uniform float maxCoc;
+ void main(){
+ vec4 c0 = texture2D(tIn, vUv); float a0 = abs(c0.a);
+ vec3 acc = c0.rgb / (a0*a0 + 1.); float wsum = 1. / (a0*a0 + 1.);
+ const int N = 64;
+ for (int i = 0; i < N; i++) {
+ float r = maxCoc * sqrt((float(i) + .5) / float(N));
+ float th = float(i) * 2.39996;
+ vec2 off = vec2(cos(th), sin(th)) * r / res;
+ vec4 s = texture2D(tIn, vUv + off);
+ float sa = abs(s.a);
+ if (s.a > c0.a) sa = min(sa, max(a0, 0.));
+ float w = smoothstep(r - 1.5, r + .5, sa) / (sa*sa + 1.);
+ acc += s.rgb * w; wsum += w;
+ }
+ gl_FragColor = vec4(acc / wsum, 1.);
+ }`
+};
+
+class DofScene {
+ constructor(scene, camera, w, h) {
+ this.scene = scene; this.camera = camera;
+ this.rt = new THREE.WebGLRenderTarget(w, h, { samples: 4, type: THREE.HalfFloatType, depthTexture: new THREE.DepthTexture(w, h, THREE.FloatType) });
+ this.rtC = new THREE.WebGLRenderTarget(w, h, { type: THREE.HalfFloatType });
+ this.coc = new FullScreenQuad(new THREE.ShaderMaterial(cocShader));
+ this.gat = new FullScreenQuad(new THREE.ShaderMaterial(gatherShader));
+ this.gat.material.uniforms.res.value.set(w, h);
+ this.focus = .3; this.aper = 4; this.maxCoc = 18;
+ }
+ render(renderer, target) {
+ renderer.setRenderTarget(this.rt); renderer.clear(); renderer.render(this.scene, this.camera);
+ const u = this.coc.material.uniforms;
+ u.tColor.value = this.rt.texture; u.tDepth.value = this.rt.depthTexture; u.focus.value = this.focus; u.aper.value = this.aper; u.maxCoc.value = this.maxCoc;
+ u.near.value = this.camera.near; u.far.value = this.camera.far;
+ renderer.setRenderTarget(this.rtC); this.coc.render(renderer);
+ const g = this.gat.material.uniforms; g.tIn.value = this.rtC.texture; g.maxCoc.value = this.maxCoc;
+ renderer.setRenderTarget(target); this.gat.render(renderer);
+ }
+}
+
+class AccumPass extends Pass {
+ constructor(dof, w, h) {
+ super(); this.dof = dof; this.needsSwap = true; this.N = 12; this.setSub = null;
+ this.tmp = new THREE.WebGLRenderTarget(w, h, { type: THREE.HalfFloatType });
+ this.quad = new FullScreenQuad(new THREE.ShaderMaterial({
+ uniforms: { tex: { value: null }, k: { value: 1 } }, vertexShader: VS,
+ fragmentShader: `varying vec2 vUv; uniform sampler2D tex; uniform float k; void main(){ gl_FragColor = vec4(texture2D(tex, vUv).rgb * k, k); }`,
+ blending: THREE.CustomBlending, blendSrc: THREE.OneFactor, blendDst: THREE.OneFactor, blendSrcAlpha: THREE.OneFactor, blendDstAlpha: THREE.OneFactor,
+ depthTest: false, depthWrite: false, transparent: true
+ }));
+ }
+ render(renderer, writeBuffer) {
+ const ac = renderer.autoClear; renderer.autoClear = false;
+ renderer.setRenderTarget(writeBuffer); renderer.setClearColor(0x000000, 0); renderer.clear();
+ for (let i = 0; i < this.N; i++) {
+ this.setSub(i, this.N);
+ this.dof.render(renderer, this.tmp);
+ renderer.setRenderTarget(writeBuffer);
+ this.quad.material.uniforms.tex.value = this.tmp.texture; this.quad.material.uniforms.k.value = 1 / this.N;
+ this.quad.render(renderer);
+ }
+ renderer.autoClear = ac;
+ }
+}
+
+const gradeShader = {
+ uniforms: { tDiffuse: { value: null }, amt: { value: .45 }, warm: { value: .35 }, contrast: { value: .12 }, sat: { value: 1.05 }, lift: { value: new THREE.Vector3(.010, .006, .004) } },
+ vertexShader: `varying vec2 vUv; void main(){ vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.); }`,
+ fragmentShader: `varying vec2 vUv; uniform sampler2D tDiffuse; uniform float amt, warm, contrast, sat; uniform vec3 lift;
+ void main(){ vec4 c = texture2D(tDiffuse, vUv); vec2 d = vUv - .5; d.x *= 1.3; float v = 1. - amt * smoothstep(.2, .85, length(d));
+ c.rgb = c.rgb * v * mix(vec3(1.), vec3(1.07, 1., .88), warm) + lift;
+ float l = dot(c.rgb, vec3(.2126, .7152, .0722)); c.rgb = mix(vec3(l), c.rgb, sat);
+ c.rgb = c.rgb * (1. + contrast) / (1. + contrast * c.rgb / (c.rgb + .6));
+ gl_FragColor = c; }`
+};
+
+export function makePost(renderer, scene, camera, w, h) {
+ const composer = new EffectComposer(renderer, new THREE.WebGLRenderTarget(w, h, { type: THREE.HalfFloatType }));
+ const dof = new DofScene(scene, camera, w, h);
+ const accum = new AccumPass(dof, w, h);
+ const bloom = new UnrealBloomPass(new THREE.Vector2(w, h), .28, .55, 1.05);
+ const grade = new ShaderPass(gradeShader);
+ composer.addPass(accum); composer.addPass(bloom); composer.addPass(grade); composer.addPass(new OutputPass());
+ return { composer, dof, accum, bloom, grade };
+}
diff --git a/styles/desktop-flythrough/demo/src/shots.js b/styles/desktop-flythrough/demo/src/shots.js
new file mode 100644
index 0000000..ab62dd2
--- /dev/null
+++ b/styles/desktop-flythrough/demo/src/shots.js
@@ -0,0 +1,61 @@
+// The one take for 叮之前: [t, target (Vector3 | subject), dist, az, el, fov, target offset?, {ease}?] and impact shakes [t, amp, decay].
+// Film seconds. az 0 = camera on the +z side looking toward −z (screens and cards read upright); el in radians.
+import { VO, CREDIT_T, DUR } from './vo.js';
+const R = { ease: 1 };
+export const KEYS = [
+ // S1 your phone and the title; the cat pops; send; whip to the friend's phone, where it seems to arrive at once
+ [0.0, 'Atent', .66, .42, .58, 34],
+ [1.2, 'Atent', .62, .36, .6, 34],
+ [2.95, 'Atent', .6, .3, .62, 34, null, R],
+ [3.15, 'wide', 1.25, .05, .78, 35], // the whip arcs up over the desk, so the route and the stops pass through frame, not bare paper
+ [3.35, 'B', .6, -.25, .72, 35],
+ [4.5, 'B', .58, -.2, .74, 35, null, R],
+ // S2 rise over the desk: not a straight line, but a route through two stops
+ [5.7, 'wide', 2.35, .0, 1.0, 36],
+ [7.35, 'wide', 2.33, .02, 1.0, 36, null, R],
+ // S3 back to the cat; it leaps to the compress card (the whip rides the leap)
+ [7.9, 'cat', .5, .3, .52, 36],
+ [8.35, 'cat', .5, .28, .52, 36, null, R],
+ [8.85, 'cmp', .55, -.05, .72, 36],
+ [10.3, 'cmp', .52, -.02, .78, 36, null, R],
+ // S4 the press, the counter, original ≈ compressed
+ [11.2, 'cmp', .6, .0, .95, 36],
+ [16.9, 'cmp', .57, .05, .97, 36, null, R],
+ // S5 ride the hops to the server
+ [17.6, 'cat', .52, .35, .5, 36],
+ [18.7, 'cat', .56, .4, .46, 36],
+ [19.6, 'srvTop', .62, .3, .5, 36, null, R],
+ // S6 half an orbit round the server; the drawer opens, the photo goes in, a window lights
+ [21.4, 'srv', .64, .62, .42, 36],
+ [22.9, 'srv', .74, .18, .52, 36],
+ [24.4, 'srv', .68, .0, .46, 36],
+ [26.0, 'srvTop', .62, -.22, .44, 36, null, R],
+ // S7–S8 the bell rises, flies to the friend's phone, taps it; the banner drops
+ [27.6, 'bell', .55, -.2, .4, 36],
+ [28.25, 'bell', .56, -.18, .42, 36, null, R],
+ [29.0, 'Btop', .7, -.15, .7, 36],
+ [30.5, 'Btop', .62, -.1, .9, 36],
+ [32.0, 'Btop', .6, -.05, .98, 36, null, R],
+ // S9 the ring
+ [34.5, 'Btop', .58, -.04, 1.0, 36, null, R],
+ // S10 the phone goes to the server: pull out to see both, the route lights back to the server, the photo hops home
+ [35.6, 'leg2', 1.2, -.1, .75, 36],
+ [37.3, 'leg2', 1.15, -.15, .74, 36],
+ [38.4, 'cat', .62, -.3, .55, 36],
+ // S11 slow connection: blurry, then sharp
+ [39.9, 'Bbubble', .5, -.05, .95, 36],
+ [44.8, 'Bbubble', .47, -.02, .98, 36, null, R],
+ // S12 the whole relay
+ [46.5, 'wide', 2.4, .06, 1.05, 36],
+ [48.3, 'wide', 2.37, .07, 1.05, 36, null, R],
+ // S13 the friend's copy; S14 your original
+ [49.0, 'Bbubble', .46, -.05, 1.0, 36],
+ [VO[13].t0 + .2, 'Bbubble', .45, -.04, 1.0, 36, null, R],
+ [VO[13].t0 + .4, 'wide', 1.3, .03, .95, 36],
+ [VO[13].t0 + .6, 'Aalbum', .6, .05, 1.0, 36],
+ [CREDIT_T - .25, 'Aalbum', .58, .07, 1.0, 36, null, R],
+ // S15 the closing shot: one long rise and pull-back until all four stops and the relay line are in frame; everything hops once, the cats bow
+ [CREDIT_T + .55, 'final', 2.55, .22, 1.02, 36],
+ [DUR, 'final', 2.62, .3, 1.04, 36],
+];
+export const SHAKES = [[2.25, .002, 10], [10.5, .006, 8], [33.5, .004, 9]];
diff --git a/styles/desktop-flythrough/demo/src/vo.js b/styles/desktop-flythrough/demo/src/vo.js
new file mode 100644
index 0000000..67341dc
--- /dev/null
+++ b/styles/desktop-flythrough/demo/src/vo.js
@@ -0,0 +1,103 @@
+// Voice-over lines on the film clock (generated by audio/vo_timeline.py from vo/). t0/t1 = speech start/end.
+export const DUR = 59.95;
+export const CREDIT_T = 55.4;
+export const VO = [
+ {
+ "id": "v01",
+ "t0": 0.8,
+ "t1": 4.412,
+ "zh": "你给朋友发了张猫,叮的一声,对面马上就收到了。",
+ "en": "You send a friend a cat photo. Ding, it arrives right away."
+ },
+ {
+ "id": "v02",
+ "t0": 4.812,
+ "t1": 7.266,
+ "zh": "可这张照片,并没有直接飞过去。",
+ "en": "But the photo didn't fly straight there."
+ },
+ {
+ "id": "v03",
+ "t0": 7.766,
+ "t1": 10.593,
+ "zh": "按下发送的那一刻,第一步,是压小。",
+ "en": "The moment you hit send, step one: make it smaller."
+ },
+ {
+ "id": "v04",
+ "t0": 10.893,
+ "t1": 16.895,
+ "zh": "原图太大、传得太慢,软件会先把它悄悄压缩,体积小了,看着却差不多。",
+ "en": "The original is too big and slow to send, so the app quietly compresses it: smaller, yet it looks about the same."
+ },
+ {
+ "id": "v05",
+ "t0": 17.495,
+ "t1": 20.294,
+ "zh": "接着,照片来到第二站,服务器。",
+ "en": "Next, the photo reaches stop two: the server."
+ },
+ {
+ "id": "v06",
+ "t0": 20.594,
+ "t1": 25.639,
+ "zh": "也就是聊天软件的云端中转站,照片先存放在这儿,等着对面来取。",
+ "en": "That's the chat app's relay station in the cloud. The photo waits here to be picked up."
+ },
+ {
+ "id": "v07",
+ "t0": 26.239,
+ "t1": 28.119,
+ "zh": "第三步,才轮到发通知。",
+ "en": "Only then comes step three: the notification."
+ },
+ {
+ "id": "v08",
+ "t0": 28.419,
+ "t1": 32.024,
+ "zh": "服务器拍了拍朋友的手机,嘿,有张照片找你。",
+ "en": "The server taps your friend's phone: \"Hey, a photo for you.\""
+ },
+ {
+ "id": "v09",
+ "t0": 32.324,
+ "t1": 34.282,
+ "zh": "这时候,手机才响了一声。",
+ "en": "That's when the phone goes ding."
+ },
+ {
+ "id": "v10",
+ "t0": 34.882,
+ "t1": 39.3,
+ "zh": "收到通知后,朋友的手机才真正去服务器,把照片取回来。",
+ "en": "After the notification, your friend's phone goes to the server and fetches the photo."
+ },
+ {
+ "id": "v11",
+ "t0": 39.6,
+ "t1": 44.211,
+ "zh": "所以网慢的时候,你会看到它先糊一下,再瞬间变清楚。",
+ "en": "So on a slow connection, you see it blurry for a moment, then suddenly sharp."
+ },
+ {
+ "id": "v12",
+ "t0": 44.811,
+ "t1": 47.763,
+ "zh": "一声叮的背后,其实是一场无声的接力。",
+ "en": "Behind that one ding is a silent relay."
+ },
+ {
+ "id": "v13",
+ "t0": 48.113,
+ "t1": 52.007,
+ "zh": "如果你没勾原图,朋友收到的,只是那只猫的压缩版。",
+ "en": "Unless you ticked \"Original\", what your friend gets is just a compressed copy of the cat."
+ },
+ {
+ "id": "v14",
+ "t0": 52.307,
+ "t1": 55.1,
+ "zh": "而真正的原图,一直都在你的手机里。",
+ "en": "The real original has been on your phone all along."
+ }
+];
diff --git a/styles/desktop-flythrough/demo/src/voxel.js b/styles/desktop-flythrough/demo/src/voxel.js
new file mode 100644
index 0000000..7b7b1a1
--- /dev/null
+++ b/styles/desktop-flythrough/demo/src/voxel.js
@@ -0,0 +1,69 @@
+// Pixel monster → voxel toy. One instanced column per pixel: thin at the silhouette, thicker inside, eyes stand proud.
+// Hierarchy: root (feet position, yaw) → hingeG (lies flat ↔ stands, about the feet line) → squashG (scale at the feet) → spinG (centre: flips, tilts) → mesh
+// set({pos, yaw, e, hinge, sq, tiltX, tiltZ, spinX, spinZ, scale, vis})
+// e: 0 flat sticker … 1 full toy (cells extrude in a ripple from the centre); hinge: 0 lying on the paper … 1 standing; sq: squash (<1) / stretch (>1)
+import * as THREE from 'three';
+import { RoundedBoxGeometry } from 'three/addons/geometries/RoundedBoxGeometry.js';
+import { clamp, hash, back } from '/core/lib.js';
+
+const DIRS = [[1, 0], [-1, 0], [0, 1], [0, -1]];
+// bevelled cells: each voxel keeps a thin rounded edge that catches the low sun (toy plastic, not CG boxes)
+const box = new RoundedBoxGeometry(1, 1, 1, 2, .16);
+
+export function makeMonster(data, cell, name = '', depthK = 1) {
+ const { w, h, cells } = data, key = (i, j) => i + ',' + j;
+ const occ = new Set(cells.map(([i, j]) => key(i, j)));
+ const dist = new Map(), q = [];
+ for (const [i, j] of cells) if (DIRS.some(([a, b]) => !occ.has(key(i + a, j + b)))) { dist.set(key(i, j), 1); q.push([i, j]); }
+ for (let k = 0; k < q.length; k++) {
+ const [i, j] = q[k], d = dist.get(key(i, j));
+ for (const [a, b] of DIRS) { const n = key(i + a, j + b); if (occ.has(n) && !dist.has(n)) { dist.set(n, d + 1); q.push([i + a, j + b]); } }
+ }
+ const mesh = new THREE.InstancedMesh(box, new THREE.MeshStandardMaterial({ roughness: .48, metalness: 0 }), cells.length);
+ mesh.castShadow = mesh.receiveShadow = true; mesh.frustumCulled = false;
+ const cx = w / 2, cyMid = h / 2;
+ // the dominant body colour (for trails, tiny stand-ins)
+ const tally = {}; cells.forEach(([, , c]) => tally[c] = (tally[c] || 0) + 1);
+ const main = Object.entries(tally).sort((a, b) => b[1] - a[1])[0][0];
+ const info = cells.map(([i, j, c], k) => {
+ const col = new THREE.Color(c), lum = .2126 * col.r + .7152 * col.g + .0722 * col.b;
+ const d = dist.get(key(i, j)), eye = lum < .02;
+ const r = Math.hypot(i + .5 - cx, (j + .5 - cyMid) * 1.1) / Math.hypot(cx, cyMid);
+ mesh.setColorAt(k, col);
+ return { x: (i + .5 - cx) * cell, y: (h - j - .5) * cell, dep: (2.2 + Math.min(d - 1, 3.2) * 1.15) * cell * depthK, eye, delay: r * .55 + hash(k * 7.3 + w) * .12 };
+ });
+ const H_ = h * cell;
+ const root = new THREE.Group(), hingeG = new THREE.Group(), squashG = new THREE.Group(), spinG = new THREE.Group();
+ root.add(hingeG); hingeG.add(squashG); squashG.add(spinG); spinG.add(mesh);
+ spinG.position.y = H_ / 2; mesh.position.y = -H_ / 2;
+ const m4 = new THREE.Matrix4(), p = new THREE.Vector3(), s = new THREE.Vector3(), qq = new THREE.Quaternion();
+ const M = { name, root, mesh, info, w, h, cell, height: H_, width: w * cell, main, e: -1 };
+ M.extrude = e => {
+ if (Math.abs(e - M.e) < 1e-4) return; M.e = e;
+ info.forEach((o, k) => {
+ const ek = clamp((e * 1.45 - o.delay) / .55), g = ek <= 0 ? 0 : back(ek, 1.6);
+ const dz = Math.max(cell * .2, o.dep * g) + (o.eye ? cell * .9 * g : 0);
+ p.set(o.x, o.y, (o.eye ? cell * .45 * g : 0)); s.set(cell * .94, cell * .94, dz);
+ m4.compose(p, qq, s); mesh.setMatrixAt(k, m4);
+ });
+ mesh.instanceMatrix.needsUpdate = true;
+ };
+ M.set = (st = {}) => {
+ const { pos, yaw = 0, e = 1, hinge = 1, sq = 1, tiltX = 0, tiltZ = 0, spinX = 0, spinZ = 0, scale = 1, vis = true } = st;
+ root.visible = vis && scale > .001; if (!root.visible) return;
+ if (pos) root.position.copy(pos);
+ root.rotation.y = yaw;
+ hingeG.rotation.x = -Math.PI / 2 * (1 - clamp(hinge));
+ const sxz = 1 / Math.sqrt(Math.max(.2, sq));
+ squashG.scale.set(sxz * scale, sq * scale, sxz * scale);
+ spinG.rotation.set(tiltX + spinX, 0, tiltZ + spinZ);
+ M.extrude(e);
+ };
+ // blink: eye cells (pure black) take the colour of the cell above them while closed
+ const eyes = info.map((o, k) => o.eye ? k : -1).filter(k => k >= 0), lid = new THREE.Color(), eyeCol = new THREE.Color('#0d0d0d');
+ const above = eyes.map(k => { const [i, j] = cells[k]; const up = cells.findIndex(([a, b2, c]) => a === i && b2 === j - 1 && new THREE.Color(c).getHex() !== 0x0d0d0d); return up >= 0 ? new THREE.Color(cells[up][2]) : eyeCol; });
+ let closed = false;
+ M.blink = on => { if (on === closed || !eyes.length) return; closed = on; eyes.forEach((k, n) => mesh.setColorAt(k, on ? above[n] : eyeCol)); mesh.instanceColor.needsUpdate = true; };
+ M.extrude(1);
+ return M;
+}
diff --git a/styles/desktop-flythrough/demo/src/world.js b/styles/desktop-flythrough/demo/src/world.js
new file mode 100644
index 0000000..d53b0fe
--- /dev/null
+++ b/styles/desktop-flythrough/demo/src/world.js
@@ -0,0 +1,114 @@
+// Shared world: renderer, sunlit dotted paper, card helper, dot ripples, small builders.
+import * as THREE from 'three';
+import { RoundedBoxGeometry } from 'three/addons/geometries/RoundedBoxGeometry.js';
+import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
+import * as K from './cards.js';
+
+export const W = 1920, H = 1080, D = .03; // D: dot spacing; dot centres sit at ((i+.5)D, (k+.5)D)
+
+export function makeWorld(opt = {}) {
+ const renderer = new THREE.WebGLRenderer({ antialias: false, preserveDrawingBuffer: true });
+ renderer.setPixelRatio(1); renderer.setSize(W, H); document.body.prepend(renderer.domElement);
+ renderer.toneMapping = THREE.NeutralToneMapping; renderer.toneMappingExposure = 1.0;
+ renderer.localClippingEnabled = true;
+ renderer.shadowMap.enabled = true; renderer.shadowMap.type = THREE.PCFSoftShadowMap;
+ const ANISO = renderer.capabilities.getMaxAnisotropy();
+ const scene = new THREE.Scene();
+ const HAZE = new THREE.Color(opt.haze || K.COL.paper).multiplyScalar(.97); scene.background = HAZE; scene.fog = new THREE.FogExp2(HAZE, .075);
+ const camera = new THREE.PerspectiveCamera(38, W / H, .005, 80);
+ scene.environment = new THREE.PMREMGenerator(renderer).fromScene(new RoomEnvironment(), .04).texture; scene.environmentIntensity = .25;
+ scene.add(new THREE.HemisphereLight(0xc8d6ff, 0xf3e3cc, .7)); // cool sky, warm bounce
+ const sun = new THREE.DirectionalLight(0xffdcb4, 3.8); // early-morning sun: warm, low
+ sun.castShadow = true; sun.shadow.mapSize.set(4096, 4096); sun.shadow.bias = -.0001; sun.shadow.normalBias = .0006;
+ scene.add(sun, sun.target);
+ const SUNDIR = new THREE.Vector3(-2.2, .92, -1.15).normalize(); // about 20° up from the back-left: long shadows
+ const tex = cv => { const x = new THREE.CanvasTexture(cv); x.colorSpace = THREE.SRGBColorSpace; x.anisotropy = ANISO; return x; };
+ const t = new THREE.CanvasTexture(K.dotTile()); t.wrapS = t.wrapT = THREE.RepeatWrapping; t.colorSpace = THREE.SRGBColorSpace; t.anisotropy = ANISO;
+ if (!opt.mat) { // the whole desk is dotted paper
+ t.repeat.set(60 / (8 * D), 60 / (8 * D));
+ const desk = new THREE.Mesh(new THREE.PlaneGeometry(60, 60), new THREE.MeshStandardMaterial({ map: t, roughness: .92 }));
+ desk.rotation.x = -Math.PI / 2; desk.receiveShadow = true; scene.add(desk);
+ } else { // a dotted paper mat (top at y = 0) on a light oak desk
+ const [mw, mh] = opt.mat; t.repeat.set(mw / (8 * D), mh / (8 * D)); // mw, mh are multiples of 2D so the printed dots line up with dotPatch
+ const mat = new THREE.Mesh(new RoundedBoxGeometry(mw, .003, mh, 2, .0014), [0, 1, 2, 3, 4, 5].map(i => new THREE.MeshStandardMaterial(i === 2 ? { map: t, roughness: .92 } : { color: K.COL.paper, roughness: .92 })));
+ mat.position.y = -.0015; mat.receiveShadow = true; mat.castShadow = true; scene.add(mat);
+ const wt = new THREE.CanvasTexture(woodTile()); wt.wrapS = wt.wrapT = THREE.RepeatWrapping; wt.repeat.set(30 / 2.4, 30 / 2.4); wt.colorSpace = THREE.SRGBColorSpace; wt.anisotropy = ANISO;
+ const desk = new THREE.Mesh(new THREE.PlaneGeometry(30, 30), new THREE.MeshStandardMaterial({ map: wt, roughness: .62 }));
+ desk.rotation.x = -Math.PI / 2; desk.position.y = -.003; desk.receiveShadow = true; scene.add(desk);
+ }
+ return { renderer, scene, camera, sun, SUNDIR, ANISO, tex };
+}
+
+// light oak: planks 0.3 wide running along x, long soft grain, faint seams (one tile = 2.4 × 2.4 units)
+function woodTile(px = 2048) {
+ const [c, x] = K.canvas(px, px, 1), plank = px / 8;
+ for (let p = 0; p < 8; p++) {
+ const y0 = p * plank, hue = (p * 37 % 7) / 7;
+ x.fillStyle = `rgb(${222 - hue * 10},${204 - hue * 9},${178 - hue * 8})`; x.fillRect(0, y0, px, plank);
+ for (let g = 0; g < 46; g++) { // grain lines: long low-frequency waves
+ const yy = y0 + (g + .5) * plank / 46, a = .025 + ((g * 13 + p * 7) % 9) / 9 * .05, ph = (g * 1.7 + p) % 6.28, amp = 2 + (g % 5);
+ x.strokeStyle = `rgba(120,86,52,${a})`; x.lineWidth = 1 + (g % 3) * .6; x.beginPath();
+ for (let i = 0; i <= px; i += 32) x.lineTo(i, yy + Math.sin(i / px * 6.28 * (1 + p % 3) + ph) * amp + Math.sin(i / 97 + g) * .8);
+ x.stroke();
+ }
+ x.fillStyle = 'rgba(90,64,40,.18)'; x.fillRect(0, y0, px, 2);
+ }
+ K.grain(x, px, px, 5, 40000, 'rgba(80,55,30,.04)', 'rgba(255,250,240,.12)');
+ return c;
+}
+
+// a card lying on the paper: rounded slab + printed top (canvas). group.userData.redraw() re-uploads the canvas
+export function card(world, cv, w, h, thick = .005) {
+ const g = new THREE.Group(), tex = world.tex(cv);
+ const slab = new THREE.Mesh(new RoundedBoxGeometry(w, thick, h, 2, thick * .45), new THREE.MeshStandardMaterial({ color: K.COL.card, roughness: .8 }));
+ slab.position.y = thick / 2; slab.castShadow = slab.receiveShadow = true; g.add(slab);
+ const top = new THREE.Mesh(new THREE.PlaneGeometry(w, h), new THREE.MeshStandardMaterial({ map: tex, roughness: .85, transparent: true }));
+ top.rotation.x = -Math.PI / 2; top.position.y = thick + .0002; top.receiveShadow = true; g.add(top);
+ g.userData = { tex, top: thick, redraw: () => { tex.needsUpdate = true; } };
+ return g;
+}
+
+// Dot patch: real 3D dots over a disc of the paper, so impacts can push a ripple through them.
+// ripples: [{t, x, z, amp, speed}] — each a travelling ring that lifts the dots it passes; skip(x, z): leave out dots under cards
+export function dotPatch(world, cx, cz, R, ripples, skip = () => false) {
+ const pts = [];
+ for (let i = Math.floor((cx - R) / D); i <= Math.ceil((cx + R) / D); i++)
+ for (let k = Math.floor((cz - R) / D); k <= Math.ceil((cz + R) / D); k++) {
+ const x = (i + .5) * D, z = (k + .5) * D; if (Math.hypot(x - cx, z - cz) < R && !skip(x, z)) pts.push([x, z]);
+ }
+ const geo = new THREE.CylinderGeometry(D * .075, D * .075, .0016, 10);
+ const mesh = new THREE.InstancedMesh(geo, new THREE.MeshStandardMaterial({ color: K.COL.dot, roughness: .9 }), pts.length);
+ mesh.castShadow = true; mesh.receiveShadow = true; world.scene.add(mesh);
+ const m4 = new THREE.Matrix4(), p = new THREE.Vector3(), q = new THREE.Quaternion(), s = new THREE.Vector3(1, 1, 1);
+ mesh.update = t => {
+ let any = false;
+ pts.forEach(([x, z], j) => {
+ let y = 0;
+ for (const r of ripples) {
+ const dt = t - r.t; if (dt < 0 || dt > 1.6) continue;
+ const d = Math.hypot(x - r.x, z - r.z), front = dt * (r.speed || 1.1), w = .06;
+ y += (r.amp || .03) * Math.exp(-(((d - front) / w) ** 2)) * Math.exp(-dt * 2.2) * Math.exp(-d * 1.2);
+ }
+ if (y > 1e-4) any = true;
+ p.set(x, .0008 + y, z); s.set(1, 1 + y * 120, 1); m4.compose(p, q, s); mesh.setMatrixAt(j, m4);
+ });
+ mesh.visible = any; mesh.instanceMatrix.needsUpdate = true;
+ };
+ return mesh;
+}
+
+export const rbox = (w, h, d, r = .003) => new RoundedBoxGeometry(w, h, d, 2, r);
+
+// a rounded tag that stands on its own and faces the camera (call .face(camera) each frame). h: world height
+export function pill(world, text, { bg = K.COL.accent, fg = '#ffffff', h = .026, size = 40, font = K.MONO, wt = 600, line = null } = {}) {
+ const ph = size * 2, pad = size * .8, [, m] = K.canvas(10, 10);
+ m.font = `${wt} ${size}px ${font}`; const tw = m.measureText(text).width, pw = Math.ceil(Math.max(tw + pad * 2, ph));
+ const [cv, c] = K.canvas(pw + 8, ph + 8, 3);
+ if (bg) { c.fillStyle = bg; K.rr(c, 4, 4, pw, ph, ph / 2); c.fill(); }
+ if (line) { c.strokeStyle = line; c.lineWidth = 5; K.rr(c, 6.5, 6.5, pw - 5, ph - 5, ph / 2); c.stroke(); }
+ K.txt(c, text, 4 + pw / 2, 4 + ph / 2 + 1, { size, wt, col: fg, align: 'center', font });
+ const w = h * (pw + 8) / (ph + 8);
+ const mesh = new THREE.Mesh(new THREE.PlaneGeometry(w, h), new THREE.MeshStandardMaterial({ map: world.tex(cv), transparent: true, alphaTest: .3, side: THREE.DoubleSide, roughness: .7 }));
+ mesh.castShadow = true; mesh.face = cam => mesh.quaternion.copy(cam.quaternion); world.scene.add(mesh); mesh.w = w;
+ return mesh;
+}
diff --git a/styles/desktop-flythrough/demo/stills/styleframe.jpg b/styles/desktop-flythrough/demo/stills/styleframe.jpg
new file mode 100644
index 0000000..048622b
Binary files /dev/null and b/styles/desktop-flythrough/demo/stills/styleframe.jpg differ
diff --git a/styles/desktop-flythrough/demo/tools/camspeed.mjs b/styles/desktop-flythrough/demo/tools/camspeed.mjs
new file mode 100644
index 0000000..e41d5a1
--- /dev/null
+++ b/styles/desktop-flythrough/demo/tools/camspeed.mjs
@@ -0,0 +1,20 @@
+// LIB=<library> node tools/camspeed.mjs [out.json] → camera speed (default out/camspeed.json): per-frame camera motion (view-direction turn rate + translation relative to subject distance)
+import fs from 'fs';
+const LIB = process.env.LIB || process.env.HOME + '/lemo-opuscar';
+const { openDemo, closeServer } = await import(LIB + '/core/render/page.mjs');
+const dir = decodeURIComponent(new URL('..', import.meta.url).pathname).replace(/\/$/, '');
+const { browser, page } = await openDemo(dir);
+const out = await page.evaluate(() => {
+ const r = []; let prev = null;
+ for (let f = 0; f <= Math.round(window.DUR * 30); f++) {
+ const t = f / 30, d = window.DBG(t), c = d.cam, g = d.tg;
+ const v = [g[0] - c[0], g[1] - c[1], g[2] - c[2]], L = Math.hypot(...v), u = v.map(x => x / L);
+ if (prev) { const dot = Math.min(1, u[0] * prev.u[0] + u[1] * prev.u[1] + u[2] * prev.u[2]); const ang = Math.acos(dot) * 30;
+ const tr = Math.hypot(c[0] - prev.c[0], c[1] - prev.c[1], c[2] - prev.c[2]) * 30 / L; r.push([+t.toFixed(3), +ang.toFixed(3), +tr.toFixed(3)]); }
+ prev = { u, c };
+ }
+ return r;
+});
+fs.writeFileSync(process.argv[2] || dir + '/out/camspeed.json', JSON.stringify(out));
+console.log('frames', out.length, 'max ang', Math.max(...out.map(x => x[1])).toFixed(2), 'max tr', Math.max(...out.map(x => x[2])).toFixed(2));
+await browser.close(); closeServer();
diff --git a/styles/desktop-flythrough/demo/tools/chars.txt b/styles/desktop-flythrough/demo/tools/chars.txt
new file mode 100644
index 0000000..ab7fe22
--- /dev/null
+++ b/styles/desktop-flythrough/demo/tools/chars.txt
@@ -0,0 +1 @@
+!()+,-.0123456789:?·×–—…‹←→↔−∝≈─✓✗、。一三上下不中之也了二云以件会传体你候儿先入其册再刚到刻前力务勾却压原去友发取变只叮可后响嘛嘿器回图在场声多大天太如存它实家对小就差干并张得息悄慢我所手才找把拍按接收放新无早时是有朋服机来林果楚正步没消清照片版猫的直相看真着瞬知积站端第等糊给缩网而聊背转轮软输过这送通那都里间面飞马,:?
\ No newline at end of file
diff --git a/styles/desktop-flythrough/demo/tools/subset.py b/styles/desktop-flythrough/demo/tools/subset.py
new file mode 100644
index 0000000..5a2d1c7
--- /dev/null
+++ b/styles/desktop-flythrough/demo/tools/subset.py
@@ -0,0 +1,10 @@
+"""Subset Noto Sans SC (OFL) to every character the film shows: card print, screens, pills and the subtitles (src/*.js, index.html).
+Run from the library root: .venv/bin/python styles/desktop-flythrough/demo/tools/subset.py"""
+import os, glob
+HERE = os.path.dirname(os.path.abspath(__file__)); D = os.path.dirname(HERE)
+txt = ''.join(open(f, encoding='utf-8').read() for f in glob.glob(os.path.join(D, 'src', '*.js')) + [os.path.join(D, 'index.html')])
+chars = sorted(set(ch for ch in txt if ord(ch) > 0x2000) | set('0123456789:,.?!-+()·×→←✓≈‹,。:、'))
+open(os.path.join(HERE, 'chars.txt'), 'w', encoding='utf-8').write(''.join(chars))
+from fontTools import subset
+subset.main([os.path.join(HERE, 'NotoSansSC-VF.ttf'), '--text-file=' + os.path.join(HERE, 'chars.txt'), '--output-file=' + os.path.join(D, 'fonts', 'NotoSansSC-sub.ttf'), '--layout-features=*', '--no-hinting'])
+print(len(chars), 'chars')
diff --git a/styles/desktop-flythrough/demo/vo/dur.json b/styles/desktop-flythrough/demo/vo/dur.json
new file mode 100644
index 0000000..f5efa70
--- /dev/null
+++ b/styles/desktop-flythrough/demo/vo/dur.json
@@ -0,0 +1,16 @@
+{
+ "v01": 3.612,
+ "v02": 2.454,
+ "v03": 2.827,
+ "v04": 6.002,
+ "v05": 2.799,
+ "v06": 5.045,
+ "v07": 1.88,
+ "v08": 3.605,
+ "v09": 1.958,
+ "v10": 4.418,
+ "v11": 4.611,
+ "v12": 2.952,
+ "v13": 3.894,
+ "v14": 2.793
+}
\ No newline at end of file
diff --git a/styles/desktop-flythrough/demo/vo/lines.json b/styles/desktop-flythrough/demo/vo/lines.json
new file mode 100644
index 0000000..a5c4cb7
--- /dev/null
+++ b/styles/desktop-flythrough/demo/vo/lines.json
@@ -0,0 +1,62 @@
+[
+ {
+ "id": "v01",
+ "text": "你给朋友发了张猫,叮的一声,对面马上就收到了。"
+ },
+ {
+ "id": "v02",
+ "text": "可这张照片,并没有直接飞过去。"
+ },
+ {
+ "id": "v03",
+ "text": "按下发送的那一刻,第一步,是压小。"
+ },
+ {
+ "id": "v04",
+ "text": "原图太大、传得太慢,软件会先把它悄悄压缩,体积小了,看着却差不多。",
+ "asr": "原图太大,船的太慢,软件会先把它敲敲压缩,体积小了,看着却差不多。"
+ },
+ {
+ "id": "v05",
+ "text": "接着,照片来到第二站,服务器。",
+ "rate": "+8%"
+ },
+ {
+ "id": "v06",
+ "text": "也就是聊天软件的云端中转站,照片先存放在这儿,等着对面来取。"
+ },
+ {
+ "id": "v07",
+ "text": "第三步,才轮到发通知。"
+ },
+ {
+ "id": "v08",
+ "text": "服务器拍了拍朋友的手机,嘿,有张照片找你。"
+ },
+ {
+ "id": "v09",
+ "text": "这时候,手机才响了一声。"
+ },
+ {
+ "id": "v10",
+ "text": "收到通知后,朋友的手机才真正去服务器,把照片取回来。"
+ },
+ {
+ "id": "v11",
+ "text": "所以网慢的时候,你会看到它先糊一下,再瞬间变清楚。",
+ "asr": "所以,往慢的时候,你会看到,他先胡以下,再瞬间变清楚。"
+ },
+ {
+ "id": "v12",
+ "text": "一声叮的背后,其实是一场无声的接力。"
+ },
+ {
+ "id": "v13",
+ "text": "如果你没勾原图,朋友收到的,只是那只猫的压缩版。",
+ "asr": "如果你没勾援图,朋友收到的,只是那只猫的压缩板。"
+ },
+ {
+ "id": "v14",
+ "text": "而真正的原图,一直都在你的手机里。"
+ }
+]
\ No newline at end of file
diff --git a/styles/desktop-flythrough/demo/vo/lines_en.json b/styles/desktop-flythrough/demo/vo/lines_en.json
new file mode 100644
index 0000000..47b34cf
--- /dev/null
+++ b/styles/desktop-flythrough/demo/vo/lines_en.json
@@ -0,0 +1,69 @@
+[
+ {
+ "id": "v01",
+ "text": "You send a friend a cat photo. Ding, it arrives right away.",
+ "say": "You send a friend a cat photo, ding, it arrives right away."
+ },
+ {
+ "id": "v02",
+ "text": "But the photo didn't fly straight there."
+ },
+ {
+ "id": "v03",
+ "text": "The moment you hit send, step one: make it smaller.",
+ "rate": "+15%"
+ },
+ {
+ "id": "v04",
+ "text": "The original is too big and slow to send, so the app quietly compresses it: smaller, yet it looks about the same.",
+ "rate": "+15%"
+ },
+ {
+ "id": "v05",
+ "text": "Next, the photo reaches stop two: the server.",
+ "rate": "+13%"
+ },
+ {
+ "id": "v06",
+ "text": "That's the chat app's relay station in the cloud. The photo waits here to be picked up."
+ },
+ {
+ "id": "v07",
+ "text": "Only then comes step three: the notification.",
+ "rate": "+15%",
+ "say": "Step three: the notification.",
+ "asr": "Step three: the notification."
+ },
+ {
+ "id": "v08",
+ "text": "The server taps your friend's phone: \"Hey, a photo for you.\"",
+ "say": "The server taps, your friend's phone: \"Hey, a photo for you.\""
+ },
+ {
+ "id": "v09",
+ "text": "That's when the phone goes ding.",
+ "say": "That's when the phone goes: ding!"
+ },
+ {
+ "id": "v10",
+ "text": "After the notification, your friend's phone goes to the server and fetches the photo."
+ },
+ {
+ "id": "v11",
+ "text": "So on a slow connection, you see it blurry for a moment, then suddenly sharp.",
+ "say": "So on a slow connection, you see it, blurry for a moment, then suddenly sharp."
+ },
+ {
+ "id": "v12",
+ "text": "Behind that one ding is a silent relay."
+ },
+ {
+ "id": "v13",
+ "text": "Unless you ticked \"Original\", what your friend gets is just a compressed copy of the cat.",
+ "rate": "+25%"
+ },
+ {
+ "id": "v14",
+ "text": "The real original has been on your phone all along."
+ }
+]
\ No newline at end of file
diff --git a/styles/desktop-flythrough/demo/vo/timeline.json b/styles/desktop-flythrough/demo/vo/timeline.json
new file mode 100644
index 0000000..ffad35d
--- /dev/null
+++ b/styles/desktop-flythrough/demo/vo/timeline.json
@@ -0,0 +1,103 @@
+{
+ "dur": 59.95,
+ "lines": [
+ {
+ "id": "v01",
+ "t0": 0.8,
+ "t1": 4.412,
+ "zh": "你给朋友发了张猫,叮的一声,对面马上就收到了。",
+ "en": "You send a friend a cat photo. Ding, it arrives right away."
+ },
+ {
+ "id": "v02",
+ "t0": 4.812,
+ "t1": 7.266,
+ "zh": "可这张照片,并没有直接飞过去。",
+ "en": "But the photo didn't fly straight there."
+ },
+ {
+ "id": "v03",
+ "t0": 7.766,
+ "t1": 10.593,
+ "zh": "按下发送的那一刻,第一步,是压小。",
+ "en": "The moment you hit send, step one: make it smaller."
+ },
+ {
+ "id": "v04",
+ "t0": 10.893,
+ "t1": 16.895,
+ "zh": "原图太大、传得太慢,软件会先把它悄悄压缩,体积小了,看着却差不多。",
+ "en": "The original is too big and slow to send, so the app quietly compresses it: smaller, yet it looks about the same."
+ },
+ {
+ "id": "v05",
+ "t0": 17.495,
+ "t1": 20.294,
+ "zh": "接着,照片来到第二站,服务器。",
+ "en": "Next, the photo reaches stop two: the server."
+ },
+ {
+ "id": "v06",
+ "t0": 20.594,
+ "t1": 25.639,
+ "zh": "也就是聊天软件的云端中转站,照片先存放在这儿,等着对面来取。",
+ "en": "That's the chat app's relay station in the cloud. The photo waits here to be picked up."
+ },
+ {
+ "id": "v07",
+ "t0": 26.239,
+ "t1": 28.119,
+ "zh": "第三步,才轮到发通知。",
+ "en": "Only then comes step three: the notification."
+ },
+ {
+ "id": "v08",
+ "t0": 28.419,
+ "t1": 32.024,
+ "zh": "服务器拍了拍朋友的手机,嘿,有张照片找你。",
+ "en": "The server taps your friend's phone: \"Hey, a photo for you.\""
+ },
+ {
+ "id": "v09",
+ "t0": 32.324,
+ "t1": 34.282,
+ "zh": "这时候,手机才响了一声。",
+ "en": "That's when the phone goes ding."
+ },
+ {
+ "id": "v10",
+ "t0": 34.882,
+ "t1": 39.3,
+ "zh": "收到通知后,朋友的手机才真正去服务器,把照片取回来。",
+ "en": "After the notification, your friend's phone goes to the server and fetches the photo."
+ },
+ {
+ "id": "v11",
+ "t0": 39.6,
+ "t1": 44.211,
+ "zh": "所以网慢的时候,你会看到它先糊一下,再瞬间变清楚。",
+ "en": "So on a slow connection, you see it blurry for a moment, then suddenly sharp."
+ },
+ {
+ "id": "v12",
+ "t0": 44.811,
+ "t1": 47.763,
+ "zh": "一声叮的背后,其实是一场无声的接力。",
+ "en": "Behind that one ding is a silent relay."
+ },
+ {
+ "id": "v13",
+ "t0": 48.113,
+ "t1": 52.007,
+ "zh": "如果你没勾原图,朋友收到的,只是那只猫的压缩版。",
+ "en": "Unless you ticked \"Original\", what your friend gets is just a compressed copy of the cat."
+ },
+ {
+ "id": "v14",
+ "t0": 52.307,
+ "t1": 55.1,
+ "zh": "而真正的原图,一直都在你的手机里。",
+ "en": "The real original has been on your phone all along."
+ }
+ ]
+}
\ No newline at end of file
diff --git a/styles/desktop-flythrough/demo/vo/words.json b/styles/desktop-flythrough/demo/vo/words.json
new file mode 100644
index 0000000..7f94aa9
--- /dev/null
+++ b/styles/desktop-flythrough/demo/vo/words.json
@@ -0,0 +1,1140 @@
+{
+"v01": [
+[
+"你",
+-0.6,
+0.1
+],
+[
+"给",
+0.1,
+0.2
+],
+[
+"朋友",
+0.2,
+0.44
+],
+[
+"发",
+0.44,
+0.62
+],
+[
+"了",
+0.62,
+0.72
+],
+[
+"张",
+0.72,
+0.86
+],
+[
+"猫,",
+0.86,
+1.08
+],
+[
+"叮",
+1.38,
+1.46
+],
+[
+"的",
+1.46,
+1.6
+],
+[
+"一",
+1.6,
+1.78
+],
+[
+"声,",
+1.78,
+1.94
+],
+[
+"对",
+2.3,
+2.36
+],
+[
+"面",
+2.36,
+2.52
+],
+[
+"马",
+2.52,
+2.7
+],
+[
+"上",
+2.7,
+2.9
+],
+[
+"就",
+2.9,
+3.04
+],
+[
+"收",
+3.04,
+3.2
+],
+[
+"到了。",
+3.2,
+3.4
+]
+],
+"v02": [
+[
+"可",
+-0.6,
+0.12
+],
+[
+"这",
+0.12,
+0.26
+],
+[
+"张",
+0.26,
+0.4
+],
+[
+"照",
+0.4,
+0.56
+],
+[
+"片",
+0.56,
+0.86
+],
+[
+"并",
+0.86,
+1.24
+],
+[
+"没有",
+1.24,
+1.42
+],
+[
+"直接",
+1.42,
+1.7
+],
+[
+"飞",
+1.7,
+1.96
+],
+[
+"过",
+1.96,
+2.12
+],
+[
+"去。",
+2.12,
+2.34
+]
+],
+"v03": [
+[
+"按",
+-0.22,
+0.14
+],
+[
+"下",
+0.14,
+0.3
+],
+[
+"发",
+0.3,
+0.46
+],
+[
+"送",
+0.46,
+0.62
+],
+[
+"的",
+0.62,
+0.72
+],
+[
+"那",
+0.72,
+0.84
+],
+[
+"一",
+0.84,
+1.02
+],
+[
+"刻,",
+1.02,
+1.16
+],
+[
+"第一",
+1.4,
+1.6
+],
+[
+"步,",
+1.6,
+1.9
+],
+[
+"是",
+2.16,
+2.28
+],
+[
+"压",
+2.28,
+2.46
+],
+[
+"小。",
+2.46,
+2.66
+]
+],
+"v04": [
+[
+"原",
+-0.6,
+0.16
+],
+[
+"图",
+0.16,
+0.3
+],
+[
+"太",
+0.3,
+0.5
+],
+[
+"大,",
+0.5,
+0.74
+],
+[
+"船",
+1.0,
+1.1
+],
+[
+"的",
+1.1,
+1.2
+],
+[
+"太",
+1.2,
+1.36
+],
+[
+"慢,",
+1.36,
+1.58
+],
+[
+"软",
+1.94,
+2.12
+],
+[
+"件",
+2.12,
+2.26
+],
+[
+"会",
+2.26,
+2.5
+],
+[
+"先",
+2.5,
+2.86
+],
+[
+"把它",
+2.86,
+3.08
+],
+[
+"敲",
+3.08,
+3.28
+],
+[
+"敲",
+3.28,
+3.44
+],
+[
+"压",
+3.44,
+3.68
+],
+[
+"缩,",
+3.68,
+3.86
+],
+[
+"体",
+4.1,
+4.24
+],
+[
+"积",
+4.24,
+4.38
+],
+[
+"小",
+4.38,
+4.58
+],
+[
+"了,",
+4.58,
+4.8
+],
+[
+"看",
+5.06,
+5.2
+],
+[
+"着",
+5.2,
+5.3
+],
+[
+"却",
+5.3,
+5.44
+],
+[
+"差不多。",
+5.44,
+5.76
+]
+],
+"v05": [
+[
+"接",
+-0.6,
+0.16
+],
+[
+"着,",
+0.16,
+0.4
+],
+[
+"照",
+0.7,
+0.82
+],
+[
+"片",
+0.82,
+1.06
+],
+[
+"来",
+1.06,
+1.22
+],
+[
+"到",
+1.22,
+1.38
+],
+[
+"第二",
+1.38,
+1.62
+],
+[
+"站,",
+1.62,
+1.88
+],
+[
+"服",
+2.16,
+2.32
+],
+[
+"务",
+2.32,
+2.48
+],
+[
+"器。",
+2.48,
+2.64
+]
+],
+"v06": [
+[
+"也",
+-0.24,
+0.12
+],
+[
+"就是",
+0.12,
+0.3
+],
+[
+"聊",
+0.3,
+0.52
+],
+[
+"天",
+0.52,
+0.7
+],
+[
+"软",
+0.7,
+0.88
+],
+[
+"件",
+0.88,
+1.04
+],
+[
+"的",
+1.04,
+1.16
+],
+[
+"云",
+1.16,
+1.32
+],
+[
+"端",
+1.32,
+1.44
+],
+[
+"中",
+1.44,
+1.6
+],
+[
+"转",
+1.6,
+1.78
+],
+[
+"站,",
+1.78,
+2.04
+],
+[
+"照",
+2.34,
+2.48
+],
+[
+"片",
+2.48,
+2.74
+],
+[
+"先",
+2.74,
+2.92
+],
+[
+"存",
+2.92,
+3.1
+],
+[
+"放",
+3.1,
+3.28
+],
+[
+"在",
+3.28,
+3.46
+],
+[
+"这",
+3.46,
+3.64
+],
+[
+"儿,",
+3.64,
+3.94
+],
+[
+"等",
+3.96,
+4.04
+],
+[
+"着",
+4.04,
+4.18
+],
+[
+"对",
+4.18,
+4.28
+],
+[
+"面",
+4.28,
+4.5
+],
+[
+"来",
+4.5,
+4.66
+],
+[
+"取。",
+4.66,
+4.9
+]
+],
+"v07": [
+[
+"第三",
+-0.08,
+0.28
+],
+[
+"步,",
+0.28,
+0.56
+],
+[
+"才",
+0.8,
+0.9
+],
+[
+"轮",
+0.9,
+1.06
+],
+[
+"到",
+1.06,
+1.2
+],
+[
+"发",
+1.2,
+1.36
+],
+[
+"通",
+1.36,
+1.52
+],
+[
+"知。",
+1.52,
+1.72
+]
+],
+"v08": [
+[
+"服",
+-0.2,
+0.16
+],
+[
+"务",
+0.16,
+0.28
+],
+[
+"器",
+0.28,
+0.44
+],
+[
+"拍",
+0.44,
+0.7
+],
+[
+"了",
+0.7,
+0.78
+],
+[
+"拍",
+0.78,
+0.92
+],
+[
+"朋友",
+0.92,
+1.14
+],
+[
+"的",
+1.14,
+1.28
+],
+[
+"手",
+1.28,
+1.42
+],
+[
+"机,",
+1.42,
+1.68
+],
+[
+"嘿,",
+1.98,
+2.16
+],
+[
+"有",
+2.52,
+2.6
+],
+[
+"张",
+2.6,
+2.76
+],
+[
+"照",
+2.76,
+2.9
+],
+[
+"片",
+2.9,
+3.1
+],
+[
+"找",
+3.1,
+3.3
+],
+[
+"你。",
+3.3,
+3.48
+]
+],
+"v09": [
+[
+"这",
+-0.2,
+0.16
+],
+[
+"时候,",
+0.16,
+0.48
+],
+[
+"手",
+0.8,
+0.9
+],
+[
+"机",
+0.9,
+1.1
+],
+[
+"才",
+1.1,
+1.24
+],
+[
+"响",
+1.24,
+1.42
+],
+[
+"了",
+1.42,
+1.54
+],
+[
+"一",
+1.54,
+1.66
+],
+[
+"声。",
+1.66,
+1.8
+]
+],
+"v10": [
+[
+"收",
+-0.2,
+0.16
+],
+[
+"到",
+0.16,
+0.28
+],
+[
+"通",
+0.28,
+0.42
+],
+[
+"知",
+0.42,
+0.6
+],
+[
+"后,",
+0.6,
+0.8
+],
+[
+"朋友",
+1.1,
+1.32
+],
+[
+"的",
+1.32,
+1.46
+],
+[
+"手",
+1.46,
+1.6
+],
+[
+"机",
+1.6,
+1.86
+],
+[
+"才",
+1.86,
+2.14
+],
+[
+"真",
+2.14,
+2.32
+],
+[
+"正",
+2.32,
+2.48
+],
+[
+"去",
+2.48,
+2.62
+],
+[
+"服",
+2.62,
+2.76
+],
+[
+"务",
+2.76,
+2.88
+],
+[
+"器,",
+2.88,
+3.08
+],
+[
+"把",
+3.34,
+3.46
+],
+[
+"照",
+3.46,
+3.6
+],
+[
+"片",
+3.6,
+3.82
+],
+[
+"取",
+3.82,
+3.98
+],
+[
+"回",
+3.98,
+4.16
+],
+[
+"来。",
+4.16,
+4.3
+]
+],
+"v11": [
+[
+"所以,",
+-0.06,
+0.3
+],
+[
+"往",
+0.58,
+0.68
+],
+[
+"慢",
+0.68,
+0.88
+],
+[
+"的时候,",
+0.88,
+1.22
+],
+[
+"你",
+1.64,
+1.7
+],
+[
+"会",
+1.7,
+1.8
+],
+[
+"看到,",
+1.8,
+2.06
+],
+[
+"他",
+2.38,
+2.48
+],
+[
+"先",
+2.48,
+2.66
+],
+[
+"胡",
+2.66,
+2.84
+],
+[
+"以",
+2.84,
+3.0
+],
+[
+"下,",
+3.0,
+3.18
+],
+[
+"再",
+3.52,
+3.6
+],
+[
+"瞬",
+3.6,
+3.78
+],
+[
+"间",
+3.78,
+3.96
+],
+[
+"变",
+3.96,
+4.08
+],
+[
+"清楚。",
+4.08,
+4.42
+]
+],
+"v12": [
+[
+"一",
+-0.22,
+0.14
+],
+[
+"声",
+0.14,
+0.3
+],
+[
+"钉",
+0.3,
+0.44
+],
+[
+"的",
+0.44,
+0.54
+],
+[
+"背",
+0.54,
+0.7
+],
+[
+"后,",
+0.7,
+0.98
+],
+[
+"其实",
+1.22,
+1.42
+],
+[
+"是",
+1.42,
+1.72
+],
+[
+"一",
+1.72,
+1.84
+],
+[
+"场",
+1.84,
+1.98
+],
+[
+"无",
+1.98,
+2.18
+],
+[
+"声",
+2.18,
+2.36
+],
+[
+"的",
+2.36,
+2.48
+],
+[
+"接",
+2.48,
+2.64
+],
+[
+"力。",
+2.64,
+2.84
+]
+],
+"v13": [
+[
+"如果你",
+-0.1,
+0.26
+],
+[
+"没",
+0.26,
+0.48
+],
+[
+"勾",
+0.48,
+0.6
+],
+[
+"援",
+0.6,
+0.8
+],
+[
+"图,",
+0.8,
+1.06
+],
+[
+"朋友",
+1.34,
+1.5
+],
+[
+"收",
+1.5,
+1.78
+],
+[
+"到",
+1.78,
+1.98
+],
+[
+"的,",
+1.98,
+2.14
+],
+[
+"只是",
+2.48,
+2.66
+],
+[
+"那",
+2.66,
+2.82
+],
+[
+"只",
+2.82,
+2.96
+],
+[
+"猫",
+2.96,
+3.12
+],
+[
+"的",
+3.12,
+3.24
+],
+[
+"压",
+3.24,
+3.4
+],
+[
+"缩",
+3.4,
+3.56
+],
+[
+"板。",
+3.56,
+3.74
+]
+],
+"v14": [
+[
+"而",
+-0.6,
+0.14
+],
+[
+"真",
+0.14,
+0.3
+],
+[
+"正",
+0.3,
+0.48
+],
+[
+"的",
+0.48,
+0.58
+],
+[
+"圆",
+0.58,
+0.76
+],
+[
+"图",
+0.76,
+1.04
+],
+[
+"一直",
+1.04,
+1.5
+],
+[
+"都",
+1.5,
+1.72
+],
+[
+"在",
+1.72,
+1.9
+],
+[
+"你的",
+1.9,
+2.04
+],
+[
+"手",
+2.04,
+2.24
+],
+[
+"机",
+2.24,
+2.48
+],
+[
+"里。",
+2.48,
+2.66
+]
+]
+}
\ No newline at end of file
diff --git a/styles/desktop-flythrough/desktop-flythrough.srt b/styles/desktop-flythrough/desktop-flythrough.srt
new file mode 100644
index 0000000..aa43e45
--- /dev/null
+++ b/styles/desktop-flythrough/desktop-flythrough.srt
@@ -0,0 +1,69 @@
+1
+00:00:00,680 --> 00:00:04,692
+你给朋友发了张猫,叮的一声,对面马上就收到了。
+You send a friend a cat photo. Ding, it arrives right away.
+
+2
+00:00:04,692 --> 00:00:07,646
+可这张照片,并没有直接飞过去。
+But the photo didn't fly straight there.
+
+3
+00:00:07,646 --> 00:00:10,773
+按下发送的那一刻,第一步,是压小。
+The moment you hit send, step one: make it smaller.
+
+4
+00:00:10,773 --> 00:00:17,375
+原图太大、传得太慢,软件会先把它悄悄压缩,体积小了,看着却差不多。
+The original is too big and slow to send, so the app quietly compresses it: smaller, yet it looks about the same.
+
+5
+00:00:17,375 --> 00:00:20,474
+接着,照片来到第二站,服务器。
+Next, the photo reaches stop two: the server.
+
+6
+00:00:20,474 --> 00:00:26,119
+也就是聊天软件的云端中转站,照片先存放在这儿,等着对面来取。
+That's the chat app's relay station in the cloud. The photo waits here to be picked up.
+
+7
+00:00:26,119 --> 00:00:28,299
+第三步,才轮到发通知。
+Only then comes step three: the notification.
+
+8
+00:00:28,299 --> 00:00:32,204
+服务器拍了拍朋友的手机,嘿,有张照片找你。
+The server taps your friend's phone: "Hey, a photo for you."
+
+9
+00:00:32,204 --> 00:00:34,762
+这时候,手机才响了一声。
+That's when the phone goes ding.
+
+10
+00:00:34,762 --> 00:00:39,480
+收到通知后,朋友的手机才真正去服务器,把照片取回来。
+After the notification, your friend's phone goes to the server and fetches the photo.
+
+11
+00:00:39,480 --> 00:00:44,691
+所以网慢的时候,你会看到它先糊一下,再瞬间变清楚。
+So on a slow connection, you see it blurry for a moment, then suddenly sharp.
+
+12
+00:00:44,691 --> 00:00:47,993
+一声叮的背后,其实是一场无声的接力。
+Behind that one ding is a silent relay.
+
+13
+00:00:47,993 --> 00:00:52,187
+如果你没勾原图,朋友收到的,只是那只猫的压缩版。
+Unless you ticked "Original", what your friend gets is just a compressed copy of the cat.
+
+14
+00:00:52,187 --> 00:00:55,600
+而真正的原图,一直都在你的手机里。
+The real original has been on your phone all along.
diff --git a/styles/desktop-flythrough/poster.jpg b/styles/desktop-flythrough/poster.jpg
new file mode 100644
index 0000000..ceb5a34
Binary files /dev/null and b/styles/desktop-flythrough/poster.jpg differ
diff --git a/styles/desktop-flythrough/style.json b/styles/desktop-flythrough/style.json
new file mode 100644
index 0000000..1b80893
--- /dev/null
+++ b/styles/desktop-flythrough/style.json
@@ -0,0 +1,19 @@
+{
+ "slug": "desktop-flythrough",
+ "num": "77",
+ "en": "Desktop Flythrough",
+ "cn": "桌面穿梭",
+ "category_en": "Materials & 3D",
+ "category_cn": "材质与 3D",
+ "film": "Before the Ding",
+ "line": "A cat photo hops across app cards laid on a sunlit desk, squeezed by a press, parked in a server tower and fetched by a friend's phone, as one camera flies after it.",
+ "line_cn": "一张猫照片在阳光下的桌面上跳过一张张应用卡片:被压小、存进服务器小楼、再被朋友的手机取回,一个镜头一路跟着飞。",
+ "uses": [
+ "How an app works, step by step",
+ "Workflows across several tools",
+ "Product and feature explainers",
+ "Data moving between devices"
+ ],
+ "frame_sec": 56.85,
+ "dur": 59.95
+}