@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.
Files changed (96) hide show
  1. package/dist/catalog/CarouselDeviceCamera.d.ts +12 -0
  2. package/dist/catalog/CarouselDeviceCamera.d.ts.map +1 -0
  3. package/dist/catalog/CarouselDeviceCamera.js +44 -0
  4. package/dist/catalog/CarouselDeviceCamera.js.map +1 -0
  5. package/dist/catalog/CarouselGlassCompositor.d.ts +7 -2
  6. package/dist/catalog/CarouselGlassCompositor.d.ts.map +1 -1
  7. package/dist/catalog/CarouselGlassCompositor.js +85 -24
  8. package/dist/catalog/CarouselGlassCompositor.js.map +1 -1
  9. package/dist/catalog/CarouselGround.d.ts +21 -0
  10. package/dist/catalog/CarouselGround.d.ts.map +1 -0
  11. package/dist/catalog/CarouselGround.js +107 -0
  12. package/dist/catalog/CarouselGround.js.map +1 -0
  13. package/dist/catalog/CatalogDepthBlur.d.ts +26 -0
  14. package/dist/catalog/CatalogDepthBlur.d.ts.map +1 -0
  15. package/dist/catalog/CatalogDepthBlur.js +87 -0
  16. package/dist/catalog/CatalogDepthBlur.js.map +1 -0
  17. package/dist/catalog/CatalogModelOutline.d.ts +31 -0
  18. package/dist/catalog/CatalogModelOutline.d.ts.map +1 -0
  19. package/dist/catalog/CatalogModelOutline.js +127 -0
  20. package/dist/catalog/CatalogModelOutline.js.map +1 -0
  21. package/dist/catalog/CatalogSpatialElementLayer.d.ts +44 -2
  22. package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -1
  23. package/dist/catalog/CatalogSpatialElementLayer.js +293 -88
  24. package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
  25. package/dist/catalog/CatalogTransition.d.ts.map +1 -1
  26. package/dist/catalog/CatalogTransition.js +62 -4
  27. package/dist/catalog/CatalogTransition.js.map +1 -1
  28. package/dist/catalog/SpatialGeometryCapture.d.ts +9 -0
  29. package/dist/catalog/SpatialGeometryCapture.d.ts.map +1 -1
  30. package/dist/catalog/SpatialGeometryCapture.js +11 -1
  31. package/dist/catalog/SpatialGeometryCapture.js.map +1 -1
  32. package/dist/catalog/cardModelFit.d.ts +7 -0
  33. package/dist/catalog/cardModelFit.d.ts.map +1 -0
  34. package/dist/catalog/cardModelFit.js +16 -0
  35. package/dist/catalog/cardModelFit.js.map +1 -0
  36. package/dist/catalog/cardProjection.d.ts +8 -0
  37. package/dist/catalog/cardProjection.d.ts.map +1 -0
  38. package/dist/catalog/cardProjection.js +51 -0
  39. package/dist/catalog/cardProjection.js.map +1 -0
  40. package/dist/catalog/carouselMotion.d.ts +35 -0
  41. package/dist/catalog/carouselMotion.d.ts.map +1 -1
  42. package/dist/catalog/carouselMotion.js +85 -4
  43. package/dist/catalog/carouselMotion.js.map +1 -1
  44. package/dist/catalog/carouselProximity.d.ts +11 -0
  45. package/dist/catalog/carouselProximity.d.ts.map +1 -0
  46. package/dist/catalog/carouselProximity.js +13 -0
  47. package/dist/catalog/carouselProximity.js.map +1 -0
  48. package/dist/catalog/carouselSupport.d.ts +4 -0
  49. package/dist/catalog/carouselSupport.d.ts.map +1 -0
  50. package/dist/catalog/carouselSupport.js +30 -0
  51. package/dist/catalog/carouselSupport.js.map +1 -0
  52. package/dist/catalog/catalogPose.d.ts +36 -6
  53. package/dist/catalog/catalogPose.d.ts.map +1 -1
  54. package/dist/catalog/catalogPose.js +79 -23
  55. package/dist/catalog/catalogPose.js.map +1 -1
  56. package/dist/catalog/deviceYaw.d.ts +21 -0
  57. package/dist/catalog/deviceYaw.d.ts.map +1 -0
  58. package/dist/catalog/deviceYaw.js +87 -0
  59. package/dist/catalog/deviceYaw.js.map +1 -0
  60. package/dist/catalog/listDeviceOrientation.d.ts +15 -0
  61. package/dist/catalog/listDeviceOrientation.d.ts.map +1 -0
  62. package/dist/catalog/listDeviceOrientation.js +245 -0
  63. package/dist/catalog/listDeviceOrientation.js.map +1 -0
  64. package/dist/stage/DeviceGeometryMotion.d.ts +13 -0
  65. package/dist/stage/DeviceGeometryMotion.d.ts.map +1 -0
  66. package/dist/stage/DeviceGeometryMotion.js +37 -0
  67. package/dist/stage/DeviceGeometryMotion.js.map +1 -0
  68. package/dist/stage/LiquidGlassPanel.d.ts +2 -0
  69. package/dist/stage/LiquidGlassPanel.d.ts.map +1 -1
  70. package/dist/stage/LiquidGlassPanel.js +8 -1
  71. package/dist/stage/LiquidGlassPanel.js.map +1 -1
  72. package/dist/stage/MinimapController.d.ts +1 -0
  73. package/dist/stage/MinimapController.d.ts.map +1 -1
  74. package/dist/stage/MinimapController.js +7 -0
  75. package/dist/stage/MinimapController.js.map +1 -1
  76. package/dist/stage/PanelPresentationController.d.ts.map +1 -1
  77. package/dist/stage/PanelPresentationController.js +19 -7
  78. package/dist/stage/PanelPresentationController.js.map +1 -1
  79. package/dist/stage/StageExperience.d.ts +56 -0
  80. package/dist/stage/StageExperience.d.ts.map +1 -1
  81. package/dist/stage/StageExperience.js +53 -17
  82. package/dist/stage/StageExperience.js.map +1 -1
  83. package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
  84. package/dist/stage/StageRenderPipeline.js +14 -63
  85. package/dist/stage/StageRenderPipeline.js.map +1 -1
  86. package/dist/stage/interactionOutline.d.ts +14 -0
  87. package/dist/stage/interactionOutline.d.ts.map +1 -0
  88. package/dist/stage/interactionOutline.js +81 -0
  89. package/dist/stage/interactionOutline.js.map +1 -0
  90. package/dist/stage/panelContext.d.ts +2 -0
  91. package/dist/stage/panelContext.d.ts.map +1 -1
  92. package/dist/stage/panelContext.js.map +1 -1
  93. package/dist/stage/stageTypes.d.ts +1 -0
  94. package/dist/stage/stageTypes.d.ts.map +1 -1
  95. package/dist/stage/stageTypes.js.map +1 -1
  96. package/package.json +1 -1
