import type { Frame } from 'playwright'; import type { VisualQaAssert, VisualQaCategory } from './types'; export interface SceneStats { meshes: number; visibleMeshes: number; triangles: number; nanMeshes: string[]; zeroScaleMeshes: string[]; /** * Meshes under an engine-contract hidden template (a weapon's `Shell` ejected-casing node, authored at zero * scale on purpose). Reported for the record; never counted as visible and never a collapsed-transform defect. */ hiddenTemplateMeshes?: string[]; invisibleMaterialMeshes: string[]; materials: number; texturedMaterials: number; vertexColourMeshes: number; distinctColours: number; /** Up to 32 distinct base colours (hex, no #) of untextured materials, for the placeholder check. */ colourHexes?: string[]; /** World-space bounds of the drawn geometry. */ bounds: { min: [number, number, number]; max: [number, number, number]; size: [number, number, number]; } | null; } /** * Installs `globalThis.__vqaStats(root)` in a frame. Call with the item's own root Object3D: * await frame.evaluate(() => __vqaStats(myRoot)) */ export declare const INSTALL_SCENE_STATS = "globalThis.__vqaStats = function (root, opts) {\n opts = opts || {};\n const out = { meshes: 0, visibleMeshes: 0, triangles: 0, nanMeshes: [], zeroScaleMeshes: [], hiddenTemplateMeshes: [], invisibleMaterialMeshes: [],\n materials: 0, texturedMaterials: 0, vertexColourMeshes: 0, distinctColours: 0, colourHexes: [], bounds: null };\n if (!root) return out;\n root.updateMatrixWorld(true);\n const mn = [Infinity, Infinity, Infinity], mx = [-Infinity, -Infinity, -Infinity];\n const mats = new Set(); const colours = new Set();\n const isVisible = (o) => { for (let p = o; p; p = p.parent) { if (p.visible === false) return false; if (p === root) break; } return true; };\n const e = new Float64Array(16);\n // The engine's weapon-shell contract (ShellEjector.registerWeaponShell, GunFxSystem.#resolveShellNode): a node named\n // exactly \"Shell\" is the ejected-casing TEMPLATE, authored at ZERO scale so the casing never draws on the held or\n // displayed weapon. Meshes under it are deliberately collapsed, not a transform defect.\n const underShellTemplate = (o) => {\n for (let p = o.parent; p; p = p.parent) {\n if (/^shell$/i.test(p.name || '')) { const s = p.scale; if (s && (Math.abs(s.x) < 1e-6 || Math.abs(s.y) < 1e-6 || Math.abs(s.z) < 1e-6)) return true; }\n if (p === root) break;\n }\n return false;\n };\n // VEHICLE BATCHING (engine vehicleBatchedDraw.ts): the runtime packs a car's static parts \u2014 and fitted add-on parts \u2014\n // into `helix:vehicle-batch:*` BatchedMeshes. Each original mesh stays in the graph with its real transform as a\n // PROXY whose material clone is `visible = false`; the batch draws it at the proxy's pose. So a proxy whose instance\n // intends to be visible IS drawn and is measured from its own geometry and matrix, a proxy hidden on purpose (a\n // hide op) is not drawn, and the batch itself (every part packed in its local frame) is never measured.\n const proxies = new Map();\n const sceneRoot = (globalThis.__vqa && globalThis.__vqa.scene) || root;\n if (sceneRoot && sceneRoot.traverse) {\n sceneRoot.traverse((b) => { if (b.isBatchedMesh && Array.isArray(b.instances)) for (const inst of b.instances) if (inst && inst.mesh) proxies.set(inst.mesh, inst); });\n }\n root.traverse((o) => {\n if (!o.isMesh || !o.geometry || o.isBatchedMesh) return;\n out.meshes++;\n if (!isVisible(o)) return;\n if (opts.exclude && opts.exclude(o)) return;\n if (underShellTemplate(o)) { if (out.hiddenTemplateMeshes.length < 40) out.hiddenTemplateMeshes.push(o.name || o.uuid.slice(0, 8)); return; }\n const g = o.geometry; const pos = g.attributes && g.attributes.position; if (!pos) return;\n const proxy = proxies.get(o);\n if (proxy && proxy.visibleIntent === false) return;\n const ms = Array.isArray(o.material) ? o.material : [o.material];\n const allInvisible = !proxy && ms.every((m) => !m || m.visible === false || (m.transparent && (m.opacity ?? 1) < 0.02) || m.colorWrite === false);\n if (allInvisible) { if (out.invisibleMaterialMeshes.length < 40) out.invisibleMaterialMeshes.push(o.name || o.uuid.slice(0, 8)); return; }\n out.visibleMeshes++;\n const me = o.matrixWorld.elements; let nan = false; for (let i = 0; i < 16; i++) { e[i] = me[i]; if (!Number.isFinite(me[i])) nan = true; }\n const sx = Math.hypot(me[0], me[1], me[2]), sy = Math.hypot(me[4], me[5], me[6]), sz = Math.hypot(me[8], me[9], me[10]);\n if (sx < 1e-6 || sy < 1e-6 || sz < 1e-6) { if (out.zeroScaleMeshes.length < 40) out.zeroScaleMeshes.push(o.name || o.uuid.slice(0, 8)); return; }\n const idx = g.index ? g.index.array : null;\n const n = idx ? idx.length : pos.count;\n const start = (g.drawRange && g.drawRange.start) || 0;\n const count = Math.min(n - start, (g.drawRange && Number.isFinite(g.drawRange.count)) ? g.drawRange.count : n);\n out.triangles += Math.floor(count / 3);\n const step = Math.max(1, Math.floor(count / 20000));\n const skinned = o.isSkinnedMesh && typeof o.getVertexPosition === 'function';\n const tmp = skinned ? new (o.position.constructor)() : null;\n for (let k = start; k < start + count; k += step) {\n const vi = idx ? idx[k] : k;\n let x, y, z;\n if (skinned) { o.getVertexPosition(vi, tmp); x = tmp.x; y = tmp.y; z = tmp.z; }\n else { x = pos.getX(vi); y = pos.getY(vi); z = pos.getZ(vi); }\n if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z)) { nan = true; continue; }\n const wx = e[0] * x + e[4] * y + e[8] * z + e[12];\n const wy = e[1] * x + e[5] * y + e[9] * z + e[13];\n const wz = e[2] * x + e[6] * y + e[10] * z + e[14];\n if (wx < mn[0]) mn[0] = wx; if (wy < mn[1]) mn[1] = wy; if (wz < mn[2]) mn[2] = wz;\n if (wx > mx[0]) mx[0] = wx; if (wy > mx[1]) mx[1] = wy; if (wz > mx[2]) mx[2] = wz;\n }\n if (nan && out.nanMeshes.length < 40) out.nanMeshes.push(o.name || o.uuid.slice(0, 8));\n if (g.attributes.color) out.vertexColourMeshes++;\n for (const m of ms) {\n if (!m || mats.has(m)) continue; mats.add(m);\n if (m.map || m.emissiveMap || m.normalMap || m.colorNode || m.baseColorMap) out.texturedMaterials++;\n if (m.color && m.color.getHexString) colours.add(m.color.getHexString());\n }\n });\n out.materials = mats.size; out.distinctColours = colours.size; out.colourHexes = [...colours].slice(0, 32);\n if (mn[0] <= mx[0]) {\n const r = (v) => Math.round(v * 10000) / 10000;\n out.bounds = { min: mn.map(r), max: mx.map(r), size: mx.map((v, i) => r(v - mn[i])) };\n }\n return out;\n};"; export declare function installSceneStats(frame: Frame): Promise; /** Size envelope (largest dimension, metres) per category: [min, max]. Deliberately wide — catches 26 cm "outfits" * and 40 m cars, not taste. Wearables are measured ON the body, so the envelope is the garment's own extent. */ export declare const SCALE_ENVELOPE: Record; /** * Per-slot MINIMUM for a worn garment, as a fraction of the base body's height, applied to the garment's largest * on-body dimension. The test is "is this the right order of magnitude for the slot" (the 26 cm Male Police Uniform * shipped as an outfit), NOT "is this a full-length garment": a mini dress, crop top, bikini bottom or short skirt is * a short garment and a legitimate one. * * Calibrated 2026-10-02 from the 143 gated garments in these five slots in the whole-catalogue sweep (largest on-body dimension / base * body height, bodies 1.53-1.87 m). Smallest legitimate garment per slot -> the floor, with the lump as the reject: * outfit/full_body 0.351 (evening dress) floor 0.25 rejects the 26 cm Police Uniform lump (0.164 of Base Male) * top 0.163 (bandeau crop top) floor 0.10 * bottom 0.128 (tankini bottoms) floor 0.09 * footwear 0.156 (wedge pumps) floor 0.10 (unchanged: 0.18 m on a 1.75 m body) * headwear 0.128 (cap) floor 0.07 (unchanged: 0.12 m on a 1.75 m body) * The old flat minimums (outfit 1.1, top 0.45, bottom 0.6 m) failed 23 legitimate garments: every dress under 1 m, * crop tops and blouses, and every pair of shorts, skirts and tankini bottoms. Relative, because the bases span * 1.53 m (Kemonomimi) to 1.87 m (Sims 4) and a metre value is only right for one of them. */ export declare const WEARABLE_SLOT_MIN_FRACTION: Record; /** Body height assumed when the harness could not measure the base (or measured an implausible one). */ export declare const REFERENCE_BODY_HEIGHT_M = 1.75; export interface ImageStats { file: string; lumaStdev: number; meanLuma: number; } export declare function imageStats(file: string): Promise; export declare function commonAsserts(category: VisualQaCategory, stats: SceneStats, images: ImageStats[], opts?: { subject?: string; slot?: string | null; minTriangles?: number; bodyHeight?: number | null; }): VisualQaAssert[];