Video: voxel titles, new opening with world turn, app punch-ins and callouts, six-screen montage, props sequence; site carries the new film
This commit is contained in:
37 files changed
+2672
-165
No files matched your search
@@ -36,25 +36,45 @@
|
||||
line-height: 1;
|
||||
}
|
||||
.version {
|
||||
top: 232px;
|
||||
font-size: 40px;
|
||||
font-weight: 300;
|
||||
top: 936px;
|
||||
font-size: 30px;
|
||||
font-weight: 400;
|
||||
}
|
||||
.url {
|
||||
top: 292px;
|
||||
font-size: 28px;
|
||||
top: 1000px;
|
||||
font-size: 24px;
|
||||
font-weight: 300;
|
||||
letter-spacing: 0.01em;
|
||||
}
|
||||
.cap {
|
||||
top: 846px;
|
||||
}
|
||||
.cap .en {
|
||||
margin: 0;
|
||||
font-size: 48px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.015em;
|
||||
}
|
||||
.cap .zh {
|
||||
margin: 14px 0 0;
|
||||
font-family: "PingFang SC", sans-serif;
|
||||
font-size: 30px;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0.04em;
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<svg id="frame" width="1920" height="1080" viewBox="0 0 1920 1080"><g id="world"></g></svg>
|
||||
<div class="words">
|
||||
<h1 data-text="title">Ely Office</h1>
|
||||
<h1 data-text="name">Ely Office</h1>
|
||||
<p class="version" data-text="version" data-soft>0.1.0 · macOS</p>
|
||||
<h1 data-text="name">Ely Office 0.1.0</h1>
|
||||
<p class="version" data-text="version" data-soft>Out now for macOS · Windows and Linux soon macOS 现已推出 · Windows 与 Linux 即将推出</p>
|
||||
<p class="url" data-text="url" data-soft>github.com/ZacharyZhang-NY/ElyOffice/releases</p>
|
||||
<div class="cap" data-text="offline"><p class="en">Works with the network off.</p><p class="zh">断网照常工作。</p></div>
|
||||
<div class="cap" data-text="open"><p class="en">Open source, AGPL.</p><p class="zh">开源,AGPL 许可。</p></div>
|
||||
<div class="cap" data-text="local"><p class="en">Your files stay in your folders.</p><p class="zh">文件留在你自己的文件夹里。</p></div>
|
||||
</div>
|
||||
<script type="module" src="./page.ts"></script>
|
||||
</body>
|
||||
|
||||
+105
-29
@@ -2,9 +2,11 @@
|
||||
import "../../src/iso.css";
|
||||
import { UNIT, block, order, project } from "../../src/iso.ts";
|
||||
import { ACCENT, model } from "../../src/model.ts";
|
||||
import { type Box, DESK, PAPER, SCREEN, props, screens, tiles } from "./parts.ts";
|
||||
import { type Box, DESK, PAPER, SCREEN, SHEET, lamp, props, screens, tiles } from "./parts.ts";
|
||||
import { BAR, BEAT, glide, toward } from "./time.ts";
|
||||
import { type Moment, moment } from "./timeline.ts";
|
||||
import { DESK_END, type Moment, SEED, TURN, moment } from "./timeline.ts";
|
||||
import { montage, turnedBlock, turnedOrder } from "./turn.ts";
|
||||
import { view } from "../opening/plan.ts";
|
||||
|
||||
export const WIDTH = 1920;
|
||||
export const HEIGHT = 1080;
|
||||
@@ -39,6 +41,7 @@ const DARK: Record<string, string> = {
|
||||
[DESK]: "#3a3a3a",
|
||||
[PAPER]: "#5c5c5a",
|
||||
[SCREEN]: "#3a3a3c",
|
||||
[SHEET]: "#7a7a78",
|
||||
[ACCENT]: ACCENT,
|
||||
};
|
||||
const PAGE = ["#fbfbfa", "#252525"];
|
||||
@@ -64,15 +67,62 @@ interface Camera {
|
||||
const corners = (b: Box): [number, number][] =>
|
||||
[0, 1].flatMap((i) => [0, 1].flatMap((j) => [0, 1].map((k) => project(b.x + i * b.w, b.y + j * b.d, b.z + k * b.h))));
|
||||
|
||||
/** Fits the whole film's model below the title. */
|
||||
const base: Camera = (() => {
|
||||
const all = [...model.flatMap((p) => p.blocks), ...props.flatMap((p) => p.blocks)].flatMap(corners);
|
||||
/** Frames `boxes` inside w by h, centred at (cx, cy). */
|
||||
function fit(boxes: Box[], w: number, h: number, cx: number, cy: number): Camera {
|
||||
const all = boxes.flatMap(corners);
|
||||
const xs = all.map(([x]) => x);
|
||||
const ys = all.map(([, y]) => y);
|
||||
const [x0, x1, y0, y1] = [Math.min(...xs), Math.max(...xs), Math.min(...ys), Math.max(...ys)];
|
||||
const s = Math.min(1500 / (x1 - x0), 620 / (y1 - y0));
|
||||
return { s, x: WIDTH / 2 - (s * (x0 + x1)) / 2, y: 690 - (s * (y0 + y1)) / 2 };
|
||||
const s = Math.min(w / (x1 - x0), h / (y1 - y0));
|
||||
return { s, x: cx - (s * (x0 + x1)) / 2, y: cy - (s * (y0 + y1)) / 2 };
|
||||
}
|
||||
|
||||
/** Eases between cameras by log scale and centre point. */
|
||||
function blend(a: Camera, b: Camera, u: number): Camera {
|
||||
if (u <= 0) return a;
|
||||
if (u >= 1) return b;
|
||||
const s = a.s * (b.s / a.s) ** u;
|
||||
const ca = [(WIDTH / 2 - a.x) / a.s, (HEIGHT / 2 - a.y) / a.s];
|
||||
const cb = [(WIDTH / 2 - b.x) / b.s, (HEIGHT / 2 - b.y) / b.s];
|
||||
const [cx, cy] = [ca[0] + (cb[0] - ca[0]) * u, ca[1] + (cb[1] - ca[1]) * u];
|
||||
return { s, x: WIDTH / 2 - s * cx, y: HEIGHT / 2 - s * cy };
|
||||
}
|
||||
|
||||
const everything = [...model.flatMap((p) => p.blocks), ...lamp, ...props.flatMap((p) => p.blocks)];
|
||||
/** Model under the title; whole model; end card. */
|
||||
const hero = fit(everything, 1720, 790, WIDTH / 2, 640);
|
||||
const wide = fit(everything, 1800, 960, WIDTH / 2, 545);
|
||||
/** End card: below the title, or above the delivered voxel type. */
|
||||
const ending = () => (hidden.has("name") ? fit(everything, 1500, 340, WIDTH / 2, 235) : fit(everything, 1440, 600, WIDTH / 2, 575));
|
||||
/** The opening's last framing, in this renderer's terms. */
|
||||
const opened = (() => {
|
||||
const v = view(514);
|
||||
const [cx, cy] = project(v.cx, v.cy, 0);
|
||||
return { s: v.s / UNIT, x: v.ox - (v.s / UNIT) * cx, y: v.oy - (v.s / UNIT) * cy };
|
||||
})();
|
||||
const close = props.map((p) => fit(p.blocks, 1200, 640, WIDTH / 2, 420));
|
||||
const seed = (() => {
|
||||
const [px, py] = project(SEED[0] + 0.5, SEED[1] + 0.5, model[0].blocks[0].h);
|
||||
return { s: 10, x: WIDTH / 2 - 10 * px, y: HEIGHT / 2 - 10 * py };
|
||||
})();
|
||||
|
||||
/** The camera for model scenes at time `t`. */
|
||||
function camera(t: number): Camera {
|
||||
const beat = t / BEAT;
|
||||
if (beat < 16) {
|
||||
const x = Math.min(beat / (DESK_END + 2), 1);
|
||||
const v = 1 - (1 - x) ** 1.6;
|
||||
const s = 1 / (1 / seed.s + (1 / hero.s - 1 / seed.s) * v);
|
||||
const c = blend(seed, hero, Math.log(s / seed.s) / Math.log(hero.s / seed.s));
|
||||
return { ...c, s };
|
||||
}
|
||||
if (beat < 128) return blend(hero, { ...hero, s: hero.s * 1.05 }, (beat - 16) / 16);
|
||||
if (beat < TURN[1]) return blend(montage, wide, glide((beat - TURN[0]) / (TURN[1] - TURN[0])));
|
||||
if (beat < 144) return blend(wide, close[0], toward(t, 144, BEAT / 2, glide));
|
||||
if (beat < 148) return blend(close[0], close[1], toward(t, 148, BEAT / 2, glide));
|
||||
if (beat < 152) return blend(close[1], close[2], toward(t, 152, BEAT / 2, glide));
|
||||
return blend(close[2], ending(), toward(t, 160, BAR, glide));
|
||||
}
|
||||
|
||||
/** Pinned face corners: TL, TR, BL, BR of +y side. */
|
||||
function face(b: Box): [number, number][] {
|
||||
@@ -80,18 +130,36 @@ function face(b: Box): [number, number][] {
|
||||
return [project(b.x, y, b.z + b.h), project(b.x + b.w, y, b.z + b.h), project(b.x, y, b.z), project(b.x + b.w, y, b.z)];
|
||||
}
|
||||
|
||||
/** Pushes from the base view until the screen fills frame. */
|
||||
function push(app: string, t: number, beat: number): Camera {
|
||||
/** The flat window the recording lands in; matches edit/plan.json. */
|
||||
const WINDOW = { x: 144, y: 40, w: 1632, h: 918 };
|
||||
const RECT: [number, number][] = [
|
||||
[WINDOW.x, WINDOW.y],
|
||||
[WINDOW.x + WINDOW.w, WINDOW.y],
|
||||
[WINDOW.x, WINDOW.y + WINDOW.h],
|
||||
[WINDOW.x + WINDOW.w, WINDOW.y + WINDOW.h],
|
||||
];
|
||||
|
||||
/** Face bounds in world pixels. */
|
||||
function bounds(app: string) {
|
||||
const pts = face(screens[app]);
|
||||
const xs = pts.map(([x]) => x);
|
||||
const ys = pts.map(([, y]) => y);
|
||||
const [cx, cy] = [(Math.min(...xs) + Math.max(...xs)) / 2, (Math.min(...ys) + Math.max(...ys)) / 2];
|
||||
const end = Math.min((0.78 * HEIGHT) / (Math.max(...ys) - Math.min(...ys)), (0.8 * WIDTH) / (Math.max(...xs) - Math.min(...xs)));
|
||||
const u = toward(t, beat + 2, 2 * BEAT, glide);
|
||||
const s = base.s * (end / base.s) ** u;
|
||||
const [px, py] = [base.x + base.s * cx, base.y + base.s * cy];
|
||||
const [qx, qy] = [px + (WIDTH / 2 - px) * u, py + (HEIGHT / 2 - py) * u];
|
||||
return { s, x: qx - s * cx, y: qy - s * cy };
|
||||
return { x0: Math.min(...xs), x1: Math.max(...xs), y0: Math.min(...ys), y1: Math.max(...ys) };
|
||||
}
|
||||
|
||||
/** Pushes toward the screen, then into it on the last beat. */
|
||||
function push(app: string, t: number, beat: number): { cam: Camera; flat: number } {
|
||||
const f = bounds(app);
|
||||
const [cx, cy] = [(f.x0 + f.x1) / 2, (f.y0 + f.y1) / 2];
|
||||
const at = (s: number, px: number, py: number): Camera => ({ s, x: px - s * cx, y: py - s * cy });
|
||||
const near = Math.min((0.62 * HEIGHT) / (f.y1 - f.y0), 1060 / (f.x1 - f.x0));
|
||||
const into = WINDOW.w / (f.x1 - f.x0);
|
||||
const start = opened;
|
||||
const aim = at(near, 1250, 520);
|
||||
const full = at(into, WINDOW.x + WINDOW.w / 2, WINDOW.y + WINDOW.h / 2);
|
||||
const flat = toward(t, beat + 4, BEAT, glide);
|
||||
const cam = flat > 0 ? blend(aim, full, flat) : blend(start, aim, toward(t, beat + 3, 3 * BEAT, glide));
|
||||
return { cam, flat };
|
||||
}
|
||||
|
||||
const svg = document.querySelector<SVGSVGElement>("#frame");
|
||||
@@ -99,12 +167,13 @@ const world = document.querySelector<SVGGElement>("#world");
|
||||
if (!svg || !world) throw new Error("index.html lacks #frame or #world");
|
||||
|
||||
function draw(m: Moment, cam: Camera) {
|
||||
const page = mix(mix("#000000", PAGE[0], m.light), PAGE[1], m.dark);
|
||||
const page = mix(PAGE[0], PAGE[1], m.dark);
|
||||
document.body.style.background = page;
|
||||
svg!.style.background = page;
|
||||
world!.setAttribute("transform", `matrix(${cam.s} 0 0 ${cam.s} ${cam.x} ${cam.y})`);
|
||||
const groups = m.pieces.map(({ box, land }) => {
|
||||
const g = block({ ...box, tone: tone(box.tone, m.dark) });
|
||||
const groups = m.pieces.map(({ box, land, dark }) => {
|
||||
const toned = { ...box, tone: tone(box.tone, dark) };
|
||||
const g = m.angle ? turnedBlock(toned, m.angle) : block(toned);
|
||||
if (tiles.includes(box)) g.classList.add("tile");
|
||||
if (land < 1) {
|
||||
g.setAttribute("transform", `translate(0 ${(-UNIT * (1 - land)).toFixed(3)})`);
|
||||
@@ -112,18 +181,23 @@ function draw(m: Moment, cam: Camera) {
|
||||
}
|
||||
return g;
|
||||
});
|
||||
world!.replaceChildren(...order(m.pieces.map((p) => p.box)).map((i) => groups[i]));
|
||||
const boxes = m.pieces.map((p) => p.box);
|
||||
world!.replaceChildren(...(m.angle ? turnedOrder(boxes, m.angle) : order(boxes)).map((i) => groups[i]));
|
||||
for (const el of document.querySelectorAll<HTMLElement>("[data-text]")) {
|
||||
const shown = m.texts[el.dataset.text!] ?? 0;
|
||||
const shown = hidden.has(el.dataset.text!) ? 0 : (m.texts[el.dataset.text!] ?? 0);
|
||||
el.style.opacity = shown.toFixed(4);
|
||||
const [day, dark] = el.dataset.soft === undefined ? INK : SOFT;
|
||||
el.style.color = mix(day, dark, m.dark);
|
||||
}
|
||||
}
|
||||
|
||||
/** Screen-face corners in frame pixels, with the landing's state. */
|
||||
/** Texts another layer draws instead. */
|
||||
const hidden = new Set<string>();
|
||||
|
||||
/** Screen-face corners in frame pixels, and the flattening. */
|
||||
export interface Face {
|
||||
opacity: number;
|
||||
flat: number;
|
||||
corners: [number, number][];
|
||||
}
|
||||
|
||||
@@ -135,23 +209,25 @@ function render(name: string, f: number): Face | null {
|
||||
if (f < first || f >= end) throw new Error(`frame ${f} is outside ${name}`);
|
||||
const t = f / FPS;
|
||||
const app = scene.app;
|
||||
const beat = scene.from * 4 + 1;
|
||||
const m = moment(t, app ? { app, beat } : undefined);
|
||||
const cam = app ? push(app, t, beat) : base;
|
||||
const beat = scene.from * 4;
|
||||
const m = moment(t, app ? { app, beat: beat + 1 } : undefined);
|
||||
const { cam, flat } = app ? push(app, t, beat) : { cam: camera(t), flat: 0 };
|
||||
draw(m, cam);
|
||||
if (!app) return null;
|
||||
const piece = m.pieces.find((p) => p.box === screens[app]);
|
||||
if (!piece) return { opacity: 0, corners: [] };
|
||||
if (!piece) return { opacity: 0, flat, corners: [] };
|
||||
const lift = -UNIT * (1 - piece.land);
|
||||
const pinned = face(piece.box).map(([x, y]) => [cam.x + cam.s * x, cam.y + cam.s * (y + lift)]);
|
||||
return {
|
||||
opacity: piece.land,
|
||||
corners: face(piece.box).map(([x, y]) => [cam.x + cam.s * x, cam.y + cam.s * (y + lift)]),
|
||||
flat,
|
||||
corners: pinned.map(([x, y], i) => [x + (RECT[i][0] - x) * flat, y + (RECT[i][1] - y) * flat]),
|
||||
};
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
ely: { scenes: Scene[]; frames: typeof frames; render: typeof render };
|
||||
ely: { scenes: Scene[]; frames: typeof frames; render: typeof render; hide: (names: string[]) => void };
|
||||
}
|
||||
}
|
||||
window.ely = { scenes, frames, render };
|
||||
window.ely = { scenes, frames, render, hide: (names) => names.forEach((n) => hidden.add(n)) };
|
||||
+87
-34
@@ -27,7 +27,8 @@ export const screens: Record<string, Box> = {
|
||||
ElyTable: screen(5, 1.4, 2.9, 2.4),
|
||||
ElyShow: on(9.4, 1.25, 3.2, 0.05, 1.8, 0.4, SCREEN),
|
||||
ElyPDF: screen(13, 4.3, 2.4, 1),
|
||||
ElyTree: screen(6.5, 7.9, 2.9, 2.8),
|
||||
// Flush with the trunk front: hides the road edge behind.
|
||||
ElyTree: screen(6.5, 8.22, 2.9, 2.8),
|
||||
ElyMark: screen(1, 7.4, 3, 2),
|
||||
};
|
||||
|
||||
@@ -43,11 +44,11 @@ const ROAD = TOP + 0.08;
|
||||
|
||||
/** Mark to Tree first, then four exports queue at PDF. */
|
||||
export const trips: Trip[] = [
|
||||
{ path: [[4.26, 7.9], [5.2, 7.9]], lands: 129, hops: [130, 131] },
|
||||
{ path: [[11, 3.1], [11, 4.9], [12.74, 4.9]], lands: 130, hops: [132, 133] },
|
||||
{ path: [[6.3, 4.16], [6.3, 4.9], [12.14, 4.9]], lands: 130.25, hops: [132, 133, 134, 135] },
|
||||
{ path: [[2.3, 4.26], [2.3, 4.9], [11.54, 4.9]], lands: 130.5, hops: [132, 133, 134, 135, 136, 137] },
|
||||
{ path: [[2.3, 6.74], [2.3, 4.9], [10.94, 4.9]], lands: 130.75, hops: [132, 133, 134, 135, 136, 137] },
|
||||
{ path: [[4.26, 7.9], [5.2, 7.9]], lands: 136.5, hops: [137, 138] },
|
||||
{ path: [[11, 3.1], [11, 4.9], [12.74, 4.9]], lands: 136.75, hops: [139, 140] },
|
||||
{ path: [[6.3, 4.16], [6.3, 4.9], [12.14, 4.9]], lands: 137, hops: [139, 140, 141, 142] },
|
||||
{ path: [[2.3, 4.26], [2.3, 4.9], [11.54, 4.9]], lands: 137.5, hops: [139, 140, 141, 142, 143, 144] },
|
||||
{ path: [[2.3, 6.74], [2.3, 4.9], [10.94, 4.9]], lands: 137.75, hops: [139, 140, 141, 142, 143, 144] },
|
||||
];
|
||||
|
||||
/** The point `s` along a polyline. */
|
||||
@@ -75,38 +76,90 @@ export function file(trip: Trip, s: number): Box {
|
||||
return { x: x - FILE / 2, y: y - FILE / 2, z: ROAD, w: FILE, d: FILE, h: FILE, tone: ACCENT };
|
||||
}
|
||||
|
||||
/** Three props, each landing block by block from its bar. */
|
||||
export const props: { bar: number; blocks: Box[] }[] = [
|
||||
/** A lighter tone for paper sheets. */
|
||||
export const SHEET = "#fbfbfa";
|
||||
|
||||
/** The lamp the dark spreads from; lands in bar 35. */
|
||||
export const LAMP = { beat: 138, centre: [14.4, 1.9] as [number, number] };
|
||||
export const lamp: Box[] = [
|
||||
on(14.4, 1.4, 1, 1, 0.15),
|
||||
on(14.8, 1.8, 0.2, 0.2, 2.4, 0.15),
|
||||
on(13.9, 1.8, 0.9, 0.2, 0.15, 2.4),
|
||||
on(13.6, 1.55, 0.7, 0.7, 0.45, 1.95),
|
||||
];
|
||||
|
||||
/** Three props on plinths before the desk, built on sixteenths. */
|
||||
export interface Prop {
|
||||
bar: number;
|
||||
caption: string;
|
||||
blocks: Box[];
|
||||
}
|
||||
|
||||
/** A prop's blocks, placed on a 4 by 4 plinth at (ox, oy). */
|
||||
function plinth(ox: number, oy: number, list: [number, number, number, number, number, number, string?][]): Box[] {
|
||||
const base: Box = { x: ox, y: oy, z: 0, w: 4, d: 4, h: TOP, tone: DESK };
|
||||
const boxes = [base, ...list.map(([x, y, w, d, h, z, tone]) => on(ox + x, oy + y, w, d, h, z, tone ?? PAPER))];
|
||||
return boxes.map(snap);
|
||||
}
|
||||
|
||||
/** Snaps to 1/64 so touching faces compare exactly. */
|
||||
function snap(b: Box): Box {
|
||||
const r = (v: number) => Math.round(v * 64) / 64;
|
||||
const [x, y, z] = [r(b.x), r(b.y), r(b.z)];
|
||||
return { x, y, z, w: r(b.x + b.w) - x, d: r(b.y + b.d) - y, h: r(b.z + b.h) - z, tone: b.tone };
|
||||
}
|
||||
|
||||
export const props: Prop[] = [
|
||||
{
|
||||
bar: 36,
|
||||
caption: "offline",
|
||||
blocks: plinth(1.5, 12.2, [
|
||||
[0.3, 0.4, 0.3, 1.8, 1, 0, SHEET],
|
||||
[0.3, 0.4, 0.3, 1.8, 1, 1, SHEET],
|
||||
[0.6, 1, 0.2, 0.6, 0.6, 0.3, SCREEN],
|
||||
[3.4, 3.45, 0.3, 0.45, 0.4, 0, ACCENT],
|
||||
[3.4, 2.45, 0.3, 1, 0.4, 0, ACCENT],
|
||||
[3.4, 1.45, 0.3, 1, 0.4, 0, ACCENT],
|
||||
[2.9, 1.15, 0.8, 0.3, 0.4, 0, ACCENT],
|
||||
[1.85, 0.95, 1.05, 0.7, 1.2, 0, SHEET],
|
||||
[1.6, 1.1, 0.25, 0.4, 0.4, 0.4, SCREEN],
|
||||
]),
|
||||
},
|
||||
{
|
||||
bar: 37,
|
||||
blocks: [
|
||||
on(10, 7.2, 1.2, 0.6, 1.3),
|
||||
on(10.2, 8.5, 0.8, 0.8, 0.6),
|
||||
on(10.38, 8.15, 0.12, 0.35, 0.12, 0.25),
|
||||
on(10.7, 8.15, 0.12, 0.35, 0.12, 0.25),
|
||||
on(10.45, 9.3, 0.3, 1.2, 0.2),
|
||||
on(10.75, 10.2, 1.4, 0.3, 0.2),
|
||||
],
|
||||
caption: "open",
|
||||
blocks: plinth(6.7, 12.2, [
|
||||
[0.6, 0.6, 1.3, 1.3, 0.15, 0],
|
||||
[1.9, 0.6, 1.3, 1.3, 0.15, 0],
|
||||
[0.6, 1.9, 1.3, 1.3, 0.15, 0],
|
||||
[1.9, 1.9, 1.3, 1.3, 0.15, 0],
|
||||
[0.6, 0.6, 2.6, 0.15, 1.3, 0.15],
|
||||
[0.6, 0.75, 0.15, 2.45, 1.3, 0.15],
|
||||
[3.05, 0.75, 0.15, 2.3, 1.3, 0.15],
|
||||
[0.75, 3.05, 2.45, 0.15, 1.3, 0.15],
|
||||
[1.4, 1.4, 1, 1, 1.7, 0.15, ACCENT],
|
||||
[0.6, 0.45, 2.6, 0.15, 2, 1.45, SHEET],
|
||||
[0.75, 3.2, 2.45, 0.75, 0.06, 0],
|
||||
[3.2, 0.75, 0.75, 2.3, 0.06, 0],
|
||||
]),
|
||||
},
|
||||
{
|
||||
bar: 38,
|
||||
blocks: [
|
||||
on(12.4, 7.2, 1.9, 1.9, 0.1),
|
||||
on(12.4, 7.2, 1.9, 0.12, 1.1, 0.1),
|
||||
on(12.4, 7.32, 0.12, 1.78, 1.1, 0.1),
|
||||
on(14.18, 7.32, 0.12, 1.66, 1.1, 0.1),
|
||||
on(12.52, 8.98, 1.78, 0.12, 1.1, 0.1),
|
||||
on(11.5, 7.32, 0.9, 1.66, 0.06),
|
||||
on(12.52, 9.1, 1.78, 0.9, 0.06),
|
||||
],
|
||||
},
|
||||
{
|
||||
bar: 39,
|
||||
blocks: [
|
||||
on(14.6, 8.2, 1.3, 0.12, 1.5),
|
||||
on(14.6, 8.2, 0.55, 0.12, 0.2, 1.5),
|
||||
on(14.75, 8.32, 1, 0.08, 1.4, 0, ACCENT),
|
||||
on(14.6, 8.4, 1.3, 0.12, 1.15),
|
||||
],
|
||||
caption: "local",
|
||||
blocks: plinth(11.9, 12.2, [
|
||||
[0.4, 1.6, 0.8, 0.2, 2.6, 0],
|
||||
[1.2, 1.6, 0.8, 0.2, 2.6, 0],
|
||||
[2, 1.6, 0.8, 0.2, 2.6, 0],
|
||||
[2.8, 1.6, 0.8, 0.2, 2.6, 0],
|
||||
[0.4, 1.6, 1.2, 0.2, 0.35, 2.6, ACCENT],
|
||||
[0.7, 1.8, 2.6, 0.15, 2.9, 0, SHEET],
|
||||
[1, 1.95, 2, 0.03, 0.1, 2.6],
|
||||
[1, 1.95, 1.6, 0.03, 0.1, 2.35],
|
||||
[1, 1.95, 1.8, 0.03, 0.1, 2.1],
|
||||
[0.4, 1.98, 0.8, 0.2, 2, 0],
|
||||
[1.2, 1.98, 0.8, 0.2, 2, 0],
|
||||
[2, 1.98, 0.8, 0.2, 2, 0],
|
||||
[2.8, 1.98, 0.8, 0.2, 2, 0],
|
||||
]),
|
||||
},
|
||||
];
|
||||
@@ -1,6 +1,6 @@
|
||||
// Renders iso scenes to PNG frames, faces and MP4s.
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { chromium } from "playwright";
|
||||
@@ -10,6 +10,11 @@ const here = dirname(fileURLToPath(import.meta.url));
|
||||
const site = resolve(here, "../..");
|
||||
const out = resolve(here, "../out/scenes");
|
||||
const PAGES = 6;
|
||||
/** Texts that delivered voxel type replaces. */
|
||||
const extra = resolve(here, "../out/extra");
|
||||
const hide = [["type-title", ["title"]], ["type-end", ["name", "version", "url"]]]
|
||||
.filter(([d]) => existsSync(join(extra, d)))
|
||||
.flatMap(([, t]) => t);
|
||||
|
||||
const server = await createServer({ root: site, configFile: false, logLevel: "error", server: { port: 0 } });
|
||||
await server.listen();
|
||||
@@ -27,12 +32,14 @@ async function open() {
|
||||
});
|
||||
await page.goto(url, { waitUntil: "networkidle" });
|
||||
await page.evaluate(() => document.fonts.ready);
|
||||
await page.evaluate((names) => window.ely.hide(names), hide);
|
||||
return page;
|
||||
}
|
||||
|
||||
const pages = await Promise.all(Array.from({ length: PAGES }, open));
|
||||
const all = await pages[0].evaluate(() => window.ely.scenes.map((s) => ({ ...s, range: window.ely.frames(s) })));
|
||||
const wanted = process.argv.slice(2);
|
||||
if (hide.length) console.log(`hidden: ${hide.join(", ")}`);
|
||||
const unknown = wanted.filter((name) => !all.some((s) => s.name === name));
|
||||
if (unknown.length) throw new Error(`unknown scenes: ${unknown.join(", ")}`);
|
||||
const scenes = wanted.length ? all.filter((s) => wanted.includes(s.name)) : all;
|
||||
|
||||
@@ -1,74 +1,95 @@
|
||||
// The model at any moment, as pieces and texts.
|
||||
import { model } from "../../src/model.ts";
|
||||
import { type Box, file, length, props, screens, tiles, trips } from "./parts.ts";
|
||||
import { LAMP, type Box, file, lamp, length, props, screens, tiles, trips } from "./parts.ts";
|
||||
import { BEAT, LAND, begun, glide, toward } from "./time.ts";
|
||||
import { slabs } from "./turn.ts";
|
||||
|
||||
/** A box and its landing progress, 0 to 1. */
|
||||
/** A box, its landing progress, and whether it is dark. */
|
||||
export interface Piece {
|
||||
box: Box;
|
||||
land: number;
|
||||
dark: number;
|
||||
}
|
||||
|
||||
/** Everything one frame shows, before the camera. */
|
||||
export interface Moment {
|
||||
pieces: Piece[];
|
||||
/** 0 is black, 1 is the page. */
|
||||
light: number;
|
||||
/** 0 is the light palette, 1 the dark one. */
|
||||
/** The page and texts: 0 light, 1 dark. */
|
||||
dark: number;
|
||||
/** The model's turn about the desk centre, radians. */
|
||||
angle: number;
|
||||
texts: Record<string, number>;
|
||||
}
|
||||
|
||||
/** The desk grows in rings around this tile. */
|
||||
const SEED = [8, 5];
|
||||
/** The desk grows outward from this tile. */
|
||||
export const SEED = [8, 5];
|
||||
const ring = (b: Box) => Math.abs(b.x - SEED[0]) + Math.abs(b.y - SEED[1]);
|
||||
const angle = (b: Box) => Math.atan2(b.y - SEED[1], b.x - SEED[0]);
|
||||
|
||||
/** Ring k lands from beat k + 1, by quarters. */
|
||||
const tileBeats = tiles.map((tile) => {
|
||||
const k = ring(tile);
|
||||
const mates = tiles.filter((t) => ring(t) === k).sort((a, b) => angle(a) - angle(b));
|
||||
const quarter = Math.floor((mates.indexOf(tile) * 4) / mates.length);
|
||||
return k + 1 + quarter / 4;
|
||||
/** Tiles land faster and faster: count grows as time squared. */
|
||||
export const DESK_END = 12;
|
||||
const byRing = tiles.map((_, i) => i).sort((a, b) => ring(tiles[a]) - ring(tiles[b]) || angle(tiles[a]) - angle(tiles[b]));
|
||||
const tileBeats: number[] = [];
|
||||
byRing.forEach((tile, n) => {
|
||||
tileBeats[tile] = Math.round(DESK_END * Math.sqrt(n / (tiles.length - 1)) * 4) / 4;
|
||||
});
|
||||
const DESK_DONE = 15;
|
||||
const DESK_DONE = DESK_END + 1;
|
||||
|
||||
/** Beat each app starts on; its blocks follow on sixteenths. */
|
||||
const partBeats = [16, 18, 21, 23, 25, 27, 29];
|
||||
const partBeats = [16, 18, 20, 22, 24, 26, 28];
|
||||
|
||||
/** Beats of each text's fade, ending on that beat. */
|
||||
/** Fade in ending on the first beat; gone at the second. */
|
||||
const TEXTS: Record<string, [number, number]> = {
|
||||
title: [31, 32],
|
||||
name: [161, 168],
|
||||
version: [161.5, 168],
|
||||
url: [162, 168],
|
||||
title: [24, 32],
|
||||
offline: [144.5, 147.5],
|
||||
open: [148.5, 151.5],
|
||||
local: [152.5, 155.5],
|
||||
name: [160, 168.1],
|
||||
version: [160.5, 168.1],
|
||||
url: [161, 168.1],
|
||||
};
|
||||
|
||||
const DARK = 136;
|
||||
/** Bar 35 turns back from the montage's -90°. */
|
||||
export const TURN: [number, number] = [136, 140];
|
||||
|
||||
/** The dark wave: from the lamp, one step per sixteenth. */
|
||||
export const WAVE = 140;
|
||||
export const NIGHT = 144;
|
||||
const lampFar = Math.max(...tiles.map((t) => Math.hypot(t.x + 0.5 - LAMP.centre[0], t.y + 0.5 - LAMP.centre[1])));
|
||||
function flip(b: Box): number {
|
||||
const d = Math.hypot(b.x + b.w / 2 - LAMP.centre[0], b.y + b.d / 2 - LAMP.centre[1]);
|
||||
return WAVE + Math.min(15, Math.floor((16 * d) / lampFar)) / 4;
|
||||
}
|
||||
|
||||
function landed(t: number, box: Box, beat: number, out: Piece[]) {
|
||||
if (begun(t, beat)) out.push({ box, land: toward(t, beat) });
|
||||
if (begun(t, beat)) out.push({ box, land: toward(t, beat), dark: t >= flip(box) * BEAT ? 1 : 0 });
|
||||
}
|
||||
|
||||
/** A trip's file: dropped at its start, then hopping. */
|
||||
function travel(t: number, trip: (typeof trips)[number]): Piece | null {
|
||||
if (!begun(t, trip.lands)) return null;
|
||||
function travel(t: number, trip: (typeof trips)[number], out: Piece[]) {
|
||||
if (!begun(t, trip.lands)) return;
|
||||
const step = length(trip.path) / trip.hops.length;
|
||||
const s = trip.hops.reduce((sum, beat) => sum + step * toward(t, beat), 0);
|
||||
return { box: file(trip, s), land: toward(t, trip.lands) };
|
||||
out.push({ box: file(trip, s), land: toward(t, trip.lands), dark: 0 });
|
||||
}
|
||||
|
||||
/** The model at `t`, plus a plate's screen. */
|
||||
export function moment(t: number, screen?: { app: string; beat: number }): Moment {
|
||||
const pieces: Piece[] = [];
|
||||
if (t < DESK_DONE * BEAT) tiles.forEach((tile, i) => landed(t, tile, tileBeats[i], pieces));
|
||||
else pieces.push({ box: model[0].blocks[0], land: 1 });
|
||||
const wave = t >= (WAVE - 0.01) * BEAT && t < NIGHT * BEAT;
|
||||
if (t < DESK_DONE * BEAT || wave) tiles.forEach((tile, i) => landed(t, tile, tileBeats[i], pieces));
|
||||
else landed(t, model[0].blocks[0], 0, pieces);
|
||||
model.slice(1).forEach((part, p) => part.blocks.forEach((b, i) => landed(t, b, partBeats[p] + i / 4, pieces)));
|
||||
for (const trip of trips) {
|
||||
const piece = travel(t, trip);
|
||||
if (piece) pieces.push(piece);
|
||||
lamp.forEach((b, i) => landed(t, b, LAMP.beat + i / 4, pieces));
|
||||
for (const trip of trips) travel(t, trip, pieces);
|
||||
for (const prop of props) {
|
||||
prop.blocks.forEach((box, i) => {
|
||||
if (begun(t, prop.bar * 4 + i / 4)) pieces.push({ box, land: toward(t, prop.bar * 4 + i / 4), dark: 1 });
|
||||
});
|
||||
}
|
||||
if (t >= TURN[0] * BEAT - 1e-6 && t < 138 * BEAT) {
|
||||
slabs.forEach((box, i) => pieces.push({ box, land: 1 - toward(t, 136.5 + i / 4), dark: 0 }));
|
||||
}
|
||||
for (const prop of props) prop.blocks.forEach((b, i) => landed(t, b, (prop.bar - 1) * 4 + i / 4, pieces));
|
||||
if (screen) {
|
||||
const box = screens[screen.app];
|
||||
if (!box) throw new Error(`no screen for ${screen.app}`);
|
||||
@@ -76,7 +97,10 @@ export function moment(t: number, screen?: { app: string; beat: number }): Momen
|
||||
}
|
||||
const texts: Record<string, number> = {};
|
||||
for (const [name, [from, to]] of Object.entries(TEXTS)) {
|
||||
if (!screen && t < to * BEAT) texts[name] = toward(t, from, LAND, glide);
|
||||
if (screen || t >= to * BEAT) continue;
|
||||
const out = to < 168 ? 1 - toward(t, to, LAND, glide) : 1;
|
||||
texts[name] = toward(t, from, LAND, glide) * out;
|
||||
}
|
||||
return { pieces, light: toward(t, 0.5, LAND, glide), dark: toward(t, DARK, LAND, glide), texts };
|
||||
const turn = t < TURN[0] * BEAT || t >= TURN[1] * BEAT ? 0 : 1 - glide((t / BEAT - TURN[0]) / (TURN[1] - TURN[0]));
|
||||
return { pieces, dark: t >= NIGHT * BEAT ? 1 : 0, angle: (-Math.PI / 2) * turn, texts };
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
// The model turned about the desk centre, as the montage draws it.
|
||||
import { project } from "../../src/iso.ts";
|
||||
import { model } from "../../src/model.ts";
|
||||
import { type Box, SCREEN, screens } from "./parts.ts";
|
||||
|
||||
const SVG = "http://www.w3.org/2000/svg";
|
||||
export const PIVOT = [8, 5.5];
|
||||
const COS = Math.cos(Math.PI / 6);
|
||||
const TOP = model[0].blocks[0].h;
|
||||
|
||||
/** A world point turned by `a`, then projected. */
|
||||
export function turned(a: number, x: number, y: number, z: number): [number, number] {
|
||||
const [dx, dy] = [x - PIVOT[0], y - PIVOT[1]];
|
||||
return project(PIVOT[0] + dx * Math.cos(a) - dy * Math.sin(a), PIVOT[1] + dx * Math.sin(a) + dy * Math.cos(a), z);
|
||||
}
|
||||
|
||||
/** The montage's grown screens, which leave in bar 35. */
|
||||
export const slabs: Box[] = ["ElyMark", "ElyTable", "ElyShow", "ElyDoc", "ElyPDF", "ElyTree"].map((app) => {
|
||||
if (app === "ElyShow") return { x: 8.6, y: 2, z: TOP + 0.25, w: 4.8, d: 0.08, h: 2.7, tone: SCREEN };
|
||||
// The montage drew Tree's screen at its old depth.
|
||||
const b = app === "ElyTree" ? { ...screens[app], y: 7.9 } : screens[app];
|
||||
return { ...b, x: b.x - b.w / 4, w: b.w * 1.5, h: b.h * 1.5 };
|
||||
});
|
||||
|
||||
/** The montage's fixed framing, in this renderer's camera terms. */
|
||||
export const montage = (() => {
|
||||
const boxes = [...model.flatMap((p) => p.blocks), ...slabs, ...slabs.map((b) => ({ ...b, z: b.z + 1 }))];
|
||||
const xs: number[] = [];
|
||||
const ys: number[] = [];
|
||||
for (let i = 0; i <= 90; i++) {
|
||||
const a = (-i * Math.PI) / 180;
|
||||
for (const b of boxes) for (const [x, y, z] of corners(b)) {
|
||||
const [dx, dy] = [x - PIVOT[0], y - PIVOT[1]];
|
||||
const [rx, ry] = [dx * Math.cos(a) - dy * Math.sin(a), dx * Math.sin(a) + dy * Math.cos(a)];
|
||||
xs.push((rx - ry) * COS);
|
||||
ys.push((rx + ry) / 2 - z);
|
||||
}
|
||||
}
|
||||
const [x0, x1, y0, y1] = [Math.min(...xs), Math.max(...xs), Math.min(...ys), Math.max(...ys)];
|
||||
const S = Math.min(1800 / (x1 - x0), 1000 / (y1 - y0));
|
||||
const [X, Y] = [960 - (S * (x0 + x1)) / 2, 540 - (S * (y0 + y1)) / 2];
|
||||
const [cx, cy] = [(PIVOT[0] - PIVOT[1]) * COS, (PIVOT[0] + PIVOT[1]) / 2];
|
||||
const [, unit] = project(0, 0, -1);
|
||||
return { s: S / unit, x: X - S * cx, y: Y - S * cy };
|
||||
})();
|
||||
|
||||
function corners(b: Box): [number, number, number][] {
|
||||
return [0, 1].flatMap((i) => [0, 1].flatMap((j) => [0, 1].map((k) => [b.x + i * b.w, b.y + j * b.d, b.z + k * b.h] as [number, number, number])));
|
||||
}
|
||||
|
||||
/** Side darkness by turned normal: +y 9%, +x 20%. */
|
||||
function darkness(nx: number, ny: number): number {
|
||||
const u = Math.atan2(ny, nx) - Math.PI / 2;
|
||||
return 0.145 - 0.055 * (Math.cos(u) + Math.sin(u));
|
||||
}
|
||||
|
||||
function polygon(points: [number, number][], fill: string): SVGPolygonElement {
|
||||
const el = document.createElementNS(SVG, "polygon");
|
||||
el.setAttribute("points", points.map(([x, y]) => `${x.toFixed(2)},${y.toFixed(2)}`).join(" "));
|
||||
el.style.fill = fill;
|
||||
return el;
|
||||
}
|
||||
|
||||
/** Convex hull of points, for the seam-hiding outline. */
|
||||
function hull(points: [number, number][]): [number, number][] {
|
||||
const p = [...points].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
|
||||
const cross = (o: number[], a: number[], b: number[]) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
|
||||
const half = (list: [number, number][]) => {
|
||||
const out: [number, number][] = [];
|
||||
for (const q of list) {
|
||||
while (out.length >= 2 && cross(out[out.length - 2], out[out.length - 1], q) <= 0) out.pop();
|
||||
out.push(q);
|
||||
}
|
||||
return out.slice(0, -1);
|
||||
};
|
||||
return [...half(p), ...half([...p].reverse())];
|
||||
}
|
||||
|
||||
/** A block turned by `a`: visible sides, then the top. */
|
||||
export function turnedBlock(b: Box, a: number): SVGGElement {
|
||||
const P = (x: number, y: number, z: number) => turned(a, x, y, z);
|
||||
const [x, y, z, X, Y, Z] = [b.x, b.y, b.z, b.x + b.w, b.y + b.d, b.z + b.h];
|
||||
const sides: { n: [number, number]; c: [number, number, number][] }[] = [
|
||||
{ n: [1, 0], c: [[X, y, Z], [X, Y, Z], [X, Y, z], [X, y, z]] },
|
||||
{ n: [-1, 0], c: [[x, Y, Z], [x, y, Z], [x, y, z], [x, Y, z]] },
|
||||
{ n: [0, 1], c: [[X, Y, Z], [x, Y, Z], [x, Y, z], [X, Y, z]] },
|
||||
{ n: [0, -1], c: [[x, y, Z], [X, y, Z], [X, y, z], [x, y, z]] },
|
||||
];
|
||||
const shade = (d: number) => `color-mix(in oklab, ${b.tone}, black ${(d * 100).toFixed(2)}%)`;
|
||||
const g = document.createElementNS(SVG, "g");
|
||||
g.append(polygon(hull(corners(b).map(([px, py, pz]) => P(px, py, pz))), shade(0.09)));
|
||||
for (const { n, c } of sides) {
|
||||
const [nx, ny] = [n[0] * Math.cos(a) - n[1] * Math.sin(a), n[0] * Math.sin(a) + n[1] * Math.cos(a)];
|
||||
if (nx + ny <= 1e-9) continue;
|
||||
g.append(polygon(c.map(([px, py, pz]) => P(px, py, pz)), shade(darkness(nx, ny))));
|
||||
}
|
||||
g.append(polygon([P(x, y, Z), P(X, y, Z), P(X, Y, Z), P(x, Y, Z)], b.tone));
|
||||
return g;
|
||||
}
|
||||
|
||||
/** Back to front for a view turned by `a`. */
|
||||
export function turnedOrder(list: Box[], a: number): number[] {
|
||||
const view = [Math.cos(a) + Math.sin(a), Math.cos(a) - Math.sin(a)];
|
||||
const rect = (b: Box) => {
|
||||
const pts = corners(b).map(([x, y, z]) => turned(a, x, y, z));
|
||||
const xs = pts.map(([px]) => px);
|
||||
const ys = pts.map(([, py]) => py);
|
||||
return [Math.min(...xs), Math.max(...xs), Math.min(...ys), Math.max(...ys)];
|
||||
};
|
||||
const rects = list.map(rect);
|
||||
const meet = (i: number, j: number) =>
|
||||
rects[i][0] < rects[j][1] - 0.01 && rects[j][0] < rects[i][1] - 0.01 && rects[i][2] < rects[j][3] - 0.01 && rects[j][2] < rects[i][3] - 0.01;
|
||||
const lo = (b: Box) => [b.x, b.y, b.z];
|
||||
const hi = (b: Box) => [b.x + b.w, b.y + b.d, b.z + b.h];
|
||||
// Separating axes agree when the blocks truly overlap.
|
||||
const behind = (p: Box, q: Box): boolean | null => {
|
||||
const sign = [view[0], view[1], 1];
|
||||
const votes = new Set<boolean>();
|
||||
for (let k = 0; k < 3; k++) {
|
||||
if (Math.abs(sign[k]) < 1e-6) continue;
|
||||
if (hi(p)[k] <= lo(q)[k]) votes.add(sign[k] > 0);
|
||||
if (hi(q)[k] <= lo(p)[k]) votes.add(sign[k] < 0);
|
||||
}
|
||||
return votes.size === 1 ? [...votes][0] : null;
|
||||
};
|
||||
const before = list.map((q, i) => list.flatMap((p, j) => (j !== i && meet(i, j) && behind(p, q) === true ? [j] : [])));
|
||||
const done = new Set<number>();
|
||||
const out: number[] = [];
|
||||
while (out.length < list.length) {
|
||||
const next = list.findIndex((_, i) => !done.has(i) && before[i].every((j) => done.has(j)));
|
||||
if (next < 0) throw new Error("turned blocks occlude in a cycle");
|
||||
done.add(next);
|
||||
out.push(next);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
Reference in new issue
Block a user