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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +1 -1
  2. package/dist/catalog/CarouselGlassCompositor.d.ts +7 -2
  3. package/dist/catalog/CarouselGlassCompositor.d.ts.map +1 -1
  4. package/dist/catalog/CarouselGlassCompositor.js +85 -24
  5. package/dist/catalog/CarouselGlassCompositor.js.map +1 -1
  6. package/dist/catalog/CarouselGround.d.ts +21 -0
  7. package/dist/catalog/CarouselGround.d.ts.map +1 -0
  8. package/dist/catalog/CarouselGround.js +107 -0
  9. package/dist/catalog/CarouselGround.js.map +1 -0
  10. package/dist/catalog/CatalogDepthBlur.d.ts +26 -0
  11. package/dist/catalog/CatalogDepthBlur.d.ts.map +1 -0
  12. package/dist/catalog/CatalogDepthBlur.js +87 -0
  13. package/dist/catalog/CatalogDepthBlur.js.map +1 -0
  14. package/dist/catalog/CatalogModelOutline.d.ts +31 -0
  15. package/dist/catalog/CatalogModelOutline.d.ts.map +1 -0
  16. package/dist/catalog/CatalogModelOutline.js +127 -0
  17. package/dist/catalog/CatalogModelOutline.js.map +1 -0
  18. package/dist/catalog/CatalogSpatialElementLayer.d.ts +29 -2
  19. package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -1
  20. package/dist/catalog/CatalogSpatialElementLayer.js +170 -41
  21. package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
  22. package/dist/catalog/CatalogTransition.d.ts.map +1 -1
  23. package/dist/catalog/CatalogTransition.js +49 -4
  24. package/dist/catalog/CatalogTransition.js.map +1 -1
  25. package/dist/catalog/SpatialGeometryCapture.d.ts +9 -0
  26. package/dist/catalog/SpatialGeometryCapture.d.ts.map +1 -1
  27. package/dist/catalog/SpatialGeometryCapture.js +11 -1
  28. package/dist/catalog/SpatialGeometryCapture.js.map +1 -1
  29. package/dist/catalog/cardModelFit.d.ts +7 -0
  30. package/dist/catalog/cardModelFit.d.ts.map +1 -0
  31. package/dist/catalog/cardModelFit.js +16 -0
  32. package/dist/catalog/cardModelFit.js.map +1 -0
  33. package/dist/catalog/cardProjection.d.ts +8 -0
  34. package/dist/catalog/cardProjection.d.ts.map +1 -0
  35. package/dist/catalog/cardProjection.js +51 -0
  36. package/dist/catalog/cardProjection.js.map +1 -0
  37. package/dist/catalog/carouselMotion.d.ts +35 -0
  38. package/dist/catalog/carouselMotion.d.ts.map +1 -1
  39. package/dist/catalog/carouselMotion.js +85 -4
  40. package/dist/catalog/carouselMotion.js.map +1 -1
  41. package/dist/catalog/carouselProximity.d.ts +11 -0
  42. package/dist/catalog/carouselProximity.d.ts.map +1 -0
  43. package/dist/catalog/carouselProximity.js +13 -0
  44. package/dist/catalog/carouselProximity.js.map +1 -0
  45. package/dist/catalog/carouselSupport.d.ts +4 -0
  46. package/dist/catalog/carouselSupport.d.ts.map +1 -0
  47. package/dist/catalog/carouselSupport.js +30 -0
  48. package/dist/catalog/carouselSupport.js.map +1 -0
  49. package/dist/catalog/catalogPose.d.ts +36 -6
  50. package/dist/catalog/catalogPose.d.ts.map +1 -1
  51. package/dist/catalog/catalogPose.js +79 -23
  52. package/dist/catalog/catalogPose.js.map +1 -1
  53. package/dist/spatial-element/SpatialElementDockController.d.ts +1 -1
  54. package/dist/spatial-element/SpatialElementDockController.d.ts.map +1 -1
  55. package/dist/spatial-element/SpatialElementDockController.js +29 -2
  56. package/dist/spatial-element/SpatialElementDockController.js.map +1 -1
  57. package/dist/spatial-element/messages.d.ts +2 -0
  58. package/dist/spatial-element/messages.d.ts.map +1 -1
  59. package/dist/spatial-element/messages.js +1 -1
  60. package/dist/spatial-element/messages.js.map +1 -1
  61. package/dist/spatial-element/spatialTheme.d.ts.map +1 -1
  62. package/dist/spatial-element/spatialTheme.js +1 -0
  63. package/dist/spatial-element/spatialTheme.js.map +1 -1
  64. package/dist/spatial-element/types.d.ts +2 -0
  65. package/dist/spatial-element/types.d.ts.map +1 -1
  66. package/dist/spatial-element/types.js.map +1 -1
  67. package/dist/stage/LiquidGlassPanel.d.ts +2 -0
  68. package/dist/stage/LiquidGlassPanel.d.ts.map +1 -1
  69. package/dist/stage/LiquidGlassPanel.js +8 -1
  70. package/dist/stage/LiquidGlassPanel.js.map +1 -1
  71. package/dist/stage/MinimapController.d.ts +3 -1
  72. package/dist/stage/MinimapController.d.ts.map +1 -1
  73. package/dist/stage/MinimapController.js +23 -20
  74. package/dist/stage/MinimapController.js.map +1 -1
  75. package/dist/stage/PageBindingController.d.ts +4 -0
  76. package/dist/stage/PageBindingController.d.ts.map +1 -1
  77. package/dist/stage/PageBindingController.js +15 -4
  78. package/dist/stage/PageBindingController.js.map +1 -1
  79. package/dist/stage/PanelPresentationController.d.ts +1 -0
  80. package/dist/stage/PanelPresentationController.d.ts.map +1 -1
  81. package/dist/stage/PanelPresentationController.js +38 -7
  82. package/dist/stage/PanelPresentationController.js.map +1 -1
  83. package/dist/stage/SpatialElementInteractionController.d.ts +2 -0
  84. package/dist/stage/SpatialElementInteractionController.d.ts.map +1 -1
  85. package/dist/stage/SpatialElementInteractionController.js +23 -5
  86. package/dist/stage/SpatialElementInteractionController.js.map +1 -1
  87. package/dist/stage/StageExperience.d.ts +58 -1
  88. package/dist/stage/StageExperience.d.ts.map +1 -1
  89. package/dist/stage/StageExperience.js +112 -19
  90. package/dist/stage/StageExperience.js.map +1 -1
  91. package/dist/stage/StageFullscreenController.d.ts +17 -0
  92. package/dist/stage/StageFullscreenController.d.ts.map +1 -0
  93. package/dist/stage/StageFullscreenController.js +90 -0
  94. package/dist/stage/StageFullscreenController.js.map +1 -0
  95. package/dist/stage/StageRenderPipeline.d.ts +6 -0
  96. package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
  97. package/dist/stage/StageRenderPipeline.js +46 -65
  98. package/dist/stage/StageRenderPipeline.js.map +1 -1
  99. package/dist/stage/VirtualScrollController.d.ts.map +1 -1
  100. package/dist/stage/VirtualScrollController.js +6 -0
  101. package/dist/stage/VirtualScrollController.js.map +1 -1
  102. package/dist/stage/interactionOutline.d.ts +14 -0
  103. package/dist/stage/interactionOutline.d.ts.map +1 -0
  104. package/dist/stage/interactionOutline.js +81 -0
  105. package/dist/stage/interactionOutline.js.map +1 -0
  106. package/dist/stage/minimap/MinimapProjection.d.ts +7 -0
  107. package/dist/stage/minimap/MinimapProjection.d.ts.map +1 -1
  108. package/dist/stage/minimap/MinimapProjection.js +14 -13
  109. package/dist/stage/minimap/MinimapProjection.js.map +1 -1
  110. package/dist/stage/panelContext.d.ts +9 -0
  111. package/dist/stage/panelContext.d.ts.map +1 -1
  112. package/dist/stage/panelContext.js.map +1 -1
  113. package/dist/stage/stageDom.d.ts +2 -0
  114. package/dist/stage/stageDom.d.ts.map +1 -1
  115. package/dist/stage/stageDom.js +4 -0
  116. package/dist/stage/stageDom.js.map +1 -1
  117. package/dist/stage/stageVisualTest.d.ts +2 -0
  118. package/dist/stage/stageVisualTest.d.ts.map +1 -1
  119. package/dist/stage/stageVisualTest.js.map +1 -1
  120. package/package.json +1 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@ Beta API; MPL-2.0; see LICENSE.
