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 种现成风格,也能做出你自己的
JavaScript agent-skillsai-agentsai-short-filmai-videoanimationcanvasclaudeclaude-codeclaude-code-pluginclaude-code-skillcreative-codingffmpegfilmmakingmotion-graphicsopus-5-5prompt-librarytext-to-speechthreejsvideo-productionwebgl
Printed Long Take: a scratchboard print in one unbroken take, with narration and bilingual subtitles
lemomo-ai947694093da3
diff --git a/styles/printed-long-take/DEMO.md b/styles/printed-long-take/DEMO.mdnew file mode 100644index 0000000..60a0aa9--- /dev/null+++ b/styles/printed-long-take/DEMO.md@@ -0,0 +1,74 @@+# Printed Long Take — our demo++One example among many. Don't reuse its story, arc, shots, props or timings.++Demo: *Thirty-Three Cranes* 《三十三只》 (60.0 s) · `printed-long-take.mp4` (English narration) · source in [`demo/`](demo/)++## Story & structure++A January dawn at minus twenty on the Setsuri river at Tsurui, in the wetlands of eastern Hokkaido. The river is spring-fed and does not freeze; red-crowned cranes sleep standing in it. The crowns wake one by one, the flock lifts off over the cleared marsh to a feeding field, where a board says that in the winter of 1952 only 33 cranes were found in all of Hokkaido. Feeding began that year; the same field is printed again as the numbers grow; the board is cut with the January 2025 count, 1,927, and "Vulnerable" is struck and sealed "Near Threatened" (Ministry of the Environment, March 2026). A narrator tells it in eleven short lines; every line has a subtitle bar, Chinese above English. Every fact is in [`demo/FACTS.md`](demo/FACTS.md). The bridge name 音羽橋 on the plate is the real bridge's name; the plate, thermometer, board, notice and seal are our own drawing.++Why it fits: the crane is already ink, paper and one red, so the single red needs no excuse; the steaming river, rimed trees and volcano row are what knife cuts draw well. Native moves spent: the sky carved open and one red waking (dawn), through the steam (takeoff into the air), the same place printed again (the four prints, the red as a second plate), words cut into the world (plate, board, seal), a plate of type in the sky (title and end card).++## Shots++| # | Time | Narration | Shot | Camera |+|---|---|---|---|---|+| 1 | 0–5.2 | line 1 | night valley, volcano row, windbreak grid, steaming river; title cut into the sky (0.15–5.0) | high wide, sinking |+| 2 | 5.2–7.5 | line 2 | low over the water toward the bridge | glide, decelerating |+| 3 | 7.5–11.3 | — | stone pier with the cast-iron plate 音羽橋 / Otowa Bridge and a dial at −20, snow and icicles; then past the pier and under the bridge | long-lens hold, then the pass slowed to half speed with an ease in and out (10.0–11.3) |+| 4 | 11.3–14.1 | line 3 | sleeping cranes close in the water, the sky starting to be cut | water level, low aim |+| 5 | 14.1–16.6 | — | crowns wake left to right; the nearest pair calls | tilting up with the dawn |+| 6 | 16.6–19.35 | — | run, splash, lift off; into the steam (19.1–19.55, under half a second of paper) | rising with the leaders |+| 7 | 19.35–24.4 | line 4 | aerial over the marsh; tilts down to the cleared field grid (20.9–22.6) | tracking behind |+| 8 | 24.4–29.0 | line 5 | following one crane down into the corn field | follow, then along the fence |+| 9 | 29.0–34.0 | line 6 | the board: 丹顶鹤 · 冬季清点, 1952 年冬, 33 只; notice 保护等级 易危 | near-still |+| 10 | 34.0–38.3 | line 7 | the 1952 print: 33 cranes, deep snow, tracks; corn spreads at 37.0 | locked |+| 11 | 38.3–41.7 | line 8 | peels at 39.3, 40.1, 40.8; each print gets its red a beat later, a hair off register | locked |+| 12 | 41.7–46.1 | line 9 | 2025 年 1 月 and 1,927 只 cut into the right column (42.0–44.1) | near-still |+| 13 | 46.1–51.8 | line 10 | 易危 struck at 48.0; the seal 近危 2026.3 and 已移出濒危 at 48.95, one frame of shake | near-still |+| 14 | 51.8–56.8 | line 11 | a quick turn off the board to a pair dancing; crane up to the opening direction | rise and pull back |+| 15 | 56.8–60.0 | — | end card cut into the day sky | still |++## Narration++The voice reads one line per cue; Chinese and English start at the same moments, and the subtitle bar (and `printed-long-take.srt`) shows both lines.++| # | Chinese | English |+|---|---|---|+| 1 | 这么冷的清晨,河水却没有结冰,还升腾着阵阵白汽。 | On a morning this cold, the river still hasn’t frozen; it breathes white steam. |+| 2 | 这里是北海道东部的湿地。 | This is a wetland in eastern Hokkaido. |+| 3 | 站在河水里安静睡觉的,是丹顶鹤。 | Asleep, standing in the water: red-crowned cranes. |+| 4 | 早年间,随着湿地被一片片开垦,它们差点就彻底失去了家园。 | Long ago, as the wetlands were cleared field by field, they nearly lost their home for good. |+| 5 | 天亮后,它们成群飞去的地方,是一块专门撒满玉米的田地。 | At daybreak they fly in flocks to a field scattered with corn, just for them. |+| 6 | 回想一九五二年冬天,整个北海道,一共只找到了三十三只丹顶鹤。 | Think back to the winter of 1952: in all of Hokkaido, only 33 cranes were found. |+| 7 | 也是从那一年起,当地人决定在冬天给它们投喂食物。 | That was the year local people decided to feed them through the winter. |+| 8 | 就这样,丹顶鹤的数量,一年比一年多。 | And so, year after year, there were more of them. |+| 9 | 到了二零二五年,已经数到了一千九百二十七只。 | By 2025 the count had reached 1,927. |+| 10 | 它们的保护级别,也终于从易危,降到了近危。 | Their status finally eased, from Vulnerable to Near Threatened. |+| 11 | 虽然不再算作濒危物种了,但这群雪地里的精灵,依然需要人们的守护。 | No longer counted as endangered, these spirits of the snow still need people to look after them. |++- English (the library demo): edge-tts `en-US-AvaNeural`, `+10%`; lines 1, 4, 5, 6 and 9 at `+25%`. In the spoken version only (`say` in `demo/lines_en.json`), line 1 drops "still", line 6 drops "Think back to", line 9 drops "had" and reads the number as "one thousand nine hundred twenty-seven", line 5 gets a pause after "daybreak".+- Chinese: edge-tts `zh-CN-XiaoxiaoNeural`, `+25%`.+- Line starts (s): 1.0, 5.4, 11.11, 19.6, 24.6, 29.2, 34.2, 38.5, 41.9, 46.3, 52.0 (`VO` in `demo/timeline.js`, before the bridge slow-down; `window.EV` and the subtitles carry them through it).++## Score structure++72 bpm in three, D dorian to D major, ducked about 17 dB under the voice (foley about 7 dB) and up again in the silent shots 3, 5, 6 and 15. Night: bowed vibraphone, a double bass pedal, glockenspiel under the title; harp on every beat from 5.5 s, slowing with the picture under the bridge. Dawn: the horn theme, hand chimes. Takeoff: timpani and string tremolo, cut by the steam. Air: pizzicato bass and xylophone in three. Prints: timpani and pizzicato strokes on the block thumps and the corn. Verdict: a held bass A1, the seal with a gran cassa, the theme in D major on horn, harp from 51.8 s, a long D major chord and three glockenspiel notes on the end card. Foley: the river under its ice edge, frost cracks, synthesised crane calls, splashes and wing beats, wind, snow crunches, pecking, knife cuts, block thumps, a torn sheet, the seal. Mix before the master: −16.0 LUFS, true peak −2.1 dBFS, 60.00 s.++## Palette & props++Ink `#16171b`, paper `#ede5cd`, red `#c4332b` only on crowns (each with a thin paper ring, never under 5 px by day), yellow `#dfa443` for the sun, its light and the corn. Props: the volcano row (an even cone, a broad massif with a crater rim, a small cone), the windbreak grid, rimed alders and willows, a stone pier with a cast-iron plate, a dial thermometer, snow and icicles; a fenced feeding field with huts, corn, crane tracks and fence shadows; a plank board in two columns (1952 | 2025) over a pasted status notice, Chinese and numbers only, with a square seal. Cranes: 16 silhouette poses; distant ones drawn up to 3× larger.++## End card++Cut into the day sky as an ink plate over the still wide shot, upper right and at least 5% inside the frame: 三十三只 / Thirty-Three Cranes / LemoLab × Claude Opus 5.5, from 56.8 to 60.0 s. 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/printed-long-take/demo/build.sh` makes `printed-long-take.mp4` with the English narration; `sh styles/printed-long-take/demo/build.sh zh` makes `printed-long-take-zh.mp4` with the Chinese one. Steps: font subset (`tools/subset.py`, Noto Serif SC 700 from github.com/google/fonts), narration with edge-tts into `voice/<lang>/` and `asr_check.py`, `events.mjs`, `audio.py [zh]` → `mix.wav`, `video.mjs`, `mux.sh`, `tools/srt.py` → `printed-long-take.srt`, `readcheck.mjs`, poster and style frame at 15.4 s.+- Files: `index.html` → `scene.js` (renderer, print pass with the subtitle bar, flocks, cameras, sky state, the bridge slow-down `WARP`, `window.TEXTS`, `window.EV`), `timeline.js` (every time and `VO`), `world.js` (terrain, river, volcanoes, trees, bridge and pier, field, `Flock`), `look.js` (materials), `textures.js` (atlases), `props.js` (plate, dial, board, sky type), `audio.py` (narration, score, foley, ducking), `lines_zh.json`, `lines_en.json`, `voice/*/dur.json`, `FACTS.md`, `CREDITS`.+- The subtitle bar is timed on the Chinese reading (`voice/zh/dur.json`) in both versions; English lines finish inside the same cues.+- `readcheck.mjs` passes on every word in the world (17 pieces). The subtitle bar follows the speech and is left out by its contract; `?subs=1` reports it too.+- `?atlas=crane|tree|mist|sun` shows an atlas; `?cam=x,y,z,tx,ty,tz` overrides the camera to check a frame.+- Demo-specific pitfalls: the plate and the board must stay fully in frame through their holds; trees are cleared along the camera path (`clearPath`) so the low glide never passes through a crown; the print shot renders two passes during each peel; any time after 10 s written in `timeline.js` is on the timeline before the bridge slow-down.diff --git a/styles/printed-long-take/STYLE.md b/styles/printed-long-take/STYLE.mdnew file mode 100644index 0000000..c7fa0e1--- /dev/null+++ b/styles/printed-long-take/STYLE.md@@ -0,0 +1,121 @@+# Printed Long Take — Style Prompt++> A three-dimensional world rendered as a scratchboard print, ink and paper with one red, crossed by one unbroken camera move. Depth, weather and light are all cut lines; the camera travels through the print instead of the print being turned page by page.+> References (grammar only): wood engraving and scratchboard illustration (tone made by the width of parallel cuts), Japanese shin-hanga landscapes (layered planes of mountain, forest, water), and the single-take tracking shot of documentary nature films (a move that never cuts). Take the cut line, the layering and the unbroken move; never copy a print, an illustrator's figures or a film's route.++## 1. Essence, and what it is not++- **Only ink, paper and one red.** Every value is either ink or paper; grey exists only as a density of lines. One red is reserved for one small subject. A warm yellow may appear for the sun, a lamp or one material, never as a second accent.+- **Tone is cut, not shaded.** Shadow sides of hills carry knife lines that run down the fall line; skies are parallel horizontal cuts whose width makes the light; snow is paper with a few drift strokes; water is ink with cut ripples.+- **Real depth, flat marks.** The scene is built in 3D (terrain, rivers, thousands of trees, buildings), but every surface is drawn with flat marks fixed in world space, so the layers slide past each other like a printed diorama.+- **At least three layers in every frame:** sky / a mountain or forest band / a middle ground of fields, water or snow / a foreground of branches, fences or posts. Ink and paper roughly half and half.+- **One continuous move** carries the story; cuts are rare and designed.++Not woodcut (flat printed blocks, a mostly static camera, one block per image). Not ukiyo-e (flat colour fields, no depth travel). Not a toon-shaded 3D game (no smooth shading, no gradients, no specular). Not a pencil sketch (no hatching that follows form loosely; every line is a knife cut with a blunt entry and a tapered exit).++## 2. Materials & rendering++- **Render model:** three.js scene at 2× supersampling, box-filtered down in a final print pass. Every material is a small shader that decides "ink or paper" per pixel; there is no lighting except one direction used to choose lit and shadow faces.+- **Faceted terrain:** mountains and volcanoes are low-poly cones with flat facets. Lit facets are paper with a few fine ink cuts near the terminator; shadow facets are ink with paper cuts running down the slope. Cut spacing is fixed in world units so lines never swim when the camera moves.+- **Sky in direction space:** a sphere that travels with the camera; cuts are rows of constant elevation, so they stay horizontal and never slide with translation. Night = sparse wavy wind cuts and square stab stars; day = dense parallel cuts, thicker near the horizon. Words in the sky are plates hung in the same direction space.+- **Billboard atlases drawn on canvas:** trees (pines, frosted deciduous trees), animals, steam. Cylindrical billboards for anything standing, spherical with a screen rotation for anything flying. Sample the atlas with a negative mip bias and alpha-test so thin shapes survive at distance.+- **Water** is a ribbon cut into the snow (the ground is discarded inside a river mask), with bank walls and a paper snow lip. Ripples are short cuts across the flow, faded to solid ink where they would turn grey with distance.+- **Print pass (screen space):** paper fibre, ink mottling in the darks, soft grey blotches near the top of the sheet, a two-frame flicker, a light vignette. Nothing else lives in screen space except transitions made of paper (a whiteout, a sheet being peeled).+- **Props with words** (plates, boards, notices) are canvases on meshes: carved letters in paper on an ink ground, or ink on a pasted paper label. They sit at a 3/4 angle with thickness, a snow cap or a rim.++## 3. Colour logic++- Two values carry everything: ink (a warm black) and paper (a warm off-white). Never pure black or pure white, never a third grey fill.+- **One red, reserved for one subject**, kept small (a crown, a lamp, a flag) and never smaller than about 3 px at 1080p; enlarge it a little rather than lose it.+- A warm yellow is allowed for light itself (sun disc, its road on water, warm cuts in a dawn sky, a lamp) and one material at most. It never fills a large area except that one material.+- Value order by depth: far mountains paper with ink shadow facets; forest bands solid ink; the middle ground paper; foreground ink silhouettes. Keep the subject on the opposite value of what lies behind it.+- Example palette: ink `#16171b`, paper `#ede5cd`, red `#c4332b`, yellow `#dfa443`.++## 4. Type & subtitles++- One serif typeface, bold (e.g. Noto Serif SC, OFL), subset to the characters used. Chinese and English each on their own line.+- **Type lives in the world:** carved into a board, cast on a plate, printed on a pasted notice, or cut as a plate of type into the sky. Words in the world carry only keywords and numbers; no centred title cards, no headers.+- Sizes at 1080p: at most three sizes per frame; nothing smaller than 28 px for Chinese or 22 px for Latin; every word at least 5% inside the frame. Left-aligned blocks, aligned by optical edge.+- Words appear the way the medium makes them: cut left to right with chips at the knife, pressed by a seal, revealed under a peeled sheet.+- Reading time: hold every piece ≥ max(1.8 s, characters ÷ 4.5 for CJK + characters ÷ 15 for Latin + 1.5 s); judged comparisons hold still ≥ 2.5 s before the verdict lands.++### Narration & subtitles++When the film tells a story with a narrator:++- **Speech and picture move together.** Each line is spoken while the shot shows what it names; the long take keeps going under the voice, and the silent stretches (a hold to read, a pass through a structure, a flock taking off) are left without words.+- **Words in the world carry only keywords and numbers** (a count on a board, a date on a seal). The sentence is in the voice and the subtitle, not on the props.+- **One subtitle bar per spoken line**, at the bottom inside the 5% safe area: one Chinese line above one English line, never wrapped, in the film's serif, paper letters on a translucent ink band. It appears with the line and leaves with it; keep the subject of each shot above it.+- A second-language version swaps only the voice: the same picture, the same bilingual bar, each line starting at the same moment, finished before the next one starts.++## 5. Motion quality++- The camera moves continuously and slowly; the world moves on ones. The print pass flickers on twos (12 fps), so the image breathes like a worn sheet.+- Easing: long monotone curves; the camera keeps momentum through key positions and decelerates into every hold. No bounce, no shake except one frame for an impact.+- Animals are flat silhouettes with three or four poses per action (sleep, wake, call, peck, walk, run, three wing frames, land, leap, bow). Wings cycle on fixed frames; never morph between poses.+- Steam, snow and splashes are paper marks: horizontal cut wisps, square stabs, short arcs.+- Mountains, horizon and sky texture never move; trees never sway.++## 6. Camera grammar++| Move | What it expresses | Can serve |+|---|---|---|+| High wide establishing frame, sinking and pushing | the whole place at once; the layers separate as it moves | a valley; a coastline; a city seen from its hills |+| Low glide over water or snow | speed, intimacy with the ground; foreground marks rush past | a river journey; a road; a migration |+| Hold on a prop with words, long lens | reading time inside the take | a sign; a plaque; a gauge; a date |+| Pass through a structure (bridge, gate, arch, tunnel) | a threshold, a change of time or light | night to day; outside to inside; then to now |+| Locked frame | a document, a comparison, a count | the same place in four years; before and after |+| Rise and pull back to the opening angle | the place again, changed | a return; a conclusion; an epilogue |+| Follow a flying or falling subject | the subject leads the camera to the next place | birds, a kite, a leaf, a paper plane |++Framing: the horizon sits on a third; the subject is never smaller than 1/20 of the frame height when it must be recognised; words stay inside the frame with a margin of 5% and never cross another object. Allowed transitions: through a structure, through steam or snow (under half a second of white paper), a match on a falling or rising subject, a sheet peeled from the corner, a seal. Forbidden: fades to black, cross-dissolves, slides, page flips, zoom cuts.++## 7. Sound palette++- Three layers. **The world:** the matter of the place (water under ice, frost cracking, wind in three weights, wings, steps on snow, small animal sounds). **The print:** knife through paper or wood, a block's thump, a sheet torn away, a seal pressed; used only on transitions and verdicts, never as a bed. **Music:** a small chamber group of real samples.+- Timbres that suit the medium: bowed vibraphone, harp, horn, low strings, pizzicato bass, xylophone, glockenspiel, timpani. Avoid synth pads and drum kits.+- A three-beat or slow pulse that can stop; silence before a verdict, then one heavy low stroke.+- A narrator, when there is one, sits on top: music ducks about 17 dB under speech and comes back up in the silent stretches; foley ducks about 7 dB.+- Animal calls are recordings with a CC0 or CC BY licence or are synthesised; never CC BY-NC.+- Mix: music sits under the world; the print sounds are the loudest events. Integrated −16 LUFS in the master, true peak under −3 dBTP (the final mux brings it to −14).++## 8. Native moves++- **The sky carved open.** The sky is cut from the horizon up, one row at a time, the newest row still running across; dawn as a carving, not a gradient. *Fits content like:* a factory's first shift; the first day after a war; a city's lights coming on in reverse at dawn.+- **One red waking.** In a field of ink and paper, the single red appears point by point (heads lifting, windows lighting, flags raised) across the frame. *Fits content like:* poppies opening on a hillside; lanterns along a river; the first lit windows of a rebuilt street.+- **Through the steam.** The take passes through a cloud of paper cuts that eats the frame for under half a second; the world on the other side is a different scale or place. *Fits content like:* a ship into fog and out at a harbour; a train through a tunnel's smoke; a balloon through cloud.+- **The same place printed again.** A locked frame of one place; the top sheet peels from the corner to show the next year's print beneath, with ink that has not quite taken. *Fits content like:* a coastline retreating; a forest replanted; a village growing into a town.+- **Words cut into the world.** A count or a date carved into a board, cast in a plate or stamped by a seal while the camera holds. *Fits content like:* a flood mark on a wall; a ship's name on the hull; a record on a mountain hut.+- **A plate of type in the sky.** The title or the sign-off is cut into the sky as an ink block with paper letters, part of the same direction-space sky. *Fits content like:* a title over a skyline; chapter names over a sea; a dedication over a valley.++## 9. Pitfalls of the medium++- **Close-ups expose the flat shading.** 3D props pushed close to the lens look like toys. Keep living subjects to mid shot as flat silhouettes; give close props real materials (carved wood, concrete formwork, cast iron).+- **Empty paper.** A field of snow without layers goes blank. Keep three layers in frame; add drift strokes, reed ticks, thickets, belts.+- **Grey sludge.** Fine cuts at distance average to grey; fade them to solid ink or paper with distance and use negative mip bias for thin sprites.+- **Sliding lines.** Any cut spaced in screen space swims as the camera moves; anchor cuts to world space (or direction space for the sky).+- **The road look.** A dark river with a pale bank lip and regular dashes reads as asphalt. Break the rhythm of bank marks and keep the lip narrow.+- **Small subjects vanish.** Real-scale animals disappear in a wide frame; draw distant ones up to 3× larger (a printmaker's scale), keep the red at its minimum size.+- **Camera through solids.** Clear trees and posts from the camera path before placing scenery; check every low pass frame by frame.+- **Too many greys from post.** Vignette and blotches darken the paper and make the print look dirty; keep them light.++## 10. Engine++- `demo/look.js`: every material. `carveMat(scale)` (faceted terrain cuts), `skyMat` (direction-space sky with `uFront` for carving, `uDense` for day, and `typePlate` for words in the sky), `groundMat(mask, rect)` (snow with a river cut out), `waterMat`, `bankMat`, `concreteMat`, `woodMat`, `billboardMat(tex, mode, opts)` (cylindrical or spherical, `fade` near the camera), `reflectMat`, `crownMat` (minimum-size red points).+- `demo/textures.js`: `pineAtlas`, `frostTreeAtlas` (drawn at 2×), `craneAtlas` with `POSE` and `HEAD` (silhouette poses and where the red sits), `mistAtlas`, `moonCanvas`, `sunCanvas`, `cut()` (the knife stroke used everywhere).+- `demo/world.js`: `buildWorld(scene, proj, clearPath)`, the river ribbon and mask, `volcano(cx, cz, h, r, seed, crater)`, belts and thickets, `Flock` (instanced birds with crowns and reflections, printmaker's scale by distance).+- `demo/props.js`: carved type on canvas (`carvedText`, `plateCanvas`, `boardCanvas`, `skyTypeCanvas`).+- `demo/props.js`, `demo/textures.js` and `demo/look.js` are all the drawing; `demo/scene.js` holds the subtitle bar (`SUBS`, `drawSub`) and the time warp that slows one stretch of the take (`WARP`).+- Minimal example, not in the demo: a lighthouse on a cliff at night: `volcano(0, -800, 120, 400, 7, .8)` for the headland, a white cylinder with `concreteMat`, one red lamp as a `crownMat` point, sea as `waterMat` on a wide ribbon, `skyMat` with `uFront` rising for dawn.++## 11. Variation space++The agent decides the place, the subject that gets the red, the route of the take, where the cuts fall, the words and where they are carved, the pacing and the score.++- **Three structures:** a river followed from source to sea in one take, with the dates carved on bridges; a street at night, one window lit per year, ending on the full street; a mountain hut's logbook, each page a different season of the same view.+- **Three openings:** a single red lamp in a black frame that turns out to be a ship far out at sea; a close cut of frost on a window that the camera passes through into the valley; a title cut into a night sky over a harbour.+- **Three endings:** the camera rises until the place becomes a printed map; a final seal pressed onto the scene itself; the sheet peeled away to show blank paper with the first line of the next story cut in.++---++How our demo was made (story, shots, score, end card, build): [DEMO.md](DEMO.md). Read it after your treatment exists.diff --git a/styles/printed-long-take/demo/CREDITS b/styles/printed-long-take/demo/CREDITSnew file mode 100644index 0000000..68a95cf--- /dev/null+++ b/styles/printed-long-take/demo/CREDITS@@ -0,0 +1,28 @@+Thirty-Three Cranes (三十三只) — Printed Long Take (Lemo-Opuscar) · LemoLab × Claude Opus 5.5++A film about a real place and real counts (see FACTS.md). No photographs, footage, scans, maps, 3D models or AI-generated+images: the valley, river, bridge, trees, cranes, sky, board and paper are drawn in code (world.js, look.js, textures.js,+props.js, scene.js). The bridge's name on the plate is the real name; the plate, thermometer, board, notice and seal are ours.++FONTS (SIL Open Font License 1.1; not in git, build.sh downloads it from github.com/google/fonts)+- Noto Serif SC (variable, NotoSerifSC[wght].ttf) — Google, instanced at weight 700 and subset by tools/subset.py to the+ characters the film prints (fonts/NotoSerifSC-700.woff2). Licence text: fonts/OFL-NotoSerifSC.txt++NARRATION+- Microsoft edge-tts (online neural voices): en-US-AvaNeural for the English version, zh-CN-XiaoxiaoNeural for the Chinese+ one. The text is the film's own (lines_en.json, lines_zh.json).++MUSIC & SOUND+- Original score and sound design written for this film in audio.py: synthesis in numpy through the library's+ core/audio/sfx.py (river, frost, wind, wings, snow, pecking, knife, block, torn paper, seal, and the cranes' calls,+ synthesised: no recording), plus sampled instruments through core/audio/sampler.py: bowed vibraphone, harp, horn,+ cellos, violas, violins (sustain, tremolo), contrabass (sustain, pizzicato), xylophone, glockenspiel, hand chimes,+ timpani, gran cassa.+- Samples (CC0): VS Chamber Orchestra: Community Edition (Versilian Studios), Versilian Community Sample Library+ (Versilian Studios). Downloaded with sh tools/fetch.sh instruments vsco2ce | vcsl.++CODE+- Rendering, speech, sampler and mastering tools from Lemo-Opuscar (MIT), used from the library. three.js (MIT).++FACTS+- Every number and claim on screen and in the narration, with its source and quoted wording: FACTS.md.diff --git a/styles/printed-long-take/demo/FACTS.md b/styles/printed-long-take/demo/FACTS.mdnew file mode 100644index 0000000..609939f--- /dev/null+++ b/styles/printed-long-take/demo/FACTS.md@@ -0,0 +1,37 @@+# Facts on screen — Thirty-Three Cranes++Every number and claim the film shows or the narration says, with an official or authoritative source and the wording quoted.++| On screen | Claim | Source | Quoted wording |+|---|---|---|---|+| Board, rows 1–2: 「1952 年冬 · 第一次清点:33 只」 / "Winter 1952 · first count: 33 cranes" | The first Hokkaido-wide count, at the winter feeding sites, found 33 cranes (survey of 29 Nov 1952) | Ministry of the Environment, Red Data Book 5th ed., Tancho: https://www.env.go.jp/nature/kisho/5th-rl-2026/BI0134_RDB5th.pdf ; MOE press table (2002): https://www.env.go.jp/content/900525768.pdf (release https://www.env.go.jp/press/3180.html) | 「1952 年の冬に 33 羽が確認された。」; 「33羽 S27.11.29」; 「昭和27年からタンチョウの冬期給餌所において毎年実施しており」 |+| Board, rows 3–4: 「2025 · 1,927 只」 / "2025 · 1,927 cranes" | Winter distribution survey of 22 Jan 2025 (Hokkaido Government, commissioned by MOE): 1,927 birds in all, 38 of them kept in captivity | Hokkaido Government: https://www.pref.hokkaido.lg.jp/ks/skn/tantyou.html ; MOE RDB (above) | 「令和7年(2025年)1月22日(水)」「総数1,927羽(成鳥1,694羽、幼鳥162羽、不明33羽、飼育個体38羽)」; 「2025 年 1 月下旬の調査では 1,927 羽が確認された。」 |+| Paper notice 「易危 Vulnerable」 struck; seal 「近危 / Near Threatened / 2026.3」 | MOE 5th Red List (17 Mar 2026) moved the crane from VU to NT, out of the threatened categories | MOE press release, 17 Mar 2026: https://www.env.go.jp/press/press_03312.html ; Hokkaido Shimbun, 17 Mar 2026: https://www.hokkaido-np.co.jp/article/1288160/ | 「絶滅危惧Ⅱ類(VU)から準絶滅危惧(NT)にカテゴリーが1段階引き下げられ、絶滅危惧種から除外された。」; 「■1952年に33羽→2025年は1927羽に」 |+| The feeding field and its corn | Feeding first succeeded in Akan and Tsurui in 1952 | MOE species page: https://www.env.go.jp/nature/kisho/hogozoushoku/tancho.html | 「【昭和27年】阿寒町及び鶴居村にて給餌に成功。」 |+| Four prints of the field (no numbers shown) | Bird counts per print follow the survey trend: 33 (1952), 172 (1965), 458 (1995), 1,927 (2025); drawn at 3 / 13 / 46 / ~300 birds as an illustration | MOE press table (2002): https://www.env.go.jp/content/900525768.pdf | 「172羽 S40.12.4」「458羽 H7.12.5」 |+| The Setsuri river at Otowa Bridge, steaming, unfrozen, cranes roosting in it | Spring-fed, it does not freeze in midwinter; a known roost | Japan National Trust with Tsurui Village, 11 Dec 2025: https://ntrust.or.jp/index/press20251211.pdf ; MOE RDB (above) | 「鶴居村を流れる雪裡川は、真冬でも川が凍らないため、国の特別天然記念物タンチョウの貴重なねぐらとして有名です。」; 「音羽橋がかかる雪裡川は、豊富な湧き水のおかげで真冬でも凍らず」; 「冬は不凍の河川でねぐらをとり」 |+| Red crowns; the pair calling together | The red crown is bare skin; mated pairs give a unison call | MOE RDB (above); International Crane Foundation: https://savingcranes.org/species/red-crowned-crane/ | 「頭頂は皮膚が赤く裸出している。」; "A duet performed by a pair, to strengthen their bond and protect their territory." |+| The volcano row to the north (not named on screen) | The Akan range is seen from Tsurui | Tsurui Village guide: https://www.vill.tsurui.lg.jp/material/files/group/6/p1.pdf | 「阿寒連峰を望みながら、お食事ができます。」 |++Invented for the film: the board and its wording, the pasted notice and the seal, the plate and dial thermometer on the bridge pier (the bridge's name is real), the thermometer reading as a typical January dawn there, the layout of the valley, and how many birds stand in each print.++## Narration++| Narration | Claim | Source | Quoted wording |+|---|---|---|---|+| 这里是北海道东部的湿地 | In Japan the crane lives mainly in the wetlands of eastern Hokkaido | MOE species page: https://www.env.go.jp/nature/kisho/hogozoushoku/tancho.html | 「国内では、北海道東部の湿原を中心に分布している。」 |+| 湿地一片片被开垦,它们差点没了家 | Its wetland habitat was developed on a large scale and shrank | MOE Red Data Book 5th ed.: https://www.env.go.jp/nature/kisho/5th-rl-2026/BI0134_RDB5th.pdf | 「生息地の湿原が大規模に開発されて減少した」 |+| 那年起,人们开始喂它们。鹤一年比一年多 | Feeding succeeded in 1952; winter feeding raised the numbers | MOE species page; RDB 5th ed. (above) | 「【昭和27年】阿寒町及び鶴居村にて給餌に成功。」; 「冬期の給餌により個体数は増加し」 |+| 不再算濒危了,但还得有人守着 | Removed from the threatened categories; risk judged smaller but still to be watched | MOE press release 2026-03-17: https://www.env.go.jp/press/press_03312.html ; RDB 5th ed. | 「絶滅危惧種から除外された。」; 「現時点では絶滅の危険度は小さくなったと考えられるものの…今後も注視が必要である。」 |+| Board v2: 「2025 年 1 月 / January 2025」 | The 1,927 count is the survey of 22 Jan 2025 | Hokkaido Government (see table above) | 「令和7年(2025年)1月22日(水)」 |+| 回想一九五二年冬天,整个北海道,一共只找到了三十三只丹顶鹤 / in all of Hokkaido, only 33 cranes were found | The 1952 winter figure is for all of Hokkaido | MOE Red Data Book 5th ed. (above) | 「北海道の個体数は、1952 年冬に 33 羽が確認されただけで」 |+| 到了二零二五年,已经数到了一千九百二十七只 / By 2025 the count had reached 1,927 | Survey of 22 Jan 2025; the total includes 38 captive birds | Hokkaido Government (above) | 「総数1,927羽(…飼育個体38羽)」 |+| 保护级别…从易危,降到了近危 / from Vulnerable to Near Threatened | VU to NT in the 5th Red List, March 2026 | MOE press release 2026-03-17 (above) | 「絶滅危惧Ⅱ類(VU)から準絶滅危惧(NT)にカテゴリーが1段階引き下げられ」 |++## Names++| On screen | Claim | Source | Quoted wording |+|---|---|---|---|+| Plate 「音羽橋 / Otowa Bridge」 | The real name of the bridge over the Setsuri river at Tsurui, kept in its Japanese form | Japan National Trust with Tsurui Village, 11 Dec 2025: https://ntrust.or.jp/index/press20251211.pdf | 「音羽橋がかかる雪裡川は、豊富な湧き水のおかげで真冬でも凍らず」 |++"雪地里的精灵 / spirits of the snow" is a figure of speech, not a claim.diff --git a/styles/printed-long-take/demo/audio.py b/styles/printed-long-take/demo/audio.pynew file mode 100644index 0000000..dfa5bae--- /dev/null+++ b/styles/printed-long-take/demo/audio.py@@ -0,0 +1,246 @@+"""Narration, score and sound for 三十三只 Thirty-Three Cranes (60.0 s). Reads events.json (export first:+node core/render/events.mjs styles/printed-long-take/demo) and the narration in voice/<lang>/ (edge-tts, see build.sh), writes+mix.wav (48 kHz stereo, exactly the film length, about -16 LUFS, true peak under -1.5 dBTP) and prints the CREDITS lines.+Run from the library root:+ .venv/bin/python styles/printed-long-take/demo/audio.py English narration (voice/en/), the library demo+ .venv/bin/python styles/printed-long-take/demo/audio.py zh Chinese narration (voice/zh/)+The narration leads; music is ducked about 17 dB under it and foley about 7 dB. Three layers under the voice. The world: the+river under its ice edge, frost, wind, wings, snow, pecking, the cranes' calls (synthesised). The print: knife on paper and wood,+the block's thump, the sheet torn away, the seal. Music: 72 bpm in three, D minor to D major; bowed vibraphone and harp at+night, the horn's theme at dawn, xylophone and pizzicato bass in the air, strokes for the prints, horn in the major after the+seal, three glockenspiel notes on the end card."""+import os, sys, json, subprocess+HERE = os.path.dirname(os.path.abspath(__file__)); LANG = 'zh' if 'zh' in sys.argv[1:] else 'en'; LIB = os.path.abspath(os.path.join(HERE, '../../..')); sys.path.insert(0, LIB)+import numpy as np, soundfile as sf+from core.audio import sampler as S, sfx as X+from core.audio.sfx import SR, add, limit, noise, bp, lp, hp, env_exp, t_, norm, thump, brown++X._rng = np.random.default_rng(33); S.seed(33); R = np.random.default_rng(1952)+E = json.load(open(os.path.join(HERE, 'events.json'))); DUR = E['dur']; EV = E['ev']; N = int(round(DUR * SR))+ev = lambda ty: [e for e in EV if e['type'] == ty]+one = lambda ty: ev(ty)[0]['t']+tt = np.arange(N) / SR+# the picture slows down through the bridge (timeline.js WARP): fixed times written below are in the+# unslowed timeline and go through nt(); times read from events.json are already film time+WA, WB, WD = 9.95, 11.75, .4+def ot(t): # film time -> unslowed time+ if t <= WA: return t+ if t >= WB: return t - WD+ u = (t - WA) / (WB - WA); return t - WD * (u - np.sin(2 * np.pi * u) / (2 * np.pi))+def nt(x): # unslowed time -> film time+ if x <= WA: return x+ lo, hi = x, x + WD+ for _ in range(40):+ mid = (lo + hi) / 2+ if ot(mid) < x: lo = mid+ else: hi = mid+ return (lo + hi) / 2+c0 = 0.0+mus = np.zeros((N, 2), np.float32); fx = np.zeros((N, 2), np.float32); amb = np.zeros((N, 2), np.float32)++def add(buf, x, at, gain=1.0, pan=0.0): # stereo arrays go straight in; mono ones are panned by sfx.add+ if x.ndim == 1: return X.add(buf, x, at, gain, pan)+ s = int(round(at * SR)); e = min(len(buf), s + len(x))+ if e > s >= 0: buf[s:e] += x[:e - s] * gain+def env(a, b, fi=.3, fo=.3):+ return np.clip((tt - a) / max(fi, 1e-3), 0, 1) * np.clip((b - tt) / max(fo, 1e-3), 0, 1)+def st(x, g=1., pan=0.): # mono → stereo (constant power)+ l, r = np.cos((pan + 1) * np.pi / 4), np.sin((pan + 1) * np.pi / 4)+ return np.stack([x * l * g, x * r * g], 1).astype(np.float32)++# ================================================================== the world+# the river: low gurgle under the ice edge, little bubbling knocks+river = lp(brown(DUR + .1), 420)[:N] * .5 + bp(noise(DUR + .1), 300, 1400)[:N] * .05+bub = np.zeros(N)+for t in np.arange(0, DUR, .11):+ if R.random() < .5:+ f = 380 + R.random() * 500; d = .06; s = t_(d)+ x = np.sin(2 * np.pi * f * s * (1 + s * 6)) * env_exp(d, .015)+ i = int(t * SR); bub[i:i + len(x)] += x[:max(0, min(len(x), N - i))] * (.05 + R.random() * .05)+river = norm(river + bub, .5)+gain_r = (.32 + .3 * env(5.0, nt(16.7), 1.0, 1.5)) * (1 - env(nt(18.6), nt(24.0), .2, .2)) * (1 - env(nt(24), nt(55.6), .3, 1.5) * .85)+amb += st(river * gain_r, 1., -.1) + st(np.roll(river, 9000) * gain_r, .8, .3)+# wind: a thin high hiss at night, a broad wind in the air, a steady breeze over the field+w = noise(DUR + .1)[:N]+night_w = hp(lp(w, 2600), 900) * .05 * (1 - env(nt(17), DUR, .5, .1))+air_w = bp(w, 200, 1800) * .32 * env(one('air'), nt(24.2), .15, .6)+field_w = bp(w, 300, 2400) * .06 * env(nt(24), DUR, .8, 1.5)+amb += st(night_w + air_w + field_w, 1., .0)+# under the bridge: everything closes in, a hollow ring+ub = one('underBridge')+amb *= (1 - .55 * env(ub, ub + .55, .15, .2))[:, None]+add(fx, st(lp(noise(.9), 300) * env_exp(.9, .4), .35), ub, 1.)+# frost cracks in the branches+def crack(v=1.):+ d = .12; return norm(hp(noise(d), 2500) * env_exp(d, .01) + np.sin(2 * np.pi * 3100 * t_(d)) * env_exp(d, .004) * .4) * v+for e in ev('frostcrack'): add(fx, st(crack(), .2, R.uniform(-.7, .7)), e['t'])++# the cranes: a bugle-like voice, synthesised (no recording used)+def crane_voice(dur, f0, v=1., glide=.12):+ s = t_(dur); f = f0 * (1 - glide + glide * np.minimum(1, s / .05)) * (1 - .05 * s / dur)+ ph = 2 * np.pi * np.cumsum(f) / SR+ x = sum(a * np.sin(k * ph) for k, a in [(1, 1), (2, .55), (3, .45), (4, .25), (5, .18), (6, .1)])+ x = bp(x, 700, 4200)+ a = np.minimum(1, s / .015) * np.minimum(1, (dur - s) / .05)+ return norm(x * a * (1 + .15 * np.sin(2 * np.pi * 28 * s)), 1.) * v+def unison(at, v=1., pan=0.): # the male's long low note, the female's two short high ones, three times+ for k in range(3):+ b = at + k * .62+ add(fx, st(crane_voice(.44, 780, 1.), .5 * v, pan - .2), b)+ add(fx, st(crane_voice(.15, 1080, 1.), .42 * v, pan + .2), b + .2)+ add(fx, st(crane_voice(.15, 1120, 1.), .42 * v, pan + .2), b + .4)+add(fx, st(crane_voice(.22, 720, 1., .05), .1, .3), one('sleepcall')) # one murmurs in its sleep+unison(one('unison'), 1.0, -.3)+for k in range(9): # the river answers+ t = one('calls') + k * .38 + R.random() * .2+ add(fx, st(crane_voice(.2 + R.random() * .2, 850 + R.random() * 350), .12 + R.random() * .08, R.uniform(-.9, .9)), t)+# wings: a soft beat of air+def flap(v=1.):+ d = .22; s = t_(d); return norm(bp(noise(d), 120, 900) * np.sin(np.pi * np.minimum(1, s / d)) ** 2, 1.) * v+def slap(v=1.):+ d = .09; return norm(bp(noise(d), 600, 4000) * env_exp(d, .015), 1.) * v+to = one('takeoff')+for k in range(46): # running across the water, then lifting off+ t = to + k * .05 + R.random() * .02+ for j in range(5): add(fx, st(slap(), .07, R.uniform(-.6, .6)), t + j * .085)+ for j in range(5): add(fx, st(flap(), .2 * (1 - k / 60), R.uniform(-.7, .7)), t + .55 + j * .44)+# the steam swallows the sound for half a second; in the air, a steady wing beat+wb = one('air')+fx *= (1 - .9 * env(one('steam') - .05, wb + .25, .15, .2))[:, None]+for t in np.arange(wb + .2, nt(24.0), .44): add(fx, st(flap(), .16, -.2), t); add(fx, st(flap(), .1, .3), t + .21)+# the descent: the wings brake, birds touch down on snow, the field talks+add(fx, st(lp(noise(1.1), 900) * np.sin(np.pi * np.minimum(1, t_(1.1) / 1.1)), .3, .1), one('descend') + .3)+def crunch(v=1.):+ d = .12; return norm(bp(noise(d), 500, 5000) * env_exp(d, .03) * (1 + (np.random.default_rng(int(v * 1000)).random(int(d * SR)) > .7)), 1.) * v+add(fx, st(crunch(), .35, 0), one('touchdown'))+add(fx, st(flap(), .3, 0), one('touchdown') - .25)+for e in ev('land'): add(fx, st(crunch(), .12, e.get('pan', 0)), e['t']); add(fx, st(flap(), .1, e.get('pan', 0)), e['t'] - .2)+for t in np.arange(nt(24.4), DUR - 1.5, .23): # the field: pecking and murmurs, thinned out under the type+ quiet = nt(41.3) < t < nt(48.6)+ if R.random() < (.25 if quiet else .55):+ d = .03; s = t_(d); x = np.sin(2 * np.pi * (900 + R.random() * 400) * s) * env_exp(d, .006)+ add(fx, st(x, .05, R.uniform(-.8, .8)), t)+ if R.random() < (.04 if quiet else .12):+ add(fx, st(crane_voice(.18 + R.random() * .2, 820 + R.random() * 360), .05 + R.random() * .05, R.uniform(-.9, .9)), t)+for e in ev('danceflap'): add(fx, st(flap(), .35, .2), e['t']); add(fx, st(flap(), .3, .2), e['t'] + .3)++# ================================================================== the print+def scrape(d, v=1., f0=2500, f1=6000): # a knife drawn through paper or wood+ s = t_(d); x = bp(noise(d), f0, f1) * (.6 + .4 * np.abs(np.sin(2 * np.pi * 37 * s)))+ return norm(x * np.minimum(1, s / .01) * np.minimum(1, (d - s) / .03), 1.) * v+c0 = one('carveTitle')+for k in range(5): add(fx, st(scrape(.16 + R.random() * .1), .16, .2 + k * .08), c0 + k * .22)+for k in range(3): add(fx, st(scrape(.14), .08, .4), one('uncarveTitle') + k * .25)+for k in range(11): # the dawn is cut into the sky, one line at a time+ add(fx, st(scrape(.35 + R.random() * .3, 1., 1800, 5200), .06, R.uniform(-.6, .6)), nt(11.2 + k * .42 + R.random() * .1))+def block(v=1.): # the inked block meets the paper+ x = thump(1, 62).copy(); y = lp(noise(.25), 400) * env_exp(.25, .05) * .5; x[:len(y)] += y[:len(x)]+ return norm(x, 1.) * v+def tear(v=1.):+ d = .32; s = t_(d); x = bp(noise(d), 900, 7000) * (np.random.default_rng(3).random(len(s)) > .45) * np.sin(np.pi * s / d) ** .5+ return norm(x, 1.) * v+add(fx, st(block(), .45), one('print0'))+for i, e in enumerate(ev('peel')):+ add(fx, st(tear(), .3 + .05 * i, .3), e['t']); add(fx, st(block(), .5 + .08 * i), e['t'] + .27)+add(fx, st(lp(noise(1.2), 2500) * np.sin(np.pi * t_(1.2) / 1.2) ** 2 * .5, .25, -.2), one('corn')) # corn thrown on the snow+for e in ev('redplate'): add(fx, st(block(), .22, .2), e['t']) # the red plate pressed on+for e in ev('knife'): add(fx, st(scrape(.09, 1., 3000, 8000), .22, -.1), e['t']); add(fx, st(crack(), .05, -.1), e['t'] + .07)+add(fx, st(scrape(.32, 1., 1500, 4500), .3, -.2), one('strike'))+stp = one('stamp')+add(fx, st(thump(1, 48), 1.0), stp); add(fx, st(lp(noise(.3), 260) * env_exp(.3, .08), .6), stp)+unison(stp + .45, .7, .25)++# ================================================================== music: 72 bpm, three beats to a bar+B = 60 / 72+sc = []+def n(t, inst, p, d, v, pan=0., g=1.): sc.append((t, inst, p, d, v, pan, g))+# night: bowed vibraphone high and still, a bass pedal, the harp's three-note figure from the river onwards+n(0, 'vibraphone_bowed', 'A5', nt(11.5), .3, .3, .55)+for t0, ch in ((0, ['D4', 'F4', 'A4']), (5.0, ['D4', 'G4', 'Bb4']), (8.4, ['C4', 'F4', 'A4'])):+ for i, p in enumerate(ch): n(t0 + i * .05, 'vibraphone_bowed', p, 4.6 if t0 < 8 else nt(12.8) - 8.4, .3, -.3 + .3 * i, .5)+n(0, 'contrabass', 'D2', nt(12.5), .3, 0, .4)+for k, p in enumerate(['D6', 'A5', 'F6', 'E6']): n(c0 + .08 + k * .27, 'glockenspiel', p, 1.4, .22, .35)+harp = ['D4', 'A4', 'F5', 'D4', 'A4', 'E5', 'C4', 'G4', 'E5', 'Bb3', 'F4', 'D5']+k = 0; t = 5.5+while t < 17.0:+ n(nt(t), 'harp', harp[k % 12], .9, .3 + (.08 if k % 3 == 0 else 0), .25 * ((k % 3) - 1), .8); t += B; k += 1+# dawn: the horn's theme (D dorian), first statement+theme = [('A3', 1), ('D4', 2), ('E4', 1), ('F4', 1.5), ('E4', .5), ('D4', 1), ('C4', 1), ('D4', 3)]+t = 13.6+for p, b in theme: n(nt(t), 'horn', p, b * B * .95, .5, -.15, .9); t += b * B+n(nt(11.5), 'contrabass', 'D2', 5.2, .3, 0, .45); n(nt(11.5), 'cellos', 'A2', 5.0, .28, .2, .5)+for t0, p in ((14.0, 'D6'), (15.2, 'A5')): n(nt(t0), 'hand_chimes', p, 2.0, .18, .4)+# takeoff swell, then the steam cuts it+n(nt(16.2), 'timpani', 'D2', 2.4, .35, 0, .5)+for i, p in enumerate(['D3', 'A3', 'D4', 'F4']): n(nt(16.4) + i * .05, 'violins_trem' if i > 1 else 'violas', p if i > 1 else p, 2.2, .3 + .05 * i, -.3 + .2 * i, .5)+# the air: xylophone and pizzicato bass in a steady three+bars = [('D2', ['D5', 'A5', 'F5']), ('Bb1', ['D5', 'F5', 'Bb5']), ('C2', ['E5', 'G5', 'C6']), ('A1', ['C#5', 'E5', 'A5'])]+t = one('air') + .1; k = 0+while t < nt(24.6):+ bass, top = bars[k % 4]+ n(t, 'contrabass_pizz', bass, 1.0, .55, -.1, .9)+ for j in range(3): n(t + j * B, 'xylophone', top[j], .4, .32 + (.08 if j == 0 else 0), .25, .7)+ t += 3 * B; k += 1+# the field: the music thins to one low string+n(nt(24.6), 'cellos', 'D3', 3.5, .25, 0, .45); n(nt(26.5), 'contrabass', 'D2', 6.2, .28, 0, .5)+n(nt(28.6), 'vibraphone_bowed', 'F4', 3.8, .22, -.2, .4)+# the prints: four strokes, each closer than the last (the block thumps sit on them)+for t0, p in zip([one('print0'), one('corn')] + [e['t'] + .27 for e in ev('peel')], ['D2', 'F2', 'D2', 'A1', 'D2']):+ n(t0, 'timpani', p, 1.2, .5, 0, .7); n(t0, 'contrabass_pizz', p, .8, .5, 0, .7)+# the verdict: one held note under the cutting, silence before the seal, then the theme in D major+n(nt(41.3), 'contrabass', 'A1', 7.0, .26, 0, .45)+n(stp, 'gran_cassa', None, None, .7, 0, .8)+for i, p in enumerate(['D3', 'A3', 'F#4', 'A4']): n(stp + .55 + i * .03, 'violas' if i < 2 else 'violins', p, 6.5, .32, -.3 + .2 * i, .5)+majr = [('A3', 1), ('D4', 2), ('E4', 1), ('F#4', 1.5), ('G4', .5), ('A4', 1), ('B4', 1), ('A4', 2), ('F#4', 1), ('D4', 3)]+t = stp + .9+for p, b in majr: n(t, 'horn', p, b * B * .95, .52, -.15, .9); t += b * B+n(stp + .6, 'contrabass', 'D2', 7.0, .3, 0, .5)+for k in range(12): n(nt(51.4) + k * B, 'harp', ['D4', 'A4', 'F#5', 'D5'][k % 4], 1.0, .28, .2, .7)+# the long chord, and three glockenspiel notes on the end card+end = one('endcard')+for i, p in enumerate(['D3', 'A3', 'D4', 'F#4', 'A4']): n(end - .6, 'violins' if i > 2 else 'cellos', p, 3.6, .3, -.3 + .15 * i, .45)+n(end - .6, 'horn', 'D4', 3.4, .42, -.1, .7)+for k, p in enumerate(['A5', 'F#5', 'D6']): n(end + .1 + k * .5, 'glockenspiel', p, 2.5, .28, .3)++mus += S.render(sc, dur=DUR)[:N]+mus = S.room(mus, size=.6, mix=.22)+fx = S.room(fx, size=.35, mix=.12)++# ================================================================== mix: music under the effects, a quiet tail+vo = np.zeros(N, np.float32)+for e in ev('vo'):+ x, sr = sf.read(os.path.join(HERE, 'voice', LANG, e['id'] + '.wav'), dtype='float32')+ 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).astype(np.float32)+ i = int(e['t'] * SR); vo[i:i + len(x)] += x[:max(0, N - i)]+vo = vo / max(1e-6, np.sqrt(np.mean(vo[np.abs(vo) > 1e-4] ** 2))) * .1 # speech at a fixed level+# ducking: a smoothed speech envelope, held through the pauses inside a line+ve = np.convolve((np.abs(vo) > .003).astype(np.float32), np.ones(int(.35 * SR)) / int(.35 * SR), 'same')+ve = np.clip(ve * 4, 0, 1)+k = int(.25 * SR); ve = np.maximum.accumulate(np.r_[ve, np.zeros(k)])[:N] * 0 + np.convolve(ve, np.ones(k) / k, 'same')+ve = np.clip(ve, 0, 1)+duck_m = 10 ** (-17 / 20) * ve + (1 - ve)+duck_f = 10 ** (-7 / 20) * ve + (1 - ve)+mix = mus * .62 * duck_m[:, None] + fx * .9 * duck_f[:, None] + amb * .55 * duck_f[:, None] + st(vo, 1.4)+tail = np.clip((DUR - tt) / 1.4, 0, 1) ** 1.5+head = np.clip(tt / .04, 0, 1)+mix *= (tail * head)[:, None]+# loudness to about -16 LUFS (measured with ffmpeg), then a ceiling for true peak+tmp = os.path.join(HERE, 'mix.wav')+def lufs(x):+ sf.write(tmp, x, SR, subtype='PCM_24')+ out = subprocess.run(['ffmpeg', '-hide_banner', '-nostats', '-i', tmp, '-af', 'ebur128=peak=true', '-f', 'null', '-'], capture_output=True, text=True).stderr+ I = float(out.split('Integrated loudness:')[1].split('I:')[1].split('LUFS')[0]); P = float(out.split('True peak:')[1].split('Peak:')[1].split('dBFS')[0])+ return I, P+for _ in range(3):+ I, P = lufs(limit(mix, .6))+ mix *= 10 ** ((-16 - I) / 20)+base, ceil = mix.copy(), -2.2+for _ in range(8): # the limiter works on samples; walk its ceiling down until the true peak (between samples) is under -3+ mix = limit(base, 10 ** (ceil / 20)); I, P = lufs(mix)+ mix *= 10 ** ((-16 - I) / 20); mix = limit(mix, 10 ** (ceil / 20)); I, P = lufs(mix)+ if P <= -1.7: break+ ceil -= .5+assert len(mix) == N+print(f'{os.path.basename(tmp)} {DUR:.2f} s {I:.1f} LUFS true peak {P:.1f} dBFS')+print('\n'.join(S.credits(sorted({e[1] for e in sc}))))diff --git a/styles/printed-long-take/demo/build.sh b/styles/printed-long-take/demo/build.shnew file mode 100644index 0000000..687cbf1--- /dev/null+++ b/styles/printed-long-take/demo/build.sh@@ -0,0 +1,55 @@+#!/bin/sh+# One command: 《三十三只》 Thirty-Three Cranes (Printed Long Take demo)+# sh styles/printed-long-take/demo/build.sh English narration (the library demo)+# sh styles/printed-long-take/demo/build.sh zh Chinese narration+# font, narration and its speech check, events, score + mix, picture, master, subtitles, reading-time check, poster.+# In a fresh clone (fonts and samples are not in git) Noto Serif SC is downloaded from github.com/google/fonts (OFL)+# and the sample packs with tools/fetch.sh. The narration uses edge-tts (online).+set -e+LANGV=${1:-en}+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=printed-long-take+OUT=$NAME; [ "$LANGV" = zh ] && OUT=$NAME-zh+FPS=30+FRAME=15.4 # the crowns waking at dawn: poster and gallery still (no subtitle on screen)+cd "$LIB"++# font (gitignored): Noto Serif SC variable, subset to every character the film prints at weight 700+[ -f "$HERE/tools/NotoSerifSC-VF.ttf" ] || curl -sfL -o "$HERE/tools/NotoSerifSC-VF.ttf" "https://github.com/google/fonts/raw/main/ofl/notoserifsc/NotoSerifSC%5Bwght%5D.ttf"+"$PY" "$HERE/tools/subset.py"+# sampled instruments (library packs, CC0), fetched once per clone+for l in vcsl vsco2ce; do [ -d "core/audio/instruments/$l" ] || sh tools/fetch.sh instruments $l; done++# narration: one wav per line in voice/<lang>/ (Xiaoxiao +25% for Chinese, Ava +10% with per-line rates for English), then check it+if [ "$LANGV" = zh ]; then+ "$PY" core/tts/tts_zh.py "$HERE/lines_zh.json" "$HERE/voice/zh" --voice zh-CN-XiaoxiaoNeural --rate +25%+ "$PY" core/tts/asr_check.py "$HERE/lines_zh.json" "$HERE/voice/zh" --lang zh || echo "(Chinese check: differences are homophones and digits; listen to any new line)"+else+ "$PY" core/tts/tts_zh.py "$HERE/lines_en.json" "$HERE/voice/en" --voice en-US-AvaNeural --rate +10%+ "$PY" core/tts/asr_check.py "$HERE/lines_en.json" "$HERE/voice/en" --lang en+fi+# the subtitle bar is timed on the Chinese reading in either version+[ -f "$HERE/voice/zh/dur.json" ] || "$PY" core/tts/tts_zh.py "$HERE/lines_zh.json" "$HERE/voice/zh" --voice zh-CN-XiaoxiaoNeural --rate +25%++# events from the picture, then narration, score and effects placed on them (mix.wav, about -16 LUFS before the master)+node core/render/events.mjs "$HERE"+"$PY" "$HERE/audio.py" "$LANGV"++# 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/mix.wav" "$FILM/$OUT.mp4" $FPS 0++# bilingual subtitles and the reading time of every word in the world (window.TEXTS)+"$PY" "$HERE/tools/srt.py"+node core/render/readcheck.mjs "$HERE" > "$HERE/out/readcheck.txt" && echo "readcheck ok" || { tail -20 "$HERE/out/readcheck.txt"; exit 1; }++# poster and the gallery style frame+ffmpeg -v error -y -ss $FRAME -i "$FILM/$OUT.mp4" -frames:v 1 -q:v 2 "$FILM/poster.jpg"+mkdir -p "$HERE/stills"+ffmpeg -v error -y -ss $FRAME -i "$FILM/$OUT.mp4" -frames:v 1 -q:v 2 "$HERE/stills/styleframe.jpg"+echo "done: $FILM/$OUT.mp4"diff --git a/styles/printed-long-take/demo/events.json b/styles/printed-long-take/demo/events.jsonnew file mode 100644index 0000000..47e28fa--- /dev/null+++ b/styles/printed-long-take/demo/events.json@@ -0,0 +1 @@+{"dur":60,"ev":[{"t":0,"type":"start"},{"t":0.15,"type":"carveTitle"},{"t":1,"type":"vo","id":"l01"},{"t":1.7,"type":"frostcrack"},{"t":2.6,"type":"sleepcall"},{"t":3.4,"type":"frostcrack"},{"t":4.4,"type":"uncarveTitle"},{"t":4.9,"type":"frostcrack"},{"t":5.4,"type":"vo","id":"l02"},{"t":6.2,"type":"frostcrack"},{"t":7.6,"type":"bridgeHold"},{"t":10.102,"type":"underBridge"},{"t":10.85,"type":"outBridge"},{"t":11.107,"type":"vo","id":"l03"},{"t":14.144,"type":"wake","pan":-0.37209943834860026},{"t":14.149,"type":"wake","pan":-0.6562611055389422},{"t":14.154,"type":"wake","pan":-0.3664024812692222},{"t":14.157,"type":"wake","pan":-0.7161909541373375},{"t":14.175,"type":"wake","pan":-0.3659949048771875},{"t":14.183,"type":"wake","pan":-0.7030282734119927},{"t":14.215,"type":"wake","pan":-0.08489402357716752},{"t":14.244,"type":"wake","pan":-0.5671881942342788},{"t":14.318,"type":"wake","pan":-0.40110390573668453},{"t":14.339,"type":"wake","pan":0.1475223743149804},{"t":14.368,"type":"wake","pan":-0.33703318920496866},{"t":14.376,"type":"wake","pan":0.18048426289652278},{"t":14.378,"type":"wake","pan":-0.03368332936636165},{"t":14.398,"type":"wake","pan":-0.01656889646417565},{"t":14.402,"type":"wake","pan":0.18878524364384613},{"t":14.458,"type":"wake","pan":0.08992209355363674},{"t":14.463,"type":"wake","pan":-0.09489809382350008},{"t":14.472,"type":"wake","pan":-0.03255050820815894},{"t":14.473,"type":"wake","pan":0.30413844760440156},{"t":14.487,"type":"wake","pan":0.09013462822645203},{"t":14.49,"type":"wake","pan":0.1581135871798354},{"t":14.507,"type":"wake","pan":0.06922261234642156},{"t":14.51,"type":"wake","pan":0.08205576887768176},{"t":14.512,"type":"wake","pan":-0.08376317284739009},{"t":14.521,"type":"wake","pan":0.047946979813891254},{"t":14.551,"type":"wake","pan":0.42549050190589494},{"t":14.558,"type":"wake","pan":0.2637503024501105},{"t":14.565,"type":"wake","pan":0.3526765485774324},{"t":14.57,"type":"wake","pan":0.38257985512805387},{"t":14.629,"type":"wake","pan":0.23220422212034464},{"t":14.63,"type":"wake","pan":0.41366711453547667},{"t":14.646,"type":"wake","pan":0.10054496473943193},{"t":14.65,"type":"wake","pan":0.6388888888888888},{"t":14.711,"type":"wake","pan":0.2033067517794175},{"t":14.74,"type":"wake","pan":0.4847375609193144},{"t":14.752,"type":"wake","pan":0.258748674837538},{"t":14.76,"type":"wake","pan":0.7444444444444448},{"t":14.78,"type":"wake","pan":0.7320919763528155},{"t":14.781,"type":"wake","pan":0.3498172291360425},{"t":14.793,"type":"wake","pan":0.42540173284164084},{"t":14.797,"type":"wake","pan":1},{"t":14.8,"type":"wake","pan":0.5222222222222226},{"t":14.801,"type":"wake","pan":0.43387465339360964},{"t":14.801,"type":"wake","pan":0.8666666666666664},{"t":14.809,"type":"wake","pan":0.45746108832665616},{"t":14.844,"type":"wake","pan":0.9888888888888887},{"t":14.899,"type":"wake","pan":0.4390042980281821},{"t":14.924,"type":"wake","pan":1},{"t":14.927,"type":"wake","pan":0.9111111111111114},{"t":14.936,"type":"wake","pan":0.5134222757229041},{"t":14.949,"type":"wake","pan":0.53177817124315},{"t":15.5,"type":"unison"},{"t":16.6,"type":"calls"},{"t":16.6,"type":"takeoff"},{"t":19.1,"type":"steam"},{"t":19.35,"type":"air"},{"t":19.6,"type":"vo","id":"l04"},{"t":24.4,"type":"descend"},{"t":24.6,"type":"vo","id":"l05"},{"t":27.2,"type":"touchdown"},{"t":27.666,"type":"land","pan":-0.4554470617933671},{"t":27.745,"type":"land","pan":0.42785679634026935},{"t":27.926,"type":"land","pan":0.6458430522928669},{"t":27.942,"type":"land","pan":0.29210241428191813},{"t":27.947,"type":"land","pan":-0.07079498424433801},{"t":28.035,"type":"land","pan":0.5500182208062036},{"t":28.077,"type":"land","pan":-0.6664797400201359},{"t":28.109,"type":"land","pan":-0.7190105762594058},{"t":28.165,"type":"land","pan":-0.7274004113211191},{"t":28.492,"type":"land","pan":-0.41197464306940146},{"t":28.737,"type":"land","pan":-0.2881778411755359},{"t":28.761,"type":"land","pan":-0.4687360743137198},{"t":29,"type":"board"},{"t":29.2,"type":"vo","id":"l06"},{"t":29.206,"type":"land","pan":0.446460863804505},{"t":29.222,"type":"land","pan":0.2826464335465836},{"t":29.256,"type":"land","pan":-0.31765929965817463},{"t":29.287,"type":"land","pan":0.06415879434261954},{"t":29.479,"type":"land","pan":-0.17890791890607466},{"t":29.544,"type":"land","pan":0.6800401207996571},{"t":29.749,"type":"land","pan":0.30351833162818237},{"t":29.907,"type":"land","pan":-0.4703933558907735},{"t":29.938,"type":"land","pan":-0.43151229530601504},{"t":30.012,"type":"land","pan":0.5607376063590926},{"t":30.099,"type":"land","pan":-0.6143352253829079},{"t":30.099,"type":"land","pan":0.5236066189452206},{"t":30.29,"type":"land","pan":-0.6581983760619263},{"t":31.035,"type":"land","pan":0.5198773381551405},{"t":34,"type":"print0"},{"t":34.2,"type":"vo","id":"l07"},{"t":37,"type":"corn"},{"t":38.5,"type":"vo","id":"l08"},{"t":39.3,"type":"peel","i":0},{"t":39.75,"type":"redplate","i":0},{"t":40.1,"type":"peel","i":1},{"t":40.55,"type":"redplate","i":1},{"t":40.8,"type":"peel","i":2},{"t":41.25,"type":"redplate","i":2},{"t":41.9,"type":"vo","id":"l09"},{"t":42,"type":"knife","i":0},{"t":42.133,"type":"knife","i":1},{"t":42.267,"type":"knife","i":2},{"t":42.4,"type":"knife","i":3},{"t":42.533,"type":"knife","i":4},{"t":42.667,"type":"knife","i":5},{"t":43,"type":"knife","i":6},{"t":43.138,"type":"knife","i":7},{"t":43.275,"type":"knife","i":8},{"t":43.413,"type":"knife","i":9},{"t":43.55,"type":"knife","i":10},{"t":43.688,"type":"knife","i":11},{"t":43.825,"type":"knife","i":12},{"t":43.963,"type":"knife","i":13},{"t":46.3,"type":"vo","id":"l10"},{"t":48,"type":"strike"},{"t":49.05,"type":"stamp"},{"t":52,"type":"danceflap"},{"t":52,"type":"vo","id":"l11"},{"t":52.95,"type":"danceflap"},{"t":53.9,"type":"danceflap"},{"t":54.85,"type":"danceflap"},{"t":55.8,"type":"danceflap"},{"t":56.8,"type":"endcard"}]}\ No newline at end of filediff --git a/styles/printed-long-take/demo/fonts/OFL-NotoSerifSC.txt b/styles/printed-long-take/demo/fonts/OFL-NotoSerifSC.txtnew file mode 100644index 0000000..94d1bf7--- /dev/null+++ b/styles/printed-long-take/demo/fonts/OFL-NotoSerifSC.txt@@ -0,0 +1,94 @@+Copyright 2012 Google Inc. All Rights Reserved.++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/printed-long-take/demo/index.html b/styles/printed-long-take/demo/index.htmlnew file mode 100644index 0000000..bd9f33c--- /dev/null+++ b/styles/printed-long-take/demo/index.html@@ -0,0 +1,17 @@+<!doctype html>+<html>+<head>+<meta charset="utf-8">+<title>Thirty-Three Cranes — Printed Long Take</title>+<style>+ html, body { margin: 0; background: #1d1e21; overflow: hidden; }+ canvas { display: block; width: 100vw; height: 100vh; }+</style>+</head>+<body>+<script type="importmap">+{ "imports": { "three": "/node_modules/three/build/three.module.js" } }+</script>+<script type="module" src="./scene.js"></script>+</body>+</html>diff --git a/styles/printed-long-take/demo/lines_en.json b/styles/printed-long-take/demo/lines_en.jsonnew file mode 100644index 0000000..08e7c92--- /dev/null+++ b/styles/printed-long-take/demo/lines_en.json@@ -0,0 +1,59 @@+[+ {+ "id": "l01",+ "text": "On a morning this cold, the river still hasn’t frozen; it breathes white steam.",+ "rate": "+25%",+ "say": "On a morning this cold, the river hasn't frozen; it breathes white steam.",+ "asr": "On a morning this cold, the river hasn't frozen; it breathes white steam."+ },+ {+ "id": "l02",+ "text": "This is a wetland in eastern Hokkaido."+ },+ {+ "id": "l03",+ "text": "Asleep, standing in the water: red-crowned cranes.",+ "asr": "A sleep, standing in the water, red-crowned cranes."+ },+ {+ "id": "l04",+ "text": "Long ago, as the wetlands were cleared field by field, they nearly lost their home for good.",+ "rate": "+25%"+ },+ {+ "id": "l05",+ "text": "At daybreak they fly in flocks to a field scattered with corn, just for them.",+ "rate": "+25%",+ "say": "At daybreak, they fly in flocks to a field scattered with corn, just for them."+ },+ {+ "id": "l06",+ "text": "Think back to the winter of 1952: in all of Hokkaido, only 33 cranes were found.",+ "say": "The winter of nineteen fifty-two: in all of Hokkaido, only thirty-three cranes were found.",+ "rate": "+25%",+ "asr": "The winter of 1952, in all of Hokkaido, only 33 cranes were found."+ },+ {+ "id": "l07",+ "text": "That was the year local people decided to feed them through the winter."+ },+ {+ "id": "l08",+ "text": "And so, year after year, there were more of them."+ },+ {+ "id": "l09",+ "text": "By 2025 the count had reached 1,927.",+ "say": "By twenty twenty-five the count reached one thousand nine hundred twenty-seven.",+ "rate": "+25%",+ "asr": "By 2025, the count reached 1,927."+ },+ {+ "id": "l10",+ "text": "Their status finally eased, from Vulnerable to Near Threatened."+ },+ {+ "id": "l11",+ "text": "No longer counted as endangered, these spirits of the snow still need people to look after them."+ }+]\ No newline at end of filediff --git a/styles/printed-long-take/demo/lines_zh.json b/styles/printed-long-take/demo/lines_zh.jsonnew file mode 100644index 0000000..5322ac4--- /dev/null+++ b/styles/printed-long-take/demo/lines_zh.json@@ -0,0 +1,46 @@+[+ {+ "id": "l01",+ "text": "这么冷的清晨,河水却没有结冰,还升腾着阵阵白汽。"+ },+ {+ "id": "l02",+ "text": "这里是北海道东部的湿地。"+ },+ {+ "id": "l03",+ "text": "站在河水里安静睡觉的,是丹顶鹤。"+ },+ {+ "id": "l04",+ "text": "早年间,随着湿地被一片片开垦,它们差点就彻底失去了家园。"+ },+ {+ "id": "l05",+ "text": "天亮后,它们成群飞去的地方,是一块专门撒满玉米的田地。"+ },+ {+ "id": "l06",+ "text": "回想一九五二年冬天,整个北海道,一共只找到了三十三只丹顶鹤。"+ },+ {+ "id": "l07",+ "text": "也是从那一年起,当地人决定在冬天给它们投喂食物。"+ },+ {+ "id": "l08",+ "text": "就这样,丹顶鹤的数量,一年比一年多。"+ },+ {+ "id": "l09",+ "text": "到了二零二五年,已经数到了一千九百二十七只。"+ },+ {+ "id": "l10",+ "text": "它们的保护级别,也终于从易危,降到了近危。"+ },+ {+ "id": "l11",+ "text": "虽然不再算作濒危物种了,但这群雪地里的精灵,依然需要人们的守护。"+ }+]\ No newline at end of filediff --git a/styles/printed-long-take/demo/look.js b/styles/printed-long-take/demo/look.jsnew file mode 100644index 0000000..c7f28a7--- /dev/null+++ b/styles/printed-long-take/demo/look.js@@ -0,0 +1,403 @@+// Materials: every surface is drawn as a scratchboard print — ink, paper, one red and a little warm yellow.+// Knife lines are fixed in world space (or in direction space for the sky) so they never slide with the camera.+import * as THREE from 'three';++THREE.ColorManagement.enabled = false; // hex values are print inks, used as written++export const C = {+ ink: new THREE.Color('#16171b'), paper: new THREE.Color('#ede5cd'),+ red: new THREE.Color('#c4332b'), redShade: new THREE.Color('#7e2229'),+ yellow: new THREE.Color('#dfa443'), wood: new THREE.Color('#3a2f27'),+};+const v3 = c => new THREE.Vector3(c.r, c.g, c.b);+// shared uniforms: the light, the warmth of the sunrise+export const U = {+ uInk: { value: v3(C.ink) }, uPaper: { value: v3(C.paper) }, uYellow: { value: v3(C.yellow) },+ uL: { value: new THREE.Vector3(-0.92, 0.36, 0.3).normalize() },+ uWarm: { value: 0 }, uCam: { value: new THREE.Vector3() }, uSun: { value: new THREE.Vector3(1, .02, 0).normalize() },+};++export const GLSL_HASH = /* glsl */`+ float h11(float n){ return fract(sin(n*127.1+311.7)*43758.5453); }+ float h21(vec2 p){ return fract(sin(dot(p, vec2(127.1,311.7)))*43758.5453); }+ float vn(vec2 p){ vec2 i=floor(p), f=fract(p); f=f*f*(3.-2.*f);+ return mix(mix(h21(i),h21(i+vec2(1,0)),f.x), mix(h21(i+vec2(0,1)),h21(i+vec2(1,1)),f.x), f.y); }+`;+const VS_WORLD = `varying vec3 vW; void main(){ vec4 w = modelMatrix*vec4(position,1.); vW = w.xyz; gl_Position = projectionMatrix*viewMatrix*w; }`;++// ------------------------------------------------------------------ mountains: flat faces, carved shadow sides+export const carveMat = (scale = 1) => new THREE.ShaderMaterial({+ uniforms: { ...U, uScale: { value: scale } }, side: THREE.DoubleSide,+ vertexShader: VS_WORLD,+ fragmentShader: GLSL_HASH + `+ uniform vec3 uInk, uPaper, uYellow, uL; uniform float uWarm, uScale; varying vec3 vW;+ float scratches(vec3 p, vec3 n, float spacing, float density, float wmax, float seed){+ vec3 down = vec3(0.,-1.,0.);+ vec3 d = down - n*dot(down,n); float dl = length(d); d = dl > 1e-3 ? d/dl : vec3(0.,0.,1.);+ vec3 side = normalize(cross(n, d));+ float u = dot(p, d), s0 = dot(p, side) / spacing, id = floor(s0), cov = 0.;+ for (int k=-1; k<=1; k++){+ float i = id + float(k);+ float r1 = h11(i*1.13+seed), r2 = h11(i*2.71+seed+3.), r3 = h11(i*5.3+seed+7.), r4 = h11(i*9.1+seed+1.);+ float s = s0 - i - .5 - (r1-.5)*.6 - u*(r3-.5)*.35/spacing;+ float segL = spacing*(8.+r2*14.), uj = u/segL + r4*7., j = floor(uj), f = fract(uj);+ float on = step(1.-density, h11(j*3.7+i*.71+seed));+ float taper = smoothstep(0.,.08,f) * (1.-smoothstep(.35+.5*r2, .95, f));+ float w = wmax*(.35+.65*r1)*taper, aa = fwidth(s);+ cov = max(cov, on*(1.-smoothstep(w-aa, w+aa, abs(s))));+ }+ return cov;+ }+ void main(){+ vec3 n = normalize(cross(dFdx(vW), dFdy(vW)));+ float ndl = dot(n, uL);+ vec3 lit = mix(uPaper, mix(uPaper, uYellow, .35), uWarm*smoothstep(.3,.8,ndl));+ vec3 col;+ if (ndl > 0.12) { float k = scratches(vW*uScale, n, 3.2, .22*smoothstep(.55,.12,ndl), .07, 11.); col = mix(lit, uInk, k); }+ else { float dens = mix(.8, .3, smoothstep(.12,-.5,ndl)); float k = scratches(vW*uScale, n, 2.4, dens, .16, 3.); col = mix(uInk, uPaper, k*.95); }+ gl_FragColor = vec4(col, 1.);+ }`,+});+export const mtnMat = carveMat(1);++// ------------------------------------------------------------------ snow ground, with the river cut out of it+export function groundMat(maskTex, rect) {+ return new THREE.ShaderMaterial({+ uniforms: { ...U, tMask: { value: maskTex }, uRect: { value: new THREE.Vector4(...rect) } },+ vertexShader: VS_WORLD,+ fragmentShader: GLSL_HASH + `+ uniform vec3 uInk, uPaper, uCam; uniform sampler2D tMask; uniform vec4 uRect; varying vec3 vW;+ void main(){+ vec2 mu = (vW.xz - uRect.xy) / uRect.zw;+ float m = (mu.x > 0. && mu.x < 1. && mu.y > 0. && mu.y < 1.) ? texture2D(tMask, mu).r : 0.;+ if (m > .5) discard;+ float dist = distance(vW, uCam);+ // wind-drift strokes across the snow+ float v = vW.z*.16 + sin(vW.x*.013)*3. + sin(vW.x*.041+1.3)*.8;+ float row = floor(v); v += vW.x*(h11(row*7.3)-.5)*.03;+ row = floor(v); float f = fract(v)-.5 - (h11(row*2.2)-.5)*.5;+ float segs = vW.x/(6.+h11(row)*14.) + h11(row*3.1)*9.;+ float on = step(.965, h11(floor(segs)*1.7 + row*.37)) * smoothstep(0.,.12,fract(segs)) * (1.-smoothstep(.2,.6,fract(segs)));+ float w = (.015+.03*h11(floor(segs)+row))*on, aa = fwidth(v);+ float k = on*(1.-smoothstep(w-aa, w+aa, abs(f)));+ k *= 1.-smoothstep(90., 260., dist);+ // the snow cornice along the river: short ink hatching where the bank drops away+ float bank = smoothstep(.12, .45, m) * smoothstep(25., 70., dist);+ float hv = (vW.x+vW.z)*1.6; float hf = abs(fract(hv)-.5);+ float ha = fwidth(hv);+ float hk = bank * (1.-smoothstep(.12-ha, .12+ha, hf)) * step(.35, h21(floor(vec2(hv, vW.x*.3+vW.z*.3))));+ k = max(k, hk*.9);+ // far snow: sparse reed stubble ticks keep the marsh from going blank from the air+ vec2 rc = floor(vW.xz/vec2(3.,1.4)); vec2 rf = fract(vW.xz/vec2(3.,1.4))-.5;+ float reed = step(.93, h21(rc*1.31)) * (1.-smoothstep(.04, .07, abs(rf.x+rf.y*.25))) * step(abs(rf.y), .4);+ reed *= smoothstep(120., 300., dist) * (1.-smoothstep(1400., 2600., dist)) * step(.45, vn(vW.xz*.004));+ k = max(k, reed*.8);+ gl_FragColor = vec4(mix(uPaper, uInk, k*.9), 1.);+ }`,+ });+}++// ------------------------------------------------------------------ open water: ink with carved ripple lines across the flow+export const waterMat = new THREE.ShaderMaterial({+ uniforms: { ...U, uT: { value: 0 } },+ vertexShader: `attribute vec2 aRiv; varying vec2 vR; varying vec3 vW;+ void main(){ vR = aRiv; vec4 w = modelMatrix*vec4(position,1.); vW = w.xyz; gl_Position = projectionMatrix*viewMatrix*w; }`,+ fragmentShader: GLSL_HASH + `+ uniform vec3 uInk, uPaper, uYellow, uCam, uSun; uniform float uWarm, uT; varying vec2 vR; varying vec3 vW;+ void main(){+ // vR.x = metres along the river, vR.y = -1..1 across it+ float flow = vR.x + uT*.6;+ float v = flow*3.4 + sin(vR.y*2.1 + vR.x*.05)*.35;+ float row = floor(v), f = fract(v)-.5;+ float segs = vR.y*(4.+h11(row)*6.) + h11(row*1.9)*5. + sin(uT*.8+row)*.15;+ float on = step(.62, h11(floor(segs)*2.3+row)) * (1.-smoothstep(.5,.95,fract(segs))) * smoothstep(0.,.15,fract(segs));+ float aa = fwidth(v), w = .055*on*(.6+.8*h11(floor(segs)+row*3.1));+ float k = on*(1.-smoothstep(w-aa, w+aa, abs(f)));+ k *= 1. - smoothstep(.25, .7, aa); // far water stays ink instead of turning grey+ // slush: small paper floes drifting with the current+ vec2 sc = vec2((vR.x - uT*.55)*.9, vR.y*7.); vec2 si = floor(sc), sf = fract(sc)-.5;+ float sh = h21(si*1.37);+ float floe = step(.86, sh) * (1.-smoothstep(.16, .2, length(sf*vec2(1., 1.8 + sh)))) * (1.-smoothstep(.25, .7, aa));+ k = max(k, floe);+ // a sheen of the sky near the banks: denser cuts at the edges+ float edge = smoothstep(.75, .98, abs(vR.y));+ k = max(k, edge * step(.55, h21(vec2(floor(v*2.), floor(vR.y*9.)))) * (1.-smoothstep(.1,.18,abs(fract(v*2.)-.5))));+ // the sun's road on the water at sunrise+ vec3 d = normalize(vW - uCam); vec3 r = reflect(d, vec3(0.,1.,0.));+ float road = pow(max(dot(normalize(r.xz), normalize(uSun.xz)), 0.), 220.) * uWarm;+ float rk = road * (1.-smoothstep(.16, .3, abs(f))) * step(.25, h11(floor(segs*1.7)+row*3.));+ vec3 lineCol = mix(uPaper, uYellow, clamp(road*1.6, 0., 1.));+ vec3 col = mix(uInk, lineCol, max(k, rk));+ gl_FragColor = vec4(col, 1.);+ }`,+});++// river banks: the cut wall of snow and earth, ink with paper strata+export const bankMat = new THREE.ShaderMaterial({+ uniforms: { ...U }, side: THREE.DoubleSide,+ vertexShader: `attribute vec2 aB; varying vec2 vB; varying vec3 vW;+ void main(){ vB = aB; vec4 w = modelMatrix*vec4(position,1.); vW = w.xyz; gl_Position = projectionMatrix*viewMatrix*w; }`,+ fragmentShader: GLSL_HASH + `+ uniform vec3 uInk, uPaper; varying vec2 vB; varying vec3 vW;+ void main(){+ // vB.x = metres along the bank, vB.y = 0 at the water .. 1 at the lip+ if (vB.y > .8) { // the snow lip, with an ink undercut line+ float lip = smoothstep(.8, .84, vB.y);+ gl_FragColor = vec4(mix(uInk, uPaper, lip), 1.); return;+ }+ float v = vB.y*6. + sin(vB.x*.4)*.4, row = floor(v), f = fract(v)-.5;+ float segs = vB.x/(3.+h11(row)*6.) + h11(row*3.)*7.;+ float on = step(.88, h11(floor(segs)+row*1.7)) * smoothstep(0.,.1,fract(segs))*(1.-smoothstep(.5,.9,fract(segs)));+ float aa = fwidth(v), w = .06*on;+ float k = on*(1.-smoothstep(w-aa, w+aa, abs(f)));+ // icicles hanging under the lip+ float ic = step(.6, h11(floor(vB.x*3.))) * step(.8 - .25*h11(floor(vB.x*3.)+4.), vB.y) * (1.-smoothstep(.15,.3,abs(fract(vB.x*3.)-.5)));+ gl_FragColor = vec4(uInk, 1.);+ }`,+});++// shelf ice along the banks+export const iceMat = new THREE.ShaderMaterial({+ uniforms: { ...U },+ vertexShader: VS_WORLD,+ fragmentShader: GLSL_HASH + `+ uniform vec3 uInk, uPaper; varying vec3 vW;+ void main(){+ float cn = abs(vn(vW.xz*.7)-.5), ca = fwidth(cn);+ float k = (1.-smoothstep(.008-ca,.008+ca,cn))*.7;+ gl_FragColor = vec4(mix(uPaper, uInk, k), 1.);+ }`,+});++// ------------------------------------------------------------------ the sky: knife cuts in direction space+// night: sparse wind cuts and stab-cut stars; dawn: the sky is carved from the horizon up, line by line;+// day: dense horizontal cuts, still ink between them, so white mountains keep their weight.+export const skyMat = new THREE.ShaderMaterial({+ uniforms: { ...U, uFront: { value: -1 }, uStars: { value: 1 }, uDense: { value: 0 },+ tType1: { value: null }, uRect1: { value: new THREE.Vector4() }, uAmt1: { value: 0 },+ tType2: { value: null }, uRect2: { value: new THREE.Vector4() }, uAmt2: { value: 0 } },+ side: THREE.BackSide, depthWrite: false,+ vertexShader: VS_WORLD,+ fragmentShader: GLSL_HASH + `+ uniform vec3 uInk, uPaper, uYellow, uCam, uSun; uniform float uFront, uStars, uDense, uWarm; varying vec3 vW;+ uniform sampler2D tType1, tType2; uniform vec4 uRect1, uRect2; uniform float uAmt1, uAmt2;+ // a plate of carved type hung in direction space: an ink block cleared out of the sky, letters cut in paper,+ // revealed left to right as the knife goes (amt 0..1), and taken back the same way+ vec3 typePlate(vec3 col, sampler2D tex, vec4 rect, float amt, float az, float el, float plate){+ vec2 uv = vec2((az - rect.x)/(rect.z - rect.x), (el - rect.y)/(rect.w - rect.y));+ if (amt <= 0. || uv.x < -.06 || uv.x > 1.06 || uv.y < -.12 || uv.y > 1.12) return col;+ // the cleared plate, with a ragged knife edge+ float e = min(min(uv.x + .05, 1.05 - uv.x)*3., min(uv.y + .1, 1.1 - uv.y));+ float rag = (h21(floor(vec2(az, el)*900.)) - .5)*.012;+ float inside = smoothstep(0., .004, e + rag) * plate * clamp(amt*3., 0., 1.);+ col = mix(col, uInk, inside);+ if (uv.x < 0. || uv.x > 1. || uv.y < 0. || uv.y > 1.) return col;+ float a = texture2D(tex, uv).a;+ float shown = step(uv.x, amt*1.04);+ return mix(col, uPaper, a*shown);+ }+ float lineRow(float el, float az, float rows, float prob, float seed, float wmul, float segMin, float segMax, out float rowEl){+ float v = el*rows; float row = floor(v);+ float ph = h11(row*1.7+seed)*6.28, amp = .18 + h11(row*3.1+seed)*.25, fr = 4. + h11(row*5.3+seed)*9.;+ v += sin(ph + az*fr)*amp;+ row = floor(v); float f = fract(v)-.5;+ rowEl = (row + .5)/rows;+ float segL = segMin + h11(row*2.9+seed)*(segMax-segMin);+ float s = az/segL + h11(row*7.7+seed)*9.; float j = floor(s), sf = fract(s);+ float on = step(1.-prob, h11(j*3.1+row*.71+seed));+ float taper = smoothstep(0.,.06,sf)*(1.-smoothstep(.55,.98,sf));+ float w = (.07 + .1*h11(j+row*1.3+seed))*wmul*taper*on;+ float aa = fwidth(v)*.9;+ return 1.-smoothstep(w-aa, w+aa, abs(f));+ }+ void main(){+ vec3 d = normalize(vW - uCam);+ float el = asin(clamp(d.y,-1.,1.)), az = atan(d.x, -d.z);+ if (el < -.004) { gl_FragColor = vec4(uPaper, 1.); return; }+ float re;+ // night wind cuts+ float kn = lineRow(el, az, 105., .45, 0., 1., .06, .32, re) * (1.-uDense);+ // carved dawn / day: an engraver's sky. Straight parallel cuts, thick near the horizon and thin overhead,+ // so the tone is made by the width of the lines. Rows up to the front are cut; the newest row still runs left to right.+ float sunA0 = max(dot(normalize(d.xz), normalize(uSun.xz)), 0.);+ float glow0 = pow(sunA0, 24.) * (1.-smoothstep(.0, .3, el)) * uWarm;+ float rows = 260.;+ float v = el*rows + sin(az*2.3 + floor(el*rows)*1.7)*.06;+ float row = floor(v), f = fract(v)-.5;+ re = (row+.5)/rows;+ float cov = mix(.5, .1, smoothstep(.0, .36, el)) * mix(.85, 1., uDense) + glow0*.3;+ float segL = .5 + h11(row*2.9+21.)*1.1;+ float sg = az/segL + h11(row*7.7)*9.; float sj = floor(sg), sf = fract(sg);+ float on = step(.12, h11(sj*3.1+row*.71+21.));+ float taper = smoothstep(0.,.03,sf)*(1.-smoothstep(.9,1.,sf));+ float w = cov*.5*mix(.55, 1., taper)*on;+ float aa = fwidth(v)*.9;+ float kd = 1.-smoothstep(w-aa, w+aa, abs(f));+ float carved = step(re, uFront);+ float edge = step(uFront - 1./rows, re);+ float run = clamp((uFront - re)*rows, 0., 1.);+ float sweep = step(az, mix(-3.2, 3.2, run));+ kd *= carved * mix(1., sweep, edge);+ // stars, dimming as the day comes+ vec2 sc = vec2(az, el)*vec2(140., 140.); vec2 cid = floor(sc), cf = fract(sc)-.5;+ float sr = h21(cid), ss = mix(.1, .2, step(.92, h21(cid+3.)));+ float star = step(.965, sr) * step(max(abs(cf.x),abs(cf.y)*1.1), ss) * uStars * smoothstep(.0, .05, el);+ float k = max(max(kn, kd), star);+ // warm light near the sun: the cut lines catch it+ float sunA = max(dot(normalize(d.xz), normalize(uSun.xz)), 0.);+ float glow = pow(sunA, 26.) * (1.-smoothstep(.0, .3, el)) * uWarm;+ vec3 lineCol = mix(uPaper, uYellow, clamp(glow*1.3, 0., .85));+ vec3 col = mix(uInk, lineCol, k);+ col = typePlate(col, tType1, uRect1, uAmt1, az, el, 1.);+ col = typePlate(col, tType2, uRect2, uAmt2, az, el, 1.);+ gl_FragColor = vec4(col, 1.);+ }`,+});++// ------------------------------------------------------------------ billboards+// mode 0: cylindrical (trees, standing cranes), feet at the pivot; mode 1: spherical, centred, rotated on screen.+export function billboardMat(tex, mode, opts = {}) {+ return new THREE.ShaderMaterial({+ uniforms: { tMap: { value: tex }, ...U, uTint: { value: 0 } },+ vertexShader: `+ attribute vec3 aOff; attribute vec2 aSize; attribute vec4 aTile; attribute float aRot;+ varying vec2 vUv; varying vec3 vW;+ void main(){+ vec3 right = vec3(viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0]);+ vec3 up = vec3(viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1]);+ ${mode === 0 ? 'right = normalize(vec3(right.x,0.,right.z)); up = vec3(0.,1.,0.);' : ''}+ vec2 q = position.xy*aSize; float c = cos(aRot), s = sin(aRot);+ q = vec2(c*q.x - s*q.y, s*q.x + c*q.y);+ vec3 p = aOff + right*q.x + up*q.y;+ vUv = aTile.xy + uv*aTile.zw; vW = p;+ gl_Position = projectionMatrix*viewMatrix*vec4(p,1.);+ }`,+ fragmentShader: `+ uniform sampler2D tMap; uniform vec3 uYellow, uCam, uSun; uniform float uTint, uWarm; varying vec2 vUv; varying vec3 vW;+ void main(){+ vec4 c = texture2D(tMap, vUv, -1.6); if (c.a < .42) discard; // sharper mips keep thin sprites alive far away+ ${opts.fade ? `if (fract(sin(dot(gl_FragCoord.xy, vec2(12.9898,78.233)))*43758.5453) > smoothstep(${opts.fade[0].toFixed(1)}, ${opts.fade[1].toFixed(1)}, distance(vW, uCam))) discard;` : ''}+ float l = dot(c.rgb, vec3(.33));+ vec3 col = c.rgb;+ ${opts.warm ? 'col = mix(col, mix(col, uYellow, .35), uWarm*uTint*smoothstep(.5,.8,l)*smoothstep(-.1,.6,dot(normalize(vW.xz-uCam.xz), normalize(uSun.xz))));' : ''}+ gl_FragColor = vec4(col, 1.);+ }`,+ side: THREE.DoubleSide,+ ...(opts.transparentDepth ? { depthWrite: false } : {}),+ });+}+// the cranes' reflections: the same sprite hung upside down from the water line, cut into broken horizontal strips+export function reflectMat(tex) {+ return new THREE.ShaderMaterial({+ uniforms: { tMap: { value: tex }, uWaterY: { value: -.6 }, uT: { value: 0 } },+ vertexShader: `+ attribute vec3 aOff; attribute vec2 aSize; attribute vec4 aTile; attribute float aRot;+ uniform float uWaterY; varying vec2 vUv; varying float vY;+ void main(){+ vec3 right = vec3(viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0]);+ right = normalize(vec3(right.x,0.,right.z));+ vec2 q = position.xy*aSize;+ float sink = uWaterY - aOff.y;+ vec3 p = vec3(aOff.x, uWaterY + .01, aOff.z) + right*q.x + vec3(0.,-1.,0.)*(q.y - sink);+ vUv = aTile.xy + uv*aTile.zw; vY = q.y;+ gl_Position = projectionMatrix*viewMatrix*vec4(p,1.);+ }`,+ fragmentShader: GLSL_HASH + `+ uniform sampler2D tMap; uniform vec3 uPaper; uniform float uT; varying vec2 vUv; varying float vY;+ void main(){+ float band = vY*14.; float row = floor(band);+ vec2 uv = vUv + vec2(sin(row*1.7 + uT*2.)*.004, 0.);+ vec4 c = texture2D(tMap, uv); if (c.a < .45) discard;+ float l = dot(c.rgb, vec3(.33)); if (l < .5) discard;+ if (abs(fract(band)-.5) > .22 || h11(row*3.3) < .2) discard;+ gl_FragColor = vec4(${'vec3(0.93,0.90,0.80)'}, 1.);+ }`,+ side: THREE.DoubleSide,+ });+}+// the red crowns: one round red stab per bird, never smaller than a few pixels+export function crownMat(proj) {+ return new THREE.ShaderMaterial({+ uniforms: { uProj: { value: proj }, uMin: { value: 7 }, uRed: { value: v3(C.red) }, uPaper: U.uPaper, uOn: { value: 1 }, uShift: { value: new THREE.Vector2() } },+ vertexShader: `+ attribute vec3 aOff; attribute vec2 aSize; attribute vec2 aHead; attribute float aRot; attribute float aMode; attribute float aOn;+ uniform float uProj, uMin, uOn; uniform vec2 uShift; varying float vOn;+ void main(){+ vec3 right = vec3(viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0]);+ vec3 up = vec3(viewMatrix[0][1], viewMatrix[1][1], viewMatrix[2][1]);+ if (aMode < .5) { right = normalize(vec3(right.x,0.,right.z)); up = vec3(0.,1.,0.); }+ vec2 q = vec2((aHead.x-.5)*aSize.x, (aMode < .5 ? (1.-aHead.y) : (.5-aHead.y))*aSize.y);+ float c = cos(aRot), s = sin(aRot); q = vec2(c*q.x - s*q.y, s*q.x + c*q.y);+ vec3 p = aOff + right*q.x + up*q.y + (vec3(0.)) ;+ vec4 mv = viewMatrix*vec4(p,1.);+ mv.z += .02; // sit just in front of the head+ float px = (aMode < .5 ? .045 : .026)*abs(aSize.y)*uProj/-mv.z;+ // the red plus a paper ring around it, so it separates from the ink of the head+ gl_PointSize = aOn*uOn > .01 ? max(px, uMin)*aOn*1.45 : 0.;+ vOn = aOn*uOn;+ gl_Position = projectionMatrix*mv;+ gl_Position.xy += uShift/vec2(1920., 1080.)*gl_Position.w;+ }`,+ fragmentShader: `uniform vec3 uRed, uPaper; varying float vOn;+ void main(){ vec2 q = gl_PointCoord-.5; float r = length(q); if (r > .5 || vOn < .01) discard;+ gl_FragColor = vec4(r < .345 ? uRed : uPaper, 1.); }`,+ });+}++// flat-shaded props (bridge, hut, fence, sign) with ink hulls+export function toonMat(lit, shade) {+ return new THREE.ShaderMaterial({+ uniforms: { uLit: { value: v3(lit) }, uShade: { value: v3(shade) }, uL: U.uL },+ vertexShader: `varying vec3 vN; void main(){ vN = normalize(mat3(modelMatrix)*normal); gl_Position = projectionMatrix*viewMatrix*modelMatrix*vec4(position,1.); }`,+ fragmentShader: `uniform vec3 uLit, uShade, uL; varying vec3 vN;+ void main(){ gl_FragColor = vec4(dot(normalize(vN), uL) > .05 ? uLit : uShade, 1.); }`,+ });+}+// wood: dark boards with paper grain cuts along the board+export const woodMat = new THREE.ShaderMaterial({+ uniforms: { ...U },+ vertexShader: `varying vec3 vW; varying vec3 vN; void main(){ vN = normalize(mat3(modelMatrix)*normal); vec4 w = modelMatrix*vec4(position,1.); vW = w.xyz; gl_Position = projectionMatrix*viewMatrix*w; }`,+ fragmentShader: GLSL_HASH + `+ uniform vec3 uInk, uPaper, uL; varying vec3 vW; varying vec3 vN;+ void main(){+ vec3 n = normalize(vN);+ if (n.y > .7) { gl_FragColor = vec4(uPaper, 1.); return; } // snow on top+ float along = abs(n.x) > abs(n.z) ? vW.z : vW.x;+ float v = vW.y*7. + sin(along*1.3)*.3, row = floor(v), f = fract(v)-.5;+ float segs = along*(.8+h11(row)) + h11(row*2.)*5.;+ float on = step(.55, h11(floor(segs)+row*3.)) * smoothstep(0.,.1,fract(segs))*(1.-smoothstep(.4,.9,fract(segs)));+ float aa = fwidth(v), lit = dot(n, uL) > .05 ? 1. : .45;+ float k = on*(1.-smoothstep(.06*lit-aa, .06*lit+aa, abs(f)));+ gl_FragColor = vec4(mix(uInk, uPaper, k*.8), 1.);+ }`,+});+// concrete in moonlight: lit faces paper with the formwork lines cut in ink, shadow faces ink with paper lines+export const concreteMat = new THREE.ShaderMaterial({+ uniforms: { ...U },+ vertexShader: `varying vec3 vW; varying vec3 vN; void main(){ vN = normalize(mat3(modelMatrix)*normal); vec4 w = modelMatrix*vec4(position,1.); vW = w.xyz; gl_Position = projectionMatrix*viewMatrix*w; }`,+ fragmentShader: GLSL_HASH + `+ uniform vec3 uInk, uPaper, uL; varying vec3 vW; varying vec3 vN;+ float ln(float v, float w){ float f = abs(fract(v)-.5), a = fwidth(v); return 1.-smoothstep(w-a, w+a, f); }+ void main(){+ vec3 n = normalize(vN);+ if (n.y > .7) { gl_FragColor = vec4(uPaper, 1.); return; }+ float along = abs(n.x) > abs(n.z) ? vW.z : vW.x;+ // courses of cut stone: horizontal joints every 0.42 m, staggered vertical joints+ float fy = fract(vW.y/.42), row = floor(vW.y/.42);+ float joints = max(ln(vW.y/.42 + .5, .035), ln(along/.9 + h11(row)*.5 + .5, .03) * step(.12, fy) * step(fy, .88));+ if (dot(n, uL) <= 0.) { // the shadow face: ink, diagonal hatching, paper joints+ float hatch = ln((along + vW.y*.8)*7., .16);+ gl_FragColor = vec4(mix(uInk, uPaper, max(joints*.85, hatch*.4)), 1.); return;+ }+ // the lit face: paper, ink joints, chisel marks thicker toward the waterline, a frozen splash band at the bottom+ vec2 cc = vec2(along, vW.y)*vec2(9., 14.); vec2 ci = floor(cc), cf = fract(cc)-.5;+ float chis = step(.74 - .22*smoothstep(1.4, -.6, vW.y), h21(ci)) * (1.-smoothstep(.05, .09, abs(cf.x - cf.y*.6)));+ float k = max(joints*.95, chis*.8);+ float ice = smoothstep(-.4, -.25, vW.y) * (1.-smoothstep(.0, .3 + .25*h11(floor(along*6.)), vW.y));+ k *= 1. - ice;+ gl_FragColor = vec4(mix(uPaper, uInk, k), 1.);+ }`,+});+export const inkMat = new THREE.MeshBasicMaterial({ color: C.ink });+export const paperMat = new THREE.MeshBasicMaterial({ color: C.paper });+export const hullMat = new THREE.MeshBasicMaterial({ color: C.ink, side: THREE.BackSide });diff --git a/styles/printed-long-take/demo/props.js b/styles/printed-long-take/demo/props.jsnew file mode 100644index 0000000..3dd63c0--- /dev/null+++ b/styles/printed-long-take/demo/props.js@@ -0,0 +1,176 @@+// The things in the world that carry words: the cast-iron bridge plate, the dial thermometer, the board at the feeding+// field, and the plates of carved type in the sky (title and end card). All drawn on canvas, in ink and paper only.+import { mulberry } from '/core/lib.js';+import { INK, PAPER, cut } from './textures.js';++export const FONT = `'NotoSerifSC', serif`;+const font = (px) => `700 ${px}px ${FONT}`;++// letters cut into an ink ground: paper face, a hairline of ink inside each stroke edge, a few knife nicks+function carvedText(g, text, x, y, px, R, opts = {}) {+ g.font = font(px); g.textBaseline = 'alphabetic'; g.textAlign = opts.align || 'left';+ g.fillStyle = opts.col || PAPER; g.fillText(text, x, y);+ if (opts.nicks !== false) {+ const w = g.measureText(text).width, x0 = opts.align === 'center' ? x - w / 2 : opts.align === 'right' ? x - w : x;+ g.save(); g.globalCompositeOperation = 'source-atop';+ for (let i = 0; i < w / 18; i++) { const xx = x0 + R() * w, yy = y - R() * px * .8; cut(g, xx, yy, xx + 6 + R() * 14, yy + (R() - .5) * 2, 1.6, R, INK); }+ g.restore();+ }+ return g.measureText(text).width;+}++// ------------------------------------------------------------------ the bridge plate: cast iron, raised letters+export function plateCanvas() {+ const W = 1100, H = 560, c = document.createElement('canvas'); c.width = W; c.height = H;+ const g = c.getContext('2d'), R = mulberry(31);+ g.fillStyle = INK; g.fillRect(0, 0, W, H);+ // a raised rim and four bolts+ g.strokeStyle = PAPER; g.lineWidth = 10; g.strokeRect(26, 26, W - 52, H - 52);+ g.lineWidth = 3; g.strokeRect(44, 44, W - 88, H - 88);+ for (const [x, y] of [[70, 70], [W - 70, 70], [70, H - 70], [W - 70, H - 70]]) { g.fillStyle = PAPER; g.beginPath(); g.arc(x, y, 13, 0, 7); g.fill(); g.fillStyle = INK; g.fillRect(x - 9, y - 2, 18, 4); }+ carvedText(g, '音羽橋', W / 2, 300, 210, R, { align: 'center', nicks: false });+ carvedText(g, 'Otowa Bridge', W / 2, 455, 96, R, { align: 'center', nicks: false });+ // rime on the top edge of the plate+ for (let i = 0; i < 60; i++) { const x = R() * W; cut(g, x, 4 + R() * 10, x + 10 + R() * 30, 6 + R() * 10, 5, R, PAPER); }+ return c;+}+// where each line sits on the plate, as fractions of its width and height (for the reading check)+export const PLATE_LINES = [+ { id: 'plate-cn', text: '音羽橋', u0: .2, u1: .8, v0: .17, v1: .58 },+ { id: 'plate-en', text: 'Otowa Bridge', u0: .2, u1: .8, v0: .66, v1: .86 },+];++// ------------------------------------------------------------------ an old dial thermometer: paper face, ink scale, needle on −20+export function dialCanvas() {+ const S = 600, c = document.createElement('canvas'); c.width = S; c.height = S;+ const g = c.getContext('2d'), m = S / 2, R = mulberry(77);+ g.fillStyle = INK; g.beginPath(); g.arc(m, m, 296, 0, 7); g.fill();+ g.fillStyle = PAPER; g.beginPath(); g.arc(m, m, 262, 0, 7); g.fill();+ // scale −40 … +40 over 270°+ const ang = v => (-225 + (v + 40) / 80 * 270) * Math.PI / 180;+ g.strokeStyle = INK; g.lineCap = 'butt';+ for (let v = -40; v <= 40; v += 2) {+ const a = ang(v), r0 = v % 10 ? 222 : 200;+ g.lineWidth = v % 10 ? 4 : 9; g.beginPath(); g.moveTo(m + Math.cos(a) * r0, m + Math.sin(a) * r0); g.lineTo(m + Math.cos(a) * 248, m + Math.sin(a) * 248); g.stroke();+ }+ g.fillStyle = INK; g.font = font(46); g.textAlign = 'center'; g.textBaseline = 'middle';+ for (const v of [-40, -20, 0, 20, 40]) { const a = ang(v); g.fillText(v < 0 ? '−' + -v : String(v), m + Math.cos(a) * 160, m + Math.sin(a) * 160); }+ g.font = font(60); g.fillText('°C', m, m + 120);+ // the needle, on −20+ const a = ang(-20);+ g.strokeStyle = INK; g.lineWidth = 12; g.lineCap = 'round';+ g.beginPath(); g.moveTo(m - Math.cos(a) * 40, m - Math.sin(a) * 40); g.lineTo(m + Math.cos(a) * 236, m + Math.sin(a) * 236); g.stroke();+ g.fillStyle = INK; g.beginPath(); g.arc(m, m, 26, 0, 7); g.fill();+ // frost on the glass+ for (let i = 0; i < 26; i++) { const aa = R() * 7, r = 250 + R() * 30; cut(g, m + Math.cos(aa) * r, m + Math.sin(aa) * r, m + Math.cos(aa + .08) * (r - 20), m + Math.sin(aa + .08) * (r - 20), 4, R, PAPER); }+ return c;+}++// ------------------------------------------------------------------ the board at the feeding field+// Two counts side by side on one baseline, the status band under them: old status under 1952, the seal under 2025.+// Chinese and numbers only on the board; the English is in the subtitle bar.+// state: { date: 0..1, num: 0..1 (the 2025 column, cut in), strike: 0..1, stamp: 0..1 }+export const BOARD = { W: 2048, H: 1408 };+const M = 130;+const PIECES = [ // id, text, x, baseline, px, group+ ['b-head', '丹顶鹤 · 冬季清点', M, 190, 88, 'base'],+ ['b-d1', '1952 年冬', M, 380, 84, 'base'],+ ['b-n1', '33 只', M, 700, 0, 'base'],+ ['b-d2', '2025 年 1 月', 1110, 380, 84, 'date'],+ ['b-n2', '1,927 只', 1110, 700, 0, 'num'],+ ['b-lab', '保护等级', M + 50, 960, 72, 'base'],+ ['b-old', '易危', M + 50, 1150, 150, 'base'],+];+const NUM = 250, UNIT = 100;+function numeral(g, x, y, num, R) { // a big carved numeral with its unit after it+ const w = carvedText(g, num, x - 8, y, NUM, R);+ carvedText(g, '只', x + w + 10, y, UNIT, R);+ return w + 10 + UNIT;+}+export function boardCanvas(c, st) {+ const { W, H } = BOARD;+ if (!c) { c = document.createElement('canvas'); c.width = W; c.height = H; }+ const g = c.getContext('2d'), R = mulberry(1952);+ g.save(); g.beginPath(); g.rect(0, 0, W, H); g.clip();+ g.fillStyle = INK; g.fillRect(0, 0, W, H);+ for (let p = 0; p < 3; p++) {+ const y0 = p * H / 3;+ g.fillStyle = '#2b2c31'; g.fillRect(0, y0 + H / 3 - 3, W, 6);+ for (let i = 0; i < 60; i++) { const y = y0 + 10 + R() * (H / 3 - 20), x = R() * W; cut(g, x, y, x + 60 + R() * 260, y + (R() - .5) * 4, 1.4 + R() * 1.4, R, '#34353b'); }+ }+ const clipCarve = (k, x, y, w, h, draw) => { // the knife goes left to right; chips at its edge+ if (k <= 0) return;+ g.save(); g.beginPath(); g.rect(x - 10, y - h, (w + 30) * k, h * 1.35); g.clip(); draw(); g.restore();+ if (k < 1) { const xe = x + w * k; for (let i = 0; i < 8; i++) { const xx = xe + R() * 30, yy = y - R() * h; cut(g, xx, yy, xx + 8, yy - 6, 3, R, PAPER); } }+ };+ carvedText(g, '丹顶鹤 · 冬季清点', M, 190, 88, R);+ cut(g, M, 250, W - M, 252, 5, R, PAPER, .2);+ carvedText(g, '1952 年冬', M, 380, 84, R);+ numeral(g, M, 700, '33', R);+ cut(g, 1024, 300, 1026, 770, 5, R, PAPER, .2);+ // the empty column waits: two faint scored guide lines+ if (st.date <= 0) { g.strokeStyle = '#4a4b50'; g.lineWidth = 3; for (const y of [392, 712]) { g.beginPath(); g.moveTo(1110, y); g.lineTo(1900, y); g.stroke(); } }+ clipCarve(st.date, 1110, 380, 520, 90, () => carvedText(g, '2025 年 1 月', 1110, 380, 84, R));+ clipCarve(st.num, 1110, 700, 860, 260, () => numeral(g, 1110, 700, '1,927', R));++ // the pasted paper notice, the width of the board+ const by = 820, bh = 480;+ g.fillStyle = PAPER; g.beginPath(); g.moveTo(M - 24, by + 6); g.lineTo(W - M + 24, by); g.lineTo(W - M + 20, by + bh); g.lineTo(M - 18, by + bh - 4); g.closePath(); g.fill();+ g.strokeStyle = INK; g.lineWidth = 5; g.strokeRect(M + 8, by + 28, W - 2 * M - 16, bh - 56);+ g.fillStyle = INK; g.textAlign = 'left'; g.textBaseline = 'alphabetic';+ g.font = font(72); g.fillText('保护等级', M + 50, 960);+ g.font = font(150); g.fillText('易危', M + 50, 1150);+ if (st.strike > 0) cut(g, M + 20, 1095, M + 20 + 380 * st.strike, 1085, 24, mulberry(9), INK, .1);+ // the cut arrow from the old status toward the seal, under the 2025 column+ if (st.strike > 0) { // the arrow is cut with the strike, pointing to where the seal will land+ const k = st.strike; cut(g, 560, 1095, 560 + 420 * k, 1095, 9, R, INK, .1);+ if (k >= 1) { g.beginPath(); g.moveTo(1004, 1095); g.lineTo(968, 1074); g.lineTo(968, 1116); g.fill(); }+ }+ if (st.stamp > 0) {+ const ss = 360 * (1 + .12 * (1 - st.stamp)), cx = 1110 + 180, cy = by + bh / 2;+ g.save(); g.translate(cx, cy); g.rotate(-.04); g.globalAlpha = Math.min(1, st.stamp * 1.5);+ g.fillStyle = INK; g.fillRect(-ss / 2, -ss / 2, ss, ss);+ g.fillStyle = PAPER; g.fillRect(-ss / 2 + 14, -ss / 2 + 14, ss - 28, ss - 28); g.fillStyle = INK; g.fillRect(-ss / 2 + 24, -ss / 2 + 24, ss - 48, ss - 48);+ const k = ss / 360; g.fillStyle = PAPER; g.textAlign = 'center';+ g.font = font(132 * k); g.fillText('近危', 0, 18 * k);+ g.font = font(66 * k); g.fillText('2026.3', 0, 128 * k);+ const r = mulberry(5); g.fillStyle = INK; for (let i = 0; i < 50; i++) g.fillRect((r() - .5) * ss * .85, (r() - .5) * ss * .85, 3 + r() * 6, 2 + r() * 4);+ g.restore();+ g.globalAlpha = Math.min(1, st.stamp * 1.5); g.fillStyle = INK; g.textAlign = 'left';+ g.font = font(76); g.fillText('已移出濒危', 1520, 1090); g.globalAlpha = 1;+ }+ g.restore();+ return c;+}+// where each read piece is on the board (canvas px), for the reading check+export function boardPieces(st) {+ const g = document.createElement('canvas').getContext('2d'), out = [];+ const box = (id, text, x, y, px, w) => { g.font = font(px); w = w ?? g.measureText(text).width; out.push({ id, text, x0: x, y0: y - px * .88, x1: x + w, y1: y + px * .14 }); };+ box('b-head', '丹顶鹤 · 冬季清点', M, 190, 88);+ box('b-d1', '1952 年冬', M, 380, 84);+ g.font = font(NUM); const w33 = g.measureText('33').width + 10 + UNIT, w19 = g.measureText('1,927').width + 10 + UNIT;+ box('b-n1', '33 只', M, 700, NUM * .74, w33);+ if (st.date > 0) box('b-d2', '2025 年 1 月', 1110, 380, 84);+ if (st.num > 0) box('b-n2', '1,927 只', 1110, 700, NUM * .74, w19);+ box('b-lab', '保护等级', M + 50, 960, 72);+ box('b-old', '易危', M + 50, 1150, 150);+ if (st.stamp > .5) {+ out.push({ id: 's-cn', text: '近危', x0: 1290 - 130, y0: 1060 - 120, x1: 1290 + 130, y1: 1060 + 25 });+ out.push({ id: 's-date', text: '2026.3', x0: 1290 - 105, y0: 1060 + 70, x1: 1290 + 105, y1: 1060 + 135 });+ box('s-note', '已移出濒危', 1520, 1090, 76);+ }+ return out;+}++// ------------------------------------------------------------------ plates of carved type for the sky (title, end card)+// lines: [{text, px, y}], returns the canvas and each line's box as fractions of the canvas+export function skyTypeCanvas(lines, W = 2400, H = 820) {+ const c = document.createElement('canvas'); c.width = W; c.height = H;+ const g = c.getContext('2d'), R = mulberry(4);+ const boxes = [];+ for (const L of lines) {+ const w = carvedText(g, L.text, L.x ?? 40, L.y, L.px, R, { nicks: true });+ boxes.push({ id: L.id, text: L.text, u0: (L.x ?? 40) / W, u1: ((L.x ?? 40) + w) / W, v0: (L.y - L.px * .92) / H, v1: (L.y + L.px * .22) / H });+ }+ return { c, boxes };+}diff --git a/styles/printed-long-take/demo/scene.js b/styles/printed-long-take/demo/scene.jsnew file mode 100644index 0000000..08c537d--- /dev/null+++ b/styles/printed-long-take/demo/scene.js@@ -0,0 +1,646 @@+// Thirty-Three Cranes — Printed Long Take. A three-dimensional winter valley rendered as a scratchboard print:+// one unbroken camera move from the steaming river to the air, then the feeding field and the board that keeps the count.+import * as THREE from 'three';+import { mulberry, clamp, lerp, ss, eio, seg, track, hash } from '/core/lib.js';+import { C, U, skyMat, GLSL_HASH } from './look.js';+import { buildWorld, WY, BRIDGE, RIVER } from './world.js';+import { POSE, craneAtlas, frostTreeAtlas, mistAtlas, sunCanvas } from './textures.js';+import { T, VO } from './timeline.js';+import { skyTypeCanvas, boardCanvas, boardPieces, PLATE_LINES, BOARD } from './props.js';+import { canvasTex } from './world.js';++const Q = new URLSearchParams(location.search);+const W_ = 1920, H_ = 1080, SS = 2;+window.DUR = T.DUR;++// ---------------------------------------------------------------- renderer+const renderer = new THREE.WebGLRenderer({ antialias: false, preserveDrawingBuffer: true });+renderer.setPixelRatio(1); renderer.setSize(W_, H_, false);+renderer.outputColorSpace = THREE.LinearSRGBColorSpace;+document.body.appendChild(renderer.domElement);+const rtA = new THREE.WebGLRenderTarget(W_ * SS, H_ * SS, { samples: 4 });+const rtB = new THREE.WebGLRenderTarget(W_ * SS, H_ * SS, { samples: 4 });++const scene = new THREE.Scene(); scene.background = C.ink;+const camera = new THREE.PerspectiveCamera(34, W_ / H_, .3, 9000);+const projScale = () => H_ * SS / (2 * Math.tan(camera.fov * Math.PI / 360));++// atlas preview (?atlas=crane|tree|mist|sun)+if (Q.get('atlas')) {+ const c = { crane: craneAtlas, tree: frostTreeAtlas, mist: mistAtlas, sun: sunCanvas }[Q.get('atlas')]();+ document.body.innerHTML = ''; document.body.style.background = '#8a8a80';+ c.style.cssText = 'width:100vw;height:100vh;object-fit:contain;display:block'; document.body.appendChild(c);+ window.render = () => {}; window.READY = true;+ await new Promise(() => {});+}++// the camera's path through the valley, keyed (time, [eye, target])+const CAM_A_KEYS = [+ [0, [-18, 44, 222, -6, 30, -280]],+ [2.6, [-12, 25, 160, -3, 14, -230]],+ [5.2, [-3, 6.5, 62, 4, 2.6, -40]],+ [6.6, [4.2, 1.4, 12, 11, 1.6, -27]],+ [7.3, [8.2, 1.1, -12, 12.6, 1.9, -27.3]],+ [7.7, [9.4, 1.1, -17.6, 12.7, 2.4, -27.3]],+ [9.9, [9.8, 1.1, -18.8, 12.7, 2.4, -27.3]],+ [10.6, [6.6, .8, -31, 12, .9, -52]],+ [11.6, [19, .55, -64, 120, 6, -110]],+ [12.4, [34, .4, -87, 180, 3.2, -118]],+ [13.6, [34.7, .4, -87.3, 180, 3.6, -119]],+ [15.0, [35.8, .4, -87.8, 180, 10, -121]],+ [16.2, [36.8, .4, -88.2, 180, 11.4, -122]],+ [17.0, [37.4, .7, -88.4, 180, 11.4, -122]],+ [17.8, [38.6, 2.2, -88.2, 180, 11.4, -122]],+ [18.4, [38.4, 5.5, -89.5, 180, 11.4, -122]],+ [18.95, [36.5, 9.5, -92, 180, 11.4, -122]],+];+const PATH_CLEAR = (() => { const f = track(CAM_A_KEYS), o = []; for (let t = 2; t < 19; t += .1) { const c = f(t); if (c[1] < 40) o.push([c[0], c[2], t > 9.9 && t < 13 ? 15 : c[1] > 12 ? 12 : 9]); } return o; })();+// the type must be loaded before any plate or board is drawn+const fontFace = await new FontFace('NotoSerifSC', 'url(./fonts/NotoSerifSC-700.woff2)', { weight: '700' }).load();+document.fonts.add(fontFace);+const W = buildWorld(scene, projScale(), PATH_CLEAR);++// ---------------------------------------------------------------- the print pass+const printMat = new THREE.ShaderMaterial({+ uniforms: {+ tA: { value: rtA.texture }, tB: { value: rtB.texture }, uT: { value: 0 }, uRes: { value: new THREE.Vector2(W_, H_) },+ uPeel: { value: -1 }, uWhite: { value: 0 }, uFresh: { value: 0 }, tSub: { value: null }, uPaper: U.uPaper, uInk: U.uInk,+ },+ vertexShader: `varying vec2 vUv; void main(){ vUv = uv; gl_Position = vec4(position.xy,0.,1.); }`,+ fragmentShader: GLSL_HASH + `+ uniform sampler2D tA, tB, tSub; uniform float uT, uPeel, uWhite, uFresh; uniform vec2 uRes; uniform vec3 uPaper, uInk; varying vec2 vUv;+ float fbm(vec2 p){ float a=.5, s=0.; for(int i=0;i<5;i++){ s+=a*vn(p); p*=2.03; a*=.5; } return s; }+ vec3 freshInk(vec3 c, vec2 uv, float amt){+ // a print just pulled: the ink hasn't covered everywhere yet+ float dark = 1. - smoothstep(.2, .5, dot(c, vec3(.33)));+ float m = smoothstep(.6, .72, fbm(uv*vec2(260.,150.)+7.)) * amt;+ float sp = step(.82, h21(floor(uv*vec2(900.,500.))));+ return mix(c, uPaper*.9, dark*max(m*.8, sp*amt*.5));+ }+ void main(){+ vec2 uv = vUv;+ vec3 c = texture2D(tA, uv).rgb;+ if (uPeel >= 0.) {+ // the top sheet is peeled from the top-right corner; the fresh print lies under it+ vec2 asp = vec2(uRes.x/uRes.y, 1.);+ vec2 p = uv*asp, corner = asp, D = normalize(-asp);+ float diag = length(asp), s = uPeel*(diag+.15);+ float d = dot(p - corner, D);+ vec3 under = freshInk(texture2D(tB, uv).rgb, uv, uFresh);+ if (d < s) {+ c = under * (1. - .4*smoothstep(.1, 0., s - d)); // shadow along the fold+ } else if (d < 2.*s) {+ vec2 pm = p - 2.*(d - s)*D; // where this bit of the flap came from+ vec2 um = pm/asp;+ if (um.x <= 1. && um.y <= 1. && um.x >= 0. && um.y >= 0.) {+ float k = (d - s)/max(s, 1e-3);+ vec3 ghost = texture2D(tA, vec2(1.-um.x, um.y)).rgb; // show-through, mirrored+ vec3 back = mix(uPaper, ghost, .13) * (.8 + .26*smoothstep(0., .5, k) - .1*smoothstep(.5, 1., k));+ back *= 1. + (fbm(um*vec2(500.,300.))-.5)*.05;+ c = back;+ // the flap's edge, a hard ink line+ float e = min(min(um.x, um.y), min(1.-um.x, 1.-um.y));+ c = mix(uInk, c, smoothstep(.0, .0025, e));+ } else {+ c *= 1. - .3*smoothstep(.05, 0., d - 2.*s + .02); // cast shadow of the flap+ }+ }+ } else if (uFresh > 0.) {+ c = freshInk(c, uv, uFresh);+ }+ float lum = dot(c, vec3(.299,.587,.114));+ float dark = 1. - smoothstep(.18, .55, lum);+ float tf = floor(uT*12.)/12.;+ float fib = fbm(uv*vec2(700.,420.));+ c *= 1. + (fib-.5)*.06*(1.-dark);+ float mot = fbm(uv*vec2(46.,26.) + 3.);+ c += dark*(mot-.5)*.05;+ float b = fbm(vec2(uv.x*4.2 + tf*.06, uv.y*2.2 - tf*.02) + 11.);+ b = smoothstep(.5, .78, b) * smoothstep(.62, 1., uv.y);+ c += dark*b*.09;+ // steam whiteout: the picture is eaten by horizontal paper cuts+ if (uWhite > 0.) {+ float row = floor(uv.y*120.), f = abs(fract(uv.y*120.)-.5);+ float r = h11(row*1.7), run = vn(vec2(uv.x*3. + r*20., row*.37));+ float w = smoothstep(.0, .25, uWhite*1.8 - r*.5 - run*.5 + (.5-f)*.3);+ c = mix(c, uPaper*(1. + (fib-.5)*.05), clamp(w, 0., 1.));+ }+ c *= 1. + (h11(tf*13.7)-.5)*.03;+ vec2 q = uv-.5; c *= 1. - dot(q,q)*.1;+ vec4 sb = texture2D(tSub, uv); c = mix(c, sb.rgb, sb.a);+ gl_FragColor = vec4(c, 1.);+ }`,+ depthTest: false, depthWrite: false,+});+const postScene = new THREE.Scene(), postCam = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);+postScene.add(new THREE.Mesh(new THREE.PlaneGeometry(2, 2), printMat));++// ================================================================ cranes in the river+const RA = (() => {+ const R = mulberry(515), L = [];+ const put = (x, z, extra = {}) => L.push({ x, z, flip: R() < .5, s: 1.42 + R() * .16, sleep: R() < .5 ? POSE.SLEEP : POSE.SLEEP2, ...extra });+ // downstream of the bridge, in the narrow river+ for (let i = 0; i < 22; i++) {+ const u = .0, z = 26 + i * 6 + (R() - .5) * 5;+ const x = Math.sin(z * .021) * 3 + (R() - .5) * 9 - 2;+ put(x, z);+ }+ // the shallow pool east of the bend: the flock that wakes at dawn+ for (let i = 0; i < 34; i++) {+ const x = 60 + Math.pow(R(), 1.25) * 150, zc = -98 - (x - 50) * .1 - Math.max(0, x - 180) * .05;+ const hw = x < 80 ? 9 : 17;+ put(x, zc + (R() - .5) * hw * 1.5);+ }+ // a closer group in the middle distance+ for (let i = 0; i < 10; i++) put(62 + R() * 26, -101 - R() * 8 + (R() - .5) * 4);+ // a few asleep right in front of the camera, so the line about sleeping cranes has its birds+ for (const [x, z] of [[40.6, -89.4], [42.4, -91.6], [44.6, -88.6], [46.8, -92.4], [43.8, -94.6], [49.6, -90.2]]) put(x, z, { near: true, s: 1.55 });+ // the nearest pair, close to the camera, who will call+ put(53, -96.5, { pair: 1, flip: false, s: 1.55 }); put(56.6, -98.6, { pair: 2, flip: false, s: 1.5 });+ // two or three were awake all night+ L[20].awake = L[26].awake = L[9].awake = true;+ // wake order: north to south as seen from the camera facing east = left to right on screen+ const sorted = L.map((b, i) => [b.z, i]).sort((a, b) => a[0] - b[0]);+ sorted.forEach(([, i], k) => { L[i].wake = lerp(T.wake[0], T.wake[1] - .5, k / (sorted.length - 1)) + (R() - .5) * .35; });+ L.forEach(b => { if (b.pair) b.wake = T.wake[0] + .35 + b.pair * .15; b.rank = R(); });+ return L;+})();++function riverCranes(t) {+ const out = [];+ for (const b of RA) {+ const woke = b.awake || t > b.wake;+ let pose = b.sleep, crown = 0;+ if (woke) {+ const dt = b.awake ? 9 : t - b.wake;+ pose = dt < .22 ? POSE.HALF : (hash(b.rank * 99 + Math.floor((t + b.rank * 5) / 1.7)) < .3 ? POSE.ALERT2 : POSE.ALERT);+ crown = clamp(dt / .16);+ if (b.pair && t > T.pairCall && t < T.pairCall + 1.9) pose = b.pair === 1 ? POSE.CALLW : POSE.CALL;+ }+ if (t >= T.takeoff) continue; // handled by the takeoff+ out.push({ x: b.x, y: WY - .22, z: b.z, s: b.s, flip: b.flip, pose, crown });+ }+ return out;+}++// ================================================================ the aerial flock (after the steam)+const FB = (() => {+ const R = mulberry(611), L = [];+ for (let i = 0; i < 40; i++) {+ const k = i / 39;+ L.push({ back: k * 42 + (R() - .5) * 6, side: (k - .5) * 30 + (R() - .5) * 10 + Math.sin(i * 1.3) * 4, up: (R() - .5) * 8, ph: R(), s: 2.2 + R() * .15 });+ }+ return L;+})();+const B0 = new THREE.Vector3(90, 140, 560), FIELD = new THREE.Vector3(-99, 0, -186);+const BDIR = FIELD.clone().sub(B0).setY(0).normalize();+const leaderB = t => B0.clone().addScaledVector(BDIR, (t - T.cutB) * 17).add(new THREE.Vector3(0, -(t - T.cutB) * 2.5, 0));+const wingPose = (ph) => { const k = Math.floor(((ph % 1) + 1) % 1 * 4); return [POSE.FLY_UP, POSE.FLY_MID, POSE.FLY_DOWN, POSE.FLY_MID][k]; };++function flockB(t) {+ const L = leaderB(t), side = new THREE.Vector3(-BDIR.z, 0, BDIR.x);+ return FB.map((b, i) => {+ const p = L.clone().addScaledVector(BDIR, -b.back).addScaledVector(side, b.side).add(new THREE.Vector3(0, b.up + Math.sin(t * 1.3 + i) * .6, 0));+ return { x: p.x, y: p.y, z: p.z, s: b.s, pose: wingPose(t * 1.7 + b.ph), crown: 1, dir: BDIR };+ });+}+// rotate a flying sprite so it points along its heading on screen+function screenRot(list) {+ const a = new THREE.Vector3(), b = new THREE.Vector3();+ for (const c of list) {+ a.set(c.x, c.y, c.z).project(camera); b.set(c.x + c.dir.x, c.y + c.dir.y, c.z + c.dir.z).project(camera);+ const dx = (b.x - a.x) * W_, dy = (b.y - a.y) * H_;+ let r = Math.atan2(dy, dx);+ c.flip = false;+ c.rot = r;+ }+ return list;+}+++// ================================================================ the feeding field+const FR = { x0: -144.5, x1: -53.5, z0: -218.5, z1: -153.5 }; // inside the fence, a metre clear of it+const DANCERS = [[-110.0, -156.6], [-108.2, -157.3]];+const FC = (() => {+ const R = mulberry(733), L = [];+ let tries = 0;+ while (L.length < 320 && tries++ < 20000) {+ const a = R() * Math.PI * 2, rr = Math.pow(R(), .75);+ const x = -99 + Math.cos(a) * rr * 40 + (R() - .5) * 4, z = -184 + Math.sin(a) * rr * 25;+ if (x < FR.x0 || x > FR.x1 || z < FR.z0 || z > FR.z1) continue;+ if (L.some(b => (b.x - x) ** 2 + (b.z - z) ** 2 < 1.5 * 1.5)) continue; // no two birds in one place+ if (DANCERS.some(([dx, dz]) => (dx - x) ** 2 + (dz - z) ** 2 < 3.5 * 3.5)) continue;+ L.push({ x, z, flip: R() < .5, s: 1.4 + R() * .18, r: R() });+ }+ L.sort((p, q) => Math.hypot(p.x + 99, (p.z + 186) * 1.5) - Math.hypot(q.x + 99, (q.z + 186) * 1.5));+ return L;+})();+const ERA_N = [33, 90, 170, 320];+function fieldPose(i, t, r) {+ const k = Math.floor((t + r * 7) / (1.1 + r)), h = hash(i * 7.1 + k * 3.3);+ return h < .45 ? POSE.PECK : h < .7 ? POSE.WALK : h < .88 ? POSE.ALERT : POSE.ALERT2;+}+function fieldCranes(t, n, clearOf) {+ const out = [];+ for (let i = 0; i < Math.min(n, FC.length); i++) { const b = FC[i]; if (clearOf && Math.hypot(b.x - clearOf[0], b.z - clearOf[2]) < 9) continue; out.push({ x: b.x, y: 0, z: b.z, s: b.s, flip: b.flip, pose: fieldPose(i, t, b.r), crown: 1 }); }+ return out;+}+function setEra(era, t = 0) {+ W.fence.position.y = [-1.05, -.6, -.25, 0][era];+ W.corn.material.uniforms.uSpread.value = era === 0 ? lerp(.06, .32, ss(seg(t, T.corn[0], T.corn[1]))) : [.3, .5, .78, 1][era];+ W.tracks.material.uniforms.uTrack.value = [.1, .4, .75, 1][era];+ W.hut2.visible = era >= 2;+ W.hut1.position.y = [-.5, -.25, 0, 0][era];+ W.sign.visible = era === 3;+}++// ================================================================ landing (24 – 28.4): the bird we follow, and others coming in+const LAND = (() => {+ const R = mulberry(244), L = [];+ // the bird we follow: a long glide, then the flare+ L.push({ t0: 23.2, dur: 3.6, from: [-78, 26, -116], to: [-103, 0, -158.5], s: 1.55, lead: true });+ for (let i = 0; i < 26; i++) {+ const b = FC[120 + i * 3];+ const ang = -.6 + R() * 1.2, dist = 40 + R() * 40;+ L.push({ t0: 23.6 + R() * 3.8, dur: 2.4 + R() * 1.2, from: [b.x + Math.sin(ang) * dist, 16 + R() * 14, b.z + Math.cos(ang) * dist * .6 + 20], to: [b.x, 0, b.z], s: b.s, flip: R() < .5 });+ }+ return L;+})();+const leadAt = t => { const b = LAND[0], u = clamp((t - b.t0) / b.dur), e = 1 - Math.pow(1 - u, 2.2); return b.from.map((v, i) => lerp(v, b.to[i], i === 1 ? 1 - Math.pow(1 - u, 1.4) : e)); };+function landing(t) {+ const out = fieldCranes(t, 120 + Math.floor(clamp((t - 24) / 4) * 60));+ for (const b of LAND) {+ const u = (t - b.t0) / b.dur;+ if (u < 0) continue;+ if (u >= 1) { out.push({ x: b.to[0], y: 0, z: b.to[2], s: b.s, flip: b.flip, pose: u < 1.25 ? POSE.ALERT : POSE.WALK, crown: 1 }); continue; }+ const p = b.lead ? leadAt(t) : b.from.map((v, i) => lerp(v, b.to[i], i === 1 ? 1 - Math.pow(1 - u, 1.5) : 1 - Math.pow(1 - u, 2.2)));+ out.push({ x: p[0], y: p[1], z: p[2], s: b.s, flip: b.lead ? true : b.flip, pose: u > .85 ? POSE.ALERT : POSE.LAND, crown: 1 });+ }+ return out;+}+// the dancing pair: a leap with the wings thrown open, answered by a bow+function dancers(t) {+ const out = [];+ DANCERS.forEach(([x, z], i) => {+ const ph = ((t - T.dance[0]) / .95 + i * .5) % 1, up = ph < .5;+ const leap = up && i === 0 ? Math.sin(ph * 2 * Math.PI) * .7 : up && i === 1 ? Math.sin(ph * 2 * Math.PI) * .45 : 0;+ const pose = t < T.dance[0] + .2 ? POSE.ALERT : (up ? POSE.DANCE : (i === 0 ? POSE.BOW : POSE.ALERT));+ out.push({ x, y: Math.max(0, leap), z, s: 1.55, flip: i === 1, pose, crown: 1 });+ });+ return out;+}++// ================================================================ takeoff (17 – 19.75): run across the water, lift, pass over the camera+const HEADING = new THREE.Vector3(-1, 0, .06).normalize();+const takeOrder = (() => RA.map((b, i) => [b.pair ? -1 : b.near ? 999 : Math.hypot(b.x - 36, b.z + 88) + (b.x > 120 ? 30 : 0), i]).sort((a, b) => a[0] - b[0]))();+function takeoffPath(b, k, t) {+ const t0 = T.takeoff + k * .05, dt = t - t0;+ if (dt < 0) return null;+ const run = Math.min(dt, .75), d = 4.2 * run * run + Math.max(0, dt - .75) * 11;+ const climb = Math.max(0, dt - .6);+ // birds that start close to the camera turn north, away from the lens, and climb sooner+ const near = clamp((22 - Math.hypot(b.x - 36.8, b.z + 88.2)) / 12);+ const hx = lerp(HEADING.x, -.35, near), hz = lerp(HEADING.z, -.94, near);+ return { dt, x: b.x + hx * d, z: b.z + hz * d + Math.sin(dt * .9 + b.rank * 6) * climb * 1.5, y: WY - .12 + climb * climb * (1.9 + near * 2) + climb * 2.6, hx, hz };+}+function takeoff(t) {+ const stand = [], fly = [];+ takeOrder.forEach(([, i], k) => {+ const b = RA[i], p = takeoffPath(b, k, t);+ if (b.z > 0) return; // the downstream birds lift off out of shot+ if (!p) { stand.push({ x: b.x, y: WY - .12, z: b.z, s: b.s, flip: true, pose: POSE.ALERT, crown: 1 }); return; }+ if (p.dt < .62) stand.push({ x: p.x, y: WY - .12 + Math.abs(Math.sin(p.dt * 22)) * .08, z: p.z, s: b.s, flip: true, pose: POSE.RUN, crown: 1 });+ else fly.push({ x: p.x, y: p.y + .9, z: p.z, s: 2.25, pose: wingPose((p.dt - .62) * 2.3 + b.rank), crown: 1, dir: new THREE.Vector3(p.hx, .2, p.hz) });+ });+ return { stand, fly };+}+// splashes: paper stabs thrown up by the running feet+const splashGeo = new THREE.BufferGeometry();+const SPL = 1600;+splashGeo.setAttribute('position', new THREE.BufferAttribute(new Float32Array(SPL * 3), 3));+splashGeo.setAttribute('aS', new THREE.BufferAttribute(new Float32Array(SPL), 1));+const splashes = new THREE.Points(splashGeo, new THREE.ShaderMaterial({+ uniforms: { uProj: { value: projScale() }, uPaper: U.uPaper },+ vertexShader: `attribute float aS; uniform float uProj; void main(){ vec4 mv = viewMatrix*vec4(position,1.); gl_PointSize = aS > 0. ? max(aS*uProj/-mv.z, 2.) : 0.; gl_Position = projectionMatrix*mv; }`,+ fragmentShader: `uniform vec3 uPaper; void main(){ vec2 q = abs(gl_PointCoord-.5); if (max(q.x, q.y*1.6) > .5) discard; gl_FragColor = vec4(uPaper,1.); }`,+}));+splashes.frustumCulled = false; scene.add(splashes);+function placeSplashes(t) {+ const P = splashGeo.attributes.position.array, S = splashGeo.attributes.aS.array; S.fill(0);+ let n = 0;+ if (t >= T.takeoff - .1 && t < T.cutB) takeOrder.forEach(([, i], k) => {+ const b = RA[i]; if (b.z > 0) return;+ for (let j = 0; j < 9 && n < SPL - 4; j++) {+ const ts = T.takeoff + k * .05 + j * .07, age = t - ts; if (age < 0 || age > .55) continue;+ const p = takeoffPath(b, k, ts); if (!p || p.dt > .62) continue;+ for (let m = 0; m < 4; m++) {+ const r1 = hash(i * 31 + j * 7 + m), r2 = hash(i * 17 + j * 3 + m * 5), r3 = hash(i + j * 13 + m * 11);+ P.set([p.x + (r1 - .5) * .6 + HEADING.x * -age * 1.5, WY + (1.5 + r2 * 2.2) * age - 4.9 * age * age, p.z + (r3 - .5) * .8], n * 3);+ S[n] = WY + (1.5 + r2 * 2.2) * age - 4.9 * age * age > WY ? .05 + r3 * .07 : 0; n++;+ }+ }+ });+ splashGeo.attributes.position.needsUpdate = splashGeo.attributes.aS.needsUpdate = true;+}++// ================================================================ the camera+const camA = track(CAM_A_KEYS);+// during the takeoff the camera keeps its eye on the leading birds as they come at it and pass overhead+function flockEye(t) {+ const pts = takeOrder.slice(0, 8).map(([, i], k) => takeoffPath(RA[i], k, t)).filter(Boolean);+ if (!pts.length) return null;+ const m = pts.reduce((a, p) => [a[0] + p.x, a[1] + p.y, a[2] + p.z], [0, 0, 0]).map(v => v / pts.length);+ return m;+}+function camAt(t) {+ const c = camA(t);+ if (t < T.takeoff) return c;+ const e = flockEye(t); if (!e) return c;+ const k = ss(seg(t, T.takeoff + .15, T.takeoff + .9));+ // aim a little ahead of the leaders, and never straight up+ const tx = lerp(c[3], e[0] - 6, k), ty = lerp(c[4], Math.min(e[1] + 2, c[1] + 14), k), tz = lerp(c[5], e[2] - 4, k);+ return [c[0], c[1], c[2], tx, ty, tz];+}+const fovA = t => t < 8.5 ? lerp(34, 22, ss(seg(t, 6.0, 7.6))) : t < 13 ? lerp(22, 28, ss(seg(t, 9.9, 11.8))) : lerp(28, 40, ss(seg(t, 16.4, 18.0)));+function camB(t) {+ const L = leaderB(t), side = new THREE.Vector3(-BDIR.z, 0, BDIR.x);+ const p = L.clone().addScaledVector(BDIR, -70).addScaledVector(side, 10).add(new THREE.Vector3(0, 14, 0));+ const l = L.clone().addScaledVector(BDIR, 220).addScaledVector(side, -30).add(new THREE.Vector3(0, -66 - ss(seg(t, T.tilt[0], T.tilt[1])) * 95, 0));+ return [p.x, p.y, p.z, l.x, l.y, l.z];+}+// following the bird down, then along the fence to the face of the board+const camCtail = track([+ [26.8, [-99.3, 3.8, -147.5, -106.5, .6, -170]],+ [27.6, [-104.6, 2.1, -145.2, -109.5, 1.1, -166]],+ [28.6, [-110.65, 1.62, -145.75, -112.75, 1.36, -153]],+]);+function camC(t) {+ if (t < T.landed) {+ const p = leadAt(t), u = seg(t, 24, T.landed);+ const off = [lerp(4.5, 3.2, u), lerp(1.4, 2.4, u), lerp(8, 9.5, u)];+ return [p[0] + off[0], p[1] + off[1], p[2] + off[2], p[0] - 1.8 - u * 2, p[1] - .4 - u * 1.4, p[2] - 6 - u * 10];+ }+ // hand over from following the bird to the tail move without a jolt+ const tail = camCtail(t);+ if (t < 27.2) { const f = camC(T.landed - 1e-3), k = ss(seg(t, T.landed, 27.2)); return f.map((v, i) => lerp(v, tail[i], k)); }+ return tail;+}+const camSign = t => [-110.65 - (t - 28.6) * .03, 1.62, -145.75 + (t - 28.6) * .02, -112.75, 1.36, -153];+const camPrint = [-99, 7.2, -159, -99, 1.0, -186];+const camVerdict = t => [-111.8 + (t - T.verdict[0]) * .01, 1.62, -145.5, -112.45, 1.32, -151];+const camEnd = track([+ [T.dance[0], camVerdict(T.dance[0])],+ [51.68, [-111.2, 1.7, -145.6, -107.2, 1.3, -157]],+ [52.4, [-109.6, 2.3, -146.6, -109.1, 1.2, -157]],+ [53.6, [-108.6, 3.6, -143.5, -105, 1.6, -168]],+ [56.4, [-92, 24, -86, -76, 60, -600]],+ [59.6, [-92.3, 24, -86.6, -76.3, 60, -601]],+]);+function shotAt(t) {+ if (t < T.cutB) return { k: 'A', c: camAt(t), fov: fovA(t) };+ if (t < T.cutC) return { k: 'B', c: camB(t), fov: 38 };+ if (t < T.sign1[0]) return { k: 'C', c: camC(t), fov: 36 };+ if (t < T.prints[0]) return { k: 'S', c: camSign(t), fov: 34 };+ if (t < T.prints[1]) return { k: 'P', c: camPrint, fov: 36 };+ if (t < T.dance[0]) return { k: 'V', c: camVerdict(t), fov: 34 };+ return { k: 'E', c: camEnd(t), fov: lerp(34, 38, ss(seg(t, 53.6, 56.4))) };+}++// ================================================================ light, sky, sun, moon, type in the sky+const sunDir = el => new THREE.Vector3(Math.cos(el) * .99, Math.sin(el), -Math.cos(el) * .21).normalize();+const DEG = Math.PI / 180;+const TITLE = skyTypeCanvas([+ { id: 'title-cn', text: '三十三只', px: 300, y: 300 },+ { id: 'title-en', text: 'Thirty-Three Cranes', px: 118, y: 480, x: 48 },+], 2400, 560);+const ENDC = skyTypeCanvas([+ { id: 'end-cn', text: '三十三只', px: 150, y: 170 },+ { id: 'end-en', text: 'Thirty-Three Cranes', px: 92, y: 300, x: 44 },+ { id: 'end-sign', text: 'LemoLab × Claude Opus 5.5', px: 112, y: 470, x: 44 },+], 2000, 540);+skyMat.uniforms.tType1.value = canvasTex(TITLE.c); skyMat.uniforms.uRect1.value.set(2 * DEG, 7.6 * DEG, 26 * DEG, (7.6 + 24 * 560 / 2400) * DEG);+skyMat.uniforms.tType2.value = canvasTex(ENDC.c); skyMat.uniforms.uRect2.value.set(2 * DEG, 11.4 * DEG, 29 * DEG, (11.4 + 27 * 540 / 2000) * DEG);+function setSky(t, shot) {+ const night = shot === 'A' ? 1 - ss(seg(t, T.dawn[0], T.dawn[0] + 3.5)) : 0;+ skyMat.uniforms.uFront.value = shot === 'A' ? lerp(-.02, .6, seg(t, T.dawn[0] + .2, T.takeoff + 2.6)) : 1.7;+ skyMat.uniforms.uStars.value = night;+ skyMat.uniforms.uDense.value = shot === 'A' ? ss(seg(t, 12.6, 17.0)) * .8 : 1;+ const [a0, a1, b0, b1] = T.title;+ skyMat.uniforms.uAmt1.value = t < b0 ? ss(seg(t, a0, a1)) : 1 - ss(seg(t, b0, b1));+ skyMat.uniforms.uAmt2.value = shot === 'E' ? ss(seg(t, T.end[0], T.end[0] + .7)) : 0;+ const elDeg = shot === 'A' ? lerp(-2.2, 2.0, ss(seg(t, 11.4, 16.0))) : 9;+ const sd = sunDir(elDeg * DEG);+ U.uSun.value.copy(sd);+ U.uWarm.value = shot === 'A' ? ss(seg(t, 11.4, 14.4)) : .15;+ const moonL = new THREE.Vector3(-0.92, 0.36, 0.3).normalize(), sunL = new THREE.Vector3(0.9, 0.32, -0.2).normalize();+ U.uL.value.copy(moonL).lerp(sunL, 1 - night).normalize();+ const md = new THREE.Vector3(-.36, .19, -.91).normalize();+ W.moon.position.copy(camera.position).addScaledVector(md, 7000); W.moon.lookAt(camera.position);+ W.moon.visible = night > .02; W.moon.material.opacity = night;+ W.sun.position.copy(camera.position).addScaledVector(sd, 7000); W.sun.lookAt(camera.position);+ W.sun.scale.setScalar(2.2);+ W.sun.visible = shot === 'A' && t > 10.6;+ W.sky.position.copy(camera.position);+ U.uCam.value.copy(camera.position);+}++// ================================================================ the steam+function placeMist(t) {+ const a = W.mist.geometry.attributes, L = W.mistList;+ for (let i = 0; i < L.length; i++) {+ const m = L[i], drift = t * .5 + m.ph * 3;+ const y = m.y + ((t * .12 + m.ph) % 1) * .8;+ a.aOff.array.set([m.x + Math.sin(drift * .3) * 1.5, y, m.z + Math.cos(drift * .2) * 1.2], i * 3);+ const breathe = .85 + .15 * Math.sin(t * .4 + m.ph * 6);+ a.aSize.array.set([m.w * breathe * (m.flip ? -1 : 1), m.h], i * 2);+ a.aTile.array.set([0, (3 - m.v) / 4, 1, .25], i * 4);+ }+ W.mist.geometry.instanceCount = L.length;+ a.aOff.needsUpdate = a.aSize.needsUpdate = a.aTile.needsUpdate = true;+}++// ================================================================ the board, re-cut as the film goes+let boardKey = '';+function boardState(t, shot) {+ if (shot === 'V' || shot === 'E') return {+ date: clamp((t - T.carveDate[0]) / (T.carveDate[1] - T.carveDate[0])),+ num: clamp((t - T.carveNum[0]) / (T.carveNum[1] - T.carveNum[0])),+ strike: clamp((t - T.strike) / .3), stamp: t >= T.stamp ? ss(clamp((t - T.stamp) / .1)) : 0,+ };+ return { date: 0, num: 0, strike: 0, stamp: 0 };+}+function updateBoard(st) {+ const key = [st.date, st.num, st.strike, st.stamp].map(v => v.toFixed(3)).join();+ if (key === boardKey) return;+ boardKey = key; boardCanvas(W.boardCanvas, st); W.boardTex.needsUpdate = true;+}++// ================================================================ subtitles: one bar per narration line, Chinese above English+const DURS = await (await fetch('./voice/zh/dur.json')).json();+const SUBS = VO.map(([id, at, cn, en], i) => {+ const next = VO[i + 1] ? VO[i + 1][1] : T.DUR;+ return { id, cn, en, a: at - .05, b: Math.min(at + DURS[id] + .45, next - .1) };+});+const subCanvas = document.createElement('canvas'); subCanvas.width = W_; subCanvas.height = H_;+const subTex = canvasTex(subCanvas, false);+const SUB = { cn: 42, en: 30, cnY: 960, enY: 1006 }; // bottom of the bar sits 54 px above the frame edge+let subKey = '', subBoxes = [];+function drawSub(sub, alpha) {+ const key = sub ? sub.id + alpha.toFixed(2) : '';+ if (key === subKey) return; subKey = key;+ const g = subCanvas.getContext('2d'); g.clearRect(0, 0, W_, H_); subBoxes = [];+ if (!sub || alpha <= 0) { subTex.needsUpdate = true; return; }+ g.globalAlpha = alpha;+ g.font = `700 ${SUB.cn}px 'NotoSerifSC', serif`; const wc = g.measureText(sub.cn).width;+ g.font = `500 ${SUB.en}px 'NotoSerifSC', serif`; const we = g.measureText(sub.en).width;+ const w = Math.max(wc, we) + 56, x0 = (W_ - w) / 2, y0 = SUB.cnY - SUB.cn - 16, y1 = SUB.enY + 20;+ g.fillStyle = 'rgba(22,23,27,0.62)'; g.beginPath(); g.roundRect(x0, y0, w, y1 - y0, 6); g.fill();+ g.textAlign = 'center'; g.textBaseline = 'alphabetic'; g.fillStyle = '#ede5cd';+ g.font = `700 ${SUB.cn}px 'NotoSerifSC', serif`; g.fillText(sub.cn, W_ / 2, SUB.cnY);+ g.fillStyle = 'rgba(237,229,205,0.92)'; g.font = `500 ${SUB.en}px 'NotoSerifSC', serif`; g.fillText(sub.en, W_ / 2, SUB.enY);+ subBoxes = [{ id: 'sub-cn-' + sub.id, text: sub.cn, x0: (W_ - wc) / 2, y0: SUB.cnY - SUB.cn, x1: (W_ + wc) / 2, y1: SUB.cnY + 8 },+ { id: 'sub-en-' + sub.id, text: sub.en, x0: (W_ - we) / 2, y0: SUB.enY - SUB.en, x1: (W_ + we) / 2, y1: SUB.enY + 8 }];+ subTex.needsUpdate = true;+}+function placeSub(t) {+ const sub = SUBS.find(x => t >= x.a && t < x.b);+ drawSub(sub, sub ? Math.min(1, (t - sub.a) / .12, (sub.b - t) / .12) : 0);+}++// ================================================================ render+function applyCam(c, fov) {+ camera.position.set(c[0], c[1], c[2]); camera.lookAt(c[3], c[4], c[5]);+ if (camera.fov !== fov) { camera.fov = fov; camera.updateProjectionMatrix(); }+ W.crownMat.uniforms.uProj.value = projScale(); splashes.material.uniforms.uProj.value = projScale();+}+function stateFor(t, shot, era) {+ W.river1.constructor.cam = camera.position;+ let river = [], fly = [], field = [];+ if (shot.k === 'A') {+ if (t < T.takeoff) river = riverCranes(t);+ else { const r = takeoff(t); river = r.stand; fly = screenRot(r.fly); }+ } else if (shot.k === 'B') fly = screenRot(flockB(t));+ else if (shot.k === 'C') field = landing(t);+ else if (shot.k === 'P') field = fieldCranes(t, ERA_N[era], camPrint);+ else field = fieldCranes(t, 320).concat(shot.k === 'E' ? dancers(t) : dancers(T.dance[0]));+ W.river1.set(river); W.flyers.set(fly); W.field.set(field);+}+function draw(target) { renderer.setRenderTarget(target); renderer.render(scene, camera); }++let SHOT = null;+window.render = (t) => {+ const shot = SHOT = shotAt(t);+ if (Q.get('cam')) shot.c = Q.get('cam').split(',').map(Number);+ // the stamp lands: one frame of shake+ if (shot.k === 'V' && t >= T.stamp + .1 && t < T.stamp + .14) shot.c = shot.c.map((v, i) => i < 3 ? v + [.012, -.018, 0][i] : v);+ applyCam(shot.c, shot.fov);+ setSky(t, shot.k);+ placeMist(t); placeSplashes(t);+ W.river.children[0].material.uniforms.uT.value = t; W.river1.refl.material.uniforms.uT.value = t;+ updateBoard(boardState(t, shot.k));+ placeSub(t);+ // the red: never smaller than a few pixels; by day a little larger+ W.crownMat.uniforms.uMin.value = (shot.k === 'A' && t < 13 ? 3.5 : 5) * SS;+ W.crownMat.uniforms.uOn.value = 1; W.crownMat.uniforms.uShift.value.set(0, 0);+ let era = 3;+ printMat.uniforms.uPeel.value = -1; printMat.uniforms.uFresh.value = 0;+ if (shot.k === 'P') {+ const P = T.peels;+ era = t < P[0] ? 0 : t < P[1] ? 1 : t < P[2] ? 2 : 3;+ const pi = P.findIndex(x => t >= x && t < x + .3);+ // the red is a second plate: each new print arrives without it, and it is pressed on a beat later, a hair off register+ const lastPeel = P.filter(x => t >= x).pop();+ if (lastPeel !== undefined) {+ W.crownMat.uniforms.uOn.value = t >= lastPeel + .45 ? 1 : 0;+ W.crownMat.uniforms.uShift.value.set(1.6 * SS, -1.1 * SS);+ }+ if (pi >= 0) {+ const on = W.crownMat.uniforms.uOn.value; W.crownMat.uniforms.uOn.value = 0;+ setEra(pi + 1, t); stateFor(t, shot, pi + 1); draw(rtB);+ W.crownMat.uniforms.uOn.value = 1; W.crownMat.uniforms.uShift.value.set(pi ? 1.6 * SS : 0, pi ? -1.1 * SS : 0);+ printMat.uniforms.uPeel.value = eio((t - P[pi]) / .3); printMat.uniforms.uFresh.value = 1;+ era = pi;+ } else {+ const last = P.filter(x => t >= x + .3).pop();+ if (last !== undefined) printMat.uniforms.uFresh.value = 1 - ss(seg(t, last + .3, last + 1.0));+ }+ }+ setEra(era, t); stateFor(t, shot, era);+ draw(rtA);+ printMat.uniforms.uT.value = t; printMat.uniforms.tSub.value = subTex;+ printMat.uniforms.uWhite.value = shot.k === 'A' || shot.k === 'B' ? (t < T.cutB ? ss(seg(t, T.whiteIn, T.cutB)) : 1 - ss(seg(t, T.cutB, T.whiteOut))) : 0;+ renderer.setRenderTarget(null); renderer.render(postScene, postCam);+};++// ================================================================ reading check: every line meant to be read, with its screen box+const toScreen = v => { const p = v.clone().project(camera); return [(p.x + 1) / 2 * innerWidth, (1 - p.y) / 2 * innerHeight, p.z]; };+function boxOf(pts) {+ const s = pts.map(toScreen); if (s.some(p => p[2] > 1 || p[2] < -1)) return null;+ return { x0: Math.min(...s.map(p => p[0])), y0: Math.min(...s.map(p => p[1])), x1: Math.max(...s.map(p => p[0])), y1: Math.max(...s.map(p => p[1])) };+}+function skyBoxes(rect, boxes, amt, leaving) {+ if (amt <= 0 || leaving) return [];+ const dir = (az, el) => new THREE.Vector3(Math.sin(az) * Math.cos(el), Math.sin(el), -Math.cos(az) * Math.cos(el)).multiplyScalar(1000).add(camera.position);+ return boxes.map(b => {+ const az0 = lerp(rect.x, rect.z, b.u0), az1 = lerp(rect.x, rect.z, b.u1), el1 = lerp(rect.y, rect.w, 1 - b.v0), el0 = lerp(rect.y, rect.w, 1 - b.v1);+ const bb = boxOf([dir(az0, el0), dir(az1, el0), dir(az0, el1), dir(az1, el1)]);+ return bb && { id: b.id, text: b.text, ...bb };+ }).filter(Boolean);+}+function meshBoxes(mesh, w, h, pieces) { // pieces in fractions of the mesh's face+ mesh.updateMatrixWorld();+ return pieces.map(p => {+ const c = [[p.u0, p.v0], [p.u1, p.v0], [p.u0, p.v1], [p.u1, p.v1]].map(([u, v]) => mesh.localToWorld(new THREE.Vector3((u - .5) * w, (.5 - v) * h, 0)));+ const bb = boxOf(c); return bb && { id: p.id, text: p.text, ...bb };+ }).filter(Boolean);+}+window.TEXTS = (t) => {+ const out = [], k = SHOT?.k;+ if (Q.get('subs')) out.push(...subBoxes); // the subtitle bar follows the speech (readcheck's contract leaves it out); ?subs=1 reports it+ out.push(...skyBoxes(skyMat.uniforms.uRect1.value, TITLE.boxes, skyMat.uniforms.uAmt1.value, t > T.title[2]));+ out.push(...skyBoxes(skyMat.uniforms.uRect2.value, ENDC.boxes, skyMat.uniforms.uAmt2.value, false));+ if (k === 'A' && t > 6.5 && t < 10.6) out.push(...meshBoxes(W.plate, W.plateRect.w, W.plateRect.h, PLATE_LINES));+ if (k === 'S' || k === 'V' || (k === 'C' && t > 28.1) || (k === "E" && t < T.dance[0] + .05)) {+ const st = boardState(t, k);+ out.push(...meshBoxes(W.boardFace, W.board.w, W.board.h, boardPieces(st).map(p => ({ ...p, u0: p.x0 / BOARD.W, u1: p.x1 / BOARD.W, v0: p.y0 / BOARD.H, v1: p.y1 / BOARD.H }))));+ }+ return out;+};++// ================================================================ events for the sound+window.EV = (() => {+ const E = [], add = (t, type, o = {}) => E.push({ t: +t.toFixed(3), type, ...o });+ add(0, 'start');+ add(T.title[0], 'carveTitle'); add(T.title[2], 'uncarveTitle');+ for (const t of [1.7, 3.4, 4.9, 6.2]) add(t, 'frostcrack');+ add(2.6, 'sleepcall');+ add(T.bridgeHold[0], 'bridgeHold'); add(T.underBridge + .05, 'underBridge'); add(T.underBridge + .6, 'outBridge');+ RA.forEach(b => { if (!b.awake && b.wake < T.takeoff && b.z < 0) add(b.wake, 'wake', { pan: clamp((b.z + 108) / 18, -1, 1) }); });+ add(T.pairCall, 'unison'); add(T.pairCall + 1.1, 'calls');+ add(T.takeoff, 'takeoff');+ add(T.whiteIn, 'steam'); add(T.cutB, 'air');+ add(T.cutC, 'descend'); add(T.landed, 'touchdown');+ LAND.slice(1).forEach(b => add(b.t0 + b.dur, 'land', { pan: clamp((b.to[0] + 99) / 40, -1, 1) }));+ add(T.sign1[0], 'board');+ add(T.prints[0], 'print0'); add(T.corn[0], 'corn');+ T.peels.forEach((t, i) => { add(t, 'peel', { i }); add(t + .45, 'redplate', { i }); });+ for (let i = 0; i < 6; i++) add(T.carveDate[0] + i * (T.carveDate[1] - T.carveDate[0]) / 6, 'knife', { i });+ for (let i = 0; i < 8; i++) add(T.carveNum[0] + i * (T.carveNum[1] - T.carveNum[0]) / 8, 'knife', { i: i + 6 });+ add(T.strike, 'strike'); add(T.stamp + .1, 'stamp');+ for (let i = 0; i < 5; i++) add(T.dance[0] + .2 + i * .95, 'danceflap');+ add(T.end[0], 'endcard');+ VO.forEach(([id, at]) => add(at, 'vo', { id }));+ return E.sort((a, b) => a.t - b.t);+})();++// ================================================================ the bridge, slowed: film time → the unslowed timeline+// Through WARP.a–WARP.b the picture runs at down to half speed (smooth in and out), so the pass under the bridge+// takes about 1.4 s; everything after it comes WARP.d later. Narration, subtitles and sound events move with it.+const WARP = { a: 9.95, b: 11.75, d: .4 };+const toOld = t => { if (t <= WARP.a) return t; if (t >= WARP.b) return t - WARP.d; const u = (t - WARP.a) / (WARP.b - WARP.a); return t - WARP.d * (u - Math.sin(2 * Math.PI * u) / (2 * Math.PI)); };+const toNew = x => { if (x <= WARP.a) return x; let lo = x, hi = x + WARP.d; for (let i = 0; i < 40; i++) { const m = (lo + hi) / 2; if (toOld(m) < x) lo = m; else hi = m; } return (lo + hi) / 2; };+window.DUR = +(T.DUR + WARP.d).toFixed(3);+{ const r = window.render, tx = window.TEXTS; window.render = t => r(toOld(t)); window.TEXTS = t => tx(toOld(t)); }+window.EV = window.EV.map(e => ({ ...e, t: +toNew(e.t).toFixed(3) }));+window.render(0);+window.READY = true;diff --git a/styles/printed-long-take/demo/stills/styleframe.jpg b/styles/printed-long-take/demo/stills/styleframe.jpgnew file mode 100644index 0000000..5fe7632Binary files /dev/null and b/styles/printed-long-take/demo/stills/styleframe.jpg differdiff --git a/styles/printed-long-take/demo/textures.js b/styles/printed-long-take/demo/textures.jsnew file mode 100644index 0000000..9902392--- /dev/null+++ b/styles/printed-long-take/demo/textures.js@@ -0,0 +1,442 @@+// Canvas-drawn sprites and plates. Everything is ink, paper and one red; seeded, so every worker draws the same pixels.+import { mulberry } from '/core/lib.js';++export const INK = '#16171b', PAPER = '#ede5cd', RED = '#c4332b', YELLOW = '#dfa443';++// A short knife cut: blunt entry, tapered exit, a little wobble.+export function cut(g, x0, y0, x1, y1, w, R, col, taper = .85) {+ const n = 8, dx = x1 - x0, dy = y1 - y0, len = Math.hypot(dx, dy) || 1;+ const nx = -dy / len, ny = dx / len, wob = (R() - .5) * len * .04;+ g.fillStyle = col; g.beginPath();+ for (let i = 0; i <= n; i++) {+ const s = i / n, ww = w * (1 - s * taper) * .5, b = Math.sin(s * Math.PI) * wob;+ g.lineTo(x0 + dx * s + nx * (ww + b), y0 + dy * s + ny * (ww + b));+ }+ for (let i = n; i >= 0; i--) {+ const s = i / n, ww = w * (1 - s * taper) * .5, b = Math.sin(s * Math.PI) * wob;+ g.lineTo(x0 + dx * s - nx * (ww - b), y0 + dy * s - ny * (ww - b));+ }+ g.fill();+}++// A tapered stroke along a polyline (w0 at the start, w1 at the end).+function ribbon(g, pts, w0, w1, col) {+ const L = [], Rr = [];+ for (let i = 0; i < pts.length; i++) {+ const a = pts[Math.max(0, i - 1)], b = pts[Math.min(pts.length - 1, i + 1)];+ let dx = b[0] - a[0], dy = b[1] - a[1]; const l = Math.hypot(dx, dy) || 1; dx /= l; dy /= l;+ const w = (w0 + (w1 - w0) * i / (pts.length - 1)) / 2;+ L.push([pts[i][0] - dy * w, pts[i][1] + dx * w]); Rr.push([pts[i][0] + dy * w, pts[i][1] - dx * w]);+ }+ g.fillStyle = col; g.beginPath();+ L.forEach((p, i) => i ? g.lineTo(...p) : g.moveTo(...p));+ for (let i = Rr.length - 1; i >= 0; i--) g.lineTo(...Rr[i]);+ g.closePath(); g.fill();+}+const bez = (p0, p1, p2, p3, n = 16) => {+ const o = [];+ for (let i = 0; i <= n; i++) {+ const t = i / n, u = 1 - t;+ o.push([u * u * u * p0[0] + 3 * u * u * t * p1[0] + 3 * u * t * t * p2[0] + t * t * t * p3[0],+ u * u * u * p0[1] + 3 * u * u * t * p1[1] + 3 * u * t * t * p2[1] + t * t * t * p3[1]]);+ }+ return o;+};+const quadPts = (a, c, b, n = 14) => { const o = []; for (let i = 0; i <= n; i++) { const t = i / n, u = 1 - t; o.push([u * u * a[0] + 2 * u * t * c[0] + t * t * b[0], u * u * a[1] + 2 * u * t * c[1] + t * t * b[1]]); } return o; };++// ------------------------------------------------------------------ pines (windbreak belts)+// 8 variants, each 256×512. Bottom-centre of a tile is the trunk foot.+export function pineAtlas() {+ const TW = 256, TH = 512, N = 8;+ const c = document.createElement('canvas'); c.width = TW * N; c.height = TH;+ const g = c.getContext('2d');+ for (let v = 0; v < N; v++) {+ const R = mulberry(101 + v * 17), ox = v * TW + TW / 2;+ const top = 24 + R() * 30, foot = TH - 6;+ g.fillStyle = INK; g.fillRect(ox - 3, top + 40, 6, foot - top - 40);+ const tiers = 6 + Math.floor(R() * 4), lean = (R() - .5) * 12;+ for (let i = 0; i < tiers; i++) {+ const s = i / (tiers - 1);+ const yb = foot - 30 - (foot - 30 - top - 40) * s;+ const cx = ox + lean * s;+ const hwL = (1 - s * .9) * (62 + R() * 26) + 6, hwR = (1 - s * .9) * (62 + R() * 26) + 6;+ const yt = yb - (70 + 40 * (1 - s)) * (.8 + R() * .3);+ g.fillStyle = INK; g.beginPath(); g.moveTo(cx, yt);+ g.quadraticCurveTo(cx + hwR * .35, yt + (yb - yt) * .55, cx + hwR, yb + 6 + R() * 10);+ const nR = 3 + Math.floor(R() * 3);+ for (let k = 1; k <= nR; k++) { const u = 1 - k / (nR + 1); g.lineTo(cx + hwR * u + 4, yb - 10 - R() * 8); g.lineTo(cx + hwR * (u - .5 / (nR + 1)), yb + R() * 12); }+ g.lineTo(cx, yb - 16);+ const nL = 3 + Math.floor(R() * 3);+ for (let k = nL; k >= 1; k--) { const u = 1 - k / (nL + 1); g.lineTo(cx - hwL * (u + .5 / (nL + 1)), yb + R() * 12); g.lineTo(cx - hwL * u - 4, yb - 10 - R() * 8); }+ g.lineTo(cx - hwL, yb + 6 + R() * 10);+ g.quadraticCurveTo(cx - hwL * .35, yt + (yb - yt) * .55, cx, yt);+ g.fill();+ for (const side of [-1, 1]) {+ if (R() < .25) continue;+ const hw = side < 0 ? hwL : hwR, u = .35 + R() * .45;+ const x = cx + side * hw * u, y = yt + (yb - yt) * (.35 + .55 * u);+ cut(g, x - side * hw * .3, y - 10, x + side * hw * .15, y + 2, 6 + R() * 4, R, PAPER);+ }+ }+ cut(g, ox + lean, top - 10, ox + lean, top + 50, 7, R, INK);+ }+ return c;+}++// ------------------------------------------------------------------ frosted alders and willows+// 8 variants, 512×512 each, in one row. A dark crown of twigs with the hoarfrost carved out in paper.+export function frostTreeAtlas() {+ const T = 512, N = 8, SC = 2; // drawn at 512 units, stored at 1024 px per tile, 4×2 tiles+ const c = document.createElement('canvas'); c.width = T * SC * 4; c.height = T * SC * 2;+ const cg = c.getContext('2d');+ for (let v = 0; v < N; v++) {+ // each tree is drawn large on its own sheet, then fitted into its tile with the foot on the bottom edge+ const tc = document.createElement('canvas'); tc.width = 1600 * SC; tc.height = 1200 * SC;+ const g = tc.getContext('2d'); g.scale(SC, SC);+ const R = mulberry(3100 + v * 53), ox = 800, foot = 1190;+ const willow = v >= 6, slim = v === 4 || v === 5;+ const segs = []; // [x0,y0,x1,y1,w] for frost+ const tips = [];+ const grow = (x, y, ang, len, w, d) => {+ const bend = (R() - .5) * .5;+ const x1 = x + Math.cos(ang) * len, y1 = y + Math.sin(ang) * len;+ const mx = (x + x1) / 2 + Math.cos(ang + Math.PI / 2) * len * bend * .2, my = (y + y1) / 2 + Math.sin(ang + Math.PI / 2) * len * bend * .2;+ ribbon(g, quadPts([x, y], [mx, my], [x1, y1], 8), w, w * .62, INK);+ segs.push([x, y, mx, my, x1, y1, w]);+ if (d <= 0 || len < 9) { tips.push([x1, y1, ang]); return; }+ const kids = d > 3 ? 2 : 2 + (R() < .5 ? 1 : 0);+ for (let k = 0; k < kids; k++) {+ const spread = slim ? .32 : willow ? .5 : .5;+ let a = ang + (k - (kids - 1) / 2) * spread + (R() - .5) * .35;+ if (willow && d < 3) a = a * .5 + (Math.PI / 2) * .5 * (d < 2 ? 1 : .4); // weeping tips droop+ grow(x1, y1, a, len * (.7 + R() * .14), w * .68, d - 1);+ }+ };+ const trunkH = slim ? 210 + R() * 40 : 120 + R() * 50;+ const lean = (R() - .5) * .18;+ // a second stem on some alders: they grow as clumps+ const stems = slim ? 1 : (R() < .55 ? 2 : 1);+ for (let s = 0; s < stems; s++) {+ const sx = ox + (s ? (R() - .5) * 40 : 0), a0 = -Math.PI / 2 + lean + (s ? (R() - .5) * .4 : 0);+ ribbon(g, [[sx, foot], [sx + Math.cos(a0) * trunkH * .5, foot + Math.sin(a0) * trunkH * .5], [sx + Math.cos(a0) * trunkH, foot + Math.sin(a0) * trunkH]], slim ? 12 : 20, slim ? 8 : 13, INK);+ const tx = sx + Math.cos(a0) * trunkH, ty = foot + Math.sin(a0) * trunkH;+ const nb = slim ? 3 : 4;+ for (let k = 0; k < nb; k++) {+ const a = a0 + (k - (nb - 1) / 2) * (slim ? .4 : .5) + (R() - .5) * .3;+ grow(tx, ty, a, (slim ? 70 : 92) * (.75 + R() * .4), slim ? 8 : 12, slim ? 4 : 5);+ }+ }+ // twig mass: many fine dark lines around the tips, merging into a crown+ g.strokeStyle = INK; g.lineCap = 'round';+ for (const [x, y, a] of tips) {+ for (let k = 0; k < 9; k++) {+ const aa = a + (R() - .5) * 1.6, l = 12 + R() * 26;+ g.lineWidth = 1.6 + R() * 1.6;+ g.beginPath(); g.moveTo(x, y); g.lineTo(x + Math.cos(aa) * l, y + Math.sin(aa) * l); g.stroke();+ }+ g.fillStyle = INK; g.beginPath(); g.arc(x, y, 3 + R() * 4, 0, Math.PI * 2); g.fill();+ }+ // hoarfrost: paper cuts along the upper side of every branch and stabs on the twig tips+ for (const [x0, y0, mx, my, x1, y1, w] of segs) {+ if (w < 2.2) continue;+ const pts = quadPts([x0, y0], [mx, my], [x1, y1], 6);+ let dx = x1 - x0, dy = y1 - y0; const l = Math.hypot(dx, dy) || 1; dx /= l; dy /= l;+ let nx = -dy, ny = dx; if (ny > 0) { nx = -nx; ny = -ny; } // the upper side+ const off = w * .18;+ for (let i = 0; i < pts.length - 1; i++) {+ if (R() < .25) continue;+ const [ax, ay] = pts[i], [bx, by] = pts[i + 1];+ cut(g, ax + nx * off, ay + ny * off, bx + nx * off, by + ny * off, Math.max(1.4, w * .32), R, PAPER, .6);+ }+ }+ for (const [x, y, a] of tips) {+ for (let k = 0; k < 4; k++) {+ if (R() < .3) continue;+ const aa = a + (R() - .5) * 1.6, r = 2 + R() * 10;+ const px = x + Math.cos(aa) * r, py = y + Math.sin(aa) * r;+ cut(g, px, py, px + Math.cos(aa) * (5 + R() * 8), py + Math.sin(aa) * (5 + R() * 8), 2 + R() * 1.5, R, PAPER);+ }+ }+ // snow lying at the foot+ let x0 = ox, x1 = ox, y0 = foot;+ for (const [x, y] of tips) { x0 = Math.min(x0, x - 34); x1 = Math.max(x1, x + 34); y0 = Math.min(y0, y - 34); }+ const half = Math.max(ox - x0, x1 - ox), k = Math.min(1, (T - 8) / (foot - y0), (T / 2 - 4) / half);+ const dx = (v % 4) * T * SC, dy = Math.floor(v / 4) * T * SC;+ cg.drawImage(tc, (ox - (T / 2) / k) * SC, (foot - (T - 4) / k) * SC, T / k * SC, T / k * SC, dx, dy, T * SC, T * SC);+ cg.fillStyle = PAPER; cg.beginPath(); cg.ellipse(dx + T * SC / 2, dy + T * SC - 4, 52, 12, 0, Math.PI, 0); cg.fill();+ }+ return c;+}++// ------------------------------------------------------------------ red-crowned cranes+// 4×4 poses, 512×512 tiles, facing right. Standing tiles: the feet sit on the tile's bottom edge.+// Flight tiles: top view of the bird, body on the tile's centre line. HEAD lists the crown in tile units (0–100).+export const POSE = { SLEEP: 0, SLEEP2: 1, HALF: 2, ALERT: 3, CALL: 4, PECK: 5, WALK: 6, RUN: 7, FLY_UP: 8, FLY_MID: 9, FLY_DOWN: 10, LAND: 11, DANCE: 12, BOW: 13, ALERT2: 14, CALLW: 15 };+export const HEAD = [];+export function craneAtlas() {+ const T = 512, c = document.createElement('canvas'); c.width = T * 4; c.height = T * 4;+ const g = c.getContext('2d'); g.lineJoin = 'round'; g.lineCap = 'round';+ const U = T / 100;+ for (let p = 0; p < 16; p++) {+ const R = mulberry(7000 + p * 13);+ g.save(); g.translate((p % 4) * T, Math.floor(p / 4) * T); g.scale(U, U);+ g.beginPath(); g.rect(0, 0, 100, 100); g.clip();+ HEAD[p] = drawPose(g, p, R);+ g.restore();+ }+ return c;+}++const outline = (g, w = .9) => { g.strokeStyle = INK; g.lineWidth = w; g.stroke(); };+function body(g, R, cx, cy, sx = 1, rot = 0, fluff = 0) {+ g.save(); g.translate(cx, cy); g.rotate(rot); g.scale(sx * 1.08, 1);+ g.beginPath();+ g.moveTo(15, -2);+ g.bezierCurveTo(10, -9 - fluff, -10, -9.5 - fluff, -19, -3.5);+ g.bezierCurveTo(-23, -.5, -24, 3.5, -21, 5.5);+ g.bezierCurveTo(-12, 10 + fluff * .5, 6, 10 + fluff * .5, 13, 5);+ g.bezierCurveTo(16, 3, 17, 0, 15, -2);+ g.fillStyle = PAPER; g.fill(); outline(g, .9 / sx);+ for (let i = 0; i < 5; i++) {+ const y = 4 + i * 1.2, x0 = -14 + i * 2.2 + R() * 2, x1 = 7 - i * 1.6 + R() * 2;+ cut(g, x0, y + R() * .5, x1, y + 1 + R() * .5, .5, R, INK, .9);+ }+ // black tertials draping over the tail, hanging below it+ g.beginPath();+ g.moveTo(-1, -7.5);+ g.bezierCurveTo(-9, -9, -18, -5, -24, 4);+ const tips = [[-25, 10], [-22.5, 7.5], [-21, 12], [-18.5, 8], [-16.5, 11.5], [-14, 7], [-11.5, 9.5], [-8, 5]];+ for (const [x, y] of tips) g.lineTo(x + R() * .6, y + R() * .6);+ g.bezierCurveTo(-5, 1, -1, -3, -1, -7.5);+ g.fillStyle = INK; g.fill();+ for (let i = 0; i < 4; i++) cut(g, -5 - i * 4, -4.5 + i * 1.6, -11 - i * 3.6, 6 + i * .8, .5, R, PAPER, .9);+ g.restore();+}+function neck(g, R, pts, w0 = 6.2, w1 = 3.2, nape = [.45, .95]) {+ const P = bez(pts[0], pts[1], pts[2], pts[3], 20);+ ribbon(g, P, w0, w1, INK);+ const a = Math.floor(P.length * nape[0]), b = Math.floor(P.length * nape[1]);+ const seg = [];+ for (let i = a; i <= b && i < P.length; i++) {+ const q = P[Math.min(P.length - 1, i + 1)], r = P[Math.max(0, i - 1)];+ let dx = q[0] - r[0], dy = q[1] - r[1]; const l = Math.hypot(dx, dy) || 1; dx /= l; dy /= l;+ const w = (w0 + (w1 - w0) * i / (P.length - 1)) * .26;+ seg.push([P[i][0] + dy * w, P[i][1] - dx * w]);+ }+ if (seg.length > 1) ribbon(g, seg, .6, 1.5, PAPER);+ return P[P.length - 1];+}+function head(g, x, y, ang, billL = 9) {+ g.save(); g.translate(x, y); g.rotate(ang);+ g.beginPath(); g.ellipse(0, 0, 3.3, 2.5, 0, 0, Math.PI * 2); g.fillStyle = INK; g.fill();+ g.beginPath(); g.ellipse(-1.6, .9, 1.4, 1, .2, 0, Math.PI * 2); g.fillStyle = PAPER; g.fill();+ g.beginPath(); g.moveTo(2.3, -1.3); g.lineTo(2.5 + billL, .3); g.lineTo(2.3, 1.3); g.closePath();+ g.fillStyle = PAPER; g.fill(); outline(g, .5);+ g.restore();+ return [x + Math.sin(ang) * 1.5, y - Math.cos(ang) * 1.5];+}+function legs(g, list, w = 1.3) {+ for (const L of list) {+ ribbon(g, L, w, w * .85, INK);+ const f = L[L.length - 1];+ g.strokeStyle = INK; g.lineWidth = .8;+ g.beginPath(); g.moveTo(f[0] - 3.5, f[1] + .3); g.lineTo(f[0] + 4, f[1] + .3); g.stroke();+ }+}+// a crane's wing: long and broad, fingered primaries at the tip, black secondaries along the inner trailing edge.+// root → tip along `ang`; `side` picks which side the trailing edge lies on.+function wing(g, R, root, ang, len, c0, c1, side, bow = 0) {+ const ax = Math.cos(ang), ay = Math.sin(ang), nx = -ay * side, ny = ax * side;+ const N = 14, LE = [], TE = [];+ for (let i = 0; i <= N; i++) {+ const k = i / N, b = Math.sin(Math.PI * k) * len * .07 * bow;+ const x = root[0] + ax * len * k - nx * b, y = root[1] + ay * len * k - ny * b;+ LE.push([x, y]);+ const ch = lerp1(c0, c1, k) * (1 + .22 * Math.sin(Math.PI * k * .9));+ TE.push([x + nx * ch, y + ny * ch]);+ }+ // fingers first, under the wing: the separated primaries+ const tip = LE[N];+ for (let j = 0; j < 5; j++) {+ const f = (j + .5) / 5, bx = tip[0] + nx * c1 * f * .85 - ax * 2.5, by = tip[1] + ny * c1 * f * .85 - ay * 2.5;+ const a2 = ang + side * (f * .45 - .05), fl = len * (.13 - .04 * f) + 2.5;+ const P = [[bx, by], [bx + Math.cos(a2) * fl * .55, by + Math.sin(a2) * fl * .55], [bx + Math.cos(a2) * fl, by + Math.sin(a2) * fl]];+ ribbon(g, P, c1 / 5 * 1.5, .9, INK);+ ribbon(g, P.slice(0, 2).concat([[bx + Math.cos(a2) * fl * .9, by + Math.sin(a2) * fl * .9]]), c1 / 5 * 1.05, .3, PAPER);+ }+ g.beginPath(); LE.forEach((p, i) => i ? g.lineTo(...p) : g.moveTo(...p));+ for (let i = N; i >= 0; i--) g.lineTo(...TE[i]);+ g.closePath(); g.fillStyle = PAPER; g.fill(); outline(g, .8);+ // black secondaries along the inner trailing edge, ragged where the feathers end+ const M = Math.round(N * .58);+ g.beginPath();+ for (let i = 0; i <= M; i++) g.lineTo(...TE[i]);+ for (let i = M; i >= 0; i--) {+ const d = (.55 - .1 * (i / M)) * (i === M ? .4 : 1) + (i % 2 ? .05 : 0);+ g.lineTo(lerp1(TE[i][0], LE[i][0], d), lerp1(TE[i][1], LE[i][1], d));+ }+ g.closePath(); g.fillStyle = INK; g.fill();+ for (let i = 1; i < M; i++) { const d = .45 - .1 * (i / M); cut(g, lerp1(TE[i][0], LE[i][0], d * .8), lerp1(TE[i][1], LE[i][1], d * .8), TE[i][0], TE[i][1], .4, R, PAPER, .7); }+ // primaries: a few long ink cuts running out toward the tip+ for (let j = 0; j < 3; j++) {+ const d = .3 + j * .2, i0 = M + 1, i1 = N;+ cut(g, lerp1(LE[i0][0], TE[i0][0], d), lerp1(LE[i0][1], TE[i0][1], d), lerp1(LE[i1][0], TE[i1][0], d), lerp1(LE[i1][1], TE[i1][1], d), .45, R, INK, .9);+ }+}+const lerp1 = (a, b, t) => a + (b - a) * t;++function drawPose(g, p, R) {+ const P = POSE;+ const L2 = [[[45, 61], [46.5, 80], [45.5, 99]], [[50, 61], [52, 80], [51.5, 99]]];+ if (p === P.SLEEP || p === P.SLEEP2) {+ const tilt = p === P.SLEEP ? -.05 : .06;+ legs(g, [[[47, 62], [48, 80], [47.5, 99]]]);+ body(g, R, 46, 54, 1.0, tilt, 2.5);+ // the neck folded back over the shoulders, the head tucked into the back feathers+ g.beginPath(); g.moveTo(61, 53); g.bezierCurveTo(64, 46, 60, 41, 53, 41.5); g.bezierCurveTo(48, 42, 44, 44.5, 42, 47.5);+ g.bezierCurveTo(47, 46.5, 54, 47, 61, 53); g.fillStyle = INK; g.fill();+ cut(g, 58.5, 45, 48, 43.2, .9, R, PAPER, .9);+ return [53, 42];+ }+ if (p === P.HALF) {+ legs(g, L2);+ body(g, R, 44, 53, 1, -.04, 1);+ const hp = neck(g, R, [[56, 51], [63, 45], [67, 39], [70, 34]]);+ return head(g, hp[0] + 1, hp[1] - .5, .35);+ }+ if (p === P.ALERT || p === P.ALERT2) {+ const v = p === P.ALERT2;+ legs(g, L2);+ body(g, R, 44, 53, 1, -.08, 0);+ const hp = neck(g, R, v ? [[56, 50], [62, 38], [57, 28], [59, 17]] : [[56, 50], [63, 38], [60, 27], [62, 17]]);+ return head(g, hp[0] + 1, hp[1] - 1, v ? -.15 : .12);+ }+ if (p === P.CALL || p === P.CALLW) {+ legs(g, [[[44, 61], [45.5, 80], [44.5, 99]], [[49, 61], [51, 80], [50.5, 99]]]);+ if (p === P.CALLW) wing(g, R, [50, 47], -2.75, 24, 11, 8, -1, .5);+ body(g, R, 43, 54, 1, -.12, 0);+ const hp = neck(g, R, [[55, 50], [60, 36], [57, 24], [56, 15]]);+ return head(g, hp[0], hp[1] - 1, -1.25);+ }+ if (p === P.PECK) {+ legs(g, [[[43, 64], [42, 81], [41, 99]], [[48, 64], [50, 81], [51, 99]]]);+ body(g, R, 43, 56, 1, .2, 0);+ const hp = neck(g, R, [[55, 59], [66, 61], [71, 75], [72, 88]]);+ return head(g, hp[0] + 1, hp[1] + 1, 1.1, 8);+ }+ if (p === P.WALK) {+ legs(g, [[[47, 62], [54, 80], [58, 99]], [[43, 62], [40, 80], [36, 98]]]);+ body(g, R, 43, 53, 1, -.02, 0);+ const hp = neck(g, R, [[55, 51], [64, 43], [66, 31], [71, 25]]);+ return head(g, hp[0] + 1, hp[1], .25);+ }+ if (p === P.RUN) {+ wing(g, R, [48, 47], -2.05, 32, 13, 9, -1, .6);+ legs(g, [[[44, 62], [52, 78], [60, 88]], [[40, 62], [33, 76], [28, 90]]], 1.2);+ body(g, R, 45, 54, 1, .12, 0);+ const hp = neck(g, R, [[57, 54], [68, 49], [76, 45], [84, 42]], 5.6);+ const cr = head(g, hp[0] + 1, hp[1], .2);+ wing(g, R, [52, 48], -1.8, 38, 14, 10, -1, .6);+ return cr;+ }+ if (p === P.LAND) {+ wing(g, R, [48, 45], -2.35, 34, 13, 9, -1, 1);+ legs(g, [[[47, 60], [55, 74], [56, 92]], [[44, 60], [50, 76], [49, 94]]], 1.2);+ body(g, R, 45, 52, 1, -.25, 0);+ const hp = neck(g, R, [[56, 48], [64, 41], [70, 35], [77, 32]], 5.6);+ const cr = head(g, hp[0] + 1, hp[1], .3);+ wing(g, R, [52, 46], -2.0, 40, 14, 10, -1, 1);+ return cr;+ }+ if (p === P.DANCE) {+ wing(g, R, [47, 44], -2.45, 40, 14, 10, -1, .8);+ legs(g, [[[45, 58], [44, 74], [40, 90]], [[49, 58], [52, 74], [49, 91]]], 1.2);+ body(g, R, 45, 50, 1, -.18, 0);+ const hp = neck(g, R, [[56, 47], [62, 37], [62, 26], [66, 17]], 5.6);+ const cr = head(g, hp[0] + 1, hp[1] - 1, -.15);+ wing(g, R, [53, 44], -1.25, 40, 14, 10, -1, .8);+ return cr;+ }+ if (p === P.BOW) {+ legs(g, [[[44, 63], [45.5, 81], [44.5, 99]], [[49, 63], [51, 81], [50.5, 99]]]);+ body(g, R, 44, 56, 1, .3, 0);+ wing(g, R, [48, 50], 2.75, 28, 12, 9, -1, .5);+ const hp = neck(g, R, [[55, 60], [66, 62], [72, 70], [74, 80]]);+ return head(g, hp[0] + 1, hp[1] + 1, 1.0);+ }+ // flight, seen from above+ const len = p === P.FLY_MID ? 43 : p === P.FLY_UP ? 31 : 37;+ const sweep = p === P.FLY_MID ? .1 : p === P.FLY_UP ? .38 : -.06;+ const bow = p === P.FLY_DOWN ? 1.4 : p === P.FLY_UP ? -.6 : .5;+ legs(g, [[[40, 49.3], [30, 49], [21, 48.7]], [[40, 50.7], [30, 51], [21, 51.3]]], .9);+ for (const s of [-1, 1]) {+ const L = len * (s < 0 ? .93 : 1);+ wing(g, R, [57, 50 + s * 2.6], s < 0 ? -Math.PI / 2 - sweep : Math.PI / 2 + sweep, L, 17, 12, s, bow);+ }+ g.beginPath(); g.ellipse(51, 50, 13.5, 5, 0, 0, Math.PI * 2); g.fillStyle = PAPER; g.fill(); outline(g, .8);+ g.beginPath(); g.moveTo(39, 47.2); g.lineTo(33, 50); g.lineTo(39, 52.8); g.closePath(); g.fillStyle = PAPER; g.fill(); outline(g, .6);+ ribbon(g, [[62, 50], [71, 50], [80, 50]], 4, 2.8, INK);+ ribbon(g, [[71, 49.3], [79, 49.2]], .4, 1, PAPER);+ g.beginPath(); g.ellipse(82.5, 50, 2.9, 2.3, 0, 0, Math.PI * 2); g.fillStyle = INK; g.fill();+ g.beginPath(); g.moveTo(84.6, 49); g.lineTo(93, 50); g.lineTo(84.6, 51); g.closePath(); g.fillStyle = PAPER; g.fill(); outline(g, .4);+ return [82.3, 50];+}++// ------------------------------------------------------------------ river steam+// 4 wisps, 1024×256 each, stacked: lens-shaped clusters of horizontal paper cuts.+export function mistAtlas() {+ const W = 1024, H = 256, c = document.createElement('canvas'); c.width = W; c.height = H * 4;+ const g = c.getContext('2d');+ for (let v = 0; v < 4; v++) {+ const R = mulberry(880 + v * 29), oy = v * H;+ for (let y = 30; y < H - 30; y += 8 + R() * 8) {+ const s = (y - 30) / (H - 60), env = Math.pow(Math.sin(s * Math.PI), .7);+ const half = W * .46 * env * (.7 + R() * .3), cx = W / 2 + (R() - .5) * 120;+ let x = cx - half;+ while (x < cx + half) {+ const len = 40 + R() * 260, gap = 10 + R() * 90;+ if (R() < .7) {+ const x1 = Math.min(cx + half, x + len), wv = Math.sin(x * .01 + v) * 3;+ cut(g, x, oy + y + wv, x1, oy + y + wv + (R() - .5) * 4, 4 + R() * 8 * env, R, PAPER, .9);+ }+ x += len + gap;+ }+ }+ }+ return c;+}++// ------------------------------------------------------------------ moon and sun+export function moonCanvas(S = 1024) {+ const c = document.createElement('canvas'); c.width = S; c.height = S;+ const g = c.getContext('2d'), R = mulberry(77), m = S / 2;+ g.strokeStyle = PAPER; g.lineCap = 'round';+ for (let i = 0; i < 4; i++) {+ const r = 210 + i * 70 + R() * 20, a0 = R() * 6, sw = Math.PI * (.7 + R() * .9);+ g.lineWidth = 4 - i * .6; g.beginPath();+ for (let s = 0; s <= 1; s += .01) { const a = a0 + sw * s, rr = r * (1 + Math.sin(s * 9 + i) * .012); g.lineTo(m + Math.cos(a) * rr, m + Math.sin(a) * rr * .96); }+ g.stroke();+ }+ g.fillStyle = PAPER; g.beginPath(); g.arc(m, m, 150, 0, Math.PI * 2); g.fill();+ g.strokeStyle = PAPER; g.lineWidth = 3; g.beginPath(); g.arc(m + 4, m - 2, 168, -1.2, 1.4); g.stroke();+ for (const [dx, dy, L] of [[-62, -48, 70], [-20, -20, 95], [-80, 8, 60], [-30, 38, 85], [-58, 66, 50]]) {+ const x = m + dx + (R() - .5) * 10, y = m + dy;+ cut(g, x, y, x + L, y + (R() - .5) * 4, 9, R, INK);+ }+ return c;+}+// The sun: a warm disc crossed by ink dashes, with carved rays fanning out above the horizon.+export function sunCanvas(S = 1024) {+ const c = document.createElement('canvas'); c.width = S; c.height = S;+ const g = c.getContext('2d'), R = mulberry(4401), m = S / 2;+ for (let i = 0; i < 56; i++) {+ const a = Math.PI + (i + .5) / 56 * Math.PI + (R() - .5) * .02;+ const r0 = 190 + R() * 30, r1 = 330 + R() * 170;+ cut(g, m + Math.cos(a) * r0, m + Math.sin(a) * r0, m + Math.cos(a) * r1, m + Math.sin(a) * r1, 5 + R() * 4, R, YELLOW);+ }+ g.strokeStyle = YELLOW; g.lineCap = 'round';+ for (let i = 0; i < 3; i++) { g.lineWidth = 4 - i; g.beginPath(); g.arc(m, m, 168 + i * 18, Math.PI * 1.02, Math.PI * 1.98); g.stroke(); }+ g.fillStyle = YELLOW; g.beginPath(); g.arc(m, m, 150, 0, Math.PI * 2); g.fill();+ for (let i = 0; i < 6; i++) { const y = m - 110 + i * 34, w = Math.sqrt(Math.max(0, 150 * 150 - (y - m) ** 2)); cut(g, m - w * .8, y, m + w * .55, y + 2, 6, R, INK); }+ return c;+}diff --git a/styles/printed-long-take/demo/timeline.js b/styles/printed-long-take/demo/timeline.jsnew file mode 100644index 0000000..8dc077a--- /dev/null+++ b/styles/printed-long-take/demo/timeline.js@@ -0,0 +1,38 @@+// Every time in the film, in seconds. Camera keys live in scene.js next to the shots they drive.+// The narration (voice/, 11 lines) is placed in VO below; the shot table is in DEMO.md.+export const T = {+ DUR: 59.6,+ title: [0.15, 1.1, 4.4, 5.0], // the title is cut into the night sky, held, and taken back as the camera sinks+ bridgeHold: [7.6, 10.0], // the bridge plate and the thermometer, held to read+ underBridge: 10.05, // through the bridge, out into the dawn+ dawn: [10.8, 16.2], // the sky is carved from the horizon up+ wake: [13.75, 15.4], // the red crowns wake, left to right (after "…是丹顶鹤")+ pairCall: 15.1, // the nearest pair calls in unison+ takeoff: 16.2, // the flock runs and lifts off the water+ whiteIn: 18.7, cutB: 18.95, whiteOut: 19.15, // through the steam+ tilt: [20.5, 22.2], // the aerial tilts down to the field grid at "开垦"+ cutC: 24.0, // match on the descent into the feeding field+ landed: 26.8, // the bird we follow touches down+ sign1: [28.6, 33.6], // the board: winter 1952, 33+ prints: [33.6, 41.3], // the 1952 print held, corn scattered, then three peels+ corn: [36.6, 37.9], // corn spreads on the snow at "投喂"+ peels: [38.9, 39.7, 40.4], // each peel takes 0.3 s+ verdict: [41.3, 51.4], // 2025 cut in; struck at "易危", sealed at "近危"+ carveDate: [41.6, 42.4], carveNum: [42.6, 43.7], strike: 47.6, stamp: 48.55,+ dance: [51.4, 56.4], // the pair dances; the camera rises to the opening angle+ end: [56.4, 59.6], // the end card is cut into the sky over the still wide shot+};+// narration: line id, start (s); durations are in voice/zh/dur.json (the English reading starts at the same moments). English is a free translation for the subtitle bar.+export const VO = [+ ['l01', 1.0, '这么冷的清晨,河水却没有结冰,还升腾着阵阵白汽。', 'On a morning this cold, the river still hasn’t frozen; it breathes white steam.'],+ ['l02', 5.4, '这里是北海道东部的湿地。', 'This is a wetland in eastern Hokkaido.'],+ ['l03', 10.8, '站在河水里安静睡觉的,是丹顶鹤。', 'Asleep, standing in the water: red-crowned cranes.'],+ ['l04', 19.2, '早年间,随着湿地被一片片开垦,它们差点就彻底失去了家园。', 'Long ago, as the wetlands were cleared field by field, they nearly lost their home for good.'],+ ['l05', 24.2, '天亮后,它们成群飞去的地方,是一块专门撒满玉米的田地。', 'At daybreak they fly in flocks to a field scattered with corn, just for them.'],+ ['l06', 28.8, '回想一九五二年冬天,整个北海道,一共只找到了三十三只丹顶鹤。', 'Think back to the winter of 1952: in all of Hokkaido, only 33 cranes were found.'],+ ['l07', 33.8, '也是从那一年起,当地人决定在冬天给它们投喂食物。', 'That was the year local people decided to feed them through the winter.'],+ ['l08', 38.1, '就这样,丹顶鹤的数量,一年比一年多。', 'And so, year after year, there were more of them.'],+ ['l09', 41.5, '到了二零二五年,已经数到了一千九百二十七只。', 'By 2025 the count had reached 1,927.'],+ ['l10', 45.9, '它们的保护级别,也终于从易危,降到了近危。', 'Their status finally eased, from Vulnerable to Near Threatened.'],+ ['l11', 51.6, '虽然不再算作濒危物种了,但这群雪地里的精灵,依然需要人们的守护。', 'No longer counted as endangered, these spirits of the snow still need people to look after them.'],+];diff --git a/styles/printed-long-take/demo/tools/chars.txt b/styles/printed-long-take/demo/tools/chars.txtnew file mode 100644index 0000000..428cace--- /dev/null+++ b/styles/printed-long-take/demo/tools/chars.txt@@ -0,0 +1 @@+ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~°·×–—’…→−。一七三不专东个丹么九也了二于五亮人从们但作依保共再冬冰决冷出别到北十千升危却去只后喂回园在地块垦多天失季它守安定家就差已年底开当彻想成找投护撒数整方早易是晨月有样橋比水汽没河海清湿满濒灵点然片物玉田白百的着睡种移站等算米精级终经结给群羽腾虽被要觉起近还这道那部里量门间阵降随雪零需静音顶飞食鹤,\ No newline at end of filediff --git a/styles/printed-long-take/demo/tools/srt.py b/styles/printed-long-take/demo/tools/srt.pynew file mode 100644index 0000000..74790eb--- /dev/null+++ b/styles/printed-long-take/demo/tools/srt.py@@ -0,0 +1,32 @@+"""Bilingual subtitles (one Chinese line, one English line per cue) timed like the bar in the picture.+Run from the library root: .venv/bin/python styles/printed-long-take/demo/tools/srt.py → ../printed-long-take.srt+The cue times follow scene.js: each line from its start to the end of the Chinese reading + 0.45 s (not past the next line),+then mapped through the bridge slow-down (WARP in scene.js, mirrored in audio.py)."""+import os, re, json+HERE = os.path.dirname(os.path.abspath(__file__)); D = os.path.dirname(HERE)+src = open(os.path.join(D, 'timeline.js'), encoding='utf-8').read()+DUR = float(re.search(r'DUR: ([\d.]+)', src).group(1))+VO = [(m[0], float(m[1]), m[2], m[3].replace('\\u2019', '’')) for m in re.findall(r"\['(l\d\d)', ([\d.]+), '([^']*)', '((?:[^'\\]|\\.)*)'\]", src)]+dur = json.load(open(os.path.join(D, 'voice', 'zh', 'dur.json')))+s = open(os.path.join(D, 'scene.js'), encoding='utf-8').read()+a, b, d = map(float, re.search(r'const WARP = \{ a: ([\d.]+), b: ([\d.]+), d: ([\d.]+) \}', s).groups())+import math+def old(t):+ if t <= a: return t+ if t >= b: return t - d+ u = (t - a) / (b - a); return t - d * (u - math.sin(2 * math.pi * u) / (2 * math.pi))+def new(x):+ if x <= a: return x+ lo, hi = x, x + d+ for _ in range(50):+ m = (lo + hi) / 2+ lo, hi = (m, hi) if old(m) < x else (lo, m)+ return (lo + hi) / 2+ts = lambda t: f'{int(t // 3600):02d}:{int(t % 3600 // 60):02d}:{int(t % 60):02d},{int(round(t % 1 * 1000)) % 1000:03d}'+out = []+for i, (id_, at, cn, en) in enumerate(VO):+ nxt = VO[i + 1][1] if i + 1 < len(VO) else DUR+ s0, s1 = new(at - .05), new(min(at + dur[id_] + .45, nxt - .1))+ out.append(f'{i + 1}\n{ts(s0)} --> {ts(s1)}\n{cn}\n{en}\n')+open(os.path.join(os.path.dirname(D), 'printed-long-take.srt'), 'w', encoding='utf-8').write('\n'.join(out))+print(len(out), 'cues')diff --git a/styles/printed-long-take/demo/tools/subset.py b/styles/printed-long-take/demo/tools/subset.pynew file mode 100644index 0000000..3e49100--- /dev/null+++ b/styles/printed-long-take/demo/tools/subset.py@@ -0,0 +1,18 @@+"""Noto Serif SC (OFL) at weight 700, subset to every character the film prints, as fonts/NotoSerifSC-700.woff2.+Run from the library root: .venv/bin/python styles/printed-long-take/demo/tools/subset.py+Needs tools/NotoSerifSC-VF.ttf (build.sh downloads it from github.com/google/fonts). Only kern and palt are kept:+with every layout feature kept, some browsers pick a locale variant of a character (a traditional crane for 鹤)."""+import os+from fontTools.ttLib import TTFont+from fontTools.varLib import instancer+from fontTools import subset+HERE = os.path.dirname(os.path.abspath(__file__)); D = os.path.dirname(HERE)+txt = ''.join(open(os.path.join(D, f), encoding='utf-8').read() for f in ['scene.js', 'props.js', 'timeline.js'])+chars = sorted(set(c for c in txt if ord(c) > 0x7E) | set(chr(i) for i in range(0x20, 0x7F)) | set('’−°×·'))+open(os.path.join(HERE, 'chars.txt'), 'w', encoding='utf-8').write(''.join(chars))+tmp = os.path.join(HERE, 'NotoSerifSC-700.ttf')+instancer.instantiateVariableFont(TTFont(os.path.join(HERE, 'NotoSerifSC-VF.ttf')), {'wght': 700}).save(tmp)+subset.main([tmp, '--text-file=' + os.path.join(HERE, 'chars.txt'), '--flavor=woff2', '--layout-features=kern,palt',+ '--output-file=' + os.path.join(D, 'fonts', 'NotoSerifSC-700.woff2')])+os.remove(tmp)+print(len(chars), 'chars')diff --git a/styles/printed-long-take/demo/voice/en/dur.json b/styles/printed-long-take/demo/voice/en/dur.jsonnew file mode 100644index 0000000..f4cf99d--- /dev/null+++ b/styles/printed-long-take/demo/voice/en/dur.json@@ -0,0 +1,13 @@+{+ "l01": 4.024,+ "l02": 2.118,+ "l03": 3.131,+ "l04": 4.626,+ "l05": 4.194,+ "l06": 4.729,+ "l07": 3.258,+ "l08": 2.796,+ "l09": 3.508,+ "l10": 3.628,+ "l11": 5.047+}\ No newline at end of filediff --git a/styles/printed-long-take/demo/voice/en/words.json b/styles/printed-long-take/demo/voice/en/words.jsonnew file mode 100644index 0000000..200c9e6--- /dev/null+++ b/styles/printed-long-take/demo/voice/en/words.json@@ -0,0 +1,674 @@+{+"l01": [+[+"On",+-0.6,+0.1+],+[+"a",+0.1,+0.16+],+[+"morning",+0.16,+0.36+],+[+"this",+0.36,+0.56+],+[+"cold,",+0.56,+0.86+],+[+"the",+1.28,+1.34+],+[+"river",+1.34,+1.52+],+[+"hasn't",+1.52,+1.96+],+[+"frozen.",+1.96,+2.18+],+[+"It",+2.66,+2.76+],+[+"breathes",+2.76,+3.18+],+[+"white",+3.18,+3.34+],+[+"steam.",+3.34,+3.66+]+],+"l02": [+[+"This",+-0.6,+0.14+],+[+"is",+0.14,+0.26+],+[+"a",+0.26,+0.36+],+[+"wetland",+0.36,+0.72+],+[+"in",+0.72,+0.98+],+[+"eastern",+0.98,+1.22+],+[+"Hokkaido.",+1.22,+1.82+]+],+"l03": [+[+"A",+-0.6,+0.08+],+[+"sleep,",+0.08,+0.3+],+[+"standing",+0.68,+0.98+],+[+"in",+0.98,+1.22+],+[+"the",+1.22,+1.32+],+[+"water,",+1.32,+1.52+],+[+"red",+1.88,+2.08+],+[+"-crowned",+2.08,+2.5+],+[+"cranes.",+2.5,+2.8+]+],+"l04": [+[+"Long",+-0.6,+0.12+],+[+"ago,",+0.12,+0.38+],+[+"as",+0.64,+0.84+],+[+"the",+0.84,+0.94+],+[+"wetlands",+0.94,+1.12+],+[+"were",+1.12,+1.52+],+[+"cleared",+1.52,+1.76+],+[+"field",+1.76,+2.04+],+[+"by",+2.04,+2.3+],+[+"field,",+2.3,+2.6+],+[+"they",+2.98,+3.08+],+[+"nearly",+3.08,+3.3+],+[+"lost",+3.3,+3.7+],+[+"their",+3.7,+3.92+],+[+"home",+3.92,+4.06+],+[+"for",+4.06,+4.24+],+[+"good.",+4.24,+4.44+]+],+"l05": [+[+"At",+-0.6,+0.12+],+[+"daybreak,",+0.12,+0.44+],+[+"they",+0.74,+0.94+],+[+"fly",+0.94,+1.14+],+[+"in",+1.14,+1.34+],+[+"flocks",+1.34,+1.68+],+[+"to",+1.68,+1.86+],+[+"a",+1.86,+1.94+],+[+"field",+1.94,+2.14+],+[+"scattered",+2.14,+2.52+],+[+"with",+2.52,+2.82+],+[+"corn,",+2.82,+3.06+],+[+"just",+3.46,+3.6+],+[+"for",+3.6,+3.8+],+[+"them.",+3.8,+3.96+]+],+"l06": [+[+"The",+-0.6,+0.06+],+[+"winter",+0.06,+0.22+],+[+"of",+0.22,+0.48+],+[+"1952,",+0.48,+1.22+],+[+"in",+1.68,+1.84+],+[+"all",+1.84,+2.04+],+[+"of",+2.04,+2.18+],+[+"Hokkaido,",+2.18,+2.54+],+[+"only",+2.86,+3.12+],+[+"33",+3.12,+3.54+],+[+"cranes",+3.54,+4.1+],+[+"were",+4.1,+4.2+],+[+"found.",+4.2,+4.46+]+],+"l07": [+[+"That",+-0.6,+0.1+],+[+"was",+0.1,+0.24+],+[+"the",+0.24,+0.38+],+[+"year",+0.38,+0.56+],+[+"local",+0.56,+0.84+],+[+"people",+0.84,+1.22+],+[+"decided",+1.22,+1.64+],+[+"to",+1.64,+1.92+],+[+"feed",+1.92,+2.14+],+[+"them",+2.14,+2.4+],+[+"through",+2.4,+2.62+],+[+"the",+2.62,+2.72+],+[+"winter.",+2.72,+2.9+]+],+"l08": [+[+"And",+-0.6,+0.16+],+[+"so,",+0.16,+0.42+],+[+"year",+0.76,+0.94+],+[+"after",+0.94,+1.2+],+[+"year,",+1.2,+1.48+],+[+"there",+1.92,+1.98+],+[+"were",+1.98,+2.1+],+[+"more",+2.1,+2.28+],+[+"of",+2.28,+2.42+],+[+"them.",+2.42,+2.56+]+],+"l09": [+[+"By",+-0.6,+0.1+],+[+"2025,",+0.1,+0.56+],+[+"the",+0.6,+0.94+],+[+"count",+0.94,+1.1+],+[+"reached",+1.1,+1.42+],+[+"1",+1.42,+1.74+],+[+",927.",+1.74,+3.22+]+],+"l10": [+[+"Their",+-0.6,+0.1+],+[+"status",+0.1,+0.4+],+[+"finally",+0.4,+0.96+],+[+"eased",+0.96,+1.34+],+[+"from",+1.34,+2.0+],+[+"vulnerable",+2.0,+2.3+],+[+"to",+2.3,+2.72+],+[+"near",+2.72,+2.9+],+[+"threatened.",+2.9,+3.26+]+],+"l11": [+[+"No",+-0.6,+0.14+],+[+"longer",+0.14,+0.46+],+[+"counted",+0.46,+0.74+],+[+"as",+0.74,+0.98+],+[+"endangered,",+0.98,+1.24+],+[+"these",+2.06,+2.14+],+[+"spirits",+2.14,+2.54+],+[+"of",+2.54,+2.82+],+[+"the",+2.82,+2.92+],+[+"snow",+2.92,+3.12+],+[+"still",+3.12,+3.42+],+[+"need",+3.42,+3.68+],+[+"people",+3.68,+3.94+],+[+"to",+3.94,+4.2+],+[+"look",+4.2,+4.32+],+[+"after",+4.32,+4.56+],+[+"them.",+4.56,+4.78+]+]+}\ No newline at end of filediff --git a/styles/printed-long-take/demo/voice/zh/dur.json b/styles/printed-long-take/demo/voice/zh/dur.jsonnew file mode 100644index 0000000..8cbd4d9--- /dev/null+++ b/styles/printed-long-take/demo/voice/zh/dur.json@@ -0,0 +1,13 @@+{+ "l01": 3.834,+ "l02": 1.72,+ "l03": 2.6,+ "l04": 4.707,+ "l05": 4.093,+ "l06": 4.652,+ "l07": 3.794,+ "l08": 2.832,+ "l09": 3.148,+ "l10": 3.079,+ "l11": 4.588+}\ No newline at end of filediff --git a/styles/printed-long-take/demo/world.js b/styles/printed-long-take/demo/world.jsnew file mode 100644index 0000000..8f227ac--- /dev/null+++ b/styles/printed-long-take/demo/world.js@@ -0,0 +1,470 @@+// The world: the Setsuri river at Tsurui in January, the Kushiro marsh, the grid of windbreaks, the Akan volcanoes,+// and the feeding field. Units are metres; north is -z, east is +x.+import * as THREE from 'three';+import { mulberry, clamp, lerp } from '/core/lib.js';+import { C, U, mtnMat, carveMat, groundMat, waterMat, bankMat, iceMat, skyMat, billboardMat, reflectMat, crownMat, toonMat, woodMat, concreteMat, inkMat, paperMat, hullMat } from './look.js';+import { pineAtlas, frostTreeAtlas, craneAtlas, mistAtlas, moonCanvas, sunCanvas, HEAD } from './textures.js';+import { plateCanvas, dialCanvas, boardCanvas, BOARD } from './props.js';++export const WY = -0.6; // the river surface++export function canvasTex(c, mips = true) {+ const t = new THREE.CanvasTexture(c);+ t.colorSpace = THREE.NoColorSpace; t.anisotropy = 8; t.generateMipmaps = mips;+ t.minFilter = mips ? THREE.LinearMipmapLinearFilter : THREE.LinearFilter; t.magFilter = THREE.LinearFilter;+ return t;+}++// ------------------------------------------------------------------ the river+export const RIVER = new THREE.CatmullRomCurve3([+ [-34, 620], [-14, 470], [8, 360], [-10, 250], [8, 150], [-4, 70], [2, 10], [7, -40], [26, -80], [64, -104], [120, -116],+ [190, -114], [262, -122], [350, -150], [470, -196], [640, -236], [880, -262], [1180, -300], [1550, -360], [2000, -430], [2600, -470],+].map(([x, z]) => new THREE.Vector3(x, 0, z)), false, 'centripetal');+const RLEN = RIVER.getLength();+export const riverHalf = x => 9 + 14 * clamp((x - 34) / 46) * (1 - clamp((x - 236) / 80)); // widens into a shallow pool+export const BRIDGE = { z: -30, x: 6, y: 3.6, len: 46, pier: 8.6 };++function riverFrame(u) {+ const p = RIVER.getPointAt(u), tg = RIVER.getTangentAt(u);+ const n = new THREE.Vector3(-tg.z, 0, tg.x).normalize();+ return { p, n, hw: riverHalf(p.x) };+}+// nearest river point (coarse), for placing things off the water+const RS = []; for (let i = 0; i <= 1600; i++) { const f = riverFrame(i / 1600); RS.push([f.p.x, f.p.z, f.hw]); }+export function riverDist(x, z) {+ let best = 1e9, hw = 9;+ for (const [px, pz, h] of RS) { const d = (px - x) ** 2 + (pz - z) ** 2; if (d < best) { best = d; hw = h; } }+ return Math.sqrt(best) - hw; // metres from the water's edge (negative = in the water)+}++function riverMeshes(maskG, rect) {+ const grp = new THREE.Group(), N = 1400;+ // water ribbon+ const pos = [], riv = [], idx = [];+ for (let i = 0; i <= N; i++) {+ const { p, n, hw } = riverFrame(i / N), w = hw + 1.2;+ pos.push(p.x - n.x * w, WY, p.z - n.z * w, p.x + n.x * w, WY, p.z + n.z * w);+ riv.push(i / N * RLEN, -1.08, i / N * RLEN, 1.08);+ if (i) { const a = (i - 1) * 2; idx.push(a, a + 1, a + 2, a + 1, a + 3, a + 2); }+ }+ let g = new THREE.BufferGeometry();+ g.setAttribute('position', new THREE.Float32BufferAttribute(pos, 3)); g.setAttribute('aRiv', new THREE.Float32BufferAttribute(riv, 2)); g.setIndex(idx);+ grp.add(new THREE.Mesh(g, waterMat));+ // banks: from the water up to a snow lip just outside the cut in the ground+ for (const side of [-1, 1]) {+ const bp = [], ba = [], bi = [], ip = [], ii = [];+ const R = mulberry(side > 0 ? 41 : 43);+ let wob = 0;+ for (let i = 0; i <= N; i++) {+ const { p, n, hw } = riverFrame(i / N);+ wob = wob * .9 + (R() - .5) * .25;+ const e0 = hw - .2 + wob * .3, e1 = hw + .9;+ bp.push(p.x + n.x * side * e0, WY - .05, p.z + n.z * side * e0, p.x + n.x * side * e1, .05, p.z + n.z * side * e1);+ ba.push(i / N * RLEN, 0, i / N * RLEN, 1);+ if (i) { const a = (i - 1) * 2; bi.push(a, a + 1, a + 2, a + 1, a + 3, a + 2); }+ // shelf ice: an irregular paper ledge on the water along the bank+ const iw = Math.max(0, .45 + Math.sin(i * .13 + side) * .5 + Math.sin(i * .041) * .35);+ ip.push(p.x + n.x * side * (hw - .2 - iw), WY + .03, p.z + n.z * side * (hw - .2 - iw), p.x + n.x * side * (hw + .1), WY + .03, p.z + n.z * side * (hw + .1));+ if (i) { const a = (i - 1) * 2; ii.push(a, a + 1, a + 2, a + 1, a + 3, a + 2); }+ }+ g = new THREE.BufferGeometry(); g.setAttribute('position', new THREE.Float32BufferAttribute(bp, 3)); g.setAttribute('aB', new THREE.Float32BufferAttribute(ba, 2)); g.setIndex(bi);+ grp.add(new THREE.Mesh(g, bankMat));+ g = new THREE.BufferGeometry(); g.setAttribute('position', new THREE.Float32BufferAttribute(ip, 3)); g.setIndex(ii);+ const ice = new THREE.Mesh(g, iceMat); grp.add(ice);+ }+ // the mask: where the ground is cut away+ const [x0, z0, sx, sz] = rect, S = maskG.canvas.width;+ maskG.strokeStyle = '#fff'; maskG.lineCap = 'round'; maskG.lineJoin = 'round';+ for (let i = 0; i < N; i++) {+ const a = riverFrame(i / N), b = riverFrame((i + 1) / N);+ maskG.lineWidth = (a.hw + .45) * 2 / sx * S;+ maskG.beginPath(); maskG.moveTo((a.p.x - x0) / sx * S, (a.p.z - z0) / sz * S); maskG.lineTo((b.p.x - x0) / sx * S, (b.p.z - z0) / sz * S); maskG.stroke();+ }+ return grp;+}++// marsh streams: thin ink meanders lying on the snow, seen from the air+function streams(R) {+ const grp = new THREE.Group();+ const mat = new THREE.MeshBasicMaterial({ color: C.ink, polygonOffset: true, polygonOffsetFactor: -2, polygonOffsetUnits: -2 });+ const make = (x, z, len, heading, w, seed) => {+ const r = mulberry(seed), pts = []; let a = heading, px = x, pz = z;+ for (let i = 0; i < len; i++) { pts.push(new THREE.Vector3(px, .05, pz)); a += Math.sin(i * .9 + r() * 2) * .9; px += Math.cos(a) * 26; pz += Math.sin(a) * 26; }+ const cv = new THREE.CatmullRomCurve3(pts), N = len * 10, pos = [], idx = [];+ for (let i = 0; i <= N; i++) {+ const p = cv.getPointAt(i / N), tg = cv.getTangentAt(i / N), n = new THREE.Vector3(-tg.z, 0, tg.x), ww = w * (.7 + .3 * Math.sin(i * .2));+ pos.push(p.x - n.x * ww, .05, p.z - n.z * ww, p.x + n.x * ww, .05, p.z + n.z * ww);+ if (i) { const a2 = (i - 1) * 2; idx.push(a2, a2 + 1, a2 + 2, a2 + 1, a2 + 3, a2 + 2); }+ }+ const g = new THREE.BufferGeometry(); g.setAttribute('position', new THREE.Float32BufferAttribute(pos, 3)); g.setIndex(idx);+ grp.add(new THREE.Mesh(g, mat));+ };+ make(260, 1500, 60, -1.75, 5, 11); make(900, 1600, 64, -2.1, 4, 12); make(1500, 1300, 54, -2.4, 3.5, 13);+ make(120, 700, 30, -.3, 3, 14); make(700, 220, 34, .6, 3, 15); make(1300, 500, 30, 2.6, 2.6, 16);+ make(-500, 900, 30, -1.2, 3, 17); make(1900, 200, 40, 2.9, 3.5, 18);+ return grp;+}++// ------------------------------------------------------------------ mountains: the Akan volcanoes and their ridges+function volcano(cx, cz, h, r, seed, crater = 0) {+ // a stratovolcano: concave flanks that steepen toward the summit, cut into flat facets.+ // crater > 0 truncates the summit into a rim (a broad massif instead of a sharp cone)+ const R = mulberry(seed), pos = [], n = 16;+ const prof = [[1, 0], [.62, .22], [.36, .5], [.17, .78], [.06 + crater * .14, .95 - crater * .1]];+ const rings = prof.map(([rf, hf], k) => {+ const a0 = R() * .4, ring = [];+ for (let i = 0; i < n; i++) {+ const a = a0 + i / n * Math.PI * 2 + (R() - .5) * .12 * (k > 0);+ const rr = r * rf * (1 + (R() - .5) * .1), hh = h * hf * (1 + (R() - .5) * .04 * (k > 0));+ ring.push([cx + Math.cos(a) * rr, k ? hh : -4, cz + Math.sin(a) * rr * .7]);+ }+ return ring;+ });+ const apex = [cx, h * (crater ? .86 : 1), cz];+ const tri = (a, b, c) => pos.push(...a, ...b, ...c);+ for (let k = 0; k < rings.length - 1; k++) for (let i = 0; i < n; i++) {+ const j = (i + 1) % n, A = rings[k], B = rings[k + 1];+ tri(A[i], B[j], A[j]); tri(A[i], B[i], B[j]);+ }+ const top = rings[rings.length - 1];+ for (let i = 0; i < n; i++) tri(top[i], apex, top[(i + 1) % n]);+ const g = new THREE.BufferGeometry(); g.setAttribute('position', new THREE.Float32BufferAttribute(pos, 3));+ return new THREE.Mesh(g, mtnMat);+}++// ------------------------------------------------------------------ instanced billboards+export function billboards(count, mat, pivotBottom) {+ const base = new THREE.PlaneGeometry(1, 1); if (pivotBottom) base.translate(0, .5, 0);+ const g = new THREE.InstancedBufferGeometry();+ g.index = base.index; g.attributes.position = base.attributes.position; g.attributes.uv = base.attributes.uv;+ g.setAttribute('aOff', new THREE.InstancedBufferAttribute(new Float32Array(count * 3), 3));+ g.setAttribute('aSize', new THREE.InstancedBufferAttribute(new Float32Array(count * 2), 2));+ g.setAttribute('aTile', new THREE.InstancedBufferAttribute(new Float32Array(count * 4), 4));+ g.setAttribute('aRot', new THREE.InstancedBufferAttribute(new Float32Array(count), 1));+ g.instanceCount = count;+ const m = new THREE.Mesh(g, mat); m.frustumCulled = false; return m;+}+function fillBoards(mesh, list, cols, rows = 1) {+ const a = mesh.geometry.attributes;+ list.forEach(([x, y, z, w, h, v, rot = 0], i) => {+ a.aOff.array.set([x, y, z], i * 3); a.aSize.array.set([w, h], i * 2);+ a.aTile.array.set([(v % cols) / cols, (rows - 1 - Math.floor(v / cols)) / rows, 1 / cols, 1 / rows], i * 4); a.aRot.array[i] = rot;+ });+ mesh.geometry.instanceCount = list.length;+ for (const k in a) a[k].needsUpdate = true;+}++// ------------------------------------------------------------------ cranes: one instanced flock per mesh+// each crane: {x,y,z,s (height in m), flip, pose, rot, mode (0 standing, 1 flying), crown (0..1)}+export class Flock {+ constructor(tex, crownM, max, mode, reflect = false) {+ this.max = max; this.mode = mode;+ this.mesh = billboards(max, billboardMat(tex, mode), mode === 0);+ const cg = new THREE.BufferGeometry();+ cg.setAttribute('position', new THREE.BufferAttribute(new Float32Array(max * 3), 3));+ for (const [k, n] of [['aOff', 3], ['aSize', 2], ['aHead', 2], ['aRot', 1], ['aMode', 1], ['aOn', 1]]) cg.setAttribute(k, new THREE.BufferAttribute(new Float32Array(max * n), n));+ this.crowns = new THREE.Points(cg, crownM); this.crowns.frustumCulled = false;+ if (reflect) { this.refl = billboards(max, reflectMat(tex), true); }+ }+ set(list) {+ const a = this.mesh.geometry.attributes, c = this.crowns.geometry.attributes;+ const n = Math.min(list.length, this.max);+ for (let i = 0; i < n; i++) {+ // printmaker's scale: far birds are cut a little larger so they still read as birds, not specks+ const b = list[i], d = Flock.cam ? Math.hypot(b.x - Flock.cam.x, b.y - Flock.cam.y, b.z - Flock.cam.z) : 0;+ const grow = 1 + 2 * Math.min(1, Math.max(0, (d - 40) / 160));+ const sz = b.s * 1.16 * grow, w = sz * (b.flip ? -1 : 1);+ a.aOff.array.set([b.x, b.y, b.z], i * 3); a.aSize.array.set([w, sz], i * 2);+ a.aTile.array.set([(b.pose % 4) / 4, (3 - Math.floor(b.pose / 4)) / 4, .25, .25], i * 4); a.aRot.array[i] = b.rot || 0;+ const hd = HEAD[b.pose];+ const hx = b.flip ? 1 - hd[0] / 100 : hd[0] / 100;+ c.aOff.array.set([b.x, b.y, b.z], i * 3); c.aSize.array.set([sz, sz], i * 2); c.aHead.array.set([hx, hd[1] / 100], i * 2);+ c.aRot.array[i] = b.rot || 0; c.aMode.array[i] = this.mode; c.aOn.array[i] = b.crown ?? 1;+ }+ this.mesh.geometry.instanceCount = n;+ c.position.count; this.crowns.geometry.setDrawRange(0, n);+ for (const k in a) a[k].needsUpdate = true;+ for (const k in c) c[k].needsUpdate = true;+ if (this.refl) {+ const r = this.refl.geometry.attributes;+ for (const k of ['aOff', 'aSize', 'aTile', 'aRot']) { r[k].array.set(a[k].array.subarray(0, n * r[k].itemSize)); r[k].needsUpdate = true; }+ this.refl.geometry.instanceCount = n;+ }+ }+ addTo(scene) { scene.add(this.mesh); scene.add(this.crowns); if (this.refl) scene.add(this.refl); }+}++// ------------------------------------------------------------------ props+const E = .05;+function box(parent, w, h, d, x, y, z, mat, outline = true, ry = 0) {+ const m = new THREE.Mesh(new THREE.BoxGeometry(w, h, d), mat); m.position.set(x, y, z); m.rotation.y = ry; parent.add(m);+ if (outline) { const o = new THREE.Mesh(new THREE.BoxGeometry(w + 2 * E, h + 2 * E, d + 2 * E), hullMat); o.position.copy(m.position); o.rotation.y = ry; parent.add(o); }+ return m;+}+const steel = woodMat, concrete = concreteMat;+const snowT = toonMat(C.paper, new THREE.Color('#c9c3ab'));++// Otowa bridge: a plain steel girder bridge on two piers, snow on the deck and the rails+function bridge() {+ const g = new THREE.Group(), { x, z, y, len } = BRIDGE;+ box(g, len, .9, 7.2, x, y, z, steel); // deck girder+ box(g, len, .18, 7.0, x, y + .54, z, snowT, false); // snow on the road+ for (const s of [-1, 1]) {+ box(g, len, .16, .16, x, y + 1.6, z + s * 3.45, steel); // top rail+ box(g, len, .12, .12, x, y + 1.05, z + s * 3.45, steel); // mid rail+ box(g, len - .2, .08, .2, x, y + 1.71, z + s * 3.45, snowT, false);+ for (let k = 0; k <= 22; k++) box(g, .1, 1.15, .1, x - len / 2 + k * len / 22, y + 1.05, z + s * 3.45, steel, false);+ }+ for (const s of [-1, 1]) box(g, 2.4, 4.6, 5.5, x + s * BRIDGE.pier, WY + 1.7, z, concrete); // piers+ // abutments+ for (const s of [-1, 1]) box(g, 3, 4.4, 8.4, x + s * (len / 2 - 1), 1.6, z, concrete);+ return g;+}++function hut(x, z, ry = 0, w = 4.4, d = 3.4) {+ const g = new THREE.Group();+ box(g, w, 2.4, d, 0, 1.2, 0, woodMat);+ // gable roof with snow+ const roof = new THREE.BufferGeometry(), hw = w / 2 + .35, hd = d / 2 + .4, ry0 = 2.4, ry1 = 3.6;+ const v = [-hw, ry0, -hd, hw, ry0, -hd, hw, ry1, 0, -hw, ry0, -hd, hw, ry1, 0, -hw, ry1, 0,+ -hw, ry0, hd, -hw, ry1, 0, hw, ry1, 0, -hw, ry0, hd, hw, ry1, 0, hw, ry0, hd];+ roof.setAttribute('position', new THREE.Float32BufferAttribute(v, 3)); roof.computeVertexNormals();+ const rm = new THREE.Mesh(roof, toonMat(C.paper, new THREE.Color('#bdb79f'))); rm.material.side = THREE.DoubleSide; g.add(rm);+ box(g, .7, .9, .06, w * .2, 1.0, d / 2 + .02, inkMat, false); // door+ box(g, .6, .5, .06, -w * .25, 1.5, d / 2 + .02, inkMat, false); // window+ g.position.set(x, 0, z); g.rotation.y = ry; return g;+}++// ------------------------------------------------------------------ build everything+export function buildWorld(scene, proj, clear = []) {+ // keep trees off the camera's path through the valley+ const onPath = (x, z) => clear.some(([cx, cz, r]) => (cx - x) ** 2 + (cz - z) ** 2 < r * r);+ const R = mulberry(2026);+ const W = {};+ // sky: a sphere that travels with the camera+ W.sky = new THREE.Mesh(new THREE.SphereGeometry(8000, 64, 32), skyMat); W.sky.renderOrder = -10; scene.add(W.sky);+ W.moon = new THREE.Mesh(new THREE.PlaneGeometry(900, 900), new THREE.MeshBasicMaterial({ map: canvasTex(moonCanvas()), transparent: true, depthWrite: false }));+ W.moon.renderOrder = -9; scene.add(W.moon);+ W.sun = new THREE.Mesh(new THREE.PlaneGeometry(700, 700), new THREE.MeshBasicMaterial({ map: canvasTex(sunCanvas()), transparent: true, depthWrite: false }));+ W.sun.renderOrder = -9; scene.add(W.sun);++ // ground + river+ const rect = [-1400, -1400, 4200, 4200];+ const mc = document.createElement('canvas'); mc.width = mc.height = 4096;+ const mg = mc.getContext('2d'); mg.fillStyle = '#000'; mg.fillRect(0, 0, 4096, 4096);+ W.river = riverMeshes(mg, rect); scene.add(W.river);+ // soften the mask a little so the ground can hatch the cornice+ const mc2 = document.createElement('canvas'); mc2.width = mc2.height = 4096; const mg2 = mc2.getContext('2d');+ mg2.filter = 'blur(3px)'; mg2.drawImage(mc, 0, 0); mg2.filter = 'none'; mg2.globalCompositeOperation = 'lighter'; mg2.globalAlpha = .55; mg2.drawImage(mc, 0, 0);+ const maskTex = canvasTex(mc2, false); maskTex.flipY = false;+ W.ground = new THREE.Mesh(new THREE.PlaneGeometry(24000, 24000, 1, 1), groundMat(maskTex, rect));+ W.ground.rotation.x = -Math.PI / 2; scene.add(W.ground);+ W.streams = streams(R); scene.add(W.streams);++ // mountains: two volcano cones, a broad massif, and a long row of lower ridges+ const mtns = new THREE.Group(); scene.add(mtns);+ // the Akan group to the north-west: an even cone, a broad truncated massif with a small cone at its side,+ // then a long low line of older volcanoes and ridges+ mtns.add(volcano(-560, -2300, 520, 1050, 11)); // the even cone+ mtns.add(volcano(-1500, -2600, 560, 1350, 12, 1)); // the broad massif with a crater rim+ mtns.add(volcano(-1080, -2420, 430, 760, 13)); // a small sharp cone beside it+ for (let i = 0; i < 12; i++) {+ const x = -3200 + i * 560 + (R() - .5) * 160; if (x > -1900 && x < -250) continue;+ const h = 170 + R() * 120; mtns.add(volcano(x, -2050 - R() * 300, h, h * (2.6 + R() * .8), 100 + i, R() < .5 ? .6 : 0));+ }+ for (let i = 0; i < 10; i++) { const h = 80 + R() * 50; mtns.add(volcano(-2600 + i * 560 + (R() - .5) * 150, -1700 - R() * 80, h, h * 3.4, 200 + i, .8)); }+ // a dark foothill band under the mountains+ const band = new THREE.Mesh(new THREE.PlaneGeometry(9000, 120), inkMat); band.rotation.x = -Math.PI / 2; band.position.set(0, .2, -1580); scene.add(band);++ W.bridge = bridge(); scene.add(W.bridge);+ // the cast-iron name plate and the dial thermometer on the downstream face of the east pier+ const face = BRIDGE.z + 2.75 + .03, px = BRIDGE.x + BRIDGE.pier;+ W.plate = new THREE.Mesh(new THREE.PlaneGeometry(1.1, .56), new THREE.MeshBasicMaterial({ map: canvasTex(plateCanvas()) }));+ W.plate.position.set(px - .55, 1.55, face); scene.add(W.plate);+ const plateBack = new THREE.Mesh(new THREE.BoxGeometry(1.16, .62, .05), inkMat); plateBack.position.set(px - .55, 1.55, face - .03); scene.add(plateBack);+ W.dial = new THREE.Mesh(new THREE.CircleGeometry(.23, 48), new THREE.MeshBasicMaterial({ map: canvasTex(dialCanvas()) }));+ W.dial.geometry.attributes.uv.array.forEach((v, i, a) => a[i] = v); // circle uvs already span the disc+ W.dial.position.set(px + .62, 1.5, face + .02); scene.add(W.dial);+ const dialRim = new THREE.Mesh(new THREE.CylinderGeometry(.25, .25, .06, 48), inkMat); dialRim.rotation.x = Math.PI / 2; dialRim.position.set(px + .62, 1.5, face - .01); scene.add(dialRim);+ W.plateRect = { w: 1.1, h: .56 };+ // snow lying on the plate and the dial, icicles hanging under them+ box(scene, 1.22, .07, .14, px - .55, 1.55 + .31, face + .03, paperMat, true);+ box(scene, .34, .05, .1, px + .62, 1.5 + .25, face + .02, paperMat, true);+ { const R = mulberry(88);+ const icicle = (x, y, z, L) => {+ const c = new THREE.Mesh(new THREE.ConeGeometry(.014, L, 6), paperMat); c.rotation.x = Math.PI; c.position.set(x, y - L / 2, z); scene.add(c);+ const h = new THREE.Mesh(new THREE.ConeGeometry(.024, L + .02, 6), hullMat); h.rotation.x = Math.PI; h.position.copy(c.position); scene.add(h);+ };+ for (let i = 0; i < 9; i++) icicle(px - 1.05 + i * .12 + (R() - .5) * .04, 1.55 - .31, face + .02, .05 + R() * .14);+ for (let i = 0; i < 4; i++) icicle(px + .5 + i * .08, 1.5 - .25, face + .02, .04 + R() * .08);+ for (let i = 0; i < 16; i++) icicle(px - 1.2 + i * .16 + (R() - .5) * .05, BRIDGE.y - .46, face - .02 + 2.75 * 0, .08 + R() * .3);+ }++ // ---------------- trees+ const pines = [], frost = [];+ const inField = (x, z) => x > -185 && x < -25 && z > -250 && z < -100;+ // windbreak belts: the grid of the dairy farms+ const belt = (x0, z0, x1, z1, step, hMul = 1) => {+ const L = Math.hypot(x1 - x0, z1 - z0), nx = (x1 - x0) / L, nz = (z1 - z0) / L;+ for (let s = 0; s < L; s += step * (.6 + R() * .8)) {+ for (let k = 0; k < 2; k++) {+ const x = x0 + nx * s + (-nz) * (k * 3 + (R() - .5) * 2), z = z0 + nz * s + nx * (k * 3 + (R() - .5) * 2);+ if (riverDist(x, z) < 6) continue;+ const h = (13 + R() * 7) * hMul; pines.push([x, 0, z, h * .5, h, Math.floor(R() * 8)]);+ }+ }+ };+ for (const z of [-262, -640, -1080]) belt(-1500, z, 1500, z - 20, 2.6, .8);+ for (const x of [-760, -250, 500]) belt(x, -262, x - 15, -1080, 2.8, .8);+ for (const z of [-640]) belt(1500, z, 2600, z - 40, 2.8, .8);+ // west of the river, south: scattered pines and a few belts+ for (const z of [140, 420]) belt(-1500, z, -60, z + 15, 2.8);+ belt(-260, 520, -280, -60, 3);+ // frosted alders and willows along both banks+ for (let i = 0; i <= 1600; i += 1) {+ const u = i / 1600, f = riverFrame(u);+ if (f.p.x > 900 || f.p.z > 560) continue;+ for (const side of [-1, 1]) {+ if (R() < (f.p.z > -40 ? .62 : .5)) continue;+ const pool = f.p.x > 30 && f.p.x < 280;+ if (pool && R() < .45) continue;+ const off = f.hw + (pool ? 9 : 3) + Math.pow(R(), 1.3) * 20;+ const x = f.p.x + f.n.x * side * off + (R() - .5) * 2, z = f.p.z + f.n.z * side * off + (R() - .5) * 2;+ if (Math.abs(z - BRIDGE.z) < 9 && Math.abs(x - BRIDGE.x) < 30) continue;+ if (inField(x, z) || onPath(x, z)) continue;+ const h = 7 + R() * 9;+ frost.push([x, -.05, z, h * (.9 + R() * .3), h, Math.floor(R() * 8)]);+ }+ }+ // alder thickets out in the marsh+ for (let k = 0; k < 46; k++) {+ const cx = 120 + R() * 2300, cz = -60 + R() * 1700, rr = 20 + R() * 70, n = 20 + Math.floor(R() * 70);+ if (riverDist(cx, cz) < 30) continue;+ for (let i = 0; i < n; i++) {+ const a = R() * Math.PI * 2, d = Math.sqrt(R()) * rr;+ const x = cx + Math.cos(a) * d * 1.4, z = cz + Math.sin(a) * d * .8;+ if (riverDist(x, z) < 3) continue;+ const h = 5 + R() * 6; frost.push([x, 0, z, h, h, Math.floor(R() * 8)]);+ }+ }+ // the west side: scattered pines and alders over the snow, as in a printed valley+ for (let i = 0; i < 2600; i++) {+ const x = -900 + R() * 860, z = -240 + R() * 900;+ if (riverDist(x, z) < 5 || inField(x, z)) continue;+ const cl = .5 + .5 * Math.sin(x * .021 + 1.3) * Math.cos(z * .027 - .4);+ if (R() > cl * .7) continue;+ const h = 6 + R() * 7;+ if (R() < .6) pines.push([x, 0, z, h * .5, h, Math.floor(R() * 8)]); else frost.push([x, 0, z, h, h, Math.floor(R() * 8)]);+ }+ const pineMesh = billboards(pines.length, billboardMat(canvasTex(pineAtlas()), 0), true); fillBoards(pineMesh, pines, 8); scene.add(pineMesh);+ const frostTex = canvasTex(frostTreeAtlas());+ const frostMesh = billboards(frost.length, billboardMat(frostTex, 0, { warm: true }), true); fillBoards(frostMesh, frost, 4, 2); scene.add(frostMesh);+ frostMesh.material.uniforms.uTint.value = 1;+ W.trees = { pines: pineMesh, frost: frostMesh };++ // ---------------- river steam: wisps hanging low over the water+ const mist = [];+ for (let i = 0; i <= 700; i++) {+ const f = riverFrame(i / 700);+ if (f.p.x > 700 || f.p.z > 520) continue;+ const n = R() < .5 && Math.abs(f.p.z - BRIDGE.z) > 32 ? 1 : 0;+ for (let k = 0; k < n; k++) {+ const off = (R() - .5) * f.hw * 1.7;+ mist.push({ x: f.p.x + f.n.x * off, z: f.p.z + f.n.z * off, y: WY + .8 + Math.pow(R(), 1.8) * 5, w: 18 + R() * 30, h: 3.5 + R() * 4, v: Math.floor(R() * 4), ph: R() * 6, flip: R() < .5 });+ }+ }+ W.mistList = mist;+ W.mist = billboards(mist.length, billboardMat(canvasTex(mistAtlas()), 0, { warm: true, transparentDepth: true, fade: [12, 55] }), false);+ W.mist.material.uniforms.uTint.value = 1;+ scene.add(W.mist);++ // ---------------- cranes+ const craneTex = canvasTex(craneAtlas());+ const cm = crownMat(proj);+ W.crownMat = cm;+ W.river1 = new Flock(craneTex, cm, 80, 0, true); W.river1.addTo(scene);+ W.flyers = new Flock(craneTex, cm, 80, 1); W.flyers.addTo(scene);+ W.field = new Flock(craneTex, cm, 360, 0); W.field.addTo(scene);++ // ---------------- the feeding field+ const F = W.feed = new THREE.Group(); scene.add(F);+ W.fence = new THREE.Group(); F.add(W.fence);+ const fx0 = -146, fx1 = -52, fz0 = -220, fz1 = -152;+ const post = (x, z) => { box(W.fence, .16, 1.5, .16, x, .75, z, woodMat, true); box(W.fence, .2, .1, .2, x, 1.52, z, paperMat, false); };+ for (let x = fx0; x <= fx1; x += 3.2) { post(x, fz0); if (Math.abs(x - (fx0 + fx1) / 2) > 4) post(x, fz1); }+ for (let z = fz0 + 3.2; z < fz1; z += 3.2) { post(fx0, z); post(fx1, z); }+ for (const yy of [.6, 1.2]) {+ box(W.fence, fx1 - fx0, .07, .07, (fx0 + fx1) / 2, yy, fz0, woodMat, false);+ box(W.fence, fx1 - fx0, .07, .07, (fx0 + fx1) / 2, yy, fz1, woodMat, false);+ box(W.fence, .07, .07, fz1 - fz0, fx0, yy, (fz0 + fz1) / 2, woodMat, false);+ box(W.fence, .07, .07, fz1 - fz0, fx1, yy, (fz0 + fz1) / 2, woodMat, false);+ }+ W.hut1 = hut(-158, -232, .1); F.add(W.hut1);+ W.hut2 = hut(-170, -226, .25, 3.2, 2.6); F.add(W.hut2);+ // the corn: a warm stipple on the snow, its extent set per era+ W.corn = new THREE.Mesh(new THREE.PlaneGeometry(1, 1), new THREE.ShaderMaterial({+ uniforms: { ...U, uSpread: { value: 1 } }, transparent: false,+ polygonOffset: true, polygonOffsetFactor: -3, polygonOffsetUnits: -3,+ vertexShader: `varying vec2 vU; varying vec3 vW; void main(){ vU = uv-.5; vec4 w = modelMatrix*vec4(position,1.); vW = w.xyz; gl_Position = projectionMatrix*viewMatrix*w; }`,+ fragmentShader: `+ float h21(vec2 p){ return fract(sin(dot(p, vec2(127.1,311.7)))*43758.5453); }+ uniform vec3 uYellow; uniform float uSpread; varying vec2 vU; varying vec3 vW;+ void main(){+ float r = length(vU*vec2(1., 1.));+ vec2 c = floor(vW.xz*7.); vec2 f = fract(vW.xz*7.)-.5;+ float dens = (1.-smoothstep(.12, .5, r/uSpread)) * .75;+ if (h21(c) > dens || length(f) > .32) discard;+ gl_FragColor = vec4(uYellow, 1.);+ }`,+ }));+ W.corn.rotation.x = -Math.PI / 2; W.corn.position.set(-99, .04, -186); W.corn.scale.set(44, 22, 1); F.add(W.corn);+ W.fieldRect = { x0: fx0, x1: fx1, z0: fz0, z1: fz1 };+ // long low-sun shadows of the fence posts, cut into the snow+ { const pos = [], idx = []; const sd = [-.95, .3], L = 4.2, w = .09;+ const add = (x, z) => { const n = pos.length / 3, nx = -sd[1] * w, nz = sd[0] * w;+ pos.push(x + nx, .03, z + nz, x - nx, .03, z - nz, x + sd[0] * L - nx * .4, .03, z + sd[1] * L - nz * .4, x + sd[0] * L + nx * .4, .03, z + sd[1] * L + nz * .4);+ idx.push(n, n + 1, n + 2, n, n + 2, n + 3); };+ for (let x = fx0; x <= fx1; x += 3.2) { add(x, fz0); if (Math.abs(x - (fx0 + fx1) / 2) > 4) add(x, fz1); }+ for (let z = fz0 + 3.2; z < fz1; z += 3.2) { add(fx0, z); add(fx1, z); }+ const g = new THREE.BufferGeometry(); g.setAttribute('position', new THREE.Float32BufferAttribute(pos, 3)); g.setIndex(idx);+ F.add(new THREE.Mesh(g, new THREE.MeshBasicMaterial({ color: C.ink, side: THREE.DoubleSide, polygonOffset: true, polygonOffsetFactor: -2, polygonOffsetUnits: -2 }))); }+ // crane tracks in the snow: three toes forward, walks that wander round the corn; more of them in later years+ { const c = document.createElement('canvas'); c.width = 2048; c.height = 1536; const g = c.getContext('2d'), R = mulberry(4040);+ const sx = 2048 / 100, sz = 1536 / 75; // 100 × 75 m centred on the corn+ for (let k = 0; k < 110; k++) {+ const era = R(), ang0 = R() * 6.28, r0 = 4 + Math.pow(R(), .7) * 30 * (.4 + era * .6);+ let x = Math.cos(ang0) * r0, z = Math.sin(ang0) * r0 * .7, a = R() * 6.28;+ g.fillStyle = `rgb(${Math.round(era * 255)},0,0)`; g.strokeStyle = g.fillStyle; g.lineWidth = 1.1; g.lineCap = 'round';+ for (let st = 0; st < 26; st++) {+ a += (R() - .5) * .5; x += Math.cos(a) * .55; z += Math.sin(a) * .55;+ const side = st % 2 ? 1 : -1, px = (x + 50 + Math.cos(a + 1.57) * .12 * side) * sx, pz = (z + 37.5 + Math.sin(a + 1.57) * .12 * side) * sz;+ for (const d of [-.45, 0, .45]) { g.beginPath(); g.moveTo(px, pz); g.lineTo(px + Math.cos(a + d) * 2.6, pz + Math.sin(a + d) * 2.6); g.stroke(); }+ g.beginPath(); g.moveTo(px, pz); g.lineTo(px - Math.cos(a) * 2.2, pz - Math.sin(a) * 2.2); g.stroke();+ }+ }+ const tex = canvasTex(c); tex.flipY = false;+ W.tracks = new THREE.Mesh(new THREE.PlaneGeometry(100, 75), new THREE.ShaderMaterial({+ uniforms: { tMap: { value: tex }, uTrack: { value: 1 }, uInk: U.uInk },+ polygonOffset: true, polygonOffsetFactor: -1, polygonOffsetUnits: -1,+ vertexShader: `varying vec2 vU; void main(){ vU = uv; gl_Position = projectionMatrix*modelViewMatrix*vec4(position,1.); }`,+ fragmentShader: `uniform sampler2D tMap; uniform float uTrack; uniform vec3 uInk; varying vec2 vU;+ void main(){ vec4 c = texture2D(tMap, vec2(vU.x, 1.-vU.y)); if (c.a < .4 || c.r > uTrack) discard; gl_FragColor = vec4(uInk, 1.); }`,+ }));+ W.tracks.rotation.x = -Math.PI / 2; W.tracks.position.set(-99, .025, -184); F.add(W.tracks); }+ // the board at the gate: two posts, a plank face with a canvas that is re-cut as the film goes+ const sign = W.sign = new THREE.Group(); F.add(sign);+ const bw = 1.8, bh = bw * BOARD.H / BOARD.W;+ W.boardCanvas = boardCanvas(null, { carve: 0, strike: 0, stamp: 0 });+ W.boardTex = canvasTex(W.boardCanvas);+ W.boardFace = new THREE.Mesh(new THREE.PlaneGeometry(bw, bh), new THREE.MeshBasicMaterial({ map: W.boardTex }));+ W.boardFace.position.set(0, 1.45, .046); sign.add(W.boardFace);+ box(sign, bw + .1, bh + .1, .08, 0, 1.45, 0, woodMat);+ box(sign, bw + .16, .1, .14, 0, 1.45 + bh / 2 + .1, 0, paperMat, false); // snow on the top edge+ for (const sx of [-1, 1]) box(sign, .12, 2.25, .12, sx * (bw / 2 - .12), 1.1, -.1, woodMat);+ sign.position.set(-112.4, 0, -149.2); sign.rotation.y = .2;+ W.board = { w: bw, h: bh };++ return W;+}++export { fillBoards };diff --git a/styles/printed-long-take/poster.jpg b/styles/printed-long-take/poster.jpgnew file mode 100644index 0000000..5fe7632Binary files /dev/null and b/styles/printed-long-take/poster.jpg differdiff --git a/styles/printed-long-take/printed-long-take.srt b/styles/printed-long-take/printed-long-take.srtnew file mode 100644index 0000000..75c3ab7--- /dev/null+++ b/styles/printed-long-take/printed-long-take.srt@@ -0,0 +1,54 @@+1+00:00:00,950 --> 00:00:05,284+这么冷的清晨,河水却没有结冰,还升腾着阵阵白汽。+On a morning this cold, the river still hasn’t frozen; it breathes white steam.++2+00:00:05,350 --> 00:00:07,570+这里是北海道东部的湿地。+This is a wetland in eastern Hokkaido.++3+00:00:11,026 --> 00:00:14,250+站在河水里安静睡觉的,是丹顶鹤。+Asleep, standing in the water: red-crowned cranes.++4+00:00:19,550 --> 00:00:24,500+早年间,随着湿地被一片片开垦,它们差点就彻底失去了家园。+Long ago, as the wetlands were cleared field by field, they nearly lost their home for good.++5+00:00:24,550 --> 00:00:29,100+天亮后,它们成群飞去的地方,是一块专门撒满玉米的田地。+At daybreak they fly in flocks to a field scattered with corn, just for them.++6+00:00:29,150 --> 00:00:34,100+回想一九五二年冬天,整个北海道,一共只找到了三十三只丹顶鹤。+Think back to the winter of 1952: in all of Hokkaido, only 33 cranes were found.++7+00:00:34,150 --> 00:00:38,400+也是从那一年起,当地人决定在冬天给它们投喂食物。+That was the year local people decided to feed them through the winter.++8+00:00:38,450 --> 00:00:41,782+就这样,丹顶鹤的数量,一年比一年多。+And so, year after year, there were more of them.++9+00:00:41,850 --> 00:00:45,498+到了二零二五年,已经数到了一千九百二十七只。+By 2025 the count had reached 1,927.++10+00:00:46,250 --> 00:00:49,829+它们的保护级别,也终于从易危,降到了近危。+Their status finally eased, from Vulnerable to Near Threatened.++11+00:00:51,950 --> 00:00:57,038+虽然不再算作濒危物种了,但这群雪地里的精灵,依然需要人们的守护。+No longer counted as endangered, these spirits of the snow still need people to look after them.diff --git a/styles/printed-long-take/style.json b/styles/printed-long-take/style.jsonnew file mode 100644index 0000000..888261b--- /dev/null+++ b/styles/printed-long-take/style.json@@ -0,0 +1,19 @@+{+ "slug": "printed-long-take",+ "num": "75",+ "en": "Printed Long Take",+ "cn": "印刷长镜头",+ "category_en": "Print & Printmaking",+ "category_cn": "印刷与版画",+ "film": "Thirty-Three Cranes",+ "line": "A winter valley in Hokkaido drawn as a scratchboard print, one unbroken take: red-crowned cranes wake in a steaming river, fly to a feeding field, and a carved board counts them back from 33 to 1,927.",+ "line_cn": "北海道的冬日河谷画成刮版画,一镜到底:丹顶鹤在冒白汽的河里醒来,飞到投喂地,一块刻字木牌把它们从 33 只数回到 1,927 只。",+ "uses": [+ "Places and journeys",+ "Wildlife and conservation",+ "A place changing over years",+ "Seasons and landscapes"+ ],+ "frame_sec": 15.4,+ "dur": 60.0+}