material-designer-runtime 0.1.4 → 0.1.5
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 +167 -1
- package/dist/cache/bake-cache.d.ts +45 -0
- package/dist/cache/cache.worker.d.ts +1 -0
- package/dist/cache/codec.d.ts +13 -0
- package/dist/cache/idb-core.d.ts +27 -0
- package/dist/cache/index.d.ts +7 -0
- package/dist/cache/indexeddb-store.d.ts +13 -0
- package/dist/cache/key.d.ts +21 -0
- package/dist/cache/memory-store.d.ts +2 -0
- package/dist/cache/types.d.ts +85 -0
- package/dist/cache/worker-client.d.ts +8 -0
- package/dist/graph/bake-service.d.ts +21 -1
- package/dist/graph/channel-baker.d.ts +3 -0
- package/dist/graph/texture-transfer.d.ts +13 -0
- package/dist/graph/textured-surface.d.ts +2 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +1861 -904
- package/dist/runtime.d.ts +23 -1
- package/dist/topology.d.ts +2 -0
- package/dist/version.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as e from "three";
|
|
2
|
-
import {
|
|
3
|
-
import { MeshBasicNodeMaterial as
|
|
4
|
-
import { Fn as
|
|
5
|
-
var
|
|
2
|
+
import { LinearFilter as t, LinearMipmapLinearFilter as n, NearestFilter as r, NoColorSpace as i, OrthographicCamera as a, REVISION as o, RepeatWrapping as s, SRGBColorSpace as c, Scene as l } from "three";
|
|
3
|
+
import { MeshBasicNodeMaterial as u, MeshLambertNodeMaterial as d, MeshMatcapNodeMaterial as f, MeshPhongNodeMaterial as p, MeshPhysicalNodeMaterial as m, MeshStandardNodeMaterial as h, MeshToonNodeMaterial as g, QuadMesh as _, RenderTarget as v } from "three/webgpu";
|
|
4
|
+
import { Fn as y, abs as b, acos as x, asin as S, atan as C, attribute as w, bool as ee, bumpMap as te, ceil as ne, clamp as T, color as re, cos as E, cosh as ie, cross as D, dFdx as ae, dFdy as oe, degrees as se, dot as O, exp as ce, exp2 as le, float as k, floatBitsToUint as ue, floor as A, fract as j, fwidth as de, int as M, inverseSqrt as fe, length as pe, log as me, luminance as he, max as N, min as P, mix as F, mod as I, mx_noise_float as ge, normalLocal as _e, normalMap as ve, normalWorld as ye, normalize as be, parallaxDirection as xe, positionLocal as Se, positionWorld as Ce, pow as L, radians as we, reflect as Te, round as Ee, sRGBTransferOETF as De, saturate as Oe, select as R, sign as ke, sin as z, sinh as Ae, smoothstep as B, sqrt as je, step as Me, tan as Ne, tanh as Pe, texture as V, trunc as Fe, uint as H, uniform as Ie, uniformArray as Le, uv as U, vec2 as W, vec3 as G, vec4 as Re } from "three/tsl";
|
|
5
|
+
var ze = {
|
|
6
6
|
version: 3,
|
|
7
7
|
nodes: [{
|
|
8
8
|
id: "pr",
|
|
@@ -29,20 +29,20 @@ var Ne = {
|
|
|
29
29
|
toNode: "out",
|
|
30
30
|
toInput: "surface"
|
|
31
31
|
}]
|
|
32
|
-
},
|
|
32
|
+
}, Be = [
|
|
33
33
|
0,
|
|
34
34
|
.25,
|
|
35
35
|
.5,
|
|
36
36
|
.75,
|
|
37
37
|
1
|
|
38
|
-
],
|
|
38
|
+
], Ve = [
|
|
39
39
|
"C",
|
|
40
40
|
"R",
|
|
41
41
|
"G",
|
|
42
42
|
"B"
|
|
43
43
|
];
|
|
44
|
-
function
|
|
45
|
-
let t = (e) => Array.from({ length: 5 }, (t, n) => e?.[n] ??
|
|
44
|
+
function He(e) {
|
|
45
|
+
let t = (e) => Array.from({ length: 5 }, (t, n) => e?.[n] ?? Be[n]);
|
|
46
46
|
return [
|
|
47
47
|
...t(e?.C),
|
|
48
48
|
...t(e?.R),
|
|
@@ -50,14 +50,14 @@ function Ie(e) {
|
|
|
50
50
|
...t(e?.B)
|
|
51
51
|
];
|
|
52
52
|
}
|
|
53
|
-
var
|
|
53
|
+
var Ue = [
|
|
54
54
|
"standard",
|
|
55
55
|
"physical",
|
|
56
56
|
"lambert",
|
|
57
57
|
"toon",
|
|
58
58
|
"phong",
|
|
59
59
|
"matcap"
|
|
60
|
-
],
|
|
60
|
+
], We = {
|
|
61
61
|
standard: {
|
|
62
62
|
roughMetal: !0,
|
|
63
63
|
physicalLobes: !1,
|
|
@@ -95,17 +95,17 @@ var Le = [
|
|
|
95
95
|
emissive: !1
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
|
-
function
|
|
99
|
-
return
|
|
98
|
+
function Ge(e) {
|
|
99
|
+
return Ue.includes(e) ? e : "physical";
|
|
100
100
|
}
|
|
101
|
-
var
|
|
101
|
+
var Ke = "group", qe = "group-input", Je = "group-output", Ye = "material-output", Xe = "shader-material", Ze = [
|
|
102
102
|
"baseColor",
|
|
103
103
|
"normal",
|
|
104
104
|
"emission",
|
|
105
105
|
"roughness",
|
|
106
106
|
"metallic",
|
|
107
107
|
"ambientOcclusion"
|
|
108
|
-
],
|
|
108
|
+
], Qe = {
|
|
109
109
|
float: {
|
|
110
110
|
float: "identity",
|
|
111
111
|
vector: "float-to-vector",
|
|
@@ -123,28 +123,28 @@ var Be = "group", Ve = "group-input", He = "group-output", Ue = "material-output
|
|
|
123
123
|
},
|
|
124
124
|
shader: { shader: "identity" }
|
|
125
125
|
};
|
|
126
|
-
function
|
|
127
|
-
return
|
|
126
|
+
function $e(e, t) {
|
|
127
|
+
return Qe[e]?.[t];
|
|
128
128
|
}
|
|
129
129
|
//#endregion
|
|
130
130
|
//#region src/tsl/blender-noise.ts
|
|
131
|
-
var
|
|
132
|
-
function
|
|
133
|
-
let r = 3735928584, i =
|
|
134
|
-
return o.assign(o.add(n)), a.assign(a.add(t)), i.assign(i.add(e)), o.assign(o.bitXor(a)), o.assign(o.sub(
|
|
131
|
+
var et = (e, t) => e.shiftLeft(t).bitOr(e.shiftRight(32 - t));
|
|
132
|
+
function tt(e, t, n) {
|
|
133
|
+
let r = 3735928584, i = H(r).toVar(), a = H(r).toVar(), o = H(r).toVar();
|
|
134
|
+
return o.assign(o.add(n)), a.assign(a.add(t)), i.assign(i.add(e)), o.assign(o.bitXor(a)), o.assign(o.sub(et(a, 14))), i.assign(i.bitXor(o)), i.assign(i.sub(et(o, 11))), a.assign(a.bitXor(i)), a.assign(a.sub(et(i, 25))), o.assign(o.bitXor(a)), o.assign(o.sub(et(a, 16))), i.assign(i.bitXor(o)), i.assign(i.sub(et(o, 4))), a.assign(a.bitXor(i)), a.assign(a.sub(et(i, 14))), o.assign(o.bitXor(a)), o.assign(o.sub(et(a, 24))), o;
|
|
135
135
|
}
|
|
136
|
-
var
|
|
137
|
-
function
|
|
138
|
-
let i = e.bitAnd(
|
|
139
|
-
return
|
|
136
|
+
var nt = (e, t, n) => tt(H(e), H(t), H(n)), rt = (e) => e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10)), it = (e, t) => R(t.notEqual(H(0)), e.negate(), e);
|
|
137
|
+
function at(e, t, n, r) {
|
|
138
|
+
let i = e.bitAnd(H(15)).toVar(), a = R(i.lessThan(H(8)), t, n), o = R(i.equal(H(12)).or(i.equal(H(14))), t, r), s = R(i.lessThan(H(4)), n, o);
|
|
139
|
+
return it(a, i.bitAnd(H(1))).add(it(s, i.bitAnd(H(2))));
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function ot(e, t, n, r) {
|
|
142
142
|
let i = k(1).sub(t), a = k(1).sub(n);
|
|
143
143
|
return k(1).sub(r).mul(a.mul(e[0].mul(i).add(e[1].mul(t))).add(n.mul(e[2].mul(i).add(e[3].mul(t))))).add(r.mul(a.mul(e[4].mul(i).add(e[5].mul(t))).add(n.mul(e[6].mul(i).add(e[7].mul(t))))));
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
let t = A(e.x).toVar(), n = A(e.y).toVar(), r = A(e.z).toVar(), i = e.x.sub(t).toVar(), a = e.y.sub(n).toVar(), o = e.z.sub(r).toVar(), s = M(t), c = M(n), l = M(r), u =
|
|
147
|
-
return
|
|
145
|
+
function st(e) {
|
|
146
|
+
let t = A(e.x).toVar(), n = A(e.y).toVar(), r = A(e.z).toVar(), i = e.x.sub(t).toVar(), a = e.y.sub(n).toVar(), o = e.z.sub(r).toVar(), s = M(t), c = M(n), l = M(r), u = rt(i), d = rt(a), f = rt(o), p = (e, t, n) => at(nt(s.add(e), c.add(t), l.add(n)), i.sub(e), a.sub(t), o.sub(n));
|
|
147
|
+
return ot([
|
|
148
148
|
p(0, 0, 0),
|
|
149
149
|
p(1, 0, 0),
|
|
150
150
|
p(0, 1, 0),
|
|
@@ -155,18 +155,18 @@ function tt(e) {
|
|
|
155
155
|
p(1, 1, 1)
|
|
156
156
|
], u, d, f);
|
|
157
157
|
}
|
|
158
|
-
var
|
|
159
|
-
function
|
|
158
|
+
var ct = (e) => st(e).mul(.982);
|
|
159
|
+
function lt(e, t, n, r) {
|
|
160
160
|
let i = Math.max(0, Math.min(15, Math.floor(t)));
|
|
161
|
-
return
|
|
161
|
+
return y(() => {
|
|
162
162
|
let t = k(1).toVar(), a = k(1).toVar(), o = k(0).toVar(), s = k(0).toVar();
|
|
163
|
-
for (let c = 0; c <= i; c++) o.assign(o.add(
|
|
163
|
+
for (let c = 0; c <= i; c++) o.assign(o.add(ct(e.mul(a)).mul(t))), s.assign(s.add(t)), t.assign(t.mul(n)), a.assign(a.mul(r));
|
|
164
164
|
return o.div(s).mul(.5).add(.5);
|
|
165
165
|
})();
|
|
166
166
|
}
|
|
167
167
|
//#endregion
|
|
168
168
|
//#region src/graph/nodes/texture/fbm.ts
|
|
169
|
-
var
|
|
169
|
+
var ut = {
|
|
170
170
|
type: "fbm",
|
|
171
171
|
nodeClass: "texture",
|
|
172
172
|
label: "Noise (FBM)",
|
|
@@ -217,9 +217,9 @@ var it = {
|
|
|
217
217
|
}
|
|
218
218
|
],
|
|
219
219
|
build(e) {
|
|
220
|
-
return { field:
|
|
220
|
+
return { field: lt((e.inputs.coord ?? e.coord).mul(e.live("scale")), e.constant("octaves") ?? 4, e.live("gain"), e.live("lacunarity")) };
|
|
221
221
|
}
|
|
222
|
-
},
|
|
222
|
+
}, dt = {
|
|
223
223
|
type: "domain-warp",
|
|
224
224
|
nodeClass: "vector",
|
|
225
225
|
label: "Domain Warp",
|
|
@@ -249,144 +249,144 @@ var it = {
|
|
|
249
249
|
default: 1
|
|
250
250
|
}],
|
|
251
251
|
build(e) {
|
|
252
|
-
let t = e.inputs.coord ?? e.coord, n = t.div(e.live("scale")), r =
|
|
253
|
-
return { coord: t.add(
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
let n = A(e.xyxy).add(
|
|
257
|
-
f = f.mul(
|
|
258
|
-
let
|
|
259
|
-
return
|
|
252
|
+
let t = e.inputs.coord ?? e.coord, n = t.div(e.live("scale")), r = ge(n.add(G(11.3, 0, 0))), i = ge(n.add(G(0, 47.7, 0))), a = ge(n.add(G(0, 0, 93.1)));
|
|
253
|
+
return { coord: t.add(G(r, i, a).mul(e.live("amount"))) };
|
|
254
|
+
}
|
|
255
|
+
}, ft = (e) => I(e.mul(34).add(1).mul(e), 289), pt = (e) => e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10)), mt = y(([e, t]) => {
|
|
256
|
+
let n = A(e.xyxy).add(Re(0, 0, 1, 1)), r = j(e.xyxy).sub(Re(0, 0, 1, 1)), i = I(I(n, t.xyxy), 289), a = i.xzxz, o = i.yyww, s = r.xzxz, c = r.yyww, l = j(ft(ft(a).add(o)).mul(.0243902439)).mul(2).sub(1), u = b(l).sub(.5), d = l.sub(A(l.add(.5))), f = W(d.x, u.x), p = W(d.y, u.y), m = W(d.z, u.z), h = W(d.w, u.w), g = k(1.79284291400159).sub(k(.85373472095314).mul(Re(O(f, f), O(m, m), O(p, p), O(h, h))));
|
|
257
|
+
f = f.mul(g.x), m = m.mul(g.y), p = p.mul(g.z), h = h.mul(g.w);
|
|
258
|
+
let _ = O(f, W(s.x, c.x)), v = O(p, W(s.y, c.y)), y = O(m, W(s.z, c.z)), x = O(h, W(s.w, c.w)), S = pt(r.xy), C = F(W(_, y), W(v, x), S.x);
|
|
259
|
+
return F(C.x, C.y, S.y).mul(2.3);
|
|
260
260
|
});
|
|
261
|
-
function
|
|
262
|
-
let s = typeof t == "number" ? k(Math.max(1, Math.round(t))) : t, c = typeof n == "number" ? k(Math.max(1, Math.round(n))) : n, l =
|
|
261
|
+
function ht(e, t, n, r, i, a, o = 2) {
|
|
262
|
+
let s = typeof t == "number" ? k(Math.max(1, Math.round(t))) : t, c = typeof n == "number" ? k(Math.max(1, Math.round(n))) : n, l = de(e), u = k(0), d = k(0), f = k(1), p = Math.max(2, Math.round(o));
|
|
263
263
|
for (let t = 0; t < Math.max(1, r); t++) {
|
|
264
|
-
let n = Math.round(p ** +t), r =
|
|
264
|
+
let n = Math.round(p ** +t), r = W(s.mul(n), c.mul(n)), o = f;
|
|
265
265
|
if (a !== void 0) {
|
|
266
|
-
let e =
|
|
267
|
-
o = f.mul(
|
|
266
|
+
let e = N(r.x.mul(l.x), r.y.mul(l.y)), t = T(k(1).sub(B(.2, .5, e)), 0, 1);
|
|
267
|
+
o = f.mul(F(k(1), t, a));
|
|
268
268
|
}
|
|
269
|
-
u = u.add(o.mul(
|
|
269
|
+
u = u.add(o.mul(mt(e.mul(r), r))), d = d.add(o), f = f.mul(i);
|
|
270
270
|
}
|
|
271
|
-
return
|
|
271
|
+
return F(k(0), u.div(d.max(1e-4)), P(d, 1));
|
|
272
272
|
}
|
|
273
273
|
//#endregion
|
|
274
274
|
//#region src/tsl/noise/fbm.ts
|
|
275
|
-
function
|
|
276
|
-
let c = typeof t == "number" ? k(Math.max(1, Math.round(t))) : t, l = typeof n == "number" ? k(Math.max(1, Math.round(n))) : n, u =
|
|
275
|
+
function gt(e, t, n, r, i, a, o, s = 2) {
|
|
276
|
+
let c = typeof t == "number" ? k(Math.max(1, Math.round(t))) : t, l = typeof n == "number" ? k(Math.max(1, Math.round(n))) : n, u = de(e), d = k(0), f = k(0), p = k(1), m = Math.max(2, Math.round(s));
|
|
277
277
|
for (let t = 0; t < Math.max(1, r); t++) {
|
|
278
|
-
let n = Math.round(m ** +t), r = c.mul(n), s = l.mul(n), h = e.mul(
|
|
278
|
+
let n = Math.round(m ** +t), r = c.mul(n), s = l.mul(n), h = e.mul(W(r, s)), g = p;
|
|
279
279
|
if (o !== void 0) {
|
|
280
|
-
let e =
|
|
281
|
-
g = p.mul(
|
|
280
|
+
let e = N(r.mul(u.x), s.mul(u.y)), t = T(k(1).sub(B(.2, .5, e)), 0, 1);
|
|
281
|
+
g = p.mul(F(k(1), t, o));
|
|
282
282
|
}
|
|
283
283
|
d = d.add(g.mul(a(h, r, s))), f = f.add(g), p = p.mul(i);
|
|
284
284
|
}
|
|
285
|
-
return
|
|
285
|
+
return F(k(.5), d.div(f.max(1e-4)), P(f, 1));
|
|
286
286
|
}
|
|
287
287
|
//#endregion
|
|
288
288
|
//#region src/tsl/noise/hash.ts
|
|
289
|
-
var
|
|
289
|
+
var _t = 1 / 2147483648, vt = y(([e, t, n]) => {
|
|
290
290
|
let r = e.mul(1664525).add(1013904223).toVar(), i = t.mul(1664525).add(1013904223).toVar(), a = n.mul(1664525).add(1013904223).toVar();
|
|
291
291
|
r.assign(r.add(i.mul(a))), i.assign(i.add(a.mul(r))), a.assign(a.add(r.mul(i))), r.assign(r.bitXor(r.shiftRight(16))), i.assign(i.bitXor(i.shiftRight(16))), a.assign(a.bitXor(a.shiftRight(16))), r.assign(r.add(i.mul(a))), i.assign(i.add(a.mul(r))), a.assign(a.add(r.mul(i)));
|
|
292
292
|
let o = M(2147483647);
|
|
293
|
-
return
|
|
293
|
+
return G(k(r.bitAnd(o)).mul(_t), k(i.bitAnd(o)).mul(_t), k(a.bitAnd(o)).mul(_t));
|
|
294
294
|
});
|
|
295
|
-
function
|
|
295
|
+
function yt(e, t) {
|
|
296
296
|
return typeof t == "number" && t <= 0 ? e : e.sub(M(A(k(e).div(t))).mul(M(t)));
|
|
297
297
|
}
|
|
298
|
-
function
|
|
299
|
-
return
|
|
298
|
+
function bt(e, t, n, r) {
|
|
299
|
+
return vt(yt(e, n), yt(t, r), M(0)).x;
|
|
300
300
|
}
|
|
301
|
-
function
|
|
302
|
-
return
|
|
301
|
+
function xt(e, t, n, r) {
|
|
302
|
+
return vt(yt(e, n), yt(t, r), M(0));
|
|
303
303
|
}
|
|
304
|
-
function
|
|
305
|
-
return
|
|
304
|
+
function K(e, t, n, r, i) {
|
|
305
|
+
return vt(yt(e, r), yt(t, i), M(n));
|
|
306
306
|
}
|
|
307
307
|
//#endregion
|
|
308
308
|
//#region src/tsl/noise/value.ts
|
|
309
|
-
function
|
|
310
|
-
let r = A(e), i = e.sub(r), a = i.mul(i).mul(k(3).sub(i.mul(2))), o = M(r.x), s = M(r.y), c =
|
|
311
|
-
return
|
|
309
|
+
function St(e, t, n) {
|
|
310
|
+
let r = A(e), i = e.sub(r), a = i.mul(i).mul(k(3).sub(i.mul(2))), o = M(r.x), s = M(r.y), c = bt(o, s, t, n), l = bt(o.add(1), s, t, n), u = bt(o, s.add(1), t, n), d = bt(o.add(1), s.add(1), t, n);
|
|
311
|
+
return F(F(c, l, a.x), F(u, d, a.x), a.y);
|
|
312
312
|
}
|
|
313
313
|
//#endregion
|
|
314
314
|
//#region src/tsl/noise/cellular.ts
|
|
315
|
-
var
|
|
316
|
-
function
|
|
317
|
-
let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s =
|
|
315
|
+
var Ct = 2;
|
|
316
|
+
function wt(e, t, n) {
|
|
317
|
+
let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s = G(i.x, i.y, k(0)), c = k(1e10);
|
|
318
318
|
for (let e = -1; e <= 1; e++) for (let r = -1; r <= 1; r++) {
|
|
319
|
-
let i =
|
|
320
|
-
c =
|
|
319
|
+
let i = xt(a.add(e), o.add(r), t, n), l = G(k(e).add(i.x), k(r).add(i.y), i.z);
|
|
320
|
+
c = P(c, pe(l.sub(s)));
|
|
321
321
|
}
|
|
322
|
-
return
|
|
322
|
+
return T(k(1).sub(c), 0, 1);
|
|
323
323
|
}
|
|
324
|
-
function
|
|
324
|
+
function Tt(e, t, n) {
|
|
325
325
|
let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s = k(0), c = k(0);
|
|
326
326
|
for (let e = -1; e <= 1; e++) for (let r = -1; r <= 1; r++) {
|
|
327
|
-
let l =
|
|
327
|
+
let l = xt(a.add(e), o.add(r), t, n), u = L(B(1.414, 0, pe(W(e, r).sub(i).add(W(l.x, l.y)))), Ct);
|
|
328
328
|
s = s.add(l.z.mul(u)), c = c.add(u);
|
|
329
329
|
}
|
|
330
330
|
return s.div(c.max(1e-4));
|
|
331
331
|
}
|
|
332
332
|
//#endregion
|
|
333
333
|
//#region src/tsl/noise/flow.ts
|
|
334
|
-
var
|
|
335
|
-
let n = k(.1), r =
|
|
336
|
-
return
|
|
334
|
+
var Et = (e, t) => mt(e, W(t, t)), Dt = y(([e, t]) => {
|
|
335
|
+
let n = k(.1), r = Et(e.add(W(n, 0)), t), i = Et(e.add(W(0, n)), t), a = Et(e.sub(W(n, 0)), t), o = Et(e.sub(W(0, n)), t);
|
|
336
|
+
return W(r.sub(a), i.sub(o)).div(n).mul(.5);
|
|
337
337
|
});
|
|
338
|
-
function
|
|
339
|
-
let r =
|
|
340
|
-
return
|
|
338
|
+
function Ot(e, t, n) {
|
|
339
|
+
let r = Dt(e, t);
|
|
340
|
+
return G(r.x, r.y, k(0));
|
|
341
341
|
}
|
|
342
|
-
function
|
|
343
|
-
return
|
|
342
|
+
function kt(e, t, n) {
|
|
343
|
+
return T(Dt(e, t).length().mul(.6).add(.2), 0, 1);
|
|
344
344
|
}
|
|
345
|
-
function
|
|
346
|
-
let r =
|
|
347
|
-
return
|
|
345
|
+
function At(e, t, n) {
|
|
346
|
+
let r = Dt(e, t);
|
|
347
|
+
return T(N(b(r.x), b(r.y)), 0, 1);
|
|
348
348
|
}
|
|
349
|
-
function
|
|
350
|
-
let r =
|
|
351
|
-
return
|
|
349
|
+
function jt(e, t, n) {
|
|
350
|
+
let r = Dt(e, t).mul(.4);
|
|
351
|
+
return Et(e.add(r), t).mul(.5).add(.5);
|
|
352
352
|
}
|
|
353
353
|
//#endregion
|
|
354
354
|
//#region src/tsl/noise/gabor.ts
|
|
355
|
-
var
|
|
355
|
+
var Mt = 6.283185307179586, Nt = Math.PI, Pt = 8, Ft = y(([e, t, n, r, i]) => {
|
|
356
356
|
let a = e.mul(t), o = A(a), s = a.sub(o), c = k(0).toVar();
|
|
357
357
|
for (let e = -1; e <= 1; e++) for (let a = -1; a <= 1; a++) {
|
|
358
|
-
let l = M(o.x).add(a), u = M(o.y).add(e), d = s.sub(
|
|
359
|
-
for (let e = 0; e <
|
|
360
|
-
let a =
|
|
361
|
-
c.addAssign(
|
|
358
|
+
let l = M(o.x).add(a), u = M(o.y).add(e), d = s.sub(W(a, e));
|
|
359
|
+
for (let e = 0; e < Pt; e++) {
|
|
360
|
+
let a = K(l, u, e * 2, t, t), o = K(l, u, e * 2 + 1, t, t), s = i.add(o.x.sub(.5).mul(Nt).mul(r)), f = d.sub(W(a.x, a.y)), p = O(f, f), m = ce(p.mul(-Nt)).mul(k(.5).add(E(p.mul(Nt)).mul(.5))), h = O(f, W(E(s), z(s)).mul(n)).mul(Mt), g = F(k(-1), k(1), Me(.5, a.z)), _ = k(1).sub(Me(1, p));
|
|
361
|
+
c.addAssign(z(h).mul(m).mul(g).mul(_));
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
return c.div(6).mul(.5).add(.5);
|
|
365
365
|
});
|
|
366
366
|
//#endregion
|
|
367
367
|
//#region src/tsl/noise/simplex.ts
|
|
368
|
-
function
|
|
369
|
-
let r =
|
|
370
|
-
v =
|
|
371
|
-
let y = v.mul(.07482), b = E(y), x =
|
|
372
|
-
return
|
|
368
|
+
function It(e, t, n) {
|
|
369
|
+
let r = W(e.x.add(e.y.mul(.5)), e.y), i = A(r), a = r.sub(i), o = Me(a.y, a.x), s = W(o, k(1).sub(o)), c = W(i.x.sub(i.y.mul(.5)), i.y), l = W(c.x.add(s.x).sub(s.y.mul(.5)), c.y.add(s.y)), u = W(c.x.add(.5), c.y.add(1)), d = e.sub(c), f = e.sub(l), p = e.sub(u), m = I(G(c.x, l.x, u.x), k(t)), h = I(G(c.y, l.y, u.y), k(n)), g = A(m.add(h.mul(.5)).add(.5)), _ = A(h.add(.5)), v = I(g, 289);
|
|
370
|
+
v = I(v.mul(51).add(2).mul(v).add(_), 289), v = I(v.mul(34).add(10).mul(v), 289);
|
|
371
|
+
let y = v.mul(.07482), b = E(y), x = z(y), S = W(b.x, x.x), C = W(b.y, x.y), w = W(b.z, x.z), ee = N(k(.8).sub(G(O(d, d), O(f, f), O(p, p))), 0), te = ee.mul(ee);
|
|
372
|
+
return T(O(te.mul(te), G(O(S, d), O(C, f), O(w, p))).mul(10.9).mul(.5).add(.5), 0, 1);
|
|
373
373
|
}
|
|
374
374
|
//#endregion
|
|
375
375
|
//#region src/tsl/noise/wavelet.ts
|
|
376
|
-
var
|
|
377
|
-
function
|
|
378
|
-
let r = A(e), i = j(e).sub(.5), a =
|
|
379
|
-
return
|
|
376
|
+
var Lt = 6.283185307179586;
|
|
377
|
+
function Rt(e, t, n) {
|
|
378
|
+
let r = A(e), i = j(e).sub(.5), a = bt(M(r.x), M(r.y), t, n).mul(Lt), o = E(a), s = z(a), c = o.mul(i.x).sub(s.mul(i.y)), l = s.mul(i.x).add(o.mul(i.y)), u = B(.25, 0, O(W(c, l), W(c, l)));
|
|
379
|
+
return T(z(c.mul(10)).mul(u).mul(.5).add(.5), 0, 1);
|
|
380
380
|
}
|
|
381
381
|
//#endregion
|
|
382
382
|
//#region src/tsl/noise/erosion.ts
|
|
383
|
-
function
|
|
384
|
-
let r =
|
|
385
|
-
return
|
|
383
|
+
function zt(e, t, n) {
|
|
384
|
+
let r = Dt(e, t), i = mt(e.add(r.mul(.6)), W(t, t)).mul(.5).add(.5);
|
|
385
|
+
return T(k(1).sub(i.mul(2).sub(1).abs()), 0, 1);
|
|
386
386
|
}
|
|
387
387
|
//#endregion
|
|
388
388
|
//#region src/graph/nodes/texture/tileable-noise.ts
|
|
389
|
-
var
|
|
389
|
+
var Bt = [
|
|
390
390
|
"perlin-fbm",
|
|
391
391
|
"value",
|
|
392
392
|
"worley",
|
|
@@ -394,30 +394,30 @@ var Pt = [
|
|
|
394
394
|
"gabor",
|
|
395
395
|
"simplex",
|
|
396
396
|
"wavelet"
|
|
397
|
-
],
|
|
397
|
+
], Vt = [
|
|
398
398
|
"none",
|
|
399
399
|
"curl",
|
|
400
400
|
"paper",
|
|
401
401
|
"wool",
|
|
402
402
|
"stone",
|
|
403
403
|
"erosion"
|
|
404
|
-
],
|
|
404
|
+
], q = [
|
|
405
405
|
"octaves",
|
|
406
406
|
"gain",
|
|
407
407
|
"lacunarity",
|
|
408
408
|
"antialias",
|
|
409
409
|
"tileSize"
|
|
410
|
-
],
|
|
411
|
-
"perlin-fbm": ["aspect", ...
|
|
412
|
-
value: ["aspect", ...
|
|
413
|
-
worley:
|
|
414
|
-
"voronoi-smooth":
|
|
415
|
-
stone:
|
|
416
|
-
paper:
|
|
417
|
-
wool:
|
|
418
|
-
simplex:
|
|
419
|
-
wavelet:
|
|
420
|
-
erosion:
|
|
410
|
+
], Ht = {
|
|
411
|
+
"perlin-fbm": ["aspect", ...q],
|
|
412
|
+
value: ["aspect", ...q],
|
|
413
|
+
worley: q,
|
|
414
|
+
"voronoi-smooth": q,
|
|
415
|
+
stone: q,
|
|
416
|
+
paper: q,
|
|
417
|
+
wool: q,
|
|
418
|
+
simplex: q,
|
|
419
|
+
wavelet: q,
|
|
420
|
+
erosion: q,
|
|
421
421
|
gabor: [
|
|
422
422
|
"gaborFreq",
|
|
423
423
|
"gaborAniso",
|
|
@@ -425,25 +425,25 @@ var Pt = [
|
|
|
425
425
|
"tileSize"
|
|
426
426
|
],
|
|
427
427
|
curl: []
|
|
428
|
-
},
|
|
429
|
-
value:
|
|
430
|
-
worley:
|
|
431
|
-
"voronoi-smooth":
|
|
432
|
-
stone:
|
|
433
|
-
paper:
|
|
434
|
-
wool:
|
|
435
|
-
wavelet:
|
|
436
|
-
erosion:
|
|
437
|
-
},
|
|
428
|
+
}, Ut = {
|
|
429
|
+
value: St,
|
|
430
|
+
worley: wt,
|
|
431
|
+
"voronoi-smooth": Tt,
|
|
432
|
+
stone: jt,
|
|
433
|
+
paper: kt,
|
|
434
|
+
wool: At,
|
|
435
|
+
wavelet: Rt,
|
|
436
|
+
erosion: zt
|
|
437
|
+
}, Wt = [{
|
|
438
438
|
key: "field",
|
|
439
439
|
kind: "float"
|
|
440
|
-
}],
|
|
440
|
+
}], Gt = [{
|
|
441
441
|
key: "field",
|
|
442
442
|
kind: "float"
|
|
443
443
|
}, {
|
|
444
444
|
key: "vector",
|
|
445
445
|
kind: "vector"
|
|
446
|
-
}],
|
|
446
|
+
}], Kt = {
|
|
447
447
|
type: "tileable-noise",
|
|
448
448
|
nodeClass: "texture",
|
|
449
449
|
label: "Tileable Noise",
|
|
@@ -461,14 +461,14 @@ var Pt = [
|
|
|
461
461
|
key: "noiseType",
|
|
462
462
|
label: "algorithm",
|
|
463
463
|
type: "select",
|
|
464
|
-
options:
|
|
464
|
+
options: Bt,
|
|
465
465
|
default: "perlin-fbm"
|
|
466
466
|
},
|
|
467
467
|
{
|
|
468
468
|
key: "preset",
|
|
469
469
|
label: "preset",
|
|
470
470
|
type: "select",
|
|
471
|
-
options:
|
|
471
|
+
options: Vt,
|
|
472
472
|
default: "none"
|
|
473
473
|
},
|
|
474
474
|
{
|
|
@@ -573,84 +573,84 @@ var Pt = [
|
|
|
573
573
|
key: "coord",
|
|
574
574
|
kind: "vector"
|
|
575
575
|
}],
|
|
576
|
-
outputs: e.noiseType === "perlin-fbm" && e.preset === "curl" ?
|
|
576
|
+
outputs: e.noiseType === "perlin-fbm" && e.preset === "curl" ? Gt : Wt
|
|
577
577
|
};
|
|
578
578
|
},
|
|
579
579
|
paramsFor(e) {
|
|
580
|
-
let t = e.noiseType ?? "perlin-fbm", n = e.preset ?? "none", r =
|
|
580
|
+
let t = e.noiseType ?? "perlin-fbm", n = e.preset ?? "none", r = Ht[t === "perlin-fbm" && n !== "none" ? n : t] ?? [], i = new Set([
|
|
581
581
|
"noiseType",
|
|
582
582
|
"scale",
|
|
583
583
|
...r
|
|
584
584
|
]);
|
|
585
|
-
return t === "perlin-fbm" && i.add("preset"),
|
|
585
|
+
return t === "perlin-fbm" && i.add("preset"), Kt.params.filter((e) => i.has(e.key));
|
|
586
586
|
},
|
|
587
587
|
build(e) {
|
|
588
588
|
let t = e.inputs.coord ?? e.coord, n = Math.max(1, Math.round(Number.isFinite(Number(e.constant("octaves"))) ? Number(e.constant("octaves")) : 4)), r = e.constant("noiseType") ?? "perlin-fbm", i = e.constant("preset") ?? "none", a = r === "perlin-fbm" && i !== "none" ? i : r, o = e.live("gain"), s = e.live("scale");
|
|
589
|
-
if (e.backend === "live") return { field:
|
|
590
|
-
let c = Math.max(2, Math.round(Number.isFinite(Number(e.constant("lacunarity"))) ? Number(e.constant("lacunarity")) : 2)), l =
|
|
589
|
+
if (e.backend === "live") return { field: lt(t.mul(s), n, o, e.live("lacunarity")) };
|
|
590
|
+
let c = Math.max(2, Math.round(Number.isFinite(Number(e.constant("lacunarity"))) ? Number(e.constant("lacunarity")) : 2)), l = W(t.x, t.y), u = e.live("antialias"), d = Math.max(1, Math.round(e.tileRepeat ?? 1)), f = N(A((d > 1 ? s.div(k(d)) : s).add(.5)), k(1)), p = e.live("aspect"), m = N(A(f.mul(p).add(.5)), k(1));
|
|
591
591
|
if (a === "curl") {
|
|
592
|
-
let e =
|
|
592
|
+
let e = Ot(l.mul(f), f, f);
|
|
593
593
|
return {
|
|
594
594
|
field: e.length(),
|
|
595
595
|
vector: e
|
|
596
596
|
};
|
|
597
597
|
}
|
|
598
598
|
if (a === "simplex") {
|
|
599
|
-
let e = f.add(
|
|
600
|
-
return { field:
|
|
599
|
+
let e = f.add(I(f, k(2)));
|
|
600
|
+
return { field: gt(l, e, e, n, o, It, u, c) };
|
|
601
601
|
}
|
|
602
602
|
if (a === "gabor") {
|
|
603
603
|
let t = k(1).sub(e.live("gaborAniso"));
|
|
604
|
-
return { field:
|
|
604
|
+
return { field: Ft(l, f, e.live("gaborFreq"), t, e.live("gaborOrient")) };
|
|
605
605
|
}
|
|
606
|
-
let h =
|
|
607
|
-
return h ? { field:
|
|
606
|
+
let h = Ut[a];
|
|
607
|
+
return h ? { field: gt(l, a === "value" ? m : f, f, n, o, h, u, c) } : { field: ht(l, m, f, n, o, u, c).mul(.5).add(.5) };
|
|
608
608
|
}
|
|
609
|
-
},
|
|
610
|
-
function
|
|
611
|
-
let t =
|
|
612
|
-
return k(t.x.bitXor(t.y).mul(
|
|
609
|
+
}, qt = 4294967295;
|
|
610
|
+
function Jt(e) {
|
|
611
|
+
let t = ue(e.mul(W(141421356, 2718281828)));
|
|
612
|
+
return k(t.x.bitXor(t.y).mul(H(3141592653))).div(qt);
|
|
613
613
|
}
|
|
614
|
-
function
|
|
615
|
-
return j(k(52.9829189).mul(j(O(e,
|
|
614
|
+
function Yt(e) {
|
|
615
|
+
return j(k(52.9829189).mul(j(O(e, W(.06711056, .00583715)))));
|
|
616
616
|
}
|
|
617
|
-
function
|
|
618
|
-
let t =
|
|
619
|
-
return k(t.mul(
|
|
617
|
+
function Xt(e) {
|
|
618
|
+
let t = H(e.x), n = H(e.y);
|
|
619
|
+
return k(t.mul(H(3242174889)).add(n.mul(H(2447445413)))).mul(le(-32));
|
|
620
620
|
}
|
|
621
|
-
function
|
|
621
|
+
function Zt(e) {
|
|
622
622
|
let t = k(0);
|
|
623
|
-
for (let n = 0; n < 9; n++) t = t.add(
|
|
624
|
-
return k(.9).mul(k(1.125).mul(
|
|
623
|
+
for (let n = 0; n < 9; n++) t = t.add(Jt(e.add(W(n % 3 - 1, Math.floor(n / 3) - 1))));
|
|
624
|
+
return k(.9).mul(k(1.125).mul(Jt(e)).sub(t.div(8))).add(.5);
|
|
625
625
|
}
|
|
626
|
-
var
|
|
626
|
+
var Qt = y(([e, t]) => {
|
|
627
627
|
let n = e.toVar(), r = t.toVar(), i = M(0).toVar();
|
|
628
628
|
for (let e = 256; e > 0; e >>= 1) {
|
|
629
|
-
let t = M(e), a =
|
|
629
|
+
let t = M(e), a = R(n.bitAnd(t).notEqual(M(0)), M(1), M(0)), o = R(r.bitAnd(t).notEqual(M(0)), M(1), M(0));
|
|
630
630
|
i.assign(i.add(t.mul(t).mul(a.shiftLeft(1).bitOr(a.bitXor(o)))));
|
|
631
631
|
let s = n.bitXor(r).mul(M(1).sub(o)).bitXor(M(e - 1).mul(a.bitAnd(M(1).sub(o))));
|
|
632
632
|
n.assign(n.bitXor(s)), r.assign(r.bitXor(s));
|
|
633
633
|
}
|
|
634
634
|
return i;
|
|
635
635
|
});
|
|
636
|
-
function
|
|
637
|
-
let t =
|
|
636
|
+
function $t(e) {
|
|
637
|
+
let t = Qt(M(e.x), M(e.y));
|
|
638
638
|
return j(k(.6180339887498948).mul(k(t.mod(M(262144)))));
|
|
639
639
|
}
|
|
640
|
-
var
|
|
640
|
+
var en = y(([e, t]) => {
|
|
641
641
|
let n = A(e).toVar(), r = e.sub(n);
|
|
642
|
-
n.x.assign(A(
|
|
642
|
+
n.x.assign(A(z(n.x.mul(51024)).mul(3104))), n.y.assign(A(z(n.y.mul(1324)).mul(554)));
|
|
643
643
|
let i = n.x.add(n.y);
|
|
644
|
-
r = r.mul(2).sub(1), r = r.mul(E(i)).add(
|
|
645
|
-
let a =
|
|
646
|
-
return o = k(.5).sub(o.mul(t)), o =
|
|
644
|
+
r = r.mul(2).sub(1), r = r.mul(E(i)).add(W(r.y.negate(), r.x).mul(z(i))), r = r.add(z(n.x.sub(n.y))), r = r.mul(.5).add(.5);
|
|
645
|
+
let a = z(n.x.add(r.y.mul(3.1415))).add(z(n.y.add(r.y.mul(3.1415)))).mul(.2), o = b(r.x.sub(.5).add(a));
|
|
646
|
+
return o = k(.5).sub(o.mul(t)), o = B(-2, de(o).mul(1.5).add(16), o).mul(12), o.mul(r.y);
|
|
647
647
|
});
|
|
648
|
-
function
|
|
648
|
+
function tn(e, t) {
|
|
649
649
|
let n = e, r = t, i = k(0);
|
|
650
|
-
for (let e = 0; e < 8; e++) i =
|
|
650
|
+
for (let e = 0; e < 8; e++) i = N(i, en(n, r)), n = W(n.x.sub(n.y.mul(.7)), n.x.mul(.7).add(n.y)).sub(12.31);
|
|
651
651
|
return i;
|
|
652
652
|
}
|
|
653
|
-
var
|
|
653
|
+
var nn = {
|
|
654
654
|
type: "screen-noise",
|
|
655
655
|
nodeClass: "texture",
|
|
656
656
|
label: "Screen Noise",
|
|
@@ -684,17 +684,17 @@ var Xt = {
|
|
|
684
684
|
default: 512
|
|
685
685
|
}],
|
|
686
686
|
build(e) {
|
|
687
|
-
let t = e.inputs.coord ?? e.coord, n =
|
|
688
|
-
if (r === "scratches") return { field:
|
|
687
|
+
let t = e.inputs.coord ?? e.coord, n = W(t.x, t.y), r = e.constant("noiseType") ?? "blue";
|
|
688
|
+
if (r === "scratches") return { field: tn(n.mul(5), k(3)) };
|
|
689
689
|
let i = n.mul(e.live("resolution"));
|
|
690
690
|
switch (r) {
|
|
691
|
-
case "hilbert-blue": return { field:
|
|
692
|
-
case "ign": return { field:
|
|
693
|
-
case "golden-ign": return { field:
|
|
694
|
-
default: return { field:
|
|
691
|
+
case "hilbert-blue": return { field: $t(A(i)) };
|
|
692
|
+
case "ign": return { field: Yt(A(i)) };
|
|
693
|
+
case "golden-ign": return { field: Xt(A(i)) };
|
|
694
|
+
default: return { field: Zt(A(i)) };
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
|
-
},
|
|
697
|
+
}, rn = {
|
|
698
698
|
type: "tileable-warp",
|
|
699
699
|
nodeClass: "vector",
|
|
700
700
|
label: "Tileable Warp",
|
|
@@ -726,72 +726,72 @@ var Xt = {
|
|
|
726
726
|
build(e) {
|
|
727
727
|
let t = e.inputs.coord ?? e.coord, n = e.live("amount"), r = e.live("scale").round().clamp(1, 64);
|
|
728
728
|
if (e.backend === "live") {
|
|
729
|
-
let e = t.div(r), i =
|
|
730
|
-
return { coord: t.add(
|
|
729
|
+
let e = t.div(r), i = ge(e.add(G(11.3, 0, 0))), a = ge(e.add(G(0, 47.7, 0))), o = ge(e.add(G(0, 0, 93.1)));
|
|
730
|
+
return { coord: t.add(G(i, a, o).mul(n)) };
|
|
731
731
|
}
|
|
732
|
-
let i =
|
|
733
|
-
return { coord:
|
|
732
|
+
let i = W(t.x, t.y), a = W(r, r), o = mt(i.mul(r), a), s = mt(i.mul(r).add(W(5.2, 1.3)), a), c = i.add(W(o, s).mul(n));
|
|
733
|
+
return { coord: G(c.x, c.y, t.z) };
|
|
734
734
|
}
|
|
735
|
-
},
|
|
736
|
-
function
|
|
735
|
+
}, an = 1 / 2147483648;
|
|
736
|
+
function on(e, t, n) {
|
|
737
737
|
let r = e.mul(1664525).add(1013904223).toVar(), i = t.mul(1664525).add(1013904223).toVar(), a = n.mul(1664525).add(1013904223).toVar();
|
|
738
738
|
r.assign(r.add(i.mul(a))), i.assign(i.add(a.mul(r))), a.assign(a.add(r.mul(i))), r.assign(r.bitXor(r.shiftRight(16))), i.assign(i.bitXor(i.shiftRight(16))), a.assign(a.bitXor(a.shiftRight(16))), r.assign(r.add(i.mul(a))), i.assign(i.add(a.mul(r))), a.assign(a.add(r.mul(i)));
|
|
739
739
|
let o = M(2147483647);
|
|
740
|
-
return
|
|
740
|
+
return G(k(r.bitAnd(o)).mul(an), k(i.bitAnd(o)).mul(an), k(a.bitAnd(o)).mul(an));
|
|
741
741
|
}
|
|
742
|
-
function
|
|
742
|
+
function sn(e, t) {
|
|
743
743
|
return e.sub(M(A(k(e).div(t))).mul(M(t)));
|
|
744
744
|
}
|
|
745
|
-
function
|
|
746
|
-
return typeof r == "number" && r <= 0 ?
|
|
745
|
+
function cn(e, t, n, r) {
|
|
746
|
+
return typeof r == "number" && r <= 0 ? on(e, t, n) : on(sn(e, r), sn(t, r), sn(n, r));
|
|
747
747
|
}
|
|
748
|
-
function
|
|
748
|
+
function ln(e, t, n, r) {
|
|
749
749
|
let i = e.sub(t).abs();
|
|
750
750
|
if (n === 1) return i.x.add(i.y).add(i.z);
|
|
751
751
|
if (n === 2) return i.x.max(i.y.max(i.z));
|
|
752
752
|
if (n === 3) {
|
|
753
753
|
let e = r;
|
|
754
|
-
return
|
|
754
|
+
return L(L(i.x, e).add(L(i.y, e)).add(L(i.z, e)), k(1).div(e));
|
|
755
755
|
}
|
|
756
756
|
return e.sub(t).length();
|
|
757
757
|
}
|
|
758
|
-
function
|
|
759
|
-
return
|
|
760
|
-
let o = A(e), s = e.sub(o), c = M(o.x), l = M(o.y), u = M(o.z), d = k(1e10).toVar(), f =
|
|
758
|
+
function un(e, t, n, r, i, a) {
|
|
759
|
+
return y(() => {
|
|
760
|
+
let o = A(e), s = e.sub(o), c = M(o.x), l = M(o.y), u = M(o.z), d = k(1e10).toVar(), f = G(0, 0, 0).toVar(), p = G(0, 0, 0).toVar();
|
|
761
761
|
for (let e = -1; e <= 1; e++) for (let i = -1; i <= 1; i++) for (let o = -1; o <= 1; o++) {
|
|
762
|
-
let m =
|
|
762
|
+
let m = G(o, i, e), h = m.add(cn(c.add(o), l.add(i), u.add(e), a).mul(t)), g = ln(h, s, n, r), _ = g.lessThan(d);
|
|
763
763
|
d.assign(_.select(g, d)), f.assign(_.select(m, f)), p.assign(_.select(h, p));
|
|
764
764
|
}
|
|
765
|
-
return i === "color" ?
|
|
765
|
+
return i === "color" ? cn(c.add(M(f.x)), l.add(M(f.y)), u.add(M(f.z)), a) : i === "position" ? p.add(o) : d;
|
|
766
766
|
})();
|
|
767
767
|
}
|
|
768
|
-
function
|
|
769
|
-
return
|
|
770
|
-
let o = A(e), s = e.sub(o), c = M(o.x), l = M(o.y), u = M(o.z), d = k(1e10).toVar(), f = k(1e10).toVar(), p =
|
|
768
|
+
function dn(e, t, n, r, i, a) {
|
|
769
|
+
return y(() => {
|
|
770
|
+
let o = A(e), s = e.sub(o), c = M(o.x), l = M(o.y), u = M(o.z), d = k(1e10).toVar(), f = k(1e10).toVar(), p = G(0, 0, 0).toVar(), m = G(0, 0, 0).toVar(), h = G(0, 0, 0).toVar(), g = G(0, 0, 0).toVar();
|
|
771
771
|
for (let e = -1; e <= 1; e++) for (let i = -1; i <= 1; i++) for (let o = -1; o <= 1; o++) {
|
|
772
|
-
let _ =
|
|
773
|
-
f.assign(S), m.assign(C), g.assign(w), d.assign(
|
|
772
|
+
let _ = G(o, i, e), v = _.add(cn(c.add(o), l.add(i), u.add(e), a).mul(t)), y = ln(v, s, n, r), b = y.lessThan(d).toVar(), x = y.lessThan(f).toVar(), S = R(b, d, R(x, y, f)), C = R(b, p, R(x, _, m)), w = R(b, h, R(x, v, g)), ee = R(b, y, d), te = R(b, _, p), ne = R(b, v, h);
|
|
773
|
+
f.assign(S), m.assign(C), g.assign(w), d.assign(ee), p.assign(te), h.assign(ne);
|
|
774
774
|
}
|
|
775
|
-
return i === "color" ?
|
|
775
|
+
return i === "color" ? cn(c.add(M(m.x)), l.add(M(m.y)), u.add(M(m.z)), a) : i === "position" ? g.add(o) : f;
|
|
776
776
|
})();
|
|
777
777
|
}
|
|
778
|
-
var
|
|
779
|
-
function
|
|
780
|
-
return
|
|
781
|
-
let s = A(e), c = e.sub(s), l = M(s.x), u = M(s.y), d = M(s.z), f =
|
|
782
|
-
for (let e = -1; e <=
|
|
783
|
-
let s =
|
|
784
|
-
g.assign(
|
|
778
|
+
var fn = 1;
|
|
779
|
+
function pn(e, t, n, r, i, a, o) {
|
|
780
|
+
return y(() => {
|
|
781
|
+
let s = A(e), c = e.sub(s), l = M(s.x), u = M(s.y), d = M(s.z), f = N(i, k(1e-6)), p = k(0).toVar(), m = G(0, 0, 0).toVar(), h = G(0, 0, 0).toVar(), g = k(-1).toVar();
|
|
782
|
+
for (let e = -1; e <= fn; e++) for (let i = -1; i <= fn; i++) for (let a = -1; a <= fn; a++) {
|
|
783
|
+
let s = G(a, i, e), _ = cn(l.add(a), u.add(i), d.add(e), o), v = s.add(_.mul(t)), y = ln(v, c, n, r);
|
|
784
|
+
g.assign(R(g.equal(-1), k(1), B(0, 1, k(.5).add(p.sub(y).mul(.5).div(f)))));
|
|
785
785
|
let b = f.mul(g).mul(k(1).sub(g)).toVar();
|
|
786
|
-
p.assign(
|
|
786
|
+
p.assign(F(p, y, g).sub(b)), b.assign(b.div(k(1).add(f.mul(3)))), m.assign(F(m, _, g).sub(b)), h.assign(F(h, v, g).sub(b));
|
|
787
787
|
}
|
|
788
788
|
return a === "color" ? m : a === "position" ? h.add(s) : p;
|
|
789
789
|
})();
|
|
790
790
|
}
|
|
791
|
-
var
|
|
792
|
-
function
|
|
793
|
-
return
|
|
794
|
-
let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s = M(r.z), c = (e, r, c) =>
|
|
791
|
+
var mn = (e, t, n, r, i = 0) => un(e, t, n, r, "distance", i), hn = (e, t, n, r, i = 0) => un(e, t, n, r, "color", i), gn = (e, t, n, r, i = 0) => un(e, t, n, r, "position", i), _n = (e, t, n, r, i = 0) => dn(e, t, n, r, "distance", i), vn = (e, t, n, r, i = 0) => dn(e, t, n, r, "color", i), yn = (e, t, n, r, i = 0) => dn(e, t, n, r, "position", i), bn = (e, t, n, r, i, a = 0) => pn(e, t, n, r, i, "distance", a), xn = (e, t, n, r, i, a = 0) => pn(e, t, n, r, i, "color", a), Sn = (e, t, n, r, i, a = 0) => pn(e, t, n, r, i, "position", a);
|
|
792
|
+
function Cn(e, t, n = 0) {
|
|
793
|
+
return y(() => {
|
|
794
|
+
let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s = M(r.z), c = (e, r, c) => G(e, r, c).add(cn(a.add(e), o.add(r), s.add(c), n).mul(t)).sub(i), l = G(0, 0, 0).toVar(), u = k(1e10).toVar();
|
|
795
795
|
for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) for (let n = -1; n <= 1; n++) {
|
|
796
796
|
let r = c(n, t, e), i = r.dot(r), a = i.lessThan(u);
|
|
797
797
|
u.assign(a.select(i, u)), l.assign(a.select(r, l));
|
|
@@ -806,20 +806,20 @@ function _n(e, t, n = 0) {
|
|
|
806
806
|
}
|
|
807
807
|
//#endregion
|
|
808
808
|
//#region src/tsl/lloyd-points.ts
|
|
809
|
-
function
|
|
809
|
+
function wn(e, t, n) {
|
|
810
810
|
let r = Math.imul(e, 374761393) + Math.imul(t, 668265263) + Math.imul(n, 362437) >>> 0;
|
|
811
811
|
r = Math.imul(r ^ r >>> 13, 1274126177) >>> 0;
|
|
812
812
|
let i = (r & 65535) / 65536;
|
|
813
813
|
return r = Math.imul(r ^ r >>> 16, 2246822519) >>> 0, [i, (r >>> 8 & 65535) / 65536];
|
|
814
814
|
}
|
|
815
|
-
function
|
|
815
|
+
function Tn(e, t, n) {
|
|
816
816
|
let r = e - t;
|
|
817
817
|
return r -= n * Math.round(r / n), r;
|
|
818
818
|
}
|
|
819
|
-
function
|
|
819
|
+
function En(e, t, n, r = 0) {
|
|
820
820
|
let i = e * e, a = new Float64Array(i), o = new Float64Array(i);
|
|
821
821
|
for (let n = 0; n < e; n++) for (let i = 0; i < e; i++) {
|
|
822
|
-
let [s, c] =
|
|
822
|
+
let [s, c] = wn(i, n, r), l = n * e + i;
|
|
823
823
|
a[l] = i + .5 + (s - .5) * t, o[l] = n + .5 + (c - .5) * t;
|
|
824
824
|
}
|
|
825
825
|
let s = Math.max(64, e * 24);
|
|
@@ -830,10 +830,10 @@ function bn(e, t, n, r = 0) {
|
|
|
830
830
|
for (let i = 0; i < s; i++) {
|
|
831
831
|
let u = (i + .5) / s * e, d = Math.floor(u), f = Infinity, p = 0;
|
|
832
832
|
for (let t = -1; t <= 1; t++) for (let n = -1; n <= 1; n++) {
|
|
833
|
-
let r = ((d + n) % e + e) % e, i = ((l + t) % e + e) % e * e + r, s =
|
|
833
|
+
let r = ((d + n) % e + e) % e, i = ((l + t) % e + e) % e * e + r, s = Tn(a[i], u, e), m = Tn(o[i], c, e), h = s * s + m * m;
|
|
834
834
|
h < f && (f = h, p = i);
|
|
835
835
|
}
|
|
836
|
-
t[p] += a[p] +
|
|
836
|
+
t[p] += a[p] + Tn(u, a[p], e), n[p] += o[p] + Tn(c, o[p], e), r[p]++;
|
|
837
837
|
}
|
|
838
838
|
}
|
|
839
839
|
for (let s = 0; s < i; s++) r[s] > 0 && (a[s] = (t[s] / r[s] % e + e) % e, o[s] = (n[s] / r[s] % e + e) % e);
|
|
@@ -847,9 +847,9 @@ function bn(e, t, n, r = 0) {
|
|
|
847
847
|
}
|
|
848
848
|
//#endregion
|
|
849
849
|
//#region src/tsl/relaxed-voronoi.ts
|
|
850
|
-
function
|
|
851
|
-
return
|
|
852
|
-
let n = A(e), r = e.sub(n), i = M(n.x), a = M(n.y), o = (e, n) =>
|
|
850
|
+
function Dn(e, t) {
|
|
851
|
+
return y(() => {
|
|
852
|
+
let n = A(e), r = e.sub(n), i = M(n.x), a = M(n.y), o = (e, n) => G(e, n, 0).add(t(i.add(e), a.add(n))).sub(r), s = G(0, 0, 0).toVar(), c = k(1e10).toVar();
|
|
853
853
|
for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) {
|
|
854
854
|
let n = o(t, e), r = n.dot(n), i = r.lessThan(c);
|
|
855
855
|
c.assign(i.select(r, c)), s.assign(i.select(n, s));
|
|
@@ -862,9 +862,9 @@ function xn(e, t) {
|
|
|
862
862
|
return l;
|
|
863
863
|
})();
|
|
864
864
|
}
|
|
865
|
-
function
|
|
866
|
-
return
|
|
867
|
-
let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s = (e, n) =>
|
|
865
|
+
function On(e, t, n) {
|
|
866
|
+
return y(() => {
|
|
867
|
+
let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s = (e, n) => G(e, n, 0).add(t(a.add(e), o.add(n))).sub(i), c = k(1e10).toVar(), l = M(0).toVar(), u = M(0).toVar();
|
|
868
868
|
for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) {
|
|
869
869
|
let n = s(t, e), r = n.dot(n), i = r.lessThan(c);
|
|
870
870
|
c.assign(i.select(r, c)), l.assign(i.select(a.add(t), l)), u.assign(i.select(o.add(e), u));
|
|
@@ -874,17 +874,17 @@ function Sn(e, t, n) {
|
|
|
874
874
|
}
|
|
875
875
|
//#endregion
|
|
876
876
|
//#region src/graph/nodes/texture/voronoi.ts
|
|
877
|
-
var
|
|
877
|
+
var kn = [
|
|
878
878
|
"euclidean",
|
|
879
879
|
"manhattan",
|
|
880
880
|
"chebychev",
|
|
881
881
|
"minkowski"
|
|
882
|
-
],
|
|
882
|
+
], An = [
|
|
883
883
|
"f1",
|
|
884
884
|
"f2",
|
|
885
885
|
"smooth-f1",
|
|
886
886
|
"distance-to-edge"
|
|
887
|
-
],
|
|
887
|
+
], jn = [
|
|
888
888
|
{
|
|
889
889
|
key: "distance",
|
|
890
890
|
label: "Distance",
|
|
@@ -900,7 +900,7 @@ var Cn = [
|
|
|
900
900
|
label: "Position",
|
|
901
901
|
kind: "vector"
|
|
902
902
|
}
|
|
903
|
-
],
|
|
903
|
+
], Mn = [
|
|
904
904
|
{
|
|
905
905
|
key: "distance",
|
|
906
906
|
label: "Distance",
|
|
@@ -916,11 +916,11 @@ var Cn = [
|
|
|
916
916
|
label: "Random",
|
|
917
917
|
kind: "float"
|
|
918
918
|
}
|
|
919
|
-
],
|
|
919
|
+
], Nn = [{
|
|
920
920
|
key: "coord",
|
|
921
921
|
kind: "vector"
|
|
922
922
|
}];
|
|
923
|
-
function
|
|
923
|
+
function Pn(e) {
|
|
924
924
|
let t = Array(e);
|
|
925
925
|
for (let n = 0; n < e; n++) {
|
|
926
926
|
let e = Math.sin(n * 12.9898 + 78.233) * 43758.5453;
|
|
@@ -928,12 +928,12 @@ function On(e) {
|
|
|
928
928
|
}
|
|
929
929
|
return t;
|
|
930
930
|
}
|
|
931
|
-
var
|
|
931
|
+
var Fn = {
|
|
932
932
|
type: "voronoi",
|
|
933
933
|
nodeClass: "texture",
|
|
934
934
|
label: "Voronoi",
|
|
935
|
-
inputs:
|
|
936
|
-
outputs:
|
|
935
|
+
inputs: Nn,
|
|
936
|
+
outputs: jn,
|
|
937
937
|
params: [
|
|
938
938
|
{
|
|
939
939
|
key: "scale",
|
|
@@ -957,14 +957,14 @@ var kn = {
|
|
|
957
957
|
key: "metric",
|
|
958
958
|
label: "metric",
|
|
959
959
|
type: "select",
|
|
960
|
-
options:
|
|
960
|
+
options: kn,
|
|
961
961
|
default: "euclidean"
|
|
962
962
|
},
|
|
963
963
|
{
|
|
964
964
|
key: "feature",
|
|
965
965
|
label: "feature",
|
|
966
966
|
type: "select",
|
|
967
|
-
options:
|
|
967
|
+
options: An,
|
|
968
968
|
default: "f1"
|
|
969
969
|
},
|
|
970
970
|
{
|
|
@@ -1006,8 +1006,8 @@ var kn = {
|
|
|
1006
1006
|
],
|
|
1007
1007
|
declare(e) {
|
|
1008
1008
|
return {
|
|
1009
|
-
inputs:
|
|
1010
|
-
outputs: (e.feature ?? "f1") === "distance-to-edge" ?
|
|
1009
|
+
inputs: Nn,
|
|
1010
|
+
outputs: (e.feature ?? "f1") === "distance-to-edge" ? Mn : jn
|
|
1011
1011
|
};
|
|
1012
1012
|
},
|
|
1013
1013
|
paramsFor(e) {
|
|
@@ -1019,51 +1019,51 @@ var kn = {
|
|
|
1019
1019
|
]);
|
|
1020
1020
|
t === "minkowski" && i.add("exponent"), n === "smooth-f1" && i.add("smoothness"), n === "distance-to-edge" && (i.add("relax"), i.add("edgeWidth"));
|
|
1021
1021
|
let a = n === "distance-to-edge" && r > 0;
|
|
1022
|
-
return
|
|
1022
|
+
return Fn.params.filter((e) => i.has(e.key)).map((e) => a && (e.key === "scale" || e.key === "randomness") ? {
|
|
1023
1023
|
...e,
|
|
1024
1024
|
bakeStructural: !0
|
|
1025
1025
|
} : e);
|
|
1026
1026
|
},
|
|
1027
1027
|
build(e) {
|
|
1028
|
-
let t = e.backend === "offline", n = Math.max(0,
|
|
1028
|
+
let t = e.backend === "offline", n = Math.max(0, kn.indexOf(e.constant("metric"))), r = e.constant("feature") ?? "f1", i = e.inputs.coord ?? e.coord, a = Math.max(0, Math.round(Number(e.constant("relax") ?? 0)));
|
|
1029
1029
|
if (r === "distance-to-edge" && t && a > 0) {
|
|
1030
1030
|
let t = Math.max(1, Math.round(Number(e.constant("scale") ?? 1))), n = Math.min(64, t);
|
|
1031
1031
|
t > 64 && console.warn(`[voronoi] relaxed cells capped at scale 64 (requested ${t} exceeds the uniform-buffer limit); set relax = 0 for finer faithful cells.`);
|
|
1032
|
-
let r = Number(e.constant("randomness") ?? 1), o = i.mul(n), s = e.constantArray("seeds", () =>
|
|
1032
|
+
let r = Number(e.constant("randomness") ?? 1), o = i.mul(n), s = e.constantArray("seeds", () => En(n, r, a), "vec3"), c = (e) => e.sub(M(A(k(e).div(n))).mul(M(n))), l = (e, t) => s.element(c(t).mul(n).add(c(e))), u = e.constantArray("randoms", () => Pn(n * n), "float"), d = (e, t) => u.element(c(t).mul(n).add(c(e))), f = e.live("edgeWidth"), p = Dn(o, l);
|
|
1033
1033
|
return {
|
|
1034
1034
|
distance: p,
|
|
1035
|
-
edges:
|
|
1036
|
-
random:
|
|
1035
|
+
edges: B(k(0), f, p).oneMinus(),
|
|
1036
|
+
random: On(o, l, d)
|
|
1037
1037
|
};
|
|
1038
1038
|
}
|
|
1039
|
-
let o = e.live("randomness"), s = e.live("exponent"), c = e.live("smoothness"), l = e.live("edgeWidth"), u = e.live("scale"), d =
|
|
1039
|
+
let o = e.live("randomness"), s = e.live("exponent"), c = e.live("smoothness"), l = e.live("edgeWidth"), u = e.live("scale"), d = N(A(u.add(.5)), k(1)), f = i.mul(t ? d : u), p = t ? d : 0;
|
|
1040
1040
|
switch (r) {
|
|
1041
1041
|
case "distance-to-edge": {
|
|
1042
|
-
let e =
|
|
1042
|
+
let e = Cn(f, o, p);
|
|
1043
1043
|
return {
|
|
1044
1044
|
distance: e,
|
|
1045
|
-
edges:
|
|
1046
|
-
random:
|
|
1045
|
+
edges: B(k(0), l, e).oneMinus(),
|
|
1046
|
+
random: hn(f, o, n, s, p).x
|
|
1047
1047
|
};
|
|
1048
1048
|
}
|
|
1049
1049
|
case "f2": return {
|
|
1050
|
-
distance:
|
|
1051
|
-
color:
|
|
1052
|
-
position:
|
|
1050
|
+
distance: _n(f, o, n, s, p),
|
|
1051
|
+
color: vn(f, o, n, s, p),
|
|
1052
|
+
position: yn(f, o, n, s, p)
|
|
1053
1053
|
};
|
|
1054
1054
|
case "smooth-f1": return {
|
|
1055
|
-
distance:
|
|
1056
|
-
color:
|
|
1057
|
-
position:
|
|
1055
|
+
distance: bn(f, o, n, s, c, p),
|
|
1056
|
+
color: xn(f, o, n, s, c, p),
|
|
1057
|
+
position: Sn(f, o, n, s, c, p)
|
|
1058
1058
|
};
|
|
1059
1059
|
default: return {
|
|
1060
|
-
distance:
|
|
1061
|
-
color:
|
|
1062
|
-
position:
|
|
1060
|
+
distance: mn(f, o, n, s, p),
|
|
1061
|
+
color: hn(f, o, n, s, p),
|
|
1062
|
+
position: gn(f, o, n, s, p)
|
|
1063
1063
|
};
|
|
1064
1064
|
}
|
|
1065
1065
|
}
|
|
1066
|
-
},
|
|
1066
|
+
}, In = {
|
|
1067
1067
|
type: "checker",
|
|
1068
1068
|
nodeClass: "texture",
|
|
1069
1069
|
label: "Checker",
|
|
@@ -1115,60 +1115,60 @@ var kn = {
|
|
|
1115
1115
|
}
|
|
1116
1116
|
],
|
|
1117
1117
|
build(e) {
|
|
1118
|
-
let t = (e.inputs.coord ?? e.coord).mul(e.live("scale")), n =
|
|
1118
|
+
let t = (e.inputs.coord ?? e.coord).mul(e.live("scale")), n = I(A(t.x).add(A(t.y)).add(A(t.z)), 2).lessThan(1);
|
|
1119
1119
|
return {
|
|
1120
|
-
color:
|
|
1121
|
-
fac:
|
|
1120
|
+
color: R(n, e.inputs.color1 ?? e.live("color1"), e.inputs.color2 ?? e.live("color2")),
|
|
1121
|
+
fac: R(n, k(1), k(0))
|
|
1122
1122
|
};
|
|
1123
1123
|
}
|
|
1124
|
-
},
|
|
1125
|
-
function
|
|
1126
|
-
let { columns: r, rows: i, offsetFreq: a } = t, o =
|
|
1124
|
+
}, Ln = 6.283185307179586;
|
|
1125
|
+
function Rn(e, t, n) {
|
|
1126
|
+
let { columns: r, rows: i, offsetFreq: a } = t, o = W(e.x.mul(r), e.y.mul(i)), s = y(() => {
|
|
1127
1127
|
let e = A(o.y), t = k(-1e9).toVar(), s = k(0).toVar(), c = k(0).toVar(), l = k(0).toVar();
|
|
1128
1128
|
for (let u = -1; u <= 1; u++) {
|
|
1129
|
-
let d = e.add(u), f = M(d), p =
|
|
1129
|
+
let d = e.add(u), f = M(d), p = R(I(d, k(a)).notEqual(0), n.rowOffset, k(0)), m = A(o.x.sub(p));
|
|
1130
1130
|
for (let e = -1; e <= 1; e++) {
|
|
1131
|
-
let a = m.add(e), u = M(a), h =
|
|
1132
|
-
s.assign(
|
|
1131
|
+
let a = m.add(e), u = M(a), h = K(u, f, 0, r, i), g = K(u, f, 1, r, i), _ = h.x.sub(.5).mul(n.posRandom), v = h.y.sub(.5).mul(n.posRandom), y = a.add(.5).add(p).add(_), x = d.add(.5).add(v), S = o.x.sub(y).div(r), C = o.y.sub(x).div(i), w = g.x.sub(.5).mul(2).mul(n.rotRandom).mul(Ln * .5).negate(), ee = E(w), te = z(w), ne = ee.mul(S).sub(te.mul(C)), T = te.mul(S).add(ee.mul(C)), re = k(1).add(h.z.sub(.5).mul(2).mul(n.sizeRandom)), ie = k(.5).div(r).mul(re).sub(n.gap), D = k(.5).div(i).mul(re).sub(n.gap), ae = n.roundness.mul(P(ie, D)), oe = b(ne).sub(ie.sub(ae)), se = b(T).sub(D.sub(ae)), O = pe(W(N(oe, 0), N(se, 0))), ce = P(N(oe, se), 0), le = O.add(ce).sub(ae).negate(), ue = le.greaterThan(t);
|
|
1132
|
+
s.assign(R(ue, g.y, s)), c.assign(R(ue, a, c)), l.assign(R(ue, d, l)), t.assign(R(ue, le, t));
|
|
1133
1133
|
}
|
|
1134
1134
|
}
|
|
1135
|
-
return
|
|
1136
|
-
})(), c = s.x, l = s.y, u = s.z, d = s.w, f = M(u), p = M(d), m =
|
|
1135
|
+
return Re(B(0, n.edge.add(1e-5), t), s, c, l);
|
|
1136
|
+
})(), c = s.x, l = s.y, u = s.z, d = s.w, f = M(u), p = M(d), m = R(I(d, k(a)).notEqual(0), n.rowOffset, k(0)), h = K(f, p, 0, r, i), g = u.add(.5).add(m).add(h.x.sub(.5).mul(n.posRandom)), _ = d.add(.5).add(h.y.sub(.5).mul(n.posRandom));
|
|
1137
1137
|
return {
|
|
1138
1138
|
mask: c,
|
|
1139
1139
|
value: l,
|
|
1140
|
-
cellCoord:
|
|
1141
|
-
cellRandom:
|
|
1140
|
+
cellCoord: G(o.x.sub(g), o.y.sub(_), 0),
|
|
1141
|
+
cellRandom: K(f, p, 2, r, i)
|
|
1142
1142
|
};
|
|
1143
1143
|
}
|
|
1144
|
-
function
|
|
1145
|
-
let a = t, o = n, s =
|
|
1146
|
-
let t =
|
|
1144
|
+
function zn(e, t, n, r, i) {
|
|
1145
|
+
let a = t, o = n, s = y(() => {
|
|
1146
|
+
let t = W(e.x.mul(a), e.y.mul(o)), n = A(t.y), s = k(1e9).toVar(), c = k(0).toVar(), l = k(0).toVar(), u = k(0).toVar(), d = k(0).toVar(), f = k(0).toVar();
|
|
1147
1147
|
for (let r = -1; r <= 1; r++) {
|
|
1148
|
-
let i = n.add(r), p =
|
|
1148
|
+
let i = n.add(r), p = R(I(i, k(2)).notEqual(0), k(.5), k(0)), m = A(t.x.sub(p));
|
|
1149
1149
|
for (let t = -1; t <= 1; t++) {
|
|
1150
|
-
let n = m.add(t), r = n.add(.5).add(p).div(a), h = i.add(.5).div(o), g =
|
|
1151
|
-
s.assign(
|
|
1150
|
+
let n = m.add(t), r = n.add(.5).add(p).div(a), h = i.add(.5).div(o), g = pe(W(e.x.sub(r), e.y.sub(h))), _ = g.lessThan(s);
|
|
1151
|
+
s.assign(R(_, g, s)), c.assign(R(_, r, c)), l.assign(R(_, h, l)), d.assign(R(_, n, d)), f.assign(R(_, i, f)), u.assign(R(_, bt(M(n), M(i), a, o), u));
|
|
1152
1152
|
}
|
|
1153
1153
|
}
|
|
1154
1154
|
let p = k(1e9).toVar();
|
|
1155
1155
|
for (let r = -1; r <= 1; r++) {
|
|
1156
|
-
let i = n.add(r), s =
|
|
1156
|
+
let i = n.add(r), s = R(I(i, k(2)).notEqual(0), k(.5), k(0)), u = A(t.x.sub(s));
|
|
1157
1157
|
for (let t = -1; t <= 1; t++) {
|
|
1158
|
-
let n = u.add(t).add(.5).add(s).div(a), r = i.add(.5).div(o), d = n.sub(c), f = r.sub(l), m =
|
|
1159
|
-
p.assign(
|
|
1158
|
+
let n = u.add(t).add(.5).add(s).div(a), r = i.add(.5).div(o), d = n.sub(c), f = r.sub(l), m = pe(W(d, f)).add(1e-9), h = c.add(n).mul(.5), g = l.add(r).mul(.5), _ = h.sub(e.x).mul(d.div(m)).add(g.sub(e.y).mul(f.div(m))), v = m.lessThan(1e-4);
|
|
1159
|
+
p.assign(P(p, R(v, k(1e9), _)));
|
|
1160
1160
|
}
|
|
1161
1161
|
}
|
|
1162
|
-
return
|
|
1163
|
-
})(), c = s.x, l = s.y, u = s.z, d = s.w, f =
|
|
1162
|
+
return Re(B(r, r.add(i).add(1e-5), p), u, d, f);
|
|
1163
|
+
})(), c = s.x, l = s.y, u = s.z, d = s.w, f = R(I(d, k(2)).notEqual(0), k(.5), k(0)), p = u.add(.5).add(f).div(a), m = d.add(.5).div(o);
|
|
1164
1164
|
return {
|
|
1165
1165
|
mask: c,
|
|
1166
1166
|
value: l,
|
|
1167
|
-
cellCoord:
|
|
1168
|
-
cellRandom:
|
|
1167
|
+
cellCoord: G(e.x.sub(p).mul(a), e.y.sub(m).mul(o), 0),
|
|
1168
|
+
cellRandom: K(M(u), M(d), 2, a, o)
|
|
1169
1169
|
};
|
|
1170
1170
|
}
|
|
1171
|
-
var
|
|
1171
|
+
var Bn = {
|
|
1172
1172
|
type: "tile",
|
|
1173
1173
|
nodeClass: "texture",
|
|
1174
1174
|
label: "Tile Generator",
|
|
@@ -1300,7 +1300,7 @@ var Pn = {
|
|
|
1300
1300
|
build(e) {
|
|
1301
1301
|
let t = e.inputs.coord ?? e.coord, n = Math.max(1, Math.round(Number(e.constant("columns") ?? 6)));
|
|
1302
1302
|
if (e.constant("lattice") === "hex") {
|
|
1303
|
-
let { mask: r, value: i, cellCoord: a, cellRandom: o } =
|
|
1303
|
+
let { mask: r, value: i, cellCoord: a, cellRandom: o } = zn(t, n, Math.max(2, Math.round(n * 2 / Math.sqrt(3) / 2) * 2), e.live("gap"), e.live("edge"));
|
|
1304
1304
|
return {
|
|
1305
1305
|
mask: r,
|
|
1306
1306
|
value: i,
|
|
@@ -1308,7 +1308,7 @@ var Pn = {
|
|
|
1308
1308
|
cellRandom: o
|
|
1309
1309
|
};
|
|
1310
1310
|
}
|
|
1311
|
-
let r = Math.max(1, Math.round(Number(e.constant("offsetFreq") ?? 2))), i = Math.max(1, Math.round(Number(e.constant("rows") ?? 12))), { mask: a, value: o, cellCoord: s, cellRandom: c } =
|
|
1311
|
+
let r = Math.max(1, Math.round(Number(e.constant("offsetFreq") ?? 2))), i = Math.max(1, Math.round(Number(e.constant("rows") ?? 12))), { mask: a, value: o, cellCoord: s, cellRandom: c } = Rn(t, {
|
|
1312
1312
|
columns: n,
|
|
1313
1313
|
rows: Math.ceil(i / r) * r,
|
|
1314
1314
|
offsetFreq: r
|
|
@@ -1328,28 +1328,28 @@ var Pn = {
|
|
|
1328
1328
|
cellRandom: c
|
|
1329
1329
|
};
|
|
1330
1330
|
}
|
|
1331
|
-
},
|
|
1332
|
-
function
|
|
1333
|
-
let r = t, i =
|
|
1334
|
-
let t =
|
|
1331
|
+
}, Vn = Math.PI;
|
|
1332
|
+
function Hn(e, t, n) {
|
|
1333
|
+
let r = t, i = y(() => {
|
|
1334
|
+
let t = W(e.x.mul(r), e.y.mul(r)), i = A(t.x), a = A(t.y), o = k(1e9).toVar(), s = k(10).toVar(), c = k(10).toVar(), l = k(0).toVar(), u = k(1).toVar();
|
|
1335
1335
|
for (let e = -1; e <= 1; e++) {
|
|
1336
1336
|
let d = a.add(e), f = M(d);
|
|
1337
1337
|
for (let e = -1; e <= 1; e++) {
|
|
1338
|
-
let a = i.add(e), p = M(a), m =
|
|
1339
|
-
s.assign(
|
|
1338
|
+
let a = i.add(e), p = M(a), m = K(p, f, 0, r, r), h = K(p, f, 1, r, r), g = h.z.lessThan(n.amount), _ = k(1).add(m.z.sub(.5).mul(2).mul(n.sizeRandom)), v = n.radius.div(r).mul(_), y = m.x.sub(.5).mul(n.posRandom), b = m.y.sub(.5).mul(n.posRandom), x = a.add(.5).add(y), S = d.add(.5).add(b), C = t.x.sub(x).div(r), w = t.y.sub(S).div(r), ee = R(g, pe(W(C, w)), k(1e9)), te = h.x.sub(.5).mul(2).mul(n.rotRandom).mul(Vn).negate(), ne = E(te), T = z(te), re = ne.mul(C).sub(T.mul(w)).div(v.add(1e-9)), ie = T.mul(C).add(ne.mul(w)).div(v.add(1e-9)), D = ee.lessThan(o);
|
|
1339
|
+
s.assign(R(D, re, s)), c.assign(R(D, ie, c)), l.assign(R(D, h.y, l)), u.assign(R(D, _, u)), o.assign(R(D, ee, o));
|
|
1340
1340
|
}
|
|
1341
1341
|
}
|
|
1342
|
-
return
|
|
1342
|
+
return Re(s, c, l, u);
|
|
1343
1343
|
})();
|
|
1344
1344
|
return {
|
|
1345
|
-
coord:
|
|
1345
|
+
coord: G(i.x, i.y, 0),
|
|
1346
1346
|
value: i.z,
|
|
1347
1347
|
size: i.w
|
|
1348
1348
|
};
|
|
1349
1349
|
}
|
|
1350
1350
|
//#endregion
|
|
1351
1351
|
//#region src/graph/nodes/texture/scatter.ts
|
|
1352
|
-
var
|
|
1352
|
+
var Un = {
|
|
1353
1353
|
type: "scatter",
|
|
1354
1354
|
nodeClass: "texture",
|
|
1355
1355
|
label: "Scatter",
|
|
@@ -1431,7 +1431,7 @@ var Ln = {
|
|
|
1431
1431
|
}
|
|
1432
1432
|
],
|
|
1433
1433
|
build(e) {
|
|
1434
|
-
let t = e.inputs.coord ?? e.coord, n = Math.round(Number(e.constant("density") ?? 10)), { coord: r, value: i, size: a } =
|
|
1434
|
+
let t = e.inputs.coord ?? e.coord, n = Math.round(Number(e.constant("density") ?? 10)), { coord: r, value: i, size: a } = Hn(t, Number.isFinite(n) ? Math.max(1, n) : 10, {
|
|
1435
1435
|
amount: e.live("amount"),
|
|
1436
1436
|
radius: e.live("radius"),
|
|
1437
1437
|
sizeRandom: e.live("sizeRandom"),
|
|
@@ -1444,41 +1444,41 @@ var Ln = {
|
|
|
1444
1444
|
size: a
|
|
1445
1445
|
};
|
|
1446
1446
|
}
|
|
1447
|
-
},
|
|
1447
|
+
}, Wn = 6.283185307179586, Gn = [
|
|
1448
1448
|
.13,
|
|
1449
1449
|
.21,
|
|
1450
1450
|
.09,
|
|
1451
1451
|
.17
|
|
1452
1452
|
];
|
|
1453
|
-
function
|
|
1454
|
-
let o = i ?? k(0), s =
|
|
1455
|
-
let i = j(o.mul(13.13)).mul(
|
|
1456
|
-
let o =
|
|
1453
|
+
function Kn(e, t, n, r, i, a) {
|
|
1454
|
+
let o = i ?? k(0), s = y(() => {
|
|
1455
|
+
let i = j(o.mul(13.13)).mul(Wn), s = j(o.mul(27.71)).mul(Wn), c = j(o.mul(51.37)).mul(Wn), l = j(o.mul(91.7)).mul(2).sub(1), u = a.dome.mul(k(1).add(a.formRandom.mul(l).mul(.8))).max(.2), d = j(o.mul(71.13)).mul(Wn), f = (e, r) => {
|
|
1456
|
+
let o = pe(W(e, r)), l = C(r, e), f, p;
|
|
1457
1457
|
if (t === "polygon") {
|
|
1458
|
-
let e = Math.max(3, Math.round(n)), t =
|
|
1459
|
-
f =
|
|
1458
|
+
let e = Math.max(3, Math.round(n)), t = Wn / e, r = E(A(l.div(t).add(.5)).mul(t).sub(l)).mul(o), i = Math.cos(Math.PI / e), s = T(r.div(i), 0, 1);
|
|
1459
|
+
f = B(0, a.edge.add(1e-4), s.oneMinus()), p = s.oneMinus();
|
|
1460
1460
|
} else {
|
|
1461
|
-
let e =
|
|
1462
|
-
f =
|
|
1461
|
+
let e = z(l.mul(2).add(i)).mul(.5).add(z(l.mul(3).add(s)).mul(.3)).add(z(l.mul(5).add(c)).mul(.2)), t = k(1).add(e.mul(a.irregularity.mul(.4))), n = T(o.div(t.add(1e-6)), 0, 1);
|
|
1462
|
+
f = B(0, a.edge.add(1e-4), n.oneMinus()), p = n.oneMinus();
|
|
1463
1463
|
}
|
|
1464
|
-
let m =
|
|
1464
|
+
let m = T(o, 0, 1), h = L(T(m.mul(m).oneMinus(), 0, 1), u), g = E(d).mul(e).add(z(d).mul(r)), _ = h.mul(T(k(1).add(a.tilt.mul(g)), 0, 2)), v = B(0, .3, p), y = T(_, 0, 1.5).mul(v);
|
|
1465
1465
|
return {
|
|
1466
1466
|
mask: f,
|
|
1467
|
-
height:
|
|
1467
|
+
height: y
|
|
1468
1468
|
};
|
|
1469
|
-
}, p = f(e.x, e.y), m = p.mask, h = p.height, g = Math.max(0, Math.min(
|
|
1469
|
+
}, p = f(e.x, e.y), m = p.mask, h = p.height, g = Math.max(0, Math.min(Gn.length, Math.round(r))), _ = g > 0 ? j(o.mul(33.19)).mul(Wn) : null;
|
|
1470
1470
|
for (let t = 0; t < g; t++) {
|
|
1471
|
-
let n = _.add(t / g *
|
|
1471
|
+
let n = _.add(t / g * Wn), r = a.erode.mul(Gn[t]), i = f(e.x.add(E(n).mul(r)), e.y.add(z(n).mul(r)));
|
|
1472
1472
|
m = m.min(i.mask), h = h.min(i.height);
|
|
1473
1473
|
}
|
|
1474
|
-
return
|
|
1474
|
+
return G(m, h, 0);
|
|
1475
1475
|
})();
|
|
1476
1476
|
return {
|
|
1477
1477
|
mask: s.x,
|
|
1478
1478
|
height: s.y
|
|
1479
1479
|
};
|
|
1480
1480
|
}
|
|
1481
|
-
var
|
|
1481
|
+
var qn = {
|
|
1482
1482
|
type: "shape",
|
|
1483
1483
|
nodeClass: "texture",
|
|
1484
1484
|
label: "Shape",
|
|
@@ -1579,7 +1579,7 @@ var Vn = {
|
|
|
1579
1579
|
}
|
|
1580
1580
|
],
|
|
1581
1581
|
build(e) {
|
|
1582
|
-
let t = e.inputs.coord ?? e.coord, n = e.inputs.seed, r = e.constant("shape") ?? "blob", i = Math.round(Number(e.constant("sides") ?? 6)), { mask: a, height: o } =
|
|
1582
|
+
let t = e.inputs.coord ?? e.coord, n = e.inputs.seed, r = e.constant("shape") ?? "blob", i = Math.round(Number(e.constant("sides") ?? 6)), { mask: a, height: o } = Kn(t, r, Number.isFinite(i) ? Math.max(3, i) : 6, parseInt(String(e.constant("erodeTaps") ?? "off"), 10) || 0, n ?? null, {
|
|
1583
1583
|
irregularity: e.live("irregularity"),
|
|
1584
1584
|
dome: e.live("dome"),
|
|
1585
1585
|
edge: e.live("edge"),
|
|
@@ -1592,8 +1592,8 @@ var Vn = {
|
|
|
1592
1592
|
height: o
|
|
1593
1593
|
};
|
|
1594
1594
|
}
|
|
1595
|
-
},
|
|
1596
|
-
function
|
|
1595
|
+
}, Jn = Math.PI * 2;
|
|
1596
|
+
function Yn(e, t) {
|
|
1597
1597
|
let n = e.x, r = e.y, i = e.z, a;
|
|
1598
1598
|
switch (t) {
|
|
1599
1599
|
case 1: {
|
|
@@ -1610,7 +1610,7 @@ function Un(e, t) {
|
|
|
1610
1610
|
a = n.add(r).mul(.5);
|
|
1611
1611
|
break;
|
|
1612
1612
|
case 4:
|
|
1613
|
-
a =
|
|
1613
|
+
a = C(r, n).div(Jn).add(.5);
|
|
1614
1614
|
break;
|
|
1615
1615
|
case 5: {
|
|
1616
1616
|
let e = k(.999999).sub(n.mul(n).add(r.mul(r)).add(i.mul(i)).sqrt()).max(0);
|
|
@@ -1626,7 +1626,7 @@ function Un(e, t) {
|
|
|
1626
1626
|
}
|
|
1627
1627
|
//#endregion
|
|
1628
1628
|
//#region src/graph/nodes/texture/gradient.ts
|
|
1629
|
-
var
|
|
1629
|
+
var Xn = [
|
|
1630
1630
|
"linear",
|
|
1631
1631
|
"quadratic",
|
|
1632
1632
|
"easing",
|
|
@@ -1634,7 +1634,7 @@ var Wn = [
|
|
|
1634
1634
|
"radial",
|
|
1635
1635
|
"quadratic-sphere",
|
|
1636
1636
|
"sphere"
|
|
1637
|
-
],
|
|
1637
|
+
], Zn = {
|
|
1638
1638
|
type: "gradient",
|
|
1639
1639
|
nodeClass: "texture",
|
|
1640
1640
|
label: "Gradient",
|
|
@@ -1658,68 +1658,68 @@ var Wn = [
|
|
|
1658
1658
|
key: "gradientType",
|
|
1659
1659
|
label: "type",
|
|
1660
1660
|
type: "select",
|
|
1661
|
-
options:
|
|
1661
|
+
options: Xn,
|
|
1662
1662
|
default: "linear"
|
|
1663
1663
|
}],
|
|
1664
1664
|
build(e) {
|
|
1665
|
-
return { field:
|
|
1665
|
+
return { field: Yn((e.inputs.coord ?? e.coord).mul(e.live("scale")), Math.max(0, Xn.indexOf(e.constant("gradientType")))) };
|
|
1666
1666
|
}
|
|
1667
|
-
},
|
|
1668
|
-
function
|
|
1669
|
-
if (t === 0) return k(.5).add(
|
|
1667
|
+
}, Qn = Math.PI * 2, $n = Math.PI / 2, er = 20, tr = 10;
|
|
1668
|
+
function nr(e, t) {
|
|
1669
|
+
if (t === 0) return k(.5).add(z(e.sub($n)).mul(.5));
|
|
1670
1670
|
if (t === 1) {
|
|
1671
|
-
let t = e.div(
|
|
1671
|
+
let t = e.div(Qn);
|
|
1672
1672
|
return t.sub(A(t));
|
|
1673
1673
|
}
|
|
1674
|
-
let n = e.div(
|
|
1674
|
+
let n = e.div(Qn);
|
|
1675
1675
|
return n.sub(A(n.add(.5))).abs().mul(2);
|
|
1676
1676
|
}
|
|
1677
|
-
function
|
|
1678
|
-
let a = Math.max(1, Math.round(i.scaleNum *
|
|
1679
|
-
if (s = i.dir === 0 ? e.x.mul(a *
|
|
1677
|
+
function rr(e, t, n, r, i) {
|
|
1678
|
+
let a = Math.max(1, Math.round(i.scaleNum * er / Qn)), o = Math.max(1, Math.round(i.scaleNum * tr / Qn)), s;
|
|
1679
|
+
if (s = i.dir === 0 ? e.x.mul(a * Qn) : i.dir === 1 ? e.y.mul(a * Qn) : i.dir === 2 ? e.z.mul(a * Qn) : e.x.add(e.y).add(e.z).mul(o * Qn), s = s.add(t), i.withDistortion) {
|
|
1680
1680
|
let t = Math.max(1, Math.round(i.scaleNum * i.detailScaleNum)), a = t, o = t;
|
|
1681
1681
|
i.dir === 0 ? o = 2 : i.dir === 1 && (a = 2);
|
|
1682
|
-
let c =
|
|
1682
|
+
let c = ht(W(e.x, e.y), a, o, Math.max(1, i.detail), r);
|
|
1683
1683
|
s = s.add(n.mul(c));
|
|
1684
1684
|
}
|
|
1685
|
-
return
|
|
1685
|
+
return nr(s, i.profile);
|
|
1686
1686
|
}
|
|
1687
|
-
function
|
|
1688
|
-
let o = (e) => e.sub(
|
|
1689
|
-
s = a.dir === 0 ?
|
|
1690
|
-
let c = s.length().mul(t).mul(
|
|
1687
|
+
function ir(e, t, n, r, i, a) {
|
|
1688
|
+
let o = (e) => e.sub(Ee(e)), s;
|
|
1689
|
+
s = a.dir === 0 ? G(k(0), o(e.y), o(e.z)) : a.dir === 1 ? G(o(e.x), k(0), o(e.z)) : a.dir === 2 ? G(o(e.x), o(e.y), k(0)) : G(o(e.x), o(e.y), o(e.z));
|
|
1690
|
+
let c = s.length().mul(t).mul(er).add(n);
|
|
1691
1691
|
if (a.withDistortion) {
|
|
1692
|
-
let t = Math.max(1, Math.round(a.scaleNum * a.detailScaleNum)), n =
|
|
1692
|
+
let t = Math.max(1, Math.round(a.scaleNum * a.detailScaleNum)), n = ht(W(e.x, e.y), t, t, Math.max(1, a.detail), i);
|
|
1693
1693
|
c = c.add(r.mul(n));
|
|
1694
1694
|
}
|
|
1695
|
-
return
|
|
1695
|
+
return nr(c, a.profile);
|
|
1696
1696
|
}
|
|
1697
|
-
function
|
|
1698
|
-
if (o.tileable) return o.waveType === 0 ?
|
|
1697
|
+
function ar(e, t, n, r, i, a, o) {
|
|
1698
|
+
if (o.tileable) return o.waveType === 0 ? rr(e, n, r, a, o) : ir(e, t, n, r, a, o);
|
|
1699
1699
|
let s = e.mul(t).add(1e-6).mul(.999999), c;
|
|
1700
|
-
if (o.waveType === 0) c = o.dir === 0 ? s.x.mul(
|
|
1700
|
+
if (o.waveType === 0) c = o.dir === 0 ? s.x.mul(er) : o.dir === 1 ? s.y.mul(er) : o.dir === 2 ? s.z.mul(er) : s.x.add(s.y).add(s.z).mul(tr);
|
|
1701
1701
|
else {
|
|
1702
1702
|
let e = s;
|
|
1703
|
-
o.dir === 0 ? e = s.mul(
|
|
1703
|
+
o.dir === 0 ? e = s.mul(G(0, 1, 1)) : o.dir === 1 ? e = s.mul(G(1, 0, 1)) : o.dir === 2 && (e = s.mul(G(1, 1, 0))), c = e.length().mul(er);
|
|
1704
1704
|
}
|
|
1705
1705
|
if (c = c.add(n), o.withDistortion) {
|
|
1706
|
-
let e =
|
|
1706
|
+
let e = lt(s.mul(i), o.detail, a, k(2));
|
|
1707
1707
|
c = c.add(r.mul(e.mul(2).sub(1)));
|
|
1708
1708
|
}
|
|
1709
|
-
return
|
|
1709
|
+
return nr(c, o.profile);
|
|
1710
1710
|
}
|
|
1711
1711
|
//#endregion
|
|
1712
1712
|
//#region src/graph/nodes/texture/wave.ts
|
|
1713
|
-
var
|
|
1713
|
+
var or = ["bands", "rings"], sr = [
|
|
1714
1714
|
"x",
|
|
1715
1715
|
"y",
|
|
1716
1716
|
"z",
|
|
1717
1717
|
"diagonal"
|
|
1718
|
-
],
|
|
1718
|
+
], cr = [
|
|
1719
1719
|
"sine",
|
|
1720
1720
|
"saw",
|
|
1721
1721
|
"triangle"
|
|
1722
|
-
],
|
|
1722
|
+
], lr = {
|
|
1723
1723
|
type: "wave",
|
|
1724
1724
|
nodeClass: "texture",
|
|
1725
1725
|
label: "Wave",
|
|
@@ -1746,21 +1746,21 @@ var $n = ["bands", "rings"], er = [
|
|
|
1746
1746
|
key: "waveType",
|
|
1747
1747
|
label: "type",
|
|
1748
1748
|
type: "select",
|
|
1749
|
-
options:
|
|
1749
|
+
options: or,
|
|
1750
1750
|
default: "bands"
|
|
1751
1751
|
},
|
|
1752
1752
|
{
|
|
1753
1753
|
key: "direction",
|
|
1754
1754
|
label: "direction",
|
|
1755
1755
|
type: "select",
|
|
1756
|
-
options:
|
|
1756
|
+
options: sr,
|
|
1757
1757
|
default: "x"
|
|
1758
1758
|
},
|
|
1759
1759
|
{
|
|
1760
1760
|
key: "profile",
|
|
1761
1761
|
label: "profile",
|
|
1762
1762
|
type: "select",
|
|
1763
|
-
options:
|
|
1763
|
+
options: cr,
|
|
1764
1764
|
default: "sine"
|
|
1765
1765
|
},
|
|
1766
1766
|
{
|
|
@@ -1813,18 +1813,18 @@ var $n = ["bands", "rings"], er = [
|
|
|
1813
1813
|
],
|
|
1814
1814
|
build(e) {
|
|
1815
1815
|
let t = e.inputs.coord ?? e.coord, n = {
|
|
1816
|
-
waveType: Math.max(0,
|
|
1817
|
-
dir: Math.max(0,
|
|
1818
|
-
profile: Math.max(0,
|
|
1816
|
+
waveType: Math.max(0, or.indexOf(e.constant("waveType"))),
|
|
1817
|
+
dir: Math.max(0, sr.indexOf(e.constant("direction"))),
|
|
1818
|
+
profile: Math.max(0, cr.indexOf(e.constant("profile"))),
|
|
1819
1819
|
withDistortion: Number(e.constant("distortion") ?? 0) > 0,
|
|
1820
1820
|
detail: e.constant("detail") ?? 2,
|
|
1821
1821
|
tileable: e.backend === "offline",
|
|
1822
1822
|
scaleNum: Number(e.constant("scale") ?? 1),
|
|
1823
1823
|
detailScaleNum: Number(e.constant("detailScale") ?? 1)
|
|
1824
1824
|
};
|
|
1825
|
-
return { field:
|
|
1825
|
+
return { field: ar(t, e.live("scale"), e.live("phase"), e.live("distortion"), e.live("detailScale"), e.live("detailRoughness"), n) };
|
|
1826
1826
|
}
|
|
1827
|
-
},
|
|
1827
|
+
}, ur = 6.283185307179586, dr = {
|
|
1828
1828
|
type: "anisotropic-stripes",
|
|
1829
1829
|
nodeClass: "texture",
|
|
1830
1830
|
label: "Anisotropic Stripes",
|
|
@@ -1875,10 +1875,10 @@ var $n = ["bands", "rings"], er = [
|
|
|
1875
1875
|
}
|
|
1876
1876
|
],
|
|
1877
1877
|
build(e) {
|
|
1878
|
-
let t = e.inputs.coord ?? e.coord, n =
|
|
1879
|
-
return { field: n.mul(e.live("count")).add(r).mul(
|
|
1878
|
+
let t = e.inputs.coord ?? e.coord, n = C(t.z, t.x).div(ur), r = ge(G(t.y.mul(.6), n.mul(6), k(0))).mul(e.live("waviness"));
|
|
1879
|
+
return { field: n.mul(e.live("count")).add(r).mul(ur).sin().mul(.5).add(.5).pow(e.live("sharpness")).mul(e.live("contrast")) };
|
|
1880
1880
|
}
|
|
1881
|
-
},
|
|
1881
|
+
}, fr = /* @__PURE__ */ "add.subtract.multiply.divide.multiply-add.power.logarithm.sqrt.inverse-sqrt.absolute.exponent.min.max.less-than.greater-than.sign.compare.smooth-min.smooth-max.round.floor.ceil.truncate.fraction.modulo.floored-modulo.wrap.snap.pingpong.sine.cosine.tangent.arcsine.arccosine.arctangent.arctan2.sinh.cosh.tanh.radians.degrees.mix".split("."), pr = new Set([
|
|
1882
1882
|
"sqrt",
|
|
1883
1883
|
"inverse-sqrt",
|
|
1884
1884
|
"absolute",
|
|
@@ -1900,13 +1900,13 @@ var $n = ["bands", "rings"], er = [
|
|
|
1900
1900
|
"tanh",
|
|
1901
1901
|
"radians",
|
|
1902
1902
|
"degrees"
|
|
1903
|
-
]),
|
|
1903
|
+
]), mr = new Set([
|
|
1904
1904
|
"multiply-add",
|
|
1905
1905
|
"compare",
|
|
1906
1906
|
"smooth-min",
|
|
1907
1907
|
"smooth-max",
|
|
1908
1908
|
"wrap"
|
|
1909
|
-
]),
|
|
1909
|
+
]), hr = {
|
|
1910
1910
|
power: ["Base", "Exponent"],
|
|
1911
1911
|
logarithm: ["Value", "Base"],
|
|
1912
1912
|
"multiply-add": [
|
|
@@ -1939,8 +1939,8 @@ var $n = ["bands", "rings"], er = [
|
|
|
1939
1939
|
radians: ["Degrees"],
|
|
1940
1940
|
degrees: ["Radians"]
|
|
1941
1941
|
};
|
|
1942
|
-
function
|
|
1943
|
-
let [t, n, r] =
|
|
1942
|
+
function gr(e) {
|
|
1943
|
+
let [t, n, r] = hr[e] ?? [
|
|
1944
1944
|
"A",
|
|
1945
1945
|
"B",
|
|
1946
1946
|
"C"
|
|
@@ -1949,17 +1949,17 @@ function lr(e) {
|
|
|
1949
1949
|
label: t,
|
|
1950
1950
|
kind: "float"
|
|
1951
1951
|
}];
|
|
1952
|
-
return
|
|
1952
|
+
return pr.has(e) || i.push({
|
|
1953
1953
|
key: "b",
|
|
1954
1954
|
label: n ?? "B",
|
|
1955
1955
|
kind: "float"
|
|
1956
|
-
}),
|
|
1956
|
+
}), mr.has(e) && i.push({
|
|
1957
1957
|
key: "c",
|
|
1958
1958
|
label: r ?? "C",
|
|
1959
1959
|
kind: "float"
|
|
1960
1960
|
}), i;
|
|
1961
1961
|
}
|
|
1962
|
-
var
|
|
1962
|
+
var _r = {
|
|
1963
1963
|
type: "math",
|
|
1964
1964
|
nodeClass: "converter",
|
|
1965
1965
|
label: "Math",
|
|
@@ -1981,7 +1981,7 @@ var ur = {
|
|
|
1981
1981
|
key: "op",
|
|
1982
1982
|
label: "op",
|
|
1983
1983
|
type: "select",
|
|
1984
|
-
options:
|
|
1984
|
+
options: fr,
|
|
1985
1985
|
default: "mix"
|
|
1986
1986
|
},
|
|
1987
1987
|
{
|
|
@@ -2005,7 +2005,7 @@ var ur = {
|
|
|
2005
2005
|
],
|
|
2006
2006
|
declare(e) {
|
|
2007
2007
|
return {
|
|
2008
|
-
inputs:
|
|
2008
|
+
inputs: gr(e.op ?? "mix"),
|
|
2009
2009
|
outputs: [{
|
|
2010
2010
|
key: "field",
|
|
2011
2011
|
kind: "float"
|
|
@@ -2018,63 +2018,63 @@ var ur = {
|
|
|
2018
2018
|
case "add": return { field: t.add(n) };
|
|
2019
2019
|
case "subtract": return { field: t.sub(n) };
|
|
2020
2020
|
case "multiply": return { field: t.mul(n) };
|
|
2021
|
-
case "divide": return { field:
|
|
2021
|
+
case "divide": return { field: R(n.equal(0), k(0), t.div(n)) };
|
|
2022
2022
|
case "multiply-add": return { field: t.mul(n).add(r) };
|
|
2023
|
-
case "power": return { field:
|
|
2024
|
-
case "logarithm": return { field:
|
|
2025
|
-
case "sqrt": return { field:
|
|
2026
|
-
case "inverse-sqrt": return { field:
|
|
2027
|
-
case "absolute": return { field:
|
|
2028
|
-
case "exponent": return { field:
|
|
2029
|
-
case "min": return { field:
|
|
2030
|
-
case "max": return { field:
|
|
2031
|
-
case "less-than": return { field:
|
|
2032
|
-
case "greater-than": return { field:
|
|
2033
|
-
case "sign": return { field:
|
|
2034
|
-
case "compare": return { field:
|
|
2035
|
-
case "smooth-min": return { field:
|
|
2036
|
-
case "smooth-max": return { field:
|
|
2037
|
-
case "round": return { field:
|
|
2023
|
+
case "power": return { field: L(t, n) };
|
|
2024
|
+
case "logarithm": return { field: R(t.greaterThan(0).and(n.greaterThan(0)), me(t).div(me(n)), k(0)) };
|
|
2025
|
+
case "sqrt": return { field: je(t) };
|
|
2026
|
+
case "inverse-sqrt": return { field: R(t.greaterThan(0), fe(t), k(0)) };
|
|
2027
|
+
case "absolute": return { field: b(t) };
|
|
2028
|
+
case "exponent": return { field: ce(t) };
|
|
2029
|
+
case "min": return { field: P(t, n) };
|
|
2030
|
+
case "max": return { field: N(t, n) };
|
|
2031
|
+
case "less-than": return { field: R(t.lessThan(n), k(1), k(0)) };
|
|
2032
|
+
case "greater-than": return { field: R(t.greaterThan(n), k(1), k(0)) };
|
|
2033
|
+
case "sign": return { field: ke(t) };
|
|
2034
|
+
case "compare": return { field: R(t.sub(n).abs().lessThanEqual(N(r, k(1e-5))), k(1), k(0)) };
|
|
2035
|
+
case "smooth-min": return { field: vr(t, n, r) };
|
|
2036
|
+
case "smooth-max": return { field: vr(t.negate(), n.negate(), r).negate() };
|
|
2037
|
+
case "round": return { field: Ee(t) };
|
|
2038
2038
|
case "floor": return { field: A(t) };
|
|
2039
|
-
case "ceil": return { field:
|
|
2040
|
-
case "truncate": return { field:
|
|
2039
|
+
case "ceil": return { field: ne(t) };
|
|
2040
|
+
case "truncate": return { field: Fe(t) };
|
|
2041
2041
|
case "fraction": return { field: j(t) };
|
|
2042
|
-
case "modulo": return { field:
|
|
2043
|
-
case "floored-modulo": return { field:
|
|
2044
|
-
case "wrap": return { field:
|
|
2045
|
-
case "snap": return { field:
|
|
2046
|
-
case "pingpong": return { field:
|
|
2047
|
-
case "sine": return { field:
|
|
2042
|
+
case "modulo": return { field: R(n.equal(0), k(0), t.sub(n.mul(Fe(t.div(n))))) };
|
|
2043
|
+
case "floored-modulo": return { field: R(n.equal(0), k(0), t.sub(n.mul(A(t.div(n))))) };
|
|
2044
|
+
case "wrap": return { field: yr(t, n, r) };
|
|
2045
|
+
case "snap": return { field: R(n.equal(0), k(0), A(t.div(n)).mul(n)) };
|
|
2046
|
+
case "pingpong": return { field: br(t, n) };
|
|
2047
|
+
case "sine": return { field: z(t) };
|
|
2048
2048
|
case "cosine": return { field: E(t) };
|
|
2049
|
-
case "tangent": return { field:
|
|
2050
|
-
case "arcsine": return { field:
|
|
2051
|
-
case "arccosine": return { field:
|
|
2052
|
-
case "arctangent": return { field:
|
|
2053
|
-
case "arctan2": return { field:
|
|
2054
|
-
case "sinh": return { field:
|
|
2055
|
-
case "cosh": return { field:
|
|
2056
|
-
case "tanh": return { field:
|
|
2057
|
-
case "radians": return { field:
|
|
2058
|
-
case "degrees": return { field:
|
|
2059
|
-
default: return { field:
|
|
2049
|
+
case "tangent": return { field: Ne(t) };
|
|
2050
|
+
case "arcsine": return { field: R(t.abs().lessThanEqual(1), S(t), k(0)) };
|
|
2051
|
+
case "arccosine": return { field: R(t.abs().lessThanEqual(1), x(t), k(0)) };
|
|
2052
|
+
case "arctangent": return { field: C(t) };
|
|
2053
|
+
case "arctan2": return { field: C(t, n) };
|
|
2054
|
+
case "sinh": return { field: Ae(t) };
|
|
2055
|
+
case "cosh": return { field: ie(t) };
|
|
2056
|
+
case "tanh": return { field: Pe(t) };
|
|
2057
|
+
case "radians": return { field: we(t) };
|
|
2058
|
+
case "degrees": return { field: se(t) };
|
|
2059
|
+
default: return { field: F(t, n, e.live("factor")) };
|
|
2060
2060
|
}
|
|
2061
2061
|
}
|
|
2062
2062
|
};
|
|
2063
|
-
function
|
|
2064
|
-
let r =
|
|
2065
|
-
return
|
|
2063
|
+
function vr(e, t, n) {
|
|
2064
|
+
let r = N(n.sub(e.sub(t).abs()), k(0)).div(n), i = P(e, t).sub(r.mul(r).mul(r).mul(n).div(6));
|
|
2065
|
+
return R(n.equal(0), P(e, t), i);
|
|
2066
2066
|
}
|
|
2067
|
-
function
|
|
2067
|
+
function yr(e, t, n) {
|
|
2068
2068
|
let r = t.sub(n);
|
|
2069
|
-
return
|
|
2069
|
+
return R(r.equal(0), n, e.sub(r.mul(A(e.sub(n).div(r)))));
|
|
2070
2070
|
}
|
|
2071
|
-
function
|
|
2071
|
+
function br(e, t) {
|
|
2072
2072
|
let n = t.mul(2);
|
|
2073
|
-
return
|
|
2073
|
+
return R(t.equal(0), k(0), j(e.sub(t).div(n)).mul(n).sub(t).abs());
|
|
2074
2074
|
}
|
|
2075
2075
|
//#endregion
|
|
2076
2076
|
//#region src/graph/nodes/converter/levels.ts
|
|
2077
|
-
var
|
|
2077
|
+
var xr = {
|
|
2078
2078
|
type: "levels",
|
|
2079
2079
|
nodeClass: "converter",
|
|
2080
2080
|
label: "Levels / Remap",
|
|
@@ -2114,9 +2114,9 @@ var mr = {
|
|
|
2114
2114
|
],
|
|
2115
2115
|
build(e) {
|
|
2116
2116
|
let t = e.inputs.field ?? k(.5), n = e.constant("invert") ? t.oneMinus() : t;
|
|
2117
|
-
return { field:
|
|
2117
|
+
return { field: F(e.live("min"), e.live("max"), n) };
|
|
2118
2118
|
}
|
|
2119
|
-
},
|
|
2119
|
+
}, Sr = {
|
|
2120
2120
|
type: "color-ramp",
|
|
2121
2121
|
nodeClass: "converter",
|
|
2122
2122
|
label: "Color Ramp",
|
|
@@ -2161,10 +2161,10 @@ var mr = {
|
|
|
2161
2161
|
}
|
|
2162
2162
|
],
|
|
2163
2163
|
build(e) {
|
|
2164
|
-
let t = e.inputs.field ?? k(.5), n = e.live("low"), r = e.live("high"), i =
|
|
2165
|
-
return { color:
|
|
2164
|
+
let t = e.inputs.field ?? k(.5), n = e.live("low"), r = e.live("high"), i = T(t.sub(n).div(r.sub(n).max(1e-5)), 0, 1);
|
|
2165
|
+
return { color: F(e.live("colorA"), e.live("colorB"), i) };
|
|
2166
2166
|
}
|
|
2167
|
-
},
|
|
2167
|
+
}, Cr = {
|
|
2168
2168
|
type: "height-blend",
|
|
2169
2169
|
nodeClass: "converter",
|
|
2170
2170
|
label: "Height Blend",
|
|
@@ -2221,10 +2221,10 @@ var mr = {
|
|
|
2221
2221
|
build(e) {
|
|
2222
2222
|
let t = e.inputs.heightA ?? k(.5), n = e.inputs.heightB ?? k(.5), r = e.live("transition"), i = e.live("width");
|
|
2223
2223
|
e.inputs.breakup !== void 0 && (n = n.add(e.inputs.breakup.sub(.5).mul(e.live("breakup"))));
|
|
2224
|
-
let a = n.sub(t).add(r.mul(2).sub(1)), o =
|
|
2225
|
-
return { fac:
|
|
2224
|
+
let a = n.sub(t).add(r.mul(2).sub(1)), o = N(i, de(a));
|
|
2225
|
+
return { fac: B(o.negate(), o, a) };
|
|
2226
2226
|
}
|
|
2227
|
-
},
|
|
2227
|
+
}, wr = {
|
|
2228
2228
|
type: "blend",
|
|
2229
2229
|
nodeClass: "color",
|
|
2230
2230
|
label: "Blend",
|
|
@@ -2269,7 +2269,7 @@ var mr = {
|
|
|
2269
2269
|
default: 1
|
|
2270
2270
|
}],
|
|
2271
2271
|
build(e) {
|
|
2272
|
-
let t = e.inputs.a ??
|
|
2272
|
+
let t = e.inputs.a ?? re(0), n = e.inputs.b ?? re(16777215), r;
|
|
2273
2273
|
switch (e.constant("mode")) {
|
|
2274
2274
|
case "multiply":
|
|
2275
2275
|
r = t.mul(n);
|
|
@@ -2285,9 +2285,9 @@ var mr = {
|
|
|
2285
2285
|
break;
|
|
2286
2286
|
}
|
|
2287
2287
|
let i = (e.inputs.mask ?? k(1)).mul(e.live("opacity"));
|
|
2288
|
-
return { color:
|
|
2288
|
+
return { color: F(t, r, i) };
|
|
2289
2289
|
}
|
|
2290
|
-
},
|
|
2290
|
+
}, Tr = {
|
|
2291
2291
|
type: "invert",
|
|
2292
2292
|
nodeClass: "color",
|
|
2293
2293
|
label: "Invert Color",
|
|
@@ -2314,10 +2314,10 @@ var mr = {
|
|
|
2314
2314
|
default: 1
|
|
2315
2315
|
}],
|
|
2316
2316
|
build(e) {
|
|
2317
|
-
let t = e.inputs.color ??
|
|
2318
|
-
return { color:
|
|
2317
|
+
let t = e.inputs.color ?? G(0, 0, 0), n = e.inputs.fac ?? e.live("fac");
|
|
2318
|
+
return { color: F(t, G(1, 1, 1).sub(t), n) };
|
|
2319
2319
|
}
|
|
2320
|
-
},
|
|
2320
|
+
}, Er = {
|
|
2321
2321
|
type: "bright-contrast",
|
|
2322
2322
|
nodeClass: "color",
|
|
2323
2323
|
label: "Bright / Contrast",
|
|
@@ -2360,21 +2360,21 @@ var mr = {
|
|
|
2360
2360
|
default: 0
|
|
2361
2361
|
}],
|
|
2362
2362
|
build(e) {
|
|
2363
|
-
let t = e.inputs.color ??
|
|
2363
|
+
let t = e.inputs.color ?? G(0, 0, 0), n = e.inputs.contrast ?? e.live("contrast"), r = e.inputs.bright ?? e.live("bright"), i = k(1).add(n), a = r.sub(n.mul(.5));
|
|
2364
2364
|
return { color: t.mul(i).add(a).max(0) };
|
|
2365
2365
|
}
|
|
2366
|
-
},
|
|
2367
|
-
function
|
|
2368
|
-
let t = e.x, n = e.y, r = e.z, i =
|
|
2369
|
-
return p =
|
|
2366
|
+
}, Dr = 1e-10;
|
|
2367
|
+
function Or(e) {
|
|
2368
|
+
let t = e.x, n = e.y, r = e.z, i = N(t, N(n, r)), a = P(t, P(n, r)), o = i.sub(a), s = i, c = R(i.equal(0), k(0), o.div(N(i, k(Dr)))), l = G(i, i, i).sub(e).div(N(o, k(Dr))), u = l.z.sub(l.y), d = k(2).add(l.x).sub(l.z), f = k(4).add(l.y).sub(l.x), p = R(n.equal(i), d, f);
|
|
2369
|
+
return p = R(t.equal(i), u, p), p = p.div(6), p = R(p.lessThan(0), p.add(1), p), p = R(c.equal(0), k(0), p), G(p, c, s);
|
|
2370
2370
|
}
|
|
2371
|
-
function
|
|
2372
|
-
let t = e.x, n = e.y, r = e.z, i =
|
|
2373
|
-
return u =
|
|
2371
|
+
function kr(e) {
|
|
2372
|
+
let t = e.x, n = e.y, r = e.z, i = R(t.equal(1), k(0), t).mul(6), a = A(i), o = i.sub(a), s = r.mul(k(1).sub(n)), c = r.mul(k(1).sub(n.mul(o))), l = r.mul(k(1).sub(n.mul(k(1).sub(o)))), u = G(r, s, c);
|
|
2373
|
+
return u = R(a.equal(4), G(l, s, r), u), u = R(a.equal(3), G(s, c, r), u), u = R(a.equal(2), G(s, r, l), u), u = R(a.equal(1), G(c, r, s), u), u = R(a.equal(0), G(r, l, s), u), R(n.equal(0), G(r, r, r), u);
|
|
2374
2374
|
}
|
|
2375
2375
|
//#endregion
|
|
2376
2376
|
//#region src/graph/nodes/color/hue-sat-val.ts
|
|
2377
|
-
var
|
|
2377
|
+
var Ar = {
|
|
2378
2378
|
type: "hue-sat-val",
|
|
2379
2379
|
nodeClass: "color",
|
|
2380
2380
|
label: "Hue / Saturation",
|
|
@@ -2426,17 +2426,17 @@ var Cr = {
|
|
|
2426
2426
|
}
|
|
2427
2427
|
],
|
|
2428
2428
|
build(e) {
|
|
2429
|
-
let t = e.inputs.color ??
|
|
2430
|
-
return { color:
|
|
2429
|
+
let t = e.inputs.color ?? G(.8, .8, .8), n = Or(t);
|
|
2430
|
+
return { color: F(t, kr(G(j(n.x.add(e.live("hue")).add(.5)), n.y.mul(e.live("saturation")).clamp(0, 1), n.z.mul(e.live("value")))), e.live("fac")) };
|
|
2431
2431
|
}
|
|
2432
|
-
},
|
|
2433
|
-
function
|
|
2434
|
-
let n = e.clamp(0, 1).mul(4), r = A(n).clamp(0, 3), i = n.sub(r), a =
|
|
2432
|
+
}, jr = (e, t, n, r, i) => R(e.equal(0), t, R(e.equal(1), n, R(e.equal(2), r, i)));
|
|
2433
|
+
function Mr(e, t) {
|
|
2434
|
+
let n = e.clamp(0, 1).mul(4), r = A(n).clamp(0, 3), i = n.sub(r), a = jr(r, t[0], t[0], t[1], t[2]), o = jr(r, t[0], t[1], t[2], t[3]), s = jr(r, t[1], t[2], t[3], t[4]), c = jr(r, t[2], t[3], t[4], t[4]), l = i.mul(i), u = l.mul(i);
|
|
2435
2435
|
return o.mul(2).add(s.sub(a).mul(i)).add(a.mul(2).sub(o.mul(5)).add(s.mul(4)).sub(c).mul(l)).add(o.mul(3).sub(s.mul(3)).add(c).sub(a).mul(u)).mul(.5);
|
|
2436
2436
|
}
|
|
2437
2437
|
//#endregion
|
|
2438
2438
|
//#region src/graph/nodes/color/rgb-curves.ts
|
|
2439
|
-
var
|
|
2439
|
+
var Nr = () => [...Be], Pr = {
|
|
2440
2440
|
type: "rgb-curves",
|
|
2441
2441
|
nodeClass: "color",
|
|
2442
2442
|
label: "RGB Curves",
|
|
@@ -2466,14 +2466,14 @@ var Er = () => [...Pe], Dr = {
|
|
|
2466
2466
|
label: "curves",
|
|
2467
2467
|
type: "curve",
|
|
2468
2468
|
default: {
|
|
2469
|
-
C:
|
|
2470
|
-
R:
|
|
2471
|
-
G:
|
|
2472
|
-
B:
|
|
2469
|
+
C: Nr(),
|
|
2470
|
+
R: Nr(),
|
|
2471
|
+
G: Nr(),
|
|
2472
|
+
B: Nr()
|
|
2473
2473
|
}
|
|
2474
2474
|
}],
|
|
2475
2475
|
build(e) {
|
|
2476
|
-
let t = e.inputs.color ??
|
|
2476
|
+
let t = e.inputs.color ?? G(0, 0, 0), n = e.live("curves"), r = (e) => [
|
|
2477
2477
|
0,
|
|
2478
2478
|
1,
|
|
2479
2479
|
2,
|
|
@@ -2484,10 +2484,10 @@ var Er = () => [...Pe], Dr = {
|
|
|
2484
2484
|
r(5),
|
|
2485
2485
|
r(10),
|
|
2486
2486
|
r(15)
|
|
2487
|
-
], c =
|
|
2488
|
-
return { color:
|
|
2487
|
+
], c = Mr(Mr(t.x, i), a), l = Mr(Mr(t.y, i), o), u = Mr(Mr(t.z, i), s), d = e.inputs.fac ?? e.live("fac");
|
|
2488
|
+
return { color: F(t, G(c, l, u), d) };
|
|
2489
2489
|
}
|
|
2490
|
-
},
|
|
2490
|
+
}, Fr = {
|
|
2491
2491
|
type: "luminance",
|
|
2492
2492
|
nodeClass: "converter",
|
|
2493
2493
|
label: "Luminance",
|
|
@@ -2502,9 +2502,9 @@ var Er = () => [...Pe], Dr = {
|
|
|
2502
2502
|
params: [],
|
|
2503
2503
|
build(e) {
|
|
2504
2504
|
let t = e.inputs.color;
|
|
2505
|
-
return { field: t ?
|
|
2505
|
+
return { field: t ? he(t) : k(0) };
|
|
2506
2506
|
}
|
|
2507
|
-
},
|
|
2507
|
+
}, Ir = {
|
|
2508
2508
|
type: "split-channels",
|
|
2509
2509
|
nodeClass: "converter",
|
|
2510
2510
|
label: "Split Channels",
|
|
@@ -2539,7 +2539,7 @@ var Er = () => [...Pe], Dr = {
|
|
|
2539
2539
|
b: k(0)
|
|
2540
2540
|
};
|
|
2541
2541
|
}
|
|
2542
|
-
},
|
|
2542
|
+
}, Lr = {
|
|
2543
2543
|
type: "combine-channels",
|
|
2544
2544
|
nodeClass: "converter",
|
|
2545
2545
|
label: "Combine Channels",
|
|
@@ -2563,9 +2563,9 @@ var Er = () => [...Pe], Dr = {
|
|
|
2563
2563
|
}],
|
|
2564
2564
|
params: [],
|
|
2565
2565
|
build(e) {
|
|
2566
|
-
return { color:
|
|
2566
|
+
return { color: G(e.inputs.r ?? k(0), e.inputs.g ?? k(0), e.inputs.b ?? k(0)) };
|
|
2567
2567
|
}
|
|
2568
|
-
},
|
|
2568
|
+
}, Rr = {
|
|
2569
2569
|
type: "clamp",
|
|
2570
2570
|
nodeClass: "converter",
|
|
2571
2571
|
label: "Clamp",
|
|
@@ -2619,9 +2619,9 @@ var Er = () => [...Pe], Dr = {
|
|
|
2619
2619
|
],
|
|
2620
2620
|
build(e) {
|
|
2621
2621
|
let t = e.inputs.value ?? k(0), n = e.inputs.min ?? e.live("min"), r = e.inputs.max ?? e.live("max");
|
|
2622
|
-
return e.constant("mode") === "range" ? { field: t.clamp(
|
|
2622
|
+
return e.constant("mode") === "range" ? { field: t.clamp(P(n, r), N(n, r)) } : { field: T(t, n, r) };
|
|
2623
2623
|
}
|
|
2624
|
-
},
|
|
2624
|
+
}, zr = {
|
|
2625
2625
|
type: "separate-xyz",
|
|
2626
2626
|
nodeClass: "converter",
|
|
2627
2627
|
label: "Separate XYZ",
|
|
@@ -2645,14 +2645,14 @@ var Er = () => [...Pe], Dr = {
|
|
|
2645
2645
|
],
|
|
2646
2646
|
params: [],
|
|
2647
2647
|
build(e) {
|
|
2648
|
-
let t = e.inputs.vector ??
|
|
2648
|
+
let t = e.inputs.vector ?? G(0, 0, 0);
|
|
2649
2649
|
return {
|
|
2650
2650
|
x: t.x,
|
|
2651
2651
|
y: t.y,
|
|
2652
2652
|
z: t.z
|
|
2653
2653
|
};
|
|
2654
2654
|
}
|
|
2655
|
-
},
|
|
2655
|
+
}, Br = {
|
|
2656
2656
|
type: "combine-xyz",
|
|
2657
2657
|
nodeClass: "converter",
|
|
2658
2658
|
label: "Combine XYZ",
|
|
@@ -2704,9 +2704,9 @@ var Er = () => [...Pe], Dr = {
|
|
|
2704
2704
|
}
|
|
2705
2705
|
],
|
|
2706
2706
|
build(e) {
|
|
2707
|
-
return { vector:
|
|
2707
|
+
return { vector: G(e.inputs.x ?? e.live("x"), e.inputs.y ?? e.live("y"), e.inputs.z ?? e.live("z")) };
|
|
2708
2708
|
}
|
|
2709
|
-
},
|
|
2709
|
+
}, Vr = {
|
|
2710
2710
|
type: "constant-field",
|
|
2711
2711
|
nodeClass: "input",
|
|
2712
2712
|
label: "Constant (Field)",
|
|
@@ -2727,7 +2727,7 @@ var Er = () => [...Pe], Dr = {
|
|
|
2727
2727
|
build(e) {
|
|
2728
2728
|
return { field: e.live("value") };
|
|
2729
2729
|
}
|
|
2730
|
-
},
|
|
2730
|
+
}, Hr = {
|
|
2731
2731
|
type: "constant-color",
|
|
2732
2732
|
nodeClass: "input",
|
|
2733
2733
|
label: "Constant (Color)",
|
|
@@ -2745,7 +2745,7 @@ var Er = () => [...Pe], Dr = {
|
|
|
2745
2745
|
build(e) {
|
|
2746
2746
|
return { color: e.live("color") };
|
|
2747
2747
|
}
|
|
2748
|
-
},
|
|
2748
|
+
}, Ur = {
|
|
2749
2749
|
type: "tex-coordinate",
|
|
2750
2750
|
nodeClass: "input",
|
|
2751
2751
|
label: "Texture Coordinate",
|
|
@@ -2774,20 +2774,20 @@ var Er = () => [...Pe], Dr = {
|
|
|
2774
2774
|
],
|
|
2775
2775
|
params: [],
|
|
2776
2776
|
build(e) {
|
|
2777
|
-
let t =
|
|
2777
|
+
let t = G(U().x, U().y, k(0));
|
|
2778
2778
|
return e.backend === "offline" ? {
|
|
2779
2779
|
generated: t,
|
|
2780
2780
|
uv: t,
|
|
2781
2781
|
object: t,
|
|
2782
2782
|
normal: t
|
|
2783
2783
|
} : {
|
|
2784
|
-
generated:
|
|
2784
|
+
generated: Se,
|
|
2785
2785
|
uv: t,
|
|
2786
|
-
object:
|
|
2787
|
-
normal:
|
|
2786
|
+
object: Se,
|
|
2787
|
+
normal: _e
|
|
2788
2788
|
};
|
|
2789
2789
|
}
|
|
2790
|
-
},
|
|
2790
|
+
}, Wr = [
|
|
2791
2791
|
"add",
|
|
2792
2792
|
"subtract",
|
|
2793
2793
|
"multiply",
|
|
@@ -2810,11 +2810,11 @@ var Er = () => [...Pe], Dr = {
|
|
|
2810
2810
|
"sine",
|
|
2811
2811
|
"cosine",
|
|
2812
2812
|
"tangent"
|
|
2813
|
-
],
|
|
2813
|
+
], Gr = new Set([
|
|
2814
2814
|
"dot",
|
|
2815
2815
|
"distance",
|
|
2816
2816
|
"length"
|
|
2817
|
-
]),
|
|
2817
|
+
]), Kr = [{
|
|
2818
2818
|
key: "vector1",
|
|
2819
2819
|
label: "A",
|
|
2820
2820
|
kind: "vector"
|
|
@@ -2822,11 +2822,11 @@ var Er = () => [...Pe], Dr = {
|
|
|
2822
2822
|
key: "vector2",
|
|
2823
2823
|
label: "B",
|
|
2824
2824
|
kind: "vector"
|
|
2825
|
-
}],
|
|
2825
|
+
}], qr = {
|
|
2826
2826
|
type: "vector-math",
|
|
2827
2827
|
nodeClass: "vector",
|
|
2828
2828
|
label: "Vector Math",
|
|
2829
|
-
inputs:
|
|
2829
|
+
inputs: Kr,
|
|
2830
2830
|
outputs: [{
|
|
2831
2831
|
key: "vector",
|
|
2832
2832
|
label: "Vector",
|
|
@@ -2836,7 +2836,7 @@ var Er = () => [...Pe], Dr = {
|
|
|
2836
2836
|
key: "operation",
|
|
2837
2837
|
label: "op",
|
|
2838
2838
|
type: "select",
|
|
2839
|
-
options:
|
|
2839
|
+
options: Wr,
|
|
2840
2840
|
default: "add"
|
|
2841
2841
|
}, {
|
|
2842
2842
|
key: "scale",
|
|
@@ -2850,8 +2850,8 @@ var Er = () => [...Pe], Dr = {
|
|
|
2850
2850
|
declare(e) {
|
|
2851
2851
|
let t = e.operation ?? "add";
|
|
2852
2852
|
return {
|
|
2853
|
-
inputs:
|
|
2854
|
-
outputs:
|
|
2853
|
+
inputs: Kr,
|
|
2854
|
+
outputs: Gr.has(t) ? [{
|
|
2855
2855
|
key: "value",
|
|
2856
2856
|
label: "Value",
|
|
2857
2857
|
kind: "float"
|
|
@@ -2863,14 +2863,14 @@ var Er = () => [...Pe], Dr = {
|
|
|
2863
2863
|
};
|
|
2864
2864
|
},
|
|
2865
2865
|
build(e) {
|
|
2866
|
-
let t = e.inputs.vector1 ?? e.coord, n = e.inputs.vector2 ??
|
|
2866
|
+
let t = e.inputs.vector1 ?? e.coord, n = e.inputs.vector2 ?? G(0, 0, 0);
|
|
2867
2867
|
switch (e.constant("operation") ?? "add") {
|
|
2868
2868
|
case "subtract": return { vector: t.sub(n) };
|
|
2869
2869
|
case "multiply": return { vector: t.mul(n) };
|
|
2870
2870
|
case "divide": return { vector: t.div(n) };
|
|
2871
|
-
case "cross": return { vector:
|
|
2871
|
+
case "cross": return { vector: D(t, n) };
|
|
2872
2872
|
case "project": return { vector: n.mul(O(t, n).div(O(n, n))) };
|
|
2873
|
-
case "reflect": return { vector:
|
|
2873
|
+
case "reflect": return { vector: Te(t, n.normalize()) };
|
|
2874
2874
|
case "dot": return { value: O(t, n) };
|
|
2875
2875
|
case "distance": return { value: t.sub(n).length() };
|
|
2876
2876
|
case "length": return { value: t.length() };
|
|
@@ -2878,31 +2878,31 @@ var Er = () => [...Pe], Dr = {
|
|
|
2878
2878
|
case "normalize": return { vector: t.normalize() };
|
|
2879
2879
|
case "snap": return { vector: A(t.div(n)).mul(n) };
|
|
2880
2880
|
case "floor": return { vector: A(t) };
|
|
2881
|
-
case "ceil": return { vector:
|
|
2881
|
+
case "ceil": return { vector: ne(t) };
|
|
2882
2882
|
case "fraction": return { vector: j(t) };
|
|
2883
2883
|
case "absolute": return { vector: t.abs() };
|
|
2884
|
-
case "minimum": return { vector:
|
|
2885
|
-
case "maximum": return { vector:
|
|
2886
|
-
case "sine": return { vector:
|
|
2884
|
+
case "minimum": return { vector: P(t, n) };
|
|
2885
|
+
case "maximum": return { vector: N(t, n) };
|
|
2886
|
+
case "sine": return { vector: z(t) };
|
|
2887
2887
|
case "cosine": return { vector: E(t) };
|
|
2888
|
-
case "tangent": return { vector:
|
|
2888
|
+
case "tangent": return { vector: Ne(t) };
|
|
2889
2889
|
default: return { vector: t.add(n) };
|
|
2890
2890
|
}
|
|
2891
2891
|
}
|
|
2892
2892
|
};
|
|
2893
2893
|
//#endregion
|
|
2894
2894
|
//#region src/tsl/vector-rotate.ts
|
|
2895
|
-
function
|
|
2896
|
-
let i = e.sub(t), a = E(n), o =
|
|
2897
|
-
return r === 0 ? (s = i.x, c = a.mul(i.y).sub(o.mul(i.z)), l = o.mul(i.y).add(a.mul(i.z))) : r === 1 ? (c = i.y, l = a.mul(i.z).sub(o.mul(i.x)), s = o.mul(i.z).add(a.mul(i.x))) : (l = i.z, s = a.mul(i.x).sub(o.mul(i.y)), c = o.mul(i.x).add(a.mul(i.y))), t.add(
|
|
2895
|
+
function Jr(e, t, n, r) {
|
|
2896
|
+
let i = e.sub(t), a = E(n), o = z(n), s, c, l;
|
|
2897
|
+
return r === 0 ? (s = i.x, c = a.mul(i.y).sub(o.mul(i.z)), l = o.mul(i.y).add(a.mul(i.z))) : r === 1 ? (c = i.y, l = a.mul(i.z).sub(o.mul(i.x)), s = o.mul(i.z).add(a.mul(i.x))) : (l = i.z, s = a.mul(i.x).sub(o.mul(i.y)), c = o.mul(i.x).add(a.mul(i.y))), t.add(G(s, c, l));
|
|
2898
2898
|
}
|
|
2899
2899
|
//#endregion
|
|
2900
2900
|
//#region src/graph/nodes/vector/vector-rotate.ts
|
|
2901
|
-
var
|
|
2901
|
+
var Yr = [
|
|
2902
2902
|
"x",
|
|
2903
2903
|
"y",
|
|
2904
2904
|
"z"
|
|
2905
|
-
],
|
|
2905
|
+
], Xr = {
|
|
2906
2906
|
type: "vector-rotate",
|
|
2907
2907
|
nodeClass: "vector",
|
|
2908
2908
|
label: "Vector Rotate",
|
|
@@ -2928,7 +2928,7 @@ var Hr = [
|
|
|
2928
2928
|
key: "axis",
|
|
2929
2929
|
label: "axis",
|
|
2930
2930
|
type: "select",
|
|
2931
|
-
options:
|
|
2931
|
+
options: Yr,
|
|
2932
2932
|
default: "z"
|
|
2933
2933
|
}, {
|
|
2934
2934
|
key: "angle",
|
|
@@ -2940,9 +2940,9 @@ var Hr = [
|
|
|
2940
2940
|
default: 0
|
|
2941
2941
|
}],
|
|
2942
2942
|
build(e) {
|
|
2943
|
-
return { vector:
|
|
2943
|
+
return { vector: Jr(e.inputs.vector ?? e.coord, e.inputs.center ?? G(0, 0, 0), e.inputs.angle ?? e.live("angle"), Math.max(0, Yr.indexOf(e.constant("axis")))) };
|
|
2944
2944
|
}
|
|
2945
|
-
},
|
|
2945
|
+
}, Zr = 8, Qr = {
|
|
2946
2946
|
type: "normal-from-height",
|
|
2947
2947
|
nodeClass: "vector",
|
|
2948
2948
|
label: "Normal From Height",
|
|
@@ -2966,11 +2966,11 @@ var Hr = [
|
|
|
2966
2966
|
}],
|
|
2967
2967
|
build(e) {
|
|
2968
2968
|
let t = e.inputs.height ?? k(.5);
|
|
2969
|
-
if (e.backend === "live") return { normal:
|
|
2970
|
-
let n = t, r =
|
|
2971
|
-
return { normal:
|
|
2969
|
+
if (e.backend === "live") return { normal: te(t, e.live("strength")) };
|
|
2970
|
+
let n = t, r = U(), i = ae(n).div(ae(r.x)), a = oe(n).div(oe(r.y)), o = e.live("strength"), s = W(i, a).mul(o), c = k(Zr), l = s.mul(c.div(s.length().pow(2).add(c.mul(c)).sqrt()));
|
|
2971
|
+
return { normal: be(G(l.x.negate(), l.y.negate(), k(1))).mul(.5).add(.5) };
|
|
2972
2972
|
}
|
|
2973
|
-
},
|
|
2973
|
+
}, $r = {
|
|
2974
2974
|
type: "normal-map",
|
|
2975
2975
|
nodeClass: "vector",
|
|
2976
2976
|
label: "Normal Map",
|
|
@@ -2997,13 +2997,13 @@ var Hr = [
|
|
|
2997
2997
|
default: 1
|
|
2998
2998
|
}],
|
|
2999
2999
|
build(e) {
|
|
3000
|
-
return { normal:
|
|
3000
|
+
return { normal: ve(e.inputs.color ?? G(.5, .5, 1), e.inputs.strength ?? e.live("strength")) };
|
|
3001
3001
|
}
|
|
3002
3002
|
};
|
|
3003
3003
|
//#endregion
|
|
3004
3004
|
//#region src/tsl/blender-mapping.ts
|
|
3005
|
-
function
|
|
3006
|
-
let t = E(e.x), n = E(e.y), r = E(e.z), i =
|
|
3005
|
+
function ei(e) {
|
|
3006
|
+
let t = E(e.x), n = E(e.y), r = E(e.z), i = z(e.x), a = z(e.y), o = z(e.z), s = t.mul(r), c = t.mul(o), l = i.mul(r), u = i.mul(o);
|
|
3007
3007
|
return {
|
|
3008
3008
|
m00: n.mul(r),
|
|
3009
3009
|
m10: a.mul(l).sub(c),
|
|
@@ -3016,24 +3016,24 @@ function qr(e) {
|
|
|
3016
3016
|
m22: n.mul(t)
|
|
3017
3017
|
};
|
|
3018
3018
|
}
|
|
3019
|
-
function
|
|
3020
|
-
return
|
|
3019
|
+
function ti(e, t) {
|
|
3020
|
+
return G(e.m00.mul(t.x).add(e.m10.mul(t.y)).add(e.m20.mul(t.z)), e.m01.mul(t.x).add(e.m11.mul(t.y)).add(e.m21.mul(t.z)), e.m02.mul(t.x).add(e.m12.mul(t.y)).add(e.m22.mul(t.z)));
|
|
3021
3021
|
}
|
|
3022
|
-
function
|
|
3023
|
-
return
|
|
3022
|
+
function ni(e, t) {
|
|
3023
|
+
return G(e.m00.mul(t.x).add(e.m01.mul(t.y)).add(e.m02.mul(t.z)), e.m10.mul(t.x).add(e.m11.mul(t.y)).add(e.m12.mul(t.z)), e.m20.mul(t.x).add(e.m21.mul(t.y)).add(e.m22.mul(t.z)));
|
|
3024
3024
|
}
|
|
3025
|
-
function
|
|
3026
|
-
let a =
|
|
3027
|
-
return i === 1 ?
|
|
3025
|
+
function ri(e, t, n, r, i) {
|
|
3026
|
+
let a = ei(n);
|
|
3027
|
+
return i === 1 ? ni(a, e.sub(t)).div(r) : i === 2 ? ti(a, e.mul(r)) : i === 3 ? ti(a, e.div(r)).normalize() : ti(a, e.mul(r)).add(t);
|
|
3028
3028
|
}
|
|
3029
3029
|
//#endregion
|
|
3030
3030
|
//#region src/graph/nodes/vector/mapping.ts
|
|
3031
|
-
var
|
|
3031
|
+
var ii = [
|
|
3032
3032
|
"point",
|
|
3033
3033
|
"texture",
|
|
3034
3034
|
"vector",
|
|
3035
3035
|
"normal"
|
|
3036
|
-
],
|
|
3036
|
+
], ai = {
|
|
3037
3037
|
type: "mapping",
|
|
3038
3038
|
nodeClass: "vector",
|
|
3039
3039
|
label: "Mapping",
|
|
@@ -3050,7 +3050,7 @@ var Zr = [
|
|
|
3050
3050
|
key: "mappingType",
|
|
3051
3051
|
label: "type",
|
|
3052
3052
|
type: "select",
|
|
3053
|
-
options:
|
|
3053
|
+
options: ii,
|
|
3054
3054
|
default: "point"
|
|
3055
3055
|
},
|
|
3056
3056
|
{
|
|
@@ -3085,10 +3085,10 @@ var Zr = [
|
|
|
3085
3085
|
}
|
|
3086
3086
|
],
|
|
3087
3087
|
build(e) {
|
|
3088
|
-
let t = e.inputs.vector ?? e.coord, n = Math.max(0,
|
|
3089
|
-
return { vector:
|
|
3088
|
+
let t = e.inputs.vector ?? e.coord, n = Math.max(0, ii.indexOf(e.constant("mappingType")));
|
|
3089
|
+
return { vector: ri(t, e.live("location"), e.live("rotation"), e.live("scale"), n) };
|
|
3090
3090
|
}
|
|
3091
|
-
},
|
|
3091
|
+
}, J = {
|
|
3092
3092
|
baseColor: {
|
|
3093
3093
|
key: "baseColor",
|
|
3094
3094
|
label: "Base Color",
|
|
@@ -3164,35 +3164,35 @@ var Zr = [
|
|
|
3164
3164
|
label: "Emission Strength",
|
|
3165
3165
|
kind: "float"
|
|
3166
3166
|
}
|
|
3167
|
-
},
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
],
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
],
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
],
|
|
3167
|
+
}, oi = [
|
|
3168
|
+
J.baseColor,
|
|
3169
|
+
J.alpha,
|
|
3170
|
+
J.normal,
|
|
3171
|
+
J.height,
|
|
3172
|
+
J.ambientOcclusion,
|
|
3173
|
+
J.emission,
|
|
3174
|
+
J.emissionStrength
|
|
3175
|
+
], si = [
|
|
3176
|
+
J.baseColor,
|
|
3177
|
+
J.alpha,
|
|
3178
|
+
J.normal,
|
|
3179
|
+
J.height
|
|
3180
|
+
], ci = [J.metallic, J.roughness], li = [
|
|
3181
|
+
J.ior,
|
|
3182
|
+
J.coat,
|
|
3183
|
+
J.coatRoughness,
|
|
3184
|
+
J.sheen,
|
|
3185
|
+
J.sheenRoughness,
|
|
3186
|
+
J.transmission
|
|
3187
|
+
], ui = [{
|
|
3188
3188
|
key: "bsdf",
|
|
3189
3189
|
kind: "shader"
|
|
3190
|
-
}],
|
|
3190
|
+
}], di = [
|
|
3191
3191
|
{
|
|
3192
3192
|
key: "materialType",
|
|
3193
3193
|
label: "type",
|
|
3194
3194
|
type: "select",
|
|
3195
|
-
options:
|
|
3195
|
+
options: Ue,
|
|
3196
3196
|
default: "physical"
|
|
3197
3197
|
},
|
|
3198
3198
|
{
|
|
@@ -3332,9 +3332,9 @@ var Zr = [
|
|
|
3332
3332
|
options: ["default"],
|
|
3333
3333
|
default: "default"
|
|
3334
3334
|
}
|
|
3335
|
-
],
|
|
3336
|
-
function
|
|
3337
|
-
let t =
|
|
3335
|
+
], fi = Object.fromEntries(di.filter((e) => e.type === "float" || e.type === "int").map((e) => [e.key, e.default]));
|
|
3336
|
+
function pi(e) {
|
|
3337
|
+
let t = Ge(e.materialType), n = new Set([
|
|
3338
3338
|
"materialType",
|
|
3339
3339
|
"baseColor",
|
|
3340
3340
|
"alpha",
|
|
@@ -3349,46 +3349,46 @@ function oi(e) {
|
|
|
3349
3349
|
"sheenRoughness",
|
|
3350
3350
|
"transmission"
|
|
3351
3351
|
]) n.add(e);
|
|
3352
|
-
return t === "phong" && (n.add("shininess"), n.add("specular")), t === "toon" && n.add("gradientSteps"), t === "matcap" && (n.delete("emission"), n.delete("emissionStrength"), n.add("matcap")),
|
|
3352
|
+
return t === "phong" && (n.add("shininess"), n.add("specular")), t === "toon" && n.add("gradientSteps"), t === "matcap" && (n.delete("emission"), n.delete("emissionStrength"), n.add("matcap")), di.filter((e) => n.has(e.key));
|
|
3353
3353
|
}
|
|
3354
|
-
var
|
|
3355
|
-
type:
|
|
3354
|
+
var mi = {
|
|
3355
|
+
type: Xe,
|
|
3356
3356
|
nodeClass: "shader",
|
|
3357
3357
|
label: "Material",
|
|
3358
3358
|
inputs: [
|
|
3359
|
-
|
|
3360
|
-
...
|
|
3361
|
-
...
|
|
3359
|
+
...oi,
|
|
3360
|
+
...ci,
|
|
3361
|
+
...li
|
|
3362
3362
|
],
|
|
3363
|
-
outputs:
|
|
3364
|
-
params:
|
|
3363
|
+
outputs: ui,
|
|
3364
|
+
params: di,
|
|
3365
3365
|
declare(e) {
|
|
3366
|
-
switch (
|
|
3366
|
+
switch (Ge(e.materialType)) {
|
|
3367
3367
|
case "standard": return {
|
|
3368
|
-
inputs: [
|
|
3369
|
-
outputs:
|
|
3368
|
+
inputs: [...oi, ...ci],
|
|
3369
|
+
outputs: ui
|
|
3370
3370
|
};
|
|
3371
3371
|
case "physical": return {
|
|
3372
3372
|
inputs: [
|
|
3373
|
-
|
|
3374
|
-
...
|
|
3375
|
-
...
|
|
3373
|
+
...oi,
|
|
3374
|
+
...ci,
|
|
3375
|
+
...li
|
|
3376
3376
|
],
|
|
3377
|
-
outputs:
|
|
3377
|
+
outputs: ui
|
|
3378
3378
|
};
|
|
3379
3379
|
case "matcap": return {
|
|
3380
|
-
inputs:
|
|
3381
|
-
outputs:
|
|
3380
|
+
inputs: si,
|
|
3381
|
+
outputs: ui
|
|
3382
3382
|
};
|
|
3383
3383
|
default: return {
|
|
3384
|
-
inputs:
|
|
3385
|
-
outputs:
|
|
3384
|
+
inputs: oi,
|
|
3385
|
+
outputs: ui
|
|
3386
3386
|
};
|
|
3387
3387
|
}
|
|
3388
3388
|
},
|
|
3389
|
-
paramsFor:
|
|
3389
|
+
paramsFor: pi,
|
|
3390
3390
|
build(e) {
|
|
3391
|
-
let t =
|
|
3391
|
+
let t = We[Ge(e.constant("materialType"))], n = (t) => e.inputs[t] ?? e.live(t), r = (t) => Number(e.constant(t) ?? fi[t] ?? 0), i = (t) => e.inputs[t] === void 0 ? r(t) > 0 ? e.live(t) : void 0 : e.inputs[t], a = e.inputs.emission !== void 0 || e.inputs.emissionStrength !== void 0 || (e.constant("emission") ?? "#000000") !== "#000000", o = t.emissive && a ? (e.inputs.emission ?? e.live("emission")).mul(e.inputs.emissionStrength ?? e.live("emissionStrength")) : void 0, s = {
|
|
3392
3392
|
baseColor: n("baseColor"),
|
|
3393
3393
|
normal: e.inputs.normal,
|
|
3394
3394
|
height: e.inputs.height,
|
|
@@ -3401,7 +3401,7 @@ var si = {
|
|
|
3401
3401
|
}
|
|
3402
3402
|
return { bsdf: s };
|
|
3403
3403
|
}
|
|
3404
|
-
},
|
|
3404
|
+
}, hi = [
|
|
3405
3405
|
{
|
|
3406
3406
|
key: "baseColor",
|
|
3407
3407
|
label: "base color",
|
|
@@ -3506,7 +3506,7 @@ var si = {
|
|
|
3506
3506
|
step: .1,
|
|
3507
3507
|
default: 1
|
|
3508
3508
|
}
|
|
3509
|
-
],
|
|
3509
|
+
], gi = Object.fromEntries(hi.filter((e) => e.type === "float" || e.type === "int").map((e) => [e.key, e.default])), _i = {
|
|
3510
3510
|
type: "principled-bsdf",
|
|
3511
3511
|
nodeClass: "shader",
|
|
3512
3512
|
label: "Principled BSDF",
|
|
@@ -3591,9 +3591,9 @@ var si = {
|
|
|
3591
3591
|
key: "bsdf",
|
|
3592
3592
|
kind: "shader"
|
|
3593
3593
|
}],
|
|
3594
|
-
params:
|
|
3594
|
+
params: hi,
|
|
3595
3595
|
build(e) {
|
|
3596
|
-
let t = (t) => e.inputs[t] ?? e.live(t), n = (t) => Number(e.constant(t) ??
|
|
3596
|
+
let t = (t) => e.inputs[t] ?? e.live(t), n = (t) => Number(e.constant(t) ?? gi[t] ?? 0), r = (t) => e.inputs[t] === void 0 ? n(t) > 0 ? e.live(t) : void 0 : e.inputs[t], i = e.inputs.emission !== void 0 || e.inputs.emissionStrength !== void 0 || (e.constant("emission") ?? "#000000") !== "#000000" ? (e.inputs.emission ?? e.live("emission")).mul(e.inputs.emissionStrength ?? e.live("emissionStrength")) : void 0, a = r("coat"), o = r("sheen");
|
|
3597
3597
|
return { bsdf: {
|
|
3598
3598
|
baseColor: t("baseColor"),
|
|
3599
3599
|
metallic: t("metallic"),
|
|
@@ -3611,7 +3611,7 @@ var si = {
|
|
|
3611
3611
|
transmission: r("transmission")
|
|
3612
3612
|
} };
|
|
3613
3613
|
}
|
|
3614
|
-
},
|
|
3614
|
+
}, vi = {
|
|
3615
3615
|
type: "emission",
|
|
3616
3616
|
nodeClass: "shader",
|
|
3617
3617
|
label: "Emission",
|
|
@@ -3645,20 +3645,20 @@ var si = {
|
|
|
3645
3645
|
build(e) {
|
|
3646
3646
|
let t = e.inputs.color ?? e.live("color"), n = e.inputs.strength ?? e.live("strength");
|
|
3647
3647
|
return { bsdf: {
|
|
3648
|
-
baseColor:
|
|
3648
|
+
baseColor: G(0),
|
|
3649
3649
|
roughness: k(1),
|
|
3650
3650
|
metallic: k(0),
|
|
3651
3651
|
emission: t.mul(n)
|
|
3652
3652
|
} };
|
|
3653
3653
|
}
|
|
3654
|
-
},
|
|
3655
|
-
emission:
|
|
3654
|
+
}, yi = {
|
|
3655
|
+
emission: G(0, 0, 0),
|
|
3656
3656
|
ambientOcclusion: k(1),
|
|
3657
3657
|
alpha: k(1),
|
|
3658
3658
|
coat: k(0),
|
|
3659
3659
|
sheen: k(0),
|
|
3660
3660
|
transmission: k(0)
|
|
3661
|
-
},
|
|
3661
|
+
}, bi = [
|
|
3662
3662
|
"baseColor",
|
|
3663
3663
|
"metallic",
|
|
3664
3664
|
"roughness",
|
|
@@ -3673,21 +3673,21 @@ var si = {
|
|
|
3673
3673
|
"sheenRoughness",
|
|
3674
3674
|
"transmission"
|
|
3675
3675
|
];
|
|
3676
|
-
function
|
|
3676
|
+
function xi(e, t, n) {
|
|
3677
3677
|
let r = {};
|
|
3678
|
-
for (let i of
|
|
3678
|
+
for (let i of bi) {
|
|
3679
3679
|
let a = e[i], o = t[i];
|
|
3680
3680
|
if (a === void 0 && o === void 0) continue;
|
|
3681
3681
|
if (a !== void 0 && o !== void 0) {
|
|
3682
|
-
r[i] =
|
|
3682
|
+
r[i] = F(a, o, n);
|
|
3683
3683
|
continue;
|
|
3684
3684
|
}
|
|
3685
|
-
let s =
|
|
3686
|
-
s === void 0 ? r[i] = a ?? o : r[i] = a === void 0 ?
|
|
3685
|
+
let s = yi[i];
|
|
3686
|
+
s === void 0 ? r[i] = a ?? o : r[i] = a === void 0 ? F(s, o, n) : F(a, s, n);
|
|
3687
3687
|
}
|
|
3688
3688
|
return r;
|
|
3689
3689
|
}
|
|
3690
|
-
var
|
|
3690
|
+
var Si = {
|
|
3691
3691
|
type: "mix-shader",
|
|
3692
3692
|
nodeClass: "shader",
|
|
3693
3693
|
label: "Mix Shader",
|
|
@@ -3722,9 +3722,9 @@ var hi = {
|
|
|
3722
3722
|
default: .5
|
|
3723
3723
|
}],
|
|
3724
3724
|
build(e) {
|
|
3725
|
-
return { shader:
|
|
3725
|
+
return { shader: xi(e.inputs.shaderA ?? {}, e.inputs.shaderB ?? {}, e.inputs.fac ?? e.live("fac")) };
|
|
3726
3726
|
}
|
|
3727
|
-
},
|
|
3727
|
+
}, Ci = {
|
|
3728
3728
|
type: "material-output",
|
|
3729
3729
|
nodeClass: "output",
|
|
3730
3730
|
label: "Material Output",
|
|
@@ -3751,7 +3751,7 @@ var hi = {
|
|
|
3751
3751
|
build() {
|
|
3752
3752
|
return {};
|
|
3753
3753
|
}
|
|
3754
|
-
},
|
|
3754
|
+
}, wi = {
|
|
3755
3755
|
type: "group",
|
|
3756
3756
|
nodeClass: "group",
|
|
3757
3757
|
label: "Group",
|
|
@@ -3761,7 +3761,7 @@ var hi = {
|
|
|
3761
3761
|
build() {
|
|
3762
3762
|
return {};
|
|
3763
3763
|
}
|
|
3764
|
-
},
|
|
3764
|
+
}, Ti = {
|
|
3765
3765
|
type: "group-input",
|
|
3766
3766
|
nodeClass: "input",
|
|
3767
3767
|
label: "Group Input",
|
|
@@ -3771,7 +3771,7 @@ var hi = {
|
|
|
3771
3771
|
build() {
|
|
3772
3772
|
return {};
|
|
3773
3773
|
}
|
|
3774
|
-
},
|
|
3774
|
+
}, Ei = {
|
|
3775
3775
|
type: "group-output",
|
|
3776
3776
|
nodeClass: "output",
|
|
3777
3777
|
label: "Group Output",
|
|
@@ -3784,7 +3784,7 @@ var hi = {
|
|
|
3784
3784
|
};
|
|
3785
3785
|
//#endregion
|
|
3786
3786
|
//#region src/graph/registry.ts
|
|
3787
|
-
function
|
|
3787
|
+
function Y(e, t) {
|
|
3788
3788
|
if (e.ports) return e.ports;
|
|
3789
3789
|
let n = t.get(e.type);
|
|
3790
3790
|
return n.declare ? n.declare(e.params) : {
|
|
@@ -3792,11 +3792,11 @@ function Q(e, t) {
|
|
|
3792
3792
|
outputs: n.outputs
|
|
3793
3793
|
};
|
|
3794
3794
|
}
|
|
3795
|
-
function
|
|
3795
|
+
function Di(e, t) {
|
|
3796
3796
|
let n = t.get(e.type);
|
|
3797
3797
|
return n.paramsFor ? n.paramsFor(e.params) : n.params;
|
|
3798
3798
|
}
|
|
3799
|
-
var
|
|
3799
|
+
var Oi = class {
|
|
3800
3800
|
defs = /* @__PURE__ */ new Map();
|
|
3801
3801
|
register(e) {
|
|
3802
3802
|
if (this.defs.has(e.type)) throw Error(`Duplicate node type: ${e.type}`);
|
|
@@ -3814,25 +3814,25 @@ var xi = class {
|
|
|
3814
3814
|
return [...this.defs.values()];
|
|
3815
3815
|
}
|
|
3816
3816
|
};
|
|
3817
|
-
function
|
|
3818
|
-
return new
|
|
3817
|
+
function ki() {
|
|
3818
|
+
return new Oi().register(ut).register(dt).register(Kt).register(nn).register(rn).register(Fn).register(In).register(Bn).register(Un).register(qn).register(Zn).register(lr).register(dr).register(_r).register(xr).register(Sr).register(Cr).register(wr).register(Tr).register(Er).register(Ar).register(Pr).register(Fr).register(Ir).register(Lr).register(Rr).register(zr).register(Br).register(Vr).register(Hr).register(Ur).register(qr).register(Xr).register(Qr).register($r).register(ai).register(mi).register(_i).register(vi).register(Si).register(Ci).register(wi).register(Ti).register(Ei);
|
|
3819
3819
|
}
|
|
3820
|
-
var
|
|
3821
|
-
function
|
|
3822
|
-
let n = Math.max(2, Math.min(5, Math.round(t ?? 3))), r =
|
|
3820
|
+
var Ai = ki(), ji = /* @__PURE__ */ new Map();
|
|
3821
|
+
function Mi(t) {
|
|
3822
|
+
let n = Math.max(2, Math.min(5, Math.round(t ?? 3))), r = ji.get(n);
|
|
3823
3823
|
if (r) return r;
|
|
3824
3824
|
let i = new Uint8Array(n);
|
|
3825
3825
|
for (let e = 0; e < n; e++) i[e] = Math.round(e / (n - 1) * 255);
|
|
3826
3826
|
let a = new e.DataTexture(i, n, 1, e.RedFormat);
|
|
3827
|
-
return a.minFilter = e.NearestFilter, a.magFilter = e.NearestFilter, a.needsUpdate = !0,
|
|
3827
|
+
return a.minFilter = e.NearestFilter, a.magFilter = e.NearestFilter, a.needsUpdate = !0, ji.set(n, a), a;
|
|
3828
3828
|
}
|
|
3829
|
-
function
|
|
3829
|
+
function Ni(e) {
|
|
3830
3830
|
return null;
|
|
3831
3831
|
}
|
|
3832
3832
|
//#endregion
|
|
3833
3833
|
//#region src/graph/compiler.ts
|
|
3834
|
-
var
|
|
3835
|
-
function
|
|
3834
|
+
var Pi = 2048;
|
|
3835
|
+
function Fi(e, t, n) {
|
|
3836
3836
|
let r = new Map(t.nodes.map((e) => [e.id, e])), i = /* @__PURE__ */ new Set(), a = [e];
|
|
3837
3837
|
for (; a.length;) {
|
|
3838
3838
|
let e = a.pop();
|
|
@@ -3846,11 +3846,11 @@ function Oi(e, t, n) {
|
|
|
3846
3846
|
}
|
|
3847
3847
|
return !1;
|
|
3848
3848
|
}
|
|
3849
|
-
function
|
|
3849
|
+
function Ii(e, t) {
|
|
3850
3850
|
let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), o = (e) => {
|
|
3851
3851
|
let t = a.get(e);
|
|
3852
3852
|
return t || (t = new Map(e.nodes.map((e) => [e.id, e])), a.set(e, t)), t;
|
|
3853
|
-
}, s = (e) => e.nodes.find((e) => e.type ===
|
|
3853
|
+
}, s = (e) => e.nodes.find((e) => e.type === qe)?.id, c = (e, t, r, i) => {
|
|
3854
3854
|
if (t === s(e)) {
|
|
3855
3855
|
i(r);
|
|
3856
3856
|
return;
|
|
@@ -3874,7 +3874,7 @@ function ki(e, t) {
|
|
|
3874
3874
|
i.add(a);
|
|
3875
3875
|
let o = e.subgraph;
|
|
3876
3876
|
if (!o) return;
|
|
3877
|
-
let s = o.nodes.find((e) => e.type ===
|
|
3877
|
+
let s = o.nodes.find((e) => e.type === Je), l = s && o.edges.find((e) => e.toNode === s.id && e.toInput === t);
|
|
3878
3878
|
l && c(o, l.fromNode, l.fromOutput, (t) => {
|
|
3879
3879
|
for (let i of n.edges) i.toNode === e.id && i.toInput === t && c(n, i.fromNode, i.fromOutput, r);
|
|
3880
3880
|
});
|
|
@@ -3885,19 +3885,19 @@ function ki(e, t) {
|
|
|
3885
3885
|
};
|
|
3886
3886
|
return d(e, () => {}), n;
|
|
3887
3887
|
}
|
|
3888
|
-
function
|
|
3889
|
-
return t === "float" ?
|
|
3888
|
+
function Li(e, t) {
|
|
3889
|
+
return t === "float" ? G(e) : e;
|
|
3890
3890
|
}
|
|
3891
|
-
function
|
|
3892
|
-
let n =
|
|
3891
|
+
function Ri(e, t) {
|
|
3892
|
+
let n = V(e, U());
|
|
3893
3893
|
return t === "float" ? n.r : n.xyz;
|
|
3894
3894
|
}
|
|
3895
|
-
function
|
|
3896
|
-
let t = e.nodes.find((e) => e.type ===
|
|
3895
|
+
function zi(e) {
|
|
3896
|
+
let t = e.nodes.find((e) => e.type === Ye)?.params?.outputResolution, n = typeof t == "string" ? Number(t) : typeof t == "number" ? t : NaN;
|
|
3897
3897
|
return Number.isFinite(n) && n > 0 ? n : 1024;
|
|
3898
3898
|
}
|
|
3899
|
-
function
|
|
3900
|
-
let t = e.nodes.find((e) => e.type ===
|
|
3899
|
+
function Bi(e) {
|
|
3900
|
+
let t = e.nodes.find((e) => e.type === Ye), n = t && e.edges.find((e) => e.toNode === t.id && e.toInput === "surface"), r = n && e.nodes.find((e) => e.id === n.fromNode);
|
|
3901
3901
|
if (!r || r.type !== "shader-material") return {
|
|
3902
3902
|
type: "physical",
|
|
3903
3903
|
settings: {}
|
|
@@ -3907,7 +3907,7 @@ function Ni(e) {
|
|
|
3907
3907
|
return Number.isFinite(n) ? n : t;
|
|
3908
3908
|
};
|
|
3909
3909
|
return {
|
|
3910
|
-
type:
|
|
3910
|
+
type: Ge(i.materialType),
|
|
3911
3911
|
settings: {
|
|
3912
3912
|
shininess: a(i.shininess, 30),
|
|
3913
3913
|
specular: typeof i.specular == "string" ? i.specular : "#111111",
|
|
@@ -3916,13 +3916,13 @@ function Ni(e) {
|
|
|
3916
3916
|
}
|
|
3917
3917
|
};
|
|
3918
3918
|
}
|
|
3919
|
-
function
|
|
3920
|
-
let t = e.nodes.find((e) => e.type ===
|
|
3919
|
+
function Vi(e) {
|
|
3920
|
+
let t = e.nodes.find((e) => e.type === Ye), n = t && e.edges.find((e) => e.toNode === t.id && e.toInput === "surface"), r = n && e.nodes.find((e) => e.id === n.fromNode), i = r && r.type === "shader-material" ? r.params : {}, a = (e, t) => {
|
|
3921
3921
|
let n = Number(e);
|
|
3922
3922
|
return Number.isFinite(n) ? n : t;
|
|
3923
3923
|
}, o = (e, t) => typeof e == "string" ? e : t;
|
|
3924
3924
|
return {
|
|
3925
|
-
type:
|
|
3925
|
+
type: Ge(i.materialType),
|
|
3926
3926
|
baseColor: o(i.baseColor, "#cccccc"),
|
|
3927
3927
|
metallic: a(i.metallic, 0),
|
|
3928
3928
|
roughness: a(i.roughness, .5),
|
|
@@ -3941,14 +3941,14 @@ function Pi(e) {
|
|
|
3941
3941
|
matcap: o(i.matcap, "default")
|
|
3942
3942
|
};
|
|
3943
3943
|
}
|
|
3944
|
-
function
|
|
3944
|
+
function Hi(e, t, n) {
|
|
3945
3945
|
if (n.backend === "live" || !n.allocCache || !t.bakeTileable) return 1;
|
|
3946
3946
|
let r = e.params.tileSize, i = typeof r == "string" && r !== "off" ? Number(r) : NaN;
|
|
3947
3947
|
if (!Number.isFinite(i) || i <= 0) return 1;
|
|
3948
3948
|
let a = n.outputResolution ?? 1024, o = Math.max(1, Math.round(Number(e.params.scale) || 1));
|
|
3949
3949
|
return Math.max(1, Math.min(Math.round(a / i), o));
|
|
3950
3950
|
}
|
|
3951
|
-
function
|
|
3951
|
+
function Ui(e, t, n, r, i, a) {
|
|
3952
3952
|
if (r.backend === "live" || !r.allocCache || !t.bakeTileable || n.vector !== void 0 || n.field === void 0) return;
|
|
3953
3953
|
let o = e.params.tileSize, s = typeof o == "string" && o !== "off" ? Number(o) : NaN;
|
|
3954
3954
|
if (!Number.isFinite(s) || s <= 0) return;
|
|
@@ -3956,41 +3956,41 @@ function Ii(e, t, n, r, i, a) {
|
|
|
3956
3956
|
return i.push({
|
|
3957
3957
|
cacheId: c,
|
|
3958
3958
|
kind: "float",
|
|
3959
|
-
colorNode:
|
|
3959
|
+
colorNode: Li(n.field, "float"),
|
|
3960
3960
|
sizing: { size: s }
|
|
3961
|
-
}), { field:
|
|
3961
|
+
}), { field: V(l, U().mul(k(a))).r };
|
|
3962
3962
|
}
|
|
3963
|
-
function
|
|
3963
|
+
function Wi(e) {
|
|
3964
3964
|
let t = 0;
|
|
3965
|
-
for (let n of e.nodes) t += 1, n.type === "group" && n.subgraph && (t +=
|
|
3965
|
+
for (let n of e.nodes) t += 1, n.type === "group" && n.subgraph && (t += Wi(n.subgraph));
|
|
3966
3966
|
return t;
|
|
3967
3967
|
}
|
|
3968
|
-
function
|
|
3968
|
+
function Gi(e, t, n) {
|
|
3969
3969
|
let r = {
|
|
3970
3970
|
...n,
|
|
3971
|
-
outputResolution: n.outputResolution ??
|
|
3972
|
-
}, i = r.backend === "live" ?
|
|
3971
|
+
outputResolution: n.outputResolution ?? zi(e)
|
|
3972
|
+
}, i = r.backend === "live" ? Ce : G(U().x, U().y, k(0)), a = r.soloNodeId ? { id: r.soloNodeId } : void 0, o = [], { outputs: s, uniforms: c, usage: l } = qi(e, t, r, i, o, r.allocCache ? Ii(e, t) : /* @__PURE__ */ new Set(), void 0, a);
|
|
3973
3973
|
return {
|
|
3974
|
-
bundle: a && a.value !== void 0 && a.kind && a.kind !== "shader" ?
|
|
3974
|
+
bundle: a && a.value !== void 0 && a.kind && a.kind !== "shader" ? Ki(a.value, a.kind) : ia(e, t, s),
|
|
3975
3975
|
uniforms: c,
|
|
3976
3976
|
cachePlan: o,
|
|
3977
3977
|
paramUsage: l
|
|
3978
3978
|
};
|
|
3979
3979
|
}
|
|
3980
|
-
function
|
|
3980
|
+
function Ki(e, t) {
|
|
3981
3981
|
return {
|
|
3982
|
-
baseColor: t === "float" ?
|
|
3982
|
+
baseColor: t === "float" ? G(e) : e,
|
|
3983
3983
|
roughness: k(1),
|
|
3984
3984
|
metallic: k(0)
|
|
3985
3985
|
};
|
|
3986
3986
|
}
|
|
3987
|
-
function
|
|
3988
|
-
|
|
3989
|
-
let c =
|
|
3987
|
+
function qi(e, t, n, r, i, a, o, s) {
|
|
3988
|
+
oa(e, t, o !== void 0);
|
|
3989
|
+
let c = aa(e), l = new Map(e.nodes.map((e) => [e.id, e])), u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
3990
3990
|
for (let p of c) {
|
|
3991
3991
|
let c = l.get(p);
|
|
3992
3992
|
if (!c) continue;
|
|
3993
|
-
let m =
|
|
3993
|
+
let m = Y(c, t);
|
|
3994
3994
|
if (c.type === "group-input") {
|
|
3995
3995
|
let e = {};
|
|
3996
3996
|
for (let t of m.outputs) e[t.key] = o?.[t.key];
|
|
@@ -3998,19 +3998,19 @@ function Bi(e, t, n, r, i, a, o, s) {
|
|
|
3998
3998
|
continue;
|
|
3999
3999
|
}
|
|
4000
4000
|
if (c.type === "group") {
|
|
4001
|
-
let o =
|
|
4001
|
+
let o = Yi(c, t, n, r, i, a, ea(c, e, u, l, t), s);
|
|
4002
4002
|
u.set(p, o.outputs);
|
|
4003
4003
|
for (let [e, t] of o.uniforms) d.set(e, t);
|
|
4004
4004
|
for (let [e, t] of o.usage) f.set(e, t);
|
|
4005
4005
|
continue;
|
|
4006
4006
|
}
|
|
4007
|
-
let h =
|
|
4007
|
+
let h = ea(c, e, u, l, t), g = t.get(c.type), _ = ra(g, c);
|
|
4008
4008
|
d.set(p, _);
|
|
4009
|
-
let v =
|
|
4010
|
-
u.set(p,
|
|
4009
|
+
let v = Hi(c, g, n), y = Ji(p, c, g, h, _, r, n, v, f), b = g.build(y);
|
|
4010
|
+
u.set(p, Ui(c, g, b, n, i, v) ?? b);
|
|
4011
4011
|
}
|
|
4012
4012
|
if (s && s.value === void 0) {
|
|
4013
|
-
let e = l.get(s.id), n = e ?
|
|
4013
|
+
let e = l.get(s.id), n = e ? Y(e, t).outputs[0] : void 0;
|
|
4014
4014
|
e && n && (s.value = u.get(s.id)?.[n.key], s.kind = n.kind);
|
|
4015
4015
|
}
|
|
4016
4016
|
return {
|
|
@@ -4019,7 +4019,7 @@ function Bi(e, t, n, r, i, a, o, s) {
|
|
|
4019
4019
|
usage: f
|
|
4020
4020
|
};
|
|
4021
4021
|
}
|
|
4022
|
-
function
|
|
4022
|
+
function Ji(t, n, r, i, a, o, s, c, l) {
|
|
4023
4023
|
let u = {};
|
|
4024
4024
|
l.set(t, u);
|
|
4025
4025
|
let d = n.params, f = (e) => r.params.find((t) => t.key === e)?.default;
|
|
@@ -4041,36 +4041,36 @@ function Vi(t, n, r, i, a, o, s, c, l) {
|
|
|
4041
4041
|
if (i === "vec3") {
|
|
4042
4042
|
let t = [];
|
|
4043
4043
|
for (let n = 0; n < a.length; n += 3) t.push(new e.Vector3(a[n], a[n + 1], a[n + 2]));
|
|
4044
|
-
return
|
|
4044
|
+
return Le(t);
|
|
4045
4045
|
}
|
|
4046
|
-
return
|
|
4046
|
+
return Le(Array.from(a), "float");
|
|
4047
4047
|
}
|
|
4048
4048
|
};
|
|
4049
4049
|
}
|
|
4050
|
-
function
|
|
4050
|
+
function Yi(e, t, n, r, i, a, o, s) {
|
|
4051
4051
|
let c = e.subgraph;
|
|
4052
4052
|
if (!c) return {
|
|
4053
4053
|
outputs: {},
|
|
4054
4054
|
uniforms: /* @__PURE__ */ new Map(),
|
|
4055
4055
|
usage: /* @__PURE__ */ new Map()
|
|
4056
4056
|
};
|
|
4057
|
-
let { outputs: l, uniforms: u, usage: d } =
|
|
4057
|
+
let { outputs: l, uniforms: u, usage: d } = qi(c, t, n, r, i, a, o, s), f = c.nodes.find((e) => e.type === Je), p = {};
|
|
4058
4058
|
if (!f) return {
|
|
4059
4059
|
outputs: p,
|
|
4060
4060
|
uniforms: u,
|
|
4061
4061
|
usage: d
|
|
4062
4062
|
};
|
|
4063
4063
|
let m = new Map(c.nodes.map((e) => [e.id, e]));
|
|
4064
|
-
for (let r of
|
|
4065
|
-
let o = c.edges.find((e) => e.toNode === f.id && e.toInput === r.key), u = o ?
|
|
4064
|
+
for (let r of Y(f, t).inputs) {
|
|
4065
|
+
let o = c.edges.find((e) => e.toNode === f.id && e.toInput === r.key), u = o ? ta(o, r.kind, l, m, t) : void 0;
|
|
4066
4066
|
if (n.allocCache && u !== void 0 && r.kind !== "shader" && !s) {
|
|
4067
|
-
let s = `${e.id}/${r.key}`, l = o &&
|
|
4067
|
+
let s = `${e.id}/${r.key}`, l = o && Fi(o.fromNode, c, t) || a.has(s) ? { minSize: Pi } : void 0, d = n.allocCache(s, r.kind, l);
|
|
4068
4068
|
i.push({
|
|
4069
4069
|
cacheId: s,
|
|
4070
4070
|
kind: r.kind,
|
|
4071
|
-
colorNode:
|
|
4071
|
+
colorNode: Li(u, r.kind),
|
|
4072
4072
|
sizing: l
|
|
4073
|
-
}), p[r.key] =
|
|
4073
|
+
}), p[r.key] = Ri(d, r.kind);
|
|
4074
4074
|
} else p[r.key] = u;
|
|
4075
4075
|
}
|
|
4076
4076
|
return {
|
|
@@ -4079,110 +4079,110 @@ function Hi(e, t, n, r, i, a, o, s) {
|
|
|
4079
4079
|
usage: d
|
|
4080
4080
|
};
|
|
4081
4081
|
}
|
|
4082
|
-
var
|
|
4082
|
+
var Xi = {
|
|
4083
4083
|
side: e.DoubleSide,
|
|
4084
4084
|
polygonOffset: !0,
|
|
4085
4085
|
polygonOffsetFactor: 1,
|
|
4086
4086
|
polygonOffsetUnits: 1
|
|
4087
4087
|
};
|
|
4088
|
-
function
|
|
4088
|
+
function Zi(t = "physical", n = {}) {
|
|
4089
4089
|
switch (t) {
|
|
4090
|
-
case "standard": return new
|
|
4090
|
+
case "standard": return new h({
|
|
4091
4091
|
metalness: 0,
|
|
4092
4092
|
roughness: .9,
|
|
4093
|
-
...
|
|
4093
|
+
...Xi
|
|
4094
4094
|
});
|
|
4095
|
-
case "lambert": return new
|
|
4096
|
-
case "phong": return new
|
|
4095
|
+
case "lambert": return new d({ ...Xi });
|
|
4096
|
+
case "phong": return new p({
|
|
4097
4097
|
shininess: n.shininess ?? 30,
|
|
4098
4098
|
specular: new e.Color(n.specular ?? "#111111"),
|
|
4099
|
-
...
|
|
4099
|
+
...Xi
|
|
4100
4100
|
});
|
|
4101
|
-
case "toon": return new
|
|
4102
|
-
gradientMap:
|
|
4103
|
-
...
|
|
4101
|
+
case "toon": return new g({
|
|
4102
|
+
gradientMap: Mi(n.gradientSteps),
|
|
4103
|
+
...Xi
|
|
4104
4104
|
});
|
|
4105
|
-
case "matcap": return new
|
|
4106
|
-
matcap:
|
|
4107
|
-
...
|
|
4105
|
+
case "matcap": return new f({
|
|
4106
|
+
matcap: Ni(n.matcap),
|
|
4107
|
+
...Xi
|
|
4108
4108
|
});
|
|
4109
|
-
default: return new
|
|
4109
|
+
default: return new m({
|
|
4110
4110
|
metalness: 0,
|
|
4111
4111
|
roughness: .9,
|
|
4112
|
-
...
|
|
4112
|
+
...Xi
|
|
4113
4113
|
});
|
|
4114
4114
|
}
|
|
4115
4115
|
}
|
|
4116
|
-
function
|
|
4117
|
-
let r =
|
|
4116
|
+
function Qi(e, t, n) {
|
|
4117
|
+
let r = We[n], i = e;
|
|
4118
4118
|
if (t.baseColor && (i.colorNode = t.baseColor), t.normal && (i.normalNode = t.normal), t.alpha && (i.opacityNode = t.alpha, i.transparent = !0), r.ao) {
|
|
4119
|
-
let e =
|
|
4119
|
+
let e = w("vertexAo", "float");
|
|
4120
4120
|
i.aoNode = t.ambientOcclusion ? t.ambientOcclusion.mul(e) : e;
|
|
4121
4121
|
}
|
|
4122
4122
|
r.emissive && t.emission && (i.emissiveNode = t.emission), r.roughMetal && (t.roughness && (i.roughnessNode = t.roughness), t.metallic && (i.metalnessNode = t.metallic)), r.physicalLobes && (t.ior && (i.iorNode = t.ior), t.coat && (i.clearcoatNode = t.coat), t.coatRoughness && (i.clearcoatRoughnessNode = t.coatRoughness), t.sheen && (i.sheenNode = t.sheen), t.sheenRoughness && (i.sheenRoughnessNode = t.sheenRoughness), t.transmission && (i.transmissionNode = t.transmission));
|
|
4123
4123
|
}
|
|
4124
|
-
function
|
|
4125
|
-
let { bundle: r, uniforms: i } =
|
|
4126
|
-
return
|
|
4124
|
+
function $i(e, t, n) {
|
|
4125
|
+
let { bundle: r, uniforms: i } = Gi(e, t, n), { type: a, settings: o } = Bi(e), s = Zi(a, o);
|
|
4126
|
+
return Qi(s, r, a), {
|
|
4127
4127
|
material: s,
|
|
4128
4128
|
uniforms: i
|
|
4129
4129
|
};
|
|
4130
4130
|
}
|
|
4131
|
-
function
|
|
4131
|
+
function ea(e, t, n, r, i) {
|
|
4132
4132
|
let a = {};
|
|
4133
|
-
for (let o of
|
|
4133
|
+
for (let o of Y(e, i).inputs) {
|
|
4134
4134
|
let s = t.edges.find((t) => t.toNode === e.id && t.toInput === o.key);
|
|
4135
|
-
a[o.key] = s ?
|
|
4135
|
+
a[o.key] = s ? ta(s, o.kind, n, r, i) : void 0;
|
|
4136
4136
|
}
|
|
4137
4137
|
return a;
|
|
4138
4138
|
}
|
|
4139
|
-
function
|
|
4139
|
+
function ta(e, t, n, r, i) {
|
|
4140
4140
|
let a = n.get(e.fromNode)?.[e.fromOutput];
|
|
4141
4141
|
if (a === void 0) return;
|
|
4142
|
-
let o = r.get(e.fromNode), s = o ?
|
|
4142
|
+
let o = r.get(e.fromNode), s = o ? Y(o, i).outputs.find((t) => t.key === e.fromOutput)?.kind : void 0;
|
|
4143
4143
|
if (s && s !== t) {
|
|
4144
|
-
let e =
|
|
4145
|
-
e && (a =
|
|
4144
|
+
let e = $e(s, t);
|
|
4145
|
+
e && (a = na(a, e));
|
|
4146
4146
|
}
|
|
4147
4147
|
return a;
|
|
4148
4148
|
}
|
|
4149
|
-
function
|
|
4149
|
+
function na(e, t) {
|
|
4150
4150
|
switch (t) {
|
|
4151
4151
|
case "float-to-vector":
|
|
4152
|
-
case "float-to-color": return
|
|
4152
|
+
case "float-to-color": return G(e);
|
|
4153
4153
|
case "vector-to-float": return e.x.add(e.y).add(e.z).div(3);
|
|
4154
|
-
case "color-to-float": return
|
|
4154
|
+
case "color-to-float": return he(e);
|
|
4155
4155
|
case "identity":
|
|
4156
4156
|
case "vector-to-color":
|
|
4157
4157
|
case "color-to-vector": return e;
|
|
4158
4158
|
}
|
|
4159
4159
|
}
|
|
4160
|
-
function
|
|
4160
|
+
function ra(t, n) {
|
|
4161
4161
|
let r = {};
|
|
4162
4162
|
for (let i of t.params) {
|
|
4163
4163
|
let t = n.params[i.key] ?? i.default;
|
|
4164
|
-
if (i.type === "color") r[i.key] =
|
|
4164
|
+
if (i.type === "color") r[i.key] = Ie(new e.Color(t));
|
|
4165
4165
|
else if (i.type === "vec3") {
|
|
4166
4166
|
let n = t ?? {
|
|
4167
4167
|
x: 0,
|
|
4168
4168
|
y: 0,
|
|
4169
4169
|
z: 0
|
|
4170
4170
|
};
|
|
4171
|
-
r[i.key] =
|
|
4171
|
+
r[i.key] = Ie(new e.Vector3(n.x, n.y, n.z));
|
|
4172
4172
|
} else if (i.type === "float" || i.type === "int") {
|
|
4173
4173
|
let e = Number(t);
|
|
4174
|
-
r[i.key] =
|
|
4175
|
-
} else i.type === "curve" && (r[i.key] =
|
|
4174
|
+
r[i.key] = Ie(Number.isFinite(e) ? e : Number(i.default) || 0);
|
|
4175
|
+
} else i.type === "curve" && (r[i.key] = Le(He(t), "float"));
|
|
4176
4176
|
}
|
|
4177
4177
|
return r;
|
|
4178
4178
|
}
|
|
4179
|
-
function
|
|
4180
|
-
let r = e.nodes.find((e) => e.type ===
|
|
4179
|
+
function ia(e, t, n) {
|
|
4180
|
+
let r = e.nodes.find((e) => e.type === Ye);
|
|
4181
4181
|
if (!r) return {};
|
|
4182
4182
|
let i = e.edges.find((e) => e.toNode === r.id && e.toInput === "surface");
|
|
4183
|
-
return i ?
|
|
4183
|
+
return i ? ta(i, "shader", n, new Map(e.nodes.map((e) => [e.id, e])), t) ?? {} : {};
|
|
4184
4184
|
}
|
|
4185
|
-
function
|
|
4185
|
+
function aa(e) {
|
|
4186
4186
|
let t = /* @__PURE__ */ new Map();
|
|
4187
4187
|
for (let n of e.nodes) t.set(n.id, 0);
|
|
4188
4188
|
let n = /* @__PURE__ */ new Map();
|
|
@@ -4199,18 +4199,18 @@ function Qi(e) {
|
|
|
4199
4199
|
if (i.length !== e.nodes.length) throw Error("Material graph has a cycle");
|
|
4200
4200
|
return i;
|
|
4201
4201
|
}
|
|
4202
|
-
function
|
|
4203
|
-
let r = n ?
|
|
4202
|
+
function oa(e, t, n = !1) {
|
|
4203
|
+
let r = n ? Je : Ye, i = e.nodes.filter((e) => e.type === r);
|
|
4204
4204
|
if (i.length !== 1) throw Error(`Expected exactly one ${r} node, found ${i.length}`);
|
|
4205
4205
|
let a = new Map(e.nodes.map((e) => [e.id, e])), o = /* @__PURE__ */ new Set();
|
|
4206
4206
|
for (let n of e.edges) {
|
|
4207
4207
|
let e = a.get(n.fromNode), r = a.get(n.toNode);
|
|
4208
4208
|
if (!e) throw Error(`Edge from unknown node '${n.fromNode}'`);
|
|
4209
4209
|
if (!r) throw Error(`Edge to unknown node '${n.toNode}'`);
|
|
4210
|
-
let i =
|
|
4210
|
+
let i = Y(e, t).outputs.find((e) => e.key === n.fromOutput), s = Y(r, t).inputs.find((e) => e.key === n.toInput);
|
|
4211
4211
|
if (!i) throw Error(`Node '${e.type}' has no output '${n.fromOutput}'`);
|
|
4212
4212
|
if (!s) throw Error(`Node '${r.type}' has no input '${n.toInput}'`);
|
|
4213
|
-
if (i.kind !== s.kind &&
|
|
4213
|
+
if (i.kind !== s.kind && !$e(i.kind, s.kind)) throw Error(`Type mismatch (no coercion): ${e.type}.${n.fromOutput} (${i.kind}) -> ${r.type}.${n.toInput} (${s.kind})`);
|
|
4214
4214
|
let c = `${n.toNode}/${n.toInput}`;
|
|
4215
4215
|
if (o.has(c)) throw Error(`Multiple connections into ${r.type}.${n.toInput}`);
|
|
4216
4216
|
o.add(c);
|
|
@@ -4218,54 +4218,54 @@ function $i(e, t, n = !1) {
|
|
|
4218
4218
|
}
|
|
4219
4219
|
//#endregion
|
|
4220
4220
|
//#region src/document.ts
|
|
4221
|
-
var
|
|
4222
|
-
function
|
|
4221
|
+
var sa = 4;
|
|
4222
|
+
function ca(e) {
|
|
4223
4223
|
return structuredClone(e);
|
|
4224
4224
|
}
|
|
4225
|
-
function
|
|
4226
|
-
return
|
|
4225
|
+
function la() {
|
|
4226
|
+
return ca(ze);
|
|
4227
4227
|
}
|
|
4228
|
-
function
|
|
4229
|
-
for (let t of e.nodes) t.type === "principled-bsdf" && (t.type =
|
|
4228
|
+
function ua(e) {
|
|
4229
|
+
for (let t of e.nodes) t.type === "principled-bsdf" && (t.type = Xe, t.params = {
|
|
4230
4230
|
...t.params,
|
|
4231
4231
|
materialType: "physical"
|
|
4232
|
-
}), t.subgraph &&
|
|
4232
|
+
}), t.subgraph && ua(t.subgraph);
|
|
4233
4233
|
}
|
|
4234
|
-
var
|
|
4234
|
+
var da = new Set([
|
|
4235
4235
|
"curl",
|
|
4236
4236
|
"paper",
|
|
4237
4237
|
"wool",
|
|
4238
4238
|
"stone",
|
|
4239
4239
|
"erosion"
|
|
4240
4240
|
]);
|
|
4241
|
-
function
|
|
4242
|
-
for (let t of e.nodes) t.type === "tileable-noise" &&
|
|
4241
|
+
function fa(e) {
|
|
4242
|
+
for (let t of e.nodes) t.type === "tileable-noise" && da.has(t.params.noiseType) && (t.params = {
|
|
4243
4243
|
...t.params,
|
|
4244
4244
|
preset: t.params.noiseType,
|
|
4245
4245
|
noiseType: "perlin-fbm"
|
|
4246
|
-
}), t.subgraph &&
|
|
4246
|
+
}), t.subgraph && fa(t.subgraph);
|
|
4247
4247
|
}
|
|
4248
|
-
function
|
|
4249
|
-
let t =
|
|
4250
|
-
return (e.version ?? 0) < 3 &&
|
|
4248
|
+
function pa(e) {
|
|
4249
|
+
let t = ca(e);
|
|
4250
|
+
return (e.version ?? 0) < 3 && ua(t), (e.version ?? 0) < 4 && fa(t), t.version = 4, t;
|
|
4251
4251
|
}
|
|
4252
|
-
function
|
|
4252
|
+
function ma(e, t) {
|
|
4253
4253
|
return e.nodes.find((e) => e.id === t);
|
|
4254
4254
|
}
|
|
4255
|
-
function
|
|
4255
|
+
function ha(e, t) {
|
|
4256
4256
|
return e.find((e) => e.key === t);
|
|
4257
4257
|
}
|
|
4258
|
-
function
|
|
4258
|
+
function ga(e) {
|
|
4259
4259
|
return e.structural ? "structural" : e.type === "float" || e.type === "color" || e.type === "vec3" || e.type === "curve" ? "param" : "structural";
|
|
4260
4260
|
}
|
|
4261
|
-
var
|
|
4261
|
+
var _a = class {
|
|
4262
4262
|
registry;
|
|
4263
4263
|
doc;
|
|
4264
4264
|
listeners = /* @__PURE__ */ new Set();
|
|
4265
4265
|
lastError_ = null;
|
|
4266
4266
|
soloNode_ = null;
|
|
4267
|
-
constructor(e =
|
|
4268
|
-
this.registry = t, this.doc =
|
|
4267
|
+
constructor(e = la(), t = Ai) {
|
|
4268
|
+
this.registry = t, this.doc = pa(e), this.validate(this.doc);
|
|
4269
4269
|
}
|
|
4270
4270
|
get document() {
|
|
4271
4271
|
return this.doc;
|
|
@@ -4281,7 +4281,7 @@ var ua = class {
|
|
|
4281
4281
|
}
|
|
4282
4282
|
compileBundle(e) {
|
|
4283
4283
|
try {
|
|
4284
|
-
let t =
|
|
4284
|
+
let t = Gi(this.doc, this.registry, e);
|
|
4285
4285
|
return this.lastError_ = null, t;
|
|
4286
4286
|
} catch (e) {
|
|
4287
4287
|
throw this.lastError_ = e instanceof Error ? e.message : String(e), e;
|
|
@@ -4291,17 +4291,17 @@ var ua = class {
|
|
|
4291
4291
|
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
4292
4292
|
}
|
|
4293
4293
|
setDocument(e) {
|
|
4294
|
-
let t =
|
|
4294
|
+
let t = pa(e);
|
|
4295
4295
|
this.validate(t), this.doc = t, this.emit({ kind: "structural" });
|
|
4296
4296
|
}
|
|
4297
4297
|
getDocument() {
|
|
4298
|
-
return
|
|
4298
|
+
return ca(this.doc);
|
|
4299
4299
|
}
|
|
4300
4300
|
setSoloNode(e) {
|
|
4301
4301
|
e !== this.soloNode_ && (this.soloNode_ = e, this.emit({ kind: "structural" }));
|
|
4302
4302
|
}
|
|
4303
4303
|
setOutputResolution(e) {
|
|
4304
|
-
let t = this.doc.nodes.find((e) => e.type ===
|
|
4304
|
+
let t = this.doc.nodes.find((e) => e.type === Ye);
|
|
4305
4305
|
if (!t) return;
|
|
4306
4306
|
let n = String(e);
|
|
4307
4307
|
t.params.outputResolution !== n && (t.params.outputResolution = n, this.emit({ kind: "structural" }));
|
|
@@ -4310,10 +4310,10 @@ var ua = class {
|
|
|
4310
4310
|
this.setOutputResolution(e.resolution ?? e.size ?? 1024);
|
|
4311
4311
|
}
|
|
4312
4312
|
setNodeParam(e, t, n) {
|
|
4313
|
-
let r =
|
|
4313
|
+
let r = ma(this.doc, e);
|
|
4314
4314
|
if (!r) return !1;
|
|
4315
|
-
let i = this.registry.get(r.type), a =
|
|
4316
|
-
return a ? Object.is(r.params[t], n) ? !0 : (r.params[t] = n,
|
|
4315
|
+
let i = this.registry.get(r.type), a = ha(Di(r, this.registry), t) ?? ha(i.params, t);
|
|
4316
|
+
return a ? Object.is(r.params[t], n) ? !0 : (r.params[t] = n, ga(a) === "param" ? this.emit({
|
|
4317
4317
|
kind: "param",
|
|
4318
4318
|
nodeId: e,
|
|
4319
4319
|
key: t,
|
|
@@ -4328,79 +4328,254 @@ var ua = class {
|
|
|
4328
4328
|
return n;
|
|
4329
4329
|
}
|
|
4330
4330
|
validate(e) {
|
|
4331
|
-
|
|
4331
|
+
Gi(e, this.registry, { backend: "live" }), this.lastError_ = null;
|
|
4332
4332
|
}
|
|
4333
4333
|
emit(e) {
|
|
4334
4334
|
for (let t of this.listeners) t(e);
|
|
4335
4335
|
}
|
|
4336
|
-
},
|
|
4336
|
+
}, va = [
|
|
4337
4337
|
"roughness",
|
|
4338
4338
|
"metallic",
|
|
4339
4339
|
"ambientOcclusion"
|
|
4340
|
-
],
|
|
4341
|
-
function
|
|
4342
|
-
return
|
|
4343
|
-
}
|
|
4344
|
-
var
|
|
4345
|
-
function
|
|
4346
|
-
let r = (
|
|
4347
|
-
for (let a = 0; a <
|
|
4348
|
-
let s =
|
|
4340
|
+
], ya = ["baseColor", "emission"];
|
|
4341
|
+
function ba(e, t) {
|
|
4342
|
+
return va.includes(t) ? G(e) : ya.includes(t) ? De(e) : e;
|
|
4343
|
+
}
|
|
4344
|
+
var X = 2, xa = new _(new u());
|
|
4345
|
+
function Sa(e, t, n) {
|
|
4346
|
+
let r = (X - 1) / 2, i = G(0, 0, 0);
|
|
4347
|
+
for (let a = 0; a < X; a++) for (let o = 0; o < X; o++) {
|
|
4348
|
+
let s = W(o - r, a - r).mul(t), c = V(e, U().add(s)).xyz;
|
|
4349
4349
|
n && (c = c.mul(2).sub(1)), i = i.add(c);
|
|
4350
4350
|
}
|
|
4351
|
-
return i = i.div(
|
|
4351
|
+
return i = i.div(X * X), n ? be(i).mul(.5).add(.5) : i;
|
|
4352
4352
|
}
|
|
4353
|
-
var
|
|
4354
|
-
function
|
|
4355
|
-
return [...
|
|
4353
|
+
var Ca = /* @__PURE__ */ new Map();
|
|
4354
|
+
function wa() {
|
|
4355
|
+
return [...Ca.keys()];
|
|
4356
4356
|
}
|
|
4357
|
-
function
|
|
4358
|
-
let
|
|
4359
|
-
if (
|
|
4360
|
-
let
|
|
4357
|
+
function Ta(e, t) {
|
|
4358
|
+
let n = `${e}x${t}`, a = Ca.get(n);
|
|
4359
|
+
if (a) return a;
|
|
4360
|
+
let o = new v(e, t, {
|
|
4361
4361
|
depthBuffer: !1,
|
|
4362
4362
|
stencilBuffer: !1
|
|
4363
4363
|
});
|
|
4364
|
-
|
|
4365
|
-
let
|
|
4366
|
-
let t = new
|
|
4367
|
-
return t.colorNode =
|
|
4364
|
+
o.texture.colorSpace = i, o.texture.minFilter = o.texture.magFilter = r, o.texture.wrapS = o.texture.wrapT = s;
|
|
4365
|
+
let c = W(1 / e, 1 / t), l = (e) => {
|
|
4366
|
+
let t = new u();
|
|
4367
|
+
return t.colorNode = Sa(o.texture, c, e), new _(t);
|
|
4368
4368
|
}, d = {
|
|
4369
|
-
ssRT:
|
|
4370
|
-
downColorQuad:
|
|
4371
|
-
downNormalQuad:
|
|
4369
|
+
ssRT: o,
|
|
4370
|
+
downColorQuad: l(!1),
|
|
4371
|
+
downNormalQuad: l(!0)
|
|
4372
4372
|
};
|
|
4373
|
-
return
|
|
4373
|
+
return Ca.set(n, d), d;
|
|
4374
4374
|
}
|
|
4375
|
-
function
|
|
4376
|
-
return new
|
|
4375
|
+
function Ea() {
|
|
4376
|
+
return new u();
|
|
4377
4377
|
}
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4378
|
+
function Da(e, r) {
|
|
4379
|
+
e.colorSpace = r !== "height" && ya.includes(r) ? c : i, e.wrapS = e.wrapT = s, e.generateMipmaps = !0, e.minFilter = n, e.magFilter = t, e.anisotropy = 8;
|
|
4380
|
+
}
|
|
4381
|
+
var Oa = new l(), ka = new a(-1, 1, 1, -1, 0, 1), Aa = [];
|
|
4382
|
+
async function ja(e, t, n) {
|
|
4383
|
+
for (; Aa.length < t.length;) Aa.push(new _());
|
|
4384
|
+
Oa.clear();
|
|
4385
|
+
for (let e = 0; e < t.length; e++) Aa[e].material = t[e], Oa.add(Aa[e]);
|
|
4383
4386
|
let r = e.getRenderTarget();
|
|
4384
|
-
e.setRenderTarget(
|
|
4387
|
+
e.setRenderTarget(Ta(n * X, n * X).ssRT), await e.compileAsync(Oa, ka), e.setRenderTarget(r);
|
|
4385
4388
|
}
|
|
4386
|
-
function
|
|
4387
|
-
|
|
4389
|
+
function Ma(e, t, n) {
|
|
4390
|
+
xa.material = t;
|
|
4388
4391
|
let r = e.getRenderTarget();
|
|
4389
|
-
e.setRenderTarget(n),
|
|
4392
|
+
e.setRenderTarget(n), xa.render(e), e.setRenderTarget(r);
|
|
4390
4393
|
}
|
|
4391
|
-
function
|
|
4392
|
-
let { ssRT: i, downColorQuad: a, downNormalQuad: o } =
|
|
4393
|
-
|
|
4394
|
+
function Na(e, t, n, r = !1) {
|
|
4395
|
+
let { ssRT: i, downColorQuad: a, downNormalQuad: o } = Ta(n.width * X, n.height * X);
|
|
4396
|
+
xa.material = t;
|
|
4394
4397
|
let s = e.getRenderTarget();
|
|
4395
|
-
e.setRenderTarget(i),
|
|
4398
|
+
e.setRenderTarget(i), xa.render(e), e.setRenderTarget(n), (r ? o : a).render(e), e.setRenderTarget(s);
|
|
4396
4399
|
}
|
|
4397
|
-
function
|
|
4398
|
-
let i = new
|
|
4399
|
-
i.colorNode = t, i.needsUpdate = !0,
|
|
4400
|
+
function Pa(e, t, n, r = !1) {
|
|
4401
|
+
let i = new u();
|
|
4402
|
+
i.colorNode = t, i.needsUpdate = !0, Na(e, i, n, r), i.dispose();
|
|
4403
|
+
}
|
|
4404
|
+
//#endregion
|
|
4405
|
+
//#region src/graph/texture-transfer.ts
|
|
4406
|
+
function Fa(e) {
|
|
4407
|
+
return e * e * 4;
|
|
4408
|
+
}
|
|
4409
|
+
function Ia(e) {
|
|
4410
|
+
return Math.ceil(e * 4 / 256) * 256;
|
|
4411
|
+
}
|
|
4412
|
+
function La(e, t, n) {
|
|
4413
|
+
let r = t * 4, i = r * n;
|
|
4414
|
+
if (e.length === i) return e;
|
|
4415
|
+
let a = Ia(t), o = new Uint8Array(i);
|
|
4416
|
+
for (let t = 0; t < n; t++) {
|
|
4417
|
+
let n = t * a;
|
|
4418
|
+
o.set(e.subarray(n, n + r), t * r);
|
|
4419
|
+
}
|
|
4420
|
+
return o;
|
|
4421
|
+
}
|
|
4422
|
+
function Ra(e, t, n) {
|
|
4423
|
+
let r = new Uint8Array(t * n * 4);
|
|
4424
|
+
return za(e, r, t, n), r;
|
|
4425
|
+
}
|
|
4426
|
+
function za(e, t, n, r) {
|
|
4427
|
+
let i = n * 4;
|
|
4428
|
+
for (let n = 0; n < r; n++) {
|
|
4429
|
+
let a = (r - 1 - n) * i;
|
|
4430
|
+
t.set(e.subarray(a, a + i), n * i);
|
|
4431
|
+
}
|
|
4432
|
+
}
|
|
4433
|
+
async function Ba(e, t) {
|
|
4434
|
+
let { width: n, height: r } = t;
|
|
4435
|
+
return Ra(La(await e.readRenderTargetPixelsAsync(t, 0, 0, n, r), n, r), n, r);
|
|
4436
|
+
}
|
|
4437
|
+
var Va = /* @__PURE__ */ new Map();
|
|
4438
|
+
function Ha(t, n) {
|
|
4439
|
+
let r = `${t}|${n || "none"}`, i = Va.get(r);
|
|
4440
|
+
if (i) return i;
|
|
4441
|
+
let a = new e.DataTexture(new Uint8Array(Fa(t)), t, t, e.RGBAFormat, e.UnsignedByteType);
|
|
4442
|
+
return a.colorSpace = n, a.minFilter = a.magFilter = e.NearestFilter, a.generateMipmaps = !1, a.flipY = !1, a.needsUpdate = !0, Va.set(r, a), a;
|
|
4443
|
+
}
|
|
4444
|
+
function Ua() {
|
|
4445
|
+
return [...Va.keys()];
|
|
4446
|
+
}
|
|
4447
|
+
function Wa() {
|
|
4448
|
+
for (let e of Va.values()) e.dispose();
|
|
4449
|
+
Va.clear();
|
|
4450
|
+
}
|
|
4451
|
+
function Ga(t, n, r) {
|
|
4452
|
+
let i = Ra(t, n, n), a = new e.DataTexture(i, n, n, e.RGBAFormat, e.UnsignedByteType);
|
|
4453
|
+
return Da(a, r), a.flipY = !1, a.needsUpdate = !0, a;
|
|
4454
|
+
}
|
|
4455
|
+
function Ka(e, t, n) {
|
|
4456
|
+
let { width: r, height: i } = t;
|
|
4457
|
+
if (n.length !== r * i * 4) throw Error(`texel length ${n.length} does not match target ${r}x${i} (expected ${r * i * 4})`);
|
|
4458
|
+
e.initRenderTarget(t);
|
|
4459
|
+
let a = Ha(r, t.texture.colorSpace);
|
|
4460
|
+
za(n, a.image.data, r, i), a.needsUpdate = !0, e.copyTextureToTexture(a, t.texture);
|
|
4461
|
+
}
|
|
4462
|
+
//#endregion
|
|
4463
|
+
//#region src/version.ts
|
|
4464
|
+
var qa = "0.1.5";
|
|
4465
|
+
//#endregion
|
|
4466
|
+
//#region src/topology.ts
|
|
4467
|
+
function Ja(e) {
|
|
4468
|
+
return Z(e);
|
|
4469
|
+
}
|
|
4470
|
+
function Z(e) {
|
|
4471
|
+
return Array.isArray(e) ? `[${e.map(Z).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => `${e}:${Z(t)}`).join(",")}}` : JSON.stringify(e);
|
|
4472
|
+
}
|
|
4473
|
+
function Ya(e, t) {
|
|
4474
|
+
let n = t.get(e.type), r = n.paramsFor ? n.paramsFor(e.params) : n.params, i = {};
|
|
4475
|
+
for (let t of r) (t.type === "int" || t.type === "bool" || t.type === "select" || t.bakeStructural) && (i[t.key] = e.params[t.key]);
|
|
4476
|
+
return i;
|
|
4477
|
+
}
|
|
4478
|
+
function Xa(e, t) {
|
|
4479
|
+
return {
|
|
4480
|
+
id: e.id,
|
|
4481
|
+
type: e.type,
|
|
4482
|
+
enabled: e.enabled,
|
|
4483
|
+
ports: Y(e, t),
|
|
4484
|
+
params: Ya(e, t),
|
|
4485
|
+
subgraph: e.subgraph ? Za(e.subgraph, t) : null
|
|
4486
|
+
};
|
|
4487
|
+
}
|
|
4488
|
+
function Za(e, t) {
|
|
4489
|
+
return {
|
|
4490
|
+
version: e.version,
|
|
4491
|
+
nodes: e.nodes.map((e) => Xa(e, t)).sort((e, t) => String(e.id).localeCompare(String(t.id))),
|
|
4492
|
+
edges: [...e.edges].sort((e, t) => Z(e).localeCompare(Z(t)))
|
|
4493
|
+
};
|
|
4494
|
+
}
|
|
4495
|
+
function Qa(e, t) {
|
|
4496
|
+
return Z(Za(e, t));
|
|
4497
|
+
}
|
|
4498
|
+
function $a(e) {
|
|
4499
|
+
let t = typeof e == "number" ? e : Number(e);
|
|
4500
|
+
if (!Number.isFinite(t)) return typeof e == "number" ? "nan" : `raw:${String(e)}`;
|
|
4501
|
+
let n = Number(t.toPrecision(9));
|
|
4502
|
+
return Object.is(n, -0) ? "0" : String(n);
|
|
4503
|
+
}
|
|
4504
|
+
function eo(e) {
|
|
4505
|
+
if (typeof e == "number") return `#${(e >>> 0 & 16777215).toString(16).padStart(6, "0")}`;
|
|
4506
|
+
if (typeof e == "string") {
|
|
4507
|
+
let t = e.trim().toLowerCase();
|
|
4508
|
+
return /^#[0-9a-f]{3}$/.test(t) ? `#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}` : t;
|
|
4509
|
+
}
|
|
4510
|
+
if (e && typeof e == "object") {
|
|
4511
|
+
let t = e;
|
|
4512
|
+
if (typeof t.r == "number") return `rgb(${$a(t.r)},${$a(t.g)},${$a(t.b)})`;
|
|
4513
|
+
}
|
|
4514
|
+
return Z(e);
|
|
4515
|
+
}
|
|
4516
|
+
function to(e, t) {
|
|
4517
|
+
switch (t.type) {
|
|
4518
|
+
case "float":
|
|
4519
|
+
case "int": return $a(e);
|
|
4520
|
+
case "bool": return (typeof e == "string" ? e.trim().toLowerCase() === "true" : e) ? "true" : "false";
|
|
4521
|
+
case "color": return eo(e);
|
|
4522
|
+
case "select": return String(e);
|
|
4523
|
+
case "vec3": {
|
|
4524
|
+
let t = e ?? {};
|
|
4525
|
+
return `(${$a(t.x)},${$a(t.y)},${$a(t.z)})`;
|
|
4526
|
+
}
|
|
4527
|
+
case "curve": return `[${He(e).map($a).join(",")}]`;
|
|
4528
|
+
default: return Z(e);
|
|
4529
|
+
}
|
|
4530
|
+
}
|
|
4531
|
+
function no(e, t) {
|
|
4532
|
+
if (!t.has(e.type)) return `${e.id}!${Z(e.params)}`;
|
|
4533
|
+
let n = t.get(e.type).params, r = [];
|
|
4534
|
+
for (let t of n) {
|
|
4535
|
+
let n = e.params[t.key] === void 0 ? t.default : e.params[t.key];
|
|
4536
|
+
r.push(`${t.key}=${to(n, t)}`);
|
|
4537
|
+
}
|
|
4538
|
+
let i = new Set(n.map((e) => e.key)), a = Object.keys(e.params).filter((e) => !i.has(e)).sort();
|
|
4539
|
+
for (let t of a) r.push(`${t}~${Z(e.params[t])}`);
|
|
4540
|
+
return `${e.id}{${r.join(",")}}`;
|
|
4541
|
+
}
|
|
4542
|
+
function ro(e, t) {
|
|
4543
|
+
return [...e.nodes].sort((e, t) => e.id.localeCompare(t.id)).map((e) => {
|
|
4544
|
+
let n = no(e, t);
|
|
4545
|
+
return e.subgraph ? `${n}/[${ro(e.subgraph, t)}]` : n;
|
|
4546
|
+
}).join(";");
|
|
4547
|
+
}
|
|
4548
|
+
//#endregion
|
|
4549
|
+
//#region src/cache/key.ts
|
|
4550
|
+
var io = 1, ao = 1, oo = `mdbc1.1.4.${qa}`, so = oo;
|
|
4551
|
+
function co(e) {
|
|
4552
|
+
let t = 3421674724, n = 2216829733;
|
|
4553
|
+
for (let r = 0; r < e.length; r++) {
|
|
4554
|
+
n = (n ^ e.charCodeAt(r) & 255) >>> 0;
|
|
4555
|
+
let i = n & 65535, a = n >>> 16, o = t & 65535, s = t >>> 16, c = i * 435, l = a * 435 + (c >>> 16), u = o * 435 + i * 256 + (l >>> 16), d = s * 435 + a * 256 + (u >>> 16);
|
|
4556
|
+
n = ((l & 65535) << 16 | c & 65535) >>> 0, t = ((d & 65535) << 16 | u & 65535) >>> 0;
|
|
4557
|
+
}
|
|
4558
|
+
return t.toString(16).padStart(8, "0") + n.toString(16).padStart(8, "0");
|
|
4559
|
+
}
|
|
4560
|
+
function lo(e) {
|
|
4561
|
+
let { document: t, registry: n, size: r, channels: i, backend: a = "webgpu", namespace: s = "" } = e, c = [
|
|
4562
|
+
oo,
|
|
4563
|
+
`three:${o}`,
|
|
4564
|
+
`backend:${a}`,
|
|
4565
|
+
`ns:${s}`,
|
|
4566
|
+
`size:${r}`,
|
|
4567
|
+
`ch:${[...i].sort().join(",")}`,
|
|
4568
|
+
`topo:${Qa(t, n)}`,
|
|
4569
|
+
`params:${ro(t, n)}`
|
|
4570
|
+
].join("\n");
|
|
4571
|
+
return {
|
|
4572
|
+
id: `${oo}-${co(c)}-${c.length.toString(36)}`,
|
|
4573
|
+
key: c
|
|
4574
|
+
};
|
|
4400
4575
|
}
|
|
4401
4576
|
//#endregion
|
|
4402
4577
|
//#region src/graph/node-profiler.ts
|
|
4403
|
-
function
|
|
4578
|
+
function uo(e, t, n) {
|
|
4404
4579
|
let r = n && n.length ? new Set(n) : null;
|
|
4405
4580
|
return e.nodes.filter((e) => {
|
|
4406
4581
|
if (e.enabled === !1 || r && !r.has(e.id)) return !1;
|
|
@@ -4408,12 +4583,12 @@ function Da(e, t, n) {
|
|
|
4408
4583
|
return n ? n.nodeClass !== "shader" && n.nodeClass !== "output" : !1;
|
|
4409
4584
|
});
|
|
4410
4585
|
}
|
|
4411
|
-
function
|
|
4586
|
+
function fo(e) {
|
|
4412
4587
|
if (!e.length) return 0;
|
|
4413
4588
|
let t = [...e].sort((e, t) => e - t), n = t.length >> 1;
|
|
4414
4589
|
return t.length % 2 ? t[n] : (t[n - 1] + t[n]) / 2;
|
|
4415
4590
|
}
|
|
4416
|
-
function
|
|
4591
|
+
function po(e, t, n) {
|
|
4417
4592
|
let r = new Map(e.map((e) => [e.nodeId, e]));
|
|
4418
4593
|
for (let i of e) {
|
|
4419
4594
|
let e = t.edges.filter((e) => e.toNode === i.nodeId).map((e) => r.get(e.fromNode)?.renderMs).filter((e) => e !== void 0), a = e.length ? Math.max(...e) : n;
|
|
@@ -4422,15 +4597,15 @@ function ka(e, t, n) {
|
|
|
4422
4597
|
}
|
|
4423
4598
|
//#endregion
|
|
4424
4599
|
//#region src/graph/bake-service.ts
|
|
4425
|
-
var
|
|
4426
|
-
function
|
|
4600
|
+
var mo = 1024, ho = 4096;
|
|
4601
|
+
function go(e, t) {
|
|
4427
4602
|
let n = t?.size ?? Math.max(e, t?.minSize ?? 0);
|
|
4428
|
-
return Math.min(n,
|
|
4603
|
+
return Math.min(n, ho);
|
|
4429
4604
|
}
|
|
4430
|
-
function
|
|
4605
|
+
function _o(e) {
|
|
4431
4606
|
return e?.minSize != null;
|
|
4432
4607
|
}
|
|
4433
|
-
var
|
|
4608
|
+
var vo = typeof navigator < "u" && /chrome|chromium|crios|edg\//i.test(navigator.userAgent) && !/firefox|fxios/i.test(navigator.userAgent), yo = [
|
|
4434
4609
|
"baseColor",
|
|
4435
4610
|
"roughness",
|
|
4436
4611
|
"metallic",
|
|
@@ -4438,22 +4613,22 @@ var Fa = typeof navigator < "u" && /chrome|chromium|crios|edg\//i.test(navigator
|
|
|
4438
4613
|
"normal",
|
|
4439
4614
|
"emission"
|
|
4440
4615
|
];
|
|
4441
|
-
function
|
|
4442
|
-
let
|
|
4616
|
+
function bo(e, t) {
|
|
4617
|
+
let n = new v(t, t, {
|
|
4443
4618
|
depthBuffer: !1,
|
|
4444
4619
|
stencilBuffer: !1
|
|
4445
|
-
})
|
|
4446
|
-
return
|
|
4620
|
+
});
|
|
4621
|
+
return Da(n.texture, e), n;
|
|
4447
4622
|
}
|
|
4448
|
-
function
|
|
4449
|
-
let r = new
|
|
4623
|
+
function xo(t, n = !1) {
|
|
4624
|
+
let r = new v(t, t, {
|
|
4450
4625
|
type: e.HalfFloatType,
|
|
4451
4626
|
depthBuffer: !1,
|
|
4452
4627
|
stencilBuffer: !1
|
|
4453
4628
|
}), i = r.texture;
|
|
4454
4629
|
return i.colorSpace = e.NoColorSpace, i.wrapS = i.wrapT = e.RepeatWrapping, i.generateMipmaps = n, i.minFilter = n ? e.LinearMipmapLinearFilter : e.LinearFilter, i.magFilter = e.LinearFilter, r;
|
|
4455
4630
|
}
|
|
4456
|
-
var
|
|
4631
|
+
var So = class {
|
|
4457
4632
|
channels;
|
|
4458
4633
|
targets = /* @__PURE__ */ new Map();
|
|
4459
4634
|
mats = /* @__PURE__ */ new Map();
|
|
@@ -4467,32 +4642,36 @@ var za = class {
|
|
|
4467
4642
|
hasHeight = !1;
|
|
4468
4643
|
present = /* @__PURE__ */ new Set();
|
|
4469
4644
|
signature = "";
|
|
4645
|
+
restored = !1;
|
|
4646
|
+
contentStamp = 0;
|
|
4647
|
+
lastRebuildMs = 0;
|
|
4648
|
+
disposed = !1;
|
|
4470
4649
|
size;
|
|
4471
4650
|
constructor(e, t) {
|
|
4472
4651
|
this.channels = t, this.size = e;
|
|
4473
4652
|
}
|
|
4474
4653
|
resize(e) {
|
|
4475
4654
|
if (e !== this.size) {
|
|
4476
|
-
this.size = e;
|
|
4655
|
+
this.size = e, this.restored = !1, this.contentStamp += 1;
|
|
4477
4656
|
for (let t of this.targets.values()) t.setSize(e, e), t.texture.needsUpdate = !0;
|
|
4478
4657
|
this.heightTarget && (this.heightTarget.setSize(e, e), this.heightTarget.texture.needsUpdate = !0), this.flushCaches();
|
|
4479
4658
|
}
|
|
4480
4659
|
}
|
|
4481
4660
|
target(e) {
|
|
4482
4661
|
let t = this.targets.get(e);
|
|
4483
|
-
return t || (t =
|
|
4662
|
+
return t || (t = bo(e, this.size), this.targets.set(e, t)), t;
|
|
4484
4663
|
}
|
|
4485
4664
|
channelMaterial(e) {
|
|
4486
4665
|
let t = this.mats.get(e);
|
|
4487
|
-
return t || (t =
|
|
4666
|
+
return t || (t = Ea(), this.mats.set(e, t)), t;
|
|
4488
4667
|
}
|
|
4489
4668
|
cacheTarget(e, t = this.size, n = !1) {
|
|
4490
4669
|
let r = this.cacheTargets.get(e);
|
|
4491
|
-
return r && r.texture.generateMipmaps !== n && (r.dispose(), this.cacheTargets.delete(e), r = void 0), r ? (r.width !== t || r.height !== t) && r.setSize(t, t) : (r =
|
|
4670
|
+
return r && r.texture.generateMipmaps !== n && (r.dispose(), this.cacheTargets.delete(e), r = void 0), r ? (r.width !== t || r.height !== t) && r.setSize(t, t) : (r = xo(t, n), this.cacheTargets.set(e, r)), r;
|
|
4492
4671
|
}
|
|
4493
4672
|
cacheMaterial(e) {
|
|
4494
4673
|
let t = this.cacheMats.get(e);
|
|
4495
|
-
return t || (t =
|
|
4674
|
+
return t || (t = Ea(), this.cacheMats.set(e, t)), t;
|
|
4496
4675
|
}
|
|
4497
4676
|
cacheTexture(e, t, n = !1) {
|
|
4498
4677
|
return this.cacheTarget(e, t, n).texture;
|
|
@@ -4506,11 +4685,15 @@ var za = class {
|
|
|
4506
4685
|
return this.heightTarget;
|
|
4507
4686
|
}
|
|
4508
4687
|
ensureHeightTarget() {
|
|
4509
|
-
return this.heightTarget ||=
|
|
4688
|
+
return this.heightTarget ||= bo("height", this.size), this.heightTarget;
|
|
4510
4689
|
}
|
|
4511
4690
|
texture(e) {
|
|
4512
4691
|
return this.targets.get(e)?.texture ?? null;
|
|
4513
4692
|
}
|
|
4693
|
+
setPresence(e, t) {
|
|
4694
|
+
let n = [...e].sort().join(",") + (t ? "|h" : ""), r = n !== this.signature;
|
|
4695
|
+
return this.present = e, this.hasHeight = t, this.signature = n, r;
|
|
4696
|
+
}
|
|
4514
4697
|
allocConstantArray(t, n, r, i) {
|
|
4515
4698
|
let a = `${t}/${n}`, o = this.constArrays.get(a);
|
|
4516
4699
|
if (o && o.length === r.length && o.elementType === i) {
|
|
@@ -4528,8 +4711,8 @@ var za = class {
|
|
|
4528
4711
|
if (i === "vec3") {
|
|
4529
4712
|
let t = [];
|
|
4530
4713
|
for (let n = 0; n < r.length; n += 3) t.push(new e.Vector3(r[n], r[n + 1], r[n + 2]));
|
|
4531
|
-
s =
|
|
4532
|
-
} else s =
|
|
4714
|
+
s = Le(t);
|
|
4715
|
+
} else s = Le(Array.from(r), "float");
|
|
4533
4716
|
return this.constArrays.set(a, {
|
|
4534
4717
|
node: s,
|
|
4535
4718
|
length: r.length,
|
|
@@ -4543,10 +4726,12 @@ var za = class {
|
|
|
4543
4726
|
cacheTargets: this.cacheTargets.size,
|
|
4544
4727
|
cacheMats: this.cacheMats.size,
|
|
4545
4728
|
constArrays: this.constArrays.size,
|
|
4546
|
-
heightTarget: +!!this.heightTarget
|
|
4729
|
+
heightTarget: +!!this.heightTarget,
|
|
4730
|
+
restored: +!!this.restored
|
|
4547
4731
|
};
|
|
4548
4732
|
}
|
|
4549
4733
|
flushCaches() {
|
|
4734
|
+
this.restored = !1;
|
|
4550
4735
|
for (let e of this.mats.values()) e.dispose();
|
|
4551
4736
|
this.mats.clear();
|
|
4552
4737
|
for (let e of this.cacheTargets.values()) e.dispose();
|
|
@@ -4555,6 +4740,7 @@ var za = class {
|
|
|
4555
4740
|
this.cacheMats.clear(), this.cachePlan = [], this.uniforms = /* @__PURE__ */ new Map(), this.paramUsage = /* @__PURE__ */ new Map(), this.constArrays.clear();
|
|
4556
4741
|
}
|
|
4557
4742
|
dispose() {
|
|
4743
|
+
this.disposed = !0, this.restored = !1;
|
|
4558
4744
|
for (let e of this.targets.values()) e.dispose();
|
|
4559
4745
|
this.targets.clear();
|
|
4560
4746
|
for (let e of this.mats.values()) e.dispose();
|
|
@@ -4564,7 +4750,7 @@ var za = class {
|
|
|
4564
4750
|
for (let e of this.cacheMats.values()) e.dispose();
|
|
4565
4751
|
this.cacheMats.clear(), this.cachePlan = [], this.uniforms = /* @__PURE__ */ new Map(), this.paramUsage = /* @__PURE__ */ new Map(), this.constArrays.clear(), this.heightTarget?.dispose(), this.heightTarget = null;
|
|
4566
4752
|
}
|
|
4567
|
-
},
|
|
4753
|
+
}, Co = class {
|
|
4568
4754
|
renderer = null;
|
|
4569
4755
|
compileGateDepth = 0;
|
|
4570
4756
|
get rendererBusy() {
|
|
@@ -4581,6 +4767,9 @@ var za = class {
|
|
|
4581
4767
|
scratchSize = 0;
|
|
4582
4768
|
scratchCaches = /* @__PURE__ */ new Map();
|
|
4583
4769
|
scratchCacheSize = 0;
|
|
4770
|
+
cache_ = null;
|
|
4771
|
+
pendingWrites = /* @__PURE__ */ new Map();
|
|
4772
|
+
pendingStores = /* @__PURE__ */ new Set();
|
|
4584
4773
|
attachRenderer(e) {
|
|
4585
4774
|
this.renderer = e;
|
|
4586
4775
|
}
|
|
@@ -4616,80 +4805,80 @@ var za = class {
|
|
|
4616
4805
|
});
|
|
4617
4806
|
return this.queue = n.then(() => void 0, () => void 0), n;
|
|
4618
4807
|
}
|
|
4619
|
-
createTextureSet(e =
|
|
4620
|
-
return new
|
|
4808
|
+
createTextureSet(e = yo, t = mo) {
|
|
4809
|
+
return new So(t, e);
|
|
4621
4810
|
}
|
|
4622
4811
|
bakeInto(e, t, n = {}) {
|
|
4623
4812
|
return this.enqueue(n.label ?? "surface", async () => {
|
|
4624
4813
|
let r = this.renderer;
|
|
4625
4814
|
if (!r) return !1;
|
|
4626
|
-
let i =
|
|
4815
|
+
let i = await this.tryRestoreFromCache(r, e, t, n);
|
|
4816
|
+
if (i) return i.changed;
|
|
4817
|
+
let a = performance.now(), { bundle: o, uniforms: s, cachePlan: c, paramUsage: l } = t.compileBundle({
|
|
4627
4818
|
backend: "offline",
|
|
4628
4819
|
soloNodeId: n.soloNodeId,
|
|
4629
|
-
allocCache: (t, n, r) => e.cacheTexture(t,
|
|
4820
|
+
allocCache: (t, n, r) => e.cacheTexture(t, go(e.size, r), _o(r)),
|
|
4630
4821
|
allocConstantArray: (t, n, r, i) => e.allocConstantArray(t, n, r, i)
|
|
4631
|
-
}),
|
|
4632
|
-
e.uniforms =
|
|
4633
|
-
let
|
|
4634
|
-
for (let t of
|
|
4635
|
-
let n =
|
|
4822
|
+
}), u = performance.now() - a, d = Wi(t.document);
|
|
4823
|
+
e.uniforms = s, e.paramUsage = l, e.cachePlan = c, n.soloNodeId || e.pruneCaches(new Set(c.map((e) => e.cacheId)));
|
|
4824
|
+
let f = n.channels ?? e.channels, p = /* @__PURE__ */ new Set(), m = [];
|
|
4825
|
+
for (let t of f) {
|
|
4826
|
+
let n = o[t];
|
|
4636
4827
|
if (!n) continue;
|
|
4637
4828
|
let r = e.channelMaterial(t);
|
|
4638
|
-
r.colorNode =
|
|
4829
|
+
r.colorNode = ba(n, t), r.needsUpdate = !0, m.push({
|
|
4639
4830
|
mat: r,
|
|
4640
4831
|
target: e.target(t),
|
|
4641
4832
|
isNormal: t === "normal"
|
|
4642
|
-
}),
|
|
4833
|
+
}), p.add(t);
|
|
4643
4834
|
}
|
|
4644
|
-
if (e.hasHeight =
|
|
4835
|
+
if (e.hasHeight = o.height !== void 0, e.hasHeight) {
|
|
4645
4836
|
let t = e.channelMaterial("height");
|
|
4646
|
-
t.colorNode =
|
|
4837
|
+
t.colorNode = G(o.height), t.needsUpdate = !0, m.push({
|
|
4647
4838
|
mat: t,
|
|
4648
4839
|
target: e.ensureHeightTarget(),
|
|
4649
4840
|
isNormal: !1
|
|
4650
4841
|
});
|
|
4651
4842
|
}
|
|
4652
|
-
let
|
|
4843
|
+
let h = {
|
|
4653
4844
|
runId: ++this.bakeRunId,
|
|
4654
4845
|
source: n.source,
|
|
4655
4846
|
phase: "nodes",
|
|
4656
|
-
nodeCount:
|
|
4657
|
-
compileMs:
|
|
4658
|
-
texturesTotal:
|
|
4847
|
+
nodeCount: d,
|
|
4848
|
+
compileMs: u,
|
|
4849
|
+
texturesTotal: m.length,
|
|
4659
4850
|
totalMs: 0
|
|
4660
4851
|
};
|
|
4661
|
-
this.emitReport(
|
|
4662
|
-
for (let t of
|
|
4852
|
+
this.emitReport(h);
|
|
4853
|
+
for (let t of c) {
|
|
4663
4854
|
let n = e.cacheMaterial(t.cacheId);
|
|
4664
|
-
n.colorNode = t.colorNode, n.needsUpdate = !0,
|
|
4855
|
+
n.colorNode = t.colorNode, n.needsUpdate = !0, Ma(r, n, e.cacheTarget(t.cacheId, go(e.size, t.sizing), _o(t.sizing)));
|
|
4665
4856
|
}
|
|
4666
|
-
let
|
|
4667
|
-
if (
|
|
4857
|
+
let g = 0;
|
|
4858
|
+
if (vo) {
|
|
4668
4859
|
this.emitReport({
|
|
4669
|
-
...
|
|
4860
|
+
...h,
|
|
4670
4861
|
phase: "shaders"
|
|
4671
4862
|
});
|
|
4672
4863
|
let t = performance.now();
|
|
4673
4864
|
this.compileGateDepth += 1;
|
|
4674
4865
|
try {
|
|
4675
|
-
await
|
|
4866
|
+
await ja(r, m.map((e) => e.mat), e.size);
|
|
4676
4867
|
} finally {
|
|
4677
4868
|
--this.compileGateDepth;
|
|
4678
4869
|
}
|
|
4679
|
-
|
|
4870
|
+
g = performance.now() - t;
|
|
4680
4871
|
}
|
|
4681
|
-
let
|
|
4682
|
-
for (let e of
|
|
4683
|
-
let
|
|
4684
|
-
e.present = f, e.signature = v;
|
|
4685
|
-
let b = performance.now();
|
|
4872
|
+
let _ = performance.now();
|
|
4873
|
+
for (let e of m) Na(r, e.mat, e.target, e.isNormal);
|
|
4874
|
+
let v = performance.now() - _, y = e.setPresence(p, e.hasHeight), b = performance.now();
|
|
4686
4875
|
await this.gpuSync(e.firstTarget());
|
|
4687
|
-
let x = performance.now() - b, S =
|
|
4876
|
+
let x = performance.now() - b, S = u + g + v + x;
|
|
4688
4877
|
return this.emitReport({
|
|
4689
|
-
...
|
|
4878
|
+
...h,
|
|
4690
4879
|
phase: "done",
|
|
4691
4880
|
totalMs: S
|
|
4692
|
-
}), console.log(`[bake-prof] rebuild compile=${
|
|
4881
|
+
}), console.log(`[bake-prof] rebuild compile=${u.toFixed(1)} precompile=${g.toFixed(1)} dispatch=${v.toFixed(1)} gpuWait=${x.toFixed(1)} total=${S.toFixed(1)}ms`), e.restored = !1, e.contentStamp += 1, e.lastRebuildMs = S, this.scheduleCacheWrite(e, t, n), y;
|
|
4693
4882
|
});
|
|
4694
4883
|
}
|
|
4695
4884
|
async gpuSync(e) {
|
|
@@ -4705,7 +4894,7 @@ var za = class {
|
|
|
4705
4894
|
rerenderInto(e, t) {
|
|
4706
4895
|
let n = this.queue.then(async () => {
|
|
4707
4896
|
let n = this.renderer;
|
|
4708
|
-
if (!n) return;
|
|
4897
|
+
if (!n || e.restored) return;
|
|
4709
4898
|
let r = e.present.size + (e.hasHeight && e.heightTarget ? 1 : 0), i = {
|
|
4710
4899
|
runId: ++this.bakeRunId,
|
|
4711
4900
|
source: t,
|
|
@@ -4717,9 +4906,9 @@ var za = class {
|
|
|
4717
4906
|
};
|
|
4718
4907
|
this.emitReport(i);
|
|
4719
4908
|
let a = performance.now();
|
|
4720
|
-
for (let t of e.cachePlan)
|
|
4721
|
-
for (let t of e.present)
|
|
4722
|
-
e.hasHeight && e.heightTarget &&
|
|
4909
|
+
for (let t of e.cachePlan) Ma(n, e.cacheMaterial(t.cacheId), e.cacheTarget(t.cacheId, go(e.size, t.sizing), _o(t.sizing)));
|
|
4910
|
+
for (let t of e.present) Na(n, e.channelMaterial(t), e.target(t), t === "normal");
|
|
4911
|
+
e.hasHeight && e.heightTarget && Na(n, e.channelMaterial("height"), e.heightTarget, !1);
|
|
4723
4912
|
let o = performance.now() - a, s = performance.now();
|
|
4724
4913
|
await this.gpuSync(e.firstTarget());
|
|
4725
4914
|
let c = performance.now() - s;
|
|
@@ -4727,7 +4916,7 @@ var za = class {
|
|
|
4727
4916
|
...i,
|
|
4728
4917
|
phase: "done",
|
|
4729
4918
|
totalMs: o + c
|
|
4730
|
-
}), console.log(`[bake-prof] rerender dispatch=${o.toFixed(1)} gpuWait=${c.toFixed(1)}ms`);
|
|
4919
|
+
}), console.log(`[bake-prof] rerender dispatch=${o.toFixed(1)} gpuWait=${c.toFixed(1)}ms`), e.contentStamp += 1;
|
|
4731
4920
|
});
|
|
4732
4921
|
return this.queue = n.then(() => void 0, () => void 0), n;
|
|
4733
4922
|
}
|
|
@@ -4741,17 +4930,17 @@ var za = class {
|
|
|
4741
4930
|
if (!r) return null;
|
|
4742
4931
|
let { bundle: i, cachePlan: a } = e.compileBundle({
|
|
4743
4932
|
backend: "offline",
|
|
4744
|
-
allocCache: (e, t, r) => this.scratchCache(e, n,
|
|
4933
|
+
allocCache: (e, t, r) => this.scratchCache(e, n, go(n, r), _o(r)).rt.texture
|
|
4745
4934
|
}), o = i[t];
|
|
4746
4935
|
if (!o) return null;
|
|
4747
4936
|
let s = new Set(a.map((e) => e.cacheId));
|
|
4748
4937
|
for (let [e, t] of this.scratchCaches) s.has(e) || (t.rt.dispose(), t.mat.dispose(), this.scratchCaches.delete(e));
|
|
4749
4938
|
for (let e of a) {
|
|
4750
|
-
let t = this.scratchCache(e.cacheId, n,
|
|
4751
|
-
t.mat.colorNode = e.colorNode, t.mat.needsUpdate = !0,
|
|
4939
|
+
let t = this.scratchCache(e.cacheId, n, go(n, e.sizing), _o(e.sizing));
|
|
4940
|
+
t.mat.colorNode = e.colorNode, t.mat.needsUpdate = !0, Ma(r, t.mat, t.rt);
|
|
4752
4941
|
}
|
|
4753
4942
|
let c = this.scratchTarget(n);
|
|
4754
|
-
|
|
4943
|
+
Pa(r, ba(o, t), c, t === "normal");
|
|
4755
4944
|
let l = await r.readRenderTargetPixelsAsync(c, 0, 0, n, n), u = new Uint8ClampedArray(n * n * 4), d = n * 4;
|
|
4756
4945
|
for (let e = 0; e < n; e++) {
|
|
4757
4946
|
let t = (n - 1 - e) * d;
|
|
@@ -4767,11 +4956,132 @@ var za = class {
|
|
|
4767
4956
|
rendererGeometries: e?.memory?.geometries ?? -1,
|
|
4768
4957
|
scratchTarget: this.scratch ? `${this.scratchSize}px` : "none",
|
|
4769
4958
|
scratchCaches: this.scratchCaches.size,
|
|
4770
|
-
ssPool:
|
|
4959
|
+
ssPool: wa(),
|
|
4960
|
+
transferPool: Ua(),
|
|
4961
|
+
cache: this.cache_ ? this.cache_.info() : "off"
|
|
4962
|
+
};
|
|
4963
|
+
}
|
|
4964
|
+
setCache(e) {
|
|
4965
|
+
this.cache_ = e;
|
|
4966
|
+
}
|
|
4967
|
+
get cache() {
|
|
4968
|
+
return this.cache_;
|
|
4969
|
+
}
|
|
4970
|
+
cacheMetrics() {
|
|
4971
|
+
return this.cache_ ? this.cache_.metrics() : Promise.resolve(null);
|
|
4972
|
+
}
|
|
4973
|
+
cacheKeyFor(e, t, n = yo) {
|
|
4974
|
+
return lo({
|
|
4975
|
+
document: e.document,
|
|
4976
|
+
registry: e.getRegistry(),
|
|
4977
|
+
size: t,
|
|
4978
|
+
channels: n,
|
|
4979
|
+
namespace: this.cache_?.namespace
|
|
4980
|
+
});
|
|
4981
|
+
}
|
|
4982
|
+
async tryRestoreFromCache(e, t, n, r) {
|
|
4983
|
+
let i = this.cache_;
|
|
4984
|
+
if (!i?.enabled || r.bypassCache || r.soloNodeId) return null;
|
|
4985
|
+
try {
|
|
4986
|
+
let a = performance.now(), o = this.cacheKeyFor(n, t.size, r.channels ?? t.channels), s = await i.read(o);
|
|
4987
|
+
if (!s) return null;
|
|
4988
|
+
let c = Fa(t.size), l = new Set(r.channels ?? t.channels);
|
|
4989
|
+
if (!(s.size === t.size && s.textures.length > 0 && s.textures.every((e) => (e.channel === "height" || l.has(e.channel)) && e.bytes.length === c))) return await i.delete(o), null;
|
|
4990
|
+
t.flushCaches();
|
|
4991
|
+
let u = /* @__PURE__ */ new Set(), d = !1;
|
|
4992
|
+
for (let n of s.textures) {
|
|
4993
|
+
if (n.channel === "height") {
|
|
4994
|
+
Ka(e, t.ensureHeightTarget(), n.bytes), d = !0;
|
|
4995
|
+
continue;
|
|
4996
|
+
}
|
|
4997
|
+
Ka(e, t.target(n.channel), n.bytes), u.add(n.channel);
|
|
4998
|
+
}
|
|
4999
|
+
let f = {
|
|
5000
|
+
runId: ++this.bakeRunId,
|
|
5001
|
+
source: r.source,
|
|
5002
|
+
phase: "restore",
|
|
5003
|
+
nodeCount: 0,
|
|
5004
|
+
compileMs: 0,
|
|
5005
|
+
texturesTotal: s.textures.length,
|
|
5006
|
+
totalMs: 0
|
|
5007
|
+
};
|
|
5008
|
+
this.emitReport(f);
|
|
5009
|
+
let p = t.setPresence(u, d);
|
|
5010
|
+
t.restored = !0, t.contentStamp += 1, await this.gpuSync(t.firstTarget());
|
|
5011
|
+
let m = performance.now() - a;
|
|
5012
|
+
return this.emitReport({
|
|
5013
|
+
...f,
|
|
5014
|
+
phase: "done",
|
|
5015
|
+
totalMs: m
|
|
5016
|
+
}), console.log(`[bake-prof] restore channels=${s.textures.length} bytes=${s.bytes} savedBake=${s.bakeMs.toFixed(0)}ms total=${m.toFixed(1)}ms`), { changed: p };
|
|
5017
|
+
} catch (e) {
|
|
5018
|
+
return console.warn("[bake] cache restore failed, baking instead:", e), null;
|
|
5019
|
+
}
|
|
5020
|
+
}
|
|
5021
|
+
scheduleCacheWrite(e, t, n = {}) {
|
|
5022
|
+
let r = this.cache_;
|
|
5023
|
+
if (!r?.enabled || n.soloNodeId || !this.renderer || e.disposed) return;
|
|
5024
|
+
let i = this.pendingWrites.get(e);
|
|
5025
|
+
i && clearTimeout(i.timer);
|
|
5026
|
+
let a = {
|
|
5027
|
+
set: e,
|
|
5028
|
+
graph: t,
|
|
5029
|
+
opts: n,
|
|
5030
|
+
stamp: e.contentStamp,
|
|
5031
|
+
timer: setTimeout(() => {
|
|
5032
|
+
this.pendingWrites.delete(e);
|
|
5033
|
+
let t = this.queue.then(() => this.runCacheWrite(a));
|
|
5034
|
+
this.queue = t.then(() => void 0, () => void 0);
|
|
5035
|
+
}, r.writeDelayMs)
|
|
4771
5036
|
};
|
|
5037
|
+
this.pendingWrites.set(e, a);
|
|
5038
|
+
}
|
|
5039
|
+
async flushCacheWrites() {
|
|
5040
|
+
let e = [...this.pendingWrites.values()];
|
|
5041
|
+
this.pendingWrites.clear();
|
|
5042
|
+
for (let t of e) {
|
|
5043
|
+
clearTimeout(t.timer);
|
|
5044
|
+
let e = this.queue.then(() => this.runCacheWrite(t));
|
|
5045
|
+
this.queue = e.then(() => void 0, () => void 0);
|
|
5046
|
+
}
|
|
5047
|
+
await this.queue, await Promise.all([...this.pendingStores]);
|
|
5048
|
+
}
|
|
5049
|
+
async runCacheWrite(e) {
|
|
5050
|
+
let { set: t, graph: n, opts: r, stamp: i } = e, a = this.cache_, o = this.renderer;
|
|
5051
|
+
if (!(!a?.enabled || !o || t.disposed) && t.contentStamp === i && !t.restored) try {
|
|
5052
|
+
let e = (r.channels ?? t.channels).filter((e) => t.present.has(e)), s = t.hasHeight && t.heightTarget !== null, c = e.length + +!!s;
|
|
5053
|
+
if (c === 0) return;
|
|
5054
|
+
let l = Fa(t.size) * c;
|
|
5055
|
+
if (!a.canWrite(t.lastRebuildMs, l)) return;
|
|
5056
|
+
let u = this.cacheKeyFor(n, t.size, r.channels ?? t.channels);
|
|
5057
|
+
if (await a.peek(u)) return;
|
|
5058
|
+
let d = [];
|
|
5059
|
+
for (let n of e) if (d.push({
|
|
5060
|
+
channel: n,
|
|
5061
|
+
encoding: "rgba8",
|
|
5062
|
+
bytes: await Ba(o, t.target(n))
|
|
5063
|
+
}), t.contentStamp !== i || t.disposed) return;
|
|
5064
|
+
if (s && d.push({
|
|
5065
|
+
channel: "height",
|
|
5066
|
+
encoding: "rgba8",
|
|
5067
|
+
bytes: await Ba(o, t.heightTarget)
|
|
5068
|
+
}), t.contentStamp !== i || t.disposed) return;
|
|
5069
|
+
let f = a.write(u, {
|
|
5070
|
+
size: t.size,
|
|
5071
|
+
channels: e,
|
|
5072
|
+
hasHeight: s,
|
|
5073
|
+
bakeMs: t.lastRebuildMs,
|
|
5074
|
+
textures: d
|
|
5075
|
+
}).catch((e) => {
|
|
5076
|
+
console.warn("[bake] cache write failed:", e);
|
|
5077
|
+
});
|
|
5078
|
+
this.pendingStores.add(f), f.finally(() => this.pendingStores.delete(f));
|
|
5079
|
+
} catch (e) {
|
|
5080
|
+
console.warn("[bake] cache write failed:", e);
|
|
5081
|
+
}
|
|
4772
5082
|
}
|
|
4773
5083
|
scratchTarget(e) {
|
|
4774
|
-
return (!this.scratch || this.scratchSize !== e) && (this.scratch?.dispose(), this.scratch = new
|
|
5084
|
+
return (!this.scratch || this.scratchSize !== e) && (this.scratch?.dispose(), this.scratch = new v(e, e, {
|
|
4775
5085
|
depthBuffer: !1,
|
|
4776
5086
|
stencilBuffer: !1
|
|
4777
5087
|
}), this.scratchSize = e), this.scratch;
|
|
@@ -4788,19 +5098,19 @@ var za = class {
|
|
|
4788
5098
|
if (!i) return a;
|
|
4789
5099
|
let o = this.scratchTarget(n), s = e.document, c = async (e) => {
|
|
4790
5100
|
let t = performance.now();
|
|
4791
|
-
|
|
5101
|
+
Ma(i, e, o), await this.gpuSync(o);
|
|
4792
5102
|
let n = performance.now() - t, a = [];
|
|
4793
5103
|
for (let t = 0; t < r; t++) {
|
|
4794
5104
|
let t = performance.now();
|
|
4795
|
-
|
|
5105
|
+
Ma(i, e, o), await this.gpuSync(o), a.push(performance.now() - t);
|
|
4796
5106
|
}
|
|
4797
5107
|
return {
|
|
4798
5108
|
pipelineMs: n,
|
|
4799
|
-
renderMs:
|
|
5109
|
+
renderMs: fo(a)
|
|
4800
5110
|
};
|
|
4801
|
-
}, l =
|
|
4802
|
-
l.colorNode =
|
|
4803
|
-
for (let n of
|
|
5111
|
+
}, l = Ea();
|
|
5112
|
+
l.colorNode = G(.5, .5, .5), l.needsUpdate = !0, a.overheadMs = (await c(l)).renderMs, l.dispose();
|
|
5113
|
+
for (let n of uo(s, e.getRegistry(), t.nodeIds)) {
|
|
4804
5114
|
let t = {
|
|
4805
5115
|
nodeId: n.id,
|
|
4806
5116
|
type: n.type,
|
|
@@ -4825,12 +5135,12 @@ var za = class {
|
|
|
4825
5135
|
t.error = "no solo output";
|
|
4826
5136
|
continue;
|
|
4827
5137
|
}
|
|
4828
|
-
let i =
|
|
5138
|
+
let i = Ea();
|
|
4829
5139
|
i.colorNode = r, i.needsUpdate = !0;
|
|
4830
5140
|
let o = await c(i);
|
|
4831
5141
|
i.dispose(), t.pipelineMs = o.pipelineMs, t.renderMs = o.renderMs;
|
|
4832
5142
|
}
|
|
4833
|
-
return
|
|
5143
|
+
return po(a.nodes, s, a.overheadMs), a.nodes.sort((e, t) => t.renderMs - e.renderMs), a;
|
|
4834
5144
|
});
|
|
4835
5145
|
}
|
|
4836
5146
|
scratchCache(e, t, n, r = !1) {
|
|
@@ -4840,48 +5150,48 @@ var za = class {
|
|
|
4840
5150
|
}
|
|
4841
5151
|
let i = this.scratchCaches.get(e);
|
|
4842
5152
|
return i && i.rt.texture.generateMipmaps !== r && (i.rt.dispose(), i.mat.dispose(), this.scratchCaches.delete(e), i = void 0), i ? (i.rt.width !== n || i.rt.height !== n) && i.rt.setSize(n, n) : (i = {
|
|
4843
|
-
rt:
|
|
4844
|
-
mat:
|
|
5153
|
+
rt: xo(n, r),
|
|
5154
|
+
mat: Ea()
|
|
4845
5155
|
}, this.scratchCaches.set(e, i)), i;
|
|
4846
5156
|
}
|
|
4847
|
-
},
|
|
5157
|
+
}, wo = new Co();
|
|
4848
5158
|
//#endregion
|
|
4849
5159
|
//#region src/tsl/triplanar.ts
|
|
4850
|
-
function
|
|
4851
|
-
let t =
|
|
4852
|
-
return t.div(t.dot(
|
|
5160
|
+
function To(e) {
|
|
5161
|
+
let t = L(ye.abs(), e);
|
|
5162
|
+
return t.div(t.dot(G(1, 1, 1)).max(1e-4));
|
|
4853
5163
|
}
|
|
4854
|
-
function
|
|
4855
|
-
return
|
|
4856
|
-
let r =
|
|
5164
|
+
function Eo(e, t, n) {
|
|
5165
|
+
return y(() => {
|
|
5166
|
+
let r = Ce.mul(t), i = To(n), a = V(e, r.yz).mul(i.x), o = V(e, r.zx).mul(i.y), s = V(e, r.xy).mul(i.z);
|
|
4857
5167
|
return a.add(o).add(s);
|
|
4858
5168
|
})();
|
|
4859
5169
|
}
|
|
4860
5170
|
//#endregion
|
|
4861
5171
|
//#region src/tsl/triplanar-normal.ts
|
|
4862
|
-
function
|
|
4863
|
-
return
|
|
4864
|
-
let r =
|
|
5172
|
+
function Do(e, t, n) {
|
|
5173
|
+
return y(() => {
|
|
5174
|
+
let r = Ce.mul(t), i = To(n), a = ye.sign(), o = V(e, r.yz).xyz.mul(2).sub(1), s = V(e, r.zx).xyz.mul(2).sub(1), c = V(e, r.xy).xyz.mul(2).sub(1), l = G(o.x, o.y, o.z.mul(a.x)), u = G(s.x, s.y, s.z.mul(a.y)), d = G(c.x, c.y, c.z.mul(a.z));
|
|
4865
5175
|
return l.zxy.mul(i.x).add(u.yzx.mul(i.y)).add(d.xyz.mul(i.z)).normalize();
|
|
4866
5176
|
})();
|
|
4867
5177
|
}
|
|
4868
5178
|
//#endregion
|
|
4869
5179
|
//#region src/tsl/parallax.ts
|
|
4870
|
-
var
|
|
4871
|
-
function
|
|
4872
|
-
return
|
|
4873
|
-
let i =
|
|
5180
|
+
var Oo = .3;
|
|
5181
|
+
function ko(e, t, n, r) {
|
|
5182
|
+
return y(() => {
|
|
5183
|
+
let i = xe.normalize(), a = (t) => V(e, t).x, o = 1 / r, s = i.xy.div(i.z.abs().max(Oo)).mul(n).mul(o), c = t.toVar(), l = ee(!1).toVar(), u = t, d = k(1).sub(a(u));
|
|
4874
5184
|
for (let e = 0; e < r; e++) {
|
|
4875
|
-
let t = u.sub(s), n = k(1).sub(a(t)), r = (e + 1) * o, i = k(r).greaterThanEqual(n), f = n.sub(r), p = d.sub(e * o), m =
|
|
4876
|
-
c.assign(
|
|
5185
|
+
let t = u.sub(s), n = k(1).sub(a(t)), r = (e + 1) * o, i = k(r).greaterThanEqual(n), f = n.sub(r), p = d.sub(e * o), m = Oe(f.div(f.sub(p).max(1e-5))), h = F(t, u, m);
|
|
5186
|
+
c.assign(R(l.not().and(i), h, c)), l.assign(l.or(i)), u = t, d = n;
|
|
4877
5187
|
}
|
|
4878
5188
|
return c;
|
|
4879
5189
|
})();
|
|
4880
5190
|
}
|
|
4881
5191
|
//#endregion
|
|
4882
5192
|
//#region src/graph/textured-surface.ts
|
|
4883
|
-
var
|
|
4884
|
-
function
|
|
5193
|
+
var Ao = 12;
|
|
5194
|
+
function jo(e, t) {
|
|
4885
5195
|
return [
|
|
4886
5196
|
e,
|
|
4887
5197
|
t.shininess,
|
|
@@ -4890,18 +5200,18 @@ function Ja(e, t) {
|
|
|
4890
5200
|
t.matcap
|
|
4891
5201
|
].join("|");
|
|
4892
5202
|
}
|
|
4893
|
-
var
|
|
5203
|
+
var Mo = class {
|
|
4894
5204
|
graph;
|
|
4895
5205
|
service;
|
|
4896
5206
|
source;
|
|
4897
|
-
offlineMat =
|
|
5207
|
+
offlineMat = Zi();
|
|
4898
5208
|
matType = "physical";
|
|
4899
5209
|
matSig = "";
|
|
4900
5210
|
liveUniforms = /* @__PURE__ */ new Map();
|
|
4901
5211
|
material_;
|
|
4902
|
-
scaleUniform =
|
|
4903
|
-
sharpnessUniform =
|
|
4904
|
-
parallaxScale =
|
|
5212
|
+
scaleUniform = Ie(1.2);
|
|
5213
|
+
sharpnessUniform = Ie(8);
|
|
5214
|
+
parallaxScale = Ie(0);
|
|
4905
5215
|
lastBakeMs = 0;
|
|
4906
5216
|
set;
|
|
4907
5217
|
backend = "offline";
|
|
@@ -4912,13 +5222,14 @@ var Ya = class {
|
|
|
4912
5222
|
updateInFlight = !1;
|
|
4913
5223
|
pendingKind = "none";
|
|
4914
5224
|
flushRequested = !1;
|
|
5225
|
+
bypassCacheOnce = !1;
|
|
4915
5226
|
listeners = /* @__PURE__ */ new Set();
|
|
4916
5227
|
textureListeners = /* @__PURE__ */ new Set();
|
|
4917
5228
|
lastError_ = null;
|
|
4918
5229
|
processingDepth = 0;
|
|
4919
5230
|
idleWaiters = [];
|
|
4920
5231
|
constructor(e, t, n) {
|
|
4921
|
-
this.graph = e, this.service = t, this.source = n, this.set = t.createTextureSet(
|
|
5232
|
+
this.graph = e, this.service = t, this.source = n, this.set = t.createTextureSet(yo, this.surfaceBakeSize()), this.material_ = this.buildLive(), this.graph.onChange((e) => this.onGraphChange(e));
|
|
4922
5233
|
}
|
|
4923
5234
|
get material() {
|
|
4924
5235
|
return this.material_;
|
|
@@ -4973,7 +5284,7 @@ var Ya = class {
|
|
|
4973
5284
|
await this.whenIdle(), this.set.flushCaches();
|
|
4974
5285
|
}
|
|
4975
5286
|
regenerate() {
|
|
4976
|
-
this.flushRequested = !0, this.requestUpdate("rebuild");
|
|
5287
|
+
this.flushRequested = !0, this.bypassCacheOnce = !0, this.requestUpdate("rebuild");
|
|
4977
5288
|
}
|
|
4978
5289
|
debugReport() {
|
|
4979
5290
|
return {
|
|
@@ -5028,7 +5339,7 @@ var Ya = class {
|
|
|
5028
5339
|
let e = n.value;
|
|
5029
5340
|
t.value.set(e.x, e.y, e.z);
|
|
5030
5341
|
} else if (n.paramType === "curve") {
|
|
5031
|
-
let e =
|
|
5342
|
+
let e = He(n.value), r = t.array;
|
|
5032
5343
|
for (let t = 0; t < e.length; t++) r[t] = e[t];
|
|
5033
5344
|
} else t.value = Number(n.value);
|
|
5034
5345
|
}
|
|
@@ -5061,7 +5372,7 @@ var Ya = class {
|
|
|
5061
5372
|
if (!(this.backend !== "offline" || !this.service.hasRenderer)) {
|
|
5062
5373
|
this.enterProcessing();
|
|
5063
5374
|
try {
|
|
5064
|
-
await this.service.rerenderInto(this.set, this.source), this.lastError_ = this.graph.lastError, this.notifyTexturesUpdated();
|
|
5375
|
+
await this.service.rerenderInto(this.set, this.source), this.lastError_ = this.graph.lastError, this.notifyTexturesUpdated(), this.service.scheduleCacheWrite(this.set, this.graph, { source: this.source });
|
|
5065
5376
|
} catch (e) {
|
|
5066
5377
|
this.lastError_ = e instanceof Error ? e.message : String(e), console.warn("[textured-surface] re-render failed:", this.lastError_);
|
|
5067
5378
|
} finally {
|
|
@@ -5070,7 +5381,10 @@ var Ya = class {
|
|
|
5070
5381
|
}
|
|
5071
5382
|
}
|
|
5072
5383
|
surfaceBakeSize() {
|
|
5073
|
-
return Math.max(64, Math.round(
|
|
5384
|
+
return Math.max(64, Math.round(zi(this.graph.document) / 64) * 64);
|
|
5385
|
+
}
|
|
5386
|
+
get bakeSize() {
|
|
5387
|
+
return this.surfaceBakeSize();
|
|
5074
5388
|
}
|
|
5075
5389
|
async rebuild() {
|
|
5076
5390
|
this.enterProcessing();
|
|
@@ -5080,14 +5394,17 @@ var Ya = class {
|
|
|
5080
5394
|
if (this.backend === "offline" && this.service.hasRenderer) {
|
|
5081
5395
|
let e = this.surfaceBakeSize();
|
|
5082
5396
|
this.flushRequested && (this.flushRequested = !1, this.set.flushCaches()), this.set.resize(e);
|
|
5083
|
-
let { type: n, settings: r } =
|
|
5084
|
-
a && (t = this.offlineMat, this.offlineMat =
|
|
5085
|
-
let o = this.graph.soloNode ?? void 0, s =
|
|
5397
|
+
let { type: n, settings: r } = Bi(this.graph.document), i = jo(n, r), a = i !== this.matSig;
|
|
5398
|
+
a && (t = this.offlineMat, this.offlineMat = Zi(n, r), this.matType = n, this.matSig = i);
|
|
5399
|
+
let o = this.graph.soloNode ?? void 0, s = this.bypassCacheOnce;
|
|
5400
|
+
this.bypassCacheOnce = !1;
|
|
5401
|
+
let c = performance.now(), l = await this.service.bakeInto(this.set, this.graph, {
|
|
5086
5402
|
soloNodeId: o,
|
|
5087
5403
|
label: "surface",
|
|
5088
|
-
source: this.source
|
|
5404
|
+
source: this.source,
|
|
5405
|
+
bypassCache: s
|
|
5089
5406
|
});
|
|
5090
|
-
this.lastBakeMs = performance.now() -
|
|
5407
|
+
this.lastBakeMs = performance.now() - c, (l || !this.wiredOnce || a) && (this.wire(this.set.present), this.wiredOnce = !0), this.material_ = this.offlineMat;
|
|
5091
5408
|
} else this.material_ = this.buildLive();
|
|
5092
5409
|
this.lastError_ = this.graph.lastError;
|
|
5093
5410
|
} catch (e) {
|
|
@@ -5099,7 +5416,7 @@ var Ya = class {
|
|
|
5099
5416
|
}
|
|
5100
5417
|
}
|
|
5101
5418
|
buildLive() {
|
|
5102
|
-
let e = this.graph.soloNode ?? void 0, { material: t, uniforms: n } =
|
|
5419
|
+
let e = this.graph.soloNode ?? void 0, { material: t, uniforms: n } = $i(this.graph.document, this.graph.getRegistry(), {
|
|
5103
5420
|
backend: "live",
|
|
5104
5421
|
soloNodeId: e
|
|
5105
5422
|
});
|
|
@@ -5107,13 +5424,13 @@ var Ya = class {
|
|
|
5107
5424
|
}
|
|
5108
5425
|
wire(e) {
|
|
5109
5426
|
this.lastPresent = e;
|
|
5110
|
-
let t = this.offlineMat, n =
|
|
5427
|
+
let t = this.offlineMat, n = We[this.matType], r = this.scaleUniform, i = this.sharpnessUniform, a = this.set.hasHeight && !this.triplanar && this.parallaxScale.value > 0, o = U(), s = a ? ko(this.set.heightTarget.texture, o, this.parallaxScale, Ao) : void 0, c = o.dFdx(), l = o.dFdy(), u = (e) => a ? V(e, s).grad(c, l) : V(e), d = (e) => this.triplanar ? Eo(this.set.texture(e), r, i) : u(this.set.texture(e)), f = e.has("normal") ? this.triplanar ? Do(this.set.texture("normal"), r, i) : ve(u(this.set.texture("normal")).xyz, k(1)) : ye;
|
|
5111
5428
|
if (this.debugNormals) {
|
|
5112
|
-
t.colorNode =
|
|
5429
|
+
t.colorNode = G(0, 0, 0), t.emissiveNode = f.normalize().mul(.5).add(.5), t.roughnessNode = t.metalnessNode = t.aoNode = t.normalNode = null, t.needsUpdate = !0;
|
|
5113
5430
|
return;
|
|
5114
5431
|
}
|
|
5115
5432
|
if (t.colorNode = e.has("baseColor") ? d("baseColor") : null, t.normalNode = e.has("normal") ? f : null, n.roughMetal && (t.roughnessNode = e.has("roughness") ? d("roughness").r : null, t.metalnessNode = e.has("metallic") ? d("metallic").r : null), n.ao) {
|
|
5116
|
-
let n =
|
|
5433
|
+
let n = w("vertexAo", "float");
|
|
5117
5434
|
t.aoNode = e.has("ambientOcclusion") ? d("ambientOcclusion").r.mul(n) : n;
|
|
5118
5435
|
}
|
|
5119
5436
|
n.emissive && (t.emissiveNode = e.has("emission") ? d("emission") : null), t.needsUpdate = !0;
|
|
@@ -5124,7 +5441,7 @@ var Ya = class {
|
|
|
5124
5441
|
};
|
|
5125
5442
|
//#endregion
|
|
5126
5443
|
//#region src/graph/mesh-material.ts
|
|
5127
|
-
function
|
|
5444
|
+
function No(t) {
|
|
5128
5445
|
let n = { side: e.DoubleSide };
|
|
5129
5446
|
switch (t) {
|
|
5130
5447
|
case "standard": return new e.MeshStandardMaterial(n);
|
|
@@ -5135,8 +5452,8 @@ function Xa(t) {
|
|
|
5135
5452
|
default: return new e.MeshPhysicalMaterial(n);
|
|
5136
5453
|
}
|
|
5137
5454
|
}
|
|
5138
|
-
function
|
|
5139
|
-
let n =
|
|
5455
|
+
function Po(e, t) {
|
|
5456
|
+
let n = Vi(e), r = We[n.type], i = No(n.type), a = i, o = (e) => t.get(e), s = o("baseColor");
|
|
5140
5457
|
s ? (a.map = s, a.color.set(16777215)) : a.color.set(n.baseColor);
|
|
5141
5458
|
let c = o("normal");
|
|
5142
5459
|
if (c && (a.normalMap = c), n.alpha < 1 && (a.transparent = !0, a.opacity = n.alpha), r.ao) {
|
|
@@ -5153,22 +5470,639 @@ function Za(e, t) {
|
|
|
5153
5470
|
let t = o("metallic");
|
|
5154
5471
|
t ? (a.metalnessMap = t, a.metalness = 1) : a.metalness = n.metallic;
|
|
5155
5472
|
}
|
|
5156
|
-
return r.physicalLobes && (a.ior = n.ior, a.clearcoat = n.coat, a.clearcoatRoughness = n.coatRoughness, a.sheen = n.sheen, n.sheen > 0 && a.sheenColor.set(16777215), a.sheenRoughness = n.sheenRoughness, a.transmission = n.transmission), n.type === "phong" && (a.shininess = n.shininess, a.specular.set(n.specular)), n.type === "toon" && (a.gradientMap =
|
|
5473
|
+
return r.physicalLobes && (a.ior = n.ior, a.clearcoat = n.coat, a.clearcoatRoughness = n.coatRoughness, a.sheen = n.sheen, n.sheen > 0 && a.sheenColor.set(16777215), a.sheenRoughness = n.sheenRoughness, a.transmission = n.transmission), n.type === "phong" && (a.shininess = n.shininess, a.specular.set(n.specular)), n.type === "toon" && (a.gradientMap = Mi(n.gradientSteps)), n.type === "matcap" && (a.matcap = Ni(n.matcap)), i;
|
|
5474
|
+
}
|
|
5475
|
+
//#endregion
|
|
5476
|
+
//#region src/cache/codec.ts
|
|
5477
|
+
function Fo() {
|
|
5478
|
+
return typeof OffscreenCanvas < "u" && typeof createImageBitmap < "u" && typeof ImageData < "u";
|
|
5479
|
+
}
|
|
5480
|
+
function Io(e) {
|
|
5481
|
+
let t = new OffscreenCanvas(e, e).getContext("2d", {
|
|
5482
|
+
colorSpace: "srgb",
|
|
5483
|
+
willReadFrequently: !0
|
|
5484
|
+
});
|
|
5485
|
+
if (!t) throw Error("OffscreenCanvas 2D context unavailable");
|
|
5486
|
+
return t;
|
|
5487
|
+
}
|
|
5488
|
+
async function Lo(e, t) {
|
|
5489
|
+
let n = new Uint8ClampedArray(e.length);
|
|
5490
|
+
n.set(e);
|
|
5491
|
+
for (let e = 3; e < n.length; e += 4) n[e] = 255;
|
|
5492
|
+
let r = Io(t);
|
|
5493
|
+
r.putImageData(new ImageData(n, t, t, { colorSpace: "srgb" }), 0, 0);
|
|
5494
|
+
let i = await r.canvas.convertToBlob({ type: "image/png" });
|
|
5495
|
+
return new Uint8Array(await i.arrayBuffer());
|
|
5496
|
+
}
|
|
5497
|
+
async function Ro(e, t) {
|
|
5498
|
+
let n = new Blob([e], { type: "image/png" }), r = await createImageBitmap(n, {
|
|
5499
|
+
premultiplyAlpha: "none",
|
|
5500
|
+
colorSpaceConversion: "none"
|
|
5501
|
+
});
|
|
5502
|
+
try {
|
|
5503
|
+
let e = Io(t);
|
|
5504
|
+
e.drawImage(r, 0, 0);
|
|
5505
|
+
let n = e.getImageData(0, 0, t, t, { colorSpace: "srgb" }).data, i = new Uint8Array(n.length);
|
|
5506
|
+
i.set(n);
|
|
5507
|
+
for (let e = 3; e < i.length; e += 4) i[e] = 255;
|
|
5508
|
+
return i;
|
|
5509
|
+
} finally {
|
|
5510
|
+
r.close();
|
|
5511
|
+
}
|
|
5512
|
+
}
|
|
5513
|
+
function zo() {
|
|
5514
|
+
return typeof CompressionStream < "u" && typeof DecompressionStream < "u";
|
|
5515
|
+
}
|
|
5516
|
+
async function Bo(e, t) {
|
|
5517
|
+
let n = new Blob([e]).stream().pipeThrough(t);
|
|
5518
|
+
return new Uint8Array(await new Response(n).arrayBuffer());
|
|
5519
|
+
}
|
|
5520
|
+
function Vo(e) {
|
|
5521
|
+
return Bo(e, new CompressionStream("deflate-raw"));
|
|
5522
|
+
}
|
|
5523
|
+
function Ho(e) {
|
|
5524
|
+
return Bo(e, new DecompressionStream("deflate-raw"));
|
|
5525
|
+
}
|
|
5526
|
+
async function Uo(e, t, n) {
|
|
5527
|
+
return n === "png" && Fo() ? {
|
|
5528
|
+
bytes: await Lo(e, t),
|
|
5529
|
+
encoding: "png"
|
|
5530
|
+
} : n === "deflate" && zo() ? {
|
|
5531
|
+
bytes: await Vo(e),
|
|
5532
|
+
encoding: "deflate"
|
|
5533
|
+
} : {
|
|
5534
|
+
bytes: e,
|
|
5535
|
+
encoding: "rgba8"
|
|
5536
|
+
};
|
|
5537
|
+
}
|
|
5538
|
+
async function Wo(e, t, n) {
|
|
5539
|
+
let r = e;
|
|
5540
|
+
n === "png" ? r = await Ro(e, t) : n === "deflate" && (r = await Ho(e));
|
|
5541
|
+
let i = t * t * 4;
|
|
5542
|
+
if (r.length !== i) throw Error(`decoded ${r.length} bytes, expected ${i} for ${t}x${t}`);
|
|
5543
|
+
return r;
|
|
5544
|
+
}
|
|
5545
|
+
async function Go(e = 64) {
|
|
5546
|
+
if (!Fo()) return !1;
|
|
5547
|
+
let t = new Uint8Array(e * e * 4);
|
|
5548
|
+
for (let e = 0; e < t.length; e += 4) t[e] = e % 256, t[e + 1] = e * 7 % 256, t[e + 2] = e * 13 % 256, t[e + 3] = 255;
|
|
5549
|
+
let n = await Ro(await Lo(t, e), e);
|
|
5550
|
+
if (n.length !== t.length) return !1;
|
|
5551
|
+
for (let e = 0; e < t.length; e++) if (t[e] !== n[e]) return !1;
|
|
5552
|
+
return !0;
|
|
5553
|
+
}
|
|
5554
|
+
//#endregion
|
|
5555
|
+
//#region src/cache/idb-core.ts
|
|
5556
|
+
var Ko = "material-designer-textures", qo = 1, Q = "meta", $ = "data";
|
|
5557
|
+
function Jo() {
|
|
5558
|
+
try {
|
|
5559
|
+
return typeof indexedDB < "u" && indexedDB !== null;
|
|
5560
|
+
} catch {
|
|
5561
|
+
return !1;
|
|
5562
|
+
}
|
|
5563
|
+
}
|
|
5564
|
+
function Yo(e) {
|
|
5565
|
+
return e ? `${Ko}-${e}` : Ko;
|
|
5566
|
+
}
|
|
5567
|
+
function Xo(e) {
|
|
5568
|
+
return new Promise((t, n) => {
|
|
5569
|
+
e.onsuccess = () => t(e.result), e.onerror = () => n(e.error ?? /* @__PURE__ */ Error("IndexedDB request failed"));
|
|
5570
|
+
});
|
|
5571
|
+
}
|
|
5572
|
+
function Zo(e) {
|
|
5573
|
+
return new Promise((t, n) => {
|
|
5574
|
+
e.oncomplete = () => t(), e.onabort = () => n(e.error ?? /* @__PURE__ */ Error("IndexedDB transaction aborted")), e.onerror = () => n(e.error ?? /* @__PURE__ */ Error("IndexedDB transaction failed"));
|
|
5575
|
+
});
|
|
5576
|
+
}
|
|
5577
|
+
function Qo(e) {
|
|
5578
|
+
return new Promise((t, n) => {
|
|
5579
|
+
let r = indexedDB.open(e, 1);
|
|
5580
|
+
r.onupgradeneeded = () => {
|
|
5581
|
+
let e = r.result;
|
|
5582
|
+
e.objectStoreNames.contains("meta") || e.createObjectStore(Q, { keyPath: "id" }), e.objectStoreNames.contains("data") || e.createObjectStore($, { keyPath: "id" });
|
|
5583
|
+
}, r.onsuccess = () => {
|
|
5584
|
+
let e = r.result;
|
|
5585
|
+
e.onversionchange = () => e.close(), t(e);
|
|
5586
|
+
}, r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("IndexedDB open failed")), r.onblocked = () => n(/* @__PURE__ */ Error("IndexedDB open blocked by another connection"));
|
|
5587
|
+
});
|
|
5588
|
+
}
|
|
5589
|
+
async function $o(e, t) {
|
|
5590
|
+
let n = e.transaction([Q, $], "readonly"), [r, i] = await Promise.all([Xo(n.objectStore(Q).get(t)), Xo(n.objectStore($).get(t))]);
|
|
5591
|
+
return !r || !i ? null : {
|
|
5592
|
+
meta: r,
|
|
5593
|
+
data: i
|
|
5594
|
+
};
|
|
5595
|
+
}
|
|
5596
|
+
async function es(e, t, n) {
|
|
5597
|
+
let r = e.transaction([Q, $], "readwrite");
|
|
5598
|
+
r.objectStore(Q).put(t), r.objectStore($).put(n), await Zo(r);
|
|
5599
|
+
}
|
|
5600
|
+
async function ts(e, t, n) {
|
|
5601
|
+
let r = e.transaction(Q, "readwrite"), i = r.objectStore(Q), a = await Xo(i.get(t));
|
|
5602
|
+
a && i.put({
|
|
5603
|
+
...a,
|
|
5604
|
+
lastUsedAt: n
|
|
5605
|
+
}), await Zo(r);
|
|
5606
|
+
}
|
|
5607
|
+
async function ns(e, t) {
|
|
5608
|
+
let n = e.transaction([Q, $], "readwrite");
|
|
5609
|
+
n.objectStore(Q).delete(t), n.objectStore($).delete(t), await Zo(n);
|
|
5610
|
+
}
|
|
5611
|
+
async function rs(e) {
|
|
5612
|
+
return Xo(e.transaction(Q, "readonly").objectStore(Q).getAll());
|
|
5613
|
+
}
|
|
5614
|
+
async function is(e) {
|
|
5615
|
+
let t = e.transaction([Q, $], "readwrite");
|
|
5616
|
+
t.objectStore(Q).clear(), t.objectStore($).clear(), await Zo(t);
|
|
5617
|
+
}
|
|
5618
|
+
function as(e) {
|
|
5619
|
+
return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : e.slice().buffer;
|
|
5620
|
+
}
|
|
5621
|
+
//#endregion
|
|
5622
|
+
//#region src/cache/memory-store.ts
|
|
5623
|
+
function os(e) {
|
|
5624
|
+
return {
|
|
5625
|
+
...e,
|
|
5626
|
+
channels: [...e.channels],
|
|
5627
|
+
textures: e.textures.map((e) => ({
|
|
5628
|
+
...e,
|
|
5629
|
+
bytes: new Uint8Array(e.bytes)
|
|
5630
|
+
}))
|
|
5631
|
+
};
|
|
5632
|
+
}
|
|
5633
|
+
function ss(e) {
|
|
5634
|
+
let { textures: t, ...n } = e;
|
|
5635
|
+
return {
|
|
5636
|
+
...n,
|
|
5637
|
+
channels: [...n.channels]
|
|
5638
|
+
};
|
|
5639
|
+
}
|
|
5640
|
+
function cs() {
|
|
5641
|
+
let e = /* @__PURE__ */ new Map();
|
|
5642
|
+
return {
|
|
5643
|
+
name: "memory",
|
|
5644
|
+
async get(t) {
|
|
5645
|
+
let n = e.get(t);
|
|
5646
|
+
return n ? os(n) : null;
|
|
5647
|
+
},
|
|
5648
|
+
async put(t) {
|
|
5649
|
+
e.set(t.id, os(t));
|
|
5650
|
+
},
|
|
5651
|
+
async touch(t, n) {
|
|
5652
|
+
let r = e.get(t);
|
|
5653
|
+
r && (r.lastUsedAt = n);
|
|
5654
|
+
},
|
|
5655
|
+
async delete(t) {
|
|
5656
|
+
e.delete(t);
|
|
5657
|
+
},
|
|
5658
|
+
async list() {
|
|
5659
|
+
return [...e.values()].map(ss);
|
|
5660
|
+
},
|
|
5661
|
+
async clear() {
|
|
5662
|
+
e.clear();
|
|
5663
|
+
},
|
|
5664
|
+
async estimate() {
|
|
5665
|
+
let t = 0;
|
|
5666
|
+
for (let n of e.values()) t += n.bytes;
|
|
5667
|
+
return {
|
|
5668
|
+
entries: e.size,
|
|
5669
|
+
bytes: t
|
|
5670
|
+
};
|
|
5671
|
+
}
|
|
5672
|
+
};
|
|
5673
|
+
}
|
|
5674
|
+
//#endregion
|
|
5675
|
+
//#region src/cache/cache.worker.ts?worker&inline
|
|
5676
|
+
var ls = "function e(){return typeof OffscreenCanvas<`u`&&typeof createImageBitmap<`u`&&typeof ImageData<`u`}function t(e){let t=new OffscreenCanvas(e,e).getContext(`2d`,{colorSpace:`srgb`,willReadFrequently:!0});if(!t)throw Error(`OffscreenCanvas 2D context unavailable`);return t}async function n(e,n){let r=new Uint8ClampedArray(e.length);r.set(e);for(let e=3;e<r.length;e+=4)r[e]=255;let i=t(n);i.putImageData(new ImageData(r,n,n,{colorSpace:`srgb`}),0,0);let a=await i.canvas.convertToBlob({type:`image/png`});return new Uint8Array(await a.arrayBuffer())}async function r(e,n){let r=new Blob([e],{type:`image/png`}),i=await createImageBitmap(r,{premultiplyAlpha:`none`,colorSpaceConversion:`none`});try{let e=t(n);e.drawImage(i,0,0);let r=e.getImageData(0,0,n,n,{colorSpace:`srgb`}).data,a=new Uint8Array(r.length);a.set(r);for(let e=3;e<a.length;e+=4)a[e]=255;return a}finally{i.close()}}function i(){return typeof CompressionStream<`u`&&typeof DecompressionStream<`u`}async function a(e,t){let n=new Blob([e]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}function o(e){return a(e,new CompressionStream(`deflate-raw`))}function s(e){return a(e,new DecompressionStream(`deflate-raw`))}async function c(t,r,a){return a===`png`&&e()?{bytes:await n(t,r),encoding:`png`}:a===`deflate`&&i()?{bytes:await o(t),encoding:`deflate`}:{bytes:t,encoding:`rgba8`}}async function l(e,t,n){let i=e;n===`png`?i=await r(e,t):n===`deflate`&&(i=await s(e));let a=t*t*4;if(i.length!==a)throw Error(`decoded ${i.length} bytes, expected ${a} for ${t}x${t}`);return i}const u=`material-designer-textures`,d=`meta`,f=`data`;function p(e){return e?`${u}-${e}`:u}function m(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error(`IndexedDB request failed`))})}function h(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onabort=()=>n(e.error??Error(`IndexedDB transaction aborted`)),e.onerror=()=>n(e.error??Error(`IndexedDB transaction failed`))})}function g(e){return new Promise((t,n)=>{let r=indexedDB.open(e,1);r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(`meta`)||e.createObjectStore(d,{keyPath:`id`}),e.objectStoreNames.contains(`data`)||e.createObjectStore(f,{keyPath:`id`})},r.onsuccess=()=>{let e=r.result;e.onversionchange=()=>e.close(),t(e)},r.onerror=()=>n(r.error??Error(`IndexedDB open failed`)),r.onblocked=()=>n(Error(`IndexedDB open blocked by another connection`))})}async function _(e,t){let n=e.transaction([d,f],`readonly`),[r,i]=await Promise.all([m(n.objectStore(d).get(t)),m(n.objectStore(f).get(t))]);return!r||!i?null:{meta:r,data:i}}async function v(e,t,n){let r=e.transaction([d,f],`readwrite`);r.objectStore(d).put(t),r.objectStore(f).put(n),await h(r)}async function y(e,t,n){let r=e.transaction(d,`readwrite`),i=r.objectStore(d),a=await m(i.get(t));a&&i.put({...a,lastUsedAt:n}),await h(r)}async function b(e,t){let n=e.transaction([d,f],`readwrite`);n.objectStore(d).delete(t),n.objectStore(f).delete(t),await h(n)}async function x(e){return m(e.transaction(d,`readonly`).objectStore(d).getAll())}async function S(e){let t=e.transaction([d,f],`readwrite`);t.objectStore(d).clear(),t.objectStore(f).clear(),await h(t)}function C(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.slice().buffer}const w=self;let T=null,E=p(``),D=`png`;function O(){return T||=g(E).catch(e=>{throw T=null,e}),T}async function k(e){let t=await _(await O(),e);if(!t)return{entry:null,transfer:[]};let{meta:n,data:r}=t,i=await Promise.all(r.textures.map(async e=>({channel:e.channel,encoding:`rgba8`,bytes:await l(new Uint8Array(e.bytes),n.size,e.encoding)})));return{entry:{...n,textures:i},transfer:i.map(e=>e.bytes.buffer)}}async function A(e){let t=await Promise.all(e.textures.map(async t=>({channel:t.channel,encoded:await c(t.bytes,e.size,D)}))),n=0,r=t.map(({channel:e,encoded:t})=>(n+=t.bytes.byteLength,{channel:e,encoding:t.encoding,bytes:C(t.bytes)})),i={...j(e),bytes:n},a={id:e.id,textures:r};await v(await O(),i,a)}function j(e){let{textures:t,...n}=e;return n}async function M(e){switch(e.op){case`configure`:{let{namespace:t,encoding:n}=e.payload,r=p(t??``);return r!==E&&(T?.then(e=>e.close()).catch(()=>void 0),T=null,E=r),n&&(D=n),{result:{ok:!0}}}case`get`:{let{entry:t,transfer:n}=await k(e.payload);return{result:t,transfer:n}}case`put`:return await A(e.payload),{};case`touch`:{let{id:t,lastUsedAt:n}=e.payload;return await y(await O(),t,n),{}}case`delete`:return await b(await O(),e.payload),{};case`list`:return{result:await x(await O())};case`clear`:return await S(await O()),{};case`estimate`:{let e=await x(await O()),t=0;for(let n of e)t+=n.bytes;return{result:{entries:e.length,bytes:t}}}default:throw Error(`unknown cache worker op: ${String(e.op)}`)}}w.onmessage=async e=>{let t=e.data;try{let{result:e,transfer:n}=await M(t),r={id:t.id,ok:!0,result:e};w.postMessage(r,n??[])}catch(e){let n={id:t.id,ok:!1,error:e instanceof Error?e.message:String(e)};w.postMessage(n)}};", us = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", ls], { type: "text/javascript;charset=utf-8" });
|
|
5677
|
+
function ds(e) {
|
|
5678
|
+
let t;
|
|
5679
|
+
try {
|
|
5680
|
+
if (t = us && (self.URL || self.webkitURL).createObjectURL(us), !t) throw "";
|
|
5681
|
+
let n = new Worker(t, {
|
|
5682
|
+
type: "module",
|
|
5683
|
+
name: e?.name
|
|
5684
|
+
});
|
|
5685
|
+
return n.addEventListener("error", () => {
|
|
5686
|
+
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
5687
|
+
}), n;
|
|
5688
|
+
} catch {
|
|
5689
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(ls), {
|
|
5690
|
+
type: "module",
|
|
5691
|
+
name: e?.name
|
|
5692
|
+
});
|
|
5693
|
+
}
|
|
5694
|
+
}
|
|
5695
|
+
//#endregion
|
|
5696
|
+
//#region src/cache/worker-client.ts
|
|
5697
|
+
function fs() {
|
|
5698
|
+
return typeof Worker < "u" && typeof indexedDB < "u";
|
|
5699
|
+
}
|
|
5700
|
+
function ps(e) {
|
|
5701
|
+
return e ? new Worker(e, { type: "module" }) : new ds();
|
|
5702
|
+
}
|
|
5703
|
+
function ms(e = {}) {
|
|
5704
|
+
if (!fs()) return null;
|
|
5705
|
+
let t;
|
|
5706
|
+
try {
|
|
5707
|
+
t = ps(e.url);
|
|
5708
|
+
} catch {
|
|
5709
|
+
return null;
|
|
5710
|
+
}
|
|
5711
|
+
let n = /* @__PURE__ */ new Map(), r = 1, i = null;
|
|
5712
|
+
t.onmessage = (e) => {
|
|
5713
|
+
let { id: t, ok: r, result: i, error: a } = e.data, o = n.get(t);
|
|
5714
|
+
o && (n.delete(t), r ? o.resolve(i) : o.reject(Error(a ?? "cache worker error")));
|
|
5715
|
+
};
|
|
5716
|
+
let a = (e) => {
|
|
5717
|
+
i = Error(e);
|
|
5718
|
+
for (let e of n.values()) e.reject(i);
|
|
5719
|
+
n.clear();
|
|
5720
|
+
};
|
|
5721
|
+
t.onerror = (e) => a(e.message || "cache worker crashed"), t.onmessageerror = () => a("cache worker message could not be deserialized");
|
|
5722
|
+
let o = (e, a, o = []) => {
|
|
5723
|
+
if (i) return Promise.reject(i);
|
|
5724
|
+
let s = r++;
|
|
5725
|
+
return new Promise((r, i) => {
|
|
5726
|
+
n.set(s, {
|
|
5727
|
+
resolve: r,
|
|
5728
|
+
reject: i
|
|
5729
|
+
});
|
|
5730
|
+
try {
|
|
5731
|
+
t.postMessage({
|
|
5732
|
+
id: s,
|
|
5733
|
+
op: e,
|
|
5734
|
+
payload: a
|
|
5735
|
+
}, o);
|
|
5736
|
+
} catch (e) {
|
|
5737
|
+
n.delete(s), i(e instanceof Error ? e : Error(String(e)));
|
|
5738
|
+
}
|
|
5739
|
+
});
|
|
5740
|
+
};
|
|
5741
|
+
return o("configure", {
|
|
5742
|
+
namespace: e.namespace ?? "",
|
|
5743
|
+
encoding: e.encoding ?? "png"
|
|
5744
|
+
}), {
|
|
5745
|
+
name: "worker-indexeddb",
|
|
5746
|
+
async get(e) {
|
|
5747
|
+
return await o("get", e) ?? null;
|
|
5748
|
+
},
|
|
5749
|
+
async put(e) {
|
|
5750
|
+
await o("put", e, e.textures.map((e) => e.bytes.buffer));
|
|
5751
|
+
},
|
|
5752
|
+
async touch(e, t) {
|
|
5753
|
+
await o("touch", {
|
|
5754
|
+
id: e,
|
|
5755
|
+
lastUsedAt: t
|
|
5756
|
+
});
|
|
5757
|
+
},
|
|
5758
|
+
async delete(e) {
|
|
5759
|
+
await o("delete", e);
|
|
5760
|
+
},
|
|
5761
|
+
async list() {
|
|
5762
|
+
return o("list");
|
|
5763
|
+
},
|
|
5764
|
+
async clear() {
|
|
5765
|
+
await o("clear");
|
|
5766
|
+
},
|
|
5767
|
+
async estimate() {
|
|
5768
|
+
return o("estimate");
|
|
5769
|
+
}
|
|
5770
|
+
};
|
|
5771
|
+
}
|
|
5772
|
+
//#endregion
|
|
5773
|
+
//#region src/cache/indexeddb-store.ts
|
|
5774
|
+
function hs(e = {}) {
|
|
5775
|
+
let t = Yo(e.namespace ?? ""), n = e.encoding ?? "png", r = null, i = () => (r ||= Qo(t).catch((e) => {
|
|
5776
|
+
throw r = null, e;
|
|
5777
|
+
}), r);
|
|
5778
|
+
return {
|
|
5779
|
+
name: "indexeddb",
|
|
5780
|
+
async get(e) {
|
|
5781
|
+
let t = await $o(await i(), e);
|
|
5782
|
+
if (!t) return null;
|
|
5783
|
+
let { meta: n, data: r } = t, a = await Promise.all(r.textures.map(async (e) => ({
|
|
5784
|
+
channel: e.channel,
|
|
5785
|
+
encoding: "rgba8",
|
|
5786
|
+
bytes: await Wo(new Uint8Array(e.bytes), n.size, e.encoding)
|
|
5787
|
+
})));
|
|
5788
|
+
return {
|
|
5789
|
+
...n,
|
|
5790
|
+
textures: a
|
|
5791
|
+
};
|
|
5792
|
+
},
|
|
5793
|
+
async put(e) {
|
|
5794
|
+
let t = await Promise.all(e.textures.map(async (t) => ({
|
|
5795
|
+
channel: t.channel,
|
|
5796
|
+
encoded: await Uo(t.bytes, e.size, n)
|
|
5797
|
+
}))), r = 0, a = t.map(({ channel: e, encoded: t }) => (r += t.bytes.byteLength, {
|
|
5798
|
+
channel: e,
|
|
5799
|
+
encoding: t.encoding,
|
|
5800
|
+
bytes: as(t.bytes)
|
|
5801
|
+
})), { textures: o, ...s } = e, c = {
|
|
5802
|
+
...s,
|
|
5803
|
+
bytes: r
|
|
5804
|
+
}, l = {
|
|
5805
|
+
id: e.id,
|
|
5806
|
+
textures: a
|
|
5807
|
+
};
|
|
5808
|
+
await es(await i(), c, l);
|
|
5809
|
+
},
|
|
5810
|
+
async touch(e, t) {
|
|
5811
|
+
await ts(await i(), e, t);
|
|
5812
|
+
},
|
|
5813
|
+
async delete(e) {
|
|
5814
|
+
await ns(await i(), e);
|
|
5815
|
+
},
|
|
5816
|
+
async list() {
|
|
5817
|
+
return rs(await i());
|
|
5818
|
+
},
|
|
5819
|
+
async clear() {
|
|
5820
|
+
await is(await i());
|
|
5821
|
+
},
|
|
5822
|
+
async estimate() {
|
|
5823
|
+
let e = await rs(await i()), t = 0;
|
|
5824
|
+
for (let n of e) t += n.bytes;
|
|
5825
|
+
return {
|
|
5826
|
+
entries: e.length,
|
|
5827
|
+
bytes: t
|
|
5828
|
+
};
|
|
5829
|
+
}
|
|
5830
|
+
};
|
|
5831
|
+
}
|
|
5832
|
+
function gs(e = {}) {
|
|
5833
|
+
let { worker: t = !0, ...n } = e;
|
|
5834
|
+
if (t !== !1) {
|
|
5835
|
+
let e = ms({
|
|
5836
|
+
...n,
|
|
5837
|
+
url: typeof t == "object" ? t.url : void 0
|
|
5838
|
+
});
|
|
5839
|
+
if (e) return e;
|
|
5840
|
+
}
|
|
5841
|
+
return Jo() ? hs(n) : cs();
|
|
5842
|
+
}
|
|
5843
|
+
//#endregion
|
|
5844
|
+
//#region src/cache/bake-cache.ts
|
|
5845
|
+
var _s = 256 * 1024 * 1024, vs = 256 * 1024 * 1024, ys = 250, bs = 750;
|
|
5846
|
+
function xs(e) {
|
|
5847
|
+
let t = 0;
|
|
5848
|
+
for (let n of e) t += n.bytes.byteLength;
|
|
5849
|
+
return t;
|
|
5850
|
+
}
|
|
5851
|
+
function Ss(e) {
|
|
5852
|
+
if (!e || typeof e != "object") return !1;
|
|
5853
|
+
let t = e.name;
|
|
5854
|
+
return t === "QuotaExceededError" || t === "NS_ERROR_DOM_QUOTA_REACHED";
|
|
5855
|
+
}
|
|
5856
|
+
var Cs = class {
|
|
5857
|
+
store;
|
|
5858
|
+
ownsStore;
|
|
5859
|
+
enabled_;
|
|
5860
|
+
options;
|
|
5861
|
+
onEvent;
|
|
5862
|
+
workerOption;
|
|
5863
|
+
hits = 0;
|
|
5864
|
+
misses = 0;
|
|
5865
|
+
writes = 0;
|
|
5866
|
+
evictions = 0;
|
|
5867
|
+
collisions = 0;
|
|
5868
|
+
lastError_ = null;
|
|
5869
|
+
quotaFailures = 0;
|
|
5870
|
+
gcDone = !1;
|
|
5871
|
+
constructor(e = {}) {
|
|
5872
|
+
let t = e.encoding ?? "deflate";
|
|
5873
|
+
this.ownsStore = e.store === void 0, this.workerOption = e.worker, this.store = e.store ?? gs({
|
|
5874
|
+
namespace: e.namespace ?? "",
|
|
5875
|
+
encoding: t,
|
|
5876
|
+
worker: e.worker
|
|
5877
|
+
}), this.enabled_ = e.enabled ?? !1, this.onEvent = e.onEvent, this.options = {
|
|
5878
|
+
encoding: t,
|
|
5879
|
+
budgetBytes: e.budgetBytes ?? _s,
|
|
5880
|
+
maxEntryBytes: e.maxEntryBytes ?? vs,
|
|
5881
|
+
minBakeMs: e.minBakeMs ?? ys,
|
|
5882
|
+
writeDelayMs: e.writeDelayMs ?? bs,
|
|
5883
|
+
namespace: e.namespace ?? ""
|
|
5884
|
+
};
|
|
5885
|
+
}
|
|
5886
|
+
get enabled() {
|
|
5887
|
+
return this.enabled_ && this.store !== null;
|
|
5888
|
+
}
|
|
5889
|
+
get available() {
|
|
5890
|
+
return this.store !== null;
|
|
5891
|
+
}
|
|
5892
|
+
get storeName() {
|
|
5893
|
+
return this.store?.name ?? "none";
|
|
5894
|
+
}
|
|
5895
|
+
get encoding() {
|
|
5896
|
+
return this.options.encoding;
|
|
5897
|
+
}
|
|
5898
|
+
get namespace() {
|
|
5899
|
+
return this.options.namespace;
|
|
5900
|
+
}
|
|
5901
|
+
get writeDelayMs() {
|
|
5902
|
+
return this.options.writeDelayMs;
|
|
5903
|
+
}
|
|
5904
|
+
get lastError() {
|
|
5905
|
+
return this.lastError_;
|
|
5906
|
+
}
|
|
5907
|
+
setEnabled(e) {
|
|
5908
|
+
this.enabled_ = e;
|
|
5909
|
+
}
|
|
5910
|
+
configure(e) {
|
|
5911
|
+
e.store !== void 0 && (this.store = e.store, this.ownsStore = !1, this.gcDone = !1, this.quotaFailures = 0), e.enabled !== void 0 && (this.enabled_ = e.enabled), e.onEvent !== void 0 && (this.onEvent = e.onEvent), e.budgetBytes !== void 0 && (this.options.budgetBytes = e.budgetBytes), e.maxEntryBytes !== void 0 && (this.options.maxEntryBytes = e.maxEntryBytes), e.minBakeMs !== void 0 && (this.options.minBakeMs = e.minBakeMs), e.writeDelayMs !== void 0 && (this.options.writeDelayMs = e.writeDelayMs), e.worker !== void 0 && (this.workerOption = e.worker);
|
|
5912
|
+
let t = e.encoding !== void 0 && e.encoding !== this.options.encoding, n = e.namespace !== void 0 && e.namespace !== this.options.namespace;
|
|
5913
|
+
e.encoding !== void 0 && (this.options.encoding = e.encoding), e.namespace !== void 0 && (this.options.namespace = e.namespace), (t || n || e.worker !== void 0) && this.ownsStore && (this.store = gs({
|
|
5914
|
+
namespace: this.options.namespace,
|
|
5915
|
+
encoding: this.options.encoding,
|
|
5916
|
+
worker: this.workerOption
|
|
5917
|
+
}), this.gcDone = !1, this.quotaFailures = 0);
|
|
5918
|
+
}
|
|
5919
|
+
async read(e) {
|
|
5920
|
+
if (!this.enabled || !this.store) return null;
|
|
5921
|
+
await this.ensureGc();
|
|
5922
|
+
let t = await this.guard("read", () => this.store.get(e.id), null);
|
|
5923
|
+
return t ? t.key === e.key ? (this.hits += 1, this.emit({
|
|
5924
|
+
kind: "hit",
|
|
5925
|
+
id: e.id,
|
|
5926
|
+
bytes: t.bytes
|
|
5927
|
+
}), this.guard("touch", () => this.store.touch(e.id, Date.now()), void 0), t) : (this.collisions += 1, this.misses += 1, this.emit({
|
|
5928
|
+
kind: "collision",
|
|
5929
|
+
id: e.id
|
|
5930
|
+
}), await this.guard("collision-delete", () => this.store.delete(e.id), void 0), null) : (this.misses += 1, this.emit({
|
|
5931
|
+
kind: "miss",
|
|
5932
|
+
id: e.id
|
|
5933
|
+
}), null);
|
|
5934
|
+
}
|
|
5935
|
+
async peek(e) {
|
|
5936
|
+
if (!this.enabled || !this.store) return null;
|
|
5937
|
+
let t = await this.guard("peek", () => this.store.get(e.id), null);
|
|
5938
|
+
if (!t || t.key !== e.key) return null;
|
|
5939
|
+
let { textures: n, ...r } = t;
|
|
5940
|
+
return r;
|
|
5941
|
+
}
|
|
5942
|
+
async entries() {
|
|
5943
|
+
return this.store ? this.guard("list", () => this.store.list(), []) : [];
|
|
5944
|
+
}
|
|
5945
|
+
canWrite(e, t) {
|
|
5946
|
+
return !this.enabled || !this.store || t <= 0 || t > this.options.maxEntryBytes ? !1 : e >= this.options.minBakeMs;
|
|
5947
|
+
}
|
|
5948
|
+
async write(e, t) {
|
|
5949
|
+
if (!this.enabled || !this.store) return;
|
|
5950
|
+
let n = xs(t.textures);
|
|
5951
|
+
if (!this.canWrite(t.bakeMs, n)) return;
|
|
5952
|
+
let r = Date.now(), i = {
|
|
5953
|
+
id: e.id,
|
|
5954
|
+
key: e.key,
|
|
5955
|
+
schema: so,
|
|
5956
|
+
size: t.size,
|
|
5957
|
+
encoding: this.options.encoding,
|
|
5958
|
+
channels: [...t.channels],
|
|
5959
|
+
hasHeight: t.hasHeight,
|
|
5960
|
+
bytes: n,
|
|
5961
|
+
bakeMs: t.bakeMs,
|
|
5962
|
+
createdAt: r,
|
|
5963
|
+
lastUsedAt: r,
|
|
5964
|
+
textures: t.textures
|
|
5965
|
+
};
|
|
5966
|
+
await this.evictTo(Math.max(0, this.options.budgetBytes - n), e.id), await this.put(i) && (this.writes += 1, this.emit({
|
|
5967
|
+
kind: "write",
|
|
5968
|
+
id: e.id,
|
|
5969
|
+
bytes: n
|
|
5970
|
+
}));
|
|
5971
|
+
}
|
|
5972
|
+
async delete(e) {
|
|
5973
|
+
if (!this.store) return;
|
|
5974
|
+
let t = typeof e == "string" ? e : e.id;
|
|
5975
|
+
await this.guard("delete", () => this.store.delete(t), void 0);
|
|
5976
|
+
}
|
|
5977
|
+
async clear() {
|
|
5978
|
+
this.store && await this.guard("clear", () => this.store.clear(), void 0);
|
|
5979
|
+
}
|
|
5980
|
+
async gc() {
|
|
5981
|
+
if (!this.store) return 0;
|
|
5982
|
+
let e = await this.entries(), t = 0;
|
|
5983
|
+
for (let n of e) n.schema !== so && (await this.guard("gc-delete", () => this.store.delete(n.id), void 0), t += 1);
|
|
5984
|
+
return t;
|
|
5985
|
+
}
|
|
5986
|
+
async evict() {
|
|
5987
|
+
return this.evictTo(this.options.budgetBytes);
|
|
5988
|
+
}
|
|
5989
|
+
async metrics() {
|
|
5990
|
+
let e = await this.entries(), t = 0;
|
|
5991
|
+
for (let n of e) t += n.bytes;
|
|
5992
|
+
return {
|
|
5993
|
+
enabled: this.enabled,
|
|
5994
|
+
available: this.available,
|
|
5995
|
+
store: this.storeName,
|
|
5996
|
+
encoding: this.options.encoding,
|
|
5997
|
+
entries: e.length,
|
|
5998
|
+
bytes: t,
|
|
5999
|
+
budgetBytes: this.options.budgetBytes,
|
|
6000
|
+
hits: this.hits,
|
|
6001
|
+
misses: this.misses,
|
|
6002
|
+
writes: this.writes,
|
|
6003
|
+
evictions: this.evictions,
|
|
6004
|
+
collisions: this.collisions,
|
|
6005
|
+
quota: await ws(),
|
|
6006
|
+
lastError: this.lastError_
|
|
6007
|
+
};
|
|
6008
|
+
}
|
|
6009
|
+
info() {
|
|
6010
|
+
return {
|
|
6011
|
+
enabled: this.enabled,
|
|
6012
|
+
store: this.storeName,
|
|
6013
|
+
encoding: this.options.encoding,
|
|
6014
|
+
hits: this.hits,
|
|
6015
|
+
misses: this.misses,
|
|
6016
|
+
writes: this.writes,
|
|
6017
|
+
evictions: this.evictions,
|
|
6018
|
+
collisions: this.collisions,
|
|
6019
|
+
lastError: this.lastError_
|
|
6020
|
+
};
|
|
6021
|
+
}
|
|
6022
|
+
async put(e) {
|
|
6023
|
+
try {
|
|
6024
|
+
return await this.store.put(e), this.quotaFailures = 0, !0;
|
|
6025
|
+
} catch (t) {
|
|
6026
|
+
if (!Ss(t)) return this.fail("put", t), !1;
|
|
6027
|
+
this.quotaFailures += 1, await this.evictTo(Math.floor(this.options.budgetBytes / 2), e.id);
|
|
6028
|
+
try {
|
|
6029
|
+
return await this.store.put(e), this.quotaFailures = 0, !0;
|
|
6030
|
+
} catch (e) {
|
|
6031
|
+
return this.fail("put-retry", e), this.quotaFailures >= 2 && (this.enabled_ = !1, this.emit({
|
|
6032
|
+
kind: "disabled",
|
|
6033
|
+
message: "storage quota exhausted"
|
|
6034
|
+
})), !1;
|
|
6035
|
+
}
|
|
6036
|
+
}
|
|
6037
|
+
}
|
|
6038
|
+
async evictTo(e, t) {
|
|
6039
|
+
if (!this.store) return 0;
|
|
6040
|
+
let n = await this.entries(), r = 0;
|
|
6041
|
+
for (let e of n) r += e.bytes;
|
|
6042
|
+
if (r <= e) return 0;
|
|
6043
|
+
let i = n.filter((e) => e.id !== t).sort((e, t) => e.lastUsedAt - t.lastUsedAt), a = 0;
|
|
6044
|
+
for (let t of i) {
|
|
6045
|
+
if (r <= e) break;
|
|
6046
|
+
await this.guard("evict", () => this.store.delete(t.id), void 0), r -= t.bytes, a += 1, this.evictions += 1, this.emit({
|
|
6047
|
+
kind: "evict",
|
|
6048
|
+
id: t.id,
|
|
6049
|
+
bytes: t.bytes
|
|
6050
|
+
});
|
|
6051
|
+
}
|
|
6052
|
+
return a;
|
|
6053
|
+
}
|
|
6054
|
+
async ensureGc() {
|
|
6055
|
+
this.gcDone || (this.gcDone = !0, await this.gc());
|
|
6056
|
+
}
|
|
6057
|
+
async guard(e, t, n) {
|
|
6058
|
+
try {
|
|
6059
|
+
return await t();
|
|
6060
|
+
} catch (t) {
|
|
6061
|
+
return this.fail(e, t), n;
|
|
6062
|
+
}
|
|
6063
|
+
}
|
|
6064
|
+
fail(e, t) {
|
|
6065
|
+
this.lastError_ = `${e}: ${t instanceof Error ? t.message : String(t)}`, this.emit({
|
|
6066
|
+
kind: "error",
|
|
6067
|
+
message: this.lastError_
|
|
6068
|
+
});
|
|
6069
|
+
}
|
|
6070
|
+
emit(e) {
|
|
6071
|
+
if (this.onEvent) try {
|
|
6072
|
+
this.onEvent(e);
|
|
6073
|
+
} catch {}
|
|
6074
|
+
}
|
|
6075
|
+
};
|
|
6076
|
+
async function ws() {
|
|
6077
|
+
let e = typeof navigator < "u" ? navigator.storage : void 0;
|
|
6078
|
+
if (!e?.estimate) return null;
|
|
6079
|
+
try {
|
|
6080
|
+
let { usage: t, quota: n } = await e.estimate();
|
|
6081
|
+
return {
|
|
6082
|
+
usage: t ?? 0,
|
|
6083
|
+
quota: n ?? 0
|
|
6084
|
+
};
|
|
6085
|
+
} catch {
|
|
6086
|
+
return null;
|
|
6087
|
+
}
|
|
5157
6088
|
}
|
|
5158
6089
|
//#endregion
|
|
5159
6090
|
//#region src/runtime.ts
|
|
5160
|
-
var
|
|
6091
|
+
var Ts = class {
|
|
5161
6092
|
graph;
|
|
5162
6093
|
surface;
|
|
5163
6094
|
service;
|
|
5164
6095
|
constructor(e = {}) {
|
|
5165
|
-
this.service = e.bakeService ??
|
|
6096
|
+
this.service = e.bakeService ?? wo, this.graph = new _a(e.document, e.registry ?? Ai), this.surface = new Mo(this.graph, this.service, e.source), e.cache instanceof Cs ? this.service.setCache(e.cache) : e.cache && this.service.setCache(new Cs({
|
|
6097
|
+
enabled: !0,
|
|
6098
|
+
...e.cache
|
|
6099
|
+
}));
|
|
5166
6100
|
}
|
|
5167
6101
|
getNodeMaterial() {
|
|
5168
6102
|
return this.surface.material;
|
|
5169
6103
|
}
|
|
5170
6104
|
getMeshMaterial() {
|
|
5171
|
-
return
|
|
6105
|
+
return Po(this.graph.document, { get: (e) => this.surface.getChannelTexture(e) });
|
|
5172
6106
|
}
|
|
5173
6107
|
releaseCaches() {
|
|
5174
6108
|
return this.surface.releaseCaches();
|
|
@@ -5215,40 +6149,63 @@ var Qa = class {
|
|
|
5215
6149
|
dispose() {
|
|
5216
6150
|
this.surface.dispose();
|
|
5217
6151
|
}
|
|
6152
|
+
get cache() {
|
|
6153
|
+
return this.service.cache;
|
|
6154
|
+
}
|
|
6155
|
+
setCacheEnabled(e) {
|
|
6156
|
+
let t = this.service.cache;
|
|
6157
|
+
return t ? (t.setEnabled(e), this) : (e && this.service.setCache(new Cs({ enabled: !0 })), this);
|
|
6158
|
+
}
|
|
6159
|
+
get cacheEnabled() {
|
|
6160
|
+
return this.service.cache?.enabled ?? !1;
|
|
6161
|
+
}
|
|
6162
|
+
clearCache() {
|
|
6163
|
+
return this.service.cache?.clear() ?? Promise.resolve();
|
|
6164
|
+
}
|
|
6165
|
+
async rebuildCache() {
|
|
6166
|
+
let e = this.service.cache;
|
|
6167
|
+
e && (await e.delete(this.cacheKey()), this.surface.regenerate(), await this.surface.whenIdle(), await this.service.flushCacheWrites());
|
|
6168
|
+
}
|
|
6169
|
+
getCachedTextures() {
|
|
6170
|
+
return this.service.cache?.peek(this.cacheKey()) ?? Promise.resolve(null);
|
|
6171
|
+
}
|
|
6172
|
+
async listCachedTextures() {
|
|
6173
|
+
return (await this.service.cache?.entries() ?? []).sort((e, t) => t.lastUsedAt - e.lastUsedAt);
|
|
6174
|
+
}
|
|
6175
|
+
async loadCachedChannelTextures() {
|
|
6176
|
+
let e = this.service.cache;
|
|
6177
|
+
if (!e) return null;
|
|
6178
|
+
let t = await e.read(this.cacheKey());
|
|
6179
|
+
if (!t) return null;
|
|
6180
|
+
let n = /* @__PURE__ */ new Map(), r = null;
|
|
6181
|
+
for (let e of t.textures) {
|
|
6182
|
+
let i = Ga(e.bytes, t.size, e.channel);
|
|
6183
|
+
e.channel === "height" ? r = i : n.set(e.channel, i);
|
|
6184
|
+
}
|
|
6185
|
+
return {
|
|
6186
|
+
size: t.size,
|
|
6187
|
+
channels: [...n.keys()],
|
|
6188
|
+
height: r,
|
|
6189
|
+
get: (e) => n.get(e) ?? null,
|
|
6190
|
+
dispose: () => {
|
|
6191
|
+
for (let e of n.values()) e.dispose();
|
|
6192
|
+
r?.dispose(), n.clear(), r = null;
|
|
6193
|
+
}
|
|
6194
|
+
};
|
|
6195
|
+
}
|
|
6196
|
+
cacheMetrics() {
|
|
6197
|
+
return this.service.cacheMetrics();
|
|
6198
|
+
}
|
|
6199
|
+
flushCache() {
|
|
6200
|
+
return this.service.flushCacheWrites();
|
|
6201
|
+
}
|
|
6202
|
+
cacheKey() {
|
|
6203
|
+
return this.service.cacheKeyFor(this.graph, this.surface.bakeSize, yo);
|
|
6204
|
+
}
|
|
5218
6205
|
};
|
|
5219
6206
|
//#endregion
|
|
5220
|
-
//#region src/topology.ts
|
|
5221
|
-
function $a(e) {
|
|
5222
|
-
return Array.isArray(e) ? `[${e.map($a).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => `${e}:${$a(t)}`).join(",")}}` : JSON.stringify(e);
|
|
5223
|
-
}
|
|
5224
|
-
function eo(e, t) {
|
|
5225
|
-
let n = t.get(e.type), r = n.paramsFor ? n.paramsFor(e.params) : n.params, i = {};
|
|
5226
|
-
for (let t of r) (t.type === "int" || t.type === "bool" || t.type === "select" || t.bakeStructural) && (i[t.key] = e.params[t.key]);
|
|
5227
|
-
return i;
|
|
5228
|
-
}
|
|
5229
|
-
function to(e, t) {
|
|
5230
|
-
return {
|
|
5231
|
-
id: e.id,
|
|
5232
|
-
type: e.type,
|
|
5233
|
-
enabled: e.enabled,
|
|
5234
|
-
ports: Q(e, t),
|
|
5235
|
-
params: eo(e, t),
|
|
5236
|
-
subgraph: e.subgraph ? no(e.subgraph, t) : null
|
|
5237
|
-
};
|
|
5238
|
-
}
|
|
5239
|
-
function no(e, t) {
|
|
5240
|
-
return {
|
|
5241
|
-
version: e.version,
|
|
5242
|
-
nodes: e.nodes.map((e) => to(e, t)).sort((e, t) => String(e.id).localeCompare(String(t.id))),
|
|
5243
|
-
edges: [...e.edges].sort((e, t) => $a(e).localeCompare($a(t)))
|
|
5244
|
-
};
|
|
5245
|
-
}
|
|
5246
|
-
function ro(e, t) {
|
|
5247
|
-
return $a(no(e, t));
|
|
5248
|
-
}
|
|
5249
|
-
//#endregion
|
|
5250
6207
|
//#region src/graph/tiling-test.ts
|
|
5251
|
-
function
|
|
6208
|
+
function Es(e) {
|
|
5252
6209
|
return {
|
|
5253
6210
|
version: 4,
|
|
5254
6211
|
nodes: [
|
|
@@ -5301,7 +6258,7 @@ function io(e) {
|
|
|
5301
6258
|
}]
|
|
5302
6259
|
};
|
|
5303
6260
|
}
|
|
5304
|
-
function
|
|
6261
|
+
function Ds(e, t) {
|
|
5305
6262
|
let n = (n, r) => e.data[(r * t + n) * 4], r = 0, i = 0;
|
|
5306
6263
|
for (let e = 0; e < t; e++) {
|
|
5307
6264
|
r += Math.abs(n(t - 1, e) - n(0, e));
|
|
@@ -5321,10 +6278,10 @@ function ao(e, t) {
|
|
|
5321
6278
|
ratioV: a / Math.max(o, .001)
|
|
5322
6279
|
};
|
|
5323
6280
|
}
|
|
5324
|
-
async function
|
|
6281
|
+
async function Os(e, t, n = {}) {
|
|
5325
6282
|
let r = n.size ?? 256, i = n.threshold ?? 3, a = n.channel ?? "baseColor", o = t.get("tileable-noise").params, s = o.find((e) => e.key === "noiseType")?.options ?? [], c = (o.find((e) => e.key === "preset")?.options ?? []).filter((e) => e !== "none"), l = new Set(c), u = n.types ?? [...s, ...c], d = [];
|
|
5326
6283
|
for (let o of u) {
|
|
5327
|
-
let s = new
|
|
6284
|
+
let s = new _a(Es(l.has(o) ? {
|
|
5328
6285
|
noiseType: "perlin-fbm",
|
|
5329
6286
|
preset: o
|
|
5330
6287
|
} : { noiseType: o }), t), c = await e.readImage(s, a, r);
|
|
@@ -5342,7 +6299,7 @@ async function oo(e, t, n = {}) {
|
|
|
5342
6299
|
continue;
|
|
5343
6300
|
}
|
|
5344
6301
|
n.onTile && await n.onTile(o, c);
|
|
5345
|
-
let u =
|
|
6302
|
+
let u = Ds(c, r);
|
|
5346
6303
|
d.push({
|
|
5347
6304
|
type: o,
|
|
5348
6305
|
...u,
|
|
@@ -5352,4 +6309,4 @@ async function oo(e, t, n = {}) {
|
|
|
5352
6309
|
return d;
|
|
5353
6310
|
}
|
|
5354
6311
|
//#endregion
|
|
5355
|
-
export {
|
|
6312
|
+
export { Ko as BAKE_CACHE_DB_NAME, qo as BAKE_CACHE_DB_VERSION, oo as BAKE_CACHE_ID_PREFIX, so as BAKE_CACHE_SCHEMA, io as BAKE_CACHE_VERSION, ao as BAKE_ENCODER_VERSION, Cs as BakeTextureCache, So as BakedTextureSet, Qe as COERCION_MATRIX, Ve as CURVE_CHANNELS, Be as CURVE_IDENTITY, qe as GROUP_INPUT_TYPE, Je as GROUP_OUTPUT_TYPE, Ke as GROUP_TYPE, sa as MATERIAL_DOCUMENT_VERSION, Ye as MATERIAL_OUTPUT_TYPE, qa as MATERIAL_RUNTIME_VERSION, Ue as MATERIAL_TYPES, We as MATERIAL_TYPE_CAPS, Co as MaterialBakeService, Ts as MaterialGraphRuntime, _a as MaterialGraphSession, Oi as NodeRegistry, Ze as PBR_SOCKETS, Xe as SHADER_MATERIAL_TYPE, yo as SURFACE_CHANNELS, Mo as TexturedSurface, wo as bakeService, Po as buildMeshMaterial, zo as canDeflate, Fo as canEncodePng, Ja as canonicalStringify, Fa as channelByteLength, Ga as channelDataTexture, ca as cloneMaterialDocument, $e as coercionFor, $i as compileGraph, Gi as compileSockets, Wi as countGraphNodes, lo as createBakeCacheKey, gs as createDefaultCacheStore, la as createDefaultMaterialDocument, ki as createDefaultRegistry, hs as createIndexedDbCacheStore, ro as createMaterialParamKey, Qa as createMaterialTopologyKey, cs as createMemoryCacheStore, ms as createWorkerCacheStore, He as curveToArray, Wo as decodeTexels, Ai as defaultRegistry, Vo as deflateBytes, La as depadRows, Wa as disposeTransferPool, Uo as encodeTexels, Ra as flipRows, co as fnv1a64, Ho as inflateBytes, Jo as isIndexedDbAvailable, fs as isWorkerCacheAvailable, pa as migrateMaterialDocument, Zi as newSurfaceMaterial, Di as nodeParamDefs, Y as nodePorts, Ge as normalizeMaterialType, Ia as paddedBytesPerRow, Go as pngRoundTripIsLossless, Vi as readMaterialConfig, Bi as readMaterialSurface, zi as readOutputResolution, Ba as readTargetTexels, Os as runTilingTest, Ua as transferPoolInfo, Ka as writeTargetTexels };
|