@spatial-elements/core 1.0.0-beta.3 → 1.0.0-beta.5
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/README.md +1 -1
- package/dist/catalog/CatalogSpatialElementLayer.d.ts +1 -0
- package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -1
- package/dist/catalog/CatalogSpatialElementLayer.js +13 -1
- package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
- package/dist/catalog/carouselMotion.d.ts +39 -0
- package/dist/catalog/carouselMotion.d.ts.map +1 -0
- package/dist/catalog/carouselMotion.js +104 -0
- package/dist/catalog/carouselMotion.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/spatial-element/SpatialElementDockController.d.ts +1 -1
- package/dist/spatial-element/SpatialElementDockController.d.ts.map +1 -1
- package/dist/spatial-element/SpatialElementDockController.js +29 -2
- package/dist/spatial-element/SpatialElementDockController.js.map +1 -1
- package/dist/spatial-element/messages.d.ts +34 -0
- package/dist/spatial-element/messages.d.ts.map +1 -0
- package/dist/spatial-element/messages.js +34 -0
- package/dist/spatial-element/messages.js.map +1 -0
- package/dist/spatial-element/spatialTheme.d.ts.map +1 -1
- package/dist/spatial-element/spatialTheme.js +1 -0
- package/dist/spatial-element/spatialTheme.js.map +1 -1
- package/dist/spatial-element/types.d.ts +2 -0
- package/dist/spatial-element/types.d.ts.map +1 -1
- package/dist/spatial-element/types.js.map +1 -1
- package/dist/stage/LiquidGlassPanel.d.ts +2 -0
- package/dist/stage/LiquidGlassPanel.d.ts.map +1 -1
- package/dist/stage/LiquidGlassPanel.js +11 -2
- package/dist/stage/LiquidGlassPanel.js.map +1 -1
- package/dist/stage/MinimapController.d.ts +3 -1
- package/dist/stage/MinimapController.d.ts.map +1 -1
- package/dist/stage/MinimapController.js +23 -20
- package/dist/stage/MinimapController.js.map +1 -1
- package/dist/stage/ModelPointerPreview.d.ts +22 -0
- package/dist/stage/ModelPointerPreview.d.ts.map +1 -0
- package/dist/stage/ModelPointerPreview.js +71 -0
- package/dist/stage/ModelPointerPreview.js.map +1 -0
- package/dist/stage/PageBindingController.d.ts +4 -0
- package/dist/stage/PageBindingController.d.ts.map +1 -1
- package/dist/stage/PageBindingController.js +17 -4
- package/dist/stage/PageBindingController.js.map +1 -1
- package/dist/stage/PanelPresentationController.d.ts +4 -1
- package/dist/stage/PanelPresentationController.d.ts.map +1 -1
- package/dist/stage/PanelPresentationController.js +91 -12
- package/dist/stage/PanelPresentationController.js.map +1 -1
- package/dist/stage/SpatialElementInteractionController.d.ts +12 -0
- package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -1
- package/dist/stage/SpatialElementInteractionController.js +125 -11
- package/dist/stage/SpatialElementInteractionController.js.map +1 -1
- package/dist/stage/StageExperience.d.ts +30 -1
- package/dist/stage/StageExperience.d.ts.map +1 -1
- package/dist/stage/StageExperience.js +214 -55
- package/dist/stage/StageExperience.js.map +1 -1
- package/dist/stage/StageFullscreenController.d.ts +17 -0
- package/dist/stage/StageFullscreenController.d.ts.map +1 -0
- package/dist/stage/StageFullscreenController.js +90 -0
- package/dist/stage/StageFullscreenController.js.map +1 -0
- package/dist/stage/StagePanelRuntime.d.ts +2 -1
- package/dist/stage/StagePanelRuntime.d.ts.map +1 -1
- package/dist/stage/StagePanelRuntime.js.map +1 -1
- package/dist/stage/StageRenderPipeline.d.ts +6 -0
- package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
- package/dist/stage/StageRenderPipeline.js +41 -9
- package/dist/stage/StageRenderPipeline.js.map +1 -1
- package/dist/stage/VirtualScrollController.d.ts.map +1 -1
- package/dist/stage/VirtualScrollController.js +6 -0
- package/dist/stage/VirtualScrollController.js.map +1 -1
- package/dist/stage/interactionGuidance.d.ts +22 -0
- package/dist/stage/interactionGuidance.d.ts.map +1 -0
- package/dist/stage/interactionGuidance.js +53 -0
- package/dist/stage/interactionGuidance.js.map +1 -0
- package/dist/stage/minimap/MinimapProjection.d.ts +7 -0
- package/dist/stage/minimap/MinimapProjection.d.ts.map +1 -1
- package/dist/stage/minimap/MinimapProjection.js +14 -13
- package/dist/stage/minimap/MinimapProjection.js.map +1 -1
- package/dist/stage/mouseHover.d.ts +9 -0
- package/dist/stage/mouseHover.d.ts.map +1 -0
- package/dist/stage/mouseHover.js +55 -0
- package/dist/stage/mouseHover.js.map +1 -0
- package/dist/stage/panelContext.d.ts +15 -1
- package/dist/stage/panelContext.d.ts.map +1 -1
- package/dist/stage/panelContext.js.map +1 -1
- package/dist/stage/scrollFrame.d.ts +2 -0
- package/dist/stage/scrollFrame.d.ts.map +1 -1
- package/dist/stage/scrollFrame.js +18 -5
- package/dist/stage/scrollFrame.js.map +1 -1
- package/dist/stage/stageConstants.d.ts +3 -3
- package/dist/stage/stageConstants.d.ts.map +1 -1
- package/dist/stage/stageConstants.js +3 -3
- package/dist/stage/stageConstants.js.map +1 -1
- package/dist/stage/stageDom.d.ts +2 -0
- package/dist/stage/stageDom.d.ts.map +1 -1
- package/dist/stage/stageDom.js +4 -0
- package/dist/stage/stageDom.js.map +1 -1
- package/dist/stage/stageMath.d.ts +6 -7
- package/dist/stage/stageMath.d.ts.map +1 -1
- package/dist/stage/stageMath.js +12 -11
- package/dist/stage/stageMath.js.map +1 -1
- package/dist/stage/stageTypes.d.ts +12 -2
- package/dist/stage/stageTypes.d.ts.map +1 -1
- package/dist/stage/stageTypes.js.map +1 -1
- package/dist/stage/stageVisualTest.d.ts +5 -1
- package/dist/stage/stageVisualTest.d.ts.map +1 -1
- package/dist/stage/stageVisualTest.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const MODEL_INPUT_EVENT = 'stage:model-input';
|
|
2
|
+
const STORAGE_KEY = 'spatial-elements:interaction-guidance:v1';
|
|
3
|
+
/** One learning state per browser tab, shared across products and stage remounts. */
|
|
4
|
+
export class InteractionGuidance {
|
|
5
|
+
storage;
|
|
6
|
+
state = { interacted: false };
|
|
7
|
+
listeners = new Set();
|
|
8
|
+
constructor(storage) {
|
|
9
|
+
this.storage = storage;
|
|
10
|
+
try {
|
|
11
|
+
const saved = JSON.parse(storage?.getItem(STORAGE_KEY) ?? '{}');
|
|
12
|
+
this.state = { interacted: saved.interacted === true };
|
|
13
|
+
}
|
|
14
|
+
catch { /* Storage is optional, including in private browsing. */ }
|
|
15
|
+
}
|
|
16
|
+
get snapshot() { return this.state; }
|
|
17
|
+
interact() {
|
|
18
|
+
if (!this.state.interacted)
|
|
19
|
+
this.update({ interacted: true });
|
|
20
|
+
}
|
|
21
|
+
subscribe(listener) {
|
|
22
|
+
this.listeners.add(listener);
|
|
23
|
+
listener(this.state);
|
|
24
|
+
return () => { this.listeners.delete(listener); };
|
|
25
|
+
}
|
|
26
|
+
update(state) {
|
|
27
|
+
this.state = state;
|
|
28
|
+
try {
|
|
29
|
+
this.storage?.setItem(STORAGE_KEY, JSON.stringify(state));
|
|
30
|
+
}
|
|
31
|
+
catch { /* In-memory fallback. */ }
|
|
32
|
+
for (const listener of this.listeners)
|
|
33
|
+
listener(state);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const sessions = new WeakMap();
|
|
37
|
+
/** Lazy browser access keeps server rendering isolated between requests. */
|
|
38
|
+
export function getInteractionGuidance(target = typeof window === 'undefined' ? undefined : window) {
|
|
39
|
+
if (!target)
|
|
40
|
+
return new InteractionGuidance();
|
|
41
|
+
let session = sessions.get(target);
|
|
42
|
+
if (!session) {
|
|
43
|
+
let storage;
|
|
44
|
+
try {
|
|
45
|
+
storage = target.sessionStorage;
|
|
46
|
+
}
|
|
47
|
+
catch { /* Sandboxed/private context. */ }
|
|
48
|
+
session = new InteractionGuidance(storage);
|
|
49
|
+
sessions.set(target, session);
|
|
50
|
+
}
|
|
51
|
+
return session;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=interactionGuidance.js.map
|
|
@@ -0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;YAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,yBAAyB,CAAC,CAAC;QACtG,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS;YAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC;CACD;AAED,MAAM,QAAQ,GAAG,IAAI,OAAO,EAA+B,CAAC;AAC5D,4EAA4E;AAC5E,MAAM,UAAU,sBAAsB,CAAC,MAAM,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM;IACjG,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,mBAAmB,EAAE,CAAC;IAC9C,IAAI,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,IAAI,OAA4B,CAAC;QACjC,IAAI,CAAC;YAAC,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,gCAAgC,CAAC,CAAC;QACnF,OAAO,GAAG,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAC3C,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC","sourcesContent":["export const MODEL_INPUT_EVENT = 'stage:model-input';\nexport interface ModelInputState { hovered: boolean; active: boolean }\nexport interface InteractionGuidanceState { interacted: boolean }\nconst STORAGE_KEY = 'spatial-elements:interaction-guidance:v1';\n\n/** One learning state per browser tab, shared across products and stage remounts. */\nexport class InteractionGuidance {\n\tprivate state: InteractionGuidanceState = { interacted: false };\n\tprivate readonly listeners = new Set<(state: Readonly<InteractionGuidanceState>) => void>();\n\tconstructor(private readonly storage?: Pick<Storage, 'getItem' | 'setItem'>) {\n\t\ttry {\n\t\t\tconst saved = JSON.parse(storage?.getItem(STORAGE_KEY) ?? '{}');\n\t\t\tthis.state = { interacted: saved.interacted === true };\n\t\t} catch { /* Storage is optional, including in private browsing. */ }\n\t}\n\tget snapshot(): Readonly<InteractionGuidanceState> { return this.state; }\n\tinteract() {\n\t\tif (!this.state.interacted) this.update({ interacted: true });\n\t}\n\tsubscribe(listener: (state: Readonly<InteractionGuidanceState>) => void) {\n\t\tthis.listeners.add(listener);\n\t\tlistener(this.state);\n\t\treturn () => { this.listeners.delete(listener); };\n\t}\n\tprivate update(state: InteractionGuidanceState) {\n\t\tthis.state = state;\n\t\ttry { this.storage?.setItem(STORAGE_KEY, JSON.stringify(state)); } catch { /* In-memory fallback. */ }\n\t\tfor (const listener of this.listeners) listener(state);\n\t}\n}\n\nconst sessions = new WeakMap<Window, InteractionGuidance>();\n/** Lazy browser access keeps server rendering isolated between requests. */\nexport function getInteractionGuidance(target = typeof window === 'undefined' ? undefined : window) {\n\tif (!target) return new InteractionGuidance();\n\tlet session = sessions.get(target);\n\tif (!session) {\n\t\tlet storage: Storage | undefined;\n\t\ttry { storage = target.sessionStorage; } catch { /* Sandboxed/private context. */ }\n\t\tsession = new InteractionGuidance(storage);\n\t\tsessions.set(target, session);\n\t}\n\treturn session;\n}\n"]}
|
|
@@ -36,6 +36,13 @@ export interface MinimapViewportRect {
|
|
|
36
36
|
* panel in screen space.
|
|
37
37
|
*/
|
|
38
38
|
export declare function getMinimapViewportRect(stageCamera: THREE.PerspectiveCamera, minimapCamera: THREE.PerspectiveCamera, target: THREE.Vector3, stageModel: Object3D, minimapSourceRoot: Object3D, minimapSourceLayer: Object3D, width: number, height: number): MinimapViewportRect | null;
|
|
39
|
+
/** Intersects the projected view with the panel without scaling or shifting it. */
|
|
40
|
+
export declare function clipMinimapViewportRect(rect: MinimapViewportRect, width: number, height: number): {
|
|
41
|
+
left: number;
|
|
42
|
+
top: number;
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
};
|
|
39
46
|
/** Normalizes a CSS blur radius before it is passed to the WebGPU blur pipeline. */
|
|
40
47
|
export declare function getMinimapCssBlurRadius(blur: number): number;
|
|
41
48
|
//# sourceMappingURL=MinimapProjection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MinimapProjection.d.ts","sourceRoot":"","sources":["../../../src/stage/minimap/MinimapProjection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEjF,MAAM,WAAW,iBAAiB;IACjC,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CACnC,MAAM,EAAE,SAAS,iBAAiB,EAAE,EACpC,KAAK,SAAK,EACV,WAAW,SAAO;;;EAqBlB;AAED,yFAAyF;AACzF,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,UAI3E;AAED,oFAAoF;AACpF,MAAM,WAAW,mBAAmB;IACnC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACrC,WAAW,EAAE,KAAK,CAAC,iBAAiB,EACpC,aAAa,EAAE,KAAK,CAAC,iBAAiB,EACtC,MAAM,EAAE,KAAK,CAAC,OAAO,EACrB,UAAU,EAAE,QAAQ,EACpB,iBAAiB,EAAE,QAAQ,EAC3B,kBAAkB,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AmF;AACnF,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;;EAM/F;AAED,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,UAEnD"}
|
|
@@ -82,30 +82,31 @@ export function getMinimapViewportRect(stageCamera, minimapCamera, target, stage
|
|
|
82
82
|
const maxY = Math.max(...projected.map((point) => point.y));
|
|
83
83
|
const centerX = (minX + maxX) * 0.5;
|
|
84
84
|
const centerY = (minY + maxY) * 0.5;
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
const rectWidth = maxX - minX;
|
|
86
|
+
const rectHeight = maxY - minY;
|
|
87
87
|
if (!Number.isFinite(rectWidth) ||
|
|
88
88
|
!Number.isFinite(rectHeight) ||
|
|
89
89
|
rectWidth <= 0 ||
|
|
90
90
|
rectHeight <= 0) {
|
|
91
91
|
return null;
|
|
92
92
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
rectWidth *= minScale;
|
|
96
|
-
rectHeight *= minScale;
|
|
97
|
-
const fitScale = Math.min(width / rectWidth, height / rectHeight, 1);
|
|
98
|
-
rectWidth *= fitScale;
|
|
99
|
-
rectHeight *= fitScale;
|
|
100
|
-
const maxCenterX = Math.max((width - rectWidth) * 0.5, 0);
|
|
101
|
-
const maxCenterY = Math.max((height - rectHeight) * 0.5, 0);
|
|
93
|
+
// Preserve the true footprint, including edges outside the minimap. Fitting
|
|
94
|
+
// it into the panel would falsely crop the model on wide/tall viewports.
|
|
102
95
|
return {
|
|
103
|
-
x:
|
|
104
|
-
y:
|
|
96
|
+
x: centerX,
|
|
97
|
+
y: centerY,
|
|
105
98
|
width: rectWidth,
|
|
106
99
|
height: rectHeight
|
|
107
100
|
};
|
|
108
101
|
}
|
|
102
|
+
/** Intersects the projected view with the panel without scaling or shifting it. */
|
|
103
|
+
export function clipMinimapViewportRect(rect, width, height) {
|
|
104
|
+
const left = THREE.MathUtils.clamp(width * 0.5 + rect.x - rect.width * 0.5, 0, width);
|
|
105
|
+
const right = THREE.MathUtils.clamp(width * 0.5 + rect.x + rect.width * 0.5, 0, width);
|
|
106
|
+
const top = THREE.MathUtils.clamp(height * 0.5 - rect.y - rect.height * 0.5, 0, height);
|
|
107
|
+
const bottom = THREE.MathUtils.clamp(height * 0.5 - rect.y + rect.height * 0.5, 0, height);
|
|
108
|
+
return { left, top, width: right - left, height: bottom - top };
|
|
109
|
+
}
|
|
109
110
|
/** Normalizes a CSS blur radius before it is passed to the WebGPU blur pipeline. */
|
|
110
111
|
export function getMinimapCssBlurRadius(blur) {
|
|
111
112
|
return Math.max(blur, 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MinimapProjection.js","sourceRoot":"","sources":["../../../src/stage/minimap/MinimapProjection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAU/D;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CACnC,MAAoC,EACpC,KAAK,GAAG,EAAE,EACV,WAAW,GAAG,IAAI;IAElB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAClE,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC9F,IAAI,IAAI,GAAG,MAAM,CAAC,iBAAiB,CAAC;IACpC,IAAI,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAEnC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,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AG,CAAC,KAAK,GAAG,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC;IACrE,SAAS,IAAI,QAAQ,CAAC;IACtB,UAAU,IAAI,QAAQ,CAAC;IACvB,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,SAAS,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,UAAU,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC;IAE5D,OAAO;QACN,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;QAC1D,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;QAC1D,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,UAAU;KAClB,CAAC;AACH,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,uBAAuB,CAAC,IAAY;IACnD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import * as THREE from 'three/webgpu';\nimport type { Object3D } from 'three';\n\nexport { getProjectiveCssMatrix3d } from '../cssProjection.js';\nexport type { CssProjectionPoint, CssProjectionQuad } from '../cssProjection.js';\n\nexport interface MinimapDepthBound {\n\t/** Positive camera-space distance to the bound's center. */\n\tdistance: number;\n\t/** Camera-space radius that must remain inside the clipping range. */\n\tradius: number;\n}\n\n/**\n * Fits a compact clipping range around the panel and live minimap model.\n *\n * The regular panel camera spans thousands of world units. Reusing that range\n * for thumbnail geometry collapses closely layered element surfaces into the\n * same depth values, so a small pointer tilt can make their fragments alternate.\n */\nexport function getMinimapDepthRange(\n\tbounds: readonly MinimapDepthBound[],\n\tguard = 16,\n\tminimumNear = 0.01\n) {\n\tconst safeGuard = Math.max(Number.isFinite(guard) ? guard : 0, 0);\n\tconst safeMinimumNear = Math.max(Number.isFinite(minimumNear) ? minimumNear : 0.01, 0.000001);\n\tlet near = Number.POSITIVE_INFINITY;\n\tlet far = Number.NEGATIVE_INFINITY;\n\n\tbounds.forEach(({ distance, radius }) => {\n\t\tif (!Number.isFinite(distance) || distance <= 0) return;\n\t\tconst safeRadius = Math.max(Number.isFinite(radius) ? radius : 0, 0);\n\t\tnear = Math.min(near, distance - safeRadius);\n\t\tfar = Math.max(far, distance + safeRadius);\n\t});\n\n\tif (!Number.isFinite(near) || !Number.isFinite(far)) {\n\t\treturn { near: safeMinimumNear, far: safeMinimumNear + 1 };\n\t}\n\n\tnear = Math.max(near - safeGuard, safeMinimumNear);\n\tfar = Math.max(far + safeGuard, near + 0.01);\n\treturn { near, far };\n}\n\n/** Returns the FOV that makes panel-local world units match CSS pixels at a distance. */\nexport function getPanelLocalCameraFov(panelHeight: number, distance: number) {\n\treturn THREE.MathUtils.radToDeg(\n\t\t2 * Math.atan(Math.max(panelHeight, 1) / (Math.max(distance, 1) * 2))\n\t);\n}\n\n/** Rectangle, in panel-local pixels, occupied by the main camera's current view. */\nexport interface MinimapViewportRect {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n}\n\n/**\n * Projects the main camera frustum onto the minimap model's target plane.\n *\n * The conversion intentionally passes through model-local coordinates. This keeps\n * panning and orbiting stable even though the minimap layer itself follows a tilted\n * panel in screen space.\n */\nexport function getMinimapViewportRect(\n\tstageCamera: THREE.PerspectiveCamera,\n\tminimapCamera: THREE.PerspectiveCamera,\n\ttarget: THREE.Vector3,\n\tstageModel: Object3D,\n\tminimapSourceRoot: Object3D,\n\tminimapSourceLayer: Object3D,\n\twidth: number,\n\theight: number\n): MinimapViewportRect | null {\n\tconst stageForward = new THREE.Vector3();\n\tstageCamera.getWorldDirection(stageForward);\n\tif (stageForward.lengthSq() < 0.0001) return null;\n\n\tconst targetPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(stageForward, target);\n\tconst stageOrigin = stageCamera.getWorldPosition(new THREE.Vector3());\n\tconst stageRay = new THREE.Ray();\n\tconst hit = new THREE.Vector3();\n\tconst projected: THREE.Vector2[] = [];\n\tconst corners = [\n\t\tnew THREE.Vector3(-1, -1, 0.5),\n\t\tnew THREE.Vector3(1, -1, 0.5),\n\t\tnew THREE.Vector3(1, 1, 0.5),\n\t\tnew THREE.Vector3(-1, 1, 0.5)\n\t];\n\n\tstageCamera.updateMatrixWorld(true);\n\tstageModel.updateWorldMatrix(true, true);\n\tminimapSourceRoot.updateWorldMatrix(true, true);\n\tminimapSourceLayer.updateWorldMatrix(true, true);\n\tminimapCamera.updateMatrixWorld(true);\n\n\tcorners.forEach((corner) => {\n\t\tconst worldPoint = corner.clone().unproject(stageCamera);\n\t\tconst direction = worldPoint.sub(stageOrigin).normalize();\n\t\tstageRay.set(stageOrigin, direction);\n\t\tconst intersection = stageRay.intersectPlane(targetPlane, hit);\n\t\tif (!intersection) return;\n\n\t\tconst modelPoint = stageModel.worldToLocal(intersection.clone());\n\t\tconst minimapPoint = minimapSourceRoot.localToWorld(modelPoint);\n\t\t// The camera is panel-local, so remove the layer's shared screen transform.\n\t\tminimapSourceLayer.worldToLocal(minimapPoint);\n\t\tconst ndc = minimapPoint.project(minimapCamera);\n\t\tif (!Number.isFinite(ndc.x) || !Number.isFinite(ndc.y)) return;\n\t\tprojected.push(new THREE.Vector2(ndc.x * width * 0.5, ndc.y * height * 0.5));\n\t});\n\n\tif (projected.length < 4) return null;\n\tconst minX = Math.min(...projected.map((point) => point.x));\n\tconst maxX = Math.max(...projected.map((point) => point.x));\n\tconst minY = Math.min(...projected.map((point) => point.y));\n\tconst maxY = Math.max(...projected.map((point) => point.y));\n\tconst centerX = (minX + maxX) * 0.5;\n\tconst centerY = (minY + maxY) * 0.5;\n\tlet rectWidth = maxX - minX;\n\tlet rectHeight = maxY - minY;\n\tif (\n\t\t!Number.isFinite(rectWidth) ||\n\t\t!Number.isFinite(rectHeight) ||\n\t\trectWidth <= 0 ||\n\t\trectHeight <= 0\n\t) {\n\t\treturn null;\n\t}\n\n\tconst minSize = 8;\n\tconst minScale = Math.max(minSize / rectWidth, minSize / rectHeight, 1);\n\trectWidth *= minScale;\n\trectHeight *= minScale;\n\tconst fitScale = Math.min(width / rectWidth, height / rectHeight, 1);\n\trectWidth *= fitScale;\n\trectHeight *= fitScale;\n\tconst maxCenterX = Math.max((width - rectWidth) * 0.5, 0);\n\tconst maxCenterY = Math.max((height - rectHeight) * 0.5, 0);\n\n\treturn {\n\t\tx: THREE.MathUtils.clamp(centerX, -maxCenterX, maxCenterX),\n\t\ty: THREE.MathUtils.clamp(centerY, -maxCenterY, maxCenterY),\n\t\twidth: rectWidth,\n\t\theight: rectHeight\n\t};\n}\n\n/** Normalizes a CSS blur radius before it is passed to the WebGPU blur pipeline. */\nexport function getMinimapCssBlurRadius(blur: number) {\n\treturn Math.max(blur, 0);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MinimapProjection.js","sourceRoot":"","sources":["../../../src/stage/minimap/MinimapProjection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAU/D;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CACnC,MAAoC,EACpC,KAAK,GAAG,EAAE,EACV,WAAW,GAAG,IAAI;IAElB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAClE,MAAM,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC9F,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AO;QACV,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,UAAU;KAClB,CAAC;AACH,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,uBAAuB,CAAC,IAAyB,EAAE,KAAa,EAAE,MAAc;IAC/F,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACtF,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IACvF,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IACxF,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3F,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,EAAE,CAAC;AACjE,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,uBAAuB,CAAC,IAAY;IACnD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC1B,CAAC","sourcesContent":["import * as THREE from 'three/webgpu';\nimport type { Object3D } from 'three';\n\nexport { getProjectiveCssMatrix3d } from '../cssProjection.js';\nexport type { CssProjectionPoint, CssProjectionQuad } from '../cssProjection.js';\n\nexport interface MinimapDepthBound {\n\t/** Positive camera-space distance to the bound's center. */\n\tdistance: number;\n\t/** Camera-space radius that must remain inside the clipping range. */\n\tradius: number;\n}\n\n/**\n * Fits a compact clipping range around the panel and live minimap model.\n *\n * The regular panel camera spans thousands of world units. Reusing that range\n * for thumbnail geometry collapses closely layered element surfaces into the\n * same depth values, so a small pointer tilt can make their fragments alternate.\n */\nexport function getMinimapDepthRange(\n\tbounds: readonly MinimapDepthBound[],\n\tguard = 16,\n\tminimumNear = 0.01\n) {\n\tconst safeGuard = Math.max(Number.isFinite(guard) ? guard : 0, 0);\n\tconst safeMinimumNear = Math.max(Number.isFinite(minimumNear) ? minimumNear : 0.01, 0.000001);\n\tlet near = Number.POSITIVE_INFINITY;\n\tlet far = Number.NEGATIVE_INFINITY;\n\n\tbounds.forEach(({ distance, radius }) => {\n\t\tif (!Number.isFinite(distance) || distance <= 0) return;\n\t\tconst safeRadius = Math.max(Number.isFinite(radius) ? radius : 0, 0);\n\t\tnear = Math.min(near, distance - safeRadius);\n\t\tfar = Math.max(far, distance + safeRadius);\n\t});\n\n\tif (!Number.isFinite(near) || !Number.isFinite(far)) {\n\t\treturn { near: safeMinimumNear, far: safeMinimumNear + 1 };\n\t}\n\n\tnear = Math.max(near - safeGuard, safeMinimumNear);\n\tfar = Math.max(far + safeGuard, near + 0.01);\n\treturn { near, far };\n}\n\n/** Returns the FOV that makes panel-local world units match CSS pixels at a distance. */\nexport function getPanelLocalCameraFov(panelHeight: number, distance: number) {\n\treturn THREE.MathUtils.radToDeg(\n\t\t2 * Math.atan(Math.max(panelHeight, 1) / (Math.max(distance, 1) * 2))\n\t);\n}\n\n/** Rectangle, in panel-local pixels, occupied by the main camera's current view. */\nexport interface MinimapViewportRect {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n}\n\n/**\n * Projects the main camera frustum onto the minimap model's target plane.\n *\n * The conversion intentionally passes through model-local coordinates. This keeps\n * panning and orbiting stable even though the minimap layer itself follows a tilted\n * panel in screen space.\n */\nexport function getMinimapViewportRect(\n\tstageCamera: THREE.PerspectiveCamera,\n\tminimapCamera: THREE.PerspectiveCamera,\n\ttarget: THREE.Vector3,\n\tstageModel: Object3D,\n\tminimapSourceRoot: Object3D,\n\tminimapSourceLayer: Object3D,\n\twidth: number,\n\theight: number\n): MinimapViewportRect | null {\n\tconst stageForward = new THREE.Vector3();\n\tstageCamera.getWorldDirection(stageForward);\n\tif (stageForward.lengthSq() < 0.0001) return null;\n\n\tconst targetPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(stageForward, target);\n\tconst stageOrigin = stageCamera.getWorldPosition(new THREE.Vector3());\n\tconst stageRay = new THREE.Ray();\n\tconst hit = new THREE.Vector3();\n\tconst projected: THREE.Vector2[] = [];\n\tconst corners = [\n\t\tnew THREE.Vector3(-1, -1, 0.5),\n\t\tnew THREE.Vector3(1, -1, 0.5),\n\t\tnew THREE.Vector3(1, 1, 0.5),\n\t\tnew THREE.Vector3(-1, 1, 0.5)\n\t];\n\n\tstageCamera.updateMatrixWorld(true);\n\tstageModel.updateWorldMatrix(true, true);\n\tminimapSourceRoot.updateWorldMatrix(true, true);\n\tminimapSourceLayer.updateWorldMatrix(true, true);\n\tminimapCamera.updateMatrixWorld(true);\n\n\tcorners.forEach((corner) => {\n\t\tconst worldPoint = corner.clone().unproject(stageCamera);\n\t\tconst direction = worldPoint.sub(stageOrigin).normalize();\n\t\tstageRay.set(stageOrigin, direction);\n\t\tconst intersection = stageRay.intersectPlane(targetPlane, hit);\n\t\tif (!intersection) return;\n\n\t\tconst modelPoint = stageModel.worldToLocal(intersection.clone());\n\t\tconst minimapPoint = minimapSourceRoot.localToWorld(modelPoint);\n\t\t// The camera is panel-local, so remove the layer's shared screen transform.\n\t\tminimapSourceLayer.worldToLocal(minimapPoint);\n\t\tconst ndc = minimapPoint.project(minimapCamera);\n\t\tif (!Number.isFinite(ndc.x) || !Number.isFinite(ndc.y)) return;\n\t\tprojected.push(new THREE.Vector2(ndc.x * width * 0.5, ndc.y * height * 0.5));\n\t});\n\n\tif (projected.length < 4) return null;\n\tconst minX = Math.min(...projected.map((point) => point.x));\n\tconst maxX = Math.max(...projected.map((point) => point.x));\n\tconst minY = Math.min(...projected.map((point) => point.y));\n\tconst maxY = Math.max(...projected.map((point) => point.y));\n\tconst centerX = (minX + maxX) * 0.5;\n\tconst centerY = (minY + maxY) * 0.5;\n\tconst rectWidth = maxX - minX;\n\tconst rectHeight = maxY - minY;\n\tif (\n\t\t!Number.isFinite(rectWidth) ||\n\t\t!Number.isFinite(rectHeight) ||\n\t\trectWidth <= 0 ||\n\t\trectHeight <= 0\n\t) {\n\t\treturn null;\n\t}\n\n\t// Preserve the true footprint, including edges outside the minimap. Fitting\n\t// it into the panel would falsely crop the model on wide/tall viewports.\n\treturn {\n\t\tx: centerX,\n\t\ty: centerY,\n\t\twidth: rectWidth,\n\t\theight: rectHeight\n\t};\n}\n\n/** Intersects the projected view with the panel without scaling or shifting it. */\nexport function clipMinimapViewportRect(rect: MinimapViewportRect, width: number, height: number) {\n\tconst left = THREE.MathUtils.clamp(width * 0.5 + rect.x - rect.width * 0.5, 0, width);\n\tconst right = THREE.MathUtils.clamp(width * 0.5 + rect.x + rect.width * 0.5, 0, width);\n\tconst top = THREE.MathUtils.clamp(height * 0.5 - rect.y - rect.height * 0.5, 0, height);\n\tconst bottom = THREE.MathUtils.clamp(height * 0.5 - rect.y + rect.height * 0.5, 0, height);\n\treturn { left, top, width: right - left, height: bottom - top };\n}\n\n/** Normalizes a CSS blur radius before it is passed to the WebGPU blur pipeline. */\nexport function getMinimapCssBlurRadius(blur: number) {\n\treturn Math.max(blur, 0);\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gates CSS hover effects by the actual pointer, including on touch laptops.
|
|
3
|
+
* Capability media queries alone still allow sticky touch :hover on hybrid devices.
|
|
4
|
+
* The returned lifecycle also works as a Svelte action.
|
|
5
|
+
*/
|
|
6
|
+
export declare function mouseHover(node: HTMLElement): {
|
|
7
|
+
destroy(): void;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=mouseHover.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mouseHover.d.ts","sourceRoot":"","sources":["../../src/stage/mouseHover.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW;;EAuC3C"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const hovered = new Set();
|
|
2
|
+
let subscribers = 0;
|
|
3
|
+
function clearHover(event) {
|
|
4
|
+
if (event?.pointerType === 'mouse')
|
|
5
|
+
return;
|
|
6
|
+
for (const node of hovered)
|
|
7
|
+
node.removeAttribute('data-mouse-hover');
|
|
8
|
+
hovered.clear();
|
|
9
|
+
}
|
|
10
|
+
const clearOnBlur = () => clearHover();
|
|
11
|
+
/**
|
|
12
|
+
* Gates CSS hover effects by the actual pointer, including on touch laptops.
|
|
13
|
+
* Capability media queries alone still allow sticky touch :hover on hybrid devices.
|
|
14
|
+
* The returned lifecycle also works as a Svelte action.
|
|
15
|
+
*/
|
|
16
|
+
export function mouseHover(node) {
|
|
17
|
+
const enter = (event) => {
|
|
18
|
+
if (event.pointerType !== 'mouse') {
|
|
19
|
+
clearHover();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (hovered.has(node))
|
|
23
|
+
return;
|
|
24
|
+
hovered.add(node);
|
|
25
|
+
node.setAttribute('data-mouse-hover', '');
|
|
26
|
+
};
|
|
27
|
+
const leave = () => {
|
|
28
|
+
hovered.delete(node);
|
|
29
|
+
node.removeAttribute('data-mouse-hover');
|
|
30
|
+
};
|
|
31
|
+
if (subscribers++ === 0) {
|
|
32
|
+
window.addEventListener('pointerdown', clearHover, { capture: true, passive: true });
|
|
33
|
+
window.addEventListener('pointermove', clearHover, { capture: true, passive: true });
|
|
34
|
+
window.addEventListener('blur', clearOnBlur);
|
|
35
|
+
}
|
|
36
|
+
node.addEventListener('pointerenter', enter, { passive: true });
|
|
37
|
+
node.addEventListener('pointermove', enter, { passive: true });
|
|
38
|
+
node.addEventListener('pointerleave', leave, { passive: true });
|
|
39
|
+
node.addEventListener('pointercancel', leave, { passive: true });
|
|
40
|
+
return {
|
|
41
|
+
destroy() {
|
|
42
|
+
leave();
|
|
43
|
+
node.removeEventListener('pointerenter', enter);
|
|
44
|
+
node.removeEventListener('pointermove', enter);
|
|
45
|
+
node.removeEventListener('pointerleave', leave);
|
|
46
|
+
node.removeEventListener('pointercancel', leave);
|
|
47
|
+
if (--subscribers === 0) {
|
|
48
|
+
window.removeEventListener('pointerdown', clearHover, true);
|
|
49
|
+
window.removeEventListener('pointermove', clearHover, true);
|
|
50
|
+
window.removeEventListener('blur', clearOnBlur);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=mouseHover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mouseHover.js","sourceRoot":"","sources":["../../src/stage/mouseHover.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,IAAI,GAAG,EAAe,CAAC;AACvC,IAAI,WAAW,GAAG,CAAC,CAAC;AAEpB,SAAS,UAAU,CAAC,KAAoB;IACvC,IAAI,KAAK,EAAE,WAAW,KAAK,OAAO;QAAE,OAAO;IAC3C,KAAK,MAAM,IAAI,IAAI,OAAO;QAAE,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,CAAC;IACrE,OAAO,CAAC,KAAK,EAAE,CAAC;AACjB,CAAC;AAED,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,UAAU,EAAE,CAAC;AAEvC;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,IAAiB;IAC3C,MAAM,KAAK,GAAG,CAAC,KAAmB,EAAE,EAAE;QACrC,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EA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B,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;YAChD,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;YAC/C,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;YAChD,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;YACjD,IAAI,EAAE,WAAW,KAAK,CAAC,EAAE,CAAC;gBACzB,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;gBAC5D,MAAM,CAAC,mBAAmB,CAAC,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;gBAC5D,MAAM,CAAC,mBAAmB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;YACjD,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["const hovered = new Set<HTMLElement>();\nlet subscribers = 0;\n\nfunction clearHover(event?: PointerEvent) {\n\tif (event?.pointerType === 'mouse') return;\n\tfor (const node of hovered) node.removeAttribute('data-mouse-hover');\n\thovered.clear();\n}\n\nconst clearOnBlur = () => clearHover();\n\n/**\n * Gates CSS hover effects by the actual pointer, including on touch laptops.\n * Capability media queries alone still allow sticky touch :hover on hybrid devices.\n * The returned lifecycle also works as a Svelte action.\n */\nexport function mouseHover(node: HTMLElement) {\n\tconst enter = (event: PointerEvent) => {\n\t\tif (event.pointerType !== 'mouse') {\n\t\t\tclearHover();\n\t\t\treturn;\n\t\t}\n\t\tif (hovered.has(node)) return;\n\t\thovered.add(node);\n\t\tnode.setAttribute('data-mouse-hover', '');\n\t};\n\tconst leave = () => {\n\t\thovered.delete(node);\n\t\tnode.removeAttribute('data-mouse-hover');\n\t};\n\n\tif (subscribers++ === 0) {\n\t\twindow.addEventListener('pointerdown', clearHover, { capture: true, passive: true });\n\t\twindow.addEventListener('pointermove', clearHover, { capture: true, passive: true });\n\t\twindow.addEventListener('blur', clearOnBlur);\n\t}\n\tnode.addEventListener('pointerenter', enter, { passive: true });\n\tnode.addEventListener('pointermove', enter, { passive: true });\n\tnode.addEventListener('pointerleave', leave, { passive: true });\n\tnode.addEventListener('pointercancel', leave, { passive: true });\n\n\treturn {\n\t\tdestroy() {\n\t\t\tleave();\n\t\t\tnode.removeEventListener('pointerenter', enter);\n\t\t\tnode.removeEventListener('pointermove', enter);\n\t\t\tnode.removeEventListener('pointerleave', leave);\n\t\t\tnode.removeEventListener('pointercancel', leave);\n\t\t\tif (--subscribers === 0) {\n\t\t\t\twindow.removeEventListener('pointerdown', clearHover, true);\n\t\t\t\twindow.removeEventListener('pointermove', clearHover, true);\n\t\t\t\twindow.removeEventListener('blur', clearOnBlur);\n\t\t\t}\n\t\t}\n\t};\n}\n"]}
|
|
@@ -45,7 +45,14 @@ export interface StagePanelRegistration {
|
|
|
45
45
|
getElement(): HTMLElement | undefined;
|
|
46
46
|
getFrameElement(): HTMLElement | undefined;
|
|
47
47
|
getSurfaceElement(): HTMLElement | undefined;
|
|
48
|
-
getPointerReactive(): boolean;
|
|
48
|
+
getPointerReactive(): boolean | 'lift';
|
|
49
|
+
getFocusReactive?(): boolean | 'top-right';
|
|
50
|
+
/** Neighbouring panel frame that shares a corner control's exit path. */
|
|
51
|
+
getFocusAnchor?(): HTMLElement | undefined;
|
|
52
|
+
getNativeContent?(): boolean;
|
|
53
|
+
/** Runs synchronously before the native panel surface is measured and drawn. */
|
|
54
|
+
updateNativeLayout?(): void;
|
|
55
|
+
getVisible?(): boolean;
|
|
49
56
|
getMinimapOptions(): StagePanelMinimapOptions | undefined;
|
|
50
57
|
getOptions(): LiquidGlassPanelOptions;
|
|
51
58
|
getSurface(): StagePanelSurface;
|
|
@@ -64,8 +71,15 @@ export interface StageViewportRegistration {
|
|
|
64
71
|
export interface StageContext {
|
|
65
72
|
prefetchSpatialElement?(stage: import('../spatial-element/spatialElementScene.js').SpatialElementScene): void;
|
|
66
73
|
registerPanel(panel: StagePanelRegistration): () => void;
|
|
74
|
+
/** Refresh appearance from registered getters without rebinding the page or its camera. */
|
|
75
|
+
updatePanelAppearance?(): void;
|
|
67
76
|
registerViewport(viewport: StageViewportRegistration): () => void;
|
|
68
77
|
/** Restores the element camera to its initial fitted pose. */
|
|
69
78
|
resetView(): void;
|
|
79
|
+
/** True for both native fullscreen and its viewport fallback. */
|
|
80
|
+
isFullscreen?(): boolean;
|
|
81
|
+
/** Current camera zoom focus, from the fitted detail view (0) to close-up (1). */
|
|
82
|
+
getZoomFocus?(): number;
|
|
83
|
+
setFullscreen?(fullscreen: boolean): void;
|
|
70
84
|
}
|
|
71
85
|
//# sourceMappingURL=panelContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panelContext.d.ts","sourceRoot":"","sources":["../../src/stage/panelContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEjF,eAAO,MAAM,iBAAiB,eAAkB,CAAC;AAEjD,uFAAuF;AACvF,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAE7D,+FAA+F;AAC/F,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAE7D,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,eAAe,GAAG,IAAI,CACjC,uBAAuB,EACvB,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAC1C,GAAG;IACH,0EAA0E;IAC1E,OAAO,CAAC,EAAE,iBAA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age/panelContext.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AAEjD,uFAAuF;AACvF,MAAM,CAAC,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AAE7D,+FAA+F;AAC/F,MAAM,CAAC,MAAM,wBAAwB,GAAG,oBAAoB,CAAC","sourcesContent":["\nimport type { LiquidGlassPanelOptions } from './LiquidGlassPanel.js';\nimport type { StageMinimapDockedView, StagePanelSurface } from './stageTypes.js';\n\nexport const STAGE_CONTEXT_KEY = Symbol('stage');\n\n/** Notifies an active stage that externally positioned panel frames changed layout. */\nexport const STAGE_PANEL_LAYOUT_EVENT = 'stage:panel-layout';\n\n/** Notifies an active stage that an external panel visual changed without affecting layout. */\nexport const STAGE_PANEL_VISUAL_EVENT = 'stage:panel-visual';\n\nexport interface StagePanelPose {\n\twidth: number;\n\theight: number;\n\tposition: { x: number; y: number };\n}\n\nexport interface StagePanelShape {\n\tradius: number;\n\tcontentInset?: number;\n}\n\nexport type StagePanelTheme = Omit<\n\tLiquidGlassPanelOptions,\n\t'width' | 'height' | 'position' | 'radius'\n> & {\n\t/** Semantic surface style. Defaults to the WebGPU-backed `glass` mode. */\n\tsurface?: StagePanelSurface;\n};\n\n\n\nexport interface StagePanelMinimapOptions {\n\texpandedHeight?: number;\n\tinset?: number;\n\t/** Additional unbounded scale applied to the fitted model. Values below 0.2 are clamped. */\n\tmodelScale?: number;\n\t/** Model multiplier at full pointer hover. Use 1 to disable hover enlargement. */\n\thoverModelScale?: number;\n\t/** Hover multiplier used once the minimap is expanded by camera zoom. */\n\texpandedHoverModelScale?: number;\n\t/** Optional spatial-element-specific presentation used while the minimap is docked. */\n\tdockedView?: StageMinimapDockedView;\n\toverlayColor?: string | number;\n\toverlayOpacity?: number;\n\t/** Gaussian blur radius in CSS pixels. */\n\toverlayBlur?: number;\n\tcontextColor?: string | number;\n\tcontextOpacity?: number;\n\tviewportColor?: string | number;\n}\n\nexport interface StagePanelRegistration {\n\tgetContentInset(): number;\n\tgetElement(): HTMLElement | undefined;\n\tgetFrameElement(): HTMLElement | undefined;\n\tgetSurfaceElement(): HTMLElement | undefined;\n\tgetPointerReactive(): boolean;\n\tgetMinimapOptions(): StagePanelMinimapOptions | undefined;\n\tgetOptions(): LiquidGlassPanelOptions;\n\tgetSurface(): StagePanelSurface;\n\t/** Returns the opacity of the panel surface without affecting panel content. */\n\tgetSurfaceOpacity(): number;\n\t/** Returns a transient presentation scale applied to a rendered minimap model. */\n\tgetMinimapModelScale(): number;\n\t/** Returns the animated transition from the regular to the docked minimap view. */\n\tgetMinimapDockProgress(): number;\n\t/** Returns the viewport-space top edge used to anchor the rendered model. */\n\tgetMinimapModelTop(): number | undefined;\n}\n\nexport interface StageViewportRegistration {\n\tgetElement(): HTMLElement | undefined;\n}\n\nexport interface StageContext {\n\tprefetchSpatialElement?(stage: import('../spatial-element/spatialElementScene.js').SpatialElementScene): void;\n\tregisterPanel(panel: StagePanelRegistration): () => void;\n\tregisterViewport(viewport: StageViewportRegistration): () => void;\n\t/** Restores the element camera to its initial fitted pose. */\n\tresetView(): void;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"panelContext.js","sourceRoot":"","sources":["../../src/stage/panelContext.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;AAEjD,uFAAuF;AACvF,MAAM,CAAC,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AAE7D,+FAA+F;AAC/F,MAAM,CAAC,MAAM,wBAAwB,GAAG,oBAAoB,CAAC","sourcesContent":["\nimport type { LiquidGlassPanelOptions } from './LiquidGlassPanel.js';\nimport type { StageMinimapDockedView, StagePanelSurface } from './stageTypes.js';\n\nexport const STAGE_CONTEXT_KEY = Symbol('stage');\n\n/** Notifies an active stage that externally positioned panel frames changed layout. */\nexport const STAGE_PANEL_LAYOUT_EVENT = 'stage:panel-layout';\n\n/** Notifies an active stage that an external panel visual changed without affecting layout. */\nexport const STAGE_PANEL_VISUAL_EVENT = 'stage:panel-visual';\n\nexport interface StagePanelPose {\n\twidth: number;\n\theight: number;\n\tposition: { x: number; y: number };\n}\n\nexport interface StagePanelShape {\n\tradius: number;\n\tcontentInset?: number;\n}\n\nexport type StagePanelTheme = Omit<\n\tLiquidGlassPanelOptions,\n\t'width' | 'height' | 'position' | 'radius'\n> & {\n\t/** Semantic surface style. Defaults to the WebGPU-backed `glass` mode. */\n\tsurface?: StagePanelSurface;\n};\n\n\n\nexport interface StagePanelMinimapOptions {\n\texpandedHeight?: number;\n\tinset?: number;\n\t/** Additional unbounded scale applied to the fitted model. Values below 0.2 are clamped. */\n\tmodelScale?: number;\n\t/** Model multiplier at full pointer hover. Use 1 to disable hover enlargement. */\n\thoverModelScale?: number;\n\t/** Hover multiplier used once the minimap is expanded by camera zoom. */\n\texpandedHoverModelScale?: number;\n\t/** Optional spatial-element-specific presentation used while the minimap is docked. */\n\tdockedView?: StageMinimapDockedView;\n\toverlayColor?: string | number;\n\toverlayOpacity?: number;\n\t/** Gaussian blur radius in CSS pixels. */\n\toverlayBlur?: number;\n\tcontextColor?: string | number;\n\tcontextOpacity?: number;\n\tviewportColor?: string | number;\n}\n\nexport interface StagePanelRegistration {\n\tgetContentInset(): number;\n\tgetElement(): HTMLElement | undefined;\n\tgetFrameElement(): HTMLElement | undefined;\n\tgetSurfaceElement(): HTMLElement | undefined;\n\tgetPointerReactive(): boolean | 'lift';\n\tgetFocusReactive?(): boolean | 'top-right';\n\t/** Neighbouring panel frame that shares a corner control's exit path. */\n\tgetFocusAnchor?(): HTMLElement | undefined;\n\tgetNativeContent?(): boolean;\n\t/** Runs synchronously before the native panel surface is measured and drawn. */\n\tupdateNativeLayout?(): void;\n\tgetVisible?(): boolean;\n\tgetMinimapOptions(): StagePanelMinimapOptions | undefined;\n\tgetOptions(): LiquidGlassPanelOptions;\n\tgetSurface(): StagePanelSurface;\n\t/** Returns the opacity of the panel surface without affecting panel content. */\n\tgetSurfaceOpacity(): number;\n\t/** Returns a transient presentation scale applied to a rendered minimap model. */\n\tgetMinimapModelScale(): number;\n\t/** Returns the animated transition from the regular to the docked minimap view. */\n\tgetMinimapDockProgress(): number;\n\t/** Returns the viewport-space top edge used to anchor the rendered model. */\n\tgetMinimapModelTop(): number | undefined;\n}\n\nexport interface StageViewportRegistration {\n\tgetElement(): HTMLElement | undefined;\n}\n\nexport interface StageContext {\n\tprefetchSpatialElement?(stage: import('../spatial-element/spatialElementScene.js').SpatialElementScene): void;\n\tregisterPanel(panel: StagePanelRegistration): () => void;\n\t/** Refresh appearance from registered getters without rebinding the page or its camera. */\n\tupdatePanelAppearance?(): void;\n\tregisterViewport(viewport: StageViewportRegistration): () => void;\n\t/** Restores the element camera to its initial fitted pose. */\n\tresetView(): void;\n\t/** True for both native fullscreen and its viewport fallback. */\n\tisFullscreen?(): boolean;\n\t/** Current camera zoom focus, from the fitted detail view (0) to close-up (1). */\n\tgetZoomFocus?(): number;\n\tsetFullscreen?(fullscreen: boolean): void;\n}\n"]}
|
|
@@ -30,6 +30,8 @@ export declare function getStageVisualScrollPosition(): {
|
|
|
30
30
|
scrollX: number;
|
|
31
31
|
scrollY: number;
|
|
32
32
|
};
|
|
33
|
+
/** Lets render owners defer to the ordered DOM/dock/scene update already queued. */
|
|
34
|
+
export declare function hasPendingStageScrollFrame(): boolean;
|
|
33
35
|
/** Rebase every consumer after restoration, including when no native scroll event fires. */
|
|
34
36
|
export declare function syncStageScrollToNative(): {
|
|
35
37
|
scrollX: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrollFrame.d.ts","sourceRoot":"","sources":["../../src/stage/scrollFrame.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GACjC,QAAQ,GAAG,UAAU,GAAG,YAAY,GAAG,cAAc,GAAG,OAAO,GAAG,iBAAiB,GAAG,OAAO,CAAC;AAE/F,MAAM,WAAW,gBAAgB;IAChC,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Aa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,WAAW,EAAE,sBAAsB,CAAC;IACpC,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,MAAM,wBAAwB,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;AAEzE,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB;IACjC,yEAAyE;;;;CAIhE,CAAC;AA+CX,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,sBAAsB,QAIlE;AAED,sFAAsF;AACtF,wBAAgB,4BAA4B;;;EAI3C;AAED,oFAAoF;AACpF,wBAAgB,0BAA0B,YAEzC;AAED,4FAA4F;AAC5F,wBAAgB,uBAAuB;;;EAYtC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACxC,QAAQ,EAAE,wBAAwB,EAClC,QAAQ,GAAE,MAAoC,cAa9C"}
|
|
@@ -54,6 +54,10 @@ export function getStageVisualScrollPosition() {
|
|
|
54
54
|
? { scrollX: visualScrollX, scrollY: visualScrollY }
|
|
55
55
|
: { scrollX: window.scrollX, scrollY: window.scrollY };
|
|
56
56
|
}
|
|
57
|
+
/** Lets render owners defer to the ordered DOM/dock/scene update already queued. */
|
|
58
|
+
export function hasPendingStageScrollFrame() {
|
|
59
|
+
return animationFrame !== 0;
|
|
60
|
+
}
|
|
57
61
|
/** Rebase every consumer after restoration, including when no native scroll event fires. */
|
|
58
62
|
export function syncStageScrollToNative() {
|
|
59
63
|
if (animationFrame)
|
|
@@ -105,16 +109,18 @@ function startListening() {
|
|
|
105
109
|
// the shared visual frame always receives the correct smoothing source.
|
|
106
110
|
window.addEventListener('wheel', handleWheelInput, { capture: true, passive: true });
|
|
107
111
|
window.addEventListener('keydown', handleKeyboardInput);
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
// Touch may be claimed by a carousel or geometry before it bubbles. Observe
|
|
113
|
+
// contact without blocking the browser's native pan and momentum scrolling.
|
|
114
|
+
window.addEventListener('touchstart', handleTouchInput, { capture: true, passive: true });
|
|
115
|
+
window.addEventListener('pointerdown', handlePointerInput, { capture: true, passive: true });
|
|
110
116
|
listening = true;
|
|
111
117
|
}
|
|
112
118
|
function stopListening() {
|
|
113
119
|
window.removeEventListener('scroll', handleNativeScroll);
|
|
114
120
|
window.removeEventListener('wheel', handleWheelInput, { capture: true });
|
|
115
121
|
window.removeEventListener('keydown', handleKeyboardInput);
|
|
116
|
-
window.removeEventListener('touchstart', handleTouchInput);
|
|
117
|
-
window.removeEventListener('pointerdown', handlePointerInput);
|
|
122
|
+
window.removeEventListener('touchstart', handleTouchInput, { capture: true });
|
|
123
|
+
window.removeEventListener('pointerdown', handlePointerInput, { capture: true });
|
|
118
124
|
if (animationFrame)
|
|
119
125
|
cancelAnimationFrame(animationFrame);
|
|
120
126
|
animationFrame = 0;
|
|
@@ -144,9 +150,16 @@ function handleKeyboardInput(event) {
|
|
|
144
150
|
}
|
|
145
151
|
function handleTouchInput() {
|
|
146
152
|
markStageScrollInput('touch');
|
|
153
|
+
// A finger touching the screen stops native momentum immediately. Stop any
|
|
154
|
+
// pending synthetic wheel/keyboard damping as well, even when this contact
|
|
155
|
+
// does not produce a scroll event (for example, touching to stop the page).
|
|
156
|
+
activeInputSource = 'touch';
|
|
147
157
|
}
|
|
148
158
|
function handlePointerInput(event) {
|
|
149
|
-
|
|
159
|
+
if (event.pointerType === 'touch')
|
|
160
|
+
handleTouchInput();
|
|
161
|
+
else
|
|
162
|
+
markStageScrollInput('direct');
|
|
150
163
|
}
|
|
151
164
|
function scheduleScrollFrame() {
|
|
152
165
|
if (animationFrame || !subscriptions.size)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrollFrame.js","s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,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,YAAY,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,cAAc,GAAG,CAAC,MAAM,GAAG,cAAc,CAAC,GAAG,KAAK,CAAC;IAChE,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AAED,SAAS,GAAG;IACX,OAAO,OAAO,WAAW,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["export type StageScrollInputSource =\n\t'direct' | 'keyboard' | 'navigation' | 'programmatic' | 'touch' | 'precision-wheel' | 'wheel';\n\nexport interface StageScrollFrame {\n\ttime: number;\n\t/** Shared visual position consumed by DOM, CSS3D, docking, and WebGPU. */\n\tscrollX: number;\n\tscrollY: number;\n\t/** Native browser position represented by the scrollbar and scroll proxy. */\n\ttargetScrollX: number;\n\ttargetScrollY: number;\n\tpreviousScrollX: number;\n\tpreviousScrollY: number;\n\tdeltaX: number;\n\tdeltaY: number;\n\tdirectionY: -1 | 0 | 1;\n\tinputSource: StageScrollInputSource;\n\tsettled: boolean;\n}\n\nexport type StageScrollFrameCallback = (frame: StageScrollFrame) => void;\n\n/** Ensures DOM docking is committed before the stage measures its anchors. */\nexport const STAGE_SCROLL_PRIORITY = {\n\t/** Moves the visible DOM before any viewport-dependent consumers run. */\n\tvirtualDocument: -100,\n\tdock: 0,\n\tstage: 100\n} as const;\n\nconst SMOOTHING_RATE = {\n\twheel: 32,\n\tkeyboard: 28,\n\tprogrammatic: 22\n} as const;\nconst SNAP_EPSILON = 0.1;\nconst MIN_MAX_LAG = 80;\nconst MAX_MAX_LAG = 120;\nconst MAX_FRAME_DELTA_SECONDS = 0.1;\nconst INPUT_MARK_LIFETIME = 220;\nconst PRECISION_WHEEL_DELTA = 48;\nconst PRECISION_WHEEL_INTERVAL = 40;\nconst DOM_DELTA_PIXEL = 0;\nconst KEYBOARD_SCROLL_KEYS = new Set([\n\t'ArrowDown',\n\t'ArrowUp',\n\t'End',\n\t'Home',\n\t'PageDown',\n\t'PageUp',\n\t' '\n]);\n\ninterface ScrollFrameSubscription {\n\tid: number;\n\tpriority: number;\n\tcallback: StageScrollFrameCallback;\n}\n\nconst subscriptions = new Map<number, ScrollFrameSubscription>();\nlet nextSubscriptionId = 1;\nlet animationFrame = 0;\nlet listening = false;\nlet visualScrollX = 0;\nlet visualScrollY = 0;\nlet previousScrollX = 0;\nlet previousScrollY = 0;\nlet lastFrameTime = 0;\nlet markedInputSource: StageScrollInputSource = 'direct';\nlet markedInputUntil = 0;\nlet markedInputPending = false;\nlet activeInputSource: StageScrollInputSource = 'direct';\nlet lastWheelTime = -Infinity;\nlet reducedMotionQuery: MediaQueryList | undefined;\n\n/** Marks application-initiated scrolling for the shared visual transition. */\nexport function markStageScrollInput(source: StageScrollInputSource) {\n\tmarkedInputSource = source;\n\tmarkedInputUntil = now() + INPUT_MARK_LIFETIME;\n\tmarkedInputPending = true;\n}\n\n/** Returns the last visual position, or the native position before initialization. */\nexport function getStageVisualScrollPosition() {\n\treturn listening\n\t\t? { scrollX: visualScrollX, scrollY: visualScrollY }\n\t\t: { scrollX: window.scrollX, scrollY: window.scrollY };\n}\n\n/** Rebase every consumer after restoration, including when no native scroll event fires. */\nexport function syncStageScrollToNative() {\n\tif (animationFrame) cancelAnimationFrame(animationFrame);\n\tanimationFrame = 0;\n\tvisualScrollX = previousScrollX = window.scrollX;\n\tvisualScrollY = previousScrollY = window.scrollY;\n\tlastFrameTime = 0;\n\tactiveInputSource = 'navigation';\n\tmarkedInputSource = 'direct';\n\tmarkedInputUntil = 0;\n\tmarkedInputPending = false;\n\tif (subscriptions.size) flushScrollFrame(now());\n\treturn { scrollX: visualScrollX, scrollY: visualScrollY };\n}\n\n/**\n * Shares one visual scroll timeline across DOM and WebGPU owners. Discrete\n * inputs are time-smoothed; precision, touch, and scrollbar movement stay exact.\n */\nexport function subscribeStageScrollFrame(\n\tcallback: StageScrollFrameCallback,\n\tpriority: number = STAGE_SCROLL_PRIORITY.stage\n) {\n\tconst id = nextSubscriptionId;\n\tnextSubscriptionId += 1;\n\tsubscriptions.set(id, { id, priority, callback });\n\n\tif (!listening) startListening();\n\n\treturn () => {\n\t\tsubscriptions.delete(id);\n\t\tif (subscriptions.size) return;\n\t\tstopListening();\n\t};\n}\n\nfunction startListening() {\n\tvisualScrollX = window.scrollX;\n\tvisualScrollY = window.scrollY;\n\tpreviousScrollX = visualScrollX;\n\tpreviousScrollY = visualScrollY;\n\tlastFrameTime = 0;\n\tactiveInputSource = 'direct';\n\tmarkedInputSource = 'direct';\n\tmarkedInputUntil = 0;\n\tmarkedInputPending = false;\n\tlastWheelTime = -Infinity;\n\treducedMotionQuery = window.matchMedia?.('(prefers-reduced-motion: reduce)');\n\twindow.addEventListener('scroll', handleNativeScroll, { passive: true });\n\t// Classify wheel input before OrbitControls or another target listener can\n\t// stop propagation. Native scroll is dispatched after this capture phase, so\n\t// the shared visual frame always receives the correct smoothing source.\n\twindow.addEventListener('wheel', handleWheelInput, { capture: true, passive: true });\n\twindow.addEventListener('keydown', handleKeyboardInput);\n\twindow.addEventListener('touchstart', handleTouchInput, { passive: true });\n\twindow.addEventListener('pointerdown', handlePointerInput, { passive: true });\n\tlistening = true;\n}\n\nfunction stopListening() {\n\twindow.removeEventListener('scroll', handleNativeScroll);\n\twindow.removeEventListener('wheel', handleWheelInput, { capture: true });\n\twindow.removeEventListener('keydown', handleKeyboardInput);\n\twindow.removeEventListener('touchstart', handleTouchInput);\n\twindow.removeEventListener('pointerdown', handlePointerInput);\n\tif (animationFrame) cancelAnimationFrame(animationFrame);\n\tanimationFrame = 0;\n\tlastFrameTime = 0;\n\treducedMotionQuery = undefined;\n\tlistening = false;\n}\n\nfunction handleNativeScroll() {\n\tactiveInputSource =\n\t\tmarkedInputPending || now() <= markedInputUntil ? markedInputSource : 'direct';\n\tmarkedInputPending = false;\n\tscheduleScrollFrame();\n}\n\nfunction handleWheelInput(event: WheelEvent) {\n\tconst currentTime = now();\n\tconst interval = currentTime - lastWheelTime;\n\tlastWheelTime = currentTime;\n\tconst delta = Math.max(Math.abs(event.deltaX), Math.abs(event.deltaY));\n\tconst precisionInput =\n\t\tevent.deltaMode === DOM_DELTA_PIXEL &&\n\t\t(delta <= PRECISION_WHEEL_DELTA ||\n\t\t\t(interval <= PRECISION_WHEEL_INTERVAL && delta < PRECISION_WHEEL_DELTA * 2));\n\tmarkStageScrollInput(precisionInput ? 'precision-wheel' : 'wheel');\n}\n\nfunction handleKeyboardInput(event: KeyboardEvent) {\n\tif (KEYBOARD_SCROLL_KEYS.has(event.key)) markStageScrollInput('keyboard');\n}\n\nfunction handleTouchInput() {\n\tmarkStageScrollInput('touch');\n}\n\nfunction handlePointerInput(event: PointerEvent) {\n\tmarkStageScrollInput(event.pointerType === 'touch' ? 'touch' : 'direct');\n}\n\nfunction scheduleScrollFrame() {\n\tif (animationFrame || !subscriptions.size) return;\n\tanimationFrame = requestAnimationFrame(flushScrollFrame);\n}\n\nfunction flushScrollFrame(time: number) {\n\tanimationFrame = 0;\n\tconst targetScrollX = window.scrollX;\n\tconst targetScrollY = window.scrollY;\n\tconst deltaSeconds = lastFrameTime\n\t\t? Math.min(Math.max((time - lastFrameTime) / 1000, 0), MAX_FRAME_DELTA_SECONDS)\n\t\t: 1 / 60;\n\tlastFrameTime = time;\n\n\tconst smoothingRate = getSmoothingRate(activeInputSource);\n\tif (smoothingRate === undefined || reducedMotionQuery?.matches) {\n\t\tvisualScrollX = targetScrollX;\n\t\tvisualScrollY = targetScrollY;\n\t} else {\n\t\tconst maxLag = Math.min(\n\t\t\tMath.max((window.innerHeight || MAX_MAX_LAG) * 0.12, MIN_MAX_LAG),\n\t\t\tMAX_MAX_LAG\n\t\t);\n\t\tvisualScrollX = dampScrollValue(\n\t\t\tvisualScrollX,\n\t\t\ttargetScrollX,\n\t\t\tsmoothingRate,\n\t\t\tdeltaSeconds,\n\t\t\tmaxLag\n\t\t);\n\t\tvisualScrollY = dampScrollValue(\n\t\t\tvisualScrollY,\n\t\t\ttargetScrollY,\n\t\t\tsmoothingRate,\n\t\t\tdeltaSeconds,\n\t\t\tmaxLag\n\t\t);\n\t}\n\n\tconst settled =\n\t\tMath.abs(targetScrollX - visualScrollX) <= SNAP_EPSILON &&\n\t\tMath.abs(targetScrollY - visualScrollY) <= SNAP_EPSILON;\n\tif (settled) {\n\t\tvisualScrollX = targetScrollX;\n\t\tvisualScrollY = targetScrollY;\n\t}\n\n\tconst deltaX = visualScrollX - previousScrollX;\n\tconst deltaY = visualScrollY - previousScrollY;\n\tconst frame = Object.freeze({\n\t\ttime,\n\t\tscrollX: visualScrollX,\n\t\tscrollY: visualScrollY,\n\t\ttargetScrollX,\n\t\ttargetScrollY,\n\t\tpreviousScrollX,\n\t\tpreviousScrollY,\n\t\tdeltaX,\n\t\tdeltaY,\n\t\tdirectionY: Math.sign(deltaY) as -1 | 0 | 1,\n\t\tinputSource: activeInputSource,\n\t\tsettled\n\t});\n\tpreviousScrollX = visualScrollX;\n\tpreviousScrollY = visualScrollY;\n\tconst orderedSubscriptions = Array.from(subscriptions.values()).sort(\n\t\t(left, right) => left.priority - right.priority || left.id - right.id\n\t);\n\n\tfor (const subscription of orderedSubscriptions) {\n\t\tif (subscriptions.has(subscription.id)) subscription.callback(frame);\n\t}\n\n\tif (!settled && subscriptions.size) scheduleScrollFrame();\n\telse {\n\t\tactiveInputSource = 'direct';\n\t\tlastFrameTime = 0;\n\t}\n}\n\nfunction getSmoothingRate(source: StageScrollInputSource) {\n\tswitch (source) {\n\t\tcase 'wheel':\n\t\t\treturn SMOOTHING_RATE.wheel;\n\t\tcase 'keyboard':\n\t\t\treturn SMOOTHING_RATE.keyboard;\n\t\tcase 'programmatic':\n\t\t\treturn SMOOTHING_RATE.programmatic;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nfunction dampScrollValue(\n\tcurrent: number,\n\ttarget: number,\n\trate: number,\n\tdeltaSeconds: number,\n\tmaxLag: number\n) {\n\tconst distance = target - current;\n\tconst clampedCurrent =\n\t\tMath.abs(distance) > maxLag ? target - Math.sign(distance) * maxLag : current;\n\tconst alpha = 1 - Math.exp(-rate * deltaSeconds);\n\tconst next = clampedCurrent + (target - clampedCurrent) * alpha;\n\treturn Math.abs(target - next) <= SNAP_EPSILON ? target : next;\n}\n\nfunction now() {\n\treturn typeof performance === 'undefined' ? Date.now() : performance.now();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scrollFrame.js","sourceRoot":"","sources":["../../src/stage/scrollFrame.ts"],"names":[],"mappings":"AAsBA,8EAA8E;AAC9E,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACpC,yEAAyE;IACzE,eAAe,EAAE,CAAC,GAAG;IACrB,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,GAAG;CACD,CAAC;AAEX,MAAM,cAAc,GAAG;IACtB,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,EAAE;IACZ,YAAY,EAAE,EAAE;CACP,CAAC;AACX,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACjC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,MAAM,eAAe,GAAG,CAAC,CAAC;AAC1B,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACpC,WAAW;IACX,SAAS;IACT,KAAK;IACL,MAAM;IACN,UAAU;IACV,QAAQ;IACR,GAAG;CACH,CAAC,CAAC;AAQH,MAAM,aAAa,GAAG,IAAI,GAAG,EAAmC,CAAC;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'navigation' | 'programmatic' | 'touch' | 'precision-wheel' | 'wheel';\n\nexport interface StageScrollFrame {\n\ttime: number;\n\t/** Shared visual position consumed by DOM, CSS3D, docking, and WebGPU. */\n\tscrollX: number;\n\tscrollY: number;\n\t/** Native browser position represented by the scrollbar and scroll proxy. */\n\ttargetScrollX: number;\n\ttargetScrollY: number;\n\tpreviousScrollX: number;\n\tpreviousScrollY: number;\n\tdeltaX: number;\n\tdeltaY: number;\n\tdirectionY: -1 | 0 | 1;\n\tinputSource: StageScrollInputSource;\n\tsettled: boolean;\n}\n\nexport type StageScrollFrameCallback = (frame: StageScrollFrame) => void;\n\n/** Ensures DOM docking is committed before the stage measures its anchors. */\nexport const STAGE_SCROLL_PRIORITY = {\n\t/** Moves the visible DOM before any viewport-dependent consumers run. */\n\tvirtualDocument: -100,\n\tdock: 0,\n\tstage: 100\n} as const;\n\nconst SMOOTHING_RATE = {\n\twheel: 32,\n\tkeyboard: 28,\n\tprogrammatic: 22\n} as const;\nconst SNAP_EPSILON = 0.1;\nconst MIN_MAX_LAG = 80;\nconst MAX_MAX_LAG = 120;\nconst MAX_FRAME_DELTA_SECONDS = 0.1;\nconst INPUT_MARK_LIFETIME = 220;\nconst PRECISION_WHEEL_DELTA = 48;\nconst PRECISION_WHEEL_INTERVAL = 40;\nconst DOM_DELTA_PIXEL = 0;\nconst KEYBOARD_SCROLL_KEYS = new Set([\n\t'ArrowDown',\n\t'ArrowUp',\n\t'End',\n\t'Home',\n\t'PageDown',\n\t'PageUp',\n\t' '\n]);\n\ninterface ScrollFrameSubscription {\n\tid: number;\n\tpriority: number;\n\tcallback: StageScrollFrameCallback;\n}\n\nconst subscriptions = new Map<number, ScrollFrameSubscription>();\nlet nextSubscriptionId = 1;\nlet animationFrame = 0;\nlet listening = false;\nlet visualScrollX = 0;\nlet visualScrollY = 0;\nlet previousScrollX = 0;\nlet previousScrollY = 0;\nlet lastFrameTime = 0;\nlet markedInputSource: StageScrollInputSource = 'direct';\nlet markedInputUntil = 0;\nlet markedInputPending = false;\nlet activeInputSource: StageScrollInputSource = 'direct';\nlet lastWheelTime = -Infinity;\nlet reducedMotionQuery: MediaQueryList | undefined;\n\n/** Marks application-initiated scrolling for the shared visual transition. */\nexport function markStageScrollInput(source: StageScrollInputSource) {\n\tmarkedInputSource = source;\n\tmarkedInputUntil = now() + INPUT_MARK_LIFETIME;\n\tmarkedInputPending = true;\n}\n\n/** Returns the last visual position, or the native position before initialization. */\nexport function getStageVisualScrollPosition() {\n\treturn listening\n\t\t? { scrollX: visualScrollX, scrollY: visualScrollY }\n\t\t: { scrollX: window.scrollX, scrollY: window.scrollY };\n}\n\n/** Lets render owners defer to the ordered DOM/dock/scene update already queued. */\nexport function hasPendingStageScrollFrame() {\n\treturn animationFrame !== 0;\n}\n\n/** Rebase every consumer after restoration, including when no native scroll event fires. */\nexport function syncStageScrollToNative() {\n\tif (animationFrame) cancelAnimationFrame(animationFrame);\n\tanimationFrame = 0;\n\tvisualScrollX = previousScrollX = window.scrollX;\n\tvisualScrollY = previousScrollY = window.scrollY;\n\tlastFrameTime = 0;\n\tactiveInputSource = 'navigation';\n\tmarkedInputSource = 'direct';\n\tmarkedInputUntil = 0;\n\tmarkedInputPending = false;\n\tif (subscriptions.size) flushScrollFrame(now());\n\treturn { scrollX: visualScrollX, scrollY: visualScrollY };\n}\n\n/**\n * Shares one visual scroll timeline across DOM and WebGPU owners. Discrete\n * inputs are time-smoothed; precision, touch, and scrollbar movement stay exact.\n */\nexport function subscribeStageScrollFrame(\n\tcallback: StageScrollFrameCallback,\n\tpriority: number = STAGE_SCROLL_PRIORITY.stage\n) {\n\tconst id = nextSubscriptionId;\n\tnextSubscriptionId += 1;\n\tsubscriptions.set(id, { id, priority, callback });\n\n\tif (!listening) startListening();\n\n\treturn () => {\n\t\tsubscriptions.delete(id);\n\t\tif (subscriptions.size) return;\n\t\tstopListening();\n\t};\n}\n\nfunction startListening() {\n\tvisualScrollX = window.scrollX;\n\tvisualScrollY = window.scrollY;\n\tpreviousScrollX = visualScrollX;\n\tpreviousScrollY = visualScrollY;\n\tlastFrameTime = 0;\n\tactiveInputSource = 'direct';\n\tmarkedInputSource = 'direct';\n\tmarkedInputUntil = 0;\n\tmarkedInputPending = false;\n\tlastWheelTime = -Infinity;\n\treducedMotionQuery = window.matchMedia?.('(prefers-reduced-motion: reduce)');\n\twindow.addEventListener('scroll', handleNativeScroll, { passive: true });\n\t// Classify wheel input before OrbitControls or another target listener can\n\t// stop propagation. Native scroll is dispatched after this capture phase, so\n\t// the shared visual frame always receives the correct smoothing source.\n\twindow.addEventListener('wheel', handleWheelInput, { capture: true, passive: true });\n\twindow.addEventListener('keydown', handleKeyboardInput);\n\t// Touch may be claimed by a carousel or geometry before it bubbles. Observe\n\t// contact without blocking the browser's native pan and momentum scrolling.\n\twindow.addEventListener('touchstart', handleTouchInput, { capture: true, passive: true });\n\twindow.addEventListener('pointerdown', handlePointerInput, { capture: true, passive: true });\n\tlistening = true;\n}\n\nfunction stopListening() {\n\twindow.removeEventListener('scroll', handleNativeScroll);\n\twindow.removeEventListener('wheel', handleWheelInput, { capture: true });\n\twindow.removeEventListener('keydown', handleKeyboardInput);\n\twindow.removeEventListener('touchstart', handleTouchInput, { capture: true });\n\twindow.removeEventListener('pointerdown', handlePointerInput, { capture: true });\n\tif (animationFrame) cancelAnimationFrame(animationFrame);\n\tanimationFrame = 0;\n\tlastFrameTime = 0;\n\treducedMotionQuery = undefined;\n\tlistening = false;\n}\n\nfunction handleNativeScroll() {\n\tactiveInputSource =\n\t\tmarkedInputPending || now() <= markedInputUntil ? markedInputSource : 'direct';\n\tmarkedInputPending = false;\n\tscheduleScrollFrame();\n}\n\nfunction handleWheelInput(event: WheelEvent) {\n\tconst currentTime = now();\n\tconst interval = currentTime - lastWheelTime;\n\tlastWheelTime = currentTime;\n\tconst delta = Math.max(Math.abs(event.deltaX), Math.abs(event.deltaY));\n\tconst precisionInput =\n\t\tevent.deltaMode === DOM_DELTA_PIXEL &&\n\t\t(delta <= PRECISION_WHEEL_DELTA ||\n\t\t\t(interval <= PRECISION_WHEEL_INTERVAL && delta < PRECISION_WHEEL_DELTA * 2));\n\tmarkStageScrollInput(precisionInput ? 'precision-wheel' : 'wheel');\n}\n\nfunction handleKeyboardInput(event: KeyboardEvent) {\n\tif (KEYBOARD_SCROLL_KEYS.has(event.key)) markStageScrollInput('keyboard');\n}\n\nfunction handleTouchInput() {\n\tmarkStageScrollInput('touch');\n\t// A finger touching the screen stops native momentum immediately. Stop any\n\t// pending synthetic wheel/keyboard damping as well, even when this contact\n\t// does not produce a scroll event (for example, touching to stop the page).\n\tactiveInputSource = 'touch';\n}\n\nfunction handlePointerInput(event: PointerEvent) {\n\tif (event.pointerType === 'touch') handleTouchInput();\n\telse markStageScrollInput('direct');\n}\n\nfunction scheduleScrollFrame() {\n\tif (animationFrame || !subscriptions.size) return;\n\tanimationFrame = requestAnimationFrame(flushScrollFrame);\n}\n\nfunction flushScrollFrame(time: number) {\n\tanimationFrame = 0;\n\tconst targetScrollX = window.scrollX;\n\tconst targetScrollY = window.scrollY;\n\tconst deltaSeconds = lastFrameTime\n\t\t? Math.min(Math.max((time - lastFrameTime) / 1000, 0), MAX_FRAME_DELTA_SECONDS)\n\t\t: 1 / 60;\n\tlastFrameTime = time;\n\n\tconst smoothingRate = getSmoothingRate(activeInputSource);\n\tif (smoothingRate === undefined || reducedMotionQuery?.matches) {\n\t\tvisualScrollX = targetScrollX;\n\t\tvisualScrollY = targetScrollY;\n\t} else {\n\t\tconst maxLag = Math.min(\n\t\t\tMath.max((window.innerHeight || MAX_MAX_LAG) * 0.12, MIN_MAX_LAG),\n\t\t\tMAX_MAX_LAG\n\t\t);\n\t\tvisualScrollX = dampScrollValue(\n\t\t\tvisualScrollX,\n\t\t\ttargetScrollX,\n\t\t\tsmoothingRate,\n\t\t\tdeltaSeconds,\n\t\t\tmaxLag\n\t\t);\n\t\tvisualScrollY = dampScrollValue(\n\t\t\tvisualScrollY,\n\t\t\ttargetScrollY,\n\t\t\tsmoothingRate,\n\t\t\tdeltaSeconds,\n\t\t\tmaxLag\n\t\t);\n\t}\n\n\tconst settled =\n\t\tMath.abs(targetScrollX - visualScrollX) <= SNAP_EPSILON &&\n\t\tMath.abs(targetScrollY - visualScrollY) <= SNAP_EPSILON;\n\tif (settled) {\n\t\tvisualScrollX = targetScrollX;\n\t\tvisualScrollY = targetScrollY;\n\t}\n\n\tconst deltaX = visualScrollX - previousScrollX;\n\tconst deltaY = visualScrollY - previousScrollY;\n\tconst frame = Object.freeze({\n\t\ttime,\n\t\tscrollX: visualScrollX,\n\t\tscrollY: visualScrollY,\n\t\ttargetScrollX,\n\t\ttargetScrollY,\n\t\tpreviousScrollX,\n\t\tpreviousScrollY,\n\t\tdeltaX,\n\t\tdeltaY,\n\t\tdirectionY: Math.sign(deltaY) as -1 | 0 | 1,\n\t\tinputSource: activeInputSource,\n\t\tsettled\n\t});\n\tpreviousScrollX = visualScrollX;\n\tpreviousScrollY = visualScrollY;\n\tconst orderedSubscriptions = Array.from(subscriptions.values()).sort(\n\t\t(left, right) => left.priority - right.priority || left.id - right.id\n\t);\n\n\tfor (const subscription of orderedSubscriptions) {\n\t\tif (subscriptions.has(subscription.id)) subscription.callback(frame);\n\t}\n\n\tif (!settled && subscriptions.size) scheduleScrollFrame();\n\telse {\n\t\tactiveInputSource = 'direct';\n\t\tlastFrameTime = 0;\n\t}\n}\n\nfunction getSmoothingRate(source: StageScrollInputSource) {\n\tswitch (source) {\n\t\tcase 'wheel':\n\t\t\treturn SMOOTHING_RATE.wheel;\n\t\tcase 'keyboard':\n\t\t\treturn SMOOTHING_RATE.keyboard;\n\t\tcase 'programmatic':\n\t\t\treturn SMOOTHING_RATE.programmatic;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nfunction dampScrollValue(\n\tcurrent: number,\n\ttarget: number,\n\trate: number,\n\tdeltaSeconds: number,\n\tmaxLag: number\n) {\n\tconst distance = target - current;\n\tconst clampedCurrent =\n\t\tMath.abs(distance) > maxLag ? target - Math.sign(distance) * maxLag : current;\n\tconst alpha = 1 - Math.exp(-rate * deltaSeconds);\n\tconst next = clampedCurrent + (target - clampedCurrent) * alpha;\n\treturn Math.abs(target - next) <= SNAP_EPSILON ? target : next;\n}\n\nfunction now() {\n\treturn typeof performance === 'undefined' ? Date.now() : performance.now();\n}\n"]}
|
|
@@ -30,10 +30,10 @@ export declare const PANEL_POINTER_MAX_TILT: number;
|
|
|
30
30
|
export declare const PANEL_POINTER_MAX_LIFT = 8;
|
|
31
31
|
export declare const PANEL_POINTER_DAMPING = 12;
|
|
32
32
|
/** Pointer approach distance derived from the short side with a capped aspect correction. */
|
|
33
|
-
export declare const PANEL_POINTER_PROXIMITY_SCALE = 0.
|
|
33
|
+
export declare const PANEL_POINTER_PROXIMITY_SCALE = 0.15;
|
|
34
34
|
export declare const PANEL_POINTER_PROXIMITY_ASPECT_LIMIT = 1.65;
|
|
35
|
-
export declare const PANEL_POINTER_PROXIMITY_MIN =
|
|
36
|
-
export declare const PANEL_POINTER_PROXIMITY_MAX =
|
|
35
|
+
export declare const PANEL_POINTER_PROXIMITY_MIN = 12;
|
|
36
|
+
export declare const PANEL_POINTER_PROXIMITY_MAX = 32;
|
|
37
37
|
export declare const PANEL_FOCUS_MAX_OFFSET = 190;
|
|
38
38
|
export declare const PANEL_FOCUS_MAX_ADVANCE = 360;
|
|
39
39
|
/** Caps restored shared-perspective egress on unusually short viewports. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stageConstants.d.ts","sourceRoot":"","sources":["../../src/stage/stageConstants.ts"],"names":[],"mappings":"AAIA,0FAA0F;AAC1F,eAAO,MAAM,kBAAkB;;;;CAID,CAAC;AAE/B,2FAA2F;AAC3F,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;GAgBU,CAAC;AAEtC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,6DAA6D;AAC7D,eAAO,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AAC3C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,+BAA+B,MAAM,CAAC;AACnD,6EAA6E;AAC7E,eAAO,MAAM,8BAA8B,KAAK,CAAC;AACjD,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,6FAA6F;AAC7F,eAAO,MAAM,iCAAiC,OAAO,CAAC;AACtD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAC/C,eAAO,MAAM,8BAA8B,KAAK,CAAC;AACjD,eAAO,MAAM,+BAA+B,IAAI,CAAC;AACjD,eAAO,MAAM,6BAA6B,YAAY,CAAC;AACvD,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAC7C,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,qFAAqF;AACrF,eAAO,MAAM,kBAAkB,OAAO,CAAC;AACvC,2FAA2F;AAC3F,eAAO,MAAM,yBAAyB,WAAW,CAAC;AAClD,8FAA8F;AAC9F,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,wFAAwF;AACxF,eAAO,MAAM,sBAAsB,QAAgD,CAAC;AACpF,eAAO,MAAM,wBAAwB,QAEpC,CAAC;AACF,eAAO,MAAM,WAAW,KAAK,CAAC;AAC9B,eAAO,MAAM,WAAW,KAAK,CAAC;AAE9B,uFAAuF;AACvF,eAAO,MAAM,yBAAyB;;;;;;CAML,CAAC"}
|
|
@@ -30,10 +30,10 @@ export const PANEL_POINTER_MAX_TILT = THREE.MathUtils.degToRad(10);
|
|
|
30
30
|
export const PANEL_POINTER_MAX_LIFT = 8;
|
|
31
31
|
export const PANEL_POINTER_DAMPING = 12;
|
|
32
32
|
/** Pointer approach distance derived from the short side with a capped aspect correction. */
|
|
33
|
-
export const PANEL_POINTER_PROXIMITY_SCALE = 0.
|
|
33
|
+
export const PANEL_POINTER_PROXIMITY_SCALE = 0.15;
|
|
34
34
|
export const PANEL_POINTER_PROXIMITY_ASPECT_LIMIT = 1.65;
|
|
35
|
-
export const PANEL_POINTER_PROXIMITY_MIN =
|
|
36
|
-
export const PANEL_POINTER_PROXIMITY_MAX =
|
|
35
|
+
export const PANEL_POINTER_PROXIMITY_MIN = 12;
|
|
36
|
+
export const PANEL_POINTER_PROXIMITY_MAX = 32;
|
|
37
37
|
export const PANEL_FOCUS_MAX_OFFSET = 190;
|
|
38
38
|
export const PANEL_FOCUS_MAX_ADVANCE = 360;
|
|
39
39
|
/** Caps restored shared-perspective egress on unusually short viewports. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stageConstants.js","sourceRoot":"","sources":["../../src/stage/stageConstants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,0FAA0F;AAC1F,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,UAAU,EAAE,GAAG;IACf,IAAI,EAAE,SAAS;IACf,aAAa,EAAE,GAAG;CACW,CAAC;AAE/B,2FAA2F;AAC3F,MAAM,CAAC,MAAM,cAAc,GAAG;IAC7B;QACC,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,GAAG;QACX,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE;QACzB,YAAY,EAAE,CAAC;QACf,UAAU,EAAE,EAAE;QACd,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,IAAI;QACjB,KAAK,EAAE,EAAE;QACT,SAAS,EAAE,IAAI;QACf,eAAe,EAAE,IAAI;QACrB,eAAe,EAAE,IAAI;QACrB,OAAO,EAAE,CAAC;KACV;CACmC,CAAC;AAEtC,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AACnC,MAAM,CAAC,MAAM,eAAe,GAAG,CA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G;IAChB,oBAAoB,EAAE,CAAC;CACS,CAAC","sourcesContent":["import * as THREE from 'three/webgpu';\nimport type { LiquidGlassPanelOptions } from './LiquidGlassPanel.js';\nimport type { BackgroundSettings, StageInteractionTheme } from './stageTypes.js';\n\n/** Default environment presentation used when a route supplies no background settings. */\nexport const DEFAULT_BACKGROUND = {\n\tblurriness: 0.2,\n\ttint: '#b6deff',\n\ttintIntensity: 0.3\n} satisfies BackgroundSettings;\n\n/** Fallback panel used by the imperative API when no declarative panels are registered. */\nexport const DEFAULT_PANELS = [\n\t{\n\t\twidth: 360,\n\t\theight: 230,\n\t\tradius: 42,\n\t\tposition: { x: 0, y: 42 },\n\t\tbackdropBlur: 3,\n\t\trefraction: 12,\n\t\ttint: '#ffffff',\n\t\ttintOpacity: 0.28,\n\t\tbezel: 18,\n\t\tthickness: 0.35,\n\t\tspecularOpacity: 0.18,\n\t\tshadowIntensity: 0.28,\n\t\topacity: 1\n\t}\n] satisfies LiquidGlassPanelOptions[];\n\nexport const PANEL_CAMERA_FOV = 36;\nexport const PANEL_CONTENT_Z = 0;\n/** Shared maximum tilt for every panel at a pointer edge. */\nexport const PANEL_POINTER_MAX_TILT = THREE.MathUtils.degToRad(10);\nexport const PANEL_POINTER_MAX_LIFT = 8;\nexport const PANEL_POINTER_DAMPING = 12;\n/** Pointer approach distance derived from the short side with a capped aspect correction. */\nexport const PANEL_POINTER_PROXIMITY_SCALE = 0.15;\nexport const PANEL_POINTER_PROXIMITY_ASPECT_LIMIT = 1.65;\nexport const PANEL_POINTER_PROXIMITY_MIN = 12;\nexport const PANEL_POINTER_PROXIMITY_MAX = 32;\nexport const PANEL_FOCUS_MAX_OFFSET = 190;\nexport const PANEL_FOCUS_MAX_ADVANCE = 360;\n/** Caps restored shared-perspective egress on unusually short viewports. */\nexport const PANEL_FOCUS_PERSPECTIVE_MAX_SCALE = 1.65;\nexport const PANEL_FOCUS_MIN_OPACITY = 0;\nexport const PANEL_FOCUS_MAX_BLUR = 7;\n/** Exponential damping applied to mouse-wheel dolly input. */\nexport const WHEEL_ZOOM_DAMPING = 8.5;\n/** Exponential damping used while scrolling a close-up back toward the overview. */\nexport const ZOOM_RESET_DAMPING = 8.5;\n/** Duration range for an explicit return to the fitted element view. */\nexport const VIEW_RESET_MIN_DURATION = 0.3;\nexport const VIEW_RESET_MAX_DURATION = 0.8;\nexport const MINIMAP_DEFAULT_EXPANDED_HEIGHT = 230;\n/** Viewport inset used only while the minimap is expanded by camera zoom. */\nexport const MINIMAP_FOCUSED_VIEWPORT_INSET = 10;\nexport const MINIMAP_PANEL_Z = 8;\nexport const MINIMAP_POINTER_MODEL_LIFT = 24;\n/** Default model scale at full minimap hover, independent of its dock presentation scale. */\nexport const MINIMAP_DEFAULT_HOVER_MODEL_SCALE = 1.16;\nexport const MINIMAP_OVERLAY_Z = 0.4;\nexport const MINIMAP_VIEWPORT_BORDER_THICKNESS = 3;\nexport const MINIMAP_MIN_BLUR_GUARD = 56;\nexport const MINIMAP_DEFAULT_OVERLAY_BLUR = 10;\nexport const MINIMAP_OVERLAY_REVEAL_DAMPING = 10;\nexport const MINIMAP_DEFAULT_CONTEXT_OPACITY = 0;\nexport const MINIMAP_DEFAULT_CONTEXT_COLOR = '#000000';\nexport const MINIMAP_MODEL_RENDER_ORDER = 14;\nexport const MINIMAP_DEFAULT_MODEL_SCALE = 1;\n/** Fraction of the minimap's short side reserved for the element bounding sphere. */\nexport const MINIMAP_MODEL_FILL = 0.96;\n/** Suppresses only floating-point noise while keeping DOM focus on the camera timeline. */\nexport const ZOOM_FOCUS_NOTIFY_EPSILON = 0.000001;\n/** Responsive spatial-element-fit margin that lets authored silhouettes fill the viewport. */\nexport const SPATIAL_ELEMENT_CAMERA_FIT_MARGIN = 1;\n/** Existing default view expressed as orbit angles for backwards-compatible framing. */\nexport const DEFAULT_CAMERA_AZIMUTH = THREE.MathUtils.radToDeg(Math.atan2(0.45, 1));\nexport const DEFAULT_CAMERA_ELEVATION = THREE.MathUtils.radToDeg(\n\tMath.asin(0.28 / Math.hypot(0.45, 0.28, 1))\n);\nexport const DEFAULT_HDR = '';\nexport const DEFAULT_GLB = '';\n\n/** Default element hover outline, tuned to remain visible on light and dark scenes. */\nexport const DEFAULT_INTERACTION_THEME = {\n\toutlineColor: '#7db7ff',\n\toutlineOpacity: 0.3,\n\toutlineThickness: 1,\n\toutlineGlow: 0.9,\n\toutlineGlowThickness: 8\n} satisfies StageInteractionTheme;\n"]}
|
package/dist/stage/stageDom.d.ts
CHANGED
|
@@ -7,4 +7,6 @@ export declare function getStagePositionFromRect(rect: Pick<DOMRect, 'height' |
|
|
|
7
7
|
};
|
|
8
8
|
/** Returns whether a rectangle intersects the viewport plus an optional preload margin. */
|
|
9
9
|
export declare function isViewportRectVisible(rect: Pick<DOMRect, 'bottom' | 'left' | 'right' | 'top'>, viewportWidth: number, viewportHeight: number, margin?: number): boolean;
|
|
10
|
+
/** Resolves a sticky panel inside its document-space containing block. */
|
|
11
|
+
export declare function getStickyPanelTop(documentTop: number, height: number, boundaryBottom: number, inset: number, scrollY: number): number;
|
|
10
12
|
//# sourceMappingURL=stageDom.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stageDom.d.ts","sourceRoot":"","sources":["../../src/stage/stageDom.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,WAOzD;AAED,yFAAyF;AACzF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;;;EAKhG;AAED,2FAA2F;AAC3F,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC,EACxD,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,MAAM,SAAI,WASV"}
|
|
1
|
+
{"version":3,"file":"stageDom.d.ts","sourceRoot":"","sources":["../../src/stage/stageDom.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,wBAAgB,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,WAOzD;AAED,yFAAyF;AACzF,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;;;EAKhG;AAED,2FAA2F;AAC3F,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,CAAC,EACxD,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,MAAM,SAAI,WASV;AAED,0EAA0E;AAC1E,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,UAE5H"}
|
package/dist/stage/stageDom.js
CHANGED
|
@@ -19,4 +19,8 @@ export function isViewportRectVisible(rect, viewportWidth, viewportHeight, margi
|
|
|
19
19
|
rect.bottom >= -safeMargin &&
|
|
20
20
|
rect.top <= viewportHeight + safeMargin);
|
|
21
21
|
}
|
|
22
|
+
/** Resolves a sticky panel inside its document-space containing block. */
|
|
23
|
+
export function getStickyPanelTop(documentTop, height, boundaryBottom, inset, scrollY) {
|
|
24
|
+
return Math.min(Math.max(documentTop - scrollY, inset), boundaryBottom - scrollY - height);
|
|
25
|
+
}
|
|
22
26
|
//# sourceMappingURL=stageDom.js.map
|