8
8
 
9
9
  Read the [getting-started tutorial](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/getting-started.md), [API reference](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/api.md) and [configuration migration](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/configuration-migration.md).
10
10
 
11
- Element content and required `geometry: { low, high }` belong in `SpatialElementData`; shared appearance belongs in `SpatialTheme`. Use `createSpatialTheme({ id, name })` for defaults. The SvelteKit shell needs only the theme; pages register their own data. These docs target version `1.0.0-beta.3` and newer.
11
+ Element content and required `geometry: { low, high }` belong in `SpatialElementData`; shared appearance belongs in `SpatialTheme`. Use `createSpatialTheme({ id, name })` for defaults. The SvelteKit shell needs only the theme; pages register their own data. These docs target version `1.0.0-beta.5` and newer.
12
12
 
13
13
  Installation:
14
14
 
@@ -1,9 +1,14 @@
1
1
  import * as THREE from 'three/webgpu';
2
+ import type { CatalogDepthBlur } from './CatalogDepthBlur.js';
2
3
  /** Reuses the stage device/output and glass shader; never samples its own glass output. */
3
4
  export declare class CarouselGlassCompositor {
5
+ private readonly depthBlur;
6
+ constructor(depthBlur: CatalogDepthBlur);
4
7
  getRenderTargets(): THREE.RenderTarget<THREE.Texture<unknown, THREE.TextureEventMap>, THREE.RenderTargetEventMap>[];
5
8
  private scene;
6
9
  private capture?;
10
+ private compositeMaterial?;
11
+ private composite?;
7
12
  private blurs;
8
13
  private panels;
9
14
  private size;
@@ -16,9 +21,9 @@ export declare class CarouselGlassCompositor {
16
21
  resizes: number;
17
22
  };
18
23
  beginFrame(): void;
19
- panel(card: HTMLElement, matrix: THREE.Matrix4, width: number, height: number, opacity: number): void;
24
+ panel(card: HTMLElement, matrix: THREE.Matrix4, width: number, height: number, opacity: number, focusBlur?: number): void;
20
25
  endFrame(): void;
21
- render(renderer: THREE.WebGPURenderer, camera: THREE.Camera, drawRear: () => void): void;
26
+ render(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera, drawRear: () => void): void;
22
27
  dispose(): void;
23
28
  }
24
29
  //# sourceMappingURL=CarouselGlassCompositor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CarouselGlassCompositor.d.ts","sourceRoot":"","sources":["../../src/catalog/CarouselGlassCompositor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAKtC,2FAA2F;AAC3F,qBAAa,uBAAuB;IACnC,gBAAgB;IAMhB,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,OAAO,CAAC,CAAqB;IACrC,OAAO,CAAC,KAAK,CAQT;IACJ,OAAO,CAAC,MAAM,CAGV;IACJ,OAAO,CAAC,IAAI,CAAuB;IACnC,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,OAAO,CAAK;IAEpB,QAAQ;;;;;;IASR,UAAU;IA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IAAI;IAqE5F,OAAO;CAgBP"}
