@spatial-elements/core 1.0.0-beta.5 → 1.0.0-beta.6

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.
Files changed (73) hide show
  1. package/dist/catalog/CarouselGlassCompositor.d.ts +7 -2
  2. package/dist/catalog/CarouselGlassCompositor.d.ts.map +1 -1
  3. package/dist/catalog/CarouselGlassCompositor.js +85 -24
  4. package/dist/catalog/CarouselGlassCompositor.js.map +1 -1
  5. package/dist/catalog/CarouselGround.d.ts +21 -0
  6. package/dist/catalog/CarouselGround.d.ts.map +1 -0
  7. package/dist/catalog/CarouselGround.js +107 -0
  8. package/dist/catalog/CarouselGround.js.map +1 -0
  9. package/dist/catalog/CatalogDepthBlur.d.ts +26 -0
  10. package/dist/catalog/CatalogDepthBlur.d.ts.map +1 -0
  11. package/dist/catalog/CatalogDepthBlur.js +87 -0
  12. package/dist/catalog/CatalogDepthBlur.js.map +1 -0
  13. package/dist/catalog/CatalogModelOutline.d.ts +31 -0
  14. package/dist/catalog/CatalogModelOutline.d.ts.map +1 -0
  15. package/dist/catalog/CatalogModelOutline.js +127 -0
  16. package/dist/catalog/CatalogModelOutline.js.map +1 -0
  17. package/dist/catalog/CatalogSpatialElementLayer.d.ts +29 -2
  18. package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -1
  19. package/dist/catalog/CatalogSpatialElementLayer.js +170 -41
  20. package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
  21. package/dist/catalog/CatalogTransition.d.ts.map +1 -1
  22. package/dist/catalog/CatalogTransition.js +49 -4
  23. package/dist/catalog/CatalogTransition.js.map +1 -1
  24. package/dist/catalog/SpatialGeometryCapture.d.ts +9 -0
  25. package/dist/catalog/SpatialGeometryCapture.d.ts.map +1 -1
  26. package/dist/catalog/SpatialGeometryCapture.js +11 -1
  27. package/dist/catalog/SpatialGeometryCapture.js.map +1 -1
  28. package/dist/catalog/cardModelFit.d.ts +7 -0
  29. package/dist/catalog/cardModelFit.d.ts.map +1 -0
  30. package/dist/catalog/cardModelFit.js +16 -0
  31. package/dist/catalog/cardModelFit.js.map +1 -0
  32. package/dist/catalog/cardProjection.d.ts +8 -0
  33. package/dist/catalog/cardProjection.d.ts.map +1 -0
  34. package/dist/catalog/cardProjection.js +51 -0
  35. package/dist/catalog/cardProjection.js.map +1 -0
  36. package/dist/catalog/carouselMotion.d.ts +35 -0
  37. package/dist/catalog/carouselMotion.d.ts.map +1 -1
  38. package/dist/catalog/carouselMotion.js +85 -4
  39. package/dist/catalog/carouselMotion.js.map +1 -1
  40. package/dist/catalog/carouselProximity.d.ts +11 -0
  41. package/dist/catalog/carouselProximity.d.ts.map +1 -0
  42. package/dist/catalog/carouselProximity.js +13 -0
  43. package/dist/catalog/carouselProximity.js.map +1 -0
  44. package/dist/catalog/carouselSupport.d.ts +4 -0
  45. package/dist/catalog/carouselSupport.d.ts.map +1 -0
  46. package/dist/catalog/carouselSupport.js +30 -0
  47. package/dist/catalog/carouselSupport.js.map +1 -0
  48. package/dist/catalog/catalogPose.d.ts +36 -6
  49. package/dist/catalog/catalogPose.d.ts.map +1 -1
  50. package/dist/catalog/catalogPose.js +79 -23
  51. package/dist/catalog/catalogPose.js.map +1 -1
  52. package/dist/stage/LiquidGlassPanel.d.ts +2 -0
  53. package/dist/stage/LiquidGlassPanel.d.ts.map +1 -1
  54. package/dist/stage/LiquidGlassPanel.js +8 -1
  55. package/dist/stage/LiquidGlassPanel.js.map +1 -1
  56. package/dist/stage/PanelPresentationController.d.ts.map +1 -1
  57. package/dist/stage/PanelPresentationController.js +7 -0
  58. package/dist/stage/PanelPresentationController.js.map +1 -1
  59. package/dist/stage/StageExperience.d.ts +40 -0
  60. package/dist/stage/StageExperience.d.ts.map +1 -1
  61. package/dist/stage/StageExperience.js +11 -13
  62. package/dist/stage/StageExperience.js.map +1 -1
  63. package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
  64. package/dist/stage/StageRenderPipeline.js +11 -62
  65. package/dist/stage/StageRenderPipeline.js.map +1 -1
  66. package/dist/stage/interactionOutline.d.ts +14 -0
  67. package/dist/stage/interactionOutline.d.ts.map +1 -0
  68. package/dist/stage/interactionOutline.js +81 -0
  69. package/dist/stage/interactionOutline.js.map +1 -0
  70. package/dist/stage/panelContext.d.ts +2 -0
  71. package/dist/stage/panelContext.d.ts.map +1 -1
  72. package/dist/stage/panelContext.js.map +1 -1
  73. package/package.json +1 -1
