@tresjs/post-processing 0.6.0-next.0 → 0.7.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/dist/core/effects/Vignette.vue.d.ts +47 -0
- package/dist/index.d.ts +4 -3
- package/dist/tres-postprocessing.js +184 -171
- package/dist/tres-postprocessing.umd.cjs +2 -2
- package/package.json +33 -32
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BlendFunction, VignetteEffect, VignetteTechnique } from 'postprocessing';
|
|
2
|
+
export interface VignetteProps {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the noise should be multiplied with the input color.
|
|
5
|
+
*/
|
|
6
|
+
technique?: VignetteTechnique;
|
|
7
|
+
blendFunction?: BlendFunction;
|
|
8
|
+
offset: number;
|
|
9
|
+
darkness: number;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<VignetteProps>, {
|
|
12
|
+
technique: VignetteTechnique;
|
|
13
|
+
blendFunction: BlendFunction;
|
|
14
|
+
offset: number;
|
|
15
|
+
darkness: number;
|
|
16
|
+
}>, {
|
|
17
|
+
pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
|
|
18
|
+
effect: import("vue").ShallowRef<VignetteEffect | null>;
|
|
19
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<VignetteProps>, {
|
|
20
|
+
technique: VignetteTechnique;
|
|
21
|
+
blendFunction: BlendFunction;
|
|
22
|
+
offset: number;
|
|
23
|
+
darkness: number;
|
|
24
|
+
}>>>, {
|
|
25
|
+
blendFunction: BlendFunction;
|
|
26
|
+
technique: VignetteTechnique;
|
|
27
|
+
offset: number;
|
|
28
|
+
darkness: number;
|
|
29
|
+
}, {}>;
|
|
30
|
+
export default _default;
|
|
31
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
32
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
33
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
34
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
35
|
+
} : {
|
|
36
|
+
type: import('vue').PropType<T[K]>;
|
|
37
|
+
required: true;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
type __VLS_WithDefaults<P, D> = {
|
|
41
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
42
|
+
default: D[K];
|
|
43
|
+
}> : P[K];
|
|
44
|
+
};
|
|
45
|
+
type __VLS_Prettify<T> = {
|
|
46
|
+
[K in keyof T]: T[K];
|
|
47
|
+
} & {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import Bloom from './core/effects/Bloom.vue';
|
|
2
|
+
import DepthOfField from './core/effects/DepthOfField.vue';
|
|
3
|
+
import EffectComposer from './core/EffectComposer.vue';
|
|
2
4
|
import Glitch from './core/effects/Glitch.vue';
|
|
3
5
|
import Outline from './core/effects/Outline.vue';
|
|
4
6
|
import Pixelation from './core/effects/Pixelation.vue';
|
|
5
|
-
import
|
|
7
|
+
import Vignette from './core/effects/Vignette.vue';
|
|
6
8
|
import Noise from './core/effects/Noise.vue';
|
|
7
|
-
|
|
8
|
-
export { Bloom, Glitch, Outline, Pixelation, DepthOfField, EffectComposer, Noise, };
|
|
9
|
+
export { Bloom, DepthOfField, EffectComposer, Glitch, Noise, Outline, Pixelation, Vignette, };
|
|
@@ -1,64 +1,64 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/post-processing
|
|
3
|
-
* version: v0.
|
|
3
|
+
* version: v0.7.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
|
|
9
|
-
import { EffectPass as
|
|
10
|
-
import { useTresContext as
|
|
11
|
-
import { HalfFloatType as
|
|
12
|
-
const
|
|
13
|
-
const t =
|
|
14
|
-
|
|
15
|
-
!
|
|
8
|
+
import { inject as X, shallowRef as w, watchEffect as E, onUnmounted as M, watch as g, defineComponent as f, provide as Y, computed as N, renderSlot as V } from "vue";
|
|
9
|
+
import { EffectPass as U, BloomEffect as y, DepthOfFieldEffect as F, EffectComposer as P, RenderPass as q, NormalPass as H, DepthDownsamplingPass as I, GlitchEffect as S, GlitchMode as K, OutlineEffect as R, PixelationEffect as O, VignetteTechnique as J, BlendFunction as L, VignetteEffect as D, NoiseEffect as T } from "postprocessing";
|
|
10
|
+
import { useTresContext as h, useRenderLoop as Q, normalizeColor as C } from "@tresjs/core";
|
|
11
|
+
import { HalfFloatType as z } from "three";
|
|
12
|
+
const $ = Symbol(), m = (l) => {
|
|
13
|
+
const t = X($), e = w(null), n = w(null), { scene: o, camera: a } = h();
|
|
14
|
+
E(() => {
|
|
15
|
+
!a.value || !(n != null && n.value) || (n.value.mainCamera = a.value);
|
|
16
16
|
});
|
|
17
17
|
let s = () => {
|
|
18
18
|
};
|
|
19
|
-
return s =
|
|
20
|
-
!
|
|
21
|
-
}),
|
|
19
|
+
return s = E(() => {
|
|
20
|
+
!a.value || !(t != null && t.value) || !o.value || (s(), !n.value && (n.value = l(), e.value = new U(a.value, n.value), t.value.addPass(e.value)));
|
|
21
|
+
}), M(() => {
|
|
22
22
|
var r, i, d;
|
|
23
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
24
|
}), {
|
|
25
25
|
pass: e,
|
|
26
26
|
effect: n
|
|
27
27
|
};
|
|
28
|
-
}, G = /([^[.\]])+/g,
|
|
28
|
+
}, G = /([^[.\]])+/g, Z = (l, t) => {
|
|
29
29
|
if (!t)
|
|
30
30
|
return;
|
|
31
31
|
const e = Array.isArray(t) ? t : t.match(G);
|
|
32
|
-
return e == null ? void 0 : e.reduce((n, o) => n && n[o],
|
|
33
|
-
},
|
|
32
|
+
return e == null ? void 0 : e.reduce((n, o) => n && n[o], l);
|
|
33
|
+
}, k = (l, t, e) => {
|
|
34
34
|
const n = Array.isArray(t) ? t : t.match(G);
|
|
35
|
-
n && n.reduce((o,
|
|
36
|
-
},
|
|
37
|
-
const e = { ...
|
|
35
|
+
n && n.reduce((o, a, s) => (o[a] === void 0 && (o[a] = {}), s === n.length - 1 && (o[a] = e), o[a]), l);
|
|
36
|
+
}, x = (l, t) => {
|
|
37
|
+
const e = { ...l };
|
|
38
38
|
return t.forEach((n) => delete e[n]), e;
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
(
|
|
39
|
+
}, W = (l, t, e, n, o = {}) => g(
|
|
40
|
+
l,
|
|
41
|
+
(a) => {
|
|
42
42
|
var s;
|
|
43
43
|
if (t.value)
|
|
44
|
-
if (
|
|
44
|
+
if (a === void 0) {
|
|
45
45
|
const r = n();
|
|
46
|
-
|
|
46
|
+
k(t.value, e, Z(r, e)), (s = r.dispose) == null || s.call(r);
|
|
47
47
|
} else
|
|
48
|
-
|
|
48
|
+
k(t.value, e, l());
|
|
49
49
|
},
|
|
50
50
|
o
|
|
51
|
-
),
|
|
51
|
+
), B = (l, t, e) => l.map(([n, o]) => W(
|
|
52
52
|
n,
|
|
53
53
|
t,
|
|
54
54
|
o,
|
|
55
55
|
e
|
|
56
|
-
)),
|
|
57
|
-
() =>
|
|
56
|
+
)), _ = (l, t, e) => Object.keys(l).map((n) => W(
|
|
57
|
+
() => l[n],
|
|
58
58
|
t,
|
|
59
59
|
n,
|
|
60
60
|
e
|
|
61
|
-
)),
|
|
61
|
+
)), le = /* @__PURE__ */ f({
|
|
62
62
|
__name: "Bloom",
|
|
63
63
|
props: {
|
|
64
64
|
blendFunction: {},
|
|
@@ -68,9 +68,9 @@ const N = Symbol(), p = (a) => {
|
|
|
68
68
|
luminanceSmoothing: {},
|
|
69
69
|
mipmapBlur: { type: Boolean, default: void 0 }
|
|
70
70
|
},
|
|
71
|
-
setup(
|
|
72
|
-
const e =
|
|
73
|
-
return t({ pass: n, effect: o }),
|
|
71
|
+
setup(l, { expose: t }) {
|
|
72
|
+
const e = l, { pass: n, effect: o } = m(() => new y(e));
|
|
73
|
+
return t({ pass: n, effect: o }), B(
|
|
74
74
|
[
|
|
75
75
|
// blendFunction is not updated, because it has no setter in BloomEffect
|
|
76
76
|
[() => e.intensity, "intensity"],
|
|
@@ -80,9 +80,105 @@ const N = Symbol(), p = (a) => {
|
|
|
80
80
|
],
|
|
81
81
|
o,
|
|
82
82
|
() => new y()
|
|
83
|
-
), (
|
|
83
|
+
), (a, s) => null;
|
|
84
|
+
}
|
|
85
|
+
}), ae = /* @__PURE__ */ f({
|
|
86
|
+
__name: "DepthOfField",
|
|
87
|
+
props: {
|
|
88
|
+
blendFunction: {},
|
|
89
|
+
worldFocusDistance: {},
|
|
90
|
+
worldFocusRange: {},
|
|
91
|
+
focusDistance: {},
|
|
92
|
+
focusRange: {},
|
|
93
|
+
bokehScale: {},
|
|
94
|
+
resolutionScale: {},
|
|
95
|
+
resolutionX: {},
|
|
96
|
+
resolutionY: {}
|
|
97
|
+
},
|
|
98
|
+
setup(l, { expose: t }) {
|
|
99
|
+
const e = l, { camera: n } = h(), { pass: o, effect: a } = m(() => new F(n.value, e));
|
|
100
|
+
return t({ pass: o, effect: a }), B(
|
|
101
|
+
[
|
|
102
|
+
// blendFunction is not updated, because it has no setter in BloomEffect
|
|
103
|
+
[() => e.worldFocusDistance, "circleOfConfusionMaterial.worldFocusDistance"],
|
|
104
|
+
[() => e.focusDistance, "circleOfConfusionMaterial.focusDistance"],
|
|
105
|
+
[() => e.worldFocusRange, "circleOfConfusionMaterial.worldFocusRange"],
|
|
106
|
+
[() => e.focusRange, "circleOfConfusionMaterial.focusRange"],
|
|
107
|
+
[() => e.bokehScale, "bokehScale"],
|
|
108
|
+
[() => e.resolutionScale, "blurPass.resolution.scale"],
|
|
109
|
+
[() => e.resolutionX, "resolution.width"],
|
|
110
|
+
[() => e.resolutionY, "resolution.height"]
|
|
111
|
+
],
|
|
112
|
+
a,
|
|
113
|
+
() => new F()
|
|
114
|
+
), (s, r) => null;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
let v;
|
|
118
|
+
function A() {
|
|
119
|
+
var l;
|
|
120
|
+
if (v !== void 0)
|
|
121
|
+
return v;
|
|
122
|
+
try {
|
|
123
|
+
let t;
|
|
124
|
+
const e = document.createElement("canvas");
|
|
125
|
+
return v = !!(window.WebGL2RenderingContext && (t = e.getContext("webgl2"))), t && ((l = t.getExtension("WEBGL_lose_context")) == null || l.loseContext()), v;
|
|
126
|
+
} catch {
|
|
127
|
+
return v = !1;
|
|
84
128
|
}
|
|
85
|
-
}
|
|
129
|
+
}
|
|
130
|
+
const se = /* @__PURE__ */ f({
|
|
131
|
+
__name: "EffectComposer",
|
|
132
|
+
props: {
|
|
133
|
+
enabled: { type: Boolean, default: !0 },
|
|
134
|
+
children: {},
|
|
135
|
+
depthBuffer: { type: Boolean, default: void 0 },
|
|
136
|
+
disableNormalPass: { type: Boolean, default: !1 },
|
|
137
|
+
stencilBuffer: { type: Boolean, default: void 0 },
|
|
138
|
+
resolutionScale: {},
|
|
139
|
+
autoClear: { type: Boolean, default: !0 },
|
|
140
|
+
multisampling: { default: 0 },
|
|
141
|
+
frameBufferType: { default: z }
|
|
142
|
+
},
|
|
143
|
+
setup(l) {
|
|
144
|
+
const t = l, { scene: e, camera: n, renderer: o, sizes: a } = h(), s = w(null);
|
|
145
|
+
let r = null, i = null;
|
|
146
|
+
Y($, s);
|
|
147
|
+
const d = () => {
|
|
148
|
+
s.value && (i = new H(e.value, n.value), i.enabled = !1, s.value.addPass(i), t.resolutionScale !== void 0 && A() && (r = new I({
|
|
149
|
+
normalBuffer: i.texture,
|
|
150
|
+
resolutionScale: t.resolutionScale
|
|
151
|
+
}), r.enabled = !1, s.value.addPass(r)));
|
|
152
|
+
}, c = N(() => {
|
|
153
|
+
const u = new P(), p = {
|
|
154
|
+
depthBuffer: t.depthBuffer !== void 0 ? t.depthBuffer : u.inputBuffer.depthBuffer,
|
|
155
|
+
stencilBuffer: t.stencilBuffer !== void 0 ? t.stencilBuffer : u.inputBuffer.stencilBuffer,
|
|
156
|
+
multisampling: A() ? 0 : t.multisampling !== void 0 ? t.multisampling : u.multisampling,
|
|
157
|
+
frameBufferType: t.frameBufferType !== void 0 ? t.frameBufferType : z
|
|
158
|
+
};
|
|
159
|
+
return u.dispose(), p;
|
|
160
|
+
}), b = () => {
|
|
161
|
+
!o.value && !e.value && !n.value || (s.value = new P(o.value, c.value), s.value.addPass(new q(e.value, n.value)), t.disableNormalPass || d());
|
|
162
|
+
};
|
|
163
|
+
g([o, e, n, () => t.disableNormalPass], () => {
|
|
164
|
+
!a.width.value || !a.height.value || b();
|
|
165
|
+
}), g(() => [a.width.value, a.height.value], ([u, p]) => {
|
|
166
|
+
!u && !p || (s.value ? s.value.setSize(u, p) : b());
|
|
167
|
+
}, {
|
|
168
|
+
immediate: !0
|
|
169
|
+
});
|
|
170
|
+
const { onLoop: j } = Q();
|
|
171
|
+
return j(({ delta: u }) => {
|
|
172
|
+
if (t.enabled && o.value && s.value && a.width.value && a.height.value) {
|
|
173
|
+
const p = o.value.autoClear;
|
|
174
|
+
o.value.autoClear = t.autoClear, t.stencilBuffer && !t.autoClear && o.value.clearStencil(), s.value.render(u), o.value.autoClear = p;
|
|
175
|
+
}
|
|
176
|
+
}), M(() => {
|
|
177
|
+
var u;
|
|
178
|
+
(u = s.value) == null || u.dispose();
|
|
179
|
+
}), (u, p) => V(u.$slots, "default");
|
|
180
|
+
}
|
|
181
|
+
}), re = /* @__PURE__ */ f({
|
|
86
182
|
__name: "Glitch",
|
|
87
183
|
props: {
|
|
88
184
|
blendFunction: {},
|
|
@@ -97,23 +193,23 @@ const N = Symbol(), p = (a) => {
|
|
|
97
193
|
perturbationMap: {},
|
|
98
194
|
dtSize: {}
|
|
99
195
|
},
|
|
100
|
-
setup(
|
|
101
|
-
const e =
|
|
102
|
-
return t({ pass: n, effect: o }),
|
|
103
|
-
const
|
|
196
|
+
setup(l, { expose: t }) {
|
|
197
|
+
const e = l, { pass: n, effect: o } = m(() => new S(e));
|
|
198
|
+
return t({ pass: n, effect: o }), E(() => {
|
|
199
|
+
const a = () => {
|
|
104
200
|
if (e.mode !== void 0)
|
|
105
|
-
return e.active === !1 ?
|
|
106
|
-
const s = new
|
|
201
|
+
return e.active === !1 ? K.DISABLED : e.mode;
|
|
202
|
+
const s = new S(), r = s.mode;
|
|
107
203
|
return s.dispose(), r;
|
|
108
204
|
};
|
|
109
|
-
o.value && (o.value.mode =
|
|
110
|
-
}),
|
|
111
|
-
|
|
205
|
+
o.value && (o.value.mode = a());
|
|
206
|
+
}), _(
|
|
207
|
+
x(e, ["active", "mode", "blendFunction"]),
|
|
112
208
|
o,
|
|
113
|
-
() => new
|
|
114
|
-
), (
|
|
209
|
+
() => new S()
|
|
210
|
+
), (a, s) => null;
|
|
115
211
|
}
|
|
116
|
-
}),
|
|
212
|
+
}), ue = /* @__PURE__ */ f({
|
|
117
213
|
__name: "Outline",
|
|
118
214
|
props: {
|
|
119
215
|
outlinedObjects: {},
|
|
@@ -132,8 +228,8 @@ const N = Symbol(), p = (a) => {
|
|
|
132
228
|
hiddenEdgeColor: {},
|
|
133
229
|
visibleEdgeColor: {}
|
|
134
230
|
},
|
|
135
|
-
setup(
|
|
136
|
-
const e =
|
|
231
|
+
setup(l, { expose: t }) {
|
|
232
|
+
const e = l, n = (c) => c !== void 0 ? C(c).getHex() : void 0, { camera: o, scene: a } = h(), s = {
|
|
137
233
|
blur: e.blur,
|
|
138
234
|
xRay: e.xRay,
|
|
139
235
|
kernelSize: e.kernelSize,
|
|
@@ -148,8 +244,8 @@ const N = Symbol(), p = (a) => {
|
|
|
148
244
|
resolutionScale: e.resolutionScale,
|
|
149
245
|
hiddenEdgeColor: n(e.hiddenEdgeColor),
|
|
150
246
|
visibleEdgeColor: n(e.visibleEdgeColor)
|
|
151
|
-
}, { pass: r, effect: i } =
|
|
152
|
-
t({ pass: r, effect: i }),
|
|
247
|
+
}, { pass: r, effect: i } = m(() => new R(a.value, o.value, s));
|
|
248
|
+
t({ pass: r, effect: i }), g(
|
|
153
249
|
[() => e.outlinedObjects, i],
|
|
154
250
|
// watchEffect is intentionally not used here as it would result in an endless loop
|
|
155
251
|
() => {
|
|
@@ -160,11 +256,11 @@ const N = Symbol(), p = (a) => {
|
|
|
160
256
|
immediate: !0
|
|
161
257
|
}
|
|
162
258
|
);
|
|
163
|
-
const d =
|
|
259
|
+
const d = N(() => ({
|
|
164
260
|
hiddenEdgeColor: e.hiddenEdgeColor ? C(e.hiddenEdgeColor) : void 0,
|
|
165
261
|
visibleEdgeColor: e.visibleEdgeColor ? C(e.visibleEdgeColor) : void 0
|
|
166
262
|
}));
|
|
167
|
-
return
|
|
263
|
+
return B(
|
|
168
264
|
[
|
|
169
265
|
/* some properties are not updated because of different reasons:
|
|
170
266
|
resolutionX - has no setter in OutlineEffect
|
|
@@ -184,143 +280,60 @@ const N = Symbol(), p = (a) => {
|
|
|
184
280
|
[() => d.value.visibleEdgeColor, "visibleEdgeColor"]
|
|
185
281
|
],
|
|
186
282
|
i,
|
|
187
|
-
() => new
|
|
188
|
-
), (c,
|
|
283
|
+
() => new R()
|
|
284
|
+
), (c, b) => null;
|
|
189
285
|
}
|
|
190
|
-
}),
|
|
286
|
+
}), ie = /* @__PURE__ */ f({
|
|
191
287
|
__name: "Pixelation",
|
|
192
288
|
props: {
|
|
193
289
|
granularity: {}
|
|
194
290
|
},
|
|
195
|
-
setup(
|
|
196
|
-
const e =
|
|
197
|
-
return t({ pass: n, effect: o }),
|
|
291
|
+
setup(l, { expose: t }) {
|
|
292
|
+
const e = l, { pass: n, effect: o } = m(() => new O(e.granularity));
|
|
293
|
+
return t({ pass: n, effect: o }), _(
|
|
198
294
|
e,
|
|
199
295
|
o,
|
|
200
|
-
() => new
|
|
201
|
-
), (
|
|
296
|
+
() => new O()
|
|
297
|
+
), (a, s) => null;
|
|
202
298
|
}
|
|
203
|
-
}),
|
|
204
|
-
__name: "
|
|
299
|
+
}), ce = /* @__PURE__ */ f({
|
|
300
|
+
__name: "Vignette",
|
|
205
301
|
props: {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
focusRange: {},
|
|
211
|
-
bokehScale: {},
|
|
212
|
-
resolutionScale: {},
|
|
213
|
-
resolutionX: {},
|
|
214
|
-
resolutionY: {}
|
|
302
|
+
technique: { default: J.DEFAULT },
|
|
303
|
+
blendFunction: { default: L.NORMAL },
|
|
304
|
+
offset: { default: 0.5 },
|
|
305
|
+
darkness: { default: 0.5 }
|
|
215
306
|
},
|
|
216
|
-
setup(
|
|
217
|
-
const e =
|
|
218
|
-
return t({ pass:
|
|
219
|
-
[
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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 R()
|
|
232
|
-
), (s, r) => null;
|
|
307
|
+
setup(l, { expose: t }) {
|
|
308
|
+
const e = l, { pass: n, effect: o } = m(() => new D(e));
|
|
309
|
+
return t({ pass: n, effect: o }), _(
|
|
310
|
+
x(e, ["blendFunction"]),
|
|
311
|
+
o,
|
|
312
|
+
() => new D()
|
|
313
|
+
), (a, s) => null;
|
|
233
314
|
}
|
|
234
|
-
}),
|
|
315
|
+
}), fe = /* @__PURE__ */ f({
|
|
235
316
|
__name: "Noise",
|
|
236
317
|
props: {
|
|
237
318
|
premultiply: { type: Boolean, default: !1 },
|
|
238
|
-
blendFunction: { default:
|
|
319
|
+
blendFunction: { default: L.SCREEN }
|
|
239
320
|
},
|
|
240
|
-
setup(
|
|
241
|
-
const e =
|
|
242
|
-
return t({ pass: n, effect: o }),
|
|
243
|
-
e,
|
|
321
|
+
setup(l, { expose: t }) {
|
|
322
|
+
const e = l, { pass: n, effect: o } = m(() => new T(e));
|
|
323
|
+
return t({ pass: n, effect: o }), _(
|
|
324
|
+
x(e, ["blendFunction"]),
|
|
244
325
|
o,
|
|
245
|
-
() => new
|
|
246
|
-
), (
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
let m;
|
|
250
|
-
function k() {
|
|
251
|
-
var a;
|
|
252
|
-
if (m !== void 0)
|
|
253
|
-
return m;
|
|
254
|
-
try {
|
|
255
|
-
let t;
|
|
256
|
-
const e = document.createElement("canvas");
|
|
257
|
-
return m = !!(window.WebGL2RenderingContext && (t = e.getContext("webgl2"))), t && ((a = t.getExtension("WEBGL_lose_context")) == null || a.loseContext()), m;
|
|
258
|
-
} catch {
|
|
259
|
-
return m = !1;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
const ue = /* @__PURE__ */ f({
|
|
263
|
-
__name: "EffectComposer",
|
|
264
|
-
props: {
|
|
265
|
-
enabled: { type: Boolean, default: !0 },
|
|
266
|
-
children: {},
|
|
267
|
-
depthBuffer: { type: Boolean, default: void 0 },
|
|
268
|
-
disableNormalPass: { type: Boolean, default: !1 },
|
|
269
|
-
stencilBuffer: { type: Boolean, default: void 0 },
|
|
270
|
-
resolutionScale: {},
|
|
271
|
-
autoClear: { type: Boolean, default: !0 },
|
|
272
|
-
multisampling: { default: 0 },
|
|
273
|
-
frameBufferType: { default: D }
|
|
274
|
-
},
|
|
275
|
-
setup(a) {
|
|
276
|
-
const t = a, { scene: e, camera: n, renderer: o, sizes: l } = S(), s = _(null);
|
|
277
|
-
let r = null, i = null;
|
|
278
|
-
j(N, s);
|
|
279
|
-
const d = () => {
|
|
280
|
-
s.value && (i = new K(e.value, n.value), i.enabled = !1, s.value.addPass(i), t.resolutionScale !== void 0 && k() && (r = new q({
|
|
281
|
-
normalBuffer: i.texture,
|
|
282
|
-
resolutionScale: t.resolutionScale
|
|
283
|
-
}), r.enabled = !1, s.value.addPass(r)));
|
|
284
|
-
};
|
|
285
|
-
v(() => {
|
|
286
|
-
s.value && l.width.value && l.height.value && s.value.setSize(l.width.value, l.height.value);
|
|
287
|
-
});
|
|
288
|
-
const c = M(() => {
|
|
289
|
-
const u = new z(), g = {
|
|
290
|
-
depthBuffer: t.depthBuffer !== void 0 ? t.depthBuffer : u.inputBuffer.depthBuffer,
|
|
291
|
-
stencilBuffer: t.stencilBuffer !== void 0 ? t.stencilBuffer : u.inputBuffer.stencilBuffer,
|
|
292
|
-
multisampling: k() ? 0 : t.multisampling !== void 0 ? t.multisampling : u.multisampling,
|
|
293
|
-
frameBufferType: t.frameBufferType !== void 0 ? t.frameBufferType : D
|
|
294
|
-
};
|
|
295
|
-
return u.dispose(), g;
|
|
296
|
-
}), x = () => {
|
|
297
|
-
!o.value && !e.value && !n.value || (s.value = new z(o.value, c.value), s.value.addPass(new U(e.value, n.value)), t.disableNormalPass || d());
|
|
298
|
-
};
|
|
299
|
-
let h = () => {
|
|
300
|
-
};
|
|
301
|
-
h = w([l.height, l.width], () => {
|
|
302
|
-
!l.height.value && !l.width.value || (v(x), h == null || h());
|
|
303
|
-
}, {
|
|
304
|
-
immediate: !0
|
|
305
|
-
});
|
|
306
|
-
const { onLoop: $ } = J();
|
|
307
|
-
return $(({ delta: u }) => {
|
|
308
|
-
if (t.enabled && o.value && s.value && l.width.value && l.height.value) {
|
|
309
|
-
const g = o.value.autoClear;
|
|
310
|
-
o.value.autoClear = t.autoClear, t.stencilBuffer && !t.autoClear && o.value.clearStencil(), s.value.render(u), o.value.autoClear = g;
|
|
311
|
-
}
|
|
312
|
-
}), A(() => {
|
|
313
|
-
var u;
|
|
314
|
-
(u = s.value) == null || u.dispose();
|
|
315
|
-
}), (u, g) => X(u.$slots, "default");
|
|
326
|
+
() => new T()
|
|
327
|
+
), (a, s) => null;
|
|
316
328
|
}
|
|
317
329
|
});
|
|
318
330
|
export {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
331
|
+
le as Bloom,
|
|
332
|
+
ae as DepthOfField,
|
|
333
|
+
se as EffectComposer,
|
|
334
|
+
re as Glitch,
|
|
335
|
+
fe as Noise,
|
|
336
|
+
ue as Outline,
|
|
337
|
+
ie as Pixelation,
|
|
338
|
+
ce as Vignette
|
|
326
339
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/post-processing
|
|
3
|
-
* version: v0.
|
|
3
|
+
* version: v0.7.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(s,
|
|
8
|
+
(function(s,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("vue"),require("postprocessing"),require("@tresjs/core"),require("three")):typeof define=="function"&&define.amd?define(["exports","vue","postprocessing","@tresjs/core","three"],u):(s=typeof globalThis<"u"?globalThis:s||self,u(s["tres-postprocessing"]={},s.Vue,s.Postprocessing,s.TresjsCore,s.Three))})(this,function(s,u,r,m,g){"use strict";const B=Symbol(),h=o=>{const n=u.inject(B),e=u.shallowRef(null),t=u.shallowRef(null),{scene:l,camera:a}=m.useTresContext();u.watchEffect(()=>{!a.value||!(t!=null&&t.value)||(t.value.mainCamera=a.value)});let i=()=>{};return i=u.watchEffect(()=>{!a.value||!(n!=null&&n.value)||!l.value||(i(),!t.value&&(t.value=o(),e.value=new r.EffectPass(a.value,t.value),n.value.addPass(e.value)))}),u.onUnmounted(()=>{var c,d,v;e.value&&((c=n==null?void 0:n.value)==null||c.removePass(e.value)),(d=t.value)==null||d.dispose(),(v=e.value)==null||v.dispose()}),{pass:e,effect:t}},y=/([^[.\]])+/g,T=(o,n)=>{if(!n)return;const e=Array.isArray(n)?n:n.match(y);return e==null?void 0:e.reduce((t,l)=>t&&t[l],o)},x=(o,n,e)=>{const t=Array.isArray(n)?n:n.match(y);t&&t.reduce((l,a,i)=>(l[a]===void 0&&(l[a]={}),i===t.length-1&&(l[a]=e),l[a]),o)},w=(o,n)=>{const e={...o};return n.forEach(t=>delete e[t]),e},F=(o,n,e,t,l={})=>u.watch(o,a=>{var i;if(n.value)if(a===void 0){const c=t();x(n.value,e,T(c,e)),(i=c.dispose)==null||i.call(c)}else x(n.value,e,o())},l),b=(o,n,e)=>o.map(([t,l])=>F(t,n,l,e)),E=(o,n,e)=>Object.keys(o).map(t=>F(()=>o[t],n,t,e)),R=u.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 r.BloomEffect(e));return n({pass:t,effect:l}),b([[()=>e.intensity,"intensity"],[()=>e.kernelSize,"kernelSize"],[()=>e.luminanceSmoothing,"luminanceMaterial.smoothing"],[()=>e.luminanceThreshold,"luminanceMaterial.threshold"]],l,()=>new r.BloomEffect),(a,i)=>null}}),O=u.defineComponent({__name:"DepthOfField",props:{blendFunction:{},worldFocusDistance:{},worldFocusRange:{},focusDistance:{},focusRange:{},bokehScale:{},resolutionScale:{},resolutionX:{},resolutionY:{}},setup(o,{expose:n}){const e=o,{camera:t}=m.useTresContext(),{pass:l,effect:a}=h(()=>new r.DepthOfFieldEffect(t.value,e));return n({pass:l,effect:a}),b([[()=>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"]],a,()=>new r.DepthOfFieldEffect),(i,c)=>null}});let _;function P(){var o;if(_!==void 0)return _;try{let n;const e=document.createElement("canvas");return _=!!(window.WebGL2RenderingContext&&(n=e.getContext("webgl2"))),n&&((o=n.getExtension("WEBGL_lose_context"))==null||o.loseContext()),_}catch{return _=!1}}const z=u.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:g.HalfFloatType}},setup(o){const n=o,{scene:e,camera:t,renderer:l,sizes:a}=m.useTresContext(),i=u.shallowRef(null);let c=null,d=null;u.provide(B,i);const v=()=>{i.value&&(d=new r.NormalPass(e.value,t.value),d.enabled=!1,i.value.addPass(d),n.resolutionScale!==void 0&&P()&&(c=new r.DepthDownsamplingPass({normalBuffer:d.texture,resolutionScale:n.resolutionScale}),c.enabled=!1,i.value.addPass(c)))},p=u.computed(()=>{const f=new r.EffectComposer,C={depthBuffer:n.depthBuffer!==void 0?n.depthBuffer:f.inputBuffer.depthBuffer,stencilBuffer:n.stencilBuffer!==void 0?n.stencilBuffer:f.inputBuffer.stencilBuffer,multisampling:P()?0:n.multisampling!==void 0?n.multisampling:f.multisampling,frameBufferType:n.frameBufferType!==void 0?n.frameBufferType:g.HalfFloatType};return f.dispose(),C}),S=()=>{!l.value&&!e.value&&!t.value||(i.value=new r.EffectComposer(l.value,p.value),i.value.addPass(new r.RenderPass(e.value,t.value)),n.disableNormalPass||v())};u.watch([l,e,t,()=>n.disableNormalPass],()=>{!a.width.value||!a.height.value||S()}),u.watch(()=>[a.width.value,a.height.value],([f,C])=>{!f&&!C||(i.value?i.value.setSize(f,C):S())},{immediate:!0});const{onLoop:j}=m.useRenderLoop();return j(({delta:f})=>{if(n.enabled&&l.value&&i.value&&a.width.value&&a.height.value){const C=l.value.autoClear;l.value.autoClear=n.autoClear,n.stencilBuffer&&!n.autoClear&&l.value.clearStencil(),i.value.render(f),l.value.autoClear=C}}),u.onUnmounted(()=>{var f;(f=i.value)==null||f.dispose()}),(f,C)=>u.renderSlot(f.$slots,"default")}}),D=u.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 r.GlitchEffect(e));return n({pass:t,effect:l}),u.watchEffect(()=>{const a=()=>{if(e.mode!==void 0)return e.active===!1?r.GlitchMode.DISABLED:e.mode;const i=new r.GlitchEffect,c=i.mode;return i.dispose(),c};l.value&&(l.value.mode=a())}),E(w(e,["active","mode","blendFunction"]),l,()=>new r.GlitchEffect),(a,i)=>null}}),k=u.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=p=>p!==void 0?m.normalizeColor(p).getHex():void 0,{camera:l,scene:a}=m.useTresContext(),i={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:c,effect:d}=h(()=>new r.OutlineEffect(a.value,l.value,i));n({pass:c,effect:d}),u.watch([()=>e.outlinedObjects,d],()=>{var p;(p=d.value)==null||p.selection.set(e.outlinedObjects||[])},{immediate:!0});const v=u.computed(()=>({hiddenEdgeColor:e.hiddenEdgeColor?m.normalizeColor(e.hiddenEdgeColor):void 0,visibleEdgeColor:e.visibleEdgeColor?m.normalizeColor(e.visibleEdgeColor):void 0}));return b([[()=>e.blur,"blur"],[()=>e.xRay,"xRay"],[()=>e.pulseSpeed,"pulseSpeed"],[()=>e.kernelSize,"kernelSize"],[()=>e.edgeStrength,"edgeStrength"],[()=>e.patternScale,"patternScale"],[()=>e.multisampling,"multisampling"],[()=>v.value.hiddenEdgeColor,"hiddenEdgeColor"],[()=>v.value.visibleEdgeColor,"visibleEdgeColor"]],d,()=>new r.OutlineEffect),(p,S)=>null}}),A=u.defineComponent({__name:"Pixelation",props:{granularity:{}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=h(()=>new r.PixelationEffect(e.granularity));return n({pass:t,effect:l}),E(e,l,()=>new r.PixelationEffect),(a,i)=>null}}),M=u.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}=h(()=>new r.VignetteEffect(e));return n({pass:t,effect:l}),E(w(e,["blendFunction"]),l,()=>new r.VignetteEffect),(a,i)=>null}}),N=u.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}=h(()=>new r.NoiseEffect(e));return n({pass:t,effect:l}),E(w(e,["blendFunction"]),l,()=>new r.NoiseEffect),(a,i)=>null}});s.Bloom=R,s.DepthOfField=O,s.EffectComposer=z,s.Glitch=D,s.Noise=N,s.Outline=k,s.Pixelation=A,s.Vignette=M,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tresjs/post-processing",
|
|
3
|
-
"description": "Post-processing library for TresJS",
|
|
4
|
-
"version": "0.6.0-next.0",
|
|
5
3
|
"type": "module",
|
|
4
|
+
"version": "0.7.0",
|
|
5
|
+
"packageManager": "pnpm@8.10.2",
|
|
6
|
+
"description": "Post-processing library for TresJS",
|
|
6
7
|
"author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist",
|
|
9
|
-
"*.d.ts"
|
|
10
|
-
],
|
|
11
8
|
"license": "MIT",
|
|
12
|
-
"
|
|
13
|
-
|
|
9
|
+
"keywords": [
|
|
10
|
+
"vue",
|
|
11
|
+
"3d",
|
|
12
|
+
"threejs",
|
|
13
|
+
"three",
|
|
14
|
+
"post-processing",
|
|
15
|
+
"effects",
|
|
16
|
+
"fx"
|
|
17
|
+
],
|
|
14
18
|
"exports": {
|
|
15
19
|
".": {
|
|
16
20
|
"types": "./dist/index.d.ts",
|
|
@@ -18,20 +22,17 @@
|
|
|
18
22
|
},
|
|
19
23
|
"./*": "./*"
|
|
20
24
|
},
|
|
25
|
+
"main": "./dist/tres-postprocessing.js",
|
|
26
|
+
"module": "./dist/tres-postprocessing.js",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"*.d.ts"
|
|
30
|
+
],
|
|
21
31
|
"publishConfig": {
|
|
22
32
|
"access": "public"
|
|
23
33
|
},
|
|
24
|
-
"keywords": [
|
|
25
|
-
"vue",
|
|
26
|
-
"3d",
|
|
27
|
-
"threejs",
|
|
28
|
-
"three",
|
|
29
|
-
"post-processing",
|
|
30
|
-
"effects",
|
|
31
|
-
"fx"
|
|
32
|
-
],
|
|
33
34
|
"scripts": {
|
|
34
|
-
"dev": "
|
|
35
|
+
"dev": "cd playground && npm run dev",
|
|
35
36
|
"playground": "cd playground && npm run dev",
|
|
36
37
|
"build": "vite build",
|
|
37
38
|
"preview": "vite preview",
|
|
@@ -47,33 +48,33 @@
|
|
|
47
48
|
"vue": ">=3.3"
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
50
|
-
"@tresjs/core": "^3.
|
|
51
|
-
"@unocss/core": "^0.57.
|
|
52
|
-
"@vueuse/core": "^10.
|
|
53
|
-
"postprocessing": "^6.33.
|
|
54
|
-
"three-stdlib": "^2.28.
|
|
51
|
+
"@tresjs/core": "^3.5.0",
|
|
52
|
+
"@unocss/core": "^0.57.3",
|
|
53
|
+
"@vueuse/core": "^10.6.1",
|
|
54
|
+
"postprocessing": "^6.33.3",
|
|
55
|
+
"three-stdlib": "^2.28.5"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
|
-
"@release-it/conventional-changelog": "^
|
|
58
|
+
"@release-it/conventional-changelog": "^8.0.1",
|
|
58
59
|
"@tresjs/eslint-config-vue": "^0.2.1",
|
|
59
|
-
"@types/three": "^0.
|
|
60
|
-
"@vitejs/plugin-vue": "^4.4.
|
|
60
|
+
"@types/three": "^0.158.2",
|
|
61
|
+
"@vitejs/plugin-vue": "^4.4.1",
|
|
61
62
|
"gsap": "^3.12.2",
|
|
62
63
|
"kolorist": "^1.8.0",
|
|
63
64
|
"pathe": "^1.1.1",
|
|
64
|
-
"prettier": "^3.0
|
|
65
|
-
"release-it": "^
|
|
65
|
+
"prettier": "^3.1.0",
|
|
66
|
+
"release-it": "^17.0.0",
|
|
66
67
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
67
68
|
"rollup-plugin-visualizer": "^5.9.2",
|
|
68
69
|
"three": "^0.158.0",
|
|
69
70
|
"typescript": "^5.2.2",
|
|
70
|
-
"unocss": "^0.57.
|
|
71
|
+
"unocss": "^0.57.3",
|
|
71
72
|
"vite": "^4.5.0",
|
|
72
73
|
"vite-plugin-banner": "^0.7.1",
|
|
73
|
-
"vite-plugin-dts": "3.6.
|
|
74
|
+
"vite-plugin-dts": "3.6.3",
|
|
74
75
|
"vite-svg-loader": "^4.0.0",
|
|
75
|
-
"vitepress": "1.0.0-rc.
|
|
76
|
-
"vue": "^3.3.
|
|
76
|
+
"vitepress": "1.0.0-rc.25",
|
|
77
|
+
"vue": "^3.3.8",
|
|
77
78
|
"vue-tsc": "^1.8.22"
|
|
78
79
|
}
|
|
79
80
|
}
|