@kolkrabbi/design-editor 0.13.0 → 0.14.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.
@@ -1,1719 +0,0 @@
1
- import { useSyncExternalStore as e } from "react";
2
- //#region src/loops/lib/util.js
3
- var t = Math.PI * 2, n = (e) => Math.max(0, Math.min(1, e)), r = (e, t, n) => e + (t - e) * n, i = (e) => parseInt(e, 16);
4
- function a(e) {
5
- let t = String(e || "").replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t;
6
- return n.length < 6 ? [
7
- 0,
8
- 0,
9
- 0
10
- ] : [
11
- i(n.slice(0, 2)),
12
- i(n.slice(2, 4)),
13
- i(n.slice(4, 6))
14
- ];
15
- }
16
- function o(e, t, n) {
17
- let i = a(e), o = a(t);
18
- return `rgb(${Math.round(r(i[0], o[0], n))}, ${Math.round(r(i[1], o[1], n))}, ${Math.round(r(i[2], o[2], n))})`;
19
- }
20
- //#endregion
21
- //#region src/editor/params/audioBands.js
22
- var s = {
23
- level: 0,
24
- bass: 0,
25
- mid: 0,
26
- high: 0
27
- }, c = null, l = null, u = null, d = null, f = null, p = 0, m = null, h = null, g = !1, _ = null, ee = .5, te = .12, v = (e, t) => e + (t - e) * (t > e ? ee : te);
28
- function y() {
29
- if (!g || !l) return;
30
- l.getFloatTimeDomainData(m);
31
- let e = 0;
32
- for (let t = 0; t < m.length; t++) e += m[t] * m[t];
33
- let t = Math.min(1, Math.sqrt(e / m.length) * 4);
34
- l.getByteFrequencyData(h);
35
- let n = h.length, r = Math.floor(n * .04), i = Math.floor(n * .25), a = 0, o = 0, c = 0;
36
- for (let e = 0; e < r; e++) a += h[e];
37
- for (let e = r; e < i; e++) o += h[e];
38
- for (let e = i; e < n; e++) c += h[e];
39
- s.level = v(s.level, t), s.bass = v(s.bass, Math.min(1, a / r / 200)), s.mid = v(s.mid, Math.min(1, o / (i - r) / 160)), s.high = v(s.high, Math.min(1, c / (n - i) / 120)), p = requestAnimationFrame(y);
40
- }
41
- async function ne({ file: e } = {}) {
42
- let t = e ? "file" : "mic";
43
- if (g && _ === t && !e) return !0;
44
- if (b(), typeof window > "u") return !1;
45
- try {
46
- c = new (window.AudioContext || window.webkitAudioContext)(), c.state === "suspended" && await c.resume();
47
- let n;
48
- if (e) f = URL.createObjectURL(e), d = new Audio(f), d.loop = !0, d.crossOrigin = "anonymous", n = c.createMediaElementSource(d), n.connect(c.destination), await d.play();
49
- else {
50
- if (!navigator.mediaDevices?.getUserMedia) return !1;
51
- u = await navigator.mediaDevices.getUserMedia({
52
- audio: !0,
53
- video: !1
54
- }), n = c.createMediaStreamSource(u);
55
- }
56
- return l = c.createAnalyser(), l.fftSize = 512, n.connect(l), m = new Float32Array(l.fftSize), h = new Uint8Array(l.frequencyBinCount), g = !0, _ = t, p = requestAnimationFrame(y), !0;
57
- } catch (e) {
58
- return console.info("[audio] not available:", e?.message ?? e), b(), !1;
59
- }
60
- }
61
- function b() {
62
- if (g = !1, _ = null, p &&= (cancelAnimationFrame(p), 0), u &&= (u.getTracks().forEach((e) => e.stop()), null), d &&= (d.pause(), null), f &&= (URL.revokeObjectURL(f), null), c) {
63
- try {
64
- c.close();
65
- } catch {}
66
- c = null;
67
- }
68
- l = null, m = h = null, s.level = s.bass = s.mid = s.high = 0;
69
- }
70
- function re() {
71
- return s;
72
- }
73
- function ie() {
74
- return g;
75
- }
76
- function ae() {
77
- return _;
78
- }
79
- //#endregion
80
- //#region src/editor/params/midi.js
81
- var x = /* @__PURE__ */ new Map(), S = null, C = !1, w = null;
82
- function oe(e) {
83
- let [t, n, r] = e.data;
84
- if ((t & 240) == 176 && (x.set(n, r / 127), w)) {
85
- let e = w;
86
- w = null, e(n);
87
- }
88
- }
89
- function T() {
90
- for (let e of S.inputs.values()) e.onmidimessage = oe;
91
- }
92
- async function se() {
93
- if (C) return !0;
94
- if (typeof navigator > "u" || !navigator.requestMIDIAccess) return !1;
95
- try {
96
- return S = await navigator.requestMIDIAccess(), T(), S.onstatechange = T, C = !0, !0;
97
- } catch (e) {
98
- return console.info("[midi] not available:", e?.message ?? e), !1;
99
- }
100
- }
101
- function ce() {
102
- return C;
103
- }
104
- function le(e) {
105
- return x.get(e) ?? 0;
106
- }
107
- function ue() {
108
- return x.size > 0;
109
- }
110
- function de() {
111
- return new Promise((e) => {
112
- let t = setTimeout(() => {
113
- w = null, e(null);
114
- }, 1e4);
115
- w = (n) => {
116
- clearTimeout(t), e(n);
117
- };
118
- });
119
- }
120
- //#endregion
121
- //#region src/editor/params/gamepad.js
122
- function E() {
123
- if (typeof navigator > "u" || !navigator.getGamepads) return null;
124
- let e = navigator.getGamepads();
125
- for (let t of e) if (t) return t;
126
- return null;
127
- }
128
- function D() {
129
- return !!E();
130
- }
131
- function O(e) {
132
- let t = E();
133
- if (!t) return 0;
134
- let n = t.axes[e];
135
- return Number.isFinite(n) ? (n + 1) / 2 : 0;
136
- }
137
- function fe(e) {
138
- let t = E();
139
- return t ? t.buttons[e]?.value ?? 0 : 0;
140
- }
141
- function k(e) {
142
- let t = E();
143
- return t ? +!!t.buttons[e]?.pressed : 0;
144
- }
145
- function pe(e, t) {
146
- let n = E();
147
- if (!n) return 0;
148
- let r = n.axes[e] ?? 0, i = n.axes[t] ?? 0, a = Math.atan2(i, r) / (Math.PI * 2);
149
- return a - Math.floor(a);
150
- }
151
- function me(e, t) {
152
- let n = E();
153
- if (!n) return 0;
154
- let r = n.axes[e] ?? 0, i = n.axes[t] ?? 0;
155
- return Math.min(1, Math.hypot(r, i));
156
- }
157
- var A = [
158
- {
159
- id: "pad-leftX",
160
- label: "Pad · Left stick X",
161
- axis: 0,
162
- read: () => O(0)
163
- },
164
- {
165
- id: "pad-leftY",
166
- label: "Pad · Left stick Y",
167
- axis: 1,
168
- read: () => O(1)
169
- },
170
- {
171
- id: "pad-rightX",
172
- label: "Pad · Right stick X",
173
- axis: 2,
174
- read: () => O(2)
175
- },
176
- {
177
- id: "pad-rightY",
178
- label: "Pad · Right stick Y",
179
- axis: 3,
180
- read: () => O(3)
181
- },
182
- {
183
- id: "pad-LT",
184
- label: "Pad · L2 (trigger)",
185
- button: 6,
186
- read: () => fe(6)
187
- },
188
- {
189
- id: "pad-RT",
190
- label: "Pad · R2 (trigger)",
191
- button: 7,
192
- read: () => fe(7)
193
- },
194
- {
195
- id: "pad-a",
196
- label: "Pad · A (south)",
197
- button: 0,
198
- read: () => k(0)
199
- },
200
- {
201
- id: "pad-b",
202
- label: "Pad · B (east)",
203
- button: 1,
204
- read: () => k(1)
205
- },
206
- {
207
- id: "pad-x",
208
- label: "Pad · X (west)",
209
- button: 2,
210
- read: () => k(2)
211
- },
212
- {
213
- id: "pad-y",
214
- label: "Pad · Y (north)",
215
- button: 3,
216
- read: () => k(3)
217
- },
218
- {
219
- id: "pad-L1",
220
- label: "Pad · L1 (bumper)",
221
- button: 4,
222
- read: () => k(4)
223
- },
224
- {
225
- id: "pad-R1",
226
- label: "Pad · R1 (bumper)",
227
- button: 5,
228
- read: () => k(5)
229
- },
230
- {
231
- id: "pad-leftAngle",
232
- label: "Pad · Left stick ∠ (circle)",
233
- read: () => pe(0, 1)
234
- },
235
- {
236
- id: "pad-leftForce",
237
- label: "Pad · Left stick ⊙ (push)",
238
- read: () => me(0, 1)
239
- },
240
- {
241
- id: "pad-rightAngle",
242
- label: "Pad · Right stick ∠ (circle)",
243
- read: () => pe(2, 3)
244
- },
245
- {
246
- id: "pad-rightForce",
247
- label: "Pad · Right stick ⊙ (push)",
248
- read: () => me(2, 3)
249
- }
250
- ];
251
- function he(e) {
252
- return typeof e == "string" && (e.startsWith("pad-") || e === "padX" || e === "padY");
253
- }
254
- var ge = new Map(A.filter((e) => e.axis != null).map((e) => [e.axis, e.id])), _e = new Map(A.filter((e) => e.button != null).map((e) => [e.button, e.id])), ve = .5;
255
- function ye() {
256
- return new Promise((e) => {
257
- if (typeof requestAnimationFrame > "u") return e(null);
258
- let t = E(), n = t ? [...t.axes] : [], r = typeof performance < "u" ? performance.now() : Date.now(), i = 0, a = (t) => {
259
- cancelAnimationFrame(i), e(t);
260
- }, o = () => {
261
- let e = E();
262
- if (e) {
263
- for (let [t, n] of _e) if (e.buttons[t]?.pressed) return a(n);
264
- for (let t = 0; t < e.axes.length; t++) {
265
- let r = ge.get(t);
266
- if (r && Math.abs((e.axes[t] ?? 0) - (n[t] ?? 0)) > ve) return a(r);
267
- }
268
- }
269
- if ((typeof performance < "u" ? performance.now() : Date.now()) - r > 1e4) return a(null);
270
- i = requestAnimationFrame(o);
271
- };
272
- i = requestAnimationFrame(o);
273
- });
274
- }
275
- //#endregion
276
- //#region src/editor/params/expr.js
277
- var be = {
278
- level: 0,
279
- bass: 0,
280
- mid: 0,
281
- high: 0
282
- }, xe = "\n \"use strict\";\n var s=t, time=t;\n var level=+a.level||0, bass=+a.bass||0, mid=+a.mid||0, high=+a.high||0;\n var min=0, max=1;\n var PI=Math.PI, TAU=6.283185307179586, PHI=1.618033988749895, E=Math.E,\n SQRT2=Math.SQRT2, SQRT3=1.7320508075688772, SQRT5=2.23606797749979,\n LN2=Math.LN2, LN10=Math.LN10, DEG=0.017453292519943295;\n var sin=Math.sin, cos=Math.cos, tan=Math.tan,\n asin=Math.asin, acos=Math.acos, atan=Math.atan, atan2=Math.atan2,\n sinh=Math.sinh, cosh=Math.cosh, tanh=Math.tanh,\n abs=Math.abs, sign=Math.sign, floor=Math.floor, ceil=Math.ceil,\n round=Math.round, trunc=Math.trunc, sqrt=Math.sqrt, cbrt=Math.cbrt,\n exp=Math.exp, log=Math.log, log2=Math.log2, log10=Math.log10,\n pow=Math.pow, hypot=Math.hypot;\n function frac(x){return x-floor(x);}\n function mod(a,b){return ((a%b)+b)%b;}\n function clamp(x,a,b){return x<a?a:(x>b?b:x);}\n function lerp(a,b,u){return a+(b-a)*u;}\n function smooth(u){u=clamp(u,0,1);return u*u*(3-2*u);}\n function wave(x){return sin(x*TAU)*0.5+0.5;}\n function saw(x){return frac(x);}\n function tri(x){var p=frac(x);return p<0.5?p*2:(1-p)*2;}\n function pulse(x,w){w=(w===undefined?0.5:w);return frac(x)<w?1:0;}\n function ease(x,c){c=(c===undefined?2:c);var p=frac(x);var v=p<0.5?p*2:(1-p)*2;return pow(v,c);}\n function bell(x){var p=frac(x);return exp(-pow((p-0.5)*6,2));}\n function step(x,k){k=(k===undefined?4:k);return floor(frac(x)*k)/k;}\n function rand(){return Math.random();}\n", Se = /* @__PURE__ */ new Map(), Ce = /\b(level|bass|mid|high|rand)\b/, we = [
283
- "globalThis",
284
- "window",
285
- "self",
286
- "document",
287
- "fetch",
288
- "XMLHttpRequest",
289
- "localStorage",
290
- "sessionStorage",
291
- "indexedDB",
292
- "navigator",
293
- "location",
294
- "top",
295
- "parent",
296
- "frames",
297
- "opener",
298
- "Function",
299
- "WebSocket",
300
- "Worker",
301
- "importScripts"
302
- ];
303
- function Te(e) {
304
- let t = String(e), n = Se.get(t);
305
- if (n) return n;
306
- let r;
307
- try {
308
- let e = Function("t", "a", ...we, `${xe}return (${t});`);
309
- if (typeof e(1, be) != "number") throw Error("not numeric");
310
- let n = 0;
311
- r = {
312
- ok: !0,
313
- usesLive: Ce.test(t),
314
- fn: (t, r = re()) => {
315
- try {
316
- let i = e(t, r);
317
- return typeof i == "number" && Number.isFinite(i) ? (n = i, i) : n;
318
- } catch {
319
- return n;
320
- }
321
- }
322
- };
323
- } catch {
324
- r = {
325
- ok: !1,
326
- usesLive: !1,
327
- fn: () => 0
328
- };
329
- }
330
- return Se.set(t, r), r;
331
- }
332
- //#endregion
333
- //#region src/editor/params/sources.js
334
- var j = /* @__PURE__ */ new Map();
335
- function M(e) {
336
- if (!e?.id) throw Error("modulation source needs an id");
337
- return j.set(e.id, e), e;
338
- }
339
- function Ee(e) {
340
- return j.get(e);
341
- }
342
- function De() {
343
- return [...j.values()];
344
- }
345
- function Oe(e, t, n) {
346
- let r = j.get(e);
347
- if (!r) return 0;
348
- let i = r.sample(t, n);
349
- return Number.isFinite(i) ? Math.min(1, Math.max(0, i)) : 0;
350
- }
351
- function ke() {
352
- for (let e of j.values()) if (e.live && e.active?.()) return !0;
353
- return !1;
354
- }
355
- M({
356
- id: "time",
357
- label: "Time",
358
- sample: (e) => e?.t ?? 0
359
- }), M({
360
- id: "mouseX",
361
- label: "Mouse X",
362
- sample: (e) => e?.mouse?.x ?? 0
363
- }), M({
364
- id: "mouseY",
365
- label: "Mouse Y",
366
- sample: (e) => e?.mouse?.y ?? 0
367
- });
368
- var Ae = (e) => (t, n) => {
369
- let r = t?.stage, i = n?.layer;
370
- return !r || !i || i.w == null || i.h == null ? .5 : e === "x" ? (r.x - i.x) / Math.max(1, i.w) : (r.y - i.y) / Math.max(1, i.h);
371
- };
372
- M({
373
- id: "layerX",
374
- label: "Pointer over layer X",
375
- sample: Ae("x")
376
- }), M({
377
- id: "layerY",
378
- label: "Pointer over layer Y",
379
- sample: Ae("y")
380
- });
381
- var N = (e, t) => {
382
- let n = t?.transform?.rate ?? 1, r = t?.transform?.phase ?? 0;
383
- return ((e?.t ?? 0) * n + r) % 1;
384
- };
385
- M({
386
- id: "lfo-sine",
387
- label: "LFO · sine",
388
- sample: (e, t) => .5 - .5 * Math.cos(N(e, t) * Math.PI * 2)
389
- }), M({
390
- id: "lfo-triangle",
391
- label: "LFO · triangle",
392
- sample: (e, t) => {
393
- let n = N(e, t);
394
- return n < .5 ? n * 2 : 2 - n * 2;
395
- }
396
- }), M({
397
- id: "lfo-square",
398
- label: "LFO · square",
399
- sample: (e, t) => +(N(e, t) < .5)
400
- });
401
- var P = 0;
402
- M({
403
- id: "expr",
404
- label: "Expression",
405
- live: !0,
406
- active: () => performance.now() < P,
407
- sample: (e, t) => {
408
- let n = Te(t?.transform?.expr ?? "wave(t)");
409
- return n.usesLive && (P = performance.now() + 500), n.fn((e?.t ?? 0) * G.getLoopSeconds());
410
- }
411
- });
412
- var F = (e) => ({
413
- id: `audio-${e}`,
414
- label: `Audio · ${e}`,
415
- live: !0,
416
- active: ie,
417
- ensure: () => ne(),
418
- sample: () => re()[e]
419
- });
420
- M(F("level")), M(F("bass")), M(F("mid")), M(F("high")), M({
421
- ...F("level"),
422
- id: "audio",
423
- hidden: !0
424
- }), M({
425
- id: "midi",
426
- label: "MIDI CC",
427
- live: !0,
428
- active: () => ce() && ue(),
429
- ensure: () => se(),
430
- sample: (e, t) => {
431
- let n = t?.transform?.cc;
432
- return n == null ? 0 : le(n);
433
- }
434
- });
435
- for (let e of A) M({
436
- id: e.id,
437
- label: e.label,
438
- live: !0,
439
- active: D,
440
- sample: e.read
441
- });
442
- M({
443
- id: "padX",
444
- label: "Joystick X",
445
- hidden: !0,
446
- live: !0,
447
- active: D,
448
- sample: A[0].read
449
- }), M({
450
- id: "padY",
451
- label: "Joystick Y",
452
- hidden: !0,
453
- live: !0,
454
- active: D,
455
- sample: A[1].read
456
- });
457
- //#endregion
458
- //#region src/editor/params/transport.js
459
- var I = 0, L = !1, R = 4, je = {
460
- x: .5,
461
- y: .5
462
- }, Me = null, Ne = 0, z = 0, B = /* @__PURE__ */ new Set(), V = null, H = null, U = !1;
463
- function W() {
464
- Ne++, B.forEach((e) => e());
465
- }
466
- function Pe(e) {
467
- H ??= e;
468
- let t = (e - H) / 1e3;
469
- H = e, L ? (I = (I + t / R) % 1, W()) : B.size > 0 && ke() && W(), L || B.size > 0 ? V = requestAnimationFrame(Pe) : (V = null, H = null);
470
- }
471
- function Fe() {
472
- V ??= (H = null, requestAnimationFrame(Pe));
473
- }
474
- if (typeof window < "u") {
475
- let e = (e) => {
476
- je = {
477
- x: e.clientX / window.innerWidth,
478
- y: e.clientY / window.innerHeight
479
- }, U && B.size > 0 && W();
480
- };
481
- window.addEventListener("pointermove", e), window.addEventListener("pointerdown", e);
482
- }
483
- var G = {
484
- play() {
485
- L = !0, Fe(), W();
486
- },
487
- pause() {
488
- L = !1, W();
489
- },
490
- toggle() {
491
- L ? G.pause() : G.play();
492
- },
493
- seek(e) {
494
- I = (e % 1 + 1) % 1, W();
495
- },
496
- stop() {
497
- L = !1, I = 0, z++, W();
498
- },
499
- rewind() {
500
- I = 0, z++, W();
501
- },
502
- setLoopSeconds(e) {
503
- R = Math.max(.1, Number(e) || .1), W();
504
- },
505
- isPlaying() {
506
- return L;
507
- },
508
- getLoopSeconds() {
509
- return R;
510
- },
511
- getT() {
512
- return I;
513
- },
514
- getEpoch() {
515
- return z;
516
- },
517
- getCtx() {
518
- return {
519
- t: I,
520
- mouse: je,
521
- stage: Me,
522
- epoch: z
523
- };
524
- },
525
- setStagePointer(e, t, n = !1) {
526
- Me = e == null ? null : {
527
- x: e,
528
- y: t,
529
- down: !!n
530
- }, U && B.size > 0 && W();
531
- },
532
- setPointerInterest(e) {
533
- U = !!e;
534
- }
535
- };
536
- function K(e) {
537
- return B.add(e), Fe(), () => B.delete(e);
538
- }
539
- function Ie() {
540
- return () => {};
541
- }
542
- function q() {
543
- return Ne;
544
- }
545
- function Le(t) {
546
- return e(t ? K : Ie, q, q), G.getCtx();
547
- }
548
- function Re() {
549
- return e(K, q, q), {
550
- playing: L,
551
- loopSeconds: R,
552
- t: I,
553
- play: G.play,
554
- pause: G.pause,
555
- toggle: G.toggle,
556
- seek: G.seek,
557
- stop: G.stop,
558
- rewind: G.rewind,
559
- setLoopSeconds: G.setLoopSeconds
560
- };
561
- }
562
- var ze = () => L, Be = () => z;
563
- function Ve() {
564
- return e(K, ze, ze);
565
- }
566
- function He() {
567
- return e(K, Be, Be);
568
- }
569
- //#endregion
570
- //#region src/loops/lib/themes.js
571
- var J = [
572
- {
573
- id: "dark",
574
- label: "Dark",
575
- bg: "#050506",
576
- fg: "#9ec1ff",
577
- accent: "#9ec1ff",
578
- dim: "#4a4d60",
579
- warm: "#f3c9c4",
580
- grid: "#ffffff",
581
- gridOpacity: .1
582
- },
583
- {
584
- id: "paper",
585
- label: "Paper",
586
- bg: "#f4f1ea",
587
- fg: "#16202e",
588
- accent: "#3b5b8a",
589
- dim: "#6b7280",
590
- warm: "#b0623a",
591
- grid: "#16202e",
592
- gridOpacity: .14
593
- },
594
- {
595
- id: "blueprint",
596
- label: "Blueprint",
597
- bg: "#0b1d3a",
598
- fg: "#8fd3ff",
599
- accent: "#8fd3ff",
600
- dim: "#3f5a78",
601
- warm: "#e3a054",
602
- grid: "#8fd3ff",
603
- gridOpacity: .2
604
- },
605
- {
606
- id: "mono",
607
- label: "Mono",
608
- bg: "#0a0a0a",
609
- fg: "#ededed",
610
- accent: "#ededed",
611
- dim: "#8a8a8a",
612
- warm: "#d8c4a0",
613
- grid: "#ffffff",
614
- gridOpacity: .08
615
- },
616
- {
617
- id: "amber",
618
- label: "Amber",
619
- bg: "#0c0a06",
620
- fg: "#ffb35c",
621
- accent: "#ffcf8a",
622
- dim: "#8a6a3a",
623
- warm: "#ffd8a0",
624
- grid: "#ffcf8a",
625
- gridOpacity: .12
626
- },
627
- {
628
- id: "ink",
629
- label: "Ink",
630
- bg: "#0a0b14",
631
- fg: "#f0ead8",
632
- accent: "#8b8fd6",
633
- dim: "#4a4d60",
634
- warm: "#f3c9c4",
635
- grid: "#f0ead8",
636
- gridOpacity: .07
637
- },
638
- {
639
- id: "slate",
640
- label: "Slate",
641
- bg: "#12161d",
642
- fg: "#e7eef5",
643
- accent: "#7fb0d8",
644
- dim: "#566273",
645
- warm: "#cfe0ee",
646
- grid: "#e7eef5",
647
- gridOpacity: .07
648
- },
649
- {
650
- id: "plum",
651
- label: "Plum",
652
- bg: "#120a17",
653
- fg: "#f0e6f3",
654
- accent: "#c08bd6",
655
- dim: "#5e4a66",
656
- warm: "#f3c9e8",
657
- grid: "#f0e6f3",
658
- gridOpacity: .07
659
- },
660
- {
661
- id: "kol",
662
- label: "KOL",
663
- bg: "#121215",
664
- fg: "#FAF7F0",
665
- accent: "#FFCF33",
666
- dim: "#3F6485",
667
- warm: "#E3A054",
668
- grid: "#FAF7F0",
669
- gridOpacity: .1
670
- }
671
- ], Ue = J.map((e) => ({
672
- value: e.id,
673
- label: e.label
674
- }));
675
- function We(e) {
676
- return J.find((t) => t.id === e) || J[0];
677
- }
678
- function Ge(e, t = !1) {
679
- let n = We(e);
680
- return t ? {
681
- ...n,
682
- bg: n.fg,
683
- fg: n.bg,
684
- grid: n.bg
685
- } : { ...n };
686
- }
687
- //#endregion
688
- //#region src/loops/gl/rng.js
689
- function Ke(e) {
690
- let t = e >>> 0;
691
- return function() {
692
- t |= 0, t = t + 1831565813 | 0;
693
- let e = Math.imul(t ^ t >>> 15, 1 | t);
694
- return e = e + Math.imul(e ^ e >>> 7, 61 | e) ^ e, ((e ^ e >>> 14) >>> 0) / 4294967296;
695
- };
696
- }
697
- //#endregion
698
- //#region src/loops/gl/driftPalettes.js
699
- var Y = {
700
- air: [
701
- {
702
- value: "overcast",
703
- label: "Overcast",
704
- base: "#aeb9c4",
705
- cols: [
706
- "#5d6b78",
707
- "#7c8a98",
708
- "#9aa7b4",
709
- "#c4cdd6",
710
- "#eef2f6"
711
- ]
712
- },
713
- {
714
- value: "dusk",
715
- label: "Dusk",
716
- base: "#2a1c3a",
717
- cols: [
718
- "#3a2350",
719
- "#7b3f6e",
720
- "#c75c6a",
721
- "#f08e5a",
722
- "#ffd9a0"
723
- ]
724
- },
725
- {
726
- value: "storm",
727
- label: "Storm",
728
- base: "#161b24",
729
- cols: [
730
- "#1c2230",
731
- "#2f3a4c",
732
- "#566275",
733
- "#8a97a8",
734
- "#d2dae3"
735
- ]
736
- },
737
- {
738
- value: "dawn",
739
- label: "Dawn",
740
- base: "#f6c9a0",
741
- cols: [
742
- "#caa0c0",
743
- "#e3a59a",
744
- "#f4b27e",
745
- "#ffd9a0",
746
- "#fff3df"
747
- ]
748
- },
749
- {
750
- value: "noir",
751
- label: "Noir",
752
- base: "#0a0a0c",
753
- cols: [
754
- "#101014",
755
- "#33343a",
756
- "#5d5e66",
757
- "#9a9ba4",
758
- "#ededf2"
759
- ]
760
- },
761
- {
762
- value: "aurora",
763
- label: "Aurora",
764
- base: "#02141c",
765
- cols: [
766
- "#063b3a",
767
- "#0e7a5f",
768
- "#37c98a",
769
- "#6fe0c4",
770
- "#b6a8ff"
771
- ]
772
- }
773
- ],
774
- water: [
775
- {
776
- value: "ocean",
777
- label: "Ocean",
778
- base: "#a7c7d8",
779
- cols: [
780
- "#0a2a43",
781
- "#0e4c6b",
782
- "#1f7a9c",
783
- "#56b8c9",
784
- "#cdeef0"
785
- ]
786
- },
787
- {
788
- value: "tropical",
789
- label: "Tropical",
790
- base: "#c4eee6",
791
- cols: [
792
- "#04403f",
793
- "#0a7d70",
794
- "#1bb89a",
795
- "#5fe0c0",
796
- "#e8fff7"
797
- ]
798
- },
799
- {
800
- value: "lake",
801
- label: "Lake",
802
- base: "#c7d3c4",
803
- cols: [
804
- "#1f3a36",
805
- "#2f5a4e",
806
- "#4f7e6c",
807
- "#86a892",
808
- "#dfe9d8"
809
- ]
810
- },
811
- {
812
- value: "pool",
813
- label: "Pool",
814
- base: "#d2f0fb",
815
- cols: [
816
- "#0b5a8c",
817
- "#1488c4",
818
- "#3fb6e6",
819
- "#8fdcf5",
820
- "#f4ffff"
821
- ]
822
- },
823
- {
824
- value: "sunset",
825
- label: "Sunset",
826
- base: "#ffb27a",
827
- cols: [
828
- "#2a2350",
829
- "#6e3a72",
830
- "#c75c6a",
831
- "#f0925a",
832
- "#ffe2b0"
833
- ]
834
- },
835
- {
836
- value: "ink",
837
- label: "Ink",
838
- base: "#10161c",
839
- cols: [
840
- "#0b1116",
841
- "#1d2a33",
842
- "#3a5360",
843
- "#6f8c98",
844
- "#cfe2e8"
845
- ]
846
- }
847
- ],
848
- cloth: [
849
- {
850
- value: "silk",
851
- label: "Silk",
852
- base: "#1a1418",
853
- cols: [
854
- "#3a1f2e",
855
- "#7e3c54",
856
- "#c06684",
857
- "#e6a2b0",
858
- "#ffe3ec"
859
- ]
860
- },
861
- {
862
- value: "velvet",
863
- label: "Velvet",
864
- base: "#140608",
865
- cols: [
866
- "#3a060e",
867
- "#7a0f1c",
868
- "#b62230",
869
- "#e0566a",
870
- "#ffb8bf"
871
- ]
872
- },
873
- {
874
- value: "emerald",
875
- label: "Emerald",
876
- base: "#06120e",
877
- cols: [
878
- "#063425",
879
- "#0c6b46",
880
- "#1aa16a",
881
- "#56cf95",
882
- "#bff0d4"
883
- ]
884
- },
885
- {
886
- value: "royal",
887
- label: "Royal",
888
- base: "#070a18",
889
- cols: [
890
- "#0e1c52",
891
- "#1f3a9c",
892
- "#3a5fd0",
893
- "#7e9bee",
894
- "#d4e0ff"
895
- ]
896
- },
897
- {
898
- value: "gold",
899
- label: "Gold",
900
- base: "#161007",
901
- cols: [
902
- "#3a2606",
903
- "#7e5510",
904
- "#c08a22",
905
- "#e6bd56",
906
- "#fff0c0"
907
- ]
908
- },
909
- {
910
- value: "linen",
911
- label: "Linen",
912
- base: "#161310",
913
- cols: [
914
- "#4a4036",
915
- "#6f6253",
916
- "#998a77",
917
- "#c4b8a4",
918
- "#f2ead9"
919
- ]
920
- }
921
- ]
922
- }, qe = (e, t) => {
923
- let n = Y[e] || Y.air;
924
- return n.find((e) => e.value === t) || n[0];
925
- }, X = Math.PI * 2, Je = [
926
- {
927
- id: "box",
928
- label: "Cube"
929
- },
930
- {
931
- id: "sphere",
932
- label: "Sphere"
933
- },
934
- {
935
- id: "torus",
936
- label: "Torus"
937
- },
938
- {
939
- id: "torusKnot",
940
- label: "Torus knot"
941
- },
942
- {
943
- id: "cone",
944
- label: "Cone"
945
- },
946
- {
947
- id: "cylinder",
948
- label: "Cylinder"
949
- },
950
- {
951
- id: "icosahedron",
952
- label: "Icosahedron"
953
- },
954
- {
955
- id: "octahedron",
956
- label: "Octahedron"
957
- },
958
- {
959
- id: "dodecahedron",
960
- label: "Dodecahedron"
961
- }
962
- ], Ye = [
963
- {
964
- id: "spin",
965
- label: "Spin",
966
- sample: (e) => ({ rot: [
967
- 0,
968
- e * X,
969
- 0
970
- ] })
971
- },
972
- {
973
- id: "tumble",
974
- label: "Tumble",
975
- sample: (e) => ({ rot: [
976
- e * X,
977
- e * 2 * X,
978
- 0
979
- ] })
980
- },
981
- {
982
- id: "bob",
983
- label: "Bob",
984
- sample: (e) => ({
985
- pos: [
986
- 0,
987
- Math.sin(e * X) * .45,
988
- 0
989
- ],
990
- rot: [
991
- 0,
992
- e * X,
993
- 0
994
- ]
995
- })
996
- },
997
- {
998
- id: "pulse",
999
- label: "Pulse",
1000
- sample: (e) => ({
1001
- scale: 1 + Math.sin(e * X) * .18,
1002
- rot: [
1003
- 0,
1004
- e * X,
1005
- 0
1006
- ]
1007
- })
1008
- },
1009
- {
1010
- id: "sway",
1011
- label: "Sway",
1012
- sample: (e) => ({ rot: [
1013
- 0,
1014
- Math.sin(e * X) * .6,
1015
- Math.sin(e * X * 2) * .3
1016
- ] })
1017
- },
1018
- {
1019
- id: "flip",
1020
- label: "Flip",
1021
- sample: (e) => ({ rot: [
1022
- e * X,
1023
- 0,
1024
- 0
1025
- ] })
1026
- },
1027
- {
1028
- id: "orbit",
1029
- label: "Orbit",
1030
- sample: (e) => ({
1031
- pos: [
1032
- Math.cos(e * X) * .5,
1033
- 0,
1034
- Math.sin(e * X) * .5
1035
- ],
1036
- rot: [
1037
- 0,
1038
- -e * X,
1039
- 0
1040
- ]
1041
- })
1042
- }
1043
- ], Xe = [
1044
- {
1045
- value: "single",
1046
- label: "Single"
1047
- },
1048
- {
1049
- value: "ring",
1050
- label: "Ring"
1051
- },
1052
- {
1053
- value: "grid",
1054
- label: "Grid"
1055
- },
1056
- {
1057
- value: "line",
1058
- label: "Line"
1059
- },
1060
- {
1061
- value: "spiral",
1062
- label: "Spiral"
1063
- },
1064
- {
1065
- value: "scatter",
1066
- label: "Scatter"
1067
- }
1068
- ], Ze = Math.PI * 2, Qe = 2.399963229728653;
1069
- function Z(e, t) {
1070
- let n = Math.sin((e + 1) * t) * 43758.5453;
1071
- return (n - Math.floor(n)) * 2 - 1;
1072
- }
1073
- function $e(e, t, n) {
1074
- let r = Math.max(1, Math.round(t)), i = [];
1075
- if (e === "single" || r === 1) {
1076
- for (let e = 0; e < r; e++) i.push([
1077
- 0,
1078
- 0,
1079
- 0
1080
- ]);
1081
- return i;
1082
- }
1083
- if (e === "ring") for (let e = 0; e < r; e++) {
1084
- let t = e / r * Ze;
1085
- i.push([
1086
- Math.cos(t) * n,
1087
- 0,
1088
- Math.sin(t) * n
1089
- ]);
1090
- }
1091
- else if (e === "line") for (let e = 0; e < r; e++) i.push([
1092
- (e - (r - 1) / 2) * n,
1093
- 0,
1094
- 0
1095
- ]);
1096
- else if (e === "grid") {
1097
- let e = Math.ceil(Math.sqrt(r)), t = Math.ceil(r / e);
1098
- for (let a = 0; a < r; a++) {
1099
- let r = a % e, o = Math.floor(a / e);
1100
- i.push([
1101
- (r - (e - 1) / 2) * n,
1102
- ((t - 1) / 2 - o) * n,
1103
- 0
1104
- ]);
1105
- }
1106
- } else if (e === "spiral") for (let e = 0; e < r; e++) {
1107
- let t = e * Qe, a = n * Math.sqrt(e / r) * 1.3;
1108
- i.push([
1109
- Math.cos(t) * a,
1110
- (e / r - .5) * n * 1.5,
1111
- Math.sin(t) * a
1112
- ]);
1113
- }
1114
- else if (e === "scatter") for (let e = 0; e < r; e++) i.push([
1115
- Z(e, 12.9898) * n,
1116
- Z(e, 78.233) * n * .7,
1117
- Z(e, 37.719) * n
1118
- ]);
1119
- else for (let e = 0; e < r; e++) i.push([
1120
- 0,
1121
- 0,
1122
- 0
1123
- ]);
1124
- return i;
1125
- }
1126
- //#endregion
1127
- //#region src/loops/gl/gradEnums.js
1128
- var et = [
1129
- {
1130
- value: "spectrum",
1131
- label: "Spectrum",
1132
- cols: [
1133
- "#2541b2",
1134
- "#7b2ff7",
1135
- "#ff3864",
1136
- "#ff8c42",
1137
- "#ffd23f"
1138
- ]
1139
- },
1140
- {
1141
- value: "iris",
1142
- label: "Iris",
1143
- cols: [
1144
- "#0b1e7a",
1145
- "#5b2a9e",
1146
- "#c81d77",
1147
- "#ff7b54",
1148
- "#ffe66d"
1149
- ]
1150
- },
1151
- {
1152
- value: "aqua",
1153
- label: "Aqua",
1154
- cols: [
1155
- "#06113c",
1156
- "#0353a4",
1157
- "#2ec4b6",
1158
- "#80ffdb",
1159
- "#e0fbfc"
1160
- ]
1161
- },
1162
- {
1163
- value: "magma",
1164
- label: "Magma",
1165
- cols: [
1166
- "#0d0221",
1167
- "#5f0f40",
1168
- "#fb8b24",
1169
- "#e36414",
1170
- "#ffd23f"
1171
- ]
1172
- },
1173
- {
1174
- value: "candy",
1175
- label: "Candy",
1176
- cols: [
1177
- "#2b2bff",
1178
- "#11d6c9",
1179
- "#9bff8a",
1180
- "#ffd34e",
1181
- "#ff5fa2"
1182
- ]
1183
- }
1184
- ], tt = [
1185
- {
1186
- value: "black",
1187
- label: "Black",
1188
- col: "#000000"
1189
- },
1190
- {
1191
- value: "ink",
1192
- label: "Ink",
1193
- col: "#0a0612"
1194
- },
1195
- {
1196
- value: "abyss",
1197
- label: "Abyss",
1198
- col: "#04101c"
1199
- },
1200
- {
1201
- value: "plum",
1202
- label: "Plum",
1203
- col: "#140a1e"
1204
- }
1205
- ], nt = [
1206
- {
1207
- value: "custom",
1208
- label: "Custom",
1209
- p: null
1210
- },
1211
- {
1212
- value: "spectrum",
1213
- label: "Spectrum",
1214
- p: {
1215
- palette: "spectrum",
1216
- spectral: !0,
1217
- hue: 0,
1218
- irid: 1.3
1219
- }
1220
- },
1221
- {
1222
- value: "iris",
1223
- label: "Iris",
1224
- p: {
1225
- palette: "iris",
1226
- spectral: !1,
1227
- hue: .1,
1228
- irid: 1.1
1229
- }
1230
- },
1231
- {
1232
- value: "aqua",
1233
- label: "Aqua",
1234
- p: {
1235
- palette: "aqua",
1236
- spectral: !1,
1237
- hue: .5,
1238
- irid: 1
1239
- }
1240
- },
1241
- {
1242
- value: "magma",
1243
- label: "Magma",
1244
- p: {
1245
- palette: "magma",
1246
- spectral: !1,
1247
- hue: .08,
1248
- irid: .9
1249
- }
1250
- },
1251
- {
1252
- value: "candy",
1253
- label: "Candy",
1254
- p: {
1255
- palette: "candy",
1256
- spectral: !1,
1257
- hue: .8,
1258
- irid: 1.2
1259
- }
1260
- },
1261
- {
1262
- value: "noir",
1263
- label: "Noir",
1264
- p: {
1265
- palette: "spectrum",
1266
- spectral: !1,
1267
- hue: 0,
1268
- irid: .45,
1269
- backdrop: "black"
1270
- }
1271
- }
1272
- ], Q = Math.PI * 2, rt = {
1273
- manta: (e, t, n, r) => {
1274
- let i = e * 2 - 1, a = t * 2 - 1, o = i * 1.35, s = a * .65, c = Math.max(0, 1 - i * i * .55 - a * a * .9) ** .5 * .18;
1275
- return [
1276
- o,
1277
- Math.sin(n + i * Math.PI * .2) * Math.abs(i) ** 1.3 * r + c,
1278
- s
1279
- ];
1280
- },
1281
- whale: (e, t, n, r) => {
1282
- let i = e * 2 - 1, a = t * 2 - 1, o = Math.max(0, 1 - i * i) ** .55, s = i * 2.1, c = o * .42, l = a * c, u = Math.cos(t * Math.PI) * c, d = Math.max(0, (i - .55) / .45);
1283
- return [
1284
- s,
1285
- l + Math.sin(n) * r * d * d * 1.2,
1286
- u
1287
- ];
1288
- },
1289
- wing: (e, t, n, r) => {
1290
- let i = e * 2 - 1, a = t * 2 - 1, o = i * 1.4, s = a * .95 - .1, c = Math.max(0, 1 - a * a * .7) ** .6 * .08;
1291
- return [
1292
- o,
1293
- Math.sin(n + i * Math.PI * .35) * Math.abs(i) * r + c,
1294
- s
1295
- ];
1296
- },
1297
- blob: (e, t, n, r) => {
1298
- let i = e * Q, a = t * Math.PI, o = 1 + Math.sin(e * 4 * Math.PI + n) * .12 + Math.sin(t * 3 * Math.PI + n) * .1 + Math.sin((e + t) * 5 + n) * .06 * r;
1299
- return [
1300
- o * Math.sin(a) * Math.cos(i),
1301
- o * Math.cos(a),
1302
- o * Math.sin(a) * Math.sin(i)
1303
- ];
1304
- },
1305
- torus: (e, t) => {
1306
- let n = e * Q, r = t * Q, i = 1.15, a = .42;
1307
- return [
1308
- (i + a * Math.cos(r)) * Math.cos(n),
1309
- a * Math.sin(r),
1310
- (i + a * Math.cos(r)) * Math.sin(n)
1311
- ];
1312
- },
1313
- core: (e, t, n, r) => {
1314
- let i = e * 2 - 1, a = t * 2 - 1, o = Math.abs(i) ** 4 + Math.abs(a) ** 4, s = o > 0 ? o ** .25 : .01, c = s > 0 ? 1 / s : 0, l = i * c, u = a * c, d = Math.max(0, Math.cos(Math.atan2(u, l) * 4)) * .35, f = Math.sin(n) * .04 * r, p = 1 + d + f, m = Math.max(0, 1 - l * l - u * u) * .35;
1315
- return [
1316
- l * p,
1317
- m * (t < .5 ? 1 : -1),
1318
- u * p
1319
- ];
1320
- },
1321
- squid: (e, t, n, r) => {
1322
- let i = Math.floor(e * 8), a = i / 8 * Q, o = t * 2, s = Math.sin(t * Math.PI * 2.5 + n + i * .8) * r * t * .9, c = t < .15 ? (.15 - t) * 2 : 0, l = .25 + o * .35 + c * .6, u = Math.cos(a) * l + s * Math.cos(a + Math.PI / 2), d = Math.sin(a) * l + s * Math.sin(a + Math.PI / 2);
1323
- return [
1324
- u,
1325
- -o + .5,
1326
- d
1327
- ];
1328
- }
1329
- }, it = [
1330
- {
1331
- id: "helix",
1332
- label: "Helix"
1333
- },
1334
- {
1335
- id: "manta",
1336
- label: "Manta"
1337
- },
1338
- {
1339
- id: "whale",
1340
- label: "Whale"
1341
- },
1342
- {
1343
- id: "wing",
1344
- label: "Wing"
1345
- },
1346
- {
1347
- id: "blob",
1348
- label: "Blob"
1349
- },
1350
- {
1351
- id: "torus",
1352
- label: "Torus"
1353
- },
1354
- {
1355
- id: "core",
1356
- label: "Core"
1357
- },
1358
- {
1359
- id: "squid",
1360
- label: "Squid"
1361
- }
1362
- ];
1363
- function at(e, t) {
1364
- return e === "helix" ? t * 2 : t * t;
1365
- }
1366
- function ot(e, t, n, r, i) {
1367
- let a = r.amp ?? .35;
1368
- if (e === "helix") {
1369
- let e = r.turns ?? 2.5, a = r.radius ?? .85, o = r.height ?? 2.4, s = 0;
1370
- for (let r = 0; r < t; r++) {
1371
- let c = t > 1 ? r / (t - 1) : 0, l = (c - .5) * o, u = c * e * Q + n;
1372
- i[s++] = Math.sin(u) * a, i[s++] = l, i[s++] = Math.cos(u) * a, i[s++] = Math.sin(u + Math.PI) * a, i[s++] = l, i[s++] = Math.cos(u + Math.PI) * a;
1373
- }
1374
- return t * 2;
1375
- }
1376
- let o = rt[e] || rt.manta, s = 0;
1377
- for (let e = 0; e < t; e++) {
1378
- let r = t > 1 ? e / (t - 1) : 0;
1379
- for (let e = 0; e < t; e++) {
1380
- let c = o(r, t > 1 ? e / (t - 1) : 0, n, a);
1381
- i[s++] = c[0], i[s++] = c[1], i[s++] = c[2];
1382
- }
1383
- }
1384
- return t * t;
1385
- }
1386
- function st(e, t, n) {
1387
- let r = 0;
1388
- if (e === "helix") {
1389
- for (let e = 0; e < t; e++) {
1390
- let i = t > 1 ? e / (t - 1) : 0;
1391
- n[r++] = i, n[r++] = i;
1392
- }
1393
- return t * 2;
1394
- }
1395
- for (let e = 0; e < t; e++) for (let e = 0; e < t; e++) n[r++] = t > 1 ? e / (t - 1) : 0;
1396
- return t * t;
1397
- }
1398
- //#endregion
1399
- //#region src/loops/gl/envScenes.js
1400
- var ct = Math.PI * 2, lt = [
1401
- {
1402
- id: "mountain",
1403
- label: "Mountain Range"
1404
- },
1405
- {
1406
- id: "ocean",
1407
- label: "Ocean"
1408
- },
1409
- {
1410
- id: "tunnel",
1411
- label: "Tunnel"
1412
- }
1413
- ];
1414
- function ut(e, t) {
1415
- return Math.sin(e * .9 + t * .4) * .6 + Math.sin(e * 1.7 - t * 1.1 + 1.3) * .35 + Math.sin(e * .35 + t * 2.3 + 2.7) * .5 + Math.sin(e * 3.1 + t * .6 + .4) * .15;
1416
- }
1417
- var dt = {
1418
- mountain: (e, t, n, r) => {
1419
- let i = (e * 2 - 1) * 4.2, a = (t * 2 - 1) * 4.2;
1420
- return [
1421
- i,
1422
- ut(i, a) + Math.sin(i * 1.3 + n) * Math.sin(a * .9 + n * .7) * .12 * r,
1423
- a
1424
- ];
1425
- },
1426
- ocean: (e, t, n, r) => {
1427
- let i = (e * 2 - 1) * 4.2, a = (t * 2 - 1) * 4.2;
1428
- return [
1429
- i,
1430
- r * (Math.sin(i * 1.1 + n) * .5 + Math.sin(a * .85 - n * 1.3) * .4 + Math.sin((i + a) * .6 + n * .6) * .3),
1431
- a
1432
- ];
1433
- },
1434
- tunnel: (e, t, n, r) => {
1435
- let i = e * ct, a = (t * 2 - 1) * 6, o = 1.7 + Math.sin(i * 5 + a * .8 - n) * .18 * r;
1436
- return [
1437
- Math.cos(i) * o,
1438
- Math.sin(i) * o,
1439
- a
1440
- ];
1441
- }
1442
- }, ft = { tunnel: !0 };
1443
- function pt(e) {
1444
- return !!ft[e];
1445
- }
1446
- function mt(e, t, n, r, i) {
1447
- let a = r.amp ?? .5, o = dt[e] || dt.mountain, s = 0;
1448
- for (let e = 0; e < t; e++) {
1449
- let r = t > 1 ? e / (t - 1) : 0;
1450
- for (let e = 0; e < t; e++) {
1451
- let c = o(r, t > 1 ? e / (t - 1) : 0, n, a);
1452
- i[s++] = c[0], i[s++] = c[1], i[s++] = c[2];
1453
- }
1454
- }
1455
- }
1456
- function ht(e, t, n) {
1457
- let r = 0;
1458
- if (e === "tunnel") {
1459
- for (let e = 0; e < t; e++) for (let e = 0; e < t; e++) n[r++] = t > 1 ? e / (t - 1) : 0;
1460
- return;
1461
- }
1462
- for (let i = 0; i < t; i++) {
1463
- let a = t > 1 ? i / (t - 1) : 0;
1464
- for (let i = 0; i < t; i++) {
1465
- let o = t > 1 ? i / (t - 1) : 0;
1466
- n[r++] = Math.min(1, Math.max(0, .5 + ut((a * 2 - 1) * 4.2, (o * 2 - 1) * 4.2) * (e === "ocean" ? 0 : .4)));
1467
- }
1468
- }
1469
- }
1470
- function gt(e, t) {
1471
- let n = pt(e), r = n ? t : t - 1, i = new Uint32Array(r * (t - 1) * 6), a = 0;
1472
- for (let e = 0; e < r; e++) {
1473
- let r = n ? (e + 1) % t : e + 1;
1474
- for (let n = 0; n < t - 1; n++) {
1475
- let o = e * t + n, s = r * t + n, c = r * t + n + 1, l = e * t + n + 1;
1476
- i[a++] = o, i[a++] = s, i[a++] = l, i[a++] = s, i[a++] = c, i[a++] = l;
1477
- }
1478
- }
1479
- return i;
1480
- }
1481
- //#endregion
1482
- //#region src/loops/gl/meshPalettes.js
1483
- var _t = ["sphere", "plane"], vt = [
1484
- {
1485
- id: 0,
1486
- label: "normal"
1487
- },
1488
- {
1489
- id: 1,
1490
- label: "rim"
1491
- },
1492
- {
1493
- id: 2,
1494
- label: "height"
1495
- }
1496
- ], yt = [
1497
- {
1498
- id: 0,
1499
- label: "flow"
1500
- },
1501
- {
1502
- id: 1,
1503
- label: "streaks"
1504
- },
1505
- {
1506
- id: 2,
1507
- label: "aurora"
1508
- }
1509
- ], bt = [
1510
- {
1511
- id: "spectrum",
1512
- label: "Spectrum",
1513
- colors: [
1514
- "#ff3b30",
1515
- "#ffcc00",
1516
- "#34c759",
1517
- "#5ac8fa",
1518
- "#af52de"
1519
- ]
1520
- },
1521
- {
1522
- id: "heat",
1523
- label: "Heat",
1524
- colors: [
1525
- "#1a0a04",
1526
- "#a8210b",
1527
- "#ff6a00",
1528
- "#ffd000"
1529
- ]
1530
- },
1531
- {
1532
- id: "iris",
1533
- label: "Iris",
1534
- colors: [
1535
- "#00e5ff",
1536
- "#4d7cfe",
1537
- "#b14dff",
1538
- "#ff4da6"
1539
- ]
1540
- },
1541
- {
1542
- id: "sunset",
1543
- label: "Sunset",
1544
- colors: [
1545
- "#2f1b5b",
1546
- "#ff5e62",
1547
- "#ffb88c"
1548
- ]
1549
- },
1550
- {
1551
- id: "polar",
1552
- label: "Polar",
1553
- colors: [
1554
- "#04122e",
1555
- "#2a6df4",
1556
- "#9fd4ff",
1557
- "#f0fbff"
1558
- ]
1559
- },
1560
- {
1561
- id: "acid",
1562
- label: "Acid",
1563
- colors: [
1564
- "#0a2e0a",
1565
- "#1faf4b",
1566
- "#54ff4d",
1567
- "#eaff00"
1568
- ]
1569
- }
1570
- ];
1571
- function xt(e, t) {
1572
- if (!t) return e;
1573
- let n = parseInt(e.slice(1), 16), r = (n >> 16 & 255) / 255, i = (n >> 8 & 255) / 255, a = (n & 255) / 255, o = Math.max(r, i, a), s = Math.min(r, i, a), c = (o + s) / 2, l = 0, u = 0;
1574
- if (o !== s) {
1575
- let e = o - s;
1576
- u = c > .5 ? e / (2 - o - s) : e / (o + s), l = o === r ? ((i - a) / e + (i < a ? 6 : 0)) / 6 : o === i ? ((a - r) / e + 2) / 6 : ((r - i) / e + 4) / 6;
1577
- }
1578
- l = (l + t / 360 + 1) % 1;
1579
- let d = (e, t, n) => (n < 0 && (n += 1), n > 1 && --n, n < 1 / 6 ? e + (t - e) * 6 * n : n < 1 / 2 ? t : n < 2 / 3 ? e + (t - e) * (2 / 3 - n) * 6 : e);
1580
- if (u === 0) r = i = a = c;
1581
- else {
1582
- let e = c < .5 ? c * (1 + u) : c + u - c * u, t = 2 * c - e;
1583
- r = d(t, e, l + 1 / 3), i = d(t, e, l), a = d(t, e, l - 1 / 3);
1584
- }
1585
- let f = (e) => Math.round(e * 255).toString(16).padStart(2, "0");
1586
- return `#${f(r)}${f(i)}${f(a)}`;
1587
- }
1588
- //#endregion
1589
- //#region src/loops/gl/primitiveEasing.js
1590
- function St(e) {
1591
- let t = 7.5625, n = 2.75;
1592
- return e < 1 / n ? t * e * e : e < 2 / n ? (e -= 1.5 / n, t * e * e + .75) : e < 2.5 / n ? (e -= 2.25 / n, t * e * e + .9375) : (e -= 2.625 / n, t * e * e + .984375);
1593
- }
1594
- var $ = {
1595
- linear: (e) => e,
1596
- in: (e) => e * e,
1597
- out: (e) => 1 - (1 - e) * (1 - e),
1598
- inout: (e) => e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2,
1599
- sine: (e) => -(Math.cos(Math.PI * e) - 1) / 2,
1600
- cubicIn: (e) => e * e * e,
1601
- cubicOut: (e) => 1 - (1 - e) ** 3,
1602
- cubicInOut: (e) => e < .5 ? 4 * e * e * e : 1 - (-2 * e + 2) ** 3 / 2,
1603
- expoOut: (e) => e >= 1 ? 1 : 1 - 2 ** (-10 * e),
1604
- expoInOut: (e) => e <= 0 ? 0 : e >= 1 ? 1 : e < .5 ? 2 ** (20 * e - 10) / 2 : (2 - 2 ** (-20 * e + 10)) / 2,
1605
- backOut: (e) => 1 + 2.70158 * (e - 1) ** 3 + 1.70158 * (e - 1) ** 2,
1606
- backInOut: (e) => {
1607
- let t = 1.70158 * 1.525;
1608
- return e < .5 ? (2 * e) ** 2 * (3.5949095 * 2 * e - t) / 2 : ((2 * e - 2) ** 2 * (3.5949095 * (e * 2 - 2) + t) + 2) / 2;
1609
- },
1610
- elasticOut: (e) => {
1611
- if (e <= 0) return 0;
1612
- if (e >= 1) return 1;
1613
- let t = 2 * Math.PI / 3;
1614
- return 2 ** (-10 * e) * Math.sin((e * 10 - .75) * t) + 1;
1615
- },
1616
- bounceOut: St
1617
- }, Ct = {
1618
- linear: "Linear",
1619
- in: "Ease in",
1620
- out: "Ease out",
1621
- inout: "Ease in-out",
1622
- sine: "Sine",
1623
- cubicIn: "Cubic in",
1624
- cubicOut: "Cubic out",
1625
- cubicInOut: "Cubic in-out",
1626
- expoOut: "Expo out",
1627
- expoInOut: "Expo in-out",
1628
- backOut: "Back out",
1629
- backInOut: "Back in-out",
1630
- elasticOut: "Elastic out",
1631
- bounceOut: "Bounce out"
1632
- }, wt = Object.keys($).map((e) => ({
1633
- value: e,
1634
- label: Ct[e] || e
1635
- })), Tt = (e, t, n) => [
1636
- r(e[0], t[0], n),
1637
- r(e[1], t[1], n),
1638
- r(e[2], t[2], n)
1639
- ], Et = (e) => ({
1640
- rot: e.rot || [
1641
- 0,
1642
- 0,
1643
- 0
1644
- ],
1645
- pos: e.pos || [
1646
- 0,
1647
- 0,
1648
- 0
1649
- ],
1650
- scale: e.scale ?? 1
1651
- });
1652
- function Dt(e, t) {
1653
- if (!e || !e.length) return {};
1654
- if (e.length === 1) return Et(e[0]);
1655
- let n = 0;
1656
- for (; n < e.length - 1 && t > e[n + 1].t;) n++;
1657
- let i = e[n], a = e[n + 1] || i, o = a.t - i.t || 1, s = Math.max(0, Math.min(1, (t - i.t) / o));
1658
- return s = ($[a.ease] || $.inout)(s), {
1659
- rot: Tt(i.rot || [
1660
- 0,
1661
- 0,
1662
- 0
1663
- ], a.rot || [
1664
- 0,
1665
- 0,
1666
- 0
1667
- ], s),
1668
- pos: Tt(i.pos || [
1669
- 0,
1670
- 0,
1671
- 0
1672
- ], a.pos || [
1673
- 0,
1674
- 0,
1675
- 0
1676
- ], s),
1677
- scale: r(i.scale ?? 1, a.scale ?? 1, s)
1678
- };
1679
- }
1680
- var Ot = [{
1681
- t: 0,
1682
- rot: [
1683
- 0,
1684
- 0,
1685
- 0
1686
- ],
1687
- pos: [
1688
- 0,
1689
- 0,
1690
- 0
1691
- ],
1692
- scale: 1,
1693
- ease: "inout"
1694
- }, {
1695
- t: 1,
1696
- rot: [
1697
- 0,
1698
- Math.PI * 2,
1699
- 0
1700
- ],
1701
- pos: [
1702
- 0,
1703
- 0,
1704
- 0
1705
- ],
1706
- scale: 1,
1707
- ease: "inout"
1708
- }];
1709
- //#endregion
1710
- //#region src/loops/gl/phase.js
1711
- function kt(e, t) {
1712
- let n = Number(e), r = Number(t);
1713
- return !n || n <= 0 || !r || r <= 0 ? 1 : Math.max(1, Math.round(r / n));
1714
- }
1715
- function At(e, t) {
1716
- return e * t % 1;
1717
- }
1718
- //#endregion
1719
- export { Ue as A, Oe as B, Xe as C, Y as D, Je as E, Le as F, ae as G, he as H, He as I, t as J, b as K, Ve as L, We as M, G as N, qe as O, Re as P, o as Q, Ee as R, et as S, Ye as T, ye as U, Te as V, de as W, a as X, n as Y, r as Z, at as _, wt as a, tt as b, bt as c, lt as d, gt as f, it as g, ht as h, Dt as i, Ge as j, Ke as k, _t as l, mt as m, At as n, yt as o, pt as p, ne as q, Ot as r, vt as s, kt as t, xt as u, ot as v, $e as w, nt as x, st as y, De as z };