@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
@@ -1,4 +1,5 @@
1
1
  import * as THREE from 'three/webgpu';
2
+ import type { StageInteractionTheme } from '../stage/stageTypes.js';
2
3
  import type { SpatialElementRefinement } from '../stage/SpatialElementRefinement.js';
3
4
  export interface SpatialElementProjection {
4
5
  /** Visible section rectangle in CSS pixels, copied before its DOM owner unmounts. */
@@ -21,6 +22,7 @@ export declare class SpatialGeometryCapture {
21
22
  readonly model: THREE.Object3D;
22
23
  private source;
23
24
  getRenderTargets(): THREE.RenderTarget<THREE.Texture<unknown, THREE.TextureEventMap>, THREE.RenderTargetEventMap>[];
25
+ private readonly outline;
24
26
  private readonly scene;
25
27
  private readonly camera;
26
28
  private target?;
@@ -32,6 +34,7 @@ export declare class SpatialGeometryCapture {
32
34
  private frames;
33
35
  private sourceEnvironmentIntensity;
34
36
  constructor(model: THREE.Object3D, source: SpatialElementProjection, options: {
37
+ outlineTheme?: StageInteractionTheme;
35
38
  environment: THREE.Texture | null;
36
39
  environmentIntensity?: number;
37
40
  highEnvironment?: THREE.Texture;
@@ -49,6 +52,12 @@ export declare class SpatialGeometryCapture {
49
52
  render(renderer: THREE.WebGPURenderer): void;
50
53
  getSnapshot(): {
51
54
  frames: number;
55
+ outline: {
56
+ captures: number;
57
+ passes: number;
58
+ targets: number;
59
+ size: number;
60
+ };
52
61
  progress: number;
53
62
  highWeight: number;
54
63
  projection: THREE.Matrix4Tuple;
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialGeometryCapture.d.ts","sourceRoot":"","sources":["../../src/catalog/SpatialGeometryCapture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAMtC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAErF,MAAM,WAAW,wBAAwB;IACxC,qFAAqF;IACrF,YAAY,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5E,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,yFAAyF;IACzF,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG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;;IAWX,QAAQ;;;;IAWR,OAAO;CAaP"}
@@ -1,4 +1,5 @@
1
1
  import * as THREE from 'three/webgpu';
2
+ import { CatalogModelOutline } from './CatalogModelOutline.js';
2
3
  import { getSpatialElementHandoffProjection, interpolatePose, normalizeSpatialElementClipMatrix } from './CatalogSpatialElementLayer.js';
3
4
  export function captureSpatialElementProjection(model, camera) {
4
5
  model.updateWorldMatrix(true, true);
@@ -16,8 +17,9 @@ export class SpatialGeometryCapture {
16
17
  model;
17
18
  source;
18
19
  getRenderTargets() {
19
- return this.disposed ? [] : (this.options.blend?.getRenderTargets() ?? []);
20
+ return this.disposed ? [] : [...(this.options.blend?.getRenderTargets() ?? []), ...this.outline.getRenderTargets()];
20
21
  }
22
+ outline = new CatalogModelOutline();
21
23
  scene = new THREE.Scene();
22
24
  camera = new THREE.PerspectiveCamera();
23
25
  target;
@@ -112,6 +114,12 @@ export class SpatialGeometryCapture {
112
114
  this.highWeight >= 1 ? child === this.options.high : child !== this.options.high;
113
115
  renderer.render(this.scene, this.camera);
114
116
  }
117
+ if (this.options.outlineTheme) {
118
+ // A separate mask for each representation avoids retaining a High silhouette after refinement.
119
+ const outlined = this.highWeight >= 0.5 && this.options.high ? this.options.high : children.find(child => child !== this.options.high);
120
+ if (outlined)
121
+ this.outline.render(renderer, this.camera, outlined, viewport, clip, 1 - this.progress, this.options.outlineTheme);
122
+ }
115
123
  this.submitted = captureSpatialElementProjection(this.model, this.camera);
116
124
  this.submitted.fog = this.scene.fog;
117
125
  this.submitted.viewportClip = clip;
@@ -125,6 +133,7 @@ export class SpatialGeometryCapture {
125
133
  getSnapshot() {
126
134
  return {
127
135
  frames: this.frames,
136
+ outline: this.outline.getStats(),
128
137
  progress: this.progress,
129
138
  highWeight: this.highWeight,
130
139
  projection: (this.submitted ?? this.source).clip.toArray(),
@@ -143,6 +152,7 @@ export class SpatialGeometryCapture {
143
152
  if (this.disposed)
144
153
  return;
145
154
  this.disposed = true;
155
+ this.outline.dispose();
146
156
  this.model.removeFromParent();
147
157
  // Returning false hands the prepared blend back to its still-live page owner.
148
158
  let retained = false;
@@ -1 +1 @@
1
- {"version":3,"file":"SpatialGeometryCapture.js","sourceRoot":"","sources":["../../src/catalog/SpatialGeometryCapture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EACN,kCAAkC,EAClC,eAAe,EACf,iCAAiC,EACjC,MAAM,iCAAiC,CAAC;AAczC,MAAM,UAAU,+BAA+B,CAC9C,KAAqB,EACrB,MAA+B;IAE/B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,MAAM,CAAC,iBAAiB,EAAE,CAAC;IAC3B,OAAO;QACN,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE;QAChC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE;QAClC,IAAI,EAAE,iCAAiC,CACtC,IAAI,KAAK,CAAC,OAAO,EAAE;aACjB,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,kBAAkB,CAAC;aACpE,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,EAC7B,IAAI,KAAK,CAAC,OAAO,EAAE,CACnB;KACD,CAAC;AACH,CAAC;AAED,kGAAkG;AAClG,MAAM,OAAO,sBAAsB;IAgBxB;IACD;IAhBT,gBAAgB;QACf,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5E,CAAC;IACgB,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;IAC1B,MAAM,GAAG,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;IAChD,MAAM,CAA4B;IAClC,SAAS,CAA4B;IACrC,QAAQ,GAAG,KAAK,CAAC;IACjB,Q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AQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,KAAK,CAAC;QAC7C,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,QAAQ;gBAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;QAC9C,CAAC;IACF,CAAC;CACD","sourcesContent":["import * as THREE from 'three/webgpu';\nimport {\n\tgetSpatialElementHandoffProjection,\n\tinterpolatePose,\n\tnormalizeSpatialElementClipMatrix\n} from './CatalogSpatialElementLayer.js';\nimport type { SpatialElementRefinement } from '../stage/SpatialElementRefinement.js';\n\nexport interface SpatialElementProjection {\n\t/** Visible section rectangle in CSS pixels, copied before its DOM owner unmounts. */\n\tviewportClip?: { left: number; top: number; width: number; height: number };\n\tenvironmentIntensity?: number;\n\t/** Preserve the catalog depth cue while a rear element travels between render owners. */\n\tfog?: THREE.Fog | THREE.FogExp2 | null;\n\tmodel: THREE.Matrix4;\n\tcamera: THREE.Matrix4;\n\tclip: THREE.Matrix4;\n}\n\nexport function captureSpatialElementProjection(\n\tmodel: THREE.Object3D,\n\tcamera: THREE.PerspectiveCamera\n): SpatialElementProjection {\n\tmodel.updateWorldMatrix(true, true);\n\tcamera.updateMatrixWorld();\n\treturn {\n\t\tmodel: model.matrixWorld.clone(),\n\t\tcamera: camera.matrixWorld.clone(),\n\t\tclip: normalizeSpatialElementClipMatrix(\n\t\t\tnew THREE.Matrix4()\n\t\t\t\t.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse)\n\t\t\t\t.multiply(model.matrixWorld),\n\t\t\tnew THREE.Vector3()\n\t\t)\n\t};\n}\n\n/** A renderer-owned element with copied projection and independently retained asset resources. */\nexport class SpatialGeometryCapture {\n\tgetRenderTargets() {\n\t\treturn this.disposed ? [] : (this.options.blend?.getRenderTargets() ?? []);\n\t}\n\tprivate readonly scene = new THREE.Scene();\n\tprivate readonly camera = new THREE.PerspectiveCamera();\n\tprivate target?: SpatialElementProjection;\n\tprivate submitted?: SpatialElementProjection;\n\tprivate disposed = false;\n\tprivate progress = 0;\n\tprivate highWeight: number;\n\tprivate initialHighWeight: number;\n\tprivate frames = 0;\n\tprivate sourceEnvironmentIntensity: number;\n\n\tconstructor(\n\t\treadonly model: THREE.Object3D,\n\t\tprivate source: SpatialElementProjection,\n\t\toptions: {\n\t\t\tenvironment: THREE.Texture | null;\n\t\t\tenvironmentIntensity?: number;\n\t\t\thighEnvironment?: THREE.Texture;\n\t\t\treferencePoint?: THREE.Vector3;\n\t\t\tlights: THREE.Light[];\n\t\t\thigh?: THREE.Object3D;\n\t\t\thighWeight?: number;\n\t\t\tblend?: SpatialElementRefinement;\n\t\t\trelease(): boolean | void;\n\t\t}\n\t) {\n\t\tthis.options = options;\n\t\tthis.initialHighWeight = this.highWeight = options.highWeight ?? 0;\n\t\tthis.scene.environment = options.environment;\n\t\tthis.sourceEnvironmentIntensity = this.scene.environmentIntensity =\n\t\t\toptions.environmentIntensity ?? 0.5;\n\t\tfor (const light of options.lights) this.scene.add(light.clone());\n\t\tthis.scene.add(model);\n\t\tmodel.matrixAutoUpdate = false;\n\t\tmodel.matrix.copy(source.model);\n\t}\n\tprivate readonly options: {\n\t\tenvironment: THREE.Texture | null;\n\t\tenvironmentIntensity?: number;\n\t\thighEnvironment?: THREE.Texture;\n\t\treferencePoint?: THREE.Vector3;\n\t\tlights: THREE.Light[];\n\t\thigh?: THREE.Object3D;\n\t\thighWeight?: number;\n\t\tblend?: SpatialElementRefinement;\n\t\trelease(): boolean | void;\n\t};\n\n\tsetTarget(target: SpatialElementProjection, progress: number, refinement: number) {\n\t\tthis.target = target;\n\t\tthis.progress = progress;\n\t\tthis.highWeight = this.initialHighWeight * (1 - refinement);\n\t}\n\n\t/** Rebase on the exact submitted projection, without a camera or model reset. */\n\tfreeze() {\n\t\tthis.sourceEnvironmentIntensity = this.scene.environmentIntensity;\n\t\tif (this.submitted) this.source = this.submitted;\n\t\tthis.target = undefined;\n\t\tthis.progress = 0;\n\t\tthis.initialHighWeight = this.highWeight;\n\t}\n\n\trender(renderer: THREE.WebGPURenderer) {\n\t\tif (this.disposed) return;\n\t\tconst target = this.target ?? this.source;\n\t\tthis.scene.fog = target.fog ?? this.source.fog ?? null;\n\t\tthis.scene.environmentIntensity = THREE.MathUtils.lerp(\n\t\t\tthis.sourceEnvironmentIntensity,\n\t\t\ttarget.environmentIntensity ?? this.sourceEnvironmentIntensity,\n\t\t\tthis.progress\n\t\t);\n\t\tconst model = interpolatePose(this.source.model, target.model, this.progress);\n\t\tconst camera = interpolatePose(this.source.camera, target.camera, this.progress);\n\t\tthis.model.matrix.copy(model);\n\t\tthis.model.matrixWorldNeedsUpdate = true;\n\t\tthis.camera.coordinateSystem = renderer.coordinateSystem;\n\t\tcamera.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);\n\t\tthis.camera.updateMatrixWorld();\n\t\tgetSpatialElementHandoffProjection(\n\t\t\tthis.source.clip,\n\t\t\ttarget.clip,\n\t\t\tthis.progress,\n\t\t\tmodel,\n\t\t\tcamera,\n\t\t\t{\n\t\t\t\tsourceModel: this.source.model,\n\t\t\t\tsourceCamera: this.source.camera,\n\t\t\t\ttargetModel: target.model,\n\t\t\t\ttargetCamera: target.camera,\n\t\t\t\treference: this.options.referencePoint\n\t\t\t},\n\t\t\tthis.camera.projectionMatrix\n\t\t);\n\t\tthis.camera.projectionMatrixInverse.copy(this.camera.projectionMatrix).invert();\n\t\tconst viewport = { left: 0, top: 0, width: innerWidth, height: innerHeight };\n\t\tconst from = this.source.viewportClip ?? viewport,\n\t\t\tto = target.viewportClip ?? viewport;\n\t\tconst clip = { ...from };\n\t\tfor (const key of ['left', 'top', 'width', 'height'] as const)\n\t\t\tclip[key] += (to[key] - from[key]) * this.progress;\n\t\tconst previousScissor = renderer.getScissor(new THREE.Vector4());\n\t\tconst previousTest = renderer.getScissorTest();\n\t\tconst left = Math.max(0, clip.left),\n\t\t\ttop = Math.max(0, clip.top);\n\t\trenderer.setScissor(\n\t\t\tleft,\n\t\t\ttop,\n\t\t\tMath.max(0, Math.min(innerWidth, clip.left + clip.width) - left),\n\t\t\tMath.max(0, Math.min(innerHeight, clip.top + clip.height) - top)\n\t\t);\n\t\trenderer.setScissorTest(true);\n\t\ttry {\n\t\t\tconst children = [...this.model.children];\n\t\t\tconst draw = (high: boolean) => {\n\t\t\t\tthis.scene.environment = high\n\t\t\t\t\t? (this.options.highEnvironment ?? this.options.environment)\n\t\t\t\t\t: this.options.environment;\n\t\t\t\tfor (const child of children) child.visible = (child === this.options.high) === high;\n\t\t\t\trenderer.clear();\n\t\t\t\trenderer.render(this.scene, this.camera);\n\t\t\t};\n\t\t\trenderer.clearDepth();\n\t\t\tif (this.options.high && this.options.blend && this.highWeight > 0 && this.highWeight < 1)\n\t\t\t\tthis.options.blend.render(renderer, draw, false, this.highWeight);\n\t\t\telse {\n\t\t\t\tthis.scene.environment =\n\t\t\t\t\tthis.highWeight >= 1\n\t\t\t\t\t\t? (this.options.highEnvironment ?? this.options.environment)\n\t\t\t\t\t\t: this.options.environment;\n\t\t\t\tfor (const child of children)\n\t\t\t\t\tchild.visible =\n\t\t\t\t\t\tthis.highWeight >= 1 ? child === this.options.high : child !== this.options.high;\n\t\t\t\trenderer.render(this.scene, this.camera);\n\t\t\t}\n\t\t\tthis.submitted = captureSpatialElementProjection(this.model, this.camera);\n\t\t\tthis.submitted.fog = this.scene.fog;\n\t\t\tthis.submitted.viewportClip = clip;\n\t\t\tthis.frames++;\n\t\t} finally {\n\t\t\trenderer.setScissor(previousScissor);\n\t\t\trenderer.setScissorTest(previousTest);\n\t\t}\n\t}\n\n\tgetSnapshot() {\n\t\treturn {\n\t\t\tframes: this.frames,\n\t\t\tprogress: this.progress,\n\t\t\thighWeight: this.highWeight,\n\t\t\tprojection: (this.submitted ?? this.source).clip.toArray(),\n\t\t\tdisposed: this.disposed\n\t\t};\n\t}\n\n\tgetPoint() {\n\t\tconst point = this.options.referencePoint ?? new THREE.Vector3();\n\t\tconst clip = new THREE.Vector4(point.x, point.y, point.z, 1).applyMatrix4(\n\t\t\t(this.submitted ?? this.source).clip\n\t\t);\n\t\treturn {\n\t\t\tx: ((clip.x / clip.w + 1) * innerWidth) / 2,\n\t\t\ty: ((1 - clip.y / clip.w) * innerHeight) / 2\n\t\t};\n\t}\n\n\tdispose() {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.model.removeFromParent();\n\t\t// Returning false hands the prepared blend back to its still-live page owner.\n\t\tlet retained = false;\n\t\ttry {\n\t\t\tretained = this.options.release() === false;\n\t\t} finally {\n\t\t\tif (!retained) this.options.blend?.dispose();\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"SpatialGeometryCapture.js","sourceRoot":"","sources":["../../src/catalog/SpatialGeometryCapture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EACN,kCAAkC,EAClC,eAAe,EACf,iCAAiC,EACjC,MAAM,iCAAiC,CAAC;AAczC,MAAM,UAAU,+BAA+B,CAC9C,KAAqB,EACrB,MAA+B;IAE/B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,MAAM,CAAC,iBAAiB,EAAE,CAAC;IAC3B,OAAO;QACN,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE;QAChC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE;QAClC,IAAI,EAAE,iCAAiC,CACtC,IAAI,KAAK,CAAC,OAAO,EAAE;aACjB,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,kBAAkB,CAAC;aACpE,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,EAC7B,IAAI,KAAK,CAAC,OAAO,EAAE,CACnB;KACD,CAAC;AACH,CAAC;AAED,kGAAkG;AAClG,MAAM,OAAO,sBAAsB;I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C,CAAC;gBAAS,CAAC;YACV,IAAI,CAAC,QAAQ;gBAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;QAC9C,CAAC;IACF,CAAC;CACD","sourcesContent":["import * as THREE from 'three/webgpu';\nimport { CatalogModelOutline } from './CatalogModelOutline.js';\nimport type { StageInteractionTheme } from '../stage/stageTypes.js';\nimport {\n\tgetSpatialElementHandoffProjection,\n\tinterpolatePose,\n\tnormalizeSpatialElementClipMatrix\n} from './CatalogSpatialElementLayer.js';\nimport type { SpatialElementRefinement } from '../stage/SpatialElementRefinement.js';\n\nexport interface SpatialElementProjection {\n\t/** Visible section rectangle in CSS pixels, copied before its DOM owner unmounts. */\n\tviewportClip?: { left: number; top: number; width: number; height: number };\n\tenvironmentIntensity?: number;\n\t/** Preserve the catalog depth cue while a rear element travels between render owners. */\n\tfog?: THREE.Fog | THREE.FogExp2 | null;\n\tmodel: THREE.Matrix4;\n\tcamera: THREE.Matrix4;\n\tclip: THREE.Matrix4;\n}\n\nexport function captureSpatialElementProjection(\n\tmodel: THREE.Object3D,\n\tcamera: THREE.PerspectiveCamera\n): SpatialElementProjection {\n\tmodel.updateWorldMatrix(true, true);\n\tcamera.updateMatrixWorld();\n\treturn {\n\t\tmodel: model.matrixWorld.clone(),\n\t\tcamera: camera.matrixWorld.clone(),\n\t\tclip: normalizeSpatialElementClipMatrix(\n\t\t\tnew THREE.Matrix4()\n\t\t\t\t.multiplyMatrices(camera.projectionMatrix, camera.matrixWorldInverse)\n\t\t\t\t.multiply(model.matrixWorld),\n\t\t\tnew THREE.Vector3()\n\t\t)\n\t};\n}\n\n/** A renderer-owned element with copied projection and independently retained asset resources. */\nexport class SpatialGeometryCapture {\n\tgetRenderTargets() {\n\t\treturn this.disposed ? [] : [...(this.options.blend?.getRenderTargets() ?? []), ...this.outline.getRenderTargets()];\n\t}\n\tprivate readonly outline = new CatalogModelOutline();\n\tprivate readonly scene = new THREE.Scene();\n\tprivate readonly camera = new THREE.PerspectiveCamera();\n\tprivate target?: SpatialElementProjection;\n\tprivate submitted?: SpatialElementProjection;\n\tprivate disposed = false;\n\tprivate progress = 0;\n\tprivate highWeight: number;\n\tprivate initialHighWeight: number;\n\tprivate frames = 0;\n\tprivate sourceEnvironmentIntensity: number;\n\n\tconstructor(\n\t\treadonly model: THREE.Object3D,\n\t\tprivate source: SpatialElementProjection,\n\t\toptions: {\n\t\t\toutlineTheme?: StageInteractionTheme;\n\t\t\tenvironment: THREE.Texture | null;\n\t\t\tenvironmentIntensity?: number;\n\t\t\thighEnvironment?: THREE.Texture;\n\t\t\treferencePoint?: THREE.Vector3;\n\t\t\tlights: THREE.Light[];\n\t\t\thigh?: THREE.Object3D;\n\t\t\thighWeight?: number;\n\t\t\tblend?: SpatialElementRefinement;\n\t\t\trelease(): boolean | void;\n\t\t}\n\t) {\n\t\tthis.options = options;\n\t\tthis.initialHighWeight = this.highWeight = options.highWeight ?? 0;\n\t\tthis.scene.environment = options.environment;\n\t\tthis.sourceEnvironmentIntensity = this.scene.environmentIntensity =\n\t\t\toptions.environmentIntensity ?? 0.5;\n\t\tfor (const light of options.lights) this.scene.add(light.clone());\n\t\tthis.scene.add(model);\n\t\tmodel.matrixAutoUpdate = false;\n\t\tmodel.matrix.copy(source.model);\n\t}\n\tprivate readonly options: {\n\t\toutlineTheme?: StageInteractionTheme;\n\t\tenvironment: THREE.Texture | null;\n\t\tenvironmentIntensity?: number;\n\t\thighEnvironment?: THREE.Texture;\n\t\treferencePoint?: THREE.Vector3;\n\t\tlights: THREE.Light[];\n\t\thigh?: THREE.Object3D;\n\t\thighWeight?: number;\n\t\tblend?: SpatialElementRefinement;\n\t\trelease(): boolean | void;\n\t};\n\n\tsetTarget(target: SpatialElementProjection, progress: number, refinement: number) {\n\t\tthis.target = target;\n\t\tthis.progress = progress;\n\t\tthis.highWeight = this.initialHighWeight * (1 - refinement);\n\t}\n\n\t/** Rebase on the exact submitted projection, without a camera or model reset. */\n\tfreeze() {\n\t\tthis.sourceEnvironmentIntensity = this.scene.environmentIntensity;\n\t\tif (this.submitted) this.source = this.submitted;\n\t\tthis.target = undefined;\n\t\tthis.progress = 0;\n\t\tthis.initialHighWeight = this.highWeight;\n\t}\n\n\trender(renderer: THREE.WebGPURenderer) {\n\t\tif (this.disposed) return;\n\t\tconst target = this.target ?? this.source;\n\t\tthis.scene.fog = target.fog ?? this.source.fog ?? null;\n\t\tthis.scene.environmentIntensity = THREE.MathUtils.lerp(\n\t\t\tthis.sourceEnvironmentIntensity,\n\t\t\ttarget.environmentIntensity ?? this.sourceEnvironmentIntensity,\n\t\t\tthis.progress\n\t\t);\n\t\tconst model = interpolatePose(this.source.model, target.model, this.progress);\n\t\tconst camera = interpolatePose(this.source.camera, target.camera, this.progress);\n\t\tthis.model.matrix.copy(model);\n\t\tthis.model.matrixWorldNeedsUpdate = true;\n\t\tthis.camera.coordinateSystem = renderer.coordinateSystem;\n\t\tcamera.decompose(this.camera.position, this.camera.quaternion, this.camera.scale);\n\t\tthis.camera.updateMatrixWorld();\n\t\tgetSpatialElementHandoffProjection(\n\t\t\tthis.source.clip,\n\t\t\ttarget.clip,\n\t\t\tthis.progress,\n\t\t\tmodel,\n\t\t\tcamera,\n\t\t\t{\n\t\t\t\tsourceModel: this.source.model,\n\t\t\t\tsourceCamera: this.source.camera,\n\t\t\t\ttargetModel: target.model,\n\t\t\t\ttargetCamera: target.camera,\n\t\t\t\treference: this.options.referencePoint\n\t\t\t},\n\t\t\tthis.camera.projectionMatrix\n\t\t);\n\t\tthis.camera.projectionMatrixInverse.copy(this.camera.projectionMatrix).invert();\n\t\tconst viewport = { left: 0, top: 0, width: innerWidth, height: innerHeight };\n\t\tconst from = this.source.viewportClip ?? viewport,\n\t\t\tto = target.viewportClip ?? viewport;\n\t\tconst clip = { ...from };\n\t\tfor (const key of ['left', 'top', 'width', 'height'] as const)\n\t\t\tclip[key] += (to[key] - from[key]) * this.progress;\n\t\tconst previousScissor = renderer.getScissor(new THREE.Vector4());\n\t\tconst previousTest = renderer.getScissorTest();\n\t\tconst left = Math.max(0, clip.left),\n\t\t\ttop = Math.max(0, clip.top);\n\t\trenderer.setScissor(\n\t\t\tleft,\n\t\t\ttop,\n\t\t\tMath.max(0, Math.min(innerWidth, clip.left + clip.width) - left),\n\t\t\tMath.max(0, Math.min(innerHeight, clip.top + clip.height) - top)\n\t\t);\n\t\trenderer.setScissorTest(true);\n\t\ttry {\n\t\t\tconst children = [...this.model.children];\n\t\t\tconst draw = (high: boolean) => {\n\t\t\t\tthis.scene.environment = high\n\t\t\t\t\t? (this.options.highEnvironment ?? this.options.environment)\n\t\t\t\t\t: this.options.environment;\n\t\t\t\tfor (const child of children) child.visible = (child === this.options.high) === high;\n\t\t\t\trenderer.clear();\n\t\t\t\trenderer.render(this.scene, this.camera);\n\t\t\t};\n\t\t\trenderer.clearDepth();\n\t\t\tif (this.options.high && this.options.blend && this.highWeight > 0 && this.highWeight < 1)\n\t\t\t\tthis.options.blend.render(renderer, draw, false, this.highWeight);\n\t\t\telse {\n\t\t\t\tthis.scene.environment =\n\t\t\t\t\tthis.highWeight >= 1\n\t\t\t\t\t\t? (this.options.highEnvironment ?? this.options.environment)\n\t\t\t\t\t\t: this.options.environment;\n\t\t\t\tfor (const child of children)\n\t\t\t\t\tchild.visible =\n\t\t\t\t\t\tthis.highWeight >= 1 ? child === this.options.high : child !== this.options.high;\n\t\t\t\trenderer.render(this.scene, this.camera);\n\t\t\t}\n\t\t\tif (this.options.outlineTheme) {\n\t\t\t\t// A separate mask for each representation avoids retaining a High silhouette after refinement.\n\t\t\t\tconst outlined = this.highWeight >= 0.5 && this.options.high ? this.options.high : children.find(child => child !== this.options.high);\n\t\t\t\tif (outlined) this.outline.render(renderer, this.camera, outlined, viewport, clip,\n\t\t\t\t\t1 - this.progress, this.options.outlineTheme);\n\t\t\t}\n\t\t\tthis.submitted = captureSpatialElementProjection(this.model, this.camera);\n\t\t\tthis.submitted.fog = this.scene.fog;\n\t\t\tthis.submitted.viewportClip = clip;\n\t\t\tthis.frames++;\n\t\t} finally {\n\t\t\trenderer.setScissor(previousScissor);\n\t\t\trenderer.setScissorTest(previousTest);\n\t\t}\n\t}\n\n\tgetSnapshot() {\n\t\treturn {\n\t\t\tframes: this.frames,\n\t\t\toutline: this.outline.getStats(),\n\t\t\tprogress: this.progress,\n\t\t\thighWeight: this.highWeight,\n\t\t\tprojection: (this.submitted ?? this.source).clip.toArray(),\n\t\t\tdisposed: this.disposed\n\t\t};\n\t}\n\n\tgetPoint() {\n\t\tconst point = this.options.referencePoint ?? new THREE.Vector3();\n\t\tconst clip = new THREE.Vector4(point.x, point.y, point.z, 1).applyMatrix4(\n\t\t\t(this.submitted ?? this.source).clip\n\t\t);\n\t\treturn {\n\t\t\tx: ((clip.x / clip.w + 1) * innerWidth) / 2,\n\t\t\ty: ((1 - clip.y / clip.w) * innerHeight) / 2\n\t\t};\n\t}\n\n\tdispose() {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.outline.dispose();\n\t\tthis.model.removeFromParent();\n\t\t// Returning false hands the prepared blend back to its still-live page owner.\n\t\tlet retained = false;\n\t\ttry {\n\t\t\tretained = this.options.release() === false;\n\t\t} finally {\n\t\t\tif (!retained) this.options.blend?.dispose();\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /** Fit the authored view into its rectangular slot, including perspective foreshortening. */
2
+ export declare function cardModelFit(corners: readonly {
3
+ x: number;
4
+ y: number;
5
+ z: number;
6
+ }[], width: number, height: number, fill?: number, distance?: number): number;
7
+ //# sourceMappingURL=cardModelFit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cardModelFit.d.ts","sourceRoot":"","sources":["../../src/catalog/cardModelFit.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,wBAAgB,YAAY,CAC3B,OAAO,EAAE,SAAS;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,EACvD,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,IAAI,SAAO,EACX,QAAQ,SAAO,UAYf"}
@@ -0,0 +1,16 @@
1
+ /** Fit the authored view into its rectangular slot, including perspective foreshortening. */
2
+ export function cardModelFit(corners, width, height, fill = 0.87, distance = 1000) {
3
+ const halfWidth = Math.max(width, 1) * fill / 2;
4
+ const halfHeight = Math.max(height, 1) * fill / 2;
5
+ let scale = Infinity;
6
+ for (const point of corners) {
7
+ const x = Math.abs(point.x) + halfWidth * point.z / distance;
8
+ const y = Math.abs(point.y) + halfHeight * point.z / distance;
9
+ if (x > 0)
10
+ scale = Math.min(scale, halfWidth / x);
11
+ if (y > 0)
12
+ scale = Math.min(scale, halfHeight / y);
13
+ }
14
+ return Number.isFinite(scale) ? Math.max(0, scale) : 1;
15
+ }
16
+ //# sourceMappingURL=cardModelFit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cardModelFit.js","sourceRoot":"","sources":["../../src/catalog/cardModelFit.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,MAAM,UAAU,YAAY,CAC3B,OAAuD,EACvD,KAAa,EACb,MAAc,EACd,IAAI,GAAG,IAAI,EACX,QAAQ,GAAG,IAAI;IAEf,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;IAChD,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;IAClD,IAAI,KAAK,GAAG,QAAQ,CAAC;IACrB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,KAAK,CAAC,CAAC,GAAG,QAAQ,CAAC;QAC7D,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,UAAU,GAAG,KAAK,CAAC,CAAC,GAAG,QAAQ,CAAC;QAC9D,IAAI,CAAC,GAAG,CAAC;YAAE,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC;QAClD,IAAI,CAAC,GAAG,CAAC;YAAE,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,UAAU,GAAG,CAAC,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC","sourcesContent":["/** Fit the authored view into its rectangular slot, including perspective foreshortening. */\nexport function cardModelFit(\n\tcorners: readonly { x: number; y: number; z: number }[],\n\twidth: number,\n\theight: number,\n\tfill = 0.87,\n\tdistance = 1000\n) {\n\tconst halfWidth = Math.max(width, 1) * fill / 2;\n\tconst halfHeight = Math.max(height, 1) * fill / 2;\n\tlet scale = Infinity;\n\tfor (const point of corners) {\n\t\tconst x = Math.abs(point.x) + halfWidth * point.z / distance;\n\t\tconst y = Math.abs(point.y) + halfHeight * point.z / distance;\n\t\tif (x > 0) scale = Math.min(scale, halfWidth / x);\n\t\tif (y > 0) scale = Math.min(scale, halfHeight / y);\n\t}\n\treturn Number.isFinite(scale) ? Math.max(0, scale) : 1;\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { CssProjectionQuad } from '../stage/cssProjection.js';
2
+ /** Keep the card's tilted, raised text in its original layout when navigation takes over. */
3
+ export declare function captureCardElement(element: HTMLElement): {
4
+ width: number;
5
+ height: number;
6
+ corners: CssProjectionQuad;
7
+ } | undefined;
8
+ //# sourceMappingURL=cardProjection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cardProjection.d.ts","sourceRoot":"","sources":["../../src/catalog/cardProjection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AA4BnE,6FAA6F;AAC7F,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW;;;;cAsBtD"}
@@ -0,0 +1,51 @@
1
+ function borderBox(element) {
2
+ const style = getComputedStyle(element);
3
+ const px = (property) => Number.parseFloat(style.getPropertyValue(property)) || 0;
4
+ return {
5
+ width: px('width') + (style.boxSizing === 'border-box' ? 0 :
6
+ px('padding-left') + px('padding-right') + px('border-left-width') + px('border-right-width')),
7
+ height: px('height') + (style.boxSizing === 'border-box' ? 0 :
8
+ px('padding-top') + px('padding-bottom') + px('border-top-width') + px('border-bottom-width'))
9
+ };
10
+ }
11
+ function localTransform(element) {
12
+ const style = getComputedStyle(element);
13
+ const [x, y, z = 0] = style.transformOrigin.split(' ').map(Number.parseFloat);
14
+ return new DOMMatrix().translate(x, y, z)
15
+ .multiply(new DOMMatrix(style.transform === 'none' ? undefined : style.transform))
16
+ .translate(-x, -y, -z);
17
+ }
18
+ function project(matrix, width, height) {
19
+ return [[0, 0], [width, 0], [width, height], [0, height]].map(([x, y]) => {
20
+ const point = matrix.transformPoint(new DOMPoint(x, y));
21
+ return { x: point.x / point.w, y: point.y / point.w };
22
+ });
23
+ }
24
+ /** Keep the card's tilted, raised text in its original layout when navigation takes over. */
25
+ export function captureCardElement(element) {
26
+ const card = element.closest('[data-catalog-card]');
27
+ if (!card)
28
+ return;
29
+ const { width, height } = borderBox(element);
30
+ const cardSize = borderBox(card);
31
+ if (!width || !height || !cardSize.width || !cardSize.height)
32
+ return;
33
+ let matrix = new DOMMatrix();
34
+ for (let node = element; node !== card;) {
35
+ matrix = new DOMMatrix().translate(node.offsetLeft, node.offsetTop)
36
+ .multiply(localTransform(node)).multiply(matrix);
37
+ const parent = node.offsetParent;
38
+ if (!(parent instanceof HTMLElement) || (parent !== card && !card.contains(parent)))
39
+ return;
40
+ node = parent;
41
+ }
42
+ const cardMatrix = localTransform(card);
43
+ const cardCorners = project(cardMatrix, cardSize.width, cardSize.height);
44
+ const rect = card.getBoundingClientRect();
45
+ const x = rect.left - Math.min(...cardCorners.map((point) => point.x));
46
+ const y = rect.top - Math.min(...cardCorners.map((point) => point.y));
47
+ const corners = project(cardMatrix.multiply(matrix), width, height)
48
+ .map((point) => ({ x: point.x + x, y: point.y + y }));
49
+ return { width, height, corners };
50
+ }
51
+ //# sourceMappingURL=cardProjection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cardProjection.js","sourceRoot":"","sources":["../../src/catalog/cardProjection.ts"],"names":[],"mappings":"AAEA,SAAS,SAAS,CAAC,OAAoB;IACtC,MAAM,KAAK,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,EAAE,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;IAC1F,OAAO;QACN,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3D,EAAE,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,CAAC,mBAAmB,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,CAAC;QAC/F,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC7D,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,CAAC;KAC/F,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,OAAoB;IAC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,GAAG,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC;SACjE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAiC,CAAC;IACvF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AACnC,CAAC","sourcesContent":["import type { CssProjectionQuad } from '../stage/cssProjection.js';\n\nfunction borderBox(element: HTMLElement) {\n\tconst style = getComputedStyle(element);\n\tconst px = (property: string) => Number.parseFloat(style.getPropertyValue(property)) || 0;\n\treturn {\n\t\twidth: px('width') + (style.boxSizing === 'border-box' ? 0 :\n\t\t\tpx('padding-left') + px('padding-right') + px('border-left-width') + px('border-right-width')),\n\t\theight: px('height') + (style.boxSizing === 'border-box' ? 0 :\n\t\t\tpx('padding-top') + px('padding-bottom') + px('border-top-width') + px('border-bottom-width'))\n\t};\n}\n\nfunction localTransform(element: HTMLElement) {\n\tconst style = getComputedStyle(element);\n\tconst [x, y, z = 0] = style.transformOrigin.split(' ').map(Number.parseFloat);\n\treturn new DOMMatrix().translate(x, y, z)\n\t\t.multiply(new DOMMatrix(style.transform === 'none' ? undefined : style.transform))\n\t\t.translate(-x, -y, -z);\n}\n\nfunction project(matrix: DOMMatrix, width: number, height: number): CssProjectionQuad {\n\treturn [[0, 0], [width, 0], [width, height], [0, height]].map(([x, y]) => {\n\t\tconst point = matrix.transformPoint(new DOMPoint(x, y));\n\t\treturn { x: point.x / point.w, y: point.y / point.w };\n\t}) as unknown as CssProjectionQuad;\n}\n\n/** Keep the card's tilted, raised text in its original layout when navigation takes over. */\nexport function captureCardElement(element: HTMLElement) {\n\tconst card = element.closest<HTMLElement>('[data-catalog-card]');\n\tif (!card) return;\n\tconst { width, height } = borderBox(element);\n\tconst cardSize = borderBox(card);\n\tif (!width || !height || !cardSize.width || !cardSize.height) return;\n\tlet matrix = new DOMMatrix();\n\tfor (let node = element; node !== card;) {\n\t\tmatrix = new DOMMatrix().translate(node.offsetLeft, node.offsetTop)\n\t\t\t.multiply(localTransform(node)).multiply(matrix);\n\t\tconst parent: Element | null = node.offsetParent;\n\t\tif (!(parent instanceof HTMLElement) || (parent !== card && !card.contains(parent))) return;\n\t\tnode = parent;\n\t}\n\tconst cardMatrix = localTransform(card);\n\tconst cardCorners = project(cardMatrix, cardSize.width, cardSize.height);\n\tconst rect = card.getBoundingClientRect();\n\tconst x = rect.left - Math.min(...cardCorners.map((point) => point.x));\n\tconst y = rect.top - Math.min(...cardCorners.map((point) => point.y));\n\tconst corners = project(cardMatrix.multiply(matrix), width, height)\n\t\t.map((point) => ({ x: point.x + x, y: point.y + y })) as unknown as CssProjectionQuad;\n\treturn { width, height, corners };\n}\n"]}
@@ -1,3 +1,28 @@
1
+ /** Wheel adapter only: the carousel controller remains the sole owner of motion.
2
+ * Keep the last input time separate from the idle detection delay: that delay
3
+ * is not a physical hold and must not erase the release velocity.
4
+ */
5
+ export declare class CarouselWheelInput {
6
+ x: number;
7
+ idleMs: number;
8
+ lastTime: number | undefined;
9
+ samples: number;
10
+ move(delta: number, now: number): void;
11
+ }
12
+ /** Soft direction preference based on recent travel; never locks either axis. */
13
+ export declare class CarouselTouchDirection {
14
+ x: number;
15
+ y: number;
16
+ private horizontal;
17
+ private vertical;
18
+ private lastX;
19
+ private lastY;
20
+ constructor(x: number, y: number);
21
+ move(x: number, y: number): {
22
+ x: number;
23
+ y: number;
24
+ };
25
+ }
1
26
  /** Horizontal carousel motion, independent of the gesture's vertical scrolling. */
2
27
  export declare class CarouselDrag {
3
28
  private readonly startX;
@@ -15,6 +40,16 @@ export declare class CarouselDrag {
15
40
  };
16
41
  }
17
42
  export declare function clampCarouselPhase(phase: number, count: number): number;
43
+ /** Snap the predicted stopping point into a critically damped trajectory.
44
+ * Preserve release speed, but raise damping for a close boundary so there is
45
+ * no overshoot or backwards correction. Progress also drives foreground reveal.
46
+ */
47
+ export declare function sampleCarouselInertia(start: number, velocity: number, target: number, elapsed: number): {
48
+ phase: number;
49
+ velocity: number;
50
+ progress: number;
51
+ finished: boolean;
52
+ };
18
53
  /** Analytic critical damping, independent of refresh rate and dropped frames. */
19
54
  export declare function sampleCarouselSpring(start: number, velocity: number, target: number, elapsed: number): {
20
55
  phase: number;
@@ -1 +1 @@
1
- {"version":3,"file":"carouselMotion.d.ts","sourceRoot":"","sources":["../../src/catalog/carouselMotion.ts"],"names":[],"mappings":"AAIA,mFAAmF;AACnF,qBAAa,YAAY;IAQvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAR5B,MAAM,UAAS;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;gBAGJ,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EACnC,GAAG,EAAE,MAAM;IAOZ,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAe1C,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,SAAa;;;;CAUlD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,UAE9D;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,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ED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;;;EAO7G"}
@@ -1,6 +1,59 @@
1
1
  const PIXELS_PER_ITEM = 220;
2
2
  const DRAG_THRESHOLD = 8;
3
- const MAX_VELOCITY = 0.01;
3
+ const MAX_VELOCITY = 0.025;
4
+ const INERTIA_TIME = 320;
5
+ /** Wheel adapter only: the carousel controller remains the sole owner of motion.
6
+ * Keep the last input time separate from the idle detection delay: that delay
7
+ * is not a physical hold and must not erase the release velocity.
8
+ */
9
+ export class CarouselWheelInput {
10
+ x = 0;
11
+ idleMs = 110;
12
+ lastTime;
13
+ samples = 0;
14
+ move(delta, now) {
15
+ if (!Number.isFinite(delta) || !Number.isFinite(now))
16
+ return;
17
+ if (this.lastTime !== undefined) {
18
+ const interval = Math.max(0, now - this.lastTime);
19
+ // Sparse intentional samples extend the grace period; speed never ends a gesture.
20
+ this.idleMs = Math.max(110, Math.min(220, interval * 2.5));
21
+ }
22
+ this.lastTime = now;
23
+ this.samples++;
24
+ this.x -= delta;
25
+ }
26
+ }
27
+ /** Soft direction preference based on recent travel; never locks either axis. */
28
+ export class CarouselTouchDirection {
29
+ x;
30
+ y;
31
+ horizontal = 0;
32
+ vertical = 0;
33
+ lastX;
34
+ lastY;
35
+ constructor(x, y) {
36
+ this.x = x;
37
+ this.y = y;
38
+ this.lastX = x;
39
+ this.lastY = y;
40
+ }
41
+ move(x, y) {
42
+ const dx = x - this.lastX, dy = y - this.lastY;
43
+ this.lastX = x;
44
+ this.lastY = y;
45
+ const decay = Math.exp(-Math.hypot(dx, dy) / 36);
46
+ this.horizontal = this.horizontal * decay + Math.abs(dx);
47
+ this.vertical = this.vertical * decay + Math.abs(dy);
48
+ const weight = (minor, major) => {
49
+ const dominance = Math.max(0, Math.min(1, (major / Math.max(minor, 0.001) - 1.3) / 1.7));
50
+ return 1 - 0.88 * dominance;
51
+ };
52
+ this.x += dx * weight(this.horizontal, this.vertical);
53
+ this.y += dy * weight(this.vertical, this.horizontal);
54
+ return { x: this.x, y: this.y };
55
+ }
56
+ }
4
57
  /** Horizontal carousel motion, independent of the gesture's vertical scrolling. */
5
58
  export class CarouselDrag {
6
59
  startX;
@@ -23,7 +76,11 @@ export class CarouselDrag {
23
76
  if (!this.active && Math.abs(distance) < DRAG_THRESHOLD)
24
77
  return;
25
78
  this.active = true;
26
- const next = clampCarouselPhase(this.startPhase + distance / PIXELS_PER_ITEM, count);
79
+ const raw = this.startPhase + distance / PIXELS_PER_ITEM;
80
+ const boundary = clampCarouselPhase(raw, count);
81
+ const excess = raw - boundary;
82
+ // Increasing resistance, with at most a third of a seat beyond either end.
83
+ const next = count < 2 ? 0 : boundary + 0.35 * excess / (0.7 + Math.abs(excess));
27
84
  const elapsed = now - this.lastTime;
28
85
  if (elapsed > 0) {
29
86
  const speed = Math.max(-MAX_VELOCITY, Math.min(MAX_VELOCITY, (next - this.phase) / elapsed));
@@ -37,16 +94,40 @@ export class CarouselDrag {
37
94
  if (x !== this.lastX)
38
95
  this.move(x, now, count);
39
96
  // A held finger has no momentum, even if no move event arrived during the pause.
40
- const velocity = now - this.lastTime > 100 ? 0 : this.velocity;
97
+ const outside = this.phase !== clampCarouselPhase(this.phase, count);
98
+ const velocity = outside || now - this.lastTime > 100 ? 0 : this.velocity;
41
99
  return {
42
100
  velocity,
43
- target: Math.round(clampCarouselPhase(this.phase + velocity * 180, count))
101
+ target: Math.round(clampCarouselPhase(this.phase + velocity * INERTIA_TIME, count))
44
102
  };
45
103
  }
46
104
  }
47
105
  export function clampCarouselPhase(phase, count) {
48
106
  return Math.max(0, Math.min(Math.max(0, count - 1), phase));
49
107
  }
108
+ /** Snap the predicted stopping point into a critically damped trajectory.
109
+ * Preserve release speed, but raise damping for a close boundary so there is
110
+ * no overshoot or backwards correction. Progress also drives foreground reveal.
111
+ */
112
+ export function sampleCarouselInertia(start, velocity, target, elapsed) {
113
+ const distance = target - start;
114
+ if (Math.abs(distance) < 0.000001)
115
+ return { phase: target, velocity: 0, progress: 1, finished: true };
116
+ const speed = velocity * distance > 0 ? velocity : 0;
117
+ const damping = Math.max(1 / INERTIA_TIME, Math.abs(speed / distance));
118
+ const coefficient = speed - damping * distance;
119
+ const time = Math.max(0, elapsed);
120
+ const decay = Math.exp(-damping * time);
121
+ const phase = target + (-distance + coefficient * time) * decay;
122
+ const remainingSpeed = (speed - damping * coefficient * time) * decay;
123
+ const finished = (Math.abs(phase - target) < 0.001 && Math.abs(remainingSpeed) < 0.00001) || time >= 3200;
124
+ return {
125
+ phase: finished ? target : phase,
126
+ velocity: finished ? 0 : remainingSpeed,
127
+ progress: finished ? 1 : Math.max(0, Math.min(1, (phase - start) / distance)),
128
+ finished
129
+ };
130
+ }
50
131
  /** Analytic critical damping, independent of refresh rate and dropped frames. */
51
132
  export function sampleCarouselSpring(start, velocity, target, elapsed) {
52
133
  const damping = 0.012;
@@ -1 +1 @@
1
- {"version":3,"file":"carouselMotion.js","sourceRoot":"","sources":["../../src/catalog/carouselMotion.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,mFAAmF;AACnF,MAAM,OAAO,YAAY;IAQN;IACA;IARlB,MAAM,GAAG,KAAK,CAAC;IACf,KAAK,CAAS;IACN,QAAQ,GAAG,CAAC,CAAC;IACb,QAAQ,CAAS;IACjB,KAAK,CAAS;IAEtB,YACkB,MAAc,EACd,UAAkB,EACnC,GAAW;QAFM,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAQ;QAGnC,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,CAAC,CAAS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C,OAAO,GAAG,GAAG,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;IACtD,CAAC;CACD;AAED,MAAM,UAAU,4BAA4B,CAAC,KAAa,EAAE,QAAgB,EAAE,OAAe,EAAE,OAAe;IAC7G,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC;IACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,GAAG,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACtF,OAAO;QACN,QAAQ;QACR,QAAQ,EAAE,QAAQ,IAAI,CAAC,IAAI,QAAQ,IAAI,OAAO,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,GAAG,IAAI,IAAI,OAAO,IAAI,IAAI;KACtG,CAAC;AACH,CAAC","sourcesContent":["const PIXELS_PER_ITEM = 220;\nconst DRAG_THRESHOLD = 8;\nconst MAX_VELOCITY = 0.01;\n\n/** Horizontal carousel motion, independent of the gesture's vertical scrolling. */\nexport class CarouselDrag {\n\tactive = false;\n\tphase: number;\n\tprivate velocity = 0;\n\tprivate lastTime: number;\n\tprivate lastX: number;\n\n\tconstructor(\n\t\tprivate readonly startX: number,\n\t\tprivate readonly startPhase: number,\n\t\tnow: number\n\t) {\n\t\tthis.phase = startPhase;\n\t\tthis.lastTime = now;\n\t\tthis.lastX = startX;\n\t}\n\n\tmove(x: number, now: number, count: number) {\n\t\tthis.lastX = x;\n\t\tconst distance = this.startX - x;\n\t\tif (!this.active && Math.abs(distance) < DRAG_THRESHOLD) return;\n\t\tthis.active = true;\n\t\tconst next = clampCarouselPhase(this.startPhase + distance / PIXELS_PER_ITEM, count);\n\t\tconst elapsed = now - this.lastTime;\n\t\tif (elapsed > 0) {\n\t\t\tconst speed = Math.max(-MAX_VELOCITY, Math.min(MAX_VELOCITY, (next - this.phase) / elapsed));\n\t\t\tthis.velocity += (speed - this.velocity) * (1 - Math.exp(-elapsed / 40));\n\t\t}\n\t\tthis.phase = next;\n\t\tthis.lastTime = now;\n\t}\n\n\trelease(now: number, count: number, x = this.lastX) {\n\t\t// A coalesced final move may arrive only in the release event.\n\t\tif (x !== this.lastX) this.move(x, now, count);\n\t\t// A held finger has no momentum, even if no move event arrived during the pause.\n\t\tconst velocity = now - this.lastTime > 100 ? 0 : this.velocity;\n\t\treturn {\n\t\t\tvelocity,\n\t\t\ttarget: Math.round(clampCarouselPhase(this.phase + velocity * 180, count))\n\t\t};\n\t}\n}\n\nexport function clampCarouselPhase(phase: number, count: number) {\n\treturn Math.max(0, Math.min(Math.max(0, count - 1), phase));\n}\n\n/** Analytic critical damping, independent of refresh rate and dropped frames. */\nexport function sampleCarouselSpring(start: number, velocity: number, target: number, elapsed: number) {\n\tconst damping = 0.012;\n\tconst offset = start - target;\n\tconst coefficient = velocity + damping * offset;\n\tconst decay = Math.exp(-damping * elapsed);\n\treturn {\n\t\tphase: target + (offset + coefficient * elapsed) * decay,\n\t\tvelocity: (velocity - damping * coefficient * elapsed) * decay\n\t};\n}\n\n/** Page scrolling for the model surface, which owns both single-finger axes. */\nexport class CarouselScrollDrag {\n\tactive = false;\n\tprivate velocity = 0;\n\tconstructor(\n\t\tprivate lastY: number,\n\t\tpublic position: number,\n\t\treadonly maximum: number,\n\t\tprivate lastTime: number\n\t) {}\n\n\tmove(y: number, now: number) {\n\t\tconst distance = this.lastY - y;\n\t\tif (!this.active && Math.abs(distance) < 6) return;\n\t\tthis.active = true;\n\t\tconst next = Math.max(0, Math.min(this.maximum, this.position + distance));\n\t\tconst elapsed = now - this.lastTime;\n\t\tif (elapsed > 0) {\n\t\t\tconst speed = Math.max(-3, Math.min(3, (next - this.position) / elapsed));\n\t\t\tthis.velocity += (speed - this.velocity) * (1 - Math.exp(-elapsed / 40));\n\t\t}\n\t\tthis.position = next;\n\t\tthis.lastY = y;\n\t\tthis.lastTime = now;\n\t}\n\n\trelease(now: number, y = this.lastY) {\n\t\tif (y !== this.lastY) this.move(y, now);\n\t\treturn now - this.lastTime > 100 ? 0 : this.velocity;\n\t}\n}\n\nexport function sampleCarouselScrollMomentum(start: number, velocity: number, elapsed: number, maximum: number) {\n\tconst decay = Math.exp(-elapsed / 240);\n\tconst position = Math.max(0, Math.min(maximum, start + velocity * 240 * (1 - decay)));\n\treturn {\n\t\tposition,\n\t\tfinished: position <= 0 || position >= maximum || Math.abs(velocity * decay) < 0.02 || elapsed >= 1600\n\t};\n}\n"]}
1
+ {"version":3,"file":"carouselMotion.js","sourceRoot":"","sources":["../../src/catalog/carouselMotion.ts"],"names":[],"mappings":"AAAA,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,cAAc,GAAG,CAAC,CAAC;AACzB,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B,MAAM,YAAY,GAAG,GAAG,CAAC;AAEzB;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAC9B,CAAC,GAAG,CAAC,CAAC;IACN,MAAM,GAAG,GAAG,CAAC;IACb,QAAQ,CAAqB;IAC7B,OAAO,GAAG,CAAC,CAAC;IACZ,IAAI,CAAC,KAAa,EAAE,GAAW;QAC9B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,OAAO;QAC7D,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;YAClD,kFAAkF;YAClF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CA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AX_VELOCITY = 0.025;\nconst INERTIA_TIME = 320;\n\n/** Wheel adapter only: the carousel controller remains the sole owner of motion.\n * Keep the last input time separate from the idle detection delay: that delay\n * is not a physical hold and must not erase the release velocity.\n */\nexport class CarouselWheelInput {\n\tx = 0;\n\tidleMs = 110;\n\tlastTime: number | undefined;\n\tsamples = 0;\n\tmove(delta: number, now: number) {\n\t\tif (!Number.isFinite(delta) || !Number.isFinite(now)) return;\n\t\tif (this.lastTime !== undefined) {\n\t\t\tconst interval = Math.max(0, now - this.lastTime);\n\t\t\t// Sparse intentional samples extend the grace period; speed never ends a gesture.\n\t\t\tthis.idleMs = Math.max(110, Math.min(220, interval * 2.5));\n\t\t}\n\t\tthis.lastTime = now;\n\t\tthis.samples++;\n\t\tthis.x -= delta;\n\t}\n}\n\n/** Soft direction preference based on recent travel; never locks either axis. */\nexport class CarouselTouchDirection {\n\tprivate horizontal = 0;\n\tprivate vertical = 0;\n\tprivate lastX: number;\n\tprivate lastY: number;\n\tconstructor(public x: number, public y: number) {\n\t\tthis.lastX = x;\n\t\tthis.lastY = y;\n\t}\n\tmove(x: number, y: number) {\n\t\tconst dx = x - this.lastX, dy = y - this.lastY;\n\t\tthis.lastX = x;\n\t\tthis.lastY = y;\n\t\tconst decay = Math.exp(-Math.hypot(dx, dy) / 36);\n\t\tthis.horizontal = this.horizontal * decay + Math.abs(dx);\n\t\tthis.vertical = this.vertical * decay + Math.abs(dy);\n\t\tconst weight = (minor: number, major: number) => {\n\t\t\tconst dominance = Math.max(0, Math.min(1, (major / Math.max(minor, 0.001) - 1.3) / 1.7));\n\t\t\treturn 1 - 0.88 * dominance;\n\t\t};\n\t\tthis.x += dx * weight(this.horizontal, this.vertical);\n\t\tthis.y += dy * weight(this.vertical, this.horizontal);\n\t\treturn { x: this.x, y: this.y };\n\t}\n}\n\n/** Horizontal carousel motion, independent of the gesture's vertical scrolling. */\nexport class CarouselDrag {\n\tactive = false;\n\tphase: number;\n\tprivate velocity = 0;\n\tprivate lastTime: number;\n\tprivate lastX: number;\n\n\tconstructor(\n\t\tprivate readonly startX: number,\n\t\tprivate readonly startPhase: number,\n\t\tnow: number\n\t) {\n\t\tthis.phase = startPhase;\n\t\tthis.lastTime = now;\n\t\tthis.lastX = startX;\n\t}\n\n\tmove(x: number, now: number, count: number) {\n\t\tthis.lastX = x;\n\t\tconst distance = this.startX - x;\n\t\tif (!this.active && Math.abs(distance) < DRAG_THRESHOLD) return;\n\t\tthis.active = true;\n\t\tconst raw = this.startPhase + distance / PIXELS_PER_ITEM;\n\t\tconst boundary = clampCarouselPhase(raw, count);\n\t\tconst excess = raw - boundary;\n\t\t// Increasing resistance, with at most a third of a seat beyond either end.\n\t\tconst next = count < 2 ? 0 : boundary + 0.35 * excess / (0.7 + Math.abs(excess));\n\t\tconst elapsed = now - this.lastTime;\n\t\tif (elapsed > 0) {\n\t\t\tconst speed = Math.max(-MAX_VELOCITY, Math.min(MAX_VELOCITY, (next - this.phase) / elapsed));\n\t\t\tthis.velocity += (speed - this.velocity) * (1 - Math.exp(-elapsed / 40));\n\t\t}\n\t\tthis.phase = next;\n\t\tthis.lastTime = now;\n\t}\n\n\trelease(now: number, count: number, x = this.lastX) {\n\t\t// A coalesced final move may arrive only in the release event.\n\t\tif (x !== this.lastX) this.move(x, now, count);\n\t\t// A held finger has no momentum, even if no move event arrived during the pause.\n\t\tconst outside = this.phase !== clampCarouselPhase(this.phase, count);\n\t\tconst velocity = outside || now - this.lastTime > 100 ? 0 : this.velocity;\n\t\treturn {\n\t\t\tvelocity,\n\t\t\ttarget: Math.round(clampCarouselPhase(this.phase + velocity * INERTIA_TIME, count))\n\t\t};\n\t}\n}\n\nexport function clampCarouselPhase(phase: number, count: number) {\n\treturn Math.max(0, Math.min(Math.max(0, count - 1), phase));\n}\n\n/** Snap the predicted stopping point into a critically damped trajectory.\n * Preserve release speed, but raise damping for a close boundary so there is\n * no overshoot or backwards correction. Progress also drives foreground reveal.\n */\nexport function sampleCarouselInertia(start: number, velocity: number, target: number, elapsed: number) {\n\tconst distance = target - start;\n\tif (Math.abs(distance) < 0.000001) return { phase: target, velocity: 0, progress: 1, finished: true };\n\tconst speed = velocity * distance > 0 ? velocity : 0;\n\tconst damping = Math.max(1 / INERTIA_TIME, Math.abs(speed / distance));\n\tconst coefficient = speed - damping * distance;\n\tconst time = Math.max(0, elapsed);\n\tconst decay = Math.exp(-damping * time);\n\tconst phase = target + (-distance + coefficient * time) * decay;\n\tconst remainingSpeed = (speed - damping * coefficient * time) * decay;\n\tconst finished = (Math.abs(phase - target) < 0.001 && Math.abs(remainingSpeed) < 0.00001) || time >= 3200;\n\treturn {\n\t\tphase: finished ? target : phase,\n\t\tvelocity: finished ? 0 : remainingSpeed,\n\t\tprogress: finished ? 1 : Math.max(0, Math.min(1, (phase - start) / distance)),\n\t\tfinished\n\t};\n}\n\n/** Analytic critical damping, independent of refresh rate and dropped frames. */\nexport function sampleCarouselSpring(start: number, velocity: number, target: number, elapsed: number) {\n\tconst damping = 0.012;\n\tconst offset = start - target;\n\tconst coefficient = velocity + damping * offset;\n\tconst decay = Math.exp(-damping * elapsed);\n\treturn {\n\t\tphase: target + (offset + coefficient * elapsed) * decay,\n\t\tvelocity: (velocity - damping * coefficient * elapsed) * decay\n\t};\n}\n\n/** Page scrolling for the model surface, which owns both single-finger axes. */\nexport class CarouselScrollDrag {\n\tactive = false;\n\tprivate velocity = 0;\n\tconstructor(\n\t\tprivate lastY: number,\n\t\tpublic position: number,\n\t\treadonly maximum: number,\n\t\tprivate lastTime: number\n\t) {}\n\n\tmove(y: number, now: number) {\n\t\tconst distance = this.lastY - y;\n\t\tif (!this.active && Math.abs(distance) < 6) return;\n\t\tthis.active = true;\n\t\tconst next = Math.max(0, Math.min(this.maximum, this.position + distance));\n\t\tconst elapsed = now - this.lastTime;\n\t\tif (elapsed > 0) {\n\t\t\tconst speed = Math.max(-3, Math.min(3, (next - this.position) / elapsed));\n\t\t\tthis.velocity += (speed - this.velocity) * (1 - Math.exp(-elapsed / 40));\n\t\t}\n\t\tthis.position = next;\n\t\tthis.lastY = y;\n\t\tthis.lastTime = now;\n\t}\n\n\trelease(now: number, y = this.lastY) {\n\t\tif (y !== this.lastY) this.move(y, now);\n\t\treturn now - this.lastTime > 100 ? 0 : this.velocity;\n\t}\n}\n\nexport function sampleCarouselScrollMomentum(start: number, velocity: number, elapsed: number, maximum: number) {\n\tconst decay = Math.exp(-elapsed / 240);\n\tconst position = Math.max(0, Math.min(maximum, start + velocity * 240 * (1 - decay)));\n\treturn {\n\t\tposition,\n\t\tfinished: position <= 0 || position >= maximum || Math.abs(velocity * decay) < 0.02 || elapsed >= 1600\n\t};\n}\n"]}
@@ -0,0 +1,11 @@
1
+ /** Mouse approach is bounded and continuous outside the projected model bounds. */
2
+ export declare function carouselProximity(x: number, y: number, rect: {
3
+ left: number;
4
+ top: number;
5
+ width: number;
6
+ height: number;
7
+ }): {
8
+ x: number;
9
+ y: number;
10
+ };
11
+ //# sourceMappingURL=carouselProximity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carouselProximity.d.ts","sourceRoot":"","sources":["../../src/catalog/carouselProximity.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EACrD,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;;;EAWlE"}
@@ -0,0 +1,13 @@
1
+ /** Mouse approach is bounded and continuous outside the projected model bounds. */
2
+ export function carouselProximity(x, y, rect) {
3
+ const dx = x - rect.left - rect.width / 2, dy = y - rect.top - rect.height / 2;
4
+ const distance = Math.hypot(Math.max(0, Math.abs(dx) - rect.width / 2), Math.max(0, Math.abs(dy) - rect.height / 2));
5
+ const t = Math.min(1, distance / 150);
6
+ const influence = 1 - t * t * (3 - 2 * t);
7
+ const limit = 4 * Math.PI / 180;
8
+ return {
9
+ x: -Math.max(-1, Math.min(1, dy / Math.max(1, rect.height / 2))) * limit * influence || 0,
10
+ y: -Math.max(-1, Math.min(1, dx / Math.max(1, rect.width / 2))) * limit * influence || 0
11
+ };
12
+ }
13
+ //# sourceMappingURL=carouselProximity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carouselProximity.js","sourceRoot":"","sources":["../../src/catalog/carouselProximity.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,UAAU,iBAAiB,CAAC,CAAS,EAAE,CAAS,EACrD,IAAkE;IAClE,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/E,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,EACrE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IAC9C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,GAAG,CAAC,CAAC;IACtC,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC;IAChC,OAAO;QACN,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,SAAS,IAAI,CAAC;QACzF,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,SAAS,IAAI,CAAC;KACxF,CAAC;AACH,CAAC","sourcesContent":["/** Mouse approach is bounded and continuous outside the projected model bounds. */\nexport function carouselProximity(x: number, y: number,\n\trect: { left: number; top: number; width: number; height: number }) {\n\tconst dx = x - rect.left - rect.width / 2, dy = y - rect.top - rect.height / 2;\n\tconst distance = Math.hypot(Math.max(0, Math.abs(dx) - rect.width / 2),\n\t\tMath.max(0, Math.abs(dy) - rect.height / 2));\n\tconst t = Math.min(1, distance / 150);\n\tconst influence = 1 - t * t * (3 - 2 * t);\n\tconst limit = 4 * Math.PI / 180;\n\treturn {\n\t\tx: -Math.max(-1, Math.min(1, dy / Math.max(1, rect.height / 2))) * limit * influence || 0,\n\t\ty: -Math.max(-1, Math.min(1, dx / Math.max(1, rect.width / 2))) * limit * influence || 0\n\t};\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import * as THREE from 'three/webgpu';
2
+ /** Cache a small support envelope from actual vertices, rather than empty box corners. */
3
+ export declare function carouselSupport(model: THREE.Object3D, orientation: THREE.Quaternion): THREE.Vector3[];
4
+ //# sourceMappingURL=carouselSupport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carouselSupport.d.ts","sourceRoot":"","sources":["../../src/catalog/carouselSupport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,0FAA0F;AAC1F,wBAAgB,eAAe,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,CAAC,UAAU,mBAqBnF"}
@@ -0,0 +1,30 @@
1
+ import * as THREE from 'three/webgpu';
2
+ import { isMesh } from '../stage/stageSceneUtils.js';
3
+ /** Cache a small support envelope from actual vertices, rather than empty box corners. */
4
+ export function carouselSupport(model, orientation) {
5
+ const directions = [new THREE.Vector3(0, 1, 0), ...Array.from({ length: 16 }, (_, i) => new THREE.Vector3(Math.cos(i * Math.PI / 8) * 0.14, 1, Math.sin(i * Math.PI / 8) * 0.14))];
6
+ const scores = directions.map(() => Infinity);
7
+ const points = directions.map(() => new THREE.Vector3());
8
+ const vertex = new THREE.Vector3(), rotated = new THREE.Vector3();
9
+ model.updateMatrixWorld(true);
10
+ model.traverseVisible(object => {
11
+ if (!isMesh(object))
12
+ return;
13
+ const positions = object.geometry.getAttribute('position');
14
+ if (!positions)
15
+ return;
16
+ for (let i = 0; i < positions.count; i++) {
17
+ object.getVertexPosition(i, vertex).applyMatrix4(object.matrixWorld);
18
+ rotated.copy(vertex).applyQuaternion(orientation);
19
+ for (let j = 0; j < directions.length; j++) {
20
+ const score = rotated.dot(directions[j]);
21
+ if (score < scores[j]) {
22
+ scores[j] = score;
23
+ points[j].copy(vertex);
24
+ }
25
+ }
26
+ }
27
+ });
28
+ return points;
29
+ }
30
+ //# sourceMappingURL=carouselSupport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"carouselSupport.js","sourceRoot":"","sources":["../../src/catalog/carouselSupport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,0FAA0F;AAC1F,MAAM,UAAU,eAAe,CAAC,KAAqB,EAAE,WAA6B;IACnF,MAAM,UAAU,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,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AAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;gBACzC,IAAI,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;oBAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;oBAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAAC,CAAC;YACtE,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AACf,CAAC","sourcesContent":["import * as THREE from 'three/webgpu';\nimport { isMesh } from '../stage/stageSceneUtils.js';\n\n/** Cache a small support envelope from actual vertices, rather than empty box corners. */\nexport function carouselSupport(model: THREE.Object3D, orientation: THREE.Quaternion) {\n\tconst directions = [new THREE.Vector3(0, 1, 0), ...Array.from({ length: 16 }, (_, i) =>\n\t\tnew THREE.Vector3(Math.cos(i * Math.PI / 8) * 0.14, 1, Math.sin(i * Math.PI / 8) * 0.14))];\n\tconst scores = directions.map(() => Infinity);\n\tconst points = directions.map(() => new THREE.Vector3());\n\tconst vertex = new THREE.Vector3(), rotated = new THREE.Vector3();\n\tmodel.updateMatrixWorld(true);\n\tmodel.traverseVisible(object => {\n\t\tif (!isMesh(object)) return;\n\t\tconst positions = object.geometry.getAttribute('position');\n\t\tif (!positions) return;\n\t\tfor (let i = 0; i < positions.count; i++) {\n\t\t\tobject.getVertexPosition(i, vertex).applyMatrix4(object.matrixWorld);\n\t\t\trotated.copy(vertex).applyQuaternion(orientation);\n\t\t\tfor (let j = 0; j < directions.length; j++) {\n\t\t\t\tconst score = rotated.dot(directions[j]);\n\t\t\t\tif (score < scores[j]) { scores[j] = score; points[j].copy(vertex); }\n\t\t\t}\n\t\t}\n\t});\n\treturn points;\n}\n"]}