@tresjs/post-processing 0.3.0 → 0.5.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.
@@ -1,307 +1,124 @@
1
1
  /**
2
2
  * name: @tresjs/post-processing
3
- * version: v0.3.0
3
+ * version: v0.5.0
4
4
  * (c) 2023
5
5
  * description: Post-processing library for TresJS
6
6
  * author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
7
7
  */
8
- import { inject as C, getCurrentInstance as k, onMounted as I, nextTick as q, getCurrentScope as J, onScopeDispose as Q, unref as D, ref as b, watch as p, computed as y, defineComponent as O, shallowRef as T, provide as Z, watchEffect as P, renderSlot as _, toRaw as S, onUnmounted as F } from "vue";
9
- import { HalfFloatType as ee } from "three";
10
- import { useTres as te, useRenderLoop as ne, normalizeColor as R } from "@tresjs/core";
11
- import { EffectComposer as ae, RenderPass as le, NormalPass as ue, DepthDownsamplingPass as oe, BlendFunction as W, BloomEffect as ie, EffectPass as L, GlitchMode as j, GlitchEffect as re, OutlineEffect as G } from "postprocessing";
12
- function A() {
13
- const { state: e, setState: a } = C("useTres", te()), n = C("extend") || (() => {
8
+ import { inject as $, shallowRef as w, watchEffect as m, onUnmounted as T, watch as _, defineComponent as f, computed as k, provide as j, renderSlot as N } from "vue";
9
+ import { EffectPass as X, BloomEffect as x, GlitchEffect as b, GlitchMode as Y, OutlineEffect as y, PixelationEffect as P, DepthOfFieldEffect as F, EffectComposer as R, RenderPass as H, NormalPass as I, DepthDownsamplingPass as U } from "postprocessing";
10
+ import { useTresContext as S, normalizeColor as C, useRenderLoop as K } from "@tresjs/core";
11
+ import { HalfFloatType as O } from "three";
12
+ const A = Symbol(), v = (a) => {
13
+ const t = $(A), e = w(null), n = w(null), { scene: o, camera: l } = S();
14
+ m(() => {
15
+ !l.value || !(n != null && n.value) || (n.value.mainCamera = l.value);
14
16
  });
15
- return {
16
- state: e,
17
- setState: a,
18
- extend: n
17
+ let s = () => {
19
18
  };
20
- }
21
- let w;
22
- function se() {
23
- var e;
24
- if (w !== void 0)
25
- return w;
26
- try {
27
- let a;
28
- const n = document.createElement("canvas");
29
- return w = !!(window.WebGL2RenderingContext && (a = n.getContext("webgl2"))), a && ((e = a.getExtension("WEBGL_lose_context")) == null || e.loseContext()), w;
30
- } catch {
31
- return w = !1;
32
- }
33
- }
34
- function N(e) {
35
- return J() ? (Q(e), !0) : !1;
36
- }
37
- function H(e) {
38
- return typeof e == "function" ? e() : D(e);
39
- }
40
- const ce = typeof window < "u", de = () => {
41
- };
42
- function fe(e, a = !0) {
43
- k() ? I(e) : a ? e() : q(e);
44
- }
45
- function E(e) {
46
- var a;
47
- const n = H(e);
48
- return (a = n == null ? void 0 : n.$el) != null ? a : n;
49
- }
50
- const X = ce ? window : void 0;
51
- function M(...e) {
52
- let a, n, t, l;
53
- if (typeof e[0] == "string" || Array.isArray(e[0]) ? ([n, t, l] = e, a = X) : [a, n, t, l] = e, !a)
54
- return de;
55
- Array.isArray(n) || (n = [n]), Array.isArray(t) || (t = [t]);
56
- const r = [], c = () => {
57
- r.forEach((i) => i()), r.length = 0;
58
- }, f = (i, o, s, d) => (i.addEventListener(o, s, d), () => i.removeEventListener(o, s, d)), v = p(
59
- () => [E(a), H(l)],
60
- ([i, o]) => {
61
- c(), i && r.push(
62
- ...n.flatMap((s) => t.map((d) => f(i, s, d, o)))
63
- );
64
- },
65
- { immediate: !0, flush: "post" }
66
- ), u = () => {
67
- v(), c();
68
- };
69
- return N(u), u;
70
- }
71
- function ve() {
72
- const e = b(!1);
73
- return k() && I(() => {
74
- e.value = !0;
75
- }), e;
76
- }
77
- function me(e) {
78
- const a = ve();
79
- return y(() => (a.value, !!e()));
80
- }
81
- var $ = Object.getOwnPropertySymbols, he = Object.prototype.hasOwnProperty, be = Object.prototype.propertyIsEnumerable, ge = (e, a) => {
82
- var n = {};
83
- for (var t in e)
84
- he.call(e, t) && a.indexOf(t) < 0 && (n[t] = e[t]);
85
- if (e != null && $)
86
- for (var t of $(e))
87
- a.indexOf(t) < 0 && be.call(e, t) && (n[t] = e[t]);
88
- return n;
89
- };
90
- function Se(e, a, n = {}) {
91
- const t = n, { window: l = X } = t, r = ge(t, ["window"]);
92
- let c;
93
- const f = me(() => l && "ResizeObserver" in l), v = () => {
94
- c && (c.disconnect(), c = void 0);
95
- }, u = y(
96
- () => Array.isArray(e) ? e.map((s) => E(s)) : [E(e)]
97
- ), i = p(
98
- u,
99
- (s) => {
100
- if (v(), f.value && l) {
101
- c = new ResizeObserver(a);
102
- for (const d of s)
103
- d && c.observe(d, r);
104
- }
105
- },
106
- { immediate: !0, flush: "post", deep: !0 }
107
- ), o = () => {
108
- v(), i();
109
- };
110
- return N(o), {
111
- isSupported: f,
112
- stop: o
113
- };
114
- }
115
- function pe(e, a = {}) {
116
- const {
117
- reset: n = !0,
118
- windowResize: t = !0,
119
- windowScroll: l = !0,
120
- immediate: r = !0
121
- } = a, c = b(0), f = b(0), v = b(0), u = b(0), i = b(0), o = b(0), s = b(0), d = b(0);
122
- function m() {
123
- const g = E(e);
124
- if (!g) {
125
- n && (c.value = 0, f.value = 0, v.value = 0, u.value = 0, i.value = 0, o.value = 0, s.value = 0, d.value = 0);
126
- return;
127
- }
128
- const h = g.getBoundingClientRect();
129
- c.value = h.height, f.value = h.bottom, v.value = h.left, u.value = h.right, i.value = h.top, o.value = h.width, s.value = h.x, d.value = h.y;
130
- }
131
- return Se(e, m), p(() => E(e), (g) => !g && m()), l && M("scroll", m, { capture: !0, passive: !0 }), t && M("resize", m, { passive: !0 }), fe(() => {
132
- r && m();
19
+ return s = m(() => {
20
+ !l.value || !(t != null && t.value) || !o.value || (s(), !n.value && (n.value = a(), e.value = new X(l.value, n.value), t.value.addPass(e.value)));
21
+ }), T(() => {
22
+ var r, i, d;
23
+ e.value && ((r = t == null ? void 0 : t.value) == null || r.removePass(e.value)), (i = n.value) == null || i.dispose(), (d = e.value) == null || d.dispose();
133
24
  }), {
134
- height: c,
135
- bottom: f,
136
- left: v,
137
- right: u,
138
- top: i,
139
- width: o,
140
- x: s,
141
- y: d,
142
- update: m
25
+ pass: e,
26
+ effect: n
143
27
  };
144
- }
145
- const z = Symbol(), Ee = /* @__PURE__ */ O({
146
- __name: "EffectComposer",
147
- props: {
148
- enabled: { type: Boolean, default: !0 },
149
- children: {},
150
- depthBuffer: { type: Boolean },
151
- disableNormalPass: { type: Boolean, default: !1 },
152
- stencilBuffer: { type: Boolean },
153
- resolutionScale: {},
154
- autoClear: { type: Boolean, default: !0 },
155
- multisampling: { default: 8 },
156
- frameBufferType: { default: () => ee },
157
- scene: {},
158
- camera: {}
28
+ }, M = /([^[.\]])+/g, q = (a, t) => {
29
+ if (!t)
30
+ return;
31
+ const e = Array.isArray(t) ? t : t.match(M);
32
+ return e == null ? void 0 : e.reduce((n, o) => n && n[o], a);
33
+ }, z = (a, t, e) => {
34
+ const n = Array.isArray(t) ? t : t.match(M);
35
+ n && n.reduce((o, l, s) => (o[l] === void 0 && (o[l] = {}), s === n.length - 1 && (o[l] = e), o[l]), a);
36
+ }, J = (a, t) => {
37
+ const e = { ...a };
38
+ return t.forEach((n) => delete e[n]), e;
39
+ }, G = (a, t, e, n, o = {}) => _(
40
+ a,
41
+ (l) => {
42
+ var s;
43
+ if (t.value)
44
+ if (l === void 0) {
45
+ const r = n();
46
+ z(t.value, e, q(r, e)), (s = r.dispose) == null || s.call(r);
47
+ } else
48
+ z(t.value, e, a());
159
49
  },
160
- setup(e) {
161
- const { state: a } = A(), n = T(null), t = y(() => e.scene || a.scene), l = y(() => e.camera || a.camera);
162
- let r = null, c = null;
163
- const f = se();
164
- Z(z, n);
165
- function v() {
166
- n.value && (c = new ue(t.value, l.value), c.enabled = !1, n.value.addPass(c), e.resolutionScale !== void 0 && f && (r = new oe({
167
- normalBuffer: c.texture,
168
- resolutionScale: e.resolutionScale
169
- }), r.enabled = !1, n.value.addPass(r)));
170
- }
171
- const u = y(() => {
172
- var d;
173
- return (d = a.canvas) == null ? void 0 : d.value;
174
- }), { width: i, height: o } = pe(u);
175
- P(() => {
176
- n.value && i.value && o.value && n.value.setSize(i.value, o.value);
177
- }), P(() => {
178
- a.renderer && t.value && l.value && (n.value = new ae(a.renderer, {
179
- depthBuffer: e.depthBuffer,
180
- stencilBuffer: e.stencilBuffer,
181
- multisampling: e.multisampling > 0 && f ? e.multisampling : 0,
182
- frameBufferType: e.frameBufferType
183
- }), n.value.addPass(new le(t.value, l.value)), e.disableNormalPass || v());
184
- });
185
- const { onLoop: s } = ne();
186
- return s(({ delta: d }) => {
187
- if (e.enabled && a.renderer && n.value && i.value && o.value) {
188
- const m = a.renderer.autoClear;
189
- a.renderer.autoClear = e.autoClear, e.stencilBuffer && !e.autoClear && a.renderer.clearStencil(), n.value.render(d), a.renderer.autoClear = m;
190
- }
191
- }), (d, m) => _(d.$slots, "default");
192
- }
193
- }), Be = /* @__PURE__ */ O({
50
+ o
51
+ ), E = (a, t, e) => a.map(([n, o]) => G(
52
+ n,
53
+ t,
54
+ o,
55
+ e
56
+ )), L = (a, t, e) => Object.keys(a).map((n) => G(
57
+ () => a[n],
58
+ t,
59
+ n,
60
+ e
61
+ )), te = /* @__PURE__ */ f({
194
62
  __name: "Bloom",
195
63
  props: {
196
- blendFunction: { default: () => W.ADD },
197
- intensity: { default: 1 },
198
- blurPass: {},
199
- width: {},
200
- height: {},
64
+ blendFunction: {},
65
+ intensity: {},
201
66
  kernelSize: {},
202
- luminanceThreshold: { default: 0.9 },
203
- luminanceSmoothing: { default: 0.025 },
204
- mipmapBlur: { type: Boolean, default: !1 }
67
+ luminanceThreshold: {},
68
+ luminanceSmoothing: {},
69
+ mipmapBlur: { type: Boolean, default: void 0 }
205
70
  },
206
- setup(e, { expose: a }) {
207
- const { state: n } = A(), t = C(z), l = b(null), r = b(null);
208
- a({ pass: l, effect: r });
209
- function c() {
210
- r.value = new ie({
211
- blendFunction: e.blendFunction,
212
- mipmapBlur: e.mipmapBlur,
213
- intensity: e.intensity,
214
- luminanceThreshold: e.luminanceThreshold,
215
- luminanceSmoothing: e.luminanceSmoothing
216
- }), l.value = new L(D(n.camera), S(r.value));
217
- }
218
- function f() {
219
- var i, o, s;
220
- (i = r.value) == null || i.dispose(), (o = l.value) == null || o.dispose(), (s = t == null ? void 0 : t.value) == null || s.removePass(S(l.value));
221
- }
222
- const v = p(
223
- () => [n.camera, t == null ? void 0 : t.value],
224
- () => {
225
- var i;
226
- n.camera && t && t.value && (c(), (i = t == null ? void 0 : t.value) == null || i.addPass(S(l.value)));
227
- }
228
- ), u = p(
229
- () => [e.blendFunction, e.mipmapBlur, e.intensity, e.luminanceThreshold, e.luminanceSmoothing],
230
- () => {
231
- var i;
232
- l.value && (f(), c(), (i = t == null ? void 0 : t.value) == null || i.addPass(S(l.value)));
233
- }
234
- );
235
- return F(() => {
236
- f(), v(), u();
237
- }), (i, o) => null;
71
+ setup(a, { expose: t }) {
72
+ const e = a, { pass: n, effect: o } = v(() => new x(e));
73
+ return t({ pass: n, effect: o }), E(
74
+ [
75
+ // blendFunction is not updated, because it has no setter in BloomEffect
76
+ [() => e.intensity, "intensity"],
77
+ [() => e.kernelSize, "kernelSize"],
78
+ [() => e.luminanceSmoothing, "luminanceMaterial.smoothing"],
79
+ [() => e.luminanceThreshold, "luminanceMaterial.threshold"]
80
+ ],
81
+ o,
82
+ () => new x()
83
+ ), (l, s) => null;
238
84
  }
239
- }), xe = /* @__PURE__ */ O({
85
+ }), ne = /* @__PURE__ */ f({
240
86
  __name: "Glitch",
241
87
  props: {
242
- blendFunction: { default: () => W.ADD },
88
+ blendFunction: {},
243
89
  delay: {},
244
90
  duration: {},
245
91
  strength: {},
246
92
  mode: {},
247
93
  active: { type: Boolean },
248
- ratio: { default: 0.85 },
249
- columns: { default: 0.05 },
94
+ ratio: {},
95
+ columns: {},
250
96
  chromaticAberrationOffset: {},
251
- peturbationMap: {},
252
- dtSize: { default: 64 }
97
+ perturbationMap: {},
98
+ dtSize: {}
253
99
  },
254
- setup(e, { expose: a }) {
255
- const { state: n } = A(), t = C(z), l = b(null), r = b(null);
256
- a({ pass: l });
257
- function c() {
258
- r.value = new re({
259
- blendFunction: e.blendFunction,
260
- delay: e.delay,
261
- duration: e.duration,
262
- strength: e.strength,
263
- ratio: e.ratio,
264
- columns: e.columns,
265
- chromaticAberrationOffset: e.chromaticAberrationOffset,
266
- dtSize: e.dtSize
267
- }), l.value = new L(D(n.camera), S(r.value));
268
- }
269
- function f() {
270
- var o, s, d;
271
- (o = r.value) == null || o.dispose(), (s = l.value) == null || s.dispose(), (d = t == null ? void 0 : t.value) == null || d.removePass(S(l.value));
272
- }
273
- const v = p(
274
- () => [n.camera, t == null ? void 0 : t.value],
275
- () => {
276
- var o;
277
- n.camera && t && t.value && (c(), (o = t == null ? void 0 : t.value) == null || o.addPass(S(l.value)));
278
- }
279
- ), u = p(
280
- () => [e.delay, e.duration, e.strength, e.ratio, e.columns, e.chromaticAberrationOffset, e.peturbationMap, e.dtSize],
281
- () => {
282
- var o, s;
283
- l.value && ((o = t == null ? void 0 : t.value) == null || o.removePass(S(l.value)), c(), (s = t == null ? void 0 : t.value) == null || s.addPass(S(l.value)));
284
- }
285
- );
286
- P(() => {
287
- l.value && (l.value.mode = e.active ? e.mode || j.SPORADIC : j.DISABLED);
288
- });
289
- const i = p(
290
- () => e.active,
291
- (o) => {
292
- l.value && (l.value.enabled = o);
293
- }
294
- );
295
- return F(() => {
296
- f(), v(), u(), i();
297
- }), (o, s) => null;
100
+ setup(a, { expose: t }) {
101
+ const e = a, { pass: n, effect: o } = v(() => new b(e));
102
+ return t({ pass: n, effect: o }), m(() => {
103
+ const l = () => {
104
+ if (e.mode !== void 0)
105
+ return e.active === !1 ? Y.DISABLED : e.mode;
106
+ const s = new b(), r = s.mode;
107
+ return s.dispose(), r;
108
+ };
109
+ o.value && (o.value.mode = l());
110
+ }), L(
111
+ J(e, ["active", "mode", "blendFunction"]),
112
+ o,
113
+ () => new b()
114
+ ), (l, s) => null;
298
115
  }
299
- }), Oe = /* @__PURE__ */ O({
116
+ }), oe = /* @__PURE__ */ f({
300
117
  __name: "Outline",
301
118
  props: {
302
119
  outlinedObjects: {},
303
- blur: { type: Boolean },
304
- xRay: { type: Boolean },
120
+ blur: { type: Boolean, default: void 0 },
121
+ xRay: { type: Boolean, default: void 0 },
305
122
  kernelSize: {},
306
123
  pulseSpeed: {},
307
124
  resolutionX: {},
@@ -315,78 +132,180 @@ const z = Symbol(), Ee = /* @__PURE__ */ O({
315
132
  hiddenEdgeColor: {},
316
133
  visibleEdgeColor: {}
317
134
  },
318
- setup(e) {
319
- const a = e, { state: n } = A(), t = C(z), l = T(null), r = T(null), c = (u) => u !== void 0 ? R(u).getHex() : void 0, f = y(() => {
320
- const {
321
- blur: u,
322
- xRay: i,
323
- kernelSize: o,
324
- pulseSpeed: s,
325
- resolutionX: d,
326
- resolutionY: m,
327
- patternScale: g,
328
- edgeStrength: h,
329
- multisampling: B,
330
- blendFunction: x,
331
- patternTexture: Y,
332
- resolutionScale: K,
333
- hiddenEdgeColor: U,
334
- visibleEdgeColor: V
335
- } = a;
336
- return {
337
- blur: u,
338
- xRay: i,
339
- kernelSize: o,
340
- pulseSpeed: s,
341
- resolutionX: d,
342
- resolutionY: m,
343
- patternScale: g,
344
- edgeStrength: h,
345
- blendFunction: x,
346
- multisampling: B,
347
- patternTexture: Y,
348
- resolutionScale: K,
349
- hiddenEdgeColor: c(U),
350
- visibleEdgeColor: c(V)
351
- };
352
- }), v = P(() => {
353
- var u;
354
- n.camera && t && t.value && n.scene && (r.value = new G(n.scene, n.camera, f.value), l.value = new L(n.camera, r.value), (u = t.value) == null || u.addPass(l.value), v());
355
- });
356
- return p(
357
- [() => a.outlinedObjects, r],
358
- // whatchEffect is intentionally not used here as it would result in an endless loop
135
+ setup(a, { expose: t }) {
136
+ const e = a, n = (c) => c !== void 0 ? C(c).getHex() : void 0, { camera: o, scene: l } = S(), s = {
137
+ blur: e.blur,
138
+ xRay: e.xRay,
139
+ kernelSize: e.kernelSize,
140
+ pulseSpeed: e.pulseSpeed,
141
+ resolutionX: e.resolutionX,
142
+ resolutionY: e.resolutionY,
143
+ patternScale: e.patternScale,
144
+ edgeStrength: e.edgeStrength,
145
+ blendFunction: e.blendFunction,
146
+ multisampling: e.multisampling,
147
+ patternTexture: e.patternTexture,
148
+ resolutionScale: e.resolutionScale,
149
+ hiddenEdgeColor: n(e.hiddenEdgeColor),
150
+ visibleEdgeColor: n(e.visibleEdgeColor)
151
+ }, { pass: r, effect: i } = v(() => new y(l.value, o.value, s));
152
+ t({ pass: r, effect: i }), _(
153
+ [() => e.outlinedObjects, i],
154
+ // watchEffect is intentionally not used here as it would result in an endless loop
359
155
  () => {
360
- var u;
361
- (u = r.value) == null || u.selection.set(a.outlinedObjects || []);
156
+ var c;
157
+ (c = i.value) == null || c.selection.set(e.outlinedObjects || []);
362
158
  },
363
159
  {
364
160
  immediate: !0
365
161
  }
366
- ), P(() => {
367
- if (!r.value)
368
- return;
369
- const u = new G(), {
370
- blur: i,
371
- xRay: o,
372
- kernelSize: s,
373
- pulseSpeed: d,
374
- patternScale: m,
375
- edgeStrength: g,
376
- multisampling: h,
377
- hiddenEdgeColor: B,
378
- visibleEdgeColor: x
379
- } = f.value;
380
- r.value.blur = i !== void 0 ? i : u.blur, r.value.xRay = o !== void 0 ? o : u.xRay, r.value.pulseSpeed = d !== void 0 ? d : u.pulseSpeed, r.value.kernelSize = s !== void 0 ? s : u.kernelSize, r.value.edgeStrength = g !== void 0 ? g : u.edgeStrength, r.value.patternScale = m !== void 0 ? m : u.patternScale, r.value.multisampling = h !== void 0 ? h : u.multisampling, r.value.hiddenEdgeColor = B !== void 0 ? R(B) : u.hiddenEdgeColor, r.value.visibleEdgeColor = x !== void 0 ? R(x) : u.visibleEdgeColor, u.dispose();
381
- }), F(() => {
382
- var u, i, o, s;
383
- (u = r.value) == null || u.selection.clear(), l.value && ((i = t == null ? void 0 : t.value) == null || i.removePass(l.value)), (o = r.value) == null || o.dispose(), (s = l.value) == null || s.dispose();
384
- }), (u, i) => null;
162
+ );
163
+ const d = k(() => ({
164
+ hiddenEdgeColor: e.hiddenEdgeColor ? C(e.hiddenEdgeColor) : void 0,
165
+ visibleEdgeColor: e.visibleEdgeColor ? C(e.visibleEdgeColor) : void 0
166
+ }));
167
+ return E(
168
+ [
169
+ /* some properties are not updated because of different reasons:
170
+ resolutionX - has no setter in OutlineEffect
171
+ resolutionY - has no setter in OutlineEffect
172
+ blendFunction - has no setter in OutlineEffect
173
+ patternTexture - different type in constructor and in setter
174
+ resolutionScale - has no setter in OutlineEffect
175
+ */
176
+ [() => e.blur, "blur"],
177
+ [() => e.xRay, "xRay"],
178
+ [() => e.pulseSpeed, "pulseSpeed"],
179
+ [() => e.kernelSize, "kernelSize"],
180
+ [() => e.edgeStrength, "edgeStrength"],
181
+ [() => e.patternScale, "patternScale"],
182
+ [() => e.multisampling, "multisampling"],
183
+ [() => d.value.hiddenEdgeColor, "hiddenEdgeColor"],
184
+ [() => d.value.visibleEdgeColor, "visibleEdgeColor"]
185
+ ],
186
+ i,
187
+ () => new y()
188
+ ), (c, B) => null;
189
+ }
190
+ }), le = /* @__PURE__ */ f({
191
+ __name: "Pixelation",
192
+ props: {
193
+ granularity: {}
194
+ },
195
+ setup(a, { expose: t }) {
196
+ const e = a, { pass: n, effect: o } = v(() => new P(e.granularity));
197
+ return t({ pass: n, effect: o }), L(
198
+ e,
199
+ o,
200
+ () => new P()
201
+ ), (l, s) => null;
202
+ }
203
+ }), ae = /* @__PURE__ */ f({
204
+ __name: "DepthOfField",
205
+ props: {
206
+ blendFunction: {},
207
+ worldFocusDistance: {},
208
+ worldFocusRange: {},
209
+ focusDistance: {},
210
+ focusRange: {},
211
+ bokehScale: {},
212
+ resolutionScale: {},
213
+ resolutionX: {},
214
+ resolutionY: {}
215
+ },
216
+ setup(a, { expose: t }) {
217
+ const e = a, { camera: n } = S(), { pass: o, effect: l } = v(() => new F(n.value, e));
218
+ return t({ pass: o, effect: l }), E(
219
+ [
220
+ // blendFunction is not updated, because it has no setter in BloomEffect
221
+ [() => e.worldFocusDistance, "circleOfConfusionMaterial.worldFocusDistance"],
222
+ [() => e.focusDistance, "circleOfConfusionMaterial.focusDistance"],
223
+ [() => e.worldFocusRange, "circleOfConfusionMaterial.worldFocusRange"],
224
+ [() => e.focusRange, "circleOfConfusionMaterial.focusRange"],
225
+ [() => e.bokehScale, "bokehScale"],
226
+ [() => e.resolutionScale, "blurPass.resolution.scale"],
227
+ [() => e.resolutionX, "resolution.width"],
228
+ [() => e.resolutionY, "resolution.height"]
229
+ ],
230
+ l,
231
+ () => new F()
232
+ ), (s, r) => null;
233
+ }
234
+ });
235
+ let p;
236
+ function D() {
237
+ var a;
238
+ if (p !== void 0)
239
+ return p;
240
+ try {
241
+ let t;
242
+ const e = document.createElement("canvas");
243
+ return p = !!(window.WebGL2RenderingContext && (t = e.getContext("webgl2"))), t && ((a = t.getExtension("WEBGL_lose_context")) == null || a.loseContext()), p;
244
+ } catch {
245
+ return p = !1;
246
+ }
247
+ }
248
+ const se = /* @__PURE__ */ f({
249
+ __name: "EffectComposer",
250
+ props: {
251
+ enabled: { type: Boolean, default: !0 },
252
+ children: {},
253
+ depthBuffer: { type: Boolean, default: void 0 },
254
+ disableNormalPass: { type: Boolean, default: !1 },
255
+ stencilBuffer: { type: Boolean, default: void 0 },
256
+ resolutionScale: {},
257
+ autoClear: { type: Boolean, default: !0 },
258
+ multisampling: { default: 0 },
259
+ frameBufferType: { default: O }
260
+ },
261
+ setup(a) {
262
+ const t = a, { scene: e, camera: n, renderer: o, sizes: l } = S(), s = w(null);
263
+ let r = null, i = null;
264
+ j(A, s);
265
+ const d = () => {
266
+ s.value && (i = new I(e.value, n.value), i.enabled = !1, s.value.addPass(i), t.resolutionScale !== void 0 && D() && (r = new U({
267
+ normalBuffer: i.texture,
268
+ resolutionScale: t.resolutionScale
269
+ }), r.enabled = !1, s.value.addPass(r)));
270
+ };
271
+ m(() => {
272
+ s.value && l.width.value && l.height.value && s.value.setSize(l.width.value, l.height.value);
273
+ });
274
+ const c = k(() => {
275
+ const u = new R(), g = {
276
+ depthBuffer: t.depthBuffer !== void 0 ? t.depthBuffer : u.inputBuffer.depthBuffer,
277
+ stencilBuffer: t.stencilBuffer !== void 0 ? t.stencilBuffer : u.inputBuffer.stencilBuffer,
278
+ multisampling: D() ? 0 : t.multisampling !== void 0 ? t.multisampling : u.multisampling,
279
+ frameBufferType: t.frameBufferType !== void 0 ? t.frameBufferType : O
280
+ };
281
+ return u.dispose(), g;
282
+ }), B = () => {
283
+ !o.value && !e.value && !n.value || (s.value = new R(o.value, c.value), s.value.addPass(new H(e.value, n.value)), t.disableNormalPass || d());
284
+ };
285
+ let h = () => {
286
+ };
287
+ h = _([l.height, l.width], () => {
288
+ !l.height.value && !l.width.value || (m(B), h == null || h());
289
+ }, {
290
+ immediate: !0
291
+ });
292
+ const { onLoop: W } = K();
293
+ return W(({ delta: u }) => {
294
+ if (t.enabled && o.value && s.value && l.width.value && l.height.value) {
295
+ const g = o.value.autoClear;
296
+ o.value.autoClear = t.autoClear, t.stencilBuffer && !t.autoClear && o.value.clearStencil(), s.value.render(u), o.value.autoClear = g;
297
+ }
298
+ }), T(() => {
299
+ var u;
300
+ (u = s.value) == null || u.dispose();
301
+ }), (u, g) => N(u.$slots, "default");
385
302
  }
386
303
  });
387
304
  export {
388
- Be as Bloom,
389
- Ee as EffectComposer,
390
- xe as Glitch,
391
- Oe as Outline
305
+ te as Bloom,
306
+ ae as DepthOfField,
307
+ se as EffectComposer,
308
+ ne as Glitch,
309
+ oe as Outline,
310
+ le as Pixelation
392
311
  };