@@ -8,7 +8,15 @@ export interface CatalogPose {
8
8
  visible: boolean;
9
9
  front: boolean;
10
10
  panelOpacity: number;
11
+ /** CSS-pixel defocus; zero at the selected seat and continuous during dragging. */
12
+ blur?: number;
11
13
  opacity: number;
14
+ /** Camera-space offsets from the shared section origin; no per-item perspective compensation. */
15
+ orbit?: {
16
+ x: number;
17
+ y: number;
18
+ pitch: number;
19
+ };
12
20
  }
13
21
  export interface CatalogPoseProvider {
14
22
  kind: 'carousel';
@@ -16,15 +24,37 @@ export interface CatalogPoseProvider {
16
24
  }
17
25
  /** Presentation controls, never asset scale, URL or renderer ownership. */
18
26
  export interface CarouselPresentation {
19
- /** Horizontal arc extent as a fraction of section width (default 0.48). */
27
+ /** Horizontal spacing multiplier, normalized around the default 0.48. */
20
28
  radius?: number;
21
- /** Maximum rearward travel in CSS-world pixels (default 700). */
29
+ /** Turntable depth control in CSS-world pixels (default 700). */
22
30
  depth?: number;
23
31
  }
32
+ /** Cached section metrics, shared by DOM hit targets, posters and GPU poses. */
33
+ export interface CarouselLayout {
34
+ width: number;
35
+ height: number;
36
+ left: number;
37
+ viewportWidth: number;
38
+ }
39
+ export interface CarouselEmphasis {
40
+ advance: number;
41
+ panel: number;
42
+ }
43
+ export declare function carouselEmphasis(distance: number): CarouselEmphasis;
44
+ /** A gesture can only withdraw its initial presentation, never select passing seats. */
45
+ export declare class CarouselDragEmphasis {
46
+ private readonly phase;
47
+ private readonly initial;
48
+ private travel;
49
+ constructor(phase: number, initial: readonly CarouselEmphasis[]);
50
+ move(phase: number): CarouselEmphasis[];
51
+ }
24
52
  export declare function carouselDistance(index: number, phase: number, count: number): number;
25
- /** Five visible seats, plus one preparation seat on either side. No duplicated elements. */
26
- export declare function carouselResident(index: number, phase: number, count: number): boolean;
27
- /** An ordered shallow arc of element/panel groups, independent of the asset's physical dimensions. */
28
- export declare function carouselPose(index: number, phase: number, count: number, presentation?: CarouselPresentation): CatalogPose;
53
+ /** Prepare only the viewport and a small margin, including fractional drag movement. */
54
+ export declare function carouselResident(index: number, phase: number, count: number, presentation?: CarouselPresentation, layout?: CarouselLayout): boolean;
55
+ /** A shared circular turntable, tilted toward the viewer, with a smooth foreground advance. */
56
+ export declare function carouselPose(index: number, phase: number, count: number, presentation?: CarouselPresentation, layout?: CarouselLayout, emphasis?: CarouselEmphasis,
57
+ /** Shared foreground focus: zero keeps the whole turntable sharp. */
58
+ focus?: number): CatalogPose;
29
59
  export declare const CATALOG_POSE_CHANGED = "catalog-pose-changed";
30
60
  //# sourceMappingURL=catalogPose.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"catalogPose.d.ts","sourceRoot":"","sources":["../../src/catalog/catalogPose.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,IAAI,WAAW,CAAC;CACpB;AAED,2EAA2E;AAC3E,MAAM,WAAW,oBAAoB;IACpC,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAE3E;AAED,4FAA4F;AAC5F,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAE3E;AAED,sGAAsG;AACtG,wBAAgB,YAAY,CAC3B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,YAAY,GAAE,oBAAyB,GACrC,WAAW,CAwBb;AAED,eA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QAAQ,CAAC,KAAK;IAAU,OAAO,CAAC,QAAQ,CAAC,OAAO;IADpE,OAAO,CAAC,MAAM,CAAK;gBACU,KAAK,EAAE,MAAM,EAAmB,OAAO,EAAE,SAAS,gBAAgB,EAAE;IACjG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,EAAE;CAQvC;AAuCD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAE3E;AAED,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAC3E,YAAY,GAAE,oBAAyB,EAAE,MAAM,GAAE,cAA8B,WAK/E;AAED,+FAA+F;AAC/F,wBAAgB,YAAY,CAC3B,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,YAAY,GAAE,oBAAyB,EACvC,MAAM,GAAE,cAA8B,EACtC,QAAQ,mBAA0D;AAClE,qEAAqE;AACrE,KAAK,SAAI,GACP,WAAW,CAiBb;AAED,eAAO,MAAM,oBAAoB,yBAAyB,CAAC"}
@@ -1,33 +1,89 @@
1
+ const defaultLayout = { width: 1320, height: 560, left: 60, viewportWidth: 1440 };
2
+ export function carouselEmphasis(distance) {
3
+ return { advance: Math.max(0, 1 - distance * distance) ** 2,
4
+ panel: Math.max(0, 1 - Math.abs(distance)) ** 2 };
5
+ }
6
+ /** A gesture can only withdraw its initial presentation, never select passing seats. */
7
+ export class CarouselDragEmphasis {
8
+ phase;
9
+ initial;
10
+ travel = 0;
11
+ constructor(phase, initial) {
12
+ this.phase = phase;
13
+ this.initial = initial;
14
+ }
15
+ move(phase) {
16
+ this.travel = Math.max(this.travel, Math.abs(phase - this.phase));
17
+ const remaining = carouselEmphasis(this.travel);
18
+ return this.initial.map(value => ({
19
+ advance: value.advance * remaining.advance,
20
+ panel: value.panel * remaining.panel
21
+ }));
22
+ }
23
+ }
24
+ function framing(distance, presentation, layout, emphasis = carouselEmphasis(distance)) {
25
+ const compact = layout.width < 700;
26
+ const frame = Math.min(layout.width, compact ? 360 : layout.height);
27
+ const spacing = Number.isFinite(presentation.radius)
28
+ ? Math.max(0.2, Math.min(0.7, presentation.radius)) : 0.48;
29
+ const depth = Number.isFinite(presentation.depth)
30
+ ? Math.max(0, Math.min(1200, presentation.depth)) : 700;
31
+ // A larger, shallower turntable: keep useful seat spacing by reducing the
32
+ // angle between products rather than packing the same angle onto a larger ring.
33
+ const radius = frame * (compact ? 2.2 : 3.4) * spacing / 0.48 * (0.75 + depth / 2800);
34
+ const step = 0.4;
35
+ const travel = Math.abs(distance);
36
+ // Only the front arc is presented. Never wrap a long catalog onto occupied seats.
37
+ const angle = Math.max(-1.35, Math.min(1.35, distance * step));
38
+ const pitch = 10 * Math.PI / 180;
39
+ const pull = frame * 1.25;
40
+ // Smooth at both the selected seat and the point where it rejoins the ring.
41
+ const advance = pull * emphasis.advance;
42
+ const recession = radius * (1 - Math.cos(angle)) + pull - advance;
43
+ const z = -recession * Math.cos(pitch);
44
+ // Selection changes depth only; every seat retains its horizontal position.
45
+ const orbit = {
46
+ x: radius * Math.sin(angle),
47
+ y: recession * Math.sin(pitch),
48
+ pitch
49
+ };
50
+ const scale = 2500 / (2500 - z);
51
+ const anchor = layout.left + layout.width * (compact ? 0.5 : 0.31);
52
+ const center = layout.viewportWidth / 2 + (anchor - layout.viewportWidth / 2 + orbit.x) * scale;
53
+ const offset = center - anchor;
54
+ const extent = frame * 0.82 * scale * 0.6;
55
+ const seats = compact ? 1.49 : 3.24;
56
+ const arcOpacity = Math.max(0, Math.min(1, (seats - travel) / 0.38));
57
+ return { offset, scale, center, extent, orbit, z, angle, arcOpacity, seats };
58
+ }
1
59
  export function carouselDistance(index, phase, count) {
2
60
  return count > 1 ? index - phase : 0;
3
61
  }
4
- /** Five visible seats, plus one preparation seat on either side. No duplicated elements. */
5
- export function carouselResident(index, phase, count) {
6
- return Math.abs(carouselDistance(index, phase, count)) <= 3;
62
+ /** Prepare only the viewport and a small margin, including fractional drag movement. */
63
+ export function carouselResident(index, phase, count, presentation = {}, layout = defaultLayout) {
64
+ const distance = carouselDistance(index, phase, count);
65
+ const { seats } = framing(distance, presentation, layout);
66
+ // Include the neighbouring animation window before the front arc enters view.
67
+ return Math.abs(distance) < seats + 1;
7
68
  }
8
- /** An ordered shallow arc of element/panel groups, independent of the asset's physical dimensions. */
9
- export function carouselPose(index, phase, count, presentation = {}) {
69
+ /** A shared circular turntable, tilted toward the viewer, with a smooth foreground advance. */
70
+ export function carouselPose(index, phase, count, presentation = {}, layout = defaultLayout, emphasis = carouselEmphasis(carouselDistance(index, phase, count)),
71
+ /** Shared foreground focus: zero keeps the whole turntable sharp. */
72
+ focus = 1) {
10
73
  const distance = carouselDistance(index, phase, count);
11
- // Fixed angular spacing: adding spatialElements extends the arc, never closes a turntable.
12
- const angle = (distance * Math.PI) / 12;
13
- const back = Math.min(1, (1 - Math.cos(angle)) / (1 - Math.cos(Math.PI / 6)));
14
- const edge = Math.max(0, Math.min(1, (2.5 - Math.abs(distance)) * 2));
15
- const radius = Number.isFinite(presentation.radius)
16
- ? Math.max(0.2, Math.min(0.7, presentation.radius))
17
- : 0.48;
18
- const depth = Number.isFinite(presentation.depth)
19
- ? Math.max(0, Math.min(1200, presentation.depth))
20
- : 700;
74
+ const { offset, scale, center, extent, orbit, z, angle, arcOpacity } = framing(distance, presentation, layout, emphasis);
75
+ const edge = Math.max(0, Math.min(1, (center + extent) / 48, (layout.viewportWidth - center + extent) / 48)) * arcOpacity;
21
76
  return {
22
- x: 0.5 + (Math.sin(angle) * radius) / Math.sin(Math.PI / 6),
23
- y: 0.5 - back * 0.1,
24
- size: 0.82 / (1 + Math.abs(distance) * 0.65),
25
- depth: -back * depth,
26
- // Strong near-centre turn, smoothly bounded before distant seats become edge-on.
27
- yaw: -Math.atan(distance * Math.tan((28 * Math.PI) / 180)),
28
- visible: Math.abs(distance) < 2.5,
77
+ x: 0.5 + offset / Math.max(1, layout.width),
78
+ y: 0.54 - orbit.y * scale / Math.max(1, layout.height),
79
+ size: 0.82 * scale,
80
+ depth: z,
81
+ orbit,
82
+ yaw: angle,
83
+ visible: edge > 0,
29
84
  front: Math.abs(distance) <= 0.5,
30
- panelOpacity: Math.pow(Math.max(0, 1 - Math.abs(distance)), 2),
85
+ panelOpacity: emphasis.panel,
86
+ blur: Math.min(5, Math.max(0, Math.abs(distance) - 0.15) ** 1.4 * 2.2) * focus,
31
87
  opacity: edge
32
88
  };
33
89
  }
@@ -1 +1 @@
1
- {"version":3,"file":"catalogPose.js","sourceRoot":"","sources":["../../src/catalog/catalogPose.ts"],"names":[],"mappings":"AA0BA,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,KAAa,EAAE,KAAa;IAC3E,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,KAAa,EAAE,KAAa;IAC3E,OAAO,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC;AAC7D,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,YAAY,CAC3B,KAAa,EACb,KAAa,EACb,KAAa,EACb,eAAqC,EAAE;IAEvC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACvD,2FAA2F;IAC3F,MAAM,KAAK,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,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AC,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC;QAC1D,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,GAAG;QACjC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG;QAChC,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC;QAC9D,OAAO,EAAE,IAAI;KACb,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC","sourcesContent":["/** Section-local screen framing, independent of assets and camera ownership. */\nexport interface CatalogPose {\n\tx: number;\n\ty: number;\n\tsize: number;\n\tdepth: number;\n\tyaw: number;\n\tvisible: boolean;\n\tfront: boolean;\n\tpanelOpacity: number;\n\topacity: number;\n}\n\nexport interface CatalogPoseProvider {\n\tkind: 'carousel';\n\tread(): CatalogPose;\n}\n\n/** Presentation controls, never asset scale, URL or renderer ownership. */\nexport interface CarouselPresentation {\n\t/** Horizontal arc extent as a fraction of section width (default 0.48). */\n\tradius?: number;\n\t/** Maximum rearward travel in CSS-world pixels (default 700). */\n\tdepth?: number;\n}\n\nexport function carouselDistance(index: number, phase: number, count: number) {\n\treturn count > 1 ? index - phase : 0;\n}\n\n/** Five visible seats, plus one preparation seat on either side. No duplicated elements. */\nexport function carouselResident(index: number, phase: number, count: number) {\n\treturn Math.abs(carouselDistance(index, phase, count)) <= 3;\n}\n\n/** An ordered shallow arc of element/panel groups, independent of the asset's physical dimensions. */\nexport function carouselPose(\n\tindex: number,\n\tphase: number,\n\tcount: number,\n\tpresentation: CarouselPresentation = {}\n): CatalogPose {\n\tconst distance = carouselDistance(index, phase, count);\n\t// Fixed angular spacing: adding spatialElements extends the arc, never closes a turntable.\n\tconst angle = (distance * Math.PI) / 12;\n\tconst back = Math.min(1, (1 - Math.cos(angle)) / (1 - Math.cos(Math.PI / 6)));\n\tconst edge = Math.max(0, Math.min(1, (2.5 - Math.abs(distance)) * 2));\n\tconst radius = Number.isFinite(presentation.radius)\n\t\t? Math.max(0.2, Math.min(0.7, presentation.radius!))\n\t\t: 0.48;\n\tconst depth = Number.isFinite(presentation.depth)\n\t\t? Math.max(0, Math.min(1200, presentation.depth!))\n\t\t: 700;\n\treturn {\n\t\tx: 0.5 + (Math.sin(angle) * radius) / Math.sin(Math.PI / 6),\n\t\ty: 0.5 - back * 0.1,\n\t\tsize: 0.82 / (1 + Math.abs(distance) * 0.65),\n\t\tdepth: -back * depth,\n\t\t// Strong near-centre turn, smoothly bounded before distant seats become edge-on.\n\t\tyaw: -Math.atan(distance * Math.tan((28 * Math.PI) / 180)),\n\t\tvisible: Math.abs(distance) < 2.5,\n\t\tfront: Math.abs(distance) <= 0.5,\n\t\tpanelOpacity: Math.pow(Math.max(0, 1 - Math.abs(distance)), 2),\n\t\topacity: edge\n\t};\n}\n\nexport const CATALOG_POSE_CHANGED = 'catalog-pose-changed';\n"]}
1
+ {"version":3,"file":"catalogPose.js","sourceRoot":"","sources":["../../src/catalog/catalogPose.ts"],"names":[],"mappings":"AAsCA,MAAM,aAAa,GAAmB,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;AAIlG,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAChD,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC;QAC1D,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;AACpD,CAAC;AAED,wFAAwF;AACxF,MAAM,OAAO,oBAAoB;IAE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E,IAAI,GAAG,KAAK;QAClB,KAAK,EAAE,CAAC;QACR,KAAK;QACL,GAAG,EAAE,KAAK;QACV,OAAO,EAAE,IAAI,GAAG,CAAC;QACjB,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG;QAChC,YAAY,EAAE,QAAQ,CAAC,KAAK;QAC5B,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,KAAK;QAC9E,OAAO,EAAE,IAAI;KACb,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC","sourcesContent":["/** Section-local screen framing, independent of assets and camera ownership. */\nexport interface CatalogPose {\n\tx: number;\n\ty: number;\n\tsize: number;\n\tdepth: number;\n\tyaw: number;\n\tvisible: boolean;\n\tfront: boolean;\n\tpanelOpacity: number;\n\t/** CSS-pixel defocus; zero at the selected seat and continuous during dragging. */\n\tblur?: number;\n\topacity: number;\n\t/** Camera-space offsets from the shared section origin; no per-item perspective compensation. */\n\torbit?: { x: number; y: number; pitch: number };\n}\n\nexport interface CatalogPoseProvider {\n\tkind: 'carousel';\n\tread(): CatalogPose;\n}\n\n/** Presentation controls, never asset scale, URL or renderer ownership. */\nexport interface CarouselPresentation {\n\t/** Horizontal spacing multiplier, normalized around the default 0.48. */\n\tradius?: number;\n\t/** Turntable depth control in CSS-world pixels (default 700). */\n\tdepth?: number;\n}\n\n/** Cached section metrics, shared by DOM hit targets, posters and GPU poses. */\nexport interface CarouselLayout {\n\twidth: number;\n\theight: number;\n\tleft: number;\n\tviewportWidth: number;\n}\n\nconst defaultLayout: CarouselLayout = { width: 1320, height: 560, left: 60, viewportWidth: 1440 };\n\nexport interface CarouselEmphasis { advance: number; panel: number }\n\nexport function carouselEmphasis(distance: number): CarouselEmphasis {\n\treturn { advance: Math.max(0, 1 - distance * distance) ** 2,\n\t\tpanel: Math.max(0, 1 - Math.abs(distance)) ** 2 };\n}\n\n/** A gesture can only withdraw its initial presentation, never select passing seats. */\nexport class CarouselDragEmphasis {\n\tprivate travel = 0;\n\tconstructor(private readonly phase: number, private readonly initial: readonly CarouselEmphasis[]) {}\n\tmove(phase: number): CarouselEmphasis[] {\n\t\tthis.travel = Math.max(this.travel, Math.abs(phase - this.phase));\n\t\tconst remaining = carouselEmphasis(this.travel);\n\t\treturn this.initial.map(value => ({\n\t\t\tadvance: value.advance * remaining.advance,\n\t\t\tpanel: value.panel * remaining.panel\n\t\t}));\n\t}\n}\n\nfunction framing(distance: number, presentation: CarouselPresentation, layout: CarouselLayout,\n\temphasis = carouselEmphasis(distance)) {\n\tconst compact = layout.width < 700;\n\tconst frame = Math.min(layout.width, compact ? 360 : layout.height);\n\tconst spacing = Number.isFinite(presentation.radius)\n\t\t? Math.max(0.2, Math.min(0.7, presentation.radius!)) : 0.48;\n\tconst depth = Number.isFinite(presentation.depth)\n\t\t? Math.max(0, Math.min(1200, presentation.depth!)) : 700;\n\t// A larger, shallower turntable: keep useful seat spacing by reducing the\n\t// angle between products rather than packing the same angle onto a larger ring.\n\tconst radius = frame * (compact ? 2.2 : 3.4) * spacing / 0.48 * (0.75 + depth / 2800);\n\tconst step = 0.4;\n\tconst travel = Math.abs(distance);\n\t// Only the front arc is presented. Never wrap a long catalog onto occupied seats.\n\tconst angle = Math.max(-1.35, Math.min(1.35, distance * step));\n\tconst pitch = 10 * Math.PI / 180;\n\tconst pull = frame * 1.25;\n\t// Smooth at both the selected seat and the point where it rejoins the ring.\n\tconst advance = pull * emphasis.advance;\n\tconst recession = radius * (1 - Math.cos(angle)) + pull - advance;\n\tconst z = -recession * Math.cos(pitch);\n\t// Selection changes depth only; every seat retains its horizontal position.\n\tconst orbit = {\n\t\tx: radius * Math.sin(angle),\n\t\ty: recession * Math.sin(pitch),\n\t\tpitch\n\t};\n\tconst scale = 2500 / (2500 - z);\n\tconst anchor = layout.left + layout.width * (compact ? 0.5 : 0.31);\n\tconst center = layout.viewportWidth / 2 + (anchor - layout.viewportWidth / 2 + orbit.x) * scale;\n\tconst offset = center - anchor;\n\tconst extent = frame * 0.82 * scale * 0.6;\n\tconst seats = compact ? 1.49 : 3.24;\n\tconst arcOpacity = Math.max(0, Math.min(1, (seats - travel) / 0.38));\n\treturn { offset, scale, center, extent, orbit, z, angle, arcOpacity, seats };\n}\n\nexport function carouselDistance(index: number, phase: number, count: number) {\n\treturn count > 1 ? index - phase : 0;\n}\n\n/** Prepare only the viewport and a small margin, including fractional drag movement. */\nexport function carouselResident(index: number, phase: number, count: number,\n\tpresentation: CarouselPresentation = {}, layout: CarouselLayout = defaultLayout) {\n\tconst distance = carouselDistance(index, phase, count);\n\tconst { seats } = framing(distance, presentation, layout);\n\t// Include the neighbouring animation window before the front arc enters view.\n\treturn Math.abs(distance) < seats + 1;\n}\n\n/** A shared circular turntable, tilted toward the viewer, with a smooth foreground advance. */\nexport function carouselPose(\n\tindex: number,\n\tphase: number,\n\tcount: number,\n\tpresentation: CarouselPresentation = {},\n\tlayout: CarouselLayout = defaultLayout,\n\temphasis = carouselEmphasis(carouselDistance(index, phase, count)),\n\t/** Shared foreground focus: zero keeps the whole turntable sharp. */\n\tfocus = 1\n): CatalogPose {\n\tconst distance = carouselDistance(index, phase, count);\n\tconst { offset, scale, center, extent, orbit, z, angle, arcOpacity } = framing(distance, presentation, layout, emphasis);\n\tconst edge = Math.max(0, Math.min(1, (center + extent) / 48, (layout.viewportWidth - center + extent) / 48)) * arcOpacity;\n\treturn {\n\t\tx: 0.5 + offset / Math.max(1, layout.width),\n\t\ty: 0.54 - orbit.y * scale / Math.max(1, layout.height),\n\t\tsize: 0.82 * scale,\n\t\tdepth: z,\n\t\torbit,\n\t\tyaw: angle,\n\t\tvisible: edge > 0,\n\t\tfront: Math.abs(distance) <= 0.5,\n\t\tpanelOpacity: emphasis.panel,\n\t\tblur: Math.min(5, Math.max(0, Math.abs(distance) - 0.15) ** 1.4 * 2.2) * focus,\n\t\topacity: edge\n\t};\n}\n\nexport const CATALOG_POSE_CHANGED = 'catalog-pose-changed';\n"]}
@@ -0,0 +1,21 @@
1
+ import { Quaternion } from 'three/webgpu';
2
+ /** W3C intrinsic Z-X-Y orientation, expressed in the current screen frame. */
3
+ export declare function screenOrientation(alpha: number, beta: number, gamma: number, angle: number): Quaternion;
4
+ /** Bounded screen-relative yaw, pitch and roll, in degrees, without a render loop. */
5
+ export declare class DeviceYawFilter {
6
+ private reference?;
7
+ private previous?;
8
+ private time;
9
+ private quietUntil;
10
+ private filtered;
11
+ private filteredPitch;
12
+ private filteredRoll;
13
+ value: number;
14
+ pitch: number;
15
+ roll: number;
16
+ reset(): void;
17
+ /** Re-anchor to the new grip, retaining output so it can ease back to neutral. */
18
+ resume(q: Quaternion, now: number): void;
19
+ update(q: Quaternion, now: number, smoothingMs?: number): number;
20
+ }
21
+ //# sourceMappingURL=deviceYaw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deviceYaw.d.ts","sourceRoot":"","sources":["../../src/catalog/deviceYaw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,UAAU,EAAsB,MAAM,cAAc,CAAC;AAErE,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAI1F;AAED,sFAAsF;AACtF,qBAAa,eAAe;IAC3B,OAAO,CAAC,SAAS,CAAC,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAC,CAAa;IAC9B,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,aAAa,CAAK;IAC1B,OAAO,CAAC,YAAY,CAAK;IACzB,KAAK,SAAK;IACV,KAAK,SAAK;IACV,IAAI,SAAK;IACT,KAAK;IAML,kFAAkF;IAClF,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM;IAMjC,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,SAAK;CA8CnD"}
@@ -0,0 +1,87 @@
1
+ import { Euler, Quaternion, Vector3, MathUtils } from 'three/webgpu';
2
+ /** W3C intrinsic Z-X-Y orientation, expressed in the current screen frame. */
3
+ export function screenOrientation(alpha, beta, gamma, angle) {
4
+ return new Quaternion().setFromEuler(new Euler(MathUtils.degToRad(beta), MathUtils.degToRad(gamma), MathUtils.degToRad(alpha), 'ZXY')).multiply(new Quaternion().setFromAxisAngle(new Vector3(0, 0, 1), -MathUtils.degToRad(angle)));
5
+ }
6
+ /** Bounded screen-relative yaw, pitch and roll, in degrees, without a render loop. */
7
+ export class DeviceYawFilter {
8
+ reference;
9
+ previous;
10
+ time = 0;
11
+ quietUntil = 0;
12
+ filtered = 0;
13
+ filteredPitch = 0;
14
+ filteredRoll = 0;
15
+ value = 0;
16
+ pitch = 0;
17
+ roll = 0;
18
+ reset() {
19
+ this.reference = this.previous = undefined;
20
+ this.filtered = this.value = 0;
21
+ this.filteredPitch = this.pitch = 0;
22
+ this.filteredRoll = this.roll = 0;
23
+ }
24
+ /** Re-anchor to the new grip, retaining output so it can ease back to neutral. */
25
+ resume(q, now) {
26
+ this.reference = q.clone();
27
+ this.previous = q.clone();
28
+ this.time = now - 16;
29
+ this.quietUntil = 0;
30
+ }
31
+ update(q, now, smoothingMs = 60) {
32
+ const dt = now - this.time;
33
+ if (!this.reference || !this.previous || dt > 1500 || dt <= 0) {
34
+ this.reference = q.clone();
35
+ this.previous = q.clone();
36
+ this.time = now;
37
+ this.quietUntil = now;
38
+ this.filteredPitch = this.pitch = 0;
39
+ this.filteredRoll = this.roll = 0;
40
+ return this.value = this.filtered = 0;
41
+ }
42
+ const step = MathUtils.radToDeg(this.previous.angleTo(q));
43
+ const speed = step / (dt / 1000);
44
+ this.previous.copy(q);
45
+ this.time = now;
46
+ // Re-anchor after abrupt movement; wait for a quiet grip before responding again.
47
+ // Do not mistake an ordinary deliberate turn or a small noisy sample for travel.
48
+ if (speed > 240 && step > 12)
49
+ this.quietUntil = now + 400;
50
+ let target = 0;
51
+ let pitchTarget = 0;
52
+ let rollTarget = 0;
53
+ if (now < this.quietUntil)
54
+ this.reference.copy(q);
55
+ else {
56
+ const relative = this.reference.clone().invert().multiply(q);
57
+ if (relative.w < 0)
58
+ relative.set(-relative.x, -relative.y, -relative.z, -relative.w);
59
+ const yaw = MathUtils.radToDeg(2 * Math.atan2(relative.y, relative.w));
60
+ const pitch = MathUtils.radToDeg(2 * Math.atan2(relative.x, relative.w));
61
+ const roll = MathUtils.radToDeg(2 * Math.atan2(relative.z, relative.w));
62
+ // Preserve a noise floor while making small intentional turns clearly visible.
63
+ target = Math.sign(yaw) * Math.min(16, Math.max(0, Math.abs(yaw) - 1.2) * 0.55);
64
+ pitchTarget = Math.sign(pitch) * Math.min(10, Math.max(0, Math.abs(pitch) - 1.5) * 0.4);
65
+ rollTarget = Math.sign(roll) * Math.min(6, Math.max(0, Math.abs(roll) - 2) * 0.25);
66
+ }
67
+ const blend = 1 - Math.exp(-Math.min(dt, smoothingMs === 60 ? dt : 50) / smoothingMs);
68
+ this.filtered += (target - this.filtered) * blend;
69
+ this.filteredPitch += (pitchTarget - this.filteredPitch) * blend;
70
+ this.filteredRoll += (rollTarget - this.filteredRoll) * blend;
71
+ if (Math.abs(this.filtered) < 0.08 && target === 0)
72
+ this.filtered = 0;
73
+ if (Math.abs(this.filteredPitch) < 0.08 && pitchTarget === 0)
74
+ this.filteredPitch = 0;
75
+ if (Math.abs(this.filteredRoll) < 0.08 && rollTarget === 0)
76
+ this.filteredRoll = 0;
77
+ // Hysteresis, not rounding: noise at a quantization boundary must not wake rendering.
78
+ if (Math.abs(this.filtered - this.value) >= 0.12 || this.filtered === 0)
79
+ this.value = this.filtered;
80
+ if (Math.abs(this.filteredPitch - this.pitch) >= 0.12 || this.filteredPitch === 0)
81
+ this.pitch = this.filteredPitch;
82
+ if (Math.abs(this.filteredRoll - this.roll) >= 0.12 || this.filteredRoll === 0)
83
+ this.roll = this.filteredRoll;
84
+ return this.value;
85
+ }
86
+ }
87
+ //# sourceMappingURL=deviceYaw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deviceYaw.js","sourceRoot":"","sources":["../../src/catalog/deviceYaw.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAErE,8EAA8E;AAC9E,MAAM,UAAU,iBAAiB,CAAC,KAAa,EAAE,IAAY,EAAE,KAAa,EAAE,KAAa;IAC1F,OAAO,IAAI,UAAU,EAAE,CAAC,YAAY,CAAC,IAAI,KAAK,CAC7C,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CACrF,CAAC,CAAC,QAAQ,CAAC,IAAI,UAAU,EAAE,CAAC,gBAAgB,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAClG,CAAC;AAED,sFAAsF;AACtF,MAAM,OAAO,eAAe;IACnB,SAAS,CAAc;IACvB,QAAQ,CAAc;IACtB,IAAI,GAAG,CAAC,CAAC;IACT,UAAU,GAAG,CAAC,CAAC;IACf,QAAQ,GAAG,CAAC,CAAC;IACb,aAAa,GAAG,CAAC,CAAC;IAClB,YAAY,GAAG,CAAC,CAAC;IACzB,KAAK,GAAG,CAAC,CAAC;IACV,KAAK,GAAG,CAAC,CAAC;IACV,IAAI,GAAG,CAAC,CAAC;IACT,KAAK;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nexport function screenOrientation(alpha: number, beta: number, gamma: number, angle: number) {\n\treturn new Quaternion().setFromEuler(new Euler(\n\t\tMathUtils.degToRad(beta), MathUtils.degToRad(gamma), MathUtils.degToRad(alpha), 'ZXY'\n\t)).multiply(new Quaternion().setFromAxisAngle(new Vector3(0, 0, 1), -MathUtils.degToRad(angle)));\n}\n\n/** Bounded screen-relative yaw, pitch and roll, in degrees, without a render loop. */\nexport class DeviceYawFilter {\n\tprivate reference?: Quaternion;\n\tprivate previous?: Quaternion;\n\tprivate time = 0;\n\tprivate quietUntil = 0;\n\tprivate filtered = 0;\n\tprivate filteredPitch = 0;\n\tprivate filteredRoll = 0;\n\tvalue = 0;\n\tpitch = 0;\n\troll = 0;\n\treset() {\n\t\tthis.reference = this.previous = undefined;\n\t\tthis.filtered = this.value = 0;\n\t\tthis.filteredPitch = this.pitch = 0;\n\t\tthis.filteredRoll = this.roll = 0;\n\t}\n\t/** Re-anchor to the new grip, retaining output so it can ease back to neutral. */\n\tresume(q: Quaternion, now: number) {\n\t\tthis.reference = q.clone();\n\t\tthis.previous = q.clone();\n\t\tthis.time = now - 16;\n\t\tthis.quietUntil = 0;\n\t}\n\tupdate(q: Quaternion, now: number, smoothingMs = 60) {\n\t\tconst dt = now - this.time;\n\t\tif (!this.reference || !this.previous || dt > 1500 || dt <= 0) {\n\t\t\tthis.reference = q.clone();\n\t\t\tthis.previous = q.clone();\n\t\t\tthis.time = now;\n\t\t\tthis.quietUntil = now;\n\t\t\tthis.filteredPitch = this.pitch = 0;\n\t\t\tthis.filteredRoll = this.roll = 0;\n\t\t\treturn this.value = this.filtered = 0;\n\t\t}\n\t\tconst step = MathUtils.radToDeg(this.previous.angleTo(q));\n\t\tconst speed = step / (dt / 1000);\n\t\tthis.previous.copy(q);\n\t\tthis.time = now;\n\t\t// Re-anchor after abrupt movement; wait for a quiet grip before responding again.\n\t\t// Do not mistake an ordinary deliberate turn or a small noisy sample for travel.\n\t\tif (speed > 240 && step > 12) this.quietUntil = now + 400;\n\t\tlet target = 0;\n\t\tlet pitchTarget = 0;\n\t\tlet rollTarget = 0;\n\t\tif (now < this.quietUntil) this.reference.copy(q);\n\t\telse {\n\t\t\tconst relative = this.reference.clone().invert().multiply(q);\n\t\t\tif (relative.w < 0) relative.set(-relative.x, -relative.y, -relative.z, -relative.w);\n\t\t\tconst yaw = MathUtils.radToDeg(2 * Math.atan2(relative.y, relative.w));\n\t\t\tconst pitch = MathUtils.radToDeg(2 * Math.atan2(relative.x, relative.w));\n\t\t\tconst roll = MathUtils.radToDeg(2 * Math.atan2(relative.z, relative.w));\n\t\t\t// Preserve a noise floor while making small intentional turns clearly visible.\n\t\t\ttarget = Math.sign(yaw) * Math.min(16, Math.max(0, Math.abs(yaw) - 1.2) * 0.55);\n\t\t\tpitchTarget = Math.sign(pitch) * Math.min(10, Math.max(0, Math.abs(pitch) - 1.5) * 0.4);\n\t\t\trollTarget = Math.sign(roll) * Math.min(6, Math.max(0, Math.abs(roll) - 2) * 0.25);\n\t\t}\n\t\tconst blend = 1 - Math.exp(-Math.min(dt, smoothingMs === 60 ? dt : 50) / smoothingMs);\n\t\tthis.filtered += (target - this.filtered) * blend;\n\t\tthis.filteredPitch += (pitchTarget - this.filteredPitch) * blend;\n\t\tthis.filteredRoll += (rollTarget - this.filteredRoll) * blend;\n\t\tif (Math.abs(this.filtered) < 0.08 && target === 0) this.filtered = 0;\n\t\tif (Math.abs(this.filteredPitch) < 0.08 && pitchTarget === 0) this.filteredPitch = 0;\n\t\tif (Math.abs(this.filteredRoll) < 0.08 && rollTarget === 0) this.filteredRoll = 0;\n\t\t// Hysteresis, not rounding: noise at a quantization boundary must not wake rendering.\n\t\tif (Math.abs(this.filtered - this.value) >= 0.12 || this.filtered === 0) this.value = this.filtered;\n\t\tif (Math.abs(this.filteredPitch - this.pitch) >= 0.12 || this.filteredPitch === 0) this.pitch = this.filteredPitch;\n\t\tif (Math.abs(this.filteredRoll - this.roll) >= 0.12 || this.filteredRoll === 0) this.roll = this.filteredRoll;\n\t\treturn this.value;\n\t}\n}\n"]}
@@ -0,0 +1,15 @@
1
+ export type OrientationStatus = 'unavailable' | 'permission' | 'active' | 'denied';
2
+ export declare const isDeviceOrientationPaused: () => boolean;
3
+ /** Called by native scrolling and the stage's virtual-scroll frame stream. */
4
+ export declare function pauseDeviceOrientationForScroll(): void;
5
+ export declare const getListDeviceYaw: () => number;
6
+ export declare const getListDevicePitch: () => number;
7
+ export declare const getListDeviceRoll: () => number;
8
+ export declare function subscribeListDeviceYaw(callback: () => void): () => void;
9
+ /** A silent probe can recover existing consent; a prompt requires a navigation click. */
10
+ export declare function requestListDeviceOrientation(fromNavigation?: boolean): Promise<void>;
11
+ /** Mount in the application shell so entry via detail/carousel pages also works. */
12
+ export declare function retainDeviceOrientationPermission(): () => void;
13
+ /** One shared sensor listener for all visible opted-in sections, with complete teardown. */
14
+ export declare function retainListDeviceOrientation(node: HTMLElement, callback: (status: OrientationStatus) => void): () => void;
15
+ //# sourceMappingURL=listDeviceOrientation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listDeviceOrientation.d.ts","sourceRoot":"","sources":["../../src/catalog/listDeviceOrientation.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,YAAY,GAAG,QAAQ,GAAG,QAAQ,CAAC;AA0BnF,eAAO,MAAM,yBAAyB,eAAiF,CAAC;AAkBxH,8EAA8E;AAC9E,wBAAgB,+BAA+B,SAG9C;AAED,eAAO,MAAM,gBAAgB,cAAY,CAAC;AAC1C,eAAO,MAAM,kBAAkB,cAAc,CAAC;AAC9C,eAAO,MAAM,iBAAiB,cAAa,CAAC;AAC5C,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,IAAI,cAG1D;AA4DD,yFAAyF;AACzF,wBAAgB,4BAA4B,CAAC,cAAc,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBjF;AAuBD,oFAAoF;AACpF,wBAAgB,iCAAiC,eAShD;AAED,4FAA4F;AAC5F,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,cAoD3G"}
@@ -0,0 +1,245 @@
1
+ import { DeviceYawFilter, screenOrientation } from './deviceYaw.js';
2
+ const listeners = new Set();
3
+ const owners = new Map();
4
+ const visible = new Set();
5
+ const filter = new DeviceYawFilter();
6
+ let status = 'unavailable';
7
+ let yaw = 0;
8
+ let pitch = 0;
9
+ let roll = 0;
10
+ let calibratingUntil = 0;
11
+ let observer;
12
+ let motion;
13
+ let lastSample = -Infinity;
14
+ let screenAngle = 0;
15
+ let listening = false;
16
+ let granted = false;
17
+ let denied = false;
18
+ let permissionPending;
19
+ let probedPermission = false;
20
+ let permissionOwners = 0;
21
+ let hasHeading;
22
+ let scrollUntil = 0;
23
+ let scrollPaused = false;
24
+ let recoverUntil = 0;
25
+ const touchPointers = new Set();
26
+ let touches = 0;
27
+ export const isDeviceOrientationPaused = () => touches > 0 || touchPointers.size > 0 || performance.now() < scrollUntil;
28
+ function pointerStart(event) {
29
+ if (event.pointerType !== 'touch')
30
+ return;
31
+ touchPointers.add(event.pointerId);
32
+ pauseDeviceOrientationForScroll();
33
+ }
34
+ function pointerEnd(event) {
35
+ if (touchPointers.delete(event.pointerId))
36
+ pauseDeviceOrientationForScroll();
37
+ }
38
+ function touchChange(event) {
39
+ touches = event.touches.length;
40
+ pauseDeviceOrientationForScroll();
41
+ }
42
+ function releaseTouches() {
43
+ touches = 0;
44
+ touchPointers.clear();
45
+ }
46
+ /** Called by native scrolling and the stage's virtual-scroll frame stream. */
47
+ export function pauseDeviceOrientationForScroll() {
48
+ scrollUntil = performance.now() + 160;
49
+ scrollPaused = true;
50
+ }
51
+ export const getListDeviceYaw = () => yaw;
52
+ export const getListDevicePitch = () => pitch;
53
+ export const getListDeviceRoll = () => roll;
54
+ export function subscribeListDeviceYaw(callback) {
55
+ listeners.add(callback);
56
+ return () => { listeners.delete(callback); };
57
+ }
58
+ function publish(value, pitchValue = 0, rollValue = 0) {
59
+ if (value === yaw && pitchValue === pitch && rollValue === roll)
60
+ return;
61
+ yaw = value;
62
+ pitch = pitchValue;
63
+ roll = rollValue;
64
+ for (const callback of listeners)
65
+ callback();
66
+ }
67
+ function reset() {
68
+ filter.reset();
69
+ lastSample = -Infinity;
70
+ publish(0);
71
+ }
72
+ function readScreenAngle() {
73
+ return window.screen.orientation?.angle ?? window.orientation ?? 0;
74
+ }
75
+ function recalibrateScreen() {
76
+ screenAngle = readScreenAngle();
77
+ calibratingUntil = performance.now() + 300;
78
+ reset();
79
+ }
80
+ function sample(event) {
81
+ const now = performance.now();
82
+ // Do not parse, filter, allocate quaternions or invalidate GPU rendering during scrolling.
83
+ if (isDeviceOrientationPaused())
84
+ return;
85
+ const { alpha, beta, gamma } = event;
86
+ if (![beta, gamma].every(value => typeof value === 'number' && Number.isFinite(value))) {
87
+ reset();
88
+ return;
89
+ }
90
+ if (readScreenAngle() !== screenAngle)
91
+ recalibrateScreen();
92
+ // Screen rotation and sensor events can arrive in either order. Let the screen settle.
93
+ if (now < calibratingUntil)
94
+ return;
95
+ if (now - lastSample < 1000 / 60 - 1)
96
+ return;
97
+ lastSample = now;
98
+ // Some sensor/browser combinations expose tilt without a heading. Keep tilt usable.
99
+ const headingAvailable = typeof alpha === 'number' && Number.isFinite(alpha);
100
+ if (hasHeading !== headingAvailable) {
101
+ hasHeading = headingAvailable;
102
+ reset();
103
+ }
104
+ const orientation = screenOrientation(headingAvailable ? alpha : 0, beta, gamma, screenAngle);
105
+ if (scrollPaused) {
106
+ scrollPaused = false;
107
+ filter.resume(orientation, now);
108
+ recoverUntil = now + 700;
109
+ }
110
+ publish(filter.update(orientation, now, now < recoverUntil ? 400 : 60), filter.pitch, filter.roll);
111
+ }
112
+ function sync() {
113
+ // Pointer media queries describe input devices, not sensor availability (e.g. Surface).
114
+ const available = window.isSecureContext && 'DeviceOrientationEvent' in window && !motion?.matches;
115
+ status = !available ? 'unavailable' : granted ? 'active'
116
+ : window.DeviceOrientationEvent.requestPermission ? (denied ? 'denied' : 'permission') : 'active';
117
+ const active = status === 'active' && visible.size > 0 && !document.hidden;
118
+ if (active !== listening) {
119
+ listening = active;
120
+ if (active)
121
+ window.addEventListener('deviceorientation', sample, { passive: true });
122
+ else
123
+ window.removeEventListener('deviceorientation', sample);
124
+ reset();
125
+ }
126
+ for (const callback of owners.values())
127
+ callback(status);
128
+ }
129
+ /** A silent probe can recover existing consent; a prompt requires a navigation click. */
130
+ export function requestListDeviceOrientation(fromNavigation = true) {
131
+ if (granted || denied)
132
+ return Promise.resolve();
133
+ if (permissionPending)
134
+ return permissionPending;
135
+ const attempt = async () => {
136
+ try {
137
+ const permission = window.DeviceOrientationEvent.requestPermission;
138
+ granted = !permission || await permission.call(window.DeviceOrientationEvent) === 'granted';
139
+ denied = !granted;
140
+ }
141
+ catch {
142
+ // NotAllowedError without user activation is not a user denial.
143
+ if (fromNavigation)
144
+ denied = true;
145
+ }
146
+ if (owners.size)
147
+ sync();
148
+ };
149
+ permissionPending = attempt().finally(() => { permissionPending = undefined; });
150
+ return permissionPending;
151
+ }
152
+ function permissionAvailable() {
153
+ return window.isSecureContext && 'DeviceOrientationEvent' in window &&
154
+ !window.matchMedia('(prefers-reduced-motion: reduce)').matches;
155
+ }
156
+ function autoPermission() {
157
+ if (!permissionAvailable() || probedPermission)
158
+ return;
159
+ probedPermission = true;
160
+ void requestListDeviceOrientation(false);
161
+ }
162
+ function navigationPermission(event) {
163
+ if (!event.isTrusted || event.defaultPrevented || event.button !== 0 || event.metaKey ||
164
+ event.ctrlKey || event.shiftKey || event.altKey || !permissionAvailable())
165
+ return;
166
+ const anchor = event.composedPath().find(node => node instanceof HTMLAnchorElement);
167
+ if (!anchor || !anchor.hasAttribute('href') || anchor.hasAttribute('download') ||
168
+ (anchor.target && anchor.target !== '_self'))
169
+ return;
170
+ const destination = new URL(anchor.href, window.location.href);
171
+ if (destination.origin !== window.location.origin || !['http:', 'https:'].includes(destination.protocol))
172
+ return;
173
+ // Invoke synchronously, before the router handles the click; never hold up navigation.
174
+ void requestListDeviceOrientation(true);
175
+ }
176
+ /** Mount in the application shell so entry via detail/carousel pages also works. */
177
+ export function retainDeviceOrientationPermission() {
178
+ const preference = window.matchMedia('(prefers-reduced-motion: reduce)');
179
+ if (permissionOwners++ === 0)
180
+ document.addEventListener('click', navigationPermission, true);
181
+ preference.addEventListener('change', autoPermission);
182
+ autoPermission();
183
+ return () => {
184
+ preference.removeEventListener('change', autoPermission);
185
+ if (--permissionOwners === 0)
186
+ document.removeEventListener('click', navigationPermission, true);
187
+ };
188
+ }
189
+ /** One shared sensor listener for all visible opted-in sections, with complete teardown. */
190
+ export function retainListDeviceOrientation(node, callback) {
191
+ const releasePermission = retainDeviceOrientationPermission();
192
+ owners.set(node, callback);
193
+ if (owners.size === 1) {
194
+ scrollUntil = recoverUntil = 0;
195
+ scrollPaused = false;
196
+ window.addEventListener('scroll', pauseDeviceOrientationForScroll, { passive: true, capture: true });
197
+ window.addEventListener('pointerdown', pointerStart, { passive: true, capture: true });
198
+ window.addEventListener('pointerup', pointerEnd, { passive: true, capture: true });
199
+ window.addEventListener('pointercancel', pointerEnd, { passive: true, capture: true });
200
+ for (const name of ['touchstart', 'touchend', 'touchcancel'])
201
+ window.addEventListener(name, touchChange, { passive: true, capture: true });
202
+ window.addEventListener('blur', releaseTouches);
203
+ screenAngle = readScreenAngle();
204
+ calibratingUntil = 0;
205
+ window.screen.orientation?.addEventListener?.('change', recalibrateScreen);
206
+ window.addEventListener('orientationchange', recalibrateScreen);
207
+ motion = window.matchMedia('(prefers-reduced-motion: reduce)');
208
+ motion.addEventListener('change', sync);
209
+ document.addEventListener('visibilitychange', sync);
210
+ observer = new IntersectionObserver(entries => {
211
+ for (const entry of entries) {
212
+ if (entry.isIntersecting)
213
+ visible.add(entry.target);
214
+ else
215
+ visible.delete(entry.target);
216
+ }
217
+ sync();
218
+ });
219
+ }
220
+ observer.observe(node);
221
+ sync();
222
+ return () => {
223
+ releasePermission();
224
+ observer?.unobserve(node);
225
+ visible.delete(node);
226
+ owners.delete(node);
227
+ if (!owners.size) {
228
+ window.removeEventListener('scroll', pauseDeviceOrientationForScroll, true);
229
+ window.removeEventListener('pointerdown', pointerStart, true);
230
+ window.removeEventListener('pointerup', pointerEnd, true);
231
+ window.removeEventListener('pointercancel', pointerEnd, true);
232
+ for (const name of ['touchstart', 'touchend', 'touchcancel'])
233
+ window.removeEventListener(name, touchChange, true);
234
+ window.removeEventListener('blur', releaseTouches);
235
+ releaseTouches();
236
+ window.screen.orientation?.removeEventListener?.('change', recalibrateScreen);
237
+ window.removeEventListener('orientationchange', recalibrateScreen);
238
+ observer?.disconnect();
239
+ motion?.removeEventListener('change', sync);
240
+ document.removeEventListener('visibilitychange', sync);
241
+ }
242
+ sync();
243
+ };
244
+ }
245
+ //# sourceMappingURL=listDeviceOrientation.js.map