@spatial-elements/core 1.0.0-beta.3 → 1.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog/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/messages.d.ts +32 -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/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/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.map +1 -1
- package/dist/stage/PageBindingController.js +3 -1
- package/dist/stage/PageBindingController.js.map +1 -1
- package/dist/stage/PanelPresentationController.d.ts +3 -1
- package/dist/stage/PanelPresentationController.d.ts.map +1 -1
- package/dist/stage/PanelPresentationController.js +64 -9
- package/dist/stage/PanelPresentationController.js.map +1 -1
- package/dist/stage/SpatialElementInteractionController.d.ts +10 -0
- package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -1
- package/dist/stage/SpatialElementInteractionController.js +104 -8
- package/dist/stage/SpatialElementInteractionController.js.map +1 -1
- package/dist/stage/StageExperience.d.ts +12 -0
- package/dist/stage/StageExperience.d.ts.map +1 -1
- package/dist/stage/StageExperience.js +113 -49
- package/dist/stage/StageExperience.js.map +1 -1
- 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.js +1 -1
- package/dist/stage/StageRenderPipeline.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/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 +8 -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/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 +3 -1
- package/dist/stage/stageVisualTest.d.ts.map +1 -1
- package/dist/stage/stageVisualTest.js.map +1 -1
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@ import { LiquidGlassPanel, resolveLiquidGlassPanelOptions } from './LiquidGlassP
|
|
|
23
23
|
import { STAGE_PANEL_LAYOUT_EVENT, STAGE_PANEL_VISUAL_EVENT } from './panelContext.js';
|
|
24
24
|
import { DEFAULT_INTERACTION_THEME, DEFAULT_PANELS, PANEL_CAMERA_FOV, PANEL_CONTENT_Z, SPATIAL_ELEMENT_CAMERA_FIT_MARGIN, ZOOM_FOCUS_NOTIFY_EPSILON } from './stageConstants.js';
|
|
25
25
|
import { getStagePositionFromRect, isViewportRectVisible } from './stageDom.js';
|
|
26
|
-
import { STAGE_SCROLL_PRIORITY, getStageVisualScrollPosition, subscribeStageScrollFrame } from './scrollFrame.js';
|
|
26
|
+
import { STAGE_SCROLL_PRIORITY, getStageVisualScrollPosition, hasPendingStageScrollFrame, subscribeStageScrollFrame } from './scrollFrame.js';
|
|
27
27
|
import { getCameraFitDistance, getCameraOrbitDirection, getBoxCorners, getPanelFocusOpacity, getPerspectiveDistance, getSequencedMinimapFocus, getStageUiFocus, getZoomFocusDistanceRange, hasPanelGeometryChanged } from './stageMath.js';
|
|
28
28
|
import {} from './SpaceMouseAdapter.js';
|
|
29
29
|
import { disposeMinimapModelMaterials } from './minimap/MinimapModel.js';
|
|
@@ -180,6 +180,10 @@ export class StageExperience {
|
|
|
180
180
|
resize = () => this.resizeRenderer();
|
|
181
181
|
render = () => {
|
|
182
182
|
this.renderRequestId = 0;
|
|
183
|
+
// The shared callback will draw after updating DOM/dock positions. Avoid
|
|
184
|
+
// submitting an older camera/scroll frame immediately before that draw.
|
|
185
|
+
if (this.stopScrollFrames && hasPendingStageScrollFrame())
|
|
186
|
+
return;
|
|
183
187
|
this.renderFrame();
|
|
184
188
|
};
|
|
185
189
|
visibilityChange = () => {
|
|
@@ -187,9 +191,15 @@ export class StageExperience {
|
|
|
187
191
|
this.requestRender();
|
|
188
192
|
};
|
|
189
193
|
pointerMove = (event) => this.handlePointerMove(event);
|
|
190
|
-
pointerLeave = () =>
|
|
194
|
+
pointerLeave = (event) => {
|
|
195
|
+
if (event.type === 'blur' || event.pointerType === 'mouse') {
|
|
196
|
+
this.handlePointerLeave();
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
pointerContact = (event) => this.interaction.handlePointerContact(event);
|
|
191
200
|
pointerDown = (event) => this.handlePointerDown(event);
|
|
192
201
|
pointerUp = (event) => this.handlePointerUp(event);
|
|
202
|
+
touchStart = (event) => this.interaction.handleTouchStart(event);
|
|
193
203
|
wheel = (event) => this.handleWheel(event);
|
|
194
204
|
scroll = (frame) => this.handleScrollFrame(frame);
|
|
195
205
|
finishScroll = () => {
|
|
@@ -505,12 +515,14 @@ export class StageExperience {
|
|
|
505
515
|
window.addEventListener(STAGE_PANEL_LAYOUT_EVENT, this.requestPanelSync);
|
|
506
516
|
window.addEventListener(STAGE_PANEL_VISUAL_EVENT, this.requestPanelVisualSync);
|
|
507
517
|
window.addEventListener('pointermove', this.pointerMove);
|
|
518
|
+
window.addEventListener('pointerdown', this.pointerContact, { capture: true, passive: true });
|
|
508
519
|
window.addEventListener('pointerup', this.pointerUp);
|
|
509
520
|
window.addEventListener('pointercancel', this.pointerUp);
|
|
510
521
|
window.addEventListener('pointerleave', this.pointerLeave);
|
|
511
522
|
window.addEventListener('blur', this.pointerLeave);
|
|
512
523
|
document.addEventListener('visibilitychange', this.visibilityChange);
|
|
513
524
|
this.backgroundCanvas.addEventListener('pointerdown', this.pointerDown, { capture: true });
|
|
525
|
+
this.backgroundCanvas.addEventListener('touchstart', this.touchStart, { passive: false });
|
|
514
526
|
this.backgroundCanvas.addEventListener('wheel', this.wheel, {
|
|
515
527
|
capture: true,
|
|
516
528
|
passive: false
|
|
@@ -532,6 +544,7 @@ export class StageExperience {
|
|
|
532
544
|
window.removeEventListener(STAGE_PANEL_LAYOUT_EVENT, this.requestPanelSync);
|
|
533
545
|
window.removeEventListener(STAGE_PANEL_VISUAL_EVENT, this.requestPanelVisualSync);
|
|
534
546
|
window.removeEventListener('pointermove', this.pointerMove);
|
|
547
|
+
window.removeEventListener('pointerdown', this.pointerContact, { capture: true });
|
|
535
548
|
window.removeEventListener('pointerup', this.pointerUp);
|
|
536
549
|
window.removeEventListener('pointercancel', this.pointerUp);
|
|
537
550
|
window.removeEventListener('pointerleave', this.pointerLeave);
|
|
@@ -541,6 +554,7 @@ export class StageExperience {
|
|
|
541
554
|
capture: true
|
|
542
555
|
});
|
|
543
556
|
this.backgroundCanvas.removeEventListener('wheel', this.wheel, { capture: true });
|
|
557
|
+
this.backgroundCanvas.removeEventListener('touchstart', this.touchStart);
|
|
544
558
|
if (this.renderRequestId)
|
|
545
559
|
cancelAnimationFrame(this.renderRequestId);
|
|
546
560
|
this.renderRequestId = 0;
|
|
@@ -1411,6 +1425,26 @@ export class StageExperience {
|
|
|
1411
1425
|
stopVisualTestSpaceMouseMotion() {
|
|
1412
1426
|
this.setSpaceMouseMoving(false);
|
|
1413
1427
|
}
|
|
1428
|
+
/** Projects a registered panel surface for frame-by-frame DOM/GPU alignment checks. */
|
|
1429
|
+
getVisualTestPanelRect(frame) {
|
|
1430
|
+
const index = this.panelTargets.findIndex((target) => target.frame === frame);
|
|
1431
|
+
const panel = this.panelRuntimes[index];
|
|
1432
|
+
if (!panel || !panel.group.visible)
|
|
1433
|
+
return null;
|
|
1434
|
+
panel.group.updateWorldMatrix(true, false);
|
|
1435
|
+
this.panelCamera.updateMatrixWorld(true);
|
|
1436
|
+
const { width, height } = panel.options;
|
|
1437
|
+
const points = [
|
|
1438
|
+
new THREE.Vector3(-width / 2, height / 2, 0),
|
|
1439
|
+
new THREE.Vector3(width / 2, height / 2, 0),
|
|
1440
|
+
new THREE.Vector3(width / 2, -height / 2, 0),
|
|
1441
|
+
new THREE.Vector3(-width / 2, -height / 2, 0)
|
|
1442
|
+
].map((corner) => panel.group.localToWorld(corner).project(this.panelCamera));
|
|
1443
|
+
const xs = points.map((point) => (point.x + 1) * window.innerWidth / 2);
|
|
1444
|
+
const ys = points.map((point) => (1 - point.y) * window.innerHeight / 2);
|
|
1445
|
+
const x = Math.min(...xs), y = Math.min(...ys);
|
|
1446
|
+
return { x, y, width: Math.max(...xs) - x, height: Math.max(...ys) - y };
|
|
1447
|
+
}
|
|
1414
1448
|
/** Returns the live rendered minimap bounds rather than its hidden DOM fallback bounds. */
|
|
1415
1449
|
getVisualTestMinimapRect() {
|
|
1416
1450
|
const minimap = this.minimaps.values().next().value;
|
|
@@ -1921,11 +1955,17 @@ export class StageExperience {
|
|
|
1921
1955
|
options: panel.options,
|
|
1922
1956
|
pointerLift: 0,
|
|
1923
1957
|
pointerReactive: target.pointerReactive ?? true,
|
|
1958
|
+
focusReactive: target.focusReactive ?? true,
|
|
1924
1959
|
projectionRoot,
|
|
1925
1960
|
surface: target.surface
|
|
1926
1961
|
});
|
|
1927
1962
|
this.panelScene.add(projectionRoot ?? panel.group);
|
|
1928
|
-
|
|
1963
|
+
if (target.nativeContent) {
|
|
1964
|
+
// Draw floating glass above regular panels; its content stays in the top layer.
|
|
1965
|
+
panel.group.renderOrder = 100;
|
|
1966
|
+
}
|
|
1967
|
+
else
|
|
1968
|
+
this.attachPanelContent(target.content, index, target.contentInset);
|
|
1929
1969
|
}
|
|
1930
1970
|
else {
|
|
1931
1971
|
const options = resolveLiquidGlassPanelOptions(measuredOptions);
|
|
@@ -1940,18 +1980,21 @@ export class StageExperience {
|
|
|
1940
1980
|
options,
|
|
1941
1981
|
pointerLift: 0,
|
|
1942
1982
|
pointerReactive: target.pointerReactive ?? true,
|
|
1983
|
+
focusReactive: target.focusReactive ?? true,
|
|
1943
1984
|
projectionRoot,
|
|
1944
1985
|
surface: target.surface
|
|
1945
1986
|
});
|
|
1946
1987
|
if (projectionRoot)
|
|
1947
1988
|
this.panelScene.add(projectionRoot);
|
|
1948
|
-
|
|
1989
|
+
if (!target.nativeContent)
|
|
1990
|
+
this.attachPanelSurface(target.surfaceElement, index, Boolean(target.minimap));
|
|
1949
1991
|
}
|
|
1950
1992
|
this.createMinimap(index, target.minimap);
|
|
1951
1993
|
const panel = this.panelRuntimes[index];
|
|
1952
1994
|
const group = target.frame.dataset.catalogTransitionGroup;
|
|
1953
1995
|
panel.transitionGroup = group === 'enter' || group === 'shared' ? group : undefined;
|
|
1954
|
-
panel.glass?.setVisibilityAlpha(this.getPanelTransitionOpacity(panel) * (target.getSurfaceOpacity?.() ?? 1)
|
|
1996
|
+
panel.glass?.setVisibilityAlpha(this.getPanelTransitionOpacity(panel) * (target.getSurfaceOpacity?.() ?? 1) *
|
|
1997
|
+
(target.getVisible?.() === false ? 0 : 1));
|
|
1955
1998
|
const minimap = this.minimaps.get(index);
|
|
1956
1999
|
if (minimap) {
|
|
1957
2000
|
this.updateMinimapOverlayVisibility(minimap);
|
|
@@ -1977,55 +2020,76 @@ export class StageExperience {
|
|
|
1977
2020
|
return;
|
|
1978
2021
|
this.layoutDirty = false;
|
|
1979
2022
|
const measurePanels = force || this.panelMeasurementsDirty;
|
|
1980
|
-
this.panelTargets.forEach((target, index) =>
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
currentRuntime.options.position.y = options.position.y;
|
|
2003
|
-
if (currentRuntime.projectionRoot) {
|
|
2004
|
-
currentRuntime.group.position.set(0, 0, 0);
|
|
2005
|
-
this.setPanelProjectionTransform(currentRuntime.projectionRoot, options.position.x, options.position.y, 0);
|
|
2006
|
-
}
|
|
2007
|
-
else {
|
|
2008
|
-
currentRuntime.group.position.set(options.position.x, options.position.y, 0);
|
|
2023
|
+
this.panelTargets.forEach((target, index) => this.syncPanelLayout(target, index, measurePanels));
|
|
2024
|
+
this.panelMeasurementsDirty = false;
|
|
2025
|
+
}
|
|
2026
|
+
syncPanelLayout(target, index, measurePanels) {
|
|
2027
|
+
const runtime = this.panelRuntimes[index];
|
|
2028
|
+
if (!runtime)
|
|
2029
|
+
return;
|
|
2030
|
+
// Preserve the last popup mesh while closed instead of resizing it to a 1px box.
|
|
2031
|
+
if (target.nativeContent && target.getVisible?.() === false)
|
|
2032
|
+
return;
|
|
2033
|
+
const options = this.getMeasuredPanelOptions(target, measurePanels);
|
|
2034
|
+
const geometryChanged = hasPanelGeometryChanged(runtime.options, options);
|
|
2035
|
+
if (geometryChanged && runtime.glass && target.minimap) {
|
|
2036
|
+
this.replacePanel(index, options);
|
|
2037
|
+
}
|
|
2038
|
+
else {
|
|
2039
|
+
if (geometryChanged) {
|
|
2040
|
+
const radius = options.radius ?? runtime.options.radius;
|
|
2041
|
+
runtime.glass?.setVisualSize(options.width, options.height, radius);
|
|
2042
|
+
runtime.options.width = options.width;
|
|
2043
|
+
runtime.options.height = options.height;
|
|
2044
|
+
runtime.options.radius = radius;
|
|
2009
2045
|
}
|
|
2046
|
+
}
|
|
2047
|
+
const currentRuntime = this.panelRuntimes[index];
|
|
2048
|
+
if (!currentRuntime)
|
|
2049
|
+
return;
|
|
2050
|
+
currentRuntime.options.position.x = options.position.x;
|
|
2051
|
+
currentRuntime.options.position.y = options.position.y;
|
|
2052
|
+
if (currentRuntime.projectionRoot) {
|
|
2053
|
+
currentRuntime.group.position.set(0, 0, 0);
|
|
2054
|
+
this.setPanelProjectionTransform(currentRuntime.projectionRoot, options.position.x, options.position.y, 0);
|
|
2055
|
+
}
|
|
2056
|
+
else {
|
|
2057
|
+
currentRuntime.group.position.set(options.position.x, options.position.y, 0);
|
|
2058
|
+
}
|
|
2059
|
+
// Intrinsic DOM sizing and native popover layout remain owned by the adapter.
|
|
2060
|
+
if (!target.nativeContent) {
|
|
2010
2061
|
if (currentRuntime.surface === 'glass') {
|
|
2011
2062
|
this.updateContentElement(target.content, currentRuntime, target.contentInset);
|
|
2012
2063
|
}
|
|
2013
2064
|
else {
|
|
2014
2065
|
this.updateSurfaceElement(target.surfaceElement, currentRuntime, currentRuntime.options.width, currentRuntime.options.height, Boolean(target.minimap));
|
|
2015
2066
|
}
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
else {
|
|
2022
|
-
currentRuntime.content.position.set(currentRuntime.options.position.x, currentRuntime.options.position.y, PANEL_CONTENT_Z);
|
|
2023
|
-
}
|
|
2067
|
+
}
|
|
2068
|
+
if (currentRuntime.content) {
|
|
2069
|
+
if (currentRuntime.contentProjectionRoot) {
|
|
2070
|
+
currentRuntime.content.position.set(0, 0, 0);
|
|
2071
|
+
this.setPanelProjectionTransform(currentRuntime.contentProjectionRoot, currentRuntime.options.position.x, currentRuntime.options.position.y, PANEL_CONTENT_Z);
|
|
2024
2072
|
}
|
|
2025
|
-
|
|
2026
|
-
|
|
2073
|
+
else {
|
|
2074
|
+
currentRuntime.content.position.set(currentRuntime.options.position.x, currentRuntime.options.position.y, PANEL_CONTENT_Z);
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
if (geometryChanged && target.minimap)
|
|
2078
|
+
this.createMinimap(index, target.minimap);
|
|
2079
|
+
}
|
|
2080
|
+
/** Commit anchor DOM positions and dependent native surfaces in one render transaction. */
|
|
2081
|
+
renderPanelContents() {
|
|
2082
|
+
this.cssRenderer.render(this.panelContentScene, this.panelCamera);
|
|
2083
|
+
this.renderFlatPanelSurfaces();
|
|
2084
|
+
this.panelTargets.forEach((target, index) => {
|
|
2085
|
+
if (!target.nativeContent || target.getVisible?.() === false)
|
|
2086
|
+
return;
|
|
2087
|
+
target.updateNativeLayout?.();
|
|
2088
|
+
this.syncPanelLayout(target, index, true);
|
|
2089
|
+
const runtime = this.panelRuntimes[index];
|
|
2090
|
+
if (runtime)
|
|
2091
|
+
runtime.group.visible = this.isPanelTargetVisible(index);
|
|
2027
2092
|
});
|
|
2028
|
-
this.panelMeasurementsDirty = false;
|
|
2029
2093
|
}
|
|
2030
2094
|
replacePanel(index, options) {
|
|
2031
2095
|
if (!this.pipeline.activeRenderTargets)
|
|
@@ -2076,6 +2140,8 @@ export class StageExperience {
|
|
|
2076
2140
|
const target = this.panelTargets[index];
|
|
2077
2141
|
if (!target)
|
|
2078
2142
|
return true;
|
|
2143
|
+
if (target.getVisible?.() === false)
|
|
2144
|
+
return false;
|
|
2079
2145
|
const cachedRect = this.pageBinding.getPanelRect(target.frame);
|
|
2080
2146
|
if (!cachedRect)
|
|
2081
2147
|
return true;
|
|
@@ -2346,9 +2412,8 @@ export class StageExperience {
|
|
|
2346
2412
|
this.syncPanelLayouts();
|
|
2347
2413
|
const panelsAnimating = this.updatePanelPointerInteraction(delta);
|
|
2348
2414
|
const domAnimating = this.updatePanelDomRenderModes();
|
|
2415
|
+
this.renderPanelContents();
|
|
2349
2416
|
this.pipeline.renderFrame(true, false);
|
|
2350
|
-
this.cssRenderer.render(this.panelContentScene, this.panelCamera);
|
|
2351
|
-
this.renderFlatPanelSurfaces();
|
|
2352
2417
|
this.animationActive = this.catalogLayerAnimating || panelsAnimating || domAnimating;
|
|
2353
2418
|
if (!force && (this.animationActive || this.renderInvalidated))
|
|
2354
2419
|
this.scheduleRender();
|
|
@@ -2372,9 +2437,8 @@ export class StageExperience {
|
|
|
2372
2437
|
this.syncPanelLayouts();
|
|
2373
2438
|
const panelsAnimating = this.updatePanelPointerInteraction(delta);
|
|
2374
2439
|
const panelDomModeAnimating = this.updatePanelDomRenderModes();
|
|
2440
|
+
this.renderPanelContents();
|
|
2375
2441
|
this.pipeline.renderFrame(false, !this.scrollActive && !this.catalogHandoff);
|
|
2376
|
-
this.cssRenderer.render(this.panelContentScene, this.panelCamera);
|
|
2377
|
-
this.renderFlatPanelSurfaces();
|
|
2378
2442
|
this.animationActive =
|
|
2379
2443
|
this.presentation.readiness.animating ||
|
|
2380
2444
|
this.catalogLayerAnimating ||
|