@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.
- package/dist/catalog/CarouselDeviceCamera.d.ts +12 -0
- package/dist/catalog/CarouselDeviceCamera.d.ts.map +1 -0
- package/dist/catalog/CarouselDeviceCamera.js +44 -0
- package/dist/catalog/CarouselDeviceCamera.js.map +1 -0
- package/dist/catalog/CarouselGlassCompositor.d.ts +7 -2
- package/dist/catalog/CarouselGlassCompositor.d.ts.map +1 -1
- package/dist/catalog/CarouselGlassCompositor.js +85 -24
- package/dist/catalog/CarouselGlassCompositor.js.map +1 -1
- package/dist/catalog/CarouselGround.d.ts +21 -0
- package/dist/catalog/CarouselGround.d.ts.map +1 -0
- package/dist/catalog/CarouselGround.js +107 -0
- package/dist/catalog/CarouselGround.js.map +1 -0
- package/dist/catalog/CatalogDepthBlur.d.ts +26 -0
- package/dist/catalog/CatalogDepthBlur.d.ts.map +1 -0
- package/dist/catalog/CatalogDepthBlur.js +87 -0
- package/dist/catalog/CatalogDepthBlur.js.map +1 -0
- package/dist/catalog/CatalogModelOutline.d.ts +31 -0
- package/dist/catalog/CatalogModelOutline.d.ts.map +1 -0
- package/dist/catalog/CatalogModelOutline.js +127 -0
- package/dist/catalog/CatalogModelOutline.js.map +1 -0
- package/dist/catalog/CatalogSpatialElementLayer.d.ts +44 -2
- package/dist/catalog/CatalogSpatialElementLayer.d.ts.map +1 -1
- package/dist/catalog/CatalogSpatialElementLayer.js +293 -88
- package/dist/catalog/CatalogSpatialElementLayer.js.map +1 -1
- package/dist/catalog/CatalogTransition.d.ts.map +1 -1
- package/dist/catalog/CatalogTransition.js +62 -4
- package/dist/catalog/CatalogTransition.js.map +1 -1
- package/dist/catalog/SpatialGeometryCapture.d.ts +9 -0
- package/dist/catalog/SpatialGeometryCapture.d.ts.map +1 -1
- package/dist/catalog/SpatialGeometryCapture.js +11 -1
- package/dist/catalog/SpatialGeometryCapture.js.map +1 -1
- package/dist/catalog/cardModelFit.d.ts +7 -0
- package/dist/catalog/cardModelFit.d.ts.map +1 -0
- package/dist/catalog/cardModelFit.js +16 -0
- package/dist/catalog/cardModelFit.js.map +1 -0
- package/dist/catalog/cardProjection.d.ts +8 -0
- package/dist/catalog/cardProjection.d.ts.map +1 -0
- package/dist/catalog/cardProjection.js +51 -0
- package/dist/catalog/cardProjection.js.map +1 -0
- package/dist/catalog/carouselMotion.d.ts +35 -0
- package/dist/catalog/carouselMotion.d.ts.map +1 -1
- package/dist/catalog/carouselMotion.js +85 -4
- package/dist/catalog/carouselMotion.js.map +1 -1
- package/dist/catalog/carouselProximity.d.ts +11 -0
- package/dist/catalog/carouselProximity.d.ts.map +1 -0
- package/dist/catalog/carouselProximity.js +13 -0
- package/dist/catalog/carouselProximity.js.map +1 -0
- package/dist/catalog/carouselSupport.d.ts +4 -0
- package/dist/catalog/carouselSupport.d.ts.map +1 -0
- package/dist/catalog/carouselSupport.js +30 -0
- package/dist/catalog/carouselSupport.js.map +1 -0
- package/dist/catalog/catalogPose.d.ts +36 -6
- package/dist/catalog/catalogPose.d.ts.map +1 -1
- package/dist/catalog/catalogPose.js +79 -23
- package/dist/catalog/catalogPose.js.map +1 -1
- package/dist/catalog/deviceYaw.d.ts +21 -0
- package/dist/catalog/deviceYaw.d.ts.map +1 -0
- package/dist/catalog/deviceYaw.js +87 -0
- package/dist/catalog/deviceYaw.js.map +1 -0
- package/dist/catalog/listDeviceOrientation.d.ts +15 -0
- package/dist/catalog/listDeviceOrientation.d.ts.map +1 -0
- package/dist/catalog/listDeviceOrientation.js +245 -0
- package/dist/catalog/listDeviceOrientation.js.map +1 -0
- package/dist/stage/DeviceGeometryMotion.d.ts +13 -0
- package/dist/stage/DeviceGeometryMotion.d.ts.map +1 -0
- package/dist/stage/DeviceGeometryMotion.js +37 -0
- package/dist/stage/DeviceGeometryMotion.js.map +1 -0
- package/dist/stage/LiquidGlassPanel.d.ts +2 -0
- package/dist/stage/LiquidGlassPanel.d.ts.map +1 -1
- package/dist/stage/LiquidGlassPanel.js +8 -1
- package/dist/stage/LiquidGlassPanel.js.map +1 -1
- package/dist/stage/MinimapController.d.ts +1 -0
- package/dist/stage/MinimapController.d.ts.map +1 -1
- package/dist/stage/MinimapController.js +7 -0
- package/dist/stage/MinimapController.js.map +1 -1
- package/dist/stage/PanelPresentationController.d.ts.map +1 -1
- package/dist/stage/PanelPresentationController.js +19 -7
- package/dist/stage/PanelPresentationController.js.map +1 -1
- package/dist/stage/StageExperience.d.ts +56 -0
- package/dist/stage/StageExperience.d.ts.map +1 -1
- package/dist/stage/StageExperience.js +53 -17
- package/dist/stage/StageExperience.js.map +1 -1
- package/dist/stage/StageRenderPipeline.d.ts.map +1 -1
- package/dist/stage/StageRenderPipeline.js +14 -63
- package/dist/stage/StageRenderPipeline.js.map +1 -1
- package/dist/stage/interactionOutline.d.ts +14 -0
- package/dist/stage/interactionOutline.d.ts.map +1 -0
- package/dist/stage/interactionOutline.js +81 -0
- package/dist/stage/interactionOutline.js.map +1 -0
- package/dist/stage/panelContext.d.ts +2 -0
- package/dist/stage/panelContext.d.ts.map +1 -1
- package/dist/stage/panelContext.js.map +1 -1
- package/dist/stage/stageTypes.d.ts +1 -0
- package/dist/stage/stageTypes.d.ts.map +1 -1
- package/dist/stage/stageTypes.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PerspectiveCamera, Vector3 } from 'three/webgpu';
|
|
2
|
+
/** Small camera orbit around the selected geometry; UI uses a separate fixed camera. */
|
|
3
|
+
export declare class CarouselDeviceCamera {
|
|
4
|
+
readonly angles: Vector3;
|
|
5
|
+
private readonly sensorAngles;
|
|
6
|
+
private readonly pivot;
|
|
7
|
+
private pivotReady;
|
|
8
|
+
private pivotSettling;
|
|
9
|
+
orbit(camera: PerspectiveCamera, pivot: Vector3, delta?: number, smooth?: boolean): boolean;
|
|
10
|
+
update(camera: PerspectiveCamera, yaw: number, pitch: number, roll: number, delta: number, reduced?: boolean): boolean;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=CarouselDeviceCamera.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CarouselDeviceCamera.d.ts","sourceRoot":"","sources":["../../src/catalog/CarouselDeviceCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,iBAAiB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAErE,wFAAwF;AACxF,qBAAa,oBAAoB;IAChC,QAAQ,CAAC,MAAM,UAAiB;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAiB;IAC9C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiB;IACvC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAS;IAC9B,KAAK,CAAC,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,EAAE,MAAM,UAAQ;IAY1E,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,UAAQ;CAkB1G"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { MathUtils, PerspectiveCamera, Vector3 } from 'three/webgpu';
|
|
2
|
+
/** Small camera orbit around the selected geometry; UI uses a separate fixed camera. */
|
|
3
|
+
export class CarouselDeviceCamera {
|
|
4
|
+
angles = new Vector3();
|
|
5
|
+
sensorAngles = new Vector3();
|
|
6
|
+
pivot = new Vector3();
|
|
7
|
+
pivotReady = false;
|
|
8
|
+
pivotSettling = false;
|
|
9
|
+
orbit(camera, pivot, delta = 1, smooth = false) {
|
|
10
|
+
if (this.pivotReady && (smooth || this.pivotSettling)) {
|
|
11
|
+
this.pivot.lerp(pivot, 1 - Math.exp(-12 * delta));
|
|
12
|
+
this.pivotSettling = this.pivot.distanceTo(pivot) > 0.01;
|
|
13
|
+
if (!this.pivotSettling)
|
|
14
|
+
this.pivot.copy(pivot);
|
|
15
|
+
}
|
|
16
|
+
else
|
|
17
|
+
this.pivot.copy(pivot);
|
|
18
|
+
this.pivotReady = true;
|
|
19
|
+
// C' = P + Q(C - P) preserves P's camera-space position, even off-centre.
|
|
20
|
+
camera.position.set(0, 0, 2500).sub(this.pivot).applyQuaternion(camera.quaternion).add(this.pivot);
|
|
21
|
+
camera.updateMatrixWorld(true);
|
|
22
|
+
return this.pivotSettling;
|
|
23
|
+
}
|
|
24
|
+
update(camera, yaw, pitch, roll, delta, reduced = false) {
|
|
25
|
+
const target = [pitch, yaw, roll];
|
|
26
|
+
let animating = false;
|
|
27
|
+
for (let i = 0; i < 3; i++) {
|
|
28
|
+
const limit = [10, 16, 6][i];
|
|
29
|
+
// Camera orbits amplify background parallax; keep sensor motion below card strength.
|
|
30
|
+
const value = reduced ? 0 : MathUtils.clamp(target[i], -limit, limit) * 0.25;
|
|
31
|
+
let next = reduced ? 0 : MathUtils.damp(this.sensorAngles.getComponent(i), value, 40, delta);
|
|
32
|
+
if (Math.abs(next - value) < 0.001)
|
|
33
|
+
next = value;
|
|
34
|
+
this.sensorAngles.setComponent(i, next);
|
|
35
|
+
animating ||= next !== value;
|
|
36
|
+
this.angles.setComponent(i, next);
|
|
37
|
+
}
|
|
38
|
+
// Rotating the observer has the inverse visual effect of rotating the scene.
|
|
39
|
+
camera.rotation.set(...this.angles.toArray().map(MathUtils.degToRad), 'ZXY');
|
|
40
|
+
camera.updateMatrixWorld(true);
|
|
41
|
+
return animating;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=CarouselDeviceCamera.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CarouselDeviceCamera.js","sourceRoot":"","sources":["../../src/catalog/CarouselDeviceCamera.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB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AAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,SAAS,CAAC;IAClB,CAAC;CACD","sourcesContent":["import { MathUtils, PerspectiveCamera, Vector3 } from 'three/webgpu';\n\n/** Small camera orbit around the selected geometry; UI uses a separate fixed camera. */\nexport class CarouselDeviceCamera {\n\treadonly angles = new Vector3();\n\tprivate readonly sensorAngles = new Vector3();\n\tprivate readonly pivot = new Vector3();\n\tprivate pivotReady = false;\n\tprivate pivotSettling = false;\n\torbit(camera: PerspectiveCamera, pivot: Vector3, delta = 1, smooth = false) {\n\t\tif (this.pivotReady && (smooth || this.pivotSettling)) {\n\t\t\tthis.pivot.lerp(pivot, 1 - Math.exp(-12 * delta));\n\t\t\tthis.pivotSettling = this.pivot.distanceTo(pivot) > 0.01;\n\t\t\tif (!this.pivotSettling) this.pivot.copy(pivot);\n\t\t} else this.pivot.copy(pivot);\n\t\tthis.pivotReady = true;\n\t\t// C' = P + Q(C - P) preserves P's camera-space position, even off-centre.\n\t\tcamera.position.set(0, 0, 2500).sub(this.pivot).applyQuaternion(camera.quaternion).add(this.pivot);\n\t\tcamera.updateMatrixWorld(true);\n\t\treturn this.pivotSettling;\n\t}\n\tupdate(camera: PerspectiveCamera, yaw: number, pitch: number, roll: number, delta: number, reduced = false) {\n\t\tconst target = [pitch, yaw, roll];\n\t\tlet animating = false;\n\t\tfor (let i = 0; i < 3; i++) {\n\t\t\tconst limit = [10, 16, 6][i];\n\t\t\t// Camera orbits amplify background parallax; keep sensor motion below card strength.\n\t\t\tconst value = reduced ? 0 : MathUtils.clamp(target[i], -limit, limit) * 0.25;\n\t\t\tlet next = reduced ? 0 : MathUtils.damp(this.sensorAngles.getComponent(i), value, 40, delta);\n\t\t\tif (Math.abs(next - value) < 0.001) next = value;\n\t\t\tthis.sensorAngles.setComponent(i, next);\n\t\t\tanimating ||= next !== value;\n\t\t\tthis.angles.setComponent(i, next);\n\t\t}\n\t\t// Rotating the observer has the inverse visual effect of rotating the scene.\n\t\tcamera.rotation.set(...this.angles.toArray().map(MathUtils.degToRad) as [number, number, number], 'ZXY');\n\t\tcamera.updateMatrixWorld(true);\n\t\treturn animating;\n\t}\n}\n"]}
|
|
@@ -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.
|
|
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;
|
|
1
|
+
{"version":3,"file":"CarouselGlassCompositor.d.ts","sourceRoot":"","sources":["../../src/catalog/CarouselGlassCompositor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,2FAA2F;AAC3F,qBAAa,uBAAuB;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAT,SAAS,EAAE,gBAAgB;IACxD,gBAAgB;IAMhB,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,OAAO,CAAC,CAAqB;IACrC,OAAO,CAAC,iBAAiB,CAAC,CAAqB;IAC/C,OAAO,CAAC,SAAS,CAAC,CAAiB;IACnC,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;IAQV,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,SAAI;IAuD7G,QAAQ;IAWR,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,CAAC,iBAAiB,EAAE,QAAQ,EAAE,MAAM,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
|
|
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
|
-
|
|
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.
|
|
95
|
-
renderer.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
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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D,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACnC,QAAQ,EAAE,CAAC;QACX,QAAQ,CAAC,UAAU,EAAE,CAAC;QACtB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM;YAAE,IAAI,CAAC,YAAY,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,OAAO;QACN,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACzC,IAAI,CAAC,eAAe,CAAC,2BAA2B,CAAC,CAAC;YAClD,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACxB,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,gBAAg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E,MAAM,CAAC,CAAC;YAC3C,IAAI,CAAC,MAAM,EAAE,CAAC;YACd,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM;gBAAE,IAAI,CAAC,YAAY,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAC;QACjF,CAAC;gBAAS,CAAC;YACV,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;YACnC,QAAQ,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAChD,CAAC;IACF,CAAC;IAED,OAAO;QACN,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YACzC,IAAI,CAAC,eAAe,CAAC,2BAA2B,CAAC,CAAC;YAClD,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,iBAAiB,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;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,qFAAqF;AACrF,MAAM,UAAU,wBAAwB;IACvC,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1F,CAAC;AAUD,yFAAyF;AACzF,MAAM,OAAO,cAAc;IACT,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;IAC1B,IAAI,GAAG,IAAI,gBAAgB,EAAE,CAAC;IAC9B,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IACpC,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC1C,gBAAgB,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;IAC3D,UAAU,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACnC,MAAM,CAAC,GAAW,EAAE,KAAqB,EAAE,KAA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AC,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
|