@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,569 @@
|
|
|
1
|
+
import { parseRenderMeasurement } from './renderMeasurement.js';
|
|
2
|
+
import { dampAndSnap } from './damping.js';
|
|
3
|
+
import * as THREE from 'three/webgpu';
|
|
4
|
+
import {} from '../catalog/catalogPresentation.js';
|
|
5
|
+
import { CSS3DObject } from 'three/addons/renderers/CSS3DRenderer.js';
|
|
6
|
+
import { MINIMAP_FOCUSED_VIEWPORT_INSET, MINIMAP_OVERLAY_REVEAL_DAMPING, PANEL_CONTENT_Z, PANEL_POINTER_DAMPING, PANEL_POINTER_MAX_LIFT } from './stageConstants.js';
|
|
7
|
+
import { getMinimapFocusPositionOffset, getNativePanelDomPosition, getPanelFocusBlur, getPanelFocusOffset, getPanelFocusPerspectiveOffset, getPanelFocusOpacity, getPanelPointerInfluence, getPanelPointerRotation, getPerspectiveAnchoredPanelPosition, setPanelLocalPerspectiveMatrix } from './stageMath.js';
|
|
8
|
+
import { getProjectiveCssMatrix3d } from './minimap/MinimapProjection.js';
|
|
9
|
+
const PANEL_NATIVE_REST_FRAMES = 2;
|
|
10
|
+
const PANEL_NATIVE_ROTATION_EPSILON = 0.000001;
|
|
11
|
+
const PANEL_NATIVE_DEPTH_EPSILON = 0.0001;
|
|
12
|
+
function getFlatCss3DTransform(matrix) {
|
|
13
|
+
const elements = matrix.elements;
|
|
14
|
+
const epsilon = (value) => (Math.abs(value) < 1e-10 ? 0 : value);
|
|
15
|
+
// CSS3DRenderer flips the Y axis in its preserve-3d camera element. Frosted
|
|
16
|
+
// surfaces live in a flat backdrop-capable layer, so fold that camera-axis
|
|
17
|
+
// conversion into the object's final matrix instead.
|
|
18
|
+
return `translate(-50%, -50%) matrix3d(${[
|
|
19
|
+
elements[0],
|
|
20
|
+
-elements[1],
|
|
21
|
+
elements[2],
|
|
22
|
+
elements[3],
|
|
23
|
+
-elements[4],
|
|
24
|
+
elements[5],
|
|
25
|
+
-elements[6],
|
|
26
|
+
-elements[7],
|
|
27
|
+
elements[8],
|
|
28
|
+
-elements[9],
|
|
29
|
+
elements[10],
|
|
30
|
+
elements[11],
|
|
31
|
+
elements[12],
|
|
32
|
+
-elements[13],
|
|
33
|
+
elements[14],
|
|
34
|
+
elements[15]
|
|
35
|
+
]
|
|
36
|
+
.map(epsilon)
|
|
37
|
+
.join(',')})`;
|
|
38
|
+
}
|
|
39
|
+
/** Owns panel surfaces, hover and focus-safe DOM presentation independently of element loading. */
|
|
40
|
+
export class PanelPresentationController {
|
|
41
|
+
ports;
|
|
42
|
+
fixedMinimapSize = parseRenderMeasurement(typeof window === 'undefined' ? '' : (window.location?.search ?? '')) ===
|
|
43
|
+
'fixed-minimap-size';
|
|
44
|
+
constructor(ports) {
|
|
45
|
+
this.ports = ports;
|
|
46
|
+
}
|
|
47
|
+
get runtimes() {
|
|
48
|
+
return this.panelRuntimes;
|
|
49
|
+
}
|
|
50
|
+
get visiblePanels() {
|
|
51
|
+
return this.visiblePanelCount;
|
|
52
|
+
}
|
|
53
|
+
get visibleMinimaps() {
|
|
54
|
+
return this.visibleMinimapCount;
|
|
55
|
+
}
|
|
56
|
+
add(runtime) {
|
|
57
|
+
this.panelRuntimes.push(runtime);
|
|
58
|
+
}
|
|
59
|
+
set(index, runtime) {
|
|
60
|
+
this.panelRuntimes[index] = runtime;
|
|
61
|
+
}
|
|
62
|
+
release() {
|
|
63
|
+
for (const runtime of this.panelRuntimes) {
|
|
64
|
+
runtime.content?.removeFromParent();
|
|
65
|
+
runtime.contentProjectionRoot?.removeFromParent();
|
|
66
|
+
(runtime.projectionRoot ?? runtime.group).removeFromParent();
|
|
67
|
+
runtime.glass?.dispose();
|
|
68
|
+
}
|
|
69
|
+
this.panelRuntimes.length = 0;
|
|
70
|
+
for (const [element, home] of [...this.domHomes].reverse()) {
|
|
71
|
+
if (home.next?.parentNode === home.parent)
|
|
72
|
+
home.parent.insertBefore(element, home.next);
|
|
73
|
+
else
|
|
74
|
+
home.parent.appendChild(element);
|
|
75
|
+
if (home.style === null)
|
|
76
|
+
element.removeAttribute('style');
|
|
77
|
+
else
|
|
78
|
+
element.setAttribute('style', home.style);
|
|
79
|
+
if (home.draggable === null)
|
|
80
|
+
element.removeAttribute('draggable');
|
|
81
|
+
else
|
|
82
|
+
element.setAttribute('draggable', home.draggable);
|
|
83
|
+
delete element.dataset.stagePanelRenderMode;
|
|
84
|
+
}
|
|
85
|
+
this.domHomes.clear();
|
|
86
|
+
}
|
|
87
|
+
get panelCamera() {
|
|
88
|
+
return this.ports.camera;
|
|
89
|
+
}
|
|
90
|
+
get panelContentScene() {
|
|
91
|
+
return this.ports.contentScene;
|
|
92
|
+
}
|
|
93
|
+
get flatPanelLayer() {
|
|
94
|
+
return this.ports.flatLayer;
|
|
95
|
+
}
|
|
96
|
+
get nativePanelLayer() {
|
|
97
|
+
return this.ports.nativeLayer;
|
|
98
|
+
}
|
|
99
|
+
get panelTargets() {
|
|
100
|
+
return this.ports.registrations();
|
|
101
|
+
}
|
|
102
|
+
get minimaps() {
|
|
103
|
+
return this.ports.minimaps();
|
|
104
|
+
}
|
|
105
|
+
get catalogPresentation() {
|
|
106
|
+
return this.ports.frame().presentation;
|
|
107
|
+
}
|
|
108
|
+
get minimapFocus() {
|
|
109
|
+
return this.ports.frame().minimapFocus;
|
|
110
|
+
}
|
|
111
|
+
get panelUiFocus() {
|
|
112
|
+
return this.ports.frame().uiFocus;
|
|
113
|
+
}
|
|
114
|
+
get pointer() {
|
|
115
|
+
return this.ports.frame().pointer;
|
|
116
|
+
}
|
|
117
|
+
requestRender() {
|
|
118
|
+
this.ports.requestRender();
|
|
119
|
+
}
|
|
120
|
+
getPanelTransitionOpacity(panel) {
|
|
121
|
+
return this.ports.transitionOpacity(panel);
|
|
122
|
+
}
|
|
123
|
+
isPanelTargetVisible(index) {
|
|
124
|
+
return this.ports.visible(index);
|
|
125
|
+
}
|
|
126
|
+
updateMinimapState(minimap, focus) {
|
|
127
|
+
this.ports.updateMinimap(minimap, focus);
|
|
128
|
+
}
|
|
129
|
+
domHomes = new Map();
|
|
130
|
+
minimapCssLocalCorners = [
|
|
131
|
+
new THREE.Vector3(),
|
|
132
|
+
new THREE.Vector3(),
|
|
133
|
+
new THREE.Vector3(),
|
|
134
|
+
new THREE.Vector3()
|
|
135
|
+
];
|
|
136
|
+
minimapCssProjectionCorners = [
|
|
137
|
+
new THREE.Vector2(),
|
|
138
|
+
new THREE.Vector2(),
|
|
139
|
+
new THREE.Vector2(),
|
|
140
|
+
new THREE.Vector2()
|
|
141
|
+
];
|
|
142
|
+
panelRuntimes = [];
|
|
143
|
+
visiblePanelCount = 0;
|
|
144
|
+
visibleMinimapCount = 0;
|
|
145
|
+
rememberDomHome(element) {
|
|
146
|
+
if (!element.parentNode || this.domHomes.has(element))
|
|
147
|
+
return;
|
|
148
|
+
this.domHomes.set(element, {
|
|
149
|
+
parent: element.parentNode,
|
|
150
|
+
next: element.nextSibling,
|
|
151
|
+
style: element.getAttribute('style'),
|
|
152
|
+
draggable: element.getAttribute('draggable')
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
attachPanelContent(element, panelIndex = 0, inset = 28) {
|
|
156
|
+
this.rememberDomHome(element);
|
|
157
|
+
const runtime = this.panelRuntimes[panelIndex];
|
|
158
|
+
if (!runtime) {
|
|
159
|
+
throw new Error(`No panel exists at index ${panelIndex}`);
|
|
160
|
+
}
|
|
161
|
+
this.updateContentElement(element, runtime, inset);
|
|
162
|
+
element.dataset.stagePanelRenderMode = runtime.domRenderMode;
|
|
163
|
+
element.style.zIndex = `${panelIndex}`;
|
|
164
|
+
const object = new CSS3DObject(element);
|
|
165
|
+
if (runtime.projectionRoot) {
|
|
166
|
+
const projectionRoot = this.createPanelProjectionRoot(object);
|
|
167
|
+
this.setPanelProjectionTransform(projectionRoot, runtime.options.position.x, runtime.options.position.y, PANEL_CONTENT_Z);
|
|
168
|
+
runtime.contentProjectionRoot = projectionRoot;
|
|
169
|
+
this.panelContentScene.add(projectionRoot);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
object.position.set(runtime.options.position.x, runtime.options.position.y, PANEL_CONTENT_Z);
|
|
173
|
+
this.panelContentScene.add(object);
|
|
174
|
+
}
|
|
175
|
+
object.updateMatrixWorld(true);
|
|
176
|
+
element.style.transform = getFlatCss3DTransform(object.matrixWorld);
|
|
177
|
+
runtime.content = object;
|
|
178
|
+
this.requestRender();
|
|
179
|
+
return object;
|
|
180
|
+
}
|
|
181
|
+
attachPanelSurface(element, panelIndex, minimap = false) {
|
|
182
|
+
this.rememberDomHome(element);
|
|
183
|
+
const runtime = this.panelRuntimes[panelIndex];
|
|
184
|
+
if (!runtime) {
|
|
185
|
+
throw new Error(`No panel exists at index ${panelIndex}`);
|
|
186
|
+
}
|
|
187
|
+
this.updateSurfaceElement(element, runtime, runtime.options.width, runtime.options.height, minimap);
|
|
188
|
+
element.dataset.stagePanelRenderMode = runtime.domRenderMode;
|
|
189
|
+
element.style.zIndex = `${panelIndex}`;
|
|
190
|
+
const object = new CSS3DObject(element);
|
|
191
|
+
if (runtime.projectionRoot) {
|
|
192
|
+
const projectionRoot = this.createPanelProjectionRoot(object);
|
|
193
|
+
this.setPanelProjectionTransform(projectionRoot, runtime.options.position.x, runtime.options.position.y, PANEL_CONTENT_Z);
|
|
194
|
+
runtime.contentProjectionRoot = projectionRoot;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
object.position.set(runtime.options.position.x, runtime.options.position.y, PANEL_CONTENT_Z);
|
|
198
|
+
}
|
|
199
|
+
runtime.content = object;
|
|
200
|
+
this.flatPanelLayer.appendChild(element);
|
|
201
|
+
this.requestRender();
|
|
202
|
+
return object;
|
|
203
|
+
}
|
|
204
|
+
updateContentElement(element, runtime, inset = 28) {
|
|
205
|
+
const contentInset = Math.max(inset, 0);
|
|
206
|
+
element.style.width = `${Math.max(runtime.options.width - contentInset * 2, 1)}px`;
|
|
207
|
+
element.style.height = `${Math.max(runtime.options.height - contentInset * 2, 1)}px`;
|
|
208
|
+
element.style.boxSizing = 'border-box';
|
|
209
|
+
element.style.left = '0';
|
|
210
|
+
element.style.top = '0';
|
|
211
|
+
element.style.pointerEvents = 'auto';
|
|
212
|
+
element.style.userSelect = 'auto';
|
|
213
|
+
}
|
|
214
|
+
updateSurfaceElement(element, runtime, width = runtime.options.width, height = runtime.options.height, projected = false) {
|
|
215
|
+
const widthValue = `${Math.max(width, 1).toFixed(2)}px`;
|
|
216
|
+
const heightValue = `${Math.max(height, 1).toFixed(2)}px`;
|
|
217
|
+
if (element.style.width !== widthValue)
|
|
218
|
+
element.style.width = widthValue;
|
|
219
|
+
if (element.style.height !== heightValue)
|
|
220
|
+
element.style.height = heightValue;
|
|
221
|
+
element.style.boxSizing = 'border-box';
|
|
222
|
+
// CSS3DObject also enforces absolute positioning. Keep every flat surface
|
|
223
|
+
// out of normal flow so sibling panels cannot alter each other's projection.
|
|
224
|
+
element.style.position = 'absolute';
|
|
225
|
+
element.style.left = projected ? '0' : '50%';
|
|
226
|
+
element.style.top = projected ? '0' : '50%';
|
|
227
|
+
element.style.transformOrigin = projected ? '0 0' : '';
|
|
228
|
+
element.style.pointerEvents = 'auto';
|
|
229
|
+
element.style.userSelect = 'auto';
|
|
230
|
+
}
|
|
231
|
+
createPanelProjectionRoot(child) {
|
|
232
|
+
const root = new THREE.Group();
|
|
233
|
+
root.matrixAutoUpdate = false;
|
|
234
|
+
child.position.set(0, 0, 0);
|
|
235
|
+
root.add(child);
|
|
236
|
+
return root;
|
|
237
|
+
}
|
|
238
|
+
setPanelProjectionTransform(root, targetX, targetY, targetZ) {
|
|
239
|
+
setPanelLocalPerspectiveMatrix(root.matrix, targetX, targetY, targetZ, this.panelCamera.position.z);
|
|
240
|
+
root.matrixWorldNeedsUpdate = true;
|
|
241
|
+
}
|
|
242
|
+
getPanelPointerLayout(panel, index, viewportWidth, viewportHeight, uiFocus) {
|
|
243
|
+
const minimap = this.minimaps.get(index);
|
|
244
|
+
const baseX = panel.options.position.x;
|
|
245
|
+
const baseY = panel.options.position.y;
|
|
246
|
+
const baseWidth = minimap ? minimap.baseWidth : panel.options.width;
|
|
247
|
+
const baseHeight = minimap ? minimap.baseHeight : panel.options.height;
|
|
248
|
+
const minimapFocus = minimap ? this.minimapFocus : 0;
|
|
249
|
+
const expansion = minimap && !this.fixedMinimapSize
|
|
250
|
+
? THREE.MathUtils.lerp(1, minimap.options.expandedHeight / minimap.baseHeight, minimapFocus)
|
|
251
|
+
: 1;
|
|
252
|
+
const visualWidth = baseWidth * expansion;
|
|
253
|
+
const visualHeight = baseHeight * expansion;
|
|
254
|
+
const rawFocusOffset = getPanelFocusOffset(panel.options, uiFocus, viewportWidth, viewportHeight);
|
|
255
|
+
const focusDepth = minimap ? rawFocusOffset.z * 0.12 : rawFocusOffset.z;
|
|
256
|
+
const minimapProjectionScale = minimap
|
|
257
|
+
? this.panelCamera.position.z / Math.max(this.panelCamera.position.z - focusDepth, 1)
|
|
258
|
+
: 1;
|
|
259
|
+
const minimapPositionOffset = minimap
|
|
260
|
+
? getMinimapFocusPositionOffset({ x: baseX, y: baseY }, { width: minimap.baseWidth, height: minimap.baseHeight }, {
|
|
261
|
+
width: visualWidth * minimapProjectionScale,
|
|
262
|
+
height: visualHeight * minimapProjectionScale
|
|
263
|
+
}, { width: viewportWidth, height: viewportHeight }, minimapFocus, MINIMAP_FOCUSED_VIEWPORT_INSET)
|
|
264
|
+
: undefined;
|
|
265
|
+
const focusPerspectiveOffset = minimap
|
|
266
|
+
? undefined
|
|
267
|
+
: getPanelFocusPerspectiveOffset({
|
|
268
|
+
x: baseX + rawFocusOffset.x,
|
|
269
|
+
y: baseY + rawFocusOffset.y
|
|
270
|
+
}, focusDepth, this.panelCamera.position.z);
|
|
271
|
+
const focusOffset = minimap
|
|
272
|
+
? {
|
|
273
|
+
x: minimapPositionOffset?.x ?? 0,
|
|
274
|
+
y: minimapPositionOffset?.y ?? 0,
|
|
275
|
+
z: focusDepth
|
|
276
|
+
}
|
|
277
|
+
: {
|
|
278
|
+
x: rawFocusOffset.x + (focusPerspectiveOffset?.x ?? 0),
|
|
279
|
+
y: rawFocusOffset.y + (focusPerspectiveOffset?.y ?? 0),
|
|
280
|
+
z: focusDepth
|
|
281
|
+
};
|
|
282
|
+
return {
|
|
283
|
+
baseX,
|
|
284
|
+
baseY,
|
|
285
|
+
centerX: viewportWidth * 0.5 + baseX + focusOffset.x,
|
|
286
|
+
centerY: viewportHeight * 0.5 - (baseY + focusOffset.y),
|
|
287
|
+
focusOffset,
|
|
288
|
+
minimap,
|
|
289
|
+
minimapFocus,
|
|
290
|
+
visualHeight,
|
|
291
|
+
visualWidth,
|
|
292
|
+
viewportVisible: this.isPanelTargetVisible(index)
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
updatePanelPointerInteraction(delta) {
|
|
296
|
+
const viewportWidth = window.innerWidth;
|
|
297
|
+
const viewportHeight = window.innerHeight;
|
|
298
|
+
const uiFocus = this.panelUiFocus;
|
|
299
|
+
const focusOpacity = getPanelFocusOpacity(uiFocus);
|
|
300
|
+
const layouts = this.panelRuntimes.map((panel, index) => this.getPanelPointerLayout(panel, index, viewportWidth, viewportHeight, uiFocus));
|
|
301
|
+
let animationActive = false;
|
|
302
|
+
this.visiblePanelCount = 0;
|
|
303
|
+
this.visibleMinimapCount = 0;
|
|
304
|
+
this.panelRuntimes.forEach((panel, index) => {
|
|
305
|
+
const { baseX, baseY, centerX, centerY, focusOffset, minimap, minimapFocus, visualHeight, visualWidth, viewportVisible } = layouts[index];
|
|
306
|
+
const transitionOpacity = this.getPanelTransitionOpacity(panel);
|
|
307
|
+
const transitionBlocked = this.catalogPresentation.active && Boolean(panel.transitionGroup);
|
|
308
|
+
if (viewportVisible)
|
|
309
|
+
this.visiblePanelCount += 1;
|
|
310
|
+
if (minimap) {
|
|
311
|
+
minimap.viewportVisible = viewportVisible;
|
|
312
|
+
minimap.layer.visible = viewportVisible && transitionOpacity > 0.001;
|
|
313
|
+
if (viewportVisible)
|
|
314
|
+
this.visibleMinimapCount += 1;
|
|
315
|
+
}
|
|
316
|
+
if (minimap) {
|
|
317
|
+
// The camera distance is already damped. Applying another size damping
|
|
318
|
+
// would make the minimap trail behind the geometry and miss its phase endpoint.
|
|
319
|
+
minimap.currentWidth = visualWidth;
|
|
320
|
+
minimap.currentHeight = visualHeight;
|
|
321
|
+
panel.glass?.setVisualSize(minimap.currentWidth, minimap.currentHeight, minimap.baseRadius);
|
|
322
|
+
panel.group.scale.x = dampAndSnap(panel.group.scale.x, 1, PANEL_POINTER_DAMPING, delta, 0.0001);
|
|
323
|
+
panel.group.scale.y = dampAndSnap(panel.group.scale.y, 1, PANEL_POINTER_DAMPING, delta, 0.0001);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
panel.group.scale.x = dampAndSnap(panel.group.scale.x, 1, PANEL_POINTER_DAMPING, delta, 0.0001);
|
|
327
|
+
panel.group.scale.y = dampAndSnap(panel.group.scale.y, 1, PANEL_POINTER_DAMPING, delta, 0.0001);
|
|
328
|
+
}
|
|
329
|
+
panel.group.scale.z = dampAndSnap(panel.group.scale.z, 1, PANEL_POINTER_DAMPING, delta, 0.0001);
|
|
330
|
+
animationActive ||= panel.group.scale.x !== 1;
|
|
331
|
+
animationActive ||= panel.group.scale.y !== 1;
|
|
332
|
+
animationActive ||= panel.group.scale.z !== 1;
|
|
333
|
+
const halfWidth = visualWidth * 0.5;
|
|
334
|
+
const halfHeight = visualHeight * 0.5;
|
|
335
|
+
const focusBlur = getPanelFocusBlur(uiFocus, panel.options);
|
|
336
|
+
let targetX = 0;
|
|
337
|
+
let targetY = 0;
|
|
338
|
+
let targetPointerLift = 0;
|
|
339
|
+
let pointerInfluence = 0;
|
|
340
|
+
if (panel.pointerReactive && this.pointer.active && viewportVisible && !transitionBlocked) {
|
|
341
|
+
const pointerX = this.pointer.x - centerX;
|
|
342
|
+
const pointerY = this.pointer.y - centerY;
|
|
343
|
+
const outsideX = Math.max(Math.abs(pointerX) - halfWidth, 0);
|
|
344
|
+
const outsideY = Math.max(Math.abs(pointerY) - halfHeight, 0);
|
|
345
|
+
const distance = Math.hypot(outsideX, outsideY);
|
|
346
|
+
const influence = getPanelPointerInfluence(distance, visualWidth, visualHeight);
|
|
347
|
+
pointerInfluence = influence;
|
|
348
|
+
const lookX = THREE.MathUtils.clamp(pointerX / halfWidth, -1, 1);
|
|
349
|
+
const lookY = THREE.MathUtils.clamp(pointerY / halfHeight, -1, 1);
|
|
350
|
+
const rotation = getPanelPointerRotation(lookX, lookY, influence, visualWidth, visualHeight);
|
|
351
|
+
targetX = rotation.x;
|
|
352
|
+
targetY = rotation.y;
|
|
353
|
+
targetPointerLift = PANEL_POINTER_MAX_LIFT * influence;
|
|
354
|
+
}
|
|
355
|
+
panel.pointerLift = dampAndSnap(panel.pointerLift, targetPointerLift, PANEL_POINTER_DAMPING, delta, 0.01);
|
|
356
|
+
animationActive ||= panel.pointerLift !== targetPointerLift;
|
|
357
|
+
const pointerProximity = THREE.MathUtils.clamp(PANEL_POINTER_MAX_LIFT > 0 ? panel.pointerLift / PANEL_POINTER_MAX_LIFT : 0, 0, 1);
|
|
358
|
+
const panelOpacity = minimap ? 1 : focusOpacity;
|
|
359
|
+
const surfaceOpacity = THREE.MathUtils.clamp(this.panelTargets[index]?.getSurfaceOpacity?.() ?? 1, 0, 1);
|
|
360
|
+
panel.glass?.setVisibilityAlpha(panelOpacity * surfaceOpacity * transitionOpacity);
|
|
361
|
+
panel.group.visible = panel.glass ? panel.group.visible && viewportVisible : viewportVisible;
|
|
362
|
+
if (panel.surface !== 'glass') {
|
|
363
|
+
const surfaceElement = this.panelTargets[index]?.surfaceElement;
|
|
364
|
+
if (surfaceElement) {
|
|
365
|
+
const opacityValue = surfaceOpacity.toFixed(4);
|
|
366
|
+
if (surfaceElement.style.getPropertyValue('--stage-panel-surface-opacity') !== opacityValue) {
|
|
367
|
+
surfaceElement.style.setProperty('--stage-panel-surface-opacity', opacityValue);
|
|
368
|
+
}
|
|
369
|
+
if (minimap) {
|
|
370
|
+
this.updateSurfaceElement(surfaceElement, panel, minimap.currentWidth, minimap.currentHeight, true);
|
|
371
|
+
}
|
|
372
|
+
const focusOpacityValue = panelOpacity.toFixed(4);
|
|
373
|
+
if (surfaceElement.style.getPropertyValue('--stage-panel-focus-opacity') !==
|
|
374
|
+
focusOpacityValue) {
|
|
375
|
+
surfaceElement.style.setProperty('--stage-panel-focus-opacity', focusOpacityValue);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
animationActive =
|
|
380
|
+
this.easePanelTransform(panel.group, targetX, targetY, baseX + focusOffset.x, baseY + focusOffset.y, focusOffset.z + panel.pointerLift, delta, panel.projectionRoot) || animationActive;
|
|
381
|
+
if (minimap) {
|
|
382
|
+
minimap.pointerReveal = dampAndSnap(minimap.pointerReveal, pointerInfluence, MINIMAP_OVERLAY_REVEAL_DAMPING, delta, 0.001);
|
|
383
|
+
animationActive ||= minimap.pointerReveal !== pointerInfluence;
|
|
384
|
+
minimap.layer.position.copy(panel.group.position);
|
|
385
|
+
minimap.layer.rotation.copy(panel.group.rotation);
|
|
386
|
+
minimap.layer.scale.copy(panel.group.scale);
|
|
387
|
+
// All minimap layers use the same atomic panel pose so the glass, viewport
|
|
388
|
+
// ring, and floating model cannot drift apart during zoom.
|
|
389
|
+
if (viewportVisible)
|
|
390
|
+
this.updateMinimapState(minimap, minimapFocus);
|
|
391
|
+
}
|
|
392
|
+
const contentObject = panel.content;
|
|
393
|
+
if (contentObject) {
|
|
394
|
+
const contentOpacity = minimap ? 1 : focusOpacity;
|
|
395
|
+
const contentBlur = minimap ? 0 : focusBlur;
|
|
396
|
+
const interactiveContent = panel.surface === 'glass'
|
|
397
|
+
? contentObject.element
|
|
398
|
+
: (this.panelTargets[index]?.content ?? contentObject.element);
|
|
399
|
+
const pointerProximityValue = pointerProximity.toFixed(4);
|
|
400
|
+
if (interactiveContent.style.getPropertyValue('--stage-panel-pointer-proximity') !==
|
|
401
|
+
pointerProximityValue) {
|
|
402
|
+
interactiveContent.style.setProperty('--stage-panel-pointer-proximity', pointerProximityValue);
|
|
403
|
+
}
|
|
404
|
+
// Shared destinations must remain measurable while their transition alpha is zero.
|
|
405
|
+
// CSS visibility/opacity gate their paint; CSS3D visibility would set display:none.
|
|
406
|
+
contentObject.visible = viewportVisible && contentOpacity >= 0.01;
|
|
407
|
+
contentObject.element.style.setProperty('--stage-panel-content-opacity', `${contentOpacity}`);
|
|
408
|
+
if (panel.surface !== 'glass') {
|
|
409
|
+
// Keep filter off the shell that owns backdrop-filter. Applying it
|
|
410
|
+
// there turns the shell into a Backdrop Root in Chromium.
|
|
411
|
+
contentObject.element.style.filter = '';
|
|
412
|
+
}
|
|
413
|
+
interactiveContent.style.filter =
|
|
414
|
+
contentBlur > 0.05 ? `blur(${contentBlur.toFixed(2)}px)` : '';
|
|
415
|
+
const pointerEvents = transitionBlocked || contentOpacity * transitionOpacity < 0.12 ? 'none' : 'auto';
|
|
416
|
+
contentObject.element.style.pointerEvents = pointerEvents;
|
|
417
|
+
interactiveContent.style.pointerEvents = pointerEvents;
|
|
418
|
+
animationActive =
|
|
419
|
+
this.easePanelTransform(contentObject, targetX, targetY, baseX + focusOffset.x, baseY + focusOffset.y, PANEL_CONTENT_Z + focusOffset.z + panel.pointerLift, delta, panel.contentProjectionRoot) || animationActive;
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
return animationActive;
|
|
423
|
+
}
|
|
424
|
+
easePanelTransform(object, targetRotationX, targetRotationY, targetX, targetY, targetZ, delta, projectionRoot) {
|
|
425
|
+
object.rotation.x = dampAndSnap(object.rotation.x, targetRotationX, PANEL_POINTER_DAMPING, delta, 0.00005);
|
|
426
|
+
object.rotation.y = dampAndSnap(object.rotation.y, targetRotationY, PANEL_POINTER_DAMPING, delta, 0.00005);
|
|
427
|
+
if (projectionRoot) {
|
|
428
|
+
object.position.set(0, 0, 0);
|
|
429
|
+
this.setPanelProjectionTransform(projectionRoot, targetX, targetY, targetZ);
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
const anchoredPosition = getPerspectiveAnchoredPanelPosition(targetX, targetY, targetZ, this.panelCamera.position.z);
|
|
433
|
+
// Commit the complete focus pose together. Independently damping Z and then
|
|
434
|
+
// deriving X/Y from that lagging depth caused projected panels to overshoot
|
|
435
|
+
// and briefly reverse direction during close-up transitions.
|
|
436
|
+
object.position.set(anchoredPosition.x, anchoredPosition.y, targetZ);
|
|
437
|
+
}
|
|
438
|
+
return object.rotation.x !== targetRotationX || object.rotation.y !== targetRotationY;
|
|
439
|
+
}
|
|
440
|
+
updatePanelDomRenderModes() {
|
|
441
|
+
let transitionPending = false;
|
|
442
|
+
this.panelRuntimes.forEach((panel, index) => {
|
|
443
|
+
const content = panel.content;
|
|
444
|
+
const projectionRoot = panel.contentProjectionRoot;
|
|
445
|
+
if (!content || !projectionRoot || this.minimaps.has(index)) {
|
|
446
|
+
panel.nativeRestFrames = 0;
|
|
447
|
+
this.setPanelDomRenderMode(panel, 'spatial');
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
const rotationAtRest = Math.abs(content.rotation.x) <= PANEL_NATIVE_ROTATION_EPSILON &&
|
|
451
|
+
Math.abs(content.rotation.y) <= PANEL_NATIVE_ROTATION_EPSILON &&
|
|
452
|
+
Math.abs(content.rotation.z) <= PANEL_NATIVE_ROTATION_EPSILON;
|
|
453
|
+
const depthAtRest = Math.abs(projectionRoot.matrix.elements[14] - PANEL_CONTENT_Z) <=
|
|
454
|
+
PANEL_NATIVE_DEPTH_EPSILON;
|
|
455
|
+
if (!rotationAtRest || !depthAtRest) {
|
|
456
|
+
panel.nativeRestFrames = 0;
|
|
457
|
+
this.setPanelDomRenderMode(panel, 'spatial');
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
panel.nativeRestFrames = Math.min(panel.nativeRestFrames + 1, PANEL_NATIVE_REST_FRAMES);
|
|
461
|
+
if (panel.nativeRestFrames >= PANEL_NATIVE_REST_FRAMES) {
|
|
462
|
+
this.setPanelDomRenderMode(panel, 'native');
|
|
463
|
+
}
|
|
464
|
+
else if (panel.domRenderMode !== 'native') {
|
|
465
|
+
transitionPending = true;
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
return transitionPending;
|
|
469
|
+
}
|
|
470
|
+
setPanelDomRenderMode(panel, mode) {
|
|
471
|
+
if (!panel.content || panel.domRenderMode === mode)
|
|
472
|
+
return;
|
|
473
|
+
panel.domRenderMode = mode;
|
|
474
|
+
const element = panel.content.element;
|
|
475
|
+
const focused = element.contains(document.activeElement)
|
|
476
|
+
? document.activeElement
|
|
477
|
+
: undefined;
|
|
478
|
+
const restoreFocus = () => {
|
|
479
|
+
if (focused?.isConnected && document.activeElement !== focused)
|
|
480
|
+
focused.focus({ preventScroll: true });
|
|
481
|
+
};
|
|
482
|
+
element.dataset.stagePanelRenderMode = mode;
|
|
483
|
+
if (mode === 'native') {
|
|
484
|
+
if (panel.surface === 'glass') {
|
|
485
|
+
(panel.contentProjectionRoot ?? panel.content).removeFromParent();
|
|
486
|
+
}
|
|
487
|
+
this.nativePanelLayer.appendChild(element);
|
|
488
|
+
restoreFocus();
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
element.style.transform = '';
|
|
492
|
+
element.style.transformOrigin = '';
|
|
493
|
+
if (panel.surface === 'glass') {
|
|
494
|
+
element.style.left = '0';
|
|
495
|
+
element.style.top = '0';
|
|
496
|
+
const contentRoot = panel.contentProjectionRoot ?? panel.content;
|
|
497
|
+
if (contentRoot.parent !== this.panelContentScene)
|
|
498
|
+
this.panelContentScene.add(contentRoot);
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
element.style.left = '50%';
|
|
502
|
+
element.style.top = '50%';
|
|
503
|
+
this.flatPanelLayer.appendChild(element);
|
|
504
|
+
}
|
|
505
|
+
restoreFocus();
|
|
506
|
+
}
|
|
507
|
+
renderFlatPanelSurfaces() {
|
|
508
|
+
this.panelRuntimes.forEach((panel, index) => {
|
|
509
|
+
if (!panel.content || (panel.surface === 'glass' && panel.domRenderMode === 'spatial'))
|
|
510
|
+
return;
|
|
511
|
+
const { content } = panel;
|
|
512
|
+
content.element.style.display = content.visible ? '' : 'none';
|
|
513
|
+
if (!content.visible)
|
|
514
|
+
return;
|
|
515
|
+
panel.contentProjectionRoot?.updateMatrixWorld(true);
|
|
516
|
+
content.updateMatrixWorld(true);
|
|
517
|
+
const minimap = this.minimaps.get(index);
|
|
518
|
+
if (minimap) {
|
|
519
|
+
this.renderFlatMinimapSurface(content.element, minimap, minimap.currentWidth, minimap.currentHeight);
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
if (panel.domRenderMode === 'native') {
|
|
523
|
+
this.renderNativePanelSurface(panel);
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
content.element.style.transform = getFlatCss3DTransform(content.matrixWorld);
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
renderNativePanelSurface(panel) {
|
|
530
|
+
const content = panel.content;
|
|
531
|
+
if (!content)
|
|
532
|
+
return;
|
|
533
|
+
panel.contentProjectionRoot?.updateMatrixWorld(true);
|
|
534
|
+
content.updateMatrixWorld(true);
|
|
535
|
+
const element = content.element;
|
|
536
|
+
const width = Number.parseFloat(element.style.width) || element.offsetWidth;
|
|
537
|
+
const height = Number.parseFloat(element.style.height) || element.offsetHeight;
|
|
538
|
+
const matrix = content.matrixWorld.elements;
|
|
539
|
+
const position = getNativePanelDomPosition({ x: matrix[12], y: matrix[13] }, { width, height }, { width: window.innerWidth, height: window.innerHeight }, window.devicePixelRatio);
|
|
540
|
+
element.style.left = `${position.left}px`;
|
|
541
|
+
element.style.top = `${position.top}px`;
|
|
542
|
+
element.style.transform = 'none';
|
|
543
|
+
element.style.transformOrigin = '0 0';
|
|
544
|
+
}
|
|
545
|
+
renderFlatMinimapSurface(element, minimap, panelWidth, panelHeight) {
|
|
546
|
+
const halfWidth = panelWidth * 0.5;
|
|
547
|
+
const halfHeight = panelHeight * 0.5;
|
|
548
|
+
const viewportWidth = Math.max(window.innerWidth, 1);
|
|
549
|
+
const viewportHeight = Math.max(window.innerHeight, 1);
|
|
550
|
+
const localCorners = this.minimapCssLocalCorners;
|
|
551
|
+
const projectedCorners = this.minimapCssProjectionCorners;
|
|
552
|
+
localCorners[0].set(-halfWidth, halfHeight, 0);
|
|
553
|
+
localCorners[1].set(halfWidth, halfHeight, 0);
|
|
554
|
+
localCorners[2].set(halfWidth, -halfHeight, 0);
|
|
555
|
+
localCorners[3].set(-halfWidth, -halfHeight, 0);
|
|
556
|
+
const offsetLeft = element.offsetLeft;
|
|
557
|
+
const offsetTop = element.offsetTop;
|
|
558
|
+
localCorners.forEach((corner, index) => {
|
|
559
|
+
corner.applyMatrix4(minimap.layer.matrixWorld).project(minimap.screenCamera);
|
|
560
|
+
projectedCorners[index].set((corner.x + 1) * viewportWidth * 0.5 - offsetLeft, (1 - corner.y) * viewportHeight * 0.5 - offsetTop);
|
|
561
|
+
});
|
|
562
|
+
const cssWidth = Number.parseFloat(element.style.width) || panelWidth;
|
|
563
|
+
const cssHeight = Number.parseFloat(element.style.height) || panelHeight;
|
|
564
|
+
const transform = getProjectiveCssMatrix3d(projectedCorners, cssWidth, cssHeight);
|
|
565
|
+
if (transform)
|
|
566
|
+
element.style.transform = transform;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
//# sourceMappingURL=PanelPresentationController.js.map
|