3D engine that AI agents drive
Report floating and intersecting parts only from scene_look, cap job findings (#905)
Nguyen Xuan An1594416f3db1
diff --git a/scripts/agent-preview-browser.js b/scripts/agent-preview-browser.jsindex 019c535e..34fea5db 100644--- a/scripts/agent-preview-browser.js+++ b/scripts/agent-preview-browser.js@@ -184,13 +184,15 @@ function sampleFrameShares() {/*** Warnings about the frame just drawn from `camera`: framing, a stale bake and exposure (when `exposure` is given, the* effects.exposure drawn with). Imported assets have no part bounds or bake, so they get the exposure check only.+ * `placement` adds the floating and intersecting parts, which only scene_look reports: a render job would repeat them+ * for every frame of a moving scene.*/-function viewProblems(record, camera, exposure) {+function viewProblems(record, camera, exposure, { placement = false } = {}) {const problems = [];const boxes = record.scene.worldBounds?.();if (boxes) {problems.push(...framingProblems({ camera, aspect: canvas.width / canvas.height, boxes }));- problems.push(...placementProblems({ boxes }));+ if (placement) problems.push(...placementProblems({ boxes }));}if (record.scene.bakeStaleness) problems.push(...record.scene.bakeStaleness());if (exposure !== undefined) problems.push(...exposureProblems({ shares: sampleFrameShares(), exposure }));@@ -1233,7 +1235,7 @@ window.__agentPreview = {sampleMotionTime(record.scene, motionTime);}draw(record);- const render = renderInfo(record.renderer, viewProblems(record, record.scene.camera, record.scene.effects.exposure));+ const render = renderInfo(record.renderer, viewProblems(record, record.scene.camera, record.scene.effects.exposure, { placement: true }));record.lastRender = render;const labels = withLabels ? collectLabels(record, record.scene.camera, canvas.width, canvas.height) : undefined;return {diff --git a/src/frame-checks.js b/src/frame-checks.jsindex 195ba519..ea51d588 100644--- a/src/frame-checks.js+++ b/src/frame-checks.js@@ -11,6 +11,7 @@ const BLACK_FRAME_SHARE = 0.98;const CLIPPED_FRAME_SHARE = 0.35;const MAXIMUM_FINDING_NODES = 8;+const MAXIMUM_JOB_DIAGNOSTICS = 16;/** A finding names the parts it concerns in `nodes` and carries its numbers as extra fields. */function warning(kind, target, message, fix, details = {}) {@@ -229,12 +230,12 @@ export function placementProblems({ boxes }) {return problems;}-/** Adds a frame's diagnostics to `metrics.diagnostics`, keeping one entry per kind, target and message across a job's frames. */+/** Adds a frame's diagnostics to `metrics.diagnostics`, keeping one entry per kind, target and message across a job's frames, up to 16 entries. */export function mergeFrameDiagnostics(metrics, frameDiagnostics) {if (!frameDiagnostics?.length) return;metrics.diagnostics ??= [];for (const problem of frameDiagnostics) {const known = metrics.diagnostics.some(entry => entry.kind === problem.kind && entry.target === problem.target && entry.message === problem.message);- if (!known) metrics.diagnostics.push(problem);+ if (!known && metrics.diagnostics.length < MAXIMUM_JOB_DIAGNOSTICS) metrics.diagnostics.push(problem);}}diff --git a/tests/support/preview-harness.mjs b/tests/support/preview-harness.mjsindex bc03c137..a58a5e94 100644--- a/tests/support/preview-harness.mjs+++ b/tests/support/preview-harness.mjs@@ -15,7 +15,7 @@ import { BRANCH_LIMITS, createBranchStore, printableLabel } from '../../src/agenimport { sessionProblem, SCENE_STORE_LIMITS } from '../../src/agent-errors.js';import { AGENT_SCENE_DEFAULT_LIMITS } from '../../src/agent-scene-capabilities.js';import { describeApplication } from '../../src/agent-apply-report.js';-import { framingProblems, exposureProblems, lumaShares } from '../../src/frame-checks.js';+import { framingProblems, placementProblems, exposureProblems, lumaShares } from '../../src/frame-checks.js';import { agentAssetDecodeOptions, withCatalogLimitAdvice } from '../../src/agent-asset-limits.js';import { sceneQueryFor, summarizeWalkMap, walkOptionsFor, createQueryOnlyCache } from '../../scripts/agent-walkmap.js';import { describeMarks, validateMarks } from '../../src/agent-annotate.js';@@ -84,7 +84,7 @@ export function previewHarness() {// The harness loads Manifold from node_modules directly, so the preview's served-file loader is ignored.setManifoldModuleLoader: () => {},needsPhysics, loadPhysicsEngine, physicsEngineLoaded, setPhysicsModuleLoader: () => {},- describeMarks, validateMarks, sceneQueryFor, summarizeWalkMap, walkOptionsFor, createQueryOnlyCache, parseGltf, hasPatternTextures, Uint8Array, atob, sessionProblem, SCENE_STORE_LIMITS, AGENT_SCENE_DEFAULT_LIMITS, describeApplication, framingProblems, exposureProblems, lumaShares, assetCopyKey, recipeAssetNeeds, agentAssetDecodeOptions, withCatalogLimitAdvice,+ describeMarks, validateMarks, sceneQueryFor, summarizeWalkMap, walkOptionsFor, createQueryOnlyCache, parseGltf, hasPatternTextures, Uint8Array, atob, sessionProblem, SCENE_STORE_LIMITS, AGENT_SCENE_DEFAULT_LIMITS, describeApplication, framingProblems, placementProblems, exposureProblems, lumaShares, assetCopyKey, recipeAssetNeeds, agentAssetDecodeOptions, withCatalogLimitAdvice,applyProjection, applyCameraFields, mat4, resolveAgentShadow, agentEnvironmentMap, BRANCH_LIMITS,// Line art needs a real renderer with render passes, so the fault-injected one gets a no-op install.agentSceneModule: name => (name === 'lineArt' ? { installLineArt: renderer => renderer } : name === 'userPass' ? { ...agentSceneModule(name), installUserPasses: renderer => renderer } : agentSceneModule(name)), agentSceneModuleLoaded, createBranchStore, printableLabel,