@spatial-elements/core 1.0.0-beta.5 → 1.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog/CarouselDeviceCamera.d.ts +12 -0
- package/dist/catalog/CarouselDeviceCamera.d.ts.map +1 -0
- package/dist/catalog/CarouselDeviceCamera.js +44 -0
- package/dist/catalog/CarouselDeviceCamera.js.map +1 -0
- package/dist/catalog/CarouselGlassCompositor.d.ts +7 -2
- package/dist/catalog/CarouselGlassCompositor.d.ts.map +1 -1
- package/dist/catalog/CarouselGlassCompositor.js +85 -24
- package/dist/catalog/CarouselGlassCompositor.js.map +1 -1
- package/dist/catalog/CarouselGround.d.ts +21 -0
- package/dist/catalog/CarouselGround.d.ts.map +1 -0
- package/dist/catalog/CarouselGround.js +107 -0
- package/dist/catalog/CarouselGround.js.map +1 -0
- package/dist/catalog/CatalogDepthBlur.d.ts +26 -0
- package/dist/catalog/CatalogDepthBlur.d.ts.map +1 -0
- package/dist/catalog/CatalogDepthBlur.js +87 -0
- package/dist/catalog/CatalogDepthBlur.js.map +1 -0
- package/dist/catalog/CatalogModelOutline.d.ts +31 -0
- package/dist/catalog/CatalogModelOutline.d.ts.map +1 -0
- package/dist/catalog/CatalogModelOutline.js +127 -0
- package/dist/catalog/CatalogModelOutline.js.map +1 -0
- package/dist/catalog/CatalogSpatialElementLayer.d.ts +44 -2
- package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -1
- package/dist/catalog/CatalogSpatialElementLayer.js +293 -88
- package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
- package/dist/catalog/CatalogTransition.d.ts.map +1 -1
- package/dist/catalog/CatalogTransition.js +62 -4
- package/dist/catalog/CatalogTransition.js.map +1 -1
- package/dist/catalog/SpatialGeometryCapture.d.ts +9 -0
- package/dist/catalog/SpatialGeometryCapture.d.ts.map +1 -1
- package/dist/catalog/SpatialGeometryCapture.js +11 -1
- package/dist/catalog/SpatialGeometryCapture.js.map +1 -1
- package/dist/catalog/cardModelFit.d.ts +7 -0
- package/dist/catalog/cardModelFit.d.ts.map +1 -0
- package/dist/catalog/cardModelFit.js +16 -0
- package/dist/catalog/cardModelFit.js.map +1 -0
- package/dist/catalog/cardProjection.d.ts +8 -0
- package/dist/catalog/cardProjection.d.ts.map +1 -0
- package/dist/catalog/cardProjection.js +51 -0
- package/dist/catalog/cardProjection.js.map +1 -0
- package/dist/catalog/carouselMotion.d.ts +35 -0
- package/dist/catalog/carouselMotion.d.ts.map +1 -1
- package/dist/catalog/carouselMotion.js +85 -4
- package/dist/catalog/carouselMotion.js.map +1 -1
- package/dist/catalog/carouselProximity.d.ts +11 -0
- package/dist/catalog/carouselProximity.d.ts.map +1 -0
- package/dist/catalog/carouselProximity.js +13 -0
- package/dist/catalog/carouselProximity.js.map +1 -0
- package/dist/catalog/carouselSupport.d.ts +4 -0
- package/dist/catalog/carouselSupport.d.ts.map +1 -0
- package/dist/catalog/carouselSupport.js +30 -0
- package/dist/catalog/carouselSupport.js.map +1 -0
- package/dist/catalog/catalogPose.d.ts +36 -6
- package/dist/catalog/catalogPose.d.ts.map +1 -1
- package/dist/catalog/catalogPose.js +79 -23
- package/dist/catalog/catalogPose.js.map +1 -1
- package/dist/catalog/deviceYaw.d.ts +21 -0
- package/dist/catalog/deviceYaw.d.ts.map +1 -0
- package/dist/catalog/deviceYaw.js +87 -0
- package/dist/catalog/deviceYaw.js.map +1 -0
- package/dist/catalog/listDeviceOrientation.d.ts +15 -0
- package/dist/catalog/listDeviceOrientation.d.ts.map +1 -0
- package/dist/catalog/listDeviceOrientation.js +245 -0
- package/dist/catalog/listDeviceOrientation.js.map +1 -0
- package/dist/stage/DeviceGeometryMotion.d.ts +13 -0
- package/dist/stage/DeviceGeometryMotion.d.ts.map +1 -0
- package/dist/stage/DeviceGeometryMotion.js +37 -0
- package/dist/stage/DeviceGeometryMotion.js.map +1 -0
- package/dist/stage/LiquidGlassPanel.d.ts +2 -0
- package/dist/stage/LiquidGlassPanel.d.ts.map +1 -1
- package/dist/stage/LiquidGlassPanel.js +8 -1
- package/dist/stage/LiquidGlassPanel.js.map +1 -1
- package/dist/stage/MinimapController.d.ts +1 -0
- package/dist/stage/MinimapController.d.ts.map +1 -1
- package/dist/stage/MinimapController.js +7 -0
- package/dist/stage/MinimapController.js.map +1 -1
- package/dist/stage/PanelPresentationController.d.ts.map +1 -1
- package/dist/stage/PanelPresentationController.js +19 -7
- package/dist/stage/PanelPresentationController.js.map +1 -1
- package/dist/stage/StageExperience.d.ts +56 -0
- package/dist/stage/StageExperience.d.ts.map +1 -1
- package/dist/stage/StageExperience.js +53 -17
- package/dist/stage/StageExperience.js.map +1 -1
- package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
- package/dist/stage/StageRenderPipeline.js +14 -63
- package/dist/stage/StageRenderPipeline.js.map +1 -1
- package/dist/stage/interactionOutline.d.ts +14 -0
- package/dist/stage/interactionOutline.d.ts.map +1 -0
- package/dist/stage/interactionOutline.js +81 -0
- package/dist/stage/interactionOutline.js.map +1 -0
- package/dist/stage/panelContext.d.ts +2 -0
- package/dist/stage/panelContext.d.ts.map +1 -1
- package/dist/stage/panelContext.js.map +1 -1
- package/dist/stage/stageTypes.d.ts +1 -0
- package/dist/stage/stageTypes.d.ts.map +1 -1
- package/dist/stage/stageTypes.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { describeRenderTargets } from './renderTargetInventory.js';
|
|
2
|
+
import { DeviceGeometryMotion } from './DeviceGeometryMotion.js';
|
|
3
|
+
import { isDeviceOrientationPaused, getListDeviceYaw, getListDevicePitch, getListDeviceRoll, retainListDeviceOrientation, subscribeListDeviceYaw, pauseDeviceOrientationForScroll } from '../catalog/listDeviceOrientation.js';
|
|
2
4
|
import { StageRenderPipeline } from './StageRenderPipeline.js';
|
|
3
5
|
import { PanelPresentationController } from './PanelPresentationController.js';
|
|
4
6
|
import { MinimapController } from './MinimapController.js';
|
|
@@ -29,6 +31,7 @@ import {} from './SpaceMouseAdapter.js';
|
|
|
29
31
|
import { disposeMinimapModelMaterials } from './minimap/MinimapModel.js';
|
|
30
32
|
import {} from './minimap/MinimapProjection.js';
|
|
31
33
|
import { disposeMaterialOnly, getMeshBounds, getMeshMaterials, isMesh } from './stageSceneUtils.js';
|
|
34
|
+
import { isOutlineMesh } from './interactionOutline.js';
|
|
32
35
|
const SCROLL_SETTLE_DELAY = 120;
|
|
33
36
|
const VIEWPORT_CULL_MARGIN = 96;
|
|
34
37
|
/** Shared spatial state for both WebGPU glass and DOM-backed panel surfaces. */
|
|
@@ -178,7 +181,12 @@ export class StageExperience {
|
|
|
178
181
|
get minimaps() {
|
|
179
182
|
return this.minimapController.views;
|
|
180
183
|
}
|
|
181
|
-
resize = () => this.
|
|
184
|
+
resize = () => this.requestRender();
|
|
185
|
+
rendererSize = new THREE.Vector2();
|
|
186
|
+
deviceMotion = new DeviceGeometryMotion();
|
|
187
|
+
deviceOrientationEnabled;
|
|
188
|
+
releaseDeviceOrientation;
|
|
189
|
+
unsubscribeDeviceOrientation;
|
|
182
190
|
render = () => {
|
|
183
191
|
this.renderRequestId = 0;
|
|
184
192
|
// The shared callback will draw after updating DOM/dock positions. Avoid
|
|
@@ -325,6 +333,12 @@ export class StageExperience {
|
|
|
325
333
|
this.container = container;
|
|
326
334
|
if (options.dracoDecoderPath)
|
|
327
335
|
this.assets.setDracoDecoderPath(options.dracoDecoderPath);
|
|
336
|
+
this.deviceOrientationEnabled = options.deviceOrientation ?? false;
|
|
337
|
+
if (this.deviceOrientationEnabled)
|
|
338
|
+
this.unsubscribeDeviceOrientation = subscribeListDeviceYaw(() => {
|
|
339
|
+
if (this.releaseDeviceOrientation && !this.scrollActive)
|
|
340
|
+
this.requestRender();
|
|
341
|
+
});
|
|
328
342
|
this.interaction = new SpatialElementInteractionController({
|
|
329
343
|
camera: this.camera,
|
|
330
344
|
canvas: this.backgroundCanvas,
|
|
@@ -344,6 +358,7 @@ export class StageExperience {
|
|
|
344
358
|
})
|
|
345
359
|
});
|
|
346
360
|
this.minimapController = new MinimapController({
|
|
361
|
+
sensorRotation: () => this.deviceMotion.rotation,
|
|
347
362
|
renderer: this.renderer,
|
|
348
363
|
camera: this.camera,
|
|
349
364
|
panelCamera: this.panelCamera,
|
|
@@ -512,6 +527,9 @@ export class StageExperience {
|
|
|
512
527
|
this.pipeline.createSceneCapture();
|
|
513
528
|
this.createPanels();
|
|
514
529
|
this.resizeRenderer();
|
|
530
|
+
// Reparenting must preserve the already visible HTML in the same task;
|
|
531
|
+
// shader compilation below can yield for more than one browser frame.
|
|
532
|
+
this.renderPanelContents();
|
|
515
533
|
this.pipeline.warmRenderTargetSets();
|
|
516
534
|
await this.pipeline.prepareZoomEffects();
|
|
517
535
|
if (this.disposed)
|
|
@@ -522,6 +540,7 @@ export class StageExperience {
|
|
|
522
540
|
this.currentScrollY = scrollPosition.scrollY;
|
|
523
541
|
this.lastScrollY = this.currentScrollY;
|
|
524
542
|
window.addEventListener('resize', this.resize);
|
|
543
|
+
window.visualViewport?.addEventListener('resize', this.resize);
|
|
525
544
|
this.stopScrollFrames = subscribeStageScrollFrame(this.scroll, STAGE_SCROLL_PRIORITY.stage);
|
|
526
545
|
window.addEventListener(STAGE_PANEL_LAYOUT_EVENT, this.requestPanelSync);
|
|
527
546
|
window.addEventListener(STAGE_PANEL_VISUAL_EVENT, this.requestPanelVisualSync);
|
|
@@ -547,9 +566,12 @@ export class StageExperience {
|
|
|
547
566
|
if (this.disposed)
|
|
548
567
|
return;
|
|
549
568
|
this.disposed = true;
|
|
569
|
+
this.releaseDeviceOrientation?.();
|
|
570
|
+
this.unsubscribeDeviceOrientation?.();
|
|
550
571
|
this.releaseSpatialCapture();
|
|
551
572
|
this.container.removeAttribute('data-stage-scroll-rendering');
|
|
552
573
|
window.removeEventListener('resize', this.resize);
|
|
574
|
+
window.visualViewport?.removeEventListener('resize', this.resize);
|
|
553
575
|
this.stopScrollFrames?.();
|
|
554
576
|
this.stopScrollFrames = undefined;
|
|
555
577
|
window.removeEventListener(STAGE_PANEL_LAYOUT_EVENT, this.requestPanelSync);
|
|
@@ -626,6 +648,8 @@ export class StageExperience {
|
|
|
626
648
|
element);
|
|
627
649
|
}
|
|
628
650
|
capturePanelSurface(element) {
|
|
651
|
+
if (element.closest('[data-carousel-spatial-element]'))
|
|
652
|
+
return captureCssSurface(element, element, '::before');
|
|
629
653
|
if (element.hasAttribute('data-catalog-dock-surface')) {
|
|
630
654
|
const header = element.closest('[data-spatial-element-sticky-header]');
|
|
631
655
|
if (header)
|
|
@@ -848,7 +872,7 @@ export class StageExperience {
|
|
|
848
872
|
void this.initializeSpaceMouse();
|
|
849
873
|
}
|
|
850
874
|
setCatalogSpatialElements(brandId, items) {
|
|
851
|
-
this.catalogLayer ??= new CatalogSpatialElementLayer(this.assets, () => this.requestRender());
|
|
875
|
+
this.catalogLayer ??= new CatalogSpatialElementLayer(this.assets, () => this.requestRender(), () => this.interactionTheme);
|
|
852
876
|
this.catalogLayer.setPageBackground(this.pageBackground);
|
|
853
877
|
this.catalogLayer.setExitOpacity(this.returnSpatialElement
|
|
854
878
|
? this.catalogPresentation.enterOpacity
|
|
@@ -956,6 +980,8 @@ export class StageExperience {
|
|
|
956
980
|
device.destroy();
|
|
957
981
|
}
|
|
958
982
|
getPanelTransitionOpacity(panel) {
|
|
983
|
+
if (panel?.content?.element.closest('[data-catalog-shell-continuous]'))
|
|
984
|
+
return 1;
|
|
959
985
|
return getCatalogTransitionOpacity(this.catalogPresentation, panel?.transitionGroup);
|
|
960
986
|
}
|
|
961
987
|
captureCatalogGeometry(spatialElementId) {
|
|
@@ -1134,6 +1160,7 @@ export class StageExperience {
|
|
|
1134
1160
|
this.pageModelReady = false;
|
|
1135
1161
|
this.spatialCapture = new SpatialGeometryCapture(model, projection, {
|
|
1136
1162
|
environment: this.scene.environment,
|
|
1163
|
+
outlineTheme: this.modelHover ? this.interactionTheme : undefined,
|
|
1137
1164
|
environmentIntensity: this.scene.environmentIntensity,
|
|
1138
1165
|
lights: this.scene.children.filter((child) => child instanceof THREE.Light),
|
|
1139
1166
|
high: highPose,
|
|
@@ -1992,18 +2019,7 @@ export class StageExperience {
|
|
|
1992
2019
|
this.interaction.setPickTargets(model, (mesh) => this.isInteractionMesh(mesh));
|
|
1993
2020
|
}
|
|
1994
2021
|
isInteractionMesh(mesh) {
|
|
1995
|
-
|
|
1996
|
-
return false;
|
|
1997
|
-
if (this.interactionTheme.excludeMesh?.(mesh))
|
|
1998
|
-
return false;
|
|
1999
|
-
if (mesh.userData.stagePick === false || mesh.userData.stageOutline === false)
|
|
2000
|
-
return false;
|
|
2001
|
-
const materialNames = getMeshMaterials(mesh)
|
|
2002
|
-
.map((material) => material.name)
|
|
2003
|
-
.filter(Boolean)
|
|
2004
|
-
.join(' ');
|
|
2005
|
-
const label = `${mesh.name} ${materialNames}`.toLowerCase();
|
|
2006
|
-
return !/(shadow|ground|floor|plane|helper|collision|collider|reflection)/i.test(label);
|
|
2022
|
+
return this.isSpatialElementMesh(mesh) && isOutlineMesh(mesh, this.interactionTheme);
|
|
2007
2023
|
}
|
|
2008
2024
|
createPanels() {
|
|
2009
2025
|
if (!this.pipeline.activeRenderTargets &&
|
|
@@ -2242,9 +2258,10 @@ export class StageExperience {
|
|
|
2242
2258
|
return true;
|
|
2243
2259
|
return isViewportRectVisible(this.resolveStageRect(cachedRect), window.innerWidth, window.innerHeight, VIEWPORT_CULL_MARGIN);
|
|
2244
2260
|
}
|
|
2245
|
-
resizeRenderer() {
|
|
2261
|
+
resizeRenderer(invalidate = true) {
|
|
2246
2262
|
const width = window.innerWidth;
|
|
2247
2263
|
const height = window.innerHeight;
|
|
2264
|
+
this.rendererSize.set(width, height);
|
|
2248
2265
|
this.panelMeasurementsDirty = true;
|
|
2249
2266
|
this.viewportMeasurementDirty = true;
|
|
2250
2267
|
this.pipeline.resizeRenderTargets();
|
|
@@ -2265,7 +2282,8 @@ export class StageExperience {
|
|
|
2265
2282
|
this.nativePanelLayer.style.height = `${height}px`;
|
|
2266
2283
|
this.layoutDirty = true;
|
|
2267
2284
|
this.syncPanelLayouts(true);
|
|
2268
|
-
|
|
2285
|
+
if (invalidate)
|
|
2286
|
+
this.requestRender();
|
|
2269
2287
|
}
|
|
2270
2288
|
/**
|
|
2271
2289
|
* Forces WebGPU to allocate and bind both quality levels before input starts.
|
|
@@ -2397,6 +2415,7 @@ export class StageExperience {
|
|
|
2397
2415
|
handleScrollFrame(frame) {
|
|
2398
2416
|
if (this.disposed)
|
|
2399
2417
|
return;
|
|
2418
|
+
pauseDeviceOrientationForScroll();
|
|
2400
2419
|
this.currentScrollX = frame.scrollX;
|
|
2401
2420
|
this.currentScrollY = frame.scrollY;
|
|
2402
2421
|
if (this.renderRequestId)
|
|
@@ -2479,8 +2498,18 @@ export class StageExperience {
|
|
|
2479
2498
|
return this.panels.renderFlatPanelSurfaces();
|
|
2480
2499
|
}
|
|
2481
2500
|
renderFrame(force = false) {
|
|
2501
|
+
if (this.disposed)
|
|
2502
|
+
return;
|
|
2503
|
+
if (!this.disposed && (this.rendererSize.x !== window.innerWidth || this.rendererSize.y !== window.innerHeight))
|
|
2504
|
+
this.resizeRenderer(false);
|
|
2482
2505
|
const renderTargets = this.pipeline.activeRenderTargets;
|
|
2483
2506
|
const listOnly = this.catalog && !this.viewportTarget;
|
|
2507
|
+
if (this.deviceOrientationEnabled && !listOnly && this.model && !this.releaseDeviceOrientation)
|
|
2508
|
+
this.releaseDeviceOrientation = retainListDeviceOrientation(this.container, () => { });
|
|
2509
|
+
else if (listOnly && this.releaseDeviceOrientation) {
|
|
2510
|
+
this.releaseDeviceOrientation();
|
|
2511
|
+
this.releaseDeviceOrientation = undefined;
|
|
2512
|
+
}
|
|
2484
2513
|
if (this.disposed || (!listOnly && (!renderTargets || !this.pipeline.stageDisplayQuad)))
|
|
2485
2514
|
return;
|
|
2486
2515
|
if (!force && document.hidden)
|
|
@@ -2517,6 +2546,12 @@ export class StageExperience {
|
|
|
2517
2546
|
if (!renderTargets)
|
|
2518
2547
|
return;
|
|
2519
2548
|
const { controls: controlsAnimating, wheel: wheelZoomAnimating } = this.interaction.advance(now, delta);
|
|
2549
|
+
let deviceAnimating = false;
|
|
2550
|
+
if (this.deviceOrientationEnabled && this.model?.parent === this.scene && !this.catalogHandoff && !this.spatialCapture) {
|
|
2551
|
+
if (!isDeviceOrientationPaused())
|
|
2552
|
+
deviceAnimating = this.deviceMotion.update(getListDeviceYaw(), getListDevicePitch(), getListDeviceRoll(), delta);
|
|
2553
|
+
this.deviceMotion.apply(this.model, this.camera, this.initialControlsTarget);
|
|
2554
|
+
}
|
|
2520
2555
|
// The damped camera distance is the single animation clock for geometry and
|
|
2521
2556
|
// every close-up UI phase. Phase remapping remains, temporal lag does not.
|
|
2522
2557
|
this.panelFocus = this.getZoomFocusFactor();
|
|
@@ -2535,7 +2570,8 @@ export class StageExperience {
|
|
|
2535
2570
|
this.renderPanelContents();
|
|
2536
2571
|
this.pipeline.renderFrame(false, !this.scrollActive && !this.catalogHandoff);
|
|
2537
2572
|
this.animationActive =
|
|
2538
|
-
|
|
2573
|
+
deviceAnimating ||
|
|
2574
|
+
this.presentation.readiness.animating ||
|
|
2539
2575
|
this.catalogLayerAnimating ||
|
|
2540
2576
|
(this.stageViewportVisible &&
|
|
2541
2577
|
(!this.catalogHandoff || this.catalogMotionComplete) &&
|