@spatial-elements/core 0.1.0-beta.1
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/LICENSE +373 -0
- package/README.md +17 -0
- package/dist/catalog/CarouselGlassCompositor.d.ts +24 -0
- package/dist/catalog/CarouselGlassCompositor.d.ts.map +1 -0
- package/dist/catalog/CarouselGlassCompositor.js +132 -0
- package/dist/catalog/CarouselGlassCompositor.js.map +1 -0
- package/dist/catalog/CatalogEndpointRegistry.d.ts +59 -0
- package/dist/catalog/CatalogEndpointRegistry.d.ts.map +1 -0
- package/dist/catalog/CatalogEndpointRegistry.js +187 -0
- package/dist/catalog/CatalogEndpointRegistry.js.map +1 -0
- package/dist/catalog/CatalogGeometryFade.d.ts +12 -0
- package/dist/catalog/CatalogGeometryFade.d.ts.map +1 -0
- package/dist/catalog/CatalogGeometryFade.js +67 -0
- package/dist/catalog/CatalogGeometryFade.js.map +1 -0
- package/dist/catalog/CatalogPreparation.d.ts +40 -0
- package/dist/catalog/CatalogPreparation.d.ts.map +1 -0
- package/dist/catalog/CatalogPreparation.js +141 -0
- package/dist/catalog/CatalogPreparation.js.map +1 -0
- package/dist/catalog/CatalogSections.d.ts +36 -0
- package/dist/catalog/CatalogSections.d.ts.map +1 -0
- package/dist/catalog/CatalogSections.js +51 -0
- package/dist/catalog/CatalogSections.js.map +1 -0
- package/dist/catalog/CatalogSpatialElementLayer.d.ts +149 -0
- package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -0
- package/dist/catalog/CatalogSpatialElementLayer.js +920 -0
- package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -0
- package/dist/catalog/CatalogTransition.d.ts +93 -0
- package/dist/catalog/CatalogTransition.d.ts.map +1 -0
- package/dist/catalog/CatalogTransition.js +1299 -0
- package/dist/catalog/CatalogTransition.js.map +1 -0
- package/dist/catalog/EnvironmentCache.d.ts +30 -0
- package/dist/catalog/EnvironmentCache.d.ts.map +1 -0
- package/dist/catalog/EnvironmentCache.js +128 -0
- package/dist/catalog/EnvironmentCache.js.map +1 -0
- package/dist/catalog/PreparationGate.d.ts +10 -0
- package/dist/catalog/PreparationGate.d.ts.map +1 -0
- package/dist/catalog/PreparationGate.js +66 -0
- package/dist/catalog/PreparationGate.js.map +1 -0
- package/dist/catalog/PresentationLease.d.ts +16 -0
- package/dist/catalog/PresentationLease.d.ts.map +1 -0
- package/dist/catalog/PresentationLease.js +33 -0
- package/dist/catalog/PresentationLease.js.map +1 -0
- package/dist/catalog/SpatialGeometryCapture.d.ts +63 -0
- package/dist/catalog/SpatialGeometryCapture.d.ts.map +1 -0
- package/dist/catalog/SpatialGeometryCapture.js +158 -0
- package/dist/catalog/SpatialGeometryCapture.js.map +1 -0
- package/dist/catalog/assets/SpatialElementAssetManager.d.ts +92 -0
- package/dist/catalog/assets/SpatialElementAssetManager.d.ts.map +1 -0
- package/dist/catalog/assets/SpatialElementAssetManager.js +305 -0
- package/dist/catalog/assets/SpatialElementAssetManager.js.map +1 -0
- package/dist/catalog/assets/assetCosts.d.ts +4 -0
- package/dist/catalog/assets/assetCosts.d.ts.map +1 -0
- package/dist/catalog/assets/assetCosts.js +33 -0
- package/dist/catalog/assets/assetCosts.js.map +1 -0
- package/dist/catalog/assets/spatialElementAssetResources.d.ts +25 -0
- package/dist/catalog/assets/spatialElementAssetResources.d.ts.map +1 -0
- package/dist/catalog/assets/spatialElementAssetResources.js +100 -0
- package/dist/catalog/assets/spatialElementAssetResources.js.map +1 -0
- package/dist/catalog/carouselPanelProjection.d.ts +9 -0
- package/dist/catalog/carouselPanelProjection.d.ts.map +1 -0
- package/dist/catalog/carouselPanelProjection.js +33 -0
- package/dist/catalog/carouselPanelProjection.js.map +1 -0
- package/dist/catalog/carouselSelection.d.ts +7 -0
- package/dist/catalog/carouselSelection.d.ts.map +1 -0
- package/dist/catalog/carouselSelection.js +15 -0
- package/dist/catalog/carouselSelection.js.map +1 -0
- package/dist/catalog/catalogAction.d.ts +4 -0
- package/dist/catalog/catalogAction.d.ts.map +1 -0
- package/dist/catalog/catalogAction.js +9 -0
- package/dist/catalog/catalogAction.js.map +1 -0
- package/dist/catalog/catalogGeometryRequest.d.ts +13 -0
- package/dist/catalog/catalogGeometryRequest.d.ts.map +1 -0
- package/dist/catalog/catalogGeometryRequest.js +8 -0
- package/dist/catalog/catalogGeometryRequest.js.map +1 -0
- package/dist/catalog/catalogItems.d.ts +10 -0
- package/dist/catalog/catalogItems.d.ts.map +1 -0
- package/dist/catalog/catalogItems.js +23 -0
- package/dist/catalog/catalogItems.js.map +1 -0
- package/dist/catalog/catalogJourney.d.ts +38 -0
- package/dist/catalog/catalogJourney.d.ts.map +1 -0
- package/dist/catalog/catalogJourney.js +64 -0
- package/dist/catalog/catalogJourney.js.map +1 -0
- package/dist/catalog/catalogPage.d.ts +11 -0
- package/dist/catalog/catalogPage.d.ts.map +1 -0
- package/dist/catalog/catalogPage.js +2 -0
- package/dist/catalog/catalogPage.js.map +1 -0
- package/dist/catalog/catalogPose.d.ts +30 -0
- package/dist/catalog/catalogPose.d.ts.map +1 -0
- package/dist/catalog/catalogPose.js +35 -0
- package/dist/catalog/catalogPose.js.map +1 -0
- package/dist/catalog/catalogPresentation.d.ts +24 -0
- package/dist/catalog/catalogPresentation.d.ts.map +1 -0
- package/dist/catalog/catalogPresentation.js +56 -0
- package/dist/catalog/catalogPresentation.js.map +1 -0
- package/dist/catalog/catalogRecipes.d.ts +21 -0
- package/dist/catalog/catalogRecipes.d.ts.map +1 -0
- package/dist/catalog/catalogRecipes.js +84 -0
- package/dist/catalog/catalogRecipes.js.map +1 -0
- package/dist/catalog/catalogSurfaceCapture.d.ts +11 -0
- package/dist/catalog/catalogSurfaceCapture.d.ts.map +1 -0
- package/dist/catalog/catalogSurfaceCapture.js +11 -0
- package/dist/catalog/catalogSurfaceCapture.js.map +1 -0
- package/dist/catalog/catalogViewLink.d.ts +8 -0
- package/dist/catalog/catalogViewLink.d.ts.map +1 -0
- package/dist/catalog/catalogViewLink.js +37 -0
- package/dist/catalog/catalogViewLink.js.map +1 -0
- package/dist/catalog/rebasePresentation.d.ts +3 -0
- package/dist/catalog/rebasePresentation.d.ts.map +1 -0
- package/dist/catalog/rebasePresentation.js +26 -0
- package/dist/catalog/rebasePresentation.js.map +1 -0
- package/dist/catalog/spatialElementAssets.d.ts +158 -0
- package/dist/catalog/spatialElementAssets.d.ts.map +1 -0
- package/dist/catalog/spatialElementAssets.js +92 -0
- package/dist/catalog/spatialElementAssets.js.map +1 -0
- package/dist/catalog/spatialElementLodPair.d.ts +17 -0
- package/dist/catalog/spatialElementLodPair.d.ts.map +1 -0
- package/dist/catalog/spatialElementLodPair.js +5 -0
- package/dist/catalog/spatialElementLodPair.js.map +1 -0
- package/dist/catalog/transitionTiming.d.ts +15 -0
- package/dist/catalog/transitionTiming.d.ts.map +1 -0
- package/dist/catalog/transitionTiming.js +22 -0
- package/dist/catalog/transitionTiming.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/spatial-element/SpatialElementDockController.d.ts +101 -0
- package/dist/spatial-element/SpatialElementDockController.d.ts.map +1 -0
- package/dist/spatial-element/SpatialElementDockController.js +627 -0
- package/dist/spatial-element/SpatialElementDockController.js.map +1 -0
- package/dist/spatial-element/spatialElement.d.ts +28 -0
- package/dist/spatial-element/spatialElement.d.ts.map +1 -0
- package/dist/spatial-element/spatialElement.js +45 -0
- package/dist/spatial-element/spatialElement.js.map +1 -0
- package/dist/spatial-element/spatialElementDock.d.ts +43 -0
- package/dist/spatial-element/spatialElementDock.d.ts.map +1 -0
- package/dist/spatial-element/spatialElementDock.js +126 -0
- package/dist/spatial-element/spatialElementDock.js.map +1 -0
- package/dist/spatial-element/spatialElementSectionRegistry.d.ts +29 -0
- package/dist/spatial-element/spatialElementSectionRegistry.d.ts.map +1 -0
- package/dist/spatial-element/spatialElementSectionRegistry.js +67 -0
- package/dist/spatial-element/spatialElementSectionRegistry.js.map +1 -0
- package/dist/spatial-element/types.d.ts +165 -0
- package/dist/spatial-element/types.d.ts.map +1 -0
- package/dist/spatial-element/types.js +2 -0
- package/dist/spatial-element/types.js.map +1 -0
- package/dist/stage/LiquidGlassPanel.d.ts +55 -0
- package/dist/stage/LiquidGlassPanel.d.ts.map +1 -0
- package/dist/stage/LiquidGlassPanel.js +447 -0
- package/dist/stage/LiquidGlassPanel.js.map +1 -0
- package/dist/stage/MinimapBlurPipeline.d.ts +34 -0
- package/dist/stage/MinimapBlurPipeline.d.ts.map +1 -0
- package/dist/stage/MinimapBlurPipeline.js +147 -0
- package/dist/stage/MinimapBlurPipeline.js.map +1 -0
- package/dist/stage/MinimapController.d.ts +113 -0
- package/dist/stage/MinimapController.d.ts.map +1 -0
- package/dist/stage/MinimapController.js +803 -0
- package/dist/stage/MinimapController.js.map +1 -0
- package/dist/stage/OrbitControlsInterop.d.ts +8 -0
- package/dist/stage/OrbitControlsInterop.d.ts.map +1 -0
- package/dist/stage/OrbitControlsInterop.js +19 -0
- package/dist/stage/OrbitControlsInterop.js.map +1 -0
- package/dist/stage/PageBindingController.d.ts +41 -0
- package/dist/stage/PageBindingController.d.ts.map +1 -0
- package/dist/stage/PageBindingController.js +92 -0
- package/dist/stage/PageBindingController.js.map +1 -0
- package/dist/stage/PanelPresentationController.d.ts +92 -0
- package/dist/stage/PanelPresentationController.d.ts.map +1 -0
- package/dist/stage/PanelPresentationController.js +569 -0
- package/dist/stage/PanelPresentationController.js.map +1 -0
- package/dist/stage/PresentationReadiness.d.ts +30 -0
- package/dist/stage/PresentationReadiness.d.ts.map +1 -0
- package/dist/stage/PresentationReadiness.js +94 -0
- package/dist/stage/PresentationReadiness.js.map +1 -0
- package/dist/stage/SpaceMouseAdapter.d.ts +76 -0
- package/dist/stage/SpaceMouseAdapter.d.ts.map +1 -0
- package/dist/stage/SpaceMouseAdapter.js +197 -0
- package/dist/stage/SpaceMouseAdapter.js.map +1 -0
- package/dist/stage/SpatialElementInteractionController.d.ts +126 -0
- package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -0
- package/dist/stage/SpatialElementInteractionController.js +581 -0
- package/dist/stage/SpatialElementInteractionController.js.map +1 -0
- package/dist/stage/SpatialElementPresentationController.d.ts +82 -0
- package/dist/stage/SpatialElementPresentationController.d.ts.map +1 -0
- package/dist/stage/SpatialElementPresentationController.js +372 -0
- package/dist/stage/SpatialElementPresentationController.js.map +1 -0
- package/dist/stage/SpatialElementRefinement.d.ts +26 -0
- package/dist/stage/SpatialElementRefinement.d.ts.map +1 -0
- package/dist/stage/SpatialElementRefinement.js +105 -0
- package/dist/stage/SpatialElementRefinement.js.map +1 -0
- package/dist/stage/StageExperience.d.ts +536 -0
- package/dist/stage/StageExperience.d.ts.map +1 -0
- package/dist/stage/StageExperience.js +2399 -0
- package/dist/stage/StageExperience.js.map +1 -0
- package/dist/stage/StagePanelLayout.d.ts +15 -0
- package/dist/stage/StagePanelLayout.d.ts.map +1 -0
- package/dist/stage/StagePanelLayout.js +20 -0
- package/dist/stage/StagePanelLayout.js.map +1 -0
- package/dist/stage/StagePanelRuntime.d.ts +20 -0
- package/dist/stage/StagePanelRuntime.d.ts.map +1 -0
- package/dist/stage/StagePanelRuntime.js +2 -0
- package/dist/stage/StagePanelRuntime.js.map +1 -0
- package/dist/stage/StageRenderPipeline.d.ts +179 -0
- package/dist/stage/StageRenderPipeline.d.ts.map +1 -0
- package/dist/stage/StageRenderPipeline.js +901 -0
- package/dist/stage/StageRenderPipeline.js.map +1 -0
- package/dist/stage/VirtualScrollController.d.ts +64 -0
- package/dist/stage/VirtualScrollController.d.ts.map +1 -0
- package/dist/stage/VirtualScrollController.js +329 -0
- package/dist/stage/VirtualScrollController.js.map +1 -0
- package/dist/stage/cssProjection.d.ts +18 -0
- package/dist/stage/cssProjection.d.ts.map +1 -0
- package/dist/stage/cssProjection.js +52 -0
- package/dist/stage/cssProjection.js.map +1 -0
- package/dist/stage/damping.d.ts +3 -0
- package/dist/stage/damping.d.ts.map +1 -0
- package/dist/stage/damping.js +8 -0
- package/dist/stage/damping.js.map +1 -0
- package/dist/stage/minimap/MinimapGeometry.d.ts +31 -0
- package/dist/stage/minimap/MinimapGeometry.d.ts.map +1 -0
- package/dist/stage/minimap/MinimapGeometry.js +163 -0
- package/dist/stage/minimap/MinimapGeometry.js.map +1 -0
- package/dist/stage/minimap/MinimapModel.d.ts +16 -0
- package/dist/stage/minimap/MinimapModel.d.ts.map +1 -0
- package/dist/stage/minimap/MinimapModel.js +51 -0
- package/dist/stage/minimap/MinimapModel.js.map +1 -0
- package/dist/stage/minimap/MinimapProjection.d.ts +41 -0
- package/dist/stage/minimap/MinimapProjection.d.ts.map +1 -0
- package/dist/stage/minimap/MinimapProjection.js +113 -0
- package/dist/stage/minimap/MinimapProjection.js.map +1 -0
- package/dist/stage/minimap/MinimapState.d.ts +102 -0
- package/dist/stage/minimap/MinimapState.d.ts.map +1 -0
- package/dist/stage/minimap/MinimapState.js +2 -0
- package/dist/stage/minimap/MinimapState.js.map +1 -0
- package/dist/stage/minimapMeasurement.d.ts +5 -0
- package/dist/stage/minimapMeasurement.d.ts.map +1 -0
- package/dist/stage/minimapMeasurement.js +11 -0
- package/dist/stage/minimapMeasurement.js.map +1 -0
- package/dist/stage/panelContext.d.ts +71 -0
- package/dist/stage/panelContext.d.ts.map +1 -0
- package/dist/stage/panelContext.js +6 -0
- package/dist/stage/panelContext.js.map +1 -0
- package/dist/stage/panelShadow.d.ts +20 -0
- package/dist/stage/panelShadow.d.ts.map +1 -0
- package/dist/stage/panelShadow.js +22 -0
- package/dist/stage/panelShadow.js.map +1 -0
- package/dist/stage/renderMeasurement.d.ts +3 -0
- package/dist/stage/renderMeasurement.d.ts.map +1 -0
- package/dist/stage/renderMeasurement.js +19 -0
- package/dist/stage/renderMeasurement.js.map +1 -0
- package/dist/stage/renderTargetInventory.d.ts +17 -0
- package/dist/stage/renderTargetInventory.d.ts.map +1 -0
- package/dist/stage/renderTargetInventory.js +27 -0
- package/dist/stage/renderTargetInventory.js.map +1 -0
- package/dist/stage/rendererState.d.ts +14 -0
- package/dist/stage/rendererState.d.ts.map +1 -0
- package/dist/stage/rendererState.js +35 -0
- package/dist/stage/rendererState.js.map +1 -0
- package/dist/stage/resolveStageProfile.d.ts +44 -0
- package/dist/stage/resolveStageProfile.d.ts.map +1 -0
- package/dist/stage/resolveStageProfile.js +30 -0
- package/dist/stage/resolveStageProfile.js.map +1 -0
- package/dist/stage/scrollAnimation.d.ts +10 -0
- package/dist/stage/scrollAnimation.d.ts.map +1 -0
- package/dist/stage/scrollAnimation.js +11 -0
- package/dist/stage/scrollAnimation.js.map +1 -0
- package/dist/stage/scrollFrame.d.ts +43 -0
- package/dist/stage/scrollFrame.d.ts.map +1 -0
- package/dist/stage/scrollFrame.js +232 -0
- package/dist/stage/scrollFrame.js.map +1 -0
- package/dist/stage/spatialElementFrame.d.ts +6 -0
- package/dist/stage/spatialElementFrame.d.ts.map +1 -0
- package/dist/stage/spatialElementFrame.js +22 -0
- package/dist/stage/spatialElementFrame.js.map +1 -0
- package/dist/stage/stageConstants.d.ts +85 -0
- package/dist/stage/stageConstants.d.ts.map +1 -0
- package/dist/stage/stageConstants.js +85 -0
- package/dist/stage/stageConstants.js.map +1 -0
- package/dist/stage/stageDom.d.ts +10 -0
- package/dist/stage/stageDom.d.ts.map +1 -0
- package/dist/stage/stageDom.js +22 -0
- package/dist/stage/stageDom.js.map +1 -0
- package/dist/stage/stageMath.d.ts +187 -0
- package/dist/stage/stageMath.d.ts.map +1 -0
- package/dist/stage/stageMath.js +344 -0
- package/dist/stage/stageMath.js.map +1 -0
- package/dist/stage/stageSceneUtils.d.ts +42 -0
- package/dist/stage/stageSceneUtils.d.ts.map +1 -0
- package/dist/stage/stageSceneUtils.js +154 -0
- package/dist/stage/stageSceneUtils.js.map +1 -0
- package/dist/stage/stageTypes.d.ts +189 -0
- package/dist/stage/stageTypes.d.ts.map +1 -0
- package/dist/stage/stageTypes.js +2 -0
- package/dist/stage/stageTypes.js.map +1 -0
- package/dist/stage/stageVisualTest.d.ts +92 -0
- package/dist/stage/stageVisualTest.d.ts.map +1 -0
- package/dist/stage/stageVisualTest.js +5 -0
- package/dist/stage/stageVisualTest.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,803 @@
|
|
|
1
|
+
import { withRendererState } from './rendererState.js';
|
|
2
|
+
import { getMinimapMeasurementMode } from './minimapMeasurement.js';
|
|
3
|
+
import * as THREE from 'three/webgpu';
|
|
4
|
+
import { abs, acesFilmicToneMapping, color, float, length, max as tslMax, min as tslMin, mix, oneMinus, premultiplyAlpha, renderOutput, screenUV, sRGBTransferEOTF, sRGBTransferOETF, smoothstep as tslSmoothstep, step, texture, uniform, uv, vec2 } from 'three/tsl';
|
|
5
|
+
import { inverseAcesToneMapping, STAGE_TONE_MAPPING_EXPOSURE } from './LiquidGlassPanel.js';
|
|
6
|
+
import { MinimapBlurPipeline } from './MinimapBlurPipeline.js';
|
|
7
|
+
import { MINIMAP_DEFAULT_CONTEXT_COLOR, MINIMAP_DEFAULT_CONTEXT_OPACITY, MINIMAP_DEFAULT_EXPANDED_HEIGHT, MINIMAP_DEFAULT_HOVER_MODEL_SCALE, MINIMAP_DEFAULT_OVERLAY_BLUR, MINIMAP_MIN_BLUR_GUARD, MINIMAP_MODEL_FILL, MINIMAP_MODEL_RENDER_ORDER, MINIMAP_OVERLAY_Z, MINIMAP_PANEL_Z, MINIMAP_POINTER_MODEL_LIFT, MINIMAP_VIEWPORT_BORDER_THICKNESS, PANEL_CAMERA_FOV } from './stageConstants.js';
|
|
8
|
+
import { getCameraOrbitQuaternion, getMinimapHoverScale, resolveMinimapModelScale, smoothstep } from './stageMath.js';
|
|
9
|
+
import { addMinimapBlurLights, disposeMinimapModelMaterials, prepareMinimapModel } from './minimap/MinimapModel.js';
|
|
10
|
+
import { createMinimapPanelGeometry, createMinimapViewportRingGeometry, getMinimapViewportCornerRadii, updateMinimapPanelGeometry, updateMinimapViewportRingGeometry } from './minimap/MinimapGeometry.js';
|
|
11
|
+
import { getMinimapDepthRange, getMinimapCssBlurRadius, getMinimapViewportRect, getPanelLocalCameraFov } from './minimap/MinimapProjection.js';
|
|
12
|
+
import { getMeshBounds, getMeshBoundsPoints, isMesh } from './stageSceneUtils.js';
|
|
13
|
+
const MINIMAP_OVERLAY_CAPTURE_EPSILON = 0.000001;
|
|
14
|
+
/** Owns independent Low views, docking projections and their blur resources. */
|
|
15
|
+
export class MinimapController {
|
|
16
|
+
ports;
|
|
17
|
+
measurementMode = getMinimapMeasurementMode();
|
|
18
|
+
scene = new THREE.Scene();
|
|
19
|
+
constructor(ports) {
|
|
20
|
+
this.ports = ports;
|
|
21
|
+
}
|
|
22
|
+
get views() {
|
|
23
|
+
return this.minimaps;
|
|
24
|
+
}
|
|
25
|
+
dispose() {
|
|
26
|
+
for (const index of [...this.minimaps.keys()])
|
|
27
|
+
this.disposeMinimap(index);
|
|
28
|
+
}
|
|
29
|
+
get renderer() {
|
|
30
|
+
return this.ports.renderer;
|
|
31
|
+
}
|
|
32
|
+
get camera() {
|
|
33
|
+
return this.ports.camera;
|
|
34
|
+
}
|
|
35
|
+
get panelCamera() {
|
|
36
|
+
return this.ports.panelCamera;
|
|
37
|
+
}
|
|
38
|
+
get panelScene() {
|
|
39
|
+
return this.ports.panelScene;
|
|
40
|
+
}
|
|
41
|
+
get minimapScene() {
|
|
42
|
+
return this.scene;
|
|
43
|
+
}
|
|
44
|
+
get model() {
|
|
45
|
+
return this.ports.spatialElement().model;
|
|
46
|
+
}
|
|
47
|
+
get lowModel() {
|
|
48
|
+
return this.ports.spatialElement().low;
|
|
49
|
+
}
|
|
50
|
+
get cameraSettings() {
|
|
51
|
+
return this.ports.spatialElement().camera;
|
|
52
|
+
}
|
|
53
|
+
get initialCameraWorldQuaternion() {
|
|
54
|
+
return this.ports.spatialElement().restCamera;
|
|
55
|
+
}
|
|
56
|
+
get initialModelWorldQuaternion() {
|
|
57
|
+
return this.ports.spatialElement().restModel;
|
|
58
|
+
}
|
|
59
|
+
get modelHover() {
|
|
60
|
+
return this.ports.frame().hovering;
|
|
61
|
+
}
|
|
62
|
+
get modelInteractionActive() {
|
|
63
|
+
return this.ports.frame().interacting;
|
|
64
|
+
}
|
|
65
|
+
get scrollActive() {
|
|
66
|
+
return this.ports.frame().scrolling;
|
|
67
|
+
}
|
|
68
|
+
isSpatialElementMesh(mesh) {
|
|
69
|
+
return this.ports.includeMesh(mesh);
|
|
70
|
+
}
|
|
71
|
+
hideExcludedMeshes(model) {
|
|
72
|
+
model.traverse((child) => {
|
|
73
|
+
if (isMesh(child) && !this.isSpatialElementMesh(child))
|
|
74
|
+
child.visible = false;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
getZoomReferenceTarget() {
|
|
78
|
+
return this.ports.spatialElement().referenceTarget;
|
|
79
|
+
}
|
|
80
|
+
getPanelTransitionOpacity(panel) {
|
|
81
|
+
return this.ports.transitionOpacity(panel);
|
|
82
|
+
}
|
|
83
|
+
getFullPixelRatio() {
|
|
84
|
+
return this.ports.pixelRatio();
|
|
85
|
+
}
|
|
86
|
+
getPanelBlurTexture(options) {
|
|
87
|
+
return this.ports.blurTexture(options);
|
|
88
|
+
}
|
|
89
|
+
minimapModelWorldQuaternion = new THREE.Quaternion();
|
|
90
|
+
minimapMainCameraWorldQuaternion = new THREE.Quaternion();
|
|
91
|
+
minimapLiveQuaternion = new THREE.Quaternion();
|
|
92
|
+
minimapBaseQuaternion = new THREE.Quaternion();
|
|
93
|
+
minimapPanelCenter = new THREE.Vector3();
|
|
94
|
+
minimapDesiredNdc = new THREE.Vector3();
|
|
95
|
+
minimapDepthPoint = new THREE.Vector3();
|
|
96
|
+
minimapModelCenter = new THREE.Vector3();
|
|
97
|
+
minimapModelWorldScale = new THREE.Vector3();
|
|
98
|
+
minimapLayerWorldScale = new THREE.Vector3();
|
|
99
|
+
minimapModelBoundsPoint = new THREE.Vector3();
|
|
100
|
+
minimaps = new Map();
|
|
101
|
+
createMinimap(index, options) {
|
|
102
|
+
this.disposeMinimap(index);
|
|
103
|
+
if (!options || !this.model)
|
|
104
|
+
return;
|
|
105
|
+
const panel = this.ports.panel(index);
|
|
106
|
+
if (!panel)
|
|
107
|
+
return;
|
|
108
|
+
const resolved = this.resolveMinimapOptions(options, panel);
|
|
109
|
+
const modelRoot = (this.lowModel ?? this.model).clone(true);
|
|
110
|
+
this.hideExcludedMeshes(modelRoot);
|
|
111
|
+
const bounds = getMeshBounds(modelRoot, (mesh) => this.isSpatialElementMesh(mesh));
|
|
112
|
+
const sphere = bounds.getBoundingSphere(new THREE.Sphere());
|
|
113
|
+
const modelCenter = new THREE.Group();
|
|
114
|
+
modelCenter.add(modelRoot);
|
|
115
|
+
modelCenter.position.copy(sphere.center).multiplyScalar(-1);
|
|
116
|
+
const model = new THREE.Group();
|
|
117
|
+
model.add(modelCenter);
|
|
118
|
+
prepareMinimapModel(model);
|
|
119
|
+
const baseWidth = Math.max(panel.options.width, 1);
|
|
120
|
+
const baseHeight = Math.max(panel.options.height, 1);
|
|
121
|
+
const baseRadius = panel.options.radius;
|
|
122
|
+
const cssBlurRadius = getMinimapCssBlurRadius(resolved.overlayBlur);
|
|
123
|
+
const blurGuard = Math.max(MINIMAP_MIN_BLUR_GUARD, Math.ceil(cssBlurRadius * 3 + 16));
|
|
124
|
+
const maximumPanelScale = Math.max(resolved.expandedHeight / baseHeight, 1);
|
|
125
|
+
const captureExtentWidth = baseWidth * maximumPanelScale + blurGuard * 2;
|
|
126
|
+
const captureExtentHeight = baseHeight * maximumPanelScale + blurGuard * 2;
|
|
127
|
+
const maximumSourcePixelsPerCssPixel = Math.min(window.devicePixelRatio || 1, 2);
|
|
128
|
+
const aspect = baseWidth / Math.max(baseHeight, 1);
|
|
129
|
+
const modelRadius = Math.max(sphere.radius, 0.001);
|
|
130
|
+
const panelDistance = Math.max(this.panelCamera.position.z - panel.group.position.z, modelRadius * 2);
|
|
131
|
+
const minimapCamera = new THREE.PerspectiveCamera(getPanelLocalCameraFov(baseHeight, panelDistance), aspect, 0.01, panelDistance + modelRadius * 8);
|
|
132
|
+
minimapCamera.position.set(0, 0, panelDistance);
|
|
133
|
+
minimapCamera.lookAt(0, 0, 0);
|
|
134
|
+
const captureCamera = new THREE.PerspectiveCamera(getPanelLocalCameraFov(captureExtentHeight, panelDistance), captureExtentWidth / captureExtentHeight, 0.01, panelDistance + modelRadius * 8);
|
|
135
|
+
captureCamera.position.set(0, 0, panelDistance);
|
|
136
|
+
captureCamera.lookAt(0, 0, 0);
|
|
137
|
+
const screenCamera = new THREE.PerspectiveCamera(PANEL_CAMERA_FOV, Math.max(window.innerWidth, 1) / Math.max(window.innerHeight, 1), this.panelCamera.near, this.panelCamera.far);
|
|
138
|
+
const captureLayer = new THREE.Group();
|
|
139
|
+
captureLayer.add(model);
|
|
140
|
+
const sourceScene = new THREE.Scene();
|
|
141
|
+
sourceScene.add(captureLayer);
|
|
142
|
+
sourceScene.background = null;
|
|
143
|
+
const environment = this.ports.environment();
|
|
144
|
+
if (environment) {
|
|
145
|
+
sourceScene.environment = environment.texture;
|
|
146
|
+
sourceScene.environmentIntensity = 1;
|
|
147
|
+
}
|
|
148
|
+
addMinimapBlurLights(sourceScene);
|
|
149
|
+
const layer = new THREE.Group();
|
|
150
|
+
layer.position.copy(panel.group.position);
|
|
151
|
+
layer.rotation.copy(panel.group.rotation);
|
|
152
|
+
layer.scale.copy(panel.group.scale);
|
|
153
|
+
const contextTarget = new THREE.RenderTarget(1, 1, {
|
|
154
|
+
depthBuffer: true,
|
|
155
|
+
stencilBuffer: false,
|
|
156
|
+
samples: 4,
|
|
157
|
+
type: THREE.HalfFloatType
|
|
158
|
+
});
|
|
159
|
+
contextTarget.texture.minFilter = THREE.LinearFilter;
|
|
160
|
+
contextTarget.texture.magFilter = THREE.LinearFilter;
|
|
161
|
+
contextTarget.texture.generateMipmaps = false;
|
|
162
|
+
contextTarget.texture.colorSpace = THREE.NoColorSpace;
|
|
163
|
+
// Tone-map the model into display space while preserving its transparent,
|
|
164
|
+
// premultiplied edges. The backdrop tint is composited after the blur so its
|
|
165
|
+
// opacity remains independent from both the model and the page background.
|
|
166
|
+
const displayTarget = new THREE.RenderTarget(1, 1, {
|
|
167
|
+
depthBuffer: false,
|
|
168
|
+
stencilBuffer: false,
|
|
169
|
+
type: THREE.UnsignedByteType
|
|
170
|
+
});
|
|
171
|
+
displayTarget.texture.minFilter = THREE.LinearFilter;
|
|
172
|
+
displayTarget.texture.magFilter = THREE.LinearFilter;
|
|
173
|
+
displayTarget.texture.generateMipmaps = false;
|
|
174
|
+
// The display pass writes sRGB values deliberately. Keep the texture
|
|
175
|
+
// untagged so the blur runs in display space, matching CSS blur more closely.
|
|
176
|
+
displayTarget.texture.colorSpace = THREE.NoColorSpace;
|
|
177
|
+
// Preserve the exact glass-panel result underneath the minimap overlay.
|
|
178
|
+
// Reconstructing that result from the stage backdrop made the overlay's
|
|
179
|
+
// apparent opacity depend on the rotated model and could make it look more
|
|
180
|
+
// transparent than the panel it covers.
|
|
181
|
+
const panelTarget = new THREE.RenderTarget(1, 1, {
|
|
182
|
+
depthBuffer: true,
|
|
183
|
+
stencilBuffer: false,
|
|
184
|
+
samples: 4,
|
|
185
|
+
type: THREE.HalfFloatType
|
|
186
|
+
});
|
|
187
|
+
panelTarget.texture.minFilter = THREE.LinearFilter;
|
|
188
|
+
panelTarget.texture.magFilter = THREE.LinearFilter;
|
|
189
|
+
panelTarget.texture.generateMipmaps = false;
|
|
190
|
+
panelTarget.texture.colorSpace = THREE.NoColorSpace;
|
|
191
|
+
const displayOutput = renderOutput(texture(contextTarget.texture), THREE.ACESFilmicToneMapping, THREE.SRGBColorSpace);
|
|
192
|
+
const displayMaterial = new THREE.NodeMaterial();
|
|
193
|
+
// Keep transparent edge colors premultiplied through every reduction and
|
|
194
|
+
// blur pass. They are unpremultiplied exactly once by MinimapBlurPipeline.
|
|
195
|
+
displayMaterial.fragmentNode = premultiplyAlpha(displayOutput);
|
|
196
|
+
displayMaterial.depthTest = false;
|
|
197
|
+
displayMaterial.depthWrite = false;
|
|
198
|
+
displayMaterial.blending = THREE.NoBlending;
|
|
199
|
+
displayMaterial.toneMapped = false;
|
|
200
|
+
displayMaterial.needsUpdate = true;
|
|
201
|
+
const displayQuad = new THREE.QuadMesh(displayMaterial);
|
|
202
|
+
const blurPipeline = new MinimapBlurPipeline(displayTarget.texture, cssBlurRadius, maximumSourcePixelsPerCssPixel);
|
|
203
|
+
const displayRoot = (this.lowModel ?? this.model).clone(true);
|
|
204
|
+
this.hideExcludedMeshes(displayRoot);
|
|
205
|
+
const displayBounds = getMeshBounds(displayRoot, (mesh) => this.isSpatialElementMesh(mesh));
|
|
206
|
+
const displaySphere = displayBounds.getBoundingSphere(new THREE.Sphere());
|
|
207
|
+
const modelBoundsPoints = getMeshBoundsPoints(displayRoot, (mesh) => this.isSpatialElementMesh(mesh));
|
|
208
|
+
modelBoundsPoints.forEach((point) => point.sub(displaySphere.center));
|
|
209
|
+
const displayCenter = new THREE.Group();
|
|
210
|
+
displayCenter.add(displayRoot);
|
|
211
|
+
displayCenter.position.copy(displaySphere.center).multiplyScalar(-1);
|
|
212
|
+
const displayModel = new THREE.Group();
|
|
213
|
+
displayModel.add(displayCenter);
|
|
214
|
+
const displayMaterials = prepareMinimapModel(displayModel);
|
|
215
|
+
displayModel.renderOrder = MINIMAP_MODEL_RENDER_ORDER;
|
|
216
|
+
const restQuaternion = this.initialCameraWorldQuaternion
|
|
217
|
+
.clone()
|
|
218
|
+
.invert()
|
|
219
|
+
.multiply(this.initialModelWorldQuaternion);
|
|
220
|
+
const hasDockedOrientation = Number.isFinite(options.dockedView?.azimuth) ||
|
|
221
|
+
Number.isFinite(options.dockedView?.elevation);
|
|
222
|
+
const dockedQuaternion = hasDockedOrientation
|
|
223
|
+
? getCameraOrbitQuaternion(options.dockedView?.azimuth ?? this.cameraSettings.azimuth, options.dockedView?.elevation ?? this.cameraSettings.elevation)
|
|
224
|
+
.invert()
|
|
225
|
+
.multiply(this.initialModelWorldQuaternion)
|
|
226
|
+
: undefined;
|
|
227
|
+
const overlayVisibility = uniform(0);
|
|
228
|
+
const overlayPanelSize = uniform(new THREE.Vector2(baseWidth, baseHeight));
|
|
229
|
+
const overlayViewportCenter = uniform(new THREE.Vector2(baseWidth * 0.5, baseHeight * 0.5));
|
|
230
|
+
const overlayViewportHalfSize = uniform(new THREE.Vector2(baseWidth * 0.5, baseHeight * 0.5));
|
|
231
|
+
const overlayViewportRadii = uniform(new THREE.Vector4(baseRadius, baseRadius, baseRadius, baseRadius));
|
|
232
|
+
const captureUvScale = uniform(new THREE.Vector2(baseWidth / captureExtentWidth, baseHeight / captureExtentHeight));
|
|
233
|
+
const panelUv = uv();
|
|
234
|
+
const pixelPosition = panelUv.mul(overlayPanelSize);
|
|
235
|
+
const viewportOffset = pixelPosition.sub(overlayViewportCenter);
|
|
236
|
+
const rightSide = step(0, viewportOffset.x);
|
|
237
|
+
const bottomSide = step(0, viewportOffset.y);
|
|
238
|
+
const topRadius = mix(overlayViewportRadii.x, overlayViewportRadii.y, rightSide);
|
|
239
|
+
const bottomRadius = mix(overlayViewportRadii.w, overlayViewportRadii.z, rightSide);
|
|
240
|
+
const viewportRadius = mix(topRadius, bottomRadius, bottomSide);
|
|
241
|
+
const roundedOffset = abs(viewportOffset).sub(overlayViewportHalfSize.sub(vec2(viewportRadius, viewportRadius)));
|
|
242
|
+
const viewportDistance = length(tslMax(roundedOffset, vec2(0, 0)))
|
|
243
|
+
.add(tslMin(tslMax(roundedOffset.x, roundedOffset.y), 0))
|
|
244
|
+
.sub(viewportRadius);
|
|
245
|
+
const viewportMask = oneMinus(tslSmoothstep(-0.75, 0.75, viewportDistance));
|
|
246
|
+
const captureUv = panelUv.sub(0.5).mul(captureUvScale).add(0.5);
|
|
247
|
+
const blurredSample = texture(this.measurementMode === 'no-blur'
|
|
248
|
+
? displayTarget.texture
|
|
249
|
+
: blurPipeline.outputTarget.texture, captureUv);
|
|
250
|
+
const panelSample = texture(panelTarget.texture, screenUV);
|
|
251
|
+
const stageCaptureTexture = texture(this.ports.capture().sceneCapture.texture, screenUV);
|
|
252
|
+
const stageBlurTexture = texture(panel.surface === 'solid'
|
|
253
|
+
? this.ports.capture().sceneCapture.texture
|
|
254
|
+
: this.getPanelBlurTexture(panel.options), screenUV);
|
|
255
|
+
const stageSample = stageCaptureTexture;
|
|
256
|
+
const displayOverlayColorValue = new THREE.Color(resolved.overlayColor);
|
|
257
|
+
const displayContextColorValue = new THREE.Color(resolved.contextColor);
|
|
258
|
+
THREE.ColorManagement.workingToColorSpace(displayOverlayColorValue, THREE.SRGBColorSpace);
|
|
259
|
+
THREE.ColorManagement.workingToColorSpace(displayContextColorValue, THREE.SRGBColorSpace);
|
|
260
|
+
const displayOverlayColor = color(displayOverlayColorValue);
|
|
261
|
+
const displayContextColor = color(displayContextColorValue);
|
|
262
|
+
const overlayOpacity = uniform(resolved.overlayOpacity);
|
|
263
|
+
const contextOpacity = uniform(resolved.contextOpacity);
|
|
264
|
+
const outsideViewport = oneMinus(viewportMask);
|
|
265
|
+
// Glass uses its authoritative LiquidGlassPanel capture. Simple surfaces
|
|
266
|
+
// reconstruct their CSS base in the foreground compositor: frosted samples
|
|
267
|
+
// the matching preallocated blur target while solid samples the sharp stage.
|
|
268
|
+
// This prevents the minimap overlay from replacing CSS blur with a sharp copy.
|
|
269
|
+
const glassBaseLinearColor = panelSample.rgb.add(stageSample.rgb.mul(oneMinus(panelSample.a)));
|
|
270
|
+
const glassBaseDisplayColor = sRGBTransferOETF(acesFilmicToneMapping(glassBaseLinearColor, float(STAGE_TONE_MAPPING_EXPOSURE)));
|
|
271
|
+
const simpleBackdrop = panel.surface === 'frosted' ? stageBlurTexture : stageSample;
|
|
272
|
+
const simpleBackdropDisplayColor = sRGBTransferOETF(acesFilmicToneMapping(simpleBackdrop.rgb, float(STAGE_TONE_MAPPING_EXPOSURE)));
|
|
273
|
+
const displayPanelTintValue = new THREE.Color(panel.options.tint);
|
|
274
|
+
THREE.ColorManagement.workingToColorSpace(displayPanelTintValue, THREE.SRGBColorSpace);
|
|
275
|
+
const simplePanelDisplayColor = mix(simpleBackdropDisplayColor, color(displayPanelTintValue), float(panel.options.tintOpacity));
|
|
276
|
+
const panelBaseDisplayColor = panel.surface === 'glass' ? glassBaseDisplayColor : simplePanelDisplayColor;
|
|
277
|
+
const capturedDisplayColor = blurredSample.rgb.add(panelBaseDisplayColor.mul(oneMinus(blurredSample.a)));
|
|
278
|
+
const contextualDisplayColor = mix(capturedDisplayColor, displayContextColor, contextOpacity);
|
|
279
|
+
const compositeDisplayColor = mix(contextualDisplayColor, displayOverlayColor, overlayOpacity);
|
|
280
|
+
const overlayCompositeMaterial = new THREE.NodeMaterial();
|
|
281
|
+
// Decode once for the final scene render. The intermediate targets stay in
|
|
282
|
+
// display space so the Gaussian convolution behaves like a CSS backdrop blur.
|
|
283
|
+
overlayCompositeMaterial.colorNode = inverseAcesToneMapping(sRGBTransferEOTF(compositeDisplayColor));
|
|
284
|
+
overlayCompositeMaterial.opacityNode = overlayVisibility.mul(outsideViewport);
|
|
285
|
+
overlayCompositeMaterial.depthTest = false;
|
|
286
|
+
overlayCompositeMaterial.depthWrite = false;
|
|
287
|
+
overlayCompositeMaterial.transparent = true;
|
|
288
|
+
overlayCompositeMaterial.toneMapped = false;
|
|
289
|
+
const overlayComposite = new THREE.Mesh(createMinimapPanelGeometry(baseWidth, baseHeight, baseRadius), overlayCompositeMaterial);
|
|
290
|
+
overlayComposite.position.z = MINIMAP_OVERLAY_Z;
|
|
291
|
+
overlayComposite.renderOrder = MINIMAP_MODEL_RENDER_ORDER + 1;
|
|
292
|
+
overlayComposite.visible = false;
|
|
293
|
+
const overlayRing = new THREE.Mesh(createMinimapViewportRingGeometry(baseWidth, baseHeight, 0, 0, baseWidth, baseHeight, {
|
|
294
|
+
topLeft: baseRadius,
|
|
295
|
+
topRight: baseRadius,
|
|
296
|
+
bottomRight: baseRadius,
|
|
297
|
+
bottomLeft: baseRadius
|
|
298
|
+
}, MINIMAP_VIEWPORT_BORDER_THICKNESS), new THREE.MeshBasicMaterial({
|
|
299
|
+
color: resolved.viewportColor,
|
|
300
|
+
depthTest: true,
|
|
301
|
+
depthWrite: false,
|
|
302
|
+
opacity: 0.96,
|
|
303
|
+
transparent: true
|
|
304
|
+
}));
|
|
305
|
+
overlayRing.material.toneMapped = false;
|
|
306
|
+
const ringRestMaterial = overlayRing.material;
|
|
307
|
+
const ringForegroundMaterial = ringRestMaterial.clone();
|
|
308
|
+
ringForegroundMaterial.depthTest = false;
|
|
309
|
+
overlayRing.position.z = MINIMAP_OVERLAY_Z;
|
|
310
|
+
overlayRing.renderOrder = MINIMAP_MODEL_RENDER_ORDER + 2;
|
|
311
|
+
overlayRing.visible = true;
|
|
312
|
+
layer.add(displayModel, overlayComposite, overlayRing);
|
|
313
|
+
this.minimapScene.add(layer);
|
|
314
|
+
this.minimaps.set(index, {
|
|
315
|
+
panelIndex: index,
|
|
316
|
+
screenCamera,
|
|
317
|
+
camera: minimapCamera,
|
|
318
|
+
captureCamera,
|
|
319
|
+
model,
|
|
320
|
+
sourceRoot: modelRoot,
|
|
321
|
+
displayModel,
|
|
322
|
+
spatialElementRoot: displayRoot,
|
|
323
|
+
modelBoundsPoints,
|
|
324
|
+
restQuaternion,
|
|
325
|
+
dockedQuaternion,
|
|
326
|
+
displayMaterials,
|
|
327
|
+
displayOpacity: 1,
|
|
328
|
+
layer,
|
|
329
|
+
modelRadius,
|
|
330
|
+
baseWidth,
|
|
331
|
+
baseHeight,
|
|
332
|
+
baseRadius,
|
|
333
|
+
currentWidth: baseWidth,
|
|
334
|
+
currentHeight: baseHeight,
|
|
335
|
+
sourceScene,
|
|
336
|
+
captureLayer,
|
|
337
|
+
contextTarget,
|
|
338
|
+
displayTarget,
|
|
339
|
+
panelTarget,
|
|
340
|
+
blurPipeline,
|
|
341
|
+
displayMaterial,
|
|
342
|
+
displayQuad,
|
|
343
|
+
overlayComposite,
|
|
344
|
+
stageCaptureTexture,
|
|
345
|
+
stageBlurTexture,
|
|
346
|
+
overlayVisibility,
|
|
347
|
+
overlayPanelSize,
|
|
348
|
+
overlayViewportCenter,
|
|
349
|
+
overlayViewportHalfSize,
|
|
350
|
+
overlayViewportRadii,
|
|
351
|
+
captureUvScale,
|
|
352
|
+
blurGuard,
|
|
353
|
+
captureExtentWidth,
|
|
354
|
+
captureExtentHeight,
|
|
355
|
+
overlayRing,
|
|
356
|
+
ringRestMaterial,
|
|
357
|
+
ringForegroundMaterial,
|
|
358
|
+
overlayProgress: 0,
|
|
359
|
+
overlayGeometryWidth: baseWidth,
|
|
360
|
+
overlayGeometryHeight: baseHeight,
|
|
361
|
+
overlayGeometryDirty: false,
|
|
362
|
+
overlayCaptureState: [],
|
|
363
|
+
overlayCaptureDirty: true,
|
|
364
|
+
overlayCaptureValid: false,
|
|
365
|
+
panelCaptureState: [],
|
|
366
|
+
panelCaptureDirty: true,
|
|
367
|
+
panelCaptureValid: false,
|
|
368
|
+
pointerReveal: 0,
|
|
369
|
+
viewportVisible: true,
|
|
370
|
+
options: resolved
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
resolveMinimapOptions(options, panel) {
|
|
374
|
+
return {
|
|
375
|
+
expandedHeight: Math.max(options.expandedHeight ?? MINIMAP_DEFAULT_EXPANDED_HEIGHT, panel.options.height),
|
|
376
|
+
inset: Math.max(options.inset ?? 0, 0),
|
|
377
|
+
modelScale: resolveMinimapModelScale(options.modelScale),
|
|
378
|
+
hoverModelScale: resolveMinimapModelScale(options.hoverModelScale, MINIMAP_DEFAULT_HOVER_MODEL_SCALE),
|
|
379
|
+
expandedHoverModelScale: resolveMinimapModelScale(options.expandedHoverModelScale, resolveMinimapModelScale(options.hoverModelScale, MINIMAP_DEFAULT_HOVER_MODEL_SCALE)),
|
|
380
|
+
overlayColor: options.overlayColor ?? '#123274',
|
|
381
|
+
overlayOpacity: THREE.MathUtils.clamp(options.overlayOpacity ?? 0.22, 0, 1),
|
|
382
|
+
overlayBlur: THREE.MathUtils.clamp(options.overlayBlur ?? MINIMAP_DEFAULT_OVERLAY_BLUR, 0, 40),
|
|
383
|
+
contextColor: options.contextColor ?? MINIMAP_DEFAULT_CONTEXT_COLOR,
|
|
384
|
+
contextOpacity: THREE.MathUtils.clamp(options.contextOpacity ?? MINIMAP_DEFAULT_CONTEXT_OPACITY, 0, 1),
|
|
385
|
+
viewportColor: options.viewportColor ?? '#4569b1'
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
disposeMinimap(index) {
|
|
389
|
+
const minimap = this.minimaps.get(index);
|
|
390
|
+
if (!minimap)
|
|
391
|
+
return;
|
|
392
|
+
minimap.layer.removeFromParent();
|
|
393
|
+
minimap.captureLayer.removeFromParent();
|
|
394
|
+
minimap.model.removeFromParent();
|
|
395
|
+
disposeMinimapModelMaterials(minimap.model);
|
|
396
|
+
minimap.displayModel.removeFromParent();
|
|
397
|
+
disposeMinimapModelMaterials(minimap.displayModel);
|
|
398
|
+
minimap.contextTarget.dispose();
|
|
399
|
+
minimap.displayTarget.dispose();
|
|
400
|
+
minimap.panelTarget.dispose();
|
|
401
|
+
minimap.blurPipeline.dispose();
|
|
402
|
+
minimap.displayMaterial.dispose();
|
|
403
|
+
const geometries = new Set([minimap.overlayComposite.geometry, minimap.overlayRing.geometry]);
|
|
404
|
+
geometries.forEach((geometry) => geometry.dispose());
|
|
405
|
+
minimap.overlayComposite.material.dispose();
|
|
406
|
+
minimap.ringRestMaterial.dispose();
|
|
407
|
+
minimap.ringForegroundMaterial.dispose();
|
|
408
|
+
this.minimaps.delete(index);
|
|
409
|
+
}
|
|
410
|
+
updateMinimapState(minimap, focus) {
|
|
411
|
+
const panel = this.ports.panel(minimap.panelIndex);
|
|
412
|
+
if (!panel || !this.model)
|
|
413
|
+
return;
|
|
414
|
+
const panelWidth = Math.max(minimap.currentWidth, 8);
|
|
415
|
+
const panelHeight = Math.max(minimap.currentHeight, 8);
|
|
416
|
+
const contentWidth = Math.max(panelWidth - minimap.options.inset * 2, 8);
|
|
417
|
+
const contentHeight = Math.max(panelHeight - minimap.options.inset * 2, 8);
|
|
418
|
+
this.camera.updateMatrixWorld(true);
|
|
419
|
+
this.panelCamera.updateMatrixWorld(true);
|
|
420
|
+
this.updateMinimapDisplayModel(minimap, panelWidth, panelHeight, focus);
|
|
421
|
+
this.syncMinimapProjection(minimap, panelWidth, panelHeight);
|
|
422
|
+
const viewportRect = focus > 0.001 && this.ports.spatialElement().hasControls
|
|
423
|
+
? getMinimapViewportRect(this.camera, minimap.camera, this.getZoomReferenceTarget(), this.model, minimap.sourceRoot, minimap.captureLayer, panelWidth, panelHeight)
|
|
424
|
+
: null;
|
|
425
|
+
const rectWidth = viewportRect?.width ?? panelWidth * 0.82;
|
|
426
|
+
const rectHeight = viewportRect?.height ?? panelHeight * 0.82;
|
|
427
|
+
const rectX = viewportRect?.x ?? 0;
|
|
428
|
+
const rectY = viewportRect?.y ?? 0;
|
|
429
|
+
this.updateMinimapViewport(minimap, panelWidth, panelHeight, contentWidth, contentHeight, rectX, rectY, rectWidth, rectHeight, focus);
|
|
430
|
+
this.updateMinimapOverlayCaptureState(minimap);
|
|
431
|
+
}
|
|
432
|
+
updateMinimapOverlayCaptureState(minimap) {
|
|
433
|
+
// SpatialElement pixels depend on the capture's own camera and model, not the
|
|
434
|
+
// main camera's moving viewport hole or the backdrop behind the panel.
|
|
435
|
+
this.recordMinimapCaptureState(minimap, false);
|
|
436
|
+
this.recordMinimapCaptureState(minimap, true);
|
|
437
|
+
}
|
|
438
|
+
recordMinimapCaptureState(minimap, panelCapture) {
|
|
439
|
+
const snapshot = panelCapture ? minimap.panelCaptureState : minimap.overlayCaptureState;
|
|
440
|
+
let offset = 0;
|
|
441
|
+
let changed = snapshot.length === 0;
|
|
442
|
+
const record = (value) => {
|
|
443
|
+
const resolved = Number.isFinite(value) ? value : 0;
|
|
444
|
+
if (snapshot[offset] === undefined ||
|
|
445
|
+
Math.abs(snapshot[offset] - resolved) > MINIMAP_OVERLAY_CAPTURE_EPSILON) {
|
|
446
|
+
changed = true;
|
|
447
|
+
}
|
|
448
|
+
snapshot[offset] = resolved;
|
|
449
|
+
offset += 1;
|
|
450
|
+
};
|
|
451
|
+
const recordMatrix = (matrix) => {
|
|
452
|
+
for (const value of matrix.elements)
|
|
453
|
+
record(value);
|
|
454
|
+
};
|
|
455
|
+
recordMatrix(minimap.captureCamera.matrixWorld);
|
|
456
|
+
recordMatrix(minimap.captureCamera.projectionMatrix);
|
|
457
|
+
recordMatrix(minimap.captureLayer.matrixWorld);
|
|
458
|
+
recordMatrix(minimap.model.matrixWorld);
|
|
459
|
+
record(this.getFullPixelRatio());
|
|
460
|
+
record(minimap.sourceScene.environment?.id ?? -1);
|
|
461
|
+
record(minimap.sourceScene.environment?.version ?? -1);
|
|
462
|
+
record(minimap.sourceScene.environmentIntensity);
|
|
463
|
+
if (panelCapture) {
|
|
464
|
+
recordMatrix(minimap.screenCamera.matrixWorld);
|
|
465
|
+
recordMatrix(minimap.screenCamera.projectionMatrix);
|
|
466
|
+
recordMatrix(this.camera.matrixWorld);
|
|
467
|
+
recordMatrix(this.camera.projectionMatrix);
|
|
468
|
+
if (this.model) {
|
|
469
|
+
record(this.model.position.x);
|
|
470
|
+
record(this.model.position.y);
|
|
471
|
+
record(this.model.position.z);
|
|
472
|
+
record(this.model.quaternion.x);
|
|
473
|
+
record(this.model.quaternion.y);
|
|
474
|
+
record(this.model.quaternion.z);
|
|
475
|
+
record(this.model.quaternion.w);
|
|
476
|
+
record(this.model.scale.x);
|
|
477
|
+
record(this.model.scale.y);
|
|
478
|
+
record(this.model.scale.z);
|
|
479
|
+
}
|
|
480
|
+
record(minimap.currentWidth);
|
|
481
|
+
record(minimap.currentHeight);
|
|
482
|
+
record(minimap.captureUvScale.value.x);
|
|
483
|
+
record(minimap.captureUvScale.value.y);
|
|
484
|
+
record(this.ports.capture()?.scale ?? 1);
|
|
485
|
+
record(window.innerWidth);
|
|
486
|
+
record(window.innerHeight);
|
|
487
|
+
record(window.devicePixelRatio || 1);
|
|
488
|
+
record(this.modelHover ? 1 : 0);
|
|
489
|
+
record(this.modelInteractionActive ? 1 : 0);
|
|
490
|
+
record(this.scrollActive ? 1 : 0);
|
|
491
|
+
record(this.ports.target(minimap.panelIndex)?.getSurfaceOpacity?.() ?? 1);
|
|
492
|
+
}
|
|
493
|
+
if (snapshot.length !== offset)
|
|
494
|
+
changed = true;
|
|
495
|
+
snapshot.length = offset;
|
|
496
|
+
if (changed) {
|
|
497
|
+
if (panelCapture)
|
|
498
|
+
minimap.panelCaptureDirty = true;
|
|
499
|
+
else
|
|
500
|
+
minimap.overlayCaptureDirty = true;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
updateMinimapDisplayModel(minimap, panelWidth, panelHeight, focus) {
|
|
504
|
+
const contentWidth = Math.max(panelWidth - minimap.options.inset * 2, 8);
|
|
505
|
+
const contentHeight = Math.max(panelHeight - minimap.options.inset * 2, 8);
|
|
506
|
+
const availableDiameter = Math.min(contentWidth, contentHeight) * MINIMAP_MODEL_FILL;
|
|
507
|
+
const presentationScale = THREE.MathUtils.clamp(this.ports.target(minimap.panelIndex)?.getMinimapModelScale?.() ?? 1, 0.2, 2);
|
|
508
|
+
const baseScale = (availableDiameter * minimap.options.modelScale * presentationScale) /
|
|
509
|
+
Math.max(minimap.modelRadius * 2, 0.001);
|
|
510
|
+
const hoverModelScale = THREE.MathUtils.lerp(minimap.options.hoverModelScale, minimap.options.expandedHoverModelScale, THREE.MathUtils.clamp(focus, 0, 1));
|
|
511
|
+
const targetScale = baseScale * getMinimapHoverScale(hoverModelScale, minimap.pointerReveal);
|
|
512
|
+
const modelZ = MINIMAP_PANEL_Z + MINIMAP_POINTER_MODEL_LIFT * minimap.pointerReveal;
|
|
513
|
+
const modelWorldQuaternion = this.minimapModelWorldQuaternion;
|
|
514
|
+
const mainCameraWorldQuaternion = this.minimapMainCameraWorldQuaternion;
|
|
515
|
+
const liveQuaternion = this.minimapLiveQuaternion;
|
|
516
|
+
const baseQuaternion = this.minimapBaseQuaternion;
|
|
517
|
+
this.model?.getWorldQuaternion(modelWorldQuaternion);
|
|
518
|
+
this.camera.getWorldQuaternion(mainCameraWorldQuaternion);
|
|
519
|
+
liveQuaternion.copy(mainCameraWorldQuaternion).invert().multiply(modelWorldQuaternion);
|
|
520
|
+
baseQuaternion.slerpQuaternions(minimap.restQuaternion, liveQuaternion, THREE.MathUtils.clamp(focus, 0, 1));
|
|
521
|
+
if (minimap.dockedQuaternion) {
|
|
522
|
+
minimap.displayModel.quaternion.slerpQuaternions(baseQuaternion, minimap.dockedQuaternion, THREE.MathUtils.clamp(this.ports.target(minimap.panelIndex)?.getMinimapDockProgress?.() ?? 0, 0, 1));
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
minimap.displayModel.quaternion.copy(baseQuaternion);
|
|
526
|
+
}
|
|
527
|
+
minimap.displayModel.scale.setScalar(targetScale);
|
|
528
|
+
minimap.displayModel.position.set(0, 0, modelZ);
|
|
529
|
+
}
|
|
530
|
+
alignMinimapModelToDockTop(minimap) {
|
|
531
|
+
const targetTop = this.ports.target(minimap.panelIndex)?.getMinimapModelTop?.();
|
|
532
|
+
if (targetTop === undefined || !Number.isFinite(targetTop))
|
|
533
|
+
return;
|
|
534
|
+
for (let iteration = 0; iteration < 2; iteration += 1) {
|
|
535
|
+
const projected = this.getProjectedMinimapModelRect(minimap);
|
|
536
|
+
if (!projected || Math.abs(projected.y - targetTop) < 0.001)
|
|
537
|
+
return;
|
|
538
|
+
const startY = minimap.displayModel.position.y;
|
|
539
|
+
minimap.displayModel.position.y = startY + 1;
|
|
540
|
+
const shifted = this.getProjectedMinimapModelRect(minimap);
|
|
541
|
+
minimap.displayModel.position.y = startY;
|
|
542
|
+
if (!shifted)
|
|
543
|
+
return;
|
|
544
|
+
const pixelsPerLocalUnit = shifted.y - projected.y;
|
|
545
|
+
if (Math.abs(pixelsPerLocalUnit) < 0.000001)
|
|
546
|
+
return;
|
|
547
|
+
minimap.displayModel.position.y += THREE.MathUtils.clamp((targetTop - projected.y) / pixelsPerLocalUnit, -window.innerHeight, window.innerHeight);
|
|
548
|
+
}
|
|
549
|
+
minimap.displayModel.updateWorldMatrix(true, true);
|
|
550
|
+
}
|
|
551
|
+
getProjectedMinimapModelRect(minimap) {
|
|
552
|
+
minimap.layer.updateWorldMatrix(true, false);
|
|
553
|
+
minimap.displayModel.updateWorldMatrix(true, true);
|
|
554
|
+
minimap.screenCamera.updateMatrixWorld(true);
|
|
555
|
+
const viewportWidth = Math.max(window.innerWidth, 1);
|
|
556
|
+
const viewportHeight = Math.max(window.innerHeight, 1);
|
|
557
|
+
let left = Number.POSITIVE_INFINITY;
|
|
558
|
+
let top = Number.POSITIVE_INFINITY;
|
|
559
|
+
let right = Number.NEGATIVE_INFINITY;
|
|
560
|
+
let bottom = Number.NEGATIVE_INFINITY;
|
|
561
|
+
for (const boundsPoint of minimap.modelBoundsPoints) {
|
|
562
|
+
const projectedPoint = this.minimapModelBoundsPoint
|
|
563
|
+
.copy(boundsPoint)
|
|
564
|
+
.applyMatrix4(minimap.displayModel.matrixWorld)
|
|
565
|
+
.project(minimap.screenCamera);
|
|
566
|
+
const x = (projectedPoint.x + 1) * viewportWidth * 0.5;
|
|
567
|
+
const y = (1 - projectedPoint.y) * viewportHeight * 0.5;
|
|
568
|
+
left = Math.min(left, x);
|
|
569
|
+
top = Math.min(top, y);
|
|
570
|
+
right = Math.max(right, x);
|
|
571
|
+
bottom = Math.max(bottom, y);
|
|
572
|
+
}
|
|
573
|
+
if (![left, top, right, bottom].every(Number.isFinite))
|
|
574
|
+
return null;
|
|
575
|
+
return { x: left, y: top, width: right - left, height: bottom - top };
|
|
576
|
+
}
|
|
577
|
+
syncMinimapProjection(minimap, panelWidth, panelHeight) {
|
|
578
|
+
minimap.layer.updateWorldMatrix(true, true);
|
|
579
|
+
minimap.displayModel.updateWorldMatrix(true, true);
|
|
580
|
+
const panelCenter = minimap.layer.getWorldPosition(this.minimapPanelCenter);
|
|
581
|
+
const viewportWidth = Math.max(window.innerWidth, 1);
|
|
582
|
+
const viewportHeight = Math.max(window.innerHeight, 1);
|
|
583
|
+
const desiredNdc = this.minimapDesiredNdc.copy(panelCenter).project(this.panelCamera);
|
|
584
|
+
const screenCamera = minimap.screenCamera;
|
|
585
|
+
// Renderer switches coordinate systems on first draw and rebuilds the projection.
|
|
586
|
+
// Do this before installing our off-axis terms, including hidden/new minimaps.
|
|
587
|
+
screenCamera.coordinateSystem = this.renderer.coordinateSystem;
|
|
588
|
+
screenCamera.fov = PANEL_CAMERA_FOV;
|
|
589
|
+
screenCamera.aspect = viewportWidth / viewportHeight;
|
|
590
|
+
screenCamera.position.set(panelCenter.x, panelCenter.y, this.panelCamera.position.z);
|
|
591
|
+
screenCamera.quaternion.copy(this.panelCamera.quaternion);
|
|
592
|
+
screenCamera.clearViewOffset();
|
|
593
|
+
screenCamera.updateMatrixWorld(true);
|
|
594
|
+
const panelDistance = -this.minimapDepthPoint
|
|
595
|
+
.copy(panelCenter)
|
|
596
|
+
.applyMatrix4(screenCamera.matrixWorldInverse).z;
|
|
597
|
+
const modelDistance = -this.minimapDepthPoint
|
|
598
|
+
.copy(minimap.displayModel.getWorldPosition(this.minimapModelCenter))
|
|
599
|
+
.applyMatrix4(screenCamera.matrixWorldInverse).z;
|
|
600
|
+
const modelWorldScale = minimap.displayModel.getWorldScale(this.minimapModelWorldScale);
|
|
601
|
+
const layerWorldScale = minimap.layer.getWorldScale(this.minimapLayerWorldScale);
|
|
602
|
+
const modelDepthRadius = minimap.modelRadius *
|
|
603
|
+
Math.max(Math.abs(modelWorldScale.x), Math.abs(modelWorldScale.y), Math.abs(modelWorldScale.z));
|
|
604
|
+
const panelDepthRadius = Math.hypot(panelWidth, panelHeight) *
|
|
605
|
+
0.5 *
|
|
606
|
+
Math.max(Math.abs(layerWorldScale.x), Math.abs(layerWorldScale.y), Math.abs(layerWorldScale.z));
|
|
607
|
+
const depthRange = getMinimapDepthRange([
|
|
608
|
+
{ distance: panelDistance, radius: panelDepthRadius },
|
|
609
|
+
{ distance: modelDistance, radius: modelDepthRadius }
|
|
610
|
+
]);
|
|
611
|
+
screenCamera.near = depthRange.near;
|
|
612
|
+
screenCamera.far = depthRange.far;
|
|
613
|
+
screenCamera.updateProjectionMatrix();
|
|
614
|
+
// This is the original pre-split projection: the optical axis stays centred
|
|
615
|
+
// on the minimap while an off-axis frustum preserves its page position.
|
|
616
|
+
screenCamera.projectionMatrix.elements[8] = -desiredNdc.x;
|
|
617
|
+
screenCamera.projectionMatrix.elements[9] = -desiredNdc.y;
|
|
618
|
+
screenCamera.projectionMatrixInverse.copy(screenCamera.projectionMatrix).invert();
|
|
619
|
+
this.alignMinimapModelToDockTop(minimap);
|
|
620
|
+
const localPanelDistance = Math.max(screenCamera.position.z - panelCenter.z, 1);
|
|
621
|
+
minimap.camera.fov = getPanelLocalCameraFov(panelHeight, localPanelDistance);
|
|
622
|
+
minimap.camera.aspect = Math.max(panelWidth, 1) / Math.max(panelHeight, 1);
|
|
623
|
+
minimap.camera.near = Math.max(localPanelDistance / 10000, 0.01);
|
|
624
|
+
minimap.camera.far = localPanelDistance + minimap.modelRadius * 8 + MINIMAP_POINTER_MODEL_LIFT;
|
|
625
|
+
minimap.camera.position.set(0, 0, localPanelDistance);
|
|
626
|
+
minimap.camera.quaternion.identity();
|
|
627
|
+
minimap.camera.clearViewOffset();
|
|
628
|
+
minimap.camera.updateProjectionMatrix();
|
|
629
|
+
minimap.camera.updateMatrixWorld(true);
|
|
630
|
+
const captureWidth = minimap.captureExtentWidth;
|
|
631
|
+
const captureHeight = minimap.captureExtentHeight;
|
|
632
|
+
const captureCenterNdc = panelCenter.clone().project(screenCamera);
|
|
633
|
+
const captureScaleX = viewportWidth / captureWidth;
|
|
634
|
+
const captureScaleY = viewportHeight / captureHeight;
|
|
635
|
+
const cropProjection = new THREE.Matrix4().set(captureScaleX, 0, 0, -captureScaleX * captureCenterNdc.x, 0, captureScaleY, 0, -captureScaleY * captureCenterNdc.y, 0, 0, 1, 0, 0, 0, 0, 1);
|
|
636
|
+
// Crop the exact live minimap projection instead of rebuilding an
|
|
637
|
+
// approximation with a second panel-local camera. This keeps every rotated
|
|
638
|
+
// part of the blurred clone in precisely the same frustum as the visible
|
|
639
|
+
// model while retaining guard pixels for the blur kernel.
|
|
640
|
+
minimap.captureCamera.copy(screenCamera, false);
|
|
641
|
+
minimap.captureCamera.projectionMatrix.premultiply(cropProjection);
|
|
642
|
+
minimap.captureCamera.projectionMatrixInverse
|
|
643
|
+
.copy(minimap.captureCamera.projectionMatrix)
|
|
644
|
+
.invert();
|
|
645
|
+
minimap.captureCamera.updateMatrixWorld(true);
|
|
646
|
+
minimap.captureUvScale.value.set(panelWidth / captureWidth, panelHeight / captureHeight);
|
|
647
|
+
// The capture contains only the model. The live glass and live model remain
|
|
648
|
+
// visible below the compositor, so fading the overlay cannot reveal a
|
|
649
|
+
// differently positioned duplicate or bake glass edge shading into it.
|
|
650
|
+
minimap.captureLayer.position.copy(minimap.layer.position);
|
|
651
|
+
minimap.captureLayer.quaternion.copy(minimap.layer.quaternion);
|
|
652
|
+
minimap.captureLayer.scale.copy(minimap.layer.scale);
|
|
653
|
+
minimap.model.position.copy(minimap.displayModel.position);
|
|
654
|
+
minimap.model.quaternion.copy(minimap.displayModel.quaternion);
|
|
655
|
+
minimap.model.scale.copy(minimap.displayModel.scale);
|
|
656
|
+
minimap.captureLayer.updateWorldMatrix(true, true);
|
|
657
|
+
}
|
|
658
|
+
updateMinimapViewport(minimap, panelWidth, panelHeight, contentWidth, contentHeight, rectX, rectY, rectWidth, rectHeight, focus) {
|
|
659
|
+
const target = this.ports.target(minimap.panelIndex);
|
|
660
|
+
if (!target)
|
|
661
|
+
return;
|
|
662
|
+
const progress = smoothstep(0.04, 0.72, focus);
|
|
663
|
+
const viewportWidth = Math.min(rectWidth, panelWidth);
|
|
664
|
+
const viewportHeight = Math.min(rectHeight, panelHeight);
|
|
665
|
+
const targetLeft = THREE.MathUtils.clamp(panelWidth * 0.5 + rectX - viewportWidth * 0.5, 0, panelWidth - viewportWidth);
|
|
666
|
+
const targetTop = THREE.MathUtils.clamp(panelHeight * 0.5 - rectY - viewportHeight * 0.5, 0, panelHeight - viewportHeight);
|
|
667
|
+
const left = THREE.MathUtils.lerp(0, targetLeft, progress);
|
|
668
|
+
const top = THREE.MathUtils.lerp(0, targetTop, progress);
|
|
669
|
+
const currentWidth = THREE.MathUtils.lerp(panelWidth, viewportWidth, progress);
|
|
670
|
+
const currentHeight = THREE.MathUtils.lerp(panelHeight, viewportHeight, progress);
|
|
671
|
+
const radius = THREE.MathUtils.lerp(minimap.baseRadius, 2, progress);
|
|
672
|
+
const cornerRadii = getMinimapViewportCornerRadii(panelWidth, panelHeight, left, top, currentWidth, currentHeight, radius, minimap.baseRadius);
|
|
673
|
+
const overlayProgress = smoothstep(0.02, 0.14, progress);
|
|
674
|
+
target.content.style.width = `${contentWidth}px`;
|
|
675
|
+
target.content.style.height = `${contentHeight}px`;
|
|
676
|
+
this.updateMinimapRenderMask(minimap, panelWidth, panelHeight, left, top, currentWidth, currentHeight, cornerRadii, overlayProgress);
|
|
677
|
+
}
|
|
678
|
+
updateMinimapRenderMask(minimap, panelWidth, panelHeight, viewportLeft, viewportTop, viewportWidth, viewportHeight, cornerRadii, overlayProgress) {
|
|
679
|
+
const panelW = Math.max(panelWidth, 0.001);
|
|
680
|
+
const panelH = Math.max(panelHeight, 0.001);
|
|
681
|
+
const width = THREE.MathUtils.clamp(viewportWidth, 0.001, panelW);
|
|
682
|
+
const height = THREE.MathUtils.clamp(viewportHeight, 0.001, panelH);
|
|
683
|
+
const left = THREE.MathUtils.clamp(viewportLeft, 0, panelW - width);
|
|
684
|
+
const top = THREE.MathUtils.clamp(viewportTop, 0, panelH - height);
|
|
685
|
+
const lineWidth = MINIMAP_VIEWPORT_BORDER_THICKNESS;
|
|
686
|
+
if (Math.abs(minimap.overlayGeometryWidth - panelW) > MINIMAP_OVERLAY_CAPTURE_EPSILON ||
|
|
687
|
+
Math.abs(minimap.overlayGeometryHeight - panelH) > MINIMAP_OVERLAY_CAPTURE_EPSILON) {
|
|
688
|
+
minimap.overlayGeometryDirty = true;
|
|
689
|
+
}
|
|
690
|
+
minimap.overlayPanelSize.value.set(panelW, panelH);
|
|
691
|
+
minimap.overlayViewportCenter.value.set(left + width * 0.5, top + height * 0.5);
|
|
692
|
+
minimap.overlayViewportHalfSize.value.set(width * 0.5, height * 0.5);
|
|
693
|
+
minimap.overlayViewportRadii.value.set(cornerRadii.topLeft, cornerRadii.topRight, cornerRadii.bottomRight, cornerRadii.bottomLeft);
|
|
694
|
+
updateMinimapViewportRingGeometry(minimap.overlayRing.geometry, panelW, panelH, left, top, width, height, cornerRadii, lineWidth);
|
|
695
|
+
minimap.overlayProgress = overlayProgress;
|
|
696
|
+
this.updateMinimapOverlayVisibility(minimap);
|
|
697
|
+
if (minimap.overlayComposite.visible && minimap.overlayGeometryDirty) {
|
|
698
|
+
updateMinimapPanelGeometry(minimap.overlayComposite.geometry, panelW, panelH, minimap.baseRadius);
|
|
699
|
+
minimap.overlayGeometryWidth = panelW;
|
|
700
|
+
minimap.overlayGeometryHeight = panelH;
|
|
701
|
+
minimap.overlayGeometryDirty = false;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
updateMinimapOverlayVisibility(minimap) {
|
|
705
|
+
const reveal = smoothstep(0.38, 0.95, THREE.MathUtils.clamp(minimap.pointerReveal, 0, 1));
|
|
706
|
+
const overlayProgress = THREE.MathUtils.clamp(minimap.overlayProgress, 0, 1);
|
|
707
|
+
const overlayFade = 1 - reveal;
|
|
708
|
+
const transitionOpacity = this.getPanelTransitionOpacity(this.ports.panel(minimap.panelIndex));
|
|
709
|
+
const visibleOverlay = overlayProgress * overlayFade * transitionOpacity;
|
|
710
|
+
const surfaceOpacity = THREE.MathUtils.clamp(this.ports.target(minimap.panelIndex)?.getSurfaceOpacity?.() ?? 1, 0, 1);
|
|
711
|
+
const ringOpacity = 0.96 *
|
|
712
|
+
THREE.MathUtils.lerp(1, overlayFade, overlayProgress) *
|
|
713
|
+
surfaceOpacity *
|
|
714
|
+
transitionOpacity;
|
|
715
|
+
const ringInForeground = overlayProgress > 0.001;
|
|
716
|
+
minimap.overlayRing.material = ringInForeground
|
|
717
|
+
? minimap.ringForegroundMaterial
|
|
718
|
+
: minimap.ringRestMaterial;
|
|
719
|
+
minimap.overlayComposite.visible =
|
|
720
|
+
this.measurementMode !== 'no-overlay' && visibleOverlay > 0.001;
|
|
721
|
+
minimap.overlayVisibility.value = visibleOverlay;
|
|
722
|
+
minimap.overlayRing.visible = ringOpacity > 0.001;
|
|
723
|
+
minimap.overlayRing.material.opacity = ringOpacity;
|
|
724
|
+
// The live model is the sole sharp source. The opaque outside compositor
|
|
725
|
+
// hides it beneath the overlay while the viewport hole reveals it unchanged.
|
|
726
|
+
// Keeping it stable also removes the white cross-fade haze on hover.
|
|
727
|
+
this.setMinimapDisplayModelOpacity(minimap, transitionOpacity);
|
|
728
|
+
}
|
|
729
|
+
setMinimapDisplayModelOpacity(minimap, opacity) {
|
|
730
|
+
const resolvedOpacity = THREE.MathUtils.clamp(opacity, 0, 1);
|
|
731
|
+
// Exact endpoints restore authored transparency/depth ownership after a transition.
|
|
732
|
+
if (resolvedOpacity === minimap.displayOpacity)
|
|
733
|
+
return;
|
|
734
|
+
minimap.displayOpacity = resolvedOpacity;
|
|
735
|
+
minimap.displayModel.visible = resolvedOpacity > 0.001;
|
|
736
|
+
minimap.displayMaterials.forEach((state) => {
|
|
737
|
+
const transparent = state.transparent || resolvedOpacity < 0.999;
|
|
738
|
+
if (state.material.transparent !== transparent) {
|
|
739
|
+
state.material.transparent = transparent;
|
|
740
|
+
state.material.needsUpdate = true;
|
|
741
|
+
}
|
|
742
|
+
state.material.opacity = state.opacity * resolvedOpacity;
|
|
743
|
+
state.material.depthWrite = state.depthWrite && resolvedOpacity > 0.999;
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
renderMinimapBlur(minimap) {
|
|
747
|
+
return withRendererState(this.renderer, () => {
|
|
748
|
+
this.ensureMinimapBlurTargetSize(minimap);
|
|
749
|
+
const previousClearAlpha = this.renderer.getClearAlpha();
|
|
750
|
+
const previousClearColor = this.renderer.getClearColor(new THREE.Color());
|
|
751
|
+
// Capture and tone-map the model with transparency intact, then blur its
|
|
752
|
+
// premultiplied display-space color. The overlay tint is applied later by the
|
|
753
|
+
// compositor, so a black opacity of 0.4 remains a true translucent black.
|
|
754
|
+
this.renderer.setClearColor(0x000000, 0);
|
|
755
|
+
this.renderer.setRenderTarget(minimap.contextTarget);
|
|
756
|
+
this.renderer.clear();
|
|
757
|
+
this.renderer.render(minimap.sourceScene, minimap.captureCamera);
|
|
758
|
+
this.renderer.setClearColor(0x000000, 0);
|
|
759
|
+
this.renderer.setRenderTarget(minimap.displayTarget);
|
|
760
|
+
this.renderer.clear();
|
|
761
|
+
minimap.displayQuad.render(this.renderer);
|
|
762
|
+
if (this.measurementMode !== 'no-blur')
|
|
763
|
+
minimap.blurPipeline.render(this.renderer, minimap.displayTarget.width / minimap.captureExtentWidth, minimap.displayTarget.height / minimap.captureExtentHeight);
|
|
764
|
+
this.renderer.setRenderTarget(null);
|
|
765
|
+
this.renderer.setClearColor(previousClearColor, previousClearAlpha);
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
renderMinimapPanelCapture(minimap) {
|
|
769
|
+
return withRendererState(this.renderer, () => {
|
|
770
|
+
const pixelRatio = this.getFullPixelRatio();
|
|
771
|
+
const targetWidth = Math.max(1, Math.round(window.innerWidth * pixelRatio));
|
|
772
|
+
const targetHeight = Math.max(1, Math.round(window.innerHeight * pixelRatio));
|
|
773
|
+
if (minimap.panelTarget.width !== targetWidth ||
|
|
774
|
+
minimap.panelTarget.height !== targetHeight) {
|
|
775
|
+
minimap.panelTarget.setSize(targetWidth, targetHeight);
|
|
776
|
+
}
|
|
777
|
+
const previousClearAlpha = this.renderer.getClearAlpha();
|
|
778
|
+
const previousClearColor = this.renderer.getClearColor(new THREE.Color());
|
|
779
|
+
this.renderer.setClearColor(0x000000, 0);
|
|
780
|
+
this.renderer.setRenderTarget(minimap.panelTarget);
|
|
781
|
+
this.renderer.clear();
|
|
782
|
+
this.renderer.render(this.panelScene, minimap.screenCamera);
|
|
783
|
+
this.renderer.setRenderTarget(null);
|
|
784
|
+
this.renderer.setClearColor(previousClearColor, previousClearAlpha);
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
ensureMinimapBlurTargetSize(minimap) {
|
|
788
|
+
const pixelRatio = this.getFullPixelRatio();
|
|
789
|
+
const targetWidth = Math.max(16, Math.round(minimap.captureExtentWidth * pixelRatio));
|
|
790
|
+
const targetHeight = Math.max(16, Math.round(minimap.captureExtentHeight * pixelRatio));
|
|
791
|
+
if (minimap.contextTarget.width === targetWidth &&
|
|
792
|
+
minimap.contextTarget.height === targetHeight &&
|
|
793
|
+
minimap.displayTarget.width === targetWidth &&
|
|
794
|
+
minimap.displayTarget.height === targetHeight &&
|
|
795
|
+
minimap.blurPipeline.outputTarget.width === targetWidth &&
|
|
796
|
+
minimap.blurPipeline.outputTarget.height === targetHeight)
|
|
797
|
+
return;
|
|
798
|
+
minimap.contextTarget.setSize(targetWidth, targetHeight);
|
|
799
|
+
minimap.displayTarget.setSize(targetWidth, targetHeight);
|
|
800
|
+
minimap.blurPipeline.setSize(targetWidth, targetHeight);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
//# sourceMappingURL=MinimapController.js.map
|