@spatial-elements/core 1.0.0-beta.6 → 1.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog/CarouselDeviceCamera.d.ts +20 -0
- package/dist/catalog/CarouselDeviceCamera.d.ts.map +1 -0
- package/dist/catalog/CarouselDeviceCamera.js +58 -0
- package/dist/catalog/CarouselDeviceCamera.js.map +1 -0
- package/dist/catalog/CarouselGlassCompositor.d.ts +8 -2
- package/dist/catalog/CarouselGlassCompositor.d.ts.map +1 -1
- package/dist/catalog/CarouselGlassCompositor.js +69 -12
- package/dist/catalog/CarouselGlassCompositor.js.map +1 -1
- package/dist/catalog/CarouselGround.d.ts +22 -1
- package/dist/catalog/CarouselGround.d.ts.map +1 -1
- package/dist/catalog/CarouselGround.js +185 -24
- package/dist/catalog/CarouselGround.js.map +1 -1
- package/dist/catalog/CatalogDepthBlur.d.ts +20 -1
- package/dist/catalog/CatalogDepthBlur.d.ts.map +1 -1
- package/dist/catalog/CatalogDepthBlur.js +126 -23
- package/dist/catalog/CatalogDepthBlur.js.map +1 -1
- package/dist/catalog/CatalogGeometryFade.d.ts +5 -1
- package/dist/catalog/CatalogGeometryFade.d.ts.map +1 -1
- package/dist/catalog/CatalogGeometryFade.js +39 -7
- package/dist/catalog/CatalogGeometryFade.js.map +1 -1
- package/dist/catalog/CatalogModelOutline.d.ts +3 -1
- package/dist/catalog/CatalogModelOutline.d.ts.map +1 -1
- package/dist/catalog/CatalogModelOutline.js +11 -2
- package/dist/catalog/CatalogModelOutline.js.map +1 -1
- package/dist/catalog/CatalogPreparation.d.ts.map +1 -1
- package/dist/catalog/CatalogPreparation.js +8 -6
- package/dist/catalog/CatalogPreparation.js.map +1 -1
- package/dist/catalog/CatalogSpatialElementLayer.d.ts +144 -3
- package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -1
- package/dist/catalog/CatalogSpatialElementLayer.js +554 -103
- package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
- package/dist/catalog/CatalogTransition.d.ts +4 -0
- package/dist/catalog/CatalogTransition.d.ts.map +1 -1
- package/dist/catalog/CatalogTransition.js +109 -27
- package/dist/catalog/CatalogTransition.js.map +1 -1
- package/dist/catalog/CatalogWarmOutputContext.d.ts +39 -0
- package/dist/catalog/CatalogWarmOutputContext.d.ts.map +1 -0
- package/dist/catalog/CatalogWarmOutputContext.js +159 -0
- package/dist/catalog/CatalogWarmOutputContext.js.map +1 -0
- package/dist/catalog/EarlyNavigationCoordinator.d.ts +35 -0
- package/dist/catalog/EarlyNavigationCoordinator.d.ts.map +1 -0
- package/dist/catalog/EarlyNavigationCoordinator.js +103 -0
- package/dist/catalog/EarlyNavigationCoordinator.js.map +1 -0
- package/dist/catalog/NavigationFeedback.d.ts +12 -0
- package/dist/catalog/NavigationFeedback.d.ts.map +1 -0
- package/dist/catalog/NavigationFeedback.js +40 -0
- package/dist/catalog/NavigationFeedback.js.map +1 -0
- package/dist/catalog/PreparationGate.d.ts +4 -0
- package/dist/catalog/PreparationGate.d.ts.map +1 -1
- package/dist/catalog/PreparationGate.js +1 -0
- package/dist/catalog/PreparationGate.js.map +1 -1
- package/dist/catalog/SourceDomClipping.d.ts +8 -0
- package/dist/catalog/SourceDomClipping.d.ts.map +1 -0
- package/dist/catalog/SourceDomClipping.js +74 -0
- package/dist/catalog/SourceDomClipping.js.map +1 -0
- package/dist/catalog/SourceDomMotion.d.ts +28 -0
- package/dist/catalog/SourceDomMotion.d.ts.map +1 -0
- package/dist/catalog/SourceDomMotion.js +111 -0
- package/dist/catalog/SourceDomMotion.js.map +1 -0
- package/dist/catalog/SpatialPageRegistry.d.ts +1 -0
- package/dist/catalog/SpatialPageRegistry.d.ts.map +1 -1
- package/dist/catalog/SpatialPageRegistry.js.map +1 -1
- package/dist/catalog/StagedCatalogTransition.d.ts +74 -0
- package/dist/catalog/StagedCatalogTransition.d.ts.map +1 -0
- package/dist/catalog/StagedCatalogTransition.js +270 -0
- package/dist/catalog/StagedCatalogTransition.js.map +1 -0
- package/dist/catalog/cardProjection.d.ts +31 -0
- package/dist/catalog/cardProjection.d.ts.map +1 -1
- package/dist/catalog/cardProjection.js +63 -4
- package/dist/catalog/cardProjection.js.map +1 -1
- package/dist/catalog/carouselPanelProjection.d.ts.map +1 -1
- package/dist/catalog/carouselPanelProjection.js +48 -11
- package/dist/catalog/carouselPanelProjection.js.map +1 -1
- package/dist/catalog/catalogActivationFocus.d.ts +5 -0
- package/dist/catalog/catalogActivationFocus.d.ts.map +1 -0
- package/dist/catalog/catalogActivationFocus.js +39 -0
- package/dist/catalog/catalogActivationFocus.js.map +1 -0
- package/dist/catalog/catalogJourney.d.ts +2 -0
- package/dist/catalog/catalogJourney.d.ts.map +1 -1
- package/dist/catalog/catalogJourney.js.map +1 -1
- package/dist/catalog/catalogPose.d.ts +18 -0
- package/dist/catalog/catalogPose.d.ts.map +1 -1
- package/dist/catalog/catalogPose.js +26 -5
- package/dist/catalog/catalogPose.js.map +1 -1
- package/dist/catalog/catalogTransitionViewport.d.ts +9 -0
- package/dist/catalog/catalogTransitionViewport.d.ts.map +1 -0
- package/dist/catalog/catalogTransitionViewport.js +13 -0
- package/dist/catalog/catalogTransitionViewport.js.map +1 -0
- package/dist/catalog/catalogViewLink.d.ts +2 -0
- package/dist/catalog/catalogViewLink.d.ts.map +1 -1
- package/dist/catalog/catalogViewLink.js +10 -2
- package/dist/catalog/catalogViewLink.js.map +1 -1
- package/dist/catalog/deviceYaw.d.ts +21 -0
- package/dist/catalog/deviceYaw.d.ts.map +1 -0
- package/dist/catalog/deviceYaw.js +87 -0
- package/dist/catalog/deviceYaw.js.map +1 -0
- package/dist/catalog/listDeviceOrientation.d.ts +17 -0
- package/dist/catalog/listDeviceOrientation.d.ts.map +1 -0
- package/dist/catalog/listDeviceOrientation.js +262 -0
- package/dist/catalog/listDeviceOrientation.js.map +1 -0
- package/dist/catalog/stagedDetailGeometry.d.ts +37 -0
- package/dist/catalog/stagedDetailGeometry.d.ts.map +1 -0
- package/dist/catalog/stagedDetailGeometry.js +55 -0
- package/dist/catalog/stagedDetailGeometry.js.map +1 -0
- package/dist/catalog/stagedDockGeometry.d.ts +66 -0
- package/dist/catalog/stagedDockGeometry.d.ts.map +1 -0
- package/dist/catalog/stagedDockGeometry.js +66 -0
- package/dist/catalog/stagedDockGeometry.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/spatial-element/ResponsiveViewportMetrics.d.ts +18 -0
- package/dist/spatial-element/ResponsiveViewportMetrics.d.ts.map +1 -0
- package/dist/spatial-element/ResponsiveViewportMetrics.js +68 -0
- package/dist/spatial-element/ResponsiveViewportMetrics.js.map +1 -0
- package/dist/spatial-element/SectionSurfaceRegistry.d.ts +24 -0
- package/dist/spatial-element/SectionSurfaceRegistry.d.ts.map +1 -0
- package/dist/spatial-element/SectionSurfaceRegistry.js +48 -0
- package/dist/spatial-element/SectionSurfaceRegistry.js.map +1 -0
- package/dist/spatial-element/SpatialElementDockController.d.ts +19 -9
- package/dist/spatial-element/SpatialElementDockController.d.ts.map +1 -1
- package/dist/spatial-element/SpatialElementDockController.js +189 -93
- package/dist/spatial-element/SpatialElementDockController.js.map +1 -1
- package/dist/spatial-element/SpatialElementPaneController.d.ts +67 -0
- package/dist/spatial-element/SpatialElementPaneController.d.ts.map +1 -0
- package/dist/spatial-element/SpatialElementPaneController.js +245 -0
- package/dist/spatial-element/SpatialElementPaneController.js.map +1 -0
- package/dist/spatial-element/activeDetailSection.d.ts +8 -0
- package/dist/spatial-element/activeDetailSection.d.ts.map +1 -0
- package/dist/spatial-element/activeDetailSection.js +19 -0
- package/dist/spatial-element/activeDetailSection.js.map +1 -0
- package/dist/spatial-element/layoutTokens.json +53 -0
- package/dist/spatial-element/responsiveLayout.d.ts +1389 -0
- package/dist/spatial-element/responsiveLayout.d.ts.map +1 -0
- package/dist/spatial-element/responsiveLayout.js +265 -0
- package/dist/spatial-element/responsiveLayout.js.map +1 -0
- package/dist/spatial-element/sectionBackground.d.ts +29 -0
- package/dist/spatial-element/sectionBackground.d.ts.map +1 -0
- package/dist/spatial-element/sectionBackground.js +66 -0
- package/dist/spatial-element/sectionBackground.js.map +1 -0
- package/dist/spatial-element/spatialElement.d.ts +1 -0
- package/dist/spatial-element/spatialElement.d.ts.map +1 -1
- package/dist/spatial-element/spatialElement.js +1 -0
- package/dist/spatial-element/spatialElement.js.map +1 -1
- package/dist/spatial-element/spatialElementDock.d.ts +15 -0
- package/dist/spatial-element/spatialElementDock.d.ts.map +1 -1
- package/dist/spatial-element/spatialElementDock.js +22 -0
- package/dist/spatial-element/spatialElementDock.js.map +1 -1
- package/dist/spatial-element/spatialElementMedia.d.ts +16 -0
- package/dist/spatial-element/spatialElementMedia.d.ts.map +1 -0
- package/dist/spatial-element/spatialElementMedia.js +29 -0
- package/dist/spatial-element/spatialElementMedia.js.map +1 -0
- package/dist/spatial-element/spatialTheme.d.ts +12 -1
- package/dist/spatial-element/spatialTheme.d.ts.map +1 -1
- package/dist/spatial-element/spatialTheme.js +30 -1
- package/dist/spatial-element/spatialTheme.js.map +1 -1
- package/dist/spatial-element/types.d.ts +50 -2
- package/dist/spatial-element/types.d.ts.map +1 -1
- package/dist/spatial-element/types.js.map +1 -1
- package/dist/stage/BackgroundLayerOutput.d.ts +76 -0
- package/dist/stage/BackgroundLayerOutput.d.ts.map +1 -0
- package/dist/stage/BackgroundLayerOutput.js +333 -0
- package/dist/stage/BackgroundLayerOutput.js.map +1 -0
- package/dist/stage/DeviceGeometryMotion.d.ts +13 -0
- package/dist/stage/DeviceGeometryMotion.d.ts.map +1 -0
- package/dist/stage/DeviceGeometryMotion.js +37 -0
- package/dist/stage/DeviceGeometryMotion.js.map +1 -0
- package/dist/stage/LiquidGlassPanel.d.ts +3 -0
- package/dist/stage/LiquidGlassPanel.d.ts.map +1 -1
- package/dist/stage/LiquidGlassPanel.js +27 -2
- package/dist/stage/LiquidGlassPanel.js.map +1 -1
- package/dist/stage/MinimapController.d.ts +1 -0
- package/dist/stage/MinimapController.d.ts.map +1 -1
- package/dist/stage/MinimapController.js +35 -47
- package/dist/stage/MinimapController.js.map +1 -1
- package/dist/stage/PageBindingController.d.ts +4 -0
- package/dist/stage/PageBindingController.d.ts.map +1 -1
- package/dist/stage/PageBindingController.js +12 -4
- package/dist/stage/PageBindingController.js.map +1 -1
- package/dist/stage/PanelPresentationController.d.ts +17 -0
- package/dist/stage/PanelPresentationController.d.ts.map +1 -1
- package/dist/stage/PanelPresentationController.js +83 -22
- package/dist/stage/PanelPresentationController.js.map +1 -1
- package/dist/stage/SpatialElementInteractionController.d.ts +7 -0
- package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -1
- package/dist/stage/SpatialElementInteractionController.js +9 -0
- package/dist/stage/SpatialElementInteractionController.js.map +1 -1
- package/dist/stage/SpatialElementPresentationController.d.ts +14 -2
- package/dist/stage/SpatialElementPresentationController.d.ts.map +1 -1
- package/dist/stage/SpatialElementPresentationController.js +47 -2
- package/dist/stage/SpatialElementPresentationController.js.map +1 -1
- package/dist/stage/SpatialElementRefinement.d.ts +34 -1
- package/dist/stage/SpatialElementRefinement.d.ts.map +1 -1
- package/dist/stage/SpatialElementRefinement.js +175 -37
- package/dist/stage/SpatialElementRefinement.js.map +1 -1
- package/dist/stage/StageExperience.d.ts +183 -5
- package/dist/stage/StageExperience.d.ts.map +1 -1
- package/dist/stage/StageExperience.js +421 -57
- package/dist/stage/StageExperience.js.map +1 -1
- package/dist/stage/StageRenderPipeline.d.ts +76 -1
- package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
- package/dist/stage/StageRenderPipeline.js +424 -47
- package/dist/stage/StageRenderPipeline.js.map +1 -1
- package/dist/stage/VirtualScrollController.d.ts +7 -0
- package/dist/stage/VirtualScrollController.d.ts.map +1 -1
- package/dist/stage/VirtualScrollController.js +57 -4
- package/dist/stage/VirtualScrollController.js.map +1 -1
- package/dist/stage/minimap/MinimapModel.d.ts +2 -1
- package/dist/stage/minimap/MinimapModel.d.ts.map +1 -1
- package/dist/stage/minimap/MinimapModel.js +34 -4
- package/dist/stage/minimap/MinimapModel.js.map +1 -1
- package/dist/stage/minimap/MinimapModelGeometry.d.ts +21 -0
- package/dist/stage/minimap/MinimapModelGeometry.d.ts.map +1 -0
- package/dist/stage/minimap/MinimapModelGeometry.js +68 -0
- package/dist/stage/minimap/MinimapModelGeometry.js.map +1 -0
- package/dist/stage/minimap/MinimapState.d.ts +3 -8
- package/dist/stage/minimap/MinimapState.d.ts.map +1 -1
- package/dist/stage/minimap/MinimapState.js.map +1 -1
- package/dist/stage/panelContext.d.ts +7 -0
- package/dist/stage/panelContext.d.ts.map +1 -1
- package/dist/stage/panelContext.js.map +1 -1
- package/dist/stage/rendererState.d.ts +2 -0
- package/dist/stage/rendererState.d.ts.map +1 -1
- package/dist/stage/rendererState.js +13 -0
- package/dist/stage/rendererState.js.map +1 -1
- package/dist/stage/sceneEndpointEligibility.d.ts +20 -0
- package/dist/stage/sceneEndpointEligibility.d.ts.map +1 -0
- package/dist/stage/sceneEndpointEligibility.js +363 -0
- package/dist/stage/sceneEndpointEligibility.js.map +1 -0
- package/dist/stage/stageDom.d.ts.map +1 -1
- package/dist/stage/stageDom.js +6 -1
- package/dist/stage/stageDom.js.map +1 -1
- package/dist/stage/stageMath.d.ts +3 -3
- package/dist/stage/stageMath.d.ts.map +1 -1
- package/dist/stage/stageMath.js +11 -10
- package/dist/stage/stageMath.js.map +1 -1
- package/dist/stage/stageTypes.d.ts +8 -1
- package/dist/stage/stageTypes.d.ts.map +1 -1
- package/dist/stage/stageTypes.js.map +1 -1
- package/dist/stage/stageVisualTest.d.ts +19 -0
- package/dist/stage/stageVisualTest.d.ts.map +1 -1
- package/dist/stage/stageVisualTest.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogDepthBlur.js","sourceRoot":"","sources":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AAE,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;;gBAC9C,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAClC,IAAI,CAAC,IAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC5B,IAAI,CAAC,MAAM,EAAE,CAAC;QACf,CAAC;gBAAS,CAAC;YACV,QAAQ,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;YACtC,IAAI,WAAW;gBAAE,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;;gBAChD,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACpC,QAAQ,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAC/C,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;IACD,OAAO;QACN,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;IAC1B,CAAC;CACD","sourcesContent":["import * as THREE from 'three/webgpu';\nimport { texture, uniform } from 'three/tsl';\nimport { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';\nimport { gaussianTargets } from '../stage/renderTargetInventory.js';\n\nexport interface BlurRect { left: number; top: number; width: number; height: number }\n\n/** One bounded scratch image for all defocused models and panels, reused between draws. */\nexport class CatalogDepthBlur {\n\tprivate capture?: THREE.RenderTarget;\n\tprivate effect?: ReturnType<typeof gaussianBlur>;\n\tprivate material?: THREE.NodeMaterial;\n\tprivate quad?: THREE.QuadMesh;\n\tprivate readonly camera = new THREE.PerspectiveCamera();\n\tprivate readonly direction = uniform(new THREE.Vector2());\n\tprivate passes = 0;\n\tgetRenderTargets() { return this.capture ? [this.capture, ...gaussianTargets(this.effect!)] : []; }\n\tgetStats() { return { passes: this.passes, targets: this.getRenderTargets().length, size: this.capture?.width ?? 0 }; }\n\n\trender(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera,\n\t\tbounds: BlurRect, radius: number, draw: (camera: THREE.PerspectiveCamera) => void,\n\t\tclip: BlurRect = { left: 0, top: 0, width: innerWidth, height: innerHeight }) {\n\t\tif (radius < 0.05) { draw(camera); return; }\n\t\tconst padding = Math.ceil(radius * 3 + 2);\n\t\tconst left = Math.max(0, clip.left, Math.floor(bounds.left - padding));\n\t\tconst top = Math.max(0, clip.top, Math.floor(bounds.top - padding));\n\t\tconst right = Math.min(innerWidth, clip.left + clip.width, Math.ceil(bounds.left + bounds.width + padding));\n\t\tconst bottom = Math.min(innerHeight, clip.top + clip.height, Math.ceil(bounds.top + bounds.height + padding));\n\t\tconst width = right - left, height = bottom - top;\n\t\tif (width <= 0 || height <= 0) return;\n\t\tif (!this.capture) {\n\t\t\tthis.capture = new THREE.RenderTarget(512, 512, { type: THREE.HalfFloatType });\n\t\t\tthis.effect = gaussianBlur(texture(this.capture.texture), this.direction, 2,\n\t\t\t\t{ resolutionScale: 0.5, premultipliedAlpha: false });\n\t\t\t// Several actors reuse the scratch image within one stage frame.\n\t\t\tthis.effect.updateBeforeType = THREE.NodeUpdateType.RENDER;\n\t\t\tthis.material = new THREE.NodeMaterial();\n\t\t\tthis.material.fragmentNode = this.effect;\n\t\t\tthis.material.transparent = true;\n\t\t\t// Captures and Gaussian samples are already premultiplied; do not multiply alpha twice.\n\t\t\tthis.material.blending = THREE.CustomBlending;\n\t\t\tthis.material.blendSrc = this.material.blendSrcAlpha = THREE.OneFactor;\n\t\t\tthis.material.blendDst = this.material.blendDstAlpha = THREE.OneMinusSrcAlphaFactor;\n\t\t\tthis.material.depthTest = false;\n\t\t\tthis.material.depthWrite = false;\n\t\t\tthis.material.toneMapped = false;\n\t\t\tthis.quad = new THREE.QuadMesh(this.material);\n\t\t}\n\t\tconst destination = renderer.getRenderTarget();\n\t\tconst viewport = destination ? destination.viewport.clone() : renderer.getViewport(new THREE.Vector4());\n\t\tconst clearColor = renderer.getClearColor(new THREE.Color());\n\t\tconst clearAlpha = renderer.getClearAlpha();\n\t\tconst scissorTest = renderer.getScissorTest();\n\t\tthis.camera.copy(camera);\n\t\tthis.camera.setViewOffset(innerWidth, innerHeight, left, top, width, height);\n\t\t// The half-resolution Gaussian uses a kernel standard deviation of 7/3 texels.\n\t\tthis.direction.value.set(radius * 256 / width / (7 / 3), radius * 256 / height / (7 / 3));\n\t\ttry {\n\t\t\trenderer.setRenderTarget(this.capture);\n\t\t\trenderer.setScissorTest(false);\n\t\t\trenderer.setClearColor(0x000000, 0);\n\t\t\trenderer.clear();\n\t\t\tdraw(this.camera);\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\tconst scaleX = viewport.z / innerWidth, scaleY = viewport.w / innerHeight;\n\t\t\tconst output = new THREE.Vector4(viewport.x + left * scaleX, viewport.y + top * scaleY, width * scaleX, height * scaleY);\n\t\t\tif (destination) destination.viewport.copy(output);\n\t\t\telse renderer.setViewport(output);\n\t\t\tthis.quad!.render(renderer);\n\t\t\tthis.passes++;\n\t\t} finally {\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\tif (destination) destination.viewport.copy(viewport);\n\t\t\telse renderer.setViewport(viewport);\n\t\t\trenderer.setClearColor(clearColor, clearAlpha);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t}\n\t}\n\tdispose() {\n\t\tthis.capture?.dispose();\n\t\tthis.effect?.dispose();\n\t\tthis.material?.dispose();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CatalogDepthBlur.js","sourceRoot":"","sources":["../../src/catalog/CatalogDepthBlur.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAC5E,OAAO,EAAE,eA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":["import * as THREE from 'three/webgpu';\nimport { texture, uniform } from 'three/tsl';\nimport { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';\nimport { gaussianTargets } from '../stage/renderTargetInventory.js';\nimport { clearFullTarget, withRendererState } from '../stage/rendererState.js';\nimport type { CatalogWarmOutputContext } from './CatalogWarmOutputContext.js';\n\nexport interface BlurRect { left: number; top: number; width: number; height: number }\n\nexport function resolveDepthBlurRect(bounds: BlurRect, radius: number,\n\tclip: BlurRect = { left: 0, top: 0, width: innerWidth, height: innerHeight }): BlurRect | undefined {\n\tconst padding = Math.ceil(radius * 3 + 2);\n\tconst left = Math.max(0, clip.left, Math.floor(bounds.left - padding));\n\tconst top = Math.max(0, clip.top, Math.floor(bounds.top - padding));\n\tconst right = Math.min(innerWidth, clip.left + clip.width, Math.ceil(bounds.left + bounds.width + padding));\n\tconst bottom = Math.min(innerHeight, clip.top + clip.height, Math.ceil(bounds.top + bounds.height + padding));\n\treturn right > left && bottom > top ? { left, top, width: right - left, height: bottom - top } : undefined;\n}\n\n/** One bounded scratch image for all defocused models and panels, reused between draws. */\nexport class CatalogDepthBlur {\n\tprivate capture?: THREE.RenderTarget;\n\tprivate effect?: ReturnType<typeof gaussianBlur>;\n\tprivate material?: THREE.NodeMaterial;\n\tprivate quad?: THREE.QuadMesh;\n\tprivate readonly camera = new THREE.PerspectiveCamera();\n\tprivate readonly direction = uniform(new THREE.Vector2());\n\tprivate passes = 0;\n\tprivate resolvedTexture?: ReturnType<typeof texture>;\n\tprivate readonly resolvedOpacity = uniform(1);\n\tprivate resolvedMaterial?: THREE.NodeMaterial;\n\tprivate cacheResolveQuad?: THREE.QuadMesh;\n\tprivate resolvedCanvasQuad?: THREE.QuadMesh;\n\tprivate resolvedOffscreenQuad?: THREE.QuadMesh;\n\tgetRenderTargets() { return this.capture ? [this.capture, ...gaussianTargets(this.effect!)] : []; }\n\tgetStats() { return { passes: this.passes, targets: this.getRenderTargets().length, size: this.capture?.width ?? 0 }; }\n\t/** Idle preparation borrows the real capture context without resolving it onto any output. */\n\tprepareCapture(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera,\n\t\tdraw: (camera: THREE.PerspectiveCamera) => void) {\n\t\tthis.ensureResources();\n\t\tconst destination = renderer.getRenderTarget(), previousCamera = this.camera.clone();\n\t\ttry {\n\t\t\tthis.camera.copy(camera);\n\t\t\trenderer.setRenderTarget(this.capture!);\n\t\t\tdraw(this.camera);\n\t\t} finally {\n\t\t\tthis.camera.copy(previousCamera);\n\t\t\trenderer.setRenderTarget(destination);\n\t\t}\n\t}\n\t/** Idle-only: retain one already blurred image, using the existing capture/Gaussian scratch. */\n\tprepareResolved(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera,\n\t\trect: BlurRect, radius: number, target: THREE.RenderTarget,\n\t\tdraw: (camera: THREE.PerspectiveCamera) => void) {\n\t\tthis.ensureResources();\n\t\tthis.ensureResolvedComposite(target.texture);\n\t\tconst previousCamera = this.camera.clone(), direction = this.direction.value.clone();\n\t\ttry {\n\t\t\twithRendererState(renderer, () => {\n\t\t\t\tthis.captureSource(renderer, camera, rect, radius, draw);\n\t\t\t\trenderer.setRenderTarget(target);\n\t\t\t\trenderer.setClearColor(0, 0);\n\t\t\t\tclearFullTarget(renderer);\n\t\t\t\t// The Gaussian resolves at 256²; this full-size copy introduces no resampling.\n\t\t\t\tthis.cacheResolveQuad!.render(renderer);\n\t\t\t});\n\t\t} finally { this.camera.copy(previousCamera); this.direction.value.copy(direction); }\n\t}\n\t/** No allocation or Gaussian update: only the retained image and its linear opacity. */\n\tdrawResolved(renderer: THREE.WebGPURenderer, source: THREE.Texture, rect: BlurRect, opacity: number,\n\t\tpreserveCanvasScissor = false, warmOutput?: CatalogWarmOutputContext) {\n\t\tif (!this.resolvedTexture || !this.resolvedCanvasQuad || !this.resolvedOffscreenQuad) return false;\n\t\tconst destination = renderer.getRenderTarget();\n\t\tconst viewport = destination ? destination.viewport.clone() : renderer.getViewport(new THREE.Vector4());\n\t\tconst scissorTest = renderer.getScissorTest();\n\t\tthis.resolvedTexture.value = source;\n\t\tthis.resolvedOpacity.value = opacity;\n\t\ttry {\n\t\t\tif (destination || !preserveCanvasScissor) renderer.setScissorTest(false);\n\t\t\tthis.setOutputViewport(renderer, destination, viewport, rect);\n\t\t\t(destination && !warmOutput?.usesCanvasOwner(destination) ? this.resolvedOffscreenQuad : this.resolvedCanvasQuad).render(renderer);\n\t\t} finally {\n\t\t\tif (destination) destination.viewport.copy(viewport); else renderer.setViewport(viewport);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t}\n\t\treturn true;\n\t}\n\n\trender(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera,\n\t\tbounds: BlurRect, radius: number, draw: (camera: THREE.PerspectiveCamera) => void,\n\t\tclip: BlurRect = { left: 0, top: 0, width: innerWidth, height: innerHeight }, preserveCanvasScissor = false) {\n\t\tif (radius < 0.05) { draw(camera); return; }\n\t\tconst rect = resolveDepthBlurRect(bounds, radius, clip);\n\t\tif (!rect) return;\n\t\tthis.ensureResources();\n\t\tthis.renderCapture(renderer, camera, rect.left, rect.top, rect.width, rect.height, radius, draw, preserveCanvasScissor);\n\t}\n\tprivate ensureResolvedComposite(source: THREE.Texture) {\n\t\tif (this.resolvedMaterial) return;\n\t\tconst resolvedTexture = texture(source);\n\t\tthis.resolvedTexture = resolvedTexture;\n\t\tthis.resolvedMaterial = new THREE.NodeMaterial();\n\t\tthis.resolvedMaterial.fragmentNode = resolvedTexture.mul(this.resolvedOpacity);\n\t\tthis.resolvedMaterial.transparent = true;\n\t\tthis.resolvedMaterial.blending = THREE.CustomBlending;\n\t\tthis.resolvedMaterial.blendSrc = this.resolvedMaterial.blendSrcAlpha = THREE.OneFactor;\n\t\tthis.resolvedMaterial.blendDst = this.resolvedMaterial.blendDstAlpha = THREE.OneMinusSrcAlphaFactor;\n\t\tthis.resolvedMaterial.depthTest = this.resolvedMaterial.depthWrite = this.resolvedMaterial.toneMapped = false;\n\t\t// The cache's HalfFloat copy must not replace the live resolve owner's\n\t\t// Canvas/RGBA8 pipeline when a later pointer pose needs the live fallback.\n\t\tthis.cacheResolveQuad = new THREE.QuadMesh(this.material!);\n\t\t// Retain both render-object owners, just as the live geometry fade does.\n\t\tthis.resolvedCanvasQuad = new THREE.QuadMesh(this.resolvedMaterial);\n\t\tthis.resolvedOffscreenQuad = new THREE.QuadMesh(this.resolvedMaterial);\n\t}\n\tprivate ensureResources() {\n\t\tif (!this.capture) {\n\t\t\tthis.capture = new THREE.RenderTarget(512, 512, { type: THREE.HalfFloatType });\n\t\t\tthis.effect = gaussianBlur(texture(this.capture.texture), this.direction, 2,\n\t\t\t\t{ resolutionScale: 0.5, premultipliedAlpha: false });\n\t\t\t// Several actors reuse the scratch image within one stage frame.\n\t\t\tthis.effect.updateBeforeType = THREE.NodeUpdateType.RENDER;\n\t\t\tthis.material = new THREE.NodeMaterial();\n\t\t\tthis.material.fragmentNode = this.effect;\n\t\t\tthis.material.transparent = true;\n\t\t\t// Captures and Gaussian samples are already premultiplied; do not multiply alpha twice.\n\t\t\tthis.material.blending = THREE.CustomBlending;\n\t\t\tthis.material.blendSrc = this.material.blendSrcAlpha = THREE.OneFactor;\n\t\t\tthis.material.blendDst = this.material.blendDstAlpha = THREE.OneMinusSrcAlphaFactor;\n\t\t\tthis.material.depthTest = false;\n\t\t\tthis.material.depthWrite = false;\n\t\t\tthis.material.toneMapped = false;\n\t\t\tthis.quad = new THREE.QuadMesh(this.material);\n\t\t}\n\t}\n\tprivate renderCapture(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera,\n\t\tleft: number, top: number, width: number, height: number, radius: number,\n\t\tdraw: (camera: THREE.PerspectiveCamera) => void, preserveCanvasScissor: boolean) {\n\t\tconst destination = renderer.getRenderTarget();\n\t\tconst viewport = destination ? destination.viewport.clone() : renderer.getViewport(new THREE.Vector4());\n\t\tconst clearColor = renderer.getClearColor(new THREE.Color());\n\t\tconst clearAlpha = renderer.getClearAlpha();\n\t\tconst scissorTest = renderer.getScissorTest();\n\t\ttry {\n\t\t\tthis.captureSource(renderer, camera, { left, top, width, height }, radius, draw);\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\t// Idle warmup still uses the real Canvas format, but must not paint it.\n\t\t\tif (!destination && preserveCanvasScissor) renderer.setScissorTest(scissorTest);\n\t\t\tthis.setOutputViewport(renderer, destination, viewport, { left, top, width, height });\n\t\t\tthis.quad!.render(renderer);\n\t\t\tthis.passes++;\n\t\t} finally {\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\tif (destination) destination.viewport.copy(viewport);\n\t\t\telse renderer.setViewport(viewport);\n\t\t\trenderer.setClearColor(clearColor, clearAlpha);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t}\n\t}\n\tprivate captureSource(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera,\n\t\trect: BlurRect, radius: number, draw: (camera: THREE.PerspectiveCamera) => void) {\n\t\tthis.camera.copy(camera);\n\t\tthis.camera.setViewOffset(innerWidth, innerHeight, rect.left, rect.top, rect.width, rect.height);\n\t\t// The half-resolution Gaussian uses a kernel standard deviation of 7/3 texels.\n\t\tthis.direction.value.set(radius * 256 / rect.width / (7 / 3), radius * 256 / rect.height / (7 / 3));\n\t\trenderer.setRenderTarget(this.capture!);\n\t\trenderer.setScissorTest(false);\n\t\trenderer.setClearColor(0, 0);\n\t\trenderer.clear();\n\t\tdraw(this.camera);\n\t}\n\tprivate setOutputViewport(renderer: THREE.WebGPURenderer, destination: THREE.RenderTarget | null,\n\t\tviewport: THREE.Vector4, rect: BlurRect) {\n\t\tconst scaleX = viewport.z / innerWidth, scaleY = viewport.w / innerHeight;\n\t\tconst output = new THREE.Vector4(viewport.x + rect.left * scaleX, viewport.y + rect.top * scaleY,\n\t\t\trect.width * scaleX, rect.height * scaleY);\n\t\tif (destination) destination.viewport.copy(output); else renderer.setViewport(output);\n\t}\n\tdispose() {\n\t\tthis.capture?.dispose();\n\t\tthis.effect?.dispose();\n\t\tthis.material?.dispose();\n\t\tthis.resolvedMaterial?.dispose();\n\t}\n}\n"]}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import * as THREE from 'three/webgpu';
|
|
2
|
+
import type { CatalogWarmOutputContext } from './CatalogWarmOutputContext.js';
|
|
2
3
|
/** Fade the resolved image, never the individual opaque surfaces of a element. */
|
|
3
4
|
export declare class CatalogGeometryFade {
|
|
4
5
|
getRenderTargets(): THREE.RenderTarget<THREE.Texture<unknown, THREE.TextureEventMap>, THREE.RenderTargetEventMap>[];
|
|
5
6
|
private capture?;
|
|
6
7
|
private material?;
|
|
7
8
|
private quad?;
|
|
9
|
+
private offscreenQuad?;
|
|
8
10
|
private readonly alpha;
|
|
9
|
-
|
|
11
|
+
private frozenCapture?;
|
|
12
|
+
/** A source token belongs to one frozen source generation and output band only. */
|
|
13
|
+
render(renderer: THREE.WebGPURenderer, opacity: number, draw: () => void, warmOutput?: CatalogWarmOutputContext, frozenSource?: object): void;
|
|
10
14
|
dispose(): void;
|
|
11
15
|
}
|
|
12
16
|
//# sourceMappingURL=CatalogGeometryFade.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogGeometryFade.d.ts","sourceRoot":"","sources":["../../src/catalog/CatalogGeometryFade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"CatalogGeometryFade.d.ts","sourceRoot":"","sources":["../../src/catalog/CatalogGeometryFade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAiB9E,kFAAkF;AAClF,qBAAa,mBAAmB;IAC/B,gBAAgB;IAGhB,OAAO,CAAC,OAAO,CAAC,CAAqB;IACrC,OAAO,CAAC,QAAQ,CAAC,CAAqB;IACtC,OAAO,CAAC,IAAI,CAAC,CAAiB;IAC9B,OAAO,CAAC,aAAa,CAAC,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAc;IACpC,OAAO,CAAC,aAAa,CAAC,CAAgB;IAEtC,mFAAmF;IACnF,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,IAAI,EACvE,UAAU,CAAC,EAAE,wBAAwB,EAAE,YAAY,CAAC,EAAE,MAAM;IA0E7D,OAAO;CASP"}
|
|
@@ -9,8 +9,13 @@ export class CatalogGeometryFade {
|
|
|
9
9
|
capture;
|
|
10
10
|
material;
|
|
11
11
|
quad;
|
|
12
|
+
offscreenQuad;
|
|
12
13
|
alpha = uniform(1);
|
|
13
|
-
|
|
14
|
+
frozenCapture;
|
|
15
|
+
/** A source token belongs to one frozen source generation and output band only. */
|
|
16
|
+
render(renderer, opacity, draw, warmOutput, frozenSource) {
|
|
17
|
+
if (!frozenSource || warmOutput || opacity >= 1 || opacity <= 0)
|
|
18
|
+
this.frozenCapture = undefined;
|
|
14
19
|
if (opacity >= 1) {
|
|
15
20
|
draw();
|
|
16
21
|
return;
|
|
@@ -27,6 +32,7 @@ export class CatalogGeometryFade {
|
|
|
27
32
|
type: THREE.HalfFloatType,
|
|
28
33
|
samples: 4
|
|
29
34
|
});
|
|
35
|
+
this.capture.addEventListener('dispose', () => { this.frozenCapture = undefined; });
|
|
30
36
|
this.material = new THREE.NodeMaterial();
|
|
31
37
|
this.material.fragmentNode = texture(this.capture.texture).mul(this.alpha);
|
|
32
38
|
this.material.transparent = true;
|
|
@@ -35,23 +41,46 @@ export class CatalogGeometryFade {
|
|
|
35
41
|
this.material.depthWrite = false;
|
|
36
42
|
this.material.toneMapped = false;
|
|
37
43
|
this.quad = new THREE.QuadMesh(this.material);
|
|
44
|
+
// Canvas output and High preparation can share a render-context format
|
|
45
|
+
// while using different color spaces. Keep both render-object owners alive:
|
|
46
|
+
// otherwise preparing High evicts the already warmed Canvas pipeline.
|
|
47
|
+
this.offscreenQuad = new THREE.QuadMesh(this.material);
|
|
38
48
|
}
|
|
39
49
|
this.capture.setSize(width, height);
|
|
50
|
+
const next = frozenSource && !warmOutput ? {
|
|
51
|
+
source: frozenSource, renderer, destination,
|
|
52
|
+
canvas: destination ? undefined : renderer.getCanvasTarget(),
|
|
53
|
+
width: size.width, height: size.height, captureWidth: width, captureHeight: height,
|
|
54
|
+
coordinateSystem: renderer.coordinateSystem, toneMapping: renderer.toneMapping,
|
|
55
|
+
exposure: renderer.toneMappingExposure, colorSpace: renderer.outputColorSpace
|
|
56
|
+
} : undefined;
|
|
57
|
+
const previous = this.frozenCapture;
|
|
58
|
+
const reuse = next && previous && next.source === previous.source && next.renderer === previous.renderer &&
|
|
59
|
+
next.destination === previous.destination && next.canvas === previous.canvas &&
|
|
60
|
+
next.width === previous.width && next.height === previous.height &&
|
|
61
|
+
next.captureWidth === previous.captureWidth && next.captureHeight === previous.captureHeight &&
|
|
62
|
+
next.coordinateSystem === previous.coordinateSystem && next.toneMapping === previous.toneMapping &&
|
|
63
|
+
next.exposure === previous.exposure && next.colorSpace === previous.colorSpace;
|
|
40
64
|
const color = renderer.getClearColor(new THREE.Color());
|
|
41
65
|
const clearAlpha = renderer.getClearAlpha();
|
|
42
66
|
const scissor = renderer.getScissor(new THREE.Vector4());
|
|
43
67
|
const scissorTest = renderer.getScissorTest();
|
|
44
68
|
try {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
69
|
+
// One shared scratch target: another band, ordinary draw or warmup replaces
|
|
70
|
+
// these pixels. The first fractional frame always performs the full capture.
|
|
71
|
+
this.frozenCapture = undefined;
|
|
72
|
+
if (!reuse) {
|
|
73
|
+
renderer.setRenderTarget(this.capture);
|
|
74
|
+
renderer.setScissorTest(false);
|
|
75
|
+
renderer.setClearColor(0x000000, 0);
|
|
76
|
+
renderer.clear();
|
|
77
|
+
draw();
|
|
78
|
+
}
|
|
50
79
|
renderer.setRenderTarget(destination);
|
|
51
80
|
renderer.setScissor(scissor);
|
|
52
81
|
renderer.setScissorTest(scissorTest);
|
|
53
82
|
this.alpha.value = opacity;
|
|
54
|
-
this.quad.render(renderer);
|
|
83
|
+
(destination && !warmOutput?.usesCanvasOwner(destination) ? this.offscreenQuad : this.quad).render(renderer);
|
|
55
84
|
}
|
|
56
85
|
finally {
|
|
57
86
|
renderer.setRenderTarget(destination);
|
|
@@ -59,13 +88,16 @@ export class CatalogGeometryFade {
|
|
|
59
88
|
renderer.setScissor(scissor);
|
|
60
89
|
renderer.setScissorTest(scissorTest);
|
|
61
90
|
}
|
|
91
|
+
this.frozenCapture = next;
|
|
62
92
|
}
|
|
63
93
|
dispose() {
|
|
94
|
+
this.frozenCapture = undefined;
|
|
64
95
|
this.capture?.dispose();
|
|
65
96
|
this.material?.dispose();
|
|
66
97
|
this.capture = undefined;
|
|
67
98
|
this.material = undefined;
|
|
68
99
|
this.quad = undefined;
|
|
100
|
+
this.offscreenQuad = undefined;
|
|
69
101
|
}
|
|
70
102
|
}
|
|
71
103
|
//# sourceMappingURL=CatalogGeometryFade.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogGeometryFade.js","sourceRoot":"","sources":["../../src/catalog/CatalogGeometryFade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"CatalogGeometryFade.js","sourceRoot":"","sources":["../../src/catalog/CatalogGeometryFade.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,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;QACzB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,aAAa,GAAG,SAAS,CAAC;IAChC,CAAC;CACD","sourcesContent":["import * as THREE from 'three/webgpu';\nimport { texture, uniform } from 'three/tsl';\nimport { getRefinementSize } from '../stage/SpatialElementRefinement.js';\nimport type { CatalogWarmOutputContext } from './CatalogWarmOutputContext.js';\n\ninterface FrozenCapture {\n\tsource: object;\n\trenderer: THREE.WebGPURenderer;\n\tdestination: THREE.RenderTarget | null;\n\tcanvas?: THREE.CanvasTarget;\n\twidth: number;\n\theight: number;\n\tcaptureWidth: number;\n\tcaptureHeight: number;\n\tcoordinateSystem: THREE.WebGPURenderer['coordinateSystem'];\n\ttoneMapping: THREE.WebGPURenderer['toneMapping'];\n\texposure: number;\n\tcolorSpace: THREE.WebGPURenderer['outputColorSpace'];\n}\n\n/** Fade the resolved image, never the individual opaque surfaces of a element. */\nexport class CatalogGeometryFade {\n\tgetRenderTargets() {\n\t\treturn this.capture ? [this.capture] : [];\n\t}\n\tprivate capture?: THREE.RenderTarget;\n\tprivate material?: THREE.NodeMaterial;\n\tprivate quad?: THREE.QuadMesh;\n\tprivate offscreenQuad?: THREE.QuadMesh;\n\tprivate readonly alpha = uniform(1);\n\tprivate frozenCapture?: FrozenCapture;\n\n\t/** A source token belongs to one frozen source generation and output band only. */\n\trender(renderer: THREE.WebGPURenderer, opacity: number, draw: () => void,\n\t\twarmOutput?: CatalogWarmOutputContext, frozenSource?: object) {\n\t\tif (!frozenSource || warmOutput || opacity >= 1 || opacity <= 0) this.frozenCapture = undefined;\n\t\tif (opacity >= 1) {\n\t\t\tdraw();\n\t\t\treturn;\n\t\t}\n\t\tif (opacity <= 0) return;\n\t\tconst destination = renderer.getRenderTarget();\n\t\tconst size = destination ?? renderer.getDrawingBufferSize(new THREE.Vector2());\n\t\t// Use the same budget as the preparation target. Otherwise the first moving\n\t\t// frame reallocates a full-resolution MSAA capture after the bounded warm-up.\n\t\tconst { width, height } = getRefinementSize(size.width, size.height);\n\t\tif (!this.capture) {\n\t\t\tthis.capture = new THREE.RenderTarget(width, height, {\n\t\t\t\ttype: THREE.HalfFloatType,\n\t\t\t\tsamples: 4\n\t\t\t});\n\t\t\tthis.capture.addEventListener('dispose', () => { this.frozenCapture = undefined; });\n\t\t\tthis.material = new THREE.NodeMaterial();\n\t\t\tthis.material.fragmentNode = texture(this.capture.texture).mul(this.alpha);\n\t\t\tthis.material.transparent = true;\n\t\t\tthis.material.premultipliedAlpha = true;\n\t\t\tthis.material.depthTest = false;\n\t\t\tthis.material.depthWrite = false;\n\t\t\tthis.material.toneMapped = false;\n\t\t\tthis.quad = new THREE.QuadMesh(this.material);\n\t\t\t// Canvas output and High preparation can share a render-context format\n\t\t\t// while using different color spaces. Keep both render-object owners alive:\n\t\t\t// otherwise preparing High evicts the already warmed Canvas pipeline.\n\t\t\tthis.offscreenQuad = new THREE.QuadMesh(this.material);\n\t\t}\n\t\tthis.capture.setSize(width, height);\n\t\tconst next: FrozenCapture | undefined = frozenSource && !warmOutput ? {\n\t\t\tsource: frozenSource, renderer, destination,\n\t\t\tcanvas: destination ? undefined : renderer.getCanvasTarget(),\n\t\t\twidth: size.width, height: size.height, captureWidth: width, captureHeight: height,\n\t\t\tcoordinateSystem: renderer.coordinateSystem, toneMapping: renderer.toneMapping,\n\t\t\texposure: renderer.toneMappingExposure, colorSpace: renderer.outputColorSpace\n\t\t} : undefined;\n\t\tconst previous = this.frozenCapture;\n\t\tconst reuse = next && previous && next.source === previous.source && next.renderer === previous.renderer &&\n\t\t\tnext.destination === previous.destination && next.canvas === previous.canvas &&\n\t\t\tnext.width === previous.width && next.height === previous.height &&\n\t\t\tnext.captureWidth === previous.captureWidth && next.captureHeight === previous.captureHeight &&\n\t\t\tnext.coordinateSystem === previous.coordinateSystem && next.toneMapping === previous.toneMapping &&\n\t\t\tnext.exposure === previous.exposure && next.colorSpace === previous.colorSpace;\n\t\tconst color = renderer.getClearColor(new THREE.Color());\n\t\tconst clearAlpha = renderer.getClearAlpha();\n\t\tconst scissor = renderer.getScissor(new THREE.Vector4());\n\t\tconst scissorTest = renderer.getScissorTest();\n\t\ttry {\n\t\t\t// One shared scratch target: another band, ordinary draw or warmup replaces\n\t\t\t// these pixels. The first fractional frame always performs the full capture.\n\t\t\tthis.frozenCapture = undefined;\n\t\t\tif (!reuse) {\n\t\t\t\trenderer.setRenderTarget(this.capture);\n\t\t\t\trenderer.setScissorTest(false);\n\t\t\t\trenderer.setClearColor(0x000000, 0);\n\t\t\t\trenderer.clear();\n\t\t\t\tdraw();\n\t\t\t}\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\trenderer.setScissor(scissor);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t\tthis.alpha.value = opacity;\n\t\t\t(destination && !warmOutput?.usesCanvasOwner(destination) ? this.offscreenQuad : this.quad)!.render(renderer);\n\t\t} finally {\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\trenderer.setClearColor(color, clearAlpha);\n\t\t\trenderer.setScissor(scissor);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t}\n\t\tthis.frozenCapture = next;\n\t}\n\tdispose() {\n\t\tthis.frozenCapture = undefined;\n\t\tthis.capture?.dispose();\n\t\tthis.material?.dispose();\n\t\tthis.capture = undefined;\n\t\tthis.material = undefined;\n\t\tthis.quad = undefined;\n\t\tthis.offscreenQuad = undefined;\n\t}\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as THREE from 'three/webgpu';
|
|
2
2
|
import type { StageInteractionTheme } from '../stage/stageTypes.js';
|
|
3
3
|
import type { BlurRect } from './CatalogDepthBlur.js';
|
|
4
|
+
import type { CatalogWarmOutputContext } from './CatalogWarmOutputContext.js';
|
|
4
5
|
/** A shared, cropped silhouette target. Idle hover fades reuse its last mask. */
|
|
5
6
|
export declare class CatalogModelOutline {
|
|
6
7
|
private readonly scene;
|
|
@@ -15,6 +16,7 @@ export declare class CatalogModelOutline {
|
|
|
15
16
|
private maskMaterial?;
|
|
16
17
|
private material?;
|
|
17
18
|
private quad?;
|
|
19
|
+
private offscreenQuad?;
|
|
18
20
|
private captures;
|
|
19
21
|
private passes;
|
|
20
22
|
getRenderTargets(): THREE.RenderTarget<THREE.Texture<unknown, THREE.TextureEventMap>, THREE.RenderTargetEventMap>[];
|
|
@@ -24,7 +26,7 @@ export declare class CatalogModelOutline {
|
|
|
24
26
|
targets: number;
|
|
25
27
|
size: number;
|
|
26
28
|
};
|
|
27
|
-
render(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera, model: THREE.Object3D, bounds: BlurRect, clip: BlurRect, opacity: number, theme: StageInteractionTheme): void;
|
|
29
|
+
render(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera, model: THREE.Object3D, bounds: BlurRect, clip: BlurRect, opacity: number, theme: StageInteractionTheme, warmOutput?: CatalogWarmOutputContext): void;
|
|
28
30
|
release(model: THREE.Object3D): void;
|
|
29
31
|
dispose(): void;
|
|
30
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogModelOutline.d.ts","sourceRoot":"","sources":["../../src/catalog/CatalogModelOutline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"CatalogModelOutline.d.ts","sourceRoot":"","sources":["../../src/catalog/CatalogModelOutline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAE9E,iFAAiF;AACjF,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2B;IACpD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuB;IACnD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuB;IACpD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuB;IAClD,OAAO,CAAC,KAAK,CAAiD;IAC9D,OAAO,CAAC,MAAM,CAAC,CAAiB;IAChC,OAAO,CAAC,OAAO,CAAC,CAAqB;IACrC,OAAO,CAAC,YAAY,CAAC,CAA0B;IAC/C,OAAO,CAAC,QAAQ,CAAC,CAA8B;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAiB;IAC9B,OAAO,CAAC,aAAa,CAAC,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,MAAM,CAAK;IACnB,gBAAgB;IAChB,QAAQ;;;;;;IAER,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC,iBAAiB,EACrE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EACvD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,qBAAqB,EAAE,UAAU,CAAC,EAAE,wBAAwB;IA6FrF,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ;IAM7B,OAAO;CAQP"}
|
|
@@ -16,11 +16,12 @@ export class CatalogModelOutline {
|
|
|
16
16
|
maskMaterial;
|
|
17
17
|
material;
|
|
18
18
|
quad;
|
|
19
|
+
offscreenQuad;
|
|
19
20
|
captures = 0;
|
|
20
21
|
passes = 0;
|
|
21
22
|
getRenderTargets() { return this.capture ? [this.capture] : []; }
|
|
22
23
|
getStats() { return { captures: this.captures, passes: this.passes, targets: this.getRenderTargets().length, size: this.capture?.width ?? 0 }; }
|
|
23
|
-
render(renderer, camera, model, bounds, clip, opacity, theme) {
|
|
24
|
+
render(renderer, camera, model, bounds, clip, opacity, theme, warmOutput) {
|
|
24
25
|
if (opacity <= 0.001)
|
|
25
26
|
return;
|
|
26
27
|
const padding = Math.ceil(theme.outlineThickness * Math.max(1, theme.outlineGlowThickness) + 2);
|
|
@@ -39,6 +40,7 @@ export class CatalogModelOutline {
|
|
|
39
40
|
this.material.colorNode = this.controls.color;
|
|
40
41
|
this.material.opacityNode = createOutlineOpacity(texture(this.capture.texture), this.controls);
|
|
41
42
|
this.quad = new THREE.QuadMesh(this.material);
|
|
43
|
+
this.offscreenQuad = new THREE.QuadMesh(this.material);
|
|
42
44
|
}
|
|
43
45
|
let mask = this.masks.get(model);
|
|
44
46
|
if (!mask) {
|
|
@@ -75,6 +77,7 @@ export class CatalogModelOutline {
|
|
|
75
77
|
const destination = renderer.getRenderTarget();
|
|
76
78
|
const viewport = destination ? destination.viewport.clone() : renderer.getViewport(new THREE.Vector4());
|
|
77
79
|
const clearColor = renderer.getClearColor(new THREE.Color()), clearAlpha = renderer.getClearAlpha();
|
|
80
|
+
const scissor = renderer.getScissor(new THREE.Vector4());
|
|
78
81
|
const scissorTest = renderer.getScissorTest();
|
|
79
82
|
try {
|
|
80
83
|
renderer.setScissorTest(false);
|
|
@@ -89,13 +92,18 @@ export class CatalogModelOutline {
|
|
|
89
92
|
this.captures++;
|
|
90
93
|
}
|
|
91
94
|
renderer.setRenderTarget(destination);
|
|
95
|
+
// Only the offscreen mask ignores clipping. The final composite must
|
|
96
|
+
// respect its caller, including a zero-area idle-preparation scissor.
|
|
97
|
+
renderer.setScissor(scissor);
|
|
98
|
+
renderer.setScissorTest(scissorTest);
|
|
92
99
|
const scaleX = viewport.z / innerWidth, scaleY = viewport.w / innerHeight;
|
|
93
100
|
const output = new THREE.Vector4(viewport.x + left * scaleX, viewport.y + top * scaleY, width * scaleX, height * scaleY);
|
|
94
101
|
if (destination)
|
|
95
102
|
destination.viewport.copy(output);
|
|
96
103
|
else
|
|
97
104
|
renderer.setViewport(output);
|
|
98
|
-
|
|
105
|
+
// Keep Canvas and offscreen color-space variants owned independently.
|
|
106
|
+
(destination && !warmOutput?.usesCanvasOwner(destination) ? this.offscreenQuad : this.quad).render(renderer);
|
|
99
107
|
this.passes++;
|
|
100
108
|
}
|
|
101
109
|
finally {
|
|
@@ -105,6 +113,7 @@ export class CatalogModelOutline {
|
|
|
105
113
|
else
|
|
106
114
|
renderer.setViewport(viewport);
|
|
107
115
|
renderer.setClearColor(clearColor, clearAlpha);
|
|
116
|
+
renderer.setScissor(scissor);
|
|
108
117
|
renderer.setScissorTest(scissorTest);
|
|
109
118
|
}
|
|
110
119
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogModelOutline.js","sourceRoot":"","sources":["../../src/catalog/CatalogModelOutline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC5G,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAIrD,iFAAiF;AACjF,MAAM,OAAO,mBAAmB;IACd,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;IAC1B,MAAM,GAAG,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;IACvC,QAAQ,GAAG,qBAAqB,EAAE,CAAC;IACnC,WAAW,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;IAClC,YAAY,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;IACnC,UAAU,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;IAC1C,KAAK,GA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AAK,KAAK;YAAE,OAAO;QAClC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;IACD,OAAO;QACN,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;IAC1B,CAAC;CACD","sourcesContent":["import * as THREE from 'three/webgpu';\nimport { texture } from 'three/tsl';\nimport { createOutlineOpacity, createOutlineUniforms, isOutlineMesh } from '../stage/interactionOutline.js';\nimport { isMesh } from '../stage/stageSceneUtils.js';\nimport type { StageInteractionTheme } from '../stage/stageTypes.js';\nimport type { BlurRect } from './CatalogDepthBlur.js';\n\n/** A shared, cropped silhouette target. Idle hover fades reuse its last mask. */\nexport class CatalogModelOutline {\n\tprivate readonly scene = new THREE.Scene();\n\tprivate readonly camera = new THREE.PerspectiveCamera();\n\tprivate readonly controls = createOutlineUniforms();\n\tprivate readonly modelMatrix = new THREE.Matrix4();\n\tprivate readonly cameraMatrix = new THREE.Matrix4();\n\tprivate readonly projection = new THREE.Matrix4();\n\tprivate masks = new WeakMap<THREE.Object3D, THREE.Object3D>();\n\tprivate source?: THREE.Object3D;\n\tprivate capture?: THREE.RenderTarget;\n\tprivate maskMaterial?: THREE.MeshBasicMaterial;\n\tprivate material?: THREE.MeshBasicNodeMaterial;\n\tprivate quad?: THREE.QuadMesh;\n\tprivate captures = 0;\n\tprivate passes = 0;\n\tgetRenderTargets() { return this.capture ? [this.capture] : []; }\n\tgetStats() { return { captures: this.captures, passes: this.passes, targets: this.getRenderTargets().length, size: this.capture?.width ?? 0 }; }\n\n\trender(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera,\n\t\tmodel: THREE.Object3D, bounds: BlurRect, clip: BlurRect,\n\t\topacity: number, theme: StageInteractionTheme) {\n\t\tif (opacity <= 0.001) return;\n\t\tconst padding = Math.ceil(theme.outlineThickness * Math.max(1, theme.outlineGlowThickness) + 2);\n\t\tconst left = Math.max(0, clip.left, Math.floor(bounds.left - padding));\n\t\tconst top = Math.max(0, clip.top, Math.floor(bounds.top - padding));\n\t\tconst right = Math.min(innerWidth, clip.left + clip.width, Math.ceil(bounds.left + bounds.width + padding));\n\t\tconst bottom = Math.min(innerHeight, clip.top + clip.height, Math.ceil(bounds.top + bounds.height + padding));\n\t\tconst width = right - left, height = bottom - top;\n\t\tif (width <= 0 || height <= 0) return;\n\t\tif (!this.capture) {\n\t\t\tthis.capture = new THREE.RenderTarget(512, 512, { depthBuffer: true, samples: 4 });\n\t\t\tthis.capture.texture.generateMipmaps = false;\n\t\t\tthis.maskMaterial = new THREE.MeshBasicMaterial({ color: 0xffffff, side: THREE.DoubleSide, toneMapped: false });\n\t\t\tthis.material = new THREE.MeshBasicNodeMaterial({ transparent: true, depthTest: false, depthWrite: false, toneMapped: false });\n\t\t\tthis.material.colorNode = this.controls.color;\n\t\t\tthis.material.opacityNode = createOutlineOpacity(texture(this.capture.texture), this.controls);\n\t\t\tthis.quad = new THREE.QuadMesh(this.material);\n\t\t}\n\t\tlet mask = this.masks.get(model);\n\t\tif (!mask) {\n\t\t\tmask = model.clone(true);\n\t\t\tmask.traverse(child => {\n\t\t\t\tif (!isMesh(child)) return;\n\t\t\t\tchild.visible &&= isOutlineMesh(child, theme);\n\t\t\t\tchild.material = this.maskMaterial!;\n\t\t\t});\n\t\t\tmask.matrixAutoUpdate = false;\n\t\t\tthis.masks.set(model, mask);\n\t\t}\n\t\tmodel.updateWorldMatrix(true, false);\n\t\tmask.matrix.copy(model.matrixWorld);\n\t\tmask.matrixWorldNeedsUpdate = true;\n\t\tthis.camera.copy(camera);\n\t\t// Crop the actual projection, including custom transition camera matrices.\n\t\tthis.camera.projectionMatrix.copy(new THREE.Matrix4().set(\n\t\t\tinnerWidth / width, 0, 0, (innerWidth - 2 * left - width) / width,\n\t\t\t0, innerHeight / height, 0, (2 * top + height - innerHeight) / height,\n\t\t\t0, 0, 1, 0,\n\t\t\t0, 0, 0, 1\n\t\t).multiply(camera.projectionMatrix));\n\t\tthis.camera.projectionMatrixInverse.copy(this.camera.projectionMatrix).invert();\n\t\tconst changed = this.source !== model || !this.modelMatrix.equals(model.matrixWorld) ||\n\t\t\t!this.cameraMatrix.equals(camera.matrixWorld) || !this.projection.equals(this.camera.projectionMatrix);\n\t\tif (this.source !== model) {\n\t\t\tthis.scene.clear();\n\t\t\tthis.scene.add(mask);\n\t\t\tthis.source = model;\n\t\t}\n\t\tthis.controls.color.value.set(theme.outlineColor);\n\t\tthis.controls.strength.value = theme.outlineOpacity;\n\t\tthis.controls.glow.value = theme.outlineGlow;\n\t\tthis.controls.opacityScale.value = opacity;\n\t\tthis.controls.texel.value.set(theme.outlineThickness / width, theme.outlineThickness / height);\n\t\tthis.controls.glowTexel.value.copy(this.controls.texel.value).multiplyScalar(theme.outlineGlowThickness);\n\t\tconst destination = renderer.getRenderTarget();\n\t\tconst viewport = destination ? destination.viewport.clone() : renderer.getViewport(new THREE.Vector4());\n\t\tconst clearColor = renderer.getClearColor(new THREE.Color()), clearAlpha = renderer.getClearAlpha();\n\t\tconst scissorTest = renderer.getScissorTest();\n\t\ttry {\n\t\t\trenderer.setScissorTest(false);\n\t\t\tif (changed) {\n\t\t\t\trenderer.setRenderTarget(this.capture);\n\t\t\t\trenderer.setClearColor(0x000000, 0);\n\t\t\t\trenderer.clear();\n\t\t\t\trenderer.render(this.scene, this.camera);\n\t\t\t\tthis.modelMatrix.copy(model.matrixWorld);\n\t\t\t\tthis.cameraMatrix.copy(camera.matrixWorld);\n\t\t\t\tthis.projection.copy(this.camera.projectionMatrix);\n\t\t\t\tthis.captures++;\n\t\t\t}\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\tconst scaleX = viewport.z / innerWidth, scaleY = viewport.w / innerHeight;\n\t\t\tconst output = new THREE.Vector4(viewport.x + left * scaleX, viewport.y + top * scaleY, width * scaleX, height * scaleY);\n\t\t\tif (destination) destination.viewport.copy(output);\n\t\t\telse renderer.setViewport(output);\n\t\t\tthis.quad!.render(renderer);\n\t\t\tthis.passes++;\n\t\t} finally {\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\tif (destination) destination.viewport.copy(viewport);\n\t\t\telse renderer.setViewport(viewport);\n\t\t\trenderer.setClearColor(clearColor, clearAlpha);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t}\n\t}\n\trelease(model: THREE.Object3D) {\n\t\tthis.masks.delete(model);\n\t\tif (this.source !== model) return;\n\t\tthis.source = undefined;\n\t\tthis.scene.clear();\n\t}\n\tdispose() {\n\t\tthis.scene.clear();\n\t\tthis.source = undefined;\n\t\tthis.masks = new WeakMap();\n\t\tthis.capture?.dispose();\n\t\tthis.maskMaterial?.dispose();\n\t\tthis.material?.dispose();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CatalogModelOutline.js","sourceRoot":"","sources":["../../src/catalog/CatalogModelOutline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC5G,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAKrD,iFAAiF;AACjF,MAAM,OAAO,mBAAmB;IACd,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;IAC1B,MAAM,GAAG,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;IACvC,QAAQ,GAAG,qBAAqB,EAAE,CAAC;IACnC,WAAW,GAAG,IAAI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eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9G,IAAI,CAAC,MAAM,EAAE,CAAC;QACf,CAAC;gBAAS,CAAC;YACV,QAAQ,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;YACtC,IAAI,WAAW;gBAAE,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;;gBAChD,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACpC,QAAQ,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAC/C,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC7B,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;IACD,OAAO,CAAC,KAAqB;QAC5B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACzB,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK;YAAE,OAAO;QAClC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;IACD,OAAO;QACN,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;IAC1B,CAAC;CACD","sourcesContent":["import * as THREE from 'three/webgpu';\nimport { texture } from 'three/tsl';\nimport { createOutlineOpacity, createOutlineUniforms, isOutlineMesh } from '../stage/interactionOutline.js';\nimport { isMesh } from '../stage/stageSceneUtils.js';\nimport type { StageInteractionTheme } from '../stage/stageTypes.js';\nimport type { BlurRect } from './CatalogDepthBlur.js';\nimport type { CatalogWarmOutputContext } from './CatalogWarmOutputContext.js';\n\n/** A shared, cropped silhouette target. Idle hover fades reuse its last mask. */\nexport class CatalogModelOutline {\n\tprivate readonly scene = new THREE.Scene();\n\tprivate readonly camera = new THREE.PerspectiveCamera();\n\tprivate readonly controls = createOutlineUniforms();\n\tprivate readonly modelMatrix = new THREE.Matrix4();\n\tprivate readonly cameraMatrix = new THREE.Matrix4();\n\tprivate readonly projection = new THREE.Matrix4();\n\tprivate masks = new WeakMap<THREE.Object3D, THREE.Object3D>();\n\tprivate source?: THREE.Object3D;\n\tprivate capture?: THREE.RenderTarget;\n\tprivate maskMaterial?: THREE.MeshBasicMaterial;\n\tprivate material?: THREE.MeshBasicNodeMaterial;\n\tprivate quad?: THREE.QuadMesh;\n\tprivate offscreenQuad?: THREE.QuadMesh;\n\tprivate captures = 0;\n\tprivate passes = 0;\n\tgetRenderTargets() { return this.capture ? [this.capture] : []; }\n\tgetStats() { return { captures: this.captures, passes: this.passes, targets: this.getRenderTargets().length, size: this.capture?.width ?? 0 }; }\n\n\trender(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera,\n\t\tmodel: THREE.Object3D, bounds: BlurRect, clip: BlurRect,\n\t\topacity: number, theme: StageInteractionTheme, warmOutput?: CatalogWarmOutputContext) {\n\t\tif (opacity <= 0.001) return;\n\t\tconst padding = Math.ceil(theme.outlineThickness * Math.max(1, theme.outlineGlowThickness) + 2);\n\t\tconst left = Math.max(0, clip.left, Math.floor(bounds.left - padding));\n\t\tconst top = Math.max(0, clip.top, Math.floor(bounds.top - padding));\n\t\tconst right = Math.min(innerWidth, clip.left + clip.width, Math.ceil(bounds.left + bounds.width + padding));\n\t\tconst bottom = Math.min(innerHeight, clip.top + clip.height, Math.ceil(bounds.top + bounds.height + padding));\n\t\tconst width = right - left, height = bottom - top;\n\t\tif (width <= 0 || height <= 0) return;\n\t\tif (!this.capture) {\n\t\t\tthis.capture = new THREE.RenderTarget(512, 512, { depthBuffer: true, samples: 4 });\n\t\t\tthis.capture.texture.generateMipmaps = false;\n\t\t\tthis.maskMaterial = new THREE.MeshBasicMaterial({ color: 0xffffff, side: THREE.DoubleSide, toneMapped: false });\n\t\t\tthis.material = new THREE.MeshBasicNodeMaterial({ transparent: true, depthTest: false, depthWrite: false, toneMapped: false });\n\t\t\tthis.material.colorNode = this.controls.color;\n\t\t\tthis.material.opacityNode = createOutlineOpacity(texture(this.capture.texture), this.controls);\n\t\t\tthis.quad = new THREE.QuadMesh(this.material);\n\t\t\tthis.offscreenQuad = new THREE.QuadMesh(this.material);\n\t\t}\n\t\tlet mask = this.masks.get(model);\n\t\tif (!mask) {\n\t\t\tmask = model.clone(true);\n\t\t\tmask.traverse(child => {\n\t\t\t\tif (!isMesh(child)) return;\n\t\t\t\tchild.visible &&= isOutlineMesh(child, theme);\n\t\t\t\tchild.material = this.maskMaterial!;\n\t\t\t});\n\t\t\tmask.matrixAutoUpdate = false;\n\t\t\tthis.masks.set(model, mask);\n\t\t}\n\t\tmodel.updateWorldMatrix(true, false);\n\t\tmask.matrix.copy(model.matrixWorld);\n\t\tmask.matrixWorldNeedsUpdate = true;\n\t\tthis.camera.copy(camera);\n\t\t// Crop the actual projection, including custom transition camera matrices.\n\t\tthis.camera.projectionMatrix.copy(new THREE.Matrix4().set(\n\t\t\tinnerWidth / width, 0, 0, (innerWidth - 2 * left - width) / width,\n\t\t\t0, innerHeight / height, 0, (2 * top + height - innerHeight) / height,\n\t\t\t0, 0, 1, 0,\n\t\t\t0, 0, 0, 1\n\t\t).multiply(camera.projectionMatrix));\n\t\tthis.camera.projectionMatrixInverse.copy(this.camera.projectionMatrix).invert();\n\t\tconst changed = this.source !== model || !this.modelMatrix.equals(model.matrixWorld) ||\n\t\t\t!this.cameraMatrix.equals(camera.matrixWorld) || !this.projection.equals(this.camera.projectionMatrix);\n\t\tif (this.source !== model) {\n\t\t\tthis.scene.clear();\n\t\t\tthis.scene.add(mask);\n\t\t\tthis.source = model;\n\t\t}\n\t\tthis.controls.color.value.set(theme.outlineColor);\n\t\tthis.controls.strength.value = theme.outlineOpacity;\n\t\tthis.controls.glow.value = theme.outlineGlow;\n\t\tthis.controls.opacityScale.value = opacity;\n\t\tthis.controls.texel.value.set(theme.outlineThickness / width, theme.outlineThickness / height);\n\t\tthis.controls.glowTexel.value.copy(this.controls.texel.value).multiplyScalar(theme.outlineGlowThickness);\n\t\tconst destination = renderer.getRenderTarget();\n\t\tconst viewport = destination ? destination.viewport.clone() : renderer.getViewport(new THREE.Vector4());\n\t\tconst clearColor = renderer.getClearColor(new THREE.Color()), clearAlpha = renderer.getClearAlpha();\n\t\tconst scissor = renderer.getScissor(new THREE.Vector4());\n\t\tconst scissorTest = renderer.getScissorTest();\n\t\ttry {\n\t\t\trenderer.setScissorTest(false);\n\t\t\tif (changed) {\n\t\t\t\trenderer.setRenderTarget(this.capture);\n\t\t\t\trenderer.setClearColor(0x000000, 0);\n\t\t\t\trenderer.clear();\n\t\t\t\trenderer.render(this.scene, this.camera);\n\t\t\t\tthis.modelMatrix.copy(model.matrixWorld);\n\t\t\t\tthis.cameraMatrix.copy(camera.matrixWorld);\n\t\t\t\tthis.projection.copy(this.camera.projectionMatrix);\n\t\t\t\tthis.captures++;\n\t\t\t}\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\t// Only the offscreen mask ignores clipping. The final composite must\n\t\t\t// respect its caller, including a zero-area idle-preparation scissor.\n\t\t\trenderer.setScissor(scissor);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t\tconst scaleX = viewport.z / innerWidth, scaleY = viewport.w / innerHeight;\n\t\t\tconst output = new THREE.Vector4(viewport.x + left * scaleX, viewport.y + top * scaleY, width * scaleX, height * scaleY);\n\t\t\tif (destination) destination.viewport.copy(output);\n\t\t\telse renderer.setViewport(output);\n\t\t\t// Keep Canvas and offscreen color-space variants owned independently.\n\t\t\t(destination && !warmOutput?.usesCanvasOwner(destination) ? this.offscreenQuad : this.quad)!.render(renderer);\n\t\t\tthis.passes++;\n\t\t} finally {\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\tif (destination) destination.viewport.copy(viewport);\n\t\t\telse renderer.setViewport(viewport);\n\t\t\trenderer.setClearColor(clearColor, clearAlpha);\n\t\t\trenderer.setScissor(scissor);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t}\n\t}\n\trelease(model: THREE.Object3D) {\n\t\tthis.masks.delete(model);\n\t\tif (this.source !== model) return;\n\t\tthis.source = undefined;\n\t\tthis.scene.clear();\n\t}\n\tdispose() {\n\t\tthis.scene.clear();\n\t\tthis.source = undefined;\n\t\tthis.masks = new WeakMap();\n\t\tthis.capture?.dispose();\n\t\tthis.maskMaterial?.dispose();\n\t\tthis.material?.dispose();\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogPreparation.d.ts","sourceRoot":"","sources":["../../src/catalog/CatalogPreparation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAQrF,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,KAAK,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACtH,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,MAAM,WAAW,YAAY;IAC5B,QAAQ,EAAE,2BAA2B,CAAC;IACtC,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC;IACrB,SAAS,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/B,KAAK,EAAE,w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B,CAAC;gBAE3B,MAAM,EAAE,0BAA0B,EAClC,YAAY,EAAE,gBAAgB,EAC9B,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,CACb,IAAI,EAAE,YAAY,EAClB,WAAW,EAAE,mBAAmB,EAChC,MAAM,EAAE,WAAW,KACf,OAAO,CAAC,IAAI,CAAC,EACV,OAAO,EAAE,MAAM,IAAI;IAE5B,OAAO,CAAC,KAAK,EAAE,mBAAmB;IA2FlC,QAAQ,CAAC,KAAK,EAAE,yBAAyB;IAQzC,OAAO;CAQP;AACD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,QAKrD"}
|
|
@@ -34,15 +34,17 @@ export class CatalogPreparation {
|
|
|
34
34
|
highState: pair ? 'loading' : 'unavailable'
|
|
35
35
|
};
|
|
36
36
|
this.current = entry;
|
|
37
|
+
const setBackgroundState = (state) => {
|
|
38
|
+
if (this.current !== entry || entry.controller.signal.aborted || entry.backgroundState === state)
|
|
39
|
+
return;
|
|
40
|
+
entry.backgroundState = state;
|
|
41
|
+
this.changed();
|
|
42
|
+
};
|
|
37
43
|
void entry.environment.ready
|
|
38
44
|
.then(async () => {
|
|
39
45
|
await this.gate.wait(entry.controller.signal);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, () => {
|
|
43
|
-
entry.backgroundState = 'failed';
|
|
44
|
-
this.changed();
|
|
45
|
-
})
|
|
46
|
+
setBackgroundState('ready');
|
|
47
|
+
}, () => setBackgroundState('failed'))
|
|
46
48
|
.catch(() => { });
|
|
47
49
|
if (entry.environment.value)
|
|
48
50
|
entry.backgroundState = 'ready';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CatalogPreparation.js","sourceRoot":"","sources":["../../src/catalog/CatalogPreparation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,0BAA0B,EA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QAAQ,EAAE,OAAO,EAAE,CAAC;oBACpB,IAAI,IAAI;wBAAE,mBAAmB,CAAC,IAAI,CAAC,CAAC;oBACpC,KAAK,CAAC,OAAO,EAAE,CAAC;gBACjB,CAAC;YACF,CAAC,CAAC,EAAE,CAAC;QACN,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;IACD,QAAQ,CAAC,KAAgC;QACxC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACxB,IAAI,IAAI,EAAE,CAAC;YACV,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;YACvB,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;QAC7B,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IACD,OAAO;QACN,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,KAAK;YAAE,OAAO;QACnB,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,IAAI;YAAE,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACD;AACD,MAAM,UAAU,mBAAmB,CAAC,IAAkB;IACrD,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACrB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACzD,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;AACzB,CAAC","sourcesContent":["import * as THREE from 'three/webgpu';\nimport { DEFAULT_BACKGROUND } from '../stage/stageConstants.js';\nimport type { SpatialElementScene } from '../spatial-element/spatialElementScene.js';\nimport { prepareSpatialElementFrame } from '../stage/spatialElementFrame.js';\nimport {\n\tapplyModelMaterialOverrides,\n\tgetMeshBounds,\n\tgetMeshMaterials,\n\tisMesh\n} from '../stage/stageSceneUtils.js';\nimport { SpatialElementRefinement } from '../stage/SpatialElementRefinement.js';\nimport type { SpatialElementAssetInstance, SpatialElementAssetManager } from './assets/SpatialElementAssetManager.js';\nimport type { EnvironmentCache, PreparedEnvironment } from './EnvironmentCache.js';\nimport type { PreparationGate } from './PreparationGate.js';\nimport { resolveSpatialElementLodPair } from './spatialElementLodPair.js';\n\nexport interface PreparedHigh {\n\tinstance: SpatialElementAssetInstance;\n\tpose: THREE.Object3D;\n\toverrides: Set<THREE.Material>;\n\tblend: SpatialElementRefinement;\n}\nexport interface SpatialElementPreparation {\n\tkey: string;\n\tcontroller: AbortController;\n\tenvironment: ReturnType<EnvironmentCache['acquire']>;\n\tbackgroundState: 'loading' | 'ready' | 'failed';\n\thighState: 'loading' | 'ready' | 'failed' | 'unavailable' | 'adopted';\n\thigh?: PreparedHigh;\n\ttimings?: { buildMs: number; gpuWarmMs: number };\n}\nexport const preparationKey = (\n\tstage: Pick<SpatialElementScene, 'hdr' | 'glb' | 'lodPair' | 'model' | 'background'>\n) => JSON.stringify([stage.hdr, stage.glb, stage.lodPair, stage.model ?? {}, { ...DEFAULT_BACKGROUND, ...stage.background }]);\n\n/** At most one speculative presentation is retained; active instances are adopted by the stage. */\nexport class CatalogPreparation {\n\tcurrent?: SpatialElementPreparation;\n\tconstructor(\n\t\tprivate assets: SpatialElementAssetManager,\n\t\tprivate environments: EnvironmentCache,\n\t\tprivate gate: PreparationGate,\n\t\tprivate warm: (\n\t\t\thigh: PreparedHigh,\n\t\t\tenvironment: PreparedEnvironment,\n\t\t\tsignal: AbortSignal\n\t\t) => Promise<void>,\n\t\tprivate changed: () => void\n\t) {}\n\tprepare(stage: SpatialElementScene) {\n\t\tconst key = preparationKey(stage);\n\t\tif (this.current?.key === key && this.current.highState !== 'adopted') return this.current;\n\t\tthis.dispose();\n\t\tconst pair = resolveSpatialElementLodPair(stage.glb, stage.lodPair);\n\t\tconst entry: SpatialElementPreparation = {\n\t\t\tkey,\n\t\t\tcontroller: new AbortController(),\n\t\t\tenvironment: this.environments.acquire(stage.hdr),\n\t\t\tbackgroundState: 'loading',\n\t\t\thighState: pair ? 'loading' : 'unavailable'\n\t\t};\n\t\tthis.current = entry;\n\t\tvoid entry.environment.ready\n\t\t\t.then(\n\t\t\t\tasync () => {\n\t\t\t\t\tawait this.gate.wait(entry.controller.signal);\n\t\t\t\t\tentry.backgroundState = 'ready';\n\t\t\t\t\tthis.changed();\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tentry.backgroundState = 'failed';\n\t\t\t\t\tthis.changed();\n\t\t\t\t}\n\t\t\t)\n\t\t\t.catch(() => {});\n\t\tif (entry.environment.value) entry.backgroundState = 'ready';\n\t\tif (pair) {\n\t\t\tconst signal = entry.controller.signal;\n\t\t\tconst lease = this.assets.acquire(pair.high, { signal });\n\t\t\tvoid (async () => {\n\t\t\t\tlet high: PreparedHigh | undefined;\n\t\t\t\tlet instance: SpatialElementAssetInstance | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tconst [, environment] = await Promise.all([lease.ready, entry.environment.ready]);\n\t\t\t\t\tawait this.gate.wait(signal);\n\t\t\t\t\tinstance = await lease.createInstance();\n\t\t\t\t\tlet buildStarted = 0;\n\t\t\t\t\tawait this.gate.run(() => {\n\t\t\t\t\t\tbuildStarted = performance.now();\n\t\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t\t\tconst settings = stage.model ?? {};\n\t\t\t\t\t\tapplyModelMaterialOverrides(instance!.scene, settings.materialOverrides);\n\t\t\t\t\t\tconst overrides = new Set<THREE.Material>();\n\t\t\t\t\t\tconst excluded = new Set(settings.excludeMeshes ?? []);\n\t\t\t\t\t\tinstance!.scene.traverse((object) => {\n\t\t\t\t\t\t\tif (!isMesh(object)) return;\n\t\t\t\t\t\t\tif (excluded.has(object.name)) object.visible = false;\n\t\t\t\t\t\t\tif (settings.materialOverrides?.[object.name])\n\t\t\t\t\t\t\t\tgetMeshMaterials(object).forEach((material) => overrides.add(material));\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst container = new THREE.Group();\n\t\t\t\t\t\tprepareSpatialElementFrame(container, instance!.scene, pair, settings);\n\t\t\t\t\t\thigh = {\n\t\t\t\t\t\t\tinstance: instance!,\n\t\t\t\t\t\t\toverrides,\n\t\t\t\t\t\t\tpose: container.children[0],\n\t\t\t\t\t\t\tblend: new SpatialElementRefinement(true)\n\t\t\t\t\t\t};\n\t\t\t\t\t\tinstance = undefined;\n\t\t\t\t\t\tif (getMeshBounds(container, (mesh) => !excluded.has(mesh.name)).isEmpty())\n\t\t\t\t\t\t\tthrow new Error('High contains no spatialElement meshes');\n\t\t\t\t\t}, signal);\n\t\t\t\t\tconst warmStarted = performance.now();\n\t\t\t\t\tawait this.warm(high!, environment, signal);\n\t\t\t\t\tentry.timings = {\n\t\t\t\t\t\tbuildMs: warmStarted - buildStarted,\n\t\t\t\t\t\tgpuWarmMs: performance.now() - warmStarted\n\t\t\t\t\t};\n\t\t\t\t\tawait this.gate.wait(signal);\n\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t\tentry.high = high;\n\t\t\t\t\thigh = undefined;\n\t\t\t\t\tentry.highState = 'ready';\n\t\t\t\t\tthis.changed();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!signal.aborted) {\n\t\t\t\t\t\tentry.highState = 'failed';\n\t\t\t\t\t\tconsole.warn('Optional spatialElement preparation failed; retaining Low', error);\n\t\t\t\t\t\tthis.changed();\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tinstance?.dispose();\n\t\t\t\t\tif (high) disposePreparedHigh(high);\n\t\t\t\t\tlease.release();\n\t\t\t\t}\n\t\t\t})();\n\t\t}\n\t\treturn entry;\n\t}\n\ttakeHigh(entry: SpatialElementPreparation) {\n\t\tconst high = entry.high;\n\t\tif (high) {\n\t\t\tentry.high = undefined;\n\t\t\tentry.highState = 'adopted';\n\t\t}\n\t\treturn high;\n\t}\n\tdispose() {\n\t\tconst entry = this.current;\n\t\tthis.current = undefined;\n\t\tif (!entry) return;\n\t\tentry.controller.abort();\n\t\tentry.environment.release();\n\t\tif (entry.high) disposePreparedHigh(entry.high);\n\t}\n}\nexport function disposePreparedHigh(high: PreparedHigh) {\n\thigh.pose.removeFromParent();\n\thigh.blend.dispose();\n\thigh.overrides.forEach((material) => material.dispose());\n\thigh.instance.dispose();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"CatalogPreparation.js","sourceRoot":"","sources":["../../src/catalog/CatalogPreparation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EACN,2BAA2B,EAC3B,aAAa,EACb,gBAAgB,EAChB,MAAM,EACN,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAIhF,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAiB1E,MAAM,CAAC,MAAM,cAAc,GAAG,CAC7B,KAAoF,EACnF,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,EAAE,GAAG,kBAAkB,EAAE,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;AAE9H,mGAAmG;AACnG,MAAM,OAAO,kBAAkB;IAGrB;IACA;IACA;IACA;IAKA;IAVT,OAAO,CAA6B;IACpC,YACS,MAAkC,EAClC,YAA8B,EAC9B,IAAqB,EACrB,IAIU,EACV,OAAmB;QARnB,WAAM,GAAN,MAAM,C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O,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,KAAK;YAAE,OAAO;QACnB,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACzB,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,KAAK,CAAC,IAAI;YAAE,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CACD;AACD,MAAM,UAAU,mBAAmB,CAAC,IAAkB;IACrD,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACrB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACzD,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;AACzB,CAAC","sourcesContent":["import * as THREE from 'three/webgpu';\nimport { DEFAULT_BACKGROUND } from '../stage/stageConstants.js';\nimport type { SpatialElementScene } from '../spatial-element/spatialElementScene.js';\nimport { prepareSpatialElementFrame } from '../stage/spatialElementFrame.js';\nimport {\n\tapplyModelMaterialOverrides,\n\tgetMeshBounds,\n\tgetMeshMaterials,\n\tisMesh\n} from '../stage/stageSceneUtils.js';\nimport { SpatialElementRefinement } from '../stage/SpatialElementRefinement.js';\nimport type { SpatialElementAssetInstance, SpatialElementAssetManager } from './assets/SpatialElementAssetManager.js';\nimport type { EnvironmentCache, PreparedEnvironment } from './EnvironmentCache.js';\nimport type { PreparationGate } from './PreparationGate.js';\nimport { resolveSpatialElementLodPair } from './spatialElementLodPair.js';\n\nexport interface PreparedHigh {\n\tinstance: SpatialElementAssetInstance;\n\tpose: THREE.Object3D;\n\toverrides: Set<THREE.Material>;\n\tblend: SpatialElementRefinement;\n}\nexport interface SpatialElementPreparation {\n\tkey: string;\n\tcontroller: AbortController;\n\tenvironment: ReturnType<EnvironmentCache['acquire']>;\n\tbackgroundState: 'loading' | 'ready' | 'failed';\n\thighState: 'loading' | 'ready' | 'failed' | 'unavailable' | 'adopted';\n\thigh?: PreparedHigh;\n\ttimings?: { buildMs: number; gpuWarmMs: number };\n}\nexport const preparationKey = (\n\tstage: Pick<SpatialElementScene, 'hdr' | 'glb' | 'lodPair' | 'model' | 'background'>\n) => JSON.stringify([stage.hdr, stage.glb, stage.lodPair, stage.model ?? {}, { ...DEFAULT_BACKGROUND, ...stage.background }]);\n\n/** At most one speculative presentation is retained; active instances are adopted by the stage. */\nexport class CatalogPreparation {\n\tcurrent?: SpatialElementPreparation;\n\tconstructor(\n\t\tprivate assets: SpatialElementAssetManager,\n\t\tprivate environments: EnvironmentCache,\n\t\tprivate gate: PreparationGate,\n\t\tprivate warm: (\n\t\t\thigh: PreparedHigh,\n\t\t\tenvironment: PreparedEnvironment,\n\t\t\tsignal: AbortSignal\n\t\t) => Promise<void>,\n\t\tprivate changed: () => void\n\t) {}\n\tprepare(stage: SpatialElementScene) {\n\t\tconst key = preparationKey(stage);\n\t\tif (this.current?.key === key && this.current.highState !== 'adopted') return this.current;\n\t\tthis.dispose();\n\t\tconst pair = resolveSpatialElementLodPair(stage.glb, stage.lodPair);\n\t\tconst entry: SpatialElementPreparation = {\n\t\t\tkey,\n\t\t\tcontroller: new AbortController(),\n\t\t\tenvironment: this.environments.acquire(stage.hdr),\n\t\t\tbackgroundState: 'loading',\n\t\t\thighState: pair ? 'loading' : 'unavailable'\n\t\t};\n\t\tthis.current = entry;\n\t\tconst setBackgroundState = (state: 'ready' | 'failed') => {\n\t\t\tif (this.current !== entry || entry.controller.signal.aborted || entry.backgroundState === state) return;\n\t\t\tentry.backgroundState = state;\n\t\t\tthis.changed();\n\t\t};\n\t\tvoid entry.environment.ready\n\t\t\t.then(\n\t\t\t\tasync () => {\n\t\t\t\t\tawait this.gate.wait(entry.controller.signal);\n\t\t\t\t\tsetBackgroundState('ready');\n\t\t\t\t},\n\t\t\t\t() => setBackgroundState('failed')\n\t\t\t)\n\t\t\t.catch(() => {});\n\t\tif (entry.environment.value) entry.backgroundState = 'ready';\n\t\tif (pair) {\n\t\t\tconst signal = entry.controller.signal;\n\t\t\tconst lease = this.assets.acquire(pair.high, { signal });\n\t\t\tvoid (async () => {\n\t\t\t\tlet high: PreparedHigh | undefined;\n\t\t\t\tlet instance: SpatialElementAssetInstance | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tconst [, environment] = await Promise.all([lease.ready, entry.environment.ready]);\n\t\t\t\t\tawait this.gate.wait(signal);\n\t\t\t\t\tinstance = await lease.createInstance();\n\t\t\t\t\tlet buildStarted = 0;\n\t\t\t\t\tawait this.gate.run(() => {\n\t\t\t\t\t\tbuildStarted = performance.now();\n\t\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t\t\tconst settings = stage.model ?? {};\n\t\t\t\t\t\tapplyModelMaterialOverrides(instance!.scene, settings.materialOverrides);\n\t\t\t\t\t\tconst overrides = new Set<THREE.Material>();\n\t\t\t\t\t\tconst excluded = new Set(settings.excludeMeshes ?? []);\n\t\t\t\t\t\tinstance!.scene.traverse((object) => {\n\t\t\t\t\t\t\tif (!isMesh(object)) return;\n\t\t\t\t\t\t\tif (excluded.has(object.name)) object.visible = false;\n\t\t\t\t\t\t\tif (settings.materialOverrides?.[object.name])\n\t\t\t\t\t\t\t\tgetMeshMaterials(object).forEach((material) => overrides.add(material));\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst container = new THREE.Group();\n\t\t\t\t\t\tprepareSpatialElementFrame(container, instance!.scene, pair, settings);\n\t\t\t\t\t\thigh = {\n\t\t\t\t\t\t\tinstance: instance!,\n\t\t\t\t\t\t\toverrides,\n\t\t\t\t\t\t\tpose: container.children[0],\n\t\t\t\t\t\t\tblend: new SpatialElementRefinement(true)\n\t\t\t\t\t\t};\n\t\t\t\t\t\tinstance = undefined;\n\t\t\t\t\t\tif (getMeshBounds(container, (mesh) => !excluded.has(mesh.name)).isEmpty())\n\t\t\t\t\t\t\tthrow new Error('High contains no spatialElement meshes');\n\t\t\t\t\t}, signal);\n\t\t\t\t\tconst warmStarted = performance.now();\n\t\t\t\t\tawait this.warm(high!, environment, signal);\n\t\t\t\t\tentry.timings = {\n\t\t\t\t\t\tbuildMs: warmStarted - buildStarted,\n\t\t\t\t\t\tgpuWarmMs: performance.now() - warmStarted\n\t\t\t\t\t};\n\t\t\t\t\tawait this.gate.wait(signal);\n\t\t\t\t\tsignal.throwIfAborted();\n\t\t\t\t\tentry.high = high;\n\t\t\t\t\thigh = undefined;\n\t\t\t\t\tentry.highState = 'ready';\n\t\t\t\t\tthis.changed();\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (!signal.aborted) {\n\t\t\t\t\t\tentry.highState = 'failed';\n\t\t\t\t\t\tconsole.warn('Optional spatialElement preparation failed; retaining Low', error);\n\t\t\t\t\t\tthis.changed();\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tinstance?.dispose();\n\t\t\t\t\tif (high) disposePreparedHigh(high);\n\t\t\t\t\tlease.release();\n\t\t\t\t}\n\t\t\t})();\n\t\t}\n\t\treturn entry;\n\t}\n\ttakeHigh(entry: SpatialElementPreparation) {\n\t\tconst high = entry.high;\n\t\tif (high) {\n\t\t\tentry.high = undefined;\n\t\t\tentry.highState = 'adopted';\n\t\t}\n\t\treturn high;\n\t}\n\tdispose() {\n\t\tconst entry = this.current;\n\t\tthis.current = undefined;\n\t\tif (!entry) return;\n\t\tentry.controller.abort();\n\t\tentry.environment.release();\n\t\tif (entry.high) disposePreparedHigh(entry.high);\n\t}\n}\nexport function disposePreparedHigh(high: PreparedHigh) {\n\thigh.pose.removeFromParent();\n\thigh.blend.dispose();\n\thigh.overrides.forEach((material) => material.dispose());\n\thigh.instance.dispose();\n}\n"]}
|