Reuse pick bounds scratch objects
This commit is contained in:
parent
4698818498
commit
d2bb640957
@ -371,6 +371,9 @@ Scene evidence:
|
||||
hovering or dragging a large shelf/product group does not call
|
||||
`BoxHelper.setFromObject` on the full visual subtree and does not allocate
|
||||
cloned focus vectors every animation frame.
|
||||
- Scratch bounds transforms: pick-target bounds construction reuses `Box3`,
|
||||
`Matrix4`, and corner `Vector3` scratch objects for cached mesh bounds instead
|
||||
of allocating transformed bounds for every repeated shelf/product object.
|
||||
- Scene-load render gating: large scene roots are batched into one Three.js
|
||||
insertion after object preparation, and the render loop skips partial scene
|
||||
frames while the batch is still loading.
|
||||
@ -416,13 +419,13 @@ Scene evidence:
|
||||
Bundle evidence:
|
||||
|
||||
- JavaScript chunks: `4`
|
||||
- App entry chunk: `199.62 kB raw / 51.74 kB gzip`
|
||||
- App entry chunk: `200.56 kB raw / 51.84 kB gzip`
|
||||
- Largest JavaScript gzip chunk: `140.96 KiB / 170.00 KiB`
|
||||
- Total JavaScript gzip: `215.35 KiB / 230.00 KiB`
|
||||
- Total JavaScript gzip: `215.45 KiB / 230.00 KiB`
|
||||
- Large-scene performance mode: `large-scene`, target `45 fps`,
|
||||
actual idle render rate `0.8 fps`, DPR cap observed at `1.00` in release
|
||||
gate, `preserveDrawingBuffer=false`, `1` explicit readback render, shadows
|
||||
`off`, hover picking throttled to `32ms`, `41` empty frames
|
||||
`off`, hover picking throttled to `32ms`, `36` 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
|
||||
@ -432,14 +435,15 @@ Bundle evidence:
|
||||
primary 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, `342`
|
||||
scene root batch insertion under the computed `84` root cap, `347`
|
||||
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 `31/3` hit/miss, UI builder-profile cache `34/1`
|
||||
hit/miss, UI text write gating `108/464` write/skip, text selector cache
|
||||
`526/46` hit/miss, diagnostics panel throttling `20/7` render/skip, `88/636`
|
||||
`526/46` hit/miss, scratch bounds transforms `1263`, diagnostics panel
|
||||
throttling `20/7` render/skip, `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`.
|
||||
@ -473,8 +477,9 @@ Bundle evidence:
|
||||
- Camera-fit traversal gate: `browser-large-scene-performance-mode` now checks
|
||||
`bounds cache 636` and `camera traversals 0`.
|
||||
- Pick-proxy bounds gate: `browser-large-scene-performance-mode` now checks
|
||||
`fast=627` and `source=51`, proving repeated mesh pick bounds are served from
|
||||
cached source bounds.
|
||||
`fast=627`, `scratch=1263`, and `source=51`, proving repeated mesh pick bounds
|
||||
are served from cached source bounds and transformed through the reduced-
|
||||
allocation scratch path.
|
||||
- Pre-frozen mesh clone gate: `browser-large-scene-performance-mode` now checks
|
||||
`prefrozen + instanced >= repeated mesh threshold` and `spinSkip=627`,
|
||||
proving repeated mesh assets avoid re-traversing static visual subtrees and
|
||||
@ -499,34 +504,34 @@ Bundle evidence:
|
||||
|
||||
Control evidence:
|
||||
|
||||
- Cold compose endpoint: `266ms`, `4/4` composed object bodies synced.
|
||||
- Repeated compose cache: `55ms`, `cached=true`, same compose key.
|
||||
- Cold compose endpoint: `276ms`, `4/4` composed object bodies synced.
|
||||
- Repeated compose cache: `60ms`, `cached=true`, same compose key.
|
||||
- Active state endpoint: full `/state` returned `602` bodies; active
|
||||
`/state?bodies=active` returned `34` bodies in `60ms`, filtered `568` fixed
|
||||
`/state?bodies=active` returned `34` bodies in `58ms`, filtered `568` fixed
|
||||
bodies, and retained `4/4` composed dynamic bodies.
|
||||
- Scene Builder UI compose: representative run `4230ms` end to end with real
|
||||
- Scene Builder UI compose: representative run `4229ms` end to end with real
|
||||
backend diagnostics.
|
||||
- Share-link restore: representative full browser restore `7360ms`.
|
||||
- Config import restore: representative full browser restore `6728ms`.
|
||||
- Composed object body edit: `58ms`.
|
||||
- Share-link restore: representative full browser restore `7293ms`.
|
||||
- Config import restore: representative full browser restore `7748ms`.
|
||||
- Composed object body edit: `41ms`.
|
||||
- Fixed inventory edit rejection: `56ms`.
|
||||
- Dynamic composed object drop: `0.48012m`.
|
||||
- Static shelf anchor stability: `max drift 0.00000m` after a 2500 ms resume
|
||||
window.
|
||||
- Resume backend state: `56ms paused=false`
|
||||
- Resume visible UI state: `57ms`
|
||||
- Pause backend state: `47ms paused=true`
|
||||
- Pause visible UI state: `48ms`
|
||||
- Resume backend state: `58ms paused=false`
|
||||
- Resume visible UI state: `60ms`
|
||||
- Pause backend state: `50ms paused=true`
|
||||
- Pause visible UI state: `39ms`
|
||||
- Desktop acceptance wait: `1243ms` total, product telemetry `0ms`
|
||||
- Mobile acceptance wait: `277ms` total, product telemetry `0ms`
|
||||
- Runtime diagnostics panel:
|
||||
`state=http://127.0.0.1:18090/state`,
|
||||
`control=http://127.0.0.1:18090/control`,
|
||||
`latency=响应 48 ms / 确认 48 ms / 可见 48 ms`,
|
||||
`latency=响应 38 ms / 确认 38 ms / 可见 39 ms`,
|
||||
`acceptanceLatency=0 ms / 11-0-0`,
|
||||
`binding=635/636; 4/568`,
|
||||
`builderPhysics=已添加物体 4: 后端动态 4 / 仅视觉 0`,
|
||||
`renderPerformance=large-scene; target 45 fps; actual 0.8 fps; dpr 1.00; buffer preserved false; readback renders 1; shadows off; skipped 41; hover 32ms; frozen 703 prefrozen 59 spinSkip 627; instanced 568/16/16 matrices 568 cull 16 static 16; 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 342 yields 26; state payload 34/602 reduced 3 incremental 4; ui cache physics 31/3 builder 34/1 text 106/454 selector 514/46 diagnostics 20/7; pick targets 88/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 36; hover 32ms; frozen 703 prefrozen 59 spinSkip 627; instanced 568/16/16 matrices 568 cull 16 static 16; manual roots 636 updates 67; primitive geometries 7; mesh cache 51 sources 24/51 hit/miss retained 51g/17m; bounds cache 636 fast 627 scratch 1263 source 51 hoverProxy 1 cached 1/fallback 0 camera traversals 0; scene batches 1/84 suppressed 347 yields 26; state payload 34/602 reduced 3 incremental 4; ui cache physics 31/3 builder 34/1 text 112/494 selector 560/46 diagnostics 21/6; 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:
|
||||
|
||||
@ -673,6 +673,7 @@ async function readBrowserStats(page) {
|
||||
retainedMeshMaterialCount: numberData("retainedMeshMaterialCount"),
|
||||
sceneObjectBoundsCount: numberData("sceneObjectBoundsCount"),
|
||||
fastPickProxyBoundsCount: numberData("fastPickProxyBoundsCount"),
|
||||
pickBoundsScratchTransformCount: numberData("pickBoundsScratchTransformCount"),
|
||||
meshSourceBoundsCount: numberData("meshSourceBoundsCount"),
|
||||
hoverProxyBoundsHitCount: numberData("hoverProxyBoundsHitCount"),
|
||||
hoverCachedBoundsHitCount: numberData("hoverCachedBoundsHitCount"),
|
||||
@ -1682,6 +1683,7 @@ async function verifyBrowser() {
|
||||
&& (renderPerformance.retainedMeshGeometryCount ?? 0) > 0
|
||||
&& (renderPerformance.sceneObjectBoundsCount ?? 0) >= objectCount
|
||||
&& (renderPerformance.fastPickProxyBoundsCount ?? 0) >= thresholds.minMeshes
|
||||
&& (renderPerformance.pickBoundsScratchTransformCount ?? 0) >= (renderPerformance.fastPickProxyBoundsCount ?? 0) * 2
|
||||
&& (renderPerformance.meshSourceBoundsCount ?? 0) > 0
|
||||
&& (renderPerformance.hoverCachedBoundsHitCount ?? 0) > 0
|
||||
&& (renderPerformance.cameraFitTraversalCount ?? Number.POSITIVE_INFINITY) === 0
|
||||
@ -1705,7 +1707,7 @@ async function verifyBrowser() {
|
||||
&& (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 ?? "-"} cull=${renderPerformance.instancedMeshFrustumCulledCount ?? "-"} static=${renderPerformance.instancedMeshStaticMatrixCount ?? "-"} 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 ?? "-"} text ${renderPerformance.textWriteCount ?? "-"}/${renderPerformance.textWriteSkipCount ?? "-"} selector ${renderPerformance.textSelectorCacheHitCount ?? "-"}/${renderPerformance.textSelectorCacheMissCount ?? "-"} diagnostics ${renderPerformance.diagnosticsPanelRenderCount ?? "-"}/${renderPerformance.diagnosticsPanelSkipCount ?? "-"} 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}`,
|
||||
`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 ?? "-"} cull=${renderPerformance.instancedMeshFrustumCulledCount ?? "-"} static=${renderPerformance.instancedMeshStaticMatrixCount ?? "-"} 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 ?? "-"} scratch=${renderPerformance.pickBoundsScratchTransformCount ?? "-"} 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 ?? "-"} text ${renderPerformance.textWriteCount ?? "-"}/${renderPerformance.textWriteSkipCount ?? "-"} selector ${renderPerformance.textSelectorCacheHitCount ?? "-"}/${renderPerformance.textSelectorCacheMissCount ?? "-"} diagnostics ${renderPerformance.diagnosticsPanelRenderCount ?? "-"}/${renderPerformance.diagnosticsPanelSkipCount ?? "-"} 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",
|
||||
|
||||
@ -199,6 +199,7 @@ interface RuntimeDiagnostics {
|
||||
retainedMeshMaterialCount: number;
|
||||
sceneObjectBoundsCount: number;
|
||||
fastPickProxyBoundsCount: number;
|
||||
pickBoundsScratchTransformCount: number;
|
||||
meshSourceBoundsCount: number;
|
||||
hoverProxyBoundsHitCount: number;
|
||||
hoverCachedBoundsHitCount: number;
|
||||
@ -2580,6 +2581,7 @@ function currentRuntimeDiagnostics(
|
||||
retainedMeshMaterialCount: stats.retainedMeshMaterialCount,
|
||||
sceneObjectBoundsCount: stats.sceneObjectBoundsCount,
|
||||
fastPickProxyBoundsCount: stats.fastPickProxyBoundsCount,
|
||||
pickBoundsScratchTransformCount: stats.pickBoundsScratchTransformCount,
|
||||
meshSourceBoundsCount: stats.meshSourceBoundsCount,
|
||||
hoverProxyBoundsHitCount: stats.hoverProxyBoundsHitCount,
|
||||
hoverCachedBoundsHitCount: stats.hoverCachedBoundsHitCount,
|
||||
@ -2661,7 +2663,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} cull ${stats.instancedMeshFrustumCulledCount} static ${stats.instancedMeshStaticMatrixCount}; 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} text ${stats.textWriteCount}/${stats.textWriteSkipCount} selector ${stats.textSelectorCacheHitCount}/${stats.textSelectorCacheMissCount} diagnostics ${stats.diagnosticsPanelRenderCount}/${stats.diagnosticsPanelSkipCount}; 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`;
|
||||
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} cull ${stats.instancedMeshFrustumCulledCount} static ${stats.instancedMeshStaticMatrixCount}; 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} scratch ${stats.pickBoundsScratchTransformCount} 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} text ${stats.textWriteCount}/${stats.textWriteSkipCount} selector ${stats.textSelectorCacheHitCount}/${stats.textSelectorCacheMissCount} diagnostics ${stats.diagnosticsPanelRenderCount}/${stats.diagnosticsPanelSkipCount}; 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(
|
||||
@ -2729,6 +2731,7 @@ function renderDiagnosticsPanel(
|
||||
data.retainedMeshMaterialCount = String(diagnostics.stats.retainedMeshMaterialCount);
|
||||
data.sceneObjectBoundsCount = String(diagnostics.stats.sceneObjectBoundsCount);
|
||||
data.fastPickProxyBoundsCount = String(diagnostics.stats.fastPickProxyBoundsCount);
|
||||
data.pickBoundsScratchTransformCount = String(diagnostics.stats.pickBoundsScratchTransformCount);
|
||||
data.meshSourceBoundsCount = String(diagnostics.stats.meshSourceBoundsCount);
|
||||
data.hoverProxyBoundsHitCount = String(diagnostics.stats.hoverProxyBoundsHitCount);
|
||||
data.hoverCachedBoundsHitCount = String(diagnostics.stats.hoverCachedBoundsHitCount);
|
||||
|
||||
@ -144,11 +144,15 @@ export class UniversalPreviewer {
|
||||
private readonly hoverOutlineBounds = new THREE.Box3();
|
||||
private readonly hoverOutline = new THREE.Box3Helper(this.hoverOutlineBounds, "#38bdf8");
|
||||
private readonly scratchBounds = new THREE.Box3();
|
||||
private readonly scratchPickWorldBounds = new THREE.Box3();
|
||||
private readonly scratchPickLocalBounds = new THREE.Box3();
|
||||
private readonly scratchSize = new THREE.Vector3();
|
||||
private readonly scratchPickPoint = new THREE.Vector3();
|
||||
private readonly scratchBoundsCorner = new THREE.Vector3();
|
||||
private readonly scratchPreviousFocusPosition = new THREE.Vector3();
|
||||
private readonly scratchPreviousFocusQuaternion = new THREE.Quaternion();
|
||||
private readonly scratchMatrix = new THREE.Matrix4();
|
||||
private readonly scratchInverseMatrix = new THREE.Matrix4();
|
||||
private readonly editableObjectIds = new Set<string>();
|
||||
private readonly clock = new THREE.Clock();
|
||||
private readonly raycaster = new THREE.Raycaster();
|
||||
@ -198,6 +202,7 @@ export class UniversalPreviewer {
|
||||
private meshCacheMissCount = 0;
|
||||
private sceneObjectBoundsCount = 0;
|
||||
private fastPickProxyBoundsCount = 0;
|
||||
private pickBoundsScratchTransformCount = 0;
|
||||
private hoverProxyBoundsHitCount = 0;
|
||||
private hoverCachedBoundsHitCount = 0;
|
||||
private hoverRootBoundsFallbackCount = 0;
|
||||
@ -503,6 +508,7 @@ export class UniversalPreviewer {
|
||||
retainedMeshMaterialCount: this.retainedMeshMaterials.size,
|
||||
sceneObjectBoundsCount: this.sceneObjectBoundsCount,
|
||||
fastPickProxyBoundsCount: this.fastPickProxyBoundsCount,
|
||||
pickBoundsScratchTransformCount: this.pickBoundsScratchTransformCount,
|
||||
meshSourceBoundsCount: this.meshSourceBounds.size,
|
||||
hoverProxyBoundsHitCount: this.hoverProxyBoundsHitCount,
|
||||
hoverCachedBoundsHitCount: this.hoverCachedBoundsHitCount,
|
||||
@ -1064,6 +1070,7 @@ export class UniversalPreviewer {
|
||||
this.sceneObjectBounds.makeEmpty();
|
||||
this.sceneObjectBoundsCount = 0;
|
||||
this.fastPickProxyBoundsCount = 0;
|
||||
this.pickBoundsScratchTransformCount = 0;
|
||||
this.hoverProxyBoundsHitCount = 0;
|
||||
this.hoverCachedBoundsHitCount = 0;
|
||||
this.hoverRootBoundsFallbackCount = 0;
|
||||
@ -2195,21 +2202,12 @@ export class UniversalPreviewer {
|
||||
return cached;
|
||||
}
|
||||
root.updateWorldMatrix(true, true);
|
||||
const worldBounds = new THREE.Box3().setFromObject(root);
|
||||
const worldBounds = this.scratchPickWorldBounds.setFromObject(root);
|
||||
if (worldBounds.isEmpty()) {
|
||||
return undefined;
|
||||
}
|
||||
const inverseRootMatrix = new THREE.Matrix4().copy(root.matrixWorld).invert();
|
||||
const localBounds = new THREE.Box3();
|
||||
const min = worldBounds.min;
|
||||
const max = worldBounds.max;
|
||||
for (const x of [min.x, max.x]) {
|
||||
for (const y of [min.y, max.y]) {
|
||||
for (const z of [min.z, max.z]) {
|
||||
localBounds.expandByPoint(new THREE.Vector3(x, y, z).applyMatrix4(inverseRootMatrix));
|
||||
}
|
||||
}
|
||||
}
|
||||
const inverseRootMatrix = this.scratchInverseMatrix.copy(root.matrixWorld).invert();
|
||||
const localBounds = this.transformBoundsInto(worldBounds, inverseRootMatrix, this.scratchPickLocalBounds);
|
||||
if (localBounds.isEmpty()) {
|
||||
return undefined;
|
||||
}
|
||||
@ -2226,12 +2224,12 @@ export class UniversalPreviewer {
|
||||
return undefined;
|
||||
}
|
||||
root.updateWorldMatrix(true, true);
|
||||
const worldBounds = this.transformBounds(sourceBounds, visual.matrixWorld);
|
||||
const worldBounds = this.transformBoundsInto(sourceBounds, visual.matrixWorld, this.scratchPickWorldBounds);
|
||||
if (worldBounds.isEmpty()) {
|
||||
return undefined;
|
||||
}
|
||||
const inverseRootMatrix = new THREE.Matrix4().copy(root.matrixWorld).invert();
|
||||
const localBounds = this.transformBounds(worldBounds, inverseRootMatrix);
|
||||
const inverseRootMatrix = this.scratchInverseMatrix.copy(root.matrixWorld).invert();
|
||||
const localBounds = this.transformBoundsInto(worldBounds, inverseRootMatrix, this.scratchPickLocalBounds);
|
||||
if (localBounds.isEmpty()) {
|
||||
return undefined;
|
||||
}
|
||||
@ -2260,18 +2258,30 @@ export class UniversalPreviewer {
|
||||
target.worldBounds.copy(target.localBounds).applyMatrix4(bound.root.matrixWorld);
|
||||
}
|
||||
|
||||
private transformBounds(bounds: THREE.Box3, matrix: THREE.Matrix4): THREE.Box3 {
|
||||
const transformed = new THREE.Box3();
|
||||
private transformBoundsInto(bounds: THREE.Box3, matrix: THREE.Matrix4, target: THREE.Box3): THREE.Box3 {
|
||||
target.makeEmpty();
|
||||
const min = bounds.min;
|
||||
const max = bounds.max;
|
||||
for (const x of [min.x, max.x]) {
|
||||
for (const y of [min.y, max.y]) {
|
||||
for (const z of [min.z, max.z]) {
|
||||
transformed.expandByPoint(new THREE.Vector3(x, y, z).applyMatrix4(matrix));
|
||||
}
|
||||
}
|
||||
}
|
||||
return transformed;
|
||||
this.expandTransformedBoundsCorner(target, matrix, min.x, min.y, min.z);
|
||||
this.expandTransformedBoundsCorner(target, matrix, min.x, min.y, max.z);
|
||||
this.expandTransformedBoundsCorner(target, matrix, min.x, max.y, min.z);
|
||||
this.expandTransformedBoundsCorner(target, matrix, min.x, max.y, max.z);
|
||||
this.expandTransformedBoundsCorner(target, matrix, max.x, min.y, min.z);
|
||||
this.expandTransformedBoundsCorner(target, matrix, max.x, min.y, max.z);
|
||||
this.expandTransformedBoundsCorner(target, matrix, max.x, max.y, min.z);
|
||||
this.expandTransformedBoundsCorner(target, matrix, max.x, max.y, max.z);
|
||||
this.pickBoundsScratchTransformCount += 1;
|
||||
return target;
|
||||
}
|
||||
|
||||
private expandTransformedBoundsCorner(
|
||||
target: THREE.Box3,
|
||||
matrix: THREE.Matrix4,
|
||||
x: number,
|
||||
y: number,
|
||||
z: number,
|
||||
): void {
|
||||
target.expandByPoint(this.scratchBoundsCorner.set(x, y, z).applyMatrix4(matrix));
|
||||
}
|
||||
|
||||
private async createVisual(geometry: PreviewGeometry, materialId: string | undefined, token: number): Promise<THREE.Object3D> {
|
||||
|
||||
@ -233,6 +233,7 @@ export interface RendererStats {
|
||||
retainedMeshMaterialCount: number;
|
||||
sceneObjectBoundsCount: number;
|
||||
fastPickProxyBoundsCount: number;
|
||||
pickBoundsScratchTransformCount: number;
|
||||
meshSourceBoundsCount: number;
|
||||
hoverProxyBoundsHitCount: number;
|
||||
hoverCachedBoundsHitCount: number;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user