@@ -1,4 +1,8 @@
1
1
  import { CatalogGeometryFade } from './CatalogGeometryFade.js';
2
+ import { cardModelFit } from './cardModelFit.js';
3
+ import { CatalogDepthBlur } from './CatalogDepthBlur.js';
4
+ import { CatalogModelOutline } from './CatalogModelOutline.js';
5
+ import { DEFAULT_INTERACTION_THEME } from '../stage/stageConstants.js';
2
6
  import { recordCarouselPanel } from './carouselPanelProjection.js';
3
7
  import { prepareSpatialElementFrame } from '../stage/spatialElementFrame.js';
4
8
  import { resolveSpatialElementLodPair } from './spatialElementLodPair.js';
@@ -13,6 +17,9 @@ import { applyCatalogMaterialOpacity, captureCatalogMaterialOpacity } from './ca
13
17
  import { CATALOG_POSE_CHANGED } from './catalogPose.js';
14
18
  import { getProjectiveCssMatrix3d } from '../stage/cssProjection.js';
15
19
  import { CarouselGlassCompositor } from './CarouselGlassCompositor.js';
20
+ import { CarouselGround } from './CarouselGround.js';
21
+ import { carouselProximity } from './carouselProximity.js';
22
+ import { carouselSupport } from './carouselSupport.js';
16
23
  /** Removes irrelevant homogeneous scale so the reference point follows a continuous screen path. */
