feat(mockups): 14 voyage with side panel (stylised 3D, about/paths/lyrics/fan works, look 2/3)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
3cda08c32e
commit
ada8fa4f94
@@ -223,6 +223,12 @@ mockup of the transition.
|
||||
a persistent right panel (tabs: About · Paths · Lyrics · Fan works), with a 2/3 look toggle.
|
||||
Fan works and lyrics are placeholders (no real lyrics, no real fan artists' names or links).
|
||||
|
||||
- **14 is finished and committed** (`feat/sea-chart-round`, not pushed); report in
|
||||
`docs/design/002-sea-chart-spikes/14-voyage-panel-report.md`. Preview rebuilt with 01–14.
|
||||
Agent's choices: the panel stays open in all five beats (frieze beats too); the small vellum chart
|
||||
moved into the Paths tab. Rough spots: empty space around the frieze band with the panel open, light
|
||||
sea patches that read like lily pads, heavy outlines on the giant.
|
||||
|
||||
## Open questions (in priority order)
|
||||
|
||||
1. ~~Which sea-chart approach (08–11) reads best, or which mix?~~ 11's navigation + 10's style (§9).
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
# 14 Voyage with side panel — report
|
||||
|
||||
Status: **done** (not committed). Built from `14-voyage-panel-brief.md`, starting from a copy of 13.
|
||||
|
||||
## What was built
|
||||
|
||||
`src/mockups/14-voyage-panel/` is 13's five-beat curtain call, with the same beats, timings, Play/step
|
||||
controls, `?beat=` `?t=` `?play=`, the fade-through for jumps, and reduced motion. Three things
|
||||
changed, as the brief asked:
|
||||
|
||||
1. **A persistent right-side panel** (420px). It is **open in every beat, including the frieze beats 1
|
||||
and 4** (my call: it reads as one companion that stays through the whole voyage). The stage, with
|
||||
the 3D canvas, the friezes, the caption and the control bar, fills the remaining ~1020px. So the
|
||||
ship and island are framed in the visible area by construction, not hidden behind the panel.
|
||||
- Song per beat: 1 The Horse and the Infant, 2 Full Speed Ahead, 3 and 4 Polyphemus, 5 Survive.
|
||||
The panel switches at each transition's midpoint, together with the caption. The title and the
|
||||
tab content dip and settle (180 ms); under reduced motion they swap instantly.
|
||||
- Head: "Now playing on the voyage", track badge, title, saga · story time, and a **Hide ›** button.
|
||||
Collapsed, it becomes a 56px slim tab (‹, the track number, "About · Paths · Lyrics · Fan works"
|
||||
written vertically), and the stage widens. `?panel=0` starts collapsed. The grid column animates.
|
||||
- Tabs (`?tab=about|paths|lyrics|fan`, with a proper tablist and arrow keys; arrow keys inside the
|
||||
panel no longer step the beats):
|
||||
- **About**: track, saga, story time, the Odyssey book/lines (linked), the fact, parts with singers,
|
||||
`createAudioSlot` (empty state) and `createVideoCards`, restyled for the panel.
|
||||
- **Paths**: first the motif threads. Each of this song's motifs is a button with "comes from … /
|
||||
first heard here · returns in … (+n more)". Under them, a compact vertical **thread strip**: all
|
||||
10 songs as rows, one soft wavy thread per motif, knotted where it plays, with the current song
|
||||
marked "now". Clicking a motif highlights its thread and dims the others. Clicking a song row only
|
||||
highlights that row. Below that is **the route**: the small vellum chart moved here from the
|
||||
table, with "You are here" still moving with the ship.
|
||||
- **Lyrics**: placeholder lines from `sample.ts`, split by part, with singer chips. Each part has a
|
||||
left rule in its motif colour and motif tags. I left out the current-part marker: the beats carry
|
||||
no timing, so any marker would have been made up.
|
||||
- **Fan works**: the note "Placeholder fan works — real ones will be credited and linked to their
|
||||
creators.", then 3–4 cards per song in two columns: type (art / animatic / cover / cosplay), a
|
||||
stylised SVG thumbnail, a "Placeholder: …" title, "by @fan-artist", and "Credit + link to the
|
||||
original (placeholder)". The data is local, in `fanworks.ts`.
|
||||
- Look 2 panel: a vellum sheet with a wooden roller edge (12). Look 3 panel: glaze black, with a
|
||||
terracotta tongue band along the top (from the frieze) and clay accents. Motif colours are
|
||||
re-inked darker on vellum (12's `INK`) and kept light on black. Body text is 15px, with good
|
||||
contrast in both looks.
|
||||
2. **Stylised 3D** (`scene.ts`, rewritten from 13's):
|
||||
- Toon shading: `MeshToonMaterial` with a three-step gradient map. Ink outlines are inverted hulls
|
||||
(smoothed normals, back faces), plus faint facet lines on the islands and the cave dome.
|
||||
- The sky is posterised into four flat bands with a slight wave. **The sun is a small flat disc with
|
||||
one ring, with no glare** (fixes 13's rough spot).
|
||||
- The sea is unlit flat colour bands by wave height, with a hand-drawn-looking contour line on the
|
||||
crest band and a small ripple term, so the crests read as drawn patches, not lit water.
|
||||
- Island: a few-faceted bold shape in three flat bands (sand, ochre rock, olive scrub), inked, with a
|
||||
black arched cave mouth. Ship: silhouette first, with a dark hull, a terracotta gunwale band,
|
||||
striped sail, painted bow eyes, a curled stern post and a ram.
|
||||
- **Polyphemus**: an extruded black-figure profile cut-out. He strides, with his club raised, a heavy
|
||||
nose and a pointed beard. **One big painted eye** catches the firelight. His outline and incised
|
||||
lines (belt, zigzag hem, knees, chest, brow, ear) are in clay, as in the frieze. Flat layered
|
||||
flame shapes; woolly sheep made of outlined puffs.
|
||||
- Look 3: black-figure ship and island with clay outlines, a clay-lit cave mouth, a glaze sea with
|
||||
clay contour lines, and a terracotta sky.
|
||||
- **Landfall camera**: it stays behind the ship's right shoulder the whole way and only pulls back
|
||||
and up. The island rises ahead-left and stays there, so 13's sideways shuffle is gone
|
||||
(`-mid-landfall.png`).
|
||||
3. **Look toggle 2 · 3 only** (`?look=2|3`, default 2). Look 1 is removed, along with its CSS.
|
||||
|
||||
Frieze scaling: with the stage now ~1020px wide, the frieze SVGs use `meet` instead of `slice`, so the
|
||||
whole band shows (saga column to Full Speed Ahead), with the glaze surround above and below.
|
||||
`syncHorizon` uses the matching `min()` scale, so the morph still starts exactly on the painted ground
|
||||
line (`-morph.png`).
|
||||
|
||||
Files: `main.ts` (beats, DOM choreography, params), `panel.ts` (the companion), `fanworks.ts`
|
||||
(placeholder data and thumbnails), `scene.ts` (stylised 3D), `frieze.ts`, `figures.ts` and `chart.ts`
|
||||
(copied from 13; only the frieze scaling changed), `style.css`.
|
||||
|
||||
## Screenshots (1440×900, `screenshots/`)
|
||||
|
||||
- Look 2, About tab: `14-voyage-panel-beat1.png` … `-beat5.png`
|
||||
- Beat 3 tabs: `-paths.png`, `-lyrics.png`, `-fan.png`
|
||||
- Look 3: `-beat2-look3.png`, `-beat5-look3.png`, `-lyrics-look3.png`
|
||||
- Collapsed panel: `-collapsed.png`
|
||||
- Extra: `-mid-landfall.png` (2→3 at 50 %), `-morph.png` (1→2 at 40 %)
|
||||
|
||||
The credits footer is visible in every one, with the panel open or collapsed.
|
||||
|
||||
## What works
|
||||
|
||||
- The panel feels like a companion, not a modal. It is always there, and it changes song at the same
|
||||
moment as the caption. The 3D has its own uncluttered frame.
|
||||
- Paths gives a lot of information at a glance: where each motif comes from and goes next, in words
|
||||
and as threads, plus the route chart.
|
||||
- The stylised 3D is consistent with the frieze, especially the giant and look 3's black-figure
|
||||
island. The sea pattern reads as illustration.
|
||||
- Landfall is calm, and the sun no longer glares.
|
||||
- Checked: `bun test` (48 pass), `bun run typecheck`, and a production build to the scratchpad. A
|
||||
throwaway happy-dom check (not kept) confirmed the motif highlight, song highlight, tab callback,
|
||||
fan cards and collapse.
|
||||
|
||||
## What doesn't, or is rough
|
||||
|
||||
- **Frieze beats with the panel open** show a lot of empty glaze above and below the band (`-beat1`,
|
||||
`-beat4`). In the Troy band, the Full Speed Ahead ship touches the stage edge. A 14-specific,
|
||||
narrower frieze layout (fewer panels) would fill the stage better.
|
||||
- The **sea crest patches** near the camera are large, flat shapes, a bit like lily pads. They are
|
||||
stylised but could be finer.
|
||||
- The giant's beard and the flock's outlines are a little heavy at the cave's end framing. The club
|
||||
tip nearly touches the top of the frame.
|
||||
- Beats 3 and 4 share Polyphemus, so the panel does not change between them (on purpose).
|
||||
- Play hold times were not checked in a live browser; headless virtual time does not run rAF
|
||||
faithfully (same caveat as 13).
|
||||
- The panel width is fixed at 420px. It is tuned only for desktop 1440×900, as briefed.
|
||||
|
||||
## Looks 2 and 3 with the panel, honestly
|
||||
|
||||
**Look 2 (two worlds)** suits the panel best. The vellum panel sits beside a cream-and-teal poster sea
|
||||
and reads like the captain's notes next to the view. The terracotta frieze is still a clear
|
||||
"curtain". The panel has three materials around it (vellum, teal sea, clay frieze), but they belong
|
||||
together.
|
||||
|
||||
**Look 3 (frieze-led)** is the more distinctive 3D: the black-figure island with its clay-lit mouth
|
||||
(`-lyrics-look3.png`) and the giant are the strongest images in the mockup. The dark panel matches
|
||||
it, so the whole screen feels like one painted vase. The cost: the sea is very dark, so there is
|
||||
less depth. The pale vellum route chart in Paths becomes a bright foreign object in the dark panel.
|
||||
And dark-on-dark makes the screen heavy over a long session.
|
||||
|
||||
My read: look 2 for reading (the panel is where people spend time), and look 3 for the 3D moments.
|
||||
A hybrid (look 3's black-figure models and look 2's vellum panel) may be worth one toggle in a next
|
||||
round.
|
||||
@@ -0,0 +1,65 @@
|
||||
// Copied from 13: a small redraw of 12's general chart, with "You are here". In 14 it lives in the Paths tab.
|
||||
// Coordinates are 12's general chart scaled into a 320×210 card.
|
||||
|
||||
const P = (x: number, y: number): [number, number] => [10 + ((x - 50) * 300) / 1050, 10 + ((y - 85) * 190) / 660];
|
||||
const PORTS: [number, number][] = [
|
||||
P(344, 277), P(404, 331), P(432, 407), P(420, 488), P(373, 552),
|
||||
P(456, 498), P(543, 576), P(679, 576), P(766, 499), P(960, 400),
|
||||
];
|
||||
const LOOP = P(410, 592);
|
||||
const AT_SEA = P(392, 584);
|
||||
|
||||
const pt = (p: [number, number]) => `${p[0].toFixed(1)},${p[1].toFixed(1)}`;
|
||||
const port = (i: number) => PORTS[i]!;
|
||||
|
||||
/** The ship's course on the card, as one path (12's red dashed line). */
|
||||
const COURSE = `M${pt(port(0))} Q${pt(P(380, 300))} ${pt(port(1))} Q${pt(P(440, 360))} ${pt(port(2))} L${pt(port(3))} L${pt(port(4))}
|
||||
Q${pt(P(380, 600))} ${pt(LOOP)} Q${pt(P(440, 570))} ${pt(port(5))} Q${pt(P(480, 570))} ${pt(port(6))} L${pt(port(7))}
|
||||
Q${pt(P(730, 560))} ${pt(port(8))} Q${pt(P(860, 530))} ${pt(port(9))}`;
|
||||
|
||||
/** Where "You are here" sits: k=0 out at sea after Troy, k=1 at the first Cyclops port. */
|
||||
export function hereAt(k: number): [number, number] {
|
||||
const a = AT_SEA, b = LOOP, c = port(5);
|
||||
// two straight legs are close enough at this size
|
||||
if (k < 0.4) { const s = k / 0.4; return [a[0] + (b[0] - a[0]) * s, a[1] + (b[1] - a[1]) * s]; }
|
||||
const s = (k - 0.4) / 0.6;
|
||||
return [b[0] + (c[0] - b[0]) * s, b[1] + (c[1] - b[1]) * s];
|
||||
}
|
||||
|
||||
export function chartSvg(): string {
|
||||
const [ix, iy] = P(605, 470);
|
||||
const coast = `M0,0 L${pt(P(275, 85))} Q${pt(P(300, 200))} ${pt(P(290, 300))} Q${pt(P(390, 400))} ${pt(P(375, 430))} Q${pt(P(330, 520))} ${pt(P(285, 550))} Q${pt(P(240, 680))} ${pt(P(200, 745))} L0,210 Z`;
|
||||
const ports = PORTS.map((p, i) => `<circle class="c-port" cx="${p[0].toFixed(1)}" cy="${p[1].toFixed(1)}" r="2.6"/><text class="c-num" x="${(p[0] + 4).toFixed(1)}" y="${(p[1] - 3).toFixed(1)}">${i + 1}</text>`).join("");
|
||||
let rhumbs = "";
|
||||
for (let i = 0; i < 16; i++) {
|
||||
const a = (i / 16) * Math.PI * 2;
|
||||
rhumbs += `M206,48 L${(206 + Math.cos(a) * 260).toFixed(0)},${(48 + Math.sin(a) * 260).toFixed(0)} `;
|
||||
}
|
||||
let spiral = "";
|
||||
for (let r = 3; r < 15; r += 3) spiral += `<ellipse class="c-ink" cx="${port(9)[0].toFixed(1)}" cy="${(port(9)[1] - 4).toFixed(1)}" rx="${r * 1.5}" ry="${r * 0.8}"/>`;
|
||||
return `<svg class="chart__svg" viewBox="0 0 320 210" role="img" aria-label="General chart of the voyage from Troy, with the ship's position marked">
|
||||
<defs><clipPath id="chart-clip"><rect x="6" y="6" width="308" height="198"/></clipPath></defs>
|
||||
<rect class="c-vellum" x="0" y="0" width="320" height="210"/>
|
||||
<g clip-path="url(#chart-clip)">
|
||||
<path class="c-rhumb" d="${rhumbs}"/>
|
||||
<path class="c-land" d="${coast}"/>
|
||||
<ellipse class="c-land" cx="${ix.toFixed(1)}" cy="${iy.toFixed(1)}" rx="38" ry="22"/>
|
||||
<path class="c-ink" d="M${(ix - 6).toFixed(1)},${(iy + 6).toFixed(1)} a8,8 0 0 1 16,0" />
|
||||
<ellipse class="c-land" cx="${P(450, 195)[0]}" cy="${P(450, 195)[1]}" rx="9" ry="6"/>
|
||||
<ellipse class="c-land" cx="${P(722, 335)[0]}" cy="${P(722, 335)[1]}" rx="5" ry="3.5"/>
|
||||
${spiral}
|
||||
<path class="c-course" d="${COURSE}"/>
|
||||
${ports}
|
||||
<text class="c-place" x="16" y="34">Troy</text>
|
||||
<text class="c-place" x="${(ix - 30).toFixed(1)}" y="${(iy - 28).toFixed(1)}">Cyclops' Island</text>
|
||||
<text class="c-sea" x="${P(870, 440)[0].toFixed(1)}" y="${P(870, 440)[1].toFixed(1)}">two years at sea</text>
|
||||
<g class="c-rose" transform="translate(292,178)"><circle r="11"/><path d="M0,-15 L3,0 L0,15 L-3,0 Z M-15,0 L0,3 L15,0 L0,-3 Z"/></g>
|
||||
</g>
|
||||
<g class="c-here" id="chart-here">
|
||||
<circle class="c-here__ring" r="7"/>
|
||||
<circle class="c-here__dot" r="3"/>
|
||||
<text class="c-here__label" x="10" y="-8">You are here</text>
|
||||
</g>
|
||||
<rect class="c-frame" x="4" y="4" width="312" height="202"/>
|
||||
</svg>`;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// Placeholder fan works for the panel's "Fan works" tab. Every title and handle here is made up and
|
||||
// clearly marked as a placeholder: no real fan artists, no real links. Local to 14 (src/data/ has no
|
||||
// fan-works model yet; see open question 3b in the round notes).
|
||||
|
||||
export type FanWorkType = "art" | "animatic" | "cover" | "cosplay";
|
||||
export interface FanWork { type: FanWorkType; title: string; handle: string }
|
||||
|
||||
const P = "@fan-artist";
|
||||
|
||||
const BY_SONG: Record<string, FanWork[]> = {
|
||||
"the-horse-and-the-infant": [
|
||||
{ type: "art", title: "Placeholder: the horse at the gates, ink study", handle: P },
|
||||
{ type: "animatic", title: "Placeholder: storyboard of the final night", handle: P },
|
||||
{ type: "cover", title: "Placeholder: piano cover", handle: P },
|
||||
],
|
||||
"full-speed-ahead": [
|
||||
{ type: "art", title: "Placeholder: the fleet under sail", handle: P },
|
||||
{ type: "cover", title: "Placeholder: sea-shanty arrangement", handle: P },
|
||||
{ type: "animatic", title: "Placeholder: crew at the oars, animatic", handle: P },
|
||||
{ type: "cosplay", title: "Placeholder: Eurylochus armour build", handle: P },
|
||||
],
|
||||
polyphemus: [
|
||||
{ type: "art", title: "Placeholder: one eye in the dark", handle: P },
|
||||
{ type: "animatic", title: "Placeholder: the cave scene, animatic", handle: P },
|
||||
{ type: "cosplay", title: "Placeholder: Cyclops costume and club", handle: P },
|
||||
{ type: "cover", title: "Placeholder: low-strings cover", handle: P },
|
||||
],
|
||||
survive: [
|
||||
{ type: "art", title: "Placeholder: the crew by firelight", handle: P },
|
||||
{ type: "cover", title: "Placeholder: choir cover", handle: P },
|
||||
{ type: "animatic", title: "Placeholder: escape plan, animatic", handle: P },
|
||||
],
|
||||
};
|
||||
|
||||
export function fanWorksFor(songId: string): FanWork[] {
|
||||
return BY_SONG[songId] ?? [
|
||||
{ type: "art", title: "Placeholder: illustration", handle: P },
|
||||
{ type: "cover", title: "Placeholder: cover", handle: P },
|
||||
{ type: "animatic", title: "Placeholder: animatic", handle: P },
|
||||
];
|
||||
}
|
||||
|
||||
export const TYPE_LABEL: Record<FanWorkType, string> = { art: "Art", animatic: "Animatic", cover: "Cover", cosplay: "Cosplay" };
|
||||
|
||||
/** A stylised placeholder thumbnail per type (no external images). Colours come from CSS custom properties. */
|
||||
export function thumbSvg(type: FanWorkType, accent: string, seed: number): string {
|
||||
const r = (n: number) => ((Math.sin(seed * 12.9898 + n * 78.233) * 43758.5453) % 1 + 1) % 1;
|
||||
let art = "";
|
||||
if (type === "art") {
|
||||
art = `<circle cx="${120 + r(1) * 30}" cy="34" r="16" fill="${accent}"/>
|
||||
<path d="M0 80 Q40 ${58 + r(2) * 10} 80 76 T160 70 V100 H0Z" class="t-ink"/>
|
||||
<path d="M10 88 q14 -8 28 0 t28 0 t28 0 t28 0 t28 0" class="t-line"/>
|
||||
<path d="M${40 + r(3) * 40} 70 l10 -30 l10 30z" class="t-ink"/>`;
|
||||
} else if (type === "animatic") {
|
||||
let frames = "";
|
||||
for (let i = 0; i < 3; i++) frames += `<rect x="${8 + i * 50}" y="22" width="44" height="56" rx="2" class="t-frame"/><path d="M${18 + i * 50} ${66 - i * 6} q12 ${-18 + i * 6} 24 ${-4 - i * 3}" class="t-line" style="stroke:${accent}"/>`;
|
||||
let holes = "";
|
||||
for (let x = 6; x < 160; x += 12) holes += `<rect x="${x}" y="8" width="6" height="6" class="t-hole"/><rect x="${x}" y="86" width="6" height="6" class="t-hole"/>`;
|
||||
art = `<rect x="0" y="0" width="160" height="100" class="t-ink"/>${holes}${frames}`;
|
||||
} else if (type === "cover") {
|
||||
let bars = "";
|
||||
for (let i = 0; i < 18; i++) { const h = 10 + r(i) * 46; bars += `<rect x="${78 + i * 4.4}" y="${50 - h / 2}" width="2.6" height="${h}" fill="${accent}"/>`; }
|
||||
art = `<circle cx="40" cy="50" r="30" class="t-ink"/><circle cx="40" cy="50" r="9" fill="${accent}"/><circle cx="40" cy="50" r="20" class="t-line"/>${bars}`;
|
||||
} else {
|
||||
art = `<path d="M80 18 a10 10 0 1 1 0.1 0 M64 22 q16 -18 34 -4 l-4 6 q-14 -8 -26 2z" class="t-ink"/>
|
||||
<path d="M66 36 h28 l6 34 h-10 l-2 22 h-16 l-2 -22 h-10z" class="t-ink"/>
|
||||
<path d="M100 30 l22 -14" class="t-line" style="stroke:${accent};stroke-width:4"/>
|
||||
<path d="M66 52 h34" class="t-line" style="stroke:${accent}"/>`;
|
||||
}
|
||||
return `<svg class="fw__thumb" viewBox="0 0 160 100" preserveAspectRatio="xMidYMid slice" role="img" aria-label="Placeholder image">
|
||||
<rect width="160" height="100" class="t-bg"/>${art}</svg>`;
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
// Copied from 04-greek-frieze/figures.ts via 13 (mockups never import across folders).
|
||||
// Black-figure painting kit: glaze (fill: var(--ink)) with "incised" detail lines scratched back to the clay (stroke: var(--inc)).
|
||||
// Every panel shares one 300-unit-tall coordinate space with the ground line at GROUND.
|
||||
|
||||
export const PANEL_H = 300;
|
||||
export const GROUND = 284;
|
||||
|
||||
type Arms = "spear" | "open" | "down" | "raise" | "reach" | "mourn" | "club" | "throw";
|
||||
interface Person {
|
||||
x: number; y?: number; s?: number; f?: 1 | -1; arms?: Arms;
|
||||
helmet?: boolean; shield?: boolean; robe?: boolean; cyclops?: boolean; kneel?: boolean;
|
||||
beard?: boolean; infant?: boolean; cup?: boolean;
|
||||
}
|
||||
|
||||
export const g = (t: string, body: string) => `<g transform="${t}">${body}</g>`;
|
||||
export const inc = (d: string, w = 1.6) => `<path class="inc" d="${d}" stroke-width="${w}"/>`;
|
||||
export const ink = (d: string) => `<path class="ink" d="${d}"/>`;
|
||||
// A limb: glaze stroke over a wider clay stroke, so it reads as incised where it crosses glaze.
|
||||
export const limb = (d: string, w = 6) =>
|
||||
`<path class="limb-edge" d="${d}" stroke-width="${w + 3}"/><path class="limb" d="${d}" stroke-width="${w}"/>`;
|
||||
|
||||
export function person(p: Person): string {
|
||||
const { x, y = GROUND, s = 1, f = 1, arms = "down" } = p;
|
||||
const lift = p.kneel ? 36 : 0;
|
||||
let legs = "";
|
||||
if (p.kneel) {
|
||||
legs = limb("M4,-44 L34,-40 L36,-2", 8) + limb("M-2,-44 L-24,-4 L-4,-2", 8);
|
||||
} else if (!p.robe) {
|
||||
legs = limb("M-2,-80 L-10,-40 L-24,-2 L-14,-2", 8) + limb("M4,-80 L14,-40 L30,-2 L40,-2", 8);
|
||||
}
|
||||
let upper = "";
|
||||
// back arm sits behind the torso
|
||||
if (arms === "open") upper += limb("M-8,-148 L-36,-176 L-44,-196");
|
||||
if (arms === "mourn") upper += limb("M-8,-148 L-14,-120 L-6,-104");
|
||||
upper += ink("M-3,-160 h8 v10 h-8 Z");
|
||||
upper += ink("M-13,-154 L15,-154 L9,-104 L-5,-104 Z");
|
||||
if (p.robe) {
|
||||
upper += ink("M-9,-108 L11,-108 L28,-2 L-24,-2 Z");
|
||||
upper += inc("M1,-100 L2,-8 M-5,-96 L-14,-8 M7,-96 L18,-8 M-20,-30 L24,-30");
|
||||
} else {
|
||||
upper += ink("M-8,-108 L10,-108 L20,-74 L-18,-74 Z");
|
||||
upper += inc("M1,-104 L1,-77 M-5,-100 L-10,-77 M7,-100 L12,-77");
|
||||
}
|
||||
upper += inc("M-9,-146 L11,-146 M-2,-150 L1,-112");
|
||||
// head
|
||||
upper += `<circle class="ink" cx="2" cy="-168" r="11"/>`;
|
||||
upper += ink("M10,-173 L18,-166 L10,-162 Z");
|
||||
if (p.beard) upper += ink("M-2,-162 L13,-162 L5,-146 Z") + inc("M2,-158 L5,-150", 1.2);
|
||||
if (p.cyclops) {
|
||||
upper += `<circle class="clay" cx="7" cy="-171" r="5"/><circle class="ink" cx="8.5" cy="-171" r="2.4"/>`;
|
||||
} else {
|
||||
upper += inc("M5,-171 h5", 1.4);
|
||||
}
|
||||
if (p.helmet) {
|
||||
upper += ink("M-12,-166 A14 14 0 0 1 15,-170 L15,-160 L9,-160 L9,-166 Z");
|
||||
upper += ink("M-18,-178 Q-8,-214 24,-194 Q4,-200 -8,-176 Z");
|
||||
upper += inc("M-10,-166 L13,-168 M4,-176 L4,-166");
|
||||
} else if (!p.cyclops) {
|
||||
upper += inc("M-6,-176 Q2,-182 10,-176", 1.3);
|
||||
}
|
||||
if (p.shield) {
|
||||
upper += `<circle class="ink" cx="12" cy="-124" r="32"/>`;
|
||||
upper += `<circle class="inc" cx="12" cy="-124" r="26" stroke-width="1.6"/>`;
|
||||
upper += `<circle class="inc" cx="12" cy="-124" r="7" stroke-width="1.6"/>`;
|
||||
}
|
||||
// front arm
|
||||
switch (arms) {
|
||||
case "spear":
|
||||
upper += limb("M10,-148 L30,-132 L40,-150");
|
||||
upper += limb("M-4,-52 L72,-222", 3.5) + ink("M72,-222 L66,-244 L80,-226 Z");
|
||||
break;
|
||||
case "open": upper += limb("M10,-148 L40,-178 L48,-198"); break;
|
||||
case "raise": upper += limb("M10,-148 L22,-182 L26,-214"); break;
|
||||
case "reach": upper += limb("M10,-148 L36,-140 L56,-146"); break;
|
||||
case "mourn": upper += limb("M10,-148 L26,-136 L12,-172"); break;
|
||||
case "club":
|
||||
upper += limb("M10,-148 L30,-130 L40,-142");
|
||||
upper += limb("M18,-96 L66,-214", 10) + ink("M60,-218 Q66,-236 78,-214 Z");
|
||||
break;
|
||||
case "throw":
|
||||
upper += limb("M10,-148 L-6,-182 L-12,-214");
|
||||
upper += `<circle class="ink" cx="-16" cy="-232" r="18"/>` + inc("M-26,-238 Q-16,-246 -6,-236 M-24,-226 l10,2", 1.4);
|
||||
break;
|
||||
default: upper += limb("M10,-148 L16,-104");
|
||||
}
|
||||
if (p.infant) {
|
||||
upper += `<ellipse class="ink" cx="58" cy="-150" rx="7.5" ry="17" transform="rotate(-14 58 -150)"/><circle class="ink" cx="63" cy="-174" r="7"/>`;
|
||||
upper += inc("M52,-158 l12,-3 M53,-148 l12,-3 M54,-138 l11,-3", 1.3);
|
||||
}
|
||||
if (p.cup) {
|
||||
upper += ink("M48,-162 h26 q-2,12 -13,12 q-11,0 -13,-12 Z M60,-150 v5 h-5 h10");
|
||||
upper += inc("M52,-158 h18", 1.2);
|
||||
}
|
||||
const body = legs + (lift ? g(`translate(0,${lift})`, upper) : upper);
|
||||
return g(`translate(${x},${y}) scale(${f * s},${s})`, body);
|
||||
}
|
||||
|
||||
export function trojanHorse(x: number, s: number): string {
|
||||
let b = "";
|
||||
b += ink("M-92,-32 h176 v12 h-176 Z");
|
||||
for (const lx of [-60, -42, 30, 48]) b += limb(`M${lx},-112 L${lx},-30`, 10);
|
||||
b += limb("M-80,-150 Q-108,-128 -98,-88", 6);
|
||||
b += ink("M-84,-164 h150 q10,0 10,12 v36 q0,14 -14,14 h-132 q-14,0 -14,-14 v-36 q0,-12 12,-12 Z");
|
||||
b += ink("M40,-156 L60,-236 L88,-230 L68,-140 Z");
|
||||
b += ink("M58,-238 Q70,-256 100,-244 L124,-208 Q120,-196 106,-202 L84,-224 Z M62,-246 L68,-266 L76,-244 Z");
|
||||
b += inc("M-76,-146 H62 M-76,-130 H62 M-76,-116 H62 M-40,-160 V-104 M0,-160 V-104 M36,-160 V-104");
|
||||
b += inc("M62,-228 l6,-6 l2,8 l6,-6 l2,8 l6,-6 M50,-196 l6,-6 l2,8 l6,-6", 1.4);
|
||||
b += `<circle class="inc" cx="90" cy="-232" r="3" stroke-width="1.6"/>`;
|
||||
b += inc("M-6,-150 h28 v22 h-28 Z", 1.4);
|
||||
for (const wx of [-66, 56]) {
|
||||
b += `<circle class="ink" cx="${wx}" cy="-12" r="13"/><circle class="inc" cx="${wx}" cy="-12" r="8" stroke-width="1.4"/>`;
|
||||
b += inc(`M${wx - 8},-12 h16 M${wx},-20 v16`, 1.2);
|
||||
}
|
||||
return g(`translate(${x},${GROUND}) scale(${s})`, b);
|
||||
}
|
||||
|
||||
export function ship(x: number, y: number, s: number, o: { sail?: boolean; tilt?: number; f?: 1 | -1 } = {}): string {
|
||||
const f = o.f ?? 1;
|
||||
let b = "";
|
||||
for (let i = 0; i < 9; i++) {
|
||||
const ox = -96 + i * 24;
|
||||
b += `<path class="oar" d="M${ox},-44 L${ox - 18},6" />`;
|
||||
}
|
||||
b += `<path class="rig" d="M-84,-218 L-130,-60 M84,-218 L120,-48 M0,-232 L150,-90"/>`;
|
||||
b += limb("M0,-50 L0,-236", 5);
|
||||
if (o.sail) {
|
||||
b += ink("M-78,-222 h156 v104 q-78,-18 -156,0 Z");
|
||||
let grid = "";
|
||||
for (let gx = -58; gx < 78; gx += 20) grid += `M${gx},-220 V-122 `;
|
||||
grid += "M-76,-196 H76 M-76,-172 H76 M-76,-148 H76";
|
||||
b += inc(grid, 1.3);
|
||||
}
|
||||
b += limb("M-86,-222 L86,-222", 4);
|
||||
for (let i = 0; i < 8; i++) b += `<circle class="ink" cx="${-84 + i * 24}" cy="-62" r="6.5"/>`;
|
||||
b += ink("M-160,-104 Q-150,-52 -108,-30 L118,-30 L178,-36 L132,-46 L140,-84 L128,-86 Q122,-54 100,-54 L-100,-54 Q-140,-58 -150,-104 Z");
|
||||
b += inc("M-112,-40 H120 M-118,-48 H104", 1.4);
|
||||
b += `<circle class="clay" cx="122" cy="-44" r="4.5"/><circle class="ink" cx="123" cy="-44" r="2"/>`;
|
||||
return g(`translate(${x},${y}) rotate(${o.tilt ?? 0}) scale(${f * s},${s})`, b);
|
||||
}
|
||||
|
||||
export function waves(x0: number, x1: number, y: number, size = 1): string {
|
||||
let d = "";
|
||||
const step = 36 * size;
|
||||
for (let x = x0; x < x1 - step / 2; x += step) {
|
||||
d += `M${x},${y} C${x + 8 * size},${y - 22 * size} ${x + 34 * size},${y - 24 * size} ${x + 34 * size},${y - 8 * size} C${x + 34 * size},${y} ${x + 22 * size},${y + 2 * size} ${x + 20 * size},${y - 6 * size} `;
|
||||
}
|
||||
return `<path class="wave" d="${d}" stroke-width="${4 * size}"/><path class="wave" d="M${x0},${y + 2} H${x1}" stroke-width="3"/>`;
|
||||
}
|
||||
|
||||
function stele(x: number): string {
|
||||
return g(`translate(${x},${GROUND})`,
|
||||
ink("M-36,0 v-12 h72 v12 Z M-24,-12 V-150 L0,-178 L24,-150 V-12 Z") +
|
||||
inc("M-18,-146 H18 M-14,-60 H14 M-14,-48 H14 M-14,-36 H14") +
|
||||
`<circle class="inc" cx="0" cy="-112" r="12" stroke-width="1.6"/><circle class="inc" cx="0" cy="-112" r="5" stroke-width="1.2"/>`);
|
||||
}
|
||||
|
||||
const bolt = (x: number, y: number, s: number) =>
|
||||
g(`translate(${x},${y}) scale(${s})`, ink("M0,0 L22,0 L10,34 L24,34 L-6,92 L2,48 L-12,48 Z"));
|
||||
|
||||
function cave(w: number): string {
|
||||
return ink(`M0,0 H${w} V${PANEL_H} H${w - 30} Q${w - 20},${66} ${w / 2},${58} Q30,66 32,${PANEL_H} H0 Z`) +
|
||||
inc(`M${w - 22},120 q-6,-30 -14,-48 M20,150 q6,-40 18,-70 M${w * 0.3},40 q30,-6 60,-2 M${w * 0.62},44 q24,0 46,10`, 1.6);
|
||||
}
|
||||
|
||||
export interface PanelArt { w: number; art: string; inscription?: "dark" | "light"; inscrEnd?: boolean }
|
||||
|
||||
const ground = (w: number) => `<path class="ground" d="M0,${GROUND} H${w}"/>`;
|
||||
|
||||
export const PANELS: Record<string, PanelArt> = {
|
||||
"the-horse-and-the-infant": { w: 370, art: trojanHorse(132, 0.9) + person({ x: 300, f: -1, arms: "reach", helmet: true, infant: true }) },
|
||||
"just-a-man": {
|
||||
w: 240,
|
||||
art: person({ x: 96, arms: "mourn", helmet: true, beard: true }) +
|
||||
limb("M178,284 L192,70", 3.5) + ink("M192,70 L186,48 L200,66 Z") +
|
||||
`<circle class="ink" cx="176" cy="250" r="32"/><circle class="inc" cx="176" cy="250" r="26" stroke-width="1.6"/>` +
|
||||
inc("M162,236 l28,28 M190,236 l-28,28", 1.4),
|
||||
},
|
||||
"full-speed-ahead": { w: 390, art: waves(0, 390, 290) + ship(190, 276, 1, { sail: true }) },
|
||||
"open-arms": {
|
||||
w: 300,
|
||||
art: person({ x: 92, arms: "open", beard: true }) + person({ x: 214, f: -1, arms: "reach", robe: true }),
|
||||
},
|
||||
"warrior-of-the-mind": {
|
||||
w: 340,
|
||||
art: person({ x: 98, arms: "spear", helmet: true, shield: true, robe: true }) +
|
||||
person({ x: 246, f: -1, arms: "spear", helmet: true, shield: true, beard: true }),
|
||||
},
|
||||
polyphemus: {
|
||||
w: 340,
|
||||
art: person({ x: 76, arms: "reach", beard: true, cup: true }) +
|
||||
person({ x: 252, f: -1, s: 1.2, arms: "club", cyclops: true, beard: true }),
|
||||
},
|
||||
survive: {
|
||||
w: 340, inscription: "light",
|
||||
art: person({ x: 214, f: -1, s: 1.02, arms: "down", cyclops: true, beard: true }) +
|
||||
person({ x: 82, s: 0.62, arms: "mourn", kneel: true }) + person({ x: 120, s: 0.62, arms: "reach" }) + cave(340),
|
||||
},
|
||||
"remember-them": {
|
||||
w: 310,
|
||||
art: stele(155) + person({ x: 62, arms: "mourn", kneel: true, beard: true }) + person({ x: 250, f: -1, arms: "mourn", robe: true }),
|
||||
},
|
||||
"my-goodbye": {
|
||||
w: 400, inscrEnd: true,
|
||||
art: waves(160, 400, 290) + person({ x: 78, s: 1.15, arms: "throw", cyclops: true, beard: true }) +
|
||||
ship(292, 276, 0.62, { sail: true }),
|
||||
},
|
||||
storm: {
|
||||
w: 350,
|
||||
art: bolt(52, 40, 1) + bolt(282, 52, 0.8) + ship(176, 252, 0.86, { tilt: -9 }) + waves(0, 350, 278, 1.3) + waves(18, 350, 296, 0.9),
|
||||
},
|
||||
};
|
||||
|
||||
const escXml = (s: string) => s.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]!);
|
||||
|
||||
/** The painted scene for a song: figures plus its name written in the field, as on a vase. */
|
||||
export function panelSvg(id: string, title: string, withTitle = true): string {
|
||||
const p = PANELS[id] ?? { w: 260, art: person({ x: 130 }) };
|
||||
const light = p.inscription === "light";
|
||||
const x = p.inscrEnd ? p.w - 16 : light ? 46 : 16;
|
||||
const label = withTitle
|
||||
? `<text class="inscr${light ? " inscr--light" : ""}" x="${x}" y="${light ? 32 : 28}"${p.inscrEnd ? ' text-anchor="end"' : ""}>${escXml(title.toUpperCase())}</text>`
|
||||
: "";
|
||||
return `<svg class="scene" viewBox="0 0 ${p.w} ${PANEL_H}" aria-hidden="true" focusable="false">${p.art}${ground(p.w)}${label}</svg>`;
|
||||
}
|
||||
|
||||
export function panelWidth(id: string): number {
|
||||
return PANELS[id]?.w ?? 260;
|
||||
}
|
||||
|
||||
/** Narrow ladder band between consecutive songs of one saga. */
|
||||
export function ladderSvg(): string {
|
||||
let d = "M5,0 V300 M21,0 V300 ";
|
||||
for (let y = 8; y < 300; y += 12) d += `M5,${y} H21 `;
|
||||
return `<svg class="sep-art" viewBox="0 0 26 300" aria-hidden="true"><path class="rule" d="${d}"/></svg>`;
|
||||
}
|
||||
|
||||
export function palmette(cx: number, cy: number, flip = false): string {
|
||||
let leaves = "";
|
||||
for (let i = -3; i <= 3; i++) {
|
||||
leaves += `<ellipse class="ink" cx="0" cy="-26" rx="5.5" ry="18" transform="rotate(${i * 22})"/>`;
|
||||
}
|
||||
const volutes = `<path class="vol" d="M0,0 C-10,10 -28,8 -28,-4 C-28,-12 -18,-14 -16,-6 M0,0 C10,10 28,8 28,-4 C28,-12 18,-14 16,-6"/>`;
|
||||
return g(`translate(${cx},${cy}) scale(1,${flip ? -1 : 1})`, leaves + `<circle class="ink" cx="0" cy="-2" r="7"/>` + volutes);
|
||||
}
|
||||
|
||||
/** A saga boundary: palmettes framing the saga's name, painted vertically. */
|
||||
export function sagaSvg(name: string, gap: number): string {
|
||||
const tally = gap > 0
|
||||
? `<text class="tally" x="66" y="296" text-anchor="middle">${gap} ${gap === 1 ? "year" : "years"} later</text>`
|
||||
: "";
|
||||
return `<svg class="sep-art" viewBox="0 0 132 300" aria-hidden="true">
|
||||
<path class="rule" d="M4,0 V300 M128,0 V300"/>
|
||||
${palmette(66, 52)}${palmette(66, gap > 0 ? 226 : 248, true)}
|
||||
<text class="saga-name" transform="translate(71,150) rotate(-90)" text-anchor="middle">${escXml(name.replace(/^The /, "").toUpperCase())}</text>
|
||||
${tally}
|
||||
</svg>`;
|
||||
}
|
||||
|
||||
/** Elapsed story time between two songs, painted as a tally of years. */
|
||||
export function gapSvg(gap: number): string {
|
||||
const w = 40 + gap * 24;
|
||||
let bars = "";
|
||||
for (let i = 0; i < gap; i++) bars += `M${20 + i * 24 + 6},120 V180 `;
|
||||
return `<svg class="sep-art" viewBox="0 0 ${w} 300" aria-hidden="true">
|
||||
<path class="rule" d="M4,0 V300 M${w - 4},0 V300"/>
|
||||
<path class="tally-bars" d="${bars}"/>
|
||||
<text class="tally" transform="translate(${w / 2 + 4},250) rotate(-90)" >+${gap} yr</text>
|
||||
</svg>`;
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
// Copied from 13: the two frieze "curtains", full-stage SVGs in the 04 black-figure kit. In 14 they are
|
||||
// scaled with "meet", so the whole band shows beside the side panel; colours come from CSS custom properties.
|
||||
import { GROUND, PANEL_H, g, inc, ink, limb, palmette, person, PANELS, ship, waves } from "./figures";
|
||||
|
||||
export const VB_W = 1440;
|
||||
export const VB_H = 850;
|
||||
/** Band layout (stage units): top border, painted field (panels are 300 units tall, drawn at SCALE), bottom border. */
|
||||
const BAND_TOP = 146;
|
||||
const FIELD_Y = 222;
|
||||
const SCALE = 1.24;
|
||||
/** Where the painted ground line falls on the stage (also the 3D horizon at the start of the morph). */
|
||||
export const GROUND_Y = FIELD_Y + GROUND * SCALE; // ≈ 574
|
||||
const BOT_Y = GROUND_Y + 14;
|
||||
const BAND_BOT = BOT_Y + 100;
|
||||
/** Centre of the cave mouth in the Cyclops frieze, in stage units: the zoom goes through here. */
|
||||
export const MOUTH = { x: 720, y: FIELD_Y + (GROUND - 100) * SCALE };
|
||||
|
||||
const esc = (s: string) => s.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]!);
|
||||
|
||||
function defs(id: string): string {
|
||||
const meander = (key: string, y: number) =>
|
||||
`<pattern id="${id}-${key}" y="${y}" width="28" height="28" patternUnits="userSpaceOnUse"><path class="mean" d="M0 25.2H28M4.2 25.2V3H24V20.3H9.8V8.4H18.2V14.7" /></pattern>`;
|
||||
return `<defs>
|
||||
${meander("mt", BAND_TOP + 14)}${meander("mb", BOT_Y + 8)}
|
||||
<pattern id="${id}-tongues" y="${BAND_TOP + 50}" width="18" height="22" patternUnits="userSpaceOnUse">
|
||||
<path class="ink" d="M2 0H16V13A7 7 0 0 1 2 13Z" />
|
||||
</pattern>
|
||||
<pattern id="${id}-rays" y="${BOT_Y + 46}" width="32" height="54" patternUnits="userSpaceOnUse">
|
||||
<path class="ink" d="M2 54L16 6L30 54Z" />
|
||||
</pattern>
|
||||
</defs>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared chrome, split at the ground line into a top half (surround, band, top border) and a bottom half,
|
||||
* so the morph can part them along the line that becomes the horizon.
|
||||
*/
|
||||
function chrome(id: string) {
|
||||
const X0 = -200, W = VB_W + 400;
|
||||
const rule = (y: number) => `<path class="rule" d="M${X0} ${y}H${X0 + W}"/>`;
|
||||
const frame = (y: number) => `<path class="frame-rule" d="M${X0} ${y}H${X0 + W}M${X0} ${y + 5}H${X0 + W}"/>`;
|
||||
const top = `<g class="f-top">
|
||||
<rect class="f-surround" x="${X0}" y="-600" width="${W}" height="${GROUND_Y + 600}"/>
|
||||
<rect class="f-band" x="${X0}" y="${BAND_TOP}" width="${W}" height="${GROUND_Y - BAND_TOP}"/>
|
||||
${frame(BAND_TOP - 12)}${rule(BAND_TOP + 8)}
|
||||
<rect x="${X0}" y="${BAND_TOP + 14}" width="${W}" height="28" fill="url(#${id}-mt)"/>
|
||||
${rule(BAND_TOP + 46)}
|
||||
<rect x="${X0}" y="${BAND_TOP + 50}" width="${W}" height="22" fill="url(#${id}-tongues)"/>
|
||||
</g>`;
|
||||
const bottom = `<g class="f-bottom">
|
||||
<rect class="f-surround" x="${X0}" y="${GROUND_Y}" width="${W}" height="${VB_H - GROUND_Y + 600}"/>
|
||||
<rect class="f-band" x="${X0}" y="${GROUND_Y}" width="${W}" height="${BAND_BOT - GROUND_Y}"/>
|
||||
${rule(BOT_Y + 2)}
|
||||
<rect x="${X0}" y="${BOT_Y + 8}" width="${W}" height="28" fill="url(#${id}-mb)"/>
|
||||
${rule(BOT_Y + 40)}
|
||||
<rect x="${X0}" y="${BOT_Y + 46}" width="${W}" height="54" fill="url(#${id}-rays)"/>
|
||||
${frame(BAND_BOT + 6)}
|
||||
</g>`;
|
||||
return { top, bottom };
|
||||
}
|
||||
|
||||
const placed = (x: number, art: string) => g(`translate(${x},${FIELD_Y}) scale(${SCALE})`, art);
|
||||
const inscription = (x: number, text: string, anchor: "start" | "middle" | "end" = "start") =>
|
||||
`<text class="inscr" x="${x}" y="${FIELD_Y + 34}" text-anchor="${anchor}">${esc(text.toUpperCase())}</text>`;
|
||||
|
||||
/** A painted saga column (palmettes framing the saga's name), as in 04. */
|
||||
function sagaColumn(x: number, name: string): string {
|
||||
return placed(x, `<path class="rule" d="M4,0 V${PANEL_H} M128,0 V${PANEL_H}"/>${palmette(66, 52)}${palmette(66, 248, true)}
|
||||
<text class="saga-name" transform="translate(71,150) rotate(-90)" text-anchor="middle">${esc(name.toUpperCase())}</text>`);
|
||||
}
|
||||
const ladder = (x: number) => {
|
||||
let d = "M5,0 V300 M21,0 V300 ";
|
||||
for (let y = 8; y < 300; y += 12) d += `M5,${y} H21 `;
|
||||
return placed(x, `<path class="rule" d="${d}"/>`);
|
||||
};
|
||||
|
||||
/** Beat 1: the fall of Troy. */
|
||||
export function troyFrieze(): string {
|
||||
const id = "fz1";
|
||||
const c = chrome(id);
|
||||
const u = (n: number) => n * SCALE;
|
||||
let x = 22;
|
||||
let figs = sagaColumn(x, "Troy Saga");
|
||||
x += u(132) + 18;
|
||||
figs += placed(x, PANELS["the-horse-and-the-infant"]!.art) + inscription(x + 18, "The Horse and the Infant");
|
||||
x += u(370);
|
||||
figs += ladder(x);
|
||||
x += u(26) + 6;
|
||||
figs += placed(x, PANELS["just-a-man"]!.art) + inscription(x + 18, "Just a Man");
|
||||
x += u(240);
|
||||
figs += ladder(x);
|
||||
x += u(26) + 6;
|
||||
figs += placed(x, waves(0, 330, 290) + ship(170, 276, 0.9, { sail: true })) + inscription(x + 18, "Full Speed Ahead");
|
||||
return `<svg class="frieze frieze--troy" viewBox="0 0 ${VB_W} ${VB_H}" preserveAspectRatio="xMidYMid meet" aria-hidden="true">
|
||||
${defs(id)}
|
||||
${c.top}${c.bottom}
|
||||
<g class="f-figs">${figs}</g>
|
||||
<path class="ground horizon-line" d="M-200 ${GROUND_Y}H${VB_W + 200}"/>
|
||||
</svg>`;
|
||||
}
|
||||
|
||||
/* ---------- Cyclops frieze: crew, cave mouth, Polyphemus, sheep ---------- */
|
||||
|
||||
function sheep(x: number, s: number, f: 1 | -1 = 1): string {
|
||||
let b = "";
|
||||
b += limb("M-14,-14 L-16,0", 4) + limb("M-4,-14 L-3,0", 4) + limb("M12,-14 L13,0", 4) + limb("M20,-14 L22,0", 4);
|
||||
b += ink("M-24,-30 Q-26,-46 -10,-48 Q2,-58 14,-48 Q30,-50 28,-32 Q32,-16 16,-14 L-14,-14 Q-30,-14 -24,-30 Z");
|
||||
b += inc("M-14,-38 q4,-5 8,0 q4,-5 8,0 q4,-5 8,0 M-16,-26 q4,-5 8,0 q4,-5 8,0 q4,-5 8,0 q4,-5 8,0", 1.3);
|
||||
b += ink("M26,-40 L40,-44 Q46,-38 40,-30 L28,-30 Z");
|
||||
b += `<circle class="clay" cx="38" cy="-39" r="1.6"/>`;
|
||||
return g(`translate(${x},${GROUND}) scale(${f * s},${s})`, b);
|
||||
}
|
||||
|
||||
/** The rock and the arch of the cave mouth; the mouth itself is cut out with a mask so the 3D cave shows through. */
|
||||
const MOUTH_W = 120; // half-width of the arch, panel units
|
||||
const MOUTH_H = 200; // height of the arch above the ground line
|
||||
function mouthPath(cx: number): string {
|
||||
return `M${cx - MOUTH_W},${GROUND} V${GROUND - 92} Q${cx - MOUTH_W},${GROUND - MOUTH_H} ${cx},${GROUND - MOUTH_H} Q${cx + MOUTH_W},${GROUND - MOUTH_H} ${cx + MOUTH_W},${GROUND - 92} V${GROUND} Z`;
|
||||
}
|
||||
function caveRock(cx: number): string {
|
||||
const r = MOUTH_W + 46;
|
||||
let b = ink(`M${cx - r - 40},${GROUND} Q${cx - r - 30},${GROUND - 170} ${cx - r + 20},${GROUND - 222} Q${cx - 60},${GROUND - 268} ${cx + 10},${GROUND - 262} Q${cx + r - 10},${GROUND - 270} ${cx + r + 18},${GROUND - 200} Q${cx + r + 46},${GROUND - 110} ${cx + r + 40},${GROUND} Z`);
|
||||
b += `<path class="inc" d="${mouthPath(cx)}" stroke-width="5" transform="translate(${cx},${GROUND}) scale(1.06) translate(${-cx},${-GROUND})"/>`;
|
||||
b += inc(`M${cx - r - 18},${GROUND - 120} q18,-30 46,-40 M${cx - r + 4},${GROUND - 190} q34,-24 70,-26 M${cx + r - 30},${GROUND - 214} q30,6 44,40 M${cx + r + 10},${GROUND - 80} q8,-30 4,-60 M${cx - 40},${GROUND - 246} q40,-8 84,2`, 2);
|
||||
return b;
|
||||
}
|
||||
|
||||
export function cyclopsFrieze(): string {
|
||||
const id = "fz4";
|
||||
const c = chrome(id);
|
||||
const u = (n: number) => n * SCALE;
|
||||
const panelX = (stageX: number) => (stageX - 0) / SCALE; // field art is placed at x=0
|
||||
const cx = panelX(MOUTH.x);
|
||||
let art = "";
|
||||
// crew on the left: Odysseus offers the cup, two men behind him
|
||||
art += person({ x: panelX(250), s: 0.82, arms: "spear", helmet: true, shield: true });
|
||||
art += person({ x: panelX(326), s: 0.82, arms: "down", helmet: true });
|
||||
art += person({ x: panelX(398), s: 0.94, arms: "reach", beard: true, cup: true });
|
||||
art += caveRock(cx);
|
||||
// Polyphemus at his door, then the flock
|
||||
art += person({ x: panelX(1060), f: -1, s: 1.16, arms: "club", cyclops: true, beard: true });
|
||||
art += sheep(panelX(1180), 0.95) + sheep(panelX(1275), 0.85, -1) + sheep(panelX(1370), 0.92);
|
||||
let figs = sagaColumn(22, "Cyclops Saga");
|
||||
figs += placed(0, art);
|
||||
figs += inscription(u(132) + 60, "Polyphemus");
|
||||
figs += inscription(VB_W - 34, "Survive", "end");
|
||||
const mouthStage = `translate(0,${FIELD_Y}) scale(${SCALE})`;
|
||||
return `<svg class="frieze frieze--cyclops" viewBox="0 0 ${VB_W} ${VB_H}" preserveAspectRatio="xMidYMid meet" aria-hidden="true">
|
||||
${defs(id)}
|
||||
<mask id="${id}-mouth" maskUnits="userSpaceOnUse" x="-4000" y="-4000" width="10000" height="10000">
|
||||
<rect x="-4000" y="-4000" width="10000" height="10000" fill="#fff"/>
|
||||
<path d="${mouthPath(cx)}" transform="${mouthStage}" fill="#000"/>
|
||||
</mask>
|
||||
<radialGradient id="${id}-glow" cx="0.5" cy="0.92" r="0.75">
|
||||
<stop offset="0" class="glow-a"/><stop offset="0.55" class="glow-b"/><stop offset="1" class="glow-c"/>
|
||||
</radialGradient>
|
||||
<g class="f-zoom">
|
||||
<g mask="url(#${id}-mouth)">
|
||||
${c.top}${c.bottom}
|
||||
<g class="f-figs">${figs}</g>
|
||||
<path class="ground" d="M-200 ${GROUND_Y}H${VB_W + 200}"/>
|
||||
</g>
|
||||
<path class="mouth-fill" d="${mouthPath(cx)}" transform="${mouthStage}" fill="url(#${id}-glow)"/>
|
||||
</g>
|
||||
</svg>`;
|
||||
}
|
||||
@@ -1,3 +1,265 @@
|
||||
import { songs } from "../../data/sample";
|
||||
import { mountCredits } from "../../shared/credits";
|
||||
import { hereAt } from "./chart";
|
||||
import { cyclopsFrieze, GROUND_Y, MOUTH, troyFrieze, VB_H, VB_W } from "./frieze";
|
||||
import { createPanel, TABS, type Tab } from "./panel";
|
||||
import { VoyageScene, ease, webglAvailable, type Look } from "./scene";
|
||||
|
||||
mountCredits();
|
||||
|
||||
/* ---------- beats (13's five, each with the song the panel follows) ---------- */
|
||||
|
||||
interface Beat { short: string; eyebrow: string; caption: string; songId: string }
|
||||
const BEATS: Beat[] = [
|
||||
{ short: "Frieze", eyebrow: "The Troy Saga · year 0", caption: "Troy falls", songId: "the-horse-and-the-infant" },
|
||||
{ short: "To sea", eyebrow: "Between sagas · a year at sea", caption: "Out on the open sea", songId: "full-speed-ahead" },
|
||||
{ short: "Landfall", eyebrow: "The Cyclops Saga · year 1", caption: "Landfall: Cyclops' Island", songId: "polyphemus" },
|
||||
{ short: "Curtain", eyebrow: "The Cyclops Saga", caption: "Polyphemus", songId: "polyphemus" },
|
||||
{ short: "Cave", eyebrow: "Inside the cave", caption: "Into the cave", songId: "survive" },
|
||||
];
|
||||
const SEG_DUR = [1.8, 2.0, 1.2, 1.6];
|
||||
const HOLD = 3.4;
|
||||
|
||||
const LOOKS: Record<Look, string> = { 2: "Two worlds", 3: "Frieze-led" };
|
||||
|
||||
/* ---------- params ---------- */
|
||||
|
||||
const params = new URLSearchParams(location.search);
|
||||
const reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
||||
const clampBeat = (n: number) => Math.min(5, Math.max(1, Math.round(n) || 1));
|
||||
const startBeat = clampBeat(Number(params.get("beat") ?? 1));
|
||||
const freezeT = params.has("t") ? Math.min(1, Math.max(0, Number(params.get("t")) || 0)) : null;
|
||||
let look: Look = params.get("look") === "3" ? 3 : 2;
|
||||
const startTab: Tab = TABS.some((t) => t.id === params.get("tab")) ? (params.get("tab") as Tab) : "about";
|
||||
const startOpen = params.get("panel") !== "0";
|
||||
|
||||
/* ---------- DOM ---------- */
|
||||
|
||||
const app = document.getElementById("app")!;
|
||||
const esc = (s: string) => s.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]!);
|
||||
app.className = "shell";
|
||||
app.innerHTML = `
|
||||
<section class="stage" id="stage" aria-label="The voyage, in five beats">
|
||||
<div class="stage__three" id="three"></div>
|
||||
<div class="stage__fallback" id="fallback" hidden><p>3D needs WebGL; the frieze beats still play.</p></div>
|
||||
<div class="frieze-host frieze-host--troy" id="troy">${troyFrieze()}</div>
|
||||
<div class="frieze-host frieze-host--cyclops" id="cyclops">${cyclopsFrieze()}</div>
|
||||
<div class="cut" id="cut" aria-hidden="true"></div>
|
||||
<header class="cap" id="cap" aria-live="polite">
|
||||
<p class="cap__eyebrow" id="cap-eyebrow"></p>
|
||||
<h1 class="cap__title" id="cap-title"></h1>
|
||||
<button type="button" class="back" id="back" hidden>Back to sea</button>
|
||||
</header>
|
||||
<nav class="bar" aria-label="Beats">
|
||||
<button type="button" class="bar__play" id="play" aria-pressed="false">Play</button>
|
||||
<button type="button" class="bar__step" id="prev" aria-label="Previous beat">←</button>
|
||||
<ol class="dots" id="dots">
|
||||
${BEATS.map((b, i) => `<li><button type="button" data-beat="${i + 1}"><span class="dots__n">${i + 1}</span><span class="dots__label">${esc(b.short)}</span></button></li>`).join("")}
|
||||
</ol>
|
||||
<button type="button" class="bar__step" id="next" aria-label="Next beat">→</button>
|
||||
<div class="looks" role="group" aria-label="Look">
|
||||
<span class="looks__label">Look</span>
|
||||
${([2, 3] as Look[]).map((l) => `<button type="button" data-look="${l}" title="${LOOKS[l]}">${l}</button>`).join('<span class="looks__sep" aria-hidden="true">·</span>')}
|
||||
<span class="looks__name" id="look-name"></span>
|
||||
</div>
|
||||
</nav>
|
||||
</section>
|
||||
<aside class="panel" id="panel" aria-label="Song companion"></aside>`;
|
||||
|
||||
const $ = (id: string) => document.getElementById(id)!;
|
||||
const stage = $("stage");
|
||||
const troy = $("troy");
|
||||
const cyclops = $("cyclops");
|
||||
const cut = $("cut");
|
||||
const capEl = $("cap");
|
||||
const playBtn = $("play") as HTMLButtonElement;
|
||||
const backBtn = $("back") as HTMLButtonElement;
|
||||
const troyParts = {
|
||||
figs: troy.querySelector<SVGGElement>(".f-figs")!,
|
||||
top: troy.querySelector<SVGGElement>(".f-top")!,
|
||||
bottom: troy.querySelector<SVGGElement>(".f-bottom")!,
|
||||
horizon: troy.querySelector<SVGPathElement>(".horizon-line")!,
|
||||
};
|
||||
const cyParts = {
|
||||
zoom: cyclops.querySelector<SVGGElement>(".f-zoom")!,
|
||||
mouth: cyclops.querySelector<SVGPathElement>(".mouth-fill")!,
|
||||
};
|
||||
|
||||
const setParam = (k: string, v: string | null) => {
|
||||
const u = new URL(location.href);
|
||||
if (v === null) u.searchParams.delete(k);
|
||||
else u.searchParams.set(k, v);
|
||||
history.replaceState(null, "", u);
|
||||
};
|
||||
const panelEl = $("panel");
|
||||
const panel = createPanel(panelEl, {
|
||||
tab: startTab,
|
||||
open: startOpen,
|
||||
reduced,
|
||||
onTab: (t) => setParam("tab", t),
|
||||
onOpen: (o) => { app.dataset.panel = o ? "open" : "closed"; setParam("panel", o ? null : "0"); },
|
||||
});
|
||||
app.dataset.panel = startOpen ? "open" : "closed";
|
||||
const here = panel.here;
|
||||
|
||||
let scene: VoyageScene | null = null;
|
||||
if (webglAvailable()) {
|
||||
try { scene = new VoyageScene($("three"), reduced); } catch { scene = null; }
|
||||
}
|
||||
if (!scene) $("fallback").hidden = false;
|
||||
|
||||
/* ---------- state ---------- */
|
||||
|
||||
let p = freezeT !== null ? Math.max(0, startBeat - 2 + freezeT) : startBeat - 1;
|
||||
let anim: { from: number; to: number; start: number; dur: number } | null = null;
|
||||
let cutting = false;
|
||||
let playing = false;
|
||||
let holdUntil = 0;
|
||||
let shownBeat = -1;
|
||||
|
||||
const clamp01 = (x: number) => Math.min(1, Math.max(0, x));
|
||||
const easeIn = (x: number) => { const t = clamp01(x); return t * t * t; };
|
||||
const easeInOut = (x: number) => { const t = clamp01(x); return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; };
|
||||
|
||||
/* ---------- render: everything is a function of p ---------- */
|
||||
|
||||
function renderDom() {
|
||||
const s0 = clamp01(p);
|
||||
troy.hidden = s0 >= 1;
|
||||
if (!troy.hidden) {
|
||||
const flat = ease(s0 / 0.32);
|
||||
troyParts.figs.setAttribute("transform", `translate(0,${GROUND_Y}) scale(1,${(1 - flat).toFixed(4)}) translate(0,${-GROUND_Y})`);
|
||||
troyParts.figs.style.opacity = String(1 - ease((s0 - 0.1) / 0.24));
|
||||
const part = easeInOut((s0 - 0.12) / 0.5);
|
||||
troyParts.top.setAttribute("transform", `translate(0,${(-part * (GROUND_Y + 700)).toFixed(1)})`);
|
||||
troyParts.bottom.setAttribute("transform", `translate(0,${(part * (VB_H - GROUND_Y + 700)).toFixed(1)})`);
|
||||
troyParts.horizon.style.opacity = String(1 - ease((s0 - 0.5) / 0.22));
|
||||
}
|
||||
|
||||
// "You are here" on the route chart (Paths tab) follows the ship from open sea to the island.
|
||||
const [hx, hy] = hereAt(ease((p - 1.1) / 0.8));
|
||||
here.setAttribute("transform", `translate(${hx.toFixed(1)},${hy.toFixed(1)})`);
|
||||
|
||||
cyclops.hidden = p <= 2;
|
||||
if (!cyclops.hidden) {
|
||||
const drop = easeInOut(p - 2);
|
||||
cyclops.style.transform = `translateY(${((drop - 1) * 102).toFixed(2)}%)`;
|
||||
const z = clamp01(p - 3);
|
||||
cyParts.mouth.style.opacity = String(1 - ease(z / 0.28));
|
||||
const scale = 1 + 15 * easeIn((z - 0.08) / 0.92);
|
||||
cyParts.zoom.setAttribute("transform", `translate(${MOUTH.x},${MOUTH.y}) scale(${scale.toFixed(4)}) translate(${-MOUTH.x},${-MOUTH.y})`);
|
||||
cyclops.style.opacity = String(1 - ease((z - 0.72) / 0.26));
|
||||
}
|
||||
stage.dataset.world = p < 0.5 ? "frieze" : p < 2.5 ? "sea" : p < 3.5 ? "frieze" : "cave";
|
||||
|
||||
// Captions dip and swap at each transition's midpoint; the panel follows the same beat.
|
||||
const near = Math.round(p);
|
||||
const d = Math.abs(p - near);
|
||||
capEl.style.opacity = String(clamp01(1 - d * 3.2));
|
||||
if (near !== shownBeat) {
|
||||
shownBeat = near;
|
||||
const b = BEATS[near]!;
|
||||
$("cap-eyebrow").textContent = b.eyebrow;
|
||||
$("cap-title").textContent = b.caption;
|
||||
backBtn.hidden = near !== 4;
|
||||
panel.setSong(songs.find((s) => s.id === b.songId)!);
|
||||
}
|
||||
const target = anim ? anim.to : Math.round(p);
|
||||
document.querySelectorAll<HTMLButtonElement>("#dots button").forEach((btn, i) => {
|
||||
if (i === target) btn.setAttribute("aria-current", "step");
|
||||
else btn.removeAttribute("aria-current");
|
||||
});
|
||||
($("prev") as HTMLButtonElement).disabled = target <= 0;
|
||||
($("next") as HTMLButtonElement).disabled = target >= 4;
|
||||
}
|
||||
|
||||
/* ---------- navigation ---------- */
|
||||
|
||||
function go(to: number) {
|
||||
if (freezeT !== null || cutting) return;
|
||||
to = Math.min(4, Math.max(0, to));
|
||||
if (anim) { p = anim.to; anim = null; }
|
||||
if (to === p) return;
|
||||
if (reduced || Math.abs(to - p) !== 1) crossCut(to);
|
||||
else anim = { from: p, to, start: performance.now(), dur: SEG_DUR[Math.min(p, to)]! * 1000 };
|
||||
}
|
||||
|
||||
function crossCut(to: number) {
|
||||
cutting = true;
|
||||
cut.classList.add("is-on");
|
||||
window.setTimeout(() => {
|
||||
p = to;
|
||||
renderDom();
|
||||
cut.classList.remove("is-on");
|
||||
window.setTimeout(() => { cutting = false; holdUntil = performance.now() + HOLD * 1000; }, 380);
|
||||
}, reduced ? 260 : 300);
|
||||
}
|
||||
|
||||
function setPlaying(on: boolean) {
|
||||
playing = on;
|
||||
playBtn.textContent = on ? "Pause" : "Play";
|
||||
playBtn.setAttribute("aria-pressed", String(on));
|
||||
if (on) {
|
||||
if (Math.round(p) >= 4 && !anim) go(0);
|
||||
holdUntil = performance.now() + 1200;
|
||||
}
|
||||
}
|
||||
|
||||
function setLook(l: Look) {
|
||||
look = l;
|
||||
stage.dataset.look = String(l);
|
||||
document.body.dataset.look = String(l);
|
||||
scene?.setLook(l);
|
||||
panel.setLook(l);
|
||||
document.querySelectorAll<HTMLButtonElement>(".looks button").forEach((b) => b.setAttribute("aria-pressed", String(Number(b.dataset.look) === l)));
|
||||
$("look-name").textContent = LOOKS[l];
|
||||
setParam("look", String(l));
|
||||
}
|
||||
|
||||
playBtn.addEventListener("click", () => setPlaying(!playing));
|
||||
$("prev").addEventListener("click", () => { setPlaying(false); go((anim ? anim.to : p) - 1); });
|
||||
$("next").addEventListener("click", () => { setPlaying(false); go((anim ? anim.to : p) + 1); });
|
||||
backBtn.addEventListener("click", () => { setPlaying(false); go(1); });
|
||||
document.querySelectorAll<HTMLButtonElement>("#dots button").forEach((b) =>
|
||||
b.addEventListener("click", () => { setPlaying(false); go(Number(b.dataset.beat) - 1); }));
|
||||
document.querySelectorAll<HTMLButtonElement>(".looks button").forEach((b) =>
|
||||
b.addEventListener("click", () => setLook(Number(b.dataset.look) as Look)));
|
||||
window.addEventListener("keydown", (e) => {
|
||||
// Keys inside the panel (tabs, audio, links) belong to the panel.
|
||||
if (e.target instanceof Element && e.target.closest(".panel")) return;
|
||||
if (e.key === "ArrowRight") { setPlaying(false); go((anim ? anim.to : p) + 1); }
|
||||
else if (e.key === "ArrowLeft") { setPlaying(false); go((anim ? anim.to : p) - 1); }
|
||||
else if (e.key === " " && !(e.target instanceof HTMLButtonElement)) { e.preventDefault(); setPlaying(!playing); }
|
||||
});
|
||||
|
||||
/* ---------- loop ---------- */
|
||||
|
||||
const t0 = performance.now();
|
||||
function frame(now: number) {
|
||||
if (anim) {
|
||||
const k = clamp01((now - anim.start) / anim.dur);
|
||||
p = anim.from + (anim.to - anim.from) * k;
|
||||
if (k >= 1) { p = anim.to; anim = null; holdUntil = now + HOLD * 1000; }
|
||||
} else if (playing && !cutting && now >= holdUntil) {
|
||||
if (Math.round(p) >= 4) setPlaying(false);
|
||||
else go(Math.round(p) + 1);
|
||||
}
|
||||
renderDom();
|
||||
scene?.render(p, (now - t0) / 1000 + 2.2);
|
||||
requestAnimationFrame(frame);
|
||||
}
|
||||
|
||||
setLook(look);
|
||||
renderDom();
|
||||
requestAnimationFrame(frame);
|
||||
if (params.get("play") === "1" && freezeT === null) setPlaying(true);
|
||||
|
||||
/** The 3D horizon must start exactly on the frieze's painted ground line, wherever the "meet"-scaled SVG puts it. */
|
||||
function syncHorizon() {
|
||||
const w = stage.clientWidth, h = stage.clientHeight;
|
||||
if (!w || !h) return;
|
||||
const s = Math.min(w / VB_W, h / VB_H);
|
||||
scene?.setHorizon(((GROUND_Y - VB_H / 2) * s + h / 2) / h);
|
||||
}
|
||||
new ResizeObserver(syncHorizon).observe(stage);
|
||||
syncHorizon();
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
// The persistent right-side companion: About · Paths · Lyrics · Fan works for the song of the current beat.
|
||||
import { motifsInSong, sagaOf, songsWithMotif } from "../../data/query";
|
||||
import { motifs, songs } from "../../data/sample";
|
||||
import type { Motif, Song } from "../../data/types";
|
||||
import { createAudioSlot } from "../../shared/audio-slot";
|
||||
import { createVideoCards } from "../../shared/video-cards";
|
||||
import { chartSvg } from "./chart";
|
||||
import { fanWorksFor, thumbSvg, TYPE_LABEL } from "./fanworks";
|
||||
import type { Look } from "./scene";
|
||||
|
||||
export type Tab = "about" | "paths" | "lyrics" | "fan";
|
||||
export const TABS: { id: Tab; label: string }[] = [
|
||||
{ id: "about", label: "About" },
|
||||
{ id: "paths", label: "Paths" },
|
||||
{ id: "lyrics", label: "Lyrics" },
|
||||
{ id: "fan", label: "Fan works" },
|
||||
];
|
||||
|
||||
/* The shared motif colours are tuned for dark pages; on vellum (look 2) they are re-inked darker, as in 12. */
|
||||
const INK: Record<string, string> = {
|
||||
warrior: "#93650b", "open-arms": "#b2472c", "just-a-man": "#2e5d8b", remember: "#3b7347",
|
||||
odysseus: "#5b3c20", athena: "#6a4a9d", polyphemus: "#8e1e24",
|
||||
};
|
||||
const SOFT3: Record<string, string> = { odysseus: "#e9d9a6" };
|
||||
|
||||
const esc = (s: string) => s.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]!);
|
||||
const byTrack = [...songs].sort((a, b) => a.track - b.track);
|
||||
|
||||
export interface Panel {
|
||||
setSong(song: Song): void;
|
||||
setLook(look: Look): void;
|
||||
setTab(tab: Tab): void;
|
||||
setOpen(open: boolean): void;
|
||||
/** The chart's "You are here" marker, so the stage can move it as the ship sails. */
|
||||
here: SVGGElement;
|
||||
}
|
||||
|
||||
export function createPanel(host: HTMLElement, opts: { tab: Tab; open: boolean; reduced: boolean; onTab(tab: Tab): void; onOpen(open: boolean): void }): Panel {
|
||||
let look: Look = 2;
|
||||
let tab = opts.tab;
|
||||
let song: Song = songs[0]!;
|
||||
let motifPick: string | null = null;
|
||||
let songPick: string | null = null;
|
||||
let swapTimer = 0;
|
||||
const color = (id: string) => (look === 2 ? INK[id] : SOFT3[id]) ?? motifs.find((m) => m.id === id)?.color ?? "currentColor";
|
||||
|
||||
host.innerHTML = `
|
||||
<button type="button" class="panel__tab" id="panel-open" aria-controls="panel-body" aria-expanded="false">
|
||||
<span class="panel__tab-arrow" aria-hidden="true">‹</span>
|
||||
<span class="panel__tab-n" id="panel-tab-n"></span>
|
||||
<span class="panel__tab-label">About · Paths · Lyrics · Fan works</span>
|
||||
</button>
|
||||
<div class="panel__body" id="panel-body">
|
||||
<header class="panel__head">
|
||||
<div class="panel__song" id="panel-song" aria-live="polite"></div>
|
||||
<button type="button" class="panel__hide" id="panel-hide" aria-controls="panel-body" aria-expanded="true" title="Collapse the panel">Hide <span aria-hidden="true">›</span></button>
|
||||
</header>
|
||||
<div class="tabs" role="tablist" aria-label="About this song">
|
||||
${TABS.map((t) => `<button type="button" role="tab" id="tab-${t.id}" aria-controls="panel-view" data-tab="${t.id}">${t.label}</button>`).join("")}
|
||||
</div>
|
||||
<div class="panel__view" id="panel-view" role="tabpanel" tabindex="0"></div>
|
||||
</div>`;
|
||||
const $ = (id: string) => host.querySelector<HTMLElement>(`#${id}`)!;
|
||||
const view = $("panel-view");
|
||||
const songEl = $("panel-song");
|
||||
|
||||
// The route chart is built once and moved into the Paths tab, so "You are here" keeps its place.
|
||||
const chartFig = document.createElement("figure");
|
||||
chartFig.className = "route";
|
||||
chartFig.innerHTML = `${chartSvg()}<figcaption>The ship's course so far, on 12's general chart.</figcaption>`;
|
||||
const here = chartFig.querySelector<SVGGElement>("#chart-here")!;
|
||||
|
||||
/* ----- head ----- */
|
||||
function renderHead() {
|
||||
const saga = sagaOf(song);
|
||||
songEl.innerHTML = `<p class="panel__eyebrow">Now playing on the voyage</p>
|
||||
<h2 class="panel__title"><span class="panel__n">${song.track}</span>${esc(song.title)}</h2>
|
||||
<p class="panel__sub">${esc(saga.name)} · ${esc(song.storyTime.label)}</p>`;
|
||||
$("panel-tab-n").textContent = String(song.track);
|
||||
}
|
||||
|
||||
/* ----- tabs ----- */
|
||||
const motifTag = (m: Motif) => `<span class="mtag" style="--c:${color(m.id)}"><i aria-hidden="true"></i>${esc(m.name)}</span>`;
|
||||
|
||||
function about(): HTMLElement {
|
||||
const el = document.createElement("div");
|
||||
el.className = "about";
|
||||
const saga = sagaOf(song);
|
||||
const o = song.odyssey;
|
||||
const homer = o ? `<a href="${esc(o.url)}" target="_blank" rel="noopener noreferrer">Book ${o.book}, lines ${esc(o.lines.replace("-", "–"))}</a>` : "No counterpart in Homer";
|
||||
el.innerHTML = `
|
||||
<dl class="facts">
|
||||
<div><dt>Track</dt><dd>${song.track} of ${songs.length} in this sample</dd></div>
|
||||
<div><dt>Saga</dt><dd>${esc(saga.name)}</dd></div>
|
||||
<div><dt>Story time</dt><dd>${song.storyTime.yearsAfterTroy === 0 ? "Year 0" : `Year ${song.storyTime.yearsAfterTroy}`} · ${esc(song.storyTime.label)}</dd></div>
|
||||
<div><dt>The Odyssey</dt><dd>${homer}</dd></div>
|
||||
</dl>
|
||||
${song.facts.map((f) => `<p class="about__fact">${esc(f)}</p>`).join("")}
|
||||
<h3 class="sec">Parts and singers</h3>
|
||||
<ol class="parts">${song.parts.map((p) => `<li><span class="parts__name">${esc(p.name)}</span><span class="parts__who">${p.singers.map(esc).join(", ")}</span></li>`).join("")}</ol>
|
||||
<h3 class="sec">Listen</h3><div class="slot-audio"></div>
|
||||
<h3 class="sec">Watch</h3><div class="slot-video"></div>`;
|
||||
el.querySelector(".slot-audio")!.append(createAudioSlot(song));
|
||||
el.querySelector(".slot-video")!.append(createVideoCards(song));
|
||||
return el;
|
||||
}
|
||||
|
||||
function paths(): HTMLElement {
|
||||
const el = document.createElement("div");
|
||||
el.className = "paths";
|
||||
const ms = motifsInSong(song);
|
||||
const sec = document.createElement("div");
|
||||
sec.innerHTML = `<h3 class="sec">Motif threads</h3>
|
||||
<p class="hint">Each thread is a motif; a knot is a song where it plays. Pick a motif to follow it.</p>
|
||||
<ul class="mlist">${ms.map((m) => {
|
||||
const hits = songsWithMotif(m.id).sort((a, b) => a.track - b.track);
|
||||
const before = hits.filter((s) => s.track < song.track);
|
||||
const after = hits.filter((s) => s.track > song.track);
|
||||
const from = before.length ? `comes from ${esc(before[before.length - 1]!.title)}` : "first heard here";
|
||||
const next = after.length ? `returns in ${esc(after[0]!.title)}${after.length > 1 ? ` (+${after.length - 1} more)` : ""}` : "not heard again";
|
||||
return `<li><button type="button" class="mpick" data-motif="${m.id}" aria-pressed="${motifPick === m.id}" style="--c:${color(m.id)}">
|
||||
<span class="mpick__name"><i aria-hidden="true"></i>${esc(m.name)}</span><span class="mpick__path">${from} · ${next}</span></button></li>`;
|
||||
}).join("")}</ul>`;
|
||||
el.append(sec, strip(ms));
|
||||
const route = document.createElement("h3");
|
||||
route.className = "sec";
|
||||
route.textContent = "The route";
|
||||
el.append(route, chartFig);
|
||||
el.querySelectorAll<HTMLButtonElement>(".mpick").forEach((b) => b.addEventListener("click", () => {
|
||||
motifPick = motifPick === b.dataset.motif ? null : b.dataset.motif!;
|
||||
rerender(true);
|
||||
}));
|
||||
return el;
|
||||
}
|
||||
|
||||
/** The vertical thread strip: one row per song, one soft thread per motif of this song, knotted where it plays. */
|
||||
function strip(ms: Motif[]): HTMLElement {
|
||||
const ROW = 32, COL = 26, X0 = 16;
|
||||
const wrap = document.createElement("div");
|
||||
wrap.className = "strip";
|
||||
wrap.style.setProperty("--cols", String(ms.length));
|
||||
const rows = byTrack.map((s) => {
|
||||
const cls = ["strip__row", s.id === song.id ? "is-current" : "", s.id === songPick ? "is-picked" : ""].join(" ");
|
||||
return `<li><button type="button" class="${cls}" data-song="${s.id}" aria-pressed="${s.id === songPick}">
|
||||
<span class="strip__n">${s.track}</span><span class="strip__t">${esc(s.title)}</span>${s.id === song.id ? '<span class="strip__now">now</span>' : ""}</button></li>`;
|
||||
}).join("");
|
||||
const H = byTrack.length * ROW;
|
||||
const W = X0 * 2 + (ms.length - 1) * COL;
|
||||
let svg = "";
|
||||
ms.forEach((m, k) => {
|
||||
const x = X0 + k * COL;
|
||||
const ys = byTrack.map((s, i) => (s.parts.some((p) => p.motifIds.includes(m.id)) ? i * ROW + ROW / 2 : -1)).filter((y) => y >= 0);
|
||||
const y0 = ys[0]!, y1 = ys[ys.length - 1]!;
|
||||
let d = "";
|
||||
for (let y = y0; y < y1; y += 6) d += `${d ? "L" : "M"}${(x + Math.sin(y / 22 + k * 1.7) * 2.4).toFixed(1)},${y}`;
|
||||
d += `${d ? "L" : "M"}${(x + Math.sin(y1 / 22 + k * 1.7) * 2.4).toFixed(1)},${y1}`;
|
||||
const state = motifPick === m.id ? " is-on" : motifPick ? " is-dim" : "";
|
||||
svg += `<g class="thread${state}" style="--c:${color(m.id)}"><path class="thread__line" d="${d}"/>${ys.map((y) => `<circle class="thread__knot" cx="${(x + Math.sin(y / 22 + k * 1.7) * 2.4).toFixed(1)}" cy="${y}" r="5"/>`).join("")}</g>`;
|
||||
});
|
||||
wrap.innerHTML = `<ol class="strip__rows">${rows}</ol>
|
||||
<svg class="strip__threads" viewBox="0 0 ${W} ${H}" width="${W}" height="${H}" aria-hidden="true">${svg}</svg>`;
|
||||
wrap.querySelectorAll<HTMLButtonElement>(".strip__row").forEach((b) => b.addEventListener("click", () => {
|
||||
songPick = songPick === b.dataset.song ? null : b.dataset.song!;
|
||||
rerender(true);
|
||||
}));
|
||||
return wrap;
|
||||
}
|
||||
|
||||
function lyrics(): HTMLElement {
|
||||
const el = document.createElement("div");
|
||||
el.className = "lyrics";
|
||||
el.innerHTML = `<p class="note">Placeholder lyrics. The real lyrics are not reproduced on this fan site.</p>
|
||||
${song.parts.map((p) => {
|
||||
const ms = p.motifIds.flatMap((id) => motifs.find((m) => m.id === id) ?? []);
|
||||
const c = ms[0] ? color(ms[0].id) : "transparent";
|
||||
return `<section class="part" style="--c:${c}">
|
||||
<header class="part__head"><h3>${esc(p.name)}</h3><span class="part__who">${p.singers.map((s) => `<span class="singer">${esc(s)}</span>`).join("")}</span></header>
|
||||
<div class="part__lines">${p.lines.map((l) => `<p>${esc(l)}</p>`).join("")}</div>
|
||||
${ms.length ? `<p class="part__motifs">${ms.map(motifTag).join("")}</p>` : ""}
|
||||
</section>`;
|
||||
}).join("")}`;
|
||||
return el;
|
||||
}
|
||||
|
||||
function fan(): HTMLElement {
|
||||
const el = document.createElement("div");
|
||||
el.className = "fan";
|
||||
const accent = color(motifsInSong(song)[0]?.id ?? "odysseus");
|
||||
el.innerHTML = `<p class="note">Placeholder fan works — real ones will be credited and linked to their creators.</p>
|
||||
<ul class="fw">${fanWorksFor(song.id).map((w, i) => `<li class="fw__card">
|
||||
${thumbSvg(w.type, accent, song.track * 7 + i)}
|
||||
<p class="fw__type">${TYPE_LABEL[w.type]}</p>
|
||||
<p class="fw__title">${esc(w.title)}</p>
|
||||
<p class="fw__by">by ${esc(w.handle)}</p>
|
||||
<p class="fw__credit">Credit + link to the original <span>(placeholder)</span></p>
|
||||
</li>`).join("")}</ul>`;
|
||||
return el;
|
||||
}
|
||||
|
||||
function rerender(keepScroll = false) {
|
||||
const top = view.scrollTop;
|
||||
view.replaceChildren(tab === "about" ? about() : tab === "paths" ? paths() : tab === "lyrics" ? lyrics() : fan());
|
||||
view.setAttribute("aria-labelledby", `tab-${tab}`);
|
||||
host.querySelectorAll<HTMLButtonElement>("[role=tab]").forEach((b) => {
|
||||
const on = b.dataset.tab === tab;
|
||||
b.setAttribute("aria-selected", String(on));
|
||||
b.tabIndex = on ? 0 : -1;
|
||||
});
|
||||
view.scrollTop = keepScroll ? top : 0;
|
||||
}
|
||||
|
||||
/* ----- wiring ----- */
|
||||
host.querySelectorAll<HTMLButtonElement>("[role=tab]").forEach((b, i, all) => {
|
||||
b.addEventListener("click", () => { api.setTab(b.dataset.tab as Tab); opts.onTab(tab); });
|
||||
b.addEventListener("keydown", (e) => {
|
||||
const d = e.key === "ArrowRight" ? 1 : e.key === "ArrowLeft" ? -1 : 0;
|
||||
if (!d) return;
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const nb = all[(i + d + all.length) % all.length]!;
|
||||
nb.focus();
|
||||
nb.click();
|
||||
});
|
||||
});
|
||||
$("panel-open").addEventListener("click", () => { api.setOpen(true); opts.onOpen(true); });
|
||||
$("panel-hide").addEventListener("click", () => { api.setOpen(false); opts.onOpen(false); });
|
||||
|
||||
const api: Panel = {
|
||||
here,
|
||||
setSong(next) {
|
||||
if (next.id === song.id && songEl.childElementCount) return;
|
||||
const first = !songEl.childElementCount;
|
||||
song = next;
|
||||
motifPick = null;
|
||||
songPick = null;
|
||||
if (first || opts.reduced) { renderHead(); rerender(); return; }
|
||||
// a gentle swap: the panel's content dips and settles when the voyage reaches a new song
|
||||
host.classList.add("is-swapping");
|
||||
window.clearTimeout(swapTimer);
|
||||
swapTimer = window.setTimeout(() => { renderHead(); rerender(); host.classList.remove("is-swapping"); }, 180);
|
||||
},
|
||||
setLook(l) { look = l; if (songEl.childElementCount) rerender(true); },
|
||||
setTab(t) { tab = t; rerender(); },
|
||||
setOpen(open) {
|
||||
host.dataset.open = String(open);
|
||||
$("panel-open").setAttribute("aria-expanded", String(open));
|
||||
$("panel-hide").setAttribute("aria-expanded", String(open));
|
||||
($("panel-body") as HTMLElement).inert = !open;
|
||||
$("panel-open").tabIndex = open ? -1 : 0;
|
||||
},
|
||||
};
|
||||
api.setOpen(opts.open);
|
||||
return api;
|
||||
}
|
||||
@@ -0,0 +1,685 @@
|
||||
// The 3D half of the voyage, stylised: toon shading with a stepped gradient, ink outlines (inverted
|
||||
// hulls), posterised sky bands, a flat graphic sun and a contour-lined sea. Choreography is 13's, as a
|
||||
// pure function of the beat position p (0..4), with a calmer landfall camera.
|
||||
import * as THREE from "three";
|
||||
import { mergeVertices } from "three/examples/jsm/utils/BufferGeometryUtils.js";
|
||||
|
||||
export type Look = 2 | 3;
|
||||
|
||||
export function webglAvailable(): boolean {
|
||||
try {
|
||||
const c = document.createElement("canvas");
|
||||
return !!(c.getContext("webgl2") ?? c.getContext("webgl"));
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- wave field (GLSL and JS agree) ---------- */
|
||||
|
||||
const WAVE_GLSL = /* glsl */ `
|
||||
uniform float uTime;
|
||||
float seaWave(vec2 p) {
|
||||
return 0.55 * sin(p.x * 0.09 + uTime * 0.8)
|
||||
+ 0.40 * sin(p.y * 0.12 - uTime * 0.6 + p.x * 0.03)
|
||||
+ 0.18 * sin((p.x + p.y) * 0.31 + uTime * 1.7);
|
||||
}`;
|
||||
const seaWave = (x: number, z: number, t: number) =>
|
||||
0.55 * Math.sin(x * 0.09 + t * 0.8) + 0.4 * Math.sin(z * 0.12 - t * 0.6 + x * 0.03) + 0.18 * Math.sin((x + z) * 0.31 + t * 1.7);
|
||||
|
||||
/* ---------- palettes: a short list of flat inks per look ---------- */
|
||||
|
||||
interface Palette {
|
||||
sky: [string, string, string, string]; // horizon band → zenith
|
||||
sun: string; sunRing: string;
|
||||
deep: string; mid: string; crest: string; contour: string; fog: string; fogNear: number; fogFar: number;
|
||||
ink: string; inkSoft: number; light: string; lightI: number; ambient: string; ambientI: number;
|
||||
hull: string; band: string; wood: string; sail: string; sailStripe: string; eye: string;
|
||||
sand: string; rock: string; top: string; mouth: string;
|
||||
caveRock: string; caveFloor: string; caveInk: string; fire: string; fireCore: string; caveAmbient: number;
|
||||
giant: string; giantInc: string; giantEye: string; wool: string; face: string;
|
||||
}
|
||||
|
||||
const PALETTES: Record<Look, Palette> = {
|
||||
// 2 · Two worlds: a poster-paint sea, teal and cream, inked in the frieze's black.
|
||||
2: {
|
||||
sky: ["#f3dfb6", "#dcdcc4", "#b4cdc8", "#88b1c0"], sun: "#fff4dc", sunRing: "#f7e6c0",
|
||||
deep: "#1d5a6e", mid: "#2b7b88", crest: "#62aaa6", contour: "#e9efe2", fog: "#f0d7aa", fogNear: 90, fogFar: 360,
|
||||
ink: "#1d140e", inkSoft: 0.4, light: "#fff6e6", lightI: 2.4, ambient: "#9fb8c2", ambientI: 1.2,
|
||||
hull: "#2a211b", band: "#c46a33", wood: "#5b3c20", sail: "#f3ead6", sailStripe: "#1d5f86", eye: "#f3ead6",
|
||||
sand: "#e6cf98", rock: "#b0804e", top: "#6f7d3e", mouth: "#1d140e",
|
||||
caveRock: "#7a4a2c", caveFloor: "#4a2c1a", caveInk: "#1d140e", fire: "#f08a3a", fireCore: "#ffe08a", caveAmbient: 0.55,
|
||||
giant: "#16100c", giantInc: "#c46a33", giantEye: "#f6ead0", wool: "#efe6d2", face: "#1d140e",
|
||||
},
|
||||
// 3 · Frieze-led: terracotta sky, glaze-black sea, black-figure ship and island with incised clay lines.
|
||||
3: {
|
||||
sky: ["#eab27a", "#df9a5c", "#cf7d44", "#b4602f"], sun: "#efe3c8", sunRing: "#e7c69a",
|
||||
deep: "#1a110b", mid: "#2e1d12", crest: "#45291a", contour: "#c46a33", fog: "#d0804a", fogNear: 80, fogFar: 330,
|
||||
ink: "#c46a33", inkSoft: 0.75, light: "#ffd2a8", lightI: 1.4, ambient: "#c46a33", ambientI: 0.7,
|
||||
hull: "#1d140e", band: "#c46a33", wood: "#1d140e", sail: "#1d140e", sailStripe: "#c46a33", eye: "#efe3c8",
|
||||
sand: "#1d140e", rock: "#1d140e", top: "#1d140e", mouth: "#c46a33",
|
||||
caveRock: "#6a3018", caveFloor: "#2c160c", caveInk: "#1d140e", fire: "#dc8d52", fireCore: "#efe3c8", caveAmbient: 0.45,
|
||||
giant: "#120b07", giantInc: "#dc8d52", giantEye: "#efe3c8", wool: "#efe3c8", face: "#1d140e",
|
||||
},
|
||||
};
|
||||
|
||||
/* ---------- helpers ---------- */
|
||||
|
||||
function hash(x: number, y: number, z: number): number {
|
||||
const s = Math.sin(x * 127.1 + y * 311.7 + z * 74.7) * 43758.5453;
|
||||
return s - Math.floor(s);
|
||||
}
|
||||
const clamp01 = (x: number) => Math.min(1, Math.max(0, x));
|
||||
export const ease = (x: number) => { const t = clamp01(x); return t * t * (3 - 2 * t); };
|
||||
const easeInOut = (x: number) => { const t = clamp01(x); return t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2; };
|
||||
const lerp = (a: number, b: number, k: number) => a + (b - a) * k;
|
||||
const v3 = (x: number, y: number, z: number) => new THREE.Vector3(x, y, z);
|
||||
|
||||
/** Three flat tones per surface: shadow, mid, lit. */
|
||||
function stepMap(): THREE.DataTexture {
|
||||
const steps = [70, 160, 255];
|
||||
const data = new Uint8Array(steps.length * 4);
|
||||
steps.forEach((v, i) => data.set([v, v, v, 255], i * 4));
|
||||
const t = new THREE.DataTexture(data, steps.length, 1, THREE.RGBAFormat);
|
||||
t.minFilter = t.magFilter = THREE.NearestFilter;
|
||||
t.generateMipmaps = false;
|
||||
t.needsUpdate = true;
|
||||
return t;
|
||||
}
|
||||
const STEPS = stepMap();
|
||||
const toon = (color: string, opts: THREE.MeshToonMaterialParameters = {}) =>
|
||||
new THREE.MeshToonMaterial({ color, gradientMap: STEPS, ...opts });
|
||||
|
||||
/** Inverted hull: the same shape with smoothed normals, pushed out by t and drawn back-faces only. */
|
||||
function hullOf(src: THREE.BufferGeometry, t: number): THREE.BufferGeometry {
|
||||
let g = src.clone();
|
||||
for (const k of Object.keys(g.attributes)) if (k !== "position") g.deleteAttribute(k);
|
||||
g = mergeVertices(g, 1e-3);
|
||||
g.computeVertexNormals();
|
||||
const p = g.getAttribute("position") as THREE.BufferAttribute;
|
||||
const n = g.getAttribute("normal") as THREE.BufferAttribute;
|
||||
for (let i = 0; i < p.count; i++) p.setXYZ(i, p.getX(i) + n.getX(i) * t, p.getY(i) + n.getY(i) * t, p.getZ(i) + n.getZ(i) * t);
|
||||
return g;
|
||||
}
|
||||
|
||||
/** A flat ribbon along a 2D polyline (for incised lines on the giant). */
|
||||
function ribbon(pts: [number, number][], w: number, z: number): THREE.BufferGeometry {
|
||||
const pos: number[] = [];
|
||||
for (let i = 0; i < pts.length - 1; i++) {
|
||||
const [ax, ay] = pts[i]!, [bx, by] = pts[i + 1]!;
|
||||
const dx = bx - ax, dy = by - ay, l = Math.hypot(dx, dy) || 1;
|
||||
const nx = (-dy / l) * w / 2, ny = (dx / l) * w / 2;
|
||||
pos.push(ax + nx, ay + ny, z, ax - nx, ay - ny, z, bx + nx, by + ny, z, bx + nx, by + ny, z, ax - nx, ay - ny, z, bx - nx, by - ny, z);
|
||||
}
|
||||
const g = new THREE.BufferGeometry();
|
||||
g.setAttribute("position", new THREE.Float32BufferAttribute(pos, 3));
|
||||
return g;
|
||||
}
|
||||
|
||||
const shape = (pts: [number, number][]) => {
|
||||
const s = new THREE.Shape();
|
||||
pts.forEach(([x, y], i) => (i ? s.lineTo(x, y) : s.moveTo(x, y)));
|
||||
s.closePath();
|
||||
return s;
|
||||
};
|
||||
|
||||
interface IslandOpts { radius: number; height: number; seed: number }
|
||||
|
||||
/** A bold graphic island: few facets, three height bands (sand, rock, scrub) as vertex colours. */
|
||||
function islandGeometry(o: IslandOpts, cols: { sand: THREE.Color; rock: THREE.Color; top: THREE.Color }): THREE.BufferGeometry {
|
||||
let g: THREE.BufferGeometry = new THREE.ConeGeometry(o.radius, o.height, 9, 3, true);
|
||||
g.translate(0, o.height / 2 - 3, 0);
|
||||
const pos = g.getAttribute("position") as THREE.BufferAttribute;
|
||||
for (let i = 0; i < pos.count; i++) {
|
||||
const x = pos.getX(i), y = pos.getY(i), z = pos.getZ(i);
|
||||
const kx = Math.round(x * 10), ky = Math.round(y * 10), kz = Math.round(z * 10) + o.seed;
|
||||
const j = 1 - Math.min(1, (y + 3) / o.height) * 0.5;
|
||||
pos.setXYZ(i, x + (hash(kx, ky, kz) - 0.5) * o.radius * 0.22 * j, y + (hash(ky, kz, kx) - 0.5) * o.height * 0.1, z + (hash(kz, kx, ky) - 0.5) * o.radius * 0.22 * j);
|
||||
}
|
||||
g = g.toNonIndexed();
|
||||
paintIsland(g, o.height, cols);
|
||||
g.computeVertexNormals();
|
||||
return g;
|
||||
}
|
||||
function paintIsland(g: THREE.BufferGeometry, height: number, c: { sand: THREE.Color; rock: THREE.Color; top: THREE.Color }) {
|
||||
const p = g.getAttribute("position") as THREE.BufferAttribute;
|
||||
const colors = new Float32Array(p.count * 3);
|
||||
for (let f = 0; f < p.count; f += 3) {
|
||||
const y = (p.getY(f) + p.getY(f + 1) + p.getY(f + 2)) / 3;
|
||||
const col = y < 1.2 ? c.sand : y > height * 0.45 - 3 ? c.top : c.rock;
|
||||
for (let k = 0; k < 3; k++) col.toArray(colors, (f + k) * 3);
|
||||
}
|
||||
g.setAttribute("color", new THREE.BufferAttribute(colors, 3));
|
||||
}
|
||||
|
||||
/* ---------- choreography ---------- */
|
||||
|
||||
const SHIP_A = v3(0, 0, 0); // beat 2: out at sea
|
||||
const SHIP_B = v3(-4, 0, -150); // beat 3: anchored off the island
|
||||
const ISLAND = v3(-34, 0, -190);
|
||||
const ISLAND_SUNK = -48;
|
||||
/** The ship's course from open sea to the anchorage, s in 0..1, with a gentle S. */
|
||||
const shipAt = (s: number) =>
|
||||
v3(lerp(SHIP_A.x, SHIP_B.x, s) + Math.sin(s * Math.PI) * 9, 0, lerp(SHIP_A.z, SHIP_B.z, s));
|
||||
|
||||
export class VoyageScene {
|
||||
private renderer: THREE.WebGLRenderer;
|
||||
private sea = new THREE.Scene();
|
||||
private cave = new THREE.Scene();
|
||||
private camera = new THREE.PerspectiveCamera(46, 16 / 9, 0.5, 1400);
|
||||
private caveCam = new THREE.PerspectiveCamera(54, 16 / 9, 0.3, 400);
|
||||
private waveU = { uTime: { value: 0 } };
|
||||
private seaU = { uDeep: { value: new THREE.Color() }, uMid: { value: new THREE.Color() }, uCrest: { value: new THREE.Color() }, uContour: { value: new THREE.Color() } };
|
||||
private skyU = {
|
||||
uB0: { value: new THREE.Color() }, uB1: { value: new THREE.Color() }, uB2: { value: new THREE.Color() }, uB3: { value: new THREE.Color() },
|
||||
uSun: { value: new THREE.Color() }, uRing: { value: new THREE.Color() },
|
||||
uSunDir: { value: new THREE.Vector3(0.3, 0.17, -0.94).normalize() },
|
||||
};
|
||||
private fog = new THREE.Fog(0xffffff, 80, 330);
|
||||
private ambient = new THREE.AmbientLight(0xffffff, 1);
|
||||
private sunLight = new THREE.DirectionalLight(0xffffff, 2);
|
||||
private inkMat = new THREE.MeshBasicMaterial({ color: "#1d140e", side: THREE.BackSide });
|
||||
private edgeMat = new THREE.LineBasicMaterial({ color: "#1d140e", transparent: true, opacity: 0.4 });
|
||||
private ship = new THREE.Group();
|
||||
private island = new THREE.Group();
|
||||
private islandMat = toon("#ffffff", { vertexColors: true });
|
||||
private islandGeos: { geo: THREE.BufferGeometry; height: number }[] = [];
|
||||
private mouthMat = new THREE.MeshBasicMaterial({ color: "#1d140e", side: THREE.DoubleSide });
|
||||
private shipMats = { hull: toon("#2a211b"), band: toon("#c46a33"), wood: new THREE.MeshBasicMaterial({ color: "#5b3c20" }), sail: toon("#ffffff", { side: THREE.DoubleSide }), eye: new THREE.MeshBasicMaterial({ color: "#f3ead6" }), pupil: new THREE.MeshBasicMaterial({ color: "#1d140e" }) };
|
||||
private sailCanvas = document.createElement("canvas");
|
||||
private sailTex: THREE.CanvasTexture;
|
||||
// cave
|
||||
private caveMats = {
|
||||
rock: toon("#7a4a2c", { side: THREE.BackSide }), floor: toon("#4a2c1a"), boulder: toon("#4a2c1a"),
|
||||
ink: new THREE.MeshBasicMaterial({ color: "#1d140e", side: THREE.BackSide }), edge: new THREE.LineBasicMaterial({ color: "#1d140e", transparent: true, opacity: 0.55 }),
|
||||
giant: new THREE.MeshBasicMaterial({ color: "#16100c" }), giantInc: new THREE.MeshBasicMaterial({ color: "#c46a33", side: THREE.DoubleSide }), giantHull: new THREE.MeshBasicMaterial({ color: "#c46a33", side: THREE.BackSide }),
|
||||
eye: new THREE.MeshBasicMaterial({ color: "#f6ead0" }),
|
||||
wool: toon("#efe6d2"), face: new THREE.MeshBasicMaterial({ color: "#1d140e" }),
|
||||
fire: new THREE.MeshBasicMaterial({ color: "#f08a3a", side: THREE.DoubleSide }), core: new THREE.MeshBasicMaterial({ color: "#ffe08a", side: THREE.DoubleSide }),
|
||||
};
|
||||
private fireLight = new THREE.PointLight(0xff8a3a, 900, 0, 1.7);
|
||||
private caveAmbient = new THREE.AmbientLight(0xffffff, 0.5);
|
||||
private flames: THREE.Mesh[] = [];
|
||||
private eye!: THREE.Mesh;
|
||||
private ro: ResizeObserver;
|
||||
private look: Look = 2;
|
||||
private tmp = new THREE.Vector3();
|
||||
/** Fraction down the stage where the frieze's ground line sits; at p=0 the horizon sits exactly on it. */
|
||||
private horizonAt = 0.62;
|
||||
|
||||
constructor(private host: HTMLElement, private reduced: boolean) {
|
||||
this.renderer = new THREE.WebGLRenderer({ antialias: true, powerPreference: "high-performance", preserveDrawingBuffer: true });
|
||||
this.renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 1.75));
|
||||
this.renderer.domElement.className = "stage__canvas";
|
||||
this.renderer.domElement.setAttribute("aria-hidden", "true");
|
||||
host.append(this.renderer.domElement);
|
||||
this.camera.rotation.order = "YXZ";
|
||||
|
||||
this.sea.fog = this.fog;
|
||||
this.sea.add(this.ambient, this.sunLight);
|
||||
this.sunLight.position.set(-60, 90, 40);
|
||||
this.buildSky();
|
||||
this.buildSea();
|
||||
this.buildIsland();
|
||||
this.sailCanvas.width = this.sailCanvas.height = 64;
|
||||
this.sailTex = new THREE.CanvasTexture(this.sailCanvas);
|
||||
this.sailTex.colorSpace = THREE.SRGBColorSpace;
|
||||
this.sailTex.magFilter = THREE.NearestFilter;
|
||||
this.shipMats.sail.map = this.sailTex;
|
||||
this.buildShip();
|
||||
this.buildCave();
|
||||
|
||||
this.setLook(2);
|
||||
this.ro = new ResizeObserver(() => this.resize());
|
||||
this.ro.observe(host);
|
||||
this.resize();
|
||||
}
|
||||
|
||||
private outline<T extends THREE.Mesh>(m: T, t: number, mat: THREE.Material = this.inkMat): T {
|
||||
const h = new THREE.Mesh(hullOf(m.geometry, t), mat);
|
||||
m.add(h);
|
||||
return m;
|
||||
}
|
||||
|
||||
/* ----- build: sea ----- */
|
||||
|
||||
private buildSky() {
|
||||
const mat = new THREE.ShaderMaterial({
|
||||
side: THREE.BackSide, depthWrite: false, fog: false, uniforms: this.skyU,
|
||||
vertexShader: /* glsl */ `varying vec3 vDir; void main(){ vDir = normalize(position); gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0); }`,
|
||||
fragmentShader: /* glsl */ `
|
||||
uniform vec3 uB0; uniform vec3 uB1; uniform vec3 uB2; uniform vec3 uB3; uniform vec3 uSun; uniform vec3 uRing; uniform vec3 uSunDir; varying vec3 vDir;
|
||||
void main(){
|
||||
vec3 d = normalize(vDir);
|
||||
float h = d.y + 0.012 * sin(atan(d.x, d.z) * 9.0);
|
||||
vec3 col = uB0;
|
||||
col = mix(col, uB1, step(0.035, h));
|
||||
col = mix(col, uB2, step(0.09, h));
|
||||
col = mix(col, uB3, step(0.18, h));
|
||||
// a flat paper sun with one ring: no glare
|
||||
float s = dot(d, uSunDir);
|
||||
col = mix(col, uRing, step(0.99863, s) * (1.0 - step(0.99897, s)));
|
||||
col = mix(col, uSun, step(0.99939, s));
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
#include <colorspace_fragment>
|
||||
}`,
|
||||
});
|
||||
const sky = new THREE.Mesh(new THREE.SphereGeometry(1000, 48, 24), mat);
|
||||
sky.renderOrder = -1;
|
||||
this.sea.add(sky);
|
||||
}
|
||||
|
||||
private buildSea() {
|
||||
const g = new THREE.PlaneGeometry(1300, 1300, 170, 170);
|
||||
const mat = new THREE.MeshBasicMaterial({ color: 0xffffff });
|
||||
mat.onBeforeCompile = (shader) => {
|
||||
Object.assign(shader.uniforms, this.waveU, this.seaU);
|
||||
shader.vertexShader = shader.vertexShader
|
||||
.replace("#include <common>", `#include <common>\n${WAVE_GLSL}\nvarying float vH;\nvarying vec2 vWp;`)
|
||||
.replace("#include <begin_vertex>", `#include <begin_vertex>
|
||||
vec4 seaWp = modelMatrix * vec4(transformed, 1.0);
|
||||
float seaH = seaWave(seaWp.xz);
|
||||
transformed.z += seaH;
|
||||
vH = seaH;
|
||||
vWp = seaWp.xz;`);
|
||||
shader.fragmentShader = shader.fragmentShader
|
||||
.replace("#include <common>", `#include <common>\nuniform float uTime;\nuniform vec3 uDeep;\nuniform vec3 uMid;\nuniform vec3 uCrest;\nuniform vec3 uContour;\nvarying float vH;\nvarying vec2 vWp;`)
|
||||
.replace("#include <color_fragment>", `#include <color_fragment>
|
||||
// Flat bands by wave height, and an inked contour line on the crest band: waves as drawn, not as lit.
|
||||
float h = vH + 0.32 * sin(vWp.x * 0.42 + vWp.y * 0.16 + uTime * 1.1) * sin(vWp.y * 0.55 - uTime * 0.8);
|
||||
vec3 c = mix(uDeep, uMid, step(-0.5, h));
|
||||
c = mix(c, uCrest, step(0.62, h));
|
||||
float fw = fwidth(h);
|
||||
float line = 1.0 - smoothstep(0.0, 1.6 * fw, abs(h - 0.62));
|
||||
line *= 1.0 - smoothstep(0.12, 0.3, fw);
|
||||
diffuseColor.rgb = mix(c, uContour, line * 0.9);`);
|
||||
};
|
||||
const sea = new THREE.Mesh(g, mat);
|
||||
sea.rotation.x = -Math.PI / 2;
|
||||
sea.position.set(0, 0, -120);
|
||||
this.sea.add(sea);
|
||||
}
|
||||
|
||||
private buildIsland() {
|
||||
const white = new THREE.Color("#ffffff");
|
||||
const cols = { sand: white, rock: white, top: white };
|
||||
const add = (o: IslandOpts, x: number, z: number, parent: THREE.Object3D, ink: number) => {
|
||||
const geo = islandGeometry(o, cols);
|
||||
this.islandGeos.push({ geo, height: o.height });
|
||||
const m = this.outline(new THREE.Mesh(geo, this.islandMat), ink);
|
||||
m.add(new THREE.LineSegments(new THREE.EdgesGeometry(geo, 32), this.edgeMat));
|
||||
m.position.set(x, 0, z);
|
||||
parent.add(m);
|
||||
return m;
|
||||
};
|
||||
add({ radius: 26, height: 34, seed: 23 }, 0, 0, this.island, 0.45);
|
||||
add({ radius: 17, height: 22, seed: 41 }, -20, -14, this.island, 0.4);
|
||||
add({ radius: 11, height: 13, seed: 57 }, 21, -6, this.island, 0.35);
|
||||
// The cave mouth: a black arch facing the anchorage.
|
||||
const toShip = v3(SHIP_B.x + 14, 0, SHIP_B.z + 52).sub(ISLAND).setY(0).normalize();
|
||||
const arch = new THREE.Shape();
|
||||
arch.moveTo(-6, -1); arch.lineTo(-6, 4); arch.absarc(0, 4, 6, Math.PI, 0, true); arch.lineTo(6, -1); arch.closePath();
|
||||
const mouth = new THREE.Mesh(new THREE.ShapeGeometry(arch, 8), this.mouthMat);
|
||||
mouth.position.copy(toShip.clone().multiplyScalar(22)).setY(0.6);
|
||||
mouth.lookAt(mouth.position.clone().add(toShip));
|
||||
this.island.add(mouth);
|
||||
this.island.position.copy(ISLAND);
|
||||
this.sea.add(this.island);
|
||||
// a few far islets, so the sea is a place
|
||||
const spots: [number, number, number][] = [[95, -280, 9], [-150, -330, 12], [80, -95, 5], [-110, -70, 6], [170, -170, 7]];
|
||||
spots.forEach(([x, z, r], i) => add({ radius: r, height: 4 + r * 0.9, seed: 100 + i }, x, z, this.sea, 0.3));
|
||||
}
|
||||
|
||||
private buildShip() {
|
||||
const s = this.ship;
|
||||
const outline = new THREE.Shape();
|
||||
outline.moveTo(0, 4.8);
|
||||
outline.quadraticCurveTo(1.8, 1.6, 1.6, -1.6);
|
||||
outline.quadraticCurveTo(1.35, -3.4, 0, -3.9);
|
||||
outline.quadraticCurveTo(-1.35, -3.4, -1.6, -1.6);
|
||||
outline.quadraticCurveTo(-1.8, 1.6, 0, 4.8);
|
||||
const hullGeo = new THREE.ExtrudeGeometry(outline, { depth: 1.6, bevelEnabled: false, curveSegments: 6 });
|
||||
hullGeo.rotateX(Math.PI / 2);
|
||||
hullGeo.translate(0, 1.2, 0);
|
||||
const hp = hullGeo.getAttribute("position") as THREE.BufferAttribute;
|
||||
for (let i = 0; i < hp.count; i++) if (hp.getY(i) < 0.5) hp.setX(i, hp.getX(i) * 0.35);
|
||||
hullGeo.computeVertexNormals();
|
||||
s.add(this.outline(new THREE.Mesh(hullGeo, this.shipMats.hull), 0.12));
|
||||
// a painted band along the gunwale
|
||||
const band = new THREE.Mesh(new THREE.BoxGeometry(3.45, 0.32, 6.4), this.shipMats.band);
|
||||
band.position.set(0, 1.0, 0.35);
|
||||
s.add(this.outline(band, 0.07));
|
||||
// tall curled stern post and a ram at the bow: silhouette first
|
||||
const stern = new THREE.Mesh(new THREE.TorusGeometry(0.75, 0.17, 5, 10, Math.PI * 1.1), this.shipMats.hull);
|
||||
stern.rotation.y = Math.PI / 2;
|
||||
stern.position.set(0, 2.15, -3.9);
|
||||
s.add(this.outline(stern, 0.08));
|
||||
const ram = new THREE.Mesh(new THREE.ConeGeometry(0.35, 1.8, 4), this.shipMats.hull);
|
||||
ram.rotation.x = Math.PI / 2;
|
||||
ram.position.set(0, 0.35, 5.2);
|
||||
s.add(this.outline(ram, 0.06));
|
||||
// the painted eye on each side of the bow
|
||||
for (const side of [-1, 1]) {
|
||||
const eye = new THREE.Mesh(new THREE.CircleGeometry(0.38, 12), this.shipMats.eye);
|
||||
eye.position.set(side * 1.25, 1.45, 3.1);
|
||||
eye.rotation.y = side * (Math.PI / 2 - 0.5);
|
||||
const pupil = new THREE.Mesh(new THREE.CircleGeometry(0.17, 10), this.shipMats.pupil);
|
||||
pupil.position.z = 0.02;
|
||||
eye.add(pupil);
|
||||
s.add(eye);
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const oar = new THREE.Mesh(new THREE.BoxGeometry(3.6, 0.1, 0.2), this.shipMats.wood);
|
||||
oar.position.set(side * 2.7, 0.6, -1.8 + i * 1.05);
|
||||
oar.rotation.z = side * -0.38;
|
||||
s.add(oar);
|
||||
}
|
||||
}
|
||||
const mast = new THREE.Mesh(new THREE.CylinderGeometry(0.12, 0.16, 8.4, 5), this.shipMats.wood);
|
||||
mast.position.y = 5;
|
||||
const yard = new THREE.Mesh(new THREE.CylinderGeometry(0.09, 0.09, 6.8, 5), this.shipMats.wood);
|
||||
yard.rotation.z = Math.PI / 2;
|
||||
yard.position.y = 8.2;
|
||||
s.add(mast, yard);
|
||||
const sailGeo = new THREE.PlaneGeometry(6.2, 4.6, 6, 4);
|
||||
const sp = sailGeo.getAttribute("position") as THREE.BufferAttribute;
|
||||
for (let i = 0; i < sp.count; i++) {
|
||||
const x = sp.getX(i) / 3.1, y = sp.getY(i) / 2.3;
|
||||
sp.setZ(i, (1 - x * x) * (1 - 0.4 * y * y) * 1.0);
|
||||
}
|
||||
sailGeo.computeVertexNormals();
|
||||
const sail = new THREE.Mesh(sailGeo, this.shipMats.sail);
|
||||
sail.position.set(0, 5.8, 0.2);
|
||||
const sailEdge = new THREE.LineSegments(new THREE.EdgesGeometry(sailGeo, 30), new THREE.LineBasicMaterial({ color: "#1d140e" }));
|
||||
sail.add(sailEdge);
|
||||
sail.userData.edge = sailEdge;
|
||||
s.add(sail);
|
||||
this.sea.add(s);
|
||||
}
|
||||
|
||||
/* ----- build: cave ----- */
|
||||
|
||||
private buildCave() {
|
||||
const c = this.cave;
|
||||
// A faceted dome, seen from inside, with its facets inked.
|
||||
let dome: THREE.BufferGeometry = new THREE.IcosahedronGeometry(1, 2);
|
||||
const dp = dome.getAttribute("position") as THREE.BufferAttribute;
|
||||
for (let i = 0; i < dp.count; i++) {
|
||||
const x = dp.getX(i), y = dp.getY(i), z = dp.getZ(i);
|
||||
const n = 1 + (hash(Math.round(x * 40), Math.round(y * 40), Math.round(z * 40)) - 0.5) * 0.24;
|
||||
dp.setXYZ(i, x * n, y * n, z * n);
|
||||
}
|
||||
dome = dome.toNonIndexed();
|
||||
dome.computeVertexNormals();
|
||||
const shell = new THREE.Mesh(dome, this.caveMats.rock);
|
||||
shell.add(new THREE.LineSegments(new THREE.EdgesGeometry(dome, 1), this.caveMats.edge));
|
||||
shell.scale.set(44, 30, 56);
|
||||
shell.position.set(0, 4, -16);
|
||||
c.add(shell);
|
||||
const floor = new THREE.Mesh(new THREE.CircleGeometry(70, 24), this.caveMats.floor);
|
||||
floor.rotation.x = -Math.PI / 2;
|
||||
floor.position.y = -9;
|
||||
c.add(floor);
|
||||
for (let i = 0; i < 8; i++) {
|
||||
const r = 1.6 + hash(i, 2, 9) * 3.2;
|
||||
const b = new THREE.Mesh(new THREE.DodecahedronGeometry(r, 0), this.caveMats.boulder);
|
||||
const side = i % 2 ? 1 : -1;
|
||||
b.position.set(side * (16 + hash(i, 4, 1) * 16), -9 + r * 0.45, -hash(1, i, 4) * 44 + 6);
|
||||
c.add(this.outline(b, 0.18, this.caveMats.ink));
|
||||
}
|
||||
|
||||
// The fire: flat, layered flame shapes, as painted.
|
||||
const flame = (w: number, h: number) => {
|
||||
const s = new THREE.Shape();
|
||||
s.moveTo(-w, 0);
|
||||
s.quadraticCurveTo(-w * 1.1, h * 0.45, 0, h);
|
||||
s.quadraticCurveTo(w * 1.1, h * 0.45, w, 0);
|
||||
s.closePath();
|
||||
return new THREE.ShapeGeometry(s, 6);
|
||||
};
|
||||
const fire = new THREE.Group();
|
||||
fire.position.set(-12, -9, -30);
|
||||
[[-2.2, 1.8, 5.5, 0], [0, 2.6, 8.5, 1], [2.3, 1.7, 6, 2], [0, 1.4, 4.6, 3], [-1, 0.9, 3, 4], [1.2, 0.8, 2.8, 5]].forEach(([x, w, h, i]) => {
|
||||
const core = i! >= 3;
|
||||
const f = new THREE.Mesh(flame(w!, h!), core ? this.caveMats.core : this.caveMats.fire);
|
||||
f.position.set(x!, 0, core ? 0.3 : 0);
|
||||
f.userData = { phase: i! * 1.7 };
|
||||
fire.add(f);
|
||||
this.flames.push(f);
|
||||
});
|
||||
const logs = new THREE.Mesh(new THREE.BoxGeometry(6, 0.8, 1.2), this.caveMats.face);
|
||||
logs.position.y = 0.2;
|
||||
fire.add(logs);
|
||||
c.add(fire);
|
||||
this.fireLight.position.set(-12, -2, -26);
|
||||
c.add(this.fireLight, this.caveAmbient);
|
||||
|
||||
this.buildGiant();
|
||||
this.buildFlock();
|
||||
}
|
||||
|
||||
/** Polyphemus as a black-figure silhouette: one profile cut-out, incised in clay, with one great eye. */
|
||||
private buildGiant() {
|
||||
const gm = this.caveMats.giant;
|
||||
const giant = new THREE.Group();
|
||||
const D = 2.4; // depth of the cut-out
|
||||
const part = (pts: [number, number][]) => {
|
||||
const geo = new THREE.ExtrudeGeometry(shape(pts), { depth: D, bevelEnabled: false });
|
||||
geo.translate(0, 0, -D / 2);
|
||||
giant.add(this.outline(new THREE.Mesh(geo, gm), 0.32, this.caveMats.giantHull));
|
||||
};
|
||||
// Facing left (towards his flock and the cave mouth), striding, club raised behind.
|
||||
part([[-9.5, 0], [-5.2, 0], [-4.4, 1.2], [-1.6, 12.5], [-4.6, 13], [-7.4, 1.6], [-9.6, 1.2]]); // front leg
|
||||
part([[3.4, 0], [8.2, 0], [8.2, 1.3], [6.0, 1.6], [4.0, 12.8], [0.8, 12.4], [3.6, 1.4]]); // back leg
|
||||
part([[-5.6, 11.6], [5.2, 11.4], [4.2, 15.2], [3.4, 25.6], [1.6, 27.4], [-3.4, 27.4], [-4.8, 25.6], [-4.6, 15.2]]); // body and chiton
|
||||
part([[-4.2, 25.8], [-10.4, 19.4], [-11.6, 17.2], [-10.4, 16.4], [-8.4, 18.4], [-2.4, 22.6]]); // front arm, reaching
|
||||
part([[1.6, 27.0], [6.0, 31.4], [7.6, 34.6], [6.4, 35.6], [4.4, 33.0], [0.4, 24.4]]); // back arm, raised
|
||||
part([[5.0, 33.6], [6.6, 32.8], [14.6, 47.4], [14.6, 49.8], [12.6, 50.6], [10.6, 48.6]]); // the club
|
||||
// head with brow and a pointed beard
|
||||
// head in profile: brow, a heavy nose, a pointed beard
|
||||
const head = new THREE.Shape();
|
||||
head.moveTo(-0.8, 35.4);
|
||||
head.quadraticCurveTo(-4.4, 35.4, -5.0, 32.8);
|
||||
head.lineTo(-6.8, 30.6);
|
||||
head.lineTo(-5.2, 30.2);
|
||||
head.lineTo(-5.3, 28.8);
|
||||
head.lineTo(-6.0, 24.6);
|
||||
head.lineTo(-2.0, 26.6);
|
||||
head.lineTo(1.0, 27.2);
|
||||
head.quadraticCurveTo(3.2, 29.0, 2.8, 32.0);
|
||||
head.quadraticCurveTo(2.4, 35.4, -0.8, 35.4);
|
||||
const hg = new THREE.ExtrudeGeometry(head, { depth: D, bevelEnabled: false, curveSegments: 8 });
|
||||
hg.translate(0, 0, -D / 2);
|
||||
giant.add(this.outline(new THREE.Mesh(hg, gm), 0.32, this.caveMats.giantHull));
|
||||
// incisions: belt, hem, knee, muscle and beard lines
|
||||
const z = D / 2 + 0.03;
|
||||
const inc = (pts: [number, number][], w = 0.26) => giant.add(new THREE.Mesh(ribbon(pts, w, z), this.caveMats.giantInc));
|
||||
inc([[-4.7, 16.2], [4.2, 16.0]]);
|
||||
inc([[-5.4, 12.6], [-4.2, 13.6], [-3.0, 12.6], [-1.8, 13.6], [-0.6, 12.6], [0.6, 13.6], [1.8, 12.6], [3.0, 13.6], [4.4, 12.6]], 0.2);
|
||||
inc([[-4.6, 6.6], [-3.2, 7.2]]);
|
||||
inc([[3.0, 7.2], [4.6, 6.8]]);
|
||||
inc([[-3.8, 24.0], [-0.6, 21.2], [2.4, 23.6]], 0.2);
|
||||
inc([[-4.4, 28.6], [-5.0, 25.8]], 0.18);
|
||||
inc([[-3.0, 28.6], [-3.4, 26.6]], 0.18);
|
||||
inc([[-0.6, 28.4], [0.4, 31.6], [-0.2, 34.2]], 0.2); // ear and hairline
|
||||
inc([[-1.0, 33.8], [-2.8, 34.2], [-4.6, 33.2]], 0.3); // brow
|
||||
// the single eye: a big painted ring with a dark pupil, catching the firelight
|
||||
const eye = new THREE.Mesh(new THREE.CircleGeometry(1.15, 20), this.caveMats.eye);
|
||||
eye.position.set(-2.7, 31.9, z + 0.01);
|
||||
const pupil = new THREE.Mesh(new THREE.CircleGeometry(0.55, 14), this.caveMats.face);
|
||||
pupil.position.set(-0.4, 0, 0.02);
|
||||
eye.add(pupil);
|
||||
giant.add(eye);
|
||||
this.eye = eye;
|
||||
giant.position.set(7, -9, -34);
|
||||
giant.scale.setScalar(0.8);
|
||||
giant.rotation.y = -0.18;
|
||||
this.cave.add(giant);
|
||||
}
|
||||
|
||||
/** The flock: round wool puffs with black heads and legs. */
|
||||
private buildFlock() {
|
||||
for (let i = 0; i < 6; i++) {
|
||||
const sheep = new THREE.Group();
|
||||
const body = new THREE.Mesh(new THREE.IcosahedronGeometry(1.35, 1), this.caveMats.wool);
|
||||
body.scale.set(1.4, 1, 1);
|
||||
sheep.add(this.outline(body, 0.12, this.caveMats.ink));
|
||||
for (const [px, py] of [[-0.8, 0.8], [0.3, 1.0], [-0.2, -0.1]] as const) {
|
||||
const puff = new THREE.Mesh(new THREE.IcosahedronGeometry(0.8, 1), this.caveMats.wool);
|
||||
puff.position.set(px, py, 0);
|
||||
sheep.add(this.outline(puff, 0.1, this.caveMats.ink));
|
||||
}
|
||||
const head = new THREE.Mesh(new THREE.ConeGeometry(0.55, 1.4, 6), this.caveMats.face);
|
||||
head.rotation.z = Math.PI / 2 + 0.4;
|
||||
head.position.set(2.0, 0.35, 0);
|
||||
sheep.add(head);
|
||||
for (const [lx, lz] of [[-0.8, -0.45], [-0.8, 0.45], [0.8, -0.45], [0.8, 0.45]] as const) {
|
||||
const leg = new THREE.Mesh(new THREE.BoxGeometry(0.24, 1.1, 0.24), this.caveMats.face);
|
||||
leg.position.set(lx, -1.15, lz);
|
||||
sheep.add(leg);
|
||||
}
|
||||
sheep.position.set(-24 + i * 3.8 + hash(i, 3, 3) * 2, -7.4, -1 - hash(3, i, 3) * 9);
|
||||
sheep.rotation.y = (hash(i, 9, 2) - 0.5) * 1.2 + (i % 2 ? Math.PI : 0);
|
||||
this.cave.add(sheep);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----- look ----- */
|
||||
|
||||
setLook(look: Look) {
|
||||
this.look = look;
|
||||
const p = PALETTES[look];
|
||||
p.sky.forEach((h, i) => (this.skyU[`uB${i}` as "uB0"].value as THREE.Color).set(h));
|
||||
this.skyU.uSun.value.set(p.sun);
|
||||
this.skyU.uRing.value.set(p.sunRing);
|
||||
this.seaU.uDeep.value.set(p.deep);
|
||||
this.seaU.uMid.value.set(p.mid);
|
||||
this.seaU.uCrest.value.set(p.crest);
|
||||
this.seaU.uContour.value.set(p.contour);
|
||||
this.fog.color.set(p.fog);
|
||||
this.fog.near = p.fogNear;
|
||||
this.fog.far = p.fogFar;
|
||||
this.ambient.color.set(p.ambient);
|
||||
this.ambient.intensity = p.ambientI;
|
||||
this.sunLight.color.set(p.light);
|
||||
this.sunLight.intensity = p.lightI;
|
||||
this.inkMat.color.set(p.ink);
|
||||
this.edgeMat.color.set(p.ink);
|
||||
this.edgeMat.opacity = p.inkSoft;
|
||||
this.mouthMat.color.set(p.mouth);
|
||||
const cols = { sand: new THREE.Color(p.sand), rock: new THREE.Color(p.rock), top: new THREE.Color(p.top) };
|
||||
for (const { geo, height } of this.islandGeos) { paintIsland(geo, height, cols); (geo.getAttribute("color") as THREE.BufferAttribute).needsUpdate = true; }
|
||||
this.shipMats.hull.color.set(p.hull);
|
||||
this.shipMats.band.color.set(p.band);
|
||||
this.shipMats.wood.color.set(p.wood);
|
||||
this.shipMats.eye.color.set(p.eye);
|
||||
const ctx = this.sailCanvas.getContext("2d");
|
||||
if (ctx) {
|
||||
ctx.fillStyle = p.sail; ctx.fillRect(0, 0, 64, 64);
|
||||
ctx.fillStyle = p.sailStripe;
|
||||
if (look === 3) { for (const y of [10, 28, 46]) ctx.fillRect(0, y, 64, 6); }
|
||||
else for (const x of [8, 27, 46]) ctx.fillRect(x, 0, 10, 64);
|
||||
}
|
||||
this.sailTex.needsUpdate = true;
|
||||
// In look 3 the sail stays black with clay bands even in shadow.
|
||||
this.shipMats.sail.emissive.set(look === 3 ? "#ffffff" : "#000000");
|
||||
this.shipMats.sail.emissiveMap = look === 3 ? this.sailTex : null;
|
||||
this.shipMats.sail.emissiveIntensity = look === 3 ? 0.6 : 0;
|
||||
this.shipMats.sail.needsUpdate = true;
|
||||
this.ship.traverse((o) => { if (o.userData.edge) ((o.userData.edge as THREE.LineSegments).material as THREE.LineBasicMaterial).color.set(p.ink); });
|
||||
// cave
|
||||
this.caveMats.rock.color.set(p.caveRock);
|
||||
this.caveMats.floor.color.set(p.caveFloor);
|
||||
this.caveMats.boulder.color.set(p.caveFloor);
|
||||
this.caveMats.ink.color.set(p.caveInk);
|
||||
this.caveMats.edge.color.set(p.caveInk);
|
||||
this.caveMats.giant.color.set(p.giant);
|
||||
this.caveMats.giantInc.color.set(p.giantInc);
|
||||
this.caveMats.giantHull.color.set(p.giantInc);
|
||||
this.caveMats.eye.color.set(p.giantEye);
|
||||
this.caveMats.wool.color.set(p.wool);
|
||||
this.caveMats.face.color.set(p.face);
|
||||
this.caveMats.fire.color.set(p.fire);
|
||||
this.caveMats.core.color.set(p.fireCore);
|
||||
this.fireLight.color.set(p.fire);
|
||||
this.caveAmbient.intensity = p.caveAmbient;
|
||||
}
|
||||
|
||||
/* ----- frame ----- */
|
||||
|
||||
setHorizon(fraction: number) { this.horizonAt = fraction; }
|
||||
|
||||
private resize() {
|
||||
const w = this.host.clientWidth, h = this.host.clientHeight;
|
||||
if (!w || !h) return;
|
||||
this.renderer.setSize(w, h, false);
|
||||
this.camera.aspect = this.caveCam.aspect = w / h;
|
||||
this.camera.updateProjectionMatrix();
|
||||
this.caveCam.updateProjectionMatrix();
|
||||
}
|
||||
|
||||
/** Points the sea camera from pos at target; at p=0 the pitch is forced so the horizon sits on the frieze's ground line. */
|
||||
private aimSea(pos: THREE.Vector3, target: THREE.Vector3, horizonLock: number) {
|
||||
const d = this.tmp.copy(target).sub(pos);
|
||||
const yaw = Math.atan2(-d.x, -d.z);
|
||||
const pitchAim = Math.atan2(d.y, Math.hypot(d.x, d.z));
|
||||
const tanHalf = Math.tan(THREE.MathUtils.degToRad(this.camera.fov / 2));
|
||||
const pitchLock = Math.atan((this.horizonAt - 0.5) * 2 * tanHalf);
|
||||
this.camera.position.copy(pos);
|
||||
this.camera.rotation.set(lerp(pitchAim, pitchLock, horizonLock), yaw, 0);
|
||||
}
|
||||
|
||||
/** Render the world at beat position p (0 = frieze … 4 = cave), wall-clock time in seconds. */
|
||||
render(p: number, time: number) {
|
||||
const t = this.reduced ? time * 0.25 : time;
|
||||
this.waveU.uTime.value = t;
|
||||
if (p < 2.9) this.renderSea(p, t);
|
||||
else this.renderCave(p, t);
|
||||
}
|
||||
|
||||
private renderSea(p: number, t: number) {
|
||||
const sail = easeInOut(p - 1);
|
||||
const shipPos = shipAt(sail);
|
||||
const ahead = shipAt(Math.min(1, sail + 0.01)).sub(shipAt(Math.max(0, sail - 0.01)));
|
||||
const heading = Math.atan2(ahead.x, ahead.z);
|
||||
this.ship.position.set(shipPos.x, seaWave(shipPos.x, shipPos.z, t) * 0.6 - 0.15, shipPos.z);
|
||||
this.ship.rotation.set(Math.sin(t * 0.9) * 0.03, heading, Math.sin(t * 1.1) * 0.05);
|
||||
|
||||
const rise = easeInOut((p - 1.05) / 0.7);
|
||||
this.island.position.y = lerp(ISLAND_SUNK, 0, rise);
|
||||
this.island.visible = rise > 0;
|
||||
|
||||
// Camera: a fixed side (behind the ship's right shoulder) the whole way; landfall only pulls back and up,
|
||||
// so the island grows ahead-left of the ship instead of shuffling across the frame (13's rough spot).
|
||||
const m = ease((p - 0.42) / 0.58);
|
||||
const n = easeInOut(p - 1);
|
||||
const off0 = v3(0, 3.2, 74), off1 = v3(12, 9, 34), off2 = v3(15, 19, 74);
|
||||
const camOff = p <= 1 ? off0.lerp(off1, m) : off1.lerp(off2, n);
|
||||
const pos = shipPos.clone().add(camOff);
|
||||
const tgt1 = shipPos.clone().add(v3(-6, 3, -26));
|
||||
const tgt2 = shipPos.clone().lerp(ISLAND, 0.5).setY(7);
|
||||
const target = p <= 1 ? tgt1 : tgt1.lerp(tgt2, n);
|
||||
this.aimSea(pos, target, p <= 1 ? 1 - m : 0);
|
||||
this.renderer.render(this.sea, this.camera);
|
||||
}
|
||||
|
||||
private renderCave(p: number, t: number) {
|
||||
const k = easeInOut((p - 3.12) / 0.88);
|
||||
const pos = v3(lerp(0, 1, k), lerp(1, -1, k), lerp(42, 30, k));
|
||||
const target = v3(lerp(0, -4, k), lerp(0, 5, k), -40);
|
||||
this.caveCam.position.copy(pos);
|
||||
this.caveCam.lookAt(target);
|
||||
for (const f of this.flames) {
|
||||
const s = 0.82 + 0.18 * Math.sin(t * 8 + f.userData.phase) + 0.08 * Math.sin(t * 19 + f.userData.phase * 2);
|
||||
f.scale.set(1 + (1 - s) * 0.4, s, 1);
|
||||
f.lookAt(this.caveCam.position.x, f.parent!.position.y + f.position.y, this.caveCam.position.z);
|
||||
}
|
||||
this.fireLight.intensity = (this.look === 3 ? 700 : 820) * (0.9 + 0.1 * Math.sin(t * 11) * Math.sin(t * 4.3));
|
||||
this.caveMats.eye.color.set(PALETTES[this.look].giantEye).multiplyScalar(0.85 + 0.15 * Math.sin(t * 2));
|
||||
this.renderer.render(this.cave, this.caveCam);
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this.ro.disconnect();
|
||||
this.renderer.dispose();
|
||||
}
|
||||
}
|
||||
@@ -1 +1,529 @@
|
||||
body { margin: 0; --stub-14: 1; }
|
||||
/* 14 · Voyage with side panel — 13's curtain call beside a persistent companion panel; looks 2 and 3. */
|
||||
@import "@fontsource/cormorant-garamond/latin-500.css";
|
||||
@import "@fontsource/cormorant-garamond/latin-600.css";
|
||||
@import "@fontsource/cormorant-garamond/latin-700.css";
|
||||
@import "@fontsource/cormorant-garamond/latin-500-italic.css";
|
||||
@import "@fontsource/inter/latin-400.css";
|
||||
@import "@fontsource/inter/latin-600.css";
|
||||
|
||||
:root {
|
||||
/* black-figure (04) */
|
||||
--clay: #c46a33;
|
||||
--clay-hi: #dc8d52;
|
||||
--glaze: #1d140e;
|
||||
--glaze-2: #2a1d14;
|
||||
--added-white: #efe3c8;
|
||||
/* vellum (12) */
|
||||
--vellum: #e3d6b4;
|
||||
--vellum-hi: #ece2c6;
|
||||
--iron: #2b2118;
|
||||
--iron-soft: #5a4836;
|
||||
--rhumb-red: #a23a2a;
|
||||
--desk: #3a2f24;
|
||||
--serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
|
||||
--sans: "Inter", system-ui, sans-serif;
|
||||
--panel-w: 420px;
|
||||
--panel-slim: 56px;
|
||||
|
||||
/* the frieze (both looks: terracotta and black) */
|
||||
--surround: var(--glaze);
|
||||
--band: var(--clay);
|
||||
--ink: var(--glaze);
|
||||
--inc: var(--clay);
|
||||
/* look 2: vellum interface */
|
||||
--ui-bg: rgb(236 226 198 / 0.95);
|
||||
--ui-fg: var(--iron);
|
||||
--ui-soft: var(--iron-soft);
|
||||
--ui-line: rgb(43 33 24 / 0.2);
|
||||
--ui-accent: var(--rhumb-red);
|
||||
--ui-on-accent: #fff8ea;
|
||||
--pn-bg: var(--vellum-hi);
|
||||
--pn-bg-2: #e2d4b0;
|
||||
--pn-card: #f3ecd8;
|
||||
--cut: var(--glaze);
|
||||
--foot-bg: var(--desk);
|
||||
--foot-fg: var(--vellum-hi);
|
||||
}
|
||||
body[data-look="3"] {
|
||||
--ui-bg: rgb(29 20 14 / 0.92);
|
||||
--ui-fg: var(--added-white);
|
||||
--ui-soft: #e1a374;
|
||||
--ui-line: rgb(220 141 82 / 0.38);
|
||||
--ui-accent: var(--clay-hi);
|
||||
--ui-on-accent: var(--glaze);
|
||||
--pn-bg: var(--glaze);
|
||||
--pn-bg-2: var(--glaze-2);
|
||||
--pn-card: #261a12;
|
||||
--foot-bg: #120c08;
|
||||
--foot-fg: var(--clay-hi);
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
html, body { height: 100%; }
|
||||
body {
|
||||
margin: 0;
|
||||
height: 100dvh;
|
||||
display: grid;
|
||||
grid-template-rows: minmax(0, 1fr) auto;
|
||||
overflow: hidden;
|
||||
background: var(--foot-bg);
|
||||
color: var(--ui-fg);
|
||||
font-family: var(--sans);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
button { font: inherit; color: inherit; }
|
||||
:focus-visible { outline: 3px solid var(--ui-accent); outline-offset: 2px; }
|
||||
[hidden] { display: none !important; }
|
||||
|
||||
/* ---------- shell: stage | panel, credits below both ---------- */
|
||||
.shell {
|
||||
min-height: 0;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) var(--panel-w);
|
||||
transition: grid-template-columns 0.42s cubic-bezier(0.22, 0.8, 0.2, 1);
|
||||
}
|
||||
.shell[data-panel="closed"] { grid-template-columns: minmax(0, 1fr) var(--panel-slim); }
|
||||
[data-fan-credits] {
|
||||
position: relative;
|
||||
z-index: 5;
|
||||
padding: 0.8rem 1.5rem;
|
||||
background: var(--foot-bg);
|
||||
color: var(--foot-fg);
|
||||
opacity: 1;
|
||||
border-top: 1px solid var(--ui-line);
|
||||
}
|
||||
|
||||
/* ---------- stage ---------- */
|
||||
.stage {
|
||||
position: relative;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
background: var(--surround);
|
||||
isolation: isolate;
|
||||
}
|
||||
.stage__three, .frieze-host, .cut, .stage__fallback { position: absolute; inset: 0; }
|
||||
.stage__three { z-index: 0; }
|
||||
.stage__canvas { display: block; width: 100%; height: 100%; }
|
||||
.stage__fallback { display: grid; place-items: center; background: linear-gradient(#a9c3c0, #f4dfb4 60%, #1d5a6e 61%); color: var(--iron); }
|
||||
|
||||
/* ---------- friezes ---------- */
|
||||
.frieze-host { z-index: 2; pointer-events: none; will-change: transform, opacity; }
|
||||
.frieze { display: block; width: 100%; height: 100%; overflow: visible; }
|
||||
.frieze-host--cyclops { z-index: 3; }
|
||||
.f-surround { fill: var(--surround); }
|
||||
.f-band { fill: var(--band); }
|
||||
.ink { fill: var(--ink); }
|
||||
.clay { fill: var(--inc); }
|
||||
.inc { fill: none; stroke: var(--inc); stroke-linecap: round; stroke-linejoin: round; }
|
||||
.limb { fill: none; stroke: var(--ink); stroke-linecap: round; stroke-linejoin: round; }
|
||||
.limb-edge { fill: none; stroke: var(--inc); stroke-linecap: round; stroke-linejoin: round; }
|
||||
.oar { stroke: var(--ink); stroke-width: 3.2; stroke-linecap: round; }
|
||||
.rig { fill: none; stroke: var(--ink); stroke-width: 1.4; }
|
||||
.wave { fill: none; stroke: var(--ink); stroke-linecap: round; }
|
||||
.ground { stroke: var(--ink); stroke-width: 3.5; }
|
||||
.rule { fill: none; stroke: var(--ink); stroke-width: 2.6; }
|
||||
.vol { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
|
||||
.mean { fill: none; stroke: var(--ink); stroke-width: 3; }
|
||||
.frame-rule { display: none; }
|
||||
.inscr { font: 600 19px var(--serif); letter-spacing: 0.2em; fill: var(--ink); }
|
||||
.saga-name { font: 600 15px var(--serif); letter-spacing: 0.22em; fill: var(--ink); }
|
||||
.glow-a { stop-color: #e2803a; }
|
||||
.glow-b { stop-color: #3a170a; }
|
||||
.glow-c { stop-color: #0c0705; }
|
||||
|
||||
.cut {
|
||||
z-index: 6;
|
||||
background: var(--cut);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
.cut.is-on { opacity: 1; }
|
||||
|
||||
/* ---------- caption ---------- */
|
||||
.cap {
|
||||
position: absolute;
|
||||
z-index: 7;
|
||||
top: 22px;
|
||||
left: 24px;
|
||||
max-width: 420px;
|
||||
padding: 10px 18px 12px;
|
||||
background: var(--ui-bg);
|
||||
color: var(--ui-fg);
|
||||
border-left: 3px solid var(--ui-accent);
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 10px 28px -14px rgb(0 0 0 / 0.6);
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
.cap__eyebrow { margin: 0; font-size: 0.8125rem; letter-spacing: 0.03em; color: var(--ui-soft); }
|
||||
.cap__title { margin: 2px 0 0; font: 600 2rem/1.1 var(--serif); }
|
||||
.back {
|
||||
margin-top: 8px;
|
||||
padding: 5px 14px;
|
||||
border: 1px solid var(--ui-accent);
|
||||
border-radius: 999px;
|
||||
background: var(--ui-accent);
|
||||
color: var(--ui-on-accent);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* ---------- control bar ---------- */
|
||||
.bar {
|
||||
position: absolute;
|
||||
z-index: 7;
|
||||
left: 50%;
|
||||
bottom: 18px;
|
||||
transform: translateX(-50%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
background: var(--ui-bg);
|
||||
color: var(--ui-fg);
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 12px 30px -14px rgb(0 0 0 / 0.65);
|
||||
backdrop-filter: blur(4px);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.bar button { cursor: pointer; }
|
||||
.bar__play {
|
||||
min-width: 74px;
|
||||
padding: 7px 14px;
|
||||
border: 1px solid var(--ui-accent);
|
||||
border-radius: 999px;
|
||||
background: var(--ui-accent);
|
||||
color: var(--ui-on-accent);
|
||||
font-weight: 600;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
.bar__step {
|
||||
width: 32px; height: 32px;
|
||||
border: 1px solid var(--ui-line);
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
}
|
||||
.bar__step:disabled { opacity: 0.35; cursor: default; }
|
||||
.dots { display: flex; gap: 0; margin: 0; padding: 0; list-style: none; }
|
||||
.dots button {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 5px 8px 5px 5px;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: transparent;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--ui-soft);
|
||||
}
|
||||
.dots__n {
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
width: 20px; height: 20px;
|
||||
border: 1.5px solid currentColor;
|
||||
border-radius: 50%;
|
||||
font-size: 0.7rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
.dots button[aria-current] { color: var(--ui-fg); font-weight: 600; }
|
||||
.dots button[aria-current] .dots__n { background: var(--ui-accent); border-color: var(--ui-accent); color: var(--ui-on-accent); }
|
||||
.looks { display: flex; align-items: center; gap: 4px; margin-left: 6px; padding-left: 12px; border-left: 1px solid var(--ui-line); font-size: 0.8125rem; }
|
||||
.looks__label { margin-right: 4px; color: var(--ui-soft); }
|
||||
.looks__sep { color: var(--ui-soft); }
|
||||
.looks button {
|
||||
width: 26px; height: 26px;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
font-weight: 600;
|
||||
}
|
||||
.looks button[aria-pressed="true"] { border-color: var(--ui-accent); color: var(--ui-accent); }
|
||||
.looks__name { min-width: 84px; margin-left: 6px; font: italic 500 1rem var(--serif); color: var(--ui-soft); }
|
||||
|
||||
/* ---------- the panel ---------- */
|
||||
.panel {
|
||||
position: relative;
|
||||
z-index: 8;
|
||||
min-height: 0;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
background: var(--pn-bg);
|
||||
color: var(--ui-fg);
|
||||
box-shadow: -14px 0 30px -18px rgb(0 0 0 / 0.7);
|
||||
font-size: 15px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
/* look 2: a vellum sheet, held by a wooden roller along its edge (12's chart) */
|
||||
body:not([data-look="3"]) .panel {
|
||||
background:
|
||||
repeating-linear-gradient(90deg, rgb(91 65 40 / 0.03) 0 1px, transparent 1px 7px),
|
||||
linear-gradient(180deg, var(--vellum-hi), #e6d9b8);
|
||||
}
|
||||
body:not([data-look="3"]) .panel::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
top: 0; bottom: 0; left: 0;
|
||||
width: 8px;
|
||||
background: linear-gradient(90deg, #7d6a4a, #e2d5b2 45%, #8e7b58);
|
||||
}
|
||||
/* look 3: glaze black with a terracotta tongue band along the top, as on the frieze */
|
||||
body[data-look="3"] .panel::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
top: 0; left: 0; right: 0;
|
||||
height: 12px;
|
||||
background: var(--clay) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='12'%3E%3Cpath d='M2 0H12V6A5 5 0 0 1 2 6Z' fill='%231d140e'/%3E%3C/svg%3E") 0 0 / 14px 12px repeat-x;
|
||||
border-bottom: 2px solid var(--glaze);
|
||||
}
|
||||
.panel__body {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: var(--panel-w);
|
||||
display: grid;
|
||||
grid-template-rows: auto auto minmax(0, 1fr);
|
||||
padding-left: 8px;
|
||||
transition: opacity 0.25s ease, transform 0.42s cubic-bezier(0.22, 0.8, 0.2, 1);
|
||||
}
|
||||
body[data-look="3"] .panel__body { padding: 14px 0 0; }
|
||||
.panel[data-open="false"] .panel__body { opacity: 0; transform: translateX(40px); pointer-events: none; }
|
||||
|
||||
.panel__head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 22px 10px 24px; }
|
||||
.panel__song { flex: 1; min-width: 0; transition: opacity 0.18s ease, transform 0.18s ease; }
|
||||
.panel__eyebrow { margin: 0; font-size: 0.8125rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ui-soft); }
|
||||
.panel__title { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 2px; font: 600 2rem/1.05 var(--serif); }
|
||||
.panel__n {
|
||||
flex: none;
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
width: 30px; height: 30px;
|
||||
transform: translateY(-3px);
|
||||
border-radius: 50%;
|
||||
background: var(--ui-accent);
|
||||
color: var(--ui-on-accent);
|
||||
font: 600 0.9375rem var(--sans);
|
||||
}
|
||||
.panel__sub { margin: 0; color: var(--ui-soft); }
|
||||
.panel__hide {
|
||||
flex: none;
|
||||
margin-top: 2px;
|
||||
padding: 5px 12px;
|
||||
border: 1px solid var(--ui-line);
|
||||
border-radius: 999px;
|
||||
background: transparent;
|
||||
font-size: 0.875rem;
|
||||
color: var(--ui-soft);
|
||||
cursor: pointer;
|
||||
}
|
||||
.panel__hide:hover { color: var(--ui-fg); border-color: var(--ui-fg); }
|
||||
|
||||
.tabs { display: flex; gap: 4px; padding: 0 22px 0 24px; border-bottom: 1px solid var(--ui-line); }
|
||||
.tabs button {
|
||||
position: relative;
|
||||
padding: 10px 10px 11px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--ui-soft);
|
||||
font-size: 0.9375rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
.tabs button[aria-selected="true"] { color: var(--ui-fg); }
|
||||
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 3px; border-radius: 2px; background: var(--ui-accent); }
|
||||
.panel__view {
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
padding: 18px 22px 28px 24px;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--ui-line) transparent;
|
||||
transition: opacity 0.18s ease, transform 0.18s ease;
|
||||
}
|
||||
.panel.is-swapping .panel__view, .panel.is-swapping .panel__song { opacity: 0; transform: translateY(6px); }
|
||||
|
||||
/* the slim tab, shown when collapsed */
|
||||
.panel__tab {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: var(--panel-slim);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 14px;
|
||||
padding: 22px 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--ui-fg);
|
||||
cursor: pointer;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.25s ease 0.1s;
|
||||
}
|
||||
.panel[data-open="false"] .panel__tab { opacity: 1; pointer-events: auto; }
|
||||
.panel__tab-arrow { font-size: 1.5rem; line-height: 1; color: var(--ui-accent); }
|
||||
.panel__tab-n {
|
||||
display: inline-grid; place-items: center;
|
||||
width: 30px; height: 30px; border-radius: 50%;
|
||||
background: var(--ui-accent); color: var(--ui-on-accent);
|
||||
font-weight: 600; font-size: 0.9375rem;
|
||||
}
|
||||
.panel__tab-label { writing-mode: vertical-rl; font: 600 1.125rem var(--serif); letter-spacing: 0.06em; }
|
||||
|
||||
/* ---------- panel content ---------- */
|
||||
.sec { margin: 22px 0 8px; font: 600 1.3rem/1.2 var(--serif); }
|
||||
.panel__view > div > .sec:first-child, .panel__view > div > div:first-child > .sec:first-child { margin-top: 0; }
|
||||
.note {
|
||||
margin: 0 0 16px;
|
||||
padding: 9px 12px;
|
||||
border: 1px dashed var(--ui-line);
|
||||
border-radius: 4px;
|
||||
color: var(--ui-soft);
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
.hint { margin: 0 0 10px; color: var(--ui-soft); font-size: 0.875rem; }
|
||||
|
||||
/* About */
|
||||
.facts { margin: 0; display: grid; gap: 0; }
|
||||
.facts div { display: grid; grid-template-columns: 112px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--ui-line); }
|
||||
.facts dt { color: var(--ui-soft); font-size: 0.875rem; padding-top: 1px; }
|
||||
.facts dd { margin: 0; }
|
||||
.facts a, .about a { color: var(--ui-accent); text-underline-offset: 3px; }
|
||||
.about__fact { margin: 14px 0 0; font: italic 500 1.2rem/1.35 var(--serif); }
|
||||
.parts { margin: 0; padding: 0; list-style: none; }
|
||||
.parts li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--ui-line); }
|
||||
.parts__name { font-weight: 600; }
|
||||
.parts__who { color: var(--ui-soft); text-align: right; }
|
||||
.panel .audio-slot { padding: 12px 14px; border: 1px dashed var(--ui-line); border-radius: 6px; color: var(--ui-soft); opacity: 1; font-size: 0.875rem; }
|
||||
.panel .video-cards { gap: 8px; }
|
||||
.panel .video-card {
|
||||
padding: 9px 14px 9px 36px;
|
||||
border: 1px solid var(--ui-line);
|
||||
border-radius: 6px;
|
||||
background: var(--pn-card);
|
||||
font-weight: 600;
|
||||
position: relative;
|
||||
}
|
||||
.panel .video-card::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 13px; top: 50%;
|
||||
border: 6px solid transparent;
|
||||
border-left: 9px solid var(--ui-accent);
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
/* Paths: route chart */
|
||||
.route {
|
||||
margin: 0;
|
||||
padding: 8px 9px 6px;
|
||||
background: linear-gradient(160deg, #ece2c6, #dccca5);
|
||||
color: var(--iron);
|
||||
border-radius: 3px;
|
||||
box-shadow: 0 1px 0 rgb(255 255 255 / 0.4) inset, 0 8px 18px -10px rgb(20 12 6 / 0.55);
|
||||
}
|
||||
body[data-look="3"] .route { outline: 1px solid var(--clay); outline-offset: 3px; }
|
||||
.route figcaption { margin-top: 4px; font: italic 500 0.95rem var(--serif); color: var(--iron-soft); }
|
||||
.chart__svg { display: block; width: 100%; height: auto; }
|
||||
.c-vellum { fill: #e6dab9; }
|
||||
.c-frame { fill: none; stroke: var(--iron); stroke-width: 0.8; }
|
||||
.c-rhumb { fill: none; stroke: rgb(162 58 42 / 0.18); stroke-width: 0.5; }
|
||||
.c-land { fill: #c9b07a; stroke: var(--iron); stroke-width: 0.9; }
|
||||
.c-ink { fill: none; stroke: var(--iron); stroke-width: 0.7; }
|
||||
.c-course { fill: none; stroke: var(--rhumb-red); stroke-width: 1.3; stroke-dasharray: 3 2.4; }
|
||||
.c-port { fill: #f3ebd6; stroke: var(--iron); stroke-width: 0.9; }
|
||||
.c-num { font: 600 7px var(--sans); fill: var(--iron); }
|
||||
.c-place { font: 600 italic 14px var(--serif); fill: var(--iron); }
|
||||
.c-sea { font: italic 500 9px var(--serif); fill: var(--rhumb-red); }
|
||||
.c-rose circle { fill: none; stroke: var(--iron-soft); stroke-width: 0.6; }
|
||||
.c-rose path { fill: var(--iron-soft); }
|
||||
.c-here__ring { fill: rgb(162 58 42 / 0.18); stroke: var(--rhumb-red); stroke-width: 1.4; }
|
||||
.c-here__dot { fill: var(--rhumb-red); }
|
||||
.c-here__label { font: 600 9.5px var(--sans); fill: var(--rhumb-red); paint-order: stroke; stroke: #efe6cd; stroke-width: 2.5px; }
|
||||
|
||||
/* Paths: motif picks */
|
||||
.mlist { margin: 0 0 12px; padding: 0; list-style: none; display: grid; gap: 6px; }
|
||||
.mpick {
|
||||
width: 100%;
|
||||
display: grid;
|
||||
gap: 1px;
|
||||
padding: 8px 12px 9px;
|
||||
border: 1px solid var(--ui-line);
|
||||
border-left: 4px solid var(--c);
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
}
|
||||
.mpick:hover { background: var(--pn-bg-2); }
|
||||
.mpick[aria-pressed="true"] { background: var(--pn-bg-2); border-color: var(--c); }
|
||||
.mpick__name { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--c); }
|
||||
.mpick__name i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
|
||||
.mpick__path { color: var(--ui-soft); font-size: 0.875rem; }
|
||||
|
||||
/* Paths: the thread strip */
|
||||
.strip { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: start; }
|
||||
.strip__rows { grid-column: 1 / -1; grid-row: 1; margin: 0; padding: 0; list-style: none; }
|
||||
.strip__row {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 0 calc(var(--cols) * 26px + 30px) 0 8px;
|
||||
border: 0;
|
||||
border-radius: 3px;
|
||||
background: transparent;
|
||||
color: var(--ui-soft);
|
||||
text-align: left;
|
||||
font-size: 0.9375rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
.strip__row:hover { background: var(--pn-bg-2); }
|
||||
.strip__row.is-current { color: var(--ui-fg); font-weight: 600; background: var(--pn-bg-2); }
|
||||
.strip__row.is-picked { outline: 2px solid var(--ui-accent); outline-offset: -2px; color: var(--ui-fg); }
|
||||
.strip__n { width: 18px; text-align: right; font-size: 0.8125rem; font-variant-numeric: tabular-nums; }
|
||||
.strip__t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.strip__now { padding: 0 7px; border-radius: 999px; background: var(--ui-accent); color: var(--ui-on-accent); font-size: 0.75rem; font-weight: 600; }
|
||||
.strip__threads { grid-column: 2; grid-row: 1; margin-right: 12px; pointer-events: none; overflow: visible; }
|
||||
.thread__line { fill: none; stroke: var(--c); stroke-width: 2.4; stroke-linecap: round; opacity: 0.8; }
|
||||
.thread__knot { fill: var(--pn-bg); stroke: var(--c); stroke-width: 2.4; }
|
||||
.thread.is-on .thread__line { stroke-width: 4; opacity: 1; }
|
||||
.thread.is-on .thread__knot { fill: var(--c); }
|
||||
.thread.is-dim { opacity: 0.18; }
|
||||
|
||||
/* Lyrics */
|
||||
.part { margin: 0 0 16px; padding: 4px 0 6px 14px; border-left: 4px solid var(--c); }
|
||||
.part__head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; margin-bottom: 4px; }
|
||||
.part__head h3 { margin: 0; font: 600 1.3rem/1.2 var(--serif); font-variant-numeric: lining-nums; }
|
||||
.part__who { display: flex; flex-wrap: wrap; gap: 4px; }
|
||||
.singer { padding: 1px 9px; border: 1px solid var(--ui-line); border-radius: 999px; font-size: 0.8125rem; font-weight: 600; color: var(--ui-soft); }
|
||||
.part__lines p { margin: 2px 0; font: italic 500 1.15rem/1.45 var(--serif); }
|
||||
.part__motifs { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }
|
||||
.mtag { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); font-size: 0.8125rem; font-weight: 600; }
|
||||
.mtag i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
|
||||
|
||||
/* Fan works */
|
||||
.fw { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
|
||||
.fw__card { display: grid; align-content: start; gap: 2px; padding: 0 0 10px; border-radius: 5px; background: var(--pn-card); border: 1px solid var(--ui-line); overflow: hidden; }
|
||||
.fw__card > p { margin: 0 10px; }
|
||||
.fw__thumb { display: block; width: 100%; aspect-ratio: 16 / 10; margin-bottom: 6px; border-bottom: 1px solid var(--ui-line); }
|
||||
.t-bg { fill: #d9c8a0; }
|
||||
.t-ink { fill: var(--iron); }
|
||||
.t-line { fill: none; stroke: #f3ead6; stroke-width: 2; stroke-linecap: round; }
|
||||
.t-frame { fill: #d9c8a0; }
|
||||
.t-hole { fill: #d9c8a0; }
|
||||
body[data-look="3"] .t-bg, body[data-look="3"] .t-frame, body[data-look="3"] .t-hole { fill: var(--clay); }
|
||||
body[data-look="3"] .t-ink { fill: var(--glaze); }
|
||||
body[data-look="3"] .t-line { stroke: var(--added-white); }
|
||||
.fw__type { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ui-accent); }
|
||||
.fw__title { font: 600 1.05rem/1.25 var(--serif); }
|
||||
.fw__by { font-size: 0.875rem; color: var(--ui-soft); }
|
||||
.fw__credit { margin-top: 4px !important; font-size: 0.8125rem; color: var(--ui-soft); text-decoration: underline dotted; text-underline-offset: 3px; }
|
||||
.fw__credit span { text-decoration: none; display: inline-block; }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.cut { transition-duration: 0.25s; }
|
||||
.shell, .panel__body, .panel__view, .panel__song { transition: none; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user