cigar-film: a premium corona taken apart - new cigar object, tour, score, timeline; docs + npm run cigar
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
// Numerical companion to the rendered beat-sheet review. Does not mutate the scene source.
|
||||
import {pathToFileURL} from 'node:url';
|
||||
import path from 'node:path';
|
||||
import {CHROMIUM, CHROMIUM_ARGS, DIST, playwright} from '../../paths.mjs';
|
||||
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});
|
||||
const errors = [];
|
||||
page.on('pageerror', (e) => errors.push(e.message));
|
||||
await page.addInitScript(() => {window.__CAPTURE = true; window.__SIM_CONFIG = {};});
|
||||
await page.goto(pathToFileURL(path.join(DIST, 'cigar-film.html')).href);
|
||||
await page.waitForFunction(() => window.SIM?.ready, null, {timeout: 60000});
|
||||
const results = await page.evaluate(async () => {
|
||||
const {bee, T, st} = window.CIGAR;
|
||||
const rows = [];
|
||||
const heroBounds = [];
|
||||
const heroAnchors = [];
|
||||
for (const t of [0, 21.8]) {
|
||||
await window.SIM.render(t); bee.root.updateWorldMatrix(true, true);
|
||||
const box = [Infinity, Infinity, -Infinity, -Infinity];
|
||||
const bodyParts = ['Wrapper / fixed shoulder and back', 'CAP', 'BAND', 'Wrapper / upper shutter', 'Wrapper / lower shutter', 'BINDER', 'Binder / back'];
|
||||
for (const part of bee.root.children.filter((g) => bodyParts.includes(g.name))) part.traverse((o) => {
|
||||
if (!o.isMesh) return;
|
||||
const p = bee.root.position.clone(), a = o.geometry.attributes.position;
|
||||
for (let i = 0; i < a.count; i++) {
|
||||
p.fromBufferAttribute(a, i).applyMatrix4(o.matrixWorld);
|
||||
const q = st.project(p); if (!q) continue;
|
||||
box[0] = Math.min(box[0], q[0]); box[1] = Math.min(box[1], q[1]);
|
||||
box[2] = Math.max(box[2], q[0]); box[3] = Math.max(box[3], q[1]);
|
||||
}
|
||||
});
|
||||
heroBounds.push({t, box: box.map(Math.round), viewportWidthShare: +((box[2] - box[0]) / 1070).toFixed(3), clearOfNavCards: box[0] > 248 && box[2] < 1340 && box[1] > 236 && box[3] < 836});
|
||||
const points = {};
|
||||
for (const key of ['CAP', 'BAND', 'WRAPPER']) {
|
||||
const a = bee.anchors[key]; points[key] = st.project(a.obj.localToWorld(a.at.clone())).map(Math.round);
|
||||
}
|
||||
heroAnchors.push({t, points, margins: Object.values(points).every(([x, y]) => x >= 290 && x <= 1280 && y >= 276 && y <= 796)});
|
||||
}
|
||||
for (const t of [0, 4.2, 6.8, 9.3, 11.9, 14.4, 16.8, 19.3, 20.6, 21.6]) {
|
||||
await window.SIM.render(t);
|
||||
bee.root.updateWorldMatrix(true, true);
|
||||
const s = T.stateAt(t), tel = T.telemetry(t, s);
|
||||
const points = {};
|
||||
for (const [key] of tel.labelSet.set) {
|
||||
const a = bee.anchors[key], p = a.obj.localToWorld(a.at.clone());
|
||||
points[key] = st.project(p)?.map((v) => Math.round(v));
|
||||
}
|
||||
rows.push({t, view: s.view, cam: [s.cam.az, s.cam.el, s.cam.d].map((v) => +v.toFixed(1)), open: +(s.open[s.view] ?? s.explode).toFixed(2), points});
|
||||
}
|
||||
const digest = async (t) => {
|
||||
await window.SIM.render(t); bee.root.updateWorldMatrix(true, true);
|
||||
const out = []; bee.root.traverse((o) => {if (o.isMesh) out.push(...o.matrixWorld.elements);}); return out;
|
||||
};
|
||||
const a = await digest(14.4); await digest(19.3); const b = await digest(14.4);
|
||||
const deterministic = a.length === b.length && a.every((v, i) => v === b[i]);
|
||||
let finite = true;
|
||||
for (let t = 0; t <= 22; t += .25) {
|
||||
const s = T.stateAt(t); bee.pose(s);
|
||||
bee.root.traverse((o) => {for (const v of [...o.position.toArray(), ...o.quaternion.toArray(), ...o.scale.toArray()]) if (!Number.isFinite(v)) finite = false;});
|
||||
}
|
||||
const composition = heroAnchors.every((b) => b.margins);
|
||||
return {deterministic, finite, composition, heroAnchors, heroBounds, rows};
|
||||
});
|
||||
console.log(JSON.stringify({errors, ...results}, null, 2));
|
||||
await browser.close();
|
||||
if (errors.length || !results.deterministic || !results.finite || !results.composition) process.exit(1);
|
||||
Reference in New Issue
Block a user