hz-particles 1.5.2 → 1.5.3
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 +484 -479
- 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,
|
|
@@ -2922,7 +2922,7 @@ class ii {
|
|
|
2922
2922
|
this.physics.setSoftBoundary(t);
|
|
2923
2923
|
}
|
|
2924
2924
|
}
|
|
2925
|
-
class
|
|
2925
|
+
class Rr {
|
|
2926
2926
|
constructor(t) {
|
|
2927
2927
|
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
2928
|
}
|
|
@@ -3667,7 +3667,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
3667
3667
|
bindGroupLayouts: [o]
|
|
3668
3668
|
}), b = s.createPipelineLayout({
|
|
3669
3669
|
bindGroupLayouts: [l]
|
|
3670
|
-
}),
|
|
3670
|
+
}), f = s.createShaderModule({
|
|
3671
3671
|
code: Hs
|
|
3672
3672
|
}), v = s.createShaderModule({
|
|
3673
3673
|
code: Zs
|
|
@@ -3677,12 +3677,12 @@ function Ur(s, t, e, i = {}) {
|
|
|
3677
3677
|
code: $s
|
|
3678
3678
|
}), D = s.createShaderModule({
|
|
3679
3679
|
code: Er
|
|
3680
|
-
}),
|
|
3680
|
+
}), M = s.createShaderModule({
|
|
3681
3681
|
code: Ar
|
|
3682
3682
|
}), Z = (kt) => s.createRenderPipeline({
|
|
3683
3683
|
layout: d,
|
|
3684
3684
|
vertex: {
|
|
3685
|
-
module:
|
|
3685
|
+
module: f,
|
|
3686
3686
|
entryPoint: "vs_main",
|
|
3687
3687
|
buffers: [
|
|
3688
3688
|
{
|
|
@@ -3743,7 +3743,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
3743
3743
|
]
|
|
3744
3744
|
},
|
|
3745
3745
|
fragment: {
|
|
3746
|
-
module:
|
|
3746
|
+
module: f,
|
|
3747
3747
|
entryPoint: "fs_main",
|
|
3748
3748
|
targets: [{
|
|
3749
3749
|
format: Xe,
|
|
@@ -3770,7 +3770,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
3770
3770
|
dstFactor: "one-minus-src-alpha",
|
|
3771
3771
|
operation: "add"
|
|
3772
3772
|
}
|
|
3773
|
-
}),
|
|
3773
|
+
}), G = Z({
|
|
3774
3774
|
color: {
|
|
3775
3775
|
srcFactor: "src-alpha",
|
|
3776
3776
|
dstFactor: "one",
|
|
@@ -3781,10 +3781,10 @@ function Ur(s, t, e, i = {}) {
|
|
|
3781
3781
|
dstFactor: "one-minus-src-alpha",
|
|
3782
3782
|
operation: "add"
|
|
3783
3783
|
}
|
|
3784
|
-
}),
|
|
3784
|
+
}), F = s.createRenderPipeline({
|
|
3785
3785
|
layout: d,
|
|
3786
3786
|
vertex: {
|
|
3787
|
-
module:
|
|
3787
|
+
module: f,
|
|
3788
3788
|
entryPoint: "vs_main",
|
|
3789
3789
|
buffers: [
|
|
3790
3790
|
{
|
|
@@ -3845,7 +3845,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
3845
3845
|
]
|
|
3846
3846
|
},
|
|
3847
3847
|
fragment: {
|
|
3848
|
-
module:
|
|
3848
|
+
module: f,
|
|
3849
3849
|
entryPoint: "fs_main",
|
|
3850
3850
|
targets: [{
|
|
3851
3851
|
format: Xe,
|
|
@@ -3935,7 +3935,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
3935
3935
|
primitive: {
|
|
3936
3936
|
topology: "triangle-list"
|
|
3937
3937
|
}
|
|
3938
|
-
}), re = s.createShaderModule({ code: Js }),
|
|
3938
|
+
}), re = s.createShaderModule({ code: Js }), q = s.createRenderPipeline({
|
|
3939
3939
|
layout: b,
|
|
3940
3940
|
vertex: { module: re, entryPoint: "vs_main" },
|
|
3941
3941
|
fragment: {
|
|
@@ -4010,7 +4010,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
4010
4010
|
}), at = s.createRenderPipeline({
|
|
4011
4011
|
layout: d,
|
|
4012
4012
|
vertex: {
|
|
4013
|
-
module:
|
|
4013
|
+
module: M,
|
|
4014
4014
|
entryPoint: "vs_main",
|
|
4015
4015
|
buffers: [
|
|
4016
4016
|
{
|
|
@@ -4082,7 +4082,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
4082
4082
|
]
|
|
4083
4083
|
},
|
|
4084
4084
|
fragment: {
|
|
4085
|
-
module:
|
|
4085
|
+
module: M,
|
|
4086
4086
|
entryPoint: "fs_main",
|
|
4087
4087
|
targets: [{
|
|
4088
4088
|
format: Xe,
|
|
@@ -4112,12 +4112,12 @@ function Ur(s, t, e, i = {}) {
|
|
|
4112
4112
|
});
|
|
4113
4113
|
return {
|
|
4114
4114
|
particlePipeline: T,
|
|
4115
|
-
particleAdditivePipeline:
|
|
4116
|
-
particleDepthWritePipeline:
|
|
4115
|
+
particleAdditivePipeline: G,
|
|
4116
|
+
particleDepthWritePipeline: F,
|
|
4117
4117
|
blurPipeline: H,
|
|
4118
4118
|
compositePipeline: se,
|
|
4119
4119
|
directRenderPipeline: ne,
|
|
4120
|
-
finalCompositePipeline:
|
|
4120
|
+
finalCompositePipeline: q,
|
|
4121
4121
|
object3dPipeline: xt,
|
|
4122
4122
|
glbMeshPipeline: at
|
|
4123
4123
|
};
|
|
@@ -4158,7 +4158,7 @@ function si(s, t, e, i) {
|
|
|
4158
4158
|
resource: { buffer: n }
|
|
4159
4159
|
}
|
|
4160
4160
|
]
|
|
4161
|
-
}),
|
|
4161
|
+
}), f = s.createBindGroup({
|
|
4162
4162
|
layout: s.createBindGroupLayout({
|
|
4163
4163
|
entries: [
|
|
4164
4164
|
{
|
|
@@ -4315,7 +4315,7 @@ function si(s, t, e, i) {
|
|
|
4315
4315
|
});
|
|
4316
4316
|
return {
|
|
4317
4317
|
particleBindGroup: b,
|
|
4318
|
-
horizontalBlurBindGroup:
|
|
4318
|
+
horizontalBlurBindGroup: f,
|
|
4319
4319
|
verticalBlurBindGroup: v,
|
|
4320
4320
|
compositeBindGroup: C,
|
|
4321
4321
|
directRenderBindGroup: z
|
|
@@ -4534,8 +4534,8 @@ function Dr(s = 16, t = 16) {
|
|
|
4534
4534
|
for (let r = 0; r <= s; r++) {
|
|
4535
4535
|
const n = r * Math.PI / s, a = Math.sin(n), o = Math.cos(n);
|
|
4536
4536
|
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,
|
|
4537
|
+
const c = l * 2 * Math.PI / t, d = Math.sin(c), b = Math.cos(c) * a, f = o, v = d * a;
|
|
4538
|
+
e.push(b * 0.5, f * 0.5, v * 0.5), e.push(b, f, v);
|
|
4539
4539
|
}
|
|
4540
4540
|
}
|
|
4541
4541
|
for (let r = 0; r < s; r++)
|
|
@@ -4548,7 +4548,7 @@ function Dr(s = 16, t = 16) {
|
|
|
4548
4548
|
indices: new Uint16Array(i)
|
|
4549
4549
|
};
|
|
4550
4550
|
}
|
|
4551
|
-
class
|
|
4551
|
+
class Gr {
|
|
4552
4552
|
constructor(t, e, i, r, n) {
|
|
4553
4553
|
this.id = t, this.type = e, this.position = i, this.scale = r, this.color = n, this.rotation = [0, 0, 0];
|
|
4554
4554
|
}
|
|
@@ -4718,7 +4718,7 @@ class Nr {
|
|
|
4718
4718
|
* @returns {Object3D} The created object
|
|
4719
4719
|
*/
|
|
4720
4720
|
addObject(t, e = [0, 0, 0], i = [1, 1, 1], r = [1, 1, 1, 1]) {
|
|
4721
|
-
const n = new
|
|
4721
|
+
const n = new Gr(this.nextId++, t, e, i, r);
|
|
4722
4722
|
return n.uniformBuffer = this.device.createBuffer({
|
|
4723
4723
|
size: 192,
|
|
4724
4724
|
// modelMatrix (64) + normalMatrix (64) + color (16) + padding (48)
|
|
@@ -4876,7 +4876,7 @@ function qi(s, t) {
|
|
|
4876
4876
|
function ri(s, t) {
|
|
4877
4877
|
return s[0] * t[0] + s[1] * t[1] + s[2] * t[2];
|
|
4878
4878
|
}
|
|
4879
|
-
function
|
|
4879
|
+
function Fr(s, t) {
|
|
4880
4880
|
const e = new Float32Array(16);
|
|
4881
4881
|
for (let i = 0; i < 4; i++)
|
|
4882
4882
|
for (let r = 0; r < 4; r++) {
|
|
@@ -4905,41 +4905,41 @@ function Zi(s) {
|
|
|
4905
4905
|
async function Or(s, t = {}) {
|
|
4906
4906
|
const { textureFormat: e = "keep", quality: i = 0.85 } = t, r = [], n = [];
|
|
4907
4907
|
let a = 0;
|
|
4908
|
-
const o = (
|
|
4909
|
-
const se = a, ne =
|
|
4910
|
-
r.push({ offset: se, length: ne, mime:
|
|
4908
|
+
const o = (G, F, H) => {
|
|
4909
|
+
const se = a, ne = G.length;
|
|
4910
|
+
r.push({ offset: se, length: ne, mime: F, kind: H }), n.push(G), a += ne;
|
|
4911
4911
|
const re = Zi(ne);
|
|
4912
4912
|
return re && (n.push(new Uint8Array(re)), a += re), r.length - 1;
|
|
4913
4913
|
}, 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(
|
|
4914
|
+
for (const G of s.systems || []) {
|
|
4915
|
+
const F = { ...G };
|
|
4916
|
+
if (typeof F.textureImageData == "string" && F.textureImageData.startsWith("data:")) {
|
|
4917
|
+
let { mime: H, bytes: se } = Vr(F.textureImageData);
|
|
4918
4918
|
if (l && H !== "image/webp")
|
|
4919
4919
|
try {
|
|
4920
4920
|
const ne = await createImageBitmap(new Blob([se], { type: H })), re = new OffscreenCanvas(ne.width, ne.height);
|
|
4921
4921
|
re.getContext("2d").drawImage(ne, 0, 0);
|
|
4922
|
-
const
|
|
4922
|
+
const q = await re.convertToBlob({ type: "image/webp", quality: i }), tt = new Uint8Array(await q.arrayBuffer());
|
|
4923
4923
|
tt.length < se.length && (se = tt, H = "image/webp");
|
|
4924
4924
|
} catch {
|
|
4925
4925
|
}
|
|
4926
|
-
|
|
4926
|
+
F.textureImageData = { [At]: o(se, H, "texture") };
|
|
4927
4927
|
}
|
|
4928
|
-
if (typeof
|
|
4929
|
-
const H = ts(
|
|
4930
|
-
|
|
4928
|
+
if (typeof F.glbModelData == "string" && F.glbModelData.length > 0) {
|
|
4929
|
+
const H = ts(F.glbModelData);
|
|
4930
|
+
F.glbModelData = { [At]: o(H, "model/gltf-binary", "glb") };
|
|
4931
4931
|
}
|
|
4932
|
-
c.push(
|
|
4932
|
+
c.push(F);
|
|
4933
4933
|
}
|
|
4934
|
-
const d = { ...s, systems: c, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)), b = Zi(S.length),
|
|
4934
|
+
const d = { ...s, systems: c, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)), b = Zi(S.length), f = new Uint8Array(a);
|
|
4935
4935
|
let v = 0;
|
|
4936
|
-
for (const
|
|
4937
|
-
|
|
4938
|
-
const C = S.length + b, z = 20 + C + 8 + a, D = new ArrayBuffer(z),
|
|
4936
|
+
for (const G of n)
|
|
4937
|
+
f.set(G, v), v += G.length;
|
|
4938
|
+
const C = S.length + b, z = 20 + C + 8 + a, D = new ArrayBuffer(z), M = new DataView(D), Z = new Uint8Array(D);
|
|
4939
4939
|
let T = 0;
|
|
4940
|
-
|
|
4941
|
-
for (let
|
|
4942
|
-
return
|
|
4940
|
+
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;
|
|
4941
|
+
for (let G = 0; G < b; G++) Z[T++] = 32;
|
|
4942
|
+
return M.setUint32(T, a, !0), T += 4, M.setUint32(T, es, !0), T += 4, Z.set(f, T), T += a, D;
|
|
4943
4943
|
}
|
|
4944
4944
|
function is(s) {
|
|
4945
4945
|
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === ai;
|
|
@@ -4954,24 +4954,24 @@ function ss(s) {
|
|
|
4954
4954
|
for (; i + 8 <= s.byteLength; ) {
|
|
4955
4955
|
const b = t.getUint32(i, !0);
|
|
4956
4956
|
i += 4;
|
|
4957
|
-
const
|
|
4958
|
-
i += 4,
|
|
4957
|
+
const f = t.getUint32(i, !0);
|
|
4958
|
+
i += 4, f === Qi ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + b))) : f === es && (n = i), i += b;
|
|
4959
4959
|
}
|
|
4960
4960
|
if (!r) throw new Error("[unpackHZFX] missing JSON chunk");
|
|
4961
4961
|
const o = r.assets || [], l = (b) => {
|
|
4962
|
-
const
|
|
4963
|
-
return !
|
|
4962
|
+
const f = o[b];
|
|
4963
|
+
return !f || n < 0 ? null : { ...f, bytes: a.subarray(n + f.offset, n + f.offset + f.length) };
|
|
4964
4964
|
}, 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
|
-
|
|
4965
|
+
const f = { ...b };
|
|
4966
|
+
if (c(f.textureImageData)) {
|
|
4967
|
+
const v = l(f.textureImageData[At]);
|
|
4968
|
+
f.textureImageData = v ? `data:${v.mime};base64,${Hi(v.bytes)}` : void 0;
|
|
4969
4969
|
}
|
|
4970
|
-
if (c(
|
|
4971
|
-
const v = l(
|
|
4972
|
-
|
|
4970
|
+
if (c(f.glbModelData)) {
|
|
4971
|
+
const v = l(f.glbModelData[At]);
|
|
4972
|
+
f.glbModelData = v ? Hi(v.bytes) : void 0;
|
|
4973
4973
|
}
|
|
4974
|
-
return
|
|
4974
|
+
return f;
|
|
4975
4975
|
}), S = { ...r, systems: d };
|
|
4976
4976
|
return delete S.assets, S;
|
|
4977
4977
|
}
|
|
@@ -5269,48 +5269,48 @@ async function Jr(s, t = {}) {
|
|
|
5269
5269
|
let r, n, a;
|
|
5270
5270
|
const o = !!(s && s.device && s.context);
|
|
5271
5271
|
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
|
|
5272
|
+
const l = navigator.gpu.getPreferredCanvasFormat(), c = t.manager || new Rr(r), d = { layouts: {}, pipelines: {} };
|
|
5273
5273
|
function S(u) {
|
|
5274
|
-
const
|
|
5275
|
-
if (!d.pipelines[
|
|
5276
|
-
const y = r.createShaderModule({ code: Xr(u) }),
|
|
5274
|
+
const p = u ? "ms" : "ss";
|
|
5275
|
+
if (!d.pipelines[p]) {
|
|
5276
|
+
const y = r.createShaderModule({ code: Xr(u) }), h = r.createBindGroupLayout({
|
|
5277
5277
|
entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: u } }]
|
|
5278
5278
|
});
|
|
5279
|
-
d.layouts[
|
|
5280
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5279
|
+
d.layouts[p] = h, d.pipelines[p] = r.createRenderPipeline({
|
|
5280
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [h] }),
|
|
5281
5281
|
vertex: { module: y, entryPoint: "vs" },
|
|
5282
5282
|
fragment: { module: y, entryPoint: "fs", targets: [] },
|
|
5283
5283
|
primitive: { topology: "triangle-list" },
|
|
5284
5284
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !0, depthCompare: "always" }
|
|
5285
5285
|
});
|
|
5286
5286
|
}
|
|
5287
|
-
return { pipeline: d.pipelines[
|
|
5287
|
+
return { pipeline: d.pipelines[p], layout: d.layouts[p] };
|
|
5288
5288
|
}
|
|
5289
5289
|
const b = {
|
|
5290
5290
|
bloomSourceTextures: {},
|
|
5291
5291
|
bloomCompositeTextures: {},
|
|
5292
5292
|
combinedTexture: null,
|
|
5293
|
-
getBloomSourceTexture(u,
|
|
5294
|
-
const
|
|
5295
|
-
return this.bloomSourceTextures[
|
|
5296
|
-
size: [
|
|
5293
|
+
getBloomSourceTexture(u, p, y) {
|
|
5294
|
+
const h = u;
|
|
5295
|
+
return this.bloomSourceTextures[h] || (this.bloomSourceTextures[h] = r.createTexture({
|
|
5296
|
+
size: [p, y],
|
|
5297
5297
|
format: "rgba16float",
|
|
5298
5298
|
// HDR chain (see webgpu.js HDR_FORMAT) — avoids additive clip
|
|
5299
5299
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5300
|
-
})), this.bloomSourceTextures[
|
|
5300
|
+
})), this.bloomSourceTextures[h];
|
|
5301
5301
|
},
|
|
5302
|
-
getBloomCompositeTexture(u,
|
|
5303
|
-
const
|
|
5304
|
-
return this.bloomCompositeTextures[
|
|
5305
|
-
size: [
|
|
5302
|
+
getBloomCompositeTexture(u, p, y) {
|
|
5303
|
+
const h = u;
|
|
5304
|
+
return this.bloomCompositeTextures[h] || (this.bloomCompositeTextures[h] = r.createTexture({
|
|
5305
|
+
size: [p, y],
|
|
5306
5306
|
format: "rgba16float",
|
|
5307
5307
|
// HDR chain
|
|
5308
5308
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5309
|
-
})), this.bloomCompositeTextures[
|
|
5309
|
+
})), this.bloomCompositeTextures[h];
|
|
5310
5310
|
},
|
|
5311
|
-
getCombinedTexture(u,
|
|
5311
|
+
getCombinedTexture(u, p) {
|
|
5312
5312
|
return this.combinedTexture || (this.combinedTexture = r.createTexture({
|
|
5313
|
-
size: [u,
|
|
5313
|
+
size: [u, p],
|
|
5314
5314
|
format: "rgba16float",
|
|
5315
5315
|
// HDR chain — tonemapped to canvas in the final pass
|
|
5316
5316
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
@@ -5319,7 +5319,7 @@ async function Jr(s, t = {}) {
|
|
|
5319
5319
|
resizeTextures() {
|
|
5320
5320
|
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
5321
|
}
|
|
5322
|
-
},
|
|
5322
|
+
}, f = {
|
|
5323
5323
|
systemBindGroups: {},
|
|
5324
5324
|
systemBloomHorizontalBindGroups: {},
|
|
5325
5325
|
secondHorizontalBindGroups: {},
|
|
@@ -5335,224 +5335,224 @@ async function Jr(s, t = {}) {
|
|
|
5335
5335
|
clear() {
|
|
5336
5336
|
this.systemBindGroups = {}, this.systemBloomHorizontalBindGroups = {}, this.secondHorizontalBindGroups = {}, this.systemBloomCompositeBindGroups = {}, this.combinedBloomCompositeBindGroups = {}, this.combinedInitialBindGroup = null, this.finalBindGroup = null, this.textureStates = {}, this.textureRefs = {};
|
|
5337
5337
|
}
|
|
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 }),
|
|
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 }), 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
5339
|
c.onSystemCreated = (u) => {
|
|
5340
|
-
T[u] || (T[u] =
|
|
5340
|
+
T[u] || (T[u] = G());
|
|
5341
5341
|
};
|
|
5342
|
-
const
|
|
5342
|
+
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
5343
|
function oi(u) {
|
|
5344
|
-
for (const
|
|
5344
|
+
for (const p of _e) if (p.ids.has(u)) return p;
|
|
5345
5345
|
return null;
|
|
5346
5346
|
}
|
|
5347
|
-
function rs(u,
|
|
5347
|
+
function rs(u, p) {
|
|
5348
5348
|
if (!u.pos) return;
|
|
5349
|
-
u.hist.push({ t:
|
|
5350
|
-
const y =
|
|
5349
|
+
u.hist.push({ t: p, x: u.pos[0], y: u.pos[1], z: u.pos[2] });
|
|
5350
|
+
const y = p - kt;
|
|
5351
5351
|
for (; u.hist.length > 2 && u.hist[0].t < y; ) u.hist.shift();
|
|
5352
5352
|
}
|
|
5353
|
-
function li(u,
|
|
5354
|
-
const
|
|
5355
|
-
if (
|
|
5356
|
-
const
|
|
5357
|
-
return
|
|
5353
|
+
function li(u, p, y) {
|
|
5354
|
+
const h = u.hist;
|
|
5355
|
+
if (h.length === 0) {
|
|
5356
|
+
const P = u.pos;
|
|
5357
|
+
return P && (y[0] = P[0], y[1] = P[1], y[2] = P[2]), y;
|
|
5358
5358
|
}
|
|
5359
5359
|
let g;
|
|
5360
|
-
if (
|
|
5361
|
-
return g =
|
|
5362
|
-
if (
|
|
5363
|
-
return g =
|
|
5364
|
-
for (let
|
|
5365
|
-
if (
|
|
5366
|
-
const
|
|
5367
|
-
return y[0] =
|
|
5360
|
+
if (p >= h[h.length - 1].t)
|
|
5361
|
+
return g = h[h.length - 1], y[0] = g.x, y[1] = g.y, y[2] = g.z, y;
|
|
5362
|
+
if (p <= h[0].t)
|
|
5363
|
+
return g = h[0], y[0] = g.x, y[1] = g.y, y[2] = g.z, y;
|
|
5364
|
+
for (let P = h.length - 1; P > 0; P--)
|
|
5365
|
+
if (h[P - 1].t <= p) {
|
|
5366
|
+
const _ = h[P - 1], B = h[P], x = (p - _.t) / Math.max(1e-6, B.t - _.t);
|
|
5367
|
+
return y[0] = _.x + (B.x - _.x) * x, y[1] = _.y + (B.y - _.y) * x, y[2] = _.z + (B.z - _.z) * x, y;
|
|
5368
5368
|
}
|
|
5369
|
-
return g =
|
|
5369
|
+
return g = h[0], y[0] = g.x, y[1] = g.y, y[2] = g.z, y;
|
|
5370
5370
|
}
|
|
5371
5371
|
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
5372
|
new Array(257), new Array(257), new Array(257);
|
|
5373
5373
|
const Ae = [0, 0, 0];
|
|
5374
5374
|
function ns(u) {
|
|
5375
|
-
const
|
|
5376
|
-
if (!
|
|
5377
|
-
const g =
|
|
5375
|
+
const p = u.emissionRotationX || 0, y = u.emissionRotationY || 0, h = u.emissionRotationZ || 0;
|
|
5376
|
+
if (!p && !y && !h) return null;
|
|
5377
|
+
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
5378
|
return [
|
|
5379
|
-
|
|
5380
|
-
x * m *
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
x * m * E +
|
|
5384
|
-
|
|
5379
|
+
R * w,
|
|
5380
|
+
x * m * w - B * E,
|
|
5381
|
+
B * m * w + x * E,
|
|
5382
|
+
R * E,
|
|
5383
|
+
x * m * E + B * w,
|
|
5384
|
+
B * m * E - x * w,
|
|
5385
5385
|
-m,
|
|
5386
|
-
x *
|
|
5387
|
-
|
|
5386
|
+
x * R,
|
|
5387
|
+
B * R
|
|
5388
5388
|
];
|
|
5389
5389
|
}
|
|
5390
|
-
function Ut(u,
|
|
5391
|
-
return g[0] = u[0] *
|
|
5390
|
+
function Ut(u, p, y, h, g) {
|
|
5391
|
+
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
5392
|
}
|
|
5393
|
-
function as(u,
|
|
5394
|
-
let
|
|
5395
|
-
|
|
5393
|
+
function as(u, p, y, h, g, P, _) {
|
|
5394
|
+
let B = u, x = p, R = y;
|
|
5395
|
+
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
5396
|
const m = g._simPosition;
|
|
5397
|
-
return
|
|
5397
|
+
return _[0] = B + (m ? m[0] : 0), _[1] = x + (m ? m[1] : 0), _[2] = R + (m ? m[2] : 0), _;
|
|
5398
5398
|
}
|
|
5399
|
-
function os(u,
|
|
5400
|
-
let
|
|
5401
|
-
return
|
|
5399
|
+
function os(u, p, y, h, g, P) {
|
|
5400
|
+
let _ = u, B = p, x = y;
|
|
5401
|
+
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
5402
|
}
|
|
5403
|
-
function jt(u,
|
|
5404
|
-
const
|
|
5405
|
-
let x = (u % 1 + 1) % 1 *
|
|
5406
|
-
return x <
|
|
5403
|
+
function jt(u, p, y, h, g) {
|
|
5404
|
+
const P = p * 2, _ = y * 2, B = 2 * (P + _);
|
|
5405
|
+
let x = (u % 1 + 1) % 1 * B, R = 0, m = 0;
|
|
5406
|
+
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
5407
|
}
|
|
5408
5408
|
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(
|
|
5409
|
+
const p = u.emissionShape, y = Math.max(1, Math.min(256, Math.floor(u.shapeStrokeSegments ?? 96)));
|
|
5410
|
+
let h = 0, g = !1, P = [0, 0, 1];
|
|
5411
|
+
const _ = Ae;
|
|
5412
|
+
if (p === "circle") {
|
|
5413
|
+
g = !0, h = Math.max(3, y), P = [0, 0, 1];
|
|
5414
|
+
const B = u.circleOuterRadius ?? 2;
|
|
5415
|
+
for (let x = 0; x < h; x++) {
|
|
5416
|
+
const R = x / h * pt;
|
|
5417
|
+
ae[x] = Math.cos(R) * B, oe[x] = Math.sin(R) * B, le[x] = 0;
|
|
5418
5418
|
}
|
|
5419
|
-
} else if (
|
|
5420
|
-
g = !0,
|
|
5421
|
-
const
|
|
5422
|
-
for (let x = 0; x <
|
|
5423
|
-
const
|
|
5424
|
-
ae[x] = Math.cos(
|
|
5419
|
+
} else if (p === "disc") {
|
|
5420
|
+
g = !0, h = Math.max(3, y), P = [0, 1, 0];
|
|
5421
|
+
const B = u.discRadius ?? 2;
|
|
5422
|
+
for (let x = 0; x < h; x++) {
|
|
5423
|
+
const R = x / h * pt;
|
|
5424
|
+
ae[x] = Math.cos(R) * B, oe[x] = 0, le[x] = Math.sin(R) * B;
|
|
5425
5425
|
}
|
|
5426
|
-
} else if (
|
|
5427
|
-
g = !0,
|
|
5428
|
-
const
|
|
5429
|
-
for (let m = 0; m <
|
|
5430
|
-
const
|
|
5431
|
-
ae[m] = Math.cos(
|
|
5426
|
+
} else if (p === "annulus") {
|
|
5427
|
+
g = !0, h = Math.max(3, y), P = [0, 1, 0];
|
|
5428
|
+
const B = u.annulusInnerRadius ?? 1, x = u.annulusOuterRadius ?? 2, R = B + (x - B) * 0.5;
|
|
5429
|
+
for (let m = 0; m < h; m++) {
|
|
5430
|
+
const w = m / h * pt;
|
|
5431
|
+
ae[m] = Math.cos(w) * R, oe[m] = 0, le[m] = Math.sin(w) * R;
|
|
5432
5432
|
}
|
|
5433
|
-
} else if (
|
|
5434
|
-
g = !1,
|
|
5435
|
-
const
|
|
5436
|
-
for (let E = 0; E <
|
|
5437
|
-
const
|
|
5438
|
-
ae[E] = Math.cos(X) *
|
|
5433
|
+
} else if (p === "arc") {
|
|
5434
|
+
g = !1, h = Math.max(2, y + 1), P = [0, 0, 1];
|
|
5435
|
+
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;
|
|
5436
|
+
for (let E = 0; E < h; E++) {
|
|
5437
|
+
const N = h > 1 ? E / (h - 1) : 0, X = m + (w - m) * N;
|
|
5438
|
+
ae[E] = Math.cos(X) * R, oe[E] = Math.sin(X) * R, le[E] = 0;
|
|
5439
5439
|
}
|
|
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] = (
|
|
5440
|
+
} else if (p === "square") {
|
|
5441
|
+
g = !0, h = Math.max(4, y), P = [0, 0, 1];
|
|
5442
|
+
const B = u.squareSize ?? 2;
|
|
5443
|
+
for (let x = 0; x < h; x++)
|
|
5444
|
+
jt(x / h, B, B, "xy", _), ae[x] = _[0], oe[x] = _[1], le[x] = _[2];
|
|
5445
|
+
} else if (p === "rectangle") {
|
|
5446
|
+
g = !0, h = Math.max(4, y), P = [0, 0, 1];
|
|
5447
|
+
const B = (u.rectangleWidth ?? 2) * 0.5, x = (u.rectangleHeight ?? 2) * 0.5;
|
|
5448
|
+
for (let R = 0; R < h; R++)
|
|
5449
|
+
jt(R / h, B, x, "xy", _), ae[R] = _[0], oe[R] = _[1], le[R] = _[2];
|
|
5450
|
+
} else if (p === "plain") {
|
|
5451
|
+
g = !0, h = Math.max(4, y), P = [0, 1, 0];
|
|
5452
|
+
const B = (u.planeWidth ?? 2) * 0.5, x = (u.planeDepth ?? 2) * 0.5;
|
|
5453
|
+
for (let R = 0; R < h; R++)
|
|
5454
|
+
jt(R / h, B, x, "xz", _), ae[R] = _[0], oe[R] = _[1], le[R] = _[2];
|
|
5455
|
+
} else if (p === "line") {
|
|
5456
|
+
g = !1, h = Math.max(2, y + 1), P = [0, 0, 1];
|
|
5457
|
+
const B = u.lineLength ?? 4;
|
|
5458
|
+
for (let x = 0; x < h; x++) {
|
|
5459
|
+
const R = h > 1 ? x / (h - 1) : 0;
|
|
5460
|
+
ae[x] = 0, oe[x] = (R - 0.5) * B, le[x] = 0;
|
|
5461
5461
|
}
|
|
5462
|
-
} else if (
|
|
5463
|
-
g = !0,
|
|
5464
|
-
const
|
|
5465
|
-
for (let
|
|
5466
|
-
const m =
|
|
5467
|
-
ae[
|
|
5462
|
+
} else if (p === "polygon") {
|
|
5463
|
+
g = !0, h = Math.max(3, y), P = [0, 0, 1];
|
|
5464
|
+
const B = Math.max(3, Math.floor(u.polygonSides ?? 6)), x = u.polygonRadius ?? 2;
|
|
5465
|
+
for (let R = 0; R < h; R++) {
|
|
5466
|
+
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;
|
|
5467
|
+
ae[R] = O + (ye - O) * E, oe[R] = U + (xe - U) * E, le[R] = 0;
|
|
5468
5468
|
}
|
|
5469
5469
|
} else
|
|
5470
|
-
|
|
5471
|
-
return { count:
|
|
5470
|
+
h = 0;
|
|
5471
|
+
return { count: h, closed: g, planeNormal: P };
|
|
5472
5472
|
}
|
|
5473
|
-
function cs(u,
|
|
5473
|
+
function cs(u, p, y) {
|
|
5474
5474
|
if (!y.shapeStrokeEnabled || y.hidden) return u;
|
|
5475
|
-
const { count:
|
|
5476
|
-
if (
|
|
5477
|
-
const
|
|
5475
|
+
const { count: h, closed: g, planeNormal: P } = ls(y);
|
|
5476
|
+
if (h < 2) return u;
|
|
5477
|
+
const _ = ns(y), B = Math.max(1e-4, y.shapeStrokeWidth ?? 0.08), x = Math.max(0, y.opacity ?? 1);
|
|
5478
5478
|
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 (
|
|
5479
|
+
os(P[0], P[1], P[2], _, p, Ae);
|
|
5480
|
+
let R = Math.hypot(Ae[0], Ae[1], Ae[2]) || 1;
|
|
5481
|
+
const m = Ae[0] / R, w = Ae[1] / R, E = Ae[2] / R;
|
|
5482
|
+
for (let I = 0; I < h; I++)
|
|
5483
|
+
as(ae[I], oe[I], le[I], _, p, y, Ae), ae[I] = Ae[0], oe[I] = Ae[1], le[I] = Ae[2];
|
|
5484
|
+
const N = y.shapeStrokeShape ?? "straight";
|
|
5485
|
+
if (N !== "straight") {
|
|
5486
5486
|
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
|
-
|
|
5487
|
+
for (let W = 0; W < h; W++) {
|
|
5488
|
+
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;
|
|
5489
|
+
let he = 0, me = 0;
|
|
5490
|
+
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
5491
|
}
|
|
5492
5492
|
}
|
|
5493
|
-
const X = g ?
|
|
5493
|
+
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
5494
|
let it = 0;
|
|
5495
5495
|
for (let I = 0; I < X; I++) {
|
|
5496
|
-
const K = g ? (I + 1) %
|
|
5496
|
+
const K = g ? (I + 1) % h : I + 1;
|
|
5497
5497
|
it += Math.hypot(ae[K] - ae[I], oe[K] - oe[I], le[K] - le[I]);
|
|
5498
5498
|
}
|
|
5499
5499
|
const Qt = g ? Math.max(1, Math.round(it / _t)) : Math.max(it / _t, 1e-6), Mt = it > 1e-6 ? Qt / it : 0;
|
|
5500
5500
|
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 $ =
|
|
5501
|
+
for (let I = 0; I < h; I++) {
|
|
5502
|
+
const K = I === 0 ? g ? h - 1 : 0 : I - 1, Ie = I === h - 1 ? g ? 0 : h - 1 : I + 1;
|
|
5503
|
+
let W = ae[Ie] - ae[K], pe = oe[Ie] - oe[K], ee = le[Ie] - le[K];
|
|
5504
|
+
const ge = Math.hypot(W, pe, ee) || 1;
|
|
5505
|
+
W /= ge, pe /= ge, ee /= ge;
|
|
5506
|
+
let $ = w * ee - E * pe, Q = E * W - m * ee, J = m * pe - w * W, te = Math.hypot($, Q, J);
|
|
5507
5507
|
if (te < 1e-5) {
|
|
5508
|
-
const ce = V.right[0],
|
|
5509
|
-
$ = ce - ue * W, Q =
|
|
5508
|
+
const ce = V.right[0], be = V.right[1], ve = V.right[2], ue = ce * W + be * pe + ve * ee;
|
|
5509
|
+
$ = ce - ue * W, Q = be - ue * pe, J = ve - ue * ee, te = Math.hypot($, Q, J);
|
|
5510
5510
|
}
|
|
5511
5511
|
if (te < 1e-5) {
|
|
5512
|
-
const ce = V.up[0],
|
|
5513
|
-
$ = ce - ue * W, Q =
|
|
5512
|
+
const ce = V.up[0], be = V.up[1], ve = V.up[2], ue = ce * W + be * pe + ve * ee;
|
|
5513
|
+
$ = ce - ue * W, Q = be - ue * pe, J = ve - ue * ee, te = Math.hypot($, Q, J) || 1;
|
|
5514
5514
|
}
|
|
5515
5515
|
$ /= 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
5516
|
}
|
|
5517
5517
|
for (let I = 0; I < X && !(u + 54 > Ce.length); I++) {
|
|
5518
|
-
const K = g ? (I + 1) %
|
|
5519
|
-
let Q = ee - Ie, J =
|
|
5518
|
+
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];
|
|
5519
|
+
let Q = ee - Ie, J = ge - W, te = $ - pe;
|
|
5520
5520
|
const ce = Math.hypot(Q, J, te) || 1;
|
|
5521
5521
|
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++] =
|
|
5522
|
+
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;
|
|
5523
|
+
let Me, Se, he, me, we, Be;
|
|
5524
|
+
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);
|
|
5525
|
+
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) => {
|
|
5526
|
+
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
5527
|
};
|
|
5528
|
-
ft(Ot, Lt, Tt, Me,
|
|
5528
|
+
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
5529
|
}
|
|
5530
5530
|
return u;
|
|
5531
5531
|
}
|
|
5532
5532
|
const us = 0.41421356;
|
|
5533
5533
|
function ds() {
|
|
5534
5534
|
xt.clear(), at.clear();
|
|
5535
|
-
let u = 0,
|
|
5535
|
+
let u = 0, p = 0, y = 0;
|
|
5536
5536
|
V.position[0], V.position[1], V.position[2];
|
|
5537
|
-
for (const { system:
|
|
5537
|
+
for (const { system: h, config: g } of c.particleSystems) {
|
|
5538
5538
|
if (g.hidden) continue;
|
|
5539
5539
|
if (g.emissionTrailEnabled && !g.glbModelEnabled) {
|
|
5540
|
-
|
|
5541
|
-
const
|
|
5542
|
-
if (
|
|
5543
|
-
const
|
|
5540
|
+
h.readbackAndProcessParticles();
|
|
5541
|
+
const _ = h.particleData, B = h.particleVelocities, x = h.activeParticles;
|
|
5542
|
+
if (_ && B && x > 0) {
|
|
5543
|
+
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
5544
|
for (let ut = 0; ut < x; ut++) {
|
|
5545
|
-
const Ue = ut * 8, dt =
|
|
5546
|
-
let ee =
|
|
5547
|
-
const Q =
|
|
5545
|
+
const Ue = ut * 8, dt = _[Ue], I = _[Ue + 1], K = _[Ue + 2], Ie = dt + Oe, W = I + fe, pe = K + _t;
|
|
5546
|
+
let ee = _[Ue + 3], ge = _[Ue + 4], $ = _[Ue + 5];
|
|
5547
|
+
const Q = _[Ue + 6], J = _[Ue + 7];
|
|
5548
5548
|
if (Q >= J || J <= 0) continue;
|
|
5549
5549
|
const te = Q / J;
|
|
5550
5550
|
if (g.colorTransitionEnabled) {
|
|
5551
5551
|
const A = g.startColor ?? [1, 0, 0], k = g.endColor ?? [0, 0, 1];
|
|
5552
|
-
ee = A[0] + (k[0] - A[0]) * te,
|
|
5552
|
+
ee = A[0] + (k[0] - A[0]) * te, ge = A[1] + (k[1] - A[1]) * te, $ = A[2] + (k[2] - A[2]) * te;
|
|
5553
5553
|
}
|
|
5554
|
-
ee = Math.min(1, ee * X),
|
|
5555
|
-
let ce =
|
|
5554
|
+
ee = Math.min(1, ee * X), ge = Math.min(1, ge * X), $ = Math.min(1, $ * X);
|
|
5555
|
+
let ce = N;
|
|
5556
5556
|
if (g.randomSize) {
|
|
5557
5557
|
const A = Math.sin(J * 54321.67) * 43758.5453 % 1, k = A < 0 ? A + 1 : A;
|
|
5558
5558
|
ce = (g.minSize ?? 0.1) + ((g.maxSize ?? 0.5) - (g.minSize ?? 0.1)) * k;
|
|
@@ -5566,81 +5566,81 @@ async function Jr(s, t = {}) {
|
|
|
5566
5566
|
ce *= 1 + Math.pow(te, 1 / A);
|
|
5567
5567
|
}
|
|
5568
5568
|
if (ce <= 0 || te > 0.9) continue;
|
|
5569
|
-
const
|
|
5569
|
+
const be = Math.min((0.9 - te) * (1 / 0.2), 1), ve = 0.75 * ce * us * be;
|
|
5570
5570
|
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 =
|
|
5571
|
+
if (g.fadeEnabled && (ue *= Math.max(0, 1 - te)), ue *= be, ue < 0.01) continue;
|
|
5572
|
+
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);
|
|
5573
|
+
if (Bt < 1e-3) continue;
|
|
5574
|
+
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];
|
|
5575
|
+
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
5576
|
if (st < 0.2) {
|
|
5577
|
-
const A = V.up[0], k = V.up[1], de = V.up[2],
|
|
5578
|
-
|
|
5577
|
+
const A = V.up[0], k = V.up[1], de = V.up[2], Y = A * Le + k * ke + de * ze;
|
|
5578
|
+
Re = A - Y * Le, Te = k - Y * ke, Ee = de - Y * ze, st = Math.sqrt(Re * Re + Te * Te + Ee * Ee) || 1;
|
|
5579
5579
|
}
|
|
5580
|
-
|
|
5581
|
-
const rt = Math.min(
|
|
5580
|
+
Re /= st, Te /= st, Ee /= st;
|
|
5581
|
+
const rt = Math.min(w, Q);
|
|
5582
5582
|
if (rt < 1e-3) continue;
|
|
5583
5583
|
const Et = g.gravityEnabled && g.gravityStrength || 0, Ze = _s, We = Ms, $e = ws;
|
|
5584
5584
|
if (g.orientToDirection && g.burstMode && wt) {
|
|
5585
|
-
const A =
|
|
5585
|
+
const A = h._emitSimRotY || 0, k = Bs, de = Rs, Y = Ts;
|
|
5586
5586
|
for (let L = 0; L <= O; L++) {
|
|
5587
|
-
const
|
|
5588
|
-
k[L] =
|
|
5587
|
+
const j = li(qe, Ve - L / O * rt, Pi);
|
|
5588
|
+
k[L] = j[0], de[L] = j[1], Y[L] = j[2];
|
|
5589
5589
|
}
|
|
5590
5590
|
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 +
|
|
5591
|
+
const j = L > 0 ? L - 1 : 0, ie = L < O ? L + 1 : O;
|
|
5592
|
+
let Je = k[j] - k[ie], Ke = Y[j] - Y[ie];
|
|
5593
|
+
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;
|
|
5594
|
+
Ze[L] = De * dt + Ge * K + k[L], We[L] = I + ei + de[L], $e[L] = -Ge * dt + De * K + Y[L];
|
|
5595
5595
|
}
|
|
5596
5596
|
} else for (let A = 0; A <= O; A++) {
|
|
5597
5597
|
const k = A / O * rt, de = -0.5 * Et * k * k;
|
|
5598
5598
|
if (wt) {
|
|
5599
|
-
const
|
|
5600
|
-
Ze[A] = dt - Me * k +
|
|
5599
|
+
const Y = li(qe, Ve - k, Pi);
|
|
5600
|
+
Ze[A] = dt - Me * k + Y[0], We[A] = I - Se * k + de + Y[1], $e[A] = K - he * k + Y[2];
|
|
5601
5601
|
} else
|
|
5602
|
-
Ze[A] = Ie -
|
|
5602
|
+
Ze[A] = Ie - me * k, We[A] = W - we * k + de, $e[A] = pe - Be * k;
|
|
5603
5603
|
}
|
|
5604
5604
|
if (U !== "straight") {
|
|
5605
5605
|
const A = g.emissionTrailShapeAmplitude ?? 0.1, k = g.emissionTrailShapeFrequency ?? 4, de = g.emissionTrailShapeSpeed ?? 0;
|
|
5606
|
-
let
|
|
5607
|
-
ie < 1e-6 && (
|
|
5608
|
-
const Je = ke *
|
|
5606
|
+
let Y = -ze, L = 0, j = Le, ie = Math.sqrt(Y * Y + j * j);
|
|
5607
|
+
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;
|
|
5608
|
+
const Je = ke * j - ze * L, Ke = ze * Y - Le * j, Qe = Le * L - ke * Y;
|
|
5609
5609
|
for (let Pe = 1; Pe <= O; Pe++) {
|
|
5610
5610
|
const nt = Pe / O * rt, De = 2 * Math.PI * k * (Ve - nt) + de * Ve;
|
|
5611
|
-
let
|
|
5612
|
-
U === "zigzag" ?
|
|
5611
|
+
let Ge = 0, et = 0;
|
|
5612
|
+
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
5613
|
}
|
|
5614
5614
|
}
|
|
5615
|
-
if (
|
|
5616
|
-
for (let A = 1; A <= O && u <
|
|
5617
|
-
const k = A / O, de = Ze[A] - Oe,
|
|
5618
|
-
H[
|
|
5615
|
+
if (R)
|
|
5616
|
+
for (let A = 1; A <= O && u < F; A++) {
|
|
5617
|
+
const k = A / O, de = Ze[A] - Oe, Y = We[A] - fe, L = $e[A] - _t, j = u * 8, ie = u * 4;
|
|
5618
|
+
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
5619
|
}
|
|
5620
5620
|
else
|
|
5621
|
-
for (let A = 0; A < O && !(
|
|
5622
|
-
const k = A / O, de = (A + 1) / O,
|
|
5623
|
-
Ye[
|
|
5621
|
+
for (let A = 0; A < O && !(p + 42 > Ye.length); A++) {
|
|
5622
|
+
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) => {
|
|
5623
|
+
Ye[p++] = Xs, Ye[p++] = Ns, Ye[p++] = Ys, Ye[p++] = ee, Ye[p++] = ge, Ye[p++] = $, Ye[p++] = js;
|
|
5624
5624
|
};
|
|
5625
|
-
bt(
|
|
5625
|
+
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
5626
|
}
|
|
5627
5627
|
}
|
|
5628
|
-
|
|
5628
|
+
R && u > m && xt.set(g.id, { first: m, count: u - m });
|
|
5629
5629
|
}
|
|
5630
5630
|
}
|
|
5631
|
-
const
|
|
5632
|
-
y = cs(y,
|
|
5631
|
+
const P = y;
|
|
5632
|
+
y = cs(y, h, g), y > P && at.set(g.id, { first: P / 9, count: (y - P) / 9 });
|
|
5633
5633
|
}
|
|
5634
|
-
u > 0 && (r.queue.writeBuffer(re, 0, H, 0, u * 8), r.queue.writeBuffer(
|
|
5634
|
+
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
5635
|
}
|
|
5636
5636
|
const ci = () => {
|
|
5637
|
-
const [u,
|
|
5638
|
-
r.queue.writeBuffer(z, 0, new Float32Array([1, 0, u,
|
|
5637
|
+
const [u, p] = Ji(a.width, a.height);
|
|
5638
|
+
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
5639
|
};
|
|
5640
5640
|
ci();
|
|
5641
5641
|
const ui = new Float32Array(16).fill(0);
|
|
5642
|
-
ui[0] = 1, r.queue.writeBuffer(
|
|
5643
|
-
const
|
|
5642
|
+
ui[0] = 1, r.queue.writeBuffer(M, 0, ui);
|
|
5643
|
+
const Fe = Ir(r), Ne = Cr(r), {
|
|
5644
5644
|
particlePipeline: fs,
|
|
5645
5645
|
particleAdditivePipeline: ps,
|
|
5646
5646
|
particleDepthWritePipeline: hs,
|
|
@@ -5862,12 +5862,12 @@ async function Jr(s, t = {}) {
|
|
|
5862
5862
|
});
|
|
5863
5863
|
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
5864
|
const xi = () => {
|
|
5865
|
-
const u = (
|
|
5865
|
+
const u = (p) => p.createView();
|
|
5866
5866
|
ht = u(ot), Si = u(lt), Dt = u(ct), Pt = u(zt);
|
|
5867
5867
|
};
|
|
5868
5868
|
xi();
|
|
5869
|
-
const Zt = { uniformBuffer: v, appearanceUniformBuffer: C, horizontalBlurUniformBuffer: z, verticalBlurUniformBuffer: D, bloomIntensityBuffer:
|
|
5870
|
-
let
|
|
5869
|
+
const Zt = { uniformBuffer: v, appearanceUniformBuffer: C, horizontalBlurUniformBuffer: z, verticalBlurUniformBuffer: D, bloomIntensityBuffer: M };
|
|
5870
|
+
let Gt = si(r, Fe, Zt, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct });
|
|
5871
5871
|
const V = {
|
|
5872
5872
|
mvp: new Float32Array(16),
|
|
5873
5873
|
position: new Float32Array([0, 0, 10]),
|
|
@@ -5877,102 +5877,102 @@ async function Jr(s, t = {}) {
|
|
|
5877
5877
|
hasCamera: !1
|
|
5878
5878
|
};
|
|
5879
5879
|
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,
|
|
5880
|
+
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 };
|
|
5881
|
+
let _i = !1, Wt = !0, Ft = !1, Vt = null, $t = a.width, Jt = a.height;
|
|
5882
5882
|
function Mi() {
|
|
5883
|
-
const u = [ot, lt, ct, zt],
|
|
5884
|
-
ot =
|
|
5883
|
+
const u = [ot, lt, ct, zt], p = Ni(r, l, a.width, a.height);
|
|
5884
|
+
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
5885
|
let y = !1;
|
|
5886
|
-
const
|
|
5886
|
+
const h = () => {
|
|
5887
5887
|
if (!y) {
|
|
5888
|
-
y = !0, requestAnimationFrame(
|
|
5888
|
+
y = !0, requestAnimationFrame(h);
|
|
5889
5889
|
return;
|
|
5890
5890
|
}
|
|
5891
5891
|
u.forEach((g) => g.destroy());
|
|
5892
5892
|
};
|
|
5893
|
-
requestAnimationFrame(
|
|
5893
|
+
requestAnimationFrame(h);
|
|
5894
5894
|
}
|
|
5895
|
-
function Es(u,
|
|
5896
|
-
V.mvp.set(
|
|
5895
|
+
function Es(u, p, y) {
|
|
5896
|
+
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
5897
|
}
|
|
5898
|
-
function As(u,
|
|
5899
|
-
V.mvp.set(u),
|
|
5898
|
+
function As(u, p) {
|
|
5899
|
+
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
5900
|
}
|
|
5901
5901
|
async function Kt(u) {
|
|
5902
|
-
if (
|
|
5902
|
+
if (Ft) {
|
|
5903
5903
|
Vt = u;
|
|
5904
5904
|
return;
|
|
5905
5905
|
}
|
|
5906
|
-
|
|
5906
|
+
Ft = !0;
|
|
5907
5907
|
try {
|
|
5908
|
-
for (const
|
|
5909
|
-
|
|
5910
|
-
for (const
|
|
5911
|
-
await c.addSystems(
|
|
5912
|
-
for (const { config:
|
|
5913
|
-
T[
|
|
5908
|
+
for (const p in T) delete T[p];
|
|
5909
|
+
f.clear(), b.resizeTextures(), Gt = si(r, Fe, Zt, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct }), await c.replaceSystems({ systems: [], activeSystemIndex: 0 });
|
|
5910
|
+
for (const p of u)
|
|
5911
|
+
await c.addSystems(p.preset, p.position || [0, 0, 0]);
|
|
5912
|
+
for (const { config: p } of c.particleSystems)
|
|
5913
|
+
T[p.id] || (T[p.id] = G());
|
|
5914
5914
|
Wt = !0, c.respawnAllSystems();
|
|
5915
5915
|
} finally {
|
|
5916
|
-
if (
|
|
5917
|
-
const
|
|
5918
|
-
Vt = null, Kt(
|
|
5916
|
+
if (Ft = !1, Vt) {
|
|
5917
|
+
const p = Vt;
|
|
5918
|
+
Vt = null, Kt(p);
|
|
5919
5919
|
}
|
|
5920
5920
|
}
|
|
5921
5921
|
}
|
|
5922
|
-
async function Cs(u,
|
|
5923
|
-
return Kt([{ preset: u, position:
|
|
5922
|
+
async function Cs(u, p = [0, 0, 0]) {
|
|
5923
|
+
return Kt([{ preset: u, position: p }]);
|
|
5924
5924
|
}
|
|
5925
5925
|
function Us(u) {
|
|
5926
|
-
if (_i ||
|
|
5927
|
-
const
|
|
5928
|
-
if (
|
|
5926
|
+
if (_i || Ft || !c.ready || u <= 0 || c.particleSystems.length === 0) return;
|
|
5927
|
+
const p = c.clock;
|
|
5928
|
+
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
5929
|
if ((a.width !== $t || a.height !== Jt) && ($t = a.width, Jt = a.height, Mi()), Ve += u, _e.length) {
|
|
5930
5930
|
for (const m of _e) {
|
|
5931
5931
|
if (m.getPosition) {
|
|
5932
|
-
const
|
|
5933
|
-
|
|
5932
|
+
const w = m.getPosition();
|
|
5933
|
+
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
5934
|
}
|
|
5935
5935
|
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
5936
|
}
|
|
5937
|
-
for (const { system: m, config:
|
|
5938
|
-
const E = oi(
|
|
5939
|
-
if (!(!E || E.historyOnly) && (
|
|
5940
|
-
let
|
|
5937
|
+
for (const { system: m, config: w } of c.particleSystems) {
|
|
5938
|
+
const E = oi(w.id);
|
|
5939
|
+
if (!(!E || E.historyOnly) && (w.hidden = !E.pos, E.pos)) {
|
|
5940
|
+
let N = null;
|
|
5941
5941
|
if (E.orientToDirection && E.vel) {
|
|
5942
5942
|
const X = E.vel[0], O = E.vel[2];
|
|
5943
|
-
Math.hypot(X, O) > 1e-4 && (
|
|
5943
|
+
Math.hypot(X, O) > 1e-4 && (N = [0, 0, Math.atan2(X, O)]);
|
|
5944
5944
|
}
|
|
5945
|
-
m.setSimulationTransform({ position: E.pos, velocity: E.vel, rotation:
|
|
5945
|
+
m.setSimulationTransform({ position: E.pos, velocity: E.vel, rotation: N }), m.updateAppearanceUniform(), (E.justResumed || m.activeParticles === 0) && m.spawnParticles();
|
|
5946
5946
|
}
|
|
5947
5947
|
}
|
|
5948
5948
|
for (const m of _e)
|
|
5949
5949
|
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
5950
|
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})=[${
|
|
5951
|
+
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(",");
|
|
5952
|
+
console.info(`[HZFX] movingGroups(${_e.length})=[${N}] activeParticles=${m} systems=${c.particleSystems.length} ribbonVerts=${vt} camDist=${E} t=${Ve.toFixed(1)}`);
|
|
5953
5953
|
}
|
|
5954
5954
|
}
|
|
5955
|
-
if (c.updateAllSystems(u),
|
|
5956
|
-
const m = c.particleSystems.length > 0 && c.particleSystems.every(({ system:
|
|
5957
|
-
(
|
|
5955
|
+
if (c.updateAllSystems(u), p ? p.loop : c.loop ?? i) {
|
|
5956
|
+
const m = c.particleSystems.length > 0 && c.particleSystems.every(({ system: w }) => w.activeParticles === 0 && !w.emitting);
|
|
5957
|
+
(p && p.justLooped || m && Wt) && c.respawnAllSystems(), Wt = !m;
|
|
5958
5958
|
}
|
|
5959
|
-
for (const { system: m, config:
|
|
5960
|
-
|
|
5959
|
+
for (const { system: m, config: w } of c.particleSystems)
|
|
5960
|
+
w.glbModelEnabled && m.glbAnimator && (m.glbAnimator.update(u), m.updateAnimatedGLBBuffer());
|
|
5961
5961
|
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
|
|
5962
|
+
const h = r.createCommandEncoder();
|
|
5963
5963
|
let g = !1;
|
|
5964
5964
|
if (e)
|
|
5965
5965
|
try {
|
|
5966
5966
|
const m = e();
|
|
5967
5967
|
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 !==
|
|
5968
|
+
let w = null, E = null, N = !1;
|
|
5969
|
+
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) {
|
|
5970
|
+
const { pipeline: X, layout: O } = S(N);
|
|
5971
|
+
(yt.key !== w || yt.ms !== N) && (yt.key = w, yt.ms = N, yt.bindGroup = r.createBindGroup({
|
|
5972
5972
|
layout: O,
|
|
5973
5973
|
entries: [{ binding: 0, resource: E() }]
|
|
5974
5974
|
}));
|
|
5975
|
-
const U =
|
|
5975
|
+
const U = h.beginRenderPass({
|
|
5976
5976
|
colorAttachments: [],
|
|
5977
5977
|
depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5978
5978
|
});
|
|
@@ -5981,90 +5981,90 @@ async function Jr(s, t = {}) {
|
|
|
5981
5981
|
}
|
|
5982
5982
|
} catch {
|
|
5983
5983
|
}
|
|
5984
|
-
const
|
|
5984
|
+
const P = h.beginRenderPass({
|
|
5985
5985
|
colorAttachments: [{ view: ht, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5986
5986
|
depthStencilAttachment: g ? { view: Pt, depthLoadOp: "load", depthStoreOp: "store" } : { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5987
5987
|
});
|
|
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:
|
|
5988
|
+
for (const { system: m, config: w } of c.particleSystems)
|
|
5989
|
+
w.bloomEnabled || w.hidden || m.activeParticles === 0 && !at.has(w.id) || (Bi(P, m, w), Ri(P, m, w));
|
|
5990
|
+
vt > 0 && (P.setPipeline(bs), P.setBindGroup(0, Ss), P.setVertexBuffer(0, qt), P.draw(vt)), P.end();
|
|
5991
|
+
const _ = /* @__PURE__ */ new Map();
|
|
5992
|
+
for (const { system: m, config: w } of c.particleSystems) {
|
|
5993
|
+
if (!w.bloomEnabled || w.hidden || m.activeParticles === 0 && !at.has(w.id)) continue;
|
|
5994
|
+
const E = w.bloomColor || [1, 1, 1], N = `b${w.bloomIntensity ?? 1}|${E[0]}|${E[1]}|${E[2]}`, X = _.get(N);
|
|
5995
|
+
X ? X.membres.push({ system: m, config: w }) : _.set(N, { membres: [{ system: m, config: w }], premier: m });
|
|
5996
5996
|
}
|
|
5997
|
-
if (
|
|
5997
|
+
if (_.size > 0) {
|
|
5998
5998
|
const m = {
|
|
5999
5999
|
colorAttachments: [{ view: Si, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6000
|
-
},
|
|
6000
|
+
}, w = {
|
|
6001
6001
|
colorAttachments: [{ view: Dt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6002
6002
|
};
|
|
6003
|
-
for (const [E,
|
|
6004
|
-
const X = b.getBloomSourceTexture(E, a.width, a.height), O =
|
|
6003
|
+
for (const [E, N] of _) {
|
|
6004
|
+
const X = b.getBloomSourceTexture(E, a.width, a.height), O = h.beginRenderPass({
|
|
6005
6005
|
colorAttachments: [{ view: X.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
6006
6006
|
depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
|
|
6007
6007
|
});
|
|
6008
|
-
for (const { system:
|
|
6009
|
-
|
|
6010
|
-
O.end(), vi[0] =
|
|
6008
|
+
for (const { system: Oe, config: fe } of N.membres)
|
|
6009
|
+
Bi(O, Oe, fe), Ri(O, Oe, fe);
|
|
6010
|
+
O.end(), vi[0] = N.membres[0].config.bloomIntensity, r.queue.writeBuffer(M, 0, vi), f.systemBloomHorizontalBindGroups[E] || (f.systemBloomHorizontalBindGroups[E] = r.createBindGroup({
|
|
6011
6011
|
layout: Ne.bloomBindGroupLayout,
|
|
6012
6012
|
entries: [
|
|
6013
|
-
{ binding: 0, resource:
|
|
6013
|
+
{ binding: 0, resource: Fe },
|
|
6014
6014
|
{ binding: 1, resource: X.createView() },
|
|
6015
6015
|
{ binding: 2, resource: { buffer: z } }
|
|
6016
6016
|
]
|
|
6017
6017
|
}));
|
|
6018
|
-
let U =
|
|
6019
|
-
U.setPipeline(It), U.setBindGroup(0,
|
|
6018
|
+
let U = h.beginRenderPass(m);
|
|
6019
|
+
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
6020
|
layout: Ne.bloomBindGroupLayout,
|
|
6021
6021
|
entries: [
|
|
6022
|
-
{ binding: 0, resource:
|
|
6022
|
+
{ binding: 0, resource: Fe },
|
|
6023
6023
|
{ binding: 1, resource: Dt },
|
|
6024
6024
|
{ binding: 2, resource: { buffer: z } }
|
|
6025
6025
|
]
|
|
6026
|
-
})), U =
|
|
6027
|
-
const
|
|
6028
|
-
U =
|
|
6029
|
-
colorAttachments: [{ view:
|
|
6030
|
-
}), U.setPipeline(ms),
|
|
6026
|
+
})), 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();
|
|
6027
|
+
const ye = `${E}#${N.premier.config.id}`, xe = b.getBloomCompositeTexture(E, a.width, a.height);
|
|
6028
|
+
U = h.beginRenderPass({
|
|
6029
|
+
colorAttachments: [{ view: xe.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6030
|
+
}), U.setPipeline(ms), f.systemBloomCompositeBindGroups[ye] || (f.systemBloomCompositeBindGroups[ye] = r.createBindGroup({
|
|
6031
6031
|
layout: Ne.compositeBindGroupLayout,
|
|
6032
6032
|
entries: [
|
|
6033
|
-
{ binding: 0, resource:
|
|
6033
|
+
{ binding: 0, resource: Fe },
|
|
6034
6034
|
{ binding: 1, resource: X.createView() },
|
|
6035
6035
|
{ binding: 2, resource: Dt },
|
|
6036
6036
|
// ⚠️ L'uniforme du PREMIER membre : la clé de groupe garantit que tous portent la même
|
|
6037
6037
|
// intensité et la même couleur, donc n'importe lequel convient — mais il en faut un VRAI,
|
|
6038
6038
|
// écrit par `particleSystem`, pas le tampon partagé qui ne porte que l'intensité.
|
|
6039
|
-
{ binding: 3, resource: { buffer:
|
|
6039
|
+
{ binding: 3, resource: { buffer: N.premier.bloomIntensityBuffer } }
|
|
6040
6040
|
]
|
|
6041
|
-
})), U.setBindGroup(0,
|
|
6041
|
+
})), U.setBindGroup(0, f.systemBloomCompositeBindGroups[ye]), U.draw(3), U.end();
|
|
6042
6042
|
}
|
|
6043
6043
|
}
|
|
6044
|
-
const
|
|
6045
|
-
colorAttachments: [{ view:
|
|
6044
|
+
const B = b.getCombinedTexture(a.width, a.height), x = h.beginRenderPass({
|
|
6045
|
+
colorAttachments: [{ view: B.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6046
6046
|
});
|
|
6047
|
-
x.setPipeline(di),
|
|
6047
|
+
x.setPipeline(di), f.combinedInitialBindGroup || (f.combinedInitialBindGroup = r.createBindGroup({
|
|
6048
6048
|
layout: Ne.compositeBindGroupLayout,
|
|
6049
6049
|
entries: [
|
|
6050
|
-
{ binding: 0, resource:
|
|
6050
|
+
{ binding: 0, resource: Fe },
|
|
6051
6051
|
{ binding: 1, resource: ht },
|
|
6052
6052
|
{ binding: 2, resource: ht },
|
|
6053
|
-
{ binding: 3, resource: { buffer:
|
|
6053
|
+
{ binding: 3, resource: { buffer: M } }
|
|
6054
6054
|
]
|
|
6055
|
-
})), x.setBindGroup(0,
|
|
6056
|
-
for (const m of
|
|
6057
|
-
x.setPipeline(di),
|
|
6055
|
+
})), x.setBindGroup(0, f.combinedInitialBindGroup), x.draw(3);
|
|
6056
|
+
for (const m of _.keys())
|
|
6057
|
+
x.setPipeline(di), f.combinedBloomCompositeBindGroups[m] || (f.combinedBloomCompositeBindGroups[m] = r.createBindGroup({
|
|
6058
6058
|
layout: Ne.compositeBindGroupLayout,
|
|
6059
6059
|
entries: [
|
|
6060
|
-
{ binding: 0, resource:
|
|
6060
|
+
{ binding: 0, resource: Fe },
|
|
6061
6061
|
{ binding: 1, resource: b.getBloomCompositeTexture(m, a.width, a.height).createView() },
|
|
6062
6062
|
{ binding: 2, resource: ht },
|
|
6063
|
-
{ binding: 3, resource: { buffer:
|
|
6063
|
+
{ binding: 3, resource: { buffer: M } }
|
|
6064
6064
|
]
|
|
6065
|
-
})), x.setBindGroup(0,
|
|
6065
|
+
})), x.setBindGroup(0, f.combinedBloomCompositeBindGroups[m]), x.draw(3);
|
|
6066
6066
|
x.end();
|
|
6067
|
-
const
|
|
6067
|
+
const R = h.beginRenderPass({
|
|
6068
6068
|
colorAttachments: [{
|
|
6069
6069
|
view: n.getCurrentTexture().createView(),
|
|
6070
6070
|
loadOp: o ? "load" : "clear",
|
|
@@ -6072,47 +6072,47 @@ async function Jr(s, t = {}) {
|
|
|
6072
6072
|
clearValue: { r: 0, g: 0, b: 0, a: 0 }
|
|
6073
6073
|
}]
|
|
6074
6074
|
});
|
|
6075
|
-
|
|
6075
|
+
R.setPipeline(ys), f.finalBindGroup || (f.finalBindGroup = r.createBindGroup({
|
|
6076
6076
|
layout: Ne.compositeBindGroupLayout,
|
|
6077
6077
|
entries: [
|
|
6078
|
-
{ binding: 0, resource:
|
|
6079
|
-
{ binding: 1, resource:
|
|
6078
|
+
{ binding: 0, resource: Fe },
|
|
6079
|
+
{ binding: 1, resource: B.createView() },
|
|
6080
6080
|
{ binding: 2, resource: ht },
|
|
6081
|
-
{ binding: 3, resource: { buffer:
|
|
6081
|
+
{ binding: 3, resource: { buffer: M } }
|
|
6082
6082
|
]
|
|
6083
|
-
})),
|
|
6083
|
+
})), R.setBindGroup(0, f.finalBindGroup), R.draw(3), R.end(), r.queue.submit([h.finish()]);
|
|
6084
6084
|
}
|
|
6085
|
-
function wi(u,
|
|
6086
|
-
const y = u.config.id,
|
|
6087
|
-
return
|
|
6085
|
+
function wi(u, p) {
|
|
6086
|
+
const y = u.config.id, h = !f.systemBindGroups[y] || f.textureStates[y] !== p.textureEnabled || f.textureRefs[y] !== u.particleTexture;
|
|
6087
|
+
return f.textureStates[y] = p.textureEnabled, f.textureRefs[y] = u.particleTexture, h && (f.systemBindGroups[y] = r.createBindGroup({
|
|
6088
6088
|
layout: Ne.particleBindGroupLayout,
|
|
6089
6089
|
entries: [
|
|
6090
6090
|
{ binding: 0, resource: { buffer: v } },
|
|
6091
6091
|
{ binding: 1, resource: { buffer: u.appearanceUniformBuffer } },
|
|
6092
6092
|
{ binding: 2, resource: u.particleTexture.createView() },
|
|
6093
|
-
{ binding: 3, resource:
|
|
6093
|
+
{ binding: 3, resource: Fe }
|
|
6094
6094
|
]
|
|
6095
|
-
})),
|
|
6095
|
+
})), f.systemBindGroups[y];
|
|
6096
6096
|
}
|
|
6097
|
-
function
|
|
6098
|
-
const
|
|
6097
|
+
function Bi(u, p, y) {
|
|
6098
|
+
const h = p.config.id, g = y.glbModelEnabled && p.glbMeshData, P = wi(p, y), _ = y.shapeDisplay !== !1;
|
|
6099
6099
|
if (g)
|
|
6100
|
-
|
|
6100
|
+
_ && (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
6101
|
else {
|
|
6102
|
-
u.setPipeline(y.blendMode === "additive" ? ps : fs), u.setIndexBuffer(Z, "uint16"), T[
|
|
6103
|
-
const
|
|
6104
|
-
|
|
6102
|
+
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));
|
|
6103
|
+
const B = xt.get(h);
|
|
6104
|
+
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
6105
|
}
|
|
6106
6106
|
}
|
|
6107
|
-
function
|
|
6108
|
-
const
|
|
6109
|
-
!
|
|
6107
|
+
function Ri(u, p, y) {
|
|
6108
|
+
const h = at.get(y.id);
|
|
6109
|
+
!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
6110
|
}
|
|
6111
6111
|
function Is() {
|
|
6112
6112
|
$t = a.width, Jt = a.height, Mi();
|
|
6113
6113
|
}
|
|
6114
6114
|
function zs() {
|
|
6115
|
-
|
|
6115
|
+
f.clear();
|
|
6116
6116
|
}
|
|
6117
6117
|
function Ds() {
|
|
6118
6118
|
_i = !0, c.destroy(), [ot, lt, ct, zt].forEach((u) => u == null ? void 0 : u.destroy()), b.resizeTextures(), [
|
|
@@ -6120,56 +6120,61 @@ async function Jr(s, t = {}) {
|
|
|
6120
6120
|
C,
|
|
6121
6121
|
z,
|
|
6122
6122
|
D,
|
|
6123
|
-
|
|
6123
|
+
M,
|
|
6124
6124
|
Z,
|
|
6125
6125
|
re,
|
|
6126
|
-
|
|
6126
|
+
q,
|
|
6127
6127
|
tt,
|
|
6128
6128
|
qt,
|
|
6129
6129
|
Ht
|
|
6130
6130
|
].forEach((u) => u == null ? void 0 : u.destroy()), Object.values(T).forEach((u) => u == null ? void 0 : u.destroy());
|
|
6131
6131
|
}
|
|
6132
|
-
async function Ti(u,
|
|
6133
|
-
const y = await c.addSystems(u,
|
|
6134
|
-
for (const { config:
|
|
6135
|
-
T[
|
|
6132
|
+
async function Ti(u, p) {
|
|
6133
|
+
const y = await c.addSystems(u, p);
|
|
6134
|
+
for (const { config: h } of c.particleSystems)
|
|
6135
|
+
T[h.id] || (T[h.id] = G());
|
|
6136
6136
|
return c.respawnAllSystems(), new Set(Array.isArray(y) ? y : []);
|
|
6137
6137
|
}
|
|
6138
6138
|
function Ei(u) {
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6139
|
+
var p;
|
|
6140
|
+
for (const y of u) {
|
|
6141
|
+
const h = c.particleSystems.findIndex((P) => P.config.id === y);
|
|
6142
|
+
if (h < 0) continue;
|
|
6143
|
+
c.removeSystem(h), (p = T[y]) == null || p.destroy(), delete T[y], delete f.systemBindGroups[y], delete f.textureStates[y], delete f.textureRefs[y];
|
|
6144
|
+
const g = `#${y}`;
|
|
6145
|
+
for (const P in f.systemBloomCompositeBindGroups)
|
|
6146
|
+
P.endsWith(g) && delete f.systemBloomCompositeBindGroups[P];
|
|
6142
6147
|
}
|
|
6143
6148
|
}
|
|
6144
|
-
async function
|
|
6145
|
-
const y = await Ti(u,
|
|
6149
|
+
async function Gs(u, p = [0, 0, 0]) {
|
|
6150
|
+
const y = await Ti(u, p);
|
|
6146
6151
|
return { remove() {
|
|
6147
6152
|
Ei(y);
|
|
6148
6153
|
} };
|
|
6149
6154
|
}
|
|
6150
|
-
async function
|
|
6155
|
+
async function Fs(u, p = {}) {
|
|
6151
6156
|
const y = await Ti(u, [0, 0, 0]);
|
|
6152
6157
|
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...y]}]`);
|
|
6153
|
-
const
|
|
6154
|
-
return _e.push(
|
|
6158
|
+
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] };
|
|
6159
|
+
return _e.push(h), {
|
|
6155
6160
|
setPosition(g) {
|
|
6156
|
-
g && (
|
|
6161
|
+
g && (h.pos = Array.isArray(g) ? [g[0], g[1], g[2]] : [g.x, g.y, g.z]);
|
|
6157
6162
|
},
|
|
6158
6163
|
setOrientToDirection(g) {
|
|
6159
|
-
|
|
6164
|
+
h.orientToDirection = !!g;
|
|
6160
6165
|
},
|
|
6161
6166
|
remove() {
|
|
6162
6167
|
Ei(y);
|
|
6163
|
-
const g = _e.indexOf(
|
|
6168
|
+
const g = _e.indexOf(h);
|
|
6164
6169
|
g >= 0 && _e.splice(g, 1);
|
|
6165
6170
|
}
|
|
6166
6171
|
};
|
|
6167
6172
|
}
|
|
6168
|
-
function Vs(u,
|
|
6169
|
-
const
|
|
6170
|
-
return _e.push(
|
|
6173
|
+
function Vs(u, p) {
|
|
6174
|
+
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] };
|
|
6175
|
+
return _e.push(h), {
|
|
6171
6176
|
remove() {
|
|
6172
|
-
const g = _e.indexOf(
|
|
6177
|
+
const g = _e.indexOf(h);
|
|
6173
6178
|
g >= 0 && _e.splice(g, 1);
|
|
6174
6179
|
},
|
|
6175
6180
|
// Update which systems this history group covers WITHOUT losing the accumulated path
|
|
@@ -6177,7 +6182,7 @@ async function Jr(s, t = {}) {
|
|
|
6177
6182
|
// group is active — otherwise a newly-added system's id isn't in the set and its trail
|
|
6178
6183
|
// can't follow the recorded movement path (it falls back to straight extrapolation).
|
|
6179
6184
|
setIds(g) {
|
|
6180
|
-
|
|
6185
|
+
h.ids = g instanceof Set ? g : new Set(g);
|
|
6181
6186
|
}
|
|
6182
6187
|
};
|
|
6183
6188
|
}
|
|
@@ -6189,8 +6194,8 @@ async function Jr(s, t = {}) {
|
|
|
6189
6194
|
setCameraMVP: As,
|
|
6190
6195
|
setEmitters: Kt,
|
|
6191
6196
|
loadPreset: Cs,
|
|
6192
|
-
addEmitter:
|
|
6193
|
-
addMovingEmitter:
|
|
6197
|
+
addEmitter: Gs,
|
|
6198
|
+
addMovingEmitter: Fs,
|
|
6194
6199
|
render: Us,
|
|
6195
6200
|
resize: Is,
|
|
6196
6201
|
clearCaches: zs,
|
|
@@ -6212,11 +6217,11 @@ function Kr(s) {
|
|
|
6212
6217
|
(n = C == null ? void 0 : C.depthBuffer) == null ? void 0 : n.texture,
|
|
6213
6218
|
z ? (a = c.get(z)) == null ? void 0 : a.texture : null
|
|
6214
6219
|
];
|
|
6215
|
-
for (const
|
|
6216
|
-
if (
|
|
6220
|
+
for (const M of D)
|
|
6221
|
+
if (M && typeof M.createView == "function" && M.width === d && M.height === S) return M;
|
|
6217
6222
|
return null;
|
|
6218
6223
|
}
|
|
6219
|
-
const
|
|
6224
|
+
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
6225
|
return v ? { view: v, multisampled: (s.currentSamples ?? 0) > 1 } : null;
|
|
6221
6226
|
} catch {
|
|
6222
6227
|
return null;
|
|
@@ -6229,9 +6234,9 @@ export {
|
|
|
6229
6234
|
Nr as Objects3DManager,
|
|
6230
6235
|
qs as ParticleEmitter,
|
|
6231
6236
|
er as ParticlePhysics,
|
|
6232
|
-
|
|
6237
|
+
Gi as ParticleScript,
|
|
6233
6238
|
ii as ParticleSystem,
|
|
6234
|
-
|
|
6239
|
+
Rr as ParticleSystemManager,
|
|
6235
6240
|
tr as ParticleTextureManager,
|
|
6236
6241
|
Zs as blurShader,
|
|
6237
6242
|
Ws as compositeShader,
|
|
@@ -6256,7 +6261,7 @@ export {
|
|
|
6256
6261
|
is as isHZFX,
|
|
6257
6262
|
Wr as loadScene,
|
|
6258
6263
|
Kr as makeThreeSceneDepth,
|
|
6259
|
-
|
|
6264
|
+
Fr as multiplyMatrices,
|
|
6260
6265
|
Er as object3dShader,
|
|
6261
6266
|
Or as packHZFX,
|
|
6262
6267
|
or as parseGLB,
|