@tresjs/post-processing 0.7.0 → 1.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md 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
 
@@ -24,7 +23,7 @@ pnpm i @tresjs/post-processing
24
23
 
25
24
  ## Docs
26
25
 
27
- Checkout the [docs](https://postprocessing.tresjs.org/)
26
+ Checkout the [docs](https://post-processing.tresjs.org/)
28
27
 
29
28
  ## Demos
30
29
 
@@ -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,11 @@ 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, {
26
+ render: (...args: any[]) => void;
27
+ }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<EffectComposerProps>, {
22
28
  enabled: boolean;
23
29
  autoClear: boolean;
24
30
  frameBufferType: 1016;
@@ -26,7 +32,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
26
32
  depthBuffer: undefined;
27
33
  multisampling: number;
28
34
  stencilBuffer: undefined;
29
- }>>>, {
35
+ }>>> & {
36
+ onRender?: ((...args: any[]) => any) | undefined;
37
+ }, {
30
38
  enabled: boolean;
31
39
  depthBuffer: boolean;
32
40
  disableNormalPass: boolean;
@@ -1,6 +1,6 @@
1
1
  import type { Effect } from 'postprocessing';
2
2
  import { EffectPass } from 'postprocessing';
3
3
  export declare const useEffect: <T extends Effect>(newEffectFunction: () => T) => {
4
- pass: import("vue").ShallowRef<EffectPass | null>;
5
- effect: import("vue").ShallowRef<T | null>;
4
+ pass: import("vue").Ref<EffectPass | null> | import("vue").ShallowRef<EffectPass | null>;
5
+ effect: import("vue").Ref<T | null> | import("vue").ShallowRef<T | null>;
6
6
  };
@@ -1,5 +1,5 @@
1
1
  import { BloomEffect } from 'postprocessing';
2
- import type { KernelSize, BlendFunction } from 'postprocessing';
2
+ import type { BlendFunction, KernelSize } from 'postprocessing';
3
3
  export interface BloomProps {
4
4
  /**
5
5
  * The blend function of this effect. This prop is not reactive.
@@ -56,8 +56,8 @@ export interface BloomProps {
56
56
  declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<BloomProps>, {
57
57
  mipmapBlur: undefined;
58
58
  }>, {
59
- pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
60
- effect: import("vue").ShallowRef<BloomEffect | null>;
59
+ pass: import("vue").Ref<import("postprocessing").EffectPass | null> | import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
60
+ effect: import("vue").Ref<BloomEffect | null> | import("vue").ShallowRef<BloomEffect | null>;
61
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>, {
62
62
  mipmapBlur: undefined;
63
63
  }>>>, {
@@ -30,8 +30,8 @@ export interface DepthOfFieldProps {
30
30
  resolutionY?: number;
31
31
  }
32
32
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<DepthOfFieldProps>, {
33
- pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
34
- effect: import("vue").ShallowRef<DepthOfFieldEffect | null>;
33
+ pass: import("vue").Ref<import("postprocessing").EffectPass | null> | import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
34
+ effect: import("vue").Ref<DepthOfFieldEffect | null> | import("vue").ShallowRef<DepthOfFieldEffect | null>;
35
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>>>, {}, {}>;
36
36
  export default _default;
37
37
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -1,6 +1,6 @@
1
- import { GlitchMode, GlitchEffect } from 'postprocessing';
1
+ import { GlitchEffect, GlitchMode } from 'postprocessing';
2
2
  import type { BlendFunction } from 'postprocessing';
3
- import type { Vector2, Texture } from 'three';
3
+ import type { Texture, Vector2 } from 'three';
4
4
  export interface GlitchProps {
5
5
  blendFunction?: BlendFunction;
6
6
  /**
@@ -90,8 +90,8 @@ export interface GlitchProps {
90
90
  dtSize?: number;
91
91
  }
92
92
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<GlitchProps>, {
93
- pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
94
- effect: import("vue").ShallowRef<GlitchEffect | null>;
93
+ pass: import("vue").Ref<import("postprocessing").EffectPass | null> | import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
94
+ effect: import("vue").Ref<GlitchEffect | null> | import("vue").ShallowRef<GlitchEffect | null>;
95
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>>>, {}, {}>;
96
96
  export default _default;
97
97
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -10,8 +10,8 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
10
10
  premultiply: boolean;
11
11
  blendFunction: BlendFunction;
12
12
  }>, {
13
- pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
14
- effect: import("vue").ShallowRef<NoiseEffect | null>;
13
+ pass: import("vue").Ref<import("postprocessing").EffectPass | null> | import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
14
+ effect: import("vue").Ref<NoiseEffect | null> | import("vue").ShallowRef<NoiseEffect | null>;
15
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>, {
16
16
  premultiply: boolean;
17
17
  blendFunction: BlendFunction;
@@ -41,8 +41,8 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
41
41
  blur: undefined;
42
42
  xRay: undefined;
43
43
  }>, {
44
- pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
45
- effect: import("vue").ShallowRef<OutlineEffect | null>;
44
+ pass: import("vue").Ref<import("postprocessing").EffectPass | null> | import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
45
+ effect: import("vue").Ref<OutlineEffect | null> | import("vue").ShallowRef<OutlineEffect | null>;
46
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>, {
47
47
  blur: undefined;
48
48
  xRay: undefined;
@@ -6,8 +6,8 @@ export interface PixelationProps {
6
6
  granularity?: number;
7
7
  }
8
8
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<PixelationProps>, {
9
- pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
10
- effect: import("vue").ShallowRef<PixelationEffect | null>;
9
+ pass: import("vue").Ref<import("postprocessing").EffectPass | null> | import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
10
+ effect: import("vue").Ref<PixelationEffect | null> | import("vue").ShallowRef<PixelationEffect | null>;
11
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>>>, {}, {}>;
12
12
  export default _default;
13
13
  type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
@@ -14,8 +14,8 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
14
14
  offset: number;
15
15
  darkness: number;
16
16
  }>, {
17
- pass: import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
18
- effect: import("vue").ShallowRef<VignetteEffect | null>;
17
+ pass: import("vue").Ref<import("postprocessing").EffectPass | null> | import("vue").ShallowRef<import("postprocessing").EffectPass | null>;
18
+ effect: import("vue").Ref<VignetteEffect | null> | import("vue").ShallowRef<VignetteEffect | null>;
19
19
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<VignetteProps>, {
20
20
  technique: VignetteTechnique;
21
21
  blendFunction: BlendFunction;
package/dist/index.d.ts CHANGED
@@ -6,4 +6,5 @@ import Outline from './core/effects/Outline.vue';
6
6
  import Pixelation from './core/effects/Pixelation.vue';
7
7
  import Vignette from './core/effects/Vignette.vue';
8
8
  import Noise from './core/effects/Noise.vue';
9
- export { Bloom, DepthOfField, EffectComposer, Glitch, Noise, Outline, Pixelation, Vignette, };
9
+ import { useEffect } from './core/composables/effect.ts';
10
+ export { Bloom, DepthOfField, EffectComposer, Glitch, Noise, Outline, Pixelation, Vignette, useEffect, };
@@ -1,64 +1,60 @@
1
1
  /**
2
2
  * name: @tresjs/post-processing
3
- * version: v0.7.0
4
- * (c) 2023
3
+ * version: v1.0.0-next.0
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 X, shallowRef as w, watchEffect as E, onUnmounted as M, watch as g, defineComponent as f, provide as Y, computed as N, renderSlot as V } from "vue";
9
- import { EffectPass as U, BloomEffect as y, DepthOfFieldEffect as F, EffectComposer as P, RenderPass as q, NormalPass as H, DepthDownsamplingPass as I, GlitchEffect as S, GlitchMode as K, OutlineEffect as R, PixelationEffect as O, VignetteTechnique as J, BlendFunction as L, VignetteEffect as D, NoiseEffect as T } from "postprocessing";
10
- import { useTresContext as h, useRenderLoop as Q, normalizeColor as C } from "@tresjs/core";
11
- import { HalfFloatType as z } from "three";
12
- const $ = Symbol(), m = (l) => {
13
- const t = X($), e = w(null), n = w(null), { scene: o, camera: a } = h();
14
- E(() => {
15
- !a.value || !(n != null && n.value) || (n.value.mainCamera = a.value);
8
+ import { inject as q, shallowRef as E, watchEffect as x, onUnmounted as L, watch as _, defineComponent as d, provide as H, computed as $, renderSlot as I } from "vue";
9
+ import { EffectPass as K, BloomEffect as P, DepthOfFieldEffect as R, EffectComposer as O, RenderPass as J, NormalPass as Q, DepthDownsamplingPass as Z, GlitchEffect as S, GlitchMode as ee, OutlineEffect as D, PixelationEffect as T, VignetteTechnique as te, BlendFunction as G, VignetteEffect as z, NoiseEffect as k } from "postprocessing";
10
+ import { useTresContext as b, useLoop as ne, normalizeColor as w } from "@tresjs/core";
11
+ import { HalfFloatType as A } from "three";
12
+ const W = Symbol("effectComposer"), p = (l) => {
13
+ const n = q(W), e = E(null), t = E(null), { scene: o, camera: a } = b();
14
+ x(() => {
15
+ !a.value || !(t != null && t.value) || (t.value.mainCamera = a.value);
16
16
  });
17
17
  let s = () => {
18
18
  };
19
- return s = E(() => {
20
- !a.value || !(t != null && t.value) || !o.value || (s(), !n.value && (n.value = l(), e.value = new U(a.value, n.value), t.value.addPass(e.value)));
21
- }), M(() => {
22
- 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 = x(() => {
20
+ !a.value || !(n != null && n.value) || !o.value || (s(), !t.value && (t.value = l(), e.value = new K(a.value, t.value), n.value.addPass(e.value)));
21
+ }), L(() => {
22
+ var r, i, f;
23
+ e.value && ((r = n == null ? void 0 : n.value) == null || r.removePass(e.value)), (i = t.value) == null || i.dispose(), (f = e.value) == null || f.dispose();
24
24
  }), {
25
25
  pass: e,
26
- effect: n
26
+ effect: t
27
27
  };
28
- }, G = /([^[.\]])+/g, Z = (l, t) => {
29
- if (!t)
28
+ }, j = /([^[.\]])+/g, oe = (l, n) => {
29
+ if (!n)
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], l);
33
- }, k = (l, t, e) => {
34
- const n = Array.isArray(t) ? t : t.match(G);
35
- n && n.reduce((o, a, s) => (o[a] === void 0 && (o[a] = {}), s === n.length - 1 && (o[a] = e), o[a]), l);
36
- }, x = (l, t) => {
31
+ const e = Array.isArray(n) ? n : n.match(j);
32
+ return e == null ? void 0 : e.reduce((t, o) => t && t[o], l);
33
+ }, M = (l, n, e) => {
34
+ const t = Array.isArray(n) ? n : n.match(j);
35
+ t && t.reduce((o, a, s) => (o[a] === void 0 && (o[a] = {}), s === t.length - 1 && (o[a] = e), o[a]), l);
36
+ }, B = (l, n) => {
37
37
  const e = { ...l };
38
- return t.forEach((n) => delete e[n]), e;
39
- }, W = (l, t, e, n, o = {}) => g(
40
- l,
41
- (a) => {
42
- var s;
43
- if (t.value)
44
- if (a === void 0) {
45
- const r = n();
46
- k(t.value, e, Z(r, e)), (s = r.dispose) == null || s.call(r);
47
- } else
48
- k(t.value, e, l());
49
- },
50
- o
51
- ), B = (l, t, e) => l.map(([n, o]) => W(
52
- n,
38
+ return n.forEach((t) => delete e[t]), e;
39
+ }, X = (l, n, e, t, o = {}) => _(l, (a) => {
40
+ var s;
41
+ if (n.value)
42
+ if (a === void 0) {
43
+ const r = t();
44
+ M(n.value, e, oe(r, e)), (s = r.dispose) == null || s.call(r);
45
+ } else
46
+ M(n.value, e, l());
47
+ }, o), y = (l, n, e) => l.map(([t, o]) => X(
53
48
  t,
49
+ n,
54
50
  o,
55
51
  e
56
- )), _ = (l, t, e) => Object.keys(l).map((n) => W(
57
- () => l[n],
58
- t,
52
+ )), C = (l, n, e) => Object.keys(l).map((t) => X(
53
+ () => l[t],
59
54
  n,
55
+ t,
60
56
  e
61
- )), le = /* @__PURE__ */ f({
57
+ )), ue = /* @__PURE__ */ d({
62
58
  __name: "Bloom",
63
59
  props: {
64
60
  blendFunction: {},
@@ -68,9 +64,9 @@ const $ = Symbol(), m = (l) => {
68
64
  luminanceSmoothing: {},
69
65
  mipmapBlur: { type: Boolean, default: void 0 }
70
66
  },
71
- setup(l, { expose: t }) {
72
- const e = l, { pass: n, effect: o } = m(() => new y(e));
73
- return t({ pass: n, effect: o }), B(
67
+ setup(l, { expose: n }) {
68
+ const e = l, { pass: t, effect: o } = p(() => new P(e));
69
+ return n({ pass: t, effect: o }), y(
74
70
  [
75
71
  // blendFunction is not updated, because it has no setter in BloomEffect
76
72
  [() => e.intensity, "intensity"],
@@ -79,10 +75,10 @@ const $ = Symbol(), m = (l) => {
79
75
  [() => e.luminanceThreshold, "luminanceMaterial.threshold"]
80
76
  ],
81
77
  o,
82
- () => new y()
78
+ () => new P()
83
79
  ), (a, s) => null;
84
80
  }
85
- }), ae = /* @__PURE__ */ f({
81
+ }), ie = /* @__PURE__ */ d({
86
82
  __name: "DepthOfField",
87
83
  props: {
88
84
  blendFunction: {},
@@ -95,9 +91,9 @@ const $ = Symbol(), m = (l) => {
95
91
  resolutionX: {},
96
92
  resolutionY: {}
97
93
  },
98
- setup(l, { expose: t }) {
99
- const e = l, { camera: n } = h(), { pass: o, effect: a } = m(() => new F(n.value, e));
100
- return t({ pass: o, effect: a }), B(
94
+ setup(l, { expose: n }) {
95
+ const e = l, { camera: t } = b(), { pass: o, effect: a } = p(() => new R(t.value, e));
96
+ return n({ pass: o, effect: a }), y(
101
97
  [
102
98
  // blendFunction is not updated, because it has no setter in BloomEffect
103
99
  [() => e.worldFocusDistance, "circleOfConfusionMaterial.worldFocusDistance"],
@@ -110,24 +106,24 @@ const $ = Symbol(), m = (l) => {
110
106
  [() => e.resolutionY, "resolution.height"]
111
107
  ],
112
108
  a,
113
- () => new F()
109
+ () => new R()
114
110
  ), (s, r) => null;
115
111
  }
116
112
  });
117
113
  let v;
118
- function A() {
114
+ function N() {
119
115
  var l;
120
116
  if (v !== void 0)
121
117
  return v;
122
118
  try {
123
- let t;
119
+ let n;
124
120
  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;
121
+ return v = !!(window.WebGL2RenderingContext && (n = e.getContext("webgl2"))), n && ((l = n.getExtension("WEBGL_lose_context")) == null || l.loseContext()), v;
126
122
  } catch {
127
123
  return v = !1;
128
124
  }
129
125
  }
130
- const se = /* @__PURE__ */ f({
126
+ const ce = /* @__PURE__ */ d({
131
127
  __name: "EffectComposer",
132
128
  props: {
133
129
  enabled: { type: Boolean, default: !0 },
@@ -138,47 +134,49 @@ const se = /* @__PURE__ */ f({
138
134
  resolutionScale: {},
139
135
  autoClear: { type: Boolean, default: !0 },
140
136
  multisampling: { default: 0 },
141
- frameBufferType: { default: z }
137
+ frameBufferType: { default: A }
142
138
  },
143
- setup(l) {
144
- const t = l, { scene: e, camera: n, renderer: o, sizes: a } = h(), s = w(null);
145
- let r = null, i = null;
146
- Y($, s);
147
- const d = () => {
148
- s.value && (i = new H(e.value, n.value), i.enabled = !1, s.value.addPass(i), t.resolutionScale !== void 0 && A() && (r = new I({
149
- normalBuffer: i.texture,
139
+ emits: ["render"],
140
+ setup(l, { expose: n, emit: e }) {
141
+ const t = l, o = e, { scene: a, camera: s, renderer: r, sizes: i, render: f } = b(), u = E(null);
142
+ let g = null, h = null;
143
+ H(W, u), n({ composer: u });
144
+ const Y = () => {
145
+ u.value && (h = new Q(a.value, s.value), h.enabled = !1, u.value.addPass(h), t.resolutionScale !== void 0 && N() && (g = new Z({
146
+ normalBuffer: h.texture,
150
147
  resolutionScale: t.resolutionScale
151
- }), r.enabled = !1, s.value.addPass(r)));
152
- }, c = N(() => {
153
- const u = new P(), p = {
154
- depthBuffer: t.depthBuffer !== void 0 ? t.depthBuffer : u.inputBuffer.depthBuffer,
155
- stencilBuffer: t.stencilBuffer !== void 0 ? t.stencilBuffer : u.inputBuffer.stencilBuffer,
156
- multisampling: A() ? 0 : t.multisampling !== void 0 ? t.multisampling : u.multisampling,
157
- frameBufferType: t.frameBufferType !== void 0 ? t.frameBufferType : z
148
+ }), g.enabled = !1, u.value.addPass(g)));
149
+ }, V = $(() => {
150
+ const c = new O(), m = {
151
+ depthBuffer: t.depthBuffer !== void 0 ? t.depthBuffer : c.inputBuffer.depthBuffer,
152
+ stencilBuffer: t.stencilBuffer !== void 0 ? t.stencilBuffer : c.inputBuffer.stencilBuffer,
153
+ multisampling: N() ? t.multisampling !== void 0 ? t.multisampling : c.multisampling : 0,
154
+ frameBufferType: t.frameBufferType !== void 0 ? t.frameBufferType : A
158
155
  };
159
- return u.dispose(), p;
160
- }), b = () => {
161
- !o.value && !e.value && !n.value || (s.value = new P(o.value, c.value), s.value.addPass(new q(e.value, n.value)), t.disableNormalPass || d());
156
+ return c.dispose(), m;
157
+ }), F = () => {
158
+ !r.value && !a.value && !s.value || (u.value = new O(r.value, V.value), u.value.addPass(new J(a.value, s.value)), t.disableNormalPass || Y());
162
159
  };
163
- g([o, e, n, () => t.disableNormalPass], () => {
164
- !a.width.value || !a.height.value || b();
165
- }), g(() => [a.width.value, a.height.value], ([u, p]) => {
166
- !u && !p || (s.value ? s.value.setSize(u, p) : b());
160
+ _([r, a, s, () => t.disableNormalPass], () => {
161
+ !i.width.value || !i.height.value || F();
162
+ }), _(() => [i.width.value, i.height.value], ([c, m]) => {
163
+ !c && !m || (u.value ? u.value.setSize(c, m) : F());
167
164
  }, {
168
165
  immediate: !0
169
166
  });
170
- const { onLoop: j } = Q();
171
- return j(({ delta: u }) => {
172
- if (t.enabled && o.value && s.value && a.width.value && a.height.value) {
173
- const p = o.value.autoClear;
174
- o.value.autoClear = t.autoClear, t.stencilBuffer && !t.autoClear && o.value.clearStencil(), s.value.render(u), o.value.autoClear = p;
167
+ const { render: U } = ne();
168
+ return U(() => {
169
+ if (t.enabled && r.value && u.value && i.width.value && i.height.value && f.frames.value > 0) {
170
+ const c = r.value.autoClear;
171
+ r.value.autoClear = t.autoClear, t.stencilBuffer && !t.autoClear && r.value.clearStencil(), u.value.render(), o("render", u.value), r.value.autoClear = c;
175
172
  }
176
- }), M(() => {
177
- var u;
178
- (u = s.value) == null || u.dispose();
179
- }), (u, p) => V(u.$slots, "default");
173
+ f.priority.value = 0, f.mode.value === "always" ? f.frames.value = 1 : f.frames.value = Math.max(0, f.frames.value - 1);
174
+ }), L(() => {
175
+ var c;
176
+ (c = u.value) == null || c.dispose();
177
+ }), (c, m) => I(c.$slots, "default");
180
178
  }
181
- }), re = /* @__PURE__ */ f({
179
+ }), fe = /* @__PURE__ */ d({
182
180
  __name: "Glitch",
183
181
  props: {
184
182
  blendFunction: {},
@@ -193,23 +191,23 @@ const se = /* @__PURE__ */ f({
193
191
  perturbationMap: {},
194
192
  dtSize: {}
195
193
  },
196
- setup(l, { expose: t }) {
197
- const e = l, { pass: n, effect: o } = m(() => new S(e));
198
- return t({ pass: n, effect: o }), E(() => {
194
+ setup(l, { expose: n }) {
195
+ const e = l, { pass: t, effect: o } = p(() => new S(e));
196
+ return n({ pass: t, effect: o }), x(() => {
199
197
  const a = () => {
200
198
  if (e.mode !== void 0)
201
- return e.active === !1 ? K.DISABLED : e.mode;
199
+ return e.active === !1 ? ee.DISABLED : e.mode;
202
200
  const s = new S(), r = s.mode;
203
201
  return s.dispose(), r;
204
202
  };
205
203
  o.value && (o.value.mode = a());
206
- }), _(
207
- x(e, ["active", "mode", "blendFunction"]),
204
+ }), C(
205
+ B(e, ["active", "mode", "blendFunction"]),
208
206
  o,
209
207
  () => new S()
210
208
  ), (a, s) => null;
211
209
  }
212
- }), ue = /* @__PURE__ */ f({
210
+ }), de = /* @__PURE__ */ d({
213
211
  __name: "Outline",
214
212
  props: {
215
213
  outlinedObjects: {},
@@ -228,8 +226,8 @@ const se = /* @__PURE__ */ f({
228
226
  hiddenEdgeColor: {},
229
227
  visibleEdgeColor: {}
230
228
  },
231
- setup(l, { expose: t }) {
232
- const e = l, n = (c) => c !== void 0 ? C(c).getHex() : void 0, { camera: o, scene: a } = h(), s = {
229
+ setup(l, { expose: n }) {
230
+ const e = l, t = (u) => u !== void 0 ? w(u).getHex() : void 0, { camera: o, scene: a } = b(), s = {
233
231
  blur: e.blur,
234
232
  xRay: e.xRay,
235
233
  kernelSize: e.kernelSize,
@@ -242,25 +240,25 @@ const se = /* @__PURE__ */ f({
242
240
  multisampling: e.multisampling,
243
241
  patternTexture: e.patternTexture,
244
242
  resolutionScale: e.resolutionScale,
245
- hiddenEdgeColor: n(e.hiddenEdgeColor),
246
- visibleEdgeColor: n(e.visibleEdgeColor)
247
- }, { pass: r, effect: i } = m(() => new R(a.value, o.value, s));
248
- t({ pass: r, effect: i }), g(
243
+ hiddenEdgeColor: t(e.hiddenEdgeColor),
244
+ visibleEdgeColor: t(e.visibleEdgeColor)
245
+ }, { pass: r, effect: i } = p(() => new D(a.value, o.value, s));
246
+ n({ pass: r, effect: i }), _(
249
247
  [() => e.outlinedObjects, i],
250
248
  // watchEffect is intentionally not used here as it would result in an endless loop
251
249
  () => {
252
- var c;
253
- (c = i.value) == null || c.selection.set(e.outlinedObjects || []);
250
+ var u;
251
+ (u = i.value) == null || u.selection.set(e.outlinedObjects || []);
254
252
  },
255
253
  {
256
254
  immediate: !0
257
255
  }
258
256
  );
259
- const d = N(() => ({
260
- hiddenEdgeColor: e.hiddenEdgeColor ? C(e.hiddenEdgeColor) : void 0,
261
- visibleEdgeColor: e.visibleEdgeColor ? C(e.visibleEdgeColor) : void 0
257
+ const f = $(() => ({
258
+ hiddenEdgeColor: e.hiddenEdgeColor ? w(e.hiddenEdgeColor) : void 0,
259
+ visibleEdgeColor: e.visibleEdgeColor ? w(e.visibleEdgeColor) : void 0
262
260
  }));
263
- return B(
261
+ return y(
264
262
  [
265
263
  /* some properties are not updated because of different reasons:
266
264
  resolutionX - has no setter in OutlineEffect
@@ -276,64 +274,65 @@ const se = /* @__PURE__ */ f({
276
274
  [() => e.edgeStrength, "edgeStrength"],
277
275
  [() => e.patternScale, "patternScale"],
278
276
  [() => e.multisampling, "multisampling"],
279
- [() => d.value.hiddenEdgeColor, "hiddenEdgeColor"],
280
- [() => d.value.visibleEdgeColor, "visibleEdgeColor"]
277
+ [() => f.value.hiddenEdgeColor, "hiddenEdgeColor"],
278
+ [() => f.value.visibleEdgeColor, "visibleEdgeColor"]
281
279
  ],
282
280
  i,
283
- () => new R()
284
- ), (c, b) => null;
281
+ () => new D()
282
+ ), (u, g) => null;
285
283
  }
286
- }), ie = /* @__PURE__ */ f({
284
+ }), pe = /* @__PURE__ */ d({
287
285
  __name: "Pixelation",
288
286
  props: {
289
287
  granularity: {}
290
288
  },
291
- setup(l, { expose: t }) {
292
- const e = l, { pass: n, effect: o } = m(() => new O(e.granularity));
293
- return t({ pass: n, effect: o }), _(
289
+ setup(l, { expose: n }) {
290
+ const e = l, { pass: t, effect: o } = p(() => new T(e.granularity));
291
+ return n({ pass: t, effect: o }), C(
294
292
  e,
295
293
  o,
296
- () => new O()
294
+ () => new T()
297
295
  ), (a, s) => null;
298
296
  }
299
- }), ce = /* @__PURE__ */ f({
297
+ }), me = /* @__PURE__ */ d({
300
298
  __name: "Vignette",
301
299
  props: {
302
- technique: { default: J.DEFAULT },
303
- blendFunction: { default: L.NORMAL },
300
+ technique: { default: te.DEFAULT },
301
+ blendFunction: { default: G.NORMAL },
304
302
  offset: { default: 0.5 },
305
303
  darkness: { default: 0.5 }
306
304
  },
307
- setup(l, { expose: t }) {
308
- const e = l, { pass: n, effect: o } = m(() => new D(e));
309
- return t({ pass: n, effect: o }), _(
310
- x(e, ["blendFunction"]),
305
+ setup(l, { expose: n }) {
306
+ const e = l, { pass: t, effect: o } = p(() => new z(e));
307
+ return n({ pass: t, effect: o }), C(
308
+ B(e, ["blendFunction"]),
311
309
  o,
312
- () => new D()
310
+ () => new z()
313
311
  ), (a, s) => null;
314
312
  }
315
- }), fe = /* @__PURE__ */ f({
313
+ }), ve = /* @__PURE__ */ d({
316
314
  __name: "Noise",
317
315
  props: {
318
316
  premultiply: { type: Boolean, default: !1 },
319
- blendFunction: { default: L.SCREEN }
317
+ blendFunction: { default: G.SCREEN }
320
318
  },
321
- setup(l, { expose: t }) {
322
- const e = l, { pass: n, effect: o } = m(() => new T(e));
323
- return t({ pass: n, effect: o }), _(
324
- x(e, ["blendFunction"]),
319
+ setup(l, { expose: n }) {
320
+ const e = l, { pass: t, effect: o } = p(() => new k(e));
321
+ return n({ pass: t, effect: o }), C(
322
+ B(e, ["blendFunction"]),
325
323
  o,
326
- () => new T()
324
+ () => new k()
327
325
  ), (a, s) => null;
328
326
  }
329
327
  });
330
328
  export {
331
- le as Bloom,
332
- ae as DepthOfField,
333
- se as EffectComposer,
334
- re as Glitch,
335
- fe as Noise,
336
- ue as Outline,
337
- ie as Pixelation,
338
- ce as Vignette
329
+ ue as Bloom,
330
+ ie as DepthOfField,
331
+ ce as EffectComposer,
332
+ fe as Glitch,
333
+ ve as Noise,
334
+ de as Outline,
335
+ pe as Pixelation,
336
+ me as Vignette,
337
+ p as useEffect
339
338
  };
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * name: @tresjs/post-processing
3
- * version: v0.7.0
4
- * (c) 2023
3
+ * version: v1.0.0-next.0
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,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("vue"),require("postprocessing"),require("@tresjs/core"),require("three")):typeof define=="function"&&define.amd?define(["exports","vue","postprocessing","@tresjs/core","three"],u):(s=typeof globalThis<"u"?globalThis:s||self,u(s["tres-postprocessing"]={},s.Vue,s.Postprocessing,s.TresjsCore,s.Three))})(this,function(s,u,r,m,g){"use strict";const B=Symbol(),h=o=>{const n=u.inject(B),e=u.shallowRef(null),t=u.shallowRef(null),{scene:l,camera:a}=m.useTresContext();u.watchEffect(()=>{!a.value||!(t!=null&&t.value)||(t.value.mainCamera=a.value)});let i=()=>{};return i=u.watchEffect(()=>{!a.value||!(n!=null&&n.value)||!l.value||(i(),!t.value&&(t.value=o(),e.value=new r.EffectPass(a.value,t.value),n.value.addPass(e.value)))}),u.onUnmounted(()=>{var c,d,v;e.value&&((c=n==null?void 0:n.value)==null||c.removePass(e.value)),(d=t.value)==null||d.dispose(),(v=e.value)==null||v.dispose()}),{pass:e,effect:t}},y=/([^[.\]])+/g,T=(o,n)=>{if(!n)return;const e=Array.isArray(n)?n:n.match(y);return e==null?void 0:e.reduce((t,l)=>t&&t[l],o)},x=(o,n,e)=>{const t=Array.isArray(n)?n:n.match(y);t&&t.reduce((l,a,i)=>(l[a]===void 0&&(l[a]={}),i===t.length-1&&(l[a]=e),l[a]),o)},w=(o,n)=>{const e={...o};return n.forEach(t=>delete e[t]),e},F=(o,n,e,t,l={})=>u.watch(o,a=>{var i;if(n.value)if(a===void 0){const c=t();x(n.value,e,T(c,e)),(i=c.dispose)==null||i.call(c)}else x(n.value,e,o())},l),b=(o,n,e)=>o.map(([t,l])=>F(t,n,l,e)),E=(o,n,e)=>Object.keys(o).map(t=>F(()=>o[t],n,t,e)),R=u.defineComponent({__name:"Bloom",props:{blendFunction:{},intensity:{},kernelSize:{},luminanceThreshold:{},luminanceSmoothing:{},mipmapBlur:{type:Boolean,default:void 0}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=h(()=>new r.BloomEffect(e));return n({pass:t,effect:l}),b([[()=>e.intensity,"intensity"],[()=>e.kernelSize,"kernelSize"],[()=>e.luminanceSmoothing,"luminanceMaterial.smoothing"],[()=>e.luminanceThreshold,"luminanceMaterial.threshold"]],l,()=>new r.BloomEffect),(a,i)=>null}}),O=u.defineComponent({__name:"DepthOfField",props:{blendFunction:{},worldFocusDistance:{},worldFocusRange:{},focusDistance:{},focusRange:{},bokehScale:{},resolutionScale:{},resolutionX:{},resolutionY:{}},setup(o,{expose:n}){const e=o,{camera:t}=m.useTresContext(),{pass:l,effect:a}=h(()=>new r.DepthOfFieldEffect(t.value,e));return n({pass:l,effect:a}),b([[()=>e.worldFocusDistance,"circleOfConfusionMaterial.worldFocusDistance"],[()=>e.focusDistance,"circleOfConfusionMaterial.focusDistance"],[()=>e.worldFocusRange,"circleOfConfusionMaterial.worldFocusRange"],[()=>e.focusRange,"circleOfConfusionMaterial.focusRange"],[()=>e.bokehScale,"bokehScale"],[()=>e.resolutionScale,"blurPass.resolution.scale"],[()=>e.resolutionX,"resolution.width"],[()=>e.resolutionY,"resolution.height"]],a,()=>new r.DepthOfFieldEffect),(i,c)=>null}});let _;function P(){var o;if(_!==void 0)return _;try{let n;const e=document.createElement("canvas");return _=!!(window.WebGL2RenderingContext&&(n=e.getContext("webgl2"))),n&&((o=n.getExtension("WEBGL_lose_context"))==null||o.loseContext()),_}catch{return _=!1}}const z=u.defineComponent({__name:"EffectComposer",props:{enabled:{type:Boolean,default:!0},children:{},depthBuffer:{type:Boolean,default:void 0},disableNormalPass:{type:Boolean,default:!1},stencilBuffer:{type:Boolean,default:void 0},resolutionScale:{},autoClear:{type:Boolean,default:!0},multisampling:{default:0},frameBufferType:{default:g.HalfFloatType}},setup(o){const n=o,{scene:e,camera:t,renderer:l,sizes:a}=m.useTresContext(),i=u.shallowRef(null);let c=null,d=null;u.provide(B,i);const v=()=>{i.value&&(d=new r.NormalPass(e.value,t.value),d.enabled=!1,i.value.addPass(d),n.resolutionScale!==void 0&&P()&&(c=new r.DepthDownsamplingPass({normalBuffer:d.texture,resolutionScale:n.resolutionScale}),c.enabled=!1,i.value.addPass(c)))},p=u.computed(()=>{const f=new r.EffectComposer,C={depthBuffer:n.depthBuffer!==void 0?n.depthBuffer:f.inputBuffer.depthBuffer,stencilBuffer:n.stencilBuffer!==void 0?n.stencilBuffer:f.inputBuffer.stencilBuffer,multisampling:P()?0:n.multisampling!==void 0?n.multisampling:f.multisampling,frameBufferType:n.frameBufferType!==void 0?n.frameBufferType:g.HalfFloatType};return f.dispose(),C}),S=()=>{!l.value&&!e.value&&!t.value||(i.value=new r.EffectComposer(l.value,p.value),i.value.addPass(new r.RenderPass(e.value,t.value)),n.disableNormalPass||v())};u.watch([l,e,t,()=>n.disableNormalPass],()=>{!a.width.value||!a.height.value||S()}),u.watch(()=>[a.width.value,a.height.value],([f,C])=>{!f&&!C||(i.value?i.value.setSize(f,C):S())},{immediate:!0});const{onLoop:j}=m.useRenderLoop();return j(({delta:f})=>{if(n.enabled&&l.value&&i.value&&a.width.value&&a.height.value){const C=l.value.autoClear;l.value.autoClear=n.autoClear,n.stencilBuffer&&!n.autoClear&&l.value.clearStencil(),i.value.render(f),l.value.autoClear=C}}),u.onUnmounted(()=>{var f;(f=i.value)==null||f.dispose()}),(f,C)=>u.renderSlot(f.$slots,"default")}}),D=u.defineComponent({__name:"Glitch",props:{blendFunction:{},delay:{},duration:{},strength:{},mode:{},active:{type:Boolean},ratio:{},columns:{},chromaticAberrationOffset:{},perturbationMap:{},dtSize:{}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=h(()=>new r.GlitchEffect(e));return n({pass:t,effect:l}),u.watchEffect(()=>{const a=()=>{if(e.mode!==void 0)return e.active===!1?r.GlitchMode.DISABLED:e.mode;const i=new r.GlitchEffect,c=i.mode;return i.dispose(),c};l.value&&(l.value.mode=a())}),E(w(e,["active","mode","blendFunction"]),l,()=>new r.GlitchEffect),(a,i)=>null}}),k=u.defineComponent({__name:"Outline",props:{outlinedObjects:{},blur:{type:Boolean,default:void 0},xRay:{type:Boolean,default:void 0},kernelSize:{},pulseSpeed:{},resolutionX:{},resolutionY:{},edgeStrength:{},patternScale:{},multisampling:{},blendFunction:{},patternTexture:{},resolutionScale:{},hiddenEdgeColor:{},visibleEdgeColor:{}},setup(o,{expose:n}){const e=o,t=p=>p!==void 0?m.normalizeColor(p).getHex():void 0,{camera:l,scene:a}=m.useTresContext(),i={blur:e.blur,xRay:e.xRay,kernelSize:e.kernelSize,pulseSpeed:e.pulseSpeed,resolutionX:e.resolutionX,resolutionY:e.resolutionY,patternScale:e.patternScale,edgeStrength:e.edgeStrength,blendFunction:e.blendFunction,multisampling:e.multisampling,patternTexture:e.patternTexture,resolutionScale:e.resolutionScale,hiddenEdgeColor:t(e.hiddenEdgeColor),visibleEdgeColor:t(e.visibleEdgeColor)},{pass:c,effect:d}=h(()=>new r.OutlineEffect(a.value,l.value,i));n({pass:c,effect:d}),u.watch([()=>e.outlinedObjects,d],()=>{var p;(p=d.value)==null||p.selection.set(e.outlinedObjects||[])},{immediate:!0});const v=u.computed(()=>({hiddenEdgeColor:e.hiddenEdgeColor?m.normalizeColor(e.hiddenEdgeColor):void 0,visibleEdgeColor:e.visibleEdgeColor?m.normalizeColor(e.visibleEdgeColor):void 0}));return b([[()=>e.blur,"blur"],[()=>e.xRay,"xRay"],[()=>e.pulseSpeed,"pulseSpeed"],[()=>e.kernelSize,"kernelSize"],[()=>e.edgeStrength,"edgeStrength"],[()=>e.patternScale,"patternScale"],[()=>e.multisampling,"multisampling"],[()=>v.value.hiddenEdgeColor,"hiddenEdgeColor"],[()=>v.value.visibleEdgeColor,"visibleEdgeColor"]],d,()=>new r.OutlineEffect),(p,S)=>null}}),A=u.defineComponent({__name:"Pixelation",props:{granularity:{}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=h(()=>new r.PixelationEffect(e.granularity));return n({pass:t,effect:l}),E(e,l,()=>new r.PixelationEffect),(a,i)=>null}}),M=u.defineComponent({__name:"Vignette",props:{technique:{default:r.VignetteTechnique.DEFAULT},blendFunction:{default:r.BlendFunction.NORMAL},offset:{default:.5},darkness:{default:.5}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=h(()=>new r.VignetteEffect(e));return n({pass:t,effect:l}),E(w(e,["blendFunction"]),l,()=>new r.VignetteEffect),(a,i)=>null}}),N=u.defineComponent({__name:"Noise",props:{premultiply:{type:Boolean,default:!1},blendFunction:{default:r.BlendFunction.SCREEN}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=h(()=>new r.NoiseEffect(e));return n({pass:t,effect:l}),E(w(e,["blendFunction"]),l,()=>new r.NoiseEffect),(a,i)=>null}});s.Bloom=R,s.DepthOfField=O,s.EffectComposer=z,s.Glitch=D,s.Noise=N,s.Outline=k,s.Pixelation=A,s.Vignette=M,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
8
+ (function(f,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue"),require("postprocessing"),require("@tresjs/core"),require("three")):typeof define=="function"&&define.amd?define(["exports","vue","postprocessing","@tresjs/core","three"],a):(f=typeof globalThis<"u"?globalThis:f||self,a(f["tres-postprocessing"]={},f.Vue,f.Postprocessing,f.TresjsCore,f.Three))})(this,function(f,a,r,h,B){"use strict";const y=Symbol("effectComposer"),v=o=>{const n=a.inject(y),e=a.shallowRef(null),t=a.shallowRef(null),{scene:l,camera:i}=h.useTresContext();a.watchEffect(()=>{!i.value||!(t!=null&&t.value)||(t.value.mainCamera=i.value)});let u=()=>{};return u=a.watchEffect(()=>{!i.value||!(n!=null&&n.value)||!l.value||(u(),!t.value&&(t.value=o(),e.value=new r.EffectPass(i.value,t.value),n.value.addPass(e.value)))}),a.onUnmounted(()=>{var s,d,p;e.value&&((s=n==null?void 0:n.value)==null||s.removePass(e.value)),(d=t.value)==null||d.dispose(),(p=e.value)==null||p.dispose()}),{pass:e,effect:t}},x=/([^[.\]])+/g,R=(o,n)=>{if(!n)return;const e=Array.isArray(n)?n:n.match(x);return e==null?void 0:e.reduce((t,l)=>t&&t[l],o)},F=(o,n,e)=>{const t=Array.isArray(n)?n:n.match(x);t&&t.reduce((l,i,u)=>(l[i]===void 0&&(l[i]={}),u===t.length-1&&(l[i]=e),l[i]),o)},S=(o,n)=>{const e={...o};return n.forEach(t=>delete e[t]),e},P=(o,n,e,t,l={})=>a.watch(o,i=>{var u;if(n.value)if(i===void 0){const s=t();F(n.value,e,R(s,e)),(u=s.dispose)==null||u.call(s)}else F(n.value,e,o())},l),g=(o,n,e)=>o.map(([t,l])=>P(t,n,l,e)),_=(o,n,e)=>Object.keys(o).map(t=>P(()=>o[t],n,t,e)),z=a.defineComponent({__name:"Bloom",props:{blendFunction:{},intensity:{},kernelSize:{},luminanceThreshold:{},luminanceSmoothing:{},mipmapBlur:{type:Boolean,default:void 0}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=v(()=>new r.BloomEffect(e));return n({pass:t,effect:l}),g([[()=>e.intensity,"intensity"],[()=>e.kernelSize,"kernelSize"],[()=>e.luminanceSmoothing,"luminanceMaterial.smoothing"],[()=>e.luminanceThreshold,"luminanceMaterial.threshold"]],l,()=>new r.BloomEffect),(i,u)=>null}}),D=a.defineComponent({__name:"DepthOfField",props:{blendFunction:{},worldFocusDistance:{},worldFocusRange:{},focusDistance:{},focusRange:{},bokehScale:{},resolutionScale:{},resolutionX:{},resolutionY:{}},setup(o,{expose:n}){const e=o,{camera:t}=h.useTresContext(),{pass:l,effect:i}=v(()=>new r.DepthOfFieldEffect(t.value,e));return n({pass:l,effect:i}),g([[()=>e.worldFocusDistance,"circleOfConfusionMaterial.worldFocusDistance"],[()=>e.focusDistance,"circleOfConfusionMaterial.focusDistance"],[()=>e.worldFocusRange,"circleOfConfusionMaterial.worldFocusRange"],[()=>e.focusRange,"circleOfConfusionMaterial.focusRange"],[()=>e.bokehScale,"bokehScale"],[()=>e.resolutionScale,"blurPass.resolution.scale"],[()=>e.resolutionX,"resolution.width"],[()=>e.resolutionY,"resolution.height"]],i,()=>new r.DepthOfFieldEffect),(u,s)=>null}});let C;function T(){var o;if(C!==void 0)return C;try{let n;const e=document.createElement("canvas");return C=!!(window.WebGL2RenderingContext&&(n=e.getContext("webgl2"))),n&&((o=n.getExtension("WEBGL_lose_context"))==null||o.loseContext()),C}catch{return C=!1}}const M=a.defineComponent({__name:"EffectComposer",props:{enabled:{type:Boolean,default:!0},children:{},depthBuffer:{type:Boolean,default:void 0},disableNormalPass:{type:Boolean,default:!1},stencilBuffer:{type:Boolean,default:void 0},resolutionScale:{},autoClear:{type:Boolean,default:!0},multisampling:{default:0},frameBufferType:{default:B.HalfFloatType}},emits:["render"],setup(o,{expose:n,emit:e}){const t=o,l=e,{scene:i,camera:u,renderer:s,sizes:d,render:p}=h.useTresContext(),c=a.shallowRef(null);let w=null,b=null;a.provide(y,c),n({composer:c});const L=()=>{c.value&&(b=new r.NormalPass(i.value,u.value),b.enabled=!1,c.value.addPass(b),t.resolutionScale!==void 0&&T()&&(w=new r.DepthDownsamplingPass({normalBuffer:b.texture,resolutionScale:t.resolutionScale}),w.enabled=!1,c.value.addPass(w)))},$=a.computed(()=>{const m=new r.EffectComposer,E={depthBuffer:t.depthBuffer!==void 0?t.depthBuffer:m.inputBuffer.depthBuffer,stencilBuffer:t.stencilBuffer!==void 0?t.stencilBuffer:m.inputBuffer.stencilBuffer,multisampling:T()?t.multisampling!==void 0?t.multisampling:m.multisampling:0,frameBufferType:t.frameBufferType!==void 0?t.frameBufferType:B.HalfFloatType};return m.dispose(),E}),O=()=>{!s.value&&!i.value&&!u.value||(c.value=new r.EffectComposer(s.value,$.value),c.value.addPass(new r.RenderPass(i.value,u.value)),t.disableNormalPass||L())};a.watch([s,i,u,()=>t.disableNormalPass],()=>{!d.width.value||!d.height.value||O()}),a.watch(()=>[d.width.value,d.height.value],([m,E])=>{!m&&!E||(c.value?c.value.setSize(m,E):O())},{immediate:!0});const{render:q}=h.useLoop();return q(()=>{if(t.enabled&&s.value&&c.value&&d.width.value&&d.height.value&&p.frames.value>0){const m=s.value.autoClear;s.value.autoClear=t.autoClear,t.stencilBuffer&&!t.autoClear&&s.value.clearStencil(),c.value.render(),l("render",c.value),s.value.autoClear=m}p.priority.value=0,p.mode.value==="always"?p.frames.value=1:p.frames.value=Math.max(0,p.frames.value-1)}),a.onUnmounted(()=>{var m;(m=c.value)==null||m.dispose()}),(m,E)=>a.renderSlot(m.$slots,"default")}}),k=a.defineComponent({__name:"Glitch",props:{blendFunction:{},delay:{},duration:{},strength:{},mode:{},active:{type:Boolean},ratio:{},columns:{},chromaticAberrationOffset:{},perturbationMap:{},dtSize:{}},setup(o,{expose:n}){const e=o,{pass:t,effect:l}=v(()=>new r.GlitchEffect(e));return n({pass:t,effect:l}),a.watchEffect(()=>{const i=()=>{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=i())}),_(S(e,["active","mode","blendFunction"]),l,()=>new r.GlitchEffect),(i,u)=>null}}),A=a.defineComponent({__name:"Outline",props:{outlinedObjects:{},blur:{type:Boolean,default:void 0},xRay:{type:Boolean,default:void 0},kernelSize:{},pulseSpeed:{},resolutionX:{},resolutionY:{},edgeStrength:{},patternScale:{},multisampling:{},blendFunction:{},patternTexture:{},resolutionScale:{},hiddenEdgeColor:{},visibleEdgeColor:{}},setup(o,{expose:n}){const e=o,t=c=>c!==void 0?h.normalizeColor(c).getHex():void 0,{camera:l,scene:i}=h.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(i.value,l.value,u));n({pass:s,effect:d}),a.watch([()=>e.outlinedObjects,d],()=>{var c;(c=d.value)==null||c.selection.set(e.outlinedObjects||[])},{immediate:!0});const p=a.computed(()=>({hiddenEdgeColor:e.hiddenEdgeColor?h.normalizeColor(e.hiddenEdgeColor):void 0,visibleEdgeColor:e.visibleEdgeColor?h.normalizeColor(e.visibleEdgeColor):void 0}));return g([[()=>e.blur,"blur"],[()=>e.xRay,"xRay"],[()=>e.pulseSpeed,"pulseSpeed"],[()=>e.kernelSize,"kernelSize"],[()=>e.edgeStrength,"edgeStrength"],[()=>e.patternScale,"patternScale"],[()=>e.multisampling,"multisampling"],[()=>p.value.hiddenEdgeColor,"hiddenEdgeColor"],[()=>p.value.visibleEdgeColor,"visibleEdgeColor"]],d,()=>new r.OutlineEffect),(c,w)=>null}}),N=a.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,l,()=>new r.PixelationEffect),(i,u)=>null}}),j=a.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}),_(S(e,["blendFunction"]),l,()=>new r.VignetteEffect),(i,u)=>null}}),G=a.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}),_(S(e,["blendFunction"]),l,()=>new r.NoiseEffect),(i,u)=>null}});f.Bloom=z,f.DepthOfField=D,f.EffectComposer=M,f.Glitch=k,f.Noise=G,f.Outline=A,f.Pixelation=N,f.Vignette=j,f.useEffect=v,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
@@ -11,7 +11,7 @@ import type { Ref, WatchOptions } from 'vue';
11
11
  * @param {WatchOptions} watchOptions - The options for watch.
12
12
  */
13
13
  export declare const makePropWatcher: <T, E>(propGetter: () => T, target: Ref<E>, propertyPath: string, newPlainObjectFunction: () => E & {
14
- dispose?(): void;
14
+ dispose?: (() => void) | undefined;
15
15
  }, watchOptions?: WatchOptions) => import("vue").WatchStopHandle;
16
16
  /**
17
17
  * Creates multiple prop watchers for monitoring changes to multiple properties and updating a target object.
@@ -23,7 +23,7 @@ export declare const makePropWatcher: <T, E>(propGetter: () => T, target: Ref<E>
23
23
  * @param {() => E & { dispose?(): void }} newPlainObjectFunction - A function that creates a new plain object to retrieve the defaults from with an optional "dispose" method for cleanup.
24
24
  */
25
25
  export declare const makePropWatchers: <E>(propGettersAndPropertyPaths: (string | (() => any))[][], target: Ref<E>, newPlainObjectFunction: () => E & {
26
- dispose?(): void;
26
+ dispose?: (() => void) | undefined;
27
27
  }) => import("vue").WatchStopHandle[];
28
28
  /**
29
29
  * Creates multiple prop watchers via the props object for monitoring changes to multiple properties and updating a target object.
@@ -36,5 +36,5 @@ export declare const makePropWatchers: <E>(propGettersAndPropertyPaths: (string
36
36
  export declare const makePropWatchersUsingAllProps: <E>(props: {
37
37
  [key: string]: any;
38
38
  }, target: Ref<E>, newPlainObjectFunction: () => E & {
39
- dispose?(): void;
39
+ dispose?: (() => void) | undefined;
40
40
  }) => import("vue").WatchStopHandle[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tresjs/post-processing",
3
3
  "type": "module",
4
- "version": "0.7.0",
4
+ "version": "1.0.0-next.0",
5
5
  "packageManager": "pnpm@8.10.2",
6
6
  "description": "Post-processing library for TresJS",
7
7
  "author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
@@ -25,8 +25,8 @@
25
25
  "main": "./dist/tres-postprocessing.js",
26
26
  "module": "./dist/tres-postprocessing.js",
27
27
  "files": [
28
- "dist",
29
- "*.d.ts"
28
+ "*.d.ts",
29
+ "dist"
30
30
  ],
31
31
  "publishConfig": {
32
32
  "access": "public"
@@ -37,44 +37,45 @@
37
37
  "build": "vite build",
38
38
  "preview": "vite preview",
39
39
  "release": "release-it",
40
- "lint": "eslint . --ext .js,.jsx,.ts,.tsx,.vue",
41
- "lint:fix": "pnpm run lint --fix",
40
+ "lint": "eslint .",
41
+ "lint:fix": "eslint . --fix",
42
42
  "docs:dev": "vitepress dev docs",
43
43
  "docs:build": "vitepress build docs",
44
44
  "docs:preview": "vitepress preview docs"
45
45
  },
46
46
  "peerDependencies": {
47
+ "@tresjs/core": ">=4.0",
47
48
  "three": ">=0.133",
48
49
  "vue": ">=3.3"
49
50
  },
50
51
  "dependencies": {
51
- "@tresjs/core": "^3.5.0",
52
- "@unocss/core": "^0.57.3",
53
52
  "@vueuse/core": "^10.6.1",
54
- "postprocessing": "^6.33.3",
55
- "three-stdlib": "^2.28.5"
53
+ "postprocessing": "^6.33.4",
54
+ "three-stdlib": "^2.28.7"
56
55
  },
57
56
  "devDependencies": {
58
57
  "@release-it/conventional-changelog": "^8.0.1",
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",
58
+ "@tresjs/core": "^4.0.0-rc.1",
59
+ "@tresjs/eslint-config": "^1.1.0",
60
+ "@types/three": "^0.159.0",
61
+ "@unocss/core": "^0.58.0",
62
+ "@vitejs/plugin-vue": "^4.5.1",
63
+ "eslint": "^9.3.0",
64
+ "gsap": "^3.12.3",
63
65
  "kolorist": "^1.8.0",
64
66
  "pathe": "^1.1.1",
65
- "prettier": "^3.1.0",
66
67
  "release-it": "^17.0.0",
67
68
  "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",
69
+ "rollup-plugin-visualizer": "^5.10.0",
70
+ "three": "^0.159.0",
71
+ "typescript": "^5.3.2",
72
+ "unocss": "^0.58.0",
73
+ "vite": "^5.0.4",
73
74
  "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"
75
+ "vite-plugin-dts": "3.6.4",
76
+ "vite-svg-loader": "^5.1.0",
77
+ "vitepress": "1.0.0-rc.31",
78
+ "vue": "^3.3.9",
79
+ "vue-tsc": "^1.8.24"
79
80
  }
80
81
  }