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