From 9f458c0c0becea99cd6d7c5dd2b1dbea3c4c4e28 Mon Sep 17 00:00:00 2001 From: eust-w Date: Thu, 25 Jun 2026 05:33:44 +0800 Subject: [PATCH] Prune large scene hover targets --- docs/product-readiness.md | 24 +++++++++++++++--------- scripts/product-readiness-gate.mjs | 7 ++++++- src/i18n.ts | 3 +++ src/main.ts | 16 +++++++++++++++- src/preview/UniversalPreviewer.ts | 18 +++++++++++++++++- src/types.ts | 1 + 6 files changed, 57 insertions(+), 12 deletions(-) diff --git a/docs/product-readiness.md b/docs/product-readiness.md index 51dfe8a..23e67e1 100644 --- a/docs/product-readiness.md +++ b/docs/product-readiness.md @@ -351,13 +351,17 @@ Scene evidence: static-subtree traversal and spin scan when the source has no animated nodes. - Fixed repeated mesh instancing: in large scenes, repeated fixed mesh assets render through shared `InstancedMesh` batches while each manifest object keeps - its own root, body binding, pick target, editable group, and backend sync path. + its own root, body binding, cached bounds, editable group, and backend sync path. This reduces WebGL draw work for shelf/product inventory without turning the objects into frontend-only decorations. - Bounds-only picking: hover and drag picking now ray-test cached `Box3` targets directly instead of adding one invisible Three.js mesh per object. Fixed instanced objects keep detached data roots for backend sync, while only the shared instanced batches enter the render scene. +- Hover target pruning: large scenes keep all object bounds for camera fitting, + diagnostics, drag binding, and backend sync, but the high-frequency hover list + excludes repeated fixed inventory products while preserving shelf fixtures, + robots, and editable dynamic objects for user feedback. - Cached hover/drag bounds: hover focus, hover outline, and drag highlight use the existing pick target bounds through a `Box3Helper` when present, so hovering or dragging a large shelf/product group does not call @@ -404,13 +408,13 @@ Scene evidence: Bundle evidence: - JavaScript chunks: `4` -- App entry chunk: `196.18 kB raw / 50.91 kB gzip` +- App entry chunk: `196.93 kB raw / 51.13 kB gzip` - Largest JavaScript gzip chunk: `140.96 KiB / 170.00 KiB` -- Total JavaScript gzip: `214.53 KiB / 230.00 KiB` +- Total JavaScript gzip: `214.75 KiB / 230.00 KiB` - Large-scene performance mode: `large-scene`, target `45 fps`, actual idle render rate `0.9 fps`, DPR cap observed at `1.00` in release gate, `preserveDrawingBuffer=false`, `1` explicit readback render, shadows - `off`, hover picking throttled to `32ms`, `29` empty frames + `off`, hover picking throttled to `32ms`, `27` empty frames skipped, `703` static visual nodes frozen, `59` remaining mesh clones using pre-frozen source state, `627` repeated spin scans skipped, `568` repeated fixed mesh objects rendered as `16` instanced batches with `16` instanced @@ -419,13 +423,14 @@ Bundle evidence: large scene, `636` cached object bounds, `627` fast pick-target bounds from `51` cached source bounds, real hover proof `hoverProxy 1` with cached bounds and `fallback 0`, with `0` camera-fit traversals, `1/84` - scene root batch insertion under the computed `84` root cap, `344` + scene root batch insertion under the computed `84` root cap, `335` partial render frames suppressed during the primary load, `26` browser event-loop yields during scene construction, active state payload `34/602` with `3` reduced frames and `4` incremental body-map merges, UI physics-profile cache `30/3` hit/miss, UI builder-profile cache `33/1` - hit/miss, `636` cached pick targets used for bounds-only ray tests, + hit/miss, `88/636` hover targets over cached bounds used for bounds-only ray + tests, and a stable paused backend state cache reported `manual roots 636 updates 67` with `state apply 0/skip 67`. - Mesh cache lifecycle evidence: the Scene Builder compose switch reported @@ -466,8 +471,9 @@ Bundle evidence: shared GPU batches instead of one cloned render tree per item. - Hover bounds gate: `browser-hover-proxy-bounds` moves the mouse over the real canvas and now checks both `hoverProxy` and cached hover bounds increase while - `fallback=0`, proving hover highlight uses cached bounds instead of traversing - the visual root. + `fallback=0`, proving hover highlight uses the pruned cached bounds list + instead of traversing the visual root. The current proof hits the shelf + fixture at `point=0.35,0.50` with `固定物理体: geom_64`. - Scene-load batching gate: `browser-large-scene-performance-mode` now checks `scene batches 1/84`, `maxSceneRoots=84`, and `yields 26`, proving fixed instanced object roots stay detached from the Three scene while object @@ -505,7 +511,7 @@ Control evidence: `acceptanceLatency=0 ms / 11-0-0`, `binding=635/636; 4/568`, `builderPhysics=已添加物体 4: 后端动态 4 / 仅视觉 0`, - `renderPerformance=large-scene; target 45 fps; actual 0.9 fps; dpr 1.00; buffer preserved false; readback renders 1; shadows off; skipped 29; hover 32ms; frozen 703 prefrozen 59 spinSkip 627; instanced 568/16/16 matrices 568; manual roots 636 updates 67; primitive geometries 7; mesh cache 51 sources 24/51 hit/miss retained 51g/17m; bounds cache 636 fast 627 source 51 hoverProxy 1 cached 1/fallback 0 camera traversals 0; scene batches 1/84 suppressed 344 yields 26; state payload 34/602 reduced 3 incremental 4; ui cache physics 30/3 builder 33/1; pick targets 636; state apply 0/skip 67; unchanged frames 1; released 0g/0m/0t`. + `renderPerformance=large-scene; target 45 fps; actual 0.9 fps; dpr 1.00; buffer preserved false; readback renders 1; shadows off; skipped 27; hover 32ms; frozen 703 prefrozen 59 spinSkip 627; instanced 568/16/16 matrices 568; manual roots 636 updates 67; primitive geometries 7; mesh cache 51 sources 24/51 hit/miss retained 51g/17m; bounds cache 636 fast 627 source 51 hoverProxy 1 cached 1/fallback 0 camera traversals 0; scene batches 1/84 suppressed 335 yields 26; state payload 34/602 reduced 3 incremental 4; ui cache physics 30/3 builder 33/1; pick targets 88/636; state apply 0/skip 67; unchanged frames 1; released 0g/0m/0t`. - Evidence screenshot artifacts: `builder page; share page; import page; visual-only boundary canvas; desktop canvas; debug PNG; mobile canvas` - Evidence export artifacts: diff --git a/scripts/product-readiness-gate.mjs b/scripts/product-readiness-gate.mjs index dc28dc8..b9e8ab5 100644 --- a/scripts/product-readiness-gate.mjs +++ b/scripts/product-readiness-gate.mjs @@ -657,6 +657,7 @@ async function readBrowserStats(page) { manualMatrixUpdateCount: numberData("manualMatrixUpdateCount"), primitiveGeometryCount: numberData("primitiveGeometryCount"), pickProxyCount: numberData("pickProxyCount"), + hoverPickTargetCount: numberData("hoverPickTargetCount"), appliedBodyStateCount: numberData("appliedBodyStateCount"), skippedBodyStateCount: numberData("skippedBodyStateCount"), unchangedFrameCount: numberData("unchangedFrameCount"), @@ -1645,6 +1646,7 @@ async function verifyBrowser() { - (renderPerformance.instancedMeshObjectCount ?? 0) + (renderPerformance.instancedMeshBatchCount ?? 0), ); + const maxHoverPickTargets = Math.max(100, Math.ceil(objectCount * 0.18)); check( "browser-large-scene-performance-mode", renderPerformance.largeSceneMode === true @@ -1683,9 +1685,12 @@ async function verifyBrowser() { && (renderPerformance.objectPhysicsProfileCacheHitCount ?? 0) > 0 && (renderPerformance.builderPhysicsProfileCacheHitCount ?? 0) > 0 && (renderPerformance.pickProxyCount ?? 0) >= objectCount + && (renderPerformance.hoverPickTargetCount ?? Number.POSITIVE_INFINITY) > 0 + && (renderPerformance.hoverPickTargetCount ?? Number.POSITIVE_INFINITY) < (renderPerformance.pickProxyCount ?? 0) + && (renderPerformance.hoverPickTargetCount ?? Number.POSITIVE_INFINITY) <= maxHoverPickTargets && (renderPerformance.skippedBodyStateCount ?? 0) > 0 && desktopStats.diagnostics.renderPerformance.includes("large-scene"), - `mode=${renderPerformance.largeSceneMode} fps=${renderPerformance.targetRenderFps ?? "-"} dpr=${renderPerformance.renderPixelRatio ?? "-"} buffer=${renderPerformance.preserveDrawingBufferEnabled} readback=${renderPerformance.readbackRenderCount ?? "-"} shadows=${renderPerformance.shadowsEnabled} hover=${renderPerformance.hoverPickIntervalMs ?? "-"} skipped=${renderPerformance.renderSkipCount ?? "-"} frozen=${renderPerformance.frozenStaticObjectCount ?? "-"} prefrozen=${renderPerformance.preFrozenMeshCloneCount ?? "-"} spinSkip=${renderPerformance.spinningScanSkippedCount ?? "-"} instanced=${renderPerformance.instancedMeshObjectCount ?? "-"}/${renderPerformance.instancedMeshBatchCount ?? "-"}/${renderPerformance.instancedMeshDrawCount ?? "-"} matrices=${renderPerformance.instancedMeshMatrixUpdateCount ?? "-"} manualRoots=${renderPerformance.manualMatrixRootCount ?? "-"} manualUpdates=${renderPerformance.manualMatrixUpdateCount ?? "-"} primitiveGeometries=${renderPerformance.primitiveGeometryCount ?? "-"} meshCache=${renderPerformance.meshCacheSourceCount ?? "-"} hit=${renderPerformance.meshCacheHitCount ?? "-"} miss=${renderPerformance.meshCacheMissCount ?? "-"} retained=${renderPerformance.retainedMeshGeometryCount ?? "-"}g/${renderPerformance.retainedMeshMaterialCount ?? "-"}m bounds=${renderPerformance.sceneObjectBoundsCount ?? "-"} fast=${renderPerformance.fastPickProxyBoundsCount ?? "-"} source=${renderPerformance.meshSourceBoundsCount ?? "-"} hoverProxy=${renderPerformance.hoverProxyBoundsHitCount ?? "-"} cached=${renderPerformance.hoverCachedBoundsHitCount ?? "-"}/fallback=${renderPerformance.hoverRootBoundsFallbackCount ?? "-"} cameraTraversals=${renderPerformance.cameraFitTraversalCount ?? "-"} sceneBatches=${renderPerformance.sceneRootBatchCount ?? "-"}/${renderPerformance.batchedSceneRootCount ?? "-"} maxSceneRoots=${maxInstancedSceneRoots} suppressed=${renderPerformance.sceneLoadSuppressedRenderCount ?? "-"} yields=${renderPerformance.sceneBuildYieldCount ?? "-"} statePayload=${renderPerformance.statePayloadBodyCount ?? "-"}/${renderPerformance.mergedBodyStateCount ?? "-"} reduced=${renderPerformance.reducedStateFrameCount ?? "-"} incremental=${renderPerformance.incrementalBodyMergeCount ?? "-"} uiCache=physics ${renderPerformance.objectPhysicsProfileCacheHitCount ?? "-"}/${renderPerformance.objectPhysicsProfileCacheMissCount ?? "-"} builder ${renderPerformance.builderPhysicsProfileCacheHitCount ?? "-"}/${renderPerformance.builderPhysicsProfileCacheMissCount ?? "-"} pickTargets=${renderPerformance.pickProxyCount ?? "-"} stateApply=${renderPerformance.appliedBodyStateCount ?? "-"}/skip=${renderPerformance.skippedBodyStateCount ?? "-"} unchanged=${renderPerformance.unchangedFrameCount ?? "-"} released=${renderPerformance.releasedGeometryCount ?? "-"}g/${renderPerformance.releasedMaterialCount ?? "-"}m/${renderPerformance.releasedTextureCount ?? "-"}t; ${desktopStats.diagnostics.renderPerformance}`, + `mode=${renderPerformance.largeSceneMode} fps=${renderPerformance.targetRenderFps ?? "-"} dpr=${renderPerformance.renderPixelRatio ?? "-"} buffer=${renderPerformance.preserveDrawingBufferEnabled} readback=${renderPerformance.readbackRenderCount ?? "-"} shadows=${renderPerformance.shadowsEnabled} hover=${renderPerformance.hoverPickIntervalMs ?? "-"} skipped=${renderPerformance.renderSkipCount ?? "-"} frozen=${renderPerformance.frozenStaticObjectCount ?? "-"} prefrozen=${renderPerformance.preFrozenMeshCloneCount ?? "-"} spinSkip=${renderPerformance.spinningScanSkippedCount ?? "-"} instanced=${renderPerformance.instancedMeshObjectCount ?? "-"}/${renderPerformance.instancedMeshBatchCount ?? "-"}/${renderPerformance.instancedMeshDrawCount ?? "-"} matrices=${renderPerformance.instancedMeshMatrixUpdateCount ?? "-"} manualRoots=${renderPerformance.manualMatrixRootCount ?? "-"} manualUpdates=${renderPerformance.manualMatrixUpdateCount ?? "-"} primitiveGeometries=${renderPerformance.primitiveGeometryCount ?? "-"} meshCache=${renderPerformance.meshCacheSourceCount ?? "-"} hit=${renderPerformance.meshCacheHitCount ?? "-"} miss=${renderPerformance.meshCacheMissCount ?? "-"} retained=${renderPerformance.retainedMeshGeometryCount ?? "-"}g/${renderPerformance.retainedMeshMaterialCount ?? "-"}m bounds=${renderPerformance.sceneObjectBoundsCount ?? "-"} fast=${renderPerformance.fastPickProxyBoundsCount ?? "-"} source=${renderPerformance.meshSourceBoundsCount ?? "-"} hoverProxy=${renderPerformance.hoverProxyBoundsHitCount ?? "-"} cached=${renderPerformance.hoverCachedBoundsHitCount ?? "-"}/fallback=${renderPerformance.hoverRootBoundsFallbackCount ?? "-"} cameraTraversals=${renderPerformance.cameraFitTraversalCount ?? "-"} sceneBatches=${renderPerformance.sceneRootBatchCount ?? "-"}/${renderPerformance.batchedSceneRootCount ?? "-"} maxSceneRoots=${maxInstancedSceneRoots} suppressed=${renderPerformance.sceneLoadSuppressedRenderCount ?? "-"} yields=${renderPerformance.sceneBuildYieldCount ?? "-"} statePayload=${renderPerformance.statePayloadBodyCount ?? "-"}/${renderPerformance.mergedBodyStateCount ?? "-"} reduced=${renderPerformance.reducedStateFrameCount ?? "-"} incremental=${renderPerformance.incrementalBodyMergeCount ?? "-"} uiCache=physics ${renderPerformance.objectPhysicsProfileCacheHitCount ?? "-"}/${renderPerformance.objectPhysicsProfileCacheMissCount ?? "-"} builder ${renderPerformance.builderPhysicsProfileCacheHitCount ?? "-"}/${renderPerformance.builderPhysicsProfileCacheMissCount ?? "-"} pickTargets=${renderPerformance.hoverPickTargetCount ?? "-"}/${renderPerformance.pickProxyCount ?? "-"} hoverBudget=${maxHoverPickTargets} stateApply=${renderPerformance.appliedBodyStateCount ?? "-"}/skip=${renderPerformance.skippedBodyStateCount ?? "-"} unchanged=${renderPerformance.unchangedFrameCount ?? "-"} released=${renderPerformance.releasedGeometryCount ?? "-"}g/${renderPerformance.releasedMaterialCount ?? "-"}m/${renderPerformance.releasedTextureCount ?? "-"}t; ${desktopStats.diagnostics.renderPerformance}`, ); check( "browser-debug-capture-png", diff --git a/src/i18n.ts b/src/i18n.ts index a1d391d..bdea6ed 100644 --- a/src/i18n.ts +++ b/src/i18n.ts @@ -378,6 +378,7 @@ export type MessageKey = | "preset.scene.frankaCube" | "preset.scene.customUpload" | "preset.robot.none" + | "preset.robot.sceneBuiltInG1" | "preset.robot.g1" | "preset.robot.go2" | "preset.robot.franka" @@ -768,6 +769,7 @@ const messages: Record = { "preset.scene.frankaCube": "Franka + 方块物理场景", "preset.scene.customUpload": "上传场景", "preset.robot.none": "无机器人", + "preset.robot.sceneBuiltInG1": "使用场景内置 G1", "preset.robot.g1": "Unitree G1 人形机器人", "preset.robot.go2": "Unitree Go2 四足机器人", "preset.robot.franka": "Franka 单臂", @@ -1151,6 +1153,7 @@ const messages: Record = { "preset.scene.frankaCube": "Franka + cube physics", "preset.scene.customUpload": "Uploaded scene", "preset.robot.none": "No robot", + "preset.robot.sceneBuiltInG1": "Use scene built-in G1", "preset.robot.g1": "Unitree G1 humanoid", "preset.robot.go2": "Unitree Go2 quadruped", "preset.robot.franka": "Franka arm", diff --git a/src/main.ts b/src/main.ts index f21f691..ffd8be7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -182,6 +182,7 @@ interface RuntimeDiagnostics { manualMatrixUpdateCount: number; primitiveGeometryCount: number; pickProxyCount: number; + hoverPickTargetCount: number; appliedBodyStateCount: number; skippedBodyStateCount: number; unchangedFrameCount: number; @@ -1833,6 +1834,7 @@ function renderBuilderOptions(resetSelection = true): void { } else { sceneSelect.value = sceneValue; } + applyContextualRobotLabels(sceneSelect.value); robotSelect.value = robotValue; propSelect.value = propValue || (allPropPresets()[0]?.id ?? ""); if (resetSelection) { @@ -1856,6 +1858,16 @@ function fillPresetSelect(selector: string, presets: Array<{ id: string; label: } } +function applyContextualRobotLabels(sceneId: string): void { + const noneOption = document.querySelector("#builder-robot option[value='none']"); + if (!noneOption) { + return; + } + noneOption.textContent = sceneId === "g1-store-blocks-physics" + ? t("preset.robot.sceneBuiltInG1") + : t("preset.robot.none"); +} + function renderTemplateGrid(): void { const container = document.querySelector("#template-grid"); if (!container) { @@ -2515,6 +2527,7 @@ function currentRuntimeDiagnostics( manualMatrixUpdateCount: stats.manualMatrixUpdateCount, primitiveGeometryCount: stats.primitiveGeometryCount, pickProxyCount: stats.pickProxyCount, + hoverPickTargetCount: stats.hoverPickTargetCount, appliedBodyStateCount: stats.appliedBodyStateCount, skippedBodyStateCount: stats.skippedBodyStateCount, unchangedFrameCount: stats.unchangedFrameCount, @@ -2603,7 +2616,7 @@ function currentDiagnosticsReport(): string { function renderPerformanceLabel(stats: RuntimeDiagnostics["stats"]): string { const mode = stats.largeSceneMode ? "large-scene" : "standard"; const shadows = stats.shadowsEnabled ? "shadows on" : "shadows off"; - return `${mode}; target ${stats.targetRenderFps} fps; actual ${stats.actualRenderFps.toFixed(1)} fps; dpr ${stats.renderPixelRatio.toFixed(2)}; buffer preserved ${stats.preserveDrawingBufferEnabled}; readback renders ${stats.readbackRenderCount}; ${shadows}; skipped ${stats.renderSkipCount}; hover ${stats.hoverPickIntervalMs}ms; frozen ${stats.frozenStaticObjectCount} prefrozen ${stats.preFrozenMeshCloneCount} spinSkip ${stats.spinningScanSkippedCount}; instanced ${stats.instancedMeshObjectCount}/${stats.instancedMeshBatchCount}/${stats.instancedMeshDrawCount} matrices ${stats.instancedMeshMatrixUpdateCount}; manual roots ${stats.manualMatrixRootCount} updates ${stats.manualMatrixUpdateCount}; primitive geometries ${stats.primitiveGeometryCount}; mesh cache ${stats.meshCacheSourceCount} sources ${stats.meshCacheHitCount}/${stats.meshCacheMissCount} hit/miss retained ${stats.retainedMeshGeometryCount}g/${stats.retainedMeshMaterialCount}m; bounds cache ${stats.sceneObjectBoundsCount} fast ${stats.fastPickProxyBoundsCount} source ${stats.meshSourceBoundsCount} hoverProxy ${stats.hoverProxyBoundsHitCount} cached ${stats.hoverCachedBoundsHitCount}/fallback ${stats.hoverRootBoundsFallbackCount} camera traversals ${stats.cameraFitTraversalCount}; scene batches ${stats.sceneRootBatchCount}/${stats.batchedSceneRootCount} suppressed ${stats.sceneLoadSuppressedRenderCount} yields ${stats.sceneBuildYieldCount}; state payload ${stats.statePayloadBodyCount}/${stats.mergedBodyStateCount} reduced ${stats.reducedStateFrameCount} incremental ${stats.incrementalBodyMergeCount}; ui cache physics ${stats.objectPhysicsProfileCacheHitCount}/${stats.objectPhysicsProfileCacheMissCount} builder ${stats.builderPhysicsProfileCacheHitCount}/${stats.builderPhysicsProfileCacheMissCount}; pick targets ${stats.pickProxyCount}; state apply ${stats.appliedBodyStateCount}/skip ${stats.skippedBodyStateCount}; unchanged frames ${stats.unchangedFrameCount}; released ${stats.releasedGeometryCount}g/${stats.releasedMaterialCount}m/${stats.releasedTextureCount}t`; + return `${mode}; target ${stats.targetRenderFps} fps; actual ${stats.actualRenderFps.toFixed(1)} fps; dpr ${stats.renderPixelRatio.toFixed(2)}; buffer preserved ${stats.preserveDrawingBufferEnabled}; readback renders ${stats.readbackRenderCount}; ${shadows}; skipped ${stats.renderSkipCount}; hover ${stats.hoverPickIntervalMs}ms; frozen ${stats.frozenStaticObjectCount} prefrozen ${stats.preFrozenMeshCloneCount} spinSkip ${stats.spinningScanSkippedCount}; instanced ${stats.instancedMeshObjectCount}/${stats.instancedMeshBatchCount}/${stats.instancedMeshDrawCount} matrices ${stats.instancedMeshMatrixUpdateCount}; manual roots ${stats.manualMatrixRootCount} updates ${stats.manualMatrixUpdateCount}; primitive geometries ${stats.primitiveGeometryCount}; mesh cache ${stats.meshCacheSourceCount} sources ${stats.meshCacheHitCount}/${stats.meshCacheMissCount} hit/miss retained ${stats.retainedMeshGeometryCount}g/${stats.retainedMeshMaterialCount}m; bounds cache ${stats.sceneObjectBoundsCount} fast ${stats.fastPickProxyBoundsCount} source ${stats.meshSourceBoundsCount} hoverProxy ${stats.hoverProxyBoundsHitCount} cached ${stats.hoverCachedBoundsHitCount}/fallback ${stats.hoverRootBoundsFallbackCount} camera traversals ${stats.cameraFitTraversalCount}; scene batches ${stats.sceneRootBatchCount}/${stats.batchedSceneRootCount} suppressed ${stats.sceneLoadSuppressedRenderCount} yields ${stats.sceneBuildYieldCount}; state payload ${stats.statePayloadBodyCount}/${stats.mergedBodyStateCount} reduced ${stats.reducedStateFrameCount} incremental ${stats.incrementalBodyMergeCount}; ui cache physics ${stats.objectPhysicsProfileCacheHitCount}/${stats.objectPhysicsProfileCacheMissCount} builder ${stats.builderPhysicsProfileCacheHitCount}/${stats.builderPhysicsProfileCacheMissCount}; pick targets ${stats.hoverPickTargetCount}/${stats.pickProxyCount}; state apply ${stats.appliedBodyStateCount}/skip ${stats.skippedBodyStateCount}; unchanged frames ${stats.unchangedFrameCount}; released ${stats.releasedGeometryCount}g/${stats.releasedMaterialCount}m/${stats.releasedTextureCount}t`; } function renderDiagnosticsPanel(diagnostics = currentRuntimeDiagnostics()): void { @@ -2638,6 +2651,7 @@ function renderDiagnosticsPanel(diagnostics = currentRuntimeDiagnostics()): void data.manualMatrixUpdateCount = String(diagnostics.stats.manualMatrixUpdateCount); data.primitiveGeometryCount = String(diagnostics.stats.primitiveGeometryCount); data.pickProxyCount = String(diagnostics.stats.pickProxyCount); + data.hoverPickTargetCount = String(diagnostics.stats.hoverPickTargetCount); data.appliedBodyStateCount = String(diagnostics.stats.appliedBodyStateCount); data.skippedBodyStateCount = String(diagnostics.stats.skippedBodyStateCount); data.unchangedFrameCount = String(diagnostics.stats.unchangedFrameCount); diff --git a/src/preview/UniversalPreviewer.ts b/src/preview/UniversalPreviewer.ts index 256984e..286e0ba 100644 --- a/src/preview/UniversalPreviewer.ts +++ b/src/preview/UniversalPreviewer.ts @@ -481,6 +481,7 @@ export class UniversalPreviewer { manualMatrixUpdateCount: this.manualMatrixUpdateCount, primitiveGeometryCount: this.primitiveGeometryCache.size, pickProxyCount: this.pickBoundsById.size, + hoverPickTargetCount: this.pickTargets.length, appliedBodyStateCount: this.appliedBodyStateCount, skippedBodyStateCount: this.skippedBodyStateCount, unchangedFrameCount: this.unchangedFrameCount, @@ -1974,7 +1975,9 @@ export class UniversalPreviewer { this.sceneObjectBounds.union(pickTarget.worldBounds); this.sceneObjectBoundsCount += 1; this.pickBoundsById.set(object.id, pickTarget); - this.pickTargets.push(pickTarget); + if (this.shouldIncludeHoverPickTarget(object, Boolean(instancedVisual))) { + this.pickTargets.push(pickTarget); + } } this.freezeObjectRootMatrix(root); if (!instancedVisual) { @@ -2072,6 +2075,19 @@ export class UniversalPreviewer { this.editablePickTargets.push(...targets.values()); } + private shouldIncludeHoverPickTarget(object: PreviewObject, isInstancedVisual: boolean): boolean { + if (object.visible === false) { + return false; + } + if (!this.largeSceneMode || !isInstancedVisual || object.physics !== "fixed") { + return true; + } + const searchableName = `${object.body ?? ""} ${object.name ?? ""} ${object.id} ${ + object.geometry.kind === "mesh" ? object.geometry.url : "" + }`.toLowerCase(); + return searchableName.includes("shelf"); + } + private registerSpinningObjects(root: THREE.Object3D, visual?: THREE.Object3D): void { if (visual?.userData.hasSpinningObjects === false) { this.spinningScanSkippedCount += 1; diff --git a/src/types.ts b/src/types.ts index 466b5da..f4576b3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -215,6 +215,7 @@ export interface RendererStats { manualMatrixUpdateCount: number; primitiveGeometryCount: number; pickProxyCount: number; + hoverPickTargetCount: number; appliedBodyStateCount: number; skippedBodyStateCount: number; unchangedFrameCount: number;