@tresjs/post-processing 0.6.0 → 0.7.1

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 CHANGED
@@ -1,10 +1,9 @@
1
1
  ![repository-banner.png](/public/repo-banner.png)
2
2
 
3
3
  <p align="center">
4
- <a href="https://www.npmjs.com/package/@tresjs/core"><img src="https://img.shields.io/npm/v/@tresjs/post-processing?color=%2382DBCA" alt="npm package"></a>
5
-
6
- <a href="https://discord.gg/UCr96AQmWn"><img src="https://img.shields.io/badge/chat-discord-purple?style=flat&logo=discord" alt="discord chat"></a>
7
-
4
+ <a href="https://www.npmjs.com/package/@tresjs/core"><img src="https://img.shields.io/npm/v/@tresjs/post-processing?color=FF7BAC" alt="npm package"></a>
5
+ <a href="https://www.npmjs.com/package/@tresjs/post-processing"><img src="https://img.shields.io/npm/dm/@tresjs/post-processing?color=FF7BAC" alt="npm downloads"></a>
6
+ <a href="https://discord.gg/UCr96AQmWn"><img src="https://img.shields.io/badge/chat-discord-purple?style=flat&logo=discord" alt="discord chat"></a>
8
7
  </p>
9
8
  <br/>
10
9
 
@@ -1,4 +1,6 @@
1
1
  import type { TresObject } from '@tresjs/core';