17
24
  export function normalizeSpatialElementClipMatrix(matrix, point) {
18
25
  const clip = new THREE.Vector4(point.x, point.y, point.z, 1).applyMatrix4(matrix);
@@ -55,9 +62,13 @@ export function getSpatialElementHandoffProjection(sourceClip, targetClip, progr
55
62
  export class CatalogSpatialElementLayer {
56
63
  assets;
57
64
  invalidate;
65
+ interactionTheme;
58
66
  getRenderTargets() {
59
67
  return [
68
+ ...this.outline.getRenderTargets(),
69
+ ...this.depthBlur.getRenderTargets(),
60
70
  ...this.glass.getRenderTargets(),
71
+ ...this.ground.getRenderTargets(),
61
72
  ...this.geometryFade.getRenderTargets(),
62
73
  ...(this.handoff?.blend?.getRenderTargets() ?? [])
63
74
  ];
@@ -71,24 +82,33 @@ export class CatalogSpatialElementLayer {
71
82
  visible: [...this.actors.values()].filter((actor) => actor.root.visible).length,
72
83
  passes: this.passes,
73
84
  glass: this.glass.getStats(),
85
+ ground: this.ground.getStats(),
86
+ depthBlur: this.depthBlur.getStats(),
87
+ outline: this.outline.getStats(),
74
88
  actors: [...this.actors.values()].map((actor) => ({
75
89
  spatialElementId: actor.spatialElementId,
76
90
  band: actor.band,
77
91
  clip: actor.clip ? { ...actor.clip } : undefined,
78
92
  opacity: this.exitOpacity * (actor.materials[0]?.material.opacity ?? 0),
79
93
  materialOpacity: actor.materials[0]?.material.opacity ?? 0,
80
- depthWrite: actor.materials[0]?.material.depthWrite
94
+ depthWrite: actor.materials[0]?.material.depthWrite,
95
+ modelScale: actor.view.scale.x, modelDepth: actor.view.position.z,
96
+ blur: actor.blur ?? 0,
97
+ hover: actor.hover,
98
+ proximityTilt: { x: actor.rotationX, y: actor.rotationY }
81
99
  }))
82
100
  };
83
101
  }
84
- glass = new CarouselGlassCompositor();
102
+ depthBlur = new CatalogDepthBlur();
103
+ outline = new CatalogModelOutline();
104
+ glass = new CarouselGlassCompositor(this.depthBlur);
105
+ ground = new CarouselGround();
85
106
  geometryFade = new CatalogGeometryFade();
86
107
  handoffScene = new THREE.Scene();
87
108
  camera = new THREE.PerspectiveCamera(45, 1, 1, 4000);
88
109
  // The carousel sits ~2500 units from the lens. A near plane of 1 wastes depth
89
110
  // precision and makes closely spaced CAD surfaces fight after the longer-lens change.
90
111
  carouselCamera = new THREE.PerspectiveCamera(45, 1, 250, 6000);
91
- carouselFog = new THREE.Fog(0xffffff, 2700, 4000);
92
112
  handoffCamera = new THREE.PerspectiveCamera();
93
113
  actors = new Map();
94
114
  requests = new Set();
@@ -97,7 +117,7 @@ export class CatalogSpatialElementLayer {
97
117
  loadingKeys = new Set();
98
118
  failedKeys = new Set();
99
119
  motion = window.matchMedia('(prefers-reduced-motion: reduce)');
100
- pointer = { x: 0, y: 0, active: false };
120
+ pointer = { x: 0, y: 0, active: false, pressed: false };
101
121
  handoff;
102
122
  handoffPoint;
103
123
  generation = 0;
@@ -128,11 +148,18 @@ export class CatalogSpatialElementLayer {
128
148
  pointerDown = (event) => {
129
149
  if (event.pointerType !== 'mouse')
130
150
  this.pointerLeave();
151
+ this.pointer.pressed = true;
152
+ this.invalidate();
153
+ };
154
+ pointerUp = () => {
155
+ this.pointer.pressed = false;
156
+ this.invalidate();
131
157
  };
132
158
  pointerLeave = () => {
133
159
  if (!this.pointer.active)
134
160
  return;
135
161
  this.pointer.active = false;
162
+ this.pointer.pressed = false;
136
163
  this.invalidate();
137
164
  };
138
165
  resize = () => {
@@ -143,12 +170,12 @@ export class CatalogSpatialElementLayer {
143
170
  motionChange = () => this.invalidate();
144
171
  setPageBackground(value) {
145
172
  this.scene.fog.color.set(value);
146
- this.carouselFog.color.set(value);
147
173
  this.invalidate();
148
174
  }
149
- constructor(assets, invalidate) {
175
+ constructor(assets, invalidate, interactionTheme = () => DEFAULT_INTERACTION_THEME) {
150
176
  this.assets = assets;
151
177
  this.invalidate = invalidate;
178
+ this.interactionTheme = interactionTheme;
152
179
  this.scene.environmentIntensity = 0.5;
153
180
  this.scene.fog = new THREE.Fog(0xffffff, 1200, 2500);
154
181
  this.handoffScene.fog = this.scene.fog;
@@ -159,6 +186,10 @@ export class CatalogSpatialElementLayer {
159
186
  this.camera.updateMatrixWorld();
160
187
  window.addEventListener('pointermove', this.pointerMove, { passive: true });
161
188
  window.addEventListener('pointerdown', this.pointerDown, { capture: true, passive: true });
189
+ window.addEventListener('pointerup', this.pointerUp, { passive: true });
190
+ window.addEventListener('pointercancel', this.pointerUp, { passive: true });
191
+ window.addEventListener('focusin', this.motionChange);
192
+ window.addEventListener('focusout', this.motionChange);
162
193
  window.addEventListener('pointerleave', this.pointerLeave);
163
194
  window.addEventListener('blur', this.pointerLeave);
164
195
  window.addEventListener('resize', this.resize);
@@ -222,9 +253,10 @@ export class CatalogSpatialElementLayer {
222
253
  const list = document.querySelector(`[data-catalog-list][data-brand-id="${CSS.escape(brandId)}"]`);
223
254
  const slot = list?.querySelector(`[data-catalog-geometry][data-spatial-element-id="${CSS.escape(spatialElement.id)}"]${spatialElement.occurrence ? `[data-catalog-occurrence="${CSS.escape(spatialElement.occurrence)}"]` : ''}`);
224
255
  const rect = slot?.getBoundingClientRect();
256
+ const margin = spatialElement.pose ? 700 : 300;
225
257
  return (rect &&
226
- rect.top < window.innerHeight + 300 &&
227
- rect.bottom > -300 &&
258
+ rect.top < window.innerHeight + margin &&
259
+ rect.bottom > -margin &&
228
260
  rect.left < window.innerWidth &&
229
261
  rect.right > 0);
230
262
  })
@@ -297,6 +329,8 @@ export class CatalogSpatialElementLayer {
297
329
  this.lastTime = now;
298
330
  let animating = false;
299
331
  this.glass.beginFrame();
332
+ if (!this.handoff)
333
+ this.ground.beginFrame();
300
334
  for (const actor of this.actors.values()) {
301
335
  if (this.handoff?.actor === actor)
302
336
  continue;
@@ -321,32 +355,76 @@ export class CatalogSpatialElementLayer {
321
355
  this.queueDirty = true;
322
356
  continue;
323
357
  }
358
+ // Free-standing carousel geometry may still be on screen after its
359
+ // semantic section has left it. Keep the same margin as asset residency.
360
+ const margin = actor.pose ? 700 : 96;
324
361
  actor.root.visible =
325
362
  this.exitOpacity > 0.001 &&
326
- slot.top + dy < height + 96 &&
327
- slot.top + dy + slot.height > -96 &&
363
+ slot.top + dy < height + margin &&
364
+ slot.top + dy + slot.height > -margin &&
328
365
  slot.left + dx < width &&
329
366
  slot.left + dx + slot.width > 0;
330
367
  if (!actor.root.visible)
331
368
  continue;
332
369
  if (actor.pose) {
333
370
  const pose = actor.pose.read();
371
+ const approach = this.pointer.active && !this.pointer.pressed && !this.transitionActive &&
372
+ !this.motion.matches && actor.renderRect && pose.visible
373
+ ? carouselProximity(this.pointer.x, this.pointer.y, actor.renderRect) : { x: 0, y: 0 };
374
+ for (const [property, target] of [['rotationX', approach.x], ['rotationY', approach.y]]) {
375
+ actor[property] = this.motion.matches ? 0 : THREE.MathUtils.damp(actor[property], target, 12, delta);
376
+ if (Math.abs(actor[property] - target) < 0.0001)
377
+ actor[property] = target;
378
+ animating ||= actor[property] !== target;
379
+ }
380
+ const hoverTarget = !this.transitionActive && !this.pointer.pressed &&
381
+ ((this.pointer.active && actor.hitTarget?.hasAttribute('data-mouse-hover')) ||
382
+ actor.hitTarget?.matches(':focus-visible')) ? 1 : 0;
383
+ actor.hover = this.motion.matches ? hoverTarget : THREE.MathUtils.damp(actor.hover, hoverTarget, 18, delta);
384
+ if (Math.abs(actor.hover - hoverTarget) < 0.01)
385
+ actor.hover = hoverTarget;
386
+ animating ||= actor.hover !== hoverTarget;
387
+ // Reuse the outline's settled hover state: inspecting a neighbour brings it
388
+ // into focus without changing selection or allocating another render target.
389
+ actor.blur = (pose.blur ?? 0) * (1 - actor.hover);
334
390
  actor.band = pose.front ? 'front' : 'rear';
335
391
  actor.root.visible &&= pose.visible;
336
392
  applyCatalogMaterialOpacity(actor.materials, pose.opacity);
337
393
  const compact = slot.width < 700;
338
- // Anchor each coupled group at its spatialElement, so recession cannot pull neighbours together.
339
- const x = slot.left + dx + slot.width * (pose.x - (compact ? 0 : 0.19));
340
- const y = slot.top + dy + slot.height * pose.y;
341
- const perspective = 1 - pose.depth / this.carouselCamera.position.z;
342
- actor.root.matrix.makeTranslation((x - width / 2) * perspective, (height / 2 - y) * perspective, pose.depth);
394
+ // Every seat shares one scene origin. Depth now determines projected size
395
+ // and spacing naturally, including scroll parallax and the foreground advance.
396
+ const x = slot.left + dx + slot.width * (pose.orbit ? (compact ? 0.5 : 0.31) : pose.x - (compact ? 0 : 0.19));
397
+ const y = slot.top + dy + (pose.orbit ? (compact ? 180 : slot.height * 0.54) : slot.height * pose.y);
398
+ const perspective = pose.orbit ? 1 : 1 - pose.depth / this.carouselCamera.position.z;
399
+ actor.root.matrix.makeTranslation((x - width / 2) * perspective + (pose.orbit?.x ?? 0), (height / 2 - y) * perspective + (pose.orbit?.y ?? 0), pose.depth);
343
400
  actor.root.matrixWorldNeedsUpdate = true;
344
- // One physical group transform for spatialElement, panel surface and DOM projection.
345
- actor.tilt.scale.setScalar(perspective * (pose.size / 0.82));
346
- actor.tilt.rotation.set(0, pose.yaw, 0);
401
+ // Geometry follows the seat and pointer; panel projection below excludes pointer tilt.
402
+ actor.tilt.scale.setScalar(pose.orbit ? 1 : perspective * (pose.size / 0.82));
403
+ actor.tilt.rotation.set((pose.orbit?.pitch ?? 0) + actor.rotationX, pose.yaw + actor.rotationY, 0);
347
404
  actor.tilt.position.set(0, 0, 0);
348
- actor.view.position.set(0, compact ? slot.height / 2 - 180 : 0, 0);
405
+ // Keep compact models in the 360px visual area even as their parent shrinks.
406
+ // Scaling the old offset pulled side previews down into the summary panel.
407
+ actor.view.position.set(0, compact && !pose.orbit
408
+ ? (slot.height - 360) * pose.y / (pose.size / 0.82)
409
+ : 0, 0);
349
410
  actor.view.scale.setScalar((Math.min(slot.width, compact ? 360 : slot.height) * 0.82) / (actor.radius * 2));
411
+ if (pose.orbit && actor.root.visible) {
412
+ const frame = Math.min(slot.width, compact ? 360 : slot.height);
413
+ const floor = frame * 0.32;
414
+ const pitch = pose.orbit.pitch;
415
+ // Stand every model on the same plane, including wide or short assets.
416
+ actor.tilt.updateMatrix();
417
+ actor.view.updateMatrix();
418
+ const upright = new THREE.Matrix4().makeRotationX(-pitch).multiply(actor.tilt.matrix);
419
+ const bottom = Math.min(...actor.supportPoints.map(point => point.clone().applyMatrix4(actor.view.matrix).applyMatrix4(upright).y));
420
+ actor.view.position.y += (-floor - bottom) / upright.elements[5];
421
+ actor.view.updateMatrix();
422
+ const groundMatrix = new THREE.Matrix4().makeTranslation(x - width / 2, height / 2 - y, 0)
423
+ .multiply(new THREE.Matrix4().makeRotationX(pitch))
424
+ .multiply(new THREE.Matrix4().makeTranslation(0, -floor, 0));
425
+ actor.root.updateMatrixWorld(true);
426
+ this.ground.shadow(actor, actor.model, groundMatrix, 0.14 * pose.opacity);
427
+ }
350
428
  actor.root.updateMatrixWorld(true);
351
429
  const hitTarget = actor.hitTarget;
352
430
  if (hitTarget) {
@@ -368,13 +446,19 @@ export class CatalogSpatialElementLayer {
368
446
  hitTarget.style.width = `${right - left}px`;
369
447
  hitTarget.style.height = `${bottom - top}px`;
370
448
  hitTarget.style.maxWidth = 'none';
449
+ actor.renderRect = { left: left + slot.left + dx, top: top + slot.top + dy,
450
+ width: right - left, height: bottom - top };
371
451
  }
372
452
  const panel = actor.summaryPanel;
373
453
  if (panel && actor.summarySize) {
374
454
  const { width: pw, height: ph } = actor.summarySize;
375
- const matrix = actor.tilt.matrixWorld
376
- .clone()
377
- .multiply(new THREE.Matrix4().makeTranslation(compact ? 0 : slot.width * 0.39, compact ? slot.height / 2 - 360 - ph / 2 : 0, 0));
455
+ // The panel follows the seat and its yaw, but not the elevated
456
+ // product view. At rest it is parallel to the screen, also on mobile.
457
+ const panelFrame = pose.orbit
458
+ ? actor.root.matrixWorld.clone().multiply(new THREE.Matrix4().makeRotationY(pose.yaw))
459
+ : actor.tilt.matrixWorld.clone();
460
+ const matrix = panelFrame
461
+ .multiply(new THREE.Matrix4().makeTranslation(compact ? 0 : slot.width * 0.39, compact ? (pose.orbit ? 180 : slot.height / 2) - 360 - ph / 2 : 0, 0));
378
462
  const corners = [
379
463
  [-pw / 2, ph / 2],
380
464
  [pw / 2, ph / 2],
@@ -389,19 +473,25 @@ export class CatalogSpatialElementLayer {
389
473
  y: ((1 - point.y) * height) / 2 - slot.top - dy
390
474
  };
391
475
  });
392
- panel.style.transform = getProjectiveCssMatrix3d(corners, pw, ph) ?? '';
476
+ // The semantic summary keeps its intrinsic layout slot before and after
477
+ // enhancement. Project relative to that slot instead of moving it to (0, 0).
478
+ const origin = actor.summaryOrigin ?? { x: 0, y: 0 };
479
+ const localCorners = corners.map(({ x, y }) => ({
480
+ x: x - origin.x, y: y - origin.y
481
+ }));
482
+ panel.style.transform = getProjectiveCssMatrix3d(localCorners, pw, ph) ?? '';
393
483
  recordCarouselPanel(panel, corners.map((point) => ({
394
484
  x: point.x + slot.left + dx,
395
485
  y: point.y + slot.top + dy
396
486
  })), pw, ph);
397
487
  const hidden = actor.card.style.visibility === 'hidden' || panel.style.visibility === 'hidden';
398
- this.glass.panel(actor.card, matrix, pw, ph, hidden ? 0 : pose.panelOpacity * this.exitOpacity);
488
+ this.glass.panel(actor.card, matrix, pw, ph, hidden ? 0 : pose.panelOpacity * this.exitOpacity, (1 - pose.panelOpacity) * 6);
399
489
  }
400
490
  actor.clip = {
401
491
  left: 0,
402
- top: slot.top + dy,
492
+ top: 0,
403
493
  width,
404
- height: slot.height
494
+ height
405
495
  };
406
496
  if (this.isDestinationActor(actor))
407
497
  actor.root.visible = false;
@@ -421,16 +511,18 @@ export class CatalogSpatialElementLayer {
421
511
  const targets = [
422
512
  -THREE.MathUtils.radToDeg(rotation.x),
423
513
  THREE.MathUtils.radToDeg(rotation.y),
424
- -influence * 8
514
+ -influence * 8,
515
+ !this.motion.matches && !this.transitionActive &&
516
+ ((this.pointer.active && distance === 0) || actor.card.matches?.(':focus-visible')) ? 1 : 0
425
517
  ];
426
- const previous = [actor.rotationX, actor.rotationY, actor.lift];
518
+ const previous = [actor.rotationX, actor.rotationY, actor.lift, actor.hover];
427
519
  const values = previous.map((value, index) => {
428
520
  const next = this.motion.matches
429
521
  ? targets[index]
430
522
  : THREE.MathUtils.damp(value, targets[index], 14, delta);
431
523
  return Math.abs(next - targets[index]) < 0.01 ? targets[index] : next;
432
524
  });
433
- [actor.rotationX, actor.rotationY, actor.lift] = values;
525
+ [actor.rotationX, actor.rotationY, actor.lift, actor.hover] = values;
434
526
  animating ||= values.some((value, index) => value !== targets[index]);
435
527
  actor.card.style.setProperty('--catalog-rotate-x', `${actor.rotationX}deg`);
436
528
  actor.card.style.setProperty('--catalog-rotate-y', `${actor.rotationY}deg`);
@@ -439,8 +531,8 @@ export class CatalogSpatialElementLayer {
439
531
  actor.root.matrixWorldNeedsUpdate = true;
440
532
  actor.tilt.rotation.set(-THREE.MathUtils.degToRad(actor.rotationX), THREE.MathUtils.degToRad(actor.rotationY), 0);
441
533
  actor.tilt.position.y = -actor.lift;
442
- actor.view.position.set(slot.left + slot.width / 2 - card.left - card.width / 2, card.top + card.height / 2 - slot.top - slot.height / 2, 0);
443
- actor.view.scale.setScalar((Math.min(slot.width, slot.height) * 0.84) / (actor.radius * 2));
534
+ actor.view.position.set(slot.left + slot.width / 2 - card.left - card.width / 2, card.top + card.height / 2 - slot.top - slot.height / 2, 96 * actor.hover);
535
+ actor.view.scale.setScalar(actor.cardScale * (1 + 0.12 * actor.hover));
444
536
  if (this.isDestinationActor(actor))
445
537
  actor.root.visible = false;
446
538
  }
@@ -449,6 +541,8 @@ export class CatalogSpatialElementLayer {
449
541
  void this.loadVisibleSpatialElements(this.generation);
450
542
  }
451
543
  this.glass.endFrame();
544
+ if (!this.handoff)
545
+ this.ground.endFrame();
452
546
  return animating;
453
547
  }
454
548
  draw(renderer, band) {
@@ -489,12 +583,25 @@ export class CatalogSpatialElementLayer {
489
583
  continue;
490
584
  renderer.setScissor(left, top, right - left, bottom - top);
491
585
  renderer.setScissorTest(true);
492
- for (const actor of group)
493
- actor.root.visible = true;
494
586
  const fog = this.scene.fog;
495
- this.scene.fog = this.carouselFog;
587
+ this.scene.fog = null;
496
588
  try {
497
- renderer.render(this.scene, this.carouselCamera);
589
+ if (group.some((actor) => ((actor.blur ?? 0) >= 0.05 || actor.hover > 0) && actor.renderRect)) {
590
+ // Resolve far-to-near into the same output; scratch buffers are shared by every seat.
591
+ group.sort((a, b) => a.root.matrix.elements[14] - b.root.matrix.elements[14]);
592
+ for (const actor of group) {
593
+ actor.root.visible = true;
594
+ this.depthBlur.render(renderer, this.carouselCamera, actor.renderRect ?? rect, actor.blur ?? 0, (camera) => renderer.render(this.scene, camera), rect);
595
+ if (actor.hover > 0 && actor.renderRect)
596
+ this.outline.render(renderer, this.carouselCamera, actor.model, actor.renderRect, rect, actor.hover * (actor.materials[0]?.material.opacity ?? 1), this.interactionTheme());
597
+ actor.root.visible = false;
598
+ }
599
+ }
600
+ else {
601
+ for (const actor of group)
602
+ actor.root.visible = true;
603
+ renderer.render(this.scene, this.carouselCamera);
604
+ }
498
605
  }
499
606
  finally {
500
607
  this.scene.fog = fog;
@@ -524,7 +631,10 @@ export class CatalogSpatialElementLayer {
524
631
  return [...this.actors.values()].some((actor) => Boolean(actor.pose));
525
632
  }
526
633
  renderRear(renderer) {
527
- this.glass.render(renderer, this.carouselCamera, () => this.draw(renderer, 'rear'));
634
+ this.glass.render(renderer, this.carouselCamera, () => {
635
+ this.ground.draw(renderer, this.carouselCamera, this.exitOpacity);
636
+ this.draw(renderer, 'rear');
637
+ });
528
638
  }
529
639
  /** Warm the existing Low material passes in an offscreen preparation target. */
530
640
  renderForPreparation(renderer) {
@@ -548,7 +658,7 @@ export class CatalogSpatialElementLayer {
548
658
  this.handoffPoint = undefined;
549
659
  actor.model.updateWorldMatrix(true, true);
550
660
  const camera = actor.pose ? this.carouselCamera : this.camera;
551
- this.handoffScene.fog = actor.pose ? this.carouselFog : this.scene.fog;
661
+ this.handoffScene.fog = actor.pose ? null : this.scene.fog;
552
662
  camera.updateMatrixWorld();
553
663
  const sourceModel = actor.model.matrixWorld.clone();
554
664
  const sourceClip = normalizeSpatialElementClipMatrix(new THREE.Matrix4()
@@ -594,17 +704,19 @@ export class CatalogSpatialElementLayer {
594
704
  if (!actor?.slot?.isConnected)
595
705
  return;
596
706
  const rect = actor.slot.getBoundingClientRect();
707
+ const visibleRect = actor.pose && actor.renderRect ? actor.renderRect : rect;
597
708
  if (rect.width <= 0 ||
598
709
  rect.height <= 0 ||
599
710
  (actor.pose
600
- ? rect.right <= 0 || rect.bottom <= 0 || rect.left >= innerWidth || rect.top >= innerHeight
711
+ ? visibleRect.left + visibleRect.width <= 0 || visibleRect.top + visibleRect.height <= 0 ||
712
+ visibleRect.left >= innerWidth || visibleRect.top >= innerHeight
601
713
  : rect.left < 0 || rect.top < 0 || rect.right > innerWidth || rect.bottom > innerHeight))
602
714
  return;
603
715
  actor.model.updateWorldMatrix(true, true);
604
716
  const camera = actor.pose ? this.carouselCamera : this.camera;
605
717
  return {
606
718
  environmentIntensity: this.scene.environmentIntensity,
607
- fog: actor.pose ? this.carouselFog : this.scene.fog,
719
+ fog: actor.pose ? null : this.scene.fog,
608
720
  viewportClip: actor.clip ? { ...actor.clip } : undefined,
609
721
  model: actor.model.matrixWorld.clone(),
610
722
  camera: camera.matrixWorld.clone(),
@@ -631,7 +743,7 @@ export class CatalogSpatialElementLayer {
631
743
  : this.camera;
632
744
  camera.updateMatrixWorld();
633
745
  const projection = {
634
- fog: actor.pose ? this.carouselFog : this.scene.fog,
746
+ fog: actor.pose ? null : this.scene.fog,
635
747
  viewportClip: actor.clip ? { ...actor.clip } : undefined,
636
748
  model: model.matrixWorld.clone(),
637
749
  camera: camera.matrixWorld.clone(),
@@ -706,8 +818,11 @@ export class CatalogSpatialElementLayer {
706
818
  applyCatalogMaterialOpacity(this.handoff.actor.materials, opacity);
707
819
  }
708
820
  dispose() {
821
+ this.ground.dispose();
709
822
  this.glass.dispose();
823
+ this.depthBlur.dispose();
710
824
  this.geometryFade.dispose();
825
+ this.outline.dispose();
711
826
  if (this.disposed)
712
827
  return;
713
828
  this.disposed = true;
@@ -720,6 +835,10 @@ export class CatalogSpatialElementLayer {
720
835
  this.disposeActor(actor);
721
836
  window.removeEventListener('pointermove', this.pointerMove);
722
837
  window.removeEventListener('pointerdown', this.pointerDown, true);
838
+ window.removeEventListener('pointerup', this.pointerUp);
839
+ window.removeEventListener('pointercancel', this.pointerUp);
840
+ window.removeEventListener('focusin', this.motionChange);
841
+ window.removeEventListener('focusout', this.motionChange);
723
842
  window.removeEventListener('pointerleave', this.pointerLeave);
724
843
  window.removeEventListener('blur', this.pointerLeave);
725
844
  window.removeEventListener('resize', this.resize);
@@ -772,11 +891,13 @@ export class CatalogSpatialElementLayer {
772
891
  const tilt = new THREE.Group();
773
892
  const view = new THREE.Group();
774
893
  view.quaternion.copy(getCameraOrbitQuaternion(stage.camera?.azimuth, stage.camera?.elevation).invert());
894
+ const supportPoints = carouselSupport(model, view.quaternion);
775
895
  root.add(tilt);
776
896
  tilt.add(view);
777
897
  view.add(model);
778
898
  const materials = captureCatalogMaterialOpacity(model);
779
899
  applyCatalogMaterialOpacity(materials, 1);
900
+ const hitCorners = [bounds.min.x, bounds.max.x].flatMap((x) => [bounds.min.y, bounds.max.y].flatMap((y) => [bounds.min.z, bounds.max.z].map((z) => new THREE.Vector3(x, y, z))));
780
901
  return {
781
902
  key,
782
903
  brandId,
@@ -788,7 +909,11 @@ export class CatalogSpatialElementLayer {
788
909
  tilt,
789
910
  view,
790
911
  radius,
791
- hitCorners: [bounds.min.x, bounds.max.x].flatMap((x) => [bounds.min.y, bounds.max.y].flatMap((y) => [bounds.min.z, bounds.max.z].map((z) => new THREE.Vector3(x, y, z)))),
912
+ hitCorners,
913
+ fitCorners: hitCorners.map((corner) => corner.clone().applyQuaternion(view.quaternion)),
914
+ supportPoints,
915
+ cardScale: 1,
916
+ hover: 0,
792
917
  referencePoint,
793
918
  overrides,
794
919
  materials,
@@ -820,6 +945,8 @@ export class CatalogSpatialElementLayer {
820
945
  for (const { actor } of measured) {
821
946
  actor.cardRect = actor.card.getBoundingClientRect();
822
947
  actor.slotRect = actor.slot.getBoundingClientRect();
948
+ if (!actor.pose)
949
+ actor.cardScale = cardModelFit(actor.fitCorners, actor.slotRect.width, actor.slotRect.height);
823
950
  if (actor.pose) {
824
951
  actor.hitTarget = actor.card.querySelector('.spatial-element-target') ?? undefined;
825
952
  const panel = actor.card.querySelector('.summary') ?? undefined;
@@ -827,6 +954,7 @@ export class CatalogSpatialElementLayer {
827
954
  this.layoutObserver.unobserve(actor.summaryPanel);
828
955
  actor.summaryPanel = panel;
829
956
  actor.summarySize = panel ? { width: panel.offsetWidth, height: panel.offsetHeight } : undefined;
957
+ actor.summaryOrigin = panel ? { x: panel.offsetLeft ?? 0, y: panel.offsetTop ?? 0 } : undefined;
830
958
  // Summary content can resize without changing its section's fixed height.
831
959
  if (panel)
832
960
  this.layoutObserver.observe(panel);
@@ -915,6 +1043,7 @@ export class CatalogSpatialElementLayer {
915
1043
  };
916
1044
  }
917
1045
  disposeActor(actor) {
1046
+ this.outline.release(actor.model);
918
1047
  if (actor.summaryPanel)
919
1048
  this.layoutObserver.unobserve(actor.summaryPanel);
920
1049
  actor.root.removeFromParent();