hz-particles 1.5.2 → 1.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/hz-particles.cjs +6 -6
- package/dist-lib/hz-particles.mjs +488 -482
- package/package.json +1 -1
|
@@ -193,8 +193,8 @@ class qs {
|
|
|
193
193
|
if (Math.abs(a) < 1e-6 || o <= 1e-6)
|
|
194
194
|
l = Math.random();
|
|
195
195
|
else {
|
|
196
|
-
const S = Math.random(), b = 0.5 * a,
|
|
197
|
-
l = (-
|
|
196
|
+
const S = Math.random(), b = 0.5 * a, f = e, v = -S * o, C = Math.max(0, f * f - 4 * b * v);
|
|
197
|
+
l = (-f + Math.sqrt(C)) / (2 * b), Number.isFinite(l) || (l = Math.random()), l = Math.min(1, Math.max(0, l));
|
|
198
198
|
}
|
|
199
199
|
const c = l * r, d = e + a * l;
|
|
200
200
|
t[0] = Math.cos(n) * d, t[1] = c, t[2] = Math.sin(n) * d;
|
|
@@ -257,32 +257,32 @@ class qs {
|
|
|
257
257
|
}
|
|
258
258
|
calculateVelocity(t, e, i, r, n) {
|
|
259
259
|
const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, l = this.config.emissionPositionZ || 0, c = t - a, d = e - o, S = i - l, b = Math.sqrt(c * c + d * d + S * S);
|
|
260
|
-
let
|
|
260
|
+
let f, v, C;
|
|
261
261
|
if (b > 1e-4) {
|
|
262
262
|
let D = !1;
|
|
263
263
|
if (this.config.emissionShape === "circle" && this.config.circleVelocityDirection === "tangential") {
|
|
264
|
-
const
|
|
264
|
+
const M = this.inverseRotation(c, d, S), Z = Math.sqrt(M[0] * M[0] + M[1] * M[1]);
|
|
265
265
|
if (Z > 1e-4) {
|
|
266
|
-
const T = -
|
|
267
|
-
|
|
266
|
+
const T = -M[1] / Z, G = M[0] / Z, F = this.applyRotation(T, G, 0);
|
|
267
|
+
f = F[0], v = F[1], C = F[2], D = !0;
|
|
268
268
|
}
|
|
269
269
|
} else if (this.config.emissionShape === "cylinder" && this.config.cylinderVelocityDirection === "tangential") {
|
|
270
|
-
const
|
|
270
|
+
const M = this.inverseRotation(c, d, S), Z = Math.sqrt(M[0] * M[0] + M[2] * M[2]);
|
|
271
271
|
if (Z > 1e-4) {
|
|
272
|
-
const T = -
|
|
273
|
-
|
|
272
|
+
const T = -M[2] / Z, G = M[0] / Z, F = this.applyRotation(T, 0, G);
|
|
273
|
+
f = F[0], v = F[1], C = F[2], D = !0;
|
|
274
274
|
} else {
|
|
275
|
-
const T = Math.random() * Math.PI * 2,
|
|
276
|
-
|
|
275
|
+
const T = Math.random() * Math.PI * 2, G = this.applyRotation(Math.cos(T), 0, Math.sin(T));
|
|
276
|
+
f = G[0], v = G[1], C = G[2], D = !0;
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
D || (
|
|
279
|
+
D || (f = c / b, v = d / b, C = S / b);
|
|
280
280
|
} else {
|
|
281
|
-
const D = Math.random() * Math.PI * 2,
|
|
282
|
-
|
|
281
|
+
const D = Math.random() * Math.PI * 2, M = Math.acos(2 * Math.random() - 1);
|
|
282
|
+
f = Math.sin(M) * Math.cos(D), v = Math.sin(M) * Math.sin(D), C = Math.cos(M);
|
|
283
283
|
}
|
|
284
284
|
let z;
|
|
285
|
-
this.config.randomSpeed ? z = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : z = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity :
|
|
285
|
+
this.config.randomSpeed ? z = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : z = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity : f * z, r[n + 1] = this.config.overrideYVelocity ? this.config.yVelocity : v * z, r[n + 2] = this.config.overrideZVelocity ? this.config.zVelocity : C * z, r[n + 3] = 0;
|
|
286
286
|
}
|
|
287
287
|
setParticleColor(t, e) {
|
|
288
288
|
if (this.config.randomColorEnabled && this.config.randomColors.length > 0) {
|
|
@@ -1729,7 +1729,7 @@ function ar(s) {
|
|
|
1729
1729
|
}
|
|
1730
1730
|
});
|
|
1731
1731
|
}
|
|
1732
|
-
class
|
|
1732
|
+
class Gi {
|
|
1733
1733
|
/**
|
|
1734
1734
|
* @param {string} source - User script source code
|
|
1735
1735
|
* @param {object} config - ParticleSystem config (will be proxied)
|
|
@@ -1823,11 +1823,11 @@ async function or(s) {
|
|
|
1823
1823
|
const r = t.getUint32(8, !0);
|
|
1824
1824
|
let n = 12, a = null, o = null;
|
|
1825
1825
|
for (; n < r; ) {
|
|
1826
|
-
const T = t.getUint32(n, !0),
|
|
1827
|
-
if (
|
|
1828
|
-
const se = new TextDecoder("utf-8").decode(
|
|
1826
|
+
const T = t.getUint32(n, !0), G = t.getUint32(n + 4, !0), F = s.slice(n + 8, n + 8 + T);
|
|
1827
|
+
if (G === 1313821514) {
|
|
1828
|
+
const se = new TextDecoder("utf-8").decode(F);
|
|
1829
1829
|
a = JSON.parse(se);
|
|
1830
|
-
} else
|
|
1830
|
+
} else G === 5130562 && (o = F);
|
|
1831
1831
|
n += 8 + T;
|
|
1832
1832
|
}
|
|
1833
1833
|
if (!a)
|
|
@@ -1848,19 +1848,19 @@ async function or(s) {
|
|
|
1848
1848
|
const T = c.indices;
|
|
1849
1849
|
if (T === void 0)
|
|
1850
1850
|
throw new Error("Cannot generate normals without indices");
|
|
1851
|
-
const
|
|
1852
|
-
b = lr(S,
|
|
1851
|
+
const G = Fi(a, o, T);
|
|
1852
|
+
b = lr(S, G);
|
|
1853
1853
|
}
|
|
1854
|
-
const
|
|
1855
|
-
if (
|
|
1854
|
+
const f = c.indices;
|
|
1855
|
+
if (f === void 0)
|
|
1856
1856
|
throw new Error("Mesh primitive missing indices");
|
|
1857
|
-
const v =
|
|
1857
|
+
const v = Fi(a, o, f), C = S.length / 3, z = v.length;
|
|
1858
1858
|
let D = null;
|
|
1859
1859
|
c.attributes.TEXCOORD_0 !== void 0 && (D = ti(a, o, c.attributes.TEXCOORD_0, 2, 5126));
|
|
1860
|
-
let
|
|
1860
|
+
let M = !1;
|
|
1861
1861
|
if (a.materials && a.materials.length > 0) {
|
|
1862
1862
|
const T = a.materials[0];
|
|
1863
|
-
T.pbrMetallicRoughness && T.pbrMetallicRoughness.baseColorTexture !== void 0 && (
|
|
1863
|
+
T.pbrMetallicRoughness && T.pbrMetallicRoughness.baseColorTexture !== void 0 && (M = !0);
|
|
1864
1864
|
}
|
|
1865
1865
|
let Z = null;
|
|
1866
1866
|
if (a.skins && a.skins.length > 0)
|
|
@@ -1877,7 +1877,7 @@ async function or(s) {
|
|
|
1877
1877
|
vertexCount: C,
|
|
1878
1878
|
indexCount: z,
|
|
1879
1879
|
animationData: Z,
|
|
1880
|
-
hasBaseColorTexture:
|
|
1880
|
+
hasBaseColorTexture: M
|
|
1881
1881
|
};
|
|
1882
1882
|
}
|
|
1883
1883
|
function ti(s, t, e, i, r) {
|
|
@@ -1892,11 +1892,11 @@ function ti(s, t, e, i, r) {
|
|
|
1892
1892
|
if (n.componentType !== r)
|
|
1893
1893
|
throw new Error(`Attribute component type mismatch: expected ${r}, got ${n.componentType}`);
|
|
1894
1894
|
const c = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), d = n.count, S = new DataView(t, c, d * i * 4), b = new Float32Array(d * i);
|
|
1895
|
-
for (let
|
|
1896
|
-
b[
|
|
1895
|
+
for (let f = 0; f < d * i; f++)
|
|
1896
|
+
b[f] = S.getFloat32(f * 4, !0);
|
|
1897
1897
|
return b;
|
|
1898
1898
|
}
|
|
1899
|
-
function
|
|
1899
|
+
function Fi(s, t, e) {
|
|
1900
1900
|
const i = s.accessors[e];
|
|
1901
1901
|
if (i.type !== "SCALAR")
|
|
1902
1902
|
throw new Error(`Indices accessor must be SCALAR, got ${i.type}`);
|
|
@@ -1921,8 +1921,8 @@ function lr(s, t) {
|
|
|
1921
1921
|
d[1] * S[2] - d[2] * S[1],
|
|
1922
1922
|
d[2] * S[0] - d[0] * S[2],
|
|
1923
1923
|
d[0] * S[1] - d[1] * S[0]
|
|
1924
|
-
],
|
|
1925
|
-
|
|
1924
|
+
], f = Math.sqrt(b[0] * b[0] + b[1] * b[1] + b[2] * b[2]);
|
|
1925
|
+
f > 0 && (b[0] /= f, b[1] /= f, b[2] /= f), e[r] = e[n] = e[a] = b[0], e[r + 1] = e[n + 1] = e[a + 1] = b[1], e[r + 2] = e[n + 2] = e[a + 2] = b[2];
|
|
1926
1926
|
}
|
|
1927
1927
|
return e;
|
|
1928
1928
|
}
|
|
@@ -2010,11 +2010,11 @@ function hr(s, t, e) {
|
|
|
2010
2010
|
for (const d of s.animations) {
|
|
2011
2011
|
const S = [];
|
|
2012
2012
|
let b = 0;
|
|
2013
|
-
for (const
|
|
2014
|
-
const v = d.samplers[
|
|
2013
|
+
for (const f of d.channels) {
|
|
2014
|
+
const v = d.samplers[f.sampler], C = fr(s, t, v.input), z = pr(s, t, v.output), D = C[C.length - 1];
|
|
2015
2015
|
D > b && (b = D), S.push({
|
|
2016
|
-
targetNode:
|
|
2017
|
-
targetPath:
|
|
2016
|
+
targetNode: f.target.node,
|
|
2017
|
+
targetPath: f.target.path,
|
|
2018
2018
|
interpolation: v.interpolation || "LINEAR",
|
|
2019
2019
|
timestamps: C,
|
|
2020
2020
|
values: z
|
|
@@ -2045,11 +2045,11 @@ async function Vi(s) {
|
|
|
2045
2045
|
const r = t.getUint32(8, !0);
|
|
2046
2046
|
let n = 12, a = null, o = null;
|
|
2047
2047
|
for (; n < r; ) {
|
|
2048
|
-
const Z = t.getUint32(n, !0), T = t.getUint32(n + 4, !0),
|
|
2048
|
+
const Z = t.getUint32(n, !0), T = t.getUint32(n + 4, !0), G = s.slice(n + 8, n + 8 + Z);
|
|
2049
2049
|
if (T === 1313821514) {
|
|
2050
|
-
const H = new TextDecoder("utf-8").decode(
|
|
2050
|
+
const H = new TextDecoder("utf-8").decode(G);
|
|
2051
2051
|
a = JSON.parse(H);
|
|
2052
|
-
} else T === 5130562 && (o =
|
|
2052
|
+
} else T === 5130562 && (o = G);
|
|
2053
2053
|
n += 8 + Z;
|
|
2054
2054
|
}
|
|
2055
2055
|
if (!a)
|
|
@@ -2065,13 +2065,13 @@ async function Vi(s) {
|
|
|
2065
2065
|
const S = a.textures[c].source;
|
|
2066
2066
|
if (S === void 0 || !a.images || !a.images[S])
|
|
2067
2067
|
return null;
|
|
2068
|
-
const b = a.images[S],
|
|
2068
|
+
const b = a.images[S], f = b.mimeType || "image/png";
|
|
2069
2069
|
if (b.bufferView === void 0)
|
|
2070
2070
|
return null;
|
|
2071
2071
|
if (!o)
|
|
2072
2072
|
throw new Error("GLB file missing BIN chunk (required for embedded textures)");
|
|
2073
2073
|
const v = a.bufferViews[b.bufferView], C = v.byteOffset || 0, z = v.byteLength, D = o.slice(C, C + z);
|
|
2074
|
-
return { imageBlob: new Blob([D], { type:
|
|
2074
|
+
return { imageBlob: new Blob([D], { type: f }), mimeType: f };
|
|
2075
2075
|
}
|
|
2076
2076
|
function mr(s, t, e, i) {
|
|
2077
2077
|
return i = i || [0, 0, 0], i[0] = s[0] + (t[0] - s[0]) * e, i[1] = s[1] + (t[1] - s[1]) * e, i[2] = s[2] + (t[2] - s[2]) * e, i;
|
|
@@ -2088,8 +2088,8 @@ function yr(s, t, e, i) {
|
|
|
2088
2088
|
return i[0] = s[0] * l + n * t[0] * c, i[1] = s[1] * l + n * t[1] * c, i[2] = s[2] * l + n * t[2] * c, i[3] = s[3] * l + n * t[3] * c, i;
|
|
2089
2089
|
}
|
|
2090
2090
|
function gr(s, t) {
|
|
2091
|
-
const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i, l = r + r, c = e * a, d = e * o, S = e * l, b = i * o,
|
|
2092
|
-
return
|
|
2091
|
+
const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i, l = r + r, c = e * a, d = e * o, S = e * l, b = i * o, f = i * l, v = r * l, C = n * a, z = n * o, D = n * l, M = t || new Float32Array(16);
|
|
2092
|
+
return M[0] = 1 - (b + v), M[1] = d + D, M[2] = S - z, M[3] = 0, M[4] = d - D, M[5] = 1 - (c + v), M[6] = f + C, M[7] = 0, M[8] = S + z, M[9] = f - C, M[10] = 1 - (c + b), M[11] = 0, M[12] = 0, M[13] = 0, M[14] = 0, M[15] = 1, M;
|
|
2093
2093
|
}
|
|
2094
2094
|
const br = new Float32Array(16);
|
|
2095
2095
|
function Sr(s, t, e, i) {
|
|
@@ -2263,8 +2263,8 @@ class xr {
|
|
|
2263
2263
|
const C = Math.floor((l + c) / 2);
|
|
2264
2264
|
r[C] <= e ? l = C : c = C;
|
|
2265
2265
|
}
|
|
2266
|
-
const d = r[l], S = r[c], b = (e - d) / (S - d),
|
|
2267
|
-
return a === "STEP" ? (i[0] =
|
|
2266
|
+
const d = r[l], S = r[c], b = (e - d) / (S - d), f = this._extractValue(n, l, o, this._sV0), v = this._extractValue(n, c, o, this._sV1);
|
|
2267
|
+
return a === "STEP" ? (i[0] = f[0], i[1] = f[1], i[2] = f[2], o === "rotation" && (i[3] = f[3]), i) : o === "rotation" ? yr(f, v, b, i) : mr(f, v, b, i);
|
|
2268
2268
|
}
|
|
2269
2269
|
/**
|
|
2270
2270
|
* Extract value from values array at the given index.
|
|
@@ -2322,16 +2322,16 @@ class xr {
|
|
|
2322
2322
|
_applySkinning() {
|
|
2323
2323
|
const t = this.restPositions.length / 3, e = this.restPositions, i = this.restNormals, r = this.skinnedPositions, n = this.skinnedNormals, a = this.jointWeights, o = this.jointIndices, l = this.jointFinalMatrices;
|
|
2324
2324
|
for (let c = 0; c < t; c++) {
|
|
2325
|
-
const d = c * 3, S = c * 4, b = e[d],
|
|
2326
|
-
let
|
|
2325
|
+
const d = c * 3, S = c * 4, b = e[d], f = e[d + 1], v = e[d + 2], C = i[d], z = i[d + 1], D = i[d + 2];
|
|
2326
|
+
let M = 0, Z = 0, T = 0, G = 0, F = 0, H = 0;
|
|
2327
2327
|
for (let ne = 0; ne < 4; ne++) {
|
|
2328
2328
|
const re = a[S + ne];
|
|
2329
2329
|
if (re === 0) continue;
|
|
2330
|
-
const
|
|
2331
|
-
|
|
2330
|
+
const q = l[o[S + ne]];
|
|
2331
|
+
M += (q[0] * b + q[4] * f + q[8] * v + q[12]) * re, Z += (q[1] * b + q[5] * f + q[9] * v + q[13]) * re, T += (q[2] * b + q[6] * f + q[10] * v + q[14]) * re, G += (q[0] * C + q[4] * z + q[8] * D) * re, F += (q[1] * C + q[5] * z + q[9] * D) * re, H += (q[2] * C + q[6] * z + q[10] * D) * re;
|
|
2332
2332
|
}
|
|
2333
|
-
const se = Math.sqrt(
|
|
2334
|
-
se > 1e-4 && (n[d] =
|
|
2333
|
+
const se = Math.sqrt(G * G + F * F + H * H);
|
|
2334
|
+
se > 1e-4 && (n[d] = G / se, n[d + 1] = F / se, n[d + 2] = H / se), r[d] = M, r[d + 1] = Z, r[d + 2] = T;
|
|
2335
2335
|
}
|
|
2336
2336
|
}
|
|
2337
2337
|
}
|
|
@@ -2376,13 +2376,13 @@ const Li = {
|
|
|
2376
2376
|
}
|
|
2377
2377
|
};
|
|
2378
2378
|
function Pr(s, t, e, i) {
|
|
2379
|
-
const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, l = 3 * (i - t) - o, c = 1 - o - l, d = (
|
|
2380
|
-
return (
|
|
2381
|
-
if (
|
|
2382
|
-
if (
|
|
2383
|
-
let v =
|
|
2379
|
+
const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, l = 3 * (i - t) - o, c = 1 - o - l, d = (f) => ((a * f + n) * f + r) * f, S = (f) => ((c * f + l) * f + o) * f, b = (f) => (3 * a * f + 2 * n) * f + r;
|
|
2380
|
+
return (f) => {
|
|
2381
|
+
if (f <= 0) return 0;
|
|
2382
|
+
if (f >= 1) return 1;
|
|
2383
|
+
let v = f;
|
|
2384
2384
|
for (let C = 0; C < 8; C++) {
|
|
2385
|
-
const z = d(v) -
|
|
2385
|
+
const z = d(v) - f;
|
|
2386
2386
|
if (Math.abs(z) < 1e-5) break;
|
|
2387
2387
|
const D = b(v);
|
|
2388
2388
|
if (Math.abs(D) < 1e-6) break;
|
|
@@ -2419,10 +2419,10 @@ function Mr(s, t, e) {
|
|
|
2419
2419
|
else {
|
|
2420
2420
|
n = a = r.v, o = 0;
|
|
2421
2421
|
for (let S = 0; S < i - 1; S++) {
|
|
2422
|
-
const b = s[S],
|
|
2423
|
-
if (t >= b.t && t <=
|
|
2424
|
-
const v =
|
|
2425
|
-
n = b.v, a =
|
|
2422
|
+
const b = s[S], f = s[S + 1];
|
|
2423
|
+
if (t >= b.t && t <= f.t) {
|
|
2424
|
+
const v = f.t - b.t;
|
|
2425
|
+
n = b.v, a = f.v, o = $i(b.ease, v > 0 ? (t - b.t) / v : 0);
|
|
2426
2426
|
break;
|
|
2427
2427
|
}
|
|
2428
2428
|
}
|
|
@@ -2465,7 +2465,7 @@ const wr = [
|
|
|
2465
2465
|
"shapeStrokeAmplitude",
|
|
2466
2466
|
"shapeStrokeFrequency",
|
|
2467
2467
|
"shapeStrokeSpeed"
|
|
2468
|
-
],
|
|
2468
|
+
], Br = { square: 0, circle: 1, triangle: 2, diamond: 3, star: 4, hexagon: 5, ring: 6, heart: 7, cross: 8, spark: 9, leaf: 10, capsule: 11, crescent: 12, line: 13, "curved-line": 14 };
|
|
2469
2469
|
function ki(s) {
|
|
2470
2470
|
const t = atob(s), e = new Uint8Array(t.length);
|
|
2471
2471
|
for (let i = 0; i < t.length; i++)
|
|
@@ -2511,7 +2511,7 @@ class ii {
|
|
|
2511
2511
|
enabled: !0,
|
|
2512
2512
|
strength: e.softBoundaryStrength,
|
|
2513
2513
|
falloff: e.softBoundaryFalloff
|
|
2514
|
-
}), this.particleTexture = this.textureManager.getDefaultTexture(), this.updateBloomIntensity(), this.updateAppearanceUniform(), this.frameCount = 0, this.shouldReset = !1, this._scriptParticleData = new Float32Array(this.MAX_PARTICLES * 8), this._scriptVelocityData = new Float32Array(this.MAX_PARTICLES * 4), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, this._particleScript = null, e.script && (this._particleScript = new
|
|
2514
|
+
}), this.particleTexture = this.textureManager.getDefaultTexture(), this.updateBloomIntensity(), this.updateAppearanceUniform(), this.frameCount = 0, this.shouldReset = !1, this._scriptParticleData = new Float32Array(this.MAX_PARTICLES * 8), this._scriptVelocityData = new Float32Array(this.MAX_PARTICLES * 4), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, this._particleScript = null, e.script && (this._particleScript = new Gi(e.script, e, this.MAX_PARTICLES)), this.initComputePipeline(t);
|
|
2515
2515
|
}
|
|
2516
2516
|
async initComputePipeline(t) {
|
|
2517
2517
|
this.computeReady = await this.physics.initComputePipeline(this.instanceBuffer, this.velocityBuffer, this.trailBuffer);
|
|
@@ -2521,7 +2521,7 @@ class ii {
|
|
|
2521
2521
|
* @param {string|null} source - Script source code, or null to disable
|
|
2522
2522
|
*/
|
|
2523
2523
|
setScript(t) {
|
|
2524
|
-
this._particleScript && (this._particleScript.destroy(), this._particleScript = null), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, t ? (this.config.script = t, this._particleScript = new
|
|
2524
|
+
this._particleScript && (this._particleScript.destroy(), this._particleScript = null), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, t ? (this.config.script = t, this._particleScript = new Gi(t, this.config, this.MAX_PARTICLES), this._particleScript.snapshotConfig(this.config)) : delete this.config.script;
|
|
2525
2525
|
}
|
|
2526
2526
|
async setTexture(t) {
|
|
2527
2527
|
this.destroyed || (this.textureManager.destroyTexture(this.particleTexture), this.particleTexture = await this.textureManager.loadTexture(t), this.config.textureEnabled = !0, this.updateAppearanceUniform(), this.updateBuffers());
|
|
@@ -2610,7 +2610,7 @@ class ii {
|
|
|
2610
2610
|
if (this.destroyed) return;
|
|
2611
2611
|
let t = 0;
|
|
2612
2612
|
this.config.rotationMode === "random" ? t = 1 : this.config.rotationMode === "velocity" ? t = 2 : this.config.rotationMode === "oriented" ? t = 3 : this.config.rotationMode === "cylindrical" && (t = 4);
|
|
2613
|
-
const e =
|
|
2613
|
+
const e = Br[this.config.particleShape] ?? 0, i = this._appearanceData;
|
|
2614
2614
|
i[0] = this.config.fadeEnabled ? 1 : 0, i[1] = this.config.randomColorEnabled ? 2 : this.config.colorTransitionEnabled ? 1 : 0, i[2] = this.config.particleSize, i[3] = this.config.textureEnabled ? 1 : 0, i[4] = this.config.particleColor[0], i[5] = this.config.particleColor[1], i[6] = this.config.particleColor[2], i[7] = this.config.rotation || 0, i[8] = this.config.startColor[0], i[9] = this.config.startColor[1], i[10] = this.config.startColor[2], i[11] = t, i[12] = this.config.endColor[0], i[13] = this.config.endColor[1], i[14] = this.config.endColor[2], i[15] = this.config.minRotation || 0, i[16] = this.config.maxRotation || 90, i[17] = this.config.aspectRatio || 1, i[18] = this.config.randomSize ? 1 : 0, i[19] = this.config.minSize || 0.1, i[20] = this.config.maxSize || 0.5, i[21] = this.config.fadeSizeEnabled ? 1 : 0, i[22] = this.config.opacity !== void 0 ? this.config.opacity : 1, i[23] = this.config.increaseSizeEnabled ? 1 : 0, i[24] = this.config.sizeLifetimeSpeed ?? 1, i[25] = e, i[26] = 0, i[27] = this.config.pulseEnabled ? 1 : 0, i[28] = this.config.pulseAmplitude ?? 0.5, i[29] = this.config.pulseFrequency ?? 1, i[30] = this.config.pulsePhaseRandom ?? 0, i[31] = this.config.pulseOpacity ? 1 : 0, i[32] = this.config.particleShapeRotationX || 0, i[33] = this.config.particleShapeRotationY || 0, i[34] = this.config.particleShapeRotationZ || 0, i[35] = 0;
|
|
2615
2615
|
const r = this.config.followSystemTranslation ?? !0;
|
|
2616
2616
|
i[36] = r ? this._simPosition[0] : 0, i[37] = r ? this._simPosition[1] : 0, i[38] = r ? this._simPosition[2] : 0, i[39] = 0, i[40] = this._simRotX, i[41] = this._simRotZ, i[42] = this.config.velocityStretchEnabled ? 1 : 0, i[43] = this.config.velocityStretchFactor ?? 1, i[44] = this.config.noiseDistortEnabled ? 1 : 0, i[45] = this.config.noiseTilingX ?? 3, i[46] = this.config.noiseTilingY ?? 3, i[47] = this.config.noiseSpeed ?? -1.5, i[48] = this.config.noiseAmplitude ?? 0.08, i[49] = r ? this._simVelocity[0] : 0, i[50] = r ? this._simVelocity[1] : 0, i[51] = r ? this._simVelocity[2] : 0, i[52] = this.config.orientX ?? 0, i[53] = this.config.orientY ?? 0, i[54] = this.config.orientZ ?? 0, i[55] = 0, this.device.queue.writeBuffer(this.appearanceUniformBuffer, 0, i);
|
|
@@ -2709,7 +2709,7 @@ class ii {
|
|
|
2709
2709
|
if (d > 0 && this._scriptTime >= d && !this._scriptConfigRestored)
|
|
2710
2710
|
this._scriptConfigRestored = !0, this._particleScript._configSnapshot && (this._particleScript.restoreConfig(this.config), this.updateAppearanceUniform(), this.updateBloomIntensity(), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition, this.config.attractorReverse));
|
|
2711
2711
|
else if (!this._scriptConfigRestored) {
|
|
2712
|
-
const S = d > 0 ? Math.ceil(d / 0.016666666666666666) : 0, { configDirty: b, particlesDirty:
|
|
2712
|
+
const S = d > 0 ? Math.ceil(d / 0.016666666666666666) : 0, { configDirty: b, particlesDirty: f } = this._particleScript.execute(
|
|
2713
2713
|
t,
|
|
2714
2714
|
this._scriptTime,
|
|
2715
2715
|
this._scriptFrame,
|
|
@@ -2718,7 +2718,7 @@ class ii {
|
|
|
2718
2718
|
this._scriptVelocityData,
|
|
2719
2719
|
this.activeParticles
|
|
2720
2720
|
);
|
|
2721
|
-
|
|
2721
|
+
f && this.activeParticles > 0 && (this.device.queue.writeBuffer(
|
|
2722
2722
|
this.instanceBuffer,
|
|
2723
2723
|
0,
|
|
2724
2724
|
this._scriptParticleData,
|
|
@@ -2742,8 +2742,8 @@ class ii {
|
|
|
2742
2742
|
if (this.config.followSystemId) {
|
|
2743
2743
|
if (this._pendingFollowEmissions.length > 0) {
|
|
2744
2744
|
const b = this._pendingFollowEmissions.length / 6;
|
|
2745
|
-
for (let
|
|
2746
|
-
const v =
|
|
2745
|
+
for (let f = 0; f < b; f++) {
|
|
2746
|
+
const v = f * 6;
|
|
2747
2747
|
if (this.emitFollowerParticle(
|
|
2748
2748
|
this._pendingFollowEmissions[v],
|
|
2749
2749
|
this._pendingFollowEmissions[v + 1],
|
|
@@ -2756,8 +2756,8 @@ class ii {
|
|
|
2756
2756
|
}
|
|
2757
2757
|
} else {
|
|
2758
2758
|
let b = 0;
|
|
2759
|
-
const
|
|
2760
|
-
this.activeParticles < this.particleCount &&
|
|
2759
|
+
const f = Math.max(0, this.config.emissionRate || 0);
|
|
2760
|
+
this.activeParticles < this.particleCount && f > 0 ? (this.emissionAccumulator += f * t, b = Math.floor(this.emissionAccumulator + 1e-9), b > 0 && (this.emissionAccumulator -= b)) : this.activeParticles >= this.particleCount && (this.emissionAccumulator = 0);
|
|
2761
2761
|
for (let v = 0; v < b; v++)
|
|
2762
2762
|
if (this.emitParticle())
|
|
2763
2763
|
S = !0;
|
|
@@ -2767,13 +2767,13 @@ class ii {
|
|
|
2767
2767
|
}
|
|
2768
2768
|
}
|
|
2769
2769
|
if (S) {
|
|
2770
|
-
const b = this.activeParticles - d,
|
|
2770
|
+
const b = this.activeParticles - d, f = d * 8, v = d * 4;
|
|
2771
2771
|
this.device.queue.writeBuffer(
|
|
2772
2772
|
this.instanceBuffer,
|
|
2773
|
-
|
|
2773
|
+
f * 4,
|
|
2774
2774
|
// Offset in bytes (float32 = 4 bytes)
|
|
2775
2775
|
this.particleData,
|
|
2776
|
-
|
|
2776
|
+
f,
|
|
2777
2777
|
b * 8
|
|
2778
2778
|
), this.device.queue.writeBuffer(
|
|
2779
2779
|
this.velocityBuffer,
|
|
@@ -2815,15 +2815,16 @@ class ii {
|
|
|
2815
2815
|
}));
|
|
2816
2816
|
}
|
|
2817
2817
|
async readbackAndProcessParticles() {
|
|
2818
|
-
if (!(this.activeParticles <= 0))
|
|
2818
|
+
if (!(this.destroyed || this.activeParticles <= 0))
|
|
2819
2819
|
try {
|
|
2820
|
-
|
|
2820
|
+
const t = await this.physics.readbackAndProcessParticles(
|
|
2821
2821
|
this.activeParticles,
|
|
2822
2822
|
this.particleData,
|
|
2823
2823
|
this.particleVelocities,
|
|
2824
2824
|
this.instanceBuffer,
|
|
2825
2825
|
this.velocityBuffer
|
|
2826
|
-
)
|
|
2826
|
+
);
|
|
2827
|
+
if (this.destroyed || !this.particleData || !this.particleVelocities || !t.shouldUpdate) return;
|
|
2827
2828
|
let e = 0, i = !1;
|
|
2828
2829
|
for (let r = 0; r < this.activeParticles; r++) {
|
|
2829
2830
|
const n = this.particleData[r * 8 + 6], a = this.particleData[r * 8 + 7];
|
|
@@ -2922,7 +2923,7 @@ class ii {
|
|
|
2922
2923
|
this.physics.setSoftBoundary(t);
|
|
2923
2924
|
}
|
|
2924
2925
|
}
|
|
2925
|
-
class
|
|
2926
|
+
class Rr {
|
|
2926
2927
|
constructor(t) {
|
|
2927
2928
|
this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new vr({ loop: !!this.loop }), this.ready = !0;
|
|
2928
2929
|
}
|
|
@@ -3667,7 +3668,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
3667
3668
|
bindGroupLayouts: [o]
|
|
3668
3669
|
}), b = s.createPipelineLayout({
|
|
3669
3670
|
bindGroupLayouts: [l]
|
|
3670
|
-
}),
|
|
3671
|
+
}), f = s.createShaderModule({
|
|
3671
3672
|
code: Hs
|
|
3672
3673
|
}), v = s.createShaderModule({
|
|
3673
3674
|
code: Zs
|
|
@@ -3677,12 +3678,12 @@ function Ur(s, t, e, i = {}) {
|
|
|
3677
3678
|
code: $s
|
|
3678
3679
|
}), D = s.createShaderModule({
|
|
3679
3680
|
code: Er
|
|
3680
|
-
}),
|
|
3681
|
+
}), M = s.createShaderModule({
|
|
3681
3682
|
code: Ar
|
|
3682
3683
|
}), Z = (kt) => s.createRenderPipeline({
|
|
3683
3684
|
layout: d,
|
|
3684
3685
|
vertex: {
|
|
3685
|
-
module:
|
|
3686
|
+
module: f,
|
|
3686
3687
|
entryPoint: "vs_main",
|
|
3687
3688
|
buffers: [
|
|
3688
3689
|
{
|
|
@@ -3743,7 +3744,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
3743
3744
|
]
|
|
3744
3745
|
},
|
|
3745
3746
|
fragment: {
|
|
3746
|
-
module:
|
|
3747
|
+
module: f,
|
|
3747
3748
|
entryPoint: "fs_main",
|
|
3748
3749
|
targets: [{
|
|
3749
3750
|
format: Xe,
|
|
@@ -3770,7 +3771,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
3770
3771
|
dstFactor: "one-minus-src-alpha",
|
|
3771
3772
|
operation: "add"
|
|
3772
3773
|
}
|
|
3773
|
-
}),
|
|
3774
|
+
}), G = Z({
|
|
3774
3775
|
color: {
|
|
3775
3776
|
srcFactor: "src-alpha",
|
|
3776
3777
|
dstFactor: "one",
|
|
@@ -3781,10 +3782,10 @@ function Ur(s, t, e, i = {}) {
|
|
|
3781
3782
|
dstFactor: "one-minus-src-alpha",
|
|
3782
3783
|
operation: "add"
|
|
3783
3784
|
}
|
|
3784
|
-
}),
|
|
3785
|
+
}), F = s.createRenderPipeline({
|
|
3785
3786
|
layout: d,
|
|
3786
3787
|
vertex: {
|
|
3787
|
-
module:
|
|
3788
|
+
module: f,
|
|
3788
3789
|
entryPoint: "vs_main",
|
|
3789
3790
|
buffers: [
|
|
3790
3791
|
{
|
|
@@ -3845,7 +3846,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
3845
3846
|
]
|
|
3846
3847
|
},
|
|
3847
3848
|
fragment: {
|
|
3848
|
-
module:
|
|
3849
|
+
module: f,
|
|
3849
3850
|
entryPoint: "fs_main",
|
|
3850
3851
|
targets: [{
|
|
3851
3852
|
format: Xe,
|
|
@@ -3935,7 +3936,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
3935
3936
|
primitive: {
|
|
3936
3937
|
topology: "triangle-list"
|
|
3937
3938
|
}
|
|
3938
|
-
}), re = s.createShaderModule({ code: Js }),
|
|
3939
|
+
}), re = s.createShaderModule({ code: Js }), q = s.createRenderPipeline({
|
|
3939
3940
|
layout: b,
|
|
3940
3941
|
vertex: { module: re, entryPoint: "vs_main" },
|
|
3941
3942
|
fragment: {
|
|
@@ -4010,7 +4011,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
4010
4011
|
}), at = s.createRenderPipeline({
|
|
4011
4012
|
layout: d,
|
|
4012
4013
|
vertex: {
|
|
4013
|
-
module:
|
|
4014
|
+
module: M,
|
|
4014
4015
|
entryPoint: "vs_main",
|
|
4015
4016
|
buffers: [
|
|
4016
4017
|
{
|
|
@@ -4082,7 +4083,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
4082
4083
|
]
|
|
4083
4084
|
},
|
|
4084
4085
|
fragment: {
|
|
4085
|
-
module:
|
|
4086
|
+
module: M,
|
|
4086
4087
|
entryPoint: "fs_main",
|
|
4087
4088
|
targets: [{
|
|
4088
4089
|
format: Xe,
|
|
@@ -4112,12 +4113,12 @@ function Ur(s, t, e, i = {}) {
|
|
|
4112
4113
|
});
|
|
4113
4114
|
return {
|
|
4114
4115
|
particlePipeline: T,
|
|
4115
|
-
particleAdditivePipeline:
|
|
4116
|
-
particleDepthWritePipeline:
|
|
4116
|
+
particleAdditivePipeline: G,
|
|
4117
|
+
particleDepthWritePipeline: F,
|
|
4117
4118
|
blurPipeline: H,
|
|
4118
4119
|
compositePipeline: se,
|
|
4119
4120
|
directRenderPipeline: ne,
|
|
4120
|
-
finalCompositePipeline:
|
|
4121
|
+
finalCompositePipeline: q,
|
|
4121
4122
|
object3dPipeline: xt,
|
|
4122
4123
|
glbMeshPipeline: at
|
|
4123
4124
|
};
|
|
@@ -4158,7 +4159,7 @@ function si(s, t, e, i) {
|
|
|
4158
4159
|
resource: { buffer: n }
|
|
4159
4160
|
}
|
|
4160
4161
|
]
|
|
4161
|
-
}),
|
|
4162
|
+
}), f = s.createBindGroup({
|
|
4162
4163
|
layout: s.createBindGroupLayout({
|
|
4163
4164
|
entries: [
|
|
4164
4165
|
{
|
|
@@ -4315,7 +4316,7 @@ function si(s, t, e, i) {
|
|
|
4315
4316
|
});
|
|
4316
4317
|
return {
|
|
4317
4318
|
particleBindGroup: b,
|
|
4318
|
-
horizontalBlurBindGroup:
|
|
4319
|
+
horizontalBlurBindGroup: f,
|
|
4319
4320
|
verticalBlurBindGroup: v,
|
|
4320
4321
|
compositeBindGroup: C,
|
|
4321
4322
|
directRenderBindGroup: z
|
|
@@ -4534,8 +4535,8 @@ function Dr(s = 16, t = 16) {
|
|
|
4534
4535
|
for (let r = 0; r <= s; r++) {
|
|
4535
4536
|
const n = r * Math.PI / s, a = Math.sin(n), o = Math.cos(n);
|
|
4536
4537
|
for (let l = 0; l <= t; l++) {
|
|
4537
|
-
const c = l * 2 * Math.PI / t, d = Math.sin(c), b = Math.cos(c) * a,
|
|
4538
|
-
e.push(b * 0.5,
|
|
4538
|
+
const c = l * 2 * Math.PI / t, d = Math.sin(c), b = Math.cos(c) * a, f = o, v = d * a;
|
|
4539
|
+
e.push(b * 0.5, f * 0.5, v * 0.5), e.push(b, f, v);
|
|
4539
4540
|
}
|
|
4540
4541
|
}
|
|
4541
4542
|
for (let r = 0; r < s; r++)
|
|
@@ -4548,7 +4549,7 @@ function Dr(s = 16, t = 16) {
|
|
|
4548
4549
|
indices: new Uint16Array(i)
|
|
4549
4550
|
};
|
|
4550
4551
|
}
|
|
4551
|
-
class
|
|
4552
|
+
class Gr {
|
|
4552
4553
|
constructor(t, e, i, r, n) {
|
|
4553
4554
|
this.id = t, this.type = e, this.position = i, this.scale = r, this.color = n, this.rotation = [0, 0, 0];
|
|
4554
4555
|
}
|
|
@@ -4718,7 +4719,7 @@ class Nr {
|
|
|
4718
4719
|
* @returns {Object3D} The created object
|
|
4719
4720
|
*/
|
|
4720
4721
|
addObject(t, e = [0, 0, 0], i = [1, 1, 1], r = [1, 1, 1, 1]) {
|
|
4721
|
-
const n = new
|
|
4722
|
+
const n = new Gr(this.nextId++, t, e, i, r);
|
|
4722
4723
|
return n.uniformBuffer = this.device.createBuffer({
|
|
4723
4724
|
size: 192,
|
|
4724
4725
|
// modelMatrix (64) + normalMatrix (64) + color (16) + padding (48)
|
|
@@ -4876,7 +4877,7 @@ function qi(s, t) {
|
|
|
4876
4877
|
function ri(s, t) {
|
|
4877
4878
|
return s[0] * t[0] + s[1] * t[1] + s[2] * t[2];
|
|
4878
4879
|
}
|
|
4879
|
-
function
|
|
4880
|
+
function Fr(s, t) {
|
|
4880
4881
|
const e = new Float32Array(16);
|
|
4881
4882
|
for (let i = 0; i < 4; i++)
|
|
4882
4883
|
for (let r = 0; r < 4; r++) {
|
|
@@ -4905,41 +4906,41 @@ function Zi(s) {
|
|
|
4905
4906
|
async function Or(s, t = {}) {
|
|
4906
4907
|
const { textureFormat: e = "keep", quality: i = 0.85 } = t, r = [], n = [];
|
|
4907
4908
|
let a = 0;
|
|
4908
|
-
const o = (
|
|
4909
|
-
const se = a, ne =
|
|
4910
|
-
r.push({ offset: se, length: ne, mime:
|
|
4909
|
+
const o = (G, F, H) => {
|
|
4910
|
+
const se = a, ne = G.length;
|
|
4911
|
+
r.push({ offset: se, length: ne, mime: F, kind: H }), n.push(G), a += ne;
|
|
4911
4912
|
const re = Zi(ne);
|
|
4912
4913
|
return re && (n.push(new Uint8Array(re)), a += re), r.length - 1;
|
|
4913
4914
|
}, l = e === "webp" && typeof OffscreenCanvas < "u" && typeof createImageBitmap == "function", c = [];
|
|
4914
|
-
for (const
|
|
4915
|
-
const
|
|
4916
|
-
if (typeof
|
|
4917
|
-
let { mime: H, bytes: se } = Vr(
|
|
4915
|
+
for (const G of s.systems || []) {
|
|
4916
|
+
const F = { ...G };
|
|
4917
|
+
if (typeof F.textureImageData == "string" && F.textureImageData.startsWith("data:")) {
|
|
4918
|
+
let { mime: H, bytes: se } = Vr(F.textureImageData);
|
|
4918
4919
|
if (l && H !== "image/webp")
|
|
4919
4920
|
try {
|
|
4920
4921
|
const ne = await createImageBitmap(new Blob([se], { type: H })), re = new OffscreenCanvas(ne.width, ne.height);
|
|
4921
4922
|
re.getContext("2d").drawImage(ne, 0, 0);
|
|
4922
|
-
const
|
|
4923
|
+
const q = await re.convertToBlob({ type: "image/webp", quality: i }), tt = new Uint8Array(await q.arrayBuffer());
|
|
4923
4924
|
tt.length < se.length && (se = tt, H = "image/webp");
|
|
4924
4925
|
} catch {
|
|
4925
4926
|
}
|
|
4926
|
-
|
|
4927
|
+
F.textureImageData = { [At]: o(se, H, "texture") };
|
|
4927
4928
|
}
|
|
4928
|
-
if (typeof
|
|
4929
|
-
const H = ts(
|
|
4930
|
-
|
|
4929
|
+
if (typeof F.glbModelData == "string" && F.glbModelData.length > 0) {
|
|
4930
|
+
const H = ts(F.glbModelData);
|
|
4931
|
+
F.glbModelData = { [At]: o(H, "model/gltf-binary", "glb") };
|
|
4931
4932
|
}
|
|
4932
|
-
c.push(
|
|
4933
|
+
c.push(F);
|
|
4933
4934
|
}
|
|
4934
|
-
const d = { ...s, systems: c, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)), b = Zi(S.length),
|
|
4935
|
+
const d = { ...s, systems: c, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)), b = Zi(S.length), f = new Uint8Array(a);
|
|
4935
4936
|
let v = 0;
|
|
4936
|
-
for (const
|
|
4937
|
-
|
|
4938
|
-
const C = S.length + b, z = 20 + C + 8 + a, D = new ArrayBuffer(z),
|
|
4937
|
+
for (const G of n)
|
|
4938
|
+
f.set(G, v), v += G.length;
|
|
4939
|
+
const C = S.length + b, z = 20 + C + 8 + a, D = new ArrayBuffer(z), M = new DataView(D), Z = new Uint8Array(D);
|
|
4939
4940
|
let T = 0;
|
|
4940
|
-
|
|
4941
|
-
for (let
|
|
4942
|
-
return
|
|
4941
|
+
M.setUint32(T, ai, !0), T += 4, M.setUint32(T, Ki, !0), T += 4, M.setUint32(T, z, !0), T += 4, M.setUint32(T, C, !0), T += 4, M.setUint32(T, Qi, !0), T += 4, Z.set(S, T), T += S.length;
|
|
4942
|
+
for (let G = 0; G < b; G++) Z[T++] = 32;
|
|
4943
|
+
return M.setUint32(T, a, !0), T += 4, M.setUint32(T, es, !0), T += 4, Z.set(f, T), T += a, D;
|
|
4943
4944
|
}
|
|
4944
4945
|
function is(s) {
|
|
4945
4946
|
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === ai;
|
|
@@ -4954,24 +4955,24 @@ function ss(s) {
|
|
|
4954
4955
|
for (; i + 8 <= s.byteLength; ) {
|
|
4955
4956
|
const b = t.getUint32(i, !0);
|
|
4956
4957
|
i += 4;
|
|
4957
|
-
const
|
|
4958
|
-
i += 4,
|
|
4958
|
+
const f = t.getUint32(i, !0);
|
|
4959
|
+
i += 4, f === Qi ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + b))) : f === es && (n = i), i += b;
|
|
4959
4960
|
}
|
|
4960
4961
|
if (!r) throw new Error("[unpackHZFX] missing JSON chunk");
|
|
4961
4962
|
const o = r.assets || [], l = (b) => {
|
|
4962
|
-
const
|
|
4963
|
-
return !
|
|
4963
|
+
const f = o[b];
|
|
4964
|
+
return !f || n < 0 ? null : { ...f, bytes: a.subarray(n + f.offset, n + f.offset + f.length) };
|
|
4964
4965
|
}, c = (b) => b && typeof b == "object" && typeof b[At] == "number", d = (r.systems || []).map((b) => {
|
|
4965
|
-
const
|
|
4966
|
-
if (c(
|
|
4967
|
-
const v = l(
|
|
4968
|
-
|
|
4966
|
+
const f = { ...b };
|
|
4967
|
+
if (c(f.textureImageData)) {
|
|
4968
|
+
const v = l(f.textureImageData[At]);
|
|
4969
|
+
f.textureImageData = v ? `data:${v.mime};base64,${Hi(v.bytes)}` : void 0;
|
|
4969
4970
|
}
|
|
4970
|
-
if (c(
|
|
4971
|
-
const v = l(
|
|
4972
|
-
|
|
4971
|
+
if (c(f.glbModelData)) {
|
|
4972
|
+
const v = l(f.glbModelData[At]);
|
|
4973
|
+
f.glbModelData = v ? Hi(v.bytes) : void 0;
|
|
4973
4974
|
}
|
|
4974
|
-
return
|
|
4975
|
+
return f;
|
|
4975
4976
|
}), S = { ...r, systems: d };
|
|
4976
4977
|
return delete S.assets, S;
|
|
4977
4978
|
}
|
|
@@ -5269,48 +5270,48 @@ async function Jr(s, t = {}) {
|
|
|
5269
5270
|
let r, n, a;
|
|
5270
5271
|
const o = !!(s && s.device && s.context);
|
|
5271
5272
|
o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await Tr(a));
|
|
5272
|
-
const l = navigator.gpu.getPreferredCanvasFormat(), c = t.manager || new
|
|
5273
|
+
const l = navigator.gpu.getPreferredCanvasFormat(), c = t.manager || new Rr(r), d = { layouts: {}, pipelines: {} };
|
|
5273
5274
|
function S(u) {
|
|
5274
|
-
const
|
|
5275
|
-
if (!d.pipelines[
|
|
5276
|
-
const y = r.createShaderModule({ code: Xr(u) }),
|
|
5275
|
+
const p = u ? "ms" : "ss";
|
|
5276
|
+
if (!d.pipelines[p]) {
|
|
5277
|
+
const y = r.createShaderModule({ code: Xr(u) }), h = r.createBindGroupLayout({
|
|
5277
5278
|
entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: u } }]
|
|
5278
5279
|
});
|
|
5279
|
-
d.layouts[
|
|
5280
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5280
|
+
d.layouts[p] = h, d.pipelines[p] = r.createRenderPipeline({
|
|
5281
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [h] }),
|
|
5281
5282
|
vertex: { module: y, entryPoint: "vs" },
|
|
5282
5283
|
fragment: { module: y, entryPoint: "fs", targets: [] },
|
|
5283
5284
|
primitive: { topology: "triangle-list" },
|
|
5284
5285
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !0, depthCompare: "always" }
|
|
5285
5286
|
});
|
|
5286
5287
|
}
|
|
5287
|
-
return { pipeline: d.pipelines[
|
|
5288
|
+
return { pipeline: d.pipelines[p], layout: d.layouts[p] };
|
|
5288
5289
|
}
|
|
5289
5290
|
const b = {
|
|
5290
5291
|
bloomSourceTextures: {},
|
|
5291
5292
|
bloomCompositeTextures: {},
|
|
5292
5293
|
combinedTexture: null,
|
|
5293
|
-
getBloomSourceTexture(u,
|
|
5294
|
-
const
|
|
5295
|
-
return this.bloomSourceTextures[
|
|
5296
|
-
size: [
|
|
5294
|
+
getBloomSourceTexture(u, p, y) {
|
|
5295
|
+
const h = u;
|
|
5296
|
+
return this.bloomSourceTextures[h] || (this.bloomSourceTextures[h] = r.createTexture({
|
|
5297
|
+
size: [p, y],
|
|
5297
5298
|
format: "rgba16float",
|
|
5298
5299
|
// HDR chain (see webgpu.js HDR_FORMAT) — avoids additive clip
|
|
5299
5300
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5300
|
-
})), this.bloomSourceTextures[
|
|
5301
|
+
})), this.bloomSourceTextures[h];
|
|
5301
5302
|
},
|
|
5302
|
-
getBloomCompositeTexture(u,
|
|
5303
|
-
const
|
|
5304
|
-
return this.bloomCompositeTextures[
|
|
5305
|
-
size: [
|
|
5303
|
+
getBloomCompositeTexture(u, p, y) {
|
|
5304
|
+
const h = u;
|
|
5305
|
+
return this.bloomCompositeTextures[h] || (this.bloomCompositeTextures[h] = r.createTexture({
|
|
5306
|
+
size: [p, y],
|
|
5306
5307
|
format: "rgba16float",
|
|
5307
5308
|
// HDR chain
|
|
5308
5309
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5309
|
-
})), this.bloomCompositeTextures[
|
|
5310
|
+
})), this.bloomCompositeTextures[h];
|
|
5310
5311
|
},
|
|
5311
|
-
getCombinedTexture(u,
|
|
5312
|
+
getCombinedTexture(u, p) {
|
|
5312
5313
|
return this.combinedTexture || (this.combinedTexture = r.createTexture({
|
|
5313
|
-
size: [u,
|
|
5314
|
+
size: [u, p],
|
|
5314
5315
|
format: "rgba16float",
|
|
5315
5316
|
// HDR chain — tonemapped to canvas in the final pass
|
|
5316
5317
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
@@ -5319,7 +5320,7 @@ async function Jr(s, t = {}) {
|
|
|
5319
5320
|
resizeTextures() {
|
|
5320
5321
|
Object.values(this.bloomSourceTextures).forEach((u) => u == null ? void 0 : u.destroy()), Object.values(this.bloomCompositeTextures).forEach((u) => u == null ? void 0 : u.destroy()), this.combinedTexture && this.combinedTexture.destroy(), this.bloomSourceTextures = {}, this.bloomCompositeTextures = {}, this.combinedTexture = null;
|
|
5321
5322
|
}
|
|
5322
|
-
},
|
|
5323
|
+
}, f = {
|
|
5323
5324
|
systemBindGroups: {},
|
|
5324
5325
|
systemBloomHorizontalBindGroups: {},
|
|
5325
5326
|
secondHorizontalBindGroups: {},
|
|
@@ -5335,224 +5336,224 @@ async function Jr(s, t = {}) {
|
|
|
5335
5336
|
clear() {
|
|
5336
5337
|
this.systemBindGroups = {}, this.systemBloomHorizontalBindGroups = {}, this.secondHorizontalBindGroups = {}, this.systemBloomCompositeBindGroups = {}, this.combinedBloomCompositeBindGroups = {}, this.combinedInitialBindGroup = null, this.finalBindGroup = null, this.textureStates = {}, this.textureRefs = {};
|
|
5337
5338
|
}
|
|
5338
|
-
}, v = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), C = r.createBuffer({ size: 208, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), z = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), D = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }),
|
|
5339
|
+
}, v = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), C = r.createBuffer({ size: 208, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), z = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), D = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), M = r.createBuffer({ size: 64, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), Z = St(r, new Uint16Array([0, 1, 2, 0, 2, 3]), GPUBufferUsage.INDEX), T = {}, G = () => St(r, new Float32Array([-0.5, -0.5, 0, 0.5, -0.5, 0, 0.5, 0.5, 0, -0.5, 0.5, 0]), GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST);
|
|
5339
5340
|
c.onSystemCreated = (u) => {
|
|
5340
|
-
T[u] || (T[u] =
|
|
5341
|
+
T[u] || (T[u] = G());
|
|
5341
5342
|
};
|
|
5342
|
-
const
|
|
5343
|
+
const F = 4e4, H = new Float32Array(F * 8), se = new Float32Array(F * 4), ne = new Float32Array(F * 4), re = r.createBuffer({ size: F * 8 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), q = r.createBuffer({ size: F * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), tt = r.createBuffer({ size: F * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), xt = /* @__PURE__ */ new Map(), at = /* @__PURE__ */ new Map(), kt = 8, _e = [];
|
|
5343
5344
|
function oi(u) {
|
|
5344
|
-
for (const
|
|
5345
|
+
for (const p of _e) if (p.ids.has(u)) return p;
|
|
5345
5346
|
return null;
|
|
5346
5347
|
}
|
|
5347
|
-
function rs(u,
|
|
5348
|
+
function rs(u, p) {
|
|
5348
5349
|
if (!u.pos) return;
|
|
5349
|
-
u.hist.push({ t:
|
|
5350
|
-
const y =
|
|
5350
|
+
u.hist.push({ t: p, x: u.pos[0], y: u.pos[1], z: u.pos[2] });
|
|
5351
|
+
const y = p - kt;
|
|
5351
5352
|
for (; u.hist.length > 2 && u.hist[0].t < y; ) u.hist.shift();
|
|
5352
5353
|
}
|
|
5353
|
-
function li(u,
|
|
5354
|
-
const
|
|
5355
|
-
if (
|
|
5356
|
-
const
|
|
5357
|
-
return
|
|
5354
|
+
function li(u, p, y) {
|
|
5355
|
+
const h = u.hist;
|
|
5356
|
+
if (h.length === 0) {
|
|
5357
|
+
const P = u.pos;
|
|
5358
|
+
return P && (y[0] = P[0], y[1] = P[1], y[2] = P[2]), y;
|
|
5358
5359
|
}
|
|
5359
5360
|
let g;
|
|
5360
|
-
if (
|
|
5361
|
-
return g =
|
|
5362
|
-
if (
|
|
5363
|
-
return g =
|
|
5364
|
-
for (let
|
|
5365
|
-
if (
|
|
5366
|
-
const
|
|
5367
|
-
return y[0] =
|
|
5361
|
+
if (p >= h[h.length - 1].t)
|
|
5362
|
+
return g = h[h.length - 1], y[0] = g.x, y[1] = g.y, y[2] = g.z, y;
|
|
5363
|
+
if (p <= h[0].t)
|
|
5364
|
+
return g = h[0], y[0] = g.x, y[1] = g.y, y[2] = g.z, y;
|
|
5365
|
+
for (let P = h.length - 1; P > 0; P--)
|
|
5366
|
+
if (h[P - 1].t <= p) {
|
|
5367
|
+
const _ = h[P - 1], B = h[P], x = (p - _.t) / Math.max(1e-6, B.t - _.t);
|
|
5368
|
+
return y[0] = _.x + (B.x - _.x) * x, y[1] = _.y + (B.y - _.y) * x, y[2] = _.z + (B.z - _.z) * x, y;
|
|
5368
5369
|
}
|
|
5369
|
-
return g =
|
|
5370
|
+
return g = h[0], y[0] = g.x, y[1] = g.y, y[2] = g.z, y;
|
|
5370
5371
|
}
|
|
5371
5372
|
const pt = Math.PI * 2, ae = new Array(257), oe = new Array(257), le = new Array(257), Xt = new Array(257), Nt = new Array(257), Yt = new Array(257);
|
|
5372
5373
|
new Array(257), new Array(257), new Array(257);
|
|
5373
5374
|
const Ae = [0, 0, 0];
|
|
5374
5375
|
function ns(u) {
|
|
5375
|
-
const
|
|
5376
|
-
if (!
|
|
5377
|
-
const g =
|
|
5376
|
+
const p = u.emissionRotationX || 0, y = u.emissionRotationY || 0, h = u.emissionRotationZ || 0;
|
|
5377
|
+
if (!p && !y && !h) return null;
|
|
5378
|
+
const g = p * Math.PI / 180, P = y * Math.PI / 180, _ = h * Math.PI / 180, B = Math.cos(g), x = Math.sin(g), R = Math.cos(P), m = Math.sin(P), w = Math.cos(_), E = Math.sin(_);
|
|
5378
5379
|
return [
|
|
5379
|
-
|
|
5380
|
-
x * m *
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
x * m * E +
|
|
5384
|
-
|
|
5380
|
+
R * w,
|
|
5381
|
+
x * m * w - B * E,
|
|
5382
|
+
B * m * w + x * E,
|
|
5383
|
+
R * E,
|
|
5384
|
+
x * m * E + B * w,
|
|
5385
|
+
B * m * E - x * w,
|
|
5385
5386
|
-m,
|
|
5386
|
-
x *
|
|
5387
|
-
|
|
5387
|
+
x * R,
|
|
5388
|
+
B * R
|
|
5388
5389
|
];
|
|
5389
5390
|
}
|
|
5390
|
-
function Ut(u,
|
|
5391
|
-
return g[0] = u[0] *
|
|
5391
|
+
function Ut(u, p, y, h, g) {
|
|
5392
|
+
return g[0] = u[0] * p + u[1] * y + u[2] * h, g[1] = u[3] * p + u[4] * y + u[5] * h, g[2] = u[6] * p + u[7] * y + u[8] * h, g;
|
|
5392
5393
|
}
|
|
5393
|
-
function as(u,
|
|
5394
|
-
let
|
|
5395
|
-
|
|
5394
|
+
function as(u, p, y, h, g, P, _) {
|
|
5395
|
+
let B = u, x = p, R = y;
|
|
5396
|
+
h && (Ut(h, B, x, R, _), B = _[0], x = _[1], R = _[2]), B += P.emissionPositionX || 0, x += P.emissionPositionY || 0, R += P.emissionPositionZ || 0, g._simRotMatrix && (Ut(g._simRotMatrix, B, x, R, _), B = _[0], x = _[1], R = _[2]);
|
|
5396
5397
|
const m = g._simPosition;
|
|
5397
|
-
return
|
|
5398
|
+
return _[0] = B + (m ? m[0] : 0), _[1] = x + (m ? m[1] : 0), _[2] = R + (m ? m[2] : 0), _;
|
|
5398
5399
|
}
|
|
5399
|
-
function os(u,
|
|
5400
|
-
let
|
|
5401
|
-
return
|
|
5400
|
+
function os(u, p, y, h, g, P) {
|
|
5401
|
+
let _ = u, B = p, x = y;
|
|
5402
|
+
return h && (Ut(h, _, B, x, P), _ = P[0], B = P[1], x = P[2]), g._simRotMatrix && (Ut(g._simRotMatrix, _, B, x, P), _ = P[0], B = P[1], x = P[2]), P[0] = _, P[1] = B, P[2] = x, P;
|
|
5402
5403
|
}
|
|
5403
|
-
function jt(u,
|
|
5404
|
-
const
|
|
5405
|
-
let x = (u % 1 + 1) % 1 *
|
|
5406
|
-
return x <
|
|
5404
|
+
function jt(u, p, y, h, g) {
|
|
5405
|
+
const P = p * 2, _ = y * 2, B = 2 * (P + _);
|
|
5406
|
+
let x = (u % 1 + 1) % 1 * B, R = 0, m = 0;
|
|
5407
|
+
return x < P ? (R = -p + x, m = y) : (x -= P) < _ ? (R = p, m = y - x) : (x -= _) < P ? (R = p - x, m = -y) : (x -= P, R = -p, m = -y + x), h === "xz" ? (g[0] = R, g[1] = 0, g[2] = m) : (g[0] = R, g[1] = m, g[2] = 0), g;
|
|
5407
5408
|
}
|
|
5408
5409
|
function ls(u) {
|
|
5409
|
-
const
|
|
5410
|
-
let
|
|
5411
|
-
const
|
|
5412
|
-
if (
|
|
5413
|
-
g = !0,
|
|
5414
|
-
const
|
|
5415
|
-
for (let x = 0; x <
|
|
5416
|
-
const
|
|
5417
|
-
ae[x] = Math.cos(
|
|
5410
|
+
const p = u.emissionShape, y = Math.max(1, Math.min(256, Math.floor(u.shapeStrokeSegments ?? 96)));
|
|
5411
|
+
let h = 0, g = !1, P = [0, 0, 1];
|
|
5412
|
+
const _ = Ae;
|
|
5413
|
+
if (p === "circle") {
|
|
5414
|
+
g = !0, h = Math.max(3, y), P = [0, 0, 1];
|
|
5415
|
+
const B = u.circleOuterRadius ?? 2;
|
|
5416
|
+
for (let x = 0; x < h; x++) {
|
|
5417
|
+
const R = x / h * pt;
|
|
5418
|
+
ae[x] = Math.cos(R) * B, oe[x] = Math.sin(R) * B, le[x] = 0;
|
|
5418
5419
|
}
|
|
5419
|
-
} else if (
|
|
5420
|
-
g = !0,
|
|
5421
|
-
const
|
|
5422
|
-
for (let x = 0; x <
|
|
5423
|
-
const
|
|
5424
|
-
ae[x] = Math.cos(
|
|
5420
|
+
} else if (p === "disc") {
|
|
5421
|
+
g = !0, h = Math.max(3, y), P = [0, 1, 0];
|
|
5422
|
+
const B = u.discRadius ?? 2;
|
|
5423
|
+
for (let x = 0; x < h; x++) {
|
|
5424
|
+
const R = x / h * pt;
|
|
5425
|
+
ae[x] = Math.cos(R) * B, oe[x] = 0, le[x] = Math.sin(R) * B;
|
|
5425
5426
|
}
|
|
5426
|
-
} else if (
|
|
5427
|
-
g = !0,
|
|
5428
|
-
const
|
|
5429
|
-
for (let m = 0; m <
|
|
5430
|
-
const
|
|
5431
|
-
ae[m] = Math.cos(
|
|
5427
|
+
} else if (p === "annulus") {
|
|
5428
|
+
g = !0, h = Math.max(3, y), P = [0, 1, 0];
|
|
5429
|
+
const B = u.annulusInnerRadius ?? 1, x = u.annulusOuterRadius ?? 2, R = B + (x - B) * 0.5;
|
|
5430
|
+
for (let m = 0; m < h; m++) {
|
|
5431
|
+
const w = m / h * pt;
|
|
5432
|
+
ae[m] = Math.cos(w) * R, oe[m] = 0, le[m] = Math.sin(w) * R;
|
|
5432
5433
|
}
|
|
5433
|
-
} else if (
|
|
5434
|
-
g = !1,
|
|
5435
|
-
const
|
|
5436
|
-
for (let E = 0; E <
|
|
5437
|
-
const
|
|
5438
|
-
ae[E] = Math.cos(X) *
|
|
5434
|
+
} else if (p === "arc") {
|
|
5435
|
+
g = !1, h = Math.max(2, y + 1), P = [0, 0, 1];
|
|
5436
|
+
const B = u.arcInnerRadius ?? 0, x = u.arcOuterRadius ?? 2, R = B > 0 ? B + (x - B) * 0.5 : x, m = (u.arcStartAngle ?? 0) * Math.PI / 180, w = (u.arcEndAngle ?? 180) * Math.PI / 180;
|
|
5437
|
+
for (let E = 0; E < h; E++) {
|
|
5438
|
+
const N = h > 1 ? E / (h - 1) : 0, X = m + (w - m) * N;
|
|
5439
|
+
ae[E] = Math.cos(X) * R, oe[E] = Math.sin(X) * R, le[E] = 0;
|
|
5439
5440
|
}
|
|
5440
|
-
} else if (
|
|
5441
|
-
g = !0,
|
|
5442
|
-
const
|
|
5443
|
-
for (let x = 0; x <
|
|
5444
|
-
jt(x /
|
|
5445
|
-
} else if (
|
|
5446
|
-
g = !0,
|
|
5447
|
-
const
|
|
5448
|
-
for (let
|
|
5449
|
-
jt(
|
|
5450
|
-
} else if (
|
|
5451
|
-
g = !0,
|
|
5452
|
-
const
|
|
5453
|
-
for (let
|
|
5454
|
-
jt(
|
|
5455
|
-
} else if (
|
|
5456
|
-
g = !1,
|
|
5457
|
-
const
|
|
5458
|
-
for (let x = 0; x <
|
|
5459
|
-
const
|
|
5460
|
-
ae[x] = 0, oe[x] = (
|
|
5441
|
+
} else if (p === "square") {
|
|
5442
|
+
g = !0, h = Math.max(4, y), P = [0, 0, 1];
|
|
5443
|
+
const B = u.squareSize ?? 2;
|
|
5444
|
+
for (let x = 0; x < h; x++)
|
|
5445
|
+
jt(x / h, B, B, "xy", _), ae[x] = _[0], oe[x] = _[1], le[x] = _[2];
|
|
5446
|
+
} else if (p === "rectangle") {
|
|
5447
|
+
g = !0, h = Math.max(4, y), P = [0, 0, 1];
|
|
5448
|
+
const B = (u.rectangleWidth ?? 2) * 0.5, x = (u.rectangleHeight ?? 2) * 0.5;
|
|
5449
|
+
for (let R = 0; R < h; R++)
|
|
5450
|
+
jt(R / h, B, x, "xy", _), ae[R] = _[0], oe[R] = _[1], le[R] = _[2];
|
|
5451
|
+
} else if (p === "plain") {
|
|
5452
|
+
g = !0, h = Math.max(4, y), P = [0, 1, 0];
|
|
5453
|
+
const B = (u.planeWidth ?? 2) * 0.5, x = (u.planeDepth ?? 2) * 0.5;
|
|
5454
|
+
for (let R = 0; R < h; R++)
|
|
5455
|
+
jt(R / h, B, x, "xz", _), ae[R] = _[0], oe[R] = _[1], le[R] = _[2];
|
|
5456
|
+
} else if (p === "line") {
|
|
5457
|
+
g = !1, h = Math.max(2, y + 1), P = [0, 0, 1];
|
|
5458
|
+
const B = u.lineLength ?? 4;
|
|
5459
|
+
for (let x = 0; x < h; x++) {
|
|
5460
|
+
const R = h > 1 ? x / (h - 1) : 0;
|
|
5461
|
+
ae[x] = 0, oe[x] = (R - 0.5) * B, le[x] = 0;
|
|
5461
5462
|
}
|
|
5462
|
-
} else if (
|
|
5463
|
-
g = !0,
|
|
5464
|
-
const
|
|
5465
|
-
for (let
|
|
5466
|
-
const m =
|
|
5467
|
-
ae[
|
|
5463
|
+
} else if (p === "polygon") {
|
|
5464
|
+
g = !0, h = Math.max(3, y), P = [0, 0, 1];
|
|
5465
|
+
const B = Math.max(3, Math.floor(u.polygonSides ?? 6)), x = u.polygonRadius ?? 2;
|
|
5466
|
+
for (let R = 0; R < h; R++) {
|
|
5467
|
+
const m = R / h * B, w = Math.floor(m), E = m - w, N = w / B * pt, X = (w + 1) / B * pt, O = Math.cos(N) * x, U = Math.sin(N) * x, ye = Math.cos(X) * x, xe = Math.sin(X) * x;
|
|
5468
|
+
ae[R] = O + (ye - O) * E, oe[R] = U + (xe - U) * E, le[R] = 0;
|
|
5468
5469
|
}
|
|
5469
5470
|
} else
|
|
5470
|
-
|
|
5471
|
-
return { count:
|
|
5471
|
+
h = 0;
|
|
5472
|
+
return { count: h, closed: g, planeNormal: P };
|
|
5472
5473
|
}
|
|
5473
|
-
function cs(u,
|
|
5474
|
+
function cs(u, p, y) {
|
|
5474
5475
|
if (!y.shapeStrokeEnabled || y.hidden) return u;
|
|
5475
|
-
const { count:
|
|
5476
|
-
if (
|
|
5477
|
-
const
|
|
5476
|
+
const { count: h, closed: g, planeNormal: P } = ls(y);
|
|
5477
|
+
if (h < 2) return u;
|
|
5478
|
+
const _ = ns(y), B = Math.max(1e-4, y.shapeStrokeWidth ?? 0.08), x = Math.max(0, y.opacity ?? 1);
|
|
5478
5479
|
if (x <= 0) return u;
|
|
5479
|
-
os(
|
|
5480
|
-
let
|
|
5481
|
-
const m = Ae[0] /
|
|
5482
|
-
for (let I = 0; I <
|
|
5483
|
-
as(ae[I], oe[I], le[I],
|
|
5484
|
-
const
|
|
5485
|
-
if (
|
|
5480
|
+
os(P[0], P[1], P[2], _, p, Ae);
|
|
5481
|
+
let R = Math.hypot(Ae[0], Ae[1], Ae[2]) || 1;
|
|
5482
|
+
const m = Ae[0] / R, w = Ae[1] / R, E = Ae[2] / R;
|
|
5483
|
+
for (let I = 0; I < h; I++)
|
|
5484
|
+
as(ae[I], oe[I], le[I], _, p, y, Ae), ae[I] = Ae[0], oe[I] = Ae[1], le[I] = Ae[2];
|
|
5485
|
+
const N = y.shapeStrokeShape ?? "straight";
|
|
5486
|
+
if (N !== "straight") {
|
|
5486
5487
|
const I = y.shapeStrokeAmplitude ?? 0.08, K = y.shapeStrokeFrequency ?? 10, Ie = y.shapeStrokeSpeed ?? 0;
|
|
5487
|
-
for (let W = 0; W <
|
|
5488
|
-
const
|
|
5489
|
-
let
|
|
5490
|
-
|
|
5488
|
+
for (let W = 0; W < h; W++) {
|
|
5489
|
+
const pe = W === 0 ? g ? h - 1 : 0 : W - 1, ee = W === h - 1 ? g ? 0 : h - 1 : W + 1, ge = ae[ee] - ae[pe], $ = oe[ee] - oe[pe], Q = le[ee] - le[pe], J = w * Q - E * $, te = E * ge - m * Q, ce = m * $ - w * ge, be = Math.hypot(J, te, ce) || 1, ve = J / be, ue = te / be, He = ce / be, Me = g ? W / h : W / Math.max(1, h - 1), Se = pt * K * Me + Ie * Ve;
|
|
5490
|
+
let he = 0, me = 0;
|
|
5491
|
+
N === "zigzag" ? he = I * Math.sign(Math.sin(Se) || 1) : N === "sine" ? he = I * Math.sin(Se) : N === "spiral" && (he = I * Math.sin(Se), me = I * Math.cos(Se)), ae[W] += ve * he + m * me, oe[W] += ue * he + w * me, le[W] += He * he + E * me;
|
|
5491
5492
|
}
|
|
5492
5493
|
}
|
|
5493
|
-
const X = g ?
|
|
5494
|
+
const X = g ? h : h - 1, O = y.bloomIntensity || 1, U = y.startColor ?? y.particleColor ?? [1, 1, 1], ye = y.endColor ?? U, xe = y.particleColor ?? U, Oe = y.randomColorEnabled && Array.isArray(y.randomColors) && y.randomColors.length > 0 ? y.randomColors[0] : null, fe = B * 0.5, _t = Math.max(B * 4, 1e-4), je = (y.shapeStrokeSpeed ?? 0) * Ve;
|
|
5494
5495
|
let it = 0;
|
|
5495
5496
|
for (let I = 0; I < X; I++) {
|
|
5496
|
-
const K = g ? (I + 1) %
|
|
5497
|
+
const K = g ? (I + 1) % h : I + 1;
|
|
5497
5498
|
it += Math.hypot(ae[K] - ae[I], oe[K] - oe[I], le[K] - le[I]);
|
|
5498
5499
|
}
|
|
5499
5500
|
const Qt = g ? Math.max(1, Math.round(it / _t)) : Math.max(it / _t, 1e-6), Mt = it > 1e-6 ? Qt / it : 0;
|
|
5500
5501
|
let qe = 0, wt = !1, ut = 0, Ue = 0, dt = 0;
|
|
5501
|
-
for (let I = 0; I <
|
|
5502
|
-
const K = I === 0 ? g ?
|
|
5503
|
-
let W = ae[Ie] - ae[K],
|
|
5504
|
-
const
|
|
5505
|
-
W /=
|
|
5506
|
-
let $ =
|
|
5502
|
+
for (let I = 0; I < h; I++) {
|
|
5503
|
+
const K = I === 0 ? g ? h - 1 : 0 : I - 1, Ie = I === h - 1 ? g ? 0 : h - 1 : I + 1;
|
|
5504
|
+
let W = ae[Ie] - ae[K], pe = oe[Ie] - oe[K], ee = le[Ie] - le[K];
|
|
5505
|
+
const ge = Math.hypot(W, pe, ee) || 1;
|
|
5506
|
+
W /= ge, pe /= ge, ee /= ge;
|
|
5507
|
+
let $ = w * ee - E * pe, Q = E * W - m * ee, J = m * pe - w * W, te = Math.hypot($, Q, J);
|
|
5507
5508
|
if (te < 1e-5) {
|
|
5508
|
-
const ce = V.right[0],
|
|
5509
|
-
$ = ce - ue * W, Q =
|
|
5509
|
+
const ce = V.right[0], be = V.right[1], ve = V.right[2], ue = ce * W + be * pe + ve * ee;
|
|
5510
|
+
$ = ce - ue * W, Q = be - ue * pe, J = ve - ue * ee, te = Math.hypot($, Q, J);
|
|
5510
5511
|
}
|
|
5511
5512
|
if (te < 1e-5) {
|
|
5512
|
-
const ce = V.up[0],
|
|
5513
|
-
$ = ce - ue * W, Q =
|
|
5513
|
+
const ce = V.up[0], be = V.up[1], ve = V.up[2], ue = ce * W + be * pe + ve * ee;
|
|
5514
|
+
$ = ce - ue * W, Q = be - ue * pe, J = ve - ue * ee, te = Math.hypot($, Q, J) || 1;
|
|
5514
5515
|
}
|
|
5515
5516
|
$ /= te, Q /= te, J /= te, wt && ut * $ + Ue * Q + dt * J < 0 && ($ = -$, Q = -Q, J = -J), Xt[I] = $, Nt[I] = Q, Yt[I] = J, ut = $, Ue = Q, dt = J, wt = !0;
|
|
5516
5517
|
}
|
|
5517
5518
|
for (let I = 0; I < X && !(u + 54 > Ce.length); I++) {
|
|
5518
|
-
const K = g ? (I + 1) %
|
|
5519
|
-
let Q = ee - Ie, J =
|
|
5519
|
+
const K = g ? (I + 1) % h : I + 1, Ie = ae[I], W = oe[I], pe = le[I], ee = ae[K], ge = oe[K], $ = le[K];
|
|
5520
|
+
let Q = ee - Ie, J = ge - W, te = $ - pe;
|
|
5520
5521
|
const ce = Math.hypot(Q, J, te) || 1;
|
|
5521
5522
|
Q /= ce, J /= ce, te /= ce;
|
|
5522
|
-
const
|
|
5523
|
-
let Me,
|
|
5524
|
-
Oe ? (Me =
|
|
5525
|
-
const
|
|
5526
|
-
Ce[u++] = A, Ce[u++] = k, Ce[u++] = de, Ce[u++] =
|
|
5523
|
+
const be = g ? I / h : I / Math.max(1, h - 1), ve = g ? K / h : K / Math.max(1, h - 1), ue = qe * Mt + je, He = (qe + ce) * Mt + je;
|
|
5524
|
+
let Me, Se, he, me, we, Be;
|
|
5525
|
+
Oe ? (Me = me = Oe[0], Se = we = Oe[1], he = Be = Oe[2]) : y.colorTransitionEnabled ? (Me = U[0] + (ye[0] - U[0]) * be, Se = U[1] + (ye[1] - U[1]) * be, he = U[2] + (ye[2] - U[2]) * be, me = U[0] + (ye[0] - U[0]) * ve, we = U[1] + (ye[1] - U[1]) * ve, Be = U[2] + (ye[2] - U[2]) * ve) : (Me = me = xe[0], Se = we = xe[1], he = Be = xe[2]), Me = Math.min(1, Me * O), Se = Math.min(1, Se * O), he = Math.min(1, he * O), me = Math.min(1, me * O), we = Math.min(1, we * O), Be = Math.min(1, Be * O);
|
|
5526
|
+
const Bt = Xt[I], gt = Nt[I], Le = Yt[I], ke = Xt[K], ze = Nt[K], Rt = Yt[K], Ot = Ie + Bt * fe, Lt = W + gt * fe, Tt = pe + Le * fe, Re = Ie - Bt * fe, Te = W - gt * fe, Ee = pe - Le * fe, st = ee + ke * fe, rt = ge + ze * fe, Et = $ + Rt * fe, Ze = ee - ke * fe, We = ge - ze * fe, $e = $ - Rt * fe, ft = (A, k, de, Y, L, j, ie, Je, Ke) => {
|
|
5527
|
+
Ce[u++] = A, Ce[u++] = k, Ce[u++] = de, Ce[u++] = Y, Ce[u++] = L, Ce[u++] = j, Ce[u++] = ie, Ce[u++] = Je, Ce[u++] = Ke;
|
|
5527
5528
|
};
|
|
5528
|
-
ft(Ot, Lt, Tt, Me,
|
|
5529
|
+
ft(Ot, Lt, Tt, Me, Se, he, x, ue, 0), ft(Re, Te, Ee, Me, Se, he, x, ue, 1), ft(st, rt, Et, me, we, Be, x, He, 0), ft(Re, Te, Ee, Me, Se, he, x, ue, 1), ft(Ze, We, $e, me, we, Be, x, He, 1), ft(st, rt, Et, me, we, Be, x, He, 0), qe += ce;
|
|
5529
5530
|
}
|
|
5530
5531
|
return u;
|
|
5531
5532
|
}
|
|
5532
5533
|
const us = 0.41421356;
|
|
5533
5534
|
function ds() {
|
|
5534
5535
|
xt.clear(), at.clear();
|
|
5535
|
-
let u = 0,
|
|
5536
|
+
let u = 0, p = 0, y = 0;
|
|
5536
5537
|
V.position[0], V.position[1], V.position[2];
|
|
5537
|
-
for (const { system:
|
|
5538
|
+
for (const { system: h, config: g } of c.particleSystems) {
|
|
5538
5539
|
if (g.hidden) continue;
|
|
5539
5540
|
if (g.emissionTrailEnabled && !g.glbModelEnabled) {
|
|
5540
|
-
|
|
5541
|
-
const
|
|
5542
|
-
if (
|
|
5543
|
-
const
|
|
5541
|
+
h.readbackAndProcessParticles();
|
|
5542
|
+
const _ = h.particleData, B = h.particleVelocities, x = h.activeParticles;
|
|
5543
|
+
if (_ && B && x > 0) {
|
|
5544
|
+
const R = g.emissionTrailMode === "particles", m = u, w = g.emissionTrailDuration ?? 1, E = g.opacity ?? 1, N = g.particleSize ?? 0.5, X = g.bloomIntensity || 1, O = Math.max(1, Math.min(64, g.emissionTrailSegments ?? 8)), U = g.emissionTrailShape || "straight", ye = g.followSystemTranslation ?? !0, xe = h._simPosition, Oe = ye && xe ? xe[0] : 0, fe = ye && xe ? xe[1] : 0, _t = ye && xe ? xe[2] : 0, je = h._simVelocity, it = je ? je[0] : 0, Qt = je ? je[1] : 0, Mt = je ? je[2] : 0, qe = oi(g.id), wt = !!(ye && qe && qe.hist && qe.hist.length > 1);
|
|
5544
5545
|
for (let ut = 0; ut < x; ut++) {
|
|
5545
|
-
const Ue = ut * 8, dt =
|
|
5546
|
-
let ee =
|
|
5547
|
-
const Q =
|
|
5546
|
+
const Ue = ut * 8, dt = _[Ue], I = _[Ue + 1], K = _[Ue + 2], Ie = dt + Oe, W = I + fe, pe = K + _t;
|
|
5547
|
+
let ee = _[Ue + 3], ge = _[Ue + 4], $ = _[Ue + 5];
|
|
5548
|
+
const Q = _[Ue + 6], J = _[Ue + 7];
|
|
5548
5549
|
if (Q >= J || J <= 0) continue;
|
|
5549
5550
|
const te = Q / J;
|
|
5550
5551
|
if (g.colorTransitionEnabled) {
|
|
5551
5552
|
const A = g.startColor ?? [1, 0, 0], k = g.endColor ?? [0, 0, 1];
|
|
5552
|
-
ee = A[0] + (k[0] - A[0]) * te,
|
|
5553
|
+
ee = A[0] + (k[0] - A[0]) * te, ge = A[1] + (k[1] - A[1]) * te, $ = A[2] + (k[2] - A[2]) * te;
|
|
5553
5554
|
}
|
|
5554
|
-
ee = Math.min(1, ee * X),
|
|
5555
|
-
let ce =
|
|
5555
|
+
ee = Math.min(1, ee * X), ge = Math.min(1, ge * X), $ = Math.min(1, $ * X);
|
|
5556
|
+
let ce = N;
|
|
5556
5557
|
if (g.randomSize) {
|
|
5557
5558
|
const A = Math.sin(J * 54321.67) * 43758.5453 % 1, k = A < 0 ? A + 1 : A;
|
|
5558
5559
|
ce = (g.minSize ?? 0.1) + ((g.maxSize ?? 0.5) - (g.minSize ?? 0.1)) * k;
|
|
@@ -5566,81 +5567,81 @@ async function Jr(s, t = {}) {
|
|
|
5566
5567
|
ce *= 1 + Math.pow(te, 1 / A);
|
|
5567
5568
|
}
|
|
5568
5569
|
if (ce <= 0 || te > 0.9) continue;
|
|
5569
|
-
const
|
|
5570
|
+
const be = Math.min((0.9 - te) * (1 / 0.2), 1), ve = 0.75 * ce * us * be;
|
|
5570
5571
|
let ue = E;
|
|
5571
|
-
if (g.fadeEnabled && (ue *= Math.max(0, 1 - te)), ue *=
|
|
5572
|
-
const He = ut * 4, Me =
|
|
5573
|
-
if (
|
|
5574
|
-
const gt = 1 /
|
|
5575
|
-
let Tt =
|
|
5572
|
+
if (g.fadeEnabled && (ue *= Math.max(0, 1 - te)), ue *= be, ue < 0.01) continue;
|
|
5573
|
+
const He = ut * 4, Me = B[He], Se = B[He + 1], he = B[He + 2], me = Me + it, we = Se + Qt, Be = he + Mt, Bt = Math.sqrt(me * me + we * we + Be * Be);
|
|
5574
|
+
if (Bt < 1e-3) continue;
|
|
5575
|
+
const gt = 1 / Bt, Le = me * gt, ke = we * gt, ze = Be * gt, Rt = V.right[0], Ot = V.right[1], Lt = V.right[2];
|
|
5576
|
+
let Tt = Rt * Le + Ot * ke + Lt * ze, Re = Rt - Tt * Le, Te = Ot - Tt * ke, Ee = Lt - Tt * ze, st = Math.sqrt(Re * Re + Te * Te + Ee * Ee);
|
|
5576
5577
|
if (st < 0.2) {
|
|
5577
|
-
const A = V.up[0], k = V.up[1], de = V.up[2],
|
|
5578
|
-
|
|
5578
|
+
const A = V.up[0], k = V.up[1], de = V.up[2], Y = A * Le + k * ke + de * ze;
|
|
5579
|
+
Re = A - Y * Le, Te = k - Y * ke, Ee = de - Y * ze, st = Math.sqrt(Re * Re + Te * Te + Ee * Ee) || 1;
|
|
5579
5580
|
}
|
|
5580
|
-
|
|
5581
|
-
const rt = Math.min(
|
|
5581
|
+
Re /= st, Te /= st, Ee /= st;
|
|
5582
|
+
const rt = Math.min(w, Q);
|
|
5582
5583
|
if (rt < 1e-3) continue;
|
|
5583
5584
|
const Et = g.gravityEnabled && g.gravityStrength || 0, Ze = _s, We = Ms, $e = ws;
|
|
5584
5585
|
if (g.orientToDirection && g.burstMode && wt) {
|
|
5585
|
-
const A =
|
|
5586
|
+
const A = h._emitSimRotY || 0, k = Bs, de = Rs, Y = Ts;
|
|
5586
5587
|
for (let L = 0; L <= O; L++) {
|
|
5587
|
-
const
|
|
5588
|
-
k[L] =
|
|
5588
|
+
const j = li(qe, Ve - L / O * rt, Pi);
|
|
5589
|
+
k[L] = j[0], de[L] = j[1], Y[L] = j[2];
|
|
5589
5590
|
}
|
|
5590
5591
|
for (let L = 0; L <= O; L++) {
|
|
5591
|
-
const
|
|
5592
|
-
let Je = k[
|
|
5593
|
-
const nt = (Math.hypot(Je, Ke) > 1e-5 ? Math.atan2(Je, Ke) : Math.atan2(it, Mt)) - A, De = Math.cos(nt),
|
|
5594
|
-
Ze[L] = De * dt +
|
|
5592
|
+
const j = L > 0 ? L - 1 : 0, ie = L < O ? L + 1 : O;
|
|
5593
|
+
let Je = k[j] - k[ie], Ke = Y[j] - Y[ie];
|
|
5594
|
+
const nt = (Math.hypot(Je, Ke) > 1e-5 ? Math.atan2(Je, Ke) : Math.atan2(it, Mt)) - A, De = Math.cos(nt), Ge = Math.sin(nt), et = L / O * rt, ei = -0.5 * Et * et * et;
|
|
5595
|
+
Ze[L] = De * dt + Ge * K + k[L], We[L] = I + ei + de[L], $e[L] = -Ge * dt + De * K + Y[L];
|
|
5595
5596
|
}
|
|
5596
5597
|
} else for (let A = 0; A <= O; A++) {
|
|
5597
5598
|
const k = A / O * rt, de = -0.5 * Et * k * k;
|
|
5598
5599
|
if (wt) {
|
|
5599
|
-
const
|
|
5600
|
-
Ze[A] = dt - Me * k +
|
|
5600
|
+
const Y = li(qe, Ve - k, Pi);
|
|
5601
|
+
Ze[A] = dt - Me * k + Y[0], We[A] = I - Se * k + de + Y[1], $e[A] = K - he * k + Y[2];
|
|
5601
5602
|
} else
|
|
5602
|
-
Ze[A] = Ie -
|
|
5603
|
+
Ze[A] = Ie - me * k, We[A] = W - we * k + de, $e[A] = pe - Be * k;
|
|
5603
5604
|
}
|
|
5604
5605
|
if (U !== "straight") {
|
|
5605
5606
|
const A = g.emissionTrailShapeAmplitude ?? 0.1, k = g.emissionTrailShapeFrequency ?? 4, de = g.emissionTrailShapeSpeed ?? 0;
|
|
5606
|
-
let
|
|
5607
|
-
ie < 1e-6 && (
|
|
5608
|
-
const Je = ke *
|
|
5607
|
+
let Y = -ze, L = 0, j = Le, ie = Math.sqrt(Y * Y + j * j);
|
|
5608
|
+
ie < 1e-6 && (Y = 0, L = ze, j = -ke, ie = Math.sqrt(Y * Y + L * L + j * j) || 1), Y /= ie, L /= ie, j /= ie;
|
|
5609
|
+
const Je = ke * j - ze * L, Ke = ze * Y - Le * j, Qe = Le * L - ke * Y;
|
|
5609
5610
|
for (let Pe = 1; Pe <= O; Pe++) {
|
|
5610
5611
|
const nt = Pe / O * rt, De = 2 * Math.PI * k * (Ve - nt) + de * Ve;
|
|
5611
|
-
let
|
|
5612
|
-
U === "zigzag" ?
|
|
5612
|
+
let Ge = 0, et = 0;
|
|
5613
|
+
U === "zigzag" ? Ge = A * Math.sign(Math.sin(De)) : U === "sine" ? Ge = A * Math.sin(De) : U === "spiral" && (Ge = A * Math.sin(De), et = A * Math.cos(De)), Ze[Pe] += Y * Ge + Je * et, We[Pe] += L * Ge + Ke * et, $e[Pe] += j * Ge + Qe * et;
|
|
5613
5614
|
}
|
|
5614
5615
|
}
|
|
5615
|
-
if (
|
|
5616
|
-
for (let A = 1; A <= O && u <
|
|
5617
|
-
const k = A / O, de = Ze[A] - Oe,
|
|
5618
|
-
H[
|
|
5616
|
+
if (R)
|
|
5617
|
+
for (let A = 1; A <= O && u < F; A++) {
|
|
5618
|
+
const k = A / O, de = Ze[A] - Oe, Y = We[A] - fe, L = $e[A] - _t, j = u * 8, ie = u * 4;
|
|
5619
|
+
H[j] = de, H[j + 1] = Y, H[j + 2] = L, H[j + 3] = ee, H[j + 4] = ge, H[j + 5] = $, H[j + 6] = Q + (J - Q) * k, H[j + 7] = J, se[ie] = 0, se[ie + 1] = 0, se[ie + 2] = 0, se[ie + 3] = 0, ne[ie] = de, ne[ie + 1] = Y, ne[ie + 2] = L, ne[ie + 3] = 0, u++;
|
|
5619
5620
|
}
|
|
5620
5621
|
else
|
|
5621
|
-
for (let A = 0; A < O && !(
|
|
5622
|
-
const k = A / O, de = (A + 1) / O,
|
|
5623
|
-
Ye[
|
|
5622
|
+
for (let A = 0; A < O && !(p + 42 > Ye.length); A++) {
|
|
5623
|
+
const k = A / O, de = (A + 1) / O, Y = Ze[A], L = We[A], j = $e[A], ie = Ze[A + 1], Je = We[A + 1], Ke = $e[A + 1], Qe = ve * (1 - k), Pe = ve * (1 - de), nt = ue * (1 - k) * (1 - k), De = ue * (1 - de) * (1 - de), Ge = Y + Re * Qe, et = L + Te * Qe, ei = j + Ee * Qe, Ai = Y - Re * Qe, Ci = L - Te * Qe, Ui = j - Ee * Qe, Ii = ie + Re * Pe, zi = Je + Te * Pe, Di = Ke + Ee * Pe, Os = ie - Re * Pe, Ls = Je - Te * Pe, ks = Ke - Ee * Pe, bt = (Xs, Ns, Ys, js) => {
|
|
5624
|
+
Ye[p++] = Xs, Ye[p++] = Ns, Ye[p++] = Ys, Ye[p++] = ee, Ye[p++] = ge, Ye[p++] = $, Ye[p++] = js;
|
|
5624
5625
|
};
|
|
5625
|
-
bt(
|
|
5626
|
+
bt(Ge, et, ei, nt), bt(Ai, Ci, Ui, nt), bt(Ii, zi, Di, De), bt(Ai, Ci, Ui, nt), bt(Os, Ls, ks, De), bt(Ii, zi, Di, De);
|
|
5626
5627
|
}
|
|
5627
5628
|
}
|
|
5628
|
-
|
|
5629
|
+
R && u > m && xt.set(g.id, { first: m, count: u - m });
|
|
5629
5630
|
}
|
|
5630
5631
|
}
|
|
5631
|
-
const
|
|
5632
|
-
y = cs(y,
|
|
5632
|
+
const P = y;
|
|
5633
|
+
y = cs(y, h, g), y > P && at.set(g.id, { first: P / 9, count: (y - P) / 9 });
|
|
5633
5634
|
}
|
|
5634
|
-
u > 0 && (r.queue.writeBuffer(re, 0, H, 0, u * 8), r.queue.writeBuffer(
|
|
5635
|
+
u > 0 && (r.queue.writeBuffer(re, 0, H, 0, u * 8), r.queue.writeBuffer(q, 0, se, 0, u * 4), r.queue.writeBuffer(tt, 0, ne, 0, u * 4)), vt = p / 7, vt > 0 && r.queue.writeBuffer(qt, 0, Ye, 0, p), bi = y / 9, bi > 0 && r.queue.writeBuffer(Ht, 0, Ce, 0, y);
|
|
5635
5636
|
}
|
|
5636
5637
|
const ci = () => {
|
|
5637
|
-
const [u,
|
|
5638
|
-
r.queue.writeBuffer(z, 0, new Float32Array([1, 0, u,
|
|
5638
|
+
const [u, p] = Ji(a.width, a.height);
|
|
5639
|
+
r.queue.writeBuffer(z, 0, new Float32Array([1, 0, u, p, 0, 0, 0, 0])), r.queue.writeBuffer(D, 0, new Float32Array([0, 1, u, p, 0, 0, 0, 0]));
|
|
5639
5640
|
};
|
|
5640
5641
|
ci();
|
|
5641
5642
|
const ui = new Float32Array(16).fill(0);
|
|
5642
|
-
ui[0] = 1, r.queue.writeBuffer(
|
|
5643
|
-
const
|
|
5643
|
+
ui[0] = 1, r.queue.writeBuffer(M, 0, ui);
|
|
5644
|
+
const Fe = Ir(r), Ne = Cr(r), {
|
|
5644
5645
|
particlePipeline: fs,
|
|
5645
5646
|
particleAdditivePipeline: ps,
|
|
5646
5647
|
particleDepthWritePipeline: hs,
|
|
@@ -5862,12 +5863,12 @@ async function Jr(s, t = {}) {
|
|
|
5862
5863
|
});
|
|
5863
5864
|
let bi = 0, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct } = Ni(r, l, a.width, a.height), zt = Yi(r, a.width, a.height), ht, Si, Dt, Pt;
|
|
5864
5865
|
const xi = () => {
|
|
5865
|
-
const u = (
|
|
5866
|
+
const u = (p) => p.createView();
|
|
5866
5867
|
ht = u(ot), Si = u(lt), Dt = u(ct), Pt = u(zt);
|
|
5867
5868
|
};
|
|
5868
5869
|
xi();
|
|
5869
|
-
const Zt = { uniformBuffer: v, appearanceUniformBuffer: C, horizontalBlurUniformBuffer: z, verticalBlurUniformBuffer: D, bloomIntensityBuffer:
|
|
5870
|
-
let
|
|
5870
|
+
const Zt = { uniformBuffer: v, appearanceUniformBuffer: C, horizontalBlurUniformBuffer: z, verticalBlurUniformBuffer: D, bloomIntensityBuffer: M };
|
|
5871
|
+
let Gt = si(r, Fe, Zt, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct });
|
|
5871
5872
|
const V = {
|
|
5872
5873
|
mvp: new Float32Array(16),
|
|
5873
5874
|
position: new Float32Array([0, 0, 10]),
|
|
@@ -5877,102 +5878,102 @@ async function Jr(s, t = {}) {
|
|
|
5877
5878
|
hasCamera: !1
|
|
5878
5879
|
};
|
|
5879
5880
|
let Ve = 0, Ps = 0;
|
|
5880
|
-
const mt = new Float32Array(5), vi = new Float32Array(16), _s = new Array(65), Ms = new Array(65), ws = new Array(65),
|
|
5881
|
-
let _i = !1, Wt = !0,
|
|
5881
|
+
const mt = new Float32Array(5), vi = new Float32Array(16), _s = new Array(65), Ms = new Array(65), ws = new Array(65), Bs = new Array(65), Rs = new Array(65), Ts = new Array(65), Pi = [0, 0, 0], yt = { key: null, ms: !1, bindGroup: null };
|
|
5882
|
+
let _i = !1, Wt = !0, Ft = !1, Vt = null, $t = a.width, Jt = a.height;
|
|
5882
5883
|
function Mi() {
|
|
5883
|
-
const u = [ot, lt, ct, zt],
|
|
5884
|
-
ot =
|
|
5884
|
+
const u = [ot, lt, ct, zt], p = Ni(r, l, a.width, a.height);
|
|
5885
|
+
ot = p.sceneTexture, lt = p.bloomTexA, ct = p.bloomTexB, zt = Yi(r, a.width, a.height), xi(), ci(), f.clear(), b.resizeTextures(), Gt = si(r, Fe, Zt, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct });
|
|
5885
5886
|
let y = !1;
|
|
5886
|
-
const
|
|
5887
|
+
const h = () => {
|
|
5887
5888
|
if (!y) {
|
|
5888
|
-
y = !0, requestAnimationFrame(
|
|
5889
|
+
y = !0, requestAnimationFrame(h);
|
|
5889
5890
|
return;
|
|
5890
5891
|
}
|
|
5891
5892
|
u.forEach((g) => g.destroy());
|
|
5892
5893
|
};
|
|
5893
|
-
requestAnimationFrame(
|
|
5894
|
+
requestAnimationFrame(h);
|
|
5894
5895
|
}
|
|
5895
|
-
function Es(u,
|
|
5896
|
-
V.mvp.set(
|
|
5896
|
+
function Es(u, p, y) {
|
|
5897
|
+
V.mvp.set(Fr(u, p)), p && p.length >= 10 && (V.right[0] = p[0], V.right[1] = p[4], V.right[2] = p[8], V.up[0] = p[1], V.up[1] = p[5], V.up[2] = p[9]), y && (V.position[0] = y.x ?? y[0], V.position[1] = y.y ?? y[1], V.position[2] = y.z ?? y[2]), V.hasCamera = !0;
|
|
5897
5898
|
}
|
|
5898
|
-
function As(u,
|
|
5899
|
-
V.mvp.set(u),
|
|
5899
|
+
function As(u, p) {
|
|
5900
|
+
V.mvp.set(u), p && (V.position[0] = p.x ?? p[0], V.position[1] = p.y ?? p[1], V.position[2] = p.z ?? p[2]), V.hasCamera = !0;
|
|
5900
5901
|
}
|
|
5901
5902
|
async function Kt(u) {
|
|
5902
|
-
if (
|
|
5903
|
+
if (Ft) {
|
|
5903
5904
|
Vt = u;
|
|
5904
5905
|
return;
|
|
5905
5906
|
}
|
|
5906
|
-
|
|
5907
|
+
Ft = !0;
|
|
5907
5908
|
try {
|
|
5908
|
-
for (const
|
|
5909
|
-
|
|
5910
|
-
for (const
|
|
5911
|
-
await c.addSystems(
|
|
5912
|
-
for (const { config:
|
|
5913
|
-
T[
|
|
5909
|
+
for (const p in T) delete T[p];
|
|
5910
|
+
f.clear(), b.resizeTextures(), Gt = si(r, Fe, Zt, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct }), await c.replaceSystems({ systems: [], activeSystemIndex: 0 });
|
|
5911
|
+
for (const p of u)
|
|
5912
|
+
await c.addSystems(p.preset, p.position || [0, 0, 0]);
|
|
5913
|
+
for (const { config: p } of c.particleSystems)
|
|
5914
|
+
T[p.id] || (T[p.id] = G());
|
|
5914
5915
|
Wt = !0, c.respawnAllSystems();
|
|
5915
5916
|
} finally {
|
|
5916
|
-
if (
|
|
5917
|
-
const
|
|
5918
|
-
Vt = null, Kt(
|
|
5917
|
+
if (Ft = !1, Vt) {
|
|
5918
|
+
const p = Vt;
|
|
5919
|
+
Vt = null, Kt(p);
|
|
5919
5920
|
}
|
|
5920
5921
|
}
|
|
5921
5922
|
}
|
|
5922
|
-
async function Cs(u,
|
|
5923
|
-
return Kt([{ preset: u, position:
|
|
5923
|
+
async function Cs(u, p = [0, 0, 0]) {
|
|
5924
|
+
return Kt([{ preset: u, position: p }]);
|
|
5924
5925
|
}
|
|
5925
5926
|
function Us(u) {
|
|
5926
|
-
if (_i ||
|
|
5927
|
-
const
|
|
5928
|
-
if (
|
|
5927
|
+
if (_i || Ft || !c.ready || u <= 0 || c.particleSystems.length === 0) return;
|
|
5928
|
+
const p = c.clock;
|
|
5929
|
+
if (p && (p.loop = c.loop ?? i, p.duration = c.getTotalDuration(), u = p.tick(u)), u > 0.1 && (u = 0.1), u <= 0) return;
|
|
5929
5930
|
if ((a.width !== $t || a.height !== Jt) && ($t = a.width, Jt = a.height, Mi()), Ve += u, _e.length) {
|
|
5930
5931
|
for (const m of _e) {
|
|
5931
5932
|
if (m.getPosition) {
|
|
5932
|
-
const
|
|
5933
|
-
|
|
5933
|
+
const w = m.getPosition();
|
|
5934
|
+
w ? (m.pos || (m.pos = m._posBuf), Array.isArray(w) ? (m.pos[0] = w[0], m.pos[1] = w[1], m.pos[2] = w[2]) : (m.pos[0] = w.x, m.pos[1] = w.y, m.pos[2] = w.z)) : m.pos = null;
|
|
5934
5935
|
}
|
|
5935
5936
|
m.vel = m._velBuf, m.pos && m.prevPos && m.wasActive && u > 0 ? (m.vel[0] = (m.pos[0] - m.prevPos[0]) / u, m.vel[1] = (m.pos[1] - m.prevPos[1]) / u, m.vel[2] = (m.pos[2] - m.prevPos[2]) / u) : (m.vel[0] = 0, m.vel[1] = 0, m.vel[2] = 0), m.justResumed = !!m.pos && !m.wasActive, m.justResumed && (m.hist.length = 0);
|
|
5936
5937
|
}
|
|
5937
|
-
for (const { system: m, config:
|
|
5938
|
-
const E = oi(
|
|
5939
|
-
if (!(!E || E.historyOnly) && (
|
|
5940
|
-
let
|
|
5938
|
+
for (const { system: m, config: w } of c.particleSystems) {
|
|
5939
|
+
const E = oi(w.id);
|
|
5940
|
+
if (!(!E || E.historyOnly) && (w.hidden = !E.pos, E.pos)) {
|
|
5941
|
+
let N = null;
|
|
5941
5942
|
if (E.orientToDirection && E.vel) {
|
|
5942
5943
|
const X = E.vel[0], O = E.vel[2];
|
|
5943
|
-
Math.hypot(X, O) > 1e-4 && (
|
|
5944
|
+
Math.hypot(X, O) > 1e-4 && (N = [0, 0, Math.atan2(X, O)]);
|
|
5944
5945
|
}
|
|
5945
|
-
m.setSimulationTransform({ position: E.pos, velocity: E.vel, rotation:
|
|
5946
|
+
m.setSimulationTransform({ position: E.pos, velocity: E.vel, rotation: N }), m.updateAppearanceUniform(), (E.justResumed || m.activeParticles === 0) && m.spawnParticles();
|
|
5946
5947
|
}
|
|
5947
5948
|
}
|
|
5948
5949
|
for (const m of _e)
|
|
5949
5950
|
m.pos ? rs(m, Ve) : m.hist.length = 0, m.pos ? (m._prevPosBuf[0] = m.pos[0], m._prevPosBuf[1] = m.pos[1], m._prevPosBuf[2] = m.pos[2], m.prevPos = m._prevPosBuf) : m.prevPos = null, m.wasActive = !!m.pos;
|
|
5950
5951
|
if (globalThis.__HZFX_DEBUG && (Ps++ & 63) === 0) {
|
|
5951
|
-
const m = c.particleSystems.reduce((X, O) => X + (O.system.activeParticles | 0), 0),
|
|
5952
|
-
console.info(`[HZFX] movingGroups(${_e.length})=[${
|
|
5952
|
+
const m = c.particleSystems.reduce((X, O) => X + (O.system.activeParticles | 0), 0), w = _e.find((X) => X.pos), E = w ? Math.hypot(V.position[0] - w.pos[0], V.position[1] - w.pos[1], V.position[2] - w.pos[2]).toFixed(1) : "-", N = _e.map((X) => `{ids:[${[...X.ids]}],pos:${X.pos ? "1" : "0"},hist:${X.hist.length}}`).join(",");
|
|
5953
|
+
console.info(`[HZFX] movingGroups(${_e.length})=[${N}] activeParticles=${m} systems=${c.particleSystems.length} ribbonVerts=${vt} camDist=${E} t=${Ve.toFixed(1)}`);
|
|
5953
5954
|
}
|
|
5954
5955
|
}
|
|
5955
|
-
if (c.updateAllSystems(u),
|
|
5956
|
-
const m = c.particleSystems.length > 0 && c.particleSystems.every(({ system:
|
|
5957
|
-
(
|
|
5956
|
+
if (c.updateAllSystems(u), p ? p.loop : c.loop ?? i) {
|
|
5957
|
+
const m = c.particleSystems.length > 0 && c.particleSystems.every(({ system: w }) => w.activeParticles === 0 && !w.emitting);
|
|
5958
|
+
(p && p.justLooped || m && Wt) && c.respawnAllSystems(), Wt = !m;
|
|
5958
5959
|
}
|
|
5959
|
-
for (const { system: m, config:
|
|
5960
|
-
|
|
5960
|
+
for (const { system: m, config: w } of c.particleSystems)
|
|
5961
|
+
w.glbModelEnabled && m.glbAnimator && (m.glbAnimator.update(u), m.updateAnimatedGLBBuffer());
|
|
5961
5962
|
r.queue.writeBuffer(v, 0, V.mvp), mt[0] = V.position[0], mt[1] = V.position[1], mt[2] = V.position[2], mt[3] = a.height / Math.max(1, a.width), mt[4] = Ve, r.queue.writeBuffer(v, 64, mt), ds();
|
|
5962
|
-
const
|
|
5963
|
+
const h = r.createCommandEncoder();
|
|
5963
5964
|
let g = !1;
|
|
5964
5965
|
if (e)
|
|
5965
5966
|
try {
|
|
5966
5967
|
const m = e();
|
|
5967
5968
|
if (m) {
|
|
5968
|
-
let
|
|
5969
|
-
if (m instanceof GPUTexture ? m.width === a.width && m.height === a.height && (
|
|
5970
|
-
const { pipeline: X, layout: O } = S(
|
|
5971
|
-
(yt.key !==
|
|
5969
|
+
let w = null, E = null, N = !1;
|
|
5970
|
+
if (m instanceof GPUTexture ? m.width === a.width && m.height === a.height && (w = m, E = () => m.createView({ aspect: "depth-only" }), N = m.sampleCount > 1) : m.view && (w = m.view, E = () => m.view, N = !!m.multisampled), w) {
|
|
5971
|
+
const { pipeline: X, layout: O } = S(N);
|
|
5972
|
+
(yt.key !== w || yt.ms !== N) && (yt.key = w, yt.ms = N, yt.bindGroup = r.createBindGroup({
|
|
5972
5973
|
layout: O,
|
|
5973
5974
|
entries: [{ binding: 0, resource: E() }]
|
|
5974
5975
|
}));
|
|
5975
|
-
const U =
|
|
5976
|
+
const U = h.beginRenderPass({
|
|
5976
5977
|
colorAttachments: [],
|
|
5977
5978
|
depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5978
5979
|
});
|
|
@@ -5981,90 +5982,90 @@ async function Jr(s, t = {}) {
|
|
|
5981
5982
|
}
|
|
5982
5983
|
} catch {
|
|
5983
5984
|
}
|
|
5984
|
-
const
|
|
5985
|
+
const P = h.beginRenderPass({
|
|
5985
5986
|
colorAttachments: [{ view: ht, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5986
5987
|
depthStencilAttachment: g ? { view: Pt, depthLoadOp: "load", depthStoreOp: "store" } : { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5987
5988
|
});
|
|
5988
|
-
for (const { system: m, config:
|
|
5989
|
-
|
|
5990
|
-
vt > 0 && (
|
|
5991
|
-
const
|
|
5992
|
-
for (const { system: m, config:
|
|
5993
|
-
if (!
|
|
5994
|
-
const E =
|
|
5995
|
-
X ? X.membres.push({ system: m, config:
|
|
5989
|
+
for (const { system: m, config: w } of c.particleSystems)
|
|
5990
|
+
w.bloomEnabled || w.hidden || m.activeParticles === 0 && !at.has(w.id) || (Bi(P, m, w), Ri(P, m, w));
|
|
5991
|
+
vt > 0 && (P.setPipeline(bs), P.setBindGroup(0, Ss), P.setVertexBuffer(0, qt), P.draw(vt)), P.end();
|
|
5992
|
+
const _ = /* @__PURE__ */ new Map();
|
|
5993
|
+
for (const { system: m, config: w } of c.particleSystems) {
|
|
5994
|
+
if (!w.bloomEnabled || w.hidden || m.activeParticles === 0 && !at.has(w.id)) continue;
|
|
5995
|
+
const E = w.bloomColor || [1, 1, 1], N = `b${w.bloomIntensity ?? 1}|${E[0]}|${E[1]}|${E[2]}`, X = _.get(N);
|
|
5996
|
+
X ? X.membres.push({ system: m, config: w }) : _.set(N, { membres: [{ system: m, config: w }], premier: m });
|
|
5996
5997
|
}
|
|
5997
|
-
if (
|
|
5998
|
+
if (_.size > 0) {
|
|
5998
5999
|
const m = {
|
|
5999
6000
|
colorAttachments: [{ view: Si, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6000
|
-
},
|
|
6001
|
+
}, w = {
|
|
6001
6002
|
colorAttachments: [{ view: Dt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6002
6003
|
};
|
|
6003
|
-
for (const [E,
|
|
6004
|
-
const X = b.getBloomSourceTexture(E, a.width, a.height), O =
|
|
6004
|
+
for (const [E, N] of _) {
|
|
6005
|
+
const X = b.getBloomSourceTexture(E, a.width, a.height), O = h.beginRenderPass({
|
|
6005
6006
|
colorAttachments: [{ view: X.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
6006
6007
|
depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
|
|
6007
6008
|
});
|
|
6008
|
-
for (const { system:
|
|
6009
|
-
|
|
6010
|
-
O.end(), vi[0] =
|
|
6009
|
+
for (const { system: Oe, config: fe } of N.membres)
|
|
6010
|
+
Bi(O, Oe, fe), Ri(O, Oe, fe);
|
|
6011
|
+
O.end(), vi[0] = N.membres[0].config.bloomIntensity, r.queue.writeBuffer(M, 0, vi), f.systemBloomHorizontalBindGroups[E] || (f.systemBloomHorizontalBindGroups[E] = r.createBindGroup({
|
|
6011
6012
|
layout: Ne.bloomBindGroupLayout,
|
|
6012
6013
|
entries: [
|
|
6013
|
-
{ binding: 0, resource:
|
|
6014
|
+
{ binding: 0, resource: Fe },
|
|
6014
6015
|
{ binding: 1, resource: X.createView() },
|
|
6015
6016
|
{ binding: 2, resource: { buffer: z } }
|
|
6016
6017
|
]
|
|
6017
6018
|
}));
|
|
6018
|
-
let U =
|
|
6019
|
-
U.setPipeline(It), U.setBindGroup(0,
|
|
6019
|
+
let U = h.beginRenderPass(m);
|
|
6020
|
+
U.setPipeline(It), U.setBindGroup(0, f.systemBloomHorizontalBindGroups[E]), U.draw(3), U.end(), U = h.beginRenderPass(w), U.setPipeline(It), U.setBindGroup(0, Gt.verticalBlurBindGroup), U.draw(3), U.end(), f.secondHorizontalBindGroups[E] || (f.secondHorizontalBindGroups[E] = r.createBindGroup({
|
|
6020
6021
|
layout: Ne.bloomBindGroupLayout,
|
|
6021
6022
|
entries: [
|
|
6022
|
-
{ binding: 0, resource:
|
|
6023
|
+
{ binding: 0, resource: Fe },
|
|
6023
6024
|
{ binding: 1, resource: Dt },
|
|
6024
6025
|
{ binding: 2, resource: { buffer: z } }
|
|
6025
6026
|
]
|
|
6026
|
-
})), U =
|
|
6027
|
-
const
|
|
6028
|
-
U =
|
|
6029
|
-
colorAttachments: [{ view:
|
|
6030
|
-
}), U.setPipeline(ms),
|
|
6027
|
+
})), U = h.beginRenderPass(m), U.setPipeline(It), U.setBindGroup(0, f.secondHorizontalBindGroups[E]), U.draw(3), U.end(), U = h.beginRenderPass(w), U.setPipeline(It), U.setBindGroup(0, Gt.verticalBlurBindGroup), U.draw(3), U.end();
|
|
6028
|
+
const ye = `${E}#${N.premier.config.id}`, xe = b.getBloomCompositeTexture(E, a.width, a.height);
|
|
6029
|
+
U = h.beginRenderPass({
|
|
6030
|
+
colorAttachments: [{ view: xe.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6031
|
+
}), U.setPipeline(ms), f.systemBloomCompositeBindGroups[ye] || (f.systemBloomCompositeBindGroups[ye] = r.createBindGroup({
|
|
6031
6032
|
layout: Ne.compositeBindGroupLayout,
|
|
6032
6033
|
entries: [
|
|
6033
|
-
{ binding: 0, resource:
|
|
6034
|
+
{ binding: 0, resource: Fe },
|
|
6034
6035
|
{ binding: 1, resource: X.createView() },
|
|
6035
6036
|
{ binding: 2, resource: Dt },
|
|
6036
6037
|
// ⚠️ L'uniforme du PREMIER membre : la clé de groupe garantit que tous portent la même
|
|
6037
6038
|
// intensité et la même couleur, donc n'importe lequel convient — mais il en faut un VRAI,
|
|
6038
6039
|
// écrit par `particleSystem`, pas le tampon partagé qui ne porte que l'intensité.
|
|
6039
|
-
{ binding: 3, resource: { buffer:
|
|
6040
|
+
{ binding: 3, resource: { buffer: N.premier.bloomIntensityBuffer } }
|
|
6040
6041
|
]
|
|
6041
|
-
})), U.setBindGroup(0,
|
|
6042
|
+
})), U.setBindGroup(0, f.systemBloomCompositeBindGroups[ye]), U.draw(3), U.end();
|
|
6042
6043
|
}
|
|
6043
6044
|
}
|
|
6044
|
-
const
|
|
6045
|
-
colorAttachments: [{ view:
|
|
6045
|
+
const B = b.getCombinedTexture(a.width, a.height), x = h.beginRenderPass({
|
|
6046
|
+
colorAttachments: [{ view: B.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6046
6047
|
});
|
|
6047
|
-
x.setPipeline(di),
|
|
6048
|
+
x.setPipeline(di), f.combinedInitialBindGroup || (f.combinedInitialBindGroup = r.createBindGroup({
|
|
6048
6049
|
layout: Ne.compositeBindGroupLayout,
|
|
6049
6050
|
entries: [
|
|
6050
|
-
{ binding: 0, resource:
|
|
6051
|
+
{ binding: 0, resource: Fe },
|
|
6051
6052
|
{ binding: 1, resource: ht },
|
|
6052
6053
|
{ binding: 2, resource: ht },
|
|
6053
|
-
{ binding: 3, resource: { buffer:
|
|
6054
|
+
{ binding: 3, resource: { buffer: M } }
|
|
6054
6055
|
]
|
|
6055
|
-
})), x.setBindGroup(0,
|
|
6056
|
-
for (const m of
|
|
6057
|
-
x.setPipeline(di),
|
|
6056
|
+
})), x.setBindGroup(0, f.combinedInitialBindGroup), x.draw(3);
|
|
6057
|
+
for (const m of _.keys())
|
|
6058
|
+
x.setPipeline(di), f.combinedBloomCompositeBindGroups[m] || (f.combinedBloomCompositeBindGroups[m] = r.createBindGroup({
|
|
6058
6059
|
layout: Ne.compositeBindGroupLayout,
|
|
6059
6060
|
entries: [
|
|
6060
|
-
{ binding: 0, resource:
|
|
6061
|
+
{ binding: 0, resource: Fe },
|
|
6061
6062
|
{ binding: 1, resource: b.getBloomCompositeTexture(m, a.width, a.height).createView() },
|
|
6062
6063
|
{ binding: 2, resource: ht },
|
|
6063
|
-
{ binding: 3, resource: { buffer:
|
|
6064
|
+
{ binding: 3, resource: { buffer: M } }
|
|
6064
6065
|
]
|
|
6065
|
-
})), x.setBindGroup(0,
|
|
6066
|
+
})), x.setBindGroup(0, f.combinedBloomCompositeBindGroups[m]), x.draw(3);
|
|
6066
6067
|
x.end();
|
|
6067
|
-
const
|
|
6068
|
+
const R = h.beginRenderPass({
|
|
6068
6069
|
colorAttachments: [{
|
|
6069
6070
|
view: n.getCurrentTexture().createView(),
|
|
6070
6071
|
loadOp: o ? "load" : "clear",
|
|
@@ -6072,47 +6073,47 @@ async function Jr(s, t = {}) {
|
|
|
6072
6073
|
clearValue: { r: 0, g: 0, b: 0, a: 0 }
|
|
6073
6074
|
}]
|
|
6074
6075
|
});
|
|
6075
|
-
|
|
6076
|
+
R.setPipeline(ys), f.finalBindGroup || (f.finalBindGroup = r.createBindGroup({
|
|
6076
6077
|
layout: Ne.compositeBindGroupLayout,
|
|
6077
6078
|
entries: [
|
|
6078
|
-
{ binding: 0, resource:
|
|
6079
|
-
{ binding: 1, resource:
|
|
6079
|
+
{ binding: 0, resource: Fe },
|
|
6080
|
+
{ binding: 1, resource: B.createView() },
|
|
6080
6081
|
{ binding: 2, resource: ht },
|
|
6081
|
-
{ binding: 3, resource: { buffer:
|
|
6082
|
+
{ binding: 3, resource: { buffer: M } }
|
|
6082
6083
|
]
|
|
6083
|
-
})),
|
|
6084
|
+
})), R.setBindGroup(0, f.finalBindGroup), R.draw(3), R.end(), r.queue.submit([h.finish()]);
|
|
6084
6085
|
}
|
|
6085
|
-
function wi(u,
|
|
6086
|
-
const y = u.config.id,
|
|
6087
|
-
return
|
|
6086
|
+
function wi(u, p) {
|
|
6087
|
+
const y = u.config.id, h = !f.systemBindGroups[y] || f.textureStates[y] !== p.textureEnabled || f.textureRefs[y] !== u.particleTexture;
|
|
6088
|
+
return f.textureStates[y] = p.textureEnabled, f.textureRefs[y] = u.particleTexture, h && (f.systemBindGroups[y] = r.createBindGroup({
|
|
6088
6089
|
layout: Ne.particleBindGroupLayout,
|
|
6089
6090
|
entries: [
|
|
6090
6091
|
{ binding: 0, resource: { buffer: v } },
|
|
6091
6092
|
{ binding: 1, resource: { buffer: u.appearanceUniformBuffer } },
|
|
6092
6093
|
{ binding: 2, resource: u.particleTexture.createView() },
|
|
6093
|
-
{ binding: 3, resource:
|
|
6094
|
+
{ binding: 3, resource: Fe }
|
|
6094
6095
|
]
|
|
6095
|
-
})),
|
|
6096
|
+
})), f.systemBindGroups[y];
|
|
6096
6097
|
}
|
|
6097
|
-
function
|
|
6098
|
-
const
|
|
6098
|
+
function Bi(u, p, y) {
|
|
6099
|
+
const h = p.config.id, g = y.glbModelEnabled && p.glbMeshData, P = wi(p, y), _ = y.shapeDisplay !== !1;
|
|
6099
6100
|
if (g)
|
|
6100
|
-
|
|
6101
|
+
_ && (u.setPipeline(gs), u.setBindGroup(0, P), u.setVertexBuffer(0, p.glbVertexBuffer), u.setVertexBuffer(1, p.instanceBuffer), u.setVertexBuffer(2, p.velocityBuffer), u.setIndexBuffer(p.glbIndexBuffer, p.glbIndexFormat), u.drawIndexed(p.glbIndexCount, p.activeParticles));
|
|
6101
6102
|
else {
|
|
6102
|
-
u.setPipeline(y.blendMode === "additive" ? ps : fs), u.setIndexBuffer(Z, "uint16"), T[
|
|
6103
|
-
const
|
|
6104
|
-
|
|
6103
|
+
u.setPipeline(y.blendMode === "additive" ? ps : fs), u.setIndexBuffer(Z, "uint16"), T[h] || (T[h] = G()), u.setVertexBuffer(0, T[h]), u.setBindGroup(0, P), _ && (u.setVertexBuffer(1, p.instanceBuffer), u.setVertexBuffer(2, p.velocityBuffer), u.setVertexBuffer(3, p.trailBuffer), u.drawIndexed(6, p.activeParticles));
|
|
6104
|
+
const B = xt.get(h);
|
|
6105
|
+
B && (u.setVertexBuffer(1, re), u.setVertexBuffer(2, q), u.setVertexBuffer(3, tt), u.drawIndexed(6, B.count, 0, 0, B.first)), _ && y.depthWriteEnabled && (u.setPipeline(hs), u.drawIndexed(6, p.activeParticles));
|
|
6105
6106
|
}
|
|
6106
6107
|
}
|
|
6107
|
-
function
|
|
6108
|
-
const
|
|
6109
|
-
!
|
|
6108
|
+
function Ri(u, p, y) {
|
|
6109
|
+
const h = at.get(y.id);
|
|
6110
|
+
!h || h.count <= 0 || (u.setPipeline(y.blendMode === "additive" ? vs : xs), u.setBindGroup(0, wi(p, y)), u.setVertexBuffer(0, Ht), u.draw(h.count, 1, h.first, 0));
|
|
6110
6111
|
}
|
|
6111
6112
|
function Is() {
|
|
6112
6113
|
$t = a.width, Jt = a.height, Mi();
|
|
6113
6114
|
}
|
|
6114
6115
|
function zs() {
|
|
6115
|
-
|
|
6116
|
+
f.clear();
|
|
6116
6117
|
}
|
|
6117
6118
|
function Ds() {
|
|
6118
6119
|
_i = !0, c.destroy(), [ot, lt, ct, zt].forEach((u) => u == null ? void 0 : u.destroy()), b.resizeTextures(), [
|
|
@@ -6120,56 +6121,61 @@ async function Jr(s, t = {}) {
|
|
|
6120
6121
|
C,
|
|
6121
6122
|
z,
|
|
6122
6123
|
D,
|
|
6123
|
-
|
|
6124
|
+
M,
|
|
6124
6125
|
Z,
|
|
6125
6126
|
re,
|
|
6126
|
-
|
|
6127
|
+
q,
|
|
6127
6128
|
tt,
|
|
6128
6129
|
qt,
|
|
6129
6130
|
Ht
|
|
6130
6131
|
].forEach((u) => u == null ? void 0 : u.destroy()), Object.values(T).forEach((u) => u == null ? void 0 : u.destroy());
|
|
6131
6132
|
}
|
|
6132
|
-
async function Ti(u,
|
|
6133
|
-
const y = await c.addSystems(u,
|
|
6134
|
-
for (const { config:
|
|
6135
|
-
T[
|
|
6133
|
+
async function Ti(u, p) {
|
|
6134
|
+
const y = await c.addSystems(u, p);
|
|
6135
|
+
for (const { config: h } of c.particleSystems)
|
|
6136
|
+
T[h.id] || (T[h.id] = G());
|
|
6136
6137
|
return c.respawnAllSystems(), new Set(Array.isArray(y) ? y : []);
|
|
6137
6138
|
}
|
|
6138
6139
|
function Ei(u) {
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6140
|
+
var p;
|
|
6141
|
+
for (const y of u) {
|
|
6142
|
+
const h = c.particleSystems.findIndex((P) => P.config.id === y);
|
|
6143
|
+
if (h < 0) continue;
|
|
6144
|
+
c.removeSystem(h), (p = T[y]) == null || p.destroy(), delete T[y], delete f.systemBindGroups[y], delete f.textureStates[y], delete f.textureRefs[y];
|
|
6145
|
+
const g = `#${y}`;
|
|
6146
|
+
for (const P in f.systemBloomCompositeBindGroups)
|
|
6147
|
+
P.endsWith(g) && delete f.systemBloomCompositeBindGroups[P];
|
|
6142
6148
|
}
|
|
6143
6149
|
}
|
|
6144
|
-
async function
|
|
6145
|
-
const y = await Ti(u,
|
|
6150
|
+
async function Gs(u, p = [0, 0, 0]) {
|
|
6151
|
+
const y = await Ti(u, p);
|
|
6146
6152
|
return { remove() {
|
|
6147
6153
|
Ei(y);
|
|
6148
6154
|
} };
|
|
6149
6155
|
}
|
|
6150
|
-
async function
|
|
6156
|
+
async function Fs(u, p = {}) {
|
|
6151
6157
|
const y = await Ti(u, [0, 0, 0]);
|
|
6152
6158
|
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...y]}]`);
|
|
6153
|
-
const
|
|
6154
|
-
return _e.push(
|
|
6159
|
+
const h = { ids: y, pos: null, hist: [], getPosition: p.getPosition || null, orientToDirection: !!p.orientToDirection, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
|
|
6160
|
+
return _e.push(h), {
|
|
6155
6161
|
setPosition(g) {
|
|
6156
|
-
g && (
|
|
6162
|
+
g && (h.pos = Array.isArray(g) ? [g[0], g[1], g[2]] : [g.x, g.y, g.z]);
|
|
6157
6163
|
},
|
|
6158
6164
|
setOrientToDirection(g) {
|
|
6159
|
-
|
|
6165
|
+
h.orientToDirection = !!g;
|
|
6160
6166
|
},
|
|
6161
6167
|
remove() {
|
|
6162
6168
|
Ei(y);
|
|
6163
|
-
const g = _e.indexOf(
|
|
6169
|
+
const g = _e.indexOf(h);
|
|
6164
6170
|
g >= 0 && _e.splice(g, 1);
|
|
6165
6171
|
}
|
|
6166
6172
|
};
|
|
6167
6173
|
}
|
|
6168
|
-
function Vs(u,
|
|
6169
|
-
const
|
|
6170
|
-
return _e.push(
|
|
6174
|
+
function Vs(u, p) {
|
|
6175
|
+
const h = { ids: u instanceof Set ? u : new Set(u), pos: null, hist: [], getPosition: p, historyOnly: !0, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
|
|
6176
|
+
return _e.push(h), {
|
|
6171
6177
|
remove() {
|
|
6172
|
-
const g = _e.indexOf(
|
|
6178
|
+
const g = _e.indexOf(h);
|
|
6173
6179
|
g >= 0 && _e.splice(g, 1);
|
|
6174
6180
|
},
|
|
6175
6181
|
// Update which systems this history group covers WITHOUT losing the accumulated path
|
|
@@ -6177,7 +6183,7 @@ async function Jr(s, t = {}) {
|
|
|
6177
6183
|
// group is active — otherwise a newly-added system's id isn't in the set and its trail
|
|
6178
6184
|
// can't follow the recorded movement path (it falls back to straight extrapolation).
|
|
6179
6185
|
setIds(g) {
|
|
6180
|
-
|
|
6186
|
+
h.ids = g instanceof Set ? g : new Set(g);
|
|
6181
6187
|
}
|
|
6182
6188
|
};
|
|
6183
6189
|
}
|
|
@@ -6189,8 +6195,8 @@ async function Jr(s, t = {}) {
|
|
|
6189
6195
|
setCameraMVP: As,
|
|
6190
6196
|
setEmitters: Kt,
|
|
6191
6197
|
loadPreset: Cs,
|
|
6192
|
-
addEmitter:
|
|
6193
|
-
addMovingEmitter:
|
|
6198
|
+
addEmitter: Gs,
|
|
6199
|
+
addMovingEmitter: Fs,
|
|
6194
6200
|
render: Us,
|
|
6195
6201
|
resize: Is,
|
|
6196
6202
|
clearCaches: zs,
|
|
@@ -6212,11 +6218,11 @@ function Kr(s) {
|
|
|
6212
6218
|
(n = C == null ? void 0 : C.depthBuffer) == null ? void 0 : n.texture,
|
|
6213
6219
|
z ? (a = c.get(z)) == null ? void 0 : a.texture : null
|
|
6214
6220
|
];
|
|
6215
|
-
for (const
|
|
6216
|
-
if (
|
|
6221
|
+
for (const M of D)
|
|
6222
|
+
if (M && typeof M.createView == "function" && M.width === d && M.height === S) return M;
|
|
6217
6223
|
return null;
|
|
6218
6224
|
}
|
|
6219
|
-
const
|
|
6225
|
+
const f = s.getCanvasTarget ? c.get(s.getCanvasTarget()) : null, v = ((l = (o = f == null ? void 0 : f.descriptor) == null ? void 0 : o.depthStencilAttachment) == null ? void 0 : l.view) ?? null;
|
|
6220
6226
|
return v ? { view: v, multisampled: (s.currentSamples ?? 0) > 1 } : null;
|
|
6221
6227
|
} catch {
|
|
6222
6228
|
return null;
|
|
@@ -6229,9 +6235,9 @@ export {
|
|
|
6229
6235
|
Nr as Objects3DManager,
|
|
6230
6236
|
qs as ParticleEmitter,
|
|
6231
6237
|
er as ParticlePhysics,
|
|
6232
|
-
|
|
6238
|
+
Gi as ParticleScript,
|
|
6233
6239
|
ii as ParticleSystem,
|
|
6234
|
-
|
|
6240
|
+
Rr as ParticleSystemManager,
|
|
6235
6241
|
tr as ParticleTextureManager,
|
|
6236
6242
|
Zs as blurShader,
|
|
6237
6243
|
Ws as compositeShader,
|
|
@@ -6256,7 +6262,7 @@ export {
|
|
|
6256
6262
|
is as isHZFX,
|
|
6257
6263
|
Wr as loadScene,
|
|
6258
6264
|
Kr as makeThreeSceneDepth,
|
|
6259
|
-
|
|
6265
|
+
Fr as multiplyMatrices,
|
|
6260
6266
|
Er as object3dShader,
|
|
6261
6267
|
Or as packHZFX,
|
|
6262
6268
|
or as parseGLB,
|