Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

feat(engine-qa): wire the <engine-qa> panel into viewer and Rig Doctor

nirholasea0de3502286
diff --git a/pages/rig-doctor.html b/pages/rig-doctor.html
index 754b1f2d5..d2ae04204 100644
--- a/pages/rig-doctor.html
+++ b/pages/rig-doctor.html
@@ -46,7 +46,7 @@
<link rel="stylesheet" href="/rig-doctor.css" />
<script defer src="/footer-newsletter.js"></script>
- <script type="application/ld+json">{"@context":"https://schema.org","@graph":[{"@type":"WebApplication","name":"Rig Doctor","description":"Diagnose and repair a GLB avatar skeleton in the browser. Names the rig convention, scores limb coverage against the three.ws canonical skeleton, rewrites non-standard bone names, and previews the result.","url":"https://three.ws/rig-doctor","applicationCategory":"DeveloperApplication","operatingSystem":"Any","browserRequirements":"Requires WebGL2","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"Is my model uploaded anywhere?","acceptedAnswer":{"@type":"Answer","text":"No. Rig Doctor reads the file with the browser FileReader API and analyses it on your machine. No bytes are sent to any server, which is why it works with the network disconnected."}},{"@type":"Question","name":"Why does my avatar load but never move?","acceptedAnswer":{"@type":"Answer","text":"Animation clips address bones by name. If your rig names its joints something the canonical skeleton does not recognise, the clip plays against nothing and the character stands in its bind pose. Rig Doctor tells you exactly which joints failed to map and can rename them for you."}},{"@type":"Question","name":"What does the repaired file change?","acceptedAnswer":{"@type":"Answer","text":"Only the names of nodes referenced from skins[].joints[], plus an armature orientation fold when one is present. Geometry, materials, textures, and the binary chunk are copied through byte for byte."}}]}]}</script>
+ <script type="application/ld+json">{"@context":"https://schema.org","@graph":[{"@type":"WebApplication","name":"Rig Doctor","description":"Diagnose and repair a GLB avatar skeleton in the browser. Names the rig convention, scores limb coverage against the three.ws canonical skeleton, rewrites non-standard bone names, and previews the result.","url":"https://three.ws/rig-doctor","applicationCategory":"DeveloperApplication","operatingSystem":"Any","browserRequirements":"Requires WebGL2","offers":{"@type":"Offer","price":"0","priceCurrency":"USD"},"isPartOf":{"@type":"WebSite","name":"three.ws","url":"https://three.ws"}},{"@type":"FAQPage","mainEntity":[{"@type":"Question","name":"Is my model uploaded anywhere?","acceptedAnswer":{"@type":"Answer","text":"No, not by default. Rig Doctor reads the file with the browser FileReader API and analyses it on your machine, which is why the rig diagnosis works with the network disconnected. The one exception is opt-in: the Engine QA panel's LOD-budget and collider checks need server-side work, so they stay as 'not measured' until you click 'Check LOD & collider fitness', which uploads the file for that single check only."}},{"@type":"Question","name":"Why does my avatar load but never move?","acceptedAnswer":{"@type":"Answer","text":"Animation clips address bones by name. If your rig names its joints something the canonical skeleton does not recognise, the clip plays against nothing and the character stands in its bind pose. Rig Doctor tells you exactly which joints failed to map and can rename them for you."}},{"@type":"Question","name":"What does the repaired file change?","acceptedAnswer":{"@type":"Answer","text":"Only the names of nodes referenced from skins[].joints[], plus an armature orientation fold when one is present. Geometry, materials, textures, and the binary chunk are copied through byte for byte."}}]}]}</script>
</head>
<body>
<header><div id="nav-container"></div></header>
@@ -186,6 +186,15 @@
<dl class="rd-stats" id="rd-stats"></dl>
</div>
+ <div class="rd-panel">
+ <div class="rd-panel-head">
+ <h3 class="rd-panel-title" data-i18n="rig-doctor.panel_engineqa_title">Engine QA</h3>
+ <span class="rd-panel-note" data-i18n="rig-doctor.engineqa_note">Measured in your browser</span>
+ </div>
+ <engine-qa id="rd-engine-qa" align="start"></engine-qa>
+ <p class="rd-panel-foot" data-i18n="rig-doctor.engineqa_foot">Draw calls, materials, and texel density are measured right here, from the bytes already in your browser. The LOD budget and collider checks need a real LOD build and the server's manifold analyzer, so they stay behind one explicit click that uploads this file for that single check.</p>
+ </div>
+
<div class="rd-panel" id="rd-renames-panel" hidden>
<div class="rd-panel-head">
<h3 class="rd-panel-title" data-i18n="rig-doctor.panel_renames_title">Bone rewrites</h3>
@@ -321,6 +330,8 @@
</footer>
<script src="/nav.js" defer></script>
+ <!-- The <engine-qa> element, shared verbatim with /viewer. -->
+ <script type="module" src="/engine-qa-panel.js"></script>
<script type="module" src="/src/rig-doctor-page.js"></script>
<script src="/brand.js" defer></script>
<div id="footer-container"></div>
diff --git a/public/engine-qa-panel.js b/public/engine-qa-panel.js
index 0d5f7e10a..cc3f9bea4 100644
--- a/public/engine-qa-panel.js
+++ b/public/engine-qa-panel.js
@@ -390,13 +390,23 @@ class EngineQaCard extends HTMLElement {
core.push(['Texel density', `${c.texelDensity.value} px/m`, this._verdictCls(c.texelDensity.verdict)]);
}
- const needsUpgrade = r.partial === true && c.triangleBudget.verdict === 'skip' && c.collider.verdict === 'skip';
+ // The two checks that skip for structurally different reasons: Rig Doctor
+ // skips both at once (the file never left the tab, so neither a LOD build
+ // nor the manifold analyzer ran). A URL-graded model (viewer.html) already
+ // has a real collider verdict; only the LOD chain is opt-in there, because
+ // building one is real decimation work worth its own click. Either way, a
+ // single `onUpgrade` callback re-grades whatever is still missing, so one
+ // button covers one or both, labeled by whichever the host supplies.
+ const canUpgrade = typeof this._meta.onUpgrade === 'function';
+ const lodSkip = c.triangleBudget.verdict === 'skip';
+ const colliderSkip = c.collider.verdict === 'skip';
+
let lodHtml = '';
if (Array.isArray(c.triangleBudget.value)) {
lodHtml = `<h3>LOD triangle budget</h3>${c.triangleBudget.value
.map((l) => `<div class="lod-row"><span>${l.name}</span><span class="${this._verdictCls(l.verdict)}">${l.triangleCount.toLocaleString()} / ${l.budget.toLocaleString()}</span></div>`)
.join('')}${c.triangleBudget.monotonicDecrease === false ? '<p class="note">Levels are not strictly decreasing.</p>' : ''}`;
- } else if (c.triangleBudget.verdict === 'skip' && !needsUpgrade) {
+ } else if (lodSkip && !canUpgrade) {
lodHtml = `<h3>LOD triangle budget</h3><p class="note">${c.triangleBudget.reason || 'No LOD chain supplied.'}</p>`;
}
@@ -408,12 +418,14 @@ class EngineQaCard extends HTMLElement {
['Shells', String(cv.shells), ''],
['Triangles', `${cv.triangleCount.toLocaleString()} / ${cv.budget.toLocaleString()}`, this._verdictCls(c.collider.verdict)],
])}${c.collider.reason ? `<p class="note">${c.collider.reason}</p>` : ''}`;
- } else if (c.collider.verdict === 'skip' && !needsUpgrade) {
+ } else if (colliderSkip && !canUpgrade) {
colliderHtml = `<h3>Collider fitness</h3><p class="note">${c.collider.reason || 'Not measured.'}</p>`;
}
- const upgradeHtml = needsUpgrade && typeof this._meta.onUpgrade === 'function'
- ? `<h3>LOD budget &amp; collider fitness</h3><p class="note">Not measured yet: this needs a real LOD build and the server's manifold analyzer.</p><button type="button" class="action" data-upgrade>Check LOD &amp; collider fitness (uploads this file)</button>`
+ const upgradeHtml = (lodSkip || colliderSkip) && canUpgrade
+ ? `<h3>${lodSkip && colliderSkip ? 'LOD budget &amp; collider fitness' : lodSkip ? 'LOD triangle budget' : 'Collider fitness'}</h3>
+ <p class="note">${lodSkip && colliderSkip ? 'Not measured yet: this needs a real LOD build and the server’s manifold analyzer.' : lodSkip ? 'No LOD chain graded yet: this needs a real LOD build.' : 'Not measured yet: this needs the server’s manifold analyzer.'}</p>
+ <button type="button" class="action" data-upgrade>${this._meta.upgradeLabel || 'Check LOD & collider fitness'}</button>`
: '';
const stlHtml = r.checks.collider?.value?.watertight
diff --git a/public/locales/en.json b/public/locales/en.json
index d46c27e9d..8fa829d31 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -20916,6 +20916,8 @@
"drop_hint": "or click to choose a file. Nothing is uploaded.",
"drop_tip": "Or press D from anywhere on the page",
"drop_title": "Drop a .glb here",
+ "engineqa_foot": "Draw calls, materials, and texel density are measured right here, from the bytes already in your browser. The LOD budget and collider checks need a real LOD build and the server's manifold analyzer, so they stay behind one explicit click that uploads this file for that single check.",
+ "engineqa_note": "Measured in your browser",
"explain1_desc": "Every clip in the three.ws library is authored against one canonical skeleton: <code>Hips</code>, <code>LeftForeArm</code>, <code>RightUpLeg</code>, 52 joints in total. A track that names <code>LeftForeArm</code> drives nothing on a rig that calls that joint <code>lowerarm_l</code>.",
"explain1_title": "Clips address bones by name",
"explain2_desc": "Nothing errors. The GLB loads, the material renders, the mixer runs, and the character stands in its bind pose. Nobody tells you why, which is why this page exists and why it runs before you upload rather than after.",
@@ -20943,6 +20945,7 @@
"og_title": "Rig Doctor · Will your GLB animate?",
"page_title": "Rig Doctor · Will your GLB animate? · three.ws",
"panel_coverage_title": "Coverage",
+ "panel_engineqa_title": "Engine QA",
"panel_inventory_title": "Inventory",
"panel_preview_title": "Live preview",
"panel_renames_title": "Bone rewrites",
diff --git a/public/viewer.html b/public/viewer.html
index da5e730c9..85b94d68d 100644
--- a/public/viewer.html
+++ b/public/viewer.html
@@ -183,6 +183,10 @@
<!-- The physics grade, beside the authenticity badge: one says the asset is
genuine, the other says a solver can actually use it. -->
<sim-readiness id="sim-badge" align="end" hidden></sim-readiness>
+ <!-- The real-time-engine fitness grade: draw calls, materials, texel
+ density, LOD budget, collider. A different question than physics
+ readiness, so its own badge rather than folding into sim-readiness. -->
+ <engine-qa id="engine-qa-badge" align="end" hidden></engine-qa>
</header>
<div class="stage">
@@ -670,6 +674,38 @@
.then(function (ready) { if (ready) offer(); });
})();
+ // Engine QA. Same "offer, not automatic" reasoning as simulation readiness
+ // above: the base grade is cheap, but the LOD-chain upgrade is real
+ // decimation work, so it stays behind its own explicit click too.
+ (function checkEngineQa() {
+ var el = document.getElementById('engine-qa-badge');
+ if (!el || !src) return;
+ function run(withLods) {
+ var qs = '?url=' + encodeURIComponent(src) + (withLods ? '&lods=1' : '');
+ fetch('/api/3d/engine-qa' + qs, { headers: { accept: 'application/json' } })
+ .then(function (r) {
+ return r.json().then(function (body) { return { ok: r.ok, status: r.status, body: body }; });
+ })
+ .then(function (res) {
+ if (!res.ok) throw new Error((res.body && res.body.error) || ('HTTP ' + res.status));
+ el.showReport(res.body.report, {
+ gradedAt: res.body.ts,
+ sourceUrl: res.body.url,
+ stlUrl: '/api/3d/engine-qa?format=stl&url=' + encodeURIComponent(src),
+ upgradeLabel: 'Build & grade LOD chain',
+ onUpgrade: function () { run(true); },
+ });
+ })
+ .catch(function (err) {
+ el.failed(err && err.message ? err.message : 'The engine QA grade could not be fetched.', { onRetry: function () { run(withLods); } });
+ });
+ }
+ function offer() { el.ungraded({ onGrade: function () { run(false); } }); }
+ var deadline = new Promise(function (resolve) { setTimeout(function () { resolve(false); }, 10000); });
+ Promise.race([customElements.whenDefined('engine-qa').then(function () { return true; }), deadline])
+ .then(function (ready) { if (ready) offer(); });
+ })();
+
// If model-viewer itself never upgrades (script blocked), don't spin forever.
setTimeout(function () {
if (loading && !loading.classList.contains('hidden') && !customElements.get('model-viewer')) {
@@ -691,6 +727,8 @@
</script>
<!-- The <sim-readiness> element, shared verbatim with /m/:id. -->
<script type="module" src="/sim-readiness-panel.js"></script>
+ <!-- The <engine-qa> element, shared verbatim with Rig Doctor. -->
+ <script type="module" src="/engine-qa-panel.js"></script>
<!-- Runtime i18n: detects locale, swaps annotated copy, mounts <lang-switcher>. -->
<script type="module" src="/i18n.js"></script>
</body>
diff --git a/src/rig-doctor-page.js b/src/rig-doctor-page.js
index 84962d602..b547f3372 100644
--- a/src/rig-doctor-page.js
+++ b/src/rig-doctor-page.js
@@ -7,11 +7,17 @@
// the user watches their own rig perform, and offer the canonicalized GLB
// as a download when the bone names needed rewriting.
//
-// The privacy claim in the copy is load-bearing, so it constrains the code: the
-// only network requests this page makes are for the animation clip library and
-// the sample rigs, both of which are three.ws assets. The user's file is read
-// with FileReader and never posted anywhere. PoseStage consumes a blob: URL
-// created from the in-memory buffer, which never leaves the tab.
+// The privacy claim in the copy is load-bearing, so it constrains the code: by
+// default the only network requests this page makes are for the animation clip
+// library and the sample rigs, both of which are three.ws assets. The user's
+// file is read with FileReader and never posted anywhere. PoseStage consumes a
+// blob: URL created from the in-memory buffer, which never leaves the tab.
+// The Engine QA panel grades draw calls, materials, and texel density the same
+// way (src/engine-qa-client.js, zero network). Its LOD-budget and collider
+// checks are the one deliberate exception: they need the server's real LOD
+// builder and manifold analyzer, so they report "not measured" until the
+// visitor clicks the panel's own "Check LOD & collider fitness" action, which
+// uploads the file for that single grade (requestFullEngineQa below).
//
// The stage is imported lazily. Three.js plus the GLTF/DRACO/meshopt loaders are
// the heaviest thing on the page, and a visitor who reads the explainer and
@@ -19,6 +25,7 @@
import { analyzeGlb, manifestFromReport, formatBytes, CANONICAL_TOTAL, CONVENTION_COUNT } from './rig-report.js';
import { canonicalizeGLBBones } from './glb-canonicalize.js';
+import { gradeEngineQaClient } from './engine-qa-client.js';
// Clips offered under the preview, chosen so each one exercises a different
// limb group: idle reads the torso, wave the arms, walk the legs. A rig whose
@@ -229,6 +236,7 @@ function diagnose(buffer, fileName) {
renderRenames(report);
renderUnmapped(report);
renderOutputs(report);
+ renderEngineQa(buffer);
const results = $('rd-results');
results.hidden = false;
@@ -237,6 +245,82 @@ function diagnose(buffer, fileName) {
mountStage(report);
}
+// Grades the three checks that are pure math over bytes already in memory
+// (src/engine-qa-client.js, zero network). The LOD budget and collider checks
+// come back as an explicit "not measured" with an opt-in upload action; see
+// requestFullEngineQa.
+function renderEngineQa(buffer) {
+ const el = $('rd-engine-qa');
+ if (!el) return;
+ const seq = state.seq;
+ el.loading();
+ gradeEngineQaClient(buffer)
+ .then((report) => {
+ if (state.seq !== seq) return;
+ el.showReport(report, { onUpgrade: () => requestFullEngineQa(buffer, seq) });
+ })
+ .catch((err) => {
+ if (state.seq !== seq) return;
+ el.failed(err?.message || 'That file could not be graded.', { onRetry: () => renderEngineQa(buffer) });
+ });
+}
+
+// The one explicit, opt-in exception to this page's zero-network guarantee:
+// clicking the panel's own action uploads the already-in-memory buffer so the
+// server can build a real LOD chain and run the manifold analyzer, then
+// re-renders the same panel with the full report plus an STL download.
+function requestFullEngineQa(buffer, seq) {
+ const el = $('rd-engine-qa');
+ if (!el) return;
+ fetch('/api/3d/engine-qa?lods=1', {
+ method: 'POST',
+ headers: { 'content-type': 'model/gltf-binary' },
+ body: buffer,
+ })
+ .then((r) => r.json().then((body) => ({ ok: r.ok, status: r.status, body })))
+ .then((res) => {
+ if (state.seq !== seq) return;
+ if (!res.ok) throw new Error((res.body && res.body.error) || `HTTP ${res.status}`);
+ el.showReport(res.body.report, { gradedAt: res.body.ts, onDownloadStl: () => downloadStl(buffer, seq) });
+ })
+ .catch((err) => {
+ if (state.seq !== seq) return;
+ el.failed(err?.message || 'The full engine QA grade could not be fetched.', { onRetry: () => requestFullEngineQa(buffer, seq) });
+ });
+}
+
+// Same upload-on-explicit-click exception as requestFullEngineQa: the STL
+// export needs the server's manifold/watertight pipeline, so a second
+// opt-in request trades the already-granted file for the printable mesh.
+function downloadStl(buffer, seq) {
+ return fetch('/api/3d/engine-qa?format=stl', {
+ method: 'POST',
+ headers: { 'content-type': 'model/gltf-binary' },
+ body: buffer,
+ })
+ .then(async (r) => {
+ if (state.seq !== seq) return;
+ if (!r.ok) {
+ const body = await r.json().catch(() => null);
+ throw new Error((body && body.error) || `HTTP ${r.status}`);
+ }
+ const blob = await r.blob();
+ const url = URL.createObjectURL(blob);
+ const fileName = (state.report?.fileName || 'model').replace(/\.glb$/i, '') + '.stl';
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = fileName;
+ document.body.appendChild(a);
+ a.click();
+ a.remove();
+ setTimeout(() => URL.revokeObjectURL(url), 0);
+ })
+ .catch((err) => {
+ const el = $('rd-engine-qa');
+ if (el && state.seq === seq) el.failed(err?.message || 'The STL export failed.', { onRetry: () => downloadStl(buffer, seq) });
+ });
+}
+
function showError(fileName, message, headline = 'That file could not be read as a GLB.') {
const results = $('rd-results');
teardownStage();