@tresjs/post-processing 1.0.0-next.0 → 1.0.0
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/README.md +0 -4
- package/dist/core/pmndrs/Bloom.vue.d.ts +61 -0
- package/dist/core/pmndrs/DepthOfField.vue.d.ts +35 -0
- package/dist/core/pmndrs/EffectComposer.vue.d.ts +36 -0
- package/dist/core/pmndrs/Glitch.vue.d.ts +51 -0
- package/dist/core/pmndrs/Noise.vue.d.ts +16 -0
- package/dist/core/pmndrs/Outline.vue.d.ts +46 -0
- package/dist/core/pmndrs/Pixelation.vue.d.ts +12 -0
- package/dist/core/pmndrs/Vignette.vue.d.ts +20 -0
- package/dist/core/pmndrs/composables/useEffect.d.ts +6 -0
- package/dist/core/pmndrs/index.d.ts +10 -0
- package/dist/core/three/EffectComposer.vue.d.ts +20 -0
- package/dist/core/three/Glitch.vue.d.ts +15 -0
- package/dist/core/three/Halftone.vue.d.ts +23 -0
- package/dist/core/three/Output.vue.d.ts +5 -0
- package/dist/core/three/Pixelation.vue.d.ts +10 -0
- package/dist/core/three/SMAA.vue.d.ts +9 -0
- package/dist/core/three/UnrealBloom.vue.d.ts +14 -0
- package/dist/core/three/composables/useEffect.d.ts +9 -0
- package/dist/core/three/index.d.ts +9 -0
- package/dist/pmndrs.d.ts +2 -0
- package/dist/pmndrs.js +352 -0
- package/dist/prop-BjrXLDuj.js +43 -0
- package/dist/three.d.ts +2 -0
- package/dist/three.js +1762 -0
- package/dist/util/prop.d.ts +7 -7
- package/package.json +41 -32
- package/dist/core/EffectComposer.vue.d.ts +0 -70
- package/dist/core/composables/effect.d.ts +0 -6
- package/dist/core/effects/Bloom.vue.d.ts +0 -83
- package/dist/core/effects/DepthOfField.vue.d.ts +0 -45
- package/dist/core/effects/Glitch.vue.d.ts +0 -105
- package/dist/core/effects/Noise.vue.d.ts +0 -39
- package/dist/core/effects/Outline.vue.d.ts +0 -70
- package/dist/core/effects/Pixelation.vue.d.ts +0 -21
- package/dist/core/effects/Vignette.vue.d.ts +0 -47
- package/dist/core/injectionKeys.d.ts +0 -3
- package/dist/index.d.ts +0 -10
- package/dist/tres-postprocessing.js +0 -338
- package/dist/tres-postprocessing.umd.cjs +0 -8
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* name: @tresjs/post-processing
|
|
3
|
-
* version: v1.0.0-next.0
|
|
4
|
-
* (c) 2024
|
|
5
|
-
* description: Post-processing library for TresJS
|
|
6
|
-
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
|
-
*/
|
|
8
|
-
import { inject as q, shallowRef as E, watchEffect as x, onUnmounted as L, watch as _, defineComponent as d, provide as H, computed as $, renderSlot as I } from "vue";
|
|
9
|
-
import { EffectPass as K, BloomEffect as P, DepthOfFieldEffect as R, EffectComposer as O, RenderPass as J, NormalPass as Q, DepthDownsamplingPass as Z, GlitchEffect as S, GlitchMode as ee, OutlineEffect as D, PixelationEffect as T, VignetteTechnique as te, BlendFunction as G, VignetteEffect as z, NoiseEffect as k } from "postprocessing";
|
|
10
|
-
import { useTresContext as b, useLoop as ne, normalizeColor as w } from "@tresjs/core";
|
|
11
|
-
import { HalfFloatType as A } from "three";
|
|
12
|
-
const W = Symbol("effectComposer"), p = (l) => {
|
|
13
|
-
const n = q(W), e = E(null), t = E(null), { scene: o, camera: a } = b();
|
|
14
|
-
x(() => {
|
|
15
|
-
!a.value || !(t != null && t.value) || (t.value.mainCamera = a.value);
|
|
16
|
-
});
|
|
17
|
-
let s = () => {
|
|
18
|
-
};
|
|
19
|
-
return s = x(() => {
|
|
20
|
-
!a.value || !(n != null && n.value) || !o.value || (s(), !t.value && (t.value = l(), e.value = new K(a.value, t.value), n.value.addPass(e.value)));
|
|
21
|
-
}), L(() => {
|
|
22
|
-
var r, i, f;
|
|
23
|
-
e.value && ((r = n == null ? void 0 : n.value) == null || r.removePass(e.value)), (i = t.value) == null || i.dispose(), (f = e.value) == null || f.dispose();
|
|
24
|
-
}), {
|
|
25
|
-
pass: e,
|
|
26
|
-
effect: t
|
|
27
|
-
};
|
|
28
|
-
}, j = /([^[.\]])+/g, oe = (l, n) => {
|
|
29
|
-
if (!n)
|
|
30
|
-
return;
|
|
31
|
-
const e = Array.isArray(n) ? n : n.match(j);
|
|
32
|
-
return e == null ? void 0 : e.reduce((t, o) => t && t[o], l);
|
|
33
|
-
}, M = (l, n, e) => {
|
|
34
|
-
const t = Array.isArray(n) ? n : n.match(j);
|
|
35
|
-
t && t.reduce((o, a, s) => (o[a] === void 0 && (o[a] = {}), s === t.length - 1 && (o[a] = e), o[a]), l);
|
|
36
|
-
}, B = (l, n) => {
|
|
37
|
-
const e = { ...l };
|
|
38
|
-
return n.forEach((t) => delete e[t]), e;
|
|
39
|
-
}, X = (l, n, e, t, o = {}) => _(l, (a) => {
|
|
40
|
-
var s;
|
|
41
|
-
if (n.value)
|
|
42
|
-
if (a === void 0) {
|
|
43
|
-
const r = t();
|
|
44
|
-
M(n.value, e, oe(r, e)), (s = r.dispose) == null || s.call(r);
|
|
45
|
-
} else
|
|
46
|
-
M(n.value, e, l());
|
|
47
|
-
}, o), y = (l, n, e) => l.map(([t, o]) => X(
|
|
48
|
-
t,
|
|
49
|
-
n,
|
|
50
|
-
o,
|
|
51
|
-
e
|
|
52
|
-
)), C = (l, n, e) => Object.keys(l).map((t) => X(
|
|
53
|
-
() => l[t],
|
|
54
|
-
n,
|
|
55
|
-
t,
|
|
56
|
-
e
|
|
57
|
-
)), ue = /* @__PURE__ */ d({
|
|
58
|
-
__name: "Bloom",
|
|
59
|
-
props: {
|
|
60
|
-
blendFunction: {},
|
|
61
|
-
intensity: {},
|
|
62
|
-
kernelSize: {},
|
|
63
|
-
luminanceThreshold: {},
|
|
64
|
-
luminanceSmoothing: {},
|
|
65
|
-
mipmapBlur: { type: Boolean, default: void 0 }
|
|
66
|
-
},
|
|
67
|
-
setup(l, { expose: n }) {
|
|
68
|
-
const e = l, { pass: t, effect: o } = p(() => new P(e));
|
|
69
|
-
return n({ pass: t, effect: o }), y(
|
|
70
|
-
[
|
|
71
|
-
// blendFunction is not updated, because it has no setter in BloomEffect
|
|
72
|
-
[() => e.intensity, "intensity"],
|
|
73
|
-
[() => e.kernelSize, "kernelSize"],
|
|
74
|
-
[() => e.luminanceSmoothing, "luminanceMaterial.smoothing"],
|
|
75
|
-
[() => e.luminanceThreshold, "luminanceMaterial.threshold"]
|
|
76
|
-
],
|
|
77
|
-
o,
|
|
78
|
-
() => new P()
|
|
79
|
-
), (a, s) => null;
|
|
80
|
-
}
|
|
81
|
-
}), ie = /* @__PURE__ */ d({
|
|
82
|
-
__name: "DepthOfField",
|
|
83
|
-
props: {
|
|
84
|
-
blendFunction: {},
|
|
85
|
-
worldFocusDistance: {},
|
|
86
|
-
worldFocusRange: {},
|
|
87
|
-
focusDistance: {},
|
|
88
|
-
focusRange: {},
|
|
89
|
-
bokehScale: {},
|
|
90
|
-
resolutionScale: {},
|
|
91
|
-
resolutionX: {},
|
|
92
|
-
resolutionY: {}
|
|
93
|
-
},
|
|
94
|
-
setup(l, { expose: n }) {
|
|
95
|
-
const e = l, { camera: t } = b(), { pass: o, effect: a } = p(() => new R(t.value, e));
|
|
96
|
-
return n({ pass: o, effect: a }), y(
|
|
97
|
-
[
|
|
98
|
-
// blendFunction is not updated, because it has no setter in BloomEffect
|
|
99
|
-
[() => e.worldFocusDistance, "circleOfConfusionMaterial.worldFocusDistance"],
|
|
100
|
-
[() => e.focusDistance, "circleOfConfusionMaterial.focusDistance"],
|
|
101
|
-
[() => e.worldFocusRange, "circleOfConfusionMaterial.worldFocusRange"],
|
|
102
|
-
[() => e.focusRange, "circleOfConfusionMaterial.focusRange"],
|
|
103
|
-
[() => e.bokehScale, "bokehScale"],
|
|
104
|
-
[() => e.resolutionScale, "blurPass.resolution.scale"],
|
|
105
|
-
[() => e.resolutionX, "resolution.width"],
|
|
106
|
-
[() => e.resolutionY, "resolution.height"]
|
|
107
|
-
],
|
|
108
|
-
a,
|
|
109
|
-
() => new R()
|
|
110
|
-
), (s, r) => null;
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
let v;
|
|
114
|
-
function N() {
|
|
115
|
-
var l;
|
|
116
|
-
if (v !== void 0)
|
|
117
|
-
return v;
|
|
118
|
-
try {
|
|
119
|
-
let n;
|
|
120
|
-
const e = document.createElement("canvas");
|
|
121
|
-
return v = !!(window.WebGL2RenderingContext && (n = e.getContext("webgl2"))), n && ((l = n.getExtension("WEBGL_lose_context")) == null || l.loseContext()), v;
|
|
122
|
-
} catch {
|
|
123
|
-
return v = !1;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
const ce = /* @__PURE__ */ d({
|
|
127
|
-
__name: "EffectComposer",
|
|
128
|
-
props: {
|
|
129
|
-
enabled: { type: Boolean, default: !0 },
|
|
130
|
-
children: {},
|
|
131
|
-
depthBuffer: { type: Boolean, default: void 0 },
|
|
132
|
-
disableNormalPass: { type: Boolean, default: !1 },
|
|
133
|
-
stencilBuffer: { type: Boolean, default: void 0 },
|
|
134
|
-
resolutionScale: {},
|
|
135
|
-
autoClear: { type: Boolean, default: !0 },
|
|
136
|
-
multisampling: { default: 0 },
|
|
137
|
-
frameBufferType: { default: A }
|
|
138
|
-
},
|
|
139
|
-
emits: ["render"],
|
|
140
|
-
setup(l, { expose: n, emit: e }) {
|
|
141
|
-
const t = l, o = e, { scene: a, camera: s, renderer: r, sizes: i, render: f } = b(), u = E(null);
|
|
142
|
-
let g = null, h = null;
|
|
143
|
-
H(W, u), n({ composer: u });
|
|
144
|
-
const Y = () => {
|
|
145
|
-
u.value && (h = new Q(a.value, s.value), h.enabled = !1, u.value.addPass(h), t.resolutionScale !== void 0 && N() && (g = new Z({
|
|
146
|
-
normalBuffer: h.texture,
|
|
147
|
-
resolutionScale: t.resolutionScale
|
|
148
|
-
}), g.enabled = !1, u.value.addPass(g)));
|
|
149
|
-
}, V = $(() => {
|
|
150
|
-
const c = new O(), m = {
|
|
151
|
-
depthBuffer: t.depthBuffer !== void 0 ? t.depthBuffer : c.inputBuffer.depthBuffer,
|
|
152
|
-
stencilBuffer: t.stencilBuffer !== void 0 ? t.stencilBuffer : c.inputBuffer.stencilBuffer,
|
|
153
|
-
multisampling: N() ? t.multisampling !== void 0 ? t.multisampling : c.multisampling : 0,
|
|
154
|
-
frameBufferType: t.frameBufferType !== void 0 ? t.frameBufferType : A
|
|
155
|
-
};
|
|
156
|
-
return c.dispose(), m;
|
|
157
|
-
}), F = () => {
|
|
158
|
-
!r.value && !a.value && !s.value || (u.value = new O(r.value, V.value), u.value.addPass(new J(a.value, s.value)), t.disableNormalPass || Y());
|
|
159
|
-
};
|
|
160
|
-
_([r, a, s, () => t.disableNormalPass], () => {
|
|
161
|
-
!i.width.value || !i.height.value || F();
|
|
162
|
-
}), _(() => [i.width.value, i.height.value], ([c, m]) => {
|
|
163
|
-
!c && !m || (u.value ? u.value.setSize(c, m) : F());
|
|
164
|
-
}, {
|
|
165
|
-
immediate: !0
|
|
166
|
-
});
|
|
167
|
-
const { render: U } = ne();
|
|
168
|
-
return U(() => {
|
|
169
|
-
if (t.enabled && r.value && u.value && i.width.value && i.height.value && f.frames.value > 0) {
|
|
170
|
-
const c = r.value.autoClear;
|
|
171
|
-
r.value.autoClear = t.autoClear, t.stencilBuffer && !t.autoClear && r.value.clearStencil(), u.value.render(), o("render", u.value), r.value.autoClear = c;
|
|
172
|
-
}
|
|
173
|
-
f.priority.value = 0, f.mode.value === "always" ? f.frames.value = 1 : f.frames.value = Math.max(0, f.frames.value - 1);
|
|
174
|
-
}), L(() => {
|
|
175
|
-
var c;
|
|
176
|
-
(c = u.value) == null || c.dispose();
|
|
177
|
-
}), (c, m) => I(c.$slots, "default");
|
|
178
|
-
}
|
|
179
|
-
}), fe = /* @__PURE__ */ d({
|
|
180
|
-
__name: "Glitch",
|
|
181
|
-
props: {
|
|
182
|
-
blendFunction: {},
|
|
183
|
-
delay: {},
|
|
184
|
-
duration: {},
|
|
185
|
-
strength: {},
|
|
186
|
-
mode: {},
|
|
187
|
-
active: { type: Boolean },
|
|
188
|
-
ratio: {},
|
|
189
|
-
columns: {},
|
|
190
|
-
chromaticAberrationOffset: {},
|
|
191
|
-
perturbationMap: {},
|
|
192
|
-
dtSize: {}
|
|
193
|
-
},
|
|
194
|
-
setup(l, { expose: n }) {
|
|
195
|
-
const e = l, { pass: t, effect: o } = p(() => new S(e));
|
|
196
|
-
return n({ pass: t, effect: o }), x(() => {
|
|
197
|
-
const a = () => {
|
|
198
|
-
if (e.mode !== void 0)
|
|
199
|
-
return e.active === !1 ? ee.DISABLED : e.mode;
|
|
200
|
-
const s = new S(), r = s.mode;
|
|
201
|
-
return s.dispose(), r;
|
|
202
|
-
};
|
|
203
|
-
o.value && (o.value.mode = a());
|
|
204
|
-
}), C(
|
|
205
|
-
B(e, ["active", "mode", "blendFunction"]),
|
|
206
|
-
o,
|
|
207
|
-
() => new S()
|
|
208
|
-
), (a, s) => null;
|
|
209
|
-
}
|
|
210
|
-
}), de = /* @__PURE__ */ d({
|
|
211
|
-
__name: "Outline",
|
|
212
|
-
props: {
|
|
213
|
-
outlinedObjects: {},
|
|
214
|
-
blur: { type: Boolean, default: void 0 },
|
|
215
|
-
xRay: { type: Boolean, default: void 0 },
|
|
216
|
-
kernelSize: {},
|
|
217
|
-
pulseSpeed: {},
|
|
218
|
-
resolutionX: {},
|
|
219
|
-
resolutionY: {},
|
|
220
|
-
edgeStrength: {},
|
|
221
|
-
patternScale: {},
|
|
222
|
-
multisampling: {},
|
|
223
|
-
blendFunction: {},
|
|
224
|
-
patternTexture: {},
|
|
225
|
-
resolutionScale: {},
|
|
226
|
-
hiddenEdgeColor: {},
|
|
227
|
-
visibleEdgeColor: {}
|
|
228
|
-
},
|
|
229
|
-
setup(l, { expose: n }) {
|
|
230
|
-
const e = l, t = (u) => u !== void 0 ? w(u).getHex() : void 0, { camera: o, scene: a } = b(), s = {
|
|
231
|
-
blur: e.blur,
|
|
232
|
-
xRay: e.xRay,
|
|
233
|
-
kernelSize: e.kernelSize,
|
|
234
|
-
pulseSpeed: e.pulseSpeed,
|
|
235
|
-
resolutionX: e.resolutionX,
|
|
236
|
-
resolutionY: e.resolutionY,
|
|
237
|
-
patternScale: e.patternScale,
|
|
238
|
-
edgeStrength: e.edgeStrength,
|
|
239
|
-
blendFunction: e.blendFunction,
|
|
240
|
-
multisampling: e.multisampling,
|
|
241
|
-
patternTexture: e.patternTexture,
|
|
242
|
-
resolutionScale: e.resolutionScale,
|
|
243
|
-
hiddenEdgeColor: t(e.hiddenEdgeColor),
|
|
244
|
-
visibleEdgeColor: t(e.visibleEdgeColor)
|
|
245
|
-
}, { pass: r, effect: i } = p(() => new D(a.value, o.value, s));
|
|
246
|
-
n({ pass: r, effect: i }), _(
|
|
247
|
-
[() => e.outlinedObjects, i],
|
|
248
|
-
// watchEffect is intentionally not used here as it would result in an endless loop
|
|
249
|
-
() => {
|
|
250
|
-
var u;
|
|
251
|
-
(u = i.value) == null || u.selection.set(e.outlinedObjects || []);
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
immediate: !0
|
|
255
|
-
}
|
|
256
|
-
);
|
|
257
|
-
const f = $(() => ({
|
|
258
|
-
hiddenEdgeColor: e.hiddenEdgeColor ? w(e.hiddenEdgeColor) : void 0,
|
|
259
|
-
visibleEdgeColor: e.visibleEdgeColor ? w(e.visibleEdgeColor) : void 0
|
|
260
|
-
}));
|
|
261
|
-
return y(
|
|
262
|
-
[
|
|
263
|
-
/* some properties are not updated because of different reasons:
|
|
264
|
-
resolutionX - has no setter in OutlineEffect
|
|
265
|
-
resolutionY - has no setter in OutlineEffect
|
|
266
|
-
blendFunction - has no setter in OutlineEffect
|
|
267
|
-
patternTexture - different type in constructor and in setter
|
|
268
|
-
resolutionScale - has no setter in OutlineEffect
|
|
269
|
-
*/
|
|
270
|
-
[() => e.blur, "blur"],
|
|
271
|
-
[() => e.xRay, "xRay"],
|
|
272
|
-
[() => e.pulseSpeed, "pulseSpeed"],
|
|
273
|
-
[() => e.kernelSize, "kernelSize"],
|
|
274
|
-
[() => e.edgeStrength, "edgeStrength"],
|
|
275
|
-
[() => e.patternScale, "patternScale"],
|
|
276
|
-
[() => e.multisampling, "multisampling"],
|
|
277
|
-
[() => f.value.hiddenEdgeColor, "hiddenEdgeColor"],
|
|
278
|
-
[() => f.value.visibleEdgeColor, "visibleEdgeColor"]
|
|
279
|
-
],
|
|
280
|
-
i,
|
|
281
|
-
() => new D()
|
|
282
|
-
), (u, g) => null;
|
|
283
|
-
}
|
|
284
|
-
}), pe = /* @__PURE__ */ d({
|
|
285
|
-
__name: "Pixelation",
|
|
286
|
-
props: {
|
|
287
|
-
granularity: {}
|
|
288
|
-
},
|
|
289
|
-
setup(l, { expose: n }) {
|
|
290
|
-
const e = l, { pass: t, effect: o } = p(() => new T(e.granularity));
|
|
291
|
-
return n({ pass: t, effect: o }), C(
|
|
292
|
-
e,
|
|
293
|
-
o,
|
|
294
|
-
() => new T()
|
|
295
|
-
), (a, s) => null;
|
|
296
|
-
}
|
|
297
|
-
}), me = /* @__PURE__ */ d({
|
|
298
|
-
__name: "Vignette",
|
|
299
|
-
props: {
|
|
300
|
-
technique: { default: te.DEFAULT },
|
|
301
|
-
blendFunction: { default: G.NORMAL },
|
|
302
|
-
offset: { default: 0.5 },
|
|
303
|
-
darkness: { default: 0.5 }
|
|
304
|
-
},
|
|
305
|
-
setup(l, { expose: n }) {
|
|
306
|
-
const e = l, { pass: t, effect: o } = p(() => new z(e));
|
|
307
|
-
return n({ pass: t, effect: o }), C(
|
|
308
|
-
B(e, ["blendFunction"]),
|
|
309
|
-
o,
|
|
310
|
-
() => new z()
|
|
311
|
-
), (a, s) => null;
|
|
312
|
-
}
|
|
313
|
-
}), ve = /* @__PURE__ */ d({
|
|
314
|
-
__name: "Noise",
|
|
315
|
-
props: {
|
|
316
|
-
premultiply: { type: Boolean, default: !1 },
|
|
317
|
-
blendFunction: { default: G.SCREEN }
|
|
318
|
-
},
|
|
319
|
-
setup(l, { expose: n }) {
|
|
320
|
-
const e = l, { pass: t, effect: o } = p(() => new k(e));
|
|
321
|
-
return n({ pass: t, effect: o }), C(
|
|
322
|
-
B(e, ["blendFunction"]),
|
|
323
|
-
o,
|
|
324
|
-
() => new k()
|
|
325
|
-
), (a, s) => null;
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
export {
|
|
329
|
-
ue as Bloom,
|
|
330
|
-
ie as DepthOfField,
|
|
331
|
-
ce as EffectComposer,
|
|
332
|
-
fe as Glitch,
|
|
333
|
-
ve as Noise,
|
|
334
|
-
de as Outline,
|
|
335
|
-
pe as Pixelation,
|
|
336
|
-
me as Vignette,
|
|
337
|
-
p as useEffect
|
|
338
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* name: @tresjs/post-processing
|
|
3
|
-
* version: v1.0.0-next.0
|
|
4
|
-
* (c) 2024
|
|
5
|
-
* description: Post-processing library for TresJS
|
|
6
|
-
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
|
-
*/
|
|
8
|
-
(function(f,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue"),require("postprocessing"),require("@tresjs/core"),require("three")):typeof define=="function"&&define.amd?define(["exports","vue","postprocessing","@tresjs/core","three"],a):(f=typeof globalThis<"u"?globalThis:f||self,a(f["tres-postprocessing"]={},f.Vue,f.Postprocessing,f.TresjsCore,f.Three))})(this,function(f,a,r,h,B){"use strict";const y=Symbol("effectComposer"),v=o=>{const n=a.inject(y),e=a.shallowRef(null),t=a.shallowRef(null),{scene:l,camera:i}=h.useTresContext();a.watchEffect(()=>{!i.value||!(t!=null&&t.value)||(t.value.mainCamera=i.value)});let u=()=>{};return u=a.watchEffect(()=>{!i.value||!(n!=null&&n.value)||!l.value||(u(),!t.value&&(t.value=o(),e.value=new r.EffectPass(i.value,t.value),n.value.addPass(e.value)))}),a.onUnmounted(()=>{var s,d,p;e.value&&((s=n==null?void 0:n.value)==null||s.removePass(e.value)),(d=t.value)==null||d.dispose(),(p=e.value)==null||p.dispose()}),{pass:e,effect:t}},x=/([^[.\]])+/g,R=(o,n)=>{if(!n)return;const e=Array.isArray(n)?n:n.match(x);return e==null?void 0:e.reduce((t,l)=>t&&t[l],o)},F=(o,n,e)=>{const t=Array.isArray(n)?n:n.match(x);t&&t.reduce((l,i,u)=>(l[i]===void 0&&(l[i]={}),u===t.length-1&&(l[i]=e),l[i]),o)},S=(o,n)=>{const e={...o};return n.forEach(t=>delete e[t]),e},P=(o,n,e,t,l={})=>a.watch(o,i=>{var u;if(n.value)if(i===void 0){const s=t();F(n.value,e,R(s,e)),(u=s.dispose)==null||u.call(s)}else F(n.value,e,o())},l),g=(o,n,e)=>o.map(([t,l])=>P(t,n,l,e)),_=(o,n,e)=>Object.keys(o).map(t=>P(()=>o[t],n,t,e)),z=a.defineComponent({__name:"Bloom",props:{blendFunction:{},intensity:{},kernelSize:{},luminanceThreshold:{},luminanceSmoothing:{},mipmapBlur:{type:Boolean,default:void 0}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=v(()=>new r.BloomEffect(e));return n({pass:t,effect:l}),g([[()=>e.intensity,"intensity"],[()=>e.kernelSize,"kernelSize"],[()=>e.luminanceSmoothing,"luminanceMaterial.smoothing"],[()=>e.luminanceThreshold,"luminanceMaterial.threshold"]],l,()=>new r.BloomEffect),(i,u)=>null}}),D=a.defineComponent({__name:"DepthOfField",props:{blendFunction:{},worldFocusDistance:{},worldFocusRange:{},focusDistance:{},focusRange:{},bokehScale:{},resolutionScale:{},resolutionX:{},resolutionY:{}},setup(o,{expose:n}){const e=o,{camera:t}=h.useTresContext(),{pass:l,effect:i}=v(()=>new r.DepthOfFieldEffect(t.value,e));return n({pass:l,effect:i}),g([[()=>e.worldFocusDistance,"circleOfConfusionMaterial.worldFocusDistance"],[()=>e.focusDistance,"circleOfConfusionMaterial.focusDistance"],[()=>e.worldFocusRange,"circleOfConfusionMaterial.worldFocusRange"],[()=>e.focusRange,"circleOfConfusionMaterial.focusRange"],[()=>e.bokehScale,"bokehScale"],[()=>e.resolutionScale,"blurPass.resolution.scale"],[()=>e.resolutionX,"resolution.width"],[()=>e.resolutionY,"resolution.height"]],i,()=>new r.DepthOfFieldEffect),(u,s)=>null}});let C;function T(){var o;if(C!==void 0)return C;try{let n;const e=document.createElement("canvas");return C=!!(window.WebGL2RenderingContext&&(n=e.getContext("webgl2"))),n&&((o=n.getExtension("WEBGL_lose_context"))==null||o.loseContext()),C}catch{return C=!1}}const M=a.defineComponent({__name:"EffectComposer",props:{enabled:{type:Boolean,default:!0},children:{},depthBuffer:{type:Boolean,default:void 0},disableNormalPass:{type:Boolean,default:!1},stencilBuffer:{type:Boolean,default:void 0},resolutionScale:{},autoClear:{type:Boolean,default:!0},multisampling:{default:0},frameBufferType:{default:B.HalfFloatType}},emits:["render"],setup(o,{expose:n,emit:e}){const t=o,l=e,{scene:i,camera:u,renderer:s,sizes:d,render:p}=h.useTresContext(),c=a.shallowRef(null);let w=null,b=null;a.provide(y,c),n({composer:c});const L=()=>{c.value&&(b=new r.NormalPass(i.value,u.value),b.enabled=!1,c.value.addPass(b),t.resolutionScale!==void 0&&T()&&(w=new r.DepthDownsamplingPass({normalBuffer:b.texture,resolutionScale:t.resolutionScale}),w.enabled=!1,c.value.addPass(w)))},$=a.computed(()=>{const m=new r.EffectComposer,E={depthBuffer:t.depthBuffer!==void 0?t.depthBuffer:m.inputBuffer.depthBuffer,stencilBuffer:t.stencilBuffer!==void 0?t.stencilBuffer:m.inputBuffer.stencilBuffer,multisampling:T()?t.multisampling!==void 0?t.multisampling:m.multisampling:0,frameBufferType:t.frameBufferType!==void 0?t.frameBufferType:B.HalfFloatType};return m.dispose(),E}),O=()=>{!s.value&&!i.value&&!u.value||(c.value=new r.EffectComposer(s.value,$.value),c.value.addPass(new r.RenderPass(i.value,u.value)),t.disableNormalPass||L())};a.watch([s,i,u,()=>t.disableNormalPass],()=>{!d.width.value||!d.height.value||O()}),a.watch(()=>[d.width.value,d.height.value],([m,E])=>{!m&&!E||(c.value?c.value.setSize(m,E):O())},{immediate:!0});const{render:q}=h.useLoop();return q(()=>{if(t.enabled&&s.value&&c.value&&d.width.value&&d.height.value&&p.frames.value>0){const m=s.value.autoClear;s.value.autoClear=t.autoClear,t.stencilBuffer&&!t.autoClear&&s.value.clearStencil(),c.value.render(),l("render",c.value),s.value.autoClear=m}p.priority.value=0,p.mode.value==="always"?p.frames.value=1:p.frames.value=Math.max(0,p.frames.value-1)}),a.onUnmounted(()=>{var m;(m=c.value)==null||m.dispose()}),(m,E)=>a.renderSlot(m.$slots,"default")}}),k=a.defineComponent({__name:"Glitch",props:{blendFunction:{},delay:{},duration:{},strength:{},mode:{},active:{type:Boolean},ratio:{},columns:{},chromaticAberrationOffset:{},perturbationMap:{},dtSize:{}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=v(()=>new r.GlitchEffect(e));return n({pass:t,effect:l}),a.watchEffect(()=>{const i=()=>{if(e.mode!==void 0)return e.active===!1?r.GlitchMode.DISABLED:e.mode;const u=new r.GlitchEffect,s=u.mode;return u.dispose(),s};l.value&&(l.value.mode=i())}),_(S(e,["active","mode","blendFunction"]),l,()=>new r.GlitchEffect),(i,u)=>null}}),A=a.defineComponent({__name:"Outline",props:{outlinedObjects:{},blur:{type:Boolean,default:void 0},xRay:{type:Boolean,default:void 0},kernelSize:{},pulseSpeed:{},resolutionX:{},resolutionY:{},edgeStrength:{},patternScale:{},multisampling:{},blendFunction:{},patternTexture:{},resolutionScale:{},hiddenEdgeColor:{},visibleEdgeColor:{}},setup(o,{expose:n}){const e=o,t=c=>c!==void 0?h.normalizeColor(c).getHex():void 0,{camera:l,scene:i}=h.useTresContext(),u={blur:e.blur,xRay:e.xRay,kernelSize:e.kernelSize,pulseSpeed:e.pulseSpeed,resolutionX:e.resolutionX,resolutionY:e.resolutionY,patternScale:e.patternScale,edgeStrength:e.edgeStrength,blendFunction:e.blendFunction,multisampling:e.multisampling,patternTexture:e.patternTexture,resolutionScale:e.resolutionScale,hiddenEdgeColor:t(e.hiddenEdgeColor),visibleEdgeColor:t(e.visibleEdgeColor)},{pass:s,effect:d}=v(()=>new r.OutlineEffect(i.value,l.value,u));n({pass:s,effect:d}),a.watch([()=>e.outlinedObjects,d],()=>{var c;(c=d.value)==null||c.selection.set(e.outlinedObjects||[])},{immediate:!0});const p=a.computed(()=>({hiddenEdgeColor:e.hiddenEdgeColor?h.normalizeColor(e.hiddenEdgeColor):void 0,visibleEdgeColor:e.visibleEdgeColor?h.normalizeColor(e.visibleEdgeColor):void 0}));return g([[()=>e.blur,"blur"],[()=>e.xRay,"xRay"],[()=>e.pulseSpeed,"pulseSpeed"],[()=>e.kernelSize,"kernelSize"],[()=>e.edgeStrength,"edgeStrength"],[()=>e.patternScale,"patternScale"],[()=>e.multisampling,"multisampling"],[()=>p.value.hiddenEdgeColor,"hiddenEdgeColor"],[()=>p.value.visibleEdgeColor,"visibleEdgeColor"]],d,()=>new r.OutlineEffect),(c,w)=>null}}),N=a.defineComponent({__name:"Pixelation",props:{granularity:{}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=v(()=>new r.PixelationEffect(e.granularity));return n({pass:t,effect:l}),_(e,l,()=>new r.PixelationEffect),(i,u)=>null}}),j=a.defineComponent({__name:"Vignette",props:{technique:{default:r.VignetteTechnique.DEFAULT},blendFunction:{default:r.BlendFunction.NORMAL},offset:{default:.5},darkness:{default:.5}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=v(()=>new r.VignetteEffect(e));return n({pass:t,effect:l}),_(S(e,["blendFunction"]),l,()=>new r.VignetteEffect),(i,u)=>null}}),G=a.defineComponent({__name:"Noise",props:{premultiply:{type:Boolean,default:!1},blendFunction:{default:r.BlendFunction.SCREEN}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=v(()=>new r.NoiseEffect(e));return n({pass:t,effect:l}),_(S(e,["blendFunction"]),l,()=>new r.NoiseEffect),(i,u)=>null}});f.Bloom=z,f.DepthOfField=D,f.EffectComposer=M,f.Glitch=k,f.Noise=G,f.Outline=A,f.Pixelation=N,f.Vignette=j,f.useEffect=v,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|