@tresjs/post-processing 0.4.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.
- package/README.md +5 -12
- package/dist/core/EffectComposer.vue.d.ts +51 -100
- package/dist/core/composables/effect.d.ts +6 -0
- package/dist/core/effects/Bloom.vue.d.ts +37 -55
- package/dist/core/effects/DepthOfField.vue.d.ts +45 -0
- package/dist/core/effects/Glitch.vue.d.ts +17 -95
- package/dist/core/effects/Outline.vue.d.ts +32 -125
- package/dist/core/effects/Pixelation.vue.d.ts +21 -0
- package/dist/core/injectionKeys.d.ts +2 -2
- package/dist/index.d.ts +3 -1
- package/dist/tres-postprocessing.js +233 -151
- package/dist/tres-postprocessing.umd.cjs +2 -2
- package/dist/util/object.d.ts +55 -0
- package/dist/util/prop.d.ts +40 -0
- package/package.json +23 -21
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { EffectComposer } from 'postprocessing';
|
|
2
|
-
import { InjectionKey, ShallowRef } from 'vue';
|
|
1
|
+
import type { EffectComposer } from 'postprocessing';
|
|
2
|
+
import type { InjectionKey, ShallowRef } from 'vue';
|
|
3
3
|
export declare const effectComposerInjectionKey: InjectionKey<ShallowRef<EffectComposer | null>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Bloom from './core/effects/Bloom.vue';
|
|
2
2
|
import Glitch from './core/effects/Glitch.vue';
|
|
3
3
|
import Outline from './core/effects/Outline.vue';
|
|
4
|
+
import Pixelation from './core/effects/Pixelation.vue';
|
|
5
|
+
import DepthOfField from './core/effects/DepthOfField.vue';
|
|
4
6
|
import EffectComposer from './core/EffectComposer.vue';
|
|
5
|
-
export {
|
|
7
|
+
export { Bloom, Glitch, Outline, Pixelation, DepthOfField, EffectComposer, };
|
|
@@ -1,15 +1,64 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/post-processing
|
|
3
|
-
* version: v0.
|
|
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 {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { HalfFloatType as
|
|
12
|
-
const
|
|
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);
|
|
16
|
+
});
|
|
17
|
+
let s = () => {
|
|
18
|
+
};
|
|
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();
|
|
24
|
+
}), {
|
|
25
|
+
pass: e,
|
|
26
|
+
effect: n
|
|
27
|
+
};
|
|
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());
|
|
49
|
+
},
|
|
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({
|
|
13
62
|
__name: "Bloom",
|
|
14
63
|
props: {
|
|
15
64
|
blendFunction: {},
|
|
@@ -17,26 +66,23 @@ const x = Symbol(), ee = /* @__PURE__ */ _({
|
|
|
17
66
|
kernelSize: {},
|
|
18
67
|
luminanceThreshold: {},
|
|
19
68
|
luminanceSmoothing: {},
|
|
20
|
-
mipmapBlur: { type: Boolean }
|
|
69
|
+
mipmapBlur: { type: Boolean, default: void 0 }
|
|
21
70
|
},
|
|
22
|
-
setup(
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var a, d, v;
|
|
36
|
-
t.value && ((a = n == null ? void 0 : n.value) == null || a.removePass(t.value)), (d = e.value) == null || d.dispose(), (v = t.value) == null || v.dispose();
|
|
37
|
-
}), (a, d) => 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;
|
|
38
84
|
}
|
|
39
|
-
}),
|
|
85
|
+
}), ne = /* @__PURE__ */ f({
|
|
40
86
|
__name: "Glitch",
|
|
41
87
|
props: {
|
|
42
88
|
blendFunction: {},
|
|
@@ -51,29 +97,28 @@ const x = Symbol(), ee = /* @__PURE__ */ _({
|
|
|
51
97
|
perturbationMap: {},
|
|
52
98
|
dtSize: {}
|
|
53
99
|
},
|
|
54
|
-
setup(
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}), (a, d) => 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;
|
|
70
115
|
}
|
|
71
|
-
}),
|
|
116
|
+
}), oe = /* @__PURE__ */ f({
|
|
72
117
|
__name: "Outline",
|
|
73
118
|
props: {
|
|
74
119
|
outlinedObjects: {},
|
|
75
|
-
blur: { type: Boolean },
|
|
76
|
-
xRay: { type: Boolean },
|
|
120
|
+
blur: { type: Boolean, default: void 0 },
|
|
121
|
+
xRay: { type: Boolean, default: void 0 },
|
|
77
122
|
kernelSize: {},
|
|
78
123
|
pulseSpeed: {},
|
|
79
124
|
resolutionX: {},
|
|
@@ -87,91 +132,120 @@ const x = Symbol(), ee = /* @__PURE__ */ _({
|
|
|
87
132
|
hiddenEdgeColor: {},
|
|
88
133
|
visibleEdgeColor: {}
|
|
89
134
|
},
|
|
90
|
-
setup(
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
} = l;
|
|
110
|
-
return {
|
|
111
|
-
blur: u,
|
|
112
|
-
xRay: c,
|
|
113
|
-
kernelSize: p,
|
|
114
|
-
pulseSpeed: r,
|
|
115
|
-
resolutionX: m,
|
|
116
|
-
resolutionY: S,
|
|
117
|
-
patternScale: B,
|
|
118
|
-
edgeStrength: C,
|
|
119
|
-
blendFunction: E,
|
|
120
|
-
multisampling: y,
|
|
121
|
-
patternTexture: N,
|
|
122
|
-
resolutionScale: D,
|
|
123
|
-
hiddenEdgeColor: i($),
|
|
124
|
-
visibleEdgeColor: i(W)
|
|
125
|
-
};
|
|
126
|
-
}), { camera: a, scene: d } = P();
|
|
127
|
-
let v;
|
|
128
|
-
return v = h(() => {
|
|
129
|
-
!a.value || !(n != null && n.value) || !d.value || (v == null || v(), !e.value && (e.value = new A(d.value, a.value, s.value), t.value = new M(a.value, e.value), n.value.addPass(t.value)));
|
|
130
|
-
}), F(
|
|
131
|
-
[() => l.outlinedObjects, e],
|
|
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],
|
|
132
154
|
// watchEffect is intentionally not used here as it would result in an endless loop
|
|
133
155
|
() => {
|
|
134
|
-
var
|
|
135
|
-
(
|
|
156
|
+
var c;
|
|
157
|
+
(c = i.value) == null || c.selection.set(e.outlinedObjects || []);
|
|
136
158
|
},
|
|
137
159
|
{
|
|
138
160
|
immediate: !0
|
|
139
161
|
}
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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;
|
|
159
233
|
}
|
|
160
234
|
});
|
|
161
|
-
let
|
|
162
|
-
function
|
|
163
|
-
var
|
|
164
|
-
if (
|
|
165
|
-
return
|
|
235
|
+
let p;
|
|
236
|
+
function D() {
|
|
237
|
+
var a;
|
|
238
|
+
if (p !== void 0)
|
|
239
|
+
return p;
|
|
166
240
|
try {
|
|
167
|
-
let
|
|
168
|
-
const
|
|
169
|
-
return
|
|
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;
|
|
170
244
|
} catch {
|
|
171
|
-
return
|
|
245
|
+
return p = !1;
|
|
172
246
|
}
|
|
173
247
|
}
|
|
174
|
-
const
|
|
248
|
+
const se = /* @__PURE__ */ f({
|
|
175
249
|
__name: "EffectComposer",
|
|
176
250
|
props: {
|
|
177
251
|
enabled: { type: Boolean, default: !0 },
|
|
@@ -182,48 +256,56 @@ const te = /* @__PURE__ */ _({
|
|
|
182
256
|
resolutionScale: {},
|
|
183
257
|
autoClear: { type: Boolean, default: !0 },
|
|
184
258
|
multisampling: { default: 0 },
|
|
185
|
-
frameBufferType: { default:
|
|
259
|
+
frameBufferType: { default: O }
|
|
186
260
|
},
|
|
187
|
-
setup(
|
|
188
|
-
const
|
|
189
|
-
let
|
|
190
|
-
|
|
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);
|
|
191
265
|
const d = () => {
|
|
192
|
-
|
|
193
|
-
normalBuffer:
|
|
194
|
-
resolutionScale:
|
|
195
|
-
}),
|
|
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)));
|
|
196
270
|
};
|
|
197
|
-
|
|
198
|
-
|
|
271
|
+
m(() => {
|
|
272
|
+
s.value && l.width.value && l.height.value && s.value.setSize(l.width.value, l.height.value);
|
|
199
273
|
});
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
depthBuffer:
|
|
203
|
-
stencilBuffer:
|
|
204
|
-
multisampling:
|
|
205
|
-
frameBufferType:
|
|
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
|
|
206
280
|
};
|
|
207
|
-
return
|
|
208
|
-
}),
|
|
209
|
-
!
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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;
|
|
217
297
|
}
|
|
218
|
-
}),
|
|
219
|
-
var
|
|
220
|
-
(
|
|
221
|
-
}), (
|
|
298
|
+
}), T(() => {
|
|
299
|
+
var u;
|
|
300
|
+
(u = s.value) == null || u.dispose();
|
|
301
|
+
}), (u, g) => N(u.$slots, "default");
|
|
222
302
|
}
|
|
223
303
|
});
|
|
224
304
|
export {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
305
|
+
te as Bloom,
|
|
306
|
+
ae as DepthOfField,
|
|
307
|
+
se as EffectComposer,
|
|
308
|
+
ne as Glitch,
|
|
309
|
+
oe as Outline,
|
|
310
|
+
le as Pixelation
|
|
229
311
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/post-processing
|
|
3
|
-
* version: v0.
|
|
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
|
-
(function(
|
|
8
|
+
(function(c,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue"),require("postprocessing"),require("@tresjs/core"),require("three")):typeof define=="function"&&define.amd?define(["exports","vue","postprocessing","@tresjs/core","three"],i):(c=typeof globalThis<"u"?globalThis:c||self,i(c["tres-postprocessing"]={},c.Vue,c.Postprocessing,c.TresjsCore,c.Three))})(this,function(c,i,u,m,E){"use strict";const b=Symbol(),v=a=>{const t=i.inject(b),e=i.shallowRef(null),n=i.shallowRef(null),{scene:l,camera:o}=m.useTresContext();i.watchEffect(()=>{!o.value||!(n!=null&&n.value)||(n.value.mainCamera=o.value)});let r=()=>{};return r=i.watchEffect(()=>{!o.value||!(t!=null&&t.value)||!l.value||(r(),!n.value&&(n.value=a(),e.value=new u.EffectPass(o.value,n.value),t.value.addPass(e.value)))}),i.onUnmounted(()=>{var s,f,h;e.value&&((s=t==null?void 0:t.value)==null||s.removePass(e.value)),(f=n.value)==null||f.dispose(),(h=e.value)==null||h.dispose()}),{pass:e,effect:n}},_=/([^[.\]])+/g,F=(a,t)=>{if(!t)return;const e=Array.isArray(t)?t:t.match(_);return e==null?void 0:e.reduce((n,l)=>n&&n[l],a)},B=(a,t,e)=>{const n=Array.isArray(t)?t:t.match(_);n&&n.reduce((l,o,r)=>(l[o]===void 0&&(l[o]={}),r===n.length-1&&(l[o]=e),l[o]),a)},O=(a,t)=>{const e={...a};return t.forEach(n=>delete e[n]),e},y=(a,t,e,n,l={})=>i.watch(a,o=>{var r;if(t.value)if(o===void 0){const s=n();B(t.value,e,F(s,e)),(r=s.dispose)==null||r.call(s)}else B(t.value,e,a())},l),S=(a,t,e)=>a.map(([n,l])=>y(n,t,l,e)),x=(a,t,e)=>Object.keys(a).map(n=>y(()=>a[n],t,n,e)),R=i.defineComponent({__name:"Bloom",props:{blendFunction:{},intensity:{},kernelSize:{},luminanceThreshold:{},luminanceSmoothing:{},mipmapBlur:{type:Boolean,default:void 0}},setup(a,{expose:t}){const e=a,{pass:n,effect:l}=v(()=>new u.BloomEffect(e));return t({pass:n,effect:l}),S([[()=>e.intensity,"intensity"],[()=>e.kernelSize,"kernelSize"],[()=>e.luminanceSmoothing,"luminanceMaterial.smoothing"],[()=>e.luminanceThreshold,"luminanceMaterial.threshold"]],l,()=>new u.BloomEffect),(o,r)=>null}}),z=i.defineComponent({__name:"Glitch",props:{blendFunction:{},delay:{},duration:{},strength:{},mode:{},active:{type:Boolean},ratio:{},columns:{},chromaticAberrationOffset:{},perturbationMap:{},dtSize:{}},setup(a,{expose:t}){const e=a,{pass:n,effect:l}=v(()=>new u.GlitchEffect(e));return t({pass:n,effect:l}),i.watchEffect(()=>{const o=()=>{if(e.mode!==void 0)return e.active===!1?u.GlitchMode.DISABLED:e.mode;const r=new u.GlitchEffect,s=r.mode;return r.dispose(),s};l.value&&(l.value.mode=o())}),x(O(e,["active","mode","blendFunction"]),l,()=>new u.GlitchEffect),(o,r)=>null}}),D=i.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(a,{expose:t}){const e=a,n=p=>p!==void 0?m.normalizeColor(p).getHex():void 0,{camera:l,scene:o}=m.useTresContext(),r={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:n(e.hiddenEdgeColor),visibleEdgeColor:n(e.visibleEdgeColor)},{pass:s,effect:f}=v(()=>new u.OutlineEffect(o.value,l.value,r));t({pass:s,effect:f}),i.watch([()=>e.outlinedObjects,f],()=>{var p;(p=f.value)==null||p.selection.set(e.outlinedObjects||[])},{immediate:!0});const h=i.computed(()=>({hiddenEdgeColor:e.hiddenEdgeColor?m.normalizeColor(e.hiddenEdgeColor):void 0,visibleEdgeColor:e.visibleEdgeColor?m.normalizeColor(e.visibleEdgeColor):void 0}));return S([[()=>e.blur,"blur"],[()=>e.xRay,"xRay"],[()=>e.pulseSpeed,"pulseSpeed"],[()=>e.kernelSize,"kernelSize"],[()=>e.edgeStrength,"edgeStrength"],[()=>e.patternScale,"patternScale"],[()=>e.multisampling,"multisampling"],[()=>h.value.hiddenEdgeColor,"hiddenEdgeColor"],[()=>h.value.visibleEdgeColor,"visibleEdgeColor"]],f,()=>new u.OutlineEffect),(p,T)=>null}}),k=i.defineComponent({__name:"Pixelation",props:{granularity:{}},setup(a,{expose:t}){const e=a,{pass:n,effect:l}=v(()=>new u.PixelationEffect(e.granularity));return t({pass:n,effect:l}),x(e,l,()=>new u.PixelationEffect),(o,r)=>null}}),M=i.defineComponent({__name:"DepthOfField",props:{blendFunction:{},worldFocusDistance:{},worldFocusRange:{},focusDistance:{},focusRange:{},bokehScale:{},resolutionScale:{},resolutionX:{},resolutionY:{}},setup(a,{expose:t}){const e=a,{camera:n}=m.useTresContext(),{pass:l,effect:o}=v(()=>new u.DepthOfFieldEffect(n.value,e));return t({pass:l,effect:o}),S([[()=>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"]],o,()=>new u.DepthOfFieldEffect),(r,s)=>null}});let C;function P(){var a;if(C!==void 0)return C;try{let t;const e=document.createElement("canvas");return C=!!(window.WebGL2RenderingContext&&(t=e.getContext("webgl2"))),t&&((a=t.getExtension("WEBGL_lose_context"))==null||a.loseContext()),C}catch{return C=!1}}const j=i.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:E.HalfFloatType}},setup(a){const t=a,{scene:e,camera:n,renderer:l,sizes:o}=m.useTresContext(),r=i.shallowRef(null);let s=null,f=null;i.provide(b,r);const h=()=>{r.value&&(f=new u.NormalPass(e.value,n.value),f.enabled=!1,r.value.addPass(f),t.resolutionScale!==void 0&&P()&&(s=new u.DepthDownsamplingPass({normalBuffer:f.texture,resolutionScale:t.resolutionScale}),s.enabled=!1,r.value.addPass(s)))};i.watchEffect(()=>{r.value&&o.width.value&&o.height.value&&r.value.setSize(o.width.value,o.height.value)});const p=i.computed(()=>{const d=new u.EffectComposer,w={depthBuffer:t.depthBuffer!==void 0?t.depthBuffer:d.inputBuffer.depthBuffer,stencilBuffer:t.stencilBuffer!==void 0?t.stencilBuffer:d.inputBuffer.stencilBuffer,multisampling:P()?0:t.multisampling!==void 0?t.multisampling:d.multisampling,frameBufferType:t.frameBufferType!==void 0?t.frameBufferType:E.HalfFloatType};return d.dispose(),w}),T=()=>{!l.value&&!e.value&&!n.value||(r.value=new u.EffectComposer(l.value,p.value),r.value.addPass(new u.RenderPass(e.value,n.value)),t.disableNormalPass||h())};let g=()=>{};g=i.watch([o.height,o.width],()=>{!o.height.value&&!o.width.value||(i.watchEffect(T),g==null||g())},{immediate:!0});const{onLoop:A}=m.useRenderLoop();return A(({delta:d})=>{if(t.enabled&&l.value&&r.value&&o.width.value&&o.height.value){const w=l.value.autoClear;l.value.autoClear=t.autoClear,t.stencilBuffer&&!t.autoClear&&l.value.clearStencil(),r.value.render(d),l.value.autoClear=w}}),i.onUnmounted(()=>{var d;(d=r.value)==null||d.dispose()}),(d,w)=>i.renderSlot(d.$slots,"default")}});c.Bloom=R,c.DepthOfField=M,c.EffectComposer=j,c.Glitch=z,c.Outline=D,c.Pixelation=k,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves the value at a given path within a provided object.
|
|
3
|
+
*
|
|
4
|
+
* @template T - The type of value to be returned
|
|
5
|
+
*
|
|
6
|
+
* @param {any} obj - The object to extract value from
|
|
7
|
+
* @param {string | string[]} path - A path or an array of path where the value should be get from
|
|
8
|
+
*
|
|
9
|
+
* @returns {T | undefined} - The value at the given path in the object, or undefined if path is not found
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
*
|
|
13
|
+
* const obj = { a: { b: { c: 1 } } }
|
|
14
|
+
*
|
|
15
|
+
* const result = get(obj, 'a.b.c')
|
|
16
|
+
*
|
|
17
|
+
* console.log(result) // 1
|
|
18
|
+
*/
|
|
19
|
+
export declare const get: <T>(obj: any, path: string | string[]) => T | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Sets a value at a given path within a provided object. If the path does not exist, nested objects will be created.
|
|
22
|
+
*
|
|
23
|
+
* @param {any} obj - The original object to set value in
|
|
24
|
+
* @param {string | string[]} path - A path or an array of path where the value should be set
|
|
25
|
+
* @param {any} value - The value to be set at the provided path
|
|
26
|
+
*
|
|
27
|
+
* @returns {void}
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const obj = { a: { b: { c: 1 } } }
|
|
31
|
+
*
|
|
32
|
+
* set(obj, 'a.b.c', 2)
|
|
33
|
+
*
|
|
34
|
+
* console.log(obj) // { a: { b: { c: 2 } } }
|
|
35
|
+
*/
|
|
36
|
+
export declare const set: (obj: any, path: string | string[], value: any) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Omits given properties from a provided object.
|
|
39
|
+
*
|
|
40
|
+
* @template T - An object with string keys and any type of values
|
|
41
|
+
*
|
|
42
|
+
* @param {T} obj - The original object to omit properties from
|
|
43
|
+
* @param {(keyof T)[]} properties - An array of property key names to omit from the base object
|
|
44
|
+
*
|
|
45
|
+
* @returns {Partial<T>} The new object with omitted properties
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const obj = { a: 1, b: 2, c: 3 }
|
|
49
|
+
* const propsToOmit = ['b', 'c']
|
|
50
|
+
*
|
|
51
|
+
* const newObj = omit(obj, propsToOmit)
|
|
52
|
+
*
|
|
53
|
+
* console.log(newObj) // { a: 1 }
|
|
54
|
+
*/
|
|
55
|
+
export declare const omit: <T extends Record<string, any>>(obj: T, properties: (keyof T)[]) => Partial<T>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Ref, WatchOptions } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a prop watcher function that monitors changes to a property and updates a target object.
|
|
4
|
+
*
|
|
5
|
+
* @template T - The type of the property being watched.
|
|
6
|
+
* @template E - The type of the target object.
|
|
7
|
+
* @param {() => T} propGetter - A function that retrieves the prop value to be watched.
|
|
8
|
+
* @param {Ref<E>} target - A Ref representing the target object to be updated.
|
|
9
|
+
* @param {string} propertyPath - The dot-separated path to the property within the target object.
|
|
10
|
+
* @param {() => E & { dispose?(): void }} newPlainObjectFunction - A function that creates a new plain object to retrieve the defaults from with an optional "dispose" method for cleanup.
|
|
11
|
+
* @param {WatchOptions} watchOptions - The options for watch.
|
|
12
|
+
*/
|
|
13
|
+
export declare const makePropWatcher: <T, E>(propGetter: () => T, target: Ref<E>, propertyPath: string, newPlainObjectFunction: () => E & {
|
|
14
|
+
dispose?(): void;
|
|
15
|
+
}, watchOptions?: WatchOptions) => import("vue").WatchStopHandle;
|
|
16
|
+
/**
|
|
17
|
+
* Creates multiple prop watchers for monitoring changes to multiple properties and updating a target object.
|
|
18
|
+
*
|
|
19
|
+
* @template T - The type of the property being watched.
|
|
20
|
+
* @template E - The type of the target object.
|
|
21
|
+
* @param {(string | (() => T))[][]} propGettersAndPropertyPaths - An array of arrays containing pairs of prop getters and their corresponding property paths within the target object.
|
|
22
|
+
* @param {Ref<E>} target - A Ref representing the target object to be updated.
|
|
23
|
+
* @param {() => E & { dispose?(): void }} newPlainObjectFunction - A function that creates a new plain object to retrieve the defaults from with an optional "dispose" method for cleanup.
|
|
24
|
+
*/
|
|
25
|
+
export declare const makePropWatchers: <E>(propGettersAndPropertyPaths: (string | (() => any))[][], target: Ref<E>, newPlainObjectFunction: () => E & {
|
|
26
|
+
dispose?(): void;
|
|
27
|
+
}) => import("vue").WatchStopHandle[];
|
|
28
|
+
/**
|
|
29
|
+
* Creates multiple prop watchers via the props object for monitoring changes to multiple properties and updating a target object.
|
|
30
|
+
* Use this method in case the prop names match the names of the properties you want to set on your target object.
|
|
31
|
+
*
|
|
32
|
+
* @param props - The props object. Usually created via defineProps.
|
|
33
|
+
* @param {Ref<E>} target - A Ref representing the target object to be updated.
|
|
34
|
+
* @param {() => E & { dispose?(): void }} newPlainObjectFunction - A function that creates a new plain object to retrieve the defaults from with an optional "dispose" method for cleanup.
|
|
35
|
+
*/
|
|
36
|
+
export declare const makePropWatchersUsingAllProps: <E>(props: {
|
|
37
|
+
[key: string]: any;
|
|
38
|
+
}, target: Ref<E>, newPlainObjectFunction: () => E & {
|
|
39
|
+
dispose?(): void;
|
|
40
|
+
}) => import("vue").WatchStopHandle[];
|