From 73f6dc2ccff6d580b04bfb7c05d890cd661de671 Mon Sep 17 00:00:00 2001 From: eust-w Date: Wed, 24 Jun 2026 16:31:41 +0800 Subject: [PATCH] Guard visual assets from physics acceptance --- README.md | 11 ++- docs/product-readiness.md | 54 +++++++++----- scripts/product-readiness-gate.mjs | 114 +++++++++++++++++++++++++++-- src/i18n.ts | 6 ++ src/main.ts | 64 +++++++++++++++- 5 files changed, 221 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 1a71563..1aa8b53 100644 --- a/README.md +++ b/README.md @@ -143,9 +143,10 @@ npm run verify:real-backend -- \ This probe calls the live MotrixSim bridge, not a mock. It checks editable entity groups in `/manifest`, calls real backend `/compose` for the G1/store/built-in primitive scene, verifies the composed object bodies in `/state`, -writes a no-op pose for one composed body, writes a no-op pose for one product -member, resumes the simulator, confirms fixed shelf anchors do not drift, and -measures compact pause/resume control latency. +writes a pose for one composed dynamic body, verifies fixed pre-stocked product +bodies reject `set_body_pose`, resumes the simulator, confirms fixed shelf +anchors do not drift, checks a lifted dynamic prop drops under backend physics, +and measures compact pause/resume control latency. For handoff or acceptance, prefer the single product gate: @@ -177,6 +178,10 @@ restored. The gate also validates the object physics-tier evidence. The product physical scene must include backend dynamic bodies and backend fixed environment bodies; visual-only objects are allowed only as explicit, counted preview artifacts. +The product gate also validates builder physics coverage: default user-added +props must be backend dynamic bodies. A separate negative browser path uploads a +local OBJ asset and confirms the in-page acceptance fails instead of treating the +visual asset as real collision physics. For release handoff, `npm run product:release-check` first builds `dist/`, checks the JavaScript gzip bundle budget, then forces the browser gate through diff --git a/docs/product-readiness.md b/docs/product-readiness.md index c1c24d7..da85905 100644 --- a/docs/product-readiness.md +++ b/docs/product-readiness.md @@ -126,6 +126,11 @@ The product acceptance gate must pass with zero failures. It checks: - Object physics-tier diagnostics, proving the product scene has real backend dynamic bodies and fixed environment bodies, and explicitly counting any visual-only objects. +- Builder physics coverage, proving every user-added default prop in the + product physical scene is a backend dynamic body. +- Visual-only upload boundary, proving a locally uploaded OBJ asset is rendered + as a visual object and makes product acceptance fail instead of silently + passing as real collision physics. - Runtime diagnostics panel with manifest, state, control, latency, binding, and asset health evidence. - Nonblank WebGL rendering. @@ -169,6 +174,9 @@ Release checks write these artifacts: - `product-readiness-config-import-restore.jpg`: screenshot captured after importing the downloaded builder config in a clean browser context and restoring the backend physical scene. +- `product-readiness-visual-only-boundary.jpg`: screenshot captured after adding + a local uploaded OBJ asset to the physical preset. This negative-path evidence + must show visual-only builder props and a failed in-page acceptance verdict. - `product-readiness-evidence.json`: compact handoff manifest with the report hash, git branch/commit/dirty state/remotes, screenshot/export paths, byte sizes, capture strategy, builder/share/config-import status, canvas metadata, @@ -185,7 +193,7 @@ evidence to a code state: Representative product gate baseline for the current thresholds: -- Result: `38 passed / 0 warned / 0 failed` +- Result: `41 passed / 0 warned / 0 failed` - Frontend mode: `preview` for release handoff through `npm run product:release-check`. - Fail on warning: `true` for release handoff. @@ -202,7 +210,7 @@ Representative product gate baseline for the current thresholds: - Fixed inventory protection: a pre-stocked product body returned HTTP `400` for `set_body_pose`, proving fixed stock is not accidentally treated as a movable free body. -- Dynamic object drop: a lifted user-added cube dropped `0.48012m` after resume, +- Dynamic object drop: a lifted user-added cube dropped `0.47701m` after resume, proving dynamic props still use backend physics. - Object physics tiers: the diagnostics panel and exported acceptance artifacts count backend dynamic, backend fixed, backend state-only, and visual-only @@ -211,6 +219,12 @@ Representative product gate baseline for the current thresholds: - Product UI compose: the Scene Builder `Physical Scene` workflow reaches `后端物理组合场景`, keeps `4` builder props, exposes `/control`, and shows `外部仿真 / 后端物理` diagnostics. +- Builder physics coverage: the product UI and exported acceptance package show + `builderDynamic=4`, `builderVisual=0`, `total=4`, `ready=true`. +- Visual-only upload boundary: the gate uploads a local OBJ asset and adds it to + the physical preset in a separate clean browser context. The resulting preview + has `641` objects, `builderDynamic=0`, `builderVisual=5`, and the in-page + acceptance verdict correctly fails with `10 通过 / 0 警告 / 1 失败,共 11 项`. - Product share link: the gate clicks `复制分享链接`, confirms the copied URL has a `builder` payload and no `manifest` override, then opens it in a clean browser context. The restored page keeps the same `4` props, reaches @@ -265,13 +279,14 @@ Scene evidence: - Meshes: `627` - Editable groups: `4 / 568` - Fallback meshes: `0` -- Desktop acceptance: `10 通过 / 0 警告 / 0 失败,共 10 项` -- Desktop acceptance telemetry: `0 ms / 10-0-0` +- Desktop acceptance: `11 通过 / 0 警告 / 0 失败,共 11 项` +- Desktop acceptance telemetry: `0 ms / 11-0-0` - Mobile preview: `636 objects / 635 bindings / 30 pixels` -- Mobile acceptance: `10 通过 / 0 警告 / 0 失败,共 10 项` -- Mobile acceptance telemetry: `0 ms / 10-0-0` +- Mobile acceptance: `11 通过 / 0 警告 / 0 失败,共 11 项` +- Mobile acceptance telemetry: `0 ms / 11-0-0` - UI acceptance package export: `schema=motrixsim-web.acceptance-package.v1`, - `state=pass`, `objects=636`, `control=http://127.0.0.1:18090/control` + `state=pass`, `objects=636`, `builderDynamic=4`, `builderVisual=0`, + `control=http://127.0.0.1:18090/control` - UI HTML report export: title includes `MotrixSim Web 预览验收报告`, backend physics evidence is present, and `/control` is present. - UI HTML report render: the downloaded report opens in Chromium with a visible @@ -300,25 +315,26 @@ Control evidence: backend diagnostics. - Composed object body edit: `133ms`. - Fixed inventory edit rejection: `86ms`. -- Dynamic composed object drop: `0.48012m`. +- Dynamic composed object drop: `0.47701m`. - Static shelf anchor stability: `max drift 0.00000m` after a 2500 ms resume window. -- Resume backend state: `56ms paused=false` -- Resume visible UI state: `62ms` -- Pause backend state: `288ms paused=true` -- Pause visible UI state: `292ms` -- Desktop acceptance wait: `6115ms` total, product telemetry `0ms` -- Mobile acceptance wait: `11062ms` total, product telemetry `0ms` +- Resume backend state: `229ms paused=false` +- Resume visible UI state: `182ms` +- Pause backend state: `84ms paused=true` +- Pause visible UI state: `66ms` +- Desktop acceptance wait: `6535ms` total, product telemetry `0ms` +- Mobile acceptance wait: `3993ms` total, product telemetry `0ms` - Runtime diagnostics panel: `state=http://127.0.0.1:18090/state`, `control=http://127.0.0.1:18090/control`, - `latency=响应 291 ms / 确认 291 ms / 可见 292 ms`, - `acceptanceLatency=0 ms / 10-0-0`, - `binding=635/636; 4/568`. + `latency=响应 65 ms / 确认 65 ms / 可见 66 ms`, + `acceptanceLatency=0 ms / 11-0-0`, + `binding=635/636; 4/568`, + `builderPhysics=已添加物体 4: 后端动态 4 / 仅视觉 0`. - Evidence screenshot artifacts: - `builder page; share page; import page; desktop canvas; mobile canvas` + `builder page; share page; import page; visual-only boundary canvas; desktop canvas; mobile canvas` - Evidence export artifacts: - `config 1 KiB v1; package 7 KiB motrixsim-web.acceptance-package.v1; report 8 KiB; rendered screenshot recorded` + `config 1 KiB v1; package 9 KiB motrixsim-web.acceptance-package.v1; report 9 KiB; rendered screenshot recorded` Visible UI control sync is the product interaction SLA and must stay under the current `3000ms` target. Backend state polling can take longer when the remote diff --git a/scripts/product-readiness-gate.mjs b/scripts/product-readiness-gate.mjs index 290e2e7..3034203 100644 --- a/scripts/product-readiness-gate.mjs +++ b/scripts/product-readiness-gate.mjs @@ -372,6 +372,7 @@ async function collectEvidenceArtifacts(browserEvidence) { const builderCapture = browserEvidence?.screenshots?.builderCompose; const shareRestoreCapture = browserEvidence?.screenshots?.shareRestore; const configImportCapture = browserEvidence?.screenshots?.configImportRestore; + const visualOnlyBoundaryCapture = browserEvidence?.screenshots?.visualOnlyBoundary; const desktopCapture = browserEvidence?.screenshots?.desktop; const mobileCapture = browserEvidence?.screenshots?.mobile; const builderConfigExport = browserEvidence?.exports?.builderConfig; @@ -403,6 +404,15 @@ async function collectEvidenceArtifacts(browserEvidence) { summaryProps: browserEvidence?.configImportRestore?.stats?.summaryProps, } : undefined; + const visualOnlyBoundary = visualOnlyBoundaryCapture + ? { + ...(await describeArtifact(visualOnlyBoundaryCapture.path)), + strategy: captureStrategy(visualOnlyBoundaryCapture), + acceptanceState: browserEvidence?.visualOnlyBoundary?.stats?.acceptanceTelemetry?.state, + acceptanceScore: browserEvidence?.visualOnlyBoundary?.stats?.acceptanceScore, + builderPhysics: browserEvidence?.visualOnlyBoundary?.stats?.builderPhysics, + } + : undefined; const desktop = { ...(await describeArtifact(desktopCapture?.path ?? "")), strategy: captureStrategy(desktopCapture), @@ -431,6 +441,12 @@ async function collectEvidenceArtifacts(browserEvidence) { && configImportRestore.bytes >= thresholds.minEvidenceImageBytes && configImportRestore.sha256.length === 64 && ["page", "preview", "canvas"].includes(configImportRestore.strategy); + const validVisualOnlyBoundary = Boolean(visualOnlyBoundary) + && visualOnlyBoundary.bytes >= thresholds.minEvidenceImageBytes + && visualOnlyBoundary.sha256.length === 64 + && ["page", "preview", "canvas"].includes(visualOnlyBoundary.strategy) + && visualOnlyBoundary.acceptanceState === "fail" + && Number(visualOnlyBoundary.builderPhysics?.visualOnly ?? 0) > 0; const builderConfig = builderConfigExport ? { ...(await describeArtifact(builderConfigExport.path)), @@ -439,6 +455,7 @@ async function collectEvidenceArtifacts(browserEvidence) { sceneId: builderConfigExport.sceneId, robotId: builderConfigExport.robotId, propCount: builderConfigExport.propCount, + physics: builderConfigExport.physics, workspaceStatus: builderConfigExport.workspaceStatus, } : undefined; @@ -453,6 +470,7 @@ async function collectEvidenceArtifacts(browserEvidence) { objectCount: packageExport.objectCount, controlUrl: packageExport.controlUrl, objectPhysics: packageExport.objectPhysics, + builderPhysics: packageExport.builderPhysics, } : undefined; const acceptanceReport = reportExport @@ -487,13 +505,19 @@ async function collectEvidenceArtifacts(browserEvidence) { && acceptancePackage.objectCount >= thresholds.minObjects && Number(acceptancePackage.objectPhysics?.backendDynamic ?? 0) >= 4 && Number(acceptancePackage.objectPhysics?.backendFixed ?? 0) >= 1 + && Number(acceptancePackage.builderPhysics?.backendDynamic ?? 0) >= 4 + && Number(acceptancePackage.builderPhysics?.visualOnly ?? Number.POSITIVE_INFINITY) === 0 + && acceptancePackage.builderPhysics?.ready === true && String(acceptancePackage.controlUrl ?? "").includes("/control"); const validBuilderConfig = Boolean(builderConfig) && builderConfig.bytes >= 256 && builderConfig.sha256.length === 64 && builderConfig.version === 1 && builderConfig.sceneId === "g1-store-blocks-physics" - && builderConfig.propCount >= 4; + && builderConfig.propCount >= 4 + && builderConfig.physics?.ready === true + && Number(builderConfig.physics?.backendDynamic ?? 0) >= 4 + && Number(builderConfig.physics?.visualOnly ?? Number.POSITIVE_INFINITY) === 0; const validReport = Boolean(acceptanceReport) && acceptanceReport.bytes >= thresholds.minEvidenceExportBytes && acceptanceReport.sha256.length === 64 @@ -509,8 +533,8 @@ async function collectEvidenceArtifacts(browserEvidence) { && acceptanceReport.render?.containsPhysicsTiers === true; check( "evidence-screenshot-artifacts", - validDesktop && validMobile && validBuilderCompose && validShareRestore && validConfigImportRestore, - `builder ${Math.round((builderCompose?.bytes ?? 0) / 1024)} KiB ${builderCompose?.strategy ?? "-"}; share ${Math.round((shareRestore?.bytes ?? 0) / 1024)} KiB ${shareRestore?.strategy ?? "-"}; import ${Math.round((configImportRestore?.bytes ?? 0) / 1024)} KiB ${configImportRestore?.strategy ?? "-"}; desktop ${Math.round(desktop.bytes / 1024)} KiB ${desktop.strategy}; mobile ${Math.round(mobile.bytes / 1024)} KiB ${mobile.strategy}`, + validDesktop && validMobile && validBuilderCompose && validShareRestore && validConfigImportRestore && validVisualOnlyBoundary, + `builder ${Math.round((builderCompose?.bytes ?? 0) / 1024)} KiB ${builderCompose?.strategy ?? "-"}; share ${Math.round((shareRestore?.bytes ?? 0) / 1024)} KiB ${shareRestore?.strategy ?? "-"}; import ${Math.round((configImportRestore?.bytes ?? 0) / 1024)} KiB ${configImportRestore?.strategy ?? "-"}; boundary ${Math.round((visualOnlyBoundary?.bytes ?? 0) / 1024)} KiB ${visualOnlyBoundary?.strategy ?? "-"}; desktop ${Math.round(desktop.bytes / 1024)} KiB ${desktop.strategy}; mobile ${Math.round(mobile.bytes / 1024)} KiB ${mobile.strategy}`, ); check( "evidence-export-artifacts", @@ -522,6 +546,7 @@ async function collectEvidenceArtifacts(browserEvidence) { builderCompose, shareRestore, configImportRestore, + visualOnlyBoundary, desktop, mobile, }, @@ -587,6 +612,12 @@ async function readBrowserStats(page) { visualOnly: numberData("physicsVisualOnly"), total: numberData("physicsTotalObjects"), }, + builderPhysics: { + backendDynamic: numberData("builderBackendDynamic"), + visualOnly: numberData("builderVisualOnly"), + total: numberData("builderTotalObjects"), + ready: data.builderPhysicsReady === "true", + }, diagnostics: { manifestUrl: text("#diag-manifest-url"), stateUrl: text("#diag-state-url"), @@ -597,6 +628,7 @@ async function readBrowserStats(page) { acceptanceLatency: text("#diag-acceptance-latency"), binding: text("#diag-binding"), physicsTiers: text("#diag-physics-tiers"), + builderPhysics: text("#diag-builder-physics"), assets: text("#diag-assets"), status: text("#diagnostics-status"), }, @@ -850,17 +882,21 @@ async function exportAcceptanceArtifacts(page) { const packageObjectCount = Number(packageJson?.stats?.objectCount ?? 0); const packageControlUrl = packageJson?.diagnostics?.controlUrl; const packagePhysics = packageJson?.diagnostics?.stats?.objectPhysics ?? {}; + const packageBuilderPhysics = packageJson?.diagnostics?.stats?.builderPhysics ?? {}; const packageOk = packageJson?.schema === "motrixsim-web.acceptance-package.v1" && packageJson?.acceptance?.state === "pass" && packageJson?.acceptance?.failCount === 0 && packageObjectCount >= thresholds.minObjects && Number(packagePhysics.backendDynamic ?? 0) >= 4 && Number(packagePhysics.backendFixed ?? 0) >= 1 + && Number(packageBuilderPhysics.backendDynamic ?? 0) >= 4 + && Number(packageBuilderPhysics.visualOnly ?? Number.POSITIVE_INFINITY) === 0 + && packageBuilderPhysics.ready === true && String(packageControlUrl ?? "").includes("/control"); check( "browser-acceptance-package-export", packageOk, - `${packageDownload.suggestedFilename}; state=${packageJson?.acceptance?.state}; objects=${packageObjectCount}; dynamic=${packagePhysics.backendDynamic ?? "-"}; fixed=${packagePhysics.backendFixed ?? "-"}; control=${packageControlUrl ?? "-"}`, + `${packageDownload.suggestedFilename}; state=${packageJson?.acceptance?.state}; objects=${packageObjectCount}; dynamic=${packagePhysics.backendDynamic ?? "-"}; fixed=${packagePhysics.backendFixed ?? "-"}; builderDynamic=${packageBuilderPhysics.backendDynamic ?? "-"}; builderVisual=${packageBuilderPhysics.visualOnly ?? "-"}; control=${packageControlUrl ?? "-"}`, ); const reportDownload = await clickAndSaveDownload( @@ -896,6 +932,7 @@ async function exportAcceptanceArtifacts(page) { objectCount: packageObjectCount, controlUrl: packageControlUrl, objectPhysics: packagePhysics, + builderPhysics: packageBuilderPhysics, }, report: { ...reportDownload, @@ -1046,12 +1083,15 @@ async function exportBuilderConfigArtifact(page) { && config?.sceneId === "g1-store-blocks-physics" && Array.isArray(config?.props) && config.props.length >= 4 + && config?.physics?.ready === true + && Number(config?.physics?.backendDynamic ?? 0) >= 4 + && Number(config?.physics?.visualOnly ?? Number.POSITIVE_INFINITY) === 0 && /motrixsim-scene-.*\.json$/i.test(download.suggestedFilename) && /配置已导出|config exported/i.test(workspaceStatus); check( "browser-builder-config-export", exportOk, - `${download.suggestedFilename}; props=${config?.props?.length ?? "-"}; scene=${config?.sceneId ?? "-"}; status=${workspaceStatus}`, + `${download.suggestedFilename}; props=${config?.props?.length ?? "-"}; scene=${config?.sceneId ?? "-"}; builderDynamic=${config?.physics?.backendDynamic ?? "-"}; builderVisual=${config?.physics?.visualOnly ?? "-"}; status=${workspaceStatus}`, ); return { ...download, @@ -1060,6 +1100,7 @@ async function exportBuilderConfigArtifact(page) { sceneId: config?.sceneId, robotId: config?.robotId, propCount: config?.props?.length, + physics: config?.physics, workspaceStatus, }; } @@ -1281,6 +1322,52 @@ async function controlThroughUi(page, selector, expectedPaused) { return { clickMs, backend, dom: { ...dom, clickMs }, expectedPaused }; } +async function verifyVisualOnlyBoundary(browser) { + const context = await browser.newContext({ viewport: { width: 1440, height: 820 }, deviceScaleFactor: 1 }); + await context.addInitScript(() => { + window.localStorage.removeItem("motrixsim-web-locale"); + window.localStorage.removeItem("motrixsim-web-builder-draft"); + }); + const page = await context.newPage(); + try { + await page.goto(frontendUrl.href, { waitUntil: "domcontentloaded" }); + await waitForProductScene(page); + await page.setInputFiles( + "#asset-upload-file", + [path.join(rootDir, "research-tests/product-acceptance/local-upload-fixture/meshes/tri.obj")], + ); + await page.waitForFunction(() => ( + Array.from(document.querySelectorAll("[data-add-preset]")) + .some((element) => element.dataset.addPreset?.startsWith("prop-uploaded-")) + ), undefined, { timeout: thresholds.browserReadyMs }); + await page.locator('[data-add-preset^="prop-uploaded-"]').first().click(); + await page.waitForFunction(() => { + const data = document.documentElement.dataset; + const visualOnly = Number(data.builderVisualOnly ?? 0); + const status = document.querySelector("#builder-status")?.textContent ?? ""; + return visualOnly > 0 && !/组合中|composing/i.test(status); + }, undefined, { polling: 100, timeout: thresholds.browserReadyMs }); + const acceptance = await runAcceptanceReview(page); + const stats = await readBrowserStats(page); + const screenshot = await safeScreenshot( + "browser-visual-only-boundary-screenshot", + page, + path.join(outDir, "product-readiness-visual-only-boundary.jpg"), + { preferPreview: true }, + ); + const visualOnly = stats.builderPhysics?.visualOnly ?? 0; + const failCount = stats.acceptanceTelemetry.failCount ?? 0; + check( + "browser-visual-only-boundary", + visualOnly > 0 && stats.acceptanceTelemetry.state === "fail" && failCount > 0, + `builderVisual=${visualOnly}; builderDynamic=${stats.builderPhysics?.backendDynamic ?? "-"}; acceptance=${stats.acceptanceScore}; ${stats.diagnostics.builderPhysics}`, + ); + return { acceptance, stats, screenshot }; + } finally { + await closeContext(context, "visual-only-boundary-context"); + } +} + async function verifyBrowser() { await postControl("pause"); const browser = await chromium.launch({ headless: true }); @@ -1314,6 +1401,11 @@ async function verifyBrowser() { logProgress("config import restore done"); await postControl("pause"); + logProgress("visual-only boundary start"); + const visualOnlyBoundary = await verifyVisualOnlyBoundary(browser); + logProgress("visual-only boundary done"); + await postControl("pause"); + logProgress("desktop acceptance start"); const desktopContext = await browser.newContext({ viewport: { width: 1440, height: 820 }, deviceScaleFactor: 1, acceptDownloads: true }); await desktopContext.addInitScript(() => { @@ -1356,11 +1448,15 @@ async function verifyBrowser() { const fallbackCount = numericText(desktopStats.fallbacks); const pixelCount = numericText(desktopStats.pixels); const physicsTiers = desktopStats.physicsTiers ?? {}; + const builderPhysics = desktopStats.builderPhysics ?? {}; const physicsTierVisualBudget = Math.max(1, objectCount - bindingCount); const physicsTierOk = (physicsTiers.backendDynamic ?? 0) >= 4 && (physicsTiers.backendFixed ?? 0) >= 1 && (physicsTiers.total ?? 0) === objectCount && (physicsTiers.visualOnly ?? Number.POSITIVE_INFINITY) <= physicsTierVisualBudget; + const builderPhysicsOk = (builderPhysics.backendDynamic ?? 0) >= 4 + && (builderPhysics.visualOnly ?? Number.POSITIVE_INFINITY) === 0 + && builderPhysics.ready === true; const sourceLabel = `${desktopStats.sourceLabel} ${desktopStats.projectSource}`; const acceptancePassed = acceptanceScoreHasNoFailures(desktopStats.acceptanceScore); const mobileAcceptancePassed = acceptanceScoreHasNoFailures(mobileStats.acceptanceScore); @@ -1389,6 +1485,11 @@ async function verifyBrowser() { physicsTierOk, `dynamic=${physicsTiers.backendDynamic ?? "-"} fixed=${physicsTiers.backendFixed ?? "-"} state=${physicsTiers.backendStateOnly ?? "-"} visual=${physicsTiers.visualOnly ?? "-"} total=${physicsTiers.total ?? "-"} budget=${physicsTierVisualBudget}; ${desktopStats.diagnostics.physicsTiers}`, ); + check( + "browser-builder-physics-coverage", + builderPhysicsOk, + `builderDynamic=${builderPhysics.backendDynamic ?? "-"} builderVisual=${builderPhysics.visualOnly ?? "-"} total=${builderPhysics.total ?? "-"} ready=${builderPhysics.ready}; ${desktopStats.diagnostics.builderPhysics}`, + ); check( "browser-builder-compose-ui", /后端物理组合|physical backend composed/i.test(builderCompose.builderStatus) @@ -1410,6 +1511,7 @@ async function verifyBrowser() { && desktopStats.diagnostics.source.includes("外部仿真") && desktopStats.diagnostics.binding.includes(String(bindingCount)) && desktopStats.diagnostics.physicsTiers.includes(String(physicsTiers.backendDynamic ?? "")) + && desktopStats.diagnostics.builderPhysics.includes(String(builderPhysics.backendDynamic ?? "")) && desktopStats.diagnostics.assets.includes(String(meshCount)), JSON.stringify(desktopStats.diagnostics), ); @@ -1433,6 +1535,7 @@ async function verifyBrowser() { shareLink, shareRestore, configImportRestore, + visualOnlyBoundary, controlTimings: { resume: resumeControl, pause: pauseControl }, acceptanceTimings: { desktop: desktopAcceptance, mobile: mobileAcceptance }, paused, @@ -1445,6 +1548,7 @@ async function verifyBrowser() { builderCompose: builderComposeScreenshot, shareRestore: shareRestore.screenshot, configImportRestore: configImportRestore.screenshot, + visualOnlyBoundary: visualOnlyBoundary.screenshot, desktop: desktopScreenshot, mobile: mobileScreenshot, }, diff --git a/src/i18n.ts b/src/i18n.ts index fbeeb81..dab065b 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -43,6 +43,7 @@ export type MessageKey = | "label.physicsMode" | "label.physicalObjects" | "label.physicsTiers" + | "label.builderPhysics" | "label.position" | "label.selectedObject" | "label.backend" @@ -267,6 +268,7 @@ export type MessageKey = | "acceptance.check.pixels" | "acceptance.check.physics" | "acceptance.check.physicsTiers" + | "acceptance.check.builderPhysics" | "acceptance.check.report" | "acceptance.detail.manifestOk" | "acceptance.detail.manifestPending" @@ -430,6 +432,7 @@ const messages: Record = { "label.physicsMode": "运行模式", "label.physicalObjects": "真实物理对象", "label.physicsTiers": "对象物理分层", + "label.builderPhysics": "添加物体物理", "label.position": "位置", "label.selectedObject": "选中对象", "label.backend": "后端", @@ -654,6 +657,7 @@ const messages: Record = { "acceptance.check.pixels": "画面可见", "acceptance.check.physics": "物理链路", "acceptance.check.physicsTiers": "对象物理分层", + "acceptance.check.builderPhysics": "添加物体真实绑定", "acceptance.check.report": "验收摘要", "acceptance.detail.manifestOk": "已加载 {name}", "acceptance.detail.manifestPending": "尚未完成 manifest 加载", @@ -810,6 +814,7 @@ const messages: Record = { "label.physicsMode": "Mode", "label.physicalObjects": "Real physics objects", "label.physicsTiers": "Object physics tiers", + "label.builderPhysics": "Added object physics", "label.position": "Position", "placeholder.noScene": "No scene uploaded", "label.selectedObject": "Selected object", @@ -1034,6 +1039,7 @@ const messages: Record = { "acceptance.check.pixels": "Visible render", "acceptance.check.physics": "Physics path", "acceptance.check.physicsTiers": "Object physics tiers", + "acceptance.check.builderPhysics": "Added object real bindings", "acceptance.check.report": "Acceptance summary", "acceptance.detail.manifestOk": "loaded {name}", "acceptance.detail.manifestPending": "manifest has not finished loading", diff --git a/src/main.ts b/src/main.ts index 3b834fd..d96734e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -72,6 +72,13 @@ interface BuilderConfig { sceneId: string; robotId: string; robotPose: Vec3; + physics?: { + objectPolicy: "backend-dynamic-only"; + backendDynamic: number; + visualOnly: number; + total: number; + ready: boolean; + }; props: Array<{ presetId: string; position: Vec3; @@ -151,6 +158,7 @@ interface RuntimeDiagnostics { objects: number; bodyBindings: number; objectPhysics: ObjectPhysicsProfile; + builderPhysics: BuilderPhysicsProfile; editableGroups: number; groupedObjects: number; meshes: number; @@ -194,6 +202,13 @@ interface ObjectPhysicsProfile { total: number; } +interface BuilderPhysicsProfile { + backendDynamic: number; + visualOnly: number; + total: number; + ready: boolean; +} + function manifestPhysicsRole(object: PreviewObject): NonNullable | undefined { return object.physics; } @@ -604,6 +619,7 @@ document.querySelector("#app")!.innerHTML = `
${t("label.acceptanceLatency")}
-
${t("label.realBinding")}
-
${t("label.physicsTiers")}
-
+
${t("label.builderPhysics")}
-
${t("label.assetHealth")}
-
@@ -1807,6 +1823,22 @@ function builderPropPhysicsLabel(item: BuilderProp): string { return builderPropPhysicsClass(item) === "dynamic" ? t("physicsTier.backendDynamic") : t("physicsTier.visualOnly"); } +function builderPhysicsProfile(): BuilderPhysicsProfile { + const backendDynamic = builderProps.filter((item) => builderPropPhysicsClass(item) === "dynamic").length; + const total = builderProps.length; + const visualOnly = total - backendDynamic; + return { + backendDynamic, + visualOnly, + total, + ready: visualOnly === 0, + }; +} + +function builderPhysicsProfileLabel(profile = builderPhysicsProfile()): string { + return `${t("label.addedObjects")} ${profile.total}: ${t("physicsTier.backendDynamic")} ${profile.backendDynamic} / ${t("physicsTier.visualOnly")} ${profile.visualOnly}`; +} + function renderBuilderSummary(): void { const scenePreset = selectedScenePreset(); const robotPreset = selectedRobotPreset(); @@ -2042,6 +2074,7 @@ function currentAcceptanceChecks(): AcceptanceCheck[] { const stats = previewer.getStats(); const health = healthSummary(); const physicsProfile = objectPhysicsProfile(); + const builderPhysics = builderPhysicsProfile(); const manifestAvailable = stats.manifestName !== "none" && stats.objectCount > 0 && manifestInput.value.trim().length > 0; const hasUsefulMeshes = stats.loadedMeshCount > 0 || stats.objectCount > 0; const reportText = document.querySelector("#workflow-report-text")?.value.trim() ?? ""; @@ -2106,6 +2139,18 @@ function currentAcceptanceChecks(): AcceptanceCheck[] { : "warn" : "warn", }, + { + id: "builder-physics", + label: t("acceptance.check.builderPhysics"), + detail: builderPhysicsProfileLabel(builderPhysics), + state: health.hasBackendPhysics + ? builderPhysics.ready + ? "pass" + : "fail" + : builderPhysics.total === 0 + ? "warn" + : "fail", + }, { id: "report", label: t("acceptance.check.report"), @@ -2170,7 +2215,7 @@ function currentAcceptanceCases(checks = currentAcceptanceChecks()): AcceptanceC id: "backend", titleKey: "acceptance.case.backend.title", goalKey: "acceptance.case.backend.goal", - checks: pick("backend", "physics", "physics-tiers"), + checks: pick("backend", "physics", "physics-tiers", "builder-physics"), }, { id: "control", @@ -2329,6 +2374,7 @@ function currentRuntimeDiagnostics(): RuntimeDiagnostics { const stats = previewer.getStats(); const entry = latestControlTelemetry(); const physicsProfile = objectPhysicsProfile(); + const builderPhysics = builderPhysicsProfile(); return { schema: "motrixsim-web.runtime-diagnostics.v1", capturedAt: new Date().toISOString(), @@ -2344,6 +2390,7 @@ function currentRuntimeDiagnostics(): RuntimeDiagnostics { objects: stats.objectCount, bodyBindings: stats.bodyBoundObjectCount, objectPhysics: physicsProfile, + builderPhysics, editableGroups: stats.editableGroupCount, groupedObjects: stats.groupedObjectCount, meshes: stats.loadedMeshCount, @@ -2393,6 +2440,7 @@ function currentDiagnosticsReport(): string { `${t("label.acceptanceLatency")}: ${acceptanceLatencySummary()}`, `${t("label.realBinding")}: ${diagnostics.stats.bodyBindings}/${diagnostics.stats.objects}; groups ${diagnostics.stats.editableGroups}/${diagnostics.stats.groupedObjects}`, `${t("label.physicsTiers")}: ${objectPhysicsProfileLabel(diagnostics.stats.objectPhysics)}`, + `${t("label.builderPhysics")}: ${builderPhysicsProfileLabel(diagnostics.stats.builderPhysics)}`, `${t("label.assetHealth")}: meshes ${diagnostics.stats.meshes}; fallbacks ${diagnostics.stats.fallbacks}; pixels ${diagnostics.stats.nonBackgroundPixelSamples}`, ].join("\n"); } @@ -2405,6 +2453,10 @@ function renderDiagnosticsPanel(): void { data.physicsBackendStateOnly = String(diagnostics.stats.objectPhysics.backendStateOnly); data.physicsVisualOnly = String(diagnostics.stats.objectPhysics.visualOnly); data.physicsTotalObjects = String(diagnostics.stats.objectPhysics.total); + data.builderBackendDynamic = String(diagnostics.stats.builderPhysics.backendDynamic); + data.builderVisualOnly = String(diagnostics.stats.builderPhysics.visualOnly); + data.builderTotalObjects = String(diagnostics.stats.builderPhysics.total); + data.builderPhysicsReady = String(diagnostics.stats.builderPhysics.ready); setText("#diag-manifest-url", diagnostics.manifestUrl); setText("#diag-state-url", endpointLabel(diagnostics.stateUrl)); setText("#diag-control-url", endpointLabel(diagnostics.controlUrl)); @@ -2417,6 +2469,7 @@ function renderDiagnosticsPanel(): void { `${diagnostics.stats.bodyBindings}/${diagnostics.stats.objects}; ${diagnostics.stats.editableGroups}/${diagnostics.stats.groupedObjects}`, ); setText("#diag-physics-tiers", objectPhysicsProfileLabel(diagnostics.stats.objectPhysics)); + setText("#diag-builder-physics", builderPhysicsProfileLabel(diagnostics.stats.builderPhysics)); setText( "#diag-assets", `mesh ${diagnostics.stats.meshes}; fallback ${diagnostics.stats.fallbacks}; pixels ${diagnostics.stats.nonBackgroundPixelSamples}`, @@ -2458,6 +2511,7 @@ function currentWorkflowReport(): string { `${t("label.objects")}: ${stats.objectCount}`, `${t("label.editableGroups")}: ${stats.editableGroupCount} / ${stats.groupedObjectCount}`, `${t("label.physicsTiers")}: ${objectPhysicsProfileLabel(physicsProfile)}`, + `${t("label.builderPhysics")}: ${builderPhysicsProfileLabel()}`, `${t("label.meshes")}: ${stats.loadedMeshCount}`, `${t("label.pixelCheck")}: ${stats.nonBackgroundPixelSamples ?? 0}`, `${t("label.runState")}: ${runStateLabel()}`, @@ -2887,11 +2941,19 @@ function renderBuilderPhysicsGuard(): void { } function builderConfig(): BuilderConfig { + const physics = builderPhysicsProfile(); return { version: 1, sceneId: selectedScenePreset().id, robotId: selectedRobotPreset().id, robotPose: [...builderRobotPose] as Vec3, + physics: { + objectPolicy: "backend-dynamic-only", + backendDynamic: physics.backendDynamic, + visualOnly: physics.visualOnly, + total: physics.total, + ready: physics.ready, + }, props: builderProps.map((item) => ({ presetId: item.presetId, position: [...item.position] as Vec3,