@@ -5,6 +5,10 @@ import { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';
5
5
  import { LiquidGlassPanel } from '../stage/LiquidGlassPanel.js';
6
6
  /** Reuses the stage device/output and glass shader; never samples its own glass output. */
7
7
  export class CarouselGlassCompositor {
8
+ depthBlur;
9
+ constructor(depthBlur) {
10
+ this.depthBlur = depthBlur;
11
+ }
8
12
  getRenderTargets() {
9
13
  return [
10
14
  ...(this.capture ? [this.capture] : []),
@@ -13,6 +17,8 @@ export class CarouselGlassCompositor {
13
17
  }
14
18
  scene = new THREE.Scene();
15
19
  capture;
20
+ compositeMaterial;
21
+ composite;
16
22
  blurs = new Map();
17
23
  panels = new Map();
18
24
  size = new THREE.Vector2();
@@ -33,20 +39,34 @@ export class CarouselGlassCompositor {
33
39
  entry.glass.group.visible = false;
34
40
  }
35
41
  }
36
- panel(card, matrix, width, height, opacity) {
42
+ panel(card, matrix, width, height, opacity, focusBlur = 0) {
37
43
  if (card.dataset.carouselSurface !== 'glass')
38
44
  return;
39
- if (!this.capture)
45
+ if (!this.capture) {
40
46
  this.capture = new THREE.RenderTarget(1, 1);
47
+ this.compositeMaterial = new THREE.NodeMaterial();
48
+ this.compositeMaterial.fragmentNode = texture(this.capture.texture);
49
+ this.compositeMaterial.transparent = true;
50
+ this.compositeMaterial.blending = THREE.CustomBlending;
51
+ this.compositeMaterial.blendSrc = this.compositeMaterial.blendSrcAlpha = THREE.OneFactor;
52
+ this.compositeMaterial.blendDst = this.compositeMaterial.blendDstAlpha = THREE.OneMinusSrcAlphaFactor;
53
+ this.compositeMaterial.depthTest = false;
54
+ this.compositeMaterial.depthWrite = false;
55
+ this.compositeMaterial.toneMapped = false;
56
+ this.composite = new THREE.QuadMesh(this.compositeMaterial);
57
+ }
41
58
  let entry = this.panels.get(card);
42
59
  if (!entry) {
43
60
  const options = JSON.parse(card.dataset.carouselTheme ?? '{}');
44
61
  const blur = Math.min(100, Math.max(0, options.backdropBlur ?? 5));
45
62
  if (!this.blurs.has(blur)) {
46
63
  const target = new THREE.RenderTarget(1, 1, { depthBuffer: false });
47
- const effect = gaussianBlur(texture(this.capture.texture), 1, Math.max(1, Math.round(blur)), { resolutionScale: 1 });
64
+ const sample = texture(this.capture.texture);
65
+ const effect = gaussianBlur(sample, 1, Math.max(1, Math.round(blur)), { resolutionScale: 1 });
48
66
  const material = new THREE.NodeMaterial();
49
- material.colorNode = blur ? effect : texture(this.capture.texture);
67
+ // Resolve the original white backdrop after blurring, without another fullscreen capture.
68
+ const filtered = blur ? effect : sample;
69
+ material.colorNode = filtered.rgb.add(filtered.a.oneMinus());
50
70
  this.blurs.set(blur, { target, effect, material, quad: new THREE.QuadMesh(material) });
51
71
  }
52
72
  const glass = new LiquidGlassPanel(this.blurs.get(blur).target.texture, {
@@ -56,10 +76,13 @@ export class CarouselGlassCompositor {
56
76
  });
57
77
  glass.group.matrixAutoUpdate = false;
58
78
  this.scene.add(glass.group);
59
- entry = { glass, blur, active: false, seen: false };
79
+ entry = { glass, blur, focusBlur, width, height, active: false, seen: false };
60
80
  this.panels.set(card, entry);
61
81
  }
62
82
  entry.seen = true;
83
+ entry.focusBlur = focusBlur;
84
+ entry.width = width;
85
+ entry.height = height;
63
86
  entry.active = opacity > 0.001;
64
87
  entry.glass.setVisualSize(width, height);
65
88
  entry.glass.setVisibilityAlpha(opacity);
@@ -91,27 +114,64 @@ export class CarouselGlassCompositor {
91
114
  this.resizes++;
92
115
  }
93
116
  const original = renderer.getRenderTarget();
94
- renderer.setRenderTarget(this.capture);
95
- renderer.setClearColor(0xffffff, 1);
96
- renderer.clear();
97
- drawRear();
98
- for (const key of new Set(active.map(([, entry]) => entry.blur))) {
99
- const blur = this.blurs.get(key);
100
- if (blur.target.width !== width || blur.target.height !== height) {
101
- blur.target.setSize(width, height);
102
- this.resizes++;
103
- }
104
- renderer.setRenderTarget(blur.target);
117
+ const clearColor = renderer.getClearColor(new THREE.Color());
118
+ const clearAlpha = renderer.getClearAlpha();
119
+ try {
120
+ renderer.setRenderTarget(this.capture);
121
+ renderer.setClearColor(0x000000, 0);
105
122
  renderer.clear();
106
- blur.quad.render(renderer);
123
+ drawRear();
124
+ for (const key of new Set(active.map(([, entry]) => entry.blur))) {
125
+ const blur = this.blurs.get(key);
126
+ if (blur.target.width !== width || blur.target.height !== height) {
127
+ blur.target.setSize(width, height);
128
+ this.resizes++;
129
+ }
130
+ renderer.setRenderTarget(blur.target);
131
+ renderer.clear();
132
+ blur.quad.render(renderer);
133
+ }
134
+ renderer.setRenderTarget(original);
135
+ // Rear geometry, including defocus, is submitted once and reused by the glass and output.
136
+ this.composite.render(renderer);
137
+ renderer.clearDepth();
138
+ if (active.some(([, entry]) => entry.focusBlur >= 0.05)) {
139
+ for (const [, entry] of active)
140
+ entry.glass.group.visible = false;
141
+ for (const [, entry] of active) {
142
+ const group = entry.glass.group;
143
+ group.visible = true;
144
+ group.updateWorldMatrix(true, false);
145
+ const corners = [-1, 1].flatMap((x) => [-1, 1].map((y) => new THREE.Vector3(x * (entry.width / 2 + 48), y * (entry.height / 2 + 48), 0)
146
+ .applyMatrix4(group.matrixWorld).project(camera)));
147
+ const xs = corners.map((p) => (p.x + 1) * width / 2);
148
+ const ys = corners.map((p) => (1 - p.y) * height / 2);
149
+ this.depthBlur.render(renderer, camera, { left: Math.min(...xs), top: Math.min(...ys), width: Math.max(...xs) - Math.min(...xs), height: Math.max(...ys) - Math.min(...ys) }, entry.focusBlur, (projection) => {
150
+ const view = projection.view;
151
+ if (view?.enabled)
152
+ entry.glass.setBackdropUvTransform(view.offsetX / view.fullWidth, view.offsetY / view.fullHeight, view.width / view.fullWidth, view.height / view.fullHeight);
153
+ try {
154
+ renderer.render(this.scene, projection);
155
+ }
156
+ finally {
157
+ entry.glass.setBackdropUvTransform(0, 0, 1, 1);
158
+ }
159
+ });
160
+ group.visible = false;
161
+ }
162
+ for (const [, entry] of active)
163
+ entry.glass.group.visible = true;
164
+ }
165
+ else
166
+ renderer.render(this.scene, camera);
167
+ this.passes++;
168
+ for (const [card] of active)
169
+ card.setAttribute('data-carousel-glass-ready', '');
170
+ }
171
+ finally {
172
+ renderer.setRenderTarget(original);
173
+ renderer.setClearColor(clearColor, clearAlpha);
107
174
  }
108
- renderer.setRenderTarget(original);
109
- drawRear();
110
- renderer.clearDepth();
111
- renderer.render(this.scene, camera);
112
- this.passes++;
113
- for (const [card] of active)
114
- card.setAttribute('data-carousel-glass-ready', '');
115
175
  }
116
176
  dispose() {
117
177
  for (const [card, entry] of this.panels) {
@@ -121,6 +181,7 @@ export class CarouselGlassCompositor {
121
181
  this.panels.clear();
122
182
  this.scene.clear();
123
183
  this.capture?.dispose();
184
+ this.compositeMaterial?.dispose();
124
185
  for (const blur of this.blurs.values()) {
125
186
  blur.target.dispose();
126
187
  blur.material.dispose();
@@ -1 +1 @@
1
- {"version":3,"file":"CarouselGlassCompositor.js","sourceRoot":"","sources":["../../src/catalog/CarouselGlassCompositor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,2FAA2F;AAC3F,MAAM,OAAO,uBAAuB;IACnC,gBAAgB;QACf,OAAO;YACN,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACvC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,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ACxB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACxC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACtB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACxB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;CACD","sourcesContent":["import { gaussianTargets } from '../stage/renderTargetInventory.js';\nimport * as THREE from 'three/webgpu';\nimport { texture } from 'three/tsl';\nimport { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';\nimport { LiquidGlassPanel } from '../stage/LiquidGlassPanel.js';\n\n/** Reuses the stage device/output and glass shader; never samples its own glass output. */\nexport class CarouselGlassCompositor {\n\tgetRenderTargets() {\n\t\treturn [\n\t\t\t...(this.capture ? [this.capture] : []),\n\t\t\t...[...this.blurs.values()].flatMap((blur) => [blur.target, ...gaussianTargets(blur.effect)])\n\t\t];\n\t}\n\tprivate scene = new THREE.Scene();\n\tprivate capture?: THREE.RenderTarget;\n\tprivate blurs = new Map<\n\t\tnumber,\n\t\t{\n\t\t\ttarget: THREE.RenderTarget;\n\t\t\tmaterial: THREE.NodeMaterial;\n\t\t\tquad: THREE.QuadMesh;\n\t\t\teffect: ReturnType<typeof gaussianBlur>;\n\t\t}\n\t>();\n\tprivate panels = new Map<\n\t\tHTMLElement,\n\t\t{ glass: LiquidGlassPanel; blur: number; active: boolean; seen: boolean }\n\t>();\n\tprivate size = new THREE.Vector2();\n\tprivate passes = 0;\n\tprivate resizes = 0;\n\n\tgetStats() {\n\t\treturn {\n\t\t\tpanels: this.panels.size,\n\t\t\ttargets: (this.capture ? 1 : 0) + this.blurs.size,\n\t\t\tpasses: this.passes,\n\t\t\tresizes: this.resizes\n\t\t};\n\t}\n\n\tbeginFrame() {\n\t\tfor (const entry of this.panels.values()) {\n\t\t\tentry.active = false;\n\t\t\tentry.seen = false;\n\t\t\tentry.glass.group.visible = false;\n\t\t}\n\t}\n\n\tpanel(card: HTMLElement, matrix: THREE.Matrix4, width: number, height: number, opacity: number) {\n\t\tif (card.dataset.carouselSurface !== 'glass') return;\n\t\tif (!this.capture) this.capture = new THREE.RenderTarget(1, 1);\n\t\tlet entry = this.panels.get(card);\n\t\tif (!entry) {\n\t\t\tconst options = JSON.parse(card.dataset.carouselTheme ?? '{}');\n\t\t\tconst blur = Math.min(100, Math.max(0, options.backdropBlur ?? 5));\n\t\t\tif (!this.blurs.has(blur)) {\n\t\t\t\tconst target = new THREE.RenderTarget(1, 1, { depthBuffer: false });\n\t\t\t\tconst effect = gaussianBlur(\n\t\t\t\t\ttexture(this.capture.texture),\n\t\t\t\t\t1,\n\t\t\t\t\tMath.max(1, Math.round(blur)),\n\t\t\t\t\t{ resolutionScale: 1 }\n\t\t\t\t);\n\t\t\t\tconst material = new THREE.NodeMaterial();\n\t\t\t\tmaterial.colorNode = blur ? effect : texture(this.capture.texture);\n\t\t\t\tthis.blurs.set(blur, { target, effect, material, quad: new THREE.QuadMesh(material) });\n\t\t\t}\n\t\t\tconst glass = new LiquidGlassPanel(this.blurs.get(blur)!.target.texture, {\n\t\t\t\t...options,\n\t\t\t\twidth,\n\t\t\t\theight\n\t\t\t});\n\t\t\tglass.group.matrixAutoUpdate = false;\n\t\t\tthis.scene.add(glass.group);\n\t\t\tentry = { glass, blur, active: false, seen: false };\n\t\t\tthis.panels.set(card, entry);\n\t\t}\n\t\tentry.seen = true;\n\t\tentry.active = opacity > 0.001;\n\t\tentry.glass.setVisualSize(width, height);\n\t\tentry.glass.setVisibilityAlpha(opacity);\n\t\tentry.glass.group.matrix.copy(matrix);\n\t\tentry.glass.group.matrixWorldNeedsUpdate = true;\n\t}\n\n\tendFrame() {\n\t\tfor (const [card, entry] of this.panels) {\n\t\t\tif (!entry.active) card.removeAttribute('data-carousel-glass-ready');\n\t\t\tif (!entry.seen || !card.isConnected || card.hidden) {\n\t\t\t\tthis.scene.remove(entry.glass.group);\n\t\t\t\tentry.glass.dispose();\n\t\t\t\tthis.panels.delete(card);\n\t\t\t}\n\t\t}\n\t}\n\n\trender(renderer: THREE.WebGPURenderer, camera: THREE.Camera, drawRear: () => void) {\n\t\tconst active = [...this.panels.entries()].filter(([, entry]) => entry.active);\n\t\tif (!active.length || !this.capture) {\n\t\t\tdrawRear();\n\t\t\treturn;\n\t\t}\n\t\t// CSS-pixel resolution bounds blur cost; resizing only on viewport changes.\n\t\tconst width = Math.max(1, window.innerWidth),\n\t\t\theight = Math.max(1, window.innerHeight);\n\t\tif (this.size.x !== width || this.size.y !== height) {\n\t\t\tthis.size.set(width, height);\n\t\t\tthis.capture.setSize(width, height);\n\t\t\tthis.resizes++;\n\t\t}\n\t\tconst original = renderer.getRenderTarget();\n\t\trenderer.setRenderTarget(this.capture);\n\t\trenderer.setClearColor(0xffffff, 1);\n\t\trenderer.clear();\n\t\tdrawRear();\n\t\tfor (const key of new Set(active.map(([, entry]) => entry.blur))) {\n\t\t\tconst blur = this.blurs.get(key)!;\n\t\t\tif (blur.target.width !== width || blur.target.height !== height) {\n\t\t\t\tblur.target.setSize(width, height);\n\t\t\t\tthis.resizes++;\n\t\t\t}\n\t\t\trenderer.setRenderTarget(blur.target);\n\t\t\trenderer.clear();\n\t\t\tblur.quad.render(renderer);\n\t\t}\n\t\trenderer.setRenderTarget(original);\n\t\tdrawRear();\n\t\trenderer.clearDepth();\n\t\trenderer.render(this.scene, camera);\n\t\tthis.passes++;\n\t\tfor (const [card] of active) card.setAttribute('data-carousel-glass-ready', '');\n\t}\n\n\tdispose() {\n\t\tfor (const [card, entry] of this.panels) {\n\t\t\tcard.removeAttribute('data-carousel-glass-ready');\n\t\t\tentry.glass.dispose();\n\t\t}\n\t\tthis.panels.clear();\n\t\tthis.scene.clear();\n\t\tthis.capture?.dispose();\n\t\tfor (const blur of this.blurs.values()) {\n\t\t\tblur.target.dispose();\n\t\t\tblur.material.dispose();\n\t\t\tblur.effect.dispose();\n\t\t}\n\t\tthis.blurs.clear();\n\t}\n}\n"]}
1
+ {"version":3,"file":"CarouselGlassCompositor.js","sourceRoot":"","sources":["../../src/catalog/CarouselGlassCompositor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,2FAA2F;AAC3F,MAAM,OAAO,uBAAuB;IACN;IAA7B,YAA6B,SAA2B;QAA3B,cAAS,GAAT,SAAS,CAAkB;IAAG,CAAC;IAC5D,gBAAgB;QACf,OAAO;YACN,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACvC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;SAC7F,CAAC;IACH,CAAC;IACO,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;IAC1B,OAAO,CAAsB;IAC7B,iBAAiB,CAAsB;IACvC,SAAS,CAAkB;IAC3B,KAAK,GAAG,IAAI,GAAG,EAQpB,CAAC;IACI,MAAM,GAAG,IAAI,GAAG,EAGrB,CAAC;IACI,IAAI,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;IAC3B,MAAM,GAAG,CAAC,CAAC;IACX,OAAO,GAAG,CAAC,CAAC;IAEpB,QAAQ;QACP,OAAO;YACN,M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AAiB,EAAE,OAAO,EAAE,CAAC;QAClC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;YACxC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACtB,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACxB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;CACD","sourcesContent":["import { gaussianTargets } from '../stage/renderTargetInventory.js';\nimport * as THREE from 'three/webgpu';\nimport { texture } from 'three/tsl';\nimport { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';\nimport { LiquidGlassPanel } from '../stage/LiquidGlassPanel.js';\nimport type { CatalogDepthBlur } from './CatalogDepthBlur.js';\n\n/** Reuses the stage device/output and glass shader; never samples its own glass output. */\nexport class CarouselGlassCompositor {\n\tconstructor(private readonly depthBlur: CatalogDepthBlur) {}\n\tgetRenderTargets() {\n\t\treturn [\n\t\t\t...(this.capture ? [this.capture] : []),\n\t\t\t...[...this.blurs.values()].flatMap((blur) => [blur.target, ...gaussianTargets(blur.effect)])\n\t\t];\n\t}\n\tprivate scene = new THREE.Scene();\n\tprivate capture?: THREE.RenderTarget;\n\tprivate compositeMaterial?: THREE.NodeMaterial;\n\tprivate composite?: THREE.QuadMesh;\n\tprivate blurs = new Map<\n\t\tnumber,\n\t\t{\n\t\t\ttarget: THREE.RenderTarget;\n\t\t\tmaterial: THREE.NodeMaterial;\n\t\t\tquad: THREE.QuadMesh;\n\t\t\teffect: ReturnType<typeof gaussianBlur>;\n\t\t}\n\t>();\n\tprivate panels = new Map<\n\t\tHTMLElement,\n\t\t{ glass: LiquidGlassPanel; blur: number; focusBlur: number; width: number; height: number; active: boolean; seen: boolean }\n\t>();\n\tprivate size = new THREE.Vector2();\n\tprivate passes = 0;\n\tprivate resizes = 0;\n\n\tgetStats() {\n\t\treturn {\n\t\t\tpanels: this.panels.size,\n\t\t\ttargets: (this.capture ? 1 : 0) + this.blurs.size,\n\t\t\tpasses: this.passes,\n\t\t\tresizes: this.resizes\n\t\t};\n\t}\n\n\tbeginFrame() {\n\t\tfor (const entry of this.panels.values()) {\n\t\t\tentry.active = false;\n\t\t\tentry.seen = false;\n\t\t\tentry.glass.group.visible = false;\n\t\t}\n\t}\n\n\tpanel(card: HTMLElement, matrix: THREE.Matrix4, width: number, height: number, opacity: number, focusBlur = 0) {\n\t\tif (card.dataset.carouselSurface !== 'glass') return;\n\t\tif (!this.capture) {\n\t\t\tthis.capture = new THREE.RenderTarget(1, 1);\n\t\t\tthis.compositeMaterial = new THREE.NodeMaterial();\n\t\t\tthis.compositeMaterial.fragmentNode = texture(this.capture.texture);\n\t\t\tthis.compositeMaterial.transparent = true;\n\t\t\tthis.compositeMaterial.blending = THREE.CustomBlending;\n\t\t\tthis.compositeMaterial.blendSrc = this.compositeMaterial.blendSrcAlpha = THREE.OneFactor;\n\t\t\tthis.compositeMaterial.blendDst = this.compositeMaterial.blendDstAlpha = THREE.OneMinusSrcAlphaFactor;\n\t\t\tthis.compositeMaterial.depthTest = false;\n\t\t\tthis.compositeMaterial.depthWrite = false;\n\t\t\tthis.compositeMaterial.toneMapped = false;\n\t\t\tthis.composite = new THREE.QuadMesh(this.compositeMaterial);\n\t\t}\n\t\tlet entry = this.panels.get(card);\n\t\tif (!entry) {\n\t\t\tconst options = JSON.parse(card.dataset.carouselTheme ?? '{}');\n\t\t\tconst blur = Math.min(100, Math.max(0, options.backdropBlur ?? 5));\n\t\t\tif (!this.blurs.has(blur)) {\n\t\t\t\tconst target = new THREE.RenderTarget(1, 1, { depthBuffer: false });\n\t\t\t\tconst sample = texture(this.capture.texture);\n\t\t\t\tconst effect = gaussianBlur(\n\t\t\t\t\tsample,\n\t\t\t\t\t1,\n\t\t\t\t\tMath.max(1, Math.round(blur)),\n\t\t\t\t\t{ resolutionScale: 1 }\n\t\t\t\t);\n\t\t\t\tconst material = new THREE.NodeMaterial();\n\t\t\t\t// Resolve the original white backdrop after blurring, without another fullscreen capture.\n\t\t\t\tconst filtered = blur ? effect : sample;\n\t\t\t\tmaterial.colorNode = filtered.rgb.add(filtered.a.oneMinus());\n\t\t\t\tthis.blurs.set(blur, { target, effect, material, quad: new THREE.QuadMesh(material) });\n\t\t\t}\n\t\t\tconst glass = new LiquidGlassPanel(this.blurs.get(blur)!.target.texture, {\n\t\t\t\t...options,\n\t\t\t\twidth,\n\t\t\t\theight\n\t\t\t});\n\t\t\tglass.group.matrixAutoUpdate = false;\n\t\t\tthis.scene.add(glass.group);\n\t\t\tentry = { glass, blur, focusBlur, width, height, active: false, seen: false };\n\t\t\tthis.panels.set(card, entry);\n\t\t}\n\t\tentry.seen = true;\n\t\tentry.focusBlur = focusBlur;\n\t\tentry.width = width;\n\t\tentry.height = height;\n\t\tentry.active = opacity > 0.001;\n\t\tentry.glass.setVisualSize(width, height);\n\t\tentry.glass.setVisibilityAlpha(opacity);\n\t\tentry.glass.group.matrix.copy(matrix);\n\t\tentry.glass.group.matrixWorldNeedsUpdate = true;\n\t}\n\n\tendFrame() {\n\t\tfor (const [card, entry] of this.panels) {\n\t\t\tif (!entry.active) card.removeAttribute('data-carousel-glass-ready');\n\t\t\tif (!entry.seen || !card.isConnected || card.hidden) {\n\t\t\t\tthis.scene.remove(entry.glass.group);\n\t\t\t\tentry.glass.dispose();\n\t\t\t\tthis.panels.delete(card);\n\t\t\t}\n\t\t}\n\t}\n\n\trender(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera, drawRear: () => void) {\n\t\tconst active = [...this.panels.entries()].filter(([, entry]) => entry.active);\n\t\tif (!active.length || !this.capture) {\n\t\t\tdrawRear();\n\t\t\treturn;\n\t\t}\n\t\t// CSS-pixel resolution bounds blur cost; resizing only on viewport changes.\n\t\tconst width = Math.max(1, window.innerWidth),\n\t\t\theight = Math.max(1, window.innerHeight);\n\t\tif (this.size.x !== width || this.size.y !== height) {\n\t\t\tthis.size.set(width, height);\n\t\t\tthis.capture.setSize(width, height);\n\t\t\tthis.resizes++;\n\t\t}\n\t\tconst original = renderer.getRenderTarget();\n\t\tconst clearColor = renderer.getClearColor(new THREE.Color());\n\t\tconst clearAlpha = renderer.getClearAlpha();\n\t\ttry {\n\t\t\trenderer.setRenderTarget(this.capture);\n\t\t\trenderer.setClearColor(0x000000, 0);\n\t\t\trenderer.clear();\n\t\t\tdrawRear();\n\t\t\tfor (const key of new Set(active.map(([, entry]) => entry.blur))) {\n\t\t\t\tconst blur = this.blurs.get(key)!;\n\t\t\t\tif (blur.target.width !== width || blur.target.height !== height) {\n\t\t\t\t\tblur.target.setSize(width, height);\n\t\t\t\t\tthis.resizes++;\n\t\t\t\t}\n\t\t\t\trenderer.setRenderTarget(blur.target);\n\t\t\t\trenderer.clear();\n\t\t\t\tblur.quad.render(renderer);\n\t\t\t}\n\t\t\trenderer.setRenderTarget(original);\n\t\t\t// Rear geometry, including defocus, is submitted once and reused by the glass and output.\n\t\t\tthis.composite!.render(renderer);\n\t\t\trenderer.clearDepth();\n\t\t\tif (active.some(([, entry]) => entry.focusBlur >= 0.05)) {\n\t\t\t\tfor (const [, entry] of active) entry.glass.group.visible = false;\n\t\t\t\tfor (const [, entry] of active) {\n\t\t\t\t\tconst group = entry.glass.group;\n\t\t\t\t\tgroup.visible = true;\n\t\t\t\t\tgroup.updateWorldMatrix(true, false);\n\t\t\t\t\tconst corners = [-1, 1].flatMap((x) => [-1, 1].map((y) =>\n\t\t\t\t\t\tnew THREE.Vector3(x * (entry.width / 2 + 48), y * (entry.height / 2 + 48), 0)\n\t\t\t\t\t\t\t.applyMatrix4(group.matrixWorld).project(camera)));\n\t\t\t\t\tconst xs = corners.map((p) => (p.x + 1) * width / 2);\n\t\t\t\t\tconst ys = corners.map((p) => (1 - p.y) * height / 2);\n\t\t\t\t\tthis.depthBlur.render(renderer, camera,\n\t\t\t\t\t\t{ left: Math.min(...xs), top: Math.min(...ys), width: Math.max(...xs) - Math.min(...xs), height: Math.max(...ys) - Math.min(...ys) },\n\t\t\t\t\t\tentry.focusBlur, (projection) => {\n\t\t\t\t\t\t\tconst view = projection.view;\n\t\t\t\t\t\t\tif (view?.enabled) entry.glass.setBackdropUvTransform(\n\t\t\t\t\t\t\t\tview.offsetX / view.fullWidth, view.offsetY / view.fullHeight,\n\t\t\t\t\t\t\t\tview.width / view.fullWidth, view.height / view.fullHeight);\n\t\t\t\t\t\t\ttry { renderer.render(this.scene, projection); }\n\t\t\t\t\t\t\tfinally { entry.glass.setBackdropUvTransform(0, 0, 1, 1); }\n\t\t\t\t\t\t});\n\t\t\t\t\tgroup.visible = false;\n\t\t\t\t}\n\t\t\t\tfor (const [, entry] of active) entry.glass.group.visible = true;\n\t\t\t} else renderer.render(this.scene, camera);\n\t\t\tthis.passes++;\n\t\t\tfor (const [card] of active) card.setAttribute('data-carousel-glass-ready', '');\n\t\t} finally {\n\t\t\trenderer.setRenderTarget(original);\n\t\t\trenderer.setClearColor(clearColor, clearAlpha);\n\t\t}\n\t}\n\n\tdispose() {\n\t\tfor (const [card, entry] of this.panels) {\n\t\t\tcard.removeAttribute('data-carousel-glass-ready');\n\t\t\tentry.glass.dispose();\n\t\t}\n\t\tthis.panels.clear();\n\t\tthis.scene.clear();\n\t\tthis.capture?.dispose();\n\t\tthis.compositeMaterial?.dispose();\n\t\tfor (const blur of this.blurs.values()) {\n\t\t\tblur.target.dispose();\n\t\t\tblur.material.dispose();\n\t\t\tblur.effect.dispose();\n\t\t}\n\t\tthis.blurs.clear();\n\t}\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import * as THREE from 'three/webgpu';
2
+ /** Parallel light from above/right/front, projected onto the shared y=0 receiver. */
3
+ export declare function carouselShadowProjection(): THREE.Matrix4;
4
+ /** Actual mesh silhouettes on one floor; no tinted receiver or generic shadow decals. */
5
+ export declare class CarouselGround {
6
+ private readonly scene;
7
+ private readonly blur;
8
+ private readonly shadows;
9
+ private readonly seen;
10
+ getRenderTargets(): THREE.RenderTarget<THREE.Texture<unknown, THREE.TextureEventMap>, THREE.RenderTargetEventMap>[];
11
+ beginFrame(): void;
12
+ shadow(key: object, model: THREE.Object3D, floor: THREE.Matrix4, opacity: number): void;
13
+ endFrame(): void;
14
+ draw(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera, opacity?: number): void;
15
+ getStats(): {
16
+ silhouettes: number;
17
+ };
18
+ private release;
19
+ dispose(): void;
20
+ }
21
+ //# sourceMappingURL=CarouselGround.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CarouselGround.d.ts","sourceRoot":"","sources":["../../src/catalog/CarouselGround.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,qFAAqF;AACrF,wBAAgB,wBAAwB,kBAEvC;AAUD,yFAAyF;AACzF,qBAAa,cAAc;IAC1B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;IAC3C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA0B;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqB;IAC1C,gBAAgB;IAChB,UAAU;IACV,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM;IAgChF,QAAQ;IAMR,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC,iBAAiB,EAAE,OAAO,SAAI;IA0BjF,QAAQ;;;IACR,OAAO,CAAC,OAAO;IAKf,OAAO;CAGP"}
@@ -0,0 +1,107 @@
1
+ import * as THREE from 'three/webgpu';
2
+ import { CatalogDepthBlur } from './CatalogDepthBlur.js';
3
+ import { isMesh } from '../stage/stageSceneUtils.js';
4
+ /** Parallel light from above/right/front, projected onto the shared y=0 receiver. */
5
+ export function carouselShadowProjection() {
6
+ return new THREE.Matrix4().set(1, -0.65, 0, 0, 0, 0, 0, 0.4, 0, -0.55, 1, 0, 0, 0, 0, 1);
7
+ }
8
+ /** Actual mesh silhouettes on one floor; no tinted receiver or generic shadow decals. */
9
+ export class CarouselGround {
10
+ scene = new THREE.Scene();
11
+ blur = new CatalogDepthBlur();
12
+ shadows = new Map();
13
+ seen = new Set();
14
+ getRenderTargets() { return this.blur.getRenderTargets(); }
15
+ beginFrame() { this.seen.clear(); }
16
+ shadow(key, model, floor, opacity) {
17
+ this.seen.add(key);
18
+ let entry = this.shadows.get(key);
19
+ if (entry && entry.model !== model) {
20
+ this.release(entry);
21
+ this.shadows.delete(key);
22
+ entry = undefined;
23
+ }
24
+ if (!entry) {
25
+ // Replace pixels in the scratch target: overlapping triangles form one silhouette.
26
+ const material = new THREE.MeshBasicMaterial({ color: 0x000000, transparent: true,
27
+ blending: THREE.NoBlending, depthWrite: false, depthTest: false,
28
+ toneMapped: false, side: THREE.DoubleSide });
29
+ const group = new THREE.Group();
30
+ entry = { model, group, meshes: [], material, opacity };
31
+ model.traverseVisible(source => {
32
+ if (!isMesh(source))
33
+ return;
34
+ const shadow = source.clone(false);
35
+ shadow.material = material;
36
+ shadow.matrixAutoUpdate = false;
37
+ shadow.frustumCulled = false;
38
+ group.add(shadow);
39
+ entry.meshes.push({ source, shadow });
40
+ });
41
+ this.shadows.set(key, entry);
42
+ this.scene.add(group);
43
+ }
44
+ entry.opacity = opacity;
45
+ const projection = floor.clone().multiply(carouselShadowProjection()).multiply(floor.clone().invert());
46
+ for (const { source, shadow } of entry.meshes) {
47
+ shadow.matrix.copy(projection).multiply(source.matrixWorld);
48
+ shadow.matrixWorldNeedsUpdate = true;
49
+ shadow.visible = source.visible;
50
+ }
51
+ entry.group.visible = false;
52
+ }
53
+ endFrame() {
54
+ for (const [key, entry] of this.shadows)
55
+ if (!this.seen.has(key)) {
56
+ this.release(entry);
57
+ this.shadows.delete(key);
58
+ }
59
+ }
60
+ draw(renderer, camera, opacity = 1) {
61
+ for (const entry of this.shadows.values()) {
62
+ entry.material.opacity = entry.opacity * opacity;
63
+ if (entry.material.opacity <= 0.001)
64
+ continue;
65
+ let left = Infinity, top = Infinity, right = -Infinity, bottom = -Infinity;
66
+ const point = new THREE.Vector3();
67
+ for (const { shadow } of entry.meshes) {
68
+ if (!shadow.visible)
69
+ continue;
70
+ if (!shadow.geometry.boundingBox)
71
+ shadow.geometry.computeBoundingBox();
72
+ const box = shadow.geometry.boundingBox;
73
+ for (const x of [box.min.x, box.max.x])
74
+ for (const y of [box.min.y, box.max.y])
75
+ for (const z of [box.min.z, box.max.z]) {
76
+ point.set(x, y, z).applyMatrix4(shadow.matrix).project(camera);
77
+ const px = (point.x + 1) * innerWidth / 2, py = (1 - point.y) * innerHeight / 2;
78
+ left = Math.min(left, px);
79
+ right = Math.max(right, px);
80
+ top = Math.min(top, py);
81
+ bottom = Math.max(bottom, py);
82
+ }
83
+ }
84
+ if (!Number.isFinite(left))
85
+ continue;
86
+ entry.group.visible = true;
87
+ try {
88
+ this.blur.render(renderer, camera, { left, top, width: right - left, height: bottom - top }, 2.5, projection => renderer.render(this.scene, projection));
89
+ }
90
+ finally {
91
+ entry.group.visible = false;
92
+ }
93
+ }
94
+ }
95
+ getStats() { return { silhouettes: this.shadows.size }; }
96
+ release(entry) {
97
+ entry.group.removeFromParent();
98
+ entry.material.dispose();
99
+ // Geometry belongs to the asset manager and is shared, never disposed here.
100
+ }
101
+ dispose() {
102
+ this.seen.clear();
103
+ this.endFrame();
104
+ this.blur.dispose();
105
+ }
106
+ }
107
+ //# sourceMappingURL=CarouselGround.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CarouselGround.js","sourceRoot":"","sources":["../../src/catalog/CarouselGround.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC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AQ,CAAC,IAAI,CAAC;gBAAE,SAAS;YACrC,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;YAC3B,IAAI,CAAC;gBACJ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,EAAE,EAC1F,GAAG,EAAE,UAAU,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;YAC9D,CAAC;oBAAS,CAAC;gBAAC,KAAK,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC;YAAC,CAAC;QAC3C,CAAC;IACF,CAAC;IACD,QAAQ,KAAK,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,KAAa;QAC5B,KAAK,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC/B,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACzB,4EAA4E;IAC7E,CAAC;IACD,OAAO;QACN,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IACzD,CAAC;CACD","sourcesContent":["import * as THREE from 'three/webgpu';\nimport { CatalogDepthBlur } from './CatalogDepthBlur.js';\nimport { isMesh } from '../stage/stageSceneUtils.js';\n\n/** Parallel light from above/right/front, projected onto the shared y=0 receiver. */\nexport function carouselShadowProjection() {\n\treturn new THREE.Matrix4().set(1, -0.65, 0, 0, 0, 0, 0, 0.4, 0, -0.55, 1, 0, 0, 0, 0, 1);\n}\n\ninterface Shadow {\n\tmodel: THREE.Object3D;\n\tgroup: THREE.Group;\n\tmeshes: { source: THREE.Mesh; shadow: THREE.Mesh }[];\n\tmaterial: THREE.MeshBasicMaterial;\n\topacity: number;\n}\n\n/** Actual mesh silhouettes on one floor; no tinted receiver or generic shadow decals. */\nexport class CarouselGround {\n\tprivate readonly scene = new THREE.Scene();\n\tprivate readonly blur = new CatalogDepthBlur();\n\tprivate readonly shadows = new Map<object, Shadow>();\n\tprivate readonly seen = new Set<object>();\n\tgetRenderTargets() { return this.blur.getRenderTargets(); }\n\tbeginFrame() { this.seen.clear(); }\n\tshadow(key: object, model: THREE.Object3D, floor: THREE.Matrix4, opacity: number) {\n\t\tthis.seen.add(key);\n\t\tlet entry = this.shadows.get(key);\n\t\tif (entry && entry.model !== model) { this.release(entry); this.shadows.delete(key); entry = undefined; }\n\t\tif (!entry) {\n\t\t\t// Replace pixels in the scratch target: overlapping triangles form one silhouette.\n\t\t\tconst material = new THREE.MeshBasicMaterial({ color: 0x000000, transparent: true,\n\t\t\t\tblending: THREE.NoBlending, depthWrite: false, depthTest: false,\n\t\t\t\ttoneMapped: false, side: THREE.DoubleSide });\n\t\t\tconst group = new THREE.Group();\n\t\t\tentry = { model, group, meshes: [], material, opacity };\n\t\t\tmodel.traverseVisible(source => {\n\t\t\t\tif (!isMesh(source)) return;\n\t\t\t\tconst shadow = source.clone(false);\n\t\t\t\tshadow.material = material;\n\t\t\t\tshadow.matrixAutoUpdate = false;\n\t\t\t\tshadow.frustumCulled = false;\n\t\t\t\tgroup.add(shadow);\n\t\t\t\tentry!.meshes.push({ source, shadow });\n\t\t\t});\n\t\t\tthis.shadows.set(key, entry);\n\t\t\tthis.scene.add(group);\n\t\t}\n\t\tentry.opacity = opacity;\n\t\tconst projection = floor.clone().multiply(carouselShadowProjection()).multiply(floor.clone().invert());\n\t\tfor (const { source, shadow } of entry.meshes) {\n\t\t\tshadow.matrix.copy(projection).multiply(source.matrixWorld);\n\t\t\tshadow.matrixWorldNeedsUpdate = true;\n\t\t\tshadow.visible = source.visible;\n\t\t}\n\t\tentry.group.visible = false;\n\t}\n\tendFrame() {\n\t\tfor (const [key, entry] of this.shadows) if (!this.seen.has(key)) {\n\t\t\tthis.release(entry);\n\t\t\tthis.shadows.delete(key);\n\t\t}\n\t}\n\tdraw(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera, opacity = 1) {\n\t\tfor (const entry of this.shadows.values()) {\n\t\t\tentry.material.opacity = entry.opacity * opacity;\n\t\t\tif (entry.material.opacity <= 0.001) continue;\n\t\t\tlet left = Infinity, top = Infinity, right = -Infinity, bottom = -Infinity;\n\t\t\tconst point = new THREE.Vector3();\n\t\t\tfor (const { shadow } of entry.meshes) {\n\t\t\t\tif (!shadow.visible) continue;\n\t\t\t\tif (!shadow.geometry.boundingBox) shadow.geometry.computeBoundingBox();\n\t\t\t\tconst box = shadow.geometry.boundingBox!;\n\t\t\t\tfor (const x of [box.min.x, box.max.x]) for (const y of [box.min.y, box.max.y])\n\t\t\t\t\tfor (const z of [box.min.z, box.max.z]) {\n\t\t\t\t\t\tpoint.set(x, y, z).applyMatrix4(shadow.matrix).project(camera);\n\t\t\t\t\t\tconst px = (point.x + 1) * innerWidth / 2, py = (1 - point.y) * innerHeight / 2;\n\t\t\t\t\t\tleft = Math.min(left, px); right = Math.max(right, px);\n\t\t\t\t\t\ttop = Math.min(top, py); bottom = Math.max(bottom, py);\n\t\t\t\t\t}\n\t\t\t}\n\t\t\tif (!Number.isFinite(left)) continue;\n\t\t\tentry.group.visible = true;\n\t\t\ttry {\n\t\t\t\tthis.blur.render(renderer, camera, { left, top, width: right - left, height: bottom - top },\n\t\t\t\t\t2.5, projection => renderer.render(this.scene, projection));\n\t\t\t} finally { entry.group.visible = false; }\n\t\t}\n\t}\n\tgetStats() { return { silhouettes: this.shadows.size }; }\n\tprivate release(entry: Shadow) {\n\t\tentry.group.removeFromParent();\n\t\tentry.material.dispose();\n\t\t// Geometry belongs to the asset manager and is shared, never disposed here.\n\t}\n\tdispose() {\n\t\tthis.seen.clear(); this.endFrame(); this.blur.dispose();\n\t}\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import * as THREE from 'three/webgpu';
2
+ export interface BlurRect {
3
+ left: number;
4
+ top: number;
5
+ width: number;
6
+ height: number;
7
+ }
8
+ /** One bounded scratch image for all defocused models and panels, reused between draws. */
9
+ export declare class CatalogDepthBlur {
10
+ private capture?;
11
+ private effect?;
12
+ private material?;
13
+ private quad?;
14
+ private readonly camera;
15
+ private readonly direction;
16
+ private passes;
17
+ getRenderTargets(): THREE.RenderTarget<THREE.Texture<unknown, THREE.TextureEventMap>, THREE.RenderTargetEventMap>[];
18
+ getStats(): {
19
+ passes: number;
20
+ targets: number;
21
+ size: number;
22
+ };
23
+ render(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera, bounds: BlurRect, radius: number, draw: (camera: THREE.PerspectiveCamera) => void, clip?: BlurRect): void;
24
+ dispose(): void;
25
+ }
26
+ //# sourceMappingURL=CatalogDepthBlur.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CatalogDepthBlur.d.ts","sourceRoot":"","sources":["../../src/catalog/CatalogDepthBlur.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAKtC,MAAM,WAAW,QAAQ;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AAEtF,2FAA2F;AAC3F,qBAAa,gBAAgB;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAqB;IACrC,OAAO,CAAC,MAAM,CAAC,CAAkC;IACjD,OAAO,CAAC,QAAQ,CAAC,CAAqB;IACtC,OAAO,CAAC,IAAI,CAAC,CAAiB;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IACxD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgC;IAC1D,OAAO,CAAC,MAAM,CAAK;IACnB,gBAAgB;IAChB,QAAQ;;;;;IAER,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC,iBAAiB,EACrE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,iBAAiB,KAAK,IAAI,EACjF,IAAI,GAAE,QAAsE;IAyD7E,OAAO;CAKP"}
@@ -0,0 +1,87 @@
1
+ import * as THREE from 'three/webgpu';
2
+ import { texture, uniform } from 'three/tsl';
3
+ import { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';
4
+ import { gaussianTargets } from '../stage/renderTargetInventory.js';
5
+ /** One bounded scratch image for all defocused models and panels, reused between draws. */
6
+ export class CatalogDepthBlur {
7
+ capture;
8
+ effect;
9
+ material;
10
+ quad;
11
+ camera = new THREE.PerspectiveCamera();
12
+ direction = uniform(new THREE.Vector2());
13
+ passes = 0;
14
+ getRenderTargets() { return this.capture ? [this.capture, ...gaussianTargets(this.effect)] : []; }
15
+ getStats() { return { passes: this.passes, targets: this.getRenderTargets().length, size: this.capture?.width ?? 0 }; }
16
+ render(renderer, camera, bounds, radius, draw, clip = { left: 0, top: 0, width: innerWidth, height: innerHeight }) {
17
+ if (radius < 0.05) {
18
+ draw(camera);
19
+ return;
20
+ }
21
+ const padding = Math.ceil(radius * 3 + 2);
22
+ const left = Math.max(0, clip.left, Math.floor(bounds.left - padding));
23
+ const top = Math.max(0, clip.top, Math.floor(bounds.top - padding));
24
+ const right = Math.min(innerWidth, clip.left + clip.width, Math.ceil(bounds.left + bounds.width + padding));
25
+ const bottom = Math.min(innerHeight, clip.top + clip.height, Math.ceil(bounds.top + bounds.height + padding));
26
+ const width = right - left, height = bottom - top;
27
+ if (width <= 0 || height <= 0)
28
+ return;
29
+ if (!this.capture) {
30
+ this.capture = new THREE.RenderTarget(512, 512, { type: THREE.HalfFloatType });
31
+ this.effect = gaussianBlur(texture(this.capture.texture), this.direction, 2, { resolutionScale: 0.5, premultipliedAlpha: false });
32
+ // Several actors reuse the scratch image within one stage frame.
33
+ this.effect.updateBeforeType = THREE.NodeUpdateType.RENDER;
34
+ this.material = new THREE.NodeMaterial();
35
+ this.material.fragmentNode = this.effect;
36
+ this.material.transparent = true;
37
+ // Captures and Gaussian samples are already premultiplied; do not multiply alpha twice.
38
+ this.material.blending = THREE.CustomBlending;
39
+ this.material.blendSrc = this.material.blendSrcAlpha = THREE.OneFactor;
40
+ this.material.blendDst = this.material.blendDstAlpha = THREE.OneMinusSrcAlphaFactor;
41
+ this.material.depthTest = false;
42
+ this.material.depthWrite = false;
43
+ this.material.toneMapped = false;
44
+ this.quad = new THREE.QuadMesh(this.material);
45
+ }
46
+ const destination = renderer.getRenderTarget();
47
+ const viewport = destination ? destination.viewport.clone() : renderer.getViewport(new THREE.Vector4());
48
+ const clearColor = renderer.getClearColor(new THREE.Color());
49
+ const clearAlpha = renderer.getClearAlpha();
50
+ const scissorTest = renderer.getScissorTest();
51
+ this.camera.copy(camera);
52
+ this.camera.setViewOffset(innerWidth, innerHeight, left, top, width, height);
53
+ // The half-resolution Gaussian uses a kernel standard deviation of 7/3 texels.
54
+ this.direction.value.set(radius * 256 / width / (7 / 3), radius * 256 / height / (7 / 3));
55
+ try {
56
+ renderer.setRenderTarget(this.capture);
57
+ renderer.setScissorTest(false);
58
+ renderer.setClearColor(0x000000, 0);
59
+ renderer.clear();
60
+ draw(this.camera);
61
+ renderer.setRenderTarget(destination);
62
+ const scaleX = viewport.z / innerWidth, scaleY = viewport.w / innerHeight;
63
+ const output = new THREE.Vector4(viewport.x + left * scaleX, viewport.y + top * scaleY, width * scaleX, height * scaleY);
64
+ if (destination)
65
+ destination.viewport.copy(output);
66
+ else
67
+ renderer.setViewport(output);
68
+ this.quad.render(renderer);
69
+ this.passes++;
70
+ }
71
+ finally {
72
+ renderer.setRenderTarget(destination);
73
+ if (destination)
74
+ destination.viewport.copy(viewport);
75
+ else
76
+ renderer.setViewport(viewport);
77
+ renderer.setClearColor(clearColor, clearAlpha);
78
+ renderer.setScissorTest(scissorTest);
79
+ }
80
+ }
81
+ dispose() {
82
+ this.capture?.dispose();
83
+ this.effect?.dispose();
84
+ this.material?.dispose();
85
+ }
86
+ }
87
+ //# sourceMappingURL=CatalogDepthBlur.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CatalogDepthBlur.js","sourceRoot":"","sources":["../../src/catalog/CatalogDepthBlur.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAIpE,2FAA2F;AAC3F,MAAM,OAAO,gBAAgB;IACpB,OAAO,CAAsB;IAC7B,MAAM,CAAmC;IACzC,QAAQ,CAAsB;IAC9B,IAAI,CAAkB;IACb,MAAM,GAAG,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;IACvC,SAAS,GAAG,OAAO,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IAClD,MAAM,GAAG,CAAC,CAAC;IACnB,gBAAgB,KAAK,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,MAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnG,QAAQ,KAAK,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAEvH,MAAM,CAAC,QAA8B,EAAE,MAA+B,EACrE,MAAgB,EAAE,MA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AC,CAAC,GAAG,WAAW,CAAC;YAC1E,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,GAAG,MAAM,EAAE,QAAQ,CAAC,CAAC,GAAG,GAAG,GAAG,MAAM,EAAE,KAAK,GAAG,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;YACzH,IAAI,WAAW;gBAAE,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;;gBAC9C,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAClC,IAAI,CAAC,IAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC5B,IAAI,CAAC,MAAM,EAAE,CAAC;QACf,CAAC;gBAAS,CAAC;YACV,QAAQ,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;YACtC,IAAI,WAAW;gBAAE,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;;gBAChD,QAAQ,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;YACpC,QAAQ,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAC/C,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACtC,CAAC;IACF,CAAC;IACD,OAAO;QACN,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;QACvB,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;IAC1B,CAAC;CACD","sourcesContent":["import * as THREE from 'three/webgpu';\nimport { texture, uniform } from 'three/tsl';\nimport { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';\nimport { gaussianTargets } from '../stage/renderTargetInventory.js';\n\nexport interface BlurRect { left: number; top: number; width: number; height: number }\n\n/** One bounded scratch image for all defocused models and panels, reused between draws. */\nexport class CatalogDepthBlur {\n\tprivate capture?: THREE.RenderTarget;\n\tprivate effect?: ReturnType<typeof gaussianBlur>;\n\tprivate material?: THREE.NodeMaterial;\n\tprivate quad?: THREE.QuadMesh;\n\tprivate readonly camera = new THREE.PerspectiveCamera();\n\tprivate readonly direction = uniform(new THREE.Vector2());\n\tprivate passes = 0;\n\tgetRenderTargets() { return this.capture ? [this.capture, ...gaussianTargets(this.effect!)] : []; }\n\tgetStats() { return { passes: this.passes, targets: this.getRenderTargets().length, size: this.capture?.width ?? 0 }; }\n\n\trender(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera,\n\t\tbounds: BlurRect, radius: number, draw: (camera: THREE.PerspectiveCamera) => void,\n\t\tclip: BlurRect = { left: 0, top: 0, width: innerWidth, height: innerHeight }) {\n\t\tif (radius < 0.05) { draw(camera); return; }\n\t\tconst padding = Math.ceil(radius * 3 + 2);\n\t\tconst left = Math.max(0, clip.left, Math.floor(bounds.left - padding));\n\t\tconst top = Math.max(0, clip.top, Math.floor(bounds.top - padding));\n\t\tconst right = Math.min(innerWidth, clip.left + clip.width, Math.ceil(bounds.left + bounds.width + padding));\n\t\tconst bottom = Math.min(innerHeight, clip.top + clip.height, Math.ceil(bounds.top + bounds.height + padding));\n\t\tconst width = right - left, height = bottom - top;\n\t\tif (width <= 0 || height <= 0) return;\n\t\tif (!this.capture) {\n\t\t\tthis.capture = new THREE.RenderTarget(512, 512, { type: THREE.HalfFloatType });\n\t\t\tthis.effect = gaussianBlur(texture(this.capture.texture), this.direction, 2,\n\t\t\t\t{ resolutionScale: 0.5, premultipliedAlpha: false });\n\t\t\t// Several actors reuse the scratch image within one stage frame.\n\t\t\tthis.effect.updateBeforeType = THREE.NodeUpdateType.RENDER;\n\t\t\tthis.material = new THREE.NodeMaterial();\n\t\t\tthis.material.fragmentNode = this.effect;\n\t\t\tthis.material.transparent = true;\n\t\t\t// Captures and Gaussian samples are already premultiplied; do not multiply alpha twice.\n\t\t\tthis.material.blending = THREE.CustomBlending;\n\t\t\tthis.material.blendSrc = this.material.blendSrcAlpha = THREE.OneFactor;\n\t\t\tthis.material.blendDst = this.material.blendDstAlpha = THREE.OneMinusSrcAlphaFactor;\n\t\t\tthis.material.depthTest = false;\n\t\t\tthis.material.depthWrite = false;\n\t\t\tthis.material.toneMapped = false;\n\t\t\tthis.quad = new THREE.QuadMesh(this.material);\n\t\t}\n\t\tconst destination = renderer.getRenderTarget();\n\t\tconst viewport = destination ? destination.viewport.clone() : renderer.getViewport(new THREE.Vector4());\n\t\tconst clearColor = renderer.getClearColor(new THREE.Color());\n\t\tconst clearAlpha = renderer.getClearAlpha();\n\t\tconst scissorTest = renderer.getScissorTest();\n\t\tthis.camera.copy(camera);\n\t\tthis.camera.setViewOffset(innerWidth, innerHeight, left, top, width, height);\n\t\t// The half-resolution Gaussian uses a kernel standard deviation of 7/3 texels.\n\t\tthis.direction.value.set(radius * 256 / width / (7 / 3), radius * 256 / height / (7 / 3));\n\t\ttry {\n\t\t\trenderer.setRenderTarget(this.capture);\n\t\t\trenderer.setScissorTest(false);\n\t\t\trenderer.setClearColor(0x000000, 0);\n\t\t\trenderer.clear();\n\t\t\tdraw(this.camera);\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\tconst scaleX = viewport.z / innerWidth, scaleY = viewport.w / innerHeight;\n\t\t\tconst output = new THREE.Vector4(viewport.x + left * scaleX, viewport.y + top * scaleY, width * scaleX, height * scaleY);\n\t\t\tif (destination) destination.viewport.copy(output);\n\t\t\telse renderer.setViewport(output);\n\t\t\tthis.quad!.render(renderer);\n\t\t\tthis.passes++;\n\t\t} finally {\n\t\t\trenderer.setRenderTarget(destination);\n\t\t\tif (destination) destination.viewport.copy(viewport);\n\t\t\telse renderer.setViewport(viewport);\n\t\t\trenderer.setClearColor(clearColor, clearAlpha);\n\t\t\trenderer.setScissorTest(scissorTest);\n\t\t}\n\t}\n\tdispose() {\n\t\tthis.capture?.dispose();\n\t\tthis.effect?.dispose();\n\t\tthis.material?.dispose();\n\t}\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import * as THREE from 'three/webgpu';
2
+ import type { StageInteractionTheme } from '../stage/stageTypes.js';
3
+ import type { BlurRect } from './CatalogDepthBlur.js';
4
+ /** A shared, cropped silhouette target. Idle hover fades reuse its last mask. */
5
+ export declare class CatalogModelOutline {
6
+ private readonly scene;
7
+ private readonly camera;
8
+ private readonly controls;
9
+ private readonly modelMatrix;
10
+ private readonly cameraMatrix;
11
+ private readonly projection;
12
+ private masks;
13
+ private source?;
14
+ private capture?;
15
+ private maskMaterial?;
16
+ private material?;
17
+ private quad?;
18
+ private captures;
19
+ private passes;
20
+ getRenderTargets(): THREE.RenderTarget<THREE.Texture<unknown, THREE.TextureEventMap>, THREE.RenderTargetEventMap>[];
21
+ getStats(): {
22
+ captures: number;
23
+ passes: number;
24
+ targets: number;
25
+ size: number;
26
+ };
27
+ render(renderer: THREE.WebGPURenderer, camera: THREE.PerspectiveCamera, model: THREE.Object3D, bounds: BlurRect, clip: BlurRect, opacity: number, theme: StageInteractionTheme): void;
28
+ release(model: THREE.Object3D): void;
29
+ dispose(): void;
30
+ }
31
+ //# sourceMappingURL=CatalogModelOutline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CatalogModelOutline.d.ts","sourceRoot":"","sources":["../../src/catalog/CatalogModelOutline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD,iFAAiF;AACjF,qBAAa,mBAAmB;IAC/B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;IAC3C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IACxD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2B;IACpD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuB;IACnD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAuB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