2
+ import { EffectComposer as EffectComposerImpl } from 'postprocessing';
3
+ import type { ShallowRef } from 'vue';
2
4
  export interface EffectComposerProps {
3
5
  enabled?: boolean;
4
6
  children?: TresObject[];
@@ -18,7 +20,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
18
20
  depthBuffer: undefined;
19
21
  multisampling: number;
20
22
  stencilBuffer: undefined;
21
- }>, {}, 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<EffectComposerProps>, {
23
+ }>, {
24
+ composer: ShallowRef<EffectComposerImpl | null>;
25
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<EffectComposerProps>, {
22
26
  enabled: boolean;
23
27
  autoClear: boolean;
24
28
  frameBufferType: 1016;
@@ -58,7 +58,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
58
58
  }>, {
59
59
  pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
60
60
  effect: import("vue").ShallowRef<BloomEffect | null>;
61
- }, 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<BloomProps>, {
61
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<BloomProps>, {
62
62
  mipmapBlur: undefined;
63
63
  }>>>, {
64
64
  mipmapBlur: boolean;
@@ -32,7 +32,7 @@ export interface DepthOfFieldProps {
32
32
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<DepthOfFieldProps>, {
33
33
  pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
34
34
  effect: import("vue").ShallowRef<DepthOfFieldEffect | null>;
35
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<DepthOfFieldProps>>>, {}, {}>;
35
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<DepthOfFieldProps>>>, {}, {}>;
36
36
  export default _default;
37
37
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
38
38
  type __VLS_TypePropsToRuntimeProps<T> = {
@@ -92,7 +92,7 @@ export interface GlitchProps {
92
92
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<GlitchProps>, {
93
93
  pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
94
94
  effect: import("vue").ShallowRef<GlitchEffect | null>;
95
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<GlitchProps>>>, {}, {}>;
95
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<GlitchProps>>>, {}, {}>;
96
96
  export default _default;
97
97
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
98
98
  type __VLS_TypePropsToRuntimeProps<T> = {
@@ -12,7 +12,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
12
12
  }>, {
13
13
  pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
14
14
  effect: import("vue").ShallowRef<NoiseEffect | null>;
15
- }, 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<NoiseProps>, {
15
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<NoiseProps>, {
16
16
  premultiply: boolean;
17
17
  blendFunction: BlendFunction;
18
18
  }>>>, {
@@ -43,7 +43,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
43
43
  }>, {
44
44
  pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
45
45
  effect: import("vue").ShallowRef<OutlineEffect | null>;
46
- }, 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<OutlineProps>, {
46
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<OutlineProps>, {
47
47
  blur: undefined;
48
48
  xRay: undefined;
49
49
  }>>>, {
@@ -8,7 +8,7 @@ export interface PixelationProps {
8
8
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<PixelationProps>, {
9
9
  pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
10
10
  effect: import("vue").ShallowRef<PixelationEffect | null>;
11
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<PixelationProps>>>, {}, {}>;
11
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<PixelationProps>>>, {}, {}>;
12
12
  export default _default;
13
13
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
14
14
  type __VLS_TypePropsToRuntimeProps<T> = {
@@ -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").PublicProps, 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 DepthOfField from './core/effects/DepthOfField.vue';
7
+ import Vignette from './core/effects/Vignette.vue';
6
8
  import Noise from './core/effects/Noise.vue';
7
- import EffectComposer from './core/EffectComposer.vue';
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.6.0
4
- * (c) 2023
3
+ * version: v0.7.1
4
+ * (c) 2024
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 j, shallowRef as _, watchEffect as v, onUnmounted as A, watch as w, defineComponent as f, computed as M, provide as X, renderSlot as Y } from "vue";
9
- import { EffectPass as H, BloomEffect as y, GlitchEffect as S, GlitchMode as I, OutlineEffect as P, PixelationEffect as F, DepthOfFieldEffect as R, BlendFunction as U, NoiseEffect as O, EffectComposer as z, RenderPass as K, NormalPass as q, DepthDownsamplingPass as J } from "postprocessing";
10
- import { useTresContext as b, normalizeColor as C, useRenderLoop as Q } from "@tresjs/core";
11
- import { HalfFloatType as D } from "three";
12
- const N = Symbol(), p = (a) => {
13
- const t = j(N), e = _(null), n = _(null), { scene: o, camera: l } = b();
14
- v(() => {
15
- !l.value || !(n != null && n.value) || (n.value.mainCamera = l.value);
8
+ import { inject as Y, shallowRef as C, watchEffect as w, onUnmounted as N, watch as g, defineComponent as d, provide as V, computed as L, renderSlot as U } from "vue";
9
+ import { EffectPass as q, BloomEffect as F, DepthOfFieldEffect as P, EffectComposer as R, RenderPass as H, NormalPass as I, DepthDownsamplingPass as K, GlitchEffect as b, GlitchMode as J, OutlineEffect as O, PixelationEffect as D, VignetteTechnique as Q, BlendFunction as $, VignetteEffect as T, NoiseEffect as z } from "postprocessing";
10
+ import { useTresContext as h, useRenderLoop as Z, normalizeColor as S } from "@tresjs/core";
11
+ import { HalfFloatType as k } from "three";
12
+ const G = Symbol(), m = (l) => {
13
+ const t = Y(G), e = C(null), n = C(null), { scene: o, camera: a } = h();
14
+ w(() => {
15
+ !a.value || !(n != null && n.value) || (n.value.mainCamera = a.value);
16
16
  });
17
17
  let s = () => {
18
18
  };
19
- return s = v(() => {
20
- !l.value || !(t != null && t.value) || !o.value || (s(), !n.value && (n.value = a(), e.value = new H(l.value, n.value), t.value.addPass(e.value)));
21
- }), A(() => {
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();
19
+ return s = w(() => {
20
+ !a.value || !(t != null && t.value) || !o.value || (s(), !n.value && (n.value = l(), e.value = new q(a.value, n.value), t.value.addPass(e.value)));
21
+ }), N(() => {
22
+ var r, i, c;
23
+ e.value && ((r = t == null ? void 0 : t.value) == null || r.removePass(e.value)), (i = n.value) == null || i.dispose(), (c = e.value) == null || c.dispose();
24
24
  }), {
25
25
  pass: e,
26
26
  effect: n
27
27
  };
28
- }, G = /([^[.\]])+/g, V = (a, t) => {
28
+ }, W = /([^[.\]])+/g, ee = (l, t) => {
29
29
  if (!t)
30
30
  return;
31
- const e = Array.isArray(t) ? t : t.match(G);
32
- return e == null ? void 0 : e.reduce((n, o) => n && n[o], a);
33
- }, T = (a, t, e) => {
34
- const n = Array.isArray(t) ? t : t.match(G);
35
- n && n.reduce((o, l, s) => (o[l] === void 0 && (o[l] = {}), s === n.length - 1 && (o[l] = e), o[l]), a);
36
- }, L = (a, t) => {
37
- const e = { ...a };
31
+ const e = Array.isArray(t) ? t : t.match(W);
32
+ return e == null ? void 0 : e.reduce((n, o) => n && n[o], l);
33
+ }, A = (l, t, e) => {
34
+ const n = Array.isArray(t) ? t : t.match(W);
35
+ n && n.reduce((o, a, s) => (o[a] === void 0 && (o[a] = {}), s === n.length - 1 && (o[a] = e), o[a]), l);
36
+ }, E = (l, t) => {
37
+ const e = { ...l };
38
38
  return t.forEach((n) => delete e[n]), e;
39
- }, $ = (a, t, e, n, o = {}) => w(
40
- a,
41
- (l) => {
39
+ }, j = (l, t, e, n, o = {}) => g(
40
+ l,
41
+ (a) => {
42
42
  var s;
43
43
  if (t.value)
44
- if (l === void 0) {
44
+ if (a === void 0) {
45
45
  const r = n();
46
- T(t.value, e, V(r, e)), (s = r.dispose) == null || s.call(r);
46
+ A(t.value, e, ee(r, e)), (s = r.dispose) == null || s.call(r);
47
47
  } else
48
- T(t.value, e, a());
48
+ A(t.value, e, l());
49
49
  },
50
50
  o
51
- ), E = (a, t, e) => a.map(([n, o]) => $(
51
+ ), x = (l, t, e) => l.map(([n, o]) => j(
52
52
  n,
53
53
  t,
54
54
  o,
55
55
  e
56
- )), B = (a, t, e) => Object.keys(a).map((n) => $(
57
- () => a[n],
56
+ )), _ = (l, t, e) => Object.keys(l).map((n) => j(
57
+ () => l[n],
58
58
  t,
59
59
  n,
60
60
  e
61
- )), oe = /* @__PURE__ */ f({
61
+ )), ae = /* @__PURE__ */ d({
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(a, { expose: t }) {
72
- const e = a, { pass: n, effect: o } = p(() => new y(e));
73
- return t({ pass: n, effect: o }), E(
71
+ setup(l, { expose: t }) {
72
+ const e = l, { pass: n, effect: o } = m(() => new F(e));
73
+ return t({ pass: n, effect: o }), x(
74
74
  [
75
75
  // blendFunction is not updated, because it has no setter in BloomEffect
76
76
  [() => e.intensity, "intensity"],
@@ -79,10 +79,106 @@ const N = Symbol(), p = (a) => {
79
79
  [() => e.luminanceThreshold, "luminanceMaterial.threshold"]
80
80
  ],
81
81
  o,
82
- () => new y()
83
- ), (l, s) => null;
82
+ () => new F()
83
+ ), (a, s) => null;
84
+ }
85
+ }), se = /* @__PURE__ */ d({
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 P(n.value, e));
100
+ return t({ pass: o, effect: a }), x(
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 P()
114
+ ), (s, r) => null;
84
115
  }
85
- }), le = /* @__PURE__ */ f({
116
+ });
117
+ let v;
118
+ function M() {
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;
128
+ }
129
+ }
130
+ const re = /* @__PURE__ */ d({
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: k }
142
+ },
143
+ setup(l, { expose: t }) {
144
+ const e = l, { scene: n, camera: o, renderer: a, sizes: s } = h(), r = C(null);
145
+ let i = null, c = null;
146
+ V(G, r), t({ composer: r });
147
+ const f = () => {
148
+ r.value && (c = new I(n.value, o.value), c.enabled = !1, r.value.addPass(c), e.resolutionScale !== void 0 && M() && (i = new K({
149
+ normalBuffer: c.texture,
150
+ resolutionScale: e.resolutionScale
151
+ }), i.enabled = !1, r.value.addPass(i)));
152
+ }, B = L(() => {
153
+ const u = new R(), p = {
154
+ depthBuffer: e.depthBuffer !== void 0 ? e.depthBuffer : u.inputBuffer.depthBuffer,
155
+ stencilBuffer: e.stencilBuffer !== void 0 ? e.stencilBuffer : u.inputBuffer.stencilBuffer,
156
+ multisampling: M() ? e.multisampling !== void 0 ? e.multisampling : u.multisampling : 0,
157
+ frameBufferType: e.frameBufferType !== void 0 ? e.frameBufferType : k
158
+ };
159
+ return u.dispose(), p;
160
+ }), y = () => {
161
+ !a.value && !n.value && !o.value || (r.value = new R(a.value, B.value), r.value.addPass(new H(n.value, o.value)), e.disableNormalPass || f());
162
+ };
163
+ g([a, n, o, () => e.disableNormalPass], () => {
164
+ !s.width.value || !s.height.value || y();
165
+ }), g(() => [s.width.value, s.height.value], ([u, p]) => {
166
+ !u && !p || (r.value ? r.value.setSize(u, p) : y());
167
+ }, {
168
+ immediate: !0
169
+ });
170
+ const { onLoop: X } = Z();
171
+ return X(({ delta: u }) => {
172
+ if (e.enabled && a.value && r.value && s.width.value && s.height.value) {
173
+ const p = a.value.autoClear;
174
+ a.value.autoClear = e.autoClear, e.stencilBuffer && !e.autoClear && a.value.clearStencil(), r.value.render(u), a.value.autoClear = p;
175
+ }
176
+ }), N(() => {
177
+ var u;
178
+ (u = r.value) == null || u.dispose();
179
+ }), (u, p) => U(u.$slots, "default");
180
+ }
181
+ }), ue = /* @__PURE__ */ d({
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(a, { expose: t }) {
101
- const e = a, { pass: n, effect: o } = p(() => new S(e));
102
- return t({ pass: n, effect: o }), v(() => {
103
- const l = () => {
196
+ setup(l, { expose: t }) {
197
+ const e = l, { pass: n, effect: o } = m(() => new b(e));
198
+ return t({ pass: n, effect: o }), w(() => {
199
+ const a = () => {
104
200
  if (e.mode !== void 0)
105
- return e.active === !1 ? I.DISABLED : e.mode;
106
- const s = new S(), r = s.mode;
201
+ return e.active === !1 ? J.DISABLED : e.mode;
202
+ const s = new b(), r = s.mode;
107
203
  return s.dispose(), r;
108
204
  };
109
- o.value && (o.value.mode = l());
110
- }), B(
111
- L(e, ["active", "mode", "blendFunction"]),
205
+ o.value && (o.value.mode = a());
206
+ }), _(
207
+ E(e, ["active", "mode", "blendFunction"]),
112
208
  o,
113
- () => new S()
114
- ), (l, s) => null;
209
+ () => new b()
210
+ ), (a, s) => null;
115
211
  }
116
- }), ae = /* @__PURE__ */ f({
212
+ }), ie = /* @__PURE__ */ d({
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(a, { expose: t }) {
136
- const e = a, n = (c) => c !== void 0 ? C(c).getHex() : void 0, { camera: o, scene: l } = b(), s = {
231
+ setup(l, { expose: t }) {
232
+ const e = l, n = (f) => f !== void 0 ? S(f).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,23 +244,23 @@ 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 } = p(() => new P(l.value, o.value, s));
152
- t({ pass: r, effect: i }), w(
247
+ }, { pass: r, effect: i } = m(() => new O(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
  () => {
156
- var c;
157
- (c = i.value) == null || c.selection.set(e.outlinedObjects || []);
252
+ var f;
253
+ (f = i.value) == null || f.selection.set(e.outlinedObjects || []);
158
254
  },
159
255
  {
160
256
  immediate: !0
161
257
  }
162
258
  );
163
- const d = M(() => ({
164
- hiddenEdgeColor: e.hiddenEdgeColor ? C(e.hiddenEdgeColor) : void 0,
165
- visibleEdgeColor: e.visibleEdgeColor ? C(e.visibleEdgeColor) : void 0
259
+ const c = L(() => ({
260
+ hiddenEdgeColor: e.hiddenEdgeColor ? S(e.hiddenEdgeColor) : void 0,
261
+ visibleEdgeColor: e.visibleEdgeColor ? S(e.visibleEdgeColor) : void 0
166
262
  }));
167
- return E(
263
+ return x(
168
264
  [
169
265
  /* some properties are not updated because of different reasons:
170
266
  resolutionX - has no setter in OutlineEffect
@@ -180,147 +276,64 @@ const N = Symbol(), p = (a) => {
180
276
  [() => e.edgeStrength, "edgeStrength"],
181
277
  [() => e.patternScale, "patternScale"],
182
278
  [() => e.multisampling, "multisampling"],
183
- [() => d.value.hiddenEdgeColor, "hiddenEdgeColor"],
184
- [() => d.value.visibleEdgeColor, "visibleEdgeColor"]
279
+ [() => c.value.hiddenEdgeColor, "hiddenEdgeColor"],
280
+ [() => c.value.visibleEdgeColor, "visibleEdgeColor"]
185
281
  ],
186
282
  i,
187
- () => new P()
188
- ), (c, x) => null;
283
+ () => new O()
284
+ ), (f, B) => null;
189
285
  }
190
- }), se = /* @__PURE__ */ f({
286
+ }), ce = /* @__PURE__ */ d({
191
287
  __name: "Pixelation",
192
288
  props: {
193
289
  granularity: {}
194
290
  },
195
- setup(a, { expose: t }) {
196
- const e = a, { pass: n, effect: o } = p(() => new F(e.granularity));
197
- return t({ pass: n, effect: o }), B(
291
+ setup(l, { expose: t }) {
292
+ const e = l, { pass: n, effect: o } = m(() => new D(e.granularity));
293
+ return t({ pass: n, effect: o }), _(
198
294
  e,
199
295
  o,
200
- () => new F()
201
- ), (l, s) => null;
296
+ () => new D()
297
+ ), (a, s) => null;
202
298
  }
203
- }), re = /* @__PURE__ */ f({
204
- __name: "DepthOfField",
299
+ }), fe = /* @__PURE__ */ d({
300
+ __name: "Vignette",
205
301
  props: {
206
- blendFunction: {},
207
- worldFocusDistance: {},
208
- worldFocusRange: {},
209
- focusDistance: {},
210
- focusRange: {},
211
- bokehScale: {},
212
- resolutionScale: {},
213
- resolutionX: {},
214
- resolutionY: {}
302
+ technique: { default: Q.DEFAULT },
303
+ blendFunction: { default: $.NORMAL },
304
+ offset: { default: 0.5 },
305
+ darkness: { default: 0.5 }
215
306
  },
216
- setup(a, { expose: t }) {
217
- const e = a, { camera: n } = b(), { pass: o, effect: l } = p(() => new R(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 R()
232
- ), (s, r) => null;
307
+ setup(l, { expose: t }) {
308
+ const e = l, { pass: n, effect: o } = m(() => new T(e));
309
+ return t({ pass: n, effect: o }), _(
310
+ E(e, ["blendFunction"]),
311
+ o,
312
+ () => new T()
313
+ ), (a, s) => null;
233
314
  }
234
- }), ie = /* @__PURE__ */ f({
315
+ }), de = /* @__PURE__ */ d({
235
316
  __name: "Noise",
236
317
  props: {
237
318
  premultiply: { type: Boolean, default: !1 },
238
- blendFunction: { default: U.SCREEN }
319
+ blendFunction: { default: $.SCREEN }
239
320
  },
240
- setup(a, { expose: t }) {
241
- const e = a, { pass: n, effect: o } = p(() => new O(e));
242
- return t({ pass: n, effect: o }), B(
243
- L(e, ["blendFunction"]),
321
+ setup(l, { expose: t }) {
322
+ const e = l, { pass: n, effect: o } = m(() => new z(e));
323
+ return t({ pass: n, effect: o }), _(
324
+ E(e, ["blendFunction"]),
244
325
  o,
245
- () => new O()
246
- ), (l, s) => null;
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 } = b(), s = _(null);
277
- let r = null, i = null;
278
- X(N, s);
279
- const d = () => {
280
- s.value && (i = new q(e.value, n.value), i.enabled = !1, s.value.addPass(i), t.resolutionScale !== void 0 && k() && (r = new J({
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 K(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: W } = Q();
307
- return W(({ 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) => Y(u.$slots, "default");
326
+ () => new z()
327
+ ), (a, s) => null;
316
328
  }
317
329
  });
318
330
  export {
319
- oe as Bloom,
320
- re as DepthOfField,
321
- ue as EffectComposer,
322
- le as Glitch,
323
- ie as Noise,
324
- ae as Outline,
325
- se as Pixelation
331
+ ae as Bloom,
332
+ se as DepthOfField,
333
+ re as EffectComposer,
334
+ ue as Glitch,
335
+ de as Noise,
336
+ ie as Outline,
337
+ ce as Pixelation,
338
+ fe as Vignette
326
339
  };
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * name: @tresjs/post-processing
3
- * version: v0.6.0
4
- * (c) 2023
3
+ * version: v0.7.1
4
+ * (c) 2024
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,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):(s=typeof globalThis<"u"?globalThis:s||self,i(s["tres-postprocessing"]={},s.Vue,s.Postprocessing,s.TresjsCore,s.Three))})(this,function(s,i,u,m,b){"use strict";const _=Symbol(),v=a=>{const t=i.inject(_),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 c,f,h;e.value&&((c=t==null?void 0:t.value)==null||c.removePass(e.value)),(f=n.value)==null||f.dispose(),(h=e.value)==null||h.dispose()}),{pass:e,effect:n}},B=/([^[.\]])+/g,R=(a,t)=>{if(!t)return;const e=Array.isArray(t)?t:t.match(B);return e==null?void 0:e.reduce((n,l)=>n&&n[l],a)},y=(a,t,e)=>{const n=Array.isArray(t)?t:t.match(B);n&&n.reduce((l,o,r)=>(l[o]===void 0&&(l[o]={}),r===n.length-1&&(l[o]=e),l[o]),a)},x=(a,t)=>{const e={...a};return t.forEach(n=>delete e[n]),e},P=(a,t,e,n,l={})=>i.watch(a,o=>{var r;if(t.value)if(o===void 0){const c=n();y(t.value,e,R(c,e)),(r=c.dispose)==null||r.call(c)}else y(t.value,e,a())},l),E=(a,t,e)=>a.map(([n,l])=>P(n,t,l,e)),S=(a,t,e)=>Object.keys(a).map(n=>P(()=>a[n],t,n,e)),O=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}),E([[()=>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,c=r.mode;return r.dispose(),c};l.value&&(l.value.mode=o())}),S(x(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:c,effect:f}=v(()=>new u.OutlineEffect(o.value,l.value,r));t({pass:c,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 E([[()=>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}),S(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}),E([[()=>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,c)=>null}}),j=i.defineComponent({__name:"Noise",props:{premultiply:{type:Boolean,default:!1},blendFunction:{default:u.BlendFunction.SCREEN}},setup(a,{expose:t}){const e=a,{pass:n,effect:l}=v(()=>new u.NoiseEffect(e));return t({pass:n,effect:l}),S(x(e,["blendFunction"]),l,()=>new u.NoiseEffect),(o,r)=>null}});let C;function F(){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 A=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:b.HalfFloatType}},setup(a){const t=a,{scene:e,camera:n,renderer:l,sizes:o}=m.useTresContext(),r=i.shallowRef(null);let c=null,f=null;i.provide(_,r);const h=()=>{r.value&&(f=new u.NormalPass(e.value,n.value),f.enabled=!1,r.value.addPass(f),t.resolutionScale!==void 0&&F()&&(c=new u.DepthDownsamplingPass({normalBuffer:f.texture,resolutionScale:t.resolutionScale}),c.enabled=!1,r.value.addPass(c)))};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,g={depthBuffer:t.depthBuffer!==void 0?t.depthBuffer:d.inputBuffer.depthBuffer,stencilBuffer:t.stencilBuffer!==void 0?t.stencilBuffer:d.inputBuffer.stencilBuffer,multisampling:F()?0:t.multisampling!==void 0?t.multisampling:d.multisampling,frameBufferType:t.frameBufferType!==void 0?t.frameBufferType:b.HalfFloatType};return d.dispose(),g}),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 w=()=>{};w=i.watch([o.height,o.width],()=>{!o.height.value&&!o.width.value||(i.watchEffect(T),w==null||w())},{immediate:!0});const{onLoop:N}=m.useRenderLoop();return N(({delta:d})=>{if(t.enabled&&l.value&&r.value&&o.width.value&&o.height.value){const g=l.value.autoClear;l.value.autoClear=t.autoClear,t.stencilBuffer&&!t.autoClear&&l.value.clearStencil(),r.value.render(d),l.value.autoClear=g}}),i.onUnmounted(()=>{var d;(d=r.value)==null||d.dispose()}),(d,g)=>i.renderSlot(d.$slots,"default")}});s.Bloom=O,s.DepthOfField=M,s.EffectComposer=A,s.Glitch=z,s.Noise=j,s.Outline=D,s.Pixelation=k,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
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,r,p,S){"use strict";const g=Symbol(),v=o=>{const n=i.inject(g),e=i.shallowRef(null),t=i.shallowRef(null),{scene:l,camera:a}=p.useTresContext();i.watchEffect(()=>{!a.value||!(t!=null&&t.value)||(t.value.mainCamera=a.value)});let u=()=>{};return u=i.watchEffect(()=>{!a.value||!(n!=null&&n.value)||!l.value||(u(),!t.value&&(t.value=o(),e.value=new r.EffectPass(a.value,t.value),n.value.addPass(e.value)))}),i.onUnmounted(()=>{var s,d,m;e.value&&((s=n==null?void 0:n.value)==null||s.removePass(e.value)),(d=t.value)==null||d.dispose(),(m=e.value)==null||m.dispose()}),{pass:e,effect:t}},B=/([^[.\]])+/g,R=(o,n)=>{if(!n)return;const e=Array.isArray(n)?n:n.match(B);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(B);t&&t.reduce((l,a,u)=>(l[a]===void 0&&(l[a]={}),u===t.length-1&&(l[a]=e),l[a]),o)},w=(o,n)=>{const e={...o};return n.forEach(t=>delete e[t]),e},y=(o,n,e,t,l={})=>i.watch(o,a=>{var u;if(n.value)if(a===void 0){const s=t();x(n.value,e,R(s,e)),(u=s.dispose)==null||u.call(s)}else x(n.value,e,o())},l),b=(o,n,e)=>o.map(([t,l])=>y(t,n,l,e)),E=(o,n,e)=>Object.keys(o).map(t=>y(()=>o[t],n,t,e)),O=i.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}=v(()=>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,u)=>null}}),z=i.defineComponent({__name:"DepthOfField",props:{blendFunction:{},worldFocusDistance:{},worldFocusRange:{},focusDistance:{},focusRange:{},bokehScale:{},resolutionScale:{},resolutionX:{},resolutionY:{}},setup(o,{expose:n}){const e=o,{camera:t}=p.useTresContext(),{pass:l,effect:a}=v(()=>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),(u,s)=>null}});let _;function F(){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 D=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:S.HalfFloatType}},setup(o,{expose:n}){const e=o,{scene:t,camera:l,renderer:a,sizes:u}=p.useTresContext(),s=i.shallowRef(null);let d=null,m=null;i.provide(g,s),n({composer:s});const h=()=>{s.value&&(m=new r.NormalPass(t.value,l.value),m.enabled=!1,s.value.addPass(m),e.resolutionScale!==void 0&&F()&&(d=new r.DepthDownsamplingPass({normalBuffer:m.texture,resolutionScale:e.resolutionScale}),d.enabled=!1,s.value.addPass(d)))},P=i.computed(()=>{const f=new r.EffectComposer,C={depthBuffer:e.depthBuffer!==void 0?e.depthBuffer:f.inputBuffer.depthBuffer,stencilBuffer:e.stencilBuffer!==void 0?e.stencilBuffer:f.inputBuffer.stencilBuffer,multisampling:F()?e.multisampling!==void 0?e.multisampling:f.multisampling:0,frameBufferType:e.frameBufferType!==void 0?e.frameBufferType:S.HalfFloatType};return f.dispose(),C}),T=()=>{!a.value&&!t.value&&!l.value||(s.value=new r.EffectComposer(a.value,P.value),s.value.addPass(new r.RenderPass(t.value,l.value)),e.disableNormalPass||h())};i.watch([a,t,l,()=>e.disableNormalPass],()=>{!u.width.value||!u.height.value||T()}),i.watch(()=>[u.width.value,u.height.value],([f,C])=>{!f&&!C||(s.value?s.value.setSize(f,C):T())},{immediate:!0});const{onLoop:G}=p.useRenderLoop();return G(({delta:f})=>{if(e.enabled&&a.value&&s.value&&u.width.value&&u.height.value){const C=a.value.autoClear;a.value.autoClear=e.autoClear,e.stencilBuffer&&!e.autoClear&&a.value.clearStencil(),s.value.render(f),a.value.autoClear=C}}),i.onUnmounted(()=>{var f;(f=s.value)==null||f.dispose()}),(f,C)=>i.renderSlot(f.$slots,"default")}}),k=i.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}=v(()=>new r.GlitchEffect(e));return n({pass:t,effect:l}),i.watchEffect(()=>{const a=()=>{if(e.mode!==void 0)return e.active===!1?r.GlitchMode.DISABLED:e.mode;const u=new r.GlitchEffect,s=u.mode;return u.dispose(),s};l.value&&(l.value.mode=a())}),E(w(e,["active","mode","blendFunction"]),l,()=>new r.GlitchEffect),(a,u)=>null}}),A=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(o,{expose:n}){const e=o,t=h=>h!==void 0?p.normalizeColor(h).getHex():void 0,{camera:l,scene:a}=p.useTresContext(),u={blur:e.blur,xRay:e.xRay,kernelSize:e.kernelSize,pulseSpeed:e.pulseSpeed,resolutionX:e.resolutionX,resolutionY:e.resolutionY,patternScale:e.patternScale,edgeStrength:e.edgeStrength,blendFunction:e.blendFunction,multisampling:e.multisampling,patternTexture:e.patternTexture,resolutionScale:e.resolutionScale,hiddenEdgeColor:t(e.hiddenEdgeColor),visibleEdgeColor:t(e.visibleEdgeColor)},{pass:s,effect:d}=v(()=>new r.OutlineEffect(a.value,l.value,u));n({pass:s,effect:d}),i.watch([()=>e.outlinedObjects,d],()=>{var h;(h=d.value)==null||h.selection.set(e.outlinedObjects||[])},{immediate:!0});const m=i.computed(()=>({hiddenEdgeColor:e.hiddenEdgeColor?p.normalizeColor(e.hiddenEdgeColor):void 0,visibleEdgeColor:e.visibleEdgeColor?p.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"],[()=>m.value.hiddenEdgeColor,"hiddenEdgeColor"],[()=>m.value.visibleEdgeColor,"visibleEdgeColor"]],d,()=>new r.OutlineEffect),(h,P)=>null}}),M=i.defineComponent({__name:"Pixelation",props:{granularity:{}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=v(()=>new r.PixelationEffect(e.granularity));return n({pass:t,effect:l}),E(e,l,()=>new r.PixelationEffect),(a,u)=>null}}),N=i.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}=v(()=>new r.VignetteEffect(e));return n({pass:t,effect:l}),E(w(e,["blendFunction"]),l,()=>new r.VignetteEffect),(a,u)=>null}}),j=i.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}=v(()=>new r.NoiseEffect(e));return n({pass:t,effect:l}),E(w(e,["blendFunction"]),l,()=>new r.NoiseEffect),(a,u)=>null}});c.Bloom=O,c.DepthOfField=z,c.EffectComposer=D,c.Glitch=k,c.Noise=j,c.Outline=A,c.Pixelation=M,c.Vignette=N,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tresjs/post-processing",
3
3
  "type": "module",
4
- "version": "0.6.0",
5
- "packageManager": "pnpm@8.10.2",
4
+ "version": "0.7.1",
5
+ "packageManager": "pnpm@8.11.0",
6
6
  "description": "Post-processing library for TresJS",
7
7
  "author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
8
8
  "license": "MIT",
@@ -48,33 +48,33 @@
48
48
  "vue": ">=3.3"
49
49
  },
50
50
  "dependencies": {
51
- "@tresjs/core": "^3.5.0",
52
- "@unocss/core": "^0.57.3",
51
+ "@tresjs/core": "^3.5.1",
52
+ "@unocss/core": "^0.58.0",
53
53
  "@vueuse/core": "^10.6.1",
54
- "postprocessing": "^6.33.3",
55
- "three-stdlib": "^2.28.5"
54
+ "postprocessing": "^6.33.4",
55
+ "three-stdlib": "^2.28.7"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@release-it/conventional-changelog": "^8.0.1",
59
59
  "@tresjs/eslint-config-vue": "^0.2.1",
60
- "@types/three": "^0.158.2",
61
- "@vitejs/plugin-vue": "^4.4.1",
62
- "gsap": "^3.12.2",
60
+ "@types/three": "^0.159.0",
61
+ "@vitejs/plugin-vue": "^4.5.1",
62
+ "gsap": "^3.12.3",
63
63
  "kolorist": "^1.8.0",
64
64
  "pathe": "^1.1.1",
65
65
  "prettier": "^3.1.0",
66
66
  "release-it": "^17.0.0",
67
67
  "rollup-plugin-analyzer": "^4.0.0",
68
- "rollup-plugin-visualizer": "^5.9.2",
69
- "three": "^0.158.0",
70
- "typescript": "^5.2.2",
71
- "unocss": "^0.57.3",
72
- "vite": "^4.5.0",
68
+ "rollup-plugin-visualizer": "^5.10.0",
69
+ "three": "^0.159.0",
70
+ "typescript": "^5.3.2",
71
+ "unocss": "^0.58.0",
72
+ "vite": "^5.0.4",
73
73
  "vite-plugin-banner": "^0.7.1",
74
- "vite-plugin-dts": "3.6.3",
75
- "vite-svg-loader": "^4.0.0",
76
- "vitepress": "1.0.0-rc.25",
77
- "vue": "^3.3.8",
78
- "vue-tsc": "^1.8.22"
74
+ "vite-plugin-dts": "3.6.4",
75
+ "vite-svg-loader": "^5.1.0",
76
+ "vitepress": "1.0.0-rc.31",
77
+ "vue": "^3.3.9",
78
+ "vue-tsc": "^1.8.24"
79
79
  }
80
80
  }
@@ -1,6 +0,0 @@
1
- import type { Effect } from 'postprocessing';
2
- import { EffectPass } from 'postprocessing';
3
- export declare const useEffect: <T extends Effect>(newEffectFunction: () => T) => {
4
- pass: import("vue").ShallowRef<EffectPass | null>;
5
- effect: import("vue").ShallowRef<T | null>;
6
- };