Files
cutaway/sims/green/cam_track.mjs
T
Nyxera0x 5d8f1c6efe Cutaway skill: build, film and score a 3D object that takes itself apart from one picture
The skill (SKILL.md), the kit for building one HTML page and capturing a 60 fps film, the procedural sound engine, the green page and look, and 3 complete examples: a tarantula, a piranha and a wasp, each with a full film and a 10-second version. The method docs move into docs/ with the README's GIFs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 12:57:09 +03:00

24 lines
1.2 KiB
JavaScript

// print a film's camera every 0.5 s (node sims/green/cam_track.mjs <entry> <global> [step])
import {pathToFileURL} from 'node:url';
import path from 'node:path';
import {CHROMIUM, CHROMIUM_ARGS, DIST, playwright} from '../../paths.mjs';
const [entry, glob, step = '0.5'] = process.argv.slice(2);
const {chromium} = playwright();
const browser = await chromium.launch({executablePath: CHROMIUM, args: CHROMIUM_ARGS});
const page = await browser.newPage({viewport: {width: 1600, height: 900}, deviceScaleFactor: 1});
await page.addInitScript(() => { window.__CAPTURE = true; window.__SIM_CONFIG = {}; });
await page.goto(pathToFileURL(path.join(DIST, `${entry}.html`)).href);
await page.waitForFunction(() => window.SIM && window.SIM.ready, null, {timeout: 60000});
const rows = await page.evaluate(([glob, step]) => {
const T = window[glob].T;
const out = [];
for (let t = 0; t <= window.SIM.duration + 1e-6; t += Number(step)) {
const s = T.stateAt(t);
const c = s.cam;
out.push(`${t.toFixed(1).padStart(5)} ${String(s.view).padEnd(9)} az ${c.az.toFixed(0).padStart(4)} el ${c.el.toFixed(0).padStart(3)} d ${c.d.toFixed(1)}`);
}
return out;
}, [glob, step]);
console.log(rows.join('\n'));
await browser.close();