@tresjs/post-processing 0.2.0 → 0.3.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/EffectComposer.vue.d.ts +3 -3
- package/dist/core/effects/Outline.vue.d.ts +163 -0
- package/dist/core/injectionKeys.d.ts +3 -0
- package/dist/index.d.ts +1 -1
- package/dist/tres-postprocessing.js +252 -267
- package/dist/tres-postprocessing.umd.cjs +2 -2
- package/package.json +21 -21
- package/dist/core/effects/Outline.d.ts +0 -134
|
@@ -5,7 +5,7 @@ export type EffectComposerProps = {
|
|
|
5
5
|
enabled?: boolean;
|
|
6
6
|
children?: TresObject[];
|
|
7
7
|
depthBuffer?: boolean;
|
|
8
|
-
|
|
8
|
+
disableNormalPass?: boolean;
|
|
9
9
|
stencilBuffer?: boolean;
|
|
10
10
|
resolutionScale?: number;
|
|
11
11
|
autoClear?: boolean;
|
|
@@ -27,7 +27,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
27
27
|
type: __PropType<boolean | undefined>;
|
|
28
28
|
required: false;
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
disableNormalPass: {
|
|
31
31
|
type: __PropType<boolean | undefined>;
|
|
32
32
|
required: false;
|
|
33
33
|
};
|
|
@@ -72,7 +72,7 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
72
72
|
type: __PropType<boolean | undefined>;
|
|
73
73
|
required: false;
|
|
74
74
|
};
|
|
75
|
-
|
|
75
|
+
disableNormalPass: {
|
|
76
76
|
type: __PropType<boolean | undefined>;
|
|
77
77
|
required: false;
|
|
78
78
|
};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { PropType as __PropType } from 'vue';
|
|
2
|
+
import type { TresColor } from '@tresjs/core';
|
|
3
|
+
import type { Object3D, Texture } from 'three';
|
|
4
|
+
import type { BlendFunction, KernelSize } from 'postprocessing';
|
|
5
|
+
export type OutlineProps = {
|
|
6
|
+
/**
|
|
7
|
+
* The objects in the scene which should have an outline.
|
|
8
|
+
*/
|
|
9
|
+
outlinedObjects: Object3D[];
|
|
10
|
+
blur?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether occluded parts of selected objects should be visible
|
|
13
|
+
*/
|
|
14
|
+
xRay?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The blur kernel size. Must be used with blur being true.
|
|
17
|
+
*/
|
|
18
|
+
kernelSize?: KernelSize;
|
|
19
|
+
/**
|
|
20
|
+
* The pulse speed. A value of zero disables the pulse effect.
|
|
21
|
+
*/
|
|
22
|
+
pulseSpeed?: number;
|
|
23
|
+
resolutionX?: number;
|
|
24
|
+
resolutionY?: number;
|
|
25
|
+
edgeStrength?: number;
|
|
26
|
+
patternScale?: number;
|
|
27
|
+
/**
|
|
28
|
+
* The number of samples used for multisample antialiasing. Requires WebGL 2.
|
|
29
|
+
*/
|
|
30
|
+
multisampling?: number;
|
|
31
|
+
/**
|
|
32
|
+
* The blend function. Use `BlendFunction.ALPHA` for dark outlines.
|
|
33
|
+
*/
|
|
34
|
+
blendFunction?: BlendFunction;
|
|
35
|
+
patternTexture?: Texture;
|
|
36
|
+
resolutionScale?: number;
|
|
37
|
+
hiddenEdgeColor?: TresColor;
|
|
38
|
+
visibleEdgeColor?: TresColor;
|
|
39
|
+
};
|
|
40
|
+
declare const _sfc_main: import("vue").DefineComponent<{
|
|
41
|
+
outlinedObjects: {
|
|
42
|
+
type: __PropType<Object3D<import("three").Event>[]>;
|
|
43
|
+
required: true;
|
|
44
|
+
};
|
|
45
|
+
blur: {
|
|
46
|
+
type: __PropType<boolean | undefined>;
|
|
47
|
+
required: false;
|
|
48
|
+
};
|
|
49
|
+
xRay: {
|
|
50
|
+
type: __PropType<boolean | undefined>;
|
|
51
|
+
required: false;
|
|
52
|
+
};
|
|
53
|
+
kernelSize: {
|
|
54
|
+
type: __PropType<KernelSize | undefined>;
|
|
55
|
+
required: false;
|
|
56
|
+
};
|
|
57
|
+
pulseSpeed: {
|
|
58
|
+
type: __PropType<number | undefined>;
|
|
59
|
+
required: false;
|
|
60
|
+
};
|
|
61
|
+
resolutionX: {
|
|
62
|
+
type: __PropType<number | undefined>;
|
|
63
|
+
required: false;
|
|
64
|
+
};
|
|
65
|
+
resolutionY: {
|
|
66
|
+
type: __PropType<number | undefined>;
|
|
67
|
+
required: false;
|
|
68
|
+
};
|
|
69
|
+
edgeStrength: {
|
|
70
|
+
type: __PropType<number | undefined>;
|
|
71
|
+
required: false;
|
|
72
|
+
};
|
|
73
|
+
patternScale: {
|
|
74
|
+
type: __PropType<number | undefined>;
|
|
75
|
+
required: false;
|
|
76
|
+
};
|
|
77
|
+
multisampling: {
|
|
78
|
+
type: __PropType<number | undefined>;
|
|
79
|
+
required: false;
|
|
80
|
+
};
|
|
81
|
+
blendFunction: {
|
|
82
|
+
type: __PropType<BlendFunction | undefined>;
|
|
83
|
+
required: false;
|
|
84
|
+
};
|
|
85
|
+
patternTexture: {
|
|
86
|
+
type: __PropType<Texture | undefined>;
|
|
87
|
+
required: false;
|
|
88
|
+
};
|
|
89
|
+
resolutionScale: {
|
|
90
|
+
type: __PropType<number | undefined>;
|
|
91
|
+
required: false;
|
|
92
|
+
};
|
|
93
|
+
hiddenEdgeColor: {
|
|
94
|
+
type: __PropType<[r: number, g: number, b: number] | import("three").ColorRepresentation | undefined>;
|
|
95
|
+
required: false;
|
|
96
|
+
};
|
|
97
|
+
visibleEdgeColor: {
|
|
98
|
+
type: __PropType<[r: number, g: number, b: number] | import("three").ColorRepresentation | undefined>;
|
|
99
|
+
required: false;
|
|
100
|
+
};
|
|
101
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
102
|
+
outlinedObjects: {
|
|
103
|
+
type: __PropType<Object3D<import("three").Event>[]>;
|
|
104
|
+
required: true;
|
|
105
|
+
};
|
|
106
|
+
blur: {
|
|
107
|
+
type: __PropType<boolean | undefined>;
|
|
108
|
+
required: false;
|
|
109
|
+
};
|
|
110
|
+
xRay: {
|
|
111
|
+
type: __PropType<boolean | undefined>;
|
|
112
|
+
required: false;
|
|
113
|
+
};
|
|
114
|
+
kernelSize: {
|
|
115
|
+
type: __PropType<KernelSize | undefined>;
|
|
116
|
+
required: false;
|
|
117
|
+
};
|
|
118
|
+
pulseSpeed: {
|
|
119
|
+
type: __PropType<number | undefined>;
|
|
120
|
+
required: false;
|
|
121
|
+
};
|
|
122
|
+
resolutionX: {
|
|
123
|
+
type: __PropType<number | undefined>;
|
|
124
|
+
required: false;
|
|
125
|
+
};
|
|
126
|
+
resolutionY: {
|
|
127
|
+
type: __PropType<number | undefined>;
|
|
128
|
+
required: false;
|
|
129
|
+
};
|
|
130
|
+
edgeStrength: {
|
|
131
|
+
type: __PropType<number | undefined>;
|
|
132
|
+
required: false;
|
|
133
|
+
};
|
|
134
|
+
patternScale: {
|
|
135
|
+
type: __PropType<number | undefined>;
|
|
136
|
+
required: false;
|
|
137
|
+
};
|
|
138
|
+
multisampling: {
|
|
139
|
+
type: __PropType<number | undefined>;
|
|
140
|
+
required: false;
|
|
141
|
+
};
|
|
142
|
+
blendFunction: {
|
|
143
|
+
type: __PropType<BlendFunction | undefined>;
|
|
144
|
+
required: false;
|
|
145
|
+
};
|
|
146
|
+
patternTexture: {
|
|
147
|
+
type: __PropType<Texture | undefined>;
|
|
148
|
+
required: false;
|
|
149
|
+
};
|
|
150
|
+
resolutionScale: {
|
|
151
|
+
type: __PropType<number | undefined>;
|
|
152
|
+
required: false;
|
|
153
|
+
};
|
|
154
|
+
hiddenEdgeColor: {
|
|
155
|
+
type: __PropType<[r: number, g: number, b: number] | import("three").ColorRepresentation | undefined>;
|
|
156
|
+
required: false;
|
|
157
|
+
};
|
|
158
|
+
visibleEdgeColor: {
|
|
159
|
+
type: __PropType<[r: number, g: number, b: number] | import("three").ColorRepresentation | undefined>;
|
|
160
|
+
required: false;
|
|
161
|
+
};
|
|
162
|
+
}>>, {}, {}>;
|
|
163
|
+
export default _sfc_main;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import EffectComposer from './core/EffectComposer.vue';
|
|
2
2
|
import Bloom from './core/effects/Bloom.vue';
|
|
3
3
|
import Glitch from './core/effects/Glitch.vue';
|
|
4
|
-
import
|
|
4
|
+
import Outline from './core/effects/Outline.vue';
|
|
5
5
|
export { EffectComposer, Bloom, Glitch, Outline };
|
|
@@ -1,122 +1,154 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/post-processing
|
|
3
|
-
* version: v0.
|
|
3
|
+
* version: v0.3.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 { HalfFloatType as ee
|
|
10
|
-
import { useTres as te, useRenderLoop as ne } from "@tresjs/core";
|
|
11
|
-
import { EffectComposer as ae, RenderPass as le, NormalPass as
|
|
12
|
-
function
|
|
13
|
-
const { state: e, setState:
|
|
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") || (() => {
|
|
14
14
|
});
|
|
15
15
|
return {
|
|
16
16
|
state: e,
|
|
17
|
-
setState:
|
|
18
|
-
extend:
|
|
17
|
+
setState: a,
|
|
18
|
+
extend: n
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
let
|
|
21
|
+
let w;
|
|
22
22
|
function se() {
|
|
23
23
|
var e;
|
|
24
|
-
if (
|
|
25
|
-
return
|
|
24
|
+
if (w !== void 0)
|
|
25
|
+
return w;
|
|
26
26
|
try {
|
|
27
|
-
let
|
|
28
|
-
const
|
|
29
|
-
return
|
|
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
30
|
} catch {
|
|
31
|
-
return
|
|
31
|
+
return w = !1;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
return
|
|
34
|
+
function N(e) {
|
|
35
|
+
return J() ? (Q(e), !0) : !1;
|
|
36
36
|
}
|
|
37
37
|
function H(e) {
|
|
38
|
-
return typeof e == "function" ? e() :
|
|
38
|
+
return typeof e == "function" ? e() : D(e);
|
|
39
39
|
}
|
|
40
|
-
const ce = typeof window < "u",
|
|
40
|
+
const ce = typeof window < "u", de = () => {
|
|
41
41
|
};
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
return V(...e);
|
|
45
|
-
const n = e[0];
|
|
46
|
-
return typeof n == "function" ? J(K(() => ({ get: n, set: I }))) : h(n);
|
|
42
|
+
function fe(e, a = !0) {
|
|
43
|
+
k() ? I(e) : a ? e() : q(e);
|
|
47
44
|
}
|
|
48
|
-
function
|
|
49
|
-
|
|
45
|
+
function E(e) {
|
|
46
|
+
var a;
|
|
47
|
+
const n = H(e);
|
|
48
|
+
return (a = n == null ? void 0 : n.$el) != null ? a : n;
|
|
50
49
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}, c = (r, u, d, m) => (r.addEventListener(u, d, m), () => r.removeEventListener(u, d, m)), f = y(
|
|
65
|
-
() => [me(n), H(t)],
|
|
66
|
-
([r, u]) => {
|
|
67
|
-
s(), r && o.push(
|
|
68
|
-
...l.flatMap((d) => a.map((m) => c(r, d, m, u)))
|
|
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)))
|
|
69
63
|
);
|
|
70
64
|
},
|
|
71
65
|
{ immediate: !0, flush: "post" }
|
|
72
|
-
),
|
|
73
|
-
|
|
66
|
+
), u = () => {
|
|
67
|
+
v(), c();
|
|
74
68
|
};
|
|
75
|
-
return
|
|
69
|
+
return N(u), u;
|
|
76
70
|
}
|
|
77
|
-
function
|
|
78
|
-
const e =
|
|
79
|
-
return
|
|
71
|
+
function ve() {
|
|
72
|
+
const e = b(!1);
|
|
73
|
+
return k() && I(() => {
|
|
80
74
|
e.value = !0;
|
|
81
75
|
}), e;
|
|
82
76
|
}
|
|
83
|
-
function
|
|
84
|
-
const
|
|
85
|
-
return
|
|
77
|
+
function me(e) {
|
|
78
|
+
const a = ve();
|
|
79
|
+
return y(() => (a.value, !!e()));
|
|
86
80
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
|
94
113
|
};
|
|
95
|
-
return S(c), k(() => s()), o;
|
|
96
114
|
}
|
|
97
|
-
function
|
|
115
|
+
function pe(e, a = {}) {
|
|
98
116
|
const {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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;
|
|
110
130
|
}
|
|
111
|
-
return {
|
|
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();
|
|
133
|
+
}), {
|
|
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
|
|
143
|
+
};
|
|
112
144
|
}
|
|
113
|
-
const Ee = /* @__PURE__ */
|
|
145
|
+
const z = Symbol(), Ee = /* @__PURE__ */ O({
|
|
114
146
|
__name: "EffectComposer",
|
|
115
147
|
props: {
|
|
116
148
|
enabled: { type: Boolean, default: !0 },
|
|
117
149
|
children: {},
|
|
118
150
|
depthBuffer: { type: Boolean },
|
|
119
|
-
|
|
151
|
+
disableNormalPass: { type: Boolean, default: !1 },
|
|
120
152
|
stencilBuffer: { type: Boolean },
|
|
121
153
|
resolutionScale: {},
|
|
122
154
|
autoClear: { type: Boolean, default: !0 },
|
|
@@ -126,36 +158,39 @@ const Ee = /* @__PURE__ */ B({
|
|
|
126
158
|
camera: {}
|
|
127
159
|
},
|
|
128
160
|
setup(e) {
|
|
129
|
-
const { state:
|
|
130
|
-
let
|
|
131
|
-
const
|
|
132
|
-
Z(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
normalBuffer: s.texture,
|
|
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,
|
|
137
168
|
resolutionScale: e.resolutionScale
|
|
138
|
-
}),
|
|
169
|
+
}), r.enabled = !1, n.value.addPass(r)));
|
|
139
170
|
}
|
|
140
|
-
|
|
141
|
-
|
|
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, {
|
|
142
179
|
depthBuffer: e.depthBuffer,
|
|
143
180
|
stencilBuffer: e.stencilBuffer,
|
|
144
|
-
multisampling: e.multisampling > 0 &&
|
|
181
|
+
multisampling: e.multisampling > 0 && f ? e.multisampling : 0,
|
|
145
182
|
frameBufferType: e.frameBufferType
|
|
146
|
-
}),
|
|
183
|
+
}), n.value.addPass(new le(t.value, l.value)), e.disableNormalPass || v());
|
|
147
184
|
});
|
|
148
|
-
const { onLoop:
|
|
149
|
-
return
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const m = n.renderer.autoClear;
|
|
154
|
-
n.renderer.autoClear = e.autoClear, e.stencilBuffer && !e.autoClear && n.renderer.clearStencil(), l.value.render(d), n.renderer.autoClear = m;
|
|
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;
|
|
155
190
|
}
|
|
156
191
|
}), (d, m) => _(d.$slots, "default");
|
|
157
192
|
}
|
|
158
|
-
}),
|
|
193
|
+
}), Be = /* @__PURE__ */ O({
|
|
159
194
|
__name: "Bloom",
|
|
160
195
|
props: {
|
|
161
196
|
blendFunction: { default: () => W.ADD },
|
|
@@ -168,40 +203,40 @@ const Ee = /* @__PURE__ */ B({
|
|
|
168
203
|
luminanceSmoothing: { default: 0.025 },
|
|
169
204
|
mipmapBlur: { type: Boolean, default: !1 }
|
|
170
205
|
},
|
|
171
|
-
setup(e, { expose:
|
|
172
|
-
const { state:
|
|
173
|
-
|
|
174
|
-
function
|
|
175
|
-
|
|
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({
|
|
176
211
|
blendFunction: e.blendFunction,
|
|
177
212
|
mipmapBlur: e.mipmapBlur,
|
|
178
213
|
intensity: e.intensity,
|
|
179
214
|
luminanceThreshold: e.luminanceThreshold,
|
|
180
215
|
luminanceSmoothing: e.luminanceSmoothing
|
|
181
|
-
}),
|
|
216
|
+
}), l.value = new L(D(n.camera), S(r.value));
|
|
182
217
|
}
|
|
183
|
-
function
|
|
184
|
-
var
|
|
185
|
-
(
|
|
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));
|
|
186
221
|
}
|
|
187
|
-
const
|
|
188
|
-
() => [
|
|
222
|
+
const v = p(
|
|
223
|
+
() => [n.camera, t == null ? void 0 : t.value],
|
|
189
224
|
() => {
|
|
190
|
-
var
|
|
191
|
-
|
|
225
|
+
var i;
|
|
226
|
+
n.camera && t && t.value && (c(), (i = t == null ? void 0 : t.value) == null || i.addPass(S(l.value)));
|
|
192
227
|
}
|
|
193
|
-
),
|
|
228
|
+
), u = p(
|
|
194
229
|
() => [e.blendFunction, e.mipmapBlur, e.intensity, e.luminanceThreshold, e.luminanceSmoothing],
|
|
195
230
|
() => {
|
|
196
|
-
var
|
|
197
|
-
|
|
231
|
+
var i;
|
|
232
|
+
l.value && (f(), c(), (i = t == null ? void 0 : t.value) == null || i.addPass(S(l.value)));
|
|
198
233
|
}
|
|
199
234
|
);
|
|
200
|
-
return
|
|
201
|
-
|
|
202
|
-
}), (
|
|
235
|
+
return F(() => {
|
|
236
|
+
f(), v(), u();
|
|
237
|
+
}), (i, o) => null;
|
|
203
238
|
}
|
|
204
|
-
}),
|
|
239
|
+
}), xe = /* @__PURE__ */ O({
|
|
205
240
|
__name: "Glitch",
|
|
206
241
|
props: {
|
|
207
242
|
blendFunction: { default: () => W.ADD },
|
|
@@ -216,11 +251,11 @@ const Ee = /* @__PURE__ */ B({
|
|
|
216
251
|
peturbationMap: {},
|
|
217
252
|
dtSize: { default: 64 }
|
|
218
253
|
},
|
|
219
|
-
setup(e, { expose:
|
|
220
|
-
const { state:
|
|
221
|
-
|
|
222
|
-
function
|
|
223
|
-
|
|
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({
|
|
224
259
|
blendFunction: e.blendFunction,
|
|
225
260
|
delay: e.delay,
|
|
226
261
|
duration: e.duration,
|
|
@@ -229,179 +264,129 @@ const Ee = /* @__PURE__ */ B({
|
|
|
229
264
|
columns: e.columns,
|
|
230
265
|
chromaticAberrationOffset: e.chromaticAberrationOffset,
|
|
231
266
|
dtSize: e.dtSize
|
|
232
|
-
}),
|
|
267
|
+
}), l.value = new L(D(n.camera), S(r.value));
|
|
233
268
|
}
|
|
234
|
-
function
|
|
235
|
-
var
|
|
236
|
-
(
|
|
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));
|
|
237
272
|
}
|
|
238
|
-
const
|
|
239
|
-
() => [
|
|
273
|
+
const v = p(
|
|
274
|
+
() => [n.camera, t == null ? void 0 : t.value],
|
|
240
275
|
() => {
|
|
241
|
-
var
|
|
242
|
-
|
|
276
|
+
var o;
|
|
277
|
+
n.camera && t && t.value && (c(), (o = t == null ? void 0 : t.value) == null || o.addPass(S(l.value)));
|
|
243
278
|
}
|
|
244
|
-
),
|
|
279
|
+
), u = p(
|
|
245
280
|
() => [e.delay, e.duration, e.strength, e.ratio, e.columns, e.chromaticAberrationOffset, e.peturbationMap, e.dtSize],
|
|
246
281
|
() => {
|
|
247
|
-
var
|
|
248
|
-
|
|
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)));
|
|
249
284
|
}
|
|
250
285
|
);
|
|
251
|
-
|
|
252
|
-
|
|
286
|
+
P(() => {
|
|
287
|
+
l.value && (l.value.mode = e.active ? e.mode || j.SPORADIC : j.DISABLED);
|
|
253
288
|
});
|
|
254
|
-
const
|
|
289
|
+
const i = p(
|
|
255
290
|
() => e.active,
|
|
256
|
-
(
|
|
257
|
-
|
|
291
|
+
(o) => {
|
|
292
|
+
l.value && (l.value.enabled = o);
|
|
258
293
|
}
|
|
259
294
|
);
|
|
260
|
-
return
|
|
261
|
-
|
|
262
|
-
}), (
|
|
295
|
+
return F(() => {
|
|
296
|
+
f(), v(), u(), i();
|
|
297
|
+
}), (o, s) => null;
|
|
263
298
|
}
|
|
264
|
-
}),
|
|
265
|
-
|
|
299
|
+
}), Oe = /* @__PURE__ */ O({
|
|
300
|
+
__name: "Outline",
|
|
266
301
|
props: {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
},
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
blendFunction: {
|
|
278
|
-
|
|
279
|
-
},
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
},
|
|
283
|
-
patternScale: {
|
|
284
|
-
type: Number
|
|
285
|
-
},
|
|
286
|
-
edgeStrength: {
|
|
287
|
-
type: Number
|
|
288
|
-
},
|
|
289
|
-
/**
|
|
290
|
-
* The pulse speed. A value of zero disables the pulse effect.
|
|
291
|
-
*/
|
|
292
|
-
pulseSpeed: {
|
|
293
|
-
type: Number
|
|
294
|
-
},
|
|
295
|
-
visibleEdgeColor: {
|
|
296
|
-
type: [String, Number, Array]
|
|
297
|
-
},
|
|
298
|
-
hiddenEdgeColor: {
|
|
299
|
-
type: [String, Number, Array]
|
|
300
|
-
},
|
|
301
|
-
/**
|
|
302
|
-
* The number of samples used for multisample antialiasing. Requires WebGL 2.
|
|
303
|
-
*/
|
|
304
|
-
multisampling: {
|
|
305
|
-
type: Number
|
|
306
|
-
},
|
|
307
|
-
resolutionScale: {
|
|
308
|
-
type: Number
|
|
309
|
-
},
|
|
310
|
-
resolutionX: {
|
|
311
|
-
type: Number
|
|
312
|
-
},
|
|
313
|
-
resolutionY: {
|
|
314
|
-
type: Number
|
|
315
|
-
},
|
|
316
|
-
/**
|
|
317
|
-
* The blur kernel size.
|
|
318
|
-
*/
|
|
319
|
-
kernelSize: {
|
|
320
|
-
type: Number
|
|
321
|
-
},
|
|
322
|
-
blur: {
|
|
323
|
-
type: Boolean
|
|
324
|
-
},
|
|
325
|
-
/**
|
|
326
|
-
* Whether occluded parts of selected objects should be visible
|
|
327
|
-
*/
|
|
328
|
-
xRay: {
|
|
329
|
-
type: Boolean
|
|
330
|
-
}
|
|
302
|
+
outlinedObjects: {},
|
|
303
|
+
blur: { type: Boolean },
|
|
304
|
+
xRay: { type: Boolean },
|
|
305
|
+
kernelSize: {},
|
|
306
|
+
pulseSpeed: {},
|
|
307
|
+
resolutionX: {},
|
|
308
|
+
resolutionY: {},
|
|
309
|
+
edgeStrength: {},
|
|
310
|
+
patternScale: {},
|
|
311
|
+
multisampling: {},
|
|
312
|
+
blendFunction: {},
|
|
313
|
+
patternTexture: {},
|
|
314
|
+
resolutionScale: {},
|
|
315
|
+
hiddenEdgeColor: {},
|
|
316
|
+
visibleEdgeColor: {}
|
|
331
317
|
},
|
|
332
318
|
setup(e) {
|
|
333
|
-
const { state: n } =
|
|
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(() => {
|
|
334
320
|
const {
|
|
335
|
-
blur:
|
|
336
|
-
xRay:
|
|
337
|
-
kernelSize:
|
|
338
|
-
pulseSpeed:
|
|
339
|
-
resolutionX:
|
|
340
|
-
resolutionY:
|
|
341
|
-
patternScale:
|
|
342
|
-
edgeStrength:
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
patternTexture:
|
|
346
|
-
resolutionScale:
|
|
347
|
-
hiddenEdgeColor:
|
|
348
|
-
visibleEdgeColor:
|
|
349
|
-
} =
|
|
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;
|
|
350
336
|
return {
|
|
351
|
-
blur:
|
|
352
|
-
xRay:
|
|
353
|
-
kernelSize:
|
|
354
|
-
pulseSpeed:
|
|
355
|
-
resolutionX:
|
|
356
|
-
resolutionY:
|
|
357
|
-
patternScale:
|
|
358
|
-
edgeStrength:
|
|
359
|
-
blendFunction:
|
|
360
|
-
multisampling:
|
|
361
|
-
patternTexture:
|
|
362
|
-
resolutionScale:
|
|
363
|
-
hiddenEdgeColor:
|
|
364
|
-
visibleEdgeColor:
|
|
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)
|
|
365
351
|
};
|
|
366
|
-
}),
|
|
367
|
-
var
|
|
368
|
-
n.camera &&
|
|
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());
|
|
369
355
|
});
|
|
370
|
-
return
|
|
371
|
-
[() =>
|
|
356
|
+
return p(
|
|
357
|
+
[() => a.outlinedObjects, r],
|
|
372
358
|
// whatchEffect is intentionally not used here as it would result in an endless loop
|
|
373
359
|
() => {
|
|
374
|
-
var
|
|
375
|
-
(
|
|
360
|
+
var u;
|
|
361
|
+
(u = r.value) == null || u.selection.set(a.outlinedObjects || []);
|
|
376
362
|
},
|
|
377
363
|
{
|
|
378
364
|
immediate: !0
|
|
379
365
|
}
|
|
380
|
-
),
|
|
381
|
-
if (!
|
|
366
|
+
), P(() => {
|
|
367
|
+
if (!r.value)
|
|
382
368
|
return;
|
|
383
|
-
const
|
|
384
|
-
blur:
|
|
385
|
-
xRay:
|
|
386
|
-
kernelSize:
|
|
387
|
-
pulseSpeed:
|
|
388
|
-
patternScale:
|
|
389
|
-
edgeStrength:
|
|
390
|
-
multisampling:
|
|
391
|
-
hiddenEdgeColor:
|
|
392
|
-
visibleEdgeColor:
|
|
393
|
-
} =
|
|
394
|
-
|
|
395
|
-
}),
|
|
396
|
-
var
|
|
397
|
-
(
|
|
398
|
-
}), () =>
|
|
399
|
-
};
|
|
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;
|
|
400
385
|
}
|
|
401
386
|
});
|
|
402
387
|
export {
|
|
403
|
-
|
|
388
|
+
Be as Bloom,
|
|
404
389
|
Ee as EffectComposer,
|
|
405
|
-
|
|
406
|
-
|
|
390
|
+
xe as Glitch,
|
|
391
|
+
Oe as Outline
|
|
407
392
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/post-processing
|
|
3
|
-
* version: v0.
|
|
3
|
+
* version: v0.3.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(b,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue"),require("three"),require("@tresjs/core"),require("postprocessing")):typeof define=="function"&&define.amd?define(["exports","vue","three","@tresjs/core","postprocessing"],t):(b=typeof globalThis<"u"?globalThis:b||self,t(b["tres-postprocessing"]={},b.Vue,b.Three,b.TresjsCore,b.Postprocessing))})(this,function(b,t,j,g,v){"use strict";function P(){const{state:e,setState:l}=t.inject("useTres",g.useTres()),a=t.inject("extend")||(()=>{});return{state:e,setState:l,extend:a}}let C;function F(){var e;if(C!==void 0)return C;try{let l;const a=document.createElement("canvas");return C=!!(window.WebGL2RenderingContext&&(l=a.getContext("webgl2"))),l&&((e=l.getExtension("WEBGL_lose_context"))==null||e.loseContext()),C}catch{return C=!1}}function R(e){return t.getCurrentScope()?(t.onScopeDispose(e),!0):!1}function x(e){return typeof e=="function"?e():t.unref(e)}const M=typeof window<"u",D=()=>{};function L(e,l=!0){t.getCurrentInstance()?t.onMounted(e):l?e():t.nextTick(e)}function E(e){var l;const a=x(e);return(l=a==null?void 0:a.$el)!=null?l:a}const A=M?window:void 0;function z(...e){let l,a,n,o;if(typeof e[0]=="string"||Array.isArray(e[0])?([a,n,o]=e,l=A):[l,a,n,o]=e,!l)return D;Array.isArray(a)||(a=[a]),Array.isArray(n)||(n=[n]);const s=[],d=()=>{s.forEach(u=>u()),s.length=0},m=(u,r,c,f)=>(u.addEventListener(r,c,f),()=>u.removeEventListener(r,c,f)),h=t.watch(()=>[E(l),x(o)],([u,r])=>{d(),u&&s.push(...a.flatMap(c=>n.map(f=>m(u,c,f,r))))},{immediate:!0,flush:"post"}),i=()=>{h(),d()};return R(i),i}function G(){const e=t.ref(!1);return t.getCurrentInstance()&&t.onMounted(()=>{e.value=!0}),e}function $(e){const l=G();return t.computed(()=>(l.value,!!e()))}var T=Object.getOwnPropertySymbols,k=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable,W=(e,l)=>{var a={};for(var n in e)k.call(e,n)&&l.indexOf(n)<0&&(a[n]=e[n]);if(e!=null&&T)for(var n of T(e))l.indexOf(n)<0&&I.call(e,n)&&(a[n]=e[n]);return a};function N(e,l,a={}){const n=a,{window:o=A}=n,s=W(n,["window"]);let d;const m=$(()=>o&&"ResizeObserver"in o),h=()=>{d&&(d.disconnect(),d=void 0)},i=t.computed(()=>Array.isArray(e)?e.map(c=>E(c)):[E(e)]),u=t.watch(i,c=>{if(h(),m.value&&o){d=new ResizeObserver(l);for(const f of c)f&&d.observe(f,s)}},{immediate:!0,flush:"post",deep:!0}),r=()=>{h(),u()};return R(r),{isSupported:m,stop:r}}function q(e,l={}){const{reset:a=!0,windowResize:n=!0,windowScroll:o=!0,immediate:s=!0}=l,d=t.ref(0),m=t.ref(0),h=t.ref(0),i=t.ref(0),u=t.ref(0),r=t.ref(0),c=t.ref(0),f=t.ref(0);function w(){const S=E(e);if(!S){a&&(d.value=0,m.value=0,h.value=0,i.value=0,u.value=0,r.value=0,c.value=0,f.value=0);return}const y=S.getBoundingClientRect();d.value=y.height,m.value=y.bottom,h.value=y.left,i.value=y.right,u.value=y.top,r.value=y.width,c.value=y.x,f.value=y.y}return N(e,w),t.watch(()=>E(e),S=>!S&&w()),o&&z("scroll",w,{capture:!0,passive:!0}),n&&z("resize",w,{passive:!0}),L(()=>{s&&w()}),{height:d,bottom:m,left:h,right:i,top:u,width:r,x:c,y:f,update:w}}const p=Symbol(),U=t.defineComponent({__name:"EffectComposer",props:{enabled:{type:Boolean,default:!0},children:{},depthBuffer:{type:Boolean},disableNormalPass:{type:Boolean,default:!1},stencilBuffer:{type:Boolean},resolutionScale:{},autoClear:{type:Boolean,default:!0},multisampling:{default:8},frameBufferType:{default:()=>j.HalfFloatType},scene:{},camera:{}},setup(e){const{state:l}=P(),a=t.shallowRef(null),n=t.computed(()=>e.scene||l.scene),o=t.computed(()=>e.camera||l.camera);let s=null,d=null;const m=F();t.provide(p,a);function h(){a.value&&(d=new v.NormalPass(n.value,o.value),d.enabled=!1,a.value.addPass(d),e.resolutionScale!==void 0&&m&&(s=new v.DepthDownsamplingPass({normalBuffer:d.texture,resolutionScale:e.resolutionScale}),s.enabled=!1,a.value.addPass(s)))}const i=t.computed(()=>{var f;return(f=l.canvas)==null?void 0:f.value}),{width:u,height:r}=q(i);t.watchEffect(()=>{a.value&&u.value&&r.value&&a.value.setSize(u.value,r.value)}),t.watchEffect(()=>{l.renderer&&n.value&&o.value&&(a.value=new v.EffectComposer(l.renderer,{depthBuffer:e.depthBuffer,stencilBuffer:e.stencilBuffer,multisampling:e.multisampling>0&&m?e.multisampling:0,frameBufferType:e.frameBufferType}),a.value.addPass(new v.RenderPass(n.value,o.value)),e.disableNormalPass||h())});const{onLoop:c}=g.useRenderLoop();return c(({delta:f})=>{if(e.enabled&&l.renderer&&a.value&&u.value&&r.value){const w=l.renderer.autoClear;l.renderer.autoClear=e.autoClear,e.stencilBuffer&&!e.autoClear&&l.renderer.clearStencil(),a.value.render(f),l.renderer.autoClear=w}}),(f,w)=>t.renderSlot(f.$slots,"default")}}),H=t.defineComponent({__name:"Bloom",props:{blendFunction:{default:()=>v.BlendFunction.ADD},intensity:{default:1},blurPass:{},width:{},height:{},kernelSize:{},luminanceThreshold:{default:.9},luminanceSmoothing:{default:.025},mipmapBlur:{type:Boolean,default:!1}},setup(e,{expose:l}){const{state:a}=P(),n=t.inject(p),o=t.ref(null),s=t.ref(null);l({pass:o,effect:s});function d(){s.value=new v.BloomEffect({blendFunction:e.blendFunction,mipmapBlur:e.mipmapBlur,intensity:e.intensity,luminanceThreshold:e.luminanceThreshold,luminanceSmoothing:e.luminanceSmoothing}),o.value=new v.EffectPass(t.unref(a.camera),t.toRaw(s.value))}function m(){var u,r,c;(u=s.value)==null||u.dispose(),(r=o.value)==null||r.dispose(),(c=n==null?void 0:n.value)==null||c.removePass(t.toRaw(o.value))}const h=t.watch(()=>[a.camera,n==null?void 0:n.value],()=>{var u;a.camera&&n&&n.value&&(d(),(u=n==null?void 0:n.value)==null||u.addPass(t.toRaw(o.value)))}),i=t.watch(()=>[e.blendFunction,e.mipmapBlur,e.intensity,e.luminanceThreshold,e.luminanceSmoothing],()=>{var u;o.value&&(m(),d(),(u=n==null?void 0:n.value)==null||u.addPass(t.toRaw(o.value)))});return t.onUnmounted(()=>{m(),h(),i()}),(u,r)=>null}}),V=t.defineComponent({__name:"Glitch",props:{blendFunction:{default:()=>v.BlendFunction.ADD},delay:{},duration:{},strength:{},mode:{},active:{type:Boolean},ratio:{default:.85},columns:{default:.05},chromaticAberrationOffset:{},peturbationMap:{},dtSize:{default:64}},setup(e,{expose:l}){const{state:a}=P(),n=t.inject(p),o=t.ref(null),s=t.ref(null);l({pass:o});function d(){s.value=new v.GlitchEffect({blendFunction:e.blendFunction,delay:e.delay,duration:e.duration,strength:e.strength,ratio:e.ratio,columns:e.columns,chromaticAberrationOffset:e.chromaticAberrationOffset,dtSize:e.dtSize}),o.value=new v.EffectPass(t.unref(a.camera),t.toRaw(s.value))}function m(){var r,c,f;(r=s.value)==null||r.dispose(),(c=o.value)==null||c.dispose(),(f=n==null?void 0:n.value)==null||f.removePass(t.toRaw(o.value))}const h=t.watch(()=>[a.camera,n==null?void 0:n.value],()=>{var r;a.camera&&n&&n.value&&(d(),(r=n==null?void 0:n.value)==null||r.addPass(t.toRaw(o.value)))}),i=t.watch(()=>[e.delay,e.duration,e.strength,e.ratio,e.columns,e.chromaticAberrationOffset,e.peturbationMap,e.dtSize],()=>{var r,c;o.value&&((r=n==null?void 0:n.value)==null||r.removePass(t.toRaw(o.value)),d(),(c=n==null?void 0:n.value)==null||c.addPass(t.toRaw(o.value)))});t.watchEffect(()=>{o.value&&(o.value.mode=e.active?e.mode||v.GlitchMode.SPORADIC:v.GlitchMode.DISABLED)});const u=t.watch(()=>e.active,r=>{o.value&&(o.value.enabled=r)});return t.onUnmounted(()=>{m(),h(),i(),u()}),(r,c)=>null}}),X=t.defineComponent({__name:"Outline",props:{outlinedObjects:{},blur:{type:Boolean},xRay:{type:Boolean},kernelSize:{},pulseSpeed:{},resolutionX:{},resolutionY:{},edgeStrength:{},patternScale:{},multisampling:{},blendFunction:{},patternTexture:{},resolutionScale:{},hiddenEdgeColor:{},visibleEdgeColor:{}},setup(e){const l=e,{state:a}=P(),n=t.inject(p),o=t.shallowRef(null),s=t.shallowRef(null),d=i=>i!==void 0?g.normalizeColor(i).getHex():void 0,m=t.computed(()=>{const{blur:i,xRay:u,kernelSize:r,pulseSpeed:c,resolutionX:f,resolutionY:w,patternScale:S,edgeStrength:y,multisampling:B,blendFunction:O,patternTexture:Y,resolutionScale:K,hiddenEdgeColor:J,visibleEdgeColor:Q}=l;return{blur:i,xRay:u,kernelSize:r,pulseSpeed:c,resolutionX:f,resolutionY:w,patternScale:S,edgeStrength:y,blendFunction:O,multisampling:B,patternTexture:Y,resolutionScale:K,hiddenEdgeColor:d(J),visibleEdgeColor:d(Q)}}),h=t.watchEffect(()=>{var i;a.camera&&n&&n.value&&a.scene&&(s.value=new v.OutlineEffect(a.scene,a.camera,m.value),o.value=new v.EffectPass(a.camera,s.value),(i=n.value)==null||i.addPass(o.value),h())});return t.watch([()=>l.outlinedObjects,s],()=>{var i;(i=s.value)==null||i.selection.set(l.outlinedObjects||[])},{immediate:!0}),t.watchEffect(()=>{if(!s.value)return;const i=new v.OutlineEffect,{blur:u,xRay:r,kernelSize:c,pulseSpeed:f,patternScale:w,edgeStrength:S,multisampling:y,hiddenEdgeColor:B,visibleEdgeColor:O}=m.value;s.value.blur=u!==void 0?u:i.blur,s.value.xRay=r!==void 0?r:i.xRay,s.value.pulseSpeed=f!==void 0?f:i.pulseSpeed,s.value.kernelSize=c!==void 0?c:i.kernelSize,s.value.edgeStrength=S!==void 0?S:i.edgeStrength,s.value.patternScale=w!==void 0?w:i.patternScale,s.value.multisampling=y!==void 0?y:i.multisampling,s.value.hiddenEdgeColor=B!==void 0?g.normalizeColor(B):i.hiddenEdgeColor,s.value.visibleEdgeColor=O!==void 0?g.normalizeColor(O):i.visibleEdgeColor,i.dispose()}),t.onUnmounted(()=>{var i,u,r,c;(i=s.value)==null||i.selection.clear(),o.value&&((u=n==null?void 0:n.value)==null||u.removePass(o.value)),(r=s.value)==null||r.dispose(),(c=o.value)==null||c.dispose()}),(i,u)=>null}});b.Bloom=H,b.EffectComposer=U,b.Glitch=V,b.Outline=X,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tresjs/post-processing",
|
|
3
3
|
"description": "Post-processing library for TresJS",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
|
|
7
7
|
"files": [
|
|
@@ -42,38 +42,38 @@
|
|
|
42
42
|
"docs:preview": "vitepress preview docs"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@tresjs/core": "2.
|
|
46
|
-
"three": "
|
|
47
|
-
"vue": "
|
|
45
|
+
"@tresjs/core": ">=2.3.0",
|
|
46
|
+
"three": ">=0.133",
|
|
47
|
+
"vue": ">=3.3"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@vueuse/core": "^10.
|
|
51
|
-
"postprocessing": "^6.
|
|
52
|
-
"three": "^
|
|
53
|
-
"three-stdlib": "^2.23.4",
|
|
54
|
-
"vue": "^3.3.4"
|
|
50
|
+
"@vueuse/core": "^10.2.0",
|
|
51
|
+
"postprocessing": "^6.32.1",
|
|
52
|
+
"three-stdlib": "^2.23.10"
|
|
55
53
|
},
|
|
56
54
|
"devDependencies": {
|
|
57
55
|
"@alvarosabu/prettier-config": "^1.3.0",
|
|
58
56
|
"@release-it/conventional-changelog": "^5.1.1",
|
|
59
|
-
"@tresjs/cientos": "2.1.
|
|
60
|
-
"@tresjs/core": "2.
|
|
57
|
+
"@tresjs/cientos": "2.1.4",
|
|
58
|
+
"@tresjs/core": "2.3.0",
|
|
61
59
|
"@types/three": "^0.152.1",
|
|
62
|
-
"@vitejs/plugin-vue": "^4.
|
|
63
|
-
"gsap": "^3.
|
|
64
|
-
"kolorist": "^1.
|
|
65
|
-
"pathe": "^1.1.
|
|
60
|
+
"@vitejs/plugin-vue": "^4.2.3",
|
|
61
|
+
"gsap": "^3.12.1",
|
|
62
|
+
"kolorist": "^1.8.0",
|
|
63
|
+
"pathe": "^1.1.1",
|
|
66
64
|
"prettier": "^2.8.8",
|
|
67
|
-
"release-it": "^15.
|
|
65
|
+
"release-it": "^15.11.0",
|
|
68
66
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
69
|
-
"rollup-plugin-visualizer": "^5.9.
|
|
70
|
-
"
|
|
71
|
-
"
|
|
67
|
+
"rollup-plugin-visualizer": "^5.9.2",
|
|
68
|
+
"three": "^0.153.0",
|
|
69
|
+
"typescript": "^5.1.3",
|
|
70
|
+
"unocss": "^0.53.3",
|
|
72
71
|
"vite": "^4.3.9",
|
|
73
72
|
"vite-plugin-banner": "^0.7.0",
|
|
74
73
|
"vite-plugin-dts": "2.3.0",
|
|
75
74
|
"vite-svg-loader": "^4.0.0",
|
|
76
|
-
"vitepress": "1.0.0-beta.
|
|
77
|
-
"vue
|
|
75
|
+
"vitepress": "1.0.0-beta.3",
|
|
76
|
+
"vue": "^3.3.4",
|
|
77
|
+
"vue-tsc": "^1.8.1"
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import type { PropType } from 'vue';
|
|
2
|
-
import type { BlendFunction, KernelSize } from 'postprocessing';
|
|
3
|
-
import type { Object3D, ColorRepresentation } from 'three';
|
|
4
|
-
export declare const Outline: import("vue").DefineComponent<{
|
|
5
|
-
/**
|
|
6
|
-
* The objects in the scene which should have an outline.
|
|
7
|
-
*/
|
|
8
|
-
outlinedObjects: {
|
|
9
|
-
type: PropType<Object3D<import("three").Event>[]>;
|
|
10
|
-
requred: boolean;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* The blend function. Use `BlendFunction.ALPHA` for dark outlines.
|
|
14
|
-
*/
|
|
15
|
-
blendFunction: {
|
|
16
|
-
type: PropType<BlendFunction>;
|
|
17
|
-
};
|
|
18
|
-
patternTexture: {
|
|
19
|
-
type: PropType<number>;
|
|
20
|
-
};
|
|
21
|
-
patternScale: {
|
|
22
|
-
type: PropType<number>;
|
|
23
|
-
};
|
|
24
|
-
edgeStrength: {
|
|
25
|
-
type: PropType<number>;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* The pulse speed. A value of zero disables the pulse effect.
|
|
29
|
-
*/
|
|
30
|
-
pulseSpeed: {
|
|
31
|
-
type: PropType<number>;
|
|
32
|
-
};
|
|
33
|
-
visibleEdgeColor: {
|
|
34
|
-
type: PropType<[r: number, g: number, b: number] | ColorRepresentation>;
|
|
35
|
-
};
|
|
36
|
-
hiddenEdgeColor: {
|
|
37
|
-
type: PropType<[r: number, g: number, b: number] | ColorRepresentation>;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* The number of samples used for multisample antialiasing. Requires WebGL 2.
|
|
41
|
-
*/
|
|
42
|
-
multisampling: {
|
|
43
|
-
type: PropType<number>;
|
|
44
|
-
};
|
|
45
|
-
resolutionScale: {
|
|
46
|
-
type: PropType<number>;
|
|
47
|
-
};
|
|
48
|
-
resolutionX: {
|
|
49
|
-
type: PropType<number>;
|
|
50
|
-
};
|
|
51
|
-
resolutionY: {
|
|
52
|
-
type: PropType<number>;
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* The blur kernel size.
|
|
56
|
-
*/
|
|
57
|
-
kernelSize: {
|
|
58
|
-
type: PropType<KernelSize>;
|
|
59
|
-
};
|
|
60
|
-
blur: {
|
|
61
|
-
type: PropType<boolean>;
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Whether occluded parts of selected objects should be visible
|
|
65
|
-
*/
|
|
66
|
-
xRay: {
|
|
67
|
-
type: PropType<boolean>;
|
|
68
|
-
};
|
|
69
|
-
}, () => void, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
70
|
-
/**
|
|
71
|
-
* The objects in the scene which should have an outline.
|
|
72
|
-
*/
|
|
73
|
-
outlinedObjects: {
|
|
74
|
-
type: PropType<Object3D<import("three").Event>[]>;
|
|
75
|
-
requred: boolean;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* The blend function. Use `BlendFunction.ALPHA` for dark outlines.
|
|
79
|
-
*/
|
|
80
|
-
blendFunction: {
|
|
81
|
-
type: PropType<BlendFunction>;
|
|
82
|
-
};
|
|
83
|
-
patternTexture: {
|
|
84
|
-
type: PropType<number>;
|
|
85
|
-
};
|
|
86
|
-
patternScale: {
|
|
87
|
-
type: PropType<number>;
|
|
88
|
-
};
|
|
89
|
-
edgeStrength: {
|
|
90
|
-
type: PropType<number>;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* The pulse speed. A value of zero disables the pulse effect.
|
|
94
|
-
*/
|
|
95
|
-
pulseSpeed: {
|
|
96
|
-
type: PropType<number>;
|
|
97
|
-
};
|
|
98
|
-
visibleEdgeColor: {
|
|
99
|
-
type: PropType<[r: number, g: number, b: number] | ColorRepresentation>;
|
|
100
|
-
};
|
|
101
|
-
hiddenEdgeColor: {
|
|
102
|
-
type: PropType<[r: number, g: number, b: number] | ColorRepresentation>;
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* The number of samples used for multisample antialiasing. Requires WebGL 2.
|
|
106
|
-
*/
|
|
107
|
-
multisampling: {
|
|
108
|
-
type: PropType<number>;
|
|
109
|
-
};
|
|
110
|
-
resolutionScale: {
|
|
111
|
-
type: PropType<number>;
|
|
112
|
-
};
|
|
113
|
-
resolutionX: {
|
|
114
|
-
type: PropType<number>;
|
|
115
|
-
};
|
|
116
|
-
resolutionY: {
|
|
117
|
-
type: PropType<number>;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* The blur kernel size.
|
|
121
|
-
*/
|
|
122
|
-
kernelSize: {
|
|
123
|
-
type: PropType<KernelSize>;
|
|
124
|
-
};
|
|
125
|
-
blur: {
|
|
126
|
-
type: PropType<boolean>;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Whether occluded parts of selected objects should be visible
|
|
130
|
-
*/
|
|
131
|
-
xRay: {
|
|
132
|
-
type: PropType<boolean>;
|
|
133
|
-
};
|
|
134
|
-
}>>, {}, {}>;
|