@sequenza/workbench 1.0.3 → 1.0.4
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 +3 -69
- package/app/assets/index-D4zKdPfC.css +1 -0
- package/app/assets/index-b-fcoZFF.js +900 -0
- package/app/index.html +2 -2
- package/dist/index.d.ts +11 -4
- package/dist/sequenza.js +1459 -1263
- package/package.json +2 -2
- package/app/assets/index-BbK7hGuP.css +0 -1
- package/app/assets/index-h68uMvSO.js +0 -757
package/dist/sequenza.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
import { Handle as
|
|
5
|
-
const
|
|
6
|
-
const o =
|
|
1
|
+
import * as L from "twgl.js";
|
|
2
|
+
import { jsx as t, jsxs as m, Fragment as se } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef as Qe, useRef as $, useEffect as k, useState as y, useCallback as Y, createContext as Ze, useContext as ue, useMemo as re } from "react";
|
|
4
|
+
import { Handle as en, Position as ne, getBezierPath as ke, BaseEdge as nn, EdgeLabelRenderer as tn, ReactFlowProvider as on, applyNodeChanges as rn, applyEdgeChanges as sn, addEdge as Ne, useReactFlow as an, ReactFlow as ln, Controls as cn, Panel as he, getOutgoers as Ie, getSimpleBezierPath as un } from "@xyflow/react";
|
|
5
|
+
const Ee = (n) => {
|
|
6
|
+
const o = n.replace("#", "");
|
|
7
7
|
return [
|
|
8
8
|
parseInt(o.substring(0, 2), 16),
|
|
9
9
|
parseInt(o.substring(2, 4), 16),
|
|
10
10
|
parseInt(o.substring(4, 6), 16)
|
|
11
11
|
];
|
|
12
|
-
},
|
|
13
|
-
const [
|
|
14
|
-
return `#${
|
|
15
|
-
},
|
|
16
|
-
const r = Math.max(0, Math.min(1, o)),
|
|
17
|
-
if (
|
|
18
|
-
if (
|
|
19
|
-
if (r >=
|
|
20
|
-
return
|
|
21
|
-
let
|
|
22
|
-
for (let i = 0; i <
|
|
23
|
-
if (r >=
|
|
24
|
-
|
|
12
|
+
}, dn = (n, o, r) => {
|
|
13
|
+
const [s, e, a] = Ee(n), [l, u, i] = Ee(o), c = Math.round(s + (l - s) * r).toString(16).padStart(2, "0"), h = Math.round(e + (u - e) * r).toString(16).padStart(2, "0"), f = Math.round(a + (i - a) * r).toString(16).padStart(2, "0");
|
|
14
|
+
return `#${c}${h}${f}`;
|
|
15
|
+
}, De = (n, o) => {
|
|
16
|
+
const r = Math.max(0, Math.min(1, o)), s = [...n].sort((i, c) => i.position - c.position);
|
|
17
|
+
if (s.length === 0) return "#000000";
|
|
18
|
+
if (s.length === 1 || r <= s[0].position) return s[0].color;
|
|
19
|
+
if (r >= s[s.length - 1].position)
|
|
20
|
+
return s[s.length - 1].color;
|
|
21
|
+
let e = s[0], a = s[s.length - 1];
|
|
22
|
+
for (let i = 0; i < s.length - 1; i++)
|
|
23
|
+
if (r >= s[i].position && r <= s[i + 1].position) {
|
|
24
|
+
e = s[i], a = s[i + 1];
|
|
25
25
|
break;
|
|
26
26
|
}
|
|
27
|
-
const
|
|
28
|
-
return
|
|
29
|
-
},
|
|
27
|
+
const l = a.position - e.position, u = l === 0 ? 0 : (r - e.position) / l;
|
|
28
|
+
return dn(e.color, a.color, u);
|
|
29
|
+
}, fn = (n) => typeof n == "object" && n !== null && n.type === "texture" && "src" in n, mn = (n) => typeof n == "object" && n !== null && n.type === "gradient", pn = `#version 300 es
|
|
30
30
|
|
|
31
31
|
precision highp float;
|
|
32
32
|
|
|
@@ -40,7 +40,7 @@ void main() {
|
|
|
40
40
|
gl_Position = vec4(position, 0.0, 1.0);
|
|
41
41
|
}
|
|
42
42
|
`;
|
|
43
|
-
class
|
|
43
|
+
class hn {
|
|
44
44
|
programs = {};
|
|
45
45
|
fbos = {};
|
|
46
46
|
renderOrder = [];
|
|
@@ -57,11 +57,11 @@ class cn {
|
|
|
57
57
|
onTextureLoaded;
|
|
58
58
|
error = null;
|
|
59
59
|
constructor(o, r) {
|
|
60
|
-
this.patch = r, this.gl = o, this.defaultTexture =
|
|
60
|
+
this.patch = r, this.gl = o, this.defaultTexture = L.createTexture(this.gl, {
|
|
61
61
|
minMag: this.gl.NEAREST,
|
|
62
62
|
wrap: this.gl.CLAMP_TO_EDGE,
|
|
63
63
|
auto: !1
|
|
64
|
-
}),
|
|
64
|
+
}), L.setTextureFromArray(
|
|
65
65
|
this.gl,
|
|
66
66
|
this.defaultTexture,
|
|
67
67
|
new Uint8Array([0, 0, 0, 255]),
|
|
@@ -73,20 +73,20 @@ class cn {
|
|
|
73
73
|
auto: !1
|
|
74
74
|
}
|
|
75
75
|
);
|
|
76
|
-
let
|
|
77
|
-
for (let u = 0; u < r.shaders.length && !
|
|
76
|
+
let s = !1;
|
|
77
|
+
for (let u = 0; u < r.shaders.length && !s; u++) {
|
|
78
78
|
const i = r.shaders[u];
|
|
79
|
-
if (this.programs[i.id] =
|
|
79
|
+
if (this.programs[i.id] = L.createProgramInfo(
|
|
80
80
|
this.gl,
|
|
81
|
-
[
|
|
81
|
+
[pn, i.source],
|
|
82
82
|
void 0,
|
|
83
|
-
(
|
|
84
|
-
const h =
|
|
85
|
-
this.error = { message:
|
|
83
|
+
(c) => {
|
|
84
|
+
const h = c.match(/ERROR:\s*\d+:(\d+):/), f = h ? parseInt(h[1], 10) : 0;
|
|
85
|
+
this.error = { message: c, line: f, shaderName: i.name }, s = !0;
|
|
86
86
|
}
|
|
87
|
-
),
|
|
87
|
+
), s)
|
|
88
88
|
break;
|
|
89
|
-
this.fbos[i.id] =
|
|
89
|
+
this.fbos[i.id] = L.createFramebufferInfo(
|
|
90
90
|
this.gl,
|
|
91
91
|
[
|
|
92
92
|
{
|
|
@@ -101,41 +101,41 @@ class cn {
|
|
|
101
101
|
i.resolution.height
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
|
-
this.quad =
|
|
105
|
-
const
|
|
104
|
+
this.quad = L.primitives.createXYQuadBufferInfo(this.gl);
|
|
105
|
+
const e = {}, a = {};
|
|
106
106
|
this.uniforms = {};
|
|
107
107
|
for (let u = 0; u < this.patch.shaders.length; u++) {
|
|
108
108
|
const i = this.patch.shaders[u];
|
|
109
|
-
|
|
109
|
+
e[i.id] = [], a[i.id] = 0, this.dependencyMapping[i.id] = [], this.uniforms[i.id] = {};
|
|
110
110
|
}
|
|
111
111
|
for (const u of this.patch.connections)
|
|
112
|
-
|
|
112
|
+
e[u.from].push(u.to), a[u.to] += 1, this.dependencyMapping[u.to].push({
|
|
113
113
|
input: u.input,
|
|
114
114
|
from: u.from
|
|
115
115
|
});
|
|
116
|
-
const
|
|
117
|
-
(u, [i,
|
|
116
|
+
const l = [...Object.entries(a)].reduce(
|
|
117
|
+
(u, [i, c]) => c === 0 ? [...u, i] : u,
|
|
118
118
|
[]
|
|
119
119
|
);
|
|
120
|
-
for (;
|
|
121
|
-
const u =
|
|
120
|
+
for (; l.length > 0; ) {
|
|
121
|
+
const u = l.shift();
|
|
122
122
|
this.renderOrder.push(u);
|
|
123
|
-
for (const i of
|
|
124
|
-
const
|
|
125
|
-
|
|
123
|
+
for (const i of e[u]) {
|
|
124
|
+
const c = a[i] - 1;
|
|
125
|
+
a[i] = c, c === 0 && l.push(i);
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
if (this.renderOrder.length < this.patch.shaders.length)
|
|
129
|
-
throw Error("Cycle detected in graph");
|
|
129
|
+
throw console.log(this.patch, this.renderOrder), Error("Cycle detected in graph");
|
|
130
130
|
}
|
|
131
131
|
_getOrCreateTexture(o) {
|
|
132
132
|
if (!this.textures[o]) {
|
|
133
|
-
const r =
|
|
133
|
+
const r = L.createTexture(this.gl, {
|
|
134
134
|
minMag: this.gl.NEAREST,
|
|
135
135
|
wrap: this.gl.CLAMP_TO_EDGE,
|
|
136
136
|
auto: !1
|
|
137
137
|
});
|
|
138
|
-
|
|
138
|
+
L.setTextureFromArray(this.gl, r, new Uint8Array([0, 0, 0, 255]), {
|
|
139
139
|
width: 1,
|
|
140
140
|
height: 1,
|
|
141
141
|
minMag: this.gl.NEAREST,
|
|
@@ -146,50 +146,50 @@ class cn {
|
|
|
146
146
|
return this.textures[o];
|
|
147
147
|
}
|
|
148
148
|
_updateGradientUniform(o, r) {
|
|
149
|
-
let
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
for (let
|
|
153
|
-
|
|
154
|
-
return this._updateTextureUniform(o, { type: "texture", src:
|
|
149
|
+
let s = this.gradientCanvases[o];
|
|
150
|
+
s || (s = document.createElement("canvas"), s.width = 256, s.height = 1, this.gradientCanvases[o] = s);
|
|
151
|
+
const e = s.getContext("2d");
|
|
152
|
+
for (let a = 0; a < 256; a++)
|
|
153
|
+
e.fillStyle = De(r.stops, a / 255), e.fillRect(a, 0, 1, 1);
|
|
154
|
+
return this._updateTextureUniform(o, { type: "texture", src: s });
|
|
155
155
|
}
|
|
156
156
|
_updateTextureUniform(o, r) {
|
|
157
|
-
const
|
|
158
|
-
if (typeof
|
|
159
|
-
if (this.textureSrcs[o] !==
|
|
160
|
-
this.textureSrcs[o] =
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
this.textures[o] ===
|
|
157
|
+
const s = this._getOrCreateTexture(o), e = r.src;
|
|
158
|
+
if (typeof e == "string") {
|
|
159
|
+
if (this.textureSrcs[o] !== e) {
|
|
160
|
+
this.textureSrcs[o] = e;
|
|
161
|
+
const a = new Image();
|
|
162
|
+
a.onload = () => {
|
|
163
|
+
this.textures[o] === s && (L.setTextureFromElement(this.gl, s, a, {
|
|
164
164
|
minMag: this.gl.NEAREST,
|
|
165
165
|
wrap: this.gl.CLAMP_TO_EDGE,
|
|
166
166
|
auto: !1
|
|
167
167
|
}), this.onTextureLoaded?.());
|
|
168
|
-
},
|
|
168
|
+
}, a.src = e;
|
|
169
169
|
}
|
|
170
170
|
} else
|
|
171
|
-
|
|
171
|
+
L.setTextureFromElement(this.gl, s, e, {
|
|
172
172
|
minMag: this.gl.NEAREST,
|
|
173
173
|
wrap: this.gl.CLAMP_TO_EDGE,
|
|
174
174
|
auto: !1
|
|
175
175
|
});
|
|
176
|
-
return
|
|
176
|
+
return s;
|
|
177
177
|
}
|
|
178
178
|
render() {
|
|
179
179
|
if (!this.error)
|
|
180
180
|
for (let o = 0; o < this.renderOrder.length; o++) {
|
|
181
|
-
const r = this.renderOrder[o],
|
|
182
|
-
for (const [
|
|
183
|
-
|
|
184
|
-
`${r}::${
|
|
185
|
-
|
|
186
|
-
) :
|
|
187
|
-
`${r}::${
|
|
188
|
-
|
|
181
|
+
const r = this.renderOrder[o], s = this.programs[r], e = { ...this.uniforms[r] };
|
|
182
|
+
for (const [a, l] of Object.entries(e))
|
|
183
|
+
fn(l) ? e[a] = this._updateTextureUniform(
|
|
184
|
+
`${r}::${a}`,
|
|
185
|
+
l
|
|
186
|
+
) : mn(l) && (e[a] = this._updateGradientUniform(
|
|
187
|
+
`${r}::${a}`,
|
|
188
|
+
l
|
|
189
189
|
));
|
|
190
|
-
for (const
|
|
191
|
-
|
|
192
|
-
this.gl.useProgram(
|
|
190
|
+
for (const a of this.dependencyMapping[r])
|
|
191
|
+
e[a.input] = this.fbos[a.from].attachments[0];
|
|
192
|
+
this.gl.useProgram(s.program), o !== this.renderOrder.length - 1 ? L.bindFramebufferInfo(this.gl, this.fbos[r]) : L.bindFramebufferInfo(this.gl, null), L.setUniforms(s, e), L.setBuffersAndAttributes(this.gl, s, this.quad), L.drawBufferInfo(this.gl, this.quad);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
dispose() {
|
|
@@ -209,73 +209,73 @@ class cn {
|
|
|
209
209
|
o.buffer && this.gl.deleteBuffer(o.buffer);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
|
-
const Re =
|
|
213
|
-
({ patch:
|
|
214
|
-
const
|
|
215
|
-
return
|
|
216
|
-
if (
|
|
217
|
-
const h =
|
|
212
|
+
const Re = Qe(
|
|
213
|
+
({ patch: n, uniforms: o, className: r, style: s, width: e = 100, height: a = 100, animate: l, onError: u }, i) => {
|
|
214
|
+
const c = $(null);
|
|
215
|
+
return k(() => {
|
|
216
|
+
if (c.current) {
|
|
217
|
+
const h = c.current.getContext("webgl2", {
|
|
218
218
|
preserveDrawingBuffer: !0
|
|
219
|
-
}),
|
|
220
|
-
u?.(
|
|
221
|
-
let
|
|
222
|
-
const
|
|
223
|
-
|
|
219
|
+
}), f = new hn(h, n);
|
|
220
|
+
u?.(f.error);
|
|
221
|
+
let p = null;
|
|
222
|
+
const x = () => {
|
|
223
|
+
f.uniforms = o.current, f.render();
|
|
224
224
|
};
|
|
225
|
-
return
|
|
226
|
-
|
|
227
|
-
}) : (
|
|
228
|
-
|
|
225
|
+
return l ? p = requestAnimationFrame(function w() {
|
|
226
|
+
x(), p = requestAnimationFrame(w);
|
|
227
|
+
}) : (f.onTextureLoaded = x, x()), () => {
|
|
228
|
+
p !== null && cancelAnimationFrame(p), f.dispose();
|
|
229
229
|
};
|
|
230
230
|
}
|
|
231
|
-
}, [e,
|
|
231
|
+
}, [n, e, a, l]), /* @__PURE__ */ t(
|
|
232
232
|
"canvas",
|
|
233
233
|
{
|
|
234
234
|
className: `image-crisp ${r ?? ""}`,
|
|
235
|
-
style:
|
|
236
|
-
width:
|
|
237
|
-
height:
|
|
235
|
+
style: s,
|
|
236
|
+
width: e,
|
|
237
|
+
height: a,
|
|
238
238
|
ref: (h) => {
|
|
239
|
-
|
|
239
|
+
c.current = h, typeof i == "function" ? i(h) : i && (i.current = h);
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
);
|
|
243
243
|
}
|
|
244
|
-
),
|
|
245
|
-
const o = [], r =
|
|
244
|
+
), M = "([-\\d.]+)", q = "\\s*,\\s*", ce = (n) => {
|
|
245
|
+
const o = [], r = n.source.split(`
|
|
246
246
|
`);
|
|
247
|
-
for (const
|
|
248
|
-
const
|
|
247
|
+
for (const s of r) {
|
|
248
|
+
const e = s.trim(), a = e.match(
|
|
249
249
|
new RegExp(
|
|
250
|
-
`^uniform\\s+float\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${
|
|
250
|
+
`^uniform\\s+float\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${M}${q}${M}${q}${M}\\s*\\]`
|
|
251
251
|
)
|
|
252
252
|
);
|
|
253
|
-
if (
|
|
254
|
-
const v = parseFloat(
|
|
253
|
+
if (a?.[1]) {
|
|
254
|
+
const v = parseFloat(a[2]), C = parseFloat(a[3]), A = parseFloat(a[4]);
|
|
255
255
|
o.push({
|
|
256
|
-
name:
|
|
256
|
+
name: a[1],
|
|
257
257
|
type: "float",
|
|
258
258
|
min: v,
|
|
259
|
-
max:
|
|
260
|
-
default:
|
|
259
|
+
max: C,
|
|
260
|
+
default: A
|
|
261
261
|
});
|
|
262
262
|
continue;
|
|
263
263
|
}
|
|
264
|
-
const
|
|
264
|
+
const l = e.match(
|
|
265
265
|
/^uniform\s+float\s+(\w+)\s*;.*\/\/\s*time\b/
|
|
266
266
|
);
|
|
267
|
-
if (
|
|
268
|
-
o.push({ name:
|
|
267
|
+
if (l?.[1]) {
|
|
268
|
+
o.push({ name: l[1], type: "float", special: "time" });
|
|
269
269
|
continue;
|
|
270
270
|
}
|
|
271
|
-
const u =
|
|
271
|
+
const u = e.match(/^uniform\s+float\s+(\w+)\s*;/);
|
|
272
272
|
if (u?.[1]) {
|
|
273
273
|
o.push({ name: u[1], type: "float" });
|
|
274
274
|
continue;
|
|
275
275
|
}
|
|
276
|
-
const i =
|
|
276
|
+
const i = e.match(
|
|
277
277
|
new RegExp(
|
|
278
|
-
`^uniform\\s+vec2\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${
|
|
278
|
+
`^uniform\\s+vec2\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${M}${q}${M}\\s*\\]`
|
|
279
279
|
)
|
|
280
280
|
);
|
|
281
281
|
if (i?.[1]) {
|
|
@@ -286,28 +286,28 @@ const Re = Ge(
|
|
|
286
286
|
o.push({ name: i[1], type: "vec2", default: v });
|
|
287
287
|
continue;
|
|
288
288
|
}
|
|
289
|
-
const
|
|
289
|
+
const c = e.match(
|
|
290
290
|
new RegExp(
|
|
291
|
-
`^uniform\\s+vec3\\s+(\\w+)\\s*;.*\\/\\/\\s*color(?:\\s*\\[\\s*${
|
|
291
|
+
`^uniform\\s+vec3\\s+(\\w+)\\s*;.*\\/\\/\\s*color(?:\\s*\\[\\s*${M}${q}${M}${q}${M}\\s*\\])?`
|
|
292
292
|
)
|
|
293
293
|
);
|
|
294
|
-
if (
|
|
295
|
-
const v =
|
|
296
|
-
parseFloat(
|
|
297
|
-
parseFloat(
|
|
298
|
-
parseFloat(
|
|
294
|
+
if (c?.[1]) {
|
|
295
|
+
const v = c[2] !== void 0 ? [
|
|
296
|
+
parseFloat(c[2]),
|
|
297
|
+
parseFloat(c[3]),
|
|
298
|
+
parseFloat(c[4])
|
|
299
299
|
] : void 0;
|
|
300
300
|
o.push({
|
|
301
|
-
name:
|
|
301
|
+
name: c[1],
|
|
302
302
|
type: "vec3",
|
|
303
303
|
color: !0,
|
|
304
304
|
...v && { default: v }
|
|
305
305
|
});
|
|
306
306
|
continue;
|
|
307
307
|
}
|
|
308
|
-
const h =
|
|
308
|
+
const h = e.match(
|
|
309
309
|
new RegExp(
|
|
310
|
-
`^uniform\\s+vec3\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${
|
|
310
|
+
`^uniform\\s+vec3\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${M}${q}${M}${q}${M}\\s*\\]`
|
|
311
311
|
)
|
|
312
312
|
);
|
|
313
313
|
if (h?.[1]) {
|
|
@@ -319,75 +319,90 @@ const Re = Ge(
|
|
|
319
319
|
o.push({ name: h[1], type: "vec3", default: v });
|
|
320
320
|
continue;
|
|
321
321
|
}
|
|
322
|
-
const
|
|
322
|
+
const f = e.match(
|
|
323
323
|
new RegExp(
|
|
324
|
-
`^uniform\\s+vec4\\s+(\\w+)\\s*;.*\\/\\/\\s*color(?:\\s*\\[\\s*${
|
|
324
|
+
`^uniform\\s+vec4\\s+(\\w+)\\s*;.*\\/\\/\\s*color(?:\\s*\\[\\s*${M}${q}${M}${q}${M}${q}${M}\\s*\\])?`
|
|
325
325
|
)
|
|
326
326
|
);
|
|
327
|
-
if (
|
|
328
|
-
const v =
|
|
329
|
-
parseFloat(
|
|
330
|
-
parseFloat(
|
|
331
|
-
parseFloat(
|
|
332
|
-
parseFloat(
|
|
327
|
+
if (f?.[1]) {
|
|
328
|
+
const v = f[2] !== void 0 ? [
|
|
329
|
+
parseFloat(f[2]),
|
|
330
|
+
parseFloat(f[3]),
|
|
331
|
+
parseFloat(f[4]),
|
|
332
|
+
parseFloat(f[5])
|
|
333
333
|
] : void 0;
|
|
334
334
|
o.push({
|
|
335
|
-
name:
|
|
335
|
+
name: f[1],
|
|
336
336
|
type: "vec4",
|
|
337
337
|
color: !0,
|
|
338
338
|
...v && { default: v }
|
|
339
339
|
});
|
|
340
340
|
continue;
|
|
341
341
|
}
|
|
342
|
-
const
|
|
342
|
+
const p = e.match(
|
|
343
343
|
new RegExp(
|
|
344
|
-
`^uniform\\s+vec4\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${
|
|
344
|
+
`^uniform\\s+vec4\\s+(\\w+)\\s*;.*\\/\\/\\s*\\[\\s*${M}${q}${M}${q}${M}${q}${M}\\s*\\]`
|
|
345
345
|
)
|
|
346
346
|
);
|
|
347
|
-
if (
|
|
347
|
+
if (p?.[1]) {
|
|
348
348
|
const v = [
|
|
349
|
-
parseFloat(
|
|
350
|
-
parseFloat(
|
|
351
|
-
parseFloat(
|
|
352
|
-
parseFloat(
|
|
349
|
+
parseFloat(p[2]),
|
|
350
|
+
parseFloat(p[3]),
|
|
351
|
+
parseFloat(p[4]),
|
|
352
|
+
parseFloat(p[5])
|
|
353
353
|
];
|
|
354
|
-
o.push({ name:
|
|
354
|
+
o.push({ name: p[1], type: "vec4", default: v });
|
|
355
355
|
continue;
|
|
356
356
|
}
|
|
357
|
-
const
|
|
357
|
+
const x = e.match(
|
|
358
358
|
/^uniform\s+vec2\s+(\w+)\s*;.*\/\/\s*mouse\b/
|
|
359
359
|
);
|
|
360
|
-
if (
|
|
361
|
-
o.push({ name:
|
|
360
|
+
if (x?.[1]) {
|
|
361
|
+
o.push({ name: x[1], type: "vec2", special: "mouse" });
|
|
362
362
|
continue;
|
|
363
363
|
}
|
|
364
|
-
const
|
|
364
|
+
const w = e.match(
|
|
365
365
|
/^uniform\s+vec2\s+(\w+)\s*;.*\/\/\s*resolution\b/
|
|
366
366
|
);
|
|
367
|
-
if (
|
|
368
|
-
o.push({ name:
|
|
367
|
+
if (w?.[1]) {
|
|
368
|
+
o.push({ name: w[1], type: "vec2", special: "resolution" });
|
|
369
369
|
continue;
|
|
370
370
|
}
|
|
371
|
-
const
|
|
372
|
-
if (
|
|
373
|
-
const v =
|
|
374
|
-
v === "vec2" ? o.push({ name:
|
|
371
|
+
const E = e.match(/^uniform\s+(vec[234])\s+(\w+)\s*;/);
|
|
372
|
+
if (E) {
|
|
373
|
+
const v = E[1], C = E[2];
|
|
374
|
+
v === "vec2" ? o.push({ name: C, type: "vec2" }) : v === "vec3" ? o.push({ name: C, type: "vec3" }) : v === "vec4" && o.push({ name: C, type: "vec4" });
|
|
375
375
|
continue;
|
|
376
376
|
}
|
|
377
|
-
const
|
|
377
|
+
const T = e.match(
|
|
378
378
|
/^uniform\s+sampler2D\s+(\w+)\s*;(?:.*\/\/\s*(texture|gradient)\b)?/
|
|
379
379
|
);
|
|
380
|
-
if (
|
|
381
|
-
const v =
|
|
380
|
+
if (T?.[1]) {
|
|
381
|
+
const v = T[2], C = v === "texture" ? "texture" : v === "gradient" ? "gradient" : "input";
|
|
382
382
|
o.push({
|
|
383
|
-
name:
|
|
383
|
+
name: T[1],
|
|
384
384
|
type: "sampler2D",
|
|
385
|
-
source:
|
|
385
|
+
source: C
|
|
386
386
|
});
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
return o;
|
|
390
|
-
}
|
|
390
|
+
};
|
|
391
|
+
function vn(n) {
|
|
392
|
+
switch (n.type) {
|
|
393
|
+
case "float":
|
|
394
|
+
return n.default ?? 0;
|
|
395
|
+
case "vec2":
|
|
396
|
+
return n.default ?? [0, 0];
|
|
397
|
+
case "vec3":
|
|
398
|
+
return n.default ?? (n.color ? [1, 1, 1] : [0, 0, 0]);
|
|
399
|
+
case "vec4":
|
|
400
|
+
return n.default ?? (n.color ? [1, 1, 1, 1] : [0, 0, 0, 0]);
|
|
401
|
+
case "sampler2D":
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
const gn = `import { RendererComponent, type Uniforms, type Patch } from "@sequenza/lib";
|
|
391
406
|
import "@sequenza/lib/style.css";
|
|
392
407
|
import { useRef } from "react";
|
|
393
408
|
|
|
@@ -415,109 +430,113 @@ function getPatch(): Patch {
|
|
|
415
430
|
throw new Error("placeholder for patch");
|
|
416
431
|
}
|
|
417
432
|
`;
|
|
418
|
-
function
|
|
419
|
-
let r =
|
|
420
|
-
const
|
|
421
|
-
for (const
|
|
422
|
-
|
|
433
|
+
function xn(n, o) {
|
|
434
|
+
let r = gn;
|
|
435
|
+
const s = Object.keys(n).filter((a) => !!o.shaders.find((u) => u.id === a)), e = {};
|
|
436
|
+
for (const a of s)
|
|
437
|
+
e[a] = n[a];
|
|
423
438
|
return r = r.replace(
|
|
424
439
|
'throw new Error("placeholder for initial uniforms");',
|
|
425
|
-
`return ${JSON.stringify(
|
|
440
|
+
`return ${JSON.stringify(e, null, 2)};`
|
|
426
441
|
), r = r.replace(
|
|
427
442
|
'throw new Error("placeholder for patch");',
|
|
428
443
|
`return ${JSON.stringify(o, null, 2)};`
|
|
429
444
|
), r;
|
|
430
445
|
}
|
|
431
|
-
const
|
|
432
|
-
const
|
|
433
|
-
let
|
|
434
|
-
return
|
|
435
|
-
|
|
446
|
+
const ve = 14, Se = 50, Ue = ({ id: n, type: o, position: r, count: s }) => {
|
|
447
|
+
const e = o === "source";
|
|
448
|
+
let a;
|
|
449
|
+
return e ? a = "bg-neutral-300 text-neutral-500 hover:border-neutral-500 hover:text-neutral-800 bg-[#78A3C4]" : a = "bg-neutral-300", /* @__PURE__ */ t(
|
|
450
|
+
en,
|
|
436
451
|
{
|
|
437
|
-
id:
|
|
452
|
+
id: n,
|
|
438
453
|
type: o,
|
|
439
454
|
position: r,
|
|
455
|
+
className: `${r === ne.Top ? "top-0 -translate-y-1/2" : r === ne.Bottom ? "bottom-0" : ""}`,
|
|
440
456
|
style: {
|
|
441
457
|
background: "none",
|
|
442
458
|
border: "none",
|
|
443
|
-
width:
|
|
444
|
-
height:
|
|
459
|
+
width: ve * 2,
|
|
460
|
+
height: ve,
|
|
461
|
+
...s ? {
|
|
462
|
+
transform: `translateX(${s.index / (s.total - 1) * Se - Se / 2 - ve}px)`
|
|
463
|
+
} : {}
|
|
445
464
|
},
|
|
446
|
-
children: /* @__PURE__ */
|
|
465
|
+
children: /* @__PURE__ */ t(
|
|
447
466
|
"div",
|
|
448
467
|
{
|
|
449
|
-
className: `absolute inset-0 rounded-full flex items-center justify-center text-xs font-mono leading-none pointer-events-none transition-colors ${
|
|
468
|
+
className: `absolute inset-0 rounded-full flex items-center justify-center text-xs font-mono leading-none pointer-events-none transition-colors ${a}`
|
|
450
469
|
}
|
|
451
470
|
)
|
|
452
471
|
}
|
|
453
472
|
);
|
|
454
|
-
},
|
|
455
|
-
value:
|
|
473
|
+
}, V = ({
|
|
474
|
+
value: n,
|
|
456
475
|
min: o = -1 / 0,
|
|
457
476
|
max: r = 1 / 0,
|
|
458
|
-
step:
|
|
459
|
-
label:
|
|
460
|
-
onChange:
|
|
477
|
+
step: s = 0.01,
|
|
478
|
+
label: e,
|
|
479
|
+
onChange: a
|
|
461
480
|
}) => {
|
|
462
|
-
const
|
|
463
|
-
(
|
|
464
|
-
|
|
481
|
+
const l = $(!1), u = $(0), i = $(0), [c, h] = y(!1), [f, p] = y(""), x = $(null), w = $(null), E = (_) => Math.min(r, Math.max(o, _)), T = Y(
|
|
482
|
+
(_) => {
|
|
483
|
+
c || (l.current = !0, u.current = _.clientX, i.current = n, _.preventDefault());
|
|
465
484
|
},
|
|
466
|
-
[
|
|
485
|
+
[n, c]
|
|
467
486
|
);
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
if (!
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
},
|
|
474
|
-
|
|
487
|
+
k(() => {
|
|
488
|
+
const _ = (I) => {
|
|
489
|
+
if (!l.current) return;
|
|
490
|
+
const H = (I.clientX - u.current) * s;
|
|
491
|
+
a(E(parseFloat((i.current + H).toFixed(6))));
|
|
492
|
+
}, S = () => {
|
|
493
|
+
l.current = !1;
|
|
475
494
|
};
|
|
476
|
-
return window.addEventListener("mousemove",
|
|
477
|
-
window.removeEventListener("mousemove",
|
|
495
|
+
return window.addEventListener("mousemove", _), window.addEventListener("mouseup", S), () => {
|
|
496
|
+
window.removeEventListener("mousemove", _), window.removeEventListener("mouseup", S);
|
|
478
497
|
};
|
|
479
|
-
}, [
|
|
498
|
+
}, [s, o, r, a]);
|
|
480
499
|
const v = () => {
|
|
481
|
-
|
|
482
|
-
},
|
|
483
|
-
const
|
|
484
|
-
isNaN(
|
|
485
|
-
},
|
|
486
|
-
|
|
487
|
-
},
|
|
488
|
-
return /* @__PURE__ */
|
|
489
|
-
|
|
490
|
-
/* @__PURE__ */
|
|
500
|
+
p(String(n)), h(!0), setTimeout(() => x.current?.select(), 0);
|
|
501
|
+
}, C = () => {
|
|
502
|
+
const _ = parseFloat(f);
|
|
503
|
+
isNaN(_) || a(E(_)), h(!1);
|
|
504
|
+
}, A = (_) => {
|
|
505
|
+
c || (_.key === "Enter" || _.key === " " ? (_.preventDefault(), p(String(n)), h(!0), setTimeout(() => x.current?.select(), 0)) : _.key === "ArrowRight" || _.key === "ArrowUp" ? (_.preventDefault(), a(E(parseFloat((n + s).toFixed(6))))) : (_.key === "ArrowLeft" || _.key === "ArrowDown") && (_.preventDefault(), a(E(parseFloat((n - s).toFixed(6))))));
|
|
506
|
+
}, U = Number.isInteger(n) ? n.toFixed(1) : n.toFixed(3).replace(/0+$/, "");
|
|
507
|
+
return /* @__PURE__ */ m("div", { className: "flex items-center w-20 relative nodrag", children: [
|
|
508
|
+
e && /* @__PURE__ */ t("span", { className: "absolute left-1 z-10 bg-neutral-200 h-4 w-4 grid place-items-center pointer-events-none rounded-sm", children: /* @__PURE__ */ t("p", { className: "text-[11px] font-mono w-3 text-neutral-500 height-3 leading-0 -translate-y-0.5 translate-x-0.5 ", children: e }) }),
|
|
509
|
+
/* @__PURE__ */ t(
|
|
491
510
|
"div",
|
|
492
511
|
{
|
|
493
|
-
ref:
|
|
512
|
+
ref: w,
|
|
494
513
|
tabIndex: 0,
|
|
495
|
-
onMouseDown:
|
|
514
|
+
onMouseDown: T,
|
|
496
515
|
onDoubleClick: v,
|
|
497
|
-
onKeyDown:
|
|
516
|
+
onKeyDown: A,
|
|
498
517
|
className: [
|
|
499
518
|
"flex items-center justify-center",
|
|
500
519
|
"rounded overflow-hidden select-none w-full h-6",
|
|
501
520
|
"focus:outline-2 focus:outline-neutral-400 focus:outline-offset-1",
|
|
502
|
-
|
|
521
|
+
c ? "cursor-text" : "cursor-ew-resize"
|
|
503
522
|
].join(" "),
|
|
504
|
-
children:
|
|
523
|
+
children: c ? /* @__PURE__ */ t(
|
|
505
524
|
"input",
|
|
506
525
|
{
|
|
507
|
-
ref:
|
|
508
|
-
value:
|
|
509
|
-
onChange: (
|
|
510
|
-
onBlur:
|
|
511
|
-
onKeyDown: (
|
|
512
|
-
|
|
526
|
+
ref: x,
|
|
527
|
+
value: f,
|
|
528
|
+
onChange: (_) => p(_.target.value),
|
|
529
|
+
onBlur: C,
|
|
530
|
+
onKeyDown: (_) => {
|
|
531
|
+
_.key === "Enter" && C(), _.key === "Escape" && h(!1);
|
|
513
532
|
},
|
|
514
533
|
className: "outline-none text-neutral-500 text-xs font-mono border-neutral-200 pl-5 rounded-sm text-right w-full h-full bg-white"
|
|
515
534
|
}
|
|
516
|
-
) : /* @__PURE__ */
|
|
535
|
+
) : /* @__PURE__ */ t("span", { className: "text-xs font-mono text-neutral-500 pl-5 pointer-events-none border-neutral-200 bg-white rounded-sm w-full h-full flex items-center justify-end px-1", children: /* @__PURE__ */ t("p", { children: U }) })
|
|
517
536
|
}
|
|
518
537
|
)
|
|
519
538
|
] });
|
|
520
|
-
},
|
|
539
|
+
}, ae = Ze({
|
|
521
540
|
currentTime: { current: 0 },
|
|
522
541
|
mousePosition: { current: [0, 0] },
|
|
523
542
|
shaders: [],
|
|
@@ -532,286 +551,292 @@ const we = 16, Ce = ({ id: e, type: o, position: r }) => {
|
|
|
532
551
|
uniforms: { current: {} },
|
|
533
552
|
handleUpdateUniforms: () => {
|
|
534
553
|
},
|
|
535
|
-
handleUpdateNode: (
|
|
554
|
+
handleUpdateNode: (n) => n,
|
|
536
555
|
handleInsertShader: () => {
|
|
537
556
|
}
|
|
538
|
-
}),
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
],
|
|
543
|
-
const r =
|
|
544
|
-
return /* @__PURE__ */
|
|
545
|
-
/* @__PURE__ */
|
|
557
|
+
}), ge = (n) => Math.round(Math.min(1, Math.max(0, n)) * 255).toString(16).padStart(2, "0"), xe = (n) => parseInt(n, 16) / 255, Fe = ([n, o, r]) => `#${ge(n)}${ge(o)}${ge(r)}`, Pe = (n) => [
|
|
558
|
+
xe(n.slice(1, 3)),
|
|
559
|
+
xe(n.slice(3, 5)),
|
|
560
|
+
xe(n.slice(5, 7))
|
|
561
|
+
], be = ({ color: n, onChange: o }) => {
|
|
562
|
+
const r = $(null);
|
|
563
|
+
return /* @__PURE__ */ m("div", { className: "relative", children: [
|
|
564
|
+
/* @__PURE__ */ t(
|
|
546
565
|
"button",
|
|
547
566
|
{
|
|
548
567
|
onClick: () => r.current?.click(),
|
|
549
568
|
className: "w-8 h-5.5 rounded border-2 border-neutral-200 cursor-pointer",
|
|
550
|
-
style: { backgroundColor:
|
|
551
|
-
title:
|
|
569
|
+
style: { backgroundColor: n },
|
|
570
|
+
title: n
|
|
552
571
|
}
|
|
553
572
|
),
|
|
554
|
-
/* @__PURE__ */
|
|
573
|
+
/* @__PURE__ */ t(
|
|
555
574
|
"input",
|
|
556
575
|
{
|
|
557
576
|
ref: r,
|
|
558
577
|
type: "color",
|
|
559
|
-
value:
|
|
560
|
-
onChange: (
|
|
578
|
+
value: n,
|
|
579
|
+
onChange: (s) => o(s.target.value),
|
|
561
580
|
className: "absolute opacity-0 w-0 h-0 pointer-events-none"
|
|
562
581
|
}
|
|
563
582
|
)
|
|
564
583
|
] });
|
|
565
|
-
},
|
|
584
|
+
}, Q = ({ onClick: n }) => /* @__PURE__ */ t(
|
|
566
585
|
"button",
|
|
567
586
|
{
|
|
568
|
-
onClick:
|
|
587
|
+
onClick: n,
|
|
569
588
|
className: "w-6 h-6 flex items-center justify-center text-neutral-400 hover:text-neutral-700 hover:bg-neutral-100 rounded-sm select-none shrink-0",
|
|
570
589
|
title: "Reset to default",
|
|
571
590
|
children: "↺"
|
|
572
591
|
}
|
|
573
|
-
),
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
592
|
+
), _n = ({
|
|
593
|
+
name: n,
|
|
594
|
+
type: o
|
|
595
|
+
}) => {
|
|
596
|
+
const { showStats: r } = ue(ae);
|
|
597
|
+
return /* @__PURE__ */ m("div", { className: " min-w-40 flex flex-col gap-0.5 items-end", children: [
|
|
598
|
+
/* @__PURE__ */ t("span", { className: "font-mono text-xs text-neutral-900", children: n.replace("u_", "").replaceAll("_", " ").replace(/\b\w/g, (s) => s.toUpperCase()) }),
|
|
599
|
+
r && /* @__PURE__ */ t("span", { className: "font-mono text-[10px] text-neutral-500", children: o })
|
|
578
600
|
] });
|
|
579
|
-
},
|
|
580
|
-
const [
|
|
581
|
-
|
|
601
|
+
}, bn = ({ field: n, initialValue: o, handleUpdateUniformField: r }) => {
|
|
602
|
+
const [s, e] = y(o);
|
|
603
|
+
k(() => {
|
|
604
|
+
e(o), r(o);
|
|
605
|
+
}, [o]);
|
|
606
|
+
const a = (l) => {
|
|
607
|
+
e(l), r(l);
|
|
582
608
|
};
|
|
583
|
-
return /* @__PURE__ */
|
|
584
|
-
/* @__PURE__ */
|
|
585
|
-
|
|
609
|
+
return /* @__PURE__ */ m("div", { className: "flex items-center ", children: [
|
|
610
|
+
/* @__PURE__ */ t(
|
|
611
|
+
V,
|
|
586
612
|
{
|
|
587
|
-
value:
|
|
588
|
-
min:
|
|
589
|
-
max:
|
|
613
|
+
value: s,
|
|
614
|
+
min: n.min,
|
|
615
|
+
max: n.max,
|
|
590
616
|
step: 0.01,
|
|
591
|
-
onChange:
|
|
617
|
+
onChange: a
|
|
592
618
|
}
|
|
593
619
|
),
|
|
594
|
-
|
|
595
|
-
] });
|
|
596
|
-
}, pn = ({ field: e, initialValue: o, handleUpdateUniformField: r }) => {
|
|
597
|
-
const [t, s] = y(
|
|
598
|
-
o ?? e.default ?? [0, 0]
|
|
599
|
-
), l = (a, u) => {
|
|
600
|
-
const i = [...t];
|
|
601
|
-
i[a] = u, s(i), r(i);
|
|
602
|
-
};
|
|
603
|
-
return /* @__PURE__ */ p("div", { className: "flex items-center ", children: [
|
|
604
|
-
/* @__PURE__ */ n("div", { className: "flex gap-2 flex-wrap flex-col", children: ["x", "y"].map((a, u) => /* @__PURE__ */ n(
|
|
605
|
-
H,
|
|
606
|
-
{
|
|
607
|
-
label: a,
|
|
608
|
-
value: t[u],
|
|
609
|
-
onChange: (i) => l(u, i)
|
|
610
|
-
},
|
|
611
|
-
a
|
|
612
|
-
)) }),
|
|
613
|
-
e.default !== void 0 && /* @__PURE__ */ n(
|
|
614
|
-
K,
|
|
615
|
-
{
|
|
616
|
-
onClick: () => {
|
|
617
|
-
s(e.default), r(e.default);
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
)
|
|
620
|
+
n.default !== void 0 && /* @__PURE__ */ t(Q, { onClick: () => a(n.default) })
|
|
621
621
|
] });
|
|
622
|
-
},
|
|
623
|
-
const [
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
622
|
+
}, yn = ({ handleUpdateUniformField: n }) => {
|
|
623
|
+
const [o, r] = y(!1), [s, e] = y(0);
|
|
624
|
+
k(() => {
|
|
625
|
+
if (!o) return;
|
|
626
|
+
const l = Date.now() - s * 1e3;
|
|
627
|
+
let u;
|
|
628
|
+
const i = () => {
|
|
629
|
+
const c = (Date.now() - l) / 1e3;
|
|
630
|
+
e(c), n(c), u = requestAnimationFrame(i);
|
|
631
|
+
};
|
|
632
|
+
return u = requestAnimationFrame(i), () => cancelAnimationFrame(u);
|
|
633
|
+
}, [o]);
|
|
634
|
+
const a = () => {
|
|
635
|
+
r(!1), e(0), n(0);
|
|
627
636
|
};
|
|
628
|
-
return /* @__PURE__ */
|
|
629
|
-
/* @__PURE__ */
|
|
630
|
-
|
|
637
|
+
return /* @__PURE__ */ m("div", { className: "flex items-center ", children: [
|
|
638
|
+
/* @__PURE__ */ t(
|
|
639
|
+
"button",
|
|
631
640
|
{
|
|
632
|
-
|
|
633
|
-
|
|
641
|
+
onClick: () => r((l) => !l),
|
|
642
|
+
className: "text-xs font-mono text-neutral-500 bg-neutral-100 hover:bg-neutral-200 rounded-sm w-6 h-6 flex items-center justify-center select-none",
|
|
643
|
+
title: o ? "Pause" : "Play",
|
|
644
|
+
children: o ? "⏸" : "▶"
|
|
634
645
|
}
|
|
635
646
|
),
|
|
636
|
-
|
|
647
|
+
/* @__PURE__ */ m("span", { className: "font-mono text-xs text-neutral-500 px-2 w-16 text-right tabular-nums", children: [
|
|
648
|
+
s.toFixed(2),
|
|
649
|
+
"s"
|
|
650
|
+
] }),
|
|
651
|
+
/* @__PURE__ */ t(Q, { onClick: a })
|
|
637
652
|
] });
|
|
638
|
-
},
|
|
639
|
-
const [
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
653
|
+
}, wn = ({ field: n, initialValue: o, handleUpdateUniformField: r }) => {
|
|
654
|
+
const [s, e] = y(o);
|
|
655
|
+
k(() => {
|
|
656
|
+
e(o), r(o);
|
|
657
|
+
}, [o]);
|
|
658
|
+
const a = (u, i) => {
|
|
659
|
+
const c = [...s];
|
|
660
|
+
c[u] = i, e(c), r(c);
|
|
661
|
+
}, l = (u) => {
|
|
662
|
+
e(u), r(u);
|
|
643
663
|
};
|
|
644
|
-
return /* @__PURE__ */
|
|
645
|
-
/* @__PURE__ */
|
|
646
|
-
|
|
664
|
+
return /* @__PURE__ */ m("div", { className: "flex items-center ", children: [
|
|
665
|
+
/* @__PURE__ */ t("div", { className: "flex gap-2 flex-wrap flex-col", children: ["x", "y"].map((u, i) => /* @__PURE__ */ t(
|
|
666
|
+
V,
|
|
647
667
|
{
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
)
|
|
655
|
-
/* @__PURE__ */ n(
|
|
656
|
-
H,
|
|
657
|
-
{
|
|
658
|
-
label: "a",
|
|
659
|
-
value: i,
|
|
660
|
-
min: 0,
|
|
661
|
-
max: 1,
|
|
662
|
-
step: 0.01,
|
|
663
|
-
onChange: (h) => m([l, a, u, h])
|
|
664
|
-
}
|
|
665
|
-
),
|
|
666
|
-
e.default !== void 0 && /* @__PURE__ */ n(K, { onClick: () => m(e.default) })
|
|
668
|
+
label: u,
|
|
669
|
+
value: s[i],
|
|
670
|
+
onChange: (c) => a(i, c)
|
|
671
|
+
},
|
|
672
|
+
u
|
|
673
|
+
)) }),
|
|
674
|
+
n.default !== void 0 && /* @__PURE__ */ t(Q, { onClick: () => l(n.default) })
|
|
667
675
|
] });
|
|
668
|
-
},
|
|
669
|
-
const [
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
676
|
+
}, Cn = ({ field: n, initialValue: o, handleUpdateUniformField: r }) => {
|
|
677
|
+
const [s, e] = y(o);
|
|
678
|
+
k(() => {
|
|
679
|
+
e(o), r(o);
|
|
680
|
+
}, [o]);
|
|
681
|
+
const a = (u, i) => {
|
|
682
|
+
const c = [...s];
|
|
683
|
+
c[u] = i, e(c), r(c);
|
|
684
|
+
}, l = (u) => {
|
|
685
|
+
e(u), r(u);
|
|
674
686
|
};
|
|
675
|
-
return /* @__PURE__ */
|
|
676
|
-
/* @__PURE__ */
|
|
677
|
-
|
|
687
|
+
return /* @__PURE__ */ m("div", { className: "flex items-center ", children: [
|
|
688
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col gap-2", children: ["x", "y", "z"].map((u, i) => /* @__PURE__ */ t(
|
|
689
|
+
V,
|
|
678
690
|
{
|
|
679
|
-
label:
|
|
680
|
-
value:
|
|
681
|
-
onChange: (
|
|
691
|
+
label: u,
|
|
692
|
+
value: s[i],
|
|
693
|
+
onChange: (c) => a(i, c)
|
|
682
694
|
},
|
|
683
|
-
|
|
695
|
+
u
|
|
684
696
|
)) }),
|
|
685
|
-
|
|
686
|
-
|
|
697
|
+
n.default !== void 0 && /* @__PURE__ */ t(Q, { onClick: () => l(n.default) })
|
|
698
|
+
] });
|
|
699
|
+
}, Nn = ({ field: n, initialValue: o, handleUpdateUniformField: r }) => {
|
|
700
|
+
const [s, e] = y(o);
|
|
701
|
+
k(() => {
|
|
702
|
+
e(o);
|
|
703
|
+
}, [o]);
|
|
704
|
+
const a = (l) => {
|
|
705
|
+
e(l), r(l);
|
|
706
|
+
};
|
|
707
|
+
return /* @__PURE__ */ m("div", { className: "flex items-center ", children: [
|
|
708
|
+
/* @__PURE__ */ t(
|
|
709
|
+
be,
|
|
687
710
|
{
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
}
|
|
711
|
+
color: Fe(s),
|
|
712
|
+
onChange: (l) => a(Pe(l))
|
|
691
713
|
}
|
|
692
|
-
)
|
|
714
|
+
),
|
|
715
|
+
n.default !== void 0 && /* @__PURE__ */ t(Q, { onClick: () => a(n.default) })
|
|
693
716
|
] });
|
|
694
|
-
},
|
|
695
|
-
const [
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
717
|
+
}, En = ({ field: n, initialValue: o, handleUpdateUniformField: r }) => {
|
|
718
|
+
const [s, e] = y(o);
|
|
719
|
+
k(() => {
|
|
720
|
+
e(o), r(o);
|
|
721
|
+
}, [o]);
|
|
722
|
+
const a = (u, i) => {
|
|
723
|
+
const c = [...s];
|
|
724
|
+
c[u] = i, e(c), r(c);
|
|
725
|
+
}, l = (u) => {
|
|
726
|
+
e(u), r(u);
|
|
700
727
|
};
|
|
701
|
-
return /* @__PURE__ */
|
|
702
|
-
/* @__PURE__ */
|
|
703
|
-
|
|
728
|
+
return /* @__PURE__ */ m("div", { className: "flex items-center gap-2 px-2", children: [
|
|
729
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col gap-2", children: ["x", "y", "z", "w"].map((u, i) => /* @__PURE__ */ t(
|
|
730
|
+
V,
|
|
704
731
|
{
|
|
705
|
-
label:
|
|
706
|
-
value:
|
|
707
|
-
onChange: (
|
|
732
|
+
label: u,
|
|
733
|
+
value: s[i],
|
|
734
|
+
onChange: (c) => a(i, c)
|
|
708
735
|
},
|
|
709
|
-
|
|
736
|
+
u
|
|
710
737
|
)) }),
|
|
711
|
-
|
|
712
|
-
K,
|
|
713
|
-
{
|
|
714
|
-
onClick: () => {
|
|
715
|
-
s(e.default), r(e.default);
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
)
|
|
738
|
+
n.default !== void 0 && /* @__PURE__ */ t(Q, { onClick: () => l(n.default) })
|
|
719
739
|
] });
|
|
720
|
-
},
|
|
721
|
-
const [
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
a.current = Date.now();
|
|
725
|
-
const c = () => {
|
|
726
|
-
const f = l.current + (Date.now() - a.current) / 1e3;
|
|
727
|
-
s(f), i.current(f), u.current = requestAnimationFrame(c);
|
|
728
|
-
};
|
|
729
|
-
return u.current = requestAnimationFrame(c), () => {
|
|
730
|
-
cancelAnimationFrame(u.current), l.current += (Date.now() - a.current) / 1e3;
|
|
731
|
-
};
|
|
740
|
+
}, Sn = ({ field: n, initialValue: o, handleUpdateUniformField: r }) => {
|
|
741
|
+
const [s, e] = y(o);
|
|
742
|
+
k(() => {
|
|
743
|
+
e(o);
|
|
732
744
|
}, [o]);
|
|
733
|
-
const
|
|
734
|
-
|
|
745
|
+
const [a, l, u, i] = s, c = (h) => {
|
|
746
|
+
e(h), r(h);
|
|
735
747
|
};
|
|
736
|
-
return /* @__PURE__ */
|
|
737
|
-
/* @__PURE__ */
|
|
738
|
-
|
|
748
|
+
return /* @__PURE__ */ m("div", { className: "flex items-center ", children: [
|
|
749
|
+
/* @__PURE__ */ t(
|
|
750
|
+
be,
|
|
739
751
|
{
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
752
|
+
color: Fe([a, l, u]),
|
|
753
|
+
onChange: (h) => {
|
|
754
|
+
const [f, p, x] = Pe(h);
|
|
755
|
+
c([f, p, x, i]);
|
|
756
|
+
}
|
|
744
757
|
}
|
|
745
758
|
),
|
|
746
|
-
/* @__PURE__ */
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
759
|
+
/* @__PURE__ */ t(
|
|
760
|
+
V,
|
|
761
|
+
{
|
|
762
|
+
label: "a",
|
|
763
|
+
value: i,
|
|
764
|
+
min: 0,
|
|
765
|
+
max: 1,
|
|
766
|
+
step: 0.01,
|
|
767
|
+
onChange: (h) => c([a, l, u, h])
|
|
768
|
+
}
|
|
769
|
+
),
|
|
770
|
+
n.default !== void 0 && /* @__PURE__ */ t(Q, { onClick: () => c(n.default) })
|
|
751
771
|
] });
|
|
752
|
-
},
|
|
753
|
-
const { mousePosition: o } =
|
|
754
|
-
return
|
|
755
|
-
let
|
|
772
|
+
}, Un = ({ handleUpdateUniformField: n }) => {
|
|
773
|
+
const { mousePosition: o } = ue(ae), [r, s] = y([0, 0]);
|
|
774
|
+
return k(() => {
|
|
775
|
+
let e;
|
|
756
776
|
const a = () => {
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
-
o.current[1]
|
|
760
|
-
];
|
|
761
|
-
t(u), s.current(u), l = requestAnimationFrame(a);
|
|
777
|
+
const l = [o.current[0], o.current[1]];
|
|
778
|
+
s(l), n(l), e = requestAnimationFrame(a);
|
|
762
779
|
};
|
|
763
|
-
return
|
|
764
|
-
}, []), /* @__PURE__ */
|
|
765
|
-
/* @__PURE__ */
|
|
766
|
-
/* @__PURE__ */
|
|
767
|
-
] },
|
|
768
|
-
},
|
|
769
|
-
const
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
780
|
+
return e = requestAnimationFrame(a), () => cancelAnimationFrame(e);
|
|
781
|
+
}, [n]), /* @__PURE__ */ t("div", { className: "flex items-center ", children: /* @__PURE__ */ t("div", { className: "flex gap-2 flex-col", children: ["x", "y"].map((e, a) => /* @__PURE__ */ m("div", { className: "flex items-center w-20 relative", children: [
|
|
782
|
+
/* @__PURE__ */ t("span", { className: "absolute left-1 z-10 bg-neutral-200 h-4 w-4 grid place-items-center pointer-events-none rounded-sm", children: /* @__PURE__ */ t("p", { className: "text-[11px] font-mono w-3 text-neutral-500 leading-0 -translate-y-0.5 translate-x-0.5", children: e }) }),
|
|
783
|
+
/* @__PURE__ */ t("span", { className: "text-xs font-mono text-neutral-500 pl-5 pointer-events-none bg-neutral-100 rounded-sm w-full h-6 flex items-center justify-end px-1 tabular-nums", children: r[a].toFixed(3) })
|
|
784
|
+
] }, e)) }) });
|
|
785
|
+
}, An = ({ width: n, height: o, handleUpdateUniformField: r }) => {
|
|
786
|
+
const s = $(r);
|
|
787
|
+
return s.current = r, k(() => {
|
|
788
|
+
s.current([n, o]);
|
|
789
|
+
}, [n, o]), /* @__PURE__ */ t("div", { className: "flex items-center ", children: /* @__PURE__ */ t("div", { className: "flex gap-2 flex-col", children: ["w", "h"].map((e, a) => /* @__PURE__ */ m("div", { className: "flex items-center w-20 relative", children: [
|
|
790
|
+
/* @__PURE__ */ t("span", { className: "absolute left-1 z-10 bg-neutral-200 h-4 w-4 grid place-items-center pointer-events-none rounded-sm", children: /* @__PURE__ */ t("p", { className: "text-[11px] font-mono w-3 text-neutral-500 leading-0 -translate-y-0.5 translate-x-0.5", children: e }) }),
|
|
791
|
+
/* @__PURE__ */ t("span", { className: "text-xs font-mono text-neutral-500 pl-5 pointer-events-none bg-neutral-100 rounded-sm w-full h-6 flex items-center justify-end px-1 tabular-nums", children: a === 0 ? n : o })
|
|
792
|
+
] }, e)) }) });
|
|
793
|
+
}, Tn = ({ value: n, handleUpdateUniformField: o }) => {
|
|
794
|
+
const [r, s] = y(!1), e = n?.src instanceof HTMLVideoElement ? n.src : null, a = typeof n?.src == "string" ? n.src : e?.src ?? null, l = e !== null, [u, i] = y(a), [c, h] = y(l), [f, p] = y(
|
|
795
|
+
a ? a.split("/").pop() ?? null : null
|
|
796
|
+
), [x, w] = y(() => e && e.readyState >= 1 ? [e.videoWidth, e.videoHeight] : null);
|
|
797
|
+
k(() => {
|
|
798
|
+
if (x === null) {
|
|
799
|
+
if (e) {
|
|
800
|
+
const v = () => w([e.videoWidth, e.videoHeight]);
|
|
801
|
+
e.readyState >= 1 ? v() : e.addEventListener("loadedmetadata", v, { once: !0 });
|
|
802
|
+
} else if (a && !l) {
|
|
778
803
|
const v = new Image();
|
|
779
|
-
v.onload = () =>
|
|
804
|
+
v.onload = () => w([v.naturalWidth, v.naturalHeight]), v.src = a;
|
|
780
805
|
}
|
|
781
806
|
}
|
|
782
807
|
}, []);
|
|
783
|
-
const
|
|
808
|
+
const E = $(null), T = (v) => {
|
|
784
809
|
if (!v) return;
|
|
785
|
-
const
|
|
786
|
-
if (i(
|
|
787
|
-
const
|
|
788
|
-
|
|
810
|
+
const C = URL.createObjectURL(v), A = v.type.startsWith("video/");
|
|
811
|
+
if (i(C), h(A), p(v.name), w(null), A) {
|
|
812
|
+
const U = document.createElement("video");
|
|
813
|
+
U.autoplay = !0, U.muted = !0, U.loop = !0, U.playsInline = !0, U.onloadedmetadata = () => w([U.videoWidth, U.videoHeight]), U.src = C, U.play(), o({ type: "texture", src: U });
|
|
789
814
|
} else {
|
|
790
|
-
const
|
|
791
|
-
|
|
815
|
+
const U = new Image();
|
|
816
|
+
U.onload = () => w([U.naturalWidth, U.naturalHeight]), U.src = C, o({ type: "texture", src: C });
|
|
792
817
|
}
|
|
793
818
|
};
|
|
794
|
-
return
|
|
819
|
+
return k(() => {
|
|
795
820
|
if (!r) return;
|
|
796
|
-
const v = (
|
|
797
|
-
if (
|
|
798
|
-
for (const
|
|
799
|
-
if (
|
|
800
|
-
|
|
821
|
+
const v = (C) => {
|
|
822
|
+
if (C.clipboardData) {
|
|
823
|
+
for (const A of C.clipboardData.items)
|
|
824
|
+
if (A.type.startsWith("image/") || A.type.startsWith("video/")) {
|
|
825
|
+
T(A.getAsFile());
|
|
801
826
|
break;
|
|
802
827
|
}
|
|
803
828
|
}
|
|
804
829
|
};
|
|
805
830
|
return window.addEventListener("paste", v), () => window.removeEventListener("paste", v);
|
|
806
|
-
}, [r]), /* @__PURE__ */
|
|
807
|
-
/* @__PURE__ */
|
|
831
|
+
}, [r]), /* @__PURE__ */ t("div", { className: "flex items-center ", children: /* @__PURE__ */ m("div", { className: "flex flex-col items-start gap-2", children: [
|
|
832
|
+
/* @__PURE__ */ t(
|
|
808
833
|
"div",
|
|
809
834
|
{
|
|
810
835
|
tabIndex: 0,
|
|
811
|
-
onFocus: () =>
|
|
812
|
-
onBlur: () =>
|
|
836
|
+
onFocus: () => s(!0),
|
|
837
|
+
onBlur: () => s(!1),
|
|
813
838
|
className: `w-32 h-32 rounded overflow-hidden flex flex-col items-center justify-center cursor-pointer select-none transition border-4 text-neutral-500 text-xs font-mono p-2 ${r ? "bg-neutral-50 border-neutral-300" : "bg-neutral-100 border-neutral-50"}`,
|
|
814
|
-
children: u ?
|
|
839
|
+
children: u ? c ? /* @__PURE__ */ t(
|
|
815
840
|
"video",
|
|
816
841
|
{
|
|
817
842
|
src: u,
|
|
@@ -821,117 +846,111 @@ const we = 16, Ce = ({ id: e, type: o, position: r }) => {
|
|
|
821
846
|
loop: !0,
|
|
822
847
|
playsInline: !0
|
|
823
848
|
}
|
|
824
|
-
) : /* @__PURE__ */
|
|
825
|
-
/* @__PURE__ */
|
|
826
|
-
/* @__PURE__ */
|
|
849
|
+
) : /* @__PURE__ */ t("img", { src: u, className: "w-full h-full object-contain" }) : r ? "cmd+V" : /* @__PURE__ */ m(se, { children: [
|
|
850
|
+
/* @__PURE__ */ t("p", { children: "Paste" }),
|
|
851
|
+
/* @__PURE__ */ t("p", { children: "Here" })
|
|
827
852
|
] })
|
|
828
853
|
}
|
|
829
854
|
),
|
|
830
|
-
/* @__PURE__ */
|
|
831
|
-
/* @__PURE__ */
|
|
855
|
+
/* @__PURE__ */ m("div", { className: "flex flex-col items-start gap-0.5", children: [
|
|
856
|
+
/* @__PURE__ */ t(
|
|
832
857
|
"button",
|
|
833
858
|
{
|
|
834
859
|
className: "button-base",
|
|
835
|
-
onClick: () =>
|
|
860
|
+
onClick: () => E.current?.click(),
|
|
836
861
|
children: u ? "Replace" : "Upload"
|
|
837
862
|
}
|
|
838
863
|
),
|
|
839
|
-
|
|
864
|
+
f && /* @__PURE__ */ t(
|
|
840
865
|
"span",
|
|
841
866
|
{
|
|
842
867
|
className: "text-[10px] text-neutral-400 font-mono truncate max-w-32",
|
|
843
|
-
title:
|
|
844
|
-
children:
|
|
868
|
+
title: f,
|
|
869
|
+
children: f
|
|
845
870
|
}
|
|
846
871
|
),
|
|
847
|
-
|
|
848
|
-
|
|
872
|
+
x && /* @__PURE__ */ m("span", { className: "text-[10px] text-neutral-400 font-mono", children: [
|
|
873
|
+
x[0],
|
|
849
874
|
"×",
|
|
850
|
-
|
|
875
|
+
x[1]
|
|
851
876
|
] })
|
|
852
877
|
] }),
|
|
853
|
-
/* @__PURE__ */
|
|
878
|
+
/* @__PURE__ */ t(
|
|
854
879
|
"input",
|
|
855
880
|
{
|
|
856
|
-
ref:
|
|
881
|
+
ref: E,
|
|
857
882
|
type: "file",
|
|
858
883
|
accept: "image/*,video/*",
|
|
859
884
|
className: "hidden",
|
|
860
|
-
onChange: (v) =>
|
|
885
|
+
onChange: (v) => T(v.target.files?.[0] ?? null)
|
|
861
886
|
}
|
|
862
887
|
)
|
|
863
888
|
] }) });
|
|
864
|
-
},
|
|
889
|
+
}, Ae = [
|
|
865
890
|
{ position: 0, color: "#000000" },
|
|
866
891
|
{ position: 1, color: "#ffffff" }
|
|
867
|
-
],
|
|
868
|
-
const
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
const c = s.current;
|
|
881
|
-
if (!c) return;
|
|
882
|
-
const f = c.getContext("2d");
|
|
883
|
-
if (f) {
|
|
884
|
-
for (let b = 0; b < c.width; b++)
|
|
885
|
-
f.fillStyle = ke(r, b / (c.width - 1)), f.fillRect(b, 0, 1, c.height);
|
|
892
|
+
], kn = ({ value: n, handleUpdateUniformField: o }) => {
|
|
893
|
+
const [r, s] = y(
|
|
894
|
+
n?.stops ?? Ae
|
|
895
|
+
), e = $(null), a = $(null);
|
|
896
|
+
k(() => {
|
|
897
|
+
s(n?.stops ?? Ae);
|
|
898
|
+
}, [n]), k(() => {
|
|
899
|
+
const f = e.current;
|
|
900
|
+
if (!f) return;
|
|
901
|
+
const p = f.getContext("2d");
|
|
902
|
+
if (p) {
|
|
903
|
+
for (let x = 0; x < f.width; x++)
|
|
904
|
+
p.fillStyle = De(r, x / (f.width - 1)), p.fillRect(x, 0, 1, f.height);
|
|
886
905
|
o({ type: "gradient", stops: r });
|
|
887
906
|
}
|
|
888
907
|
}, [r]);
|
|
889
|
-
const
|
|
890
|
-
|
|
891
|
-
const
|
|
892
|
-
if (!
|
|
893
|
-
const
|
|
894
|
-
const v =
|
|
895
|
-
|
|
896
|
-
(
|
|
908
|
+
const l = (f) => (p) => {
|
|
909
|
+
p.preventDefault();
|
|
910
|
+
const x = a.current;
|
|
911
|
+
if (!x) return;
|
|
912
|
+
const w = (T) => {
|
|
913
|
+
const v = x.getBoundingClientRect(), A = Math.max(0, Math.min(T.clientX - v.left, v.width)) / v.width;
|
|
914
|
+
s(
|
|
915
|
+
(U) => U.map((_, S) => S === f ? { ..._, position: A } : _)
|
|
897
916
|
);
|
|
898
|
-
},
|
|
899
|
-
window.removeEventListener("mousemove",
|
|
917
|
+
}, E = () => {
|
|
918
|
+
window.removeEventListener("mousemove", w), window.removeEventListener("mouseup", E);
|
|
900
919
|
};
|
|
901
|
-
window.addEventListener("mousemove",
|
|
902
|
-
}, u = () =>
|
|
903
|
-
r.length <= 1 ||
|
|
904
|
-
},
|
|
905
|
-
(
|
|
906
|
-
), h = (
|
|
907
|
-
return /* @__PURE__ */
|
|
908
|
-
/* @__PURE__ */
|
|
909
|
-
/* @__PURE__ */
|
|
920
|
+
window.addEventListener("mousemove", w), window.addEventListener("mouseup", E);
|
|
921
|
+
}, u = () => s((f) => [...f, { position: 1, color: "#ffffff" }]), i = (f) => {
|
|
922
|
+
r.length <= 1 || s((p) => p.filter((x, w) => w !== f));
|
|
923
|
+
}, c = (f, p) => s(
|
|
924
|
+
(x) => x.map((w, E) => E === f ? { ...w, position: p } : w)
|
|
925
|
+
), h = (f, p) => s((x) => x.map((w, E) => E === f ? { ...w, color: p } : w));
|
|
926
|
+
return /* @__PURE__ */ m("div", { className: "flex flex-col gap-3 p-2", children: [
|
|
927
|
+
/* @__PURE__ */ m("div", { ref: a, className: "relative w-32 h-4 nodrag nopan", children: [
|
|
928
|
+
/* @__PURE__ */ t(
|
|
910
929
|
"canvas",
|
|
911
930
|
{
|
|
912
|
-
ref:
|
|
931
|
+
ref: e,
|
|
913
932
|
width: 128,
|
|
914
933
|
height: 16,
|
|
915
934
|
className: "w-32 h-4 rounded-sm border-2 border-neutral-200"
|
|
916
935
|
}
|
|
917
936
|
),
|
|
918
|
-
r.map((
|
|
937
|
+
r.map((f, p) => /* @__PURE__ */ t(
|
|
919
938
|
"button",
|
|
920
939
|
{
|
|
921
|
-
"aria-label": `gradient stop ${
|
|
940
|
+
"aria-label": `gradient stop ${p}`,
|
|
922
941
|
className: "absolute w-4 h-4 -translate-x-1/2 -bottom-2 rounded-sm border-2 border-neutral-200 cursor-ew-resize",
|
|
923
942
|
style: {
|
|
924
|
-
left: `${
|
|
925
|
-
backgroundColor:
|
|
943
|
+
left: `${f.position * 100}%`,
|
|
944
|
+
backgroundColor: f.color
|
|
926
945
|
},
|
|
927
|
-
onMouseDown:
|
|
946
|
+
onMouseDown: l(p)
|
|
928
947
|
},
|
|
929
|
-
|
|
948
|
+
p
|
|
930
949
|
))
|
|
931
950
|
] }),
|
|
932
|
-
/* @__PURE__ */
|
|
933
|
-
/* @__PURE__ */
|
|
934
|
-
/* @__PURE__ */
|
|
951
|
+
/* @__PURE__ */ m("div", { className: "flex items-center justify-between w-32", children: [
|
|
952
|
+
/* @__PURE__ */ t("span", { className: "font-mono text-[10px] text-neutral-500", children: "STOPS" }),
|
|
953
|
+
/* @__PURE__ */ t(
|
|
935
954
|
"button",
|
|
936
955
|
{
|
|
937
956
|
onClick: u,
|
|
@@ -940,259 +959,223 @@ const we = 16, Ce = ({ id: e, type: o, position: r }) => {
|
|
|
940
959
|
}
|
|
941
960
|
)
|
|
942
961
|
] }),
|
|
943
|
-
/* @__PURE__ */
|
|
944
|
-
/* @__PURE__ */
|
|
945
|
-
|
|
962
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col gap-1.5", children: r.map((f, p) => /* @__PURE__ */ m("div", { className: "flex items-center gap-2", children: [
|
|
963
|
+
/* @__PURE__ */ t(
|
|
964
|
+
V,
|
|
946
965
|
{
|
|
947
|
-
value:
|
|
966
|
+
value: f.position,
|
|
948
967
|
min: 0,
|
|
949
968
|
max: 1,
|
|
950
969
|
step: 0.01,
|
|
951
|
-
onChange: (
|
|
970
|
+
onChange: (x) => c(p, x)
|
|
952
971
|
}
|
|
953
972
|
),
|
|
954
|
-
/* @__PURE__ */
|
|
955
|
-
|
|
973
|
+
/* @__PURE__ */ t(
|
|
974
|
+
be,
|
|
956
975
|
{
|
|
957
|
-
color:
|
|
958
|
-
onChange: (
|
|
976
|
+
color: f.color,
|
|
977
|
+
onChange: (x) => h(p, x)
|
|
959
978
|
}
|
|
960
979
|
),
|
|
961
|
-
r.length > 1 && /* @__PURE__ */
|
|
980
|
+
r.length > 1 && /* @__PURE__ */ t(
|
|
962
981
|
"button",
|
|
963
982
|
{
|
|
964
|
-
onClick: () => i(
|
|
983
|
+
onClick: () => i(p),
|
|
965
984
|
className: "text-xs text-neutral-400 hover:text-neutral-700 leading-none px-1",
|
|
966
|
-
"aria-label": `remove stop ${
|
|
985
|
+
"aria-label": `remove stop ${p}`,
|
|
967
986
|
children: "×"
|
|
968
987
|
}
|
|
969
988
|
)
|
|
970
|
-
] },
|
|
989
|
+
] }, p)) })
|
|
971
990
|
] });
|
|
972
|
-
}, En = (e, o) => {
|
|
973
|
-
const r = {};
|
|
974
|
-
for (const t of e)
|
|
975
|
-
switch (t.type) {
|
|
976
|
-
case "float":
|
|
977
|
-
r[t.name] = t.default ?? 0;
|
|
978
|
-
break;
|
|
979
|
-
case "vec2":
|
|
980
|
-
r[t.name] = t.default ?? [0, 0];
|
|
981
|
-
break;
|
|
982
|
-
case "vec3":
|
|
983
|
-
r[t.name] = t.default ?? [0, 0, 0];
|
|
984
|
-
break;
|
|
985
|
-
case "vec4":
|
|
986
|
-
r[t.name] = t.default ?? [0, 0, 0, 0];
|
|
987
|
-
break;
|
|
988
|
-
}
|
|
989
|
-
if (o)
|
|
990
|
-
for (const t of e)
|
|
991
|
-
t.name in o && (r[t.name] = o[t.name]);
|
|
992
|
-
return r;
|
|
993
991
|
};
|
|
994
|
-
function
|
|
995
|
-
switch (
|
|
992
|
+
function In(n) {
|
|
993
|
+
switch (n.type) {
|
|
996
994
|
case "float":
|
|
997
|
-
return
|
|
995
|
+
return n.special === "time" ? "float time" : "float";
|
|
998
996
|
case "vec2":
|
|
999
|
-
return
|
|
997
|
+
return n.special === "mouse" ? "vec2 mouse" : n.special === "resolution" ? "vec2 resolution" : "vec2";
|
|
1000
998
|
case "vec3":
|
|
1001
|
-
return
|
|
999
|
+
return n.color ? "vec3 color" : "vec3";
|
|
1002
1000
|
case "vec4":
|
|
1003
|
-
return
|
|
1001
|
+
return n.color ? "vec4 color" : "vec4";
|
|
1004
1002
|
case "sampler2D":
|
|
1005
|
-
return
|
|
1003
|
+
return n.source === "gradient" ? "sampler2D gradient" : "sampler2D texture";
|
|
1006
1004
|
}
|
|
1007
1005
|
}
|
|
1008
|
-
const
|
|
1009
|
-
shader:
|
|
1010
|
-
|
|
1006
|
+
const Me = ({
|
|
1007
|
+
shader: n,
|
|
1008
|
+
savedUniforms: o,
|
|
1011
1009
|
handleUpdateUniform: r
|
|
1012
1010
|
}) => {
|
|
1013
|
-
const
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
l.current = { ...s }, r(l.current);
|
|
1019
|
-
}, [s]), t.length === 0 ? /* @__PURE__ */ p("p", { className: "px-2 py-3 font-mono text-xs", children: [
|
|
1020
|
-
"No uniforms found.",
|
|
1021
|
-
" ",
|
|
1022
|
-
/* @__PURE__ */ p("span", { children: [
|
|
1023
|
-
"Add ",
|
|
1024
|
-
/* @__PURE__ */ n("code", { className: "", children: "// [min, max, default]" }),
|
|
1025
|
-
" comments to float uniforms."
|
|
1026
|
-
] })
|
|
1027
|
-
] }) : /* @__PURE__ */ n("div", { className: "rounded flex flex-col gap-1", children: t.map((a) => {
|
|
1028
|
-
const u = `${a.name}-${a.type}`, i = (c) => {
|
|
1029
|
-
l.current[a.name] = c, r(l.current);
|
|
1030
|
-
}, m = (c) => {
|
|
1031
|
-
c === null ? delete l.current[a.name] : l.current[a.name] = c, r(l.current);
|
|
1032
|
-
};
|
|
1011
|
+
const s = re(() => ce(n), [n.source]);
|
|
1012
|
+
return s.filter((e) => !(e.type === "sampler2D" && e.source === "input")).length === 0 ? /* @__PURE__ */ t(se, {}) : /* @__PURE__ */ t("div", { className: "rounded flex flex-col gap-1", children: s.map((e) => {
|
|
1013
|
+
const a = `${e.name}-${e.type}`, l = (f) => r(e.name, f), u = (f) => {
|
|
1014
|
+
r(e.name, f);
|
|
1015
|
+
}, i = o[e.name], c = vn(e);
|
|
1033
1016
|
let h = null;
|
|
1034
|
-
switch (
|
|
1017
|
+
switch (e.type) {
|
|
1035
1018
|
case "float":
|
|
1036
|
-
h =
|
|
1037
|
-
|
|
1019
|
+
h = e.special === "time" ? /* @__PURE__ */ t(
|
|
1020
|
+
yn,
|
|
1038
1021
|
{
|
|
1039
|
-
field:
|
|
1040
|
-
handleUpdateUniformField:
|
|
1022
|
+
field: e,
|
|
1023
|
+
handleUpdateUniformField: l
|
|
1041
1024
|
}
|
|
1042
|
-
) : /* @__PURE__ */
|
|
1043
|
-
|
|
1025
|
+
) : /* @__PURE__ */ t(
|
|
1026
|
+
bn,
|
|
1044
1027
|
{
|
|
1045
|
-
field:
|
|
1046
|
-
initialValue:
|
|
1047
|
-
handleUpdateUniformField:
|
|
1028
|
+
field: e,
|
|
1029
|
+
initialValue: i ?? c,
|
|
1030
|
+
handleUpdateUniformField: l
|
|
1048
1031
|
}
|
|
1049
1032
|
);
|
|
1050
1033
|
break;
|
|
1051
1034
|
case "vec2":
|
|
1052
|
-
h =
|
|
1053
|
-
|
|
1035
|
+
h = e.special === "mouse" ? /* @__PURE__ */ t(
|
|
1036
|
+
Un,
|
|
1054
1037
|
{
|
|
1055
|
-
field:
|
|
1056
|
-
handleUpdateUniformField:
|
|
1038
|
+
field: e,
|
|
1039
|
+
handleUpdateUniformField: l
|
|
1057
1040
|
}
|
|
1058
|
-
) :
|
|
1059
|
-
|
|
1041
|
+
) : e.special === "resolution" ? /* @__PURE__ */ t(
|
|
1042
|
+
An,
|
|
1060
1043
|
{
|
|
1061
|
-
field:
|
|
1062
|
-
width:
|
|
1063
|
-
height:
|
|
1064
|
-
handleUpdateUniformField:
|
|
1044
|
+
field: e,
|
|
1045
|
+
width: n.resolution.width,
|
|
1046
|
+
height: n.resolution.height,
|
|
1047
|
+
handleUpdateUniformField: l
|
|
1065
1048
|
}
|
|
1066
|
-
) : /* @__PURE__ */
|
|
1067
|
-
|
|
1049
|
+
) : /* @__PURE__ */ t(
|
|
1050
|
+
wn,
|
|
1068
1051
|
{
|
|
1069
|
-
field:
|
|
1070
|
-
initialValue:
|
|
1071
|
-
handleUpdateUniformField:
|
|
1052
|
+
field: e,
|
|
1053
|
+
initialValue: i ?? c,
|
|
1054
|
+
handleUpdateUniformField: l
|
|
1072
1055
|
}
|
|
1073
1056
|
);
|
|
1074
1057
|
break;
|
|
1075
1058
|
case "vec3":
|
|
1076
|
-
h =
|
|
1077
|
-
|
|
1059
|
+
h = e.color ? /* @__PURE__ */ t(
|
|
1060
|
+
Nn,
|
|
1078
1061
|
{
|
|
1079
|
-
field:
|
|
1080
|
-
initialValue:
|
|
1081
|
-
handleUpdateUniformField:
|
|
1062
|
+
field: e,
|
|
1063
|
+
initialValue: i ?? c,
|
|
1064
|
+
handleUpdateUniformField: l
|
|
1082
1065
|
}
|
|
1083
|
-
) : /* @__PURE__ */
|
|
1084
|
-
|
|
1066
|
+
) : /* @__PURE__ */ t(
|
|
1067
|
+
Cn,
|
|
1085
1068
|
{
|
|
1086
|
-
field:
|
|
1087
|
-
initialValue:
|
|
1088
|
-
handleUpdateUniformField:
|
|
1069
|
+
field: e,
|
|
1070
|
+
initialValue: i ?? c,
|
|
1071
|
+
handleUpdateUniformField: l
|
|
1089
1072
|
}
|
|
1090
1073
|
);
|
|
1091
1074
|
break;
|
|
1092
1075
|
case "vec4":
|
|
1093
|
-
h =
|
|
1094
|
-
|
|
1076
|
+
h = e.color ? /* @__PURE__ */ t(
|
|
1077
|
+
Sn,
|
|
1095
1078
|
{
|
|
1096
|
-
field:
|
|
1097
|
-
initialValue:
|
|
1098
|
-
handleUpdateUniformField:
|
|
1079
|
+
field: e,
|
|
1080
|
+
initialValue: i ?? c,
|
|
1081
|
+
handleUpdateUniformField: l
|
|
1099
1082
|
}
|
|
1100
|
-
) : /* @__PURE__ */
|
|
1101
|
-
|
|
1083
|
+
) : /* @__PURE__ */ t(
|
|
1084
|
+
En,
|
|
1102
1085
|
{
|
|
1103
|
-
field:
|
|
1104
|
-
initialValue:
|
|
1105
|
-
handleUpdateUniformField:
|
|
1086
|
+
field: e,
|
|
1087
|
+
initialValue: i ?? c,
|
|
1088
|
+
handleUpdateUniformField: l
|
|
1106
1089
|
}
|
|
1107
1090
|
);
|
|
1108
1091
|
break;
|
|
1109
1092
|
case "sampler2D":
|
|
1110
|
-
|
|
1111
|
-
|
|
1093
|
+
e.source === "texture" ? h = /* @__PURE__ */ t(
|
|
1094
|
+
Tn,
|
|
1112
1095
|
{
|
|
1113
|
-
field:
|
|
1114
|
-
|
|
1115
|
-
handleUpdateUniformField:
|
|
1096
|
+
field: e,
|
|
1097
|
+
value: i,
|
|
1098
|
+
handleUpdateUniformField: u
|
|
1116
1099
|
}
|
|
1117
|
-
) :
|
|
1118
|
-
|
|
1100
|
+
) : e.source === "gradient" && (h = /* @__PURE__ */ t(
|
|
1101
|
+
kn,
|
|
1119
1102
|
{
|
|
1120
|
-
field:
|
|
1121
|
-
|
|
1122
|
-
handleUpdateUniformField:
|
|
1103
|
+
field: e,
|
|
1104
|
+
value: i,
|
|
1105
|
+
handleUpdateUniformField: l
|
|
1123
1106
|
}
|
|
1124
1107
|
));
|
|
1125
1108
|
break;
|
|
1126
1109
|
}
|
|
1127
|
-
return h === null ? null : /* @__PURE__ */
|
|
1128
|
-
/* @__PURE__ */
|
|
1129
|
-
/* @__PURE__ */
|
|
1130
|
-
] },
|
|
1110
|
+
return h === null ? null : /* @__PURE__ */ m("div", { className: "flex items-center gap-4 rounded-sm mb-1", children: [
|
|
1111
|
+
/* @__PURE__ */ t(_n, { name: e.name, type: In(e) }),
|
|
1112
|
+
/* @__PURE__ */ t("div", { className: "bg-neutral-100 p-1 rounded-md", children: h })
|
|
1113
|
+
] }, a);
|
|
1131
1114
|
}) });
|
|
1132
|
-
},
|
|
1133
|
-
children:
|
|
1115
|
+
}, de = ({
|
|
1116
|
+
children: n,
|
|
1134
1117
|
open: o,
|
|
1135
1118
|
className: r,
|
|
1136
|
-
handleOpenChange:
|
|
1119
|
+
handleOpenChange: s
|
|
1137
1120
|
}) => {
|
|
1138
|
-
const
|
|
1139
|
-
return
|
|
1140
|
-
|
|
1141
|
-
}, [o]),
|
|
1142
|
-
|
|
1143
|
-
}, [
|
|
1121
|
+
const e = $(null), [a, l] = y(o);
|
|
1122
|
+
return k(() => {
|
|
1123
|
+
l(!!o);
|
|
1124
|
+
}, [o]), k(() => {
|
|
1125
|
+
e.current !== null && (a ? e.current.showModal() : e.current.close()), s(a);
|
|
1126
|
+
}, [a]), /* @__PURE__ */ t(
|
|
1144
1127
|
"dialog",
|
|
1145
1128
|
{
|
|
1146
|
-
ref:
|
|
1147
|
-
className: `top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-3xl h-5/6 border border-neutral-300 rounded-lg starting:opacity-0 opacity-100 transition-all transition-discrete ${
|
|
1148
|
-
children:
|
|
1129
|
+
ref: e,
|
|
1130
|
+
className: `top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-3xl h-5/6 border border-neutral-300 rounded-lg starting:opacity-0 opacity-100 transition-all transition-discrete ${a ? "visible" : "hidden"} ${r} nopan nodrag nowheel`,
|
|
1131
|
+
children: o && n
|
|
1149
1132
|
}
|
|
1150
1133
|
);
|
|
1151
|
-
},
|
|
1152
|
-
uniforms:
|
|
1134
|
+
}, Te = "pnpm i @sequenza/lib", $e = ({
|
|
1135
|
+
uniforms: n,
|
|
1153
1136
|
patch: o,
|
|
1154
1137
|
open: r,
|
|
1155
|
-
onOpenChange:
|
|
1138
|
+
onOpenChange: s
|
|
1156
1139
|
}) => {
|
|
1157
|
-
const
|
|
1158
|
-
return /* @__PURE__ */
|
|
1159
|
-
|
|
1140
|
+
const e = xn(n, o), [a, l] = y("idle"), [u, i] = y("idle");
|
|
1141
|
+
return /* @__PURE__ */ m(
|
|
1142
|
+
de,
|
|
1160
1143
|
{
|
|
1161
1144
|
open: r,
|
|
1162
|
-
handleOpenChange:
|
|
1145
|
+
handleOpenChange: s,
|
|
1163
1146
|
className: "flex flex-col gap-4 p-6 overflow-y-auto",
|
|
1164
1147
|
children: [
|
|
1165
|
-
/* @__PURE__ */
|
|
1166
|
-
/* @__PURE__ */
|
|
1167
|
-
/* @__PURE__ */
|
|
1148
|
+
/* @__PURE__ */ m("div", { className: "flex items-center justify-between", children: [
|
|
1149
|
+
/* @__PURE__ */ t("h2", { className: "text-sm font-medium text-neutral-800", children: "Integrate shader" }),
|
|
1150
|
+
/* @__PURE__ */ t("button", { className: "button-base", onClick: () => s(!1), children: "Close" })
|
|
1168
1151
|
] }),
|
|
1169
|
-
/* @__PURE__ */
|
|
1170
|
-
/* @__PURE__ */
|
|
1171
|
-
/* @__PURE__ */
|
|
1172
|
-
/* @__PURE__ */
|
|
1173
|
-
/* @__PURE__ */
|
|
1174
|
-
navigator.clipboard.writeText(
|
|
1175
|
-
}, children:
|
|
1152
|
+
/* @__PURE__ */ m("div", { className: "flex flex-col gap-1", children: [
|
|
1153
|
+
/* @__PURE__ */ t("p", { className: "text-xs text-neutral-500", children: "Install" }),
|
|
1154
|
+
/* @__PURE__ */ m("div", { className: "flex items-center gap-2 bg-neutral-50 rounded py-4 px-4", children: [
|
|
1155
|
+
/* @__PURE__ */ t("code", { className: "text-xs text-neutral-700 w-full select-all", children: Te }),
|
|
1156
|
+
/* @__PURE__ */ t("button", { className: "button-base", onClick: () => {
|
|
1157
|
+
navigator.clipboard.writeText(Te), l("done"), setTimeout(() => l("idle"), 1800);
|
|
1158
|
+
}, children: a === "done" ? "Copied!" : "Copy" })
|
|
1176
1159
|
] })
|
|
1177
1160
|
] }),
|
|
1178
|
-
/* @__PURE__ */
|
|
1179
|
-
/* @__PURE__ */
|
|
1180
|
-
/* @__PURE__ */
|
|
1181
|
-
/* @__PURE__ */
|
|
1161
|
+
/* @__PURE__ */ m("div", { className: "flex flex-col gap-1 flex-1 min-h-0", children: [
|
|
1162
|
+
/* @__PURE__ */ t("p", { className: "text-xs text-neutral-500", children: "Component" }),
|
|
1163
|
+
/* @__PURE__ */ m("div", { className: "relative flex-1 min-h-0 bg-neutral-50 rounded", children: [
|
|
1164
|
+
/* @__PURE__ */ t(
|
|
1182
1165
|
"button",
|
|
1183
1166
|
{
|
|
1184
1167
|
className: "absolute top-4 right-4 button-base",
|
|
1185
1168
|
onClick: () => {
|
|
1186
|
-
navigator.clipboard.writeText(
|
|
1169
|
+
navigator.clipboard.writeText(e), i("done"), setTimeout(() => i("idle"), 1800);
|
|
1187
1170
|
},
|
|
1188
1171
|
children: u === "done" ? "Copied!" : "Copy"
|
|
1189
1172
|
}
|
|
1190
1173
|
),
|
|
1191
|
-
/* @__PURE__ */
|
|
1174
|
+
/* @__PURE__ */ t(
|
|
1192
1175
|
"textarea",
|
|
1193
1176
|
{
|
|
1194
1177
|
readOnly: !0,
|
|
1195
|
-
value:
|
|
1178
|
+
value: e,
|
|
1196
1179
|
className: "w-full h-full resize-none bg-transparent text-xs text-neutral-700 font-mono p-4 pr-12 outline-none"
|
|
1197
1180
|
}
|
|
1198
1181
|
)
|
|
@@ -1201,149 +1184,150 @@ const Ae = ({
|
|
|
1201
1184
|
]
|
|
1202
1185
|
}
|
|
1203
1186
|
);
|
|
1204
|
-
},
|
|
1205
|
-
open:
|
|
1187
|
+
}, Dn = ({
|
|
1188
|
+
open: n,
|
|
1206
1189
|
onOpenChange: o,
|
|
1207
1190
|
shader: r,
|
|
1208
|
-
patch:
|
|
1209
|
-
uniforms:
|
|
1191
|
+
patch: s,
|
|
1192
|
+
uniforms: e,
|
|
1193
|
+
savedUniforms: a,
|
|
1210
1194
|
nodeId: l,
|
|
1211
|
-
|
|
1212
|
-
handleUpdateNode:
|
|
1195
|
+
handleFieldUpdate: u,
|
|
1196
|
+
handleUpdateNode: i
|
|
1213
1197
|
}) => {
|
|
1214
|
-
const
|
|
1215
|
-
const
|
|
1216
|
-
for (const
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1198
|
+
const c = $(null), h = $(null), [f, p] = y(!1), [x, w] = y(null), E = (S, I) => {
|
|
1199
|
+
const H = S.split(/\n(?=\d+: )/), X = {};
|
|
1200
|
+
for (const z of H) {
|
|
1201
|
+
const G = z.match(/^(\d+): ([\s\S]*)/);
|
|
1202
|
+
G && (X[parseInt(G[1], 10)] = G[2].trimEnd());
|
|
1219
1203
|
}
|
|
1220
|
-
const
|
|
1221
|
-
for (let
|
|
1222
|
-
|
|
1223
|
-
return
|
|
1204
|
+
const K = Math.max(1, I - 3), N = I + 3, D = [];
|
|
1205
|
+
for (let z = K; z <= N; z++)
|
|
1206
|
+
X[z] !== void 0 && D.push(`${z}: ${X[z]}`);
|
|
1207
|
+
return D.join(`
|
|
1224
1208
|
`);
|
|
1225
|
-
}, [
|
|
1226
|
-
|
|
1227
|
-
const
|
|
1228
|
-
if (!
|
|
1229
|
-
const
|
|
1230
|
-
const { width:
|
|
1231
|
-
|
|
1209
|
+
}, [T, v] = y({ w: 1, h: 1 }), { width: C, height: A } = r.resolution;
|
|
1210
|
+
k(() => {
|
|
1211
|
+
const S = h.current;
|
|
1212
|
+
if (!S) return;
|
|
1213
|
+
const I = new ResizeObserver(([H]) => {
|
|
1214
|
+
const { width: X, height: K } = H.contentRect;
|
|
1215
|
+
v({ w: X, h: K });
|
|
1232
1216
|
});
|
|
1233
|
-
return
|
|
1217
|
+
return I.observe(S), () => I.disconnect();
|
|
1234
1218
|
}, []);
|
|
1235
1219
|
const U = () => {
|
|
1236
|
-
|
|
1237
|
-
|
|
1220
|
+
c.current?.toBlob((S) => {
|
|
1221
|
+
S && navigator.clipboard.write([new ClipboardItem({ "image/png": S })]);
|
|
1238
1222
|
});
|
|
1239
|
-
},
|
|
1240
|
-
const
|
|
1241
|
-
if (!
|
|
1242
|
-
const
|
|
1243
|
-
|
|
1223
|
+
}, _ = () => {
|
|
1224
|
+
const S = c.current?.toDataURL("image/png");
|
|
1225
|
+
if (!S) return;
|
|
1226
|
+
const I = document.createElement("a");
|
|
1227
|
+
I.href = S, I.download = `${r.name}.png`, I.click();
|
|
1244
1228
|
};
|
|
1245
|
-
return /* @__PURE__ */
|
|
1246
|
-
|
|
1229
|
+
return /* @__PURE__ */ m(
|
|
1230
|
+
de,
|
|
1247
1231
|
{
|
|
1248
|
-
open:
|
|
1232
|
+
open: n,
|
|
1249
1233
|
handleOpenChange: o,
|
|
1250
1234
|
className: "flex flex-col w-full h-full",
|
|
1251
1235
|
children: [
|
|
1252
|
-
/* @__PURE__ */
|
|
1253
|
-
/* @__PURE__ */
|
|
1254
|
-
/* @__PURE__ */
|
|
1236
|
+
/* @__PURE__ */ m("div", { className: "flex items-center justify-between px-6 py-4 shrink-0", children: [
|
|
1237
|
+
/* @__PURE__ */ t("h2", { className: "text-sm font-medium text-neutral-800", children: r.name }),
|
|
1238
|
+
/* @__PURE__ */ t("button", { className: "button-base", onClick: () => o(!1), children: "Close" })
|
|
1255
1239
|
] }),
|
|
1256
|
-
/* @__PURE__ */
|
|
1257
|
-
/* @__PURE__ */
|
|
1258
|
-
|
|
1240
|
+
/* @__PURE__ */ m("div", { className: "flex gap-16 px-6 pb-6 flex-1 min-h-0 items-center", children: [
|
|
1241
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col gap-8", children: /* @__PURE__ */ t("div", { className: "flex flex-col gap-2", children: /* @__PURE__ */ t(
|
|
1242
|
+
Me,
|
|
1259
1243
|
{
|
|
1260
1244
|
shader: r,
|
|
1261
|
-
|
|
1262
|
-
handleUpdateUniform:
|
|
1245
|
+
savedUniforms: a,
|
|
1246
|
+
handleUpdateUniform: u
|
|
1263
1247
|
}
|
|
1264
1248
|
) }) }),
|
|
1265
|
-
/* @__PURE__ */
|
|
1266
|
-
/* @__PURE__ */
|
|
1249
|
+
/* @__PURE__ */ m("div", { className: "h-full w-full flex flex-col gap-4 ", children: [
|
|
1250
|
+
/* @__PURE__ */ t(
|
|
1267
1251
|
"div",
|
|
1268
1252
|
{
|
|
1269
|
-
ref:
|
|
1253
|
+
ref: h,
|
|
1270
1254
|
className: "flex bg-neutral-50 rounded w-4/5 items-center justify-center h-full",
|
|
1271
|
-
children: /* @__PURE__ */
|
|
1255
|
+
children: /* @__PURE__ */ t(
|
|
1272
1256
|
Re,
|
|
1273
1257
|
{
|
|
1274
|
-
ref:
|
|
1258
|
+
ref: c,
|
|
1275
1259
|
animate: !0,
|
|
1276
|
-
width:
|
|
1277
|
-
height:
|
|
1278
|
-
patch:
|
|
1279
|
-
uniforms:
|
|
1280
|
-
className:
|
|
1281
|
-
onError: (
|
|
1260
|
+
width: C,
|
|
1261
|
+
height: A,
|
|
1262
|
+
patch: s,
|
|
1263
|
+
uniforms: e,
|
|
1264
|
+
className: C / A > T.w / T.h ? "w-full" : "h-full",
|
|
1265
|
+
onError: (S) => w(S)
|
|
1282
1266
|
}
|
|
1283
1267
|
)
|
|
1284
1268
|
}
|
|
1285
1269
|
),
|
|
1286
|
-
/* @__PURE__ */
|
|
1287
|
-
/* @__PURE__ */
|
|
1288
|
-
/* @__PURE__ */
|
|
1289
|
-
|
|
1270
|
+
/* @__PURE__ */ m("div", { className: "flex flex-col gap-2 ", children: [
|
|
1271
|
+
/* @__PURE__ */ m("div", { className: "flex gap-1 bg-neutral-100 p-1 rounded-md w-min", children: [
|
|
1272
|
+
/* @__PURE__ */ t(
|
|
1273
|
+
V,
|
|
1290
1274
|
{
|
|
1291
1275
|
label: "w",
|
|
1292
|
-
value:
|
|
1276
|
+
value: C,
|
|
1293
1277
|
min: 1,
|
|
1294
1278
|
step: 1,
|
|
1295
|
-
onChange: (
|
|
1296
|
-
...
|
|
1297
|
-
shader: { ...
|
|
1279
|
+
onChange: (S) => i(l, (I) => ({
|
|
1280
|
+
...I,
|
|
1281
|
+
shader: { ...I.shader, resolution: { width: S, height: A } }
|
|
1298
1282
|
}))
|
|
1299
1283
|
}
|
|
1300
1284
|
),
|
|
1301
|
-
/* @__PURE__ */
|
|
1302
|
-
|
|
1285
|
+
/* @__PURE__ */ t(
|
|
1286
|
+
V,
|
|
1303
1287
|
{
|
|
1304
1288
|
label: "h",
|
|
1305
|
-
value:
|
|
1289
|
+
value: A,
|
|
1306
1290
|
min: 1,
|
|
1307
1291
|
step: 1,
|
|
1308
|
-
onChange: (
|
|
1309
|
-
...
|
|
1310
|
-
shader: { ...
|
|
1292
|
+
onChange: (S) => i(l, (I) => ({
|
|
1293
|
+
...I,
|
|
1294
|
+
shader: { ...I.shader, resolution: { width: C, height: S } }
|
|
1311
1295
|
}))
|
|
1312
1296
|
}
|
|
1313
1297
|
)
|
|
1314
1298
|
] }),
|
|
1315
|
-
/* @__PURE__ */
|
|
1316
|
-
/* @__PURE__ */
|
|
1299
|
+
/* @__PURE__ */ m("div", { className: "flex gap-1 h-min w-min", children: [
|
|
1300
|
+
/* @__PURE__ */ t(
|
|
1317
1301
|
"button",
|
|
1318
1302
|
{
|
|
1319
1303
|
className: "button-base",
|
|
1320
|
-
onClick: () =>
|
|
1304
|
+
onClick: () => p(!0),
|
|
1321
1305
|
children: "Export"
|
|
1322
1306
|
}
|
|
1323
1307
|
),
|
|
1324
|
-
/* @__PURE__ */
|
|
1325
|
-
|
|
1308
|
+
/* @__PURE__ */ t(
|
|
1309
|
+
$e,
|
|
1326
1310
|
{
|
|
1327
|
-
uniforms:
|
|
1328
|
-
patch:
|
|
1329
|
-
open:
|
|
1330
|
-
onOpenChange:
|
|
1311
|
+
uniforms: e.current,
|
|
1312
|
+
patch: s,
|
|
1313
|
+
open: f,
|
|
1314
|
+
onOpenChange: p
|
|
1331
1315
|
}
|
|
1332
1316
|
),
|
|
1333
|
-
/* @__PURE__ */
|
|
1334
|
-
/* @__PURE__ */
|
|
1317
|
+
/* @__PURE__ */ t("button", { className: "button-base", onClick: U, children: "Copy" }),
|
|
1318
|
+
/* @__PURE__ */ t("button", { className: "button-base", onClick: _, children: "Save" })
|
|
1335
1319
|
] })
|
|
1336
1320
|
] })
|
|
1337
1321
|
] })
|
|
1338
1322
|
] }),
|
|
1339
|
-
|
|
1340
|
-
/* @__PURE__ */
|
|
1341
|
-
/* @__PURE__ */
|
|
1342
|
-
/* @__PURE__ */
|
|
1323
|
+
x && /* @__PURE__ */ m("div", { className: "flex flex-col gap-2 mx-6 mb-6 p-2 bg-white border-2 border-red-100 rounded-md", children: [
|
|
1324
|
+
/* @__PURE__ */ t("p", { className: "text-white w-min text-nowrap bg-red-700 px-2 py-1 rounded text-xs", children: x.shaderName }),
|
|
1325
|
+
/* @__PURE__ */ t("pre", { className: "text-xs text-red-600 font-mono whitespace-pre-wrap break-all", children: E(x.message, x.line) }),
|
|
1326
|
+
/* @__PURE__ */ t(
|
|
1343
1327
|
"button",
|
|
1344
1328
|
{
|
|
1345
1329
|
className: "self-start text-xs px-2 py-1 rounded border border-red-200 bg-white text-red-600 hover:bg-red-50 cursor-pointer",
|
|
1346
|
-
onClick: () => navigator.clipboard.writeText(
|
|
1330
|
+
onClick: () => navigator.clipboard.writeText(x.message),
|
|
1347
1331
|
children: "Copy error"
|
|
1348
1332
|
}
|
|
1349
1333
|
)
|
|
@@ -1351,40 +1335,45 @@ const Ae = ({
|
|
|
1351
1335
|
]
|
|
1352
1336
|
}
|
|
1353
1337
|
);
|
|
1354
|
-
}, Rn = ({ data:
|
|
1338
|
+
}, Rn = ({ data: n, selected: o, id: r }) => {
|
|
1355
1339
|
const {
|
|
1356
|
-
patches:
|
|
1357
|
-
uniforms:
|
|
1358
|
-
handleUpdateUniforms:
|
|
1359
|
-
handleUpdateNode:
|
|
1340
|
+
patches: s,
|
|
1341
|
+
uniforms: e,
|
|
1342
|
+
handleUpdateUniforms: a,
|
|
1343
|
+
handleUpdateNode: l,
|
|
1360
1344
|
showStats: u,
|
|
1361
1345
|
setOpenExportNodeId: i,
|
|
1362
|
-
openPreviewNodeId:
|
|
1346
|
+
openPreviewNodeId: c,
|
|
1363
1347
|
setOpenPreviewNodeId: h
|
|
1364
|
-
} =
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
},
|
|
1376
|
-
const
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1348
|
+
} = ue(ae), [f, p] = y(
|
|
1349
|
+
() => e.current[n.shader.id] ?? {}
|
|
1350
|
+
), x = (N, D) => {
|
|
1351
|
+
a(n.shader.id, (z) => ({
|
|
1352
|
+
...z,
|
|
1353
|
+
[N]: D
|
|
1354
|
+
}));
|
|
1355
|
+
}, { width: w, height: E } = n.shader.resolution, [T, v] = y(null), C = $(null), [A, U] = y("idle"), [_, S] = y("idle"), I = () => {
|
|
1356
|
+
C.current?.toBlob((N) => {
|
|
1357
|
+
N && navigator.clipboard.write([new ClipboardItem({ "image/png": N })]);
|
|
1358
|
+
}), U("done"), setTimeout(() => U("idle"), 1800);
|
|
1359
|
+
}, H = () => {
|
|
1360
|
+
const N = C.current?.toDataURL("image/png");
|
|
1361
|
+
if (!N) return;
|
|
1362
|
+
const D = document.createElement("a");
|
|
1363
|
+
D.href = N, D.download = `${n.shader.name}.png`, D.click();
|
|
1364
|
+
}, X = re(() => ce(n.shader).filter((N) => N.type === "sampler2D" && N.source === "input").map((N) => N.name), [n.shader]), K = (N, D) => {
|
|
1365
|
+
const z = N.split(/\n(?=\d+: )/), G = {};
|
|
1366
|
+
for (const W of z) {
|
|
1367
|
+
const Z = W.match(/^(\d+): ([\s\S]*)/);
|
|
1368
|
+
Z && (G[parseInt(Z[1], 10)] = Z[2].trimEnd());
|
|
1380
1369
|
}
|
|
1381
|
-
const
|
|
1382
|
-
for (let
|
|
1383
|
-
G[
|
|
1384
|
-
return
|
|
1370
|
+
const te = Math.max(1, D - 3), fe = D + 3, le = [];
|
|
1371
|
+
for (let W = te; W <= fe; W++)
|
|
1372
|
+
G[W] !== void 0 && le.push(`${W}: ${G[W]}`);
|
|
1373
|
+
return le.join(`
|
|
1385
1374
|
`);
|
|
1386
1375
|
};
|
|
1387
|
-
return /* @__PURE__ */
|
|
1376
|
+
return !s || s[n.shader.id] === void 0 ? null : /* @__PURE__ */ m(
|
|
1388
1377
|
"div",
|
|
1389
1378
|
{
|
|
1390
1379
|
className: `
|
|
@@ -1392,120 +1381,125 @@ const Ae = ({
|
|
|
1392
1381
|
${o ? "outline-4" : "outline-0"}
|
|
1393
1382
|
`,
|
|
1394
1383
|
children: [
|
|
1395
|
-
/* @__PURE__ */
|
|
1396
|
-
u && /* @__PURE__ */
|
|
1397
|
-
/* @__PURE__ */
|
|
1384
|
+
/* @__PURE__ */ t("p", { className: "text-sm w-min py-1 px-2 bg-neutral-100 rounded-lg text-neutral-500 text-nowrap", children: n.shader.name }),
|
|
1385
|
+
u && /* @__PURE__ */ m(se, { children: [
|
|
1386
|
+
/* @__PURE__ */ m("p", { className: "text-xs text-neutral-500 absolute -top-6", children: [
|
|
1398
1387
|
"ID: ",
|
|
1399
|
-
|
|
1388
|
+
n.shader.id
|
|
1400
1389
|
] }),
|
|
1401
|
-
/* @__PURE__ */
|
|
1390
|
+
/* @__PURE__ */ t("p", { className: "text-xs text-neutral-500 absolute -top-10", children: n.shader.name })
|
|
1402
1391
|
] }),
|
|
1403
|
-
|
|
1404
|
-
|
|
1392
|
+
X.map((N, D) => /* @__PURE__ */ t(
|
|
1393
|
+
Ue,
|
|
1405
1394
|
{
|
|
1406
|
-
id:
|
|
1395
|
+
id: N,
|
|
1407
1396
|
type: "target",
|
|
1408
|
-
position:
|
|
1397
|
+
position: ne.Top,
|
|
1398
|
+
count: {
|
|
1399
|
+
total: X.length,
|
|
1400
|
+
index: D
|
|
1401
|
+
}
|
|
1409
1402
|
},
|
|
1410
|
-
|
|
1403
|
+
N
|
|
1411
1404
|
)),
|
|
1412
|
-
/* @__PURE__ */
|
|
1413
|
-
/* @__PURE__ */
|
|
1414
|
-
|
|
1405
|
+
/* @__PURE__ */ m("div", { className: "flex gap-8", children: [
|
|
1406
|
+
/* @__PURE__ */ t(
|
|
1407
|
+
Me,
|
|
1415
1408
|
{
|
|
1416
|
-
shader:
|
|
1417
|
-
|
|
1418
|
-
handleUpdateUniform:
|
|
1419
|
-
l(e.shader.id, _);
|
|
1420
|
-
}
|
|
1409
|
+
shader: n.shader,
|
|
1410
|
+
savedUniforms: f,
|
|
1411
|
+
handleUpdateUniform: x
|
|
1421
1412
|
}
|
|
1422
|
-
)
|
|
1423
|
-
/* @__PURE__ */
|
|
1424
|
-
/* @__PURE__ */
|
|
1425
|
-
/* @__PURE__ */
|
|
1426
|
-
/* @__PURE__ */
|
|
1427
|
-
/* @__PURE__ */
|
|
1413
|
+
),
|
|
1414
|
+
/* @__PURE__ */ m("div", { className: "flex flex-col justify-center items-start gap-4 ", children: [
|
|
1415
|
+
/* @__PURE__ */ m("div", { className: "flex flex-col gap-2", children: [
|
|
1416
|
+
/* @__PURE__ */ m("div", { className: "relative max-w-96 group", children: [
|
|
1417
|
+
/* @__PURE__ */ m("div", { className: "flex absolute top-2 right-2 gap-2", children: [
|
|
1418
|
+
/* @__PURE__ */ t(
|
|
1428
1419
|
"button",
|
|
1429
1420
|
{
|
|
1430
1421
|
className: "button-base group-hover:opacity-100 opacity-0",
|
|
1431
|
-
onClick: () =>
|
|
1422
|
+
onClick: () => {
|
|
1423
|
+
h(r), p(e.current[n.shader.id] ?? {});
|
|
1424
|
+
},
|
|
1432
1425
|
children: "Expand"
|
|
1433
1426
|
}
|
|
1434
1427
|
),
|
|
1435
|
-
/* @__PURE__ */
|
|
1436
|
-
|
|
1428
|
+
/* @__PURE__ */ t(
|
|
1429
|
+
Dn,
|
|
1437
1430
|
{
|
|
1438
|
-
open:
|
|
1439
|
-
onOpenChange: (
|
|
1440
|
-
h(
|
|
1431
|
+
open: c === r,
|
|
1432
|
+
onOpenChange: (N) => {
|
|
1433
|
+
p(e.current[n.shader.id] ?? {}), h(N ? r : null);
|
|
1441
1434
|
},
|
|
1442
|
-
shader:
|
|
1443
|
-
patch:
|
|
1444
|
-
uniforms:
|
|
1435
|
+
shader: n.shader,
|
|
1436
|
+
patch: s[n.shader.id],
|
|
1437
|
+
uniforms: e,
|
|
1438
|
+
savedUniforms: f,
|
|
1445
1439
|
nodeId: r,
|
|
1446
|
-
|
|
1447
|
-
handleUpdateNode:
|
|
1440
|
+
handleFieldUpdate: x,
|
|
1441
|
+
handleUpdateNode: l
|
|
1448
1442
|
}
|
|
1449
1443
|
),
|
|
1450
|
-
/* @__PURE__ */
|
|
1444
|
+
/* @__PURE__ */ t(
|
|
1451
1445
|
"button",
|
|
1452
1446
|
{
|
|
1453
|
-
className: `button-base ${
|
|
1447
|
+
className: `button-base ${n.paused ? "opacity-100" : "group-hover:opacity-100 opacity-0"}`,
|
|
1454
1448
|
onClick: () => {
|
|
1455
|
-
|
|
1449
|
+
l(r, (N) => ({ ...N, paused: !N.paused }));
|
|
1456
1450
|
},
|
|
1457
|
-
children:
|
|
1451
|
+
children: n.paused ? "Resume" : "Pause"
|
|
1458
1452
|
}
|
|
1459
1453
|
)
|
|
1460
1454
|
] }),
|
|
1461
|
-
/* @__PURE__ */
|
|
1455
|
+
/* @__PURE__ */ t(
|
|
1462
1456
|
Re,
|
|
1463
1457
|
{
|
|
1464
|
-
ref:
|
|
1465
|
-
animate: !
|
|
1466
|
-
width:
|
|
1467
|
-
height:
|
|
1468
|
-
patch:
|
|
1469
|
-
uniforms:
|
|
1458
|
+
ref: C,
|
|
1459
|
+
animate: !n.paused,
|
|
1460
|
+
width: w,
|
|
1461
|
+
height: E,
|
|
1462
|
+
patch: s[n.shader.id],
|
|
1463
|
+
uniforms: e,
|
|
1470
1464
|
className: "w-full h-auto",
|
|
1471
|
-
style: { maxWidth: `${
|
|
1472
|
-
onError: (
|
|
1473
|
-
|
|
1465
|
+
style: { maxWidth: `${w / E * 24}rem` },
|
|
1466
|
+
onError: (N) => {
|
|
1467
|
+
v(N);
|
|
1474
1468
|
}
|
|
1475
1469
|
}
|
|
1476
1470
|
)
|
|
1477
1471
|
] }),
|
|
1478
|
-
/* @__PURE__ */
|
|
1479
|
-
/* @__PURE__ */
|
|
1480
|
-
|
|
1472
|
+
/* @__PURE__ */ m("div", { className: "flex gap-1 bg-neutral-100 rounded-md p-1 w-min", children: [
|
|
1473
|
+
/* @__PURE__ */ t(
|
|
1474
|
+
V,
|
|
1481
1475
|
{
|
|
1482
1476
|
label: "w",
|
|
1483
|
-
value:
|
|
1477
|
+
value: w,
|
|
1484
1478
|
min: 1,
|
|
1485
1479
|
step: 1,
|
|
1486
|
-
onChange: (
|
|
1487
|
-
...
|
|
1488
|
-
shader: { ...
|
|
1480
|
+
onChange: (N) => l(r, (D) => ({
|
|
1481
|
+
...D,
|
|
1482
|
+
shader: { ...D.shader, resolution: { width: N, height: E } }
|
|
1489
1483
|
}))
|
|
1490
1484
|
}
|
|
1491
1485
|
),
|
|
1492
|
-
/* @__PURE__ */
|
|
1493
|
-
|
|
1486
|
+
/* @__PURE__ */ t(
|
|
1487
|
+
V,
|
|
1494
1488
|
{
|
|
1495
1489
|
label: "h",
|
|
1496
|
-
value:
|
|
1490
|
+
value: E,
|
|
1497
1491
|
min: 1,
|
|
1498
1492
|
step: 1,
|
|
1499
|
-
onChange: (
|
|
1500
|
-
...
|
|
1501
|
-
shader: { ...
|
|
1493
|
+
onChange: (N) => l(r, (D) => ({
|
|
1494
|
+
...D,
|
|
1495
|
+
shader: { ...D.shader, resolution: { width: w, height: N } }
|
|
1502
1496
|
}))
|
|
1503
1497
|
}
|
|
1504
1498
|
)
|
|
1505
1499
|
] })
|
|
1506
1500
|
] }),
|
|
1507
|
-
/* @__PURE__ */
|
|
1508
|
-
/* @__PURE__ */
|
|
1501
|
+
/* @__PURE__ */ m("div", { className: "flex gap-1", children: [
|
|
1502
|
+
/* @__PURE__ */ t(
|
|
1509
1503
|
"button",
|
|
1510
1504
|
{
|
|
1511
1505
|
className: "button-base",
|
|
@@ -1513,96 +1507,96 @@ const Ae = ({
|
|
|
1513
1507
|
children: "Export"
|
|
1514
1508
|
}
|
|
1515
1509
|
),
|
|
1516
|
-
/* @__PURE__ */
|
|
1517
|
-
/* @__PURE__ */
|
|
1510
|
+
/* @__PURE__ */ t("button", { className: "button-base", onClick: I, children: A === "done" ? "Copied!" : "Copy" }),
|
|
1511
|
+
/* @__PURE__ */ t("button", { className: "button-base", onClick: H, children: "Save" })
|
|
1518
1512
|
] })
|
|
1519
1513
|
] })
|
|
1520
1514
|
] }),
|
|
1521
|
-
|
|
1522
|
-
/* @__PURE__ */
|
|
1523
|
-
/* @__PURE__ */
|
|
1524
|
-
/* @__PURE__ */
|
|
1515
|
+
T && /* @__PURE__ */ m("div", { className: "flex flex-col gap-2 p-2 bg-white border-2 border-red-100 rounded-md relative", children: [
|
|
1516
|
+
/* @__PURE__ */ t("p", { className: "text-white w-min text-nowrap bg-red-700 px-2 py-1 rounded text-xs", children: T.shaderName }),
|
|
1517
|
+
/* @__PURE__ */ t("pre", { className: "text-xs text-red-600 font-mono whitespace-pre-wrap break-all", children: K(T.message, T.line) }),
|
|
1518
|
+
/* @__PURE__ */ t(
|
|
1525
1519
|
"button",
|
|
1526
1520
|
{
|
|
1527
1521
|
className: "self-start text-xs px-2 py-1 rounded border border-red-200 bg-white text-red-600 hover:bg-red-50 cursor-pointer",
|
|
1528
1522
|
onClick: () => {
|
|
1529
|
-
navigator.clipboard.writeText(
|
|
1523
|
+
navigator.clipboard.writeText(T.message), S("done"), setTimeout(() => S("idle"), 1800);
|
|
1530
1524
|
},
|
|
1531
|
-
children:
|
|
1525
|
+
children: _ === "done" ? "Copied!" : "Copy error"
|
|
1532
1526
|
}
|
|
1533
1527
|
)
|
|
1534
1528
|
] }),
|
|
1535
|
-
/* @__PURE__ */
|
|
1529
|
+
/* @__PURE__ */ t(Ue, { id: "out", type: "source", position: ne.Bottom })
|
|
1536
1530
|
]
|
|
1537
1531
|
}
|
|
1538
1532
|
);
|
|
1539
1533
|
};
|
|
1540
|
-
function
|
|
1541
|
-
sourceX:
|
|
1534
|
+
function Fn({
|
|
1535
|
+
sourceX: n,
|
|
1542
1536
|
sourceY: o,
|
|
1543
1537
|
targetX: r,
|
|
1544
|
-
targetY:
|
|
1545
|
-
sourcePosition:
|
|
1546
|
-
targetPosition:
|
|
1547
|
-
style:
|
|
1538
|
+
targetY: s,
|
|
1539
|
+
sourcePosition: e,
|
|
1540
|
+
targetPosition: a,
|
|
1541
|
+
style: l = {},
|
|
1548
1542
|
markerEnd: u,
|
|
1549
1543
|
id: i
|
|
1550
1544
|
}) {
|
|
1551
|
-
const [
|
|
1552
|
-
sourceX:
|
|
1545
|
+
const [c, h, f] = ke({
|
|
1546
|
+
sourceX: n,
|
|
1553
1547
|
sourceY: o,
|
|
1554
|
-
sourcePosition:
|
|
1548
|
+
sourcePosition: e,
|
|
1555
1549
|
targetX: r,
|
|
1556
|
-
targetY:
|
|
1557
|
-
targetPosition:
|
|
1558
|
-
}), { shaders:
|
|
1559
|
-
console.log("d"),
|
|
1550
|
+
targetY: s,
|
|
1551
|
+
targetPosition: a
|
|
1552
|
+
}), { shaders: p, handleInsertShader: x } = ue(ae), [w, E] = y(!1), T = () => {
|
|
1553
|
+
console.log("d"), E(!0);
|
|
1560
1554
|
};
|
|
1561
|
-
return /* @__PURE__ */
|
|
1562
|
-
/* @__PURE__ */
|
|
1563
|
-
/* @__PURE__ */
|
|
1555
|
+
return /* @__PURE__ */ m(se, { children: [
|
|
1556
|
+
/* @__PURE__ */ t(nn, { path: c, markerEnd: u, style: l }),
|
|
1557
|
+
/* @__PURE__ */ t(tn, { children: /* @__PURE__ */ m(
|
|
1564
1558
|
"div",
|
|
1565
1559
|
{
|
|
1566
1560
|
className: "absolute -translate-1/2 origin-center pointer-events-auto",
|
|
1567
1561
|
style: {
|
|
1568
|
-
transform: `translate(${h}px,${
|
|
1562
|
+
transform: `translate(${h}px,${f}px)`
|
|
1569
1563
|
},
|
|
1570
1564
|
children: [
|
|
1571
|
-
/* @__PURE__ */
|
|
1565
|
+
/* @__PURE__ */ t(
|
|
1572
1566
|
"button",
|
|
1573
1567
|
{
|
|
1574
1568
|
className: "w-6 h-6 bg-neutral-200 rounded-full active:bg-neutral-200 z-10 flex items-center justify-center",
|
|
1575
|
-
onClick: () =>
|
|
1569
|
+
onClick: () => T(),
|
|
1576
1570
|
children: "+"
|
|
1577
1571
|
}
|
|
1578
1572
|
),
|
|
1579
|
-
/* @__PURE__ */
|
|
1580
|
-
|
|
1573
|
+
/* @__PURE__ */ t(
|
|
1574
|
+
de,
|
|
1581
1575
|
{
|
|
1582
|
-
open:
|
|
1576
|
+
open: w,
|
|
1583
1577
|
handleOpenChange: (v) => {
|
|
1584
|
-
|
|
1578
|
+
E(v);
|
|
1585
1579
|
},
|
|
1586
|
-
children: /* @__PURE__ */
|
|
1587
|
-
/* @__PURE__ */
|
|
1588
|
-
/* @__PURE__ */
|
|
1589
|
-
/* @__PURE__ */
|
|
1580
|
+
children: /* @__PURE__ */ m("div", { className: "w-full h-full flex flex-col p-4", children: [
|
|
1581
|
+
/* @__PURE__ */ m("div", { className: "w-full flex justify-between", children: [
|
|
1582
|
+
/* @__PURE__ */ t("p", { children: "Add a Shader" }),
|
|
1583
|
+
/* @__PURE__ */ t(
|
|
1590
1584
|
"button",
|
|
1591
1585
|
{
|
|
1592
1586
|
className: "button-base",
|
|
1593
1587
|
onClick: () => {
|
|
1594
|
-
|
|
1588
|
+
E(!1);
|
|
1595
1589
|
},
|
|
1596
1590
|
children: "Close"
|
|
1597
1591
|
}
|
|
1598
1592
|
)
|
|
1599
1593
|
] }),
|
|
1600
|
-
/* @__PURE__ */
|
|
1594
|
+
/* @__PURE__ */ t("div", { className: "w-full flex flex-col", children: p.map((v) => /* @__PURE__ */ t(
|
|
1601
1595
|
"button",
|
|
1602
1596
|
{
|
|
1603
1597
|
className: "text-xs flex justify-start p-1 rounded-sm hover:bg-neutral-100 cursor-pointer text-neutral-500",
|
|
1604
1598
|
onClick: () => {
|
|
1605
|
-
|
|
1599
|
+
x(v, i);
|
|
1606
1600
|
},
|
|
1607
1601
|
children: v.id
|
|
1608
1602
|
},
|
|
@@ -1616,340 +1610,366 @@ function Un({
|
|
|
1616
1610
|
) })
|
|
1617
1611
|
] });
|
|
1618
1612
|
}
|
|
1619
|
-
function
|
|
1620
|
-
fromX:
|
|
1613
|
+
function Pn({
|
|
1614
|
+
fromX: n,
|
|
1621
1615
|
fromY: o,
|
|
1622
1616
|
toX: r,
|
|
1623
|
-
toY:
|
|
1624
|
-
fromPosition:
|
|
1625
|
-
toPosition:
|
|
1626
|
-
toHandle:
|
|
1617
|
+
toY: s,
|
|
1618
|
+
fromPosition: e,
|
|
1619
|
+
toPosition: a,
|
|
1620
|
+
toHandle: l
|
|
1627
1621
|
}) {
|
|
1628
|
-
const [u] =
|
|
1629
|
-
sourceX:
|
|
1622
|
+
const [u] = ke({
|
|
1623
|
+
sourceX: n,
|
|
1630
1624
|
sourceY: o,
|
|
1631
|
-
sourcePosition:
|
|
1625
|
+
sourcePosition: e,
|
|
1632
1626
|
targetX: r,
|
|
1633
|
-
targetY:
|
|
1634
|
-
targetPosition:
|
|
1635
|
-
}), i =
|
|
1636
|
-
return /* @__PURE__ */
|
|
1637
|
-
/* @__PURE__ */
|
|
1638
|
-
/* @__PURE__ */
|
|
1627
|
+
targetY: s,
|
|
1628
|
+
targetPosition: a
|
|
1629
|
+
}), i = l ? "connect" : "new", c = s - 26, h = 6, f = 16, p = i.length * 6 + h * 2;
|
|
1630
|
+
return /* @__PURE__ */ m("g", { children: [
|
|
1631
|
+
/* @__PURE__ */ t("path", { fill: "none", stroke: "#b1b1b7", strokeWidth: 1.5, d: u }),
|
|
1632
|
+
/* @__PURE__ */ t(
|
|
1639
1633
|
"rect",
|
|
1640
1634
|
{
|
|
1641
|
-
x: r -
|
|
1642
|
-
y:
|
|
1643
|
-
width:
|
|
1644
|
-
height:
|
|
1635
|
+
x: r - p / 2,
|
|
1636
|
+
y: c - f / 2,
|
|
1637
|
+
width: p,
|
|
1638
|
+
height: f,
|
|
1645
1639
|
rx: 4,
|
|
1646
|
-
fill:
|
|
1640
|
+
fill: l ? "#404040" : "#e5e5e5",
|
|
1647
1641
|
style: { pointerEvents: "none" }
|
|
1648
1642
|
}
|
|
1649
1643
|
),
|
|
1650
|
-
/* @__PURE__ */
|
|
1644
|
+
/* @__PURE__ */ t(
|
|
1651
1645
|
"text",
|
|
1652
1646
|
{
|
|
1653
1647
|
x: r,
|
|
1654
|
-
y:
|
|
1648
|
+
y: c,
|
|
1655
1649
|
textAnchor: "middle",
|
|
1656
1650
|
dominantBaseline: "central",
|
|
1657
1651
|
fontSize: 10,
|
|
1658
1652
|
fontFamily: "monospace",
|
|
1659
|
-
fill:
|
|
1653
|
+
fill: l ? "#ffffff" : "#525252",
|
|
1660
1654
|
style: { userSelect: "none", pointerEvents: "none" },
|
|
1661
1655
|
children: i
|
|
1662
1656
|
}
|
|
1663
1657
|
),
|
|
1664
|
-
/* @__PURE__ */
|
|
1658
|
+
/* @__PURE__ */ t("foreignObject", { x: r - 8, y: s - 8, width: 16, height: 16, style: { overflow: "visible" }, children: /* @__PURE__ */ t("div", { className: "w-4 h-4 rounded-full bg-neutral-400" }) })
|
|
1665
1659
|
] });
|
|
1666
1660
|
}
|
|
1667
|
-
function
|
|
1668
|
-
const
|
|
1669
|
-
for (;
|
|
1670
|
-
const
|
|
1671
|
-
if (!
|
|
1672
|
-
const u =
|
|
1673
|
-
|
|
1674
|
-
[...
|
|
1661
|
+
function _e(n, o, r) {
|
|
1662
|
+
const s = new Map(n.map((a) => [a.id, a])), e = [r];
|
|
1663
|
+
for (; e.length > 0; ) {
|
|
1664
|
+
const a = e.shift(), l = s.get(a);
|
|
1665
|
+
if (!l || l.type !== "shader") continue;
|
|
1666
|
+
const u = l, { width: i, height: c } = u.data.shader.resolution, h = Ie(
|
|
1667
|
+
l,
|
|
1668
|
+
[...s.values()],
|
|
1675
1669
|
o
|
|
1676
1670
|
);
|
|
1677
|
-
for (const
|
|
1678
|
-
const
|
|
1679
|
-
...
|
|
1671
|
+
for (const f of h) {
|
|
1672
|
+
const p = {
|
|
1673
|
+
...f,
|
|
1680
1674
|
data: {
|
|
1681
|
-
...
|
|
1675
|
+
...f.data,
|
|
1682
1676
|
shader: {
|
|
1683
|
-
...
|
|
1684
|
-
resolution: { width: i, height:
|
|
1677
|
+
...f.data.shader,
|
|
1678
|
+
resolution: { width: i, height: c }
|
|
1685
1679
|
}
|
|
1686
1680
|
}
|
|
1687
1681
|
};
|
|
1688
|
-
|
|
1682
|
+
s.set(f.id, p), e.push(f.id);
|
|
1689
1683
|
}
|
|
1690
1684
|
}
|
|
1691
|
-
return [...
|
|
1685
|
+
return [...s.values()];
|
|
1692
1686
|
}
|
|
1693
|
-
const
|
|
1694
|
-
shaders:
|
|
1687
|
+
const Mn = ({
|
|
1688
|
+
shaders: n,
|
|
1695
1689
|
initialState: o,
|
|
1696
1690
|
handleSave: r,
|
|
1697
|
-
className:
|
|
1698
|
-
initialShowStats:
|
|
1699
|
-
initialShaderPanelOpen:
|
|
1700
|
-
initialOpenPreviewNodeId:
|
|
1691
|
+
className: s,
|
|
1692
|
+
initialShowStats: e,
|
|
1693
|
+
initialShaderPanelOpen: a,
|
|
1694
|
+
initialOpenPreviewNodeId: l,
|
|
1701
1695
|
onEditorStateChange: u,
|
|
1702
1696
|
onOpenPreviewNodeIdChange: i
|
|
1703
1697
|
}) => {
|
|
1704
|
-
const [
|
|
1705
|
-
const d = o?.nodes ?? [],
|
|
1706
|
-
let
|
|
1707
|
-
for (const
|
|
1708
|
-
|
|
1709
|
-
return
|
|
1710
|
-
}),
|
|
1711
|
-
(d) =>
|
|
1712
|
-
[
|
|
1713
|
-
),
|
|
1714
|
-
(d) => h((
|
|
1698
|
+
const [c, h] = y(o?.edges ?? []), [f, p] = y(() => {
|
|
1699
|
+
const d = o?.nodes ?? [], g = o?.edges ?? [], b = new Set(g.map((P) => P.target)), F = d.filter((P) => !b.has(P.id)).map((P) => P.id);
|
|
1700
|
+
let R = d;
|
|
1701
|
+
for (const P of F)
|
|
1702
|
+
R = _e(R, g, P);
|
|
1703
|
+
return R;
|
|
1704
|
+
}), x = Y(
|
|
1705
|
+
(d) => p((g) => rn(d, g)),
|
|
1706
|
+
[p]
|
|
1707
|
+
), w = Y(
|
|
1708
|
+
(d) => h((g) => sn(d, g)),
|
|
1715
1709
|
[h]
|
|
1716
|
-
),
|
|
1710
|
+
), E = Y(
|
|
1717
1711
|
(d) => {
|
|
1718
|
-
const
|
|
1719
|
-
(
|
|
1712
|
+
const g = /* @__PURE__ */ new Set(), b = (F) => g.has(F) ? !1 : F === d.source ? !0 : (g.add(F), Ie({ id: F }, f, c).some(
|
|
1713
|
+
(R) => b(R.id)
|
|
1720
1714
|
));
|
|
1721
|
-
return !
|
|
1715
|
+
return !b(d.target);
|
|
1722
1716
|
},
|
|
1723
|
-
[
|
|
1724
|
-
),
|
|
1717
|
+
[f, c]
|
|
1718
|
+
), T = Y(
|
|
1725
1719
|
(d) => {
|
|
1726
|
-
const
|
|
1727
|
-
|
|
1728
|
-
|
|
1720
|
+
const g = Ne({ ...d, type: "insert" }, c), b = _e(
|
|
1721
|
+
f,
|
|
1722
|
+
g,
|
|
1729
1723
|
d.source
|
|
1730
1724
|
);
|
|
1731
|
-
h(
|
|
1725
|
+
h(g), p(b);
|
|
1732
1726
|
},
|
|
1733
|
-
[
|
|
1734
|
-
), { screenToFlowPosition: v } =
|
|
1735
|
-
(d,
|
|
1736
|
-
if (!
|
|
1737
|
-
const { clientX:
|
|
1738
|
-
|
|
1727
|
+
[c, f]
|
|
1728
|
+
), { screenToFlowPosition: v } = an(), [C, A] = y(null), U = Y(
|
|
1729
|
+
(d, g) => {
|
|
1730
|
+
if (!g.isValid && g.fromNode) {
|
|
1731
|
+
const { clientX: b, clientY: F } = "changedTouches" in d ? d.changedTouches[0] : d;
|
|
1732
|
+
A({
|
|
1739
1733
|
position: v({
|
|
1740
|
-
x:
|
|
1741
|
-
y:
|
|
1734
|
+
x: b,
|
|
1735
|
+
y: F
|
|
1742
1736
|
}),
|
|
1743
|
-
sourceId:
|
|
1737
|
+
sourceId: g.fromNode.id
|
|
1744
1738
|
});
|
|
1745
1739
|
}
|
|
1746
1740
|
},
|
|
1747
1741
|
[v]
|
|
1748
|
-
),
|
|
1742
|
+
), _ = $(
|
|
1749
1743
|
o?.uniforms ?? {}
|
|
1750
1744
|
);
|
|
1751
|
-
|
|
1752
|
-
o?.uniforms && (
|
|
1753
|
-
}, [o])
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1745
|
+
k(() => {
|
|
1746
|
+
o?.uniforms && (_.current = o.uniforms);
|
|
1747
|
+
}, [o]), k(() => {
|
|
1748
|
+
p(
|
|
1749
|
+
(d) => d.map((g) => {
|
|
1750
|
+
if (g.type === "shader") {
|
|
1751
|
+
const b = g;
|
|
1752
|
+
for (const F of n)
|
|
1753
|
+
if (b.data.shader.name === F.name)
|
|
1754
|
+
return {
|
|
1755
|
+
...b,
|
|
1756
|
+
data: {
|
|
1757
|
+
...b.data,
|
|
1758
|
+
shader: {
|
|
1759
|
+
...b.data.shader,
|
|
1760
|
+
source: F.source
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
};
|
|
1764
|
+
return b;
|
|
1765
|
+
}
|
|
1766
|
+
return g;
|
|
1767
|
+
})
|
|
1768
|
+
);
|
|
1769
|
+
}, [n]);
|
|
1770
|
+
const [S, I] = y(null);
|
|
1771
|
+
k(() => {
|
|
1772
|
+
const d = (g) => {
|
|
1773
|
+
(g.metaKey || g.ctrlKey) && g.key === "s" && (g.preventDefault(), r({ nodes: f, edges: c, uniforms: _.current }), I(/* @__PURE__ */ new Date()));
|
|
1758
1774
|
};
|
|
1759
1775
|
return window.addEventListener("keydown", d), () => window.removeEventListener("keydown", d);
|
|
1760
|
-
}, [
|
|
1761
|
-
const
|
|
1762
|
-
const
|
|
1763
|
-
return {
|
|
1764
|
-
id:
|
|
1776
|
+
}, [f, c]);
|
|
1777
|
+
const H = (d) => {
|
|
1778
|
+
const g = `${Math.random() * 1e5}`, b = { ...d, id: g };
|
|
1779
|
+
return _.current[g] = {}, {
|
|
1780
|
+
id: g,
|
|
1765
1781
|
position: { x: 0, y: 0 },
|
|
1766
1782
|
data: {
|
|
1767
|
-
shader:
|
|
1768
|
-
uniforms:
|
|
1783
|
+
shader: b,
|
|
1784
|
+
uniforms: _,
|
|
1769
1785
|
paused: !1
|
|
1770
1786
|
},
|
|
1771
1787
|
type: "shader"
|
|
1772
1788
|
};
|
|
1773
|
-
},
|
|
1774
|
-
|
|
1775
|
-
},
|
|
1776
|
-
const
|
|
1777
|
-
if (!
|
|
1778
|
-
const
|
|
1779
|
-
if (
|
|
1780
|
-
const
|
|
1781
|
-
let
|
|
1782
|
-
for (const
|
|
1783
|
-
if (
|
|
1784
|
-
|
|
1789
|
+
}, X = (d) => {
|
|
1790
|
+
p((g) => [...g, H(d)]);
|
|
1791
|
+
}, K = (d, g) => {
|
|
1792
|
+
const b = c.find((O) => O.id === g);
|
|
1793
|
+
if (!b) return;
|
|
1794
|
+
const F = b.source, R = b.target, P = f.find((O) => O.id === F), B = f.find((O) => O.id === R), j = b.targetHandle;
|
|
1795
|
+
if (P && B && j) {
|
|
1796
|
+
const O = H(d), Ge = ce(O.data.shader);
|
|
1797
|
+
let me;
|
|
1798
|
+
for (const J of Ge)
|
|
1799
|
+
if (J.type === "sampler2D" && J.source === "input") {
|
|
1800
|
+
me = J.name;
|
|
1785
1801
|
break;
|
|
1786
1802
|
}
|
|
1787
|
-
if (
|
|
1788
|
-
const [
|
|
1789
|
-
sourceX:
|
|
1790
|
-
sourceY:
|
|
1791
|
-
sourcePosition:
|
|
1792
|
-
targetX:
|
|
1793
|
-
targetY:
|
|
1794
|
-
targetPosition:
|
|
1803
|
+
if (me === void 0) return;
|
|
1804
|
+
const [tt, We, Ve] = un({
|
|
1805
|
+
sourceX: P.position.x,
|
|
1806
|
+
sourceY: P.position.y,
|
|
1807
|
+
sourcePosition: ne.Bottom,
|
|
1808
|
+
targetX: B.position.x,
|
|
1809
|
+
targetY: B.position.y,
|
|
1810
|
+
targetPosition: ne.Top
|
|
1795
1811
|
});
|
|
1796
|
-
|
|
1797
|
-
const
|
|
1798
|
-
(
|
|
1799
|
-
),
|
|
1812
|
+
O.position.x = We, O.position.y = Ve, p((J) => [...J, O]), h((J) => {
|
|
1813
|
+
const pe = J.filter(
|
|
1814
|
+
(Je) => Je.id !== g
|
|
1815
|
+
), Ye = {
|
|
1800
1816
|
id: "" + Math.random() * 1e4,
|
|
1801
|
-
source:
|
|
1802
|
-
target:
|
|
1803
|
-
targetHandle:
|
|
1817
|
+
source: P.id,
|
|
1818
|
+
target: O.id,
|
|
1819
|
+
targetHandle: me,
|
|
1804
1820
|
type: "insert"
|
|
1805
|
-
},
|
|
1821
|
+
}, Ke = {
|
|
1806
1822
|
id: "" + Math.random() * 1e4,
|
|
1807
|
-
source:
|
|
1808
|
-
target:
|
|
1809
|
-
targetHandle:
|
|
1823
|
+
source: O.id,
|
|
1824
|
+
target: B.id,
|
|
1825
|
+
targetHandle: j,
|
|
1810
1826
|
type: "insert"
|
|
1811
1827
|
};
|
|
1812
|
-
return
|
|
1828
|
+
return pe.push(Ye), pe.push(Ke), pe;
|
|
1813
1829
|
});
|
|
1814
1830
|
}
|
|
1815
|
-
}, [
|
|
1831
|
+
}, [N, D] = re(() => {
|
|
1816
1832
|
const d = {};
|
|
1817
|
-
for (const
|
|
1818
|
-
d[
|
|
1819
|
-
for (const
|
|
1820
|
-
d[
|
|
1821
|
-
from:
|
|
1822
|
-
to:
|
|
1823
|
-
input:
|
|
1833
|
+
for (const b of f)
|
|
1834
|
+
d[b.id] = [];
|
|
1835
|
+
for (const b of c)
|
|
1836
|
+
d[b.target].push({
|
|
1837
|
+
from: b.source,
|
|
1838
|
+
to: b.target,
|
|
1839
|
+
input: b.targetHandle ?? ""
|
|
1824
1840
|
});
|
|
1825
1841
|
return [JSON.stringify(d), d];
|
|
1826
|
-
}, [
|
|
1842
|
+
}, [c, f]), [z, G] = re(() => {
|
|
1827
1843
|
const d = {};
|
|
1828
|
-
for (const
|
|
1829
|
-
if (
|
|
1830
|
-
const
|
|
1831
|
-
d[
|
|
1844
|
+
for (const g of f)
|
|
1845
|
+
if (g.type === "shader") {
|
|
1846
|
+
const b = g;
|
|
1847
|
+
d[b.id] = b.data.shader;
|
|
1832
1848
|
}
|
|
1833
1849
|
return [JSON.stringify(d), d];
|
|
1834
|
-
}, [
|
|
1850
|
+
}, [f]), te = re(() => {
|
|
1835
1851
|
const d = {};
|
|
1836
|
-
for (const [
|
|
1837
|
-
d[
|
|
1838
|
-
const
|
|
1839
|
-
for (;
|
|
1840
|
-
const
|
|
1841
|
-
for (const
|
|
1842
|
-
const
|
|
1843
|
-
|
|
1844
|
-
const
|
|
1845
|
-
d[
|
|
1852
|
+
for (const [g, b] of Object.entries(G)) {
|
|
1853
|
+
d[g] = { shaders: [b], connections: [] };
|
|
1854
|
+
const F = [g];
|
|
1855
|
+
for (; F.length !== 0; ) {
|
|
1856
|
+
const R = F.shift();
|
|
1857
|
+
for (const P of D[R]) {
|
|
1858
|
+
const B = P.from;
|
|
1859
|
+
F.push(B);
|
|
1860
|
+
const j = G[B];
|
|
1861
|
+
d[g].shaders.find(
|
|
1862
|
+
(O) => O.id === j.id
|
|
1863
|
+
) || d[g].shaders.push(j), d[g].connections.push(P);
|
|
1846
1864
|
}
|
|
1847
1865
|
}
|
|
1848
1866
|
}
|
|
1849
1867
|
return d;
|
|
1850
|
-
}, [
|
|
1851
|
-
(d,
|
|
1852
|
-
|
|
1868
|
+
}, [z, N]), fe = Y(
|
|
1869
|
+
(d, g) => {
|
|
1870
|
+
_.current[d] = g(
|
|
1871
|
+
_.current[d]
|
|
1872
|
+
);
|
|
1853
1873
|
},
|
|
1854
1874
|
[]
|
|
1855
|
-
),
|
|
1856
|
-
(d,
|
|
1857
|
-
|
|
1858
|
-
const
|
|
1859
|
-
if (
|
|
1860
|
-
const
|
|
1861
|
-
return { ...
|
|
1875
|
+
), le = Y(
|
|
1876
|
+
(d, g) => {
|
|
1877
|
+
p((b) => {
|
|
1878
|
+
const F = b.map((R) => {
|
|
1879
|
+
if (R.id === d && R.type === "shader") {
|
|
1880
|
+
const P = R;
|
|
1881
|
+
return { ...P, data: g(P.data) };
|
|
1862
1882
|
}
|
|
1863
|
-
return
|
|
1883
|
+
return R;
|
|
1864
1884
|
});
|
|
1865
|
-
return
|
|
1885
|
+
return _e(F, c, d);
|
|
1866
1886
|
});
|
|
1867
1887
|
},
|
|
1868
|
-
[
|
|
1869
|
-
),
|
|
1870
|
-
|
|
1888
|
+
[c]
|
|
1889
|
+
), W = $(0), Z = $([0, 0]);
|
|
1890
|
+
k(() => {
|
|
1871
1891
|
const d = setInterval(() => {
|
|
1872
|
-
|
|
1873
|
-
}, 10),
|
|
1874
|
-
|
|
1875
|
-
Math.min(1,
|
|
1876
|
-
Math.min(
|
|
1892
|
+
W.current = Date.now();
|
|
1893
|
+
}, 10), g = (b) => {
|
|
1894
|
+
Z.current = [
|
|
1895
|
+
Math.min(1, b.clientX / window.innerWidth),
|
|
1896
|
+
Math.min(b.clientY / innerHeight, 1)
|
|
1877
1897
|
];
|
|
1878
1898
|
};
|
|
1879
|
-
return window.addEventListener("mousemove",
|
|
1880
|
-
clearInterval(d), window.removeEventListener("mousemove",
|
|
1899
|
+
return window.addEventListener("mousemove", g), () => {
|
|
1900
|
+
clearInterval(d), window.removeEventListener("mousemove", g);
|
|
1881
1901
|
};
|
|
1882
1902
|
}, []);
|
|
1883
|
-
const
|
|
1884
|
-
if (
|
|
1885
|
-
const
|
|
1886
|
-
|
|
1887
|
-
const
|
|
1888
|
-
let
|
|
1889
|
-
for (const
|
|
1890
|
-
if (
|
|
1891
|
-
|
|
1903
|
+
const Oe = (d, g, b) => {
|
|
1904
|
+
if (f.find((R) => R.id === g)) {
|
|
1905
|
+
const R = H(d);
|
|
1906
|
+
R.position = b;
|
|
1907
|
+
const P = ce(R.data.shader);
|
|
1908
|
+
let B;
|
|
1909
|
+
for (const j of P)
|
|
1910
|
+
if (j.type === "sampler2D" && j.source === "input") {
|
|
1911
|
+
B = j.name;
|
|
1892
1912
|
break;
|
|
1893
1913
|
}
|
|
1894
|
-
if (
|
|
1895
|
-
const
|
|
1914
|
+
if (p((j) => [...j, R]), B !== void 0) {
|
|
1915
|
+
const j = {
|
|
1896
1916
|
id: "" + Math.random(),
|
|
1897
|
-
source:
|
|
1898
|
-
target:
|
|
1899
|
-
targetHandle:
|
|
1917
|
+
source: g,
|
|
1918
|
+
target: R.id,
|
|
1919
|
+
targetHandle: B,
|
|
1900
1920
|
type: "insert"
|
|
1901
1921
|
};
|
|
1902
|
-
h((
|
|
1922
|
+
h((O) => Ne(j, O));
|
|
1903
1923
|
}
|
|
1904
1924
|
}
|
|
1905
|
-
}, [
|
|
1906
|
-
|
|
1907
|
-
), [
|
|
1908
|
-
|
|
1925
|
+
}, [ye, Le] = y(""), [we, ze] = y(""), [ee, je] = y(e ?? !1), [oe, qe] = y(
|
|
1926
|
+
a ?? !0
|
|
1927
|
+
), [ie, Ce] = y(null), [He, Be] = y(l ?? null), Xe = (d) => {
|
|
1928
|
+
Be(d), i?.(d);
|
|
1909
1929
|
};
|
|
1910
|
-
return
|
|
1911
|
-
u?.({ showStats:
|
|
1912
|
-
}, [
|
|
1913
|
-
/* @__PURE__ */
|
|
1914
|
-
|
|
1930
|
+
return k(() => {
|
|
1931
|
+
u?.({ showStats: ee, shaderPanelOpen: oe });
|
|
1932
|
+
}, [ee, oe]), /* @__PURE__ */ m("div", { className: `w-full h-full ${s}`, children: [
|
|
1933
|
+
/* @__PURE__ */ t(
|
|
1934
|
+
ae.Provider,
|
|
1915
1935
|
{
|
|
1916
1936
|
value: {
|
|
1917
|
-
currentTime:
|
|
1918
|
-
mousePosition:
|
|
1919
|
-
shaders:
|
|
1920
|
-
patches:
|
|
1921
|
-
showStats:
|
|
1922
|
-
openExportNodeId:
|
|
1923
|
-
setOpenExportNodeId:
|
|
1924
|
-
openPreviewNodeId:
|
|
1925
|
-
setOpenPreviewNodeId:
|
|
1926
|
-
uniforms:
|
|
1927
|
-
handleUpdateUniforms:
|
|
1928
|
-
handleUpdateNode:
|
|
1929
|
-
handleInsertShader:
|
|
1937
|
+
currentTime: W,
|
|
1938
|
+
mousePosition: Z,
|
|
1939
|
+
shaders: n,
|
|
1940
|
+
patches: te,
|
|
1941
|
+
showStats: ee,
|
|
1942
|
+
openExportNodeId: ie,
|
|
1943
|
+
setOpenExportNodeId: Ce,
|
|
1944
|
+
openPreviewNodeId: He,
|
|
1945
|
+
setOpenPreviewNodeId: Xe,
|
|
1946
|
+
uniforms: _,
|
|
1947
|
+
handleUpdateUniforms: fe,
|
|
1948
|
+
handleUpdateNode: le,
|
|
1949
|
+
handleInsertShader: K
|
|
1930
1950
|
},
|
|
1931
|
-
children: /* @__PURE__ */
|
|
1932
|
-
|
|
1951
|
+
children: /* @__PURE__ */ m(
|
|
1952
|
+
ln,
|
|
1933
1953
|
{
|
|
1934
1954
|
panOnScroll: !0,
|
|
1935
1955
|
proOptions: { hideAttribution: !0 },
|
|
1936
|
-
nodes:
|
|
1956
|
+
nodes: f,
|
|
1937
1957
|
nodeTypes: { shader: Rn },
|
|
1938
|
-
edges:
|
|
1939
|
-
edgeTypes: { insert:
|
|
1940
|
-
onNodesChange:
|
|
1941
|
-
onEdgesChange:
|
|
1942
|
-
onConnect:
|
|
1943
|
-
onConnectEnd:
|
|
1944
|
-
connectionLineComponent:
|
|
1945
|
-
isValidConnection:
|
|
1958
|
+
edges: c,
|
|
1959
|
+
edgeTypes: { insert: Fn },
|
|
1960
|
+
onNodesChange: x,
|
|
1961
|
+
onEdgesChange: w,
|
|
1962
|
+
onConnect: T,
|
|
1963
|
+
onConnectEnd: U,
|
|
1964
|
+
connectionLineComponent: Pn,
|
|
1965
|
+
isValidConnection: E,
|
|
1946
1966
|
style: {
|
|
1947
|
-
background: "#
|
|
1967
|
+
background: "#F3F3F3"
|
|
1948
1968
|
},
|
|
1949
1969
|
fitView: !0,
|
|
1950
1970
|
children: [
|
|
1951
|
-
/* @__PURE__ */
|
|
1952
|
-
|
|
1971
|
+
/* @__PURE__ */ t(
|
|
1972
|
+
cn,
|
|
1953
1973
|
{
|
|
1954
1974
|
style: {
|
|
1955
1975
|
"--xy-controls-button-background-color-default": "transparent",
|
|
@@ -1957,18 +1977,18 @@ const An = ({
|
|
|
1957
1977
|
}
|
|
1958
1978
|
}
|
|
1959
1979
|
),
|
|
1960
|
-
/* @__PURE__ */
|
|
1961
|
-
/* @__PURE__ */
|
|
1980
|
+
/* @__PURE__ */ m(he, { position: "top-left", className: "flex flex-col gap-4", children: [
|
|
1981
|
+
/* @__PURE__ */ t(
|
|
1962
1982
|
"button",
|
|
1963
1983
|
{
|
|
1964
1984
|
className: "button-base",
|
|
1965
|
-
onClick: () =>
|
|
1966
|
-
children:
|
|
1985
|
+
onClick: () => je(!ee),
|
|
1986
|
+
children: ee ? "Hide Stats" : "Show Stats"
|
|
1967
1987
|
}
|
|
1968
1988
|
),
|
|
1969
|
-
|
|
1970
|
-
/* @__PURE__ */
|
|
1971
|
-
/* @__PURE__ */
|
|
1989
|
+
ee && /* @__PURE__ */ m(se, { children: [
|
|
1990
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col gap-2", children: f.map((d) => /* @__PURE__ */ t("p", { className: "text-xs text-neutral-400", children: d.id }, d.id)) }),
|
|
1991
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col gap-2", children: c.map((d) => /* @__PURE__ */ m("p", { className: "text-xs text-neutral-400", children: [
|
|
1972
1992
|
d.source,
|
|
1973
1993
|
" ",
|
|
1974
1994
|
">",
|
|
@@ -1979,109 +1999,137 @@ const An = ({
|
|
|
1979
1999
|
] }, d.id)) })
|
|
1980
2000
|
] })
|
|
1981
2001
|
] }),
|
|
1982
|
-
|
|
1983
|
-
/* @__PURE__ */
|
|
1984
|
-
/* @__PURE__ */
|
|
1985
|
-
/* @__PURE__ */
|
|
2002
|
+
n.length > 0 && /* @__PURE__ */ t(he, { position: "bottom-right", children: /* @__PURE__ */ m("div", { className: "w-56 flex flex-col rounded-sm bg-white overflow-hidden", children: [
|
|
2003
|
+
/* @__PURE__ */ m("div", { className: "flex items-center justify-between px-3 py-2", children: [
|
|
2004
|
+
/* @__PURE__ */ t("p", { className: "text-sm", children: "Add Shader" }),
|
|
2005
|
+
/* @__PURE__ */ t(
|
|
1986
2006
|
"button",
|
|
1987
2007
|
{
|
|
1988
2008
|
className: "button-base",
|
|
1989
|
-
onClick: () =>
|
|
1990
|
-
children:
|
|
2009
|
+
onClick: () => qe(!oe),
|
|
2010
|
+
children: oe ? "Hide" : "Show"
|
|
1991
2011
|
}
|
|
1992
2012
|
)
|
|
1993
2013
|
] }),
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2014
|
+
oe && /* @__PURE__ */ m("div", { className: "flex flex-col gap-1 px-2 pb-2", children: [
|
|
2015
|
+
/* @__PURE__ */ t(
|
|
2016
|
+
"input",
|
|
2017
|
+
{
|
|
2018
|
+
type: "text",
|
|
2019
|
+
value: ye,
|
|
2020
|
+
onChange: (d) => Le(d.target.value),
|
|
2021
|
+
placeholder: "Search shaders...",
|
|
2022
|
+
className: "text-xs p-1 rounded-sm border border-neutral-200 outline-none mb-1"
|
|
2023
|
+
}
|
|
2024
|
+
),
|
|
2025
|
+
/* @__PURE__ */ t("div", { className: "flex flex-col gap-1 pb-2 h-[50vh] overflow-y-auto", children: n.filter(
|
|
2026
|
+
(d) => d.name.toLowerCase().includes(ye.toLowerCase())
|
|
2027
|
+
).sort((d, g) => d.name.localeCompare(g.name)).map((d) => /* @__PURE__ */ t(
|
|
2028
|
+
"button",
|
|
2029
|
+
{
|
|
2030
|
+
className: "text-xs flex justify-start p-1 rounded-sm hover:bg-neutral-100 cursor-pointer text-neutral-500",
|
|
2031
|
+
onClick: () => X(d),
|
|
2032
|
+
children: d.id.length > 25 ? `${d.id.slice(0, 11)}...${d.id.slice(-11)}` : d.id
|
|
2033
|
+
},
|
|
2034
|
+
d.id
|
|
2035
|
+
)) })
|
|
2036
|
+
] })
|
|
2003
2037
|
] }) }),
|
|
2004
|
-
|
|
2038
|
+
S && /* @__PURE__ */ t(he, { position: "bottom-center", children: /* @__PURE__ */ m("p", { className: "text-xs text-neutral-400", children: [
|
|
2005
2039
|
"Last saved at ",
|
|
2006
|
-
|
|
2040
|
+
S.toLocaleTimeString()
|
|
2007
2041
|
] }) })
|
|
2008
2042
|
]
|
|
2009
2043
|
}
|
|
2010
2044
|
)
|
|
2011
2045
|
}
|
|
2012
2046
|
),
|
|
2013
|
-
|
|
2014
|
-
|
|
2047
|
+
ie !== null && te[ie] && /* @__PURE__ */ t(
|
|
2048
|
+
$e,
|
|
2015
2049
|
{
|
|
2016
|
-
uniforms:
|
|
2017
|
-
patch:
|
|
2050
|
+
uniforms: _.current,
|
|
2051
|
+
patch: te[ie],
|
|
2018
2052
|
open: !0,
|
|
2019
2053
|
onOpenChange: (d) => {
|
|
2020
|
-
d ||
|
|
2054
|
+
d || Ce(null);
|
|
2021
2055
|
}
|
|
2022
2056
|
}
|
|
2023
2057
|
),
|
|
2024
|
-
/* @__PURE__ */
|
|
2025
|
-
|
|
2058
|
+
/* @__PURE__ */ t(
|
|
2059
|
+
de,
|
|
2026
2060
|
{
|
|
2027
|
-
open:
|
|
2061
|
+
open: C !== null,
|
|
2028
2062
|
handleOpenChange: (d) => {
|
|
2029
|
-
d === !1 &&
|
|
2063
|
+
d === !1 && A(null);
|
|
2030
2064
|
},
|
|
2031
|
-
children: /* @__PURE__ */
|
|
2032
|
-
/* @__PURE__ */
|
|
2033
|
-
/* @__PURE__ */
|
|
2034
|
-
/* @__PURE__ */
|
|
2065
|
+
children: /* @__PURE__ */ m("div", { className: "w-full h-full flex flex-col p-4 gap-4", children: [
|
|
2066
|
+
/* @__PURE__ */ m("div", { className: "w-full flex justify-between", children: [
|
|
2067
|
+
/* @__PURE__ */ t("p", { children: "Add a Shader" }),
|
|
2068
|
+
/* @__PURE__ */ t(
|
|
2035
2069
|
"button",
|
|
2036
2070
|
{
|
|
2037
2071
|
className: "button-base",
|
|
2038
2072
|
onClick: () => {
|
|
2039
|
-
|
|
2073
|
+
A(null);
|
|
2040
2074
|
},
|
|
2041
2075
|
children: "Close"
|
|
2042
2076
|
}
|
|
2043
2077
|
)
|
|
2044
2078
|
] }),
|
|
2045
|
-
/* @__PURE__ */
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2079
|
+
/* @__PURE__ */ m("div", { className: "w-full flex flex-col h-full overflow-hidden gap-2", children: [
|
|
2080
|
+
/* @__PURE__ */ t(
|
|
2081
|
+
"input",
|
|
2082
|
+
{
|
|
2083
|
+
type: "text",
|
|
2084
|
+
value: we,
|
|
2085
|
+
onChange: (d) => ze(d.target.value),
|
|
2086
|
+
placeholder: "Search shaders...",
|
|
2087
|
+
className: "text-xs p-1 rounded-sm border border-neutral-200 outline-none mb-1"
|
|
2088
|
+
}
|
|
2089
|
+
),
|
|
2090
|
+
/* @__PURE__ */ t("div", { className: "h-full flex flex-col overflow-y-auto", children: n.filter(
|
|
2091
|
+
(d) => d.name.toLowerCase().includes(we.toLowerCase())
|
|
2092
|
+
).map((d) => /* @__PURE__ */ t(
|
|
2093
|
+
"button",
|
|
2094
|
+
{
|
|
2095
|
+
className: "text-xs flex justify-start p-1 rounded-sm hover:bg-neutral-100 cursor-pointer text-neutral-500",
|
|
2096
|
+
onClick: () => {
|
|
2097
|
+
C && Oe(
|
|
2098
|
+
d,
|
|
2099
|
+
C.sourceId,
|
|
2100
|
+
C.position
|
|
2101
|
+
), A(null);
|
|
2102
|
+
},
|
|
2103
|
+
children: d.id
|
|
2055
2104
|
},
|
|
2056
|
-
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
)) })
|
|
2105
|
+
d.id
|
|
2106
|
+
)) })
|
|
2107
|
+
] })
|
|
2060
2108
|
] })
|
|
2061
2109
|
}
|
|
2062
2110
|
)
|
|
2063
2111
|
] });
|
|
2064
|
-
},
|
|
2065
|
-
function
|
|
2066
|
-
const r = { current: o },
|
|
2067
|
-
id:
|
|
2112
|
+
}, at = (n) => /* @__PURE__ */ t(on, { children: /* @__PURE__ */ t(Mn, { ...n }) });
|
|
2113
|
+
function lt(n, o) {
|
|
2114
|
+
const r = { current: o }, s = n.shaders.map((a, l) => ({
|
|
2115
|
+
id: a.id,
|
|
2068
2116
|
type: "shader",
|
|
2069
|
-
position: { x: 0, y: -
|
|
2117
|
+
position: { x: 0, y: -l * 500 },
|
|
2070
2118
|
data: {
|
|
2071
|
-
shader:
|
|
2119
|
+
shader: a,
|
|
2072
2120
|
uniforms: r,
|
|
2073
2121
|
paused: !1
|
|
2074
2122
|
}
|
|
2075
|
-
})),
|
|
2076
|
-
id: `edge-${
|
|
2077
|
-
source:
|
|
2078
|
-
target:
|
|
2079
|
-
targetHandle:
|
|
2123
|
+
})), e = n.connections.map((a, l) => ({
|
|
2124
|
+
id: `edge-${l}`,
|
|
2125
|
+
source: a.from,
|
|
2126
|
+
target: a.to,
|
|
2127
|
+
targetHandle: a.input,
|
|
2080
2128
|
type: "insert"
|
|
2081
2129
|
}));
|
|
2082
|
-
return console.log("build", { nodes:
|
|
2130
|
+
return console.log("build", { nodes: s, edges: e, uniforms: o }), { nodes: s, edges: e, uniforms: o };
|
|
2083
2131
|
}
|
|
2084
|
-
const
|
|
2132
|
+
const $n = `#version 300 es
|
|
2085
2133
|
precision mediump float;
|
|
2086
2134
|
|
|
2087
2135
|
uniform sampler2D u_texture; // input
|
|
@@ -2103,7 +2151,7 @@ void main() {
|
|
|
2103
2151
|
fragColor = texColor;
|
|
2104
2152
|
}
|
|
2105
2153
|
}
|
|
2106
|
-
`,
|
|
2154
|
+
`, On = `#version 300 es
|
|
2107
2155
|
|
|
2108
2156
|
precision highp float;
|
|
2109
2157
|
|
|
@@ -2378,16 +2426,18 @@ void main()
|
|
|
2378
2426
|
),
|
|
2379
2427
|
1.0
|
|
2380
2428
|
);
|
|
2381
|
-
}`,
|
|
2429
|
+
}`, Ln = `#version 300 es
|
|
2382
2430
|
precision mediump float;
|
|
2383
2431
|
|
|
2384
|
-
uniform sampler2D u_texture;
|
|
2385
|
-
uniform
|
|
2432
|
+
uniform sampler2D u_texture;
|
|
2433
|
+
uniform vec2 u_resolution; // resolution
|
|
2386
2434
|
uniform float u_numColors; // [2, 16, 2]
|
|
2435
|
+
uniform float u_dither_size; // [1, 100, 10]
|
|
2387
2436
|
|
|
2388
2437
|
in vec2 vUv;
|
|
2389
2438
|
out vec4 fragColor;
|
|
2390
2439
|
|
|
2440
|
+
|
|
2391
2441
|
int bayer(int x, int y) {
|
|
2392
2442
|
int bayer64[64] = int[64](
|
|
2393
2443
|
0, 32, 8, 40, 2, 34, 10, 42,
|
|
@@ -2403,8 +2453,8 @@ int bayer(int x, int y) {
|
|
|
2403
2453
|
}
|
|
2404
2454
|
|
|
2405
2455
|
void main() {
|
|
2406
|
-
vec2 cell = floor(vUv * u_resolution);
|
|
2407
|
-
vec2 cellUv = cell / u_resolution;
|
|
2456
|
+
vec2 cell = floor(vUv * u_resolution / u_dither_size);
|
|
2457
|
+
vec2 cellUv = cell / u_resolution * u_dither_size;
|
|
2408
2458
|
|
|
2409
2459
|
vec4 color = texture(u_texture, cellUv);
|
|
2410
2460
|
|
|
@@ -2416,7 +2466,7 @@ void main() {
|
|
|
2416
2466
|
|
|
2417
2467
|
fragColor = vec4(dithered, color.a);
|
|
2418
2468
|
}
|
|
2419
|
-
`,
|
|
2469
|
+
`, zn = `#version 300 es
|
|
2420
2470
|
precision mediump float;
|
|
2421
2471
|
|
|
2422
2472
|
uniform sampler2D u_texture; // input
|
|
@@ -2455,7 +2505,7 @@ void main() {
|
|
|
2455
2505
|
|
|
2456
2506
|
fragColor = dist < dotRadius ? cellColor : u_background;
|
|
2457
2507
|
}
|
|
2458
|
-
`,
|
|
2508
|
+
`, jn = `#version 300 es
|
|
2459
2509
|
precision highp float;
|
|
2460
2510
|
|
|
2461
2511
|
in vec2 vUv;
|
|
@@ -2493,58 +2543,7 @@ void main() {
|
|
|
2493
2543
|
vec4(vec3(1.0), 1.0),
|
|
2494
2544
|
smoothstep(0.6, 0.5, dist)
|
|
2495
2545
|
);
|
|
2496
|
-
}`,
|
|
2497
|
-
precision mediump float;
|
|
2498
|
-
|
|
2499
|
-
uniform sampler2D u_texture;
|
|
2500
|
-
uniform float u_size; // [1, 100, 5]
|
|
2501
|
-
uniform vec2 u_resolution; // resolution
|
|
2502
|
-
|
|
2503
|
-
in vec2 vUv;
|
|
2504
|
-
out vec4 fragColor;
|
|
2505
|
-
|
|
2506
|
-
const float PI = 3.1415926535897932384626433832795;
|
|
2507
|
-
|
|
2508
|
-
// Gaussian function
|
|
2509
|
-
float gaussian(float x, float sigma) {
|
|
2510
|
-
return exp(-(x * x) / (2.0 * sigma * sigma)) / (sqrt(2.0 * PI) * sigma);
|
|
2511
|
-
}
|
|
2512
|
-
|
|
2513
|
-
void main() {
|
|
2514
|
-
vec2 texelSize = 1.0 / u_resolution;
|
|
2515
|
-
float sigma = u_size / 3.0; // Standard deviation based on size
|
|
2516
|
-
|
|
2517
|
-
vec4 result = vec4(0.0);
|
|
2518
|
-
float totalWeight = 0.0;
|
|
2519
|
-
|
|
2520
|
-
int kernelRadius = int(ceil(u_size));
|
|
2521
|
-
|
|
2522
|
-
// Two-pass separable Gaussian blur (horizontal + vertical in one pass for simplicity)
|
|
2523
|
-
// For better performance, this should be split into two passes, but for this implementation
|
|
2524
|
-
// we'll do a 2D kernel
|
|
2525
|
-
for (int x = -25; x <= 25; x++) {
|
|
2526
|
-
if (abs(float(x)) > float(kernelRadius)) continue;
|
|
2527
|
-
|
|
2528
|
-
for (int y = -25; y <= 25; y++) {
|
|
2529
|
-
if (abs(float(y)) > float(kernelRadius)) continue;
|
|
2530
|
-
|
|
2531
|
-
vec2 offset = vec2(float(x), float(y)) * texelSize;
|
|
2532
|
-
vec2 sampleCoord = vUv + offset;
|
|
2533
|
-
|
|
2534
|
-
// Clamp to edges
|
|
2535
|
-
sampleCoord = clamp(sampleCoord, vec2(0.0), vec2(1.0));
|
|
2536
|
-
|
|
2537
|
-
float distance = length(vec2(float(x), float(y)));
|
|
2538
|
-
float weight = gaussian(distance, sigma);
|
|
2539
|
-
|
|
2540
|
-
result += texture(u_texture, sampleCoord) * weight;
|
|
2541
|
-
totalWeight += weight;
|
|
2542
|
-
}
|
|
2543
|
-
}
|
|
2544
|
-
|
|
2545
|
-
fragColor = result / totalWeight;
|
|
2546
|
-
}
|
|
2547
|
-
`, zn = `#version 300 es
|
|
2546
|
+
}`, qn = `#version 300 es
|
|
2548
2547
|
precision mediump float;
|
|
2549
2548
|
|
|
2550
2549
|
uniform sampler2D u_texture;
|
|
@@ -2561,7 +2560,7 @@ void main() {
|
|
|
2561
2560
|
|
|
2562
2561
|
fragColor = vec4(gradientColor.rgb, 1.0);
|
|
2563
2562
|
}
|
|
2564
|
-
`,
|
|
2563
|
+
`, Hn = `#version 300 es
|
|
2565
2564
|
precision mediump float;
|
|
2566
2565
|
|
|
2567
2566
|
uniform sampler2D u_texture; // input
|
|
@@ -2633,7 +2632,7 @@ void main() {
|
|
|
2633
2632
|
|
|
2634
2633
|
fragColor = vec4(hsl2rgb(hsl), color.a);
|
|
2635
2634
|
}
|
|
2636
|
-
`,
|
|
2635
|
+
`, Bn = `#version 300 es
|
|
2637
2636
|
precision highp float;
|
|
2638
2637
|
|
|
2639
2638
|
in vec2 vUv;
|
|
@@ -2643,44 +2642,7 @@ uniform sampler2D u_image_source; // texture
|
|
|
2643
2642
|
|
|
2644
2643
|
void main() {
|
|
2645
2644
|
fragColor = texture(u_image_source, vec2(vUv.x, 1.0-vUv.y));
|
|
2646
|
-
}`,
|
|
2647
|
-
precision mediump float;
|
|
2648
|
-
|
|
2649
|
-
uniform sampler2D u_texture;
|
|
2650
|
-
uniform float u_size; // [1, 100, 5]
|
|
2651
|
-
uniform vec2 u_resolution; // resolution
|
|
2652
|
-
|
|
2653
|
-
in vec2 vUv;
|
|
2654
|
-
out vec4 fragColor;
|
|
2655
|
-
|
|
2656
|
-
void main() {
|
|
2657
|
-
vec2 texelSize = 1.0 / u_resolution;
|
|
2658
|
-
|
|
2659
|
-
vec4 result = vec4(0.0);
|
|
2660
|
-
int kernelRadius = int(ceil(u_size));
|
|
2661
|
-
int sampleCount = 0;
|
|
2662
|
-
|
|
2663
|
-
// Box blur - simple average of all pixels in the kernel
|
|
2664
|
-
for (int x = -25; x <= 25; x++) {
|
|
2665
|
-
if (abs(float(x)) > float(kernelRadius)) continue;
|
|
2666
|
-
|
|
2667
|
-
for (int y = -25; y <= 25; y++) {
|
|
2668
|
-
if (abs(float(y)) > float(kernelRadius)) continue;
|
|
2669
|
-
|
|
2670
|
-
vec2 offset = vec2(float(x), float(y)) * texelSize;
|
|
2671
|
-
vec2 sampleCoord = vUv + offset;
|
|
2672
|
-
|
|
2673
|
-
// Clamp to edges
|
|
2674
|
-
sampleCoord = clamp(sampleCoord, vec2(0.0), vec2(1.0));
|
|
2675
|
-
|
|
2676
|
-
result += texture(u_texture, sampleCoord);
|
|
2677
|
-
sampleCount++;
|
|
2678
|
-
}
|
|
2679
|
-
}
|
|
2680
|
-
|
|
2681
|
-
fragColor = result / float(sampleCount);
|
|
2682
|
-
}
|
|
2683
|
-
`, qn = `#version 300 es
|
|
2645
|
+
}`, Xn = `#version 300 es
|
|
2684
2646
|
precision highp float;
|
|
2685
2647
|
|
|
2686
2648
|
uniform float u_time; // time
|
|
@@ -2754,7 +2716,7 @@ void main() {
|
|
|
2754
2716
|
}
|
|
2755
2717
|
}
|
|
2756
2718
|
|
|
2757
|
-
}`,
|
|
2719
|
+
}`, Gn = `#version 300 es
|
|
2758
2720
|
precision mediump float;
|
|
2759
2721
|
|
|
2760
2722
|
uniform sampler2D u_texture; // input
|
|
@@ -2768,33 +2730,267 @@ void main() {
|
|
|
2768
2730
|
vec3 adjusted = clamp(color.rgb + u_rgbAdjust / 255.0, 0.0, 1.0);
|
|
2769
2731
|
fragColor = vec4(adjusted, color.a);
|
|
2770
2732
|
}
|
|
2771
|
-
`,
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2733
|
+
`, Wn = `#version 300 es
|
|
2734
|
+
precision mediump float;
|
|
2735
|
+
|
|
2736
|
+
in vec2 vUv;
|
|
2737
|
+
out vec4 fragColor;
|
|
2738
|
+
|
|
2739
|
+
uniform sampler2D u_texture_1;
|
|
2740
|
+
uniform sampler2D u_texture_2;
|
|
2741
|
+
|
|
2742
|
+
void main() {
|
|
2743
|
+
fragColor = clamp(
|
|
2744
|
+
texture(u_texture_1, vUv) + texture(u_texture_2, vUv),
|
|
2745
|
+
vec4(0.),
|
|
2746
|
+
vec4(1.)
|
|
2747
|
+
);
|
|
2748
|
+
|
|
2749
|
+
}`, Vn = `#version 300 es
|
|
2750
|
+
precision mediump float;
|
|
2751
|
+
|
|
2752
|
+
in vec2 vUv;
|
|
2753
|
+
out vec4 fragColor;
|
|
2754
|
+
|
|
2755
|
+
uniform sampler2D u_texture_1;
|
|
2756
|
+
uniform sampler2D u_texture_2;
|
|
2757
|
+
|
|
2758
|
+
void main() {
|
|
2759
|
+
fragColor = clamp(
|
|
2760
|
+
texture(u_texture_1, vUv) - texture(u_texture_2, vUv),
|
|
2761
|
+
vec4(0.),
|
|
2762
|
+
vec4(1.)
|
|
2763
|
+
);
|
|
2764
|
+
|
|
2765
|
+
}`, Yn = `#version 300 es
|
|
2766
|
+
precision mediump float;
|
|
2767
|
+
|
|
2768
|
+
in vec2 vUv;
|
|
2769
|
+
out vec4 fragColor;
|
|
2770
|
+
|
|
2771
|
+
uniform sampler2D u_texture_1;
|
|
2772
|
+
uniform sampler2D u_texture_2;
|
|
2773
|
+
uniform float u_factor; // [0, 1, 0.5]
|
|
2774
|
+
|
|
2775
|
+
void main() {
|
|
2776
|
+
fragColor = mix(
|
|
2777
|
+
texture(u_texture_1, vUv),
|
|
2778
|
+
texture(u_texture_2, vUv),
|
|
2779
|
+
u_factor
|
|
2780
|
+
);
|
|
2781
|
+
}`, Kn = `#version 300 es
|
|
2782
|
+
precision mediump float;
|
|
2783
|
+
|
|
2784
|
+
in vec2 vUv;
|
|
2785
|
+
out vec4 fragColor;
|
|
2786
|
+
|
|
2787
|
+
uniform sampler2D u_texture_1;
|
|
2788
|
+
uniform sampler2D u_texture_2;
|
|
2789
|
+
|
|
2790
|
+
void main() {
|
|
2791
|
+
fragColor = clamp(
|
|
2792
|
+
texture(u_texture_1, vUv) * texture(u_texture_2, vUv),
|
|
2793
|
+
vec4(0.),
|
|
2794
|
+
vec4(1.)
|
|
2795
|
+
);
|
|
2796
|
+
|
|
2797
|
+
}`, Jn = `#version 300 es
|
|
2798
|
+
precision mediump float;
|
|
2799
|
+
|
|
2800
|
+
in vec2 vUv;
|
|
2801
|
+
out vec4 fragColor;
|
|
2802
|
+
|
|
2803
|
+
uniform sampler2D u_texture_1;
|
|
2804
|
+
uniform sampler2D u_texture_2;
|
|
2805
|
+
|
|
2806
|
+
void main() {
|
|
2807
|
+
fragColor = clamp(
|
|
2808
|
+
texture(u_texture_1, vUv) / (texture(u_texture_2, vUv) + 0.001),
|
|
2809
|
+
vec4(0.),
|
|
2810
|
+
vec4(1.)
|
|
2811
|
+
);
|
|
2812
|
+
}`, Qn = `#version 300 es
|
|
2813
|
+
precision mediump float;
|
|
2814
|
+
|
|
2815
|
+
uniform sampler2D u_texture;
|
|
2816
|
+
uniform float u_blur_radius; // [0, 3, 0.1]
|
|
2817
|
+
uniform vec2 u_resolution; // resolution
|
|
2818
|
+
uniform vec2 u_center; // [0.5, 0.5]
|
|
2819
|
+
uniform float u_blur_sample_count; // [2, 50, 5]
|
|
2820
|
+
|
|
2821
|
+
in vec2 vUv;
|
|
2822
|
+
out vec4 fragColor;
|
|
2823
|
+
|
|
2824
|
+
void main() {
|
|
2825
|
+
vec2 aspect = vec2(u_resolution.x / u_resolution.y, 1.0);
|
|
2826
|
+
vec2 uv = vUv * aspect;
|
|
2827
|
+
vec2 center = u_center * aspect;
|
|
2828
|
+
|
|
2829
|
+
vec2 offset = uv - center;
|
|
2830
|
+
float r = atan(offset.y, offset.x);
|
|
2831
|
+
float dist = length(offset);
|
|
2832
|
+
|
|
2833
|
+
vec4 result = vec4(0.);
|
|
2834
|
+
|
|
2835
|
+
int count = int(floor(u_blur_sample_count));
|
|
2836
|
+
float invCount = 1.0 / float(count);
|
|
2837
|
+
|
|
2838
|
+
for (int i = 0; i < count; i++) {
|
|
2839
|
+
float progress = float(i) * invCount;
|
|
2840
|
+
float angle = r - u_blur_radius * 0.5 + progress * u_blur_radius;
|
|
2841
|
+
|
|
2842
|
+
vec2 rotated = vec2(cos(angle), sin(angle)) * dist;
|
|
2843
|
+
|
|
2844
|
+
vec2 sample_uv = center + rotated;
|
|
2845
|
+
sample_uv /= aspect;
|
|
2846
|
+
|
|
2847
|
+
result += texture(u_texture, sample_uv);
|
|
2848
|
+
}
|
|
2849
|
+
|
|
2850
|
+
fragColor = result * invCount;
|
|
2851
|
+
}
|
|
2852
|
+
`, Zn = `#version 300 es
|
|
2853
|
+
precision mediump float;
|
|
2854
|
+
|
|
2855
|
+
in vec2 vUv;
|
|
2856
|
+
out vec4 fragColor;
|
|
2857
|
+
|
|
2858
|
+
uniform sampler2D u_input_tex;
|
|
2859
|
+
uniform float u_blur_dist; // [0, 1, 0.1]
|
|
2860
|
+
uniform vec2 u_resolution; // resolution
|
|
2861
|
+
uniform float u_angle; // [0, 10, 0]
|
|
2862
|
+
uniform float u_blur_sample_count; // [2, 50, 5]
|
|
2863
|
+
uniform float u_start_offset; // [0, 1, 0.5]
|
|
2864
|
+
|
|
2865
|
+
|
|
2866
|
+
mat2 rotate2D(float angle) {
|
|
2867
|
+
float c = cos(angle);
|
|
2868
|
+
float s = sin(angle);
|
|
2869
|
+
return mat2(
|
|
2870
|
+
c, -s,
|
|
2871
|
+
s, c
|
|
2872
|
+
);
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
void main() {
|
|
2876
|
+
vec2 aspect = vec2(
|
|
2877
|
+
u_resolution.x / u_resolution.y,
|
|
2878
|
+
1.0
|
|
2879
|
+
);
|
|
2880
|
+
|
|
2881
|
+
vec2 uv = vUv * aspect;
|
|
2882
|
+
|
|
2883
|
+
mat2 rot_mat = rotate2D(u_angle);
|
|
2884
|
+
mat2 inv_rot_mat = rotate2D(-u_angle);
|
|
2885
|
+
vec2 rotated_uv = rot_mat * uv;
|
|
2886
|
+
|
|
2887
|
+
int count = int(floor(u_blur_sample_count));
|
|
2888
|
+
|
|
2889
|
+
vec4 result = vec4(0.0);
|
|
2890
|
+
|
|
2891
|
+
float offset_bias = u_blur_dist * u_start_offset;
|
|
2892
|
+
|
|
2893
|
+
for (int i = 0; i < count; i++) {
|
|
2894
|
+
float offset = float(i) / float(count) * u_blur_dist - offset_bias;
|
|
2895
|
+
vec2 target_pos = rotated_uv + vec2(offset, 0.0);
|
|
2896
|
+
|
|
2897
|
+
result += texture(
|
|
2898
|
+
u_input_tex,
|
|
2899
|
+
(inv_rot_mat * target_pos) / aspect
|
|
2900
|
+
);
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2903
|
+
fragColor = result / float(count);
|
|
2904
|
+
}`, et = `#version 300 es
|
|
2905
|
+
precision mediump float;
|
|
2906
|
+
|
|
2907
|
+
// from book of shaders
|
|
2908
|
+
|
|
2909
|
+
uniform vec2 u_resolution; // resolution
|
|
2910
|
+
|
|
2911
|
+
in vec2 vUv;
|
|
2912
|
+
out vec4 fragColor;
|
|
2913
|
+
|
|
2914
|
+
float random (vec2 st) {
|
|
2915
|
+
return fract(sin(dot(st.xy,
|
|
2916
|
+
vec2(12.9898,78.233)))*
|
|
2917
|
+
438758.5453123);
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2920
|
+
void main() {
|
|
2921
|
+
vec2 st = vUv.xy/u_resolution.xy;
|
|
2922
|
+
|
|
2923
|
+
float rnd1 = random(st);
|
|
2924
|
+
float rnd2 = random(st + rnd1);
|
|
2925
|
+
float rnd3 = random(vec2(rnd1, rnd2));
|
|
2926
|
+
float rnd4 = random(vec2(rnd1, rnd3));
|
|
2927
|
+
|
|
2928
|
+
fragColor = vec4(rnd1, rnd3, rnd4,1.0);
|
|
2929
|
+
}`, nt = `#version 300 es
|
|
2930
|
+
precision mediump float;
|
|
2931
|
+
|
|
2932
|
+
|
|
2933
|
+
uniform sampler2D u_input_tex;
|
|
2934
|
+
uniform vec2 u_resolution; // resolution
|
|
2935
|
+
uniform float disperse_distance; // [0, 1, 0.1]
|
|
2936
|
+
|
|
2937
|
+
in vec2 vUv;
|
|
2938
|
+
out vec4 fragColor;
|
|
2939
|
+
|
|
2940
|
+
float random (vec2 st) {
|
|
2941
|
+
return fract(sin(dot(st.xy,
|
|
2942
|
+
vec2(12.9898,78.233)))*
|
|
2943
|
+
438758.5453123);
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
void main() {
|
|
2947
|
+
vec2 aspect = vec2(
|
|
2948
|
+
u_resolution.x / u_resolution.y,
|
|
2949
|
+
1.0
|
|
2950
|
+
);
|
|
2951
|
+
vec2 uv = vUv.xy * aspect;
|
|
2952
|
+
|
|
2953
|
+
float rnd1 = random(uv);
|
|
2954
|
+
float rnd2 = random(uv.yx);
|
|
2955
|
+
|
|
2956
|
+
fragColor = texture(u_input_tex,
|
|
2957
|
+
(vec2(rnd1, rnd2) * disperse_distance - disperse_distance * 0.5 + uv)
|
|
2958
|
+
/ aspect
|
|
2959
|
+
);
|
|
2960
|
+
}`, it = {
|
|
2961
|
+
key: $n,
|
|
2962
|
+
dither: Ln,
|
|
2963
|
+
dots: zn,
|
|
2964
|
+
daffodil: On,
|
|
2965
|
+
diamonds: jn,
|
|
2966
|
+
"gradient map": qn,
|
|
2967
|
+
"hue/saturation/value": Hn,
|
|
2968
|
+
"image viewer": Bn,
|
|
2969
|
+
"blur (radial)": Qn,
|
|
2970
|
+
"blur (linear)": Zn,
|
|
2971
|
+
noise: et,
|
|
2972
|
+
dispersion: nt,
|
|
2973
|
+
lines: Xn,
|
|
2974
|
+
"color adjust": Gn,
|
|
2975
|
+
"mix (add)": Wn,
|
|
2976
|
+
"mix (subtract)": Vn,
|
|
2977
|
+
"mix (multiply)": Kn,
|
|
2978
|
+
"mix (linear)": Yn,
|
|
2979
|
+
"mix (divide)": Jn
|
|
2784
2980
|
};
|
|
2785
2981
|
export {
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2982
|
+
Ue as CustomHandle,
|
|
2983
|
+
de as Dialog,
|
|
2984
|
+
at as Editor,
|
|
2985
|
+
ae as EditorContext,
|
|
2986
|
+
$e as ExportDialog,
|
|
2987
|
+
hn as Renderer,
|
|
2792
2988
|
Re as RendererComponent,
|
|
2793
|
-
|
|
2989
|
+
V as Scrubber,
|
|
2794
2990
|
Rn as ShaderNode,
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2991
|
+
Me as UniformForm,
|
|
2992
|
+
lt as buildEditorState,
|
|
2993
|
+
xn as exportSequenzaPatch,
|
|
2994
|
+
ce as extractFields,
|
|
2995
|
+
it as staticShaders
|
|
2800
2996
|
};
|