lazy-vfx 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lazy-vfx.es.js +309 -300
- package/dist/lazy-vfx.umd.js +6 -6
- package/package.json +14 -8
package/dist/lazy-vfx.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
var
|
|
1
|
+
import he, { useRef as F, useEffect as Se, forwardRef as Ae, useState as xe, useImperativeHandle as _e, useCallback as we, useMemo as ae } from "react";
|
|
2
|
+
import { useFrame as ye } from "@react-three/fiber";
|
|
3
|
+
import { Vector3 as te, Quaternion as Re, Euler as se, Matrix4 as Me, Color as Te, PlaneGeometry as Ce, AdditiveBlending as Oe, DynamicDrawUsage as W } from "three";
|
|
4
|
+
import { useControls as ce, button as le, folder as Z } from "leva";
|
|
5
|
+
import { create as je } from "zustand";
|
|
6
|
+
var Q = { exports: {} }, J = {};
|
|
7
7
|
/**
|
|
8
8
|
* @license React
|
|
9
9
|
* react-jsx-runtime.production.js
|
|
@@ -13,27 +13,27 @@ var Z = { exports: {} }, J = {};
|
|
|
13
13
|
* This source code is licensed under the MIT license found in the
|
|
14
14
|
* LICENSE file in the root directory of this source tree.
|
|
15
15
|
*/
|
|
16
|
-
var
|
|
17
|
-
function
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
function l(
|
|
22
|
-
var
|
|
23
|
-
if (
|
|
24
|
-
|
|
16
|
+
var ue;
|
|
17
|
+
function ke() {
|
|
18
|
+
if (ue) return J;
|
|
19
|
+
ue = 1;
|
|
20
|
+
var o = Symbol.for("react.transitional.element"), v = Symbol.for("react.fragment");
|
|
21
|
+
function l(a, r, i) {
|
|
22
|
+
var p = null;
|
|
23
|
+
if (i !== void 0 && (p = "" + i), r.key !== void 0 && (p = "" + r.key), "key" in r) {
|
|
24
|
+
i = {};
|
|
25
25
|
for (var c in r)
|
|
26
|
-
c !== "key" && (
|
|
27
|
-
} else
|
|
28
|
-
return r =
|
|
29
|
-
$$typeof:
|
|
30
|
-
type:
|
|
31
|
-
key:
|
|
26
|
+
c !== "key" && (i[c] = r[c]);
|
|
27
|
+
} else i = r;
|
|
28
|
+
return r = i.ref, {
|
|
29
|
+
$$typeof: o,
|
|
30
|
+
type: a,
|
|
31
|
+
key: p,
|
|
32
32
|
ref: r !== void 0 ? r : null,
|
|
33
|
-
props:
|
|
33
|
+
props: i
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
return J.Fragment =
|
|
36
|
+
return J.Fragment = v, J.jsx = l, J.jsxs = l, J;
|
|
37
37
|
}
|
|
38
38
|
var q = {};
|
|
39
39
|
/**
|
|
@@ -45,26 +45,26 @@ var q = {};
|
|
|
45
45
|
* This source code is licensed under the MIT license found in the
|
|
46
46
|
* LICENSE file in the root directory of this source tree.
|
|
47
47
|
*/
|
|
48
|
-
var
|
|
49
|
-
function
|
|
50
|
-
return
|
|
51
|
-
function
|
|
48
|
+
var fe;
|
|
49
|
+
function Fe() {
|
|
50
|
+
return fe || (fe = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
51
|
+
function o(e) {
|
|
52
52
|
if (e == null) return null;
|
|
53
53
|
if (typeof e == "function")
|
|
54
|
-
return e.$$typeof ===
|
|
54
|
+
return e.$$typeof === M ? null : e.displayName || e.name || null;
|
|
55
55
|
if (typeof e == "string") return e;
|
|
56
56
|
switch (e) {
|
|
57
|
-
case
|
|
57
|
+
case A:
|
|
58
58
|
return "Fragment";
|
|
59
|
-
case
|
|
59
|
+
case D:
|
|
60
60
|
return "Profiler";
|
|
61
|
-
case
|
|
61
|
+
case x:
|
|
62
62
|
return "StrictMode";
|
|
63
63
|
case f:
|
|
64
64
|
return "Suspense";
|
|
65
|
-
case
|
|
65
|
+
case Y:
|
|
66
66
|
return "SuspenseList";
|
|
67
|
-
case
|
|
67
|
+
case w:
|
|
68
68
|
return "Activity";
|
|
69
69
|
}
|
|
70
70
|
if (typeof e == "object")
|
|
@@ -73,64 +73,64 @@ function we() {
|
|
|
73
73
|
), e.$$typeof) {
|
|
74
74
|
case h:
|
|
75
75
|
return "Portal";
|
|
76
|
-
case
|
|
76
|
+
case _:
|
|
77
77
|
return e.displayName || "Context";
|
|
78
78
|
case N:
|
|
79
79
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
80
|
-
case
|
|
80
|
+
case E:
|
|
81
81
|
var t = e.render;
|
|
82
82
|
return e = e.displayName, e || (e = t.displayName || t.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
83
|
-
case
|
|
84
|
-
return t = e.displayName || null, t !== null ? t :
|
|
85
|
-
case
|
|
83
|
+
case $:
|
|
84
|
+
return t = e.displayName || null, t !== null ? t : o(e.type) || "Memo";
|
|
85
|
+
case y:
|
|
86
86
|
t = e._payload, e = e._init;
|
|
87
87
|
try {
|
|
88
|
-
return
|
|
88
|
+
return o(e(t));
|
|
89
89
|
} catch {
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
return null;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function v(e) {
|
|
95
95
|
return "" + e;
|
|
96
96
|
}
|
|
97
97
|
function l(e) {
|
|
98
98
|
try {
|
|
99
|
-
|
|
99
|
+
v(e);
|
|
100
100
|
var t = !1;
|
|
101
101
|
} catch {
|
|
102
102
|
t = !0;
|
|
103
103
|
}
|
|
104
104
|
if (t) {
|
|
105
105
|
t = console;
|
|
106
|
-
var u = t.error,
|
|
106
|
+
var u = t.error, d = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
107
107
|
return u.call(
|
|
108
108
|
t,
|
|
109
109
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
110
|
-
|
|
111
|
-
),
|
|
110
|
+
d
|
|
111
|
+
), v(e);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
function
|
|
115
|
-
if (e ===
|
|
116
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
114
|
+
function a(e) {
|
|
115
|
+
if (e === A) return "<>";
|
|
116
|
+
if (typeof e == "object" && e !== null && e.$$typeof === y)
|
|
117
117
|
return "<...>";
|
|
118
118
|
try {
|
|
119
|
-
var t =
|
|
119
|
+
var t = o(e);
|
|
120
120
|
return t ? "<" + t + ">" : "<...>";
|
|
121
121
|
} catch {
|
|
122
122
|
return "<...>";
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
function r() {
|
|
126
|
-
var e =
|
|
126
|
+
var e = C.A;
|
|
127
127
|
return e === null ? null : e.getOwner();
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function i() {
|
|
130
130
|
return Error("react-stack-top-frame");
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
if (
|
|
132
|
+
function p(e) {
|
|
133
|
+
if (L.call(e, "key")) {
|
|
134
134
|
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
135
135
|
if (t && t.isReactWarning) return !1;
|
|
136
136
|
}
|
|
@@ -148,23 +148,23 @@ function we() {
|
|
|
148
148
|
configurable: !0
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
|
-
function
|
|
152
|
-
var e =
|
|
153
|
-
return
|
|
151
|
+
function T() {
|
|
152
|
+
var e = o(this.type);
|
|
153
|
+
return X[e] || (X[e] = !0, console.error(
|
|
154
154
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
155
155
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
156
156
|
}
|
|
157
|
-
function
|
|
158
|
-
var
|
|
157
|
+
function R(e, t, u, d, H, re) {
|
|
158
|
+
var m = u.ref;
|
|
159
159
|
return e = {
|
|
160
|
-
$$typeof:
|
|
160
|
+
$$typeof: S,
|
|
161
161
|
type: e,
|
|
162
162
|
key: t,
|
|
163
163
|
props: u,
|
|
164
|
-
_owner:
|
|
165
|
-
}, (
|
|
164
|
+
_owner: d
|
|
165
|
+
}, (m !== void 0 ? m : null) !== null ? Object.defineProperty(e, "ref", {
|
|
166
166
|
enumerable: !1,
|
|
167
|
-
get:
|
|
167
|
+
get: T
|
|
168
168
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
169
169
|
configurable: !1,
|
|
170
170
|
enumerable: !1,
|
|
@@ -184,64 +184,64 @@ function we() {
|
|
|
184
184
|
configurable: !1,
|
|
185
185
|
enumerable: !1,
|
|
186
186
|
writable: !0,
|
|
187
|
-
value:
|
|
187
|
+
value: re
|
|
188
188
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
189
189
|
}
|
|
190
|
-
function
|
|
191
|
-
var
|
|
192
|
-
if (
|
|
193
|
-
if (
|
|
194
|
-
if (U(
|
|
195
|
-
for (
|
|
196
|
-
|
|
197
|
-
Object.freeze && Object.freeze(
|
|
190
|
+
function n(e, t, u, d, H, re) {
|
|
191
|
+
var m = t.children;
|
|
192
|
+
if (m !== void 0)
|
|
193
|
+
if (d)
|
|
194
|
+
if (U(m)) {
|
|
195
|
+
for (d = 0; d < m.length; d++)
|
|
196
|
+
P(m[d]);
|
|
197
|
+
Object.freeze && Object.freeze(m);
|
|
198
198
|
} else
|
|
199
199
|
console.error(
|
|
200
200
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
201
201
|
);
|
|
202
|
-
else
|
|
203
|
-
if (
|
|
204
|
-
|
|
205
|
-
var
|
|
206
|
-
return
|
|
202
|
+
else P(m);
|
|
203
|
+
if (L.call(t, "key")) {
|
|
204
|
+
m = o(e);
|
|
205
|
+
var B = Object.keys(t).filter(function(Pe) {
|
|
206
|
+
return Pe !== "key";
|
|
207
207
|
});
|
|
208
|
-
|
|
208
|
+
d = 0 < B.length ? "{key: someKey, " + B.join(": ..., ") + ": ...}" : "{key: someKey}", j[m + d] || (B = 0 < B.length ? "{" + B.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
209
209
|
`A props object containing a "key" prop is being spread into JSX:
|
|
210
210
|
let props = %s;
|
|
211
211
|
<%s {...props} />
|
|
212
212
|
React keys must be passed directly to JSX without using spread:
|
|
213
213
|
let props = %s;
|
|
214
214
|
<%s key={someKey} {...props} />`,
|
|
215
|
+
d,
|
|
215
216
|
m,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
), k[v + m] = !0);
|
|
217
|
+
B,
|
|
218
|
+
m
|
|
219
|
+
), j[m + d] = !0);
|
|
220
220
|
}
|
|
221
|
-
if (
|
|
221
|
+
if (m = null, u !== void 0 && (l(u), m = "" + u), p(t) && (l(t.key), m = "" + t.key), "key" in t) {
|
|
222
222
|
u = {};
|
|
223
|
-
for (var
|
|
224
|
-
|
|
223
|
+
for (var ne in t)
|
|
224
|
+
ne !== "key" && (u[ne] = t[ne]);
|
|
225
225
|
} else u = t;
|
|
226
|
-
return
|
|
226
|
+
return m && c(
|
|
227
227
|
u,
|
|
228
228
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
229
|
-
),
|
|
229
|
+
), R(
|
|
230
230
|
e,
|
|
231
|
-
|
|
231
|
+
m,
|
|
232
232
|
u,
|
|
233
233
|
r(),
|
|
234
234
|
H,
|
|
235
|
-
|
|
235
|
+
re
|
|
236
236
|
);
|
|
237
237
|
}
|
|
238
|
-
function
|
|
239
|
-
|
|
238
|
+
function P(e) {
|
|
239
|
+
z(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === y && (e._payload.status === "fulfilled" ? z(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
240
240
|
}
|
|
241
|
-
function
|
|
242
|
-
return typeof e == "object" && e !== null && e.$$typeof ===
|
|
241
|
+
function z(e) {
|
|
242
|
+
return typeof e == "object" && e !== null && e.$$typeof === S;
|
|
243
243
|
}
|
|
244
|
-
var s =
|
|
244
|
+
var s = he, S = Symbol.for("react.transitional.element"), h = Symbol.for("react.portal"), A = Symbol.for("react.fragment"), x = Symbol.for("react.strict_mode"), D = Symbol.for("react.profiler"), N = Symbol.for("react.consumer"), _ = Symbol.for("react.context"), E = Symbol.for("react.forward_ref"), f = Symbol.for("react.suspense"), Y = Symbol.for("react.suspense_list"), $ = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), w = Symbol.for("react.activity"), M = Symbol.for("react.client.reference"), C = s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, L = Object.prototype.hasOwnProperty, U = Array.isArray, I = console.createTask ? console.createTask : function() {
|
|
245
245
|
return null;
|
|
246
246
|
};
|
|
247
247
|
s = {
|
|
@@ -249,75 +249,54 @@ React keys must be passed directly to JSX without using spread:
|
|
|
249
249
|
return e();
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
|
-
var V,
|
|
252
|
+
var V, X = {}, O = s.react_stack_bottom_frame.bind(
|
|
253
253
|
s,
|
|
254
|
-
|
|
255
|
-
)(), G =
|
|
256
|
-
q.Fragment =
|
|
257
|
-
var
|
|
258
|
-
return
|
|
254
|
+
i
|
|
255
|
+
)(), G = I(a(i)), j = {};
|
|
256
|
+
q.Fragment = A, q.jsx = function(e, t, u) {
|
|
257
|
+
var d = 1e4 > C.recentlyCreatedOwnerStacks++;
|
|
258
|
+
return n(
|
|
259
259
|
e,
|
|
260
260
|
t,
|
|
261
261
|
u,
|
|
262
262
|
!1,
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
d ? Error("react-stack-top-frame") : O,
|
|
264
|
+
d ? I(a(e)) : G
|
|
265
265
|
);
|
|
266
266
|
}, q.jsxs = function(e, t, u) {
|
|
267
|
-
var
|
|
268
|
-
return
|
|
267
|
+
var d = 1e4 > C.recentlyCreatedOwnerStacks++;
|
|
268
|
+
return n(
|
|
269
269
|
e,
|
|
270
270
|
t,
|
|
271
271
|
u,
|
|
272
272
|
!0,
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
d ? Error("react-stack-top-frame") : O,
|
|
274
|
+
d ? I(a(e)) : G
|
|
275
275
|
);
|
|
276
276
|
};
|
|
277
277
|
})()), q;
|
|
278
278
|
}
|
|
279
|
-
var
|
|
280
|
-
function
|
|
281
|
-
return
|
|
279
|
+
var de;
|
|
280
|
+
function ze() {
|
|
281
|
+
return de || (de = 1, process.env.NODE_ENV === "production" ? Q.exports = ke() : Q.exports = Fe()), Q.exports;
|
|
282
282
|
}
|
|
283
|
-
var
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
registerEmitter: (l, o) => {
|
|
287
|
-
if (g().emitters[l]) {
|
|
288
|
-
console.warn(`Emitter ${l} already exists`);
|
|
289
|
-
return;
|
|
290
|
-
}
|
|
291
|
-
n((r) => (r.emitters[l] = o, r));
|
|
292
|
-
},
|
|
293
|
-
unregisterEmitter: (l) => {
|
|
294
|
-
n((o) => (delete o.emitters[l], o));
|
|
295
|
-
},
|
|
296
|
-
emit: (l, ...o) => {
|
|
297
|
-
const r = g().emitters[l];
|
|
298
|
-
if (!r) {
|
|
299
|
-
console.warn(`Emitter ${l} not found`);
|
|
300
|
-
return;
|
|
301
|
-
}
|
|
302
|
-
r(...o);
|
|
303
|
-
}
|
|
304
|
-
}));
|
|
305
|
-
function ue(n, g) {
|
|
306
|
-
return n + Math.floor(Math.random() * (g - n + 1));
|
|
283
|
+
var b = ze();
|
|
284
|
+
function me(o, v) {
|
|
285
|
+
return o + Math.floor(Math.random() * (v - o + 1));
|
|
307
286
|
}
|
|
308
|
-
function
|
|
309
|
-
return
|
|
287
|
+
function g(o, v) {
|
|
288
|
+
return o + Math.random() * (v - o);
|
|
310
289
|
}
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
Restart:
|
|
314
|
-
Export:
|
|
315
|
-
const c = JSON.stringify(
|
|
290
|
+
const De = ({ settings: o, onChange: v, onRestart: l }) => {
|
|
291
|
+
ce("⚙️ Emitter Settings", {
|
|
292
|
+
Restart: le(() => l()),
|
|
293
|
+
Export: le(() => {
|
|
294
|
+
const c = JSON.stringify(p.current);
|
|
316
295
|
console.log("📋 Values saved to clipboard: ", c), navigator.clipboard.writeText(c);
|
|
317
296
|
})
|
|
318
297
|
});
|
|
319
|
-
const [{ ...
|
|
320
|
-
"🪄 Emitter":
|
|
298
|
+
const [{ ...a }, r] = ce(() => ({
|
|
299
|
+
"🪄 Emitter": Z({
|
|
321
300
|
duration: 4,
|
|
322
301
|
delay: 0,
|
|
323
302
|
nbParticles: 2e3,
|
|
@@ -355,7 +334,7 @@ const Te = ({ settings: n, onChange: g, onRestart: l }) => {
|
|
|
355
334
|
label: "startRotationMax"
|
|
356
335
|
}
|
|
357
336
|
}),
|
|
358
|
-
"✨ Particles":
|
|
337
|
+
"✨ Particles": Z({
|
|
359
338
|
particlesLifetime: {
|
|
360
339
|
value: [0.1, 1],
|
|
361
340
|
min: 0,
|
|
@@ -364,7 +343,7 @@ const Te = ({ settings: n, onChange: g, onRestart: l }) => {
|
|
|
364
343
|
label: "lifetime"
|
|
365
344
|
}
|
|
366
345
|
}),
|
|
367
|
-
"🌪 Forces":
|
|
346
|
+
"🌪 Forces": Z({
|
|
368
347
|
speed: {
|
|
369
348
|
value: [5, 20],
|
|
370
349
|
min: -100,
|
|
@@ -395,7 +374,7 @@ const Te = ({ settings: n, onChange: g, onRestart: l }) => {
|
|
|
395
374
|
step: 0.1
|
|
396
375
|
}
|
|
397
376
|
}),
|
|
398
|
-
"🎨 Appearance":
|
|
377
|
+
"🎨 Appearance": Z({
|
|
399
378
|
nbColors: {
|
|
400
379
|
options: [1, 2, 3]
|
|
401
380
|
},
|
|
@@ -425,119 +404,142 @@ const Te = ({ settings: n, onChange: g, onRestart: l }) => {
|
|
|
425
404
|
label: "size"
|
|
426
405
|
}
|
|
427
406
|
})
|
|
428
|
-
})),
|
|
429
|
-
...
|
|
430
|
-
colorStart: [
|
|
431
|
-
colorEnd: [
|
|
407
|
+
})), i = {
|
|
408
|
+
...a,
|
|
409
|
+
colorStart: [a.colorStart],
|
|
410
|
+
colorEnd: [a.colorEnd]
|
|
432
411
|
};
|
|
433
|
-
delete
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
var c,
|
|
437
|
-
if (
|
|
438
|
-
const
|
|
439
|
-
...
|
|
412
|
+
delete i.nbColors, delete i.colorStart2, delete i.colorEnd2, delete i.colorStart3, delete i.colorEnd3, a.nbColors > 1 && i.colorStart.push(a.colorStart2), a.nbColors > 1 && i.colorEnd.push(a.colorEnd2), a.nbColors > 2 && i.colorStart.push(a.colorStart3), a.nbColors > 2 && i.colorEnd.push(a.colorEnd3);
|
|
413
|
+
const p = F(i);
|
|
414
|
+
p.current = i, Se(() => {
|
|
415
|
+
var c, T;
|
|
416
|
+
if (o) {
|
|
417
|
+
const R = {
|
|
418
|
+
...o
|
|
440
419
|
};
|
|
441
|
-
for (let
|
|
442
|
-
((c =
|
|
420
|
+
for (let n = 0; n < 2; n++)
|
|
421
|
+
((c = o.colorStart) == null ? void 0 : c.length) > n && (R[n === 0 ? "colorStart" : `colorStart${n + 1}`] = o.colorStart[n], R.nbColors = n + 1), ((T = o.colorEnd) == null ? void 0 : T.length) > n && (R[n === 0 ? "colorEnd" : `colorEnd${n + 1}`] = o.colorEnd[n]);
|
|
443
422
|
r({
|
|
444
|
-
...
|
|
423
|
+
...R
|
|
445
424
|
});
|
|
446
425
|
}
|
|
447
|
-
}, [
|
|
448
|
-
},
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
426
|
+
}, [o]), v(i);
|
|
427
|
+
}, ie = je((o, v) => ({
|
|
428
|
+
emitters: {},
|
|
429
|
+
registerEmitter: (l, a) => {
|
|
430
|
+
if (v().emitters[l]) {
|
|
431
|
+
console.warn(`Emitter ${l} already exists`);
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
o((r) => (r.emitters[l] = a, r));
|
|
435
|
+
},
|
|
436
|
+
unregisterEmitter: (l) => {
|
|
437
|
+
o((a) => (delete a.emitters[l], a));
|
|
438
|
+
},
|
|
439
|
+
emit: (l, ...a) => {
|
|
440
|
+
const r = v().emitters[l];
|
|
441
|
+
if (!r) {
|
|
442
|
+
console.warn(`Emitter ${l} not found`);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
r(...a);
|
|
446
|
+
}
|
|
447
|
+
})), K = new te(), oe = new Re(), Ne = new se(), ee = new se(), Le = new te(), Xe = Ae(
|
|
448
|
+
({ debug: o, emitter: v, settings: l = {}, ...a }, r) => {
|
|
449
|
+
const [
|
|
450
|
+
{
|
|
451
|
+
duration: i = 1,
|
|
452
|
+
nbParticles: p = 1e3,
|
|
453
|
+
spawnMode: c = "time",
|
|
454
|
+
// time, burst
|
|
455
|
+
loop: T = !1,
|
|
456
|
+
delay: R = 0,
|
|
457
|
+
colorStart: n = ["white", "skyblue"],
|
|
458
|
+
colorEnd: P = [],
|
|
459
|
+
particlesLifetime: z = [0.1, 1],
|
|
460
|
+
speed: s = [5, 20],
|
|
461
|
+
size: S = [0.1, 1],
|
|
462
|
+
startPositionMin: h = [-1, -1, -1],
|
|
463
|
+
startPositionMax: A = [1, 1, 1],
|
|
464
|
+
startRotationMin: x = [0, 0, 0],
|
|
465
|
+
startRotationMax: D = [0, 0, 0],
|
|
466
|
+
rotationSpeedMin: N = [0, 0, 0],
|
|
467
|
+
rotationSpeedMax: _ = [0, 0, 0],
|
|
468
|
+
directionMin: E = [0, 0, 0],
|
|
469
|
+
directionMax: f = [0, 0, 0]
|
|
470
|
+
},
|
|
471
|
+
Y
|
|
472
|
+
] = xe(l), $ = ie((U) => U.emit), y = F();
|
|
473
|
+
_e(r, () => y.current);
|
|
474
|
+
const w = F(0), M = F(0);
|
|
475
|
+
ye(({ clock: U }, I) => {
|
|
476
|
+
const V = U.getElapsedTime();
|
|
477
|
+
if (w.current < p || T) {
|
|
478
|
+
if (!y)
|
|
477
479
|
return;
|
|
478
|
-
const O = (c === "burst" ?
|
|
480
|
+
const O = (c === "burst" ? p : Math.max(
|
|
479
481
|
0,
|
|
480
482
|
Math.floor(
|
|
481
|
-
(
|
|
483
|
+
(M.current - R) / i * p
|
|
482
484
|
)
|
|
483
|
-
)) -
|
|
484
|
-
O > 0 &&
|
|
485
|
-
|
|
486
|
-
const
|
|
485
|
+
)) - w.current;
|
|
486
|
+
O > 0 && M.current >= R && ($(v, O, () => {
|
|
487
|
+
y.current.updateWorldMatrix(!0), y.current.matrixWorld.decompose(K, oe, Le), Ne.setFromQuaternion(oe), ee.setFromQuaternion(oe);
|
|
488
|
+
const j = g(S[0], S[1]), e = n[me(0, n.length - 1)];
|
|
487
489
|
return {
|
|
488
490
|
position: [
|
|
489
|
-
K.x +
|
|
490
|
-
K.y +
|
|
491
|
-
K.z +
|
|
491
|
+
K.x + g(h[0], A[0]),
|
|
492
|
+
K.y + g(h[1], A[1]),
|
|
493
|
+
K.z + g(h[2], A[2])
|
|
492
494
|
],
|
|
493
495
|
direction: [
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
496
|
+
g(E[0], f[0]),
|
|
497
|
+
g(E[1], f[1]),
|
|
498
|
+
g(E[2], f[2])
|
|
497
499
|
],
|
|
498
|
-
scale: [
|
|
500
|
+
scale: [j, j, j],
|
|
499
501
|
rotation: [
|
|
500
|
-
ee.x +
|
|
501
|
-
ee.y +
|
|
502
|
-
ee.z +
|
|
502
|
+
ee.x + g(x[0], D[0]),
|
|
503
|
+
ee.y + g(x[1], D[1]),
|
|
504
|
+
ee.z + g(x[2], D[2])
|
|
503
505
|
],
|
|
504
506
|
rotationSpeed: [
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
507
|
+
g(N[0], _[0]),
|
|
508
|
+
g(N[1], _[1]),
|
|
509
|
+
g(N[2], _[2])
|
|
508
510
|
],
|
|
509
511
|
lifetime: [
|
|
510
512
|
V,
|
|
511
|
-
|
|
513
|
+
g(z[0], z[1])
|
|
512
514
|
],
|
|
513
515
|
colorStart: e,
|
|
514
|
-
colorEnd:
|
|
515
|
-
speed: [
|
|
516
|
+
colorEnd: P != null && P.length ? P[me(0, P.length - 1)] : e,
|
|
517
|
+
speed: [g(s[0], s[1])]
|
|
516
518
|
};
|
|
517
|
-
}),
|
|
519
|
+
}), w.current += O);
|
|
518
520
|
}
|
|
519
|
-
|
|
521
|
+
M.current += I;
|
|
520
522
|
});
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
}, []),
|
|
524
|
-
() =>
|
|
525
|
-
|
|
523
|
+
const C = we(() => {
|
|
524
|
+
w.current = 0, M.current = 0;
|
|
525
|
+
}, []), L = ae(
|
|
526
|
+
() => o ? /* @__PURE__ */ b.jsx(
|
|
527
|
+
De,
|
|
526
528
|
{
|
|
527
529
|
settings: l,
|
|
528
|
-
onChange:
|
|
529
|
-
onRestart:
|
|
530
|
+
onChange: Y,
|
|
531
|
+
onRestart: C
|
|
530
532
|
}
|
|
531
533
|
) : null,
|
|
532
|
-
[
|
|
534
|
+
[o]
|
|
533
535
|
);
|
|
534
|
-
return /* @__PURE__ */
|
|
535
|
-
|
|
536
|
-
/* @__PURE__ */
|
|
536
|
+
return /* @__PURE__ */ b.jsxs(b.Fragment, { children: [
|
|
537
|
+
L,
|
|
538
|
+
/* @__PURE__ */ b.jsx("object3D", { ...a, ref: y })
|
|
537
539
|
] });
|
|
538
540
|
}
|
|
539
541
|
);
|
|
540
|
-
var
|
|
542
|
+
var Ue = `varying vec2 vUv;
|
|
541
543
|
varying vec3 vColor;
|
|
542
544
|
varying vec3 vColorEnd;
|
|
543
545
|
varying float vProgress;
|
|
@@ -642,7 +644,7 @@ var ke = `varying vec2 vUv;
|
|
|
642
644
|
vUv = uv;
|
|
643
645
|
vColor = instanceColor;
|
|
644
646
|
vColorEnd = instanceColorEnd;
|
|
645
|
-
}`,
|
|
647
|
+
}`, Ie = `varying vec2 vUv;
|
|
646
648
|
varying vec3 vColor;
|
|
647
649
|
varying vec3 vColorEnd;
|
|
648
650
|
varying float vProgress;
|
|
@@ -668,167 +670,174 @@ var ke = `varying vec2 vUv;
|
|
|
668
670
|
gl_FragColor = vec4(color, alpha);
|
|
669
671
|
#endif
|
|
670
672
|
}`;
|
|
671
|
-
const
|
|
672
|
-
const {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
}
|
|
680
|
-
|
|
673
|
+
const ve = new te(), pe = new se(), ge = new Re(), Ee = new te(1, 1, 1), be = new Me(), k = new Te(), Ge = ({ name: o, settings: v = {}, alphaMap: l, geometry: a }) => {
|
|
674
|
+
const {
|
|
675
|
+
nbParticles: r = 1e3,
|
|
676
|
+
intensity: i = 1,
|
|
677
|
+
renderMode: p = "mesh",
|
|
678
|
+
fadeSize: c = [0.1, 0.9],
|
|
679
|
+
fadeAlpha: T = [0, 1],
|
|
680
|
+
gravity: R = [0, 0, 0]
|
|
681
|
+
} = v, n = F(), P = ae(() => new Ce(0.5, 0.5), []), z = () => {
|
|
682
|
+
if (!h.current || !n.current)
|
|
683
|
+
return;
|
|
684
|
+
[
|
|
685
|
+
n.current.instanceMatrix,
|
|
686
|
+
n.current.geometry.getAttribute("instanceColor"),
|
|
687
|
+
n.current.geometry.getAttribute("instanceColorEnd"),
|
|
688
|
+
n.current.geometry.getAttribute("instanceDirection"),
|
|
689
|
+
n.current.geometry.getAttribute("instanceLifetime"),
|
|
690
|
+
n.current.geometry.getAttribute("instanceSpeed"),
|
|
691
|
+
n.current.geometry.getAttribute("instanceRotationSpeed")
|
|
692
|
+
].forEach((f) => {
|
|
693
|
+
f.clearUpdateRanges(), S.current > s.current ? (f.addUpdateRange(0, s.current * f.itemSize), f.addUpdateRange(
|
|
694
|
+
S.current * f.itemSize,
|
|
695
|
+
r * f.itemSize - S.current * f.itemSize
|
|
696
|
+
)) : f.addUpdateRange(
|
|
697
|
+
S.current * f.itemSize,
|
|
698
|
+
s.current * f.itemSize - S.current * f.itemSize
|
|
699
|
+
), f.needsUpdate = !0;
|
|
700
|
+
}), S.current = s.current, h.current = !1;
|
|
701
|
+
}, s = F(0), S = F(0), h = F(!1), A = (E, f) => {
|
|
702
|
+
const Y = n.current.geometry.getAttribute("instanceColor"), $ = n.current.geometry.getAttribute("instanceColorEnd"), y = n.current.geometry.getAttribute("instanceDirection"), w = n.current.geometry.getAttribute("instanceLifetime"), M = n.current.geometry.getAttribute("instanceSpeed"), C = n.current.geometry.getAttribute(
|
|
681
703
|
"instanceRotationSpeed"
|
|
682
704
|
);
|
|
683
|
-
for (let
|
|
705
|
+
for (let L = 0; L < E; L++) {
|
|
684
706
|
s.current >= r && (s.current = 0);
|
|
685
707
|
const {
|
|
686
708
|
scale: U,
|
|
687
|
-
rotation:
|
|
709
|
+
rotation: I,
|
|
688
710
|
rotationSpeed: V,
|
|
689
|
-
position:
|
|
711
|
+
position: X,
|
|
690
712
|
direction: O,
|
|
691
713
|
lifetime: G,
|
|
692
|
-
colorStart:
|
|
714
|
+
colorStart: j,
|
|
693
715
|
colorEnd: e,
|
|
694
716
|
speed: t
|
|
695
717
|
} = f();
|
|
696
|
-
|
|
697
|
-
[
|
|
718
|
+
ve.set(...X), pe.set(...I), ge.setFromEuler(pe), Ee.set(...U), be.compose(ve, ge, Ee), n.current.setMatrixAt(s.current, be), k.set(j), Y.set(
|
|
719
|
+
[k.r, k.g, k.b],
|
|
698
720
|
s.current * 3
|
|
699
|
-
),
|
|
700
|
-
[
|
|
721
|
+
), k.set(e), $.set(
|
|
722
|
+
[k.r, k.g, k.b],
|
|
701
723
|
s.current * 3
|
|
702
|
-
),
|
|
724
|
+
), y.set(O, s.current * 3), w.set(G, s.current * 2), M.set([t], s.current), C.set(V, s.current * 3), s.current++, s.current = s.current % r;
|
|
703
725
|
}
|
|
704
|
-
|
|
705
|
-
},
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
i.current.geometry.getAttribute("instanceRotationSpeed")
|
|
716
|
-
].forEach((f) => {
|
|
717
|
-
f.clearUpdateRanges(), y.current > s.current ? (f.addUpdateRange(0, s.current * f.itemSize), f.addUpdateRange(
|
|
718
|
-
y.current * f.itemSize,
|
|
719
|
-
r * f.itemSize - y.current * f.itemSize
|
|
720
|
-
)) : f.addUpdateRange(
|
|
721
|
-
y.current * f.itemSize,
|
|
722
|
-
s.current * f.itemSize - y.current * f.itemSize
|
|
723
|
-
), f.needsUpdate = !0;
|
|
724
|
-
}), y.current = s.current, h.current = !1;
|
|
725
|
-
}, z = oe((S) => S.registerEmitter), N = oe((S) => S.unregisterEmitter);
|
|
726
|
-
ge(() => (z(n, _), () => {
|
|
727
|
-
N(n);
|
|
726
|
+
n.current.instanceMatrix.needsUpdate = !0, Y.needsUpdate = !0, $.needsUpdate = !0, y.needsUpdate = !0, w.needsUpdate = !0, M.needsUpdate = !0, C.needsUpdate = !0, h.current = !0;
|
|
727
|
+
}, [x] = xe({
|
|
728
|
+
instanceColor: new Float32Array(r * 3),
|
|
729
|
+
instanceColorEnd: new Float32Array(r * 3),
|
|
730
|
+
instanceDirection: new Float32Array(r * 3),
|
|
731
|
+
instanceLifetime: new Float32Array(r * 2),
|
|
732
|
+
instanceSpeed: new Float32Array(r * 1),
|
|
733
|
+
instanceRotationSpeed: new Float32Array(r * 3)
|
|
734
|
+
}), D = ie((E) => E.registerEmitter), N = ie((E) => E.unregisterEmitter);
|
|
735
|
+
Se(() => (D(o, A), () => {
|
|
736
|
+
N(o);
|
|
728
737
|
}), []);
|
|
729
|
-
const
|
|
738
|
+
const _ = ae(
|
|
730
739
|
() => ({
|
|
731
740
|
uTime: { value: 0 },
|
|
732
|
-
uIntensity: { value:
|
|
741
|
+
uIntensity: { value: i },
|
|
733
742
|
uFadeSize: { value: c },
|
|
734
|
-
uFadeAlpha: { value:
|
|
735
|
-
uGravity: { value:
|
|
743
|
+
uFadeAlpha: { value: T },
|
|
744
|
+
uGravity: { value: R },
|
|
736
745
|
uAlphaMap: { value: l }
|
|
737
746
|
}),
|
|
738
747
|
[]
|
|
739
748
|
);
|
|
740
|
-
return
|
|
741
|
-
|
|
742
|
-
}), /* @__PURE__ */
|
|
749
|
+
return ye(({ clock: E }) => {
|
|
750
|
+
_ && (_.uTime.value = E.elapsedTime);
|
|
751
|
+
}), /* @__PURE__ */ b.jsx(b.Fragment, { children: /* @__PURE__ */ b.jsxs(
|
|
743
752
|
"instancedMesh",
|
|
744
753
|
{
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
onBeforeRender:
|
|
754
|
+
args: [P, null, r],
|
|
755
|
+
ref: n,
|
|
756
|
+
onBeforeRender: z,
|
|
748
757
|
children: [
|
|
749
|
-
|
|
750
|
-
/* @__PURE__ */
|
|
758
|
+
a,
|
|
759
|
+
/* @__PURE__ */ b.jsx(
|
|
751
760
|
"shaderMaterial",
|
|
752
761
|
{
|
|
753
|
-
uniforms:
|
|
754
|
-
vertexShader:
|
|
755
|
-
fragmentShader:
|
|
756
|
-
blending:
|
|
762
|
+
uniforms: _,
|
|
763
|
+
vertexShader: Ue,
|
|
764
|
+
fragmentShader: Ie,
|
|
765
|
+
blending: Oe,
|
|
757
766
|
depthTest: !1,
|
|
758
767
|
depthWrite: !1,
|
|
759
768
|
transparent: !0,
|
|
760
769
|
defines: {
|
|
761
|
-
BILLBOARD_MODE:
|
|
762
|
-
MESH_MODE:
|
|
770
|
+
BILLBOARD_MODE: p === "billboard",
|
|
771
|
+
MESH_MODE: p === "mesh",
|
|
763
772
|
ALPHAMAP: !!l
|
|
764
773
|
}
|
|
765
774
|
}
|
|
766
775
|
),
|
|
767
|
-
/* @__PURE__ */
|
|
776
|
+
/* @__PURE__ */ b.jsx(
|
|
768
777
|
"instancedBufferAttribute",
|
|
769
778
|
{
|
|
770
779
|
attach: "geometry-attributes-instanceColor",
|
|
771
780
|
args: [x.instanceColor],
|
|
772
781
|
itemSize: 3,
|
|
773
782
|
count: r,
|
|
774
|
-
usage:
|
|
783
|
+
usage: W
|
|
775
784
|
}
|
|
776
785
|
),
|
|
777
|
-
/* @__PURE__ */
|
|
786
|
+
/* @__PURE__ */ b.jsx(
|
|
778
787
|
"instancedBufferAttribute",
|
|
779
788
|
{
|
|
780
789
|
attach: "geometry-attributes-instanceColorEnd",
|
|
781
790
|
args: [x.instanceColorEnd],
|
|
782
791
|
itemSize: 3,
|
|
783
792
|
count: r,
|
|
784
|
-
usage:
|
|
793
|
+
usage: W
|
|
785
794
|
}
|
|
786
795
|
),
|
|
787
|
-
/* @__PURE__ */
|
|
796
|
+
/* @__PURE__ */ b.jsx(
|
|
788
797
|
"instancedBufferAttribute",
|
|
789
798
|
{
|
|
790
799
|
attach: "geometry-attributes-instanceDirection",
|
|
791
800
|
args: [x.instanceDirection],
|
|
792
801
|
itemSize: 3,
|
|
793
802
|
count: r,
|
|
794
|
-
usage:
|
|
803
|
+
usage: W
|
|
795
804
|
}
|
|
796
805
|
),
|
|
797
|
-
/* @__PURE__ */
|
|
806
|
+
/* @__PURE__ */ b.jsx(
|
|
798
807
|
"instancedBufferAttribute",
|
|
799
808
|
{
|
|
800
809
|
attach: "geometry-attributes-instanceLifetime",
|
|
801
810
|
args: [x.instanceLifetime],
|
|
802
811
|
itemSize: 2,
|
|
803
812
|
count: r,
|
|
804
|
-
usage:
|
|
813
|
+
usage: W
|
|
805
814
|
}
|
|
806
815
|
),
|
|
807
|
-
/* @__PURE__ */
|
|
816
|
+
/* @__PURE__ */ b.jsx(
|
|
808
817
|
"instancedBufferAttribute",
|
|
809
818
|
{
|
|
810
819
|
attach: "geometry-attributes-instanceSpeed",
|
|
811
820
|
args: [x.instanceSpeed],
|
|
812
821
|
itemSize: 1,
|
|
813
822
|
count: r,
|
|
814
|
-
usage:
|
|
823
|
+
usage: W
|
|
815
824
|
}
|
|
816
825
|
),
|
|
817
|
-
/* @__PURE__ */
|
|
826
|
+
/* @__PURE__ */ b.jsx(
|
|
818
827
|
"instancedBufferAttribute",
|
|
819
828
|
{
|
|
820
829
|
attach: "geometry-attributes-instanceRotationSpeed",
|
|
821
830
|
args: [x.instanceRotationSpeed],
|
|
822
831
|
itemSize: 3,
|
|
823
832
|
count: r,
|
|
824
|
-
usage:
|
|
833
|
+
usage: W
|
|
825
834
|
}
|
|
826
835
|
)
|
|
827
836
|
]
|
|
828
837
|
}
|
|
829
|
-
);
|
|
838
|
+
) });
|
|
830
839
|
};
|
|
831
840
|
export {
|
|
832
|
-
|
|
833
|
-
|
|
841
|
+
Xe as VFXEmitter,
|
|
842
|
+
Ge as VFXParticles
|
|
834
843
|
};
|
package/dist/lazy-vfx.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(y,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react"),require("@react-three/fiber"),require("three"),require("leva"),require("zustand")):typeof define=="function"&&define.amd?define(["exports","react","@react-three/fiber","three","leva","zustand"],c):(y=typeof globalThis<"u"?globalThis:y||self,c(y.LazyVFX={},y.React,y.Fiber,y.THREE,y.leva,y.zustand))})(this,(function(y,c,ie,m,O,ge){"use strict";var q={exports:{}},H={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var se;function
|
|
9
|
+
*/var se;function Ee(){if(se)return H;se=1;var o=Symbol.for("react.transitional.element"),g=Symbol.for("react.fragment");function u(a,r,i){var b=null;if(i!==void 0&&(b=""+i),r.key!==void 0&&(b=""+r.key),"key"in r){i={};for(var l in r)l!=="key"&&(i[l]=r[l])}else i=r;return r=i.ref,{$$typeof:o,type:a,key:b,ref:r!==void 0?r:null,props:i}}return H.Fragment=g,H.jsx=u,H.jsxs=u,H}var Q={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var ce;function
|
|
17
|
+
*/var ce;function be(){return ce||(ce=1,process.env.NODE_ENV!=="production"&&(function(){function o(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case h:return"Fragment";case L:return"Profiler";case P:return"StrictMode";case d:return"Suspense";case B:return"SuspenseList";case C:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case M:return"Portal";case T:return e.displayName||"Context";case I:return(e._context.displayName||"Context")+".Consumer";case x:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case W:return t=e.displayName||null,t!==null?t:o(e.type)||"Memo";case A:t=e._payload,e=e._init;try{return o(e(t))}catch{}}return null}function g(e){return""+e}function u(e){try{g(e);var t=!1}catch{t=!0}if(t){t=console;var f=t.error,v=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return f.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",v),g(e)}}function a(e){if(e===h)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===A)return"<...>";try{var t=o(e);return t?"<"+t+">":"<...>"}catch{return"<...>"}}function r(){var e=D.A;return e===null?null:e.getOwner()}function i(){return Error("react-stack-top-frame")}function b(e){if(V.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function l(e,t){function f(){G||(G=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}f.isReactWarning=!0,Object.defineProperty(e,"key",{get:f,configurable:!0})}function F(){var e=o(this.type);return Z[e]||(Z[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function _(e,t,f,v,te,oe){var p=f.ref;return e={$$typeof:R,type:e,key:t,props:f,_owner:v},(p!==void 0?p:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:F}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:oe}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function n(e,t,f,v,te,oe){var p=t.children;if(p!==void 0)if(v)if(Y(p)){for(v=0;v<p.length;v++)w(p[v]);Object.freeze&&Object.freeze(p)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else w(p);if(V.call(t,"key")){p=o(e);var J=Object.keys(t).filter(function(Me){return Me!=="key"});v=0<J.length?"{key: someKey, "+J.join(": ..., ")+": ...}":"{key: someKey}",U[p+v]||(J=0<J.length?"{"+J.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,
|
|
22
|
+
<%s key={someKey} {...props} />`,v,p,J,p),U[p+v]=!0)}if(p=null,f!==void 0&&(u(f),p=""+f),b(t)&&(u(t.key),p=""+t.key),"key"in t){f={};for(var ae in t)ae!=="key"&&(f[ae]=t[ae])}else f=t;return p&&l(f,typeof e=="function"?e.displayName||e.name||"Unknown":e),_(e,p,f,r(),te,oe)}function w(e){N(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===A&&(e._payload.status==="fulfilled"?N(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function N(e){return typeof e=="object"&&e!==null&&e.$$typeof===R}var s=c,R=Symbol.for("react.transitional.element"),M=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),T=Symbol.for("react.context"),x=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),W=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),D=s.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=Object.prototype.hasOwnProperty,Y=Array.isArray,X=console.createTask?console.createTask:function(){return null};s={react_stack_bottom_frame:function(e){return e()}};var G,Z={},z=s.react_stack_bottom_frame.bind(s,i)(),K=X(a(i)),U={};Q.Fragment=h,Q.jsx=function(e,t,f){var v=1e4>D.recentlyCreatedOwnerStacks++;return n(e,t,f,!1,v?Error("react-stack-top-frame"):z,v?X(a(e)):K)},Q.jsxs=function(e,t,f){var v=1e4>D.recentlyCreatedOwnerStacks++;return n(e,t,f,!0,v?Error("react-stack-top-frame"):z,v?X(a(e)):K)}})()),Q}var le;function Se(){return le||(le=1,process.env.NODE_ENV==="production"?q.exports=Ee():q.exports=be()),q.exports}var S=Se();function ue(o,g){return o+Math.floor(Math.random()*(g-o+1))}function E(o,g){return o+Math.random()*(g-o)}const xe=({settings:o,onChange:g,onRestart:u})=>{O.useControls("⚙️ Emitter Settings",{Restart:O.button(()=>u()),Export:O.button(()=>{const l=JSON.stringify(b.current);console.log("📋 Values saved to clipboard: ",l),navigator.clipboard.writeText(l)})});const[{...a},r]=O.useControls(()=>({"🪄 Emitter":O.folder({duration:4,delay:0,nbParticles:2e3,spawnMode:{options:["time","burst"],value:"time"},loop:!1,startPositionMin:{value:[-1,-1,-1],min:-10,max:10,step:.1,label:"startPositionMin"},startPositionMax:{value:[1,1,1],min:-10,max:10,step:.1,label:"startPositionMax"},startRotationMin:{value:[0,0,0],min:-Math.PI*2,max:Math.PI*2,step:.1,label:"startRotationMin"},startRotationMax:{value:[0,0,0],min:-Math.PI*2,max:Math.PI*2,step:.1,label:"startRotationMax"}}),"✨ Particles":O.folder({particlesLifetime:{value:[.1,1],min:0,max:10,step:.1,label:"lifetime"}}),"🌪 Forces":O.folder({speed:{value:[5,20],min:-100,max:100},directionMin:{value:[-1,-1,-1],min:-1,max:1,step:.1},directionMax:{value:[1,1,1],min:-1,max:1,step:.1},rotationSpeedMin:{value:[0,0,0],min:0,max:10,step:.1},rotationSpeedMax:{value:[0,0,0],min:0,max:10,step:.1}}),"🎨 Appearance":O.folder({nbColors:{options:[1,2,3]},colorStart:"#ffffff",colorEnd:"#ffffff",colorStart2:{value:"#ff0000",render:l=>l("🎨 Appearance.nbColors")>1},colorEnd2:{value:"#ffffff",render:l=>l("🎨 Appearance.nbColors")>1},colorStart3:{value:"#ff0000",render:l=>l("🎨 Appearance.nbColors")>2},colorEnd3:{value:"#ff0000",render:l=>l("🎨 Appearance.nbColors")>2},size:{value:[.01,1],min:0,max:5,step:.01,label:"size"}})})),i={...a,colorStart:[a.colorStart],colorEnd:[a.colorEnd]};delete i.nbColors,delete i.colorStart2,delete i.colorEnd2,delete i.colorStart3,delete i.colorEnd3,a.nbColors>1&&i.colorStart.push(a.colorStart2),a.nbColors>1&&i.colorEnd.push(a.colorEnd2),a.nbColors>2&&i.colorStart.push(a.colorStart3),a.nbColors>2&&i.colorEnd.push(a.colorEnd3);const b=c.useRef(i);b.current=i,c.useEffect(()=>{var l,F;if(o){const _={...o};for(let n=0;n<2;n++)((l=o.colorStart)==null?void 0:l.length)>n&&(_[n===0?"colorStart":`colorStart${n+1}`]=o.colorStart[n],_.nbColors=n+1),((F=o.colorEnd)==null?void 0:F.length)>n&&(_[n===0?"colorEnd":`colorEnd${n+1}`]=o.colorEnd[n]);r({..._})}},[o]),g(i)},re=ge.create((o,g)=>({emitters:{},registerEmitter:(u,a)=>{if(g().emitters[u]){console.warn(`Emitter ${u} already exists`);return}o(r=>(r.emitters[u]=a,r))},unregisterEmitter:u=>{o(a=>(delete a.emitters[u],a))},emit:(u,...a)=>{const r=g().emitters[u];if(!r){console.warn(`Emitter ${u} not found`);return}r(...a)}})),$=new m.Vector3,ne=new m.Quaternion,ye=new m.Euler,ee=new m.Euler,Re=new m.Vector3,Pe=c.forwardRef(({debug:o,emitter:g,settings:u={},...a},r)=>{const[{duration:i=1,nbParticles:b=1e3,spawnMode:l="time",loop:F=!1,delay:_=0,colorStart:n=["white","skyblue"],colorEnd:w=[],particlesLifetime:N=[.1,1],speed:s=[5,20],size:R=[.1,1],startPositionMin:M=[-1,-1,-1],startPositionMax:h=[1,1,1],startRotationMin:P=[0,0,0],startRotationMax:L=[0,0,0],rotationSpeedMin:I=[0,0,0],rotationSpeedMax:T=[0,0,0],directionMin:x=[0,0,0],directionMax:d=[0,0,0]},B]=c.useState(u),W=re(Y=>Y.emit),A=c.useRef();c.useImperativeHandle(r,()=>A.current);const C=c.useRef(0),j=c.useRef(0);ie.useFrame(({clock:Y},X)=>{const G=Y.getElapsedTime();if(C.current<b||F){if(!A)return;const z=(l==="burst"?b:Math.max(0,Math.floor((j.current-_)/i*b)))-C.current;z>0&&j.current>=_&&(W(g,z,()=>{A.current.updateWorldMatrix(!0),A.current.matrixWorld.decompose($,ne,Re),ye.setFromQuaternion(ne),ee.setFromQuaternion(ne);const U=E(R[0],R[1]),e=n[ue(0,n.length-1)];return{position:[$.x+E(M[0],h[0]),$.y+E(M[1],h[1]),$.z+E(M[2],h[2])],direction:[E(x[0],d[0]),E(x[1],d[1]),E(x[2],d[2])],scale:[U,U,U],rotation:[ee.x+E(P[0],L[0]),ee.y+E(P[1],L[1]),ee.z+E(P[2],L[2])],rotationSpeed:[E(I[0],T[0]),E(I[1],T[1]),E(I[2],T[2])],lifetime:[G,E(N[0],N[1])],colorStart:e,colorEnd:w!=null&&w.length?w[ue(0,w.length-1)]:e,speed:[E(s[0],s[1])]}}),C.current+=z)}j.current+=X});const D=c.useCallback(()=>{C.current=0,j.current=0},[]),V=c.useMemo(()=>o?S.jsx(xe,{settings:u,onChange:B,onRestart:D}):null,[o]);return S.jsxs(S.Fragment,{children:[V,S.jsx("object3D",{...a,ref:A})]})});var Ae=`varying vec2 vUv;
|
|
23
23
|
varying vec3 vColor;
|
|
24
24
|
varying vec3 vColorEnd;
|
|
25
25
|
varying float vProgress;
|
|
@@ -124,7 +124,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
124
124
|
vUv = uv;
|
|
125
125
|
vColor = instanceColor;
|
|
126
126
|
vColorEnd = instanceColorEnd;
|
|
127
|
-
}`,
|
|
127
|
+
}`,_e=`varying vec2 vUv;
|
|
128
128
|
varying vec3 vColor;
|
|
129
129
|
varying vec3 vColorEnd;
|
|
130
130
|
varying float vProgress;
|
|
@@ -149,4 +149,4 @@ React keys must be passed directly to JSX without using spread:
|
|
|
149
149
|
#else
|
|
150
150
|
gl_FragColor = vec4(color, alpha);
|
|
151
151
|
#endif
|
|
152
|
-
}`;const fe=new
|
|
152
|
+
}`;const fe=new m.Vector3,de=new m.Euler,me=new m.Quaternion,ve=new m.Vector3(1,1,1),pe=new m.Matrix4,k=new m.Color,we=({name:o,settings:g={},alphaMap:u,geometry:a})=>{const{nbParticles:r=1e3,intensity:i=1,renderMode:b="mesh",fadeSize:l=[.1,.9],fadeAlpha:F=[0,1],gravity:_=[0,0,0]}=g,n=c.useRef(),w=c.useMemo(()=>new m.PlaneGeometry(.5,.5),[]),N=()=>{if(!M.current||!n.current)return;[n.current.instanceMatrix,n.current.geometry.getAttribute("instanceColor"),n.current.geometry.getAttribute("instanceColorEnd"),n.current.geometry.getAttribute("instanceDirection"),n.current.geometry.getAttribute("instanceLifetime"),n.current.geometry.getAttribute("instanceSpeed"),n.current.geometry.getAttribute("instanceRotationSpeed")].forEach(d=>{d.clearUpdateRanges(),R.current>s.current?(d.addUpdateRange(0,s.current*d.itemSize),d.addUpdateRange(R.current*d.itemSize,r*d.itemSize-R.current*d.itemSize)):d.addUpdateRange(R.current*d.itemSize,s.current*d.itemSize-R.current*d.itemSize),d.needsUpdate=!0}),R.current=s.current,M.current=!1},s=c.useRef(0),R=c.useRef(0),M=c.useRef(!1),h=(x,d)=>{const B=n.current.geometry.getAttribute("instanceColor"),W=n.current.geometry.getAttribute("instanceColorEnd"),A=n.current.geometry.getAttribute("instanceDirection"),C=n.current.geometry.getAttribute("instanceLifetime"),j=n.current.geometry.getAttribute("instanceSpeed"),D=n.current.geometry.getAttribute("instanceRotationSpeed");for(let V=0;V<x;V++){s.current>=r&&(s.current=0);const{scale:Y,rotation:X,rotationSpeed:G,position:Z,direction:z,lifetime:K,colorStart:U,colorEnd:e,speed:t}=d();fe.set(...Z),de.set(...X),me.setFromEuler(de),ve.set(...Y),pe.compose(fe,me,ve),n.current.setMatrixAt(s.current,pe),k.set(U),B.set([k.r,k.g,k.b],s.current*3),k.set(e),W.set([k.r,k.g,k.b],s.current*3),A.set(z,s.current*3),C.set(K,s.current*2),j.set([t],s.current),D.set(G,s.current*3),s.current++,s.current=s.current%r}n.current.instanceMatrix.needsUpdate=!0,B.needsUpdate=!0,W.needsUpdate=!0,A.needsUpdate=!0,C.needsUpdate=!0,j.needsUpdate=!0,D.needsUpdate=!0,M.current=!0},[P]=c.useState({instanceColor:new Float32Array(r*3),instanceColorEnd:new Float32Array(r*3),instanceDirection:new Float32Array(r*3),instanceLifetime:new Float32Array(r*2),instanceSpeed:new Float32Array(r*1),instanceRotationSpeed:new Float32Array(r*3)}),L=re(x=>x.registerEmitter),I=re(x=>x.unregisterEmitter);c.useEffect(()=>(L(o,h),()=>{I(o)}),[]);const T=c.useMemo(()=>({uTime:{value:0},uIntensity:{value:i},uFadeSize:{value:l},uFadeAlpha:{value:F},uGravity:{value:_},uAlphaMap:{value:u}}),[]);return ie.useFrame(({clock:x})=>{T&&(T.uTime.value=x.elapsedTime)}),S.jsx(S.Fragment,{children:S.jsxs("instancedMesh",{args:[w,null,r],ref:n,onBeforeRender:N,children:[a,S.jsx("shaderMaterial",{uniforms:T,vertexShader:Ae,fragmentShader:_e,blending:m.AdditiveBlending,depthTest:!1,depthWrite:!1,transparent:!0,defines:{BILLBOARD_MODE:b==="billboard",MESH_MODE:b==="mesh",ALPHAMAP:!!u}}),S.jsx("instancedBufferAttribute",{attach:"geometry-attributes-instanceColor",args:[P.instanceColor],itemSize:3,count:r,usage:m.DynamicDrawUsage}),S.jsx("instancedBufferAttribute",{attach:"geometry-attributes-instanceColorEnd",args:[P.instanceColorEnd],itemSize:3,count:r,usage:m.DynamicDrawUsage}),S.jsx("instancedBufferAttribute",{attach:"geometry-attributes-instanceDirection",args:[P.instanceDirection],itemSize:3,count:r,usage:m.DynamicDrawUsage}),S.jsx("instancedBufferAttribute",{attach:"geometry-attributes-instanceLifetime",args:[P.instanceLifetime],itemSize:2,count:r,usage:m.DynamicDrawUsage}),S.jsx("instancedBufferAttribute",{attach:"geometry-attributes-instanceSpeed",args:[P.instanceSpeed],itemSize:1,count:r,usage:m.DynamicDrawUsage}),S.jsx("instancedBufferAttribute",{attach:"geometry-attributes-instanceRotationSpeed",args:[P.instanceRotationSpeed],itemSize:3,count:r,usage:m.DynamicDrawUsage})]})})};y.VFXEmitter=Pe,y.VFXParticles=we,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lazy-vfx",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Effortless high-end visual effects for React and Three.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"motion-design"
|
|
15
15
|
],
|
|
16
16
|
"type": "module",
|
|
17
|
-
"main": "./dist/lazy-vfx.umd.js",
|
|
17
|
+
"main": "./dist/lazy-vfx.umd.js",
|
|
18
18
|
"module": "./dist/lazy-vfx.es.js",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"prepublishOnly": "pnpm build"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
+
"@react-three/drei": ">=9.0.0",
|
|
36
|
+
"@react-three/fiber": ">=8.0.0",
|
|
35
37
|
"react": ">=18.0.0",
|
|
36
38
|
"react-dom": ">=18.0.0",
|
|
37
|
-
"three": ">=0.150.0"
|
|
38
|
-
"@react-three/fiber": ">=8.0.0",
|
|
39
|
-
"@react-three/drei": ">=9.0.0"
|
|
39
|
+
"three": ">=0.150.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@react-three/postprocessing": "^3.0.4",
|
|
@@ -50,12 +50,18 @@
|
|
|
50
50
|
"@types/react-dom": "^19.0.4",
|
|
51
51
|
"@vitejs/plugin-react": "^4.3.4",
|
|
52
52
|
"globals": "^15.15.0",
|
|
53
|
+
"path": "^0.12.7",
|
|
53
54
|
"react": "^19.0.0",
|
|
54
55
|
"react-dom": "^19.0.0",
|
|
55
|
-
"three": "^0.
|
|
56
|
+
"three": "^0.160.0",
|
|
56
57
|
"vite": "^6.2.0",
|
|
57
|
-
"vite-plugin-glsl": "^1.5.6"
|
|
58
|
-
|
|
58
|
+
"vite-plugin-glsl": "^1.5.6"
|
|
59
|
+
},
|
|
60
|
+
"overrides": {
|
|
61
|
+
"postprocessing": "6.36.7"
|
|
62
|
+
},
|
|
63
|
+
"resolutions": {
|
|
64
|
+
"postprocessing": "6.36.7"
|
|
59
65
|
},
|
|
60
66
|
"author": "Sameer Khan",
|
|
61
67
|
"license": "MIT"
|