← back to Quadrille Showroom

scripts/probe-boot-scene.mjs

46 lines

import pw from '/Users/macstudio3/.npm-global/lib/node_modules/playwright/index.js';
const { chromium } = pw;

const errors = [];
const browser = await chromium.launch({ channel: 'chrome', headless: true, args: ['--use-angle=metal', '--ignore-gpu-blocklist'] });
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
page.on('pageerror', e => errors.push('pageerror: ' + e.message));
page.on('console', m => { if (m.type() === 'error') errors.push('console.error: ' + m.text()); });

await page.goto('http://localhost:7690/', { waitUntil: 'domcontentloaded' });
await page.waitForFunction(() => window._qh && window._qh.wingBoards && window._qh.wingBoards.length >= 50, { timeout: 25000 });
await page.waitForTimeout(3500);

const report = await page.evaluate(() => {
  const qh = window._qh;
  const scene = qh.scene;
  // top-level scene children summary
  const topLevel = scene.children.map(c => ({
    name: c.name || '(unnamed)',
    type: c.type,
    isLight: !!c.isLight,
    childCount: c.children ? c.children.length : 0
  }));
  // count meshes by keyword to detect room-dressing props
  const kw = { sofa:0, lamp:0, wing:0, board:0, rug:0, plant:0, olive:0, tree:0, sculpture:0, bust:0, chair:0, table:0 };
  let meshTotal = 0;
  scene.traverse(o => {
    if (o.isMesh) meshTotal++;
    const n = (o.name || '').toLowerCase();
    for (const k of Object.keys(kw)) if (n.includes(k)) kw[k]++;
  });
  return {
    furniturePresent: qh.furniturePresent,
    furnitureChildCount: qh.furnitureChildCount,
    currentRoomType: qh.currentRoomType,
    roomTypeGroupPresent: !!(scene.getObjectByName && scene.children.some(c => (c.name||'').startsWith('roomType:'))),
    topLevelCount: topLevel.length,
    topLevel,
    meshTotal,
    keywordCounts: kw
  };
});

console.log(JSON.stringify({ errors, report }, null, 2));
await browser.close();