@spatial-elements/sveltekit 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +373 -0
- package/README.md +17 -0
- package/dist/catalog/ScrollNavigationBridge.svelte +394 -0
- package/dist/catalog/ScrollNavigationBridge.svelte.d.ts +13 -0
- package/dist/catalog/catalogEndpointAction.d.ts +6 -0
- package/dist/catalog/catalogEndpointAction.js +18 -0
- package/dist/catalog/catalogNavigation.d.ts +7 -0
- package/dist/catalog/catalogNavigation.js +19 -0
- package/dist/catalog/catalogTransition.css +59 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/spatial-element/BrandStageShell.svelte +106 -0
- package/dist/spatial-element/BrandStageShell.svelte.d.ts +12 -0
- package/dist/spatial-element/CarouselSection.svelte +350 -0
- package/dist/spatial-element/CarouselSection.svelte.d.ts +15 -0
- package/dist/spatial-element/CarouselSpatialElement.svelte +388 -0
- package/dist/spatial-element/CarouselSpatialElement.svelte.d.ts +17 -0
- package/dist/spatial-element/ContentPage.svelte +68 -0
- package/dist/spatial-element/ContentPage.svelte.d.ts +9 -0
- package/dist/spatial-element/ListSection.svelte +30 -0
- package/dist/spatial-element/ListSection.svelte.d.ts +8 -0
- package/dist/spatial-element/Section.svelte +191 -0
- package/dist/spatial-element/Section.svelte.d.ts +14 -0
- package/dist/spatial-element/SpatialElementBreadcrumbs.svelte +69 -0
- package/dist/spatial-element/SpatialElementBreadcrumbs.svelte.d.ts +8 -0
- package/dist/spatial-element/SpatialElementCard.svelte +256 -0
- package/dist/spatial-element/SpatialElementCard.svelte.d.ts +9 -0
- package/dist/spatial-element/SpatialElementMediaRail.svelte +144 -0
- package/dist/spatial-element/SpatialElementMediaRail.svelte.d.ts +7 -0
- package/dist/spatial-element/SpatialElementPage.svelte +249 -0
- package/dist/spatial-element/SpatialElementPage.svelte.d.ts +9 -0
- package/dist/spatial-element/SpatialElementStickyHeader.svelte +351 -0
- package/dist/spatial-element/SpatialElementStickyHeader.svelte.d.ts +9 -0
- package/dist/spatial-element/SpatialElementSummaryPanel.svelte +423 -0
- package/dist/spatial-element/SpatialElementSummaryPanel.svelte.d.ts +7 -0
- package/dist/spatial-element/SpatialElementTabList.svelte +266 -0
- package/dist/spatial-element/SpatialElementTabList.svelte.d.ts +9 -0
- package/dist/spatial-element/SpatialElementTabs.svelte +123 -0
- package/dist/spatial-element/SpatialElementTabs.svelte.d.ts +8 -0
- package/dist/spatial-element/SpatialListPage.svelte +23 -0
- package/dist/spatial-element/SpatialListPage.svelte.d.ts +11 -0
- package/dist/spatial-element/brandContext.d.ts +5 -0
- package/dist/spatial-element/brandContext.js +14 -0
- package/dist/spatial-element/index.d.ts +11 -0
- package/dist/spatial-element/index.js +8 -0
- package/dist/stage/Panel.svelte +355 -0
- package/dist/stage/Panel.svelte.d.ts +24 -0
- package/dist/stage/Stage.svelte +747 -0
- package/dist/stage/Stage.svelte.d.ts +22 -0
- package/dist/stage/StageViewport.svelte +73 -0
- package/dist/stage/StageViewport.svelte.d.ts +13 -0
- package/package.json +55 -0
|
@@ -0,0 +1,747 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SpatialElementLodPair } from '@spatial-elements/core/catalog/spatialElementLodPair';
|
|
3
|
+
import { onMount, setContext, tick } from 'svelte';
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import type {
|
|
6
|
+
BackgroundSettings,
|
|
7
|
+
StageCameraSettings,
|
|
8
|
+
StageExperience,
|
|
9
|
+
StageInteractionTheme,
|
|
10
|
+
StageModelSettings,
|
|
11
|
+
StagePanelTarget,
|
|
12
|
+
StageVisualTestView,
|
|
13
|
+
StageViewportTarget,
|
|
14
|
+
StageZoomFocusState
|
|
15
|
+
} from '@spatial-elements/core/stage/StageExperience';
|
|
16
|
+
import { isStageVisualTestMode, type StageVisualTestController } from '@spatial-elements/core/stage/stageVisualTest';
|
|
17
|
+
import { VirtualScrollController } from '@spatial-elements/core/stage/VirtualScrollController';
|
|
18
|
+
import ScrollNavigationBridge from '../catalog/ScrollNavigationBridge.svelte';
|
|
19
|
+
import { CatalogTransition } from '@spatial-elements/core/catalog/CatalogTransition';
|
|
20
|
+
import { CATALOG_ENDPOINTS, CatalogEndpointRegistry } from '@spatial-elements/core/catalog/CatalogEndpointRegistry';
|
|
21
|
+
import '../catalog/catalogTransition.css';
|
|
22
|
+
import { createStageSpatialElementAssetManifest } from '@spatial-elements/core/catalog/spatialElementAssets';
|
|
23
|
+
import { CATALOG_ITEMS, CatalogItems } from '@spatial-elements/core/catalog/catalogItems';
|
|
24
|
+
import { CATALOG_SECTIONS, CatalogSections } from '@spatial-elements/core/catalog/CatalogSections';
|
|
25
|
+
import type { SpatialListItem } from '@spatial-elements/core/spatial-element/types';
|
|
26
|
+
import type { CatalogPage } from '@spatial-elements/core/catalog/catalogPage';
|
|
27
|
+
import type { OnNavigate } from '@sveltejs/kit';
|
|
28
|
+
import {
|
|
29
|
+
STAGE_CONTEXT_KEY,
|
|
30
|
+
type StageContext,
|
|
31
|
+
type StagePanelRegistration,
|
|
32
|
+
type StageViewportRegistration
|
|
33
|
+
} from '@spatial-elements/core/stage/panelContext';
|
|
34
|
+
|
|
35
|
+
interface Props {
|
|
36
|
+
dracoDecoderPath?: string;
|
|
37
|
+
ariaLabel?: string;
|
|
38
|
+
background?: BackgroundSettings;
|
|
39
|
+
pageBackground?: string;
|
|
40
|
+
hdr?: string;
|
|
41
|
+
glb?: string;
|
|
42
|
+
lodPair?: SpatialElementLodPair;
|
|
43
|
+
model?: StageModelSettings;
|
|
44
|
+
camera?: StageCameraSettings;
|
|
45
|
+
interactionTheme?: Partial<StageInteractionTheme>;
|
|
46
|
+
catalog?: CatalogPage;
|
|
47
|
+
children?: Snippet;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let {
|
|
51
|
+
ariaLabel = 'WebGPU 3D stage',
|
|
52
|
+
dracoDecoderPath,
|
|
53
|
+
pageBackground = '#ffffff',
|
|
54
|
+
background,
|
|
55
|
+
hdr,
|
|
56
|
+
glb,
|
|
57
|
+
lodPair,
|
|
58
|
+
model,
|
|
59
|
+
camera,
|
|
60
|
+
interactionTheme,
|
|
61
|
+
catalog,
|
|
62
|
+
children
|
|
63
|
+
}: Props = $props();
|
|
64
|
+
|
|
65
|
+
let displayedSpatialElements = $state<SpatialListItem[]>([]);
|
|
66
|
+
setContext(CATALOG_ITEMS, new CatalogItems((items) => (displayedSpatialElements = items)));
|
|
67
|
+
setContext(CATALOG_SECTIONS, new CatalogSections());
|
|
68
|
+
const catalogSpatialElements = $derived(
|
|
69
|
+
displayedSpatialElements.length ? displayedSpatialElements : (catalog?.spatialElements ?? [])
|
|
70
|
+
);
|
|
71
|
+
const registeredPanels: StagePanelRegistration[] = [];
|
|
72
|
+
const catalogEndpoints = new CatalogEndpointRegistry();
|
|
73
|
+
setContext(CATALOG_ENDPOINTS, catalogEndpoints);
|
|
74
|
+
let registeredViewport: StageViewportRegistration | undefined;
|
|
75
|
+
let stage: HTMLDivElement;
|
|
76
|
+
let virtualScrollSpacer: HTMLDivElement;
|
|
77
|
+
let domLayer: HTMLDivElement;
|
|
78
|
+
let status = $state('Loading stage');
|
|
79
|
+
let showStatus = $state(true);
|
|
80
|
+
let isEnhanced = $state(false);
|
|
81
|
+
let isFallback = $state(true);
|
|
82
|
+
let domLayerHidden = $state(false);
|
|
83
|
+
let domLayerOpacity = $state(1);
|
|
84
|
+
let experience = $state<StageExperience | null>(null);
|
|
85
|
+
let stageState = $state<'loading' | 'enhanced' | 'fallback'>('loading');
|
|
86
|
+
let zoomFocusState = $state<StageZoomFocusState>({
|
|
87
|
+
focus: 0,
|
|
88
|
+
uiFocus: 0,
|
|
89
|
+
uiOpacity: 1,
|
|
90
|
+
minimapFocus: 0
|
|
91
|
+
});
|
|
92
|
+
let visualTestController: StageVisualTestController | undefined;
|
|
93
|
+
let virtualScroll = $state<VirtualScrollController>();
|
|
94
|
+
let transition: CatalogTransition | undefined;
|
|
95
|
+
let initialized: Promise<void> | undefined;
|
|
96
|
+
let navigationGeneration = 0;
|
|
97
|
+
let destroyed = false;
|
|
98
|
+
let nextPageBinding: Promise<void> | undefined;
|
|
99
|
+
let releasePageBinding: (() => void) | undefined;
|
|
100
|
+
let pageBindingConsumed = false;
|
|
101
|
+
let reuseCatalogPage = false;
|
|
102
|
+
let retainedPageSignature: string | undefined;
|
|
103
|
+
const pageSignature = () =>
|
|
104
|
+
JSON.stringify([
|
|
105
|
+
pageBackground,
|
|
106
|
+
background,
|
|
107
|
+
hdr,
|
|
108
|
+
glb,
|
|
109
|
+
lodPair,
|
|
110
|
+
model,
|
|
111
|
+
camera,
|
|
112
|
+
interactionTheme
|
|
113
|
+
]);
|
|
114
|
+
const restingZoomFocus: StageZoomFocusState = {
|
|
115
|
+
focus: 0,
|
|
116
|
+
uiFocus: 0,
|
|
117
|
+
uiOpacity: 1,
|
|
118
|
+
minimapFocus: 0
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
setContext<StageContext>(STAGE_CONTEXT_KEY, {
|
|
122
|
+
prefetchSpatialElement: (config) => experience?.prefetchSpatialElement(config),
|
|
123
|
+
registerPanel(panel) {
|
|
124
|
+
registeredPanels.push(panel);
|
|
125
|
+
|
|
126
|
+
return () => {
|
|
127
|
+
const index = registeredPanels.indexOf(panel);
|
|
128
|
+
if (index >= 0) registeredPanels.splice(index, 1);
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
registerViewport(viewport) {
|
|
132
|
+
registeredViewport = viewport;
|
|
133
|
+
|
|
134
|
+
return () => {
|
|
135
|
+
if (registeredViewport === viewport) registeredViewport = undefined;
|
|
136
|
+
};
|
|
137
|
+
},
|
|
138
|
+
resetView() {
|
|
139
|
+
experience?.resetView();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
onMount(() => {
|
|
144
|
+
document.documentElement.classList.add('stage-route');
|
|
145
|
+
document.body.classList.add('stage-route');
|
|
146
|
+
virtualScroll = new VirtualScrollController(stage, domLayer, virtualScrollSpacer);
|
|
147
|
+
virtualScroll.start();
|
|
148
|
+
transition = new CatalogTransition(stage, catalogEndpoints, {
|
|
149
|
+
captureContentGeometry: (endpoint, secondary) =>
|
|
150
|
+
experience?.captureContentGeometry(endpoint.spatialElementId, secondary) ?? false,
|
|
151
|
+
prepareContentParticipants: (pairs) => experience?.prepareContentParticipants(pairs),
|
|
152
|
+
adoptContentParticipants: (pairs) => experience?.adoptContentParticipants(pairs),
|
|
153
|
+
promoteContentParticipant: (source) => experience?.promoteContentParticipant(source) ?? false,
|
|
154
|
+
geometryPoint: () => experience?.getCatalogGeometryPoint() ?? null,
|
|
155
|
+
adoptGeometry: (destination) => experience?.adoptCatalogPresentation(destination) ?? false,
|
|
156
|
+
beginMotion: () => experience?.beginCatalogMotion() ?? 'asynchronous',
|
|
157
|
+
backgroundPrepared: () => experience?.isCatalogBackgroundPrepared() ?? false,
|
|
158
|
+
captureGeometry: (source) => experience?.captureGeometry(source) ?? false,
|
|
159
|
+
prepareDestination: (destination) =>
|
|
160
|
+
experience?.prepareGeometryDestination(destination) ?? false,
|
|
161
|
+
setGeometryProgress: (progress) => experience?.setCatalogGeometryProgress(progress),
|
|
162
|
+
flushFrame: () => experience?.flushCatalogFrame(),
|
|
163
|
+
finishGeometry: () => {
|
|
164
|
+
try {
|
|
165
|
+
experience?.finishCatalogGeometry();
|
|
166
|
+
} finally {
|
|
167
|
+
if (pageBindingConsumed) releasePageBinding?.();
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
setPresentation: (presentation) => experience?.setCatalogTransitionPresentation(presentation),
|
|
171
|
+
resolveSurface: (element) => experience?.resolvePanelSurface(element) ?? element,
|
|
172
|
+
captureSurface: (element) => experience!.capturePanelSurface(element),
|
|
173
|
+
captureElement: (element) => experience?.capturePanelElement(element)
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
let disposed = false;
|
|
177
|
+
setZoomFocusState(restingZoomFocus);
|
|
178
|
+
|
|
179
|
+
const init = async () => {
|
|
180
|
+
await tick();
|
|
181
|
+
if (disposed) return;
|
|
182
|
+
if (!navigator.gpu) {
|
|
183
|
+
stageState = 'fallback';
|
|
184
|
+
showStatus = false;
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const { StageExperience } = await import('@spatial-elements/core/stage/StageExperience');
|
|
189
|
+
if (disposed) return;
|
|
190
|
+
const panels = getPanelTargets();
|
|
191
|
+
const viewport = getViewportTarget();
|
|
192
|
+
const instance = new StageExperience(stage, {
|
|
193
|
+
dracoDecoderPath,
|
|
194
|
+
catalog: Boolean(catalog),
|
|
195
|
+
heroIsPresented: () =>
|
|
196
|
+
!catalog?.spatialElementId ||
|
|
197
|
+
catalogEndpoints.getComposition({
|
|
198
|
+
brandId: catalog.brandId,
|
|
199
|
+
spatialElementId: catalog.spatialElementId
|
|
200
|
+
}) !== 'dock',
|
|
201
|
+
background,
|
|
202
|
+
pageBackground,
|
|
203
|
+
hdr,
|
|
204
|
+
glb,
|
|
205
|
+
lodPair,
|
|
206
|
+
model,
|
|
207
|
+
camera,
|
|
208
|
+
interactionTheme,
|
|
209
|
+
panels,
|
|
210
|
+
viewport,
|
|
211
|
+
enableSpaceMouse: !isStageVisualTestMode(),
|
|
212
|
+
onDeviceLost: () => {
|
|
213
|
+
if (disposed || experience !== instance) return;
|
|
214
|
+
navigationGeneration += 1;
|
|
215
|
+
transition?.cancel();
|
|
216
|
+
experience = null;
|
|
217
|
+
try {
|
|
218
|
+
instance.dispose();
|
|
219
|
+
} finally {
|
|
220
|
+
setZoomFocusState(restingZoomFocus);
|
|
221
|
+
isEnhanced = false;
|
|
222
|
+
isFallback = true;
|
|
223
|
+
stageState = 'fallback';
|
|
224
|
+
showStatus = false;
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
onZoomFocusChange: (focusState) => {
|
|
228
|
+
setZoomFocusState(focusState);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
experience = instance;
|
|
232
|
+
await instance.init();
|
|
233
|
+
|
|
234
|
+
if (disposed || experience !== instance) {
|
|
235
|
+
instance.dispose();
|
|
236
|
+
if (experience === instance) experience = null;
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
isEnhanced = true;
|
|
241
|
+
isFallback = false;
|
|
242
|
+
showStatus = false;
|
|
243
|
+
stageState = 'enhanced';
|
|
244
|
+
registerSpatialElements();
|
|
245
|
+
if (catalog) void instance.setCatalogSpatialElements(catalog.brandId, catalogSpatialElements);
|
|
246
|
+
|
|
247
|
+
if (isStageVisualTestMode()) {
|
|
248
|
+
visualTestController = createVisualTestController();
|
|
249
|
+
window.__stageVisualTest = visualTestController;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
initialized = init().catch((error: unknown) => {
|
|
254
|
+
if (disposed) return;
|
|
255
|
+
console.error(error);
|
|
256
|
+
experience?.dispose();
|
|
257
|
+
experience = null;
|
|
258
|
+
status = error instanceof Error ? error.message : 'Unable to initialize WebGPU stage';
|
|
259
|
+
isEnhanced = false;
|
|
260
|
+
isFallback = true;
|
|
261
|
+
stageState = 'fallback';
|
|
262
|
+
setZoomFocusState(restingZoomFocus);
|
|
263
|
+
showStatus = false;
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
return () => {
|
|
267
|
+
virtualScroll?.destroy();
|
|
268
|
+
virtualScroll = undefined;
|
|
269
|
+
destroyed = true;
|
|
270
|
+
releasePageBinding?.();
|
|
271
|
+
navigationGeneration += 1;
|
|
272
|
+
transition?.dispose();
|
|
273
|
+
document.documentElement.classList.remove('stage-route');
|
|
274
|
+
document.body.classList.remove('stage-route');
|
|
275
|
+
disposed = true;
|
|
276
|
+
experience?.dispose();
|
|
277
|
+
experience = null;
|
|
278
|
+
setZoomFocusState(restingZoomFocus);
|
|
279
|
+
if (window.__stageVisualTest === visualTestController) {
|
|
280
|
+
delete window.__stageVisualTest;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
$effect(() => {
|
|
286
|
+
const spatialElements = catalogSpatialElements;
|
|
287
|
+
if (experience && catalog && isEnhanced) {
|
|
288
|
+
registerSpatialElements();
|
|
289
|
+
void experience.setCatalogSpatialElements(catalog.brandId, spatialElements);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
function registerSpatialElements() {
|
|
293
|
+
if (!catalog || !experience) return;
|
|
294
|
+
for (const spatialElement of catalogSpatialElements) {
|
|
295
|
+
if (spatialElement.stage)
|
|
296
|
+
experience.spatialElements.setManifest(
|
|
297
|
+
createStageSpatialElementAssetManifest(catalog.brandId, spatialElement.id, spatialElement.stage)
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
if (catalog.spatialElementId && catalog.spatialElementStage) {
|
|
301
|
+
experience.spatialElements.setManifest(
|
|
302
|
+
createStageSpatialElementAssetManifest(catalog.brandId, catalog.spatialElementId, catalog.spatialElementStage)
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function interruptNavigation() {
|
|
308
|
+
navigationGeneration += 1;
|
|
309
|
+
reuseCatalogPage = false;
|
|
310
|
+
transition?.cancel();
|
|
311
|
+
if (pageBindingConsumed) releasePageBinding?.();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
function supersedeNavigation(destination: URL) {
|
|
315
|
+
navigationGeneration += 1;
|
|
316
|
+
transition?.supersede(destination);
|
|
317
|
+
if (pageBindingConsumed) releasePageBinding?.();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
let navigationTimings = { dataReady: 0, captured: 0, restoring: 0, bound: 0 };
|
|
321
|
+
function captureNavigation(navigation: OnNavigate) {
|
|
322
|
+
navigationTimings = { dataReady: performance.now(), captured: 0, restoring: 0, bound: 0 };
|
|
323
|
+
navigationGeneration += 1;
|
|
324
|
+
reuseCatalogPage = Boolean(
|
|
325
|
+
navigation.from &&
|
|
326
|
+
navigation.to &&
|
|
327
|
+
transition?.capture(navigation.from.url, navigation.to.url, navigation.type)
|
|
328
|
+
);
|
|
329
|
+
navigationTimings.captured = performance.now();
|
|
330
|
+
if (reuseCatalogPage) {
|
|
331
|
+
retainedPageSignature = pageSignature();
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
experience?.releasePage();
|
|
335
|
+
setZoomFocusState(restingZoomFocus);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
async function restoreNavigation() {
|
|
339
|
+
navigationTimings.restoring = performance.now();
|
|
340
|
+
const generation = navigationGeneration;
|
|
341
|
+
await initialized;
|
|
342
|
+
await tick();
|
|
343
|
+
if (destroyed || generation !== navigationGeneration || !experience) return;
|
|
344
|
+
try {
|
|
345
|
+
if (reuseCatalogPage) {
|
|
346
|
+
reuseCatalogPage = false;
|
|
347
|
+
if (retainedPageSignature === pageSignature()) {
|
|
348
|
+
await transition?.play();
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
transition?.cancel();
|
|
352
|
+
}
|
|
353
|
+
if (nextPageBinding) {
|
|
354
|
+
const pending = nextPageBinding;
|
|
355
|
+
nextPageBinding = undefined;
|
|
356
|
+
pageBindingConsumed = true;
|
|
357
|
+
await pending;
|
|
358
|
+
if (destroyed || generation !== navigationGeneration) return;
|
|
359
|
+
}
|
|
360
|
+
registerSpatialElements();
|
|
361
|
+
const catalogReady = catalog
|
|
362
|
+
? experience.setCatalogSpatialElements(catalog.brandId, catalogSpatialElements)
|
|
363
|
+
: undefined;
|
|
364
|
+
await experience.updatePage({
|
|
365
|
+
catalog: Boolean(catalog),
|
|
366
|
+
heroIsPresented: () =>
|
|
367
|
+
!catalog?.spatialElementId ||
|
|
368
|
+
catalogEndpoints.getComposition({
|
|
369
|
+
brandId: catalog.brandId,
|
|
370
|
+
spatialElementId: catalog.spatialElementId
|
|
371
|
+
}) !== 'dock',
|
|
372
|
+
deferDetailPreparation: Boolean(
|
|
373
|
+
catalog?.spatialElementId &&
|
|
374
|
+
catalogEndpoints.getComposition({
|
|
375
|
+
brandId: catalog.brandId,
|
|
376
|
+
spatialElementId: catalog.spatialElementId
|
|
377
|
+
}) === 'dock'
|
|
378
|
+
),
|
|
379
|
+
background,
|
|
380
|
+
pageBackground,
|
|
381
|
+
hdr,
|
|
382
|
+
glb,
|
|
383
|
+
lodPair,
|
|
384
|
+
model,
|
|
385
|
+
camera,
|
|
386
|
+
interactionTheme,
|
|
387
|
+
panels: getPanelTargets(),
|
|
388
|
+
viewport: getViewportTarget()
|
|
389
|
+
});
|
|
390
|
+
if (destroyed || generation !== navigationGeneration) return;
|
|
391
|
+
if (experience.getSpatialCapture()) {
|
|
392
|
+
await Promise.race([
|
|
393
|
+
catalogReady,
|
|
394
|
+
new Promise<void>((resolve) => setTimeout(resolve, 500))
|
|
395
|
+
]);
|
|
396
|
+
if (destroyed || generation !== navigationGeneration) return;
|
|
397
|
+
}
|
|
398
|
+
isEnhanced = true;
|
|
399
|
+
isFallback = false;
|
|
400
|
+
stageState = 'enhanced';
|
|
401
|
+
navigationTimings.bound = performance.now();
|
|
402
|
+
await transition?.play();
|
|
403
|
+
} catch (error) {
|
|
404
|
+
if (destroyed || generation !== navigationGeneration) return;
|
|
405
|
+
transition?.cancel();
|
|
406
|
+
try {
|
|
407
|
+
experience.discardFailedPage();
|
|
408
|
+
} catch (cleanupError) {
|
|
409
|
+
// Even a GPU cleanup failure must reveal the semantic fallback page.
|
|
410
|
+
console.error('Unable to release failed catalog presentation', cleanupError);
|
|
411
|
+
}
|
|
412
|
+
console.error('Unable to bind catalog presentation', error);
|
|
413
|
+
setZoomFocusState(restingZoomFocus);
|
|
414
|
+
isEnhanced = false;
|
|
415
|
+
isFallback = true;
|
|
416
|
+
stageState = 'fallback';
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
function setZoomFocusState(focusState: StageZoomFocusState) {
|
|
421
|
+
const clampedFocus = clampFinite(focusState.focus, 0);
|
|
422
|
+
const minimapFocus = clampFinite(focusState.minimapFocus, 0);
|
|
423
|
+
const domOpacity = clampFinite(focusState.uiOpacity, 1);
|
|
424
|
+
|
|
425
|
+
domLayerOpacity = domOpacity;
|
|
426
|
+
domLayerHidden = domOpacity <= 0.001;
|
|
427
|
+
zoomFocusState = {
|
|
428
|
+
focus: clampedFocus,
|
|
429
|
+
uiFocus: clampFinite(focusState.uiFocus, 0),
|
|
430
|
+
uiOpacity: domOpacity,
|
|
431
|
+
minimapFocus
|
|
432
|
+
};
|
|
433
|
+
// Focus diagnostics remain in data attributes. Do not publish unused inherited
|
|
434
|
+
// CSS variables here: updating them invalidates styles throughout the page.
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function createVisualTestController(): StageVisualTestController {
|
|
438
|
+
const settle = async (frames = 12) => {
|
|
439
|
+
experience?.advanceVisualTestFrames(frames);
|
|
440
|
+
await Promise.resolve();
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
const setView = async (view: StageVisualTestView) => {
|
|
444
|
+
experience?.setVisualTestView(view);
|
|
445
|
+
await settle(18);
|
|
446
|
+
};
|
|
447
|
+
const setSpaceMouseZoom = async (zoom: number) => {
|
|
448
|
+
experience?.setVisualTestSpaceMouseZoom(zoom);
|
|
449
|
+
await settle(120);
|
|
450
|
+
};
|
|
451
|
+
const driveSpaceMouseZoom = async (zoom: number, frames = 60) => {
|
|
452
|
+
experience?.driveVisualTestSpaceMouseZoom(zoom, frames);
|
|
453
|
+
await Promise.resolve();
|
|
454
|
+
};
|
|
455
|
+
const stopSpaceMouse = async () => {
|
|
456
|
+
experience?.stopVisualTestSpaceMouseMotion();
|
|
457
|
+
await settle(120);
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
return {
|
|
461
|
+
loseDevice: () => experience?.loseDeviceForTest(),
|
|
462
|
+
getCarouselStats: () => experience?.getCarouselStats() ?? null,
|
|
463
|
+
getCatalogStats: () => experience?.assets.getStats() ?? null,
|
|
464
|
+
getCatalogEndpoints: () => catalogEndpoints.getSnapshot(),
|
|
465
|
+
getCatalogOwnership: () => transition?.getOwnership() ?? null,
|
|
466
|
+
getNavigationTimings: () => ({ ...navigationTimings }),
|
|
467
|
+
captureHeroPresentation: () => experience?.captureHeroPresentation() ?? false,
|
|
468
|
+
getSpatialCapture: () => experience?.getSpatialCapture() ?? null,
|
|
469
|
+
releaseSpatialCapture: () => experience?.releaseSpatialCapture(),
|
|
470
|
+
registerCatalogEndpoint: (address, element) => catalogEndpoints.register(address, element),
|
|
471
|
+
getCatalogPresentation: () => experience?.getCatalogPresentation() ?? null,
|
|
472
|
+
holdNextPageBinding: () => {
|
|
473
|
+
releasePageBinding?.();
|
|
474
|
+
pageBindingConsumed = false;
|
|
475
|
+
nextPageBinding = new Promise<void>((resolve) => {
|
|
476
|
+
releasePageBinding = () => {
|
|
477
|
+
nextPageBinding = undefined;
|
|
478
|
+
pageBindingConsumed = false;
|
|
479
|
+
releasePageBinding = undefined;
|
|
480
|
+
resolve();
|
|
481
|
+
};
|
|
482
|
+
});
|
|
483
|
+
},
|
|
484
|
+
releasePageBinding: () => releasePageBinding?.(),
|
|
485
|
+
setView,
|
|
486
|
+
setSpaceMouseZoom,
|
|
487
|
+
driveSpaceMouseZoom,
|
|
488
|
+
stopSpaceMouse,
|
|
489
|
+
getMinimapRect: () => experience?.getVisualTestMinimapRect() ?? null,
|
|
490
|
+
getModelRect: () => experience?.getVisualTestModelRect() ?? null,
|
|
491
|
+
getMinimapModelRect: () => experience?.getVisualTestMinimapModelRect() ?? null,
|
|
492
|
+
getMinimapOrientation: () => experience?.getVisualTestMinimapOrientation() ?? null,
|
|
493
|
+
getMinimapRenderStats: () =>
|
|
494
|
+
experience?.getVisualTestMinimapRenderStats() ?? {
|
|
495
|
+
overlayCapturePasses: 0,
|
|
496
|
+
depthNear: 0,
|
|
497
|
+
depthFar: 0,
|
|
498
|
+
viewportRingInForeground: false
|
|
499
|
+
},
|
|
500
|
+
getRenderTargetStats: () =>
|
|
501
|
+
experience?.getVisualTestRenderTargetStats() ?? {
|
|
502
|
+
liveTargets: 0,
|
|
503
|
+
targets: [],
|
|
504
|
+
canvases: [],
|
|
505
|
+
creations: 0,
|
|
506
|
+
resizes: 0,
|
|
507
|
+
warmups: 0,
|
|
508
|
+
activeScale: 0
|
|
509
|
+
},
|
|
510
|
+
getVisibilityStats: () =>
|
|
511
|
+
experience?.getVisualTestVisibilityStats() ?? {
|
|
512
|
+
stageViewportVisible: false,
|
|
513
|
+
visiblePanels: 0,
|
|
514
|
+
visibleMinimaps: 0,
|
|
515
|
+
stageModelRenderPasses: 0,
|
|
516
|
+
panelBlurRenderPasses: 0,
|
|
517
|
+
panelSceneRenderPasses: 0,
|
|
518
|
+
minimapSceneRenderPasses: 0
|
|
519
|
+
},
|
|
520
|
+
reset: () => setView({ zoom: 0 }),
|
|
521
|
+
settle,
|
|
522
|
+
getState: () => ({ ...zoomFocusState })
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function clampFinite(value: number, fallback: number) {
|
|
527
|
+
return Number.isFinite(value) ? Math.min(Math.max(value, 0), 1) : fallback;
|
|
528
|
+
}
|
|
529
|
+
function getViewportTarget(): StageViewportTarget | undefined {
|
|
530
|
+
const element = registeredViewport?.getElement();
|
|
531
|
+
return element ? { element } : undefined;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
function getPanelTargets() {
|
|
535
|
+
const targets: StagePanelTarget[] = [];
|
|
536
|
+
|
|
537
|
+
registeredPanels.forEach((panel) => {
|
|
538
|
+
const frame = panel.getFrameElement();
|
|
539
|
+
const content = panel.getElement();
|
|
540
|
+
const surfaceElement = panel.getSurfaceElement();
|
|
541
|
+
if (!frame || !content || !surfaceElement) return;
|
|
542
|
+
|
|
543
|
+
targets.push({
|
|
544
|
+
content,
|
|
545
|
+
contentInset: panel.getContentInset(),
|
|
546
|
+
frame,
|
|
547
|
+
getMinimapDockProgress: panel.getMinimapDockProgress,
|
|
548
|
+
getMinimapModelScale: panel.getMinimapModelScale,
|
|
549
|
+
getMinimapModelTop: panel.getMinimapModelTop,
|
|
550
|
+
getSurfaceOpacity: panel.getSurfaceOpacity,
|
|
551
|
+
minimap: panel.getMinimapOptions(),
|
|
552
|
+
options: panel.getOptions(),
|
|
553
|
+
surface: panel.getSurface(),
|
|
554
|
+
surfaceElement,
|
|
555
|
+
pointerReactive: panel.getPointerReactive()
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
return targets;
|
|
560
|
+
}
|
|
561
|
+
</script>
|
|
562
|
+
|
|
563
|
+
{#if catalog}
|
|
564
|
+
<ScrollNavigationBridge
|
|
565
|
+
controller={virtualScroll}
|
|
566
|
+
onCapture={captureNavigation}
|
|
567
|
+
onSupersede={supersedeNavigation}
|
|
568
|
+
onInterrupt={interruptNavigation}
|
|
569
|
+
onRestored={restoreNavigation}
|
|
570
|
+
/>
|
|
571
|
+
{/if}
|
|
572
|
+
|
|
573
|
+
<div
|
|
574
|
+
bind:this={stage}
|
|
575
|
+
style:--stage-page-background={pageBackground}
|
|
576
|
+
class="stage"
|
|
577
|
+
class:stage-enhanced={isEnhanced}
|
|
578
|
+
class:stage-fallback={isFallback}
|
|
579
|
+
style:--stage-dom-opacity={domLayerOpacity}
|
|
580
|
+
data-stage-state={stageState}
|
|
581
|
+
data-stage-focus={zoomFocusState.focus.toFixed(3)}
|
|
582
|
+
data-stage-ui-focus={zoomFocusState.uiFocus.toFixed(3)}
|
|
583
|
+
data-stage-minimap-focus={zoomFocusState.minimapFocus.toFixed(3)}
|
|
584
|
+
data-stage-dom-opacity={zoomFocusState.uiOpacity.toFixed(3)}
|
|
585
|
+
aria-label={ariaLabel}
|
|
586
|
+
>
|
|
587
|
+
<div bind:this={virtualScrollSpacer} class="stage-virtual-scroll-spacer" aria-hidden="true"></div>
|
|
588
|
+
|
|
589
|
+
<div class="stage-virtual-viewport">
|
|
590
|
+
<div
|
|
591
|
+
bind:this={domLayer}
|
|
592
|
+
class="stage-dom-layer"
|
|
593
|
+
class:stage-dom-hidden={domLayerHidden}
|
|
594
|
+
aria-hidden={domLayerHidden}
|
|
595
|
+
>
|
|
596
|
+
{@render children?.()}
|
|
597
|
+
</div>
|
|
598
|
+
</div>
|
|
599
|
+
|
|
600
|
+
{#if showStatus}
|
|
601
|
+
<div class="stage-status">{status}</div>
|
|
602
|
+
{/if}
|
|
603
|
+
</div>
|
|
604
|
+
|
|
605
|
+
<style>
|
|
606
|
+
:global(html.stage-route),
|
|
607
|
+
:global(body.stage-route) {
|
|
608
|
+
margin: 0;
|
|
609
|
+
min-width: 100%;
|
|
610
|
+
min-height: 100%;
|
|
611
|
+
background: #ffffff;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
:global(body.stage-route) {
|
|
615
|
+
overflow-x: hidden;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
.stage {
|
|
619
|
+
position: relative;
|
|
620
|
+
min-height: 100vh;
|
|
621
|
+
width: 100%;
|
|
622
|
+
overflow: visible;
|
|
623
|
+
background: var(--stage-page-background, #ffffff);
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
.stage-virtual-scroll-spacer {
|
|
627
|
+
display: none;
|
|
628
|
+
width: 1px;
|
|
629
|
+
min-height: 100vh;
|
|
630
|
+
pointer-events: none;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
.stage-virtual-viewport {
|
|
634
|
+
position: relative;
|
|
635
|
+
z-index: 1;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
.stage:global(.stage-virtual-scroll-active) .stage-virtual-scroll-spacer {
|
|
639
|
+
display: block;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
.stage:global(.stage-virtual-scroll-active) .stage-virtual-viewport {
|
|
643
|
+
position: fixed;
|
|
644
|
+
inset: 0;
|
|
645
|
+
/* Clip without creating a second, programmatically scrollable container. */
|
|
646
|
+
overflow: clip;
|
|
647
|
+
pointer-events: none;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
.stage :global(.stage-webgpu-background),
|
|
651
|
+
.stage :global(.stage-webgpu-carousel-rear),
|
|
652
|
+
.stage :global(.stage-webgpu-foreground) {
|
|
653
|
+
position: fixed;
|
|
654
|
+
inset: 0;
|
|
655
|
+
display: block;
|
|
656
|
+
width: 100vw;
|
|
657
|
+
height: 100vh;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
.stage :global(.stage-webgpu-background) {
|
|
661
|
+
z-index: 0;
|
|
662
|
+
touch-action: pan-y;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
.stage :global(.stage-webgpu-carousel-rear) {
|
|
666
|
+
z-index: 0;
|
|
667
|
+
pointer-events: none;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
.stage :global(.stage-webgpu-foreground) {
|
|
671
|
+
/* Keep rendered minimaps above the fixed element header (z-index 20). */
|
|
672
|
+
z-index: 21;
|
|
673
|
+
pointer-events: none;
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
.stage :global(.stage-css3d),
|
|
677
|
+
.stage :global(.stage-css3d-flat) {
|
|
678
|
+
z-index: 3;
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
.stage :global(.stage-panel-native) {
|
|
682
|
+
z-index: 2;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
.stage-dom-layer {
|
|
686
|
+
position: relative;
|
|
687
|
+
z-index: 1;
|
|
688
|
+
pointer-events: none;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
.stage:global(.stage-virtual-scroll-active) .stage-dom-layer {
|
|
692
|
+
position: absolute;
|
|
693
|
+
top: 0;
|
|
694
|
+
left: 0;
|
|
695
|
+
width: 100%;
|
|
696
|
+
min-height: 100vh;
|
|
697
|
+
will-change: transform;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/*
|
|
701
|
+
* Fade ordinary page surfaces individually. Keeping opacity off this shared
|
|
702
|
+
* ancestor lets nested backdrop filters sample the WebGPU canvas at z-index 0.
|
|
703
|
+
*/
|
|
704
|
+
.stage :global([data-stage-dom-content]) {
|
|
705
|
+
opacity: var(--stage-dom-opacity, 1);
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
.stage-dom-layer.stage-dom-hidden :global([data-stage-dom-content]) {
|
|
709
|
+
visibility: hidden;
|
|
710
|
+
pointer-events: none !important;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
.stage-dom-layer.stage-dom-hidden
|
|
714
|
+
:global([data-stage-panel-fallback]:not([data-stage-panel-minimap])) {
|
|
715
|
+
pointer-events: none !important;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
:global(.stage.stage-enhanced [data-stage-panel-fallback][data-stage-panel-bound]) {
|
|
719
|
+
visibility: hidden !important;
|
|
720
|
+
opacity: 0 !important;
|
|
721
|
+
pointer-events: none !important;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/* A failed binding may leave pixels in either canvas; the poster owns fallback paint. */
|
|
725
|
+
.stage.stage-fallback :global(.stage-webgpu-background),
|
|
726
|
+
.stage.stage-fallback :global(.stage-webgpu-carousel-rear),
|
|
727
|
+
.stage.stage-fallback :global(.stage-webgpu-foreground) {
|
|
728
|
+
visibility: hidden !important;
|
|
729
|
+
pointer-events: none !important;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
.stage-status {
|
|
733
|
+
position: fixed;
|
|
734
|
+
left: 16px;
|
|
735
|
+
bottom: 16px;
|
|
736
|
+
z-index: 3;
|
|
737
|
+
max-width: min(420px, calc(100vw - 32px));
|
|
738
|
+
padding: 8px 10px;
|
|
739
|
+
border: 1px solid rgb(255 255 255 / 0.18);
|
|
740
|
+
border-radius: 6px;
|
|
741
|
+
color: #f5f7fb;
|
|
742
|
+
background: rgb(5 6 9 / 0.72);
|
|
743
|
+
font:
|
|
744
|
+
13px/1.35 system-ui,
|
|
745
|
+
sans-serif;
|
|
746
|
+
}
|
|
747
|
+
</style>
|