Hacky demo changes
This commit is contained in:
parent
7cba369308
commit
ea7afd618c
39 changed files with 2041 additions and 745 deletions
58
video/src/timeline.ts
Normal file
58
video/src/timeline.ts
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import type { Page } from 'playwright';
|
||||
import { installCursor, installZoomWrapper, waitForCurrentDemoMapSettled } from './dom.js';
|
||||
import { sleep } from './motion.js';
|
||||
import { dashboardUrl } from './routes.js';
|
||||
import {
|
||||
prepareAiBox,
|
||||
sceneAiCloseUp,
|
||||
sceneClusterClick,
|
||||
sceneExportAndOutro,
|
||||
sceneTravelTimeSlider,
|
||||
sceneZoomOutResults,
|
||||
type SceneCtx,
|
||||
} from './scenes.js';
|
||||
|
||||
export interface TimelineResult {
|
||||
sceneStartMs: number;
|
||||
sceneEndMs: number;
|
||||
}
|
||||
|
||||
export async function prepareTimeline(page: Page): Promise<SceneCtx> {
|
||||
await page.goto(dashboardUrl(), { waitUntil: 'domcontentloaded' });
|
||||
await page.waitForLoadState('load', { timeout: 15000 }).catch(() => {});
|
||||
await page
|
||||
.locator('[data-tutorial="ai-filters"]')
|
||||
.waitFor({ state: 'visible', timeout: 15000 });
|
||||
await page.locator('canvas').first().waitFor({ state: 'attached', timeout: 15000 });
|
||||
await waitForCurrentDemoMapSettled(page, 15000);
|
||||
|
||||
await new Promise((r) => setTimeout(r, 400));
|
||||
await installZoomWrapper(page);
|
||||
await installCursor(page);
|
||||
|
||||
const ctx: SceneCtx = { page, cursor: { x: 200, y: 240 } };
|
||||
await page.mouse.move(ctx.cursor.x, ctx.cursor.y);
|
||||
await prepareAiBox(ctx);
|
||||
await sleep(80);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
export async function runTimeline(ctx: SceneCtx): Promise<TimelineResult> {
|
||||
const sceneStartMs = Date.now();
|
||||
let mark = sceneStartMs;
|
||||
|
||||
mark = await runScene('AI close-up', mark, () => sceneAiCloseUp(ctx));
|
||||
mark = await runScene('Zoom out', mark, () => sceneZoomOutResults(ctx));
|
||||
mark = await runScene('TT slider', mark, () => sceneTravelTimeSlider(ctx));
|
||||
mark = await runScene('Cluster click', mark, () => sceneClusterClick(ctx));
|
||||
mark = await runScene('Export + outro', mark, () => sceneExportAndOutro(ctx));
|
||||
|
||||
return { sceneStartMs, sceneEndMs: mark };
|
||||
}
|
||||
|
||||
async function runScene(label: string, prev: number, scene: () => Promise<void>): Promise<number> {
|
||||
await scene();
|
||||
const now = Date.now();
|
||||
console.log(`[scene] ${label}: ${((now - prev) / 1000).toFixed(2)}s wall`);
|
||||
return now;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue