Skip to content

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

Memphis Diorama: end card with the author's credit, English comments

lemomo-aie89aa9487e8a
diff --git a/styles/memphis-diorama/DEMO.md b/styles/memphis-diorama/DEMO.md
index 7409fe1..5335c4e 100644
--- a/styles/memphis-diorama/DEMO.md
+++ b/styles/memphis-diorama/DEMO.md
@@ -2,11 +2,11 @@
One example among many. Don't reuse its story, arc, shots, props or timings.
-Demo: *Four Seasons in Pomelo Town* (柚子城的四季, 40 s) · `memphis-diorama.mp4` · source in [`demo/`](demo/)
+Demo: *Four Seasons in Pomelo Town* (柚子城的四季, 45 s) · `memphis-diorama.mp4` · source in [`demo/`](demo/)
## Story & structure
-One fictional river bend (a river, a bridge, a lane of ten houses, a plaza with one big tree, a lotus pond, fields) goes through spring, summer, autumn and winter in one take, ten seconds each. There is no protagonist: the place is the subject, and the seasons are told only by colour and by small motions.
+One fictional river bend (a river, a bridge, a lane of ten houses, a plaza with one big tree, a lotus pond, fields) goes through spring, summer, autumn and winter in one take, ten seconds each, then holds on the lit winter village for the end card. There is no protagonist: the place is the subject, and the seasons are told only by colour and by small motions.
Every change of season is the same gesture, so the film reads as one piece: **the big tree on the plaza squats down for half a second, springs back, and a wave spreads from it**. Inside the ring the ground, crowns, roofs and water take the next season's colours; as the ring passes, objects act (rows of rape flowers sink, umbrellas open or fold, haystacks pop up, snow starts).
@@ -15,14 +15,14 @@ Every change of season is the same gesture, so the film reads as one piece: **th
| Spring | 0–10 s | rape fields yellow, paddies flooded sky blue, pink and white blossom with flower dots | petals drift east, kites, swallows, ducks, a boat |
| Summer | 10–20 s | rice green, crowns deep green, three parasols open | a grey-lilac cloud crosses with rain and ripples, then eight lotus flowers open one by one |
| Autumn | 20–30 s | rice gold, grass yellow-green, crowns red, orange and yellow | haystacks pop up field by field, leaves fall, a V of geese flies south-west, swallows leave, lotus wilts |
-| Winter | 30–40 s | snow ground, white roofs and haystack caps, pastel crowns with white dots, lilac field ridges | snow, chimney smoke, a snowman appears; from 34 s dusk turns the picture pink-violet and every window and door lamp lights up at its own moment |
+| Winter | 30–39 s | snow ground, white roofs and haystack caps, pastel crowns with white dots, lilac field ridges | snow, chimney smoke, a snowman appears; from 34 s dusk turns the picture pink-violet and every window and door lamp lights up at its own moment |
![Spring](demo/stills/frame_spring.jpg) ![Summer](demo/stills/frame_summer.jpg)
![The tree squatting before autumn](demo/stills/frame_squat.jpg) ![Winter dusk](demo/stills/frame_winter.jpg)
## Shots
-One take. The camera orbits the plaza at fov 30°, high and slowly closing in; after 18 s it eases down to 0.3× speed so the pond and the village stay in frame through autumn and winter.
+One take. The camera orbits the plaza at fov 30°, high and slowly closing in; after 18 s it eases down to 0.3× speed so the pond and the village stay in frame through autumn, winter and the end card.
| # | Time | Shot | Camera | Native move / note |
|---|---|---|---|---|
@@ -35,18 +35,19 @@ One take. The camera orbits the plaza at fov 30°, high and slowly closing in; a
| 7 | 28.8–31.9 s | the squat again; the winter wave, snow starts behind it | — | Squash and spring → Wave |
| 8 | 32.6 s | a snowman bounces in on the plaza | — | |
| 9 | 33.8–38.3 s | dusk; windows and door lamps light one by one, warm pools on the lane | — | |
-| 10 | 39–40 s | the frame draws back in | — | Grow the frame (closing) |
+| 10 | 39.3–44 s | end card: lines 2 and 3 of the bottom type change to the sign-off and the style name, over the lit dusk village | slow orbit | |
+| 11 | 44–45 s | the frame draws back in | — | Grow the frame (closing) |
-Lines 2 and 3 of the bottom type change at 10.45, 20.45 and 30.45 s, halfway through each wave.
+Lines 2 and 3 of the bottom type change at 10.45, 20.45 and 30.45 s, halfway through each wave, and at 39.3 s for the end card.
## Score structure
-One continuous piece, F major, 96 BPM, a bar = 2.5 s, downbeat of bar 0 at 1.8 s so the three squats land on the downbeats of bars 3, 7 and 11 (9.3, 19.3, 29.3 s). The chords loop Bbmaj7 – C – Am7 – Dm7 (IV–V–iii–vi) once per season and resolve to Fmaj7 at 36.8 s.
+One continuous piece, F major, 96 BPM, a bar = 2.5 s, downbeat of bar 0 at 1.8 s so the three squats land on the downbeats of bars 3, 7 and 11 (9.3, 19.3, 29.3 s). The chords loop Bbmaj7 – C – Am7 – Dm7 (IV–V–iii–vi) once per season and resolve to Fmaj7 at 36.8 s, which rings on under the end card.
- Piano broken chords (left hand root and fifth, right hand eighth notes) run from 0.5 s to the end; the melody is always piano. Phrase A in spring and autumn, a higher phrase B in summer, A again in winter ending on a rising A–C–F.
- Only the thickness of the accompaniment follows the season: spring adds celesta an octave above the melody and a light shaker; summer adds a soft bass line, kick and brushes (kick lowered under the rain); autumn keeps them lighter and doubles the melody on marimba; winter drops the drums, doubles the melody on a music box and holds long bass notes.
- Every squat sounds the same: a soft low thump at the squat (T − 0.42 s), a springy rising "boing" at T, a ten-note harp run up from D, a quiet whoosh.
-- Foley, all under the music: swallows and ducks; cicadas, a distant thunder at 11.9 s, rain and drips, celesta for the lotus; leaves, haystack pops, six goose calls panned east to west; wind, a pop for the snowman, twelve celesta *tings* on F-pentatonic notes as the windows light.
+- Foley, all under the music: swallows and ducks; cicadas, a distant thunder at 11.9 s, rain and drips, celesta for the lotus; leaves, haystack pops, six goose calls panned east to west; wind, a pop for the snowman, twelve celesta *tings* on F-pentatonic notes as the windows light; at the end card (39.3 s, the next downbeat) a low piano F and a music box rising F–A–C–F.
- Synthesised in `demo/music.py` (additive piano with two detuned strings and a hammer click, detuned-saw pad, noise reverb); mastered by `core/render/mux.sh` to −14 LUFS.
## Palette & props
@@ -59,7 +60,7 @@ One continuous piece, F major, 96 BPM, a bar = 2.5 s, downbeat of bar 0 at 1.8 s
## End card
-None: the frame draws back in at 39 s over the lit dusk village, with the three bottom lines fading out with it.
+No separate card: the film's own three lines under the frame carry it. At 39.3 s, over the lit dusk village, line 1 keeps the title and lines 2 and 3 change (the usual fade) to `Eian × LemoLab × Claude Opus 5.5`, drawn in the title's ink at weight 600 so it is not missed (`strong2` in `drawText`), and 孟菲斯微缩景观 · MEMPHIS DIORAMA in the data line; they hold until the frame draws back in at 44 s and fade out with it. Eian made this style and its demo. 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
diff --git a/styles/memphis-diorama/demo/CREDITS b/styles/memphis-diorama/demo/CREDITS
index 9abf9cb..7a7e43d 100644
--- a/styles/memphis-diorama/demo/CREDITS
+++ b/styles/memphis-diorama/demo/CREDITS
@@ -1,4 +1,5 @@
Four Seasons in Pomelo Town (柚子城的四季) — Memphis Diorama (Lemo-Opuscar)
+Style and demo by Eian (https://github.com/YIAN6557), contributed to Lemo-Opuscar in pull request #14.
No AI-generated images, no stock footage, no photographs, no samples. Every shape, colour, shadow, pattern, letter
and sound is made by code in this folder: the scene is three.js geometry with a flat ShaderMaterial and an outline
diff --git a/styles/memphis-diorama/demo/main.js b/styles/memphis-diorama/demo/main.js
index d651118..33ec8d9 100644
--- a/styles/memphis-diorama/demo/main.js
+++ b/styles/memphis-diorama/demo/main.js
@@ -1,4 +1,4 @@
-// Four Seasons in Pomelo Town (柚子城的四季): one river bend through four seasons in one take, 10 s each.
+// Four Seasons in Pomelo Town: one river bend through four seasons in one take, 10 s each.
// Every change of season starts with the big tree on the plaza squatting down and springing back; a wave spreads from it.
// Page contract (core/README.md): window.READY, window.render(t), window.DUR, window.TEXTS(t).
import * as THREE from 'three';
@@ -16,9 +16,9 @@ const seg = (t, a, b) => c01((t - a) / (b - a));
const backOut = (x) => { x = c01(x); const s = 1.9; return 1 + (s + 1) * Math.pow(x - 1, 3) + s * Math.pow(x - 1, 2); };
const R = rng(2026);
const rr = (a, b) => a + (b - a) * R();
-const R2 = rng(77), rr2 = (a, b) => a + (b - a) * R2(); // 秋冬新加的东西用另一条随机数,不打乱春夏的构图
+const R2 = rng(77), rr2 = (a, b) => a + (b - a) * R2(); // autumn/winter additions use a separate RNG so spring/summer layout stays put
-// ---------- 四季的颜色:每个会变的材质带一组 [春, 夏, 秋, 冬] ----------
+// ---------- Season colours: each changing material carries [spring, summer, autumn, winter] ----------
const SEASONAL = [];
function S(cols, o = {}) {
const pats = o.patCols;
@@ -30,7 +30,7 @@ const cache = new Map();
const M = (hex, o = {}) => { const k = hex + JSON.stringify(o); if (!cache.has(k)) cache.set(k, flat(hex, o)); return cache.get(k); };
const lt = (hex, k) => '#' + new THREE.Color(hex).lerp(new THREE.Color(k > 0 ? '#FFFFFF' : '#3A2F66'), Math.abs(k)).getHexString();
-// 树冠:主色 + 朝太阳那侧的亮色团块 + 春天的小花点
+// Canopy: base colour + bright clumps on the sun side + spring blossom dots
const CS = (cols, pats, bloom) => ({ main: S(cols, { pat: 1, patCols: pats, patScale: 0.75 }), hi: S(cols.map((c, i) => (i === 3 ? '#FFFFFF' : lt(c, i === 0 ? 0.3 : 0.17))), { pat: 1, patCols: pats.map((c, i) => (i === 3 ? '#DCE6FA' : lt(c, i === 0 ? 0.28 : 0.15))), patScale: 0.6 }), bloom });
const MAT = {
grass: S(['#9DE8A6', '#6FD889', '#D6E68E', '#FBFCFF'], { pat: 1, patCols: ['#7DDC8C', '#47B868', '#BCD26E', '#E3EAFA'], patScale: 2.4 }),
@@ -53,9 +53,9 @@ const CROWN = {
teal: CS(['#62E0C8', '#14B8A0', '#FF9C6B', '#CDEFF0'], ['#B8F0DC', '#0E9A86', '#FF7A45', '#FFFFFF']),
};
-// ---------- 地形:草地 + 弯弯的小河 ----------
-const xr = (z) => -8 + 9 * Math.sin(z / 28 + 0.6); // 河中线
-const RW = 5.5; // 河半宽
+// ---------- Terrain: grass + a winding river ----------
+const xr = (z) => -8 + 9 * Math.sin(z / 28 + 0.6); // river centre line
+const RW = 5.5; // river half-width
const ground = new THREE.Mesh(new THREE.PlaneGeometry(600, 600).rotateX(-Math.PI / 2), MAT.grass); ground.receiveShadow = true; W.add(ground);
function ribbon(halfW, y, mat, off = 0, wob = 0, z0 = -160, z1 = 160, n = 320) {
const pos = [], idx = [];
@@ -69,7 +69,7 @@ ribbon(RW, 0.08, MAT.water);
ribbon(RW * 0.42, 0.1, MAT.deep, -0.6, 0.5);
const foamMat = new THREE.MeshBasicMaterial({ color: '#FFFFFF' });
for (const sd of [-1, 1]) ribbon(0.16, 0.11, foamMat, sd * (RW - 0.32), 0.16).userData.noOutline = true;
-// 草地:深浅不一的草块,打破大面积的平
+// Grass: patches of varied shade to break up the flat expanse
{
const pa = S(['#B3F0A8', '#74DA8E', '#E4EEA2', '#FFFFFF'], { pat: 1, patCols: ['#95E596', '#5ACB7A', '#CCDC80', '#E3EAFA'], patScale: 2.2 });
const pb = S(['#8EE292', '#54C878', '#F2D27A', '#F2F5FF'], { pat: 1, patCols: ['#74D886', '#3FB868', '#E2BC5E', '#E3EAFA'], patScale: 2.2 });
@@ -79,8 +79,8 @@ for (const sd of [-1, 1]) ribbon(0.16, 0.11, foamMat, sd * (RW - 0.32), 0.16).us
}
}
-// ---------- 田:一格一格,春天油菜花 / 灌水的秧田,夏天全是绿稻子 ----------
-const ROWS = [], HAYSPOTS = []; // 每块田的禾苗(春天矮,换季时长高)
+// ---------- Fields: a grid of plots, rapeseed / flooded paddies in spring, all green rice in summer ----------
+const ROWS = [], HAYSPOTS = []; // crop rows per plot (short in spring, grow at the season change)
function mergeBoxes(list) {
const pos = [], nor = [], idx = []; let base = 0;
for (const [w, h, d, x, y, z] of list) {
@@ -102,7 +102,7 @@ function plot(x0, z0, w, d, kind, near) {
ROWS.push({ m, kind, p: m.position.clone(), h0: 1.1, h1: 0.001 });
}
const PW = 10, PD = 8;
-const avoid = []; // 村子、广场、池塘这些地方不种田
+const avoid = []; // no fields on the village, plaza or pond
const blocked = (x, z, w, d) => avoid.some(([a, b, c, e]) => x < c && x + w > a && z < e && z + d > b);
avoid.push([5, -22, 76, 27], [18, 5, 66, 30]);
for (let gx = -130; gx < 130; gx += PW + 0.7) for (let gz = -120; gz < 120; gz += PD + 0.7) {
@@ -115,7 +115,7 @@ for (let gx = -130; gx < 130; gx += PW + 0.7) for (let gz = -120; gz < 120; gz +
plot(gx, gz, PW, PD, rape ? 'rape' : 'sprout', near);
}
-// ---------- 树 ----------
+// ---------- Trees ----------
const TREES = [], BLOOMS = [];
function tree(x, z, kind, cs, s = 1) {
const g = new THREE.Group(); g.position.set(x, 0, z); g.scale.setScalar(s); W.add(g);
@@ -140,7 +140,7 @@ function tree(x, z, kind, cs, s = 1) {
}
TREES.push({ g, c, lobes, p: g.position.clone(), crown: cs, ph: R() * 6.28 }); return g;
}
-// 河岸:粉、白两种花树交替
+// Riverbank: alternating pink and white blossom trees
for (let z = -110; z < 110; z += 9.5) for (const side of [-1, 1]) {
if (Math.abs(z + 4) < 6) continue;
const x = xr(z) + side * (RW + 3.4);
@@ -149,8 +149,8 @@ for (let z = -110; z < 110; z += 9.5) for (const side of [-1, 1]) {
tree(x, z, pink ? 'cloud' : 'round', pink ? CROWN.pink : CROWN.white, rr(0.85, 1.05));
}
-// ---------- 村子:一条巷子 + 两排小房子 + 银杏 ----------
-const LZ = -4; // 巷子
+// ---------- Village: a lane + two rows of houses + ginkgos ----------
+const LZ = -4; // lane
mesh(box(70, 0.14, 4.2), MAT.lane, 3 + 35, 0, LZ, W).castShadow = false;
const WALLS = ['#FFEFA8', '#FFB8D9', '#5EDFB0', '#B9A0FF', '#FF9C6B', '#FFFFFF', '#5CC8FF'];
const ROOFS = [['#FF5A5F', '#FFE0DF'], ['#2F5BFF', '#FFFFFF'], ['#14B8A0', '#B8F0DC'], ['#FFD234', '#F39C12'], ['#4A4468', '#8D86C0']];
@@ -158,18 +158,18 @@ const CHIMNEYS = [], WINS = [], DOORLAMPS = [];
function house(x, z, face, w, d, i) {
const g = new THREE.Group(); g.position.set(x, 0, z); W.add(g);
const wc = WALLS[i % WALLS.length], two = i % 3 === 1, h = two ? 6.4 : 4.0, B = 0.45, F = face * (d / 2);
- mesh(box(w + 0.5, B, d + 0.5), M('#DCD4EE', { pat: 1, patCol: '#C9C0E3', patScale: 0.32 }), 0, 0, 0, g); // 台基
- mesh(box(w, h, d), M(wc, { pat: 6, patCol: lt(wc, -0.07), patScale: 0.5 }), 0, B, 0, g); // 墙(横向木板)
+ mesh(box(w + 0.5, B, d + 0.5), M('#DCD4EE', { pat: 1, patCol: '#C9C0E3', patScale: 0.32 }), 0, 0, 0, g); // plinth
+ mesh(box(w, h, d), M(wc, { pat: 6, patCol: lt(wc, -0.07), patScale: 0.5 }), 0, B, 0, g); // walls (horizontal boards)
for (const sx of [-1, 1]) for (const sz of [-1, 1]) mesh(box(0.24, h, 0.24), M('#FFFFFF'), sx * (w / 2 - 0.04), B, sz * (d / 2 - 0.04), g);
- // 屋顶:两片坡 + 屋脊 + 山墙
+ // roof: two slopes + ridge + gables
const [rc, rp] = ROOFS[(i * 3 + 1) % ROOFS.length], run = d / 2 + 0.7, rise = 2.5, Ls = Math.hypot(run, rise), th = Math.atan2(rise, run);
const roofM = S([rc, rc, rc, '#FFFFFF'], { pat: 6, patCols: [rp, rp, rp, '#E3EAFA'], patScale: 0.55 });
for (const sd of [-1, 1]) { const sl = mesh(new THREE.BoxGeometry(w + 1.1, 0.3, Ls), roofM, 0, B + h + rise / 2 + 0.05, sd * run / 2, g); sl.rotation.x = sd * th; }
mesh(new THREE.CylinderGeometry(0.2, 0.2, w + 1.25, 10).rotateZ(Math.PI / 2), M(lt(rc, -0.15)), 0, B + h + rise + 0.12, 0, g);
const gs = new THREE.Shape(); gs.moveTo(-d / 2, 0); gs.lineTo(d / 2, 0); gs.lineTo(0, rise - 0.15); gs.closePath();
mesh(new THREE.ExtrudeGeometry(gs, { depth: w - 0.02, bevelEnabled: false }).translate(0, 0, -(w - 0.02) / 2).rotateY(Math.PI / 2), M(wc), 0, B + h, 0, g);
- WINS.push({ m: mesh(new THREE.CircleGeometry(0.42, 18).rotateY(Math.PI / 2), flat('#BFE4FF', { lit: true }), w / 2 + 0.01, B + h + 0.8, 0, g).material, T: 35.4 + rr2(0, 3.0) }); // 山墙小圆窗
- // 窗:白框 + 玻璃 + 彩色百叶 + 花箱
+ WINS.push({ m: mesh(new THREE.CircleGeometry(0.42, 18).rotateY(Math.PI / 2), flat('#BFE4FF', { lit: true }), w / 2 + 0.01, B + h + 0.8, 0, g).material, T: 35.4 + rr2(0, 3.0) }); // round gable window
+ // windows: white frame + glass + coloured shutters + flower box
const shut = ['#2F5BFF', '#FF5A5F', '#14B8A0', '#FFD234', '#FF7EB3'][i % 5];
const floors = two ? [B + 1.55, B + 4.1] : [B + 1.55];
for (const fy of floors) for (const sx of [-w / 4 - 0.15, w / 4 + 0.15]) {
@@ -182,7 +182,7 @@ function house(x, z, face, w, d, i) {
[-0.42, -0.14, 0.14, 0.42].forEach((k, j) => mesh(new THREE.SphereGeometry(0.17, 8, 6), M(['#FF5A5F', '#FFD234', '#FF7EB3', '#7FB2FF'][(i + j) % 4]), sx + k, fy - 0.05, F + face * 0.28, g));
}
}
- // 门:门框 + 台阶 + 小雨棚 + 门灯 + 两盆花
+ // door: frame + step + awning + lamp + two pots of flowers
const dc = ['#2F5BFF', '#FF5A5F', '#14B8A0'][i % 3];
mesh(box(1.25, 2.15, 0.1), M('#FFFFFF'), 0, B, F + face * 0.03, g);
mesh(box(0.95, 1.95, 0.16), M(dc, { pat: 6, patCol: lt(dc, -0.18), patScale: 0.3 }), 0, B, F + face * 0.05, g);
@@ -191,7 +191,7 @@ function house(x, z, face, w, d, i) {
const aw = mesh(box(1.7, 0.1, 0.8), M(['#FF5A5F', '#2F5BFF', '#FFD234'][(i + 1) % 3], { pat: 4, patCol: '#FFFFFF', patScale: 0.28 }), 0, B + 2.3, F + face * 0.42, g); aw.rotation.x = face * 0.3;
DOORLAMPS.push({ m: mesh(new THREE.SphereGeometry(0.16, 10, 8), flat('#FFE38A', { lit: true }), 0.85, B + 2.0, F + face * 0.12, g).material, p: V3(x + 0.85, B + 2.0, z + F + face * 2.3), T: 34.6 + rr2(0, 3.0) });
for (const sx of [-1.0, 1.0]) { mesh(new THREE.CylinderGeometry(0.22, 0.16, 0.38, 10), M('#FF9C6B'), sx, B, F + face * 0.55, g).geometry.translate(0, 0.19, 0); mesh(new THREE.SphereGeometry(0.32, 10, 8), M('#3CBE7E', { pat: 1, patCol: '#FF7EB3', patScale: 0.18 }), sx, B + 0.62, F + face * 0.55, g); }
- if (two) { // 二楼小阳台
+ if (two) { // first-floor balcony
mesh(box(2.4, 0.16, 0.9), M('#FFFFFF'), 0, B + 3.0, F + face * 0.45, g);
for (let k = -1.1; k <= 1.11; k += 0.37) mesh(box(0.07, 0.6, 0.07), M('#FFFFFF'), k, B + 3.16, F + face * 0.85, g);
mesh(box(2.4, 0.08, 0.08), M('#FFFFFF'), 0, B + 3.76, F + face * 0.85, g);
@@ -204,7 +204,7 @@ let hi = 0;
for (const x of [12, 21.5, 31, 40.5, 50, 59.5, 69]) house(x, LZ - 7.5, 1, rr(7, 8.4), 6, hi++);
for (const x of [12, 21.5, 69]) house(x, LZ + 7.5, -1, rr(7, 8.4), 6, hi++);
for (let x = 7; x < 74; x += 9.5) { tree(x + 4.7, LZ - 3.2, 'egg', CROWN.ginkgo, 0.75); }
-// 小广场 + 大树
+// Plaza + big tree
const PLAZA = V3(31, 0, 15);
mesh(new THREE.CylinderGeometry(8, 8, 0.14, 40), MAT.lane, PLAZA.x, 0.07, PLAZA.z, W).castShadow = false;
const bigTree = new THREE.Group(); bigTree.position.copy(PLAZA); W.add(bigTree);
@@ -214,8 +214,8 @@ for (const [dx, dy, dz, r] of [[0, 7.2, 0, 3.6], [2.6, 6.0, 0.8, 2.6], [-2.5, 6.
for (const [dx, dy, dz, r] of [[-1.6, 9.0, 1.3, 1.4], [-2.9, 7.4, 1.4, 1.1], [-0.6, 10.6, 0.4, 0.9]]) mesh(new THREE.SphereGeometry(r, 16, 12), CROWN.big.hi, dx, dy, dz, bigC);
for (let i = 0; i < 40; i++) { const u = R() * 6.28, v = R() * 1.3 - 0.2, r = 3.5; const b = mesh(new THREE.SphereGeometry(0.22, 8, 6), M(CROWN.big.bloom[i % 2]), Math.cos(u) * Math.cos(v) * r * 1.05, 7.0 + Math.sin(v) * r, Math.sin(u) * Math.cos(v) * r, bigC); b.castShadow = false; BLOOMS.push({ m: b, p: PLAZA.clone() }); }
TREES.push({ g: bigTree, c: bigC, p: PLAZA.clone(), crown: CROWN.big, ph: 0, big: true });
-for (const [x, z] of [[24, 9], [38, 9], [25, 21], [37, 21]]) mesh(box(1.6, 0.5, 0.6), M('#2F5BFF'), x, 0.14, z, W); // 长凳
-// 池塘
+for (const [x, z] of [[24, 9], [38, 9], [25, 21], [37, 21]]) mesh(box(1.6, 0.5, 0.6), M('#2F5BFF'), x, 0.14, z, W); // benches
+// Pond
const POND = V3(54, 0, 18), PR = 7.5;
mesh(new THREE.CylinderGeometry(PR + 0.9, PR + 0.9, 0.16, 48), MAT.bank, POND.x, 0, POND.z, W).castShadow = false;
mesh(new THREE.CylinderGeometry(PR, PR, 0.2, 48), MAT.water, POND.x, 0, POND.z, W).castShadow = false;
@@ -234,7 +234,7 @@ for (let i = 0; i < 16; i++) {
LOTUS.push({ g: f, p: f.position.clone(), d: i * 0.07 });
}
}
-// 桥:三段,中间拱起
+// Bridge: three spans, arched in the middle
const BZ = LZ, BX = xr(BZ);
const stone = M('#FFF4DD', { pat: 1, patCol: '#F2DFC2', patScale: 0.6 });
for (const [dx, len, rot, y] of [[-6.4, 5.4, 0.16, 0.0], [0, 7.6, 0, 0.86], [6.4, 5.4, -0.16, 0.0]]) {
@@ -245,7 +245,7 @@ for (const s of [-1, 1]) for (let dx = -8; dx <= 8; dx += 2) {
const y = Math.abs(dx) < 4 ? 1.36 : 1.36 - (Math.abs(dx) - 4) * 0.16 - 0.1;
mesh(box(0.28, 0.75, 0.28), M('#FF5A5F'), BX + dx, y, BZ + s * 1.65, W);
}
-// 小路:巷子 → 广场 → 池塘,路边一簇簇花丛
+// Path: lane → plaza → pond, flower clumps along the way
const BUSHES = [];
{
const pts = [[24, -2], [27, 8], [38, 18], [46, 19], [50, 26], [44, 36], [30, 42], [14, 44]];
@@ -262,7 +262,7 @@ const BUSHES = [];
}
tree(4, 34, 'round', CROWN.teal, 1.1); tree(58, 42, 'cone', CROWN.teal, 1.0); tree(26, 52, 'egg', CROWN.ginkgo, 1.0);
}
-// 广场的冰室遮阳伞(夏天才撑开)
+// Ice-shop parasols on the plaza (open only in summer)
const UMB = [];
for (const [x, z, col] of [[26, 12, '#FF5A5F'], [36, 13, '#2F5BFF'], [32, 20, '#FFD234']]) {
const g = new THREE.Group(); g.position.set(x, 0.14, z); W.add(g);
@@ -272,13 +272,13 @@ for (const [x, z, col] of [[26, 12, '#FF5A5F'], [36, 13, '#2F5BFF'], [32, 20, '#
UMB.push({ g, p: g.position.clone() });
}
-// ---------- 会动的小东西 ----------
-// 小船:顺着河慢慢漂
+// ---------- Small moving things ----------
+// Boats: drift slowly downstream
const boat = new THREE.Group(); W.add(boat);
mesh(new THREE.CylinderGeometry(0.9, 0.6, 4.2, 12, 1).rotateZ(Math.PI / 2).scale(1, 0.45, 0.75), M('#FF9C6B'), 0, 0.35, 0, boat);
mesh(new THREE.ConeGeometry(0.9, 0.5, 12, 1, true).rotateX(Math.PI).translate(0, 1.6, 0).scale(1.3, 1, 1), M('#FFD234', { pat: 4, patCol: '#FFFFFF', patScale: 0.4 }), 0.6, 0, 0, boat);
const boatman = person(boat, { col: '#2F5BFF', hat: '#FFD234' }); boatman.g.position.set(-0.9, 0.3, 0); boatman.g.scale.setScalar(0.8);
-// 鸭子:池塘里绕圈
+// Ducks: circle the pond
const DUCKS = [0, 1, 2].map((i) => {
const g = new THREE.Group(); W.add(g); g.scale.setScalar(0.9 - i * 0.18);
mesh(new THREE.SphereGeometry(0.55, 14, 10).scale(1.3, 0.8, 0.9), M('#FFFFFF'), 0, 0.42, 0, g);
@@ -286,11 +286,11 @@ const DUCKS = [0, 1, 2].map((i) => {
mesh(new THREE.ConeGeometry(0.12, 0.34, 8).rotateZ(-Math.PI / 2), M('#FF9C6B'), 0.98, 0.9, 0, g);
return g;
});
-// 巷子里散步的人(远景点缀)
+// People strolling in the lane (background detail)
const WALKERS = [
person(W, { col: '#FF5A5F' }), person(W, { col: '#14B8A0' }), person(W, { col: '#B9A0FF', hat: '#FFD234' }),
];
-// 放风筝(春):田埂上的人 + 两只风筝
+// Kite flying (spring): people on the field ridge + two kites
const flyer = person(W, { col: '#FF7EB3', hat: '#2F5BFF' }); flyer.g.position.set(-32, 0.12, 6.35); flyer.g.rotation.y = 0.8;
const KITES = [[-40, 22, -10, '#FF5A5F', '#FFD234'], [-58, 26, 18, '#2F5BFF', '#FF7EB3']].map(([x, y, z, c1, c2], i) => {
const g = new THREE.Group(); W.add(g);
@@ -300,21 +300,21 @@ const KITES = [[-40, 22, -10, '#FF5A5F', '#FFD234'], [-58, 26, 18, '#2F5BFF', '#
return { g, k, tail, line, base: V3(x, y, z), ph: i * 2.1, hand: i === 0 ? null : V3(-60, 1.3, 26) };
});
const flyer2 = person(W, { col: '#FFD234', hat: '#FF5A5F' }); flyer2.g.position.set(-60, 0.12, 27.6);
-// 燕子
+// Swallows
const SWALLOWS = [0, 1, 2, 3, 4].map((i) => {
const g = new THREE.Group(); W.add(g); const wm = M(INK);
const wl = mesh(box(0.15, 0.06, 1.1).translate(0, 0, 0.55), wm, 0, 0, 0, g), wr = mesh(box(0.15, 0.06, 1.1).translate(0, 0, -0.55), wm, 0, 0, 0, g);
mesh(new THREE.ConeGeometry(0.2, 0.9, 6).rotateZ(-Math.PI / 2), wm, 0, 0, 0, g);
return { g, wl, wr, r: rr(18, 34), h: rr(10, 16), w: rr(0.35, 0.55) * (i % 2 ? 1 : -1), ph: rr(0, 6.28), c: V3(rr(-30, 30), 0, rr(-10, 25)) };
});
-// 花瓣
+// Petals
const pinkTrees = TREES.filter((t) => t.crown === CROWN.pink || t.crown === CROWN.white || t.big);
const petalMat = [new THREE.MeshBasicMaterial({ color: '#FF9EC8', side: THREE.DoubleSide }), new THREE.MeshBasicMaterial({ color: '#FFFFFF', side: THREE.DoubleSide })];
const PETALS = Array.from({ length: 110 }, (_, i) => {
const m = new THREE.Mesh(new THREE.CircleGeometry(0.32, 6).scale(1, 0.6, 1), petalMat[i % 2]); m.userData.noOutline = true; W.add(m);
return { m, t: pinkTrees[i % pinkTrees.length], ph: R() * 4, sx: rr(-1, 1), sz: rr(-1, 1) };
});
-// 芦苇:河岸、池塘边一丛丛
+// Reeds: clumps along the river and pond
const REEDS = [];
{
const reedM = S(['#7ED957', '#2FA866', '#E0B04A', '#C9A27A']);
@@ -330,29 +330,29 @@ const REEDS = [];
for (let z = -100; z < 100; z += rr(4.5, 8)) for (const sd of [-1, 1]) { if (R() < 0.45 || Math.abs(z + 4) < 7) continue; clump(xr(z) + sd * (RW + 0.25), z); }
for (let k = 0; k < 7; k++) { const a = k / 7 * 6.28 + 0.3; if (k % 3 === 1) continue; clump(POND.x + Math.cos(a) * (PR + 0.2), POND.z + Math.sin(a) * (PR + 0.2)); }
}
-// 水面的小波纹:孟菲斯式的白色小曲线,顺流往下
+// Ripples: little white Memphis squiggles, drifting downstream
const squigGeo = (() => { const pts = []; for (let i = 0; i <= 8; i++) pts.push(V3((i - 4) * 0.24, 0, Math.sin(i * 1.5) * 0.13)); return new THREE.TubeGeometry(new THREE.CatmullRomCurve3(pts), 28, 0.06, 5); })();
const GLINTS = Array.from({ length: 70 }, () => {
const m = new THREE.Mesh(squigGeo, foamMat); m.userData.noOutline = true; W.add(m);
return { m, z0: rr(-110, 110), off: rr(-0.75, 0.75), ph: R(), sp: rr(2.0, 3.0) };
});
const PGL = Array.from({ length: 9 }, (_, i) => { const m = new THREE.Mesh(squigGeo, foamMat); m.userData.noOutline = true; W.add(m); return { m, a: i / 9 * 6.28, r: rr(1.5, PR - 1.5), ph: R() }; });
-// 夏天的过云雨:一朵灰紫的云从西往东飘,下面拖着雨丝,水面一圈圈涟漪
+// Summer shower: a grey-violet cloud drifts west to east, trailing rain, rings on the water
const rainCloud = new THREE.Group(); W.add(rainCloud);
for (const [dx, dy, dz, r] of [[0, 0, 0, 7], [6, -1, 2, 5.5], [-6, -1.2, -1, 5.5], [2, 3, -2, 5], [-3, 2, 3, 4.5]]) { const c = mesh(new THREE.SphereGeometry(r, 18, 12).scale(1, 0.62, 0.9), M('#E4DEF6', { lit: true, shadow: false }), dx, dy, dz, rainCloud); c.castShadow = true; c.receiveShadow = false; }
const rainMat = new THREE.MeshBasicMaterial({ color: '#6E9BEA', transparent: true, opacity: 0.85 });
const DROPS = Array.from({ length: 300 }, () => { const m = new THREE.Mesh(new THREE.BoxGeometry(0.14, 2.6, 0.14), rainMat); m.userData.noOutline = true; W.add(m); return { m, dx: rr(-13, 13), dz: rr(-9, 9), ph: R() }; });
const ringMat = new THREE.MeshBasicMaterial({ color: '#FFFFFF', transparent: true, depthWrite: false });
const RINGS = Array.from({ length: 160 }, () => { const m = new THREE.Mesh(new THREE.RingGeometry(0.8, 1, 24).rotateX(-Math.PI / 2), ringMat.clone()); m.userData.noOutline = true; W.add(m); return { m, dx: rr(-13, 13), dz: rr(-9, 9), ph: R() }; });
-// 白云(高处慢飘,投下影子)
+// White clouds (drift high, cast shadows)
const CLOUDS = [[-60, 46, -40, 1.0], [40, 52, -70, 1.3], [90, 48, 40, 1.1]].map(([x, y, z, s]) => {
const g = new THREE.Group(); g.position.set(x, y, z); g.scale.setScalar(s * 4); W.add(g);
for (const [dx, dy, dz, r] of [[0, 0, 0, 1.4], [1.3, -0.2, 0.2, 1.1], [-1.3, -0.25, 0, 1.0], [0.5, 0.6, -0.2, 0.9]]) { const m = mesh(new THREE.SphereGeometry(r, 18, 12).scale(1, 0.7, 1), M('#FFFFFF', { lit: true, shadow: false }), dx, dy, dz, g); m.receiveShadow = false; }
return { g, x0: x };
});
-// ---------- 秋、冬才出现的东西 ----------
-// 稻草垛:秋天收完稻子一垛垛冒出来,冬天顶上积雪
+// ---------- Autumn- and winter-only things ----------
+// Haystacks: pop up after the autumn harvest, snow-capped in winter
const HAY = [];
{
const body = M('#FFC23A', { pat: 6, patCol: '#F39C12', patScale: 0.32 });
@@ -364,13 +364,13 @@ const HAY = [];
HAY.push({ g, T: 22.0 + rr2(0, 5.5) });
}
}
-// 落叶:秋天从每棵树上飘下来
+// Falling leaves: drift from every tree in autumn
const leafMat = ['#FF7A45', '#FFD21F', '#FF5A5F', '#FFB020'].map((c) => new THREE.MeshBasicMaterial({ color: c, side: THREE.DoubleSide }));
const LEAVES = Array.from({ length: 160 }, (_, i) => {
const m = new THREE.Mesh(new THREE.CircleGeometry(0.4, 4).scale(0.7, 1, 1), leafMat[i % 4]); m.userData.noOutline = true; W.add(m);
return { m, t: TREES[(i * 7) % TREES.length], ph: R2() * 4, sx: rr2(-1, 1), sz: rr2(-1, 1) };
});
-// 大雁:排成人字往西南飞
+// Geese: V formation flying south-west
const GEESE = Array.from({ length: 9 }, (_, i) => {
const g = new THREE.Group(); W.add(g); const m = M(INK);
const wl = mesh(box(0.22, 0.07, 1.5).translate(0, 0, 0.75), m, 0, 0, 0, g), wr = mesh(box(0.22, 0.07, 1.5).translate(0, 0, -0.75), m, 0, 0, 0, g);
@@ -379,16 +379,16 @@ const GEESE = Array.from({ length: 9 }, (_, i) => {
const row = Math.ceil(i / 2), side = i === 0 ? 0 : (i % 2 ? 1 : -1);
return { g, wl, wr, off: V3(row * 2.6, 0, side * row * 2.1), ph: i * 0.7 };
});
-// 雪
+// Snow
const flakeGeo = new THREE.IcosahedronGeometry(0.27, 0), snowMat = new THREE.MeshBasicMaterial({ color: '#FFFFFF' });
const SNOW = Array.from({ length: 1000 }, () => { const m = new THREE.Mesh(flakeGeo, snowMat); m.userData.noOutline = true; W.add(m); return { m, x: rr2(-60, 115), z: rr2(-55, 80), ph: R2(), sp: rr2(0.8, 1.2) }; });
-// 烟囱冒烟(冬天)
+// Chimney smoke (winter)
W.updateMatrixWorld(true);
const SMOKE = CHIMNEYS.flatMap((ch, ci) => {
const p = ch.getWorldPosition(V3(0, 0, 0));
return [0, 1, 2, 3].map((k) => { const m = mesh(new THREE.SphereGeometry(0.55, 12, 8), M('#FFFFFF', { lit: true, shadow: false }), p.x, p.y, p.z, W); m.castShadow = false; return { m, p: V3(p.x, p.y + 2.9, p.z), ph: k / 4 + ci * 0.37 }; });
});
-// 广场上的雪人
+// Snowman on the plaza
const snowman = new THREE.Group(); snowman.position.set(26.0, 0.14, 18.4); snowman.rotation.y = 0.8; W.add(snowman);
mesh(new THREE.SphereGeometry(1.0, 18, 12), M('#FFFFFF'), 0, 0.9, 0, snowman);
mesh(new THREE.SphereGeometry(0.68, 16, 10), M('#FFFFFF'), 0, 2.2, 0, snowman);
@@ -398,12 +398,12 @@ mesh(new THREE.TorusGeometry(0.52, 0.15, 8, 20).rotateX(Math.PI / 2), M('#FF5A5F
mesh(new THREE.CylinderGeometry(0.66, 0.66, 0.08, 16), M('#2F5BFF'), 0, 2.78, 0, snowman);
mesh(new THREE.CylinderGeometry(0.42, 0.42, 0.62, 16), M('#2F5BFF', { pat: 6, patCol: '#FFD234', patScale: 0.25 }), 0, 3.1, 0, snowman);
-// ---------- 时间线 ----------
-const DUR = 40;
+// ---------- Timeline ----------
+const DUR = 45;
const WAVES = [
- { t0: 9.3, t1: 11.9, c: [PLAZA.x, PLAZA.z] }, // 春 → 夏:从大树扫开
- { t0: 19.3, t1: 21.9, c: [PLAZA.x, PLAZA.z] }, // 夏 → 秋
- { t0: 29.3, t1: 31.9, c: [PLAZA.x, PLAZA.z] }, // 秋 → 冬:三次都是大树一蹲,波从大树扫开
+ { t0: 9.3, t1: 11.9, c: [PLAZA.x, PLAZA.z] }, // spring → summer: sweeps out from the big tree
+ { t0: 19.3, t1: 21.9, c: [PLAZA.x, PLAZA.z] }, // summer → autumn
+ { t0: 29.3, t1: 31.9, c: [PLAZA.x, PLAZA.z] }, // autumn → winter: each time the tree squats and the wave sweeps out from it
];
const WAVE_MAX = 240;
function seasonState(t) {
@@ -412,11 +412,11 @@ function seasonState(t) {
const r = w && t > w.t0 ? WAVE_MAX * io(seg(t, w.t0, w.t1)) : -1;
return { i, r, c: w ? w.c : [0, 0] };
}
-// 某个位置被换季波扫过之后的进度(0 → 1),用于长高、开花、撑伞这些“动作”
+// progress (0 → 1) after the season wave passes a point; drives growing, blooming, opening parasols
const passed = (st, p, len = 1) => { if (st.r < 0) return 0; const d = Math.hypot(p.x - st.c[0], p.z - st.c[1]); return c01((st.r - d) / (16 * len)); };
const CENTER = V3(22, 0, 9);
function camAt(t) {
- // 前 18 秒和春夏版一样;之后镜头慢慢减速到 0.3 倍,秋冬还是同一个构图
+ // first 18 s match the spring/summer cut; then the camera eases to 0.3x, same framing through autumn/winter
const te = t < 18 ? t : t < 22 ? t - 0.7 * (t - 18) ** 2 / 8 : 20.6 + 0.3 * (t - 22);
const a = 0.1 + 0.02 * te, Rr = 92 - 0.4 * te, H = 70 - 0.3 * te;
return { pos: V3(CENTER.x + Math.sin(a) * Rr, H, CENTER.z + Math.cos(a) * Rr), look: CENTER.clone().add(V3(0, 0, 0)), fov: 30 };
@@ -426,15 +426,17 @@ const TEXT = [
['夏 · 一阵雨过去,荷花开了 Summer · a passing shower, lotus in bloom', '小暑 Minor Heat · 07.07 柚子城 · 河湾 Pomelo Town · River Bend'],
['秋 · 稻子黄了,大雁往南飞 Autumn · golden rice, geese flying south', '秋分 Autumn Equinox · 09.22 柚子城 · 河湾 Pomelo Town · River Bend'],
['冬 · 下雪了,窗户一盏盏亮起来 Winter · first snow, windows lighting up', '大雪 Major Snow · 12.07 柚子城 · 河湾 Pomelo Town · River Bend'],
+ ['Eian × LemoLab × Claude Opus 5.5', '孟菲斯微缩景观 · MEMPHIS DIORAMA'], // end card: same three lines, over the lit village; the sign-off is line 2, drawn strong
];
const TITLE = '柚子城的四季 Four Seasons in Pomelo Town';
+const SWAPS = [10.45, 20.45, 30.45, 39.3]; // lines 2 and 3 change halfway through each wave, then once more for the end card
setNight(0); setDusk(0); setWave(1e5); setZone([0, 0, 0, 0], 1); setLamps([]); setHalftone(1);
dio.scene.background = new THREE.Color('#8FD6FF');
function place(t) {
const st = seasonState(t), si = Math.min(st.i, 1);
- // 材质:当前季 → 下一季
+ // materials: this season → next
for (const m of SEASONAL) {
const k = Math.min(st.i, m.userData.cols.length - 1), k2 = Math.min(k + 1, m.userData.cols.length - 1);
m.uniforms.uCol.value.copy(m.userData.cols[k]); m.uniforms.uCol2.value.copy(m.userData.cols[k2]);
@@ -443,12 +445,12 @@ function place(t) {
setSeason(st.c[0], st.c[1], st.r);
const at = (n, p, len) => (st.i >= n ? 1 : st.i === n - 1 ? passed(st, p, len) : 0);
const summer = (p, len) => at(1, p, len), autumn = (p, len) => at(2, p, len), winter = (p, len) => at(3, p, len);
- const popOf = (p) => [1, 2, 3].reduce((a, n) => a + Math.sin(Math.PI * c01(at(n, p) * 1.4)), 0); // 每道波扫过时弹一下
- // 禾苗:春天油菜高、秧苗矮;波扫过之后一起长成绿稻子(带一点回弹)
+ const popOf = (p) => [1, 2, 3].reduce((a, n) => a + Math.sin(Math.PI * c01(at(n, p) * 1.4)), 0); // bounce as each wave passes
+ // crops: tall rapeseed, short seedlings in spring; all grow into green rice once the wave passes (with a little overshoot)
for (const r of ROWS) { const k = summer(r.p); r.m.visible = k < 0.99; r.m.scale.y = lerp(r.h0, r.h1, sm(k)) * (1 + 0.04 * Math.sin(t * 2.2 + r.p.x * 0.3)); }
- // 树:风里轻轻摇;波扫过时弹一下
+ // trees: sway gently in the wind; bounce as the wave passes
for (const tr of TREES) { const pop = tr.big ? 0 : popOf(tr.p) * 0.12; tr.c.rotation.z = (tr.big ? 0.012 : 0.03) * Math.sin(t * 1.3 + tr.ph); tr.c.rotation.x = 0.015 * Math.sin(t * 1.1 + tr.ph * 2); tr.c.scale.setScalar(1 + pop); }
- // 大树往下一蹲(0.5 秒),再弹起来,这一季就变了
+ // the big tree squats (0.5 s) and springs back: the season changes
{
let sy = 1;
for (const w of WAVES) {
@@ -457,18 +459,18 @@ function place(t) {
}
bigTree.scale.set(1 / Math.sqrt(sy), sy, 1 / Math.sqrt(sy));
}
- // 荷叶长大,雨后荷花开
+ // lotus leaves grow, flowers open after the rain
for (const p of PADS) { const w = sm(winter(p.p)); p.m.scale.setScalar(Math.max(lerp(p.s0, 1, backOut(summer(p.p))) * (1 - w), 0.001)); p.m.visible = w < 0.99; }
for (const l of LOTUS) { const wilt = st.i >= 2 ? sm(seg(t, 22.4 + l.d * 3, 23.6 + l.d * 3)) : 0, k = (st.i >= 1 ? backOut(seg(t, 16.6 + l.d, 17.3 + l.d)) : 0) * (1 - wilt); l.g.scale.setScalar(Math.max(k, 0.001) * 1.7); l.g.visible = k > 0.01; l.g.rotation.y = 0.2 * Math.sin(t + l.d * 9); }
for (const u of UMB) { const k = backOut(c01(summer(u.p) * 1.2 - 0.2)) * (1 - sm(c01(autumn(u.p) * 1.3))); u.g.scale.set(Math.max(k, 0.001), Math.max(k, 0.001), Math.max(k, 0.001)); u.g.visible = k > 0.01; }
- // 小船
+ // boats
{ const z = -70 + 3.4 * t, x = xr(z) + 1.2, z2 = z + 0.5, h = Math.atan2(-(xr(z2) + 1.2 - x), z2 - z); boat.position.set(x, 0.12 + 0.05 * Math.sin(t * 2), z); boat.rotation.set(0.03 * Math.sin(t * 1.7), h - Math.PI / 2, 0); }
boatman.body.rotation.z = 0.05 * Math.sin(t * 1.6);
- // 鸭子
+ // ducks
DUCKS.forEach((d, i) => { const a = 0.22 * t + i * 0.32, r = 4.6; d.position.set(POND.x + Math.cos(a) * r, 0.1 + 0.03 * Math.sin(t * 3 + i), POND.z + Math.sin(a) * r * 0.8); d.rotation.y = -a - Math.PI / 2 + Math.PI; d.rotation.z = 0.06 * Math.sin(t * 3 + i); });
- // 散步的人
+ // strollers
WALKERS.forEach((p, i) => { const s = ((i * 23 + (i === 1 ? -1 : 1) * 1.15 * t) % 66 + 66) % 66; walk(p, 8 + s, LZ + (i - 1) * 0.9, i === 1 ? Math.PI : 0, t * 2.8 + i); p.g.scale.setScalar(0.9); });
- // 风筝(春天才有,夏天的波扫过来就收了)
+ // kites (spring only, reeled in when the summer wave arrives)
for (const k of KITES) {
const gone = summer(k.base, 1);
const p = k.base.clone().add(V3(1.6 * Math.sin(t * 0.8 + k.ph), 1.2 * Math.sin(t * 1.1 + k.ph) + 30 * gone * gone, 0.8 * Math.cos(t * 0.7 + k.ph)));
@@ -478,23 +480,23 @@ function place(t) {
limb(k.line, hand, p.clone().add(V3(0, -0.4, 0))); k.line.visible = k.g.visible;
}
flyer.arms[1].rotation.set(0, 0, -2.4 + 0.1 * Math.sin(t * 1.3)); flyer2.arms[0].rotation.set(0, 0, -2.3 + 0.1 * Math.sin(t * 1.1));
- // 燕子
+ // swallows
for (const s of SWALLOWS) {
const a = s.ph + s.w * t, p = s.c.clone().add(V3(Math.cos(a) * s.r, s.h + 2 * Math.sin(t * 0.9 + s.ph), Math.sin(a) * s.r * 0.7));
- const away = autumn(p); p.y += 30 * away * away; s.g.visible = away < 0.98; // 秋天的波扫过来,燕子就飞走了
+ const away = autumn(p); p.y += 30 * away * away; s.g.visible = away < 0.98; // swallows leave when the autumn wave arrives
s.g.position.copy(p); s.g.rotation.y = -a - Math.sign(s.w) * Math.PI / 2 * -1 + (s.w > 0 ? Math.PI : 0); s.g.rotation.x = 0.4 * Math.sign(s.w);
const f = 0.7 * Math.sin(t * 14 + s.ph); s.wl.rotation.x = f; s.wr.rotation.x = -f;
}
- // 花瓣:从花树上飘下来,被风往东吹;夏天的波扫过就不再飘
+ // petals: fall from the blossom trees, blown east; stop once the summer wave passes
for (const pe of PETALS) {
const tp = pe.t.p, u = ((t * 0.28 + pe.ph / 4) % 1), age = u * 4;
- const born = Math.floor(t * 0.28 + pe.ph / 4) * 4; // 这一片在哪个周期出生
+ const born = Math.floor(t * 0.28 + pe.ph / 4) * 4; // which cycle this petal was born in
const top = pe.t.big ? 7 : 3.4;
const pos = V3(tp.x + pe.sx * 2 + age * 2.2 + 0.6 * Math.sin(age * 2.5 + pe.ph), top - age * (top / 4) * 0.95 + 0.25, tp.z + pe.sz * 2 + 0.5 * Math.cos(age * 2 + pe.ph));
pe.m.position.copy(pos); pe.m.rotation.set(age * 3 + pe.ph, age * 2, age * 1.3);
pe.m.visible = summer(tp) < 0.02 && t < 9.3 + 2.6;
}
- // 水面亮光:顺流往下
+ // water glints: drift downstream
for (const g of GLINTS) {
const u = (t * 0.35 + g.ph) % 1, z = ((g.z0 + g.sp * t + 110) % 220) - 110, x = xr(z) + g.off * RW;
g.m.position.set(x, 0.13, z); g.m.rotation.y = Math.atan2(-(xr(z + 1) - xr(z)), 1) + Math.PI / 2; g.m.scale.setScalar(Math.max(Math.sin(Math.PI * u), 0.001) * 1.25);
@@ -502,7 +504,7 @@ function place(t) {
for (const g of PGL) { const u = (t * 0.3 + g.ph) % 1, a = g.a + 0.05 * t; g.m.position.set(POND.x + Math.cos(a) * g.r, 0.13, POND.z + Math.sin(a) * g.r * 0.9); g.m.rotation.y = -a; g.m.scale.setScalar(Math.max(Math.sin(Math.PI * u), 0.001)); }
for (const r of REEDS) r.g.rotation.set(0.05 * Math.sin(t * 1.5 + r.ph), 0, 0.07 * Math.sin(t * 1.9 + r.ph));
for (const b of BLOOMS) { const k = summer(b.p); b.m.scale.setScalar(Math.max(1 - sm(k * 1.6), 0.001)); b.m.visible = k < 0.62; }
- // 雨
+ // rain
const cloudX = lerp(-100, 110, seg(t, 11.2, 19.2)), cloudZ = 26;
rainCloud.position.set(cloudX, 17, cloudZ); rainCloud.visible = (st.i >= 1 || t > 11.2) && t < 19.4;
const raining = st.i >= 1 && t > 12.2 && t < 17.8;
@@ -518,7 +520,7 @@ function place(t) {
}
for (const c of CLOUDS) c.g.position.x = c.x0 + 1.2 * t;
for (const b of BUSHES) { b.g.scale.y = b.g.scale.x * (1 + 0.15 * popOf(b.p)); b.g.rotation.y = 0.04 * Math.sin(t * 1.2 + b.ph); }
- // 秋:稻草垛一垛垛冒出来;落叶;大雁
+ // autumn: haystacks pop up one by one; falling leaves; geese
for (const h of HAY) { const k = st.i >= 2 ? backOut(seg(t, h.T, h.T + 0.5)) : 0; h.g.scale.setScalar(Math.max(k, 0.001)); h.g.visible = k > 0.01; }
for (const lf of LEAVES) {
const tp = lf.t.p, age = ((t * 0.25 + lf.ph / 4) % 1) * 4, top = lf.t.big ? 7 : 3.4;
@@ -534,7 +536,7 @@ function place(t) {
const f = 0.55 * Math.sin(t * 6 + gs.ph); gs.wl.rotation.x = f; gs.wr.rotation.x = -f;
}
}
- // 冬:下雪、烟囱冒烟、堆雪人;黄昏,窗户一盏盏亮起来
+ // winter: snow, chimney smoke, the snowman; at dusk the windows light up one by one
for (const s of SNOW) {
const u = (t * 0.11 * s.sp + s.ph) % 1, y = 32 * (1 - u);
s.m.position.set(s.x + 1.2 * Math.sin(t * 0.9 + s.ph * 9), y, s.z + 0.8 * Math.cos(t * 0.7 + s.ph * 7));
@@ -559,16 +561,16 @@ function render(t) {
const c = camAt(t);
dio.cam.fov = c.fov; dio.cam.position.copy(c.pos); dio.cam.up.set(0, 1, 0); dio.cam.lookAt(c.look); dio.cam.updateProjectionMatrix();
dio.fitShadow(V3(22, 0, 9), 100);
- // 字:第二、三行在换季波扫到一半时换
- const SWAPS = [10.45, 20.45, 30.45], near = SWAPS.find((s) => Math.abs(t - s) < 0.45);
+ // type: lines 2 and 3 switch halfway through the season wave
+ const near = SWAPS.find((s) => Math.abs(t - s) < 0.45);
const sw = near !== undefined, ti = SWAPS.filter((s) => t >= s).length;
let grow = 1e9;
if (t < 1.2) grow = 1300 * Math.pow(t / 1.2, 0.8);
else if (t > DUR - 1.0) grow = 1300 * (1 - io((t - (DUR - 1.0)) / 0.95));
const base = Math.min(sm(seg(t, 0.8, 1.6)), 1 - sm(seg(t, DUR - 1.0, DUR - 0.25)));
const swapA = sw ? Math.abs(t - near) / 0.45 : 1;
- dio.render(t, f, { grow, text: [TITLE, ...TEXT[ti]], textAlpha: base });
- if (sw) { // 换行时:先把旧字遮淡,再显出新字(第一行不动)
+ dio.render(t, f, { grow, text: [TITLE, ...TEXT[ti]], textAlpha: base, strong2: ti === 4 });
+ if (sw) { // on a switch: fade the old text out, then reveal the new (line 1 stays)
const g = dio.ctx; g.save(); g.globalAlpha = 1 - swapA; g.fillStyle = '#FFFCF6'; g.fillRect(0, 948, 1920, 60); g.restore();
}
}
@@ -579,9 +581,9 @@ function TEXTS(t) {
const g = dio.ctx, y0 = FRAME.cy + FRAME.hh + 64;
const tbox = (text, font, dy, size) => { g.save(); g.font = font; const w = g.measureText(text).width; g.restore(); return { x0: 960 - w / 2, x1: 960 + w / 2, y0: y0 + dy - size, y1: y0 + dy + size * 0.3 }; };
const out = [{ id: 'title', text: TITLE, ...tbox(TITLE, '600 25px IT, SC', 34, 25) }];
- const SWAPS = [10.45, 20.45, 30.45], ti = SWAPS.filter((s) => t >= s).length;
+ const ti = SWAPS.filter((s) => t >= s).length;
if (SWAPS.some((s) => Math.abs(t - s) < 0.45)) return out; // lines 2 and 3 are being swapped
- out.push({ id: 'season', text: TEXT[ti][0], ...tbox(TEXT[ti][0], '400 18px IT, SC', 64, 18) });
+ out.push({ id: 'season', text: TEXT[ti][0], ...(ti === 4 ? tbox(TEXT[ti][0], '600 21px IT, SC', 64, 21) : tbox(TEXT[ti][0], '400 18px IT, SC', 64, 18)) });
out.push({ id: 'info', text: TEXT[ti][1], ...tbox(TEXT[ti][1], '400 15px PM, SC', 91, 15) });
return out;
}
diff --git a/styles/memphis-diorama/demo/memphis.js b/styles/memphis-diorama/demo/memphis.js
index d8c1443..9a89b21 100644
--- a/styles/memphis-diorama/demo/memphis.js
+++ b/styles/memphis-diorama/demo/memphis.js
@@ -1,6 +1,6 @@
-// 孟菲斯微缩景观 Memphis Diorama — 3D 引擎
-// 平涂材质(不用光照算明暗,只用固定的面色调 + 硬边深靛阴影 + 世界坐标图案 + 立面窗格),
-// 法线/深度描边,颗粒喷漆画框,底部三行字。所有东西都是 t 的确定性函数。
+// Memphis Diorama: 3D engine
+// Flat materials (no lighting model: fixed face tones + hard-edged deep-indigo shadows + world-space patterns + facade windows),
+// normal/depth outlines, grainy spray-paint frame, three lines of type at the bottom. Everything is a deterministic function of t.
import * as THREE from 'three';
export const W = 1920, H = 1080, SS = 2;
@@ -8,13 +8,13 @@ export const INK = '#25214A', PAPER = '#FFFCF6';
export const FRAME = { cx: 960, cy: 468, hw: 760, hh: 372, r: 34 };
export const SUN = new THREE.Vector3(-0.42, 0.78, 0.46).normalize();
-// ---------- 随机 ----------
+// ---------- Random ----------
export function rng(a) { return () => { a |= 0; a = a + 0x6D2B79F5 | 0; let t = Math.imul(a ^ a >>> 15, 1 | a); t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t; return ((t ^ t >>> 14) >>> 0) / 4294967296; }; }
export const ease = (x) => x <= 0 ? 0 : x >= 1 ? 1 : x * x * (3 - 2 * x);
export const clamp01 = (x) => Math.max(0, Math.min(1, x));
export const lerp = (a, b, u) => a + (b - a) * u;
-// ---------- 平涂材质 ----------
+// ---------- Flat material ----------
const FLAT_VS = /* glsl */`
varying vec3 vWP;
varying vec3 vWN;
@@ -49,7 +49,7 @@ varying vec3 vWN;
#include <shadowmask_pars_fragment>
float h21(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
float aaStep(float e, float x) { float w = fwidth(x) * 0.75; return smoothstep(e - w, e + w, x); }
-// 亮灯波 + 银杏巷:波还没扫到的窗不亮;巷子里的窗按随机顺序逐格亮(uZoneLit 0→1)
+// Light-up wave + ginkgo lane: windows the wave hasn't reached stay dark; lane windows light pane by pane in random order (uZoneLit 0→1)
bool inZone(vec3 p) { return p.x > uZone.x && p.x < uZone.z && p.z > uZone.y && p.z < uZone.w; }
float waveOn(vec3 p, float hsh) {
float on = step(length(p.xz - uWaveC), uWave);
@@ -61,34 +61,34 @@ void main() {
bool top = n.y > 0.6;
vec2 puv = abs(n.y) > 0.5 ? vWP.xz : vec2(abs(n.x) > abs(n.z) ? vWP.z : vWP.x, vWP.y);
puv /= uPatScale;
- // 换季波:波扫过的地方换成下一季的颜色
+ // season wave: whatever it has passed takes the next season's colour
bool nxt = uHasC2 > 0.5 && length(vWP.xz - uSeas.xy) < uSeas.z;
vec3 col = nxt ? uCol2 : uCol, pc = nxt ? uPatCol2 : uPatCol;
- if (uPat > 0.5 && uPat < 1.5) { // 圆点
+ if (uPat > 0.5 && uPat < 1.5) { // dots
vec2 q = puv; q.x += 0.5 * mod(floor(q.y), 2.0);
float d = length(fract(q) - 0.5);
col = mix(col, pc, 1.0 - aaStep(0.17, d));
- } else if (uPat > 1.5 && uPat < 2.5) { // 斜条纹
+ } else if (uPat > 1.5 && uPat < 2.5) { // diagonal stripes
float s = fract(puv.x + puv.y);
col = mix(col, pc, 1.0 - aaStep(0.28, abs(s - 0.5)));
- } else if (uPat > 2.5 && uPat < 3.5) { // 折线
+ } else if (uPat > 2.5 && uPat < 3.5) { // zigzag
float y = fract(puv.y) - abs(fract(puv.x) - 0.5) * 0.7;
col = mix(col, pc, 1.0 - aaStep(0.07, abs(fract(y + 0.5) - 0.5)));
- } else if (uPat > 3.5 && uPat < 4.5) { // 竖条纹(遮阳棚)
+ } else if (uPat > 3.5 && uPat < 4.5) { // vertical stripes (awnings)
float s = fract(puv.x);
col = mix(col, pc, aaStep(0.5, s));
- } else if (uPat > 5.5 && uPat < 6.5) { // 横条纹(卷帘门)
+ } else if (uPat > 5.5 && uPat < 6.5) { // horizontal stripes (roller shutters)
col = mix(col, pc, aaStep(0.72, fract(puv.y)));
- } else if (uPat > 4.5 && uPat < 5.5) { // 剖面斜线
+ } else if (uPat > 4.5 && uPat < 5.5) { // section hatching
float s = fract((puv.x + puv.y) * 1.0);
col = mix(col, pc, 1.0 - aaStep(0.08, abs(s - 0.5)));
}
- // uZA:跟着亮灯波/银杏巷一起开关的灯(路灯头、天窗、串灯)
+ // uZA: lights switched with the light-up wave / ginkgo lane (lamp heads, skylights, string lights)
bool zoneOff = uZA > 0.5 && waveOn(vWP, h21(floor(vWP.xz * 0.2))) < 0.5;
bool emit = uEmit > 0.5 && !zoneOff;
bool useNC = uHasNC > 0.5 && !zoneOff;
vec3 winCol = vec3(-1.0);
- // 立面窗格
+ // facade window grid
if (uWin > 0.5 && abs(n.y) < 0.3) {
float u = abs(n.x) > abs(n.z) ? vWP.z : vWP.x;
float v = vWP.y - uY0;
@@ -98,7 +98,7 @@ void main() {
vec2 lo = vec2(0.22, 0.26), hi = vec2(0.78, 0.8);
float inside = aaStep(lo.x, f.x) * (1.0 - aaStep(hi.x, f.x)) * aaStep(lo.y, f.y) * (1.0 - aaStep(hi.y, f.y));
float inner = aaStep(lo.x + 0.06, f.x) * (1.0 - aaStep(hi.x - 0.06, f.x)) * aaStep(lo.y + 0.07, f.y) * (1.0 - aaStep(hi.y - 0.07, f.y));
- // 银杏巷来电时每一格都亮(其他地方随机亮一半多)
+ // when the ginkgo lane powers up every pane lights (elsewhere a random majority)
float lit = (inZone(vWP) ? 1.0 : step(0.42, h21(id + uSeed + n.xz * 7.0))) * waveOn(vWP, h21(id * 1.37 + uSeed + n.xz * 3.0));
vec3 glass = mix(uWinDay, lit > 0.5 ? uWinLit : uWinDark, uNight);
float glint = (1.0 - uNight) * (1.0 - aaStep(0.06, abs(f.x - f.y * 0.6 - 0.2)));
@@ -106,7 +106,7 @@ void main() {
col = mix(col, uInk, inside * (1.0 - inner));
col = mix(col, glass, inner);
if (inner > 0.5 && uNight > 0.5 && lit > 0.5) winCol = glass;
- } else if (v < 3.4 && v > 0.3) { // 底商橱窗
+ } else if (v < 3.4 && v > 0.3) { // ground-floor shop windows
float sx = fract(u / 5.6);
float inside = aaStep(0.08, sx) * (1.0 - aaStep(0.92, sx)) * aaStep(0.35, v) * (1.0 - aaStep(2.7, v));
float inner = aaStep(0.11, sx) * (1.0 - aaStep(0.89, sx)) * aaStep(0.45, v) * (1.0 - aaStep(2.6, v));
@@ -117,7 +117,7 @@ void main() {
if (inner > 0.5 && uNight > 0.5 && on > 0.5) winCol = glass;
}
}
- // 固定面色调:顶面最亮,朝太阳的侧面次之,背阳面和投影一样是"硬阴影"
+ // fixed face tones: top brightest, sun side next, shaded side matches cast shadows as "hard shadow"
float facing = dot(normalize(vec3(n.x, 0.0, n.z) + 1e-5), normalize(vec3(uSun.x, 0.0, uSun.z)));
float sh = 1.0 - getShadowMask();
if (!top) sh = max(sh, step(facing, 0.0) * (n.y < 0.6 ? 0.5 : 0.0));
@@ -126,7 +126,7 @@ void main() {
vec3 c = col * (uLit > 0.5 ? 1.0 : tone);
if (uShadow > 0.5 && !emit) {
vec3 shc = mix(vec3(1.0), vec3(0.70, 0.58, 0.90), sh);
- // 半调网点:阴影里印一层浅色网点,像印刷品(世界坐标,跟着物体走)
+ // halftone: light dots printed in the shadows, like print (world space, moves with the object)
if (uHT > 0.5 && sh > 0.5) {
vec2 wq = (abs(n.y) > 0.5 ? vWP.xz : vec2(abs(n.x) > abs(n.z) ? vWP.z : vWP.x, vWP.y)) / 0.38;
wq.x += 0.5 * mod(floor(wq.y), 2.0);
@@ -135,13 +135,13 @@ void main() {
}
c *= shc;
}
- // 夜:整体压暗到深靛,路灯光圈是硬边的暖色圆
+ // night: darken overall to deep indigo; lamp pools are hard-edged warm circles
if (useNC) c = mix(c, uNC * (uShadow > 0.5 ? mix(vec3(1.0), vec3(0.8, 0.76, 0.92), sh) : vec3(1.0)), uNight);
if (uNight > 0.0 && !emit && !useNC) {
- // 夜色:按亮度往靛紫偏,保留一点原色相(避免黄色压暗后发橄榄绿)
+ // night tint: shift toward indigo-violet by luminance, keeping some hue (so darkened yellow doesn't turn olive)
float lum = dot(c, vec3(0.2126, 0.7152, 0.0722));
vec3 dark = mix(c * vec3(0.25, 0.26, 0.44), lum * vec3(0.24, 0.22, 0.46), 0.6) + vec3(0.008, 0.007, 0.024);
- dark = mix(dark, c * vec3(0.92, 0.55, 0.6) + vec3(0.05, 0.0, 0.03), uDusk); // 黄昏:偏橙粉
+ dark = mix(dark, c * vec3(0.92, 0.55, 0.6) + vec3(0.05, 0.0, 0.03), uDusk); // dusk: orange-pink
float pool = 0.0;
for (int i = 0; i < 48; i++) {
vec4 L = uLamps[i];
@@ -185,14 +185,14 @@ export function setSeason(x, z, r) { GLOBAL.uSeas.value.set(x, z, r); }
export function setHalftone(v) { GLOBAL.uHT.value = v; }
export function setLamps(list) { for (let i = 0; i < 48; i++) { const L = list[i]; LAMPS[i].set(L ? L[0] : 0, L ? L[1] : 0, L ? L[2] : 0, L ? L[3] : 0); } }
-// 便捷:带材质的网格,默认投射和接收阴影
+// Helper: mesh with material, casts and receives shadows by default
export function mesh(geo, mat, x = 0, y = 0, z = 0, parent) {
const m = new THREE.Mesh(geo, mat); m.position.set(x, y, z); m.castShadow = true; m.receiveShadow = true;
if (parent) parent.add(m); return m;
}
export function box(w, h, d) { const g = new THREE.BoxGeometry(w, h, d); g.translate(0, h / 2, 0); return g; }
-// 文字贴图(招牌)
+// Text texture (signs)
export function signTex(text, bg, fg, w = 512, h = 160) {
const c = document.createElement('canvas'); c.width = w; c.height = h; const g = c.getContext('2d');
g.fillStyle = bg; g.fillRect(0, 0, w, h);
@@ -202,7 +202,7 @@ export function signTex(text, bg, fg, w = 512, h = 160) {
const t = new THREE.CanvasTexture(c); t.colorSpace = THREE.SRGBColorSpace; t.anisotropy = 8; return t;
}
-// ---------- 合成:描边 + 颗粒画框 ----------
+// ---------- Composite: outlines + grainy frame ----------
const COMP_FS = /* glsl */`
uniform sampler2D tCol, tNor, tDep;
uniform vec2 res;
@@ -241,7 +241,7 @@ void main() {
acc += mix(c, uInk, edge(uv));
}
vec3 col = acc * 0.25;
- // 颗粒画框(输出像素坐标,y 向下)
+ // grainy frame (output pixel coords, y down)
vec2 p = vec2(vUv.x * ${W}.0, (1.0 - vUv.y) * ${H}.0);
vec2 q = abs(p - uFrame.xy) - uFrame.zw + uRad;
float d = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - uRad;
@@ -286,7 +286,7 @@ export class Diorama {
this.quadScene = new THREE.Scene(); this.quadScene.add(this.quad);
this.quadCam = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
}
- // 阴影相机套住镜头看的那一片
+ // fit the shadow camera to the area in view
fitShadow(target, radius) {
const s = this.sun;
s.target.position.copy(target);
@@ -294,7 +294,7 @@ export class Diorama {
const c = s.shadow.camera; c.left = -radius; c.right = radius; c.top = radius; c.bottom = -radius; c.near = 10; c.far = 900;
c.updateProjectionMatrix();
}
- // t:秒;frame:帧号(颗粒每 5 帧换一次);grow:开场/结尾的长出半径
+ // t: seconds; frame: frame number (grain changes every 5 frames); grow: draw-in radius at open/close
render(t, frame, opts = {}) {
const r = this.r, cam = this.cam;
cam.updateMatrixWorld();
@@ -312,17 +312,17 @@ export class Diorama {
u.uWob.value = 22 * Math.sin(t * 0.55); u.uGrow.value = opts.grow ?? 1e9;
r.setRenderTarget(null); r.render(this.quadScene, this.quadCam);
const g = this.ctx; g.drawImage(r.domElement, 0, 0);
- if (opts.text) drawText(g, opts.text, opts.textAlpha ?? 1);
+ if (opts.text) drawText(g, opts.text, opts.textAlpha ?? 1, opts.strong2);
}
}
-// 底部三行字 + 孟菲斯小标记
-export function drawText(g, [l1, l2, l3], a) {
+// Three lines of type at the bottom + small Memphis marks
+export function drawText(g, [l1, l2, l3], a, strong2 = false) {
if (a <= 0) return;
const y0 = FRAME.cy + FRAME.hh + 64;
g.save(); g.globalAlpha = a; g.textAlign = 'center'; g.textBaseline = 'alphabetic';
g.fillStyle = '#2B2840'; g.font = '600 25px IT, SC, sans-serif'; g.fillText(l1, 960, y0 + 34);
- g.fillStyle = '#8D8AA0'; g.font = '400 18px IT, SC, sans-serif'; g.fillText(l2, 960, y0 + 64);
+ g.fillStyle = strong2 ? '#2B2840' : '#8D8AA0'; g.font = strong2 ? '600 21px IT, SC, sans-serif' : '400 18px IT, SC, sans-serif'; g.fillText(l2, 960, y0 + 64); // strong2: a line that must not be missed (the sign-off)
g.fillStyle = '#B7B4C6'; g.font = '400 15px PM, SC, monospace'; g.fillText(l3, 960, y0 + 91);
const mx = 960, my = y0;
g.fillStyle = '#FFC93C'; g.beginPath(); g.arc(mx - 24, my, 5, 0, 7); g.fill();
diff --git a/styles/memphis-diorama/demo/music.py b/styles/memphis-diorama/demo/music.py
index 111596a..af53f5f 100644
--- a/styles/memphis-diorama/demo/music.py
+++ b/styles/memphis-diorama/demo/music.py
@@ -1,9 +1,11 @@
-"""《柚子城的四季》配乐(40 秒):一整首连着的曲子,不按季节分段。全部代码合成。
-F 大调,96 BPM,每小节 2.5 秒;和弦一直走 Bbmaj7 – C – Am7 – Dm7(4–5–3–6),每 10 秒一轮。
-钢琴分解和弦从头到尾不断,主旋律一直是钢琴;季节只改变伴奏的厚薄:
-春只有钢琴 + 铺底 + 钢片琴;夏加贝斯和轻鼓;秋鼓变轻、马林巴叠旋律;冬鼓撤掉、音乐盒叠旋律,最后落到 Fmaj7。
-三次换季的声音完全一样:大树一蹲(闷“咚”)→ 弹起来(“啵嘤”)→ 一串往上走的竖琴。
-用法(库根目录): .venv/bin/python -I styles/memphis-diorama/demo/music.py → demo/out/mix.wav
+"""Score for Four Seasons in Pomelo Town (45 s): one continuous piece, not split by season. All synthesized in code.
+F major, 96 BPM, 2.5 s per bar; the chords cycle Bbmaj7 – C – Am7 – Dm7 (IV–V–iii–vi), one round every 10 s.
+Piano arpeggios run unbroken and the melody stays on piano; the seasons only change how full the accompaniment is:
+spring is piano + pad + celesta; summer adds bass and light drums; autumn lightens the drums and doubles the melody on marimba;
+winter drops the drums and doubles it on music box, settling on Fmaj7.
+All three season changes sound the same: the big tree squats (thump) → springs back (boing) → a rising harp run.
+End card (39.3 s): a low F with a music-box F major rise under the style name and sign-off; the frame draws in at 44–45 s.
+Usage (from the library root): .venv/bin/python -I styles/memphis-diorama/demo/music.py → demo/out/mix.wav
"""
import os
import wave
@@ -11,7 +13,7 @@ import numpy as np
from scipy import signal
ROOT = os.path.dirname(os.path.abspath(__file__))
-SR, DUR = 48000, 40.0
+SR, DUR = 48000, 45.0
N = int(SR * DUR)
mix = np.zeros((N, 2), np.float32)
rev = np.zeros((N, 2), np.float32)
@@ -44,9 +46,9 @@ def add(sig, t, gain=1.0, pan=0.0, send=0.25):
rev[i:i + len(sig), 0] += sig * l * send; rev[i:i + len(sig), 1] += sig * r * send
-# ---------- 音色 ----------
+# ---------- Instruments ----------
def piano(m, d=2.6, vel=0.7):
- """加法合成钢琴:两根略微走音的弦、轻微非谐、高次泛音衰减快、琴槌噪声。"""
+ """Additive piano: two slightly detuned strings, mild inharmonicity, fast-decaying upper partials, hammer noise."""
f, t = mtof(m), tt(d)
s = np.zeros_like(t)
for n in range(1, 10):
@@ -86,7 +88,7 @@ def pad(ms, d, cutoff=1100, attack=1.0):
t = tt(d)
s = np.zeros_like(t)
for m in ms:
- for dt in (-0.07, 0.0, 0.07): # 三条略微走音的锯齿,滤掉高频,暖一点
+ for dt in (-0.07, 0.0, 0.07): # three slightly detuned saws, lowpassed for warmth
f = mtof(m) * 2 ** (dt / 12)
s += 2 * ((f * t + rng.uniform()) % 1) - 1
s = filt(s / (3 * len(ms)), "lowpass", cutoff, order=4)
@@ -142,25 +144,25 @@ def whoosh(d, lo=300, hi=2500):
return filt(noise(d), "bandpass", [lo, hi]) * np.sin(np.pi * t / d) ** 2
-# ---------- 曲子 ----------
+# ---------- Score ----------
BEAT = 0.625
BAR = 2.5
-D0 = 1.8 # 第 0 小节的强拍;换季 9.3 / 19.3 / 29.3 正好落在第 3、7、11 小节
+D0 = 1.8 # downbeat of bar 0; season changes at 9.3 / 19.3 / 29.3 land on bars 3, 7, 11
BB, C, AM, DM, F = (46, [58, 62, 65, 69]), (48, [55, 60, 64, 67]), (45, [57, 60, 64, 67]), (50, [57, 60, 62, 65]), (41, [57, 60, 64, 65])
PROG = [BB, C, AM, DM] * 3 + [BB, C, F]
bt = lambda k, b=0.0: D0 + k * BAR + b * BEAT
-# 开场:画框长出来,铺底 + 一串竖琴把人带进第一小节
+# Opening: the frame draws in, pad + a harp run lead into bar 1
add(pad([53, 57, 60, 64], 2.6, 900, 1.0), 0.0, 0.10, send=0.6)
for j, m in enumerate([65, 69, 72, 76, 77, 81]):
add(harp(m), 0.45 + j * 0.2, 0.09, pan=-0.5 + 0.2 * j, send=0.5)
-# 铺底:一直跟着和弦
+# Pad: follows the chords throughout
for k, (root, ch) in enumerate(PROG):
- d = BAR + 0.9 if k < len(PROG) - 1 else 40 - bt(k)
+ d = BAR + 0.9 if k < len(PROG) - 1 else DUR - bt(k)
add(pad(ch, d, 1000 if k < 4 else 1300, 0.6), bt(k) - 0.3, 0.075, send=0.5)
-# 钢琴分解和弦:从头到尾不断(左手根音 + 五度,右手八分音符)
+# Piano arpeggios: unbroken start to end (left hand root + fifth, right hand eighths)
for k in range(-1, len(PROG)):
root, ch = PROG[k] if k >= 0 else F
last = k == len(PROG) - 1
@@ -175,11 +177,11 @@ for k in range(-1, len(PROG)):
else:
m = ch[[0, 1, 2, 3, 2, 1, 2, 3][i]]
add(piano(m, 1.6, 0.35), t, 0.22 * (0.9 if i % 2 else 1.0), pan=0.1 + 0.08 * (m - 60) / 6, send=0.35)
- if last: # 最后的 Fmaj7:慢慢往上滚
+ if last: # final Fmaj7: rolls slowly upward
for j, m in enumerate([53, 57, 60, 64, 65, 69, 72]):
add(piano(m, 3.5, 0.45), bt(k, 0.5 + j * 0.5), 0.28, pan=-0.3 + 0.1 * j, send=0.5)
-# 主旋律(钢琴)
+# Melody (piano)
A = [[(0, 77, 1.5), (1.5, 76, 0.5), (2, 74, 1), (3, 72, 1)],
[(0, 76, 1.5), (1.5, 74, 0.5), (2, 72, 1), (3, 67, 1)],
[(0, 72, 1), (1, 76, 1), (2, 81, 1.5), (3.5, 79, 0.5)],
@@ -195,7 +197,7 @@ for k, bar in enumerate(MEL):
t = bt(k, b)
dur = max(d * BEAT + 0.8, 1.4) if k < 14 else 4.0
add(piano(m, dur, 0.75), t, 0.62, pan=0.15, send=0.45)
- # 叠一层,随季节换:春钢片琴;夏不叠(让给鼓);秋马林巴;冬音乐盒
+ # doubling by season: celesta in spring; none in summer (room for drums); marimba in autumn; music box in winter
if k < 4:
add(celesta(m + 12, 1.6), t, 0.05, pan=0.35, send=0.5)
elif 8 <= k < 12:
@@ -203,15 +205,15 @@ for k, bar in enumerate(MEL):
elif k >= 12:
add(musicbox(m + 12, 2.2), t, 0.06, pan=0.35, send=0.55)
-# 贝斯:夏天进来,冬天变成长音
+# Bass: enters in summer, long notes in winter
for k in range(4, len(PROG)):
root, _ = PROG[k]
if k < 12:
for b, d in ((0, 1.4), (1.5, 0.5), (2, 1.0), (3.5, 0.5)):
add(bass(root - 12, d), bt(k, b), 0.30 * (0.85 if b else 1.0), send=0.03)
else:
- add(bass(root - 12, BAR if k < 14 else 3.2), bt(k), 0.26, send=0.05)
-# 一开始就有的轻沙锤,到夏天加踢鼓和刷子;秋天变轻;冬天撤掉
+ add(bass(root - 12, BAR if k < 14 else DUR - bt(k)), bt(k), 0.26, send=0.05)
+# Soft shaker from the start; kick and brushes join in summer; lighter in autumn; gone in winter
for k in range(0, 12):
for i in range(8):
t = bt(k, i / 2)
@@ -225,23 +227,23 @@ for k in range(0, 12):
if i in (2, 6):
add(brush(), t, 0.05 * (0.8 if k >= 8 else 1.0), pan=0.15, send=0.2)
-# ---------- 换季:三次一模一样 ----------
+# ---------- Season change: identical all three times ----------
for T in (9.3, 19.3, 29.3):
tq = tt(0.25)
- add(np.sin(2 * np.pi * np.cumsum(170 - 60 * tq / 0.25) / SR) * np.exp(-tq / 0.08), T - 0.42, 0.22, send=0.2) # 一蹲:闷“咚”
+ add(np.sin(2 * np.pi * np.cumsum(170 - 60 * tq / 0.25) / SR) * np.exp(-tq / 0.08), T - 0.42, 0.22, send=0.2) # squat: muffled thump
tb_ = tt(0.5)
boing = np.sin(2 * np.pi * np.cumsum(330 + 380 * (1 - np.exp(-tb_ / 0.06)) + 25 * np.sin(2 * np.pi * 11 * tb_) * np.exp(-tb_ / 0.2)) / SR) * np.exp(-tb_ / 0.15)
- add(boing, T, 0.10, send=0.3) # 弹起来:“啵嘤”
+ add(boing, T, 0.10, send=0.3) # spring back: boing
for j, m in enumerate([62, 65, 69, 72, 74, 77, 81, 84, 86, 89]):
- add(harp(m, 1.8), T + 0.08 + j * 0.11, 0.075, pan=-0.6 + 0.13 * j, send=0.6) # 一串往上走的竖琴
+ add(harp(m, 1.8), T + 0.08 + j * 0.11, 0.075, pan=-0.6 + 0.13 * j, send=0.6) # rising harp run
add(whoosh(2.4, 500, 4500), T, 0.035, send=0.3)
-# ---------- 拟音(都很轻,垫在音乐下面) ----------
-# 春:燕子、鸭子
+# ---------- Foley (all quiet, under the music) ----------
+# Spring: swallows, ducks
for t in (1.6, 1.75, 3.9, 4.05, 4.2, 6.3, 6.45, 8.1):
add(chirp(rng.uniform(3800, 5200), 0.08), t, 0.03, pan=rng.uniform(-0.7, 0.7), send=0.3)
add(quack(), 3.3, 0.035, pan=0.6, send=0.2); add(quack(), 3.55, 0.03, pan=0.6, send=0.2); add(quack(), 7.0, 0.03, pan=0.6, send=0.2)
-# 夏:蝉、远雷、过云雨、荷花开
+# Summer: cicadas, distant thunder, passing shower, lotus opening
tc = tt(8.6)
cic = filt(noise(8.6), "bandpass", [4500, 7000]) * (0.6 + 0.4 * np.sin(2 * np.pi * 38 * tc)) * np.minimum(tc / 1.0, 1) * np.minimum((8.6 - tc) / 1.0, 1)
cic[(tc + 10.8 > 12.2) & (tc + 10.8 < 16.8)] *= 0.25
@@ -253,7 +255,7 @@ for t in np.sort(rng.uniform(12.4, 17.6, 50)):
add(np.sin(2 * np.pi * np.cumsum(np.full(1200, rng.uniform(900, 1700)) * (1 + 0.8 * np.linspace(0, 1, 1200))) / SR) * np.exp(-tt(0.025) / 0.006), t, 0.018, pan=rng.uniform(-0.8, 0.8), send=0.2)
for i in range(8):
add(celesta([84, 86, 89, 91, 93, 96, 93, 91][i], 1.2), 16.75 + i * 0.14, 0.03, pan=0.5, send=0.5)
-# 秋:落叶、稻草垛、大雁
+# Autumn: falling leaves, haystacks, geese
for t in np.sort(rng.uniform(20.8, 29.0, 18)):
d = rng.uniform(0.25, 0.5)
add(filt(noise(d), "bandpass", [2500, 7500]) * np.sin(np.pi * tt(d) / d) ** 2, t, 0.018, pan=rng.uniform(-0.8, 0.8), send=0.15)
@@ -261,14 +263,19 @@ for t in np.sort(rng.uniform(22.1, 27.4, 10)):
add(pop(), t, 0.012, pan=rng.uniform(-0.6, 0.6), send=0.2)
for t, p in ((22.2, 0.6), (22.5, 0.55), (23.85, 0.3), (25.35, 0.0), (26.6, -0.3), (28.15, -0.6)):
add(honk(), t, 0.025, pan=p, send=0.35)
-# 冬:风、雪人、窗户一盏盏亮(叮,都在 F 大调五声音阶里)
-tw = tt(9.5)
-add(filt(noise(9.5), "bandpass", [300, 1400]) * (0.6 + 0.4 * np.sin(2 * np.pi * 0.21 * tw)) * np.minimum(tw / 1.5, 1) * np.minimum((9.5 - tw) / 1.5, 1), 30.3, 0.03, pan=-0.3, send=0.2)
+# Winter: wind, snowman, windows lighting one by one (dings, all in F major pentatonic)
+tw = tt(DUR - 30.3)
+add(filt(noise(DUR - 30.3), "bandpass", [300, 1400]) * (0.6 + 0.4 * np.sin(2 * np.pi * 0.21 * tw)) * np.minimum(tw / 1.5, 1) * np.minimum((DUR - 30.3 - tw) / 1.5, 1), 30.3, 0.03, pan=-0.3, send=0.2)
add(pop(), 32.65, 0.02, send=0.2)
for k, t in enumerate(np.sort(rng.uniform(34.7, 38.2, 12))):
add(celesta([84, 86, 88, 91, 93, 96][k % 6], 1.2), t, 0.025, pan=rng.uniform(-0.6, 0.6), send=0.6)
-# ---------- 底噪 + 混响 + 总线 ----------
+# End card (39.3 s, the downbeat after the last chord): a low F and a music-box F major rising over it
+add(piano(41, 5.0, 0.4), bt(15), 0.4, pan=-0.3, send=0.4)
+for j, m in enumerate([77, 81, 84, 89]):
+ add(musicbox(m + 12, 3.0), bt(15) + 0.15 + j * 0.22, 0.05, pan=-0.2 + 0.15 * j, send=0.6)
+
+# ---------- Noise floor + reverb + bus ----------
add(filt(noise(DUR), "lowpass", 500) * 0.4, 0, 0.012, send=0.0)
ir_t = tt(2.6)
ir = rng.standard_normal((len(ir_t), 2)).astype(np.float32) * np.exp(-ir_t / 0.75)[:, None]
diff --git a/styles/memphis-diorama/demo/stills/frame_spring.jpg b/styles/memphis-diorama/demo/stills/frame_spring.jpg
index d7dc638..f0176dd 100644
Binary files a/styles/memphis-diorama/demo/stills/frame_spring.jpg and b/styles/memphis-diorama/demo/stills/frame_spring.jpg differ
diff --git a/styles/memphis-diorama/demo/stills/frame_squat.jpg b/styles/memphis-diorama/demo/stills/frame_squat.jpg
index 431245d..a130d53 100644
Binary files a/styles/memphis-diorama/demo/stills/frame_squat.jpg and b/styles/memphis-diorama/demo/stills/frame_squat.jpg differ
diff --git a/styles/memphis-diorama/demo/stills/frame_summer.jpg b/styles/memphis-diorama/demo/stills/frame_summer.jpg
index a620cc6..ca0f3ea 100644
Binary files a/styles/memphis-diorama/demo/stills/frame_summer.jpg and b/styles/memphis-diorama/demo/stills/frame_summer.jpg differ
diff --git a/styles/memphis-diorama/demo/stills/frame_winter.jpg b/styles/memphis-diorama/demo/stills/frame_winter.jpg
index 574da2a..a1f6251 100644
Binary files a/styles/memphis-diorama/demo/stills/frame_winter.jpg and b/styles/memphis-diorama/demo/stills/frame_winter.jpg differ
diff --git a/styles/memphis-diorama/demo/stills/styleframe.jpg b/styles/memphis-diorama/demo/stills/styleframe.jpg
index f60ef48..8e0376a 100644
Binary files a/styles/memphis-diorama/demo/stills/styleframe.jpg and b/styles/memphis-diorama/demo/stills/styleframe.jpg differ
diff --git a/styles/memphis-diorama/demo/tools/fonts.py b/styles/memphis-diorama/demo/tools/fonts.py
index eabbb23..3ae2cb6 100644
--- a/styles/memphis-diorama/demo/tools/fonts.py
+++ b/styles/memphis-diorama/demo/tools/fonts.py
@@ -4,7 +4,7 @@ import sys, os, re, ssl, urllib.request, urllib.parse
D = sys.argv[1]
main = open(os.path.join(D, 'main.js'), encoding='utf-8').read()
src = main[main.index('const TEXT = ['):main.index('const TITLE')] + main[main.index('const TITLE'):].split('\n', 1)[0] # only the on-screen strings
-cjk = sorted(set(re.findall(r'[ -〿一-鿿＀-￯·°]', src)))
+cjk = sorted(set(re.findall(r'[ -〿一-鿿＀-￯·°×]', src)))
latin = ''.join(chr(c) for c in range(32, 127))
text = ''.join(cjk) + latin
print(len(cjk), 'CJK chars')
diff --git a/styles/memphis-diorama/poster.jpg b/styles/memphis-diorama/poster.jpg
index f60ef48..8e0376a 100644
Binary files a/styles/memphis-diorama/poster.jpg and b/styles/memphis-diorama/poster.jpg differ
diff --git a/styles/memphis-diorama/style.json b/styles/memphis-diorama/style.json
index 8566255..6c33fda 100644
--- a/styles/memphis-diorama/style.json
+++ b/styles/memphis-diorama/style.json
@@ -16,5 +16,5 @@
"City data maps"
],
"frame_sec": 25.0,
- "dur": 40.0
+ "dur": 45.0
}