master
AdityaAngajala
v0.13.0
12542ed
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
// The host-facing extension surface: lifecycle events through on() (load,
// error, camera, layer, contextlost, contextrestored), isolate() and
// focus(), the background option, picks that skip disabled meshes, and the
// loadBabylon() contract (the viewer's own Babylon module, babylonVersion).
import http from "node:http";
import { existsSync, readFileSync, readdirSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = resolve(__dirname, "..");
const DIST = join(ROOT, process.env.VIEWER_DIST || "dist-standalone");
const PKG = JSON.parse(readFileSync(join(ROOT, "package.json"), "utf8"));
let passed = 0, failed = 0; const failures = [];
function assert(cond, msg) { if (cond) { passed++; console.log(" ok " + msg); } else { failed++; failures.push(msg); console.log(" FAIL " + msg); } }
function section(t) { console.log("\n [" + t + "]"); }
const near = (a, b, eps = 1e-4) => Math.abs(a - b) < eps;
/**
* A GLB of 1 cm grey boxes along X, sharing one material: U1 (holding mesh
* U1_body) at 0, pad_7 at +2.5 cm, pad_17 at -2.5 cm, and two board layers
* by the built-in vocabulary, fr4_board at +5 cm and silk_top at -5 cm.
*/
function makeGlb() {
const pos = [], idx = [];
const faces = [[[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]],[[1,-1,-1],[-1,-1,-1],[-1,1,-1],[1,1,-1]],[[-1,1,1],[1,1,1],[1,1,-1],[-1,1,-1]],[[-1,-1,-1],[1,-1,-1],[1,-1,1],[-1,-1,1]],[[1,-1,1],[1,-1,-1],[1,1,-1],[1,1,1]],[[-1,-1,-1],[-1,-1,1],[-1,1,1],[-1,1,-1]]];
faces.forEach((f, fi) => { f.forEach(v => { pos.push(v[0] * 0.005, v[1] * 0.005, v[2] * 0.005); }); const b = fi * 4; idx.push(b, b + 1, b + 2, b, b + 2, b + 3); });
const pad = (b) => Buffer.concat([b, Buffer.alloc((4 - (b.length % 4)) % 4)]);
const posBuf = pad(Buffer.from(new Float32Array(pos).buffer));
const idxBuf = pad(Buffer.from(new Uint16Array(idx).buffer));
const bin = Buffer.concat([posBuf, idxBuf]);
const prim = { attributes: { POSITION: 0 }, indices: 1, material: 0 };
const json = {
asset: { version: "2.0" }, scene: 0,
scenes: [{ nodes: [0, 2, 3, 4, 5] }],
nodes: [
{ name: "U1", children: [1] },
{ name: "U1_body", mesh: 0 },
{ name: "pad_7", mesh: 1, translation: [0.025, 0, 0] },
{ name: "pad_17", mesh: 2, translation: [-0.025, 0, 0] },
{ name: "fr4_board", mesh: 3, translation: [0.05, 0, 0] },
{ name: "silk_top", mesh: 4, translation: [-0.05, 0, 0] },
],
meshes: [0, 1, 2, 3, 4].map(i => ({ name: "m" + i, primitives: [prim] })),
materials: [{ name: "grey", pbrMetallicRoughness: { baseColorFactor: [0.5, 0.5, 0.5, 1], metallicFactor: 0, roughnessFactor: 1 }, emissiveFactor: [0.5, 0.5, 0.5] }],
buffers: [{ byteLength: bin.length }],
bufferViews: [{ buffer: 0, byteOffset: 0, byteLength: posBuf.length }, { buffer: 0, byteOffset: posBuf.length, byteLength: idxBuf.length }],
accessors: [
{ bufferView: 0, componentType: 5126, count: pos.length / 3, type: "VEC3", min: [-0.005, -0.005, -0.005], max: [0.005, 0.005, 0.005] },
{ bufferView: 1, componentType: 5123, count: idx.length, type: "SCALAR" },
],
};
let jsonBuf = Buffer.from(JSON.stringify(json));
jsonBuf = Buffer.concat([jsonBuf, Buffer.alloc((4 - (jsonBuf.length % 4)) % 4, 0x20)]);
const header = Buffer.alloc(12); header.write("glTF", 0); header.writeUInt32LE(2, 4); header.writeUInt32LE(12 + 8 + jsonBuf.length + 8 + bin.length, 8);
const ch = (len, type) => { const b = Buffer.alloc(8); b.writeUInt32LE(len, 0); b.write(type, 4); return b; };
return Buffer.concat([header, ch(jsonBuf.length, "JSON"), jsonBuf, ch(bin.length, "BIN\0"), bin]);
}
const PARTS = makeGlb();
const HARNESS = `<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;height:100%;background:#000}#wrap{position:absolute;left:0;top:0;width:640px;height:400px}</style></head><body><div id="wrap"></div>
<script type="module">
await import('/adom-3d-viewer-babylon9.esm.js');
// A fresh viewer in #wrap with these options and the parts model; the previous one is destroyed.
window.__make = async (opts, model = true) => {
if (window.__v) window.__v.destroy();
window.__v = window.Adom3DViewerBabylon9.init(document.getElementById('wrap'), { zUp: true, showViewCube: true, showHelp: false, ...opts });
await window.__v.whenReady();
if (model) { await window.__v.loadModel('/parts.glb'); window.__v.frameModel(); }
};
window.__mesh = (name) => window.__v.getScene().getMeshByName(name);
// A page point over the middle of the named mesh, found by picking a grid
// in CSS pixels (scene.pick's unit at any pixel density).
window.__at = (name) => {
const s = window.__v.getScene(), c = window.__v.getEngine().getRenderingCanvas();
const hits = [];
for (let y = 4; y < c.clientHeight; y += 4) for (let x = 4; x < c.clientWidth; x += 4) {
const p = s.pick(x, y, m => m.isPickable && m.isVisible);
if (p.hit && p.pickedMesh && p.pickedMesh.name === name) hits.push([x, y]);
}
if (!hits.length) return null;
const cx = hits.reduce((a, h) => a + h[0], 0) / hits.length, cy = hits.reduce((a, h) => a + h[1], 0) / hits.length;
hits.sort((a, b) => Math.hypot(a[0] - cx, a[1] - cy) - Math.hypot(b[0] - cx, b[1] - cy));
const r = c.getBoundingClientRect();
return { x: r.left + hits[0][0], y: r.top + hits[0][1] };
};
// RGBA of one canvas pixel, or of one pixel of a PNG data URL.
window.__pixel = (x, y) => {
const src = window.__v.getEngine().getRenderingCanvas();
const c = document.createElement('canvas'); c.width = src.width; c.height = src.height;
const g = c.getContext('2d'); g.drawImage(src, 0, 0);
return [...g.getImageData(x, y, 1, 1).data];
};
window.__pngPixel = (url, x, y) => new Promise((res) => {
const img = new Image();
img.onload = () => { const c = document.createElement('canvas'); c.width = img.width; c.height = img.height; const g = c.getContext('2d'); g.drawImage(img, 0, 0); res([...g.getImageData(x, y, 1, 1).data]); };
img.src = url;
});
window.__ready = true;
</script></body></html>`;
if (!existsSync(join(DIST, "adom-3d-viewer-babylon9.esm.js"))) { console.error("dist-standalone missing; run npm run build:standalone first"); process.exit(2); }
const server = http.createServer((req, res) => {
const url = new URL(req.url, "http://x");
if (url.pathname === "/parts.glb") { res.writeHead(200, { "Content-Type": "model/gltf-binary" }); return res.end(PARTS); }
// Answers after 1 s: slower than the 300 ms timeout the test sets.
if (url.pathname === "/late.glb") { setTimeout(() => { res.writeHead(200, { "Content-Type": "model/gltf-binary" }); res.end(PARTS); }, 1000); return; }
if (url.pathname === "/view.html") { res.writeHead(200, { "Content-Type": "text/html" }); return res.end(HARNESS); }
if (url.pathname === "/favicon.ico") { res.writeHead(204); return res.end(); }
const file = join(DIST, url.pathname.replace(/^\/+/, ""));
if (file.startsWith(DIST) && existsSync(file)) { res.writeHead(200, { "Content-Type": file.endsWith(".js") ? "text/javascript" : "application/octet-stream" }); return res.end(readFileSync(file)); }
res.writeHead(404); res.end();
});
await new Promise(r => server.listen(0, "127.0.0.1", r));
const port = server.address().port;
let puppeteer; try { puppeteer = (await import("puppeteer-core")).default; } catch { puppeteer = (await import(resolve(ROOT, "..", "node_modules", "puppeteer-core", "lib", "puppeteer", "puppeteer-core.js"))).default; }
function findChrome() {
const env = process.env.PUPPETEER_EXECUTABLE_PATH; if (env && existsSync(env)) return env;
const base = join(process.env.HOME || "", ".cache", "puppeteer", "chrome");
if (existsSync(base)) for (const d of readdirSync(base)) { const p = join(base, d, "chrome-linux64", "chrome"); if (existsSync(p)) return p; }
throw new Error("no Chrome found; set PUPPETEER_EXECUTABLE_PATH");
}
const browser = await puppeteer.launch({ executablePath: findChrome(), headless: true, args: ["--no-sandbox", "--use-gl=angle", "--use-angle=swiftshader", "--enable-unsafe-swiftshader", "--disable-gpu-sandbox"] });
try {
const page = await browser.newPage();
const pageErrors = [];
page.on("pageerror", (e) => pageErrors.push(String(e && e.message || e)));
await page.setViewport({ width: 640, height: 400 });
await page.goto(`http://127.0.0.1:${port}/view.html`, { waitUntil: "load", timeout: 90000 });
await page.waitForFunction("window.__ready === true", { timeout: 90000 });
const run = (fn, ...args) => page.evaluate(fn, ...args);
const waitFor = (cond, timeout = 30000) => page.waitForFunction(cond, { timeout, polling: 100 }).then(() => true, () => false);
const pause = (ms) => new Promise(r => setTimeout(r, ms));
section("load and error events");
const loads = await run(async () => {
await window.__make({}, false);
const v = window.__v, seen = [];
const off = v.on("load", (e) => seen.push({ url: e.url, root: e.root && e.root.name, meshes: e.meshes }));
const errs = [];
v.on("error", (e) => errs.push(e));
await v.loadModel("/parts.glb");
const bytes = new Uint8Array(await (await fetch("/parts.glb")).arrayBuffer());
await v.loadModelBytes(bytes);
await v.replaceModel("/parts.glb");
let rejected = false;
try { await v.loadModel("/missing.glb"); } catch { rejected = true; }
off();
await v.loadModel("/parts.glb");
return { seen, errs, rejected };
});
assert(loads.seen.length === 3, `a load event per load, replace and bytes load, none after removal (${loads.seen.length})`);
assert(loads.seen[0] && loads.seen[0].url === "/parts.glb" && loads.seen[0].root === "__root__" && loads.seen[0].meshes >= 6, `the event names the URL and the root (${JSON.stringify(loads.seen[0])})`);
assert(loads.seen[1] && loads.seen[1].url === null, "a bytes load reports url null");
assert(loads.rejected && loads.errs.length === 1 && loads.errs[0].url === "/missing.glb" && loads.errs[0].code === "MODEL_LOAD_FAILED" && typeof loads.errs[0].message === "string",
`a failed load rejects and fires error (${JSON.stringify(loads.errs[0])})`);
const late = await run(async () => {
await window.__make({ loadTimeoutMs: 300 }, false);
const errs = [];
window.__v.on("error", (e) => errs.push(e.code));
try { await window.__v.loadModel("/late.glb"); } catch { /* expected */ }
return errs;
});
assert(JSON.stringify(late) === '["MODEL_LOAD_TIMEOUT"]', `a timed-out load fires error with MODEL_LOAD_TIMEOUT (${late})`);
section("camera and layer events");
const cam = await run(async () => {
await window.__make({});
const v = window.__v, s = v.getScene();
const states = [];
let frames = 0;
const ob = s.onAfterRenderObservable.add(() => frames++);
v.on("camera", (st) => states.push(st));
const end = await v.moveCamera("front", { ms: 400 });
await new Promise(r => setTimeout(r, 300));
s.onAfterRenderObservable.remove(ob);
const n = states.length;
await new Promise(r => setTimeout(r, 400));
return { n, quiet: states.length === n, frames, last: states[states.length - 1], end };
});
assert(cam.n >= 2 && cam.n <= cam.frames + 1, `a camera move fires camera events, no more than one per frame (${cam.n} events, ${cam.frames} frames)`);
assert(cam.last && near(cam.last.alpha, cam.end.alpha) && near(cam.last.beta, cam.end.beta) && near(cam.last.radius, cam.end.radius), "the last camera event is where the move ended");
assert(cam.quiet, "a still camera fires nothing");
const lay = await run(() => {
const v = window.__v, names = v.getLayers().map(l => l.name);
const seen = [];
v.on("layer", (e) => seen.push(e));
v.setLayerVisible(names[0], false);
v.setLayerVisible(names[0], false);
v.setLayerVisible(names[0], true);
return { names, seen };
});
assert(lay.names.length >= 2, `the model has layers (${lay.names})`);
assert(lay.seen.length === 2 && lay.seen[0].name === lay.names[0] && lay.seen[0].visible === false && lay.seen[1].visible === true, `layer fires on each change and not when nothing changes (${JSON.stringify(lay.seen)})`);
const bad = await run(() => { try { window.__v.on("click", () => {}); return null; } catch (e) { return e.message; } });
assert(!!bad && /pick/.test(bad) && /camera/.test(bad), `an unknown event throws and lists the known ones (${bad})`);
section("contextlost and contextrestored events");
const ctxEvents = await run(async () => {
const v = window.__v, seen = [];
v.on("contextlost", () => seen.push("lost"));
v.on("contextrestored", () => seen.push("restored"));
const c = v.getEngine().getRenderingCanvas();
const ext = (c.getContext("webgl2") || c.getContext("webgl")).getExtension("WEBGL_lose_context");
if (!ext) return null;
ext.loseContext();
for (let i = 0; i < 100 && !seen.includes("lost"); i++) await new Promise(r => setTimeout(r, 100));
ext.restoreContext();
for (let i = 0; i < 300 && !seen.includes("restored"); i++) await new Promise(r => setTimeout(r, 100));
return seen;
});
assert(JSON.stringify(ctxEvents) === '["lost","restored"]', `on() hears the context go and come back (${ctxEvents})`);
section("isolate");
await run(() => window.__make({}));
// The whole model's framing, for comparison once part of it is isolated.
await run(() => {
const v = window.__v, c = v.getCamera();
v.frameModel();
const s = v.getScene().getLightByName("spotLight").position;
window.__whole = { r: c.radius, upper: c.upperRadiusLimit, spot: [s.x, s.y, s.z] };
});
const BODY = await run(() => window.__at("U1_body"));
const P17 = await run(() => window.__at("pad_17"));
assert(!!BODY && !!P17, "U1_body and pad_17 are on screen");
const iso = await run(() => {
const v = window.__v, m = window.__mesh;
const casters = () => v.getShadowGenerator().getShadowMap().renderList;
const wasCaster = casters().includes(m("U1_body"));
window.__iso = v.isolate("pad_7");
return {
kept: window.__iso.meshes.map(x => x.name),
body: [m("U1_body").visibility, m("U1_body").isPickable, casters().includes(m("U1_body"))],
pad7: [m("pad_7").visibility, m("pad_7").isPickable],
wasCaster,
};
});
assert(JSON.stringify(iso.kept) === '["pad_7"]', `isolate returns the meshes kept (${iso.kept})`);
assert(JSON.stringify(iso.body) === "[0,false,false]" && iso.wasCaster, `the rest is hidden, takes no picks and casts no shadow (${iso.body})`);
assert(JSON.stringify(iso.pad7) === "[1,true]", "the target is untouched");
await run(() => { window.__picks = []; window.__v.on("pick", (e) => window.__picks.push(e.mesh ? e.mesh.name : null)); });
await page.mouse.click(BODY.x, BODY.y);
await waitFor("window.__picks.length >= 1", 5000);
assert(await run(() => window.__picks[0]) !== "U1_body", `a click where a hidden mesh sits does not pick it (${await run(() => window.__picks[0])})`);
const framed = await run(() => {
const v = window.__v, m = window.__mesh, c = v.getCamera();
const caster = () => v.getShadowGenerator().getShadowMap().renderList.includes(m("U1_body"));
const spot = () => { const p = v.getScene().getLightByName("spotLight").position; return [p.x, p.y, p.z]; };
const box = m("pad_7").getBoundingInfo().boundingBox;
const onPad = () => ["x", "y", "z"].every(k => c.target[k] >= box.minimumWorld[k] - 1e-6 && c.target[k] <= box.maximumWorld[k] + 1e-6);
v.goHome();
const home = { caster: caster(), onPad: onPad(), r: c.radius, upper: c.upperRadiusLimit, spot: spot() };
v.frameModel();
const fit = { caster: caster(), onPad: onPad(), r: c.radius, spot: spot() };
return { home, fit, whole: window.__whole };
});
const sameSpot = (a, b) => a.every((x, i) => Math.abs(x - b[i]) < 1e-6 * Math.max(1, Math.abs(b[i])));
assert(!framed.home.caster && !framed.fit.caster, "Home and Fit leave the hidden meshes out of the shadow casters");
assert(framed.home.onPad && framed.fit.onPad && framed.fit.r < framed.whole.r * 0.5,
`Home and Fit frame the isolated mesh, not the whole model (radius ${framed.fit.r.toFixed(4)} vs ${framed.whole.r.toFixed(4)})`);
assert(sameSpot(framed.home.spot, framed.whole.spot) && sameSpot(framed.fit.spot, framed.whole.spot) && framed.home.upper >= framed.whole.upper * (1 - 1e-6),
"the light and the zoom-out limit keep the whole model's bounds");
const back = await run(() => {
const v = window.__v, m = window.__mesh;
window.__iso.clear();
v.frameModel();
return [m("U1_body").visibility, m("U1_body").isPickable, v.getShadowGenerator().getShadowMap().renderList.includes(m("U1_body")), v.getCamera().radius];
});
assert(JSON.stringify(back.slice(0, 3)) === "[1,true,true]", `clear() gives every mesh its visibility, picks and shadow back (${back.slice(0, 3)})`);
assert(Math.abs(back[3] - framed.whole.r) < framed.whole.r * 1e-3, `after clear(), Fit frames the whole model again (radius ${back[3].toFixed(4)})`);
const ghost = await run(() => {
const v = window.__v, m = window.__mesh;
const h = v.isolate("U1", { mode: "ghost", alpha: 0.3 });
const r = { kept: h.meshes.map(x => x.name), pad7: [+m("pad_7").visibility.toFixed(3), m("pad_7").isPickable], body: m("U1_body").visibility };
h.clear();
return r;
});
assert(JSON.stringify(ghost.kept) === '["U1_body"]' && JSON.stringify(ghost.pad7) === "[0.3,false]" && ghost.body === 1, `ghost draws the rest at alpha and takes no picks (${JSON.stringify(ghost)})`);
const swap = await run(() => {
const v = window.__v, m = window.__mesh;
const a = v.isolate("pad_7");
const b = v.isolate("pad_17");
const during = [m("pad_7").visibility, m("pad_17").visibility, m("U1_body").visibility];
a.clear();
const afterStale = m("pad_7").visibility;
v.clearIsolate();
const none = v.isolate("nope");
return { during, afterStale, after: [m("pad_7").visibility, m("pad_17").visibility, m("U1_body").visibility], none: none.meshes.length, untouched: m("pad_7").visibility };
});
assert(JSON.stringify(swap.during) === "[0,1,0]", `a new isolate replaces the last (${swap.during})`);
assert(swap.afterStale === 0, "clear() on a replaced isolation does nothing");
assert(JSON.stringify(swap.after) === "[1,1,1]", "clearIsolate() ends it");
assert(swap.none === 0 && swap.untouched === 1, "a target that matches nothing changes nothing");
const layered = await run(() => {
const v = window.__v, name = v.getLayers()[0].name, mesh = window.__mesh(name);
v.setLayerVisible(name, false);
v.isolate("pad_7");
v.clearIsolate();
const r = { name, mesh: !!mesh, hiddenStill: !!mesh && mesh.isVisible === false && v.getLayers().find(l => l.name === name).visible === false };
v.setLayerVisible(name, true);
return r;
});
assert(layered.mesh && layered.hiddenStill, `a layer hidden before isolate stays hidden after (${layered.name})`);
const badIso = await run(() => [["hide", "blur"], ["alpha", 2]].map(([k, val]) => {
try { window.__v.isolate("pad_7", k === "hide" ? { mode: val } : { alpha: val }); return null; } catch (e) { return e.message; }
}));
assert(badIso.every(Boolean), `an unknown mode and alpha 2 throw (${badIso.join(" | ")})`);
await run(() => window.__v.clearIsolate());
section("focus");
const foc = await run(async () => {
const v = window.__v;
await v.moveCamera("home");
const before = v.getCameraState();
const st = await v.focus("pad_7", { ms: 200 });
const c = window.__mesh("pad_7").getBoundingInfo().boundingBox.centerWorld;
const none = await v.focus("nope");
return { before, st, center: [c.x, c.y, c.z], none };
});
assert(foc.st && foc.st.target.every((t, i) => near(t, foc.center[i], 1e-6)), `focus centers the target (${foc.st && foc.st.target.map(t => t.toFixed(4))})`);
assert(foc.st && near(foc.st.alpha, foc.before.alpha) && near(foc.st.beta, foc.before.beta) && foc.st.radius < foc.before.radius, "and keeps the angles, coming closer");
assert(foc.none === null, "focus on nothing resolves null");
section("picks skip disabled meshes");
await run(() => { window.__v.frameModel(); window.__picks = []; window.__mesh("pad_17").setEnabled(false); });
await page.mouse.click(P17.x, P17.y);
await waitFor("window.__picks.length >= 1", 5000);
assert(await run(() => window.__picks[0]) !== "pad_17", "a disabled mesh is not picked");
await run(() => window.__mesh("pad_17").setEnabled(true));
section("background");
const bg = await run(async () => {
const out = {};
for (const b of ["studio", "transparent", "#ff0000"]) {
await window.__make({ background: b, showViewCube: false }, false);
await new Promise(r => setTimeout(r, 300));
out[b] = { px: window.__pixel(320, 6), shot: await window.__pngPixel(await window.__v.captureScreenshot({ width: 64, height: 40 }), 32, 1) };
}
try { await window.__make({ background: "blue" }, false); out.bad = null; } catch (e) { out.bad = e.message; }
return out;
});
assert(bg.studio.px[3] === 255 && bg.studio.px[2] > bg.studio.px[0], `studio is the opaque blue-grey gradient (${bg.studio.px})`);
assert(bg.transparent.px[3] === 0, `transparent leaves the canvas clear (${bg.transparent.px})`);
assert(bg.transparent.shot[3] === 0, `and screenshots keep the alpha (${bg.transparent.shot})`);
assert(bg["#ff0000"].px[0] > 200 && bg["#ff0000"].px[1] < 60 && bg["#ff0000"].px[3] === 255, `a color fills the background (${bg["#ff0000"].px})`);
assert(!!bg.bad, `an unknown background throws (${bg.bad})`);
section("loadBabylon contract");
const lb = await run(async () => {
await window.__make({}, false);
const V = window.Adom3DViewerBabylon9, full = await V.loadBabylon();
return {
scene: window.__v.getScene() instanceof full.Scene,
mesh: full.Mesh === V.BABYLON.Mesh,
same: (await window.__v.loadBabylon()) === full,
version: V.babylonVersion,
engine: full.Engine.Version,
};
});
assert(lb.scene && lb.mesh && lb.same, "loadBabylon() resolves with the module the viewer runs on");
assert(lb.version === lb.engine && lb.version === PKG.devDependencies["@babylonjs/core"], `babylonVersion is the bundled Babylon release (${lb.version}; package.json ${PKG.devDependencies["@babylonjs/core"]})`);
assert(pageErrors.length === 0, `no page errors (${pageErrors.join(" | ") || "none"})`);
} finally {
await browser.close();
server.close();
}
console.log(`\n${passed} passed, ${failed} failed`);
if (failed) { for (const f of failures) console.log(" FAIL " + f); process.exit(1); }