Video: app names clear before the flatten; montage screens play while they lift (R2.3)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-09 02:31:47 -04:00
1 parent 48e83a9b45
commit 5e2cf83da8
7 files changed
+104 -18

No files matched your search

+16 -4
View File
@@ -5,7 +5,8 @@ import { ACCENT, model } from "../../src/model.ts";
import { type Box, DESK, PAPER, SCREEN, SHEET, lamp, props, screens, tiles } from "./parts.ts";
import { BAR, BEAT, glide, toward } from "./time.ts";
import { DESK_END, type Moment, SEED, TURN, moment } from "./timeline.ts";
import { montage, turnedBlock, turnedOrder } from "./turn.ts";
import { film, montage, slabs, turnedBlock, turnedOrder } from "./turn.ts";
import recs from "../montage/recs.json";
import { view } from "../opening/plan.ts";
export const WIDTH = 1920;
@@ -166,14 +167,23 @@ const svg = document.querySelector<SVGSVGElement>("#frame");
const world = document.querySelector<SVGGElement>("#world");
if (!svg || !world) throw new Error("index.html lacks #frame or #world");
function draw(m: Moment, cam: Camera) {
/** Draws the moment; slabs carry the montage recordings at frame `f`. */
function draw(m: Moment, cam: Camera, f: number): Promise<void>[] {
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 loads: Promise<void>[] = [];
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);
const slab = slabs.indexOf(box);
if (slab >= 0 && land > 0) {
const index = String(f - recs.first + 1).padStart(5, "0");
const { el, ready } = film(box, m.angle, `rec/${recs.apps[slab].rec}/${index}.jpg`);
g.append(el);
loads.push(ready);
}
if (tiles.includes(box)) g.classList.add("tile");
if (land < 1) {
g.setAttribute("transform", `translate(0 ${(-UNIT * (1 - land)).toFixed(3)})`);
@@ -189,6 +199,7 @@ function draw(m: Moment, cam: Camera) {
const [day, dark] = el.dataset.soft === undefined ? INK : SOFT;
el.style.color = mix(day, dark, m.dark);
}
return loads;
}
/** Texts another layer draws instead. */
@@ -202,7 +213,7 @@ export interface Face {
}
/** Draws global frame `f` of `scene`; plates return the face. */
function render(name: string, f: number): Face | null {
async function render(name: string, f: number): Promise<Face | null> {
const scene = scenes.find((s) => s.name === name);
if (!scene) throw new Error(`no scene ${name}`);
const [first, end] = frames(scene);
@@ -212,7 +223,8 @@ function render(name: string, f: number): Face | null {
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);
await Promise.all(draw(m, cam, f));
await new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(done)));
if (!app) return null;
const piece = m.pieces.find((p) => p.box === screens[app]);
if (!piece) return { opacity: 0, flat, corners: [] };