hz-particles 1.5.1 → 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 +47 -17
- package/dist-lib/hz-particles.mjs +1111 -1064
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class qs {
|
|
2
2
|
constructor(t = {}) {
|
|
3
3
|
this.config = t, this._posOut = [0, 0, 0], this._rotMatrix = null, this._invRotMatrix = null, this._cachedRotX = void 0, this._cachedRotY = void 0, this._cachedRotZ = void 0;
|
|
4
4
|
}
|
|
@@ -10,17 +10,17 @@ class Ys {
|
|
|
10
10
|
if (t === this._cachedRotX && e === this._cachedRotY && i === this._cachedRotZ)
|
|
11
11
|
return;
|
|
12
12
|
this._cachedRotX = t, this._cachedRotY = e, this._cachedRotZ = i;
|
|
13
|
-
const r = t * Math.PI / 180, n = e * Math.PI / 180, a = i * Math.PI / 180, o = Math.cos(r),
|
|
13
|
+
const r = t * Math.PI / 180, n = e * Math.PI / 180, a = i * Math.PI / 180, o = Math.cos(r), l = Math.sin(r), c = Math.cos(n), d = Math.sin(n), S = Math.cos(a), b = Math.sin(a);
|
|
14
14
|
this._rotMatrix = [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
o * d * S +
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
o * d * b -
|
|
15
|
+
c * S,
|
|
16
|
+
l * d * S - o * b,
|
|
17
|
+
o * d * S + l * b,
|
|
18
|
+
c * b,
|
|
19
|
+
l * d * b + o * S,
|
|
20
|
+
o * d * b - l * S,
|
|
21
21
|
-d,
|
|
22
|
-
|
|
23
|
-
o *
|
|
22
|
+
l * c,
|
|
23
|
+
o * c
|
|
24
24
|
], this._invRotMatrix = [
|
|
25
25
|
this._rotMatrix[0],
|
|
26
26
|
this._rotMatrix[3],
|
|
@@ -37,8 +37,8 @@ class Ys {
|
|
|
37
37
|
const r = this._posOut;
|
|
38
38
|
if (this.config.emissionShape === "cube" || this.config.emissionShape === "box" ? this._emitFromCube(r) : this.config.emissionShape === "sphere" ? this._emitFromSphere(r) : this.config.emissionShape === "square" ? this._emitFromSquare(r) : this.config.emissionShape === "circle" ? this._emitFromCircle(r) : this.config.emissionShape === "cylinder" ? this._emitFromCylinder(r) : this.config.emissionShape === "plain" ? this._emitFromPlain(r) : this.config.emissionShape === "cone" ? this._emitFromCone(r) : this.config.emissionShape === "torus" ? this._emitFromTorus(r) : this.config.emissionShape === "line" ? this._emitFromLine(r) : this.config.emissionShape === "hemisphere" ? this._emitFromHemisphere(r) : this.config.emissionShape === "disc" ? this._emitFromDisc(r) : this.config.emissionShape === "annulus" ? this._emitFromAnnulus(r) : this.config.emissionShape === "capsule" ? this._emitFromCapsule(r) : this.config.emissionShape === "arc" ? this._emitFromArc(r) : this.config.emissionShape === "spiral" ? this._emitFromSpiral(r) : this.config.emissionShape === "frustum" ? this._emitFromFrustum(r) : this.config.emissionShape === "frustumSurface" ? this._emitFromFrustumSurface(r) : this.config.emissionShape === "cubeSurface" ? this._emitFromCubeSurface(r) : this.config.emissionShape === "sphereSurface" ? this._emitFromSphereSurface(r) : this.config.emissionShape === "boxFrame" ? this._emitFromBoxFrame(r) : this.config.emissionShape === "polygon" ? this._emitFromPolygon(r) : this.config.emissionShape === "rectangle" ? this._emitFromRectangle(r) : (r[0] = 0, r[1] = 0, r[2] = 0), this.config.emissionRotationX || this.config.emissionRotationY || this.config.emissionRotationZ) {
|
|
39
39
|
this._updateRotationMatrix();
|
|
40
|
-
const o = this._rotMatrix,
|
|
41
|
-
r[0] = o[0] *
|
|
40
|
+
const o = this._rotMatrix, l = r[0], c = r[1], d = r[2];
|
|
41
|
+
r[0] = o[0] * l + o[1] * c + o[2] * d, r[1] = o[3] * l + o[4] * c + o[5] * d, r[2] = o[6] * l + o[7] * c + o[8] * d;
|
|
42
42
|
}
|
|
43
43
|
(this.config.emissionPositionX || this.config.emissionPositionY || this.config.emissionPositionZ) && (r[0] += this.config.emissionPositionX || 0, r[1] += this.config.emissionPositionY || 0, r[2] += this.config.emissionPositionZ || 0);
|
|
44
44
|
const n = e * 8;
|
|
@@ -70,29 +70,29 @@ class Ys {
|
|
|
70
70
|
let e = this.config.innerLength || 0, i = this.config.outerLength || this.config.cubeLength;
|
|
71
71
|
if (e > 0) {
|
|
72
72
|
const r = Math.floor(Math.random() * 6), n = Math.random() - 0.5, a = Math.random() - 0.5;
|
|
73
|
-
let o,
|
|
73
|
+
let o, l, c;
|
|
74
74
|
switch (r) {
|
|
75
75
|
case 0:
|
|
76
|
-
o = n,
|
|
76
|
+
o = n, l = a, c = 0.5;
|
|
77
77
|
break;
|
|
78
78
|
case 1:
|
|
79
|
-
o = n,
|
|
79
|
+
o = n, l = a, c = -0.5;
|
|
80
80
|
break;
|
|
81
81
|
case 2:
|
|
82
|
-
o = 0.5,
|
|
82
|
+
o = 0.5, l = n, c = a;
|
|
83
83
|
break;
|
|
84
84
|
case 3:
|
|
85
|
-
o = -0.5,
|
|
85
|
+
o = -0.5, l = n, c = a;
|
|
86
86
|
break;
|
|
87
87
|
case 4:
|
|
88
|
-
o = n,
|
|
88
|
+
o = n, l = 0.5, c = a;
|
|
89
89
|
break;
|
|
90
90
|
case 5:
|
|
91
|
-
o = n,
|
|
91
|
+
o = n, l = -0.5, c = a;
|
|
92
92
|
break;
|
|
93
93
|
}
|
|
94
94
|
const d = Math.random(), S = e + d * (i - e);
|
|
95
|
-
t[0] = o * S, t[1] =
|
|
95
|
+
t[0] = o * S, t[1] = l * S, t[2] = c * S;
|
|
96
96
|
} else
|
|
97
97
|
t[0] = (Math.random() - 0.5) * i, t[1] = (Math.random() - 0.5) * i, t[2] = (Math.random() - 0.5) * i;
|
|
98
98
|
}
|
|
@@ -134,14 +134,14 @@ class Ys {
|
|
|
134
134
|
t[0] = (Math.random() - 0.5) * e, t[1] = 0, t[2] = (Math.random() - 0.5) * i;
|
|
135
135
|
}
|
|
136
136
|
_emitFromCone(t) {
|
|
137
|
-
const e = this.config.coneInnerRadius || 0, i = this.config.coneOuterRadius || 2, r = this.config.coneHeight || 4, n = Math.random() * Math.PI * 2, a = Math.random(), o = a * r,
|
|
138
|
-
let
|
|
137
|
+
const e = this.config.coneInnerRadius || 0, i = this.config.coneOuterRadius || 2, r = this.config.coneHeight || 4, n = Math.random() * Math.PI * 2, a = Math.random(), o = a * r, l = i * (1 - a);
|
|
138
|
+
let c;
|
|
139
139
|
if (e > 0) {
|
|
140
140
|
const d = e * (1 - a);
|
|
141
|
-
|
|
141
|
+
c = d + (l - d) * Math.random();
|
|
142
142
|
} else
|
|
143
|
-
|
|
144
|
-
t[0] = Math.cos(n) *
|
|
143
|
+
c = l * Math.sqrt(Math.random());
|
|
144
|
+
t[0] = Math.cos(n) * c, t[1] = o, t[2] = Math.sin(n) * c;
|
|
145
145
|
}
|
|
146
146
|
_emitFromTorus(t) {
|
|
147
147
|
const e = this.config.torusMajorRadius || 2, i = this.config.torusMinorRadius || 0.5, r = Math.random() * Math.PI * 2, n = Math.random() * Math.PI * 2, a = i * Math.sqrt(Math.random());
|
|
@@ -152,9 +152,9 @@ class Ys {
|
|
|
152
152
|
t[0] = 0, t[1] = (i - 0.5) * e, t[2] = 0;
|
|
153
153
|
}
|
|
154
154
|
_emitFromHemisphere(t) {
|
|
155
|
-
const e = this.config.hemisphereInnerRadius || 0, i = this.config.hemisphereOuterRadius || 2, r = Math.random() * Math.PI * 2, n = Math.acos(Math.random()), a = Math.sin(n) * Math.cos(r), o = Math.cos(n),
|
|
156
|
-
let
|
|
157
|
-
e > 0 ?
|
|
155
|
+
const e = this.config.hemisphereInnerRadius || 0, i = this.config.hemisphereOuterRadius || 2, r = Math.random() * Math.PI * 2, n = Math.acos(Math.random()), a = Math.sin(n) * Math.cos(r), o = Math.cos(n), l = Math.sin(n) * Math.sin(r);
|
|
156
|
+
let c;
|
|
157
|
+
e > 0 ? c = e + (i - e) * Math.random() : c = i * Math.cbrt(Math.random()), t[0] = a * c, t[1] = o * c, t[2] = l * c;
|
|
158
158
|
}
|
|
159
159
|
_emitFromDisc(t) {
|
|
160
160
|
const e = this.config.discRadius || 2, i = Math.random() * Math.PI * 2, r = e * Math.sqrt(Math.random());
|
|
@@ -167,37 +167,37 @@ class Ys {
|
|
|
167
167
|
_emitFromCapsule(t) {
|
|
168
168
|
const e = this.config.capsuleRadius || 0.5, i = this.config.capsuleHeight || 4, r = i * 0.5, n = Math.PI * e * e * i, a = 4 / 3 * Math.PI * e * e * e, o = n / (n + a);
|
|
169
169
|
if (Math.random() < o) {
|
|
170
|
-
const
|
|
171
|
-
t[0] = Math.cos(
|
|
170
|
+
const l = Math.random() * Math.PI * 2, c = e * Math.sqrt(Math.random());
|
|
171
|
+
t[0] = Math.cos(l) * c, t[1] = (Math.random() - 0.5) * i, t[2] = Math.sin(l) * c;
|
|
172
172
|
} else {
|
|
173
|
-
const
|
|
174
|
-
t[0] = d * Math.sin(
|
|
173
|
+
const l = Math.random() * Math.PI * 2, c = Math.acos(2 * Math.random() - 1), d = e * Math.cbrt(Math.random());
|
|
174
|
+
t[0] = d * Math.sin(c) * Math.cos(l), t[1] = d * Math.cos(c), t[2] = d * Math.sin(c) * Math.sin(l), t[1] += t[1] >= 0 ? r : -r;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
_emitFromArc(t) {
|
|
178
|
-
const e = this.config.arcStartAngle || 0, i = this.config.arcEndAngle || 180, r = this.config.arcInnerRadius || 0, n = this.config.arcOuterRadius || 2, a = e * Math.PI / 180, o = i * Math.PI / 180,
|
|
179
|
-
let
|
|
180
|
-
r > 0 ?
|
|
178
|
+
const e = this.config.arcStartAngle || 0, i = this.config.arcEndAngle || 180, r = this.config.arcInnerRadius || 0, n = this.config.arcOuterRadius || 2, a = e * Math.PI / 180, o = i * Math.PI / 180, l = a + Math.random() * (o - a);
|
|
179
|
+
let c;
|
|
180
|
+
r > 0 ? c = r + (n - r) * Math.random() : c = n * Math.sqrt(Math.random()), t[0] = Math.cos(l) * c, t[1] = Math.sin(l) * c, t[2] = 0;
|
|
181
181
|
}
|
|
182
182
|
_emitFromSpiral(t) {
|
|
183
|
-
const e = this.config.spiralTurns || 3, i = this.config.spiralRadiusStart || 0.5, r = this.config.spiralRadiusEnd || 2, n = this.config.spiralHeight || 4, a = Math.random(), o = a * e * Math.PI * 2,
|
|
184
|
-
t[0] = Math.cos(o) *
|
|
183
|
+
const e = this.config.spiralTurns || 3, i = this.config.spiralRadiusStart || 0.5, r = this.config.spiralRadiusEnd || 2, n = this.config.spiralHeight || 4, a = Math.random(), o = a * e * Math.PI * 2, l = i + (r - i) * a;
|
|
184
|
+
t[0] = Math.cos(o) * l, t[1] = (a - 0.5) * n, t[2] = Math.sin(o) * l;
|
|
185
185
|
}
|
|
186
186
|
_emitFromFrustum(t) {
|
|
187
|
-
const e = this.config.frustumRadiusNear || 0.5, i = this.config.frustumRadiusFar || 2, r = this.config.frustumHeight || 4, n = Math.random() * Math.PI * 2, a = Math.random(), o = a * r,
|
|
188
|
-
t[0] = Math.cos(n) *
|
|
187
|
+
const e = this.config.frustumRadiusNear || 0.5, i = this.config.frustumRadiusFar || 2, r = this.config.frustumHeight || 4, n = Math.random() * Math.PI * 2, a = Math.random(), o = a * r, c = (e + (i - e) * a) * Math.sqrt(Math.random());
|
|
188
|
+
t[0] = Math.cos(n) * c, t[1] = o, t[2] = Math.sin(n) * c;
|
|
189
189
|
}
|
|
190
190
|
_emitFromFrustumSurface(t) {
|
|
191
191
|
const e = this.config.frustumRadiusNear ?? 0.5, i = this.config.frustumRadiusFar ?? 2, r = this.config.frustumHeight ?? 4, n = Math.random() * Math.PI * 2, a = i - e, o = e + a * 0.5;
|
|
192
|
-
let
|
|
192
|
+
let l;
|
|
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
|
-
|
|
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
|
-
const
|
|
200
|
-
t[0] = Math.cos(n) * d, t[1] =
|
|
199
|
+
const c = l * r, d = e + a * l;
|
|
200
|
+
t[0] = Math.cos(n) * d, t[1] = c, t[2] = Math.sin(n) * d;
|
|
201
201
|
}
|
|
202
202
|
_emitFromCubeSurface(t) {
|
|
203
203
|
const e = this.config.cubeSurfaceSize || 2, i = e * 0.5, r = Math.floor(Math.random() * 6), n = (Math.random() - 0.5) * e, a = (Math.random() - 0.5) * e;
|
|
@@ -229,22 +229,22 @@ class Ys {
|
|
|
229
229
|
_emitFromBoxFrame(t) {
|
|
230
230
|
const e = this.config.boxFrameSize || 2, i = e * 0.5, r = Math.floor(Math.random() * 12), a = (Math.random() - 0.5) * e, o = [[-1, -1], [-1, 1], [1, -1], [1, 1]];
|
|
231
231
|
if (r < 4) {
|
|
232
|
-
const [
|
|
233
|
-
t[0] = a, t[1] =
|
|
232
|
+
const [l, c] = o[r];
|
|
233
|
+
t[0] = a, t[1] = l * i, t[2] = c * i;
|
|
234
234
|
} else if (r < 8) {
|
|
235
|
-
const [
|
|
236
|
-
t[0] =
|
|
235
|
+
const [l, c] = o[r - 4];
|
|
236
|
+
t[0] = l * i, t[1] = a, t[2] = c * i;
|
|
237
237
|
} else {
|
|
238
|
-
const [
|
|
239
|
-
t[0] =
|
|
238
|
+
const [l, c] = o[r - 8];
|
|
239
|
+
t[0] = l * i, t[1] = c * i, t[2] = a;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
_emitFromPolygon(t) {
|
|
243
243
|
const e = Math.max(3, Math.floor(this.config.polygonSides || 6)), i = this.config.polygonRadius || 2, r = Math.floor(Math.random() * e), n = r / e * Math.PI * 2, a = (r + 1) / e * Math.PI * 2;
|
|
244
|
-
let o = Math.random(),
|
|
245
|
-
o +
|
|
246
|
-
const
|
|
247
|
-
t[0] =
|
|
244
|
+
let o = Math.random(), l = Math.random();
|
|
245
|
+
o + l > 1 && (o = 1 - o, l = 1 - l);
|
|
246
|
+
const c = o * Math.cos(n) + l * Math.cos(a), d = o * Math.sin(n) + l * Math.sin(a);
|
|
247
|
+
t[0] = c * i, t[1] = d * i, t[2] = 0;
|
|
248
248
|
}
|
|
249
249
|
_emitFromRectangle(t) {
|
|
250
250
|
const e = this.config.rectangleWidth || 2, i = this.config.rectangleHeight || 2;
|
|
@@ -256,33 +256,33 @@ class Ys {
|
|
|
256
256
|
e > 0 ? a = e + (i - e) * Math.random() : a = i * Math.sqrt(Math.random()), t[0] = Math.cos(n) * a, t[1] = (Math.random() - 0.5) * r, t[2] = Math.sin(n) * a;
|
|
257
257
|
}
|
|
258
258
|
calculateVelocity(t, e, i, r, n) {
|
|
259
|
-
const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0,
|
|
260
|
-
let
|
|
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 f, v, C;
|
|
261
261
|
if (b > 1e-4) {
|
|
262
|
-
let
|
|
262
|
+
let D = !1;
|
|
263
263
|
if (this.config.emissionShape === "circle" && this.config.circleVelocityDirection === "tangential") {
|
|
264
|
-
const
|
|
265
|
-
if (
|
|
266
|
-
const T = -
|
|
267
|
-
|
|
264
|
+
const M = this.inverseRotation(c, d, S), Z = Math.sqrt(M[0] * M[0] + M[1] * M[1]);
|
|
265
|
+
if (Z > 1e-4) {
|
|
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
|
|
271
|
-
if (
|
|
272
|
-
const T = -
|
|
273
|
-
|
|
270
|
+
const M = this.inverseRotation(c, d, S), Z = Math.sqrt(M[0] * M[0] + M[2] * M[2]);
|
|
271
|
+
if (Z > 1e-4) {
|
|
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
|
-
|
|
279
|
+
D || (f = c / b, v = d / b, C = S / b);
|
|
280
280
|
} else {
|
|
281
|
-
const
|
|
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
|
-
let
|
|
285
|
-
this.config.randomSpeed ?
|
|
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 : 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) {
|
|
@@ -295,7 +295,7 @@ class Ys {
|
|
|
295
295
|
t[e + 6] = 0, t[e + 7] = i + (Math.random() * 0.4 - 0.2) * i;
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
const
|
|
298
|
+
const Hs = `
|
|
299
299
|
struct Uniforms {
|
|
300
300
|
transform: mat4x4<f32>,
|
|
301
301
|
cameraPosition: vec3<f32>,
|
|
@@ -376,8 +376,26 @@ const js = `
|
|
|
376
376
|
@location(3) noiseOffset : vec2<f32>,
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
// Hachage SANS TRANSCENDANTAL (Dave Hoskins, « Hash without Sine »).
|
|
380
|
+
//
|
|
381
|
+
// ⚠️ LE fract(sin(dot(...))) QU'IL REMPLACE ÉTAIT LE PREMIER POSTE DE COÛT DE CE SHADER. Il est
|
|
382
|
+
// appelé QUATRE fois par valueNoise, et la distorsion en appelle DEUX : huit sin par pixel couvert.
|
|
383
|
+
// Sur un GPU mobile, sin n'est pas une instruction à un cycle — elle est souvent émulée, et elle
|
|
384
|
+
// domine tout le reste du fragment.
|
|
385
|
+
//
|
|
386
|
+
// ⚠️ ET AUCUN ACCENT GRAVE DANS CE COMMENTAIRE : on est à l'intérieur d'un littéral gabarit
|
|
387
|
+
// JavaScript. Un seul le referme, et le shader entier devient une erreur de syntaxe.
|
|
388
|
+
//
|
|
389
|
+
// Mesuré sur la map du propriétaire : 27 nuages additifs de 4,2 m qui se recouvrent, soit ~19 écrans
|
|
390
|
+
// pleins de pixels couverts — donc ~150 sin par pixel d'écran et par image. Il rapportait
|
|
391
|
+
// « ça lag pour de pauvres nuages », et éteindre le bruit supprimait le lag.
|
|
392
|
+
//
|
|
393
|
+
// Le remplaçant tient en trois lignes de fract/dot, sans aucune fonction transcendantale, et
|
|
394
|
+
// garde les mêmes propriétés statistiques (distribution uniforme, décorrélation spatiale).
|
|
379
395
|
fn hash21(p: vec2<f32>) -> f32 {
|
|
380
|
-
|
|
396
|
+
var p3 = fract(vec3<f32>(p.x, p.y, p.x) * 0.1031);
|
|
397
|
+
p3 = p3 + dot(p3, vec3<f32>(p3.y, p3.z, p3.x) + 33.33);
|
|
398
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
381
399
|
}
|
|
382
400
|
|
|
383
401
|
fn valueNoise(p: vec2<f32>) -> f32 {
|
|
@@ -719,7 +737,7 @@ const js = `
|
|
|
719
737
|
return vec4<f32>(input.color, alpha);
|
|
720
738
|
}
|
|
721
739
|
}
|
|
722
|
-
`,
|
|
740
|
+
`, Zs = `
|
|
723
741
|
struct BloomUniforms {
|
|
724
742
|
direction: vec2<f32>,
|
|
725
743
|
resolution: vec2<f32>,
|
|
@@ -779,7 +797,7 @@ const js = `
|
|
|
779
797
|
|
|
780
798
|
return result / totalWeight * 1.1;
|
|
781
799
|
}
|
|
782
|
-
`,
|
|
800
|
+
`, Ws = `
|
|
783
801
|
struct BloomIntensityUniforms {
|
|
784
802
|
intensity: f32,
|
|
785
803
|
color: vec3<f32>,
|
|
@@ -825,7 +843,7 @@ const js = `
|
|
|
825
843
|
|
|
826
844
|
return vec4<f32>(originalColor.rgb + (mappedBloom * bloomUniforms.intensity), originalColor.a);
|
|
827
845
|
}
|
|
828
|
-
`,
|
|
846
|
+
`, $s = `
|
|
829
847
|
struct BloomIntensityUniforms {
|
|
830
848
|
intensity: f32,
|
|
831
849
|
color: vec3<f32>,
|
|
@@ -866,7 +884,7 @@ const js = `
|
|
|
866
884
|
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
867
885
|
return textureSample(originalTexture, texSampler, input.texCoord);
|
|
868
886
|
}
|
|
869
|
-
`,
|
|
887
|
+
`, Js = `
|
|
870
888
|
@binding(0) @group(0) var texSampler: sampler;
|
|
871
889
|
@binding(1) @group(0) var originalTexture: texture_2d<f32>;
|
|
872
890
|
@binding(2) @group(0) var blurredTexture: texture_2d<f32>;
|
|
@@ -898,7 +916,7 @@ const js = `
|
|
|
898
916
|
let c = textureSample(originalTexture, texSampler, input.texCoord);
|
|
899
917
|
return vec4<f32>(aces(c.rgb), c.a);
|
|
900
918
|
}
|
|
901
|
-
`,
|
|
919
|
+
`, Ks = `
|
|
902
920
|
struct PhysicsUniforms {
|
|
903
921
|
deltaTime: f32,
|
|
904
922
|
particleSpeed: f32,
|
|
@@ -1108,7 +1126,7 @@ const js = `
|
|
|
1108
1126
|
particleBuffer[baseIndex + 1u] = newPos.y;
|
|
1109
1127
|
particleBuffer[baseIndex + 2u] = newPos.z;
|
|
1110
1128
|
}
|
|
1111
|
-
`,
|
|
1129
|
+
`, Qs = `
|
|
1112
1130
|
@group(0) @binding(0) var<storage, read> restData: array<f32>;
|
|
1113
1131
|
@group(0) @binding(1) var<storage, read> jointWeightsData: array<f32>;
|
|
1114
1132
|
@group(0) @binding(2) var<storage, read> jointIndicesData: array<u32>;
|
|
@@ -1165,7 +1183,7 @@ const js = `
|
|
|
1165
1183
|
outputData[outBase + 7u] = uv_v;
|
|
1166
1184
|
}
|
|
1167
1185
|
`;
|
|
1168
|
-
class
|
|
1186
|
+
class er {
|
|
1169
1187
|
constructor(t, e = 1e4) {
|
|
1170
1188
|
this.device = t, this.physicsSettings = {
|
|
1171
1189
|
deltaTime: 0.016,
|
|
@@ -1254,7 +1272,7 @@ class Ks {
|
|
|
1254
1272
|
}),
|
|
1255
1273
|
compute: {
|
|
1256
1274
|
module: this.device.createShaderModule({
|
|
1257
|
-
code:
|
|
1275
|
+
code: Ks
|
|
1258
1276
|
}),
|
|
1259
1277
|
entryPoint: "main"
|
|
1260
1278
|
}
|
|
@@ -1283,12 +1301,12 @@ class Ks {
|
|
|
1283
1301
|
updatePhysics(t, e, i, r, n, a) {
|
|
1284
1302
|
if (e <= 0 || !this.computeReady)
|
|
1285
1303
|
return;
|
|
1286
|
-
const o = this._physicsData,
|
|
1287
|
-
o[0] = t, o[1] = i.particleSpeed, o[2] =
|
|
1288
|
-
const
|
|
1304
|
+
const o = this._physicsData, l = this.physicsSettings;
|
|
1305
|
+
o[0] = t, o[1] = i.particleSpeed, o[2] = l.gravity, o[3] = l.turbulence, o[4] = l.attractorStrength, o[5] = l.damping, o[6] = l.attractorPosition[0], o[7] = l.attractorPosition[1], o[8] = l.attractorPosition[2], this._physicsDataU32View[9] = e, o[10] = l.confinementEnabled ? 1 : 0, o[11] = l.confinementShape === "sphere" ? 1 : 0, o[12] = l.confinementMode === "kill" ? 1 : 0, o[13] = l.confinementSpace === "local" ? 1 : 0, o[14] = l.confinementBoxHalfSize[0], o[15] = l.confinementBoxHalfSize[1], o[16] = l.confinementBoxHalfSize[2], o[17] = l.confinementSphereRadius, o[18] = l.confinementRestitution, o[19] = l.confinementFriction, o[20] = l.confinementCenter[0], o[21] = l.confinementCenter[1], o[22] = l.confinementCenter[2], o[23] = l.softBoundaryEnabled ? 1 : 0, o[24] = l.softBoundaryStrength, o[25] = l.softBoundaryFalloff, o[26] = i.velocityStretchEnabled ? 1 : 0, o[27] = i.velocityStretchFactor ?? 1, o[28] = 0, o[29] = 0, o[30] = 0, o[31] = 0, this.device.queue.writeBuffer(this.physicsUniformBuffer, 0, o);
|
|
1306
|
+
const c = a || this.device.createCommandEncoder({ label: "ParticlePhysicsEncoder" }), d = c.beginComputePass({ label: "ParticlePhysicsPass" });
|
|
1289
1307
|
d.setPipeline(this.computePipeline), d.setBindGroup(0, this.computeBindGroup);
|
|
1290
1308
|
const S = Math.max(1, Math.ceil(e / 64));
|
|
1291
|
-
d.dispatchWorkgroups(S, 1, 1), d.end(), a || this.device.queue.submit([
|
|
1309
|
+
d.dispatchWorkgroups(S, 1, 1), d.end(), a || this.device.queue.submit([c.finish()]), this.lastUpdateTime = performance.now() / 1e3;
|
|
1292
1310
|
}
|
|
1293
1311
|
async readbackAndProcessParticles(t, e, i, r, n) {
|
|
1294
1312
|
if (t <= 0)
|
|
@@ -1307,23 +1325,23 @@ class Ks {
|
|
|
1307
1325
|
0,
|
|
1308
1326
|
o
|
|
1309
1327
|
);
|
|
1310
|
-
const
|
|
1328
|
+
const l = t * 4 * 4;
|
|
1311
1329
|
return a.copyBufferToBuffer(
|
|
1312
1330
|
n,
|
|
1313
1331
|
0,
|
|
1314
1332
|
this._velocityStagingBuffer,
|
|
1315
1333
|
0,
|
|
1316
|
-
|
|
1334
|
+
l
|
|
1317
1335
|
), this.device.queue.submit([a.finish()]), await Promise.all([
|
|
1318
1336
|
(async () => {
|
|
1319
1337
|
await this._particleDataStagingBuffer.mapAsync(GPUMapMode.READ, 0, o);
|
|
1320
|
-
const
|
|
1321
|
-
e.set(
|
|
1338
|
+
const c = new Float32Array(this._particleDataStagingBuffer.getMappedRange(0, o));
|
|
1339
|
+
e.set(c), this._particleDataStagingBuffer.unmap();
|
|
1322
1340
|
})(),
|
|
1323
1341
|
(async () => {
|
|
1324
|
-
await this._velocityStagingBuffer.mapAsync(GPUMapMode.READ, 0,
|
|
1325
|
-
const
|
|
1326
|
-
i.set(
|
|
1342
|
+
await this._velocityStagingBuffer.mapAsync(GPUMapMode.READ, 0, l);
|
|
1343
|
+
const c = new Float32Array(this._velocityStagingBuffer.getMappedRange(0, l));
|
|
1344
|
+
i.set(c), this._velocityStagingBuffer.unmap();
|
|
1327
1345
|
})()
|
|
1328
1346
|
]), this._stagingInUse = !1, {
|
|
1329
1347
|
particleData: e,
|
|
@@ -1366,31 +1384,31 @@ class Ks {
|
|
|
1366
1384
|
return { shouldUpdate: !1 };
|
|
1367
1385
|
try {
|
|
1368
1386
|
this._renderStagingInUse = !0;
|
|
1369
|
-
const a = t * 8 * 4, o = t * 4 * 4,
|
|
1387
|
+
const a = t * 8 * 4, o = t * 4 * 4, l = this.device.createCommandEncoder({
|
|
1370
1388
|
label: "RenderReadbackEncoder"
|
|
1371
1389
|
});
|
|
1372
|
-
return
|
|
1390
|
+
return l.copyBufferToBuffer(
|
|
1373
1391
|
r,
|
|
1374
1392
|
0,
|
|
1375
1393
|
this._renderStagingParticleBuffer,
|
|
1376
1394
|
0,
|
|
1377
1395
|
a
|
|
1378
|
-
),
|
|
1396
|
+
), l.copyBufferToBuffer(
|
|
1379
1397
|
n,
|
|
1380
1398
|
0,
|
|
1381
1399
|
this._renderStagingVelocityBuffer,
|
|
1382
1400
|
0,
|
|
1383
1401
|
o
|
|
1384
|
-
), this.device.queue.submit([
|
|
1402
|
+
), this.device.queue.submit([l.finish()]), await Promise.all([
|
|
1385
1403
|
(async () => {
|
|
1386
1404
|
await this._renderStagingParticleBuffer.mapAsync(GPUMapMode.READ, 0, a);
|
|
1387
|
-
const
|
|
1388
|
-
e.set(
|
|
1405
|
+
const c = new Float32Array(this._renderStagingParticleBuffer.getMappedRange(0, a));
|
|
1406
|
+
e.set(c), this._renderStagingParticleBuffer.unmap();
|
|
1389
1407
|
})(),
|
|
1390
1408
|
(async () => {
|
|
1391
1409
|
await this._renderStagingVelocityBuffer.mapAsync(GPUMapMode.READ, 0, o);
|
|
1392
|
-
const
|
|
1393
|
-
i.set(
|
|
1410
|
+
const c = new Float32Array(this._renderStagingVelocityBuffer.getMappedRange(0, o));
|
|
1411
|
+
i.set(c), this._renderStagingVelocityBuffer.unmap();
|
|
1394
1412
|
})()
|
|
1395
1413
|
]), this._renderStagingInUse = !1, {
|
|
1396
1414
|
particleData: e,
|
|
@@ -1419,31 +1437,31 @@ class Ks {
|
|
|
1419
1437
|
return { shouldUpdate: !1 };
|
|
1420
1438
|
try {
|
|
1421
1439
|
this._scriptStagingInUse = !0;
|
|
1422
|
-
const a = t * 8 * 4, o = t * 4 * 4,
|
|
1440
|
+
const a = t * 8 * 4, o = t * 4 * 4, l = this.device.createCommandEncoder({
|
|
1423
1441
|
label: "ScriptReadbackEncoder"
|
|
1424
1442
|
});
|
|
1425
|
-
return
|
|
1443
|
+
return l.copyBufferToBuffer(
|
|
1426
1444
|
r,
|
|
1427
1445
|
0,
|
|
1428
1446
|
this._scriptStagingParticleBuffer,
|
|
1429
1447
|
0,
|
|
1430
1448
|
a
|
|
1431
|
-
),
|
|
1449
|
+
), l.copyBufferToBuffer(
|
|
1432
1450
|
n,
|
|
1433
1451
|
0,
|
|
1434
1452
|
this._scriptStagingVelocityBuffer,
|
|
1435
1453
|
0,
|
|
1436
1454
|
o
|
|
1437
|
-
), this.device.queue.submit([
|
|
1455
|
+
), this.device.queue.submit([l.finish()]), await Promise.all([
|
|
1438
1456
|
(async () => {
|
|
1439
1457
|
await this._scriptStagingParticleBuffer.mapAsync(GPUMapMode.READ, 0, a);
|
|
1440
|
-
const
|
|
1441
|
-
e.set(
|
|
1458
|
+
const c = new Float32Array(this._scriptStagingParticleBuffer.getMappedRange(0, a));
|
|
1459
|
+
e.set(c), this._scriptStagingParticleBuffer.unmap();
|
|
1442
1460
|
})(),
|
|
1443
1461
|
(async () => {
|
|
1444
1462
|
await this._scriptStagingVelocityBuffer.mapAsync(GPUMapMode.READ, 0, o);
|
|
1445
|
-
const
|
|
1446
|
-
i.set(
|
|
1463
|
+
const c = new Float32Array(this._scriptStagingVelocityBuffer.getMappedRange(0, o));
|
|
1464
|
+
i.set(c), this._scriptStagingVelocityBuffer.unmap();
|
|
1447
1465
|
})()
|
|
1448
1466
|
]), this._scriptStagingInUse = !1, { shouldUpdate: !0 };
|
|
1449
1467
|
} catch (a) {
|
|
@@ -1461,7 +1479,7 @@ class Ks {
|
|
|
1461
1479
|
t.enabled !== void 0 && (e.softBoundaryEnabled = t.enabled), t.strength !== void 0 && (e.softBoundaryStrength = t.strength), t.falloff !== void 0 && (e.softBoundaryFalloff = t.falloff);
|
|
1462
1480
|
}
|
|
1463
1481
|
}
|
|
1464
|
-
class
|
|
1482
|
+
class tr {
|
|
1465
1483
|
constructor(t) {
|
|
1466
1484
|
this.device = t, this.defaultTexture = null, this.createDefaultTexture();
|
|
1467
1485
|
}
|
|
@@ -1500,7 +1518,7 @@ class Qs {
|
|
|
1500
1518
|
t && t.label !== "defaultParticleTexture" && t.destroy();
|
|
1501
1519
|
}
|
|
1502
1520
|
}
|
|
1503
|
-
const
|
|
1521
|
+
const Wi = Object.freeze({
|
|
1504
1522
|
sin: Math.sin,
|
|
1505
1523
|
cos: Math.cos,
|
|
1506
1524
|
abs: Math.abs,
|
|
@@ -1521,7 +1539,7 @@ const Hi = Object.freeze({
|
|
|
1521
1539
|
return s + (t - s) * e;
|
|
1522
1540
|
},
|
|
1523
1541
|
smoothstep(s, t, e) {
|
|
1524
|
-
const i =
|
|
1542
|
+
const i = Wi.clamp((e - s) / (t - s), 0, 1);
|
|
1525
1543
|
return i * i * (3 - 2 * i);
|
|
1526
1544
|
}
|
|
1527
1545
|
}), Ct = /* @__PURE__ */ new Set([
|
|
@@ -1567,7 +1585,7 @@ const Hi = Object.freeze({
|
|
|
1567
1585
|
"shapeStrokeFrequency",
|
|
1568
1586
|
"shapeStrokeSpeed"
|
|
1569
1587
|
]);
|
|
1570
|
-
class
|
|
1588
|
+
class ir {
|
|
1571
1589
|
constructor(t) {
|
|
1572
1590
|
this._collection = t, this._pd = null, this._vd = null, this._pi = 0, this._vi = 0;
|
|
1573
1591
|
}
|
|
@@ -1645,9 +1663,9 @@ class er {
|
|
|
1645
1663
|
this._vd[this._vi + 2] = t, this._collection._dirty = !0;
|
|
1646
1664
|
}
|
|
1647
1665
|
}
|
|
1648
|
-
class
|
|
1666
|
+
class sr {
|
|
1649
1667
|
constructor() {
|
|
1650
|
-
this._proxy = new
|
|
1668
|
+
this._proxy = new ir(this), this._pd = null, this._vd = null, this.count = 0, this._dirty = !1;
|
|
1651
1669
|
}
|
|
1652
1670
|
_bind(t, e, i) {
|
|
1653
1671
|
this._pd = t, this._vd = e, this.count = i, this._dirty = !1;
|
|
@@ -1656,14 +1674,14 @@ class tr {
|
|
|
1656
1674
|
return t < 0 || t >= this.count ? null : this._proxy._bind(this._pd, this._vd, t);
|
|
1657
1675
|
}
|
|
1658
1676
|
}
|
|
1659
|
-
const
|
|
1660
|
-
function
|
|
1677
|
+
const rr = 1e6;
|
|
1678
|
+
function nr(s) {
|
|
1661
1679
|
let t = 0;
|
|
1662
1680
|
return s.replace(
|
|
1663
1681
|
/\b(for|while)\s*\([^)]*\)\s*\{/g,
|
|
1664
1682
|
(e) => {
|
|
1665
1683
|
const i = `__lc${t++}`;
|
|
1666
|
-
return `${e} if(++${i}>${
|
|
1684
|
+
return `${e} if(++${i}>${rr})throw new Error("Loop limit exceeded");`;
|
|
1667
1685
|
}
|
|
1668
1686
|
).replace(
|
|
1669
1687
|
/\b(for|while)\s*\([^)]*\)\s*\{/g,
|
|
@@ -1683,7 +1701,7 @@ function sr(s) {
|
|
|
1683
1701
|
const ni = /* @__PURE__ */ new Map();
|
|
1684
1702
|
for (const s of Ct)
|
|
1685
1703
|
ni.set(s.toLowerCase(), s);
|
|
1686
|
-
function
|
|
1704
|
+
function ar(s) {
|
|
1687
1705
|
const t = { value: !1 }, e = /* @__PURE__ */ new Set();
|
|
1688
1706
|
return new Proxy(s, {
|
|
1689
1707
|
get(r, n) {
|
|
@@ -1701,9 +1719,9 @@ function rr(s) {
|
|
|
1701
1719
|
if (typeof n != "string") return !0;
|
|
1702
1720
|
let o = n;
|
|
1703
1721
|
if (!Ct.has(o)) {
|
|
1704
|
-
const
|
|
1705
|
-
if (
|
|
1706
|
-
e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${
|
|
1722
|
+
const l = ni.get(o.toLowerCase());
|
|
1723
|
+
if (l)
|
|
1724
|
+
e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${l}?`)), o = l;
|
|
1707
1725
|
else
|
|
1708
1726
|
return !0;
|
|
1709
1727
|
}
|
|
@@ -1718,7 +1736,7 @@ class Gi {
|
|
|
1718
1736
|
* @param {number} maxParticles - Max particle count for pre-allocation
|
|
1719
1737
|
*/
|
|
1720
1738
|
constructor(t, e, i) {
|
|
1721
|
-
this._particles = new
|
|
1739
|
+
this._particles = new sr(), this._configProxy = ar(e), this._configSnapshot = null, this._fn = null, this._error = !1, this.compile(t);
|
|
1722
1740
|
}
|
|
1723
1741
|
/**
|
|
1724
1742
|
* Compile script source into a sandboxed function.
|
|
@@ -1734,7 +1752,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1734
1752
|
var deltaTime = __deltaTime, time = __time;
|
|
1735
1753
|
var currentFrame = __currentFrame, totalFrames = __totalFrames;
|
|
1736
1754
|
var particles = __particles, config = __config, math = __math;
|
|
1737
|
-
${
|
|
1755
|
+
${nr(t)}
|
|
1738
1756
|
};`, r = new Function(i);
|
|
1739
1757
|
this._fn = r();
|
|
1740
1758
|
} catch (e) {
|
|
@@ -1756,9 +1774,9 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1756
1774
|
if (!this._fn || this._error) return { configDirty: !1, particlesDirty: !1 };
|
|
1757
1775
|
this._particles._bind(n, a, o), this._configProxy.__resetDirty();
|
|
1758
1776
|
try {
|
|
1759
|
-
this._fn(t, e, i, r, this._particles, this._configProxy,
|
|
1760
|
-
} catch (
|
|
1761
|
-
console.warn("[ParticleScript] Runtime error:",
|
|
1777
|
+
this._fn(t, e, i, r, this._particles, this._configProxy, Wi);
|
|
1778
|
+
} catch (l) {
|
|
1779
|
+
console.warn("[ParticleScript] Runtime error:", l.message);
|
|
1762
1780
|
}
|
|
1763
1781
|
return {
|
|
1764
1782
|
configDirty: this._configProxy.__dirty,
|
|
@@ -1795,7 +1813,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1795
1813
|
this._fn = null, this._particles = null, this._configProxy = null, this._configSnapshot = null;
|
|
1796
1814
|
}
|
|
1797
1815
|
}
|
|
1798
|
-
async function
|
|
1816
|
+
async function or(s) {
|
|
1799
1817
|
const t = new DataView(s);
|
|
1800
1818
|
if (t.getUint32(0, !0) !== 1179937895)
|
|
1801
1819
|
throw new Error("Invalid GLB file: incorrect magic number");
|
|
@@ -1805,49 +1823,49 @@ async function nr(s) {
|
|
|
1805
1823
|
const r = t.getUint32(8, !0);
|
|
1806
1824
|
let n = 12, a = null, o = null;
|
|
1807
1825
|
for (; n < r; ) {
|
|
1808
|
-
const T = t.getUint32(n, !0),
|
|
1809
|
-
if (
|
|
1810
|
-
const
|
|
1811
|
-
a = JSON.parse(
|
|
1812
|
-
} else
|
|
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
|
+
a = JSON.parse(se);
|
|
1830
|
+
} else G === 5130562 && (o = F);
|
|
1813
1831
|
n += 8 + T;
|
|
1814
1832
|
}
|
|
1815
1833
|
if (!a)
|
|
1816
1834
|
throw new Error("GLB file missing JSON chunk");
|
|
1817
1835
|
if (!a.meshes || a.meshes.length === 0)
|
|
1818
1836
|
throw new Error("GLB file contains no meshes");
|
|
1819
|
-
const
|
|
1820
|
-
if (!
|
|
1837
|
+
const c = a.meshes[0].primitives[0];
|
|
1838
|
+
if (!c)
|
|
1821
1839
|
throw new Error("First mesh has no primitives");
|
|
1822
|
-
const d =
|
|
1840
|
+
const d = c.attributes.POSITION;
|
|
1823
1841
|
if (d === void 0)
|
|
1824
1842
|
throw new Error("Mesh primitive missing POSITION attribute");
|
|
1825
1843
|
const S = ti(a, o, d, 3, 5126);
|
|
1826
1844
|
let b;
|
|
1827
|
-
if (
|
|
1828
|
-
b = ti(a, o,
|
|
1845
|
+
if (c.attributes.NORMAL !== void 0)
|
|
1846
|
+
b = ti(a, o, c.attributes.NORMAL, 3, 5126);
|
|
1829
1847
|
else {
|
|
1830
|
-
const T =
|
|
1848
|
+
const T = c.indices;
|
|
1831
1849
|
if (T === void 0)
|
|
1832
1850
|
throw new Error("Cannot generate normals without indices");
|
|
1833
|
-
const
|
|
1834
|
-
b =
|
|
1851
|
+
const G = Fi(a, o, T);
|
|
1852
|
+
b = lr(S, G);
|
|
1835
1853
|
}
|
|
1836
|
-
const
|
|
1837
|
-
if (
|
|
1854
|
+
const f = c.indices;
|
|
1855
|
+
if (f === void 0)
|
|
1838
1856
|
throw new Error("Mesh primitive missing indices");
|
|
1839
|
-
const v =
|
|
1840
|
-
let
|
|
1841
|
-
|
|
1842
|
-
let
|
|
1857
|
+
const v = Fi(a, o, f), C = S.length / 3, z = v.length;
|
|
1858
|
+
let D = null;
|
|
1859
|
+
c.attributes.TEXCOORD_0 !== void 0 && (D = ti(a, o, c.attributes.TEXCOORD_0, 2, 5126));
|
|
1860
|
+
let M = !1;
|
|
1843
1861
|
if (a.materials && a.materials.length > 0) {
|
|
1844
1862
|
const T = a.materials[0];
|
|
1845
|
-
T.pbrMetallicRoughness && T.pbrMetallicRoughness.baseColorTexture !== void 0 && (
|
|
1863
|
+
T.pbrMetallicRoughness && T.pbrMetallicRoughness.baseColorTexture !== void 0 && (M = !0);
|
|
1846
1864
|
}
|
|
1847
|
-
let
|
|
1865
|
+
let Z = null;
|
|
1848
1866
|
if (a.skins && a.skins.length > 0)
|
|
1849
1867
|
try {
|
|
1850
|
-
|
|
1868
|
+
Z = hr(a, o, c), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", Z);
|
|
1851
1869
|
} catch (T) {
|
|
1852
1870
|
console.warn("Failed to extract animation data:", T);
|
|
1853
1871
|
}
|
|
@@ -1855,11 +1873,11 @@ async function nr(s) {
|
|
|
1855
1873
|
positions: S,
|
|
1856
1874
|
normals: b,
|
|
1857
1875
|
indices: v,
|
|
1858
|
-
texCoords:
|
|
1859
|
-
vertexCount:
|
|
1860
|
-
indexCount:
|
|
1861
|
-
animationData:
|
|
1862
|
-
hasBaseColorTexture:
|
|
1876
|
+
texCoords: D,
|
|
1877
|
+
vertexCount: C,
|
|
1878
|
+
indexCount: z,
|
|
1879
|
+
animationData: Z,
|
|
1880
|
+
hasBaseColorTexture: M
|
|
1863
1881
|
};
|
|
1864
1882
|
}
|
|
1865
1883
|
function ti(s, t, e, i, r) {
|
|
@@ -1873,137 +1891,137 @@ function ti(s, t, e, i, r) {
|
|
|
1873
1891
|
throw new Error(`Attribute accessor type mismatch: expected ${i} components, got ${o}`);
|
|
1874
1892
|
if (n.componentType !== r)
|
|
1875
1893
|
throw new Error(`Attribute component type mismatch: expected ${r}, got ${n.componentType}`);
|
|
1876
|
-
const
|
|
1877
|
-
for (let
|
|
1878
|
-
b[
|
|
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 f = 0; f < d * i; f++)
|
|
1896
|
+
b[f] = S.getFloat32(f * 4, !0);
|
|
1879
1897
|
return b;
|
|
1880
1898
|
}
|
|
1881
|
-
function
|
|
1899
|
+
function Fi(s, t, e) {
|
|
1882
1900
|
const i = s.accessors[e];
|
|
1883
1901
|
if (i.type !== "SCALAR")
|
|
1884
1902
|
throw new Error(`Indices accessor must be SCALAR, got ${i.type}`);
|
|
1885
1903
|
const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count;
|
|
1886
1904
|
if (i.componentType === 5123) {
|
|
1887
|
-
const o = new DataView(t, n, a * 2),
|
|
1888
|
-
for (let
|
|
1889
|
-
c
|
|
1890
|
-
return
|
|
1905
|
+
const o = new DataView(t, n, a * 2), l = new Uint16Array(a);
|
|
1906
|
+
for (let c = 0; c < a; c++)
|
|
1907
|
+
l[c] = o.getUint16(c * 2, !0);
|
|
1908
|
+
return l;
|
|
1891
1909
|
} else if (i.componentType === 5125) {
|
|
1892
|
-
const o = new DataView(t, n, a * 4),
|
|
1893
|
-
for (let
|
|
1894
|
-
c
|
|
1895
|
-
return
|
|
1910
|
+
const o = new DataView(t, n, a * 4), l = new Uint32Array(a);
|
|
1911
|
+
for (let c = 0; c < a; c++)
|
|
1912
|
+
l[c] = o.getUint32(c * 4, !0);
|
|
1913
|
+
return l;
|
|
1896
1914
|
} else
|
|
1897
1915
|
throw new Error(`Unsupported index component type: ${i.componentType}`);
|
|
1898
1916
|
}
|
|
1899
|
-
function
|
|
1917
|
+
function lr(s, t) {
|
|
1900
1918
|
const e = new Float32Array(s.length);
|
|
1901
1919
|
for (let i = 0; i < t.length; i += 3) {
|
|
1902
|
-
const r = t[i] * 3, n = t[i + 1] * 3, a = t[i + 2] * 3, o = [s[r], s[r + 1], s[r + 2]],
|
|
1920
|
+
const r = t[i] * 3, n = t[i + 1] * 3, a = t[i + 2] * 3, o = [s[r], s[r + 1], s[r + 2]], l = [s[n], s[n + 1], s[n + 2]], c = [s[a], s[a + 1], s[a + 2]], d = [l[0] - o[0], l[1] - o[1], l[2] - o[2]], S = [c[0] - o[0], c[1] - o[1], c[2] - o[2]], b = [
|
|
1903
1921
|
d[1] * S[2] - d[2] * S[1],
|
|
1904
1922
|
d[2] * S[0] - d[0] * S[2],
|
|
1905
1923
|
d[0] * S[1] - d[1] * S[0]
|
|
1906
|
-
],
|
|
1907
|
-
|
|
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];
|
|
1908
1926
|
}
|
|
1909
1927
|
return e;
|
|
1910
1928
|
}
|
|
1911
|
-
function
|
|
1929
|
+
function cr(s, t, e) {
|
|
1912
1930
|
const i = s.accessors[e];
|
|
1913
1931
|
if (i.type !== "VEC4")
|
|
1914
1932
|
throw new Error(`JOINTS_0 must be VEC4, got ${i.type}`);
|
|
1915
1933
|
const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count;
|
|
1916
1934
|
if (i.componentType === 5121) {
|
|
1917
|
-
const o = new DataView(t, n, a * 4),
|
|
1918
|
-
for (let
|
|
1919
|
-
c
|
|
1920
|
-
return
|
|
1935
|
+
const o = new DataView(t, n, a * 4), l = new Uint8Array(a * 4);
|
|
1936
|
+
for (let c = 0; c < a * 4; c++)
|
|
1937
|
+
l[c] = o.getUint8(c);
|
|
1938
|
+
return l;
|
|
1921
1939
|
} else if (i.componentType === 5123) {
|
|
1922
|
-
const o = new DataView(t, n, a * 8),
|
|
1923
|
-
for (let
|
|
1924
|
-
c
|
|
1925
|
-
return
|
|
1940
|
+
const o = new DataView(t, n, a * 8), l = new Uint8Array(a * 4);
|
|
1941
|
+
for (let c = 0; c < a * 4; c++)
|
|
1942
|
+
l[c] = o.getUint16(c * 2, !0);
|
|
1943
|
+
return l;
|
|
1926
1944
|
} else
|
|
1927
1945
|
throw new Error(`Unsupported JOINTS_0 component type: ${i.componentType}`);
|
|
1928
1946
|
}
|
|
1929
|
-
function
|
|
1947
|
+
function ur(s, t, e) {
|
|
1930
1948
|
const i = s.accessors[e];
|
|
1931
1949
|
if (i.type !== "VEC4")
|
|
1932
1950
|
throw new Error(`WEIGHTS_0 must be VEC4, got ${i.type}`);
|
|
1933
1951
|
const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count;
|
|
1934
1952
|
if (i.componentType === 5126) {
|
|
1935
|
-
const o = new DataView(t, n, a * 16),
|
|
1936
|
-
for (let
|
|
1937
|
-
c
|
|
1938
|
-
return
|
|
1953
|
+
const o = new DataView(t, n, a * 16), l = new Float32Array(a * 4);
|
|
1954
|
+
for (let c = 0; c < a * 4; c++)
|
|
1955
|
+
l[c] = o.getFloat32(c * 4, !0);
|
|
1956
|
+
return l;
|
|
1939
1957
|
} else if (i.componentType === 5121) {
|
|
1940
|
-
const o = new DataView(t, n, a * 4),
|
|
1941
|
-
for (let
|
|
1942
|
-
c
|
|
1943
|
-
return
|
|
1958
|
+
const o = new DataView(t, n, a * 4), l = new Float32Array(a * 4);
|
|
1959
|
+
for (let c = 0; c < a * 4; c++)
|
|
1960
|
+
l[c] = o.getUint8(c) / 255;
|
|
1961
|
+
return l;
|
|
1944
1962
|
} else
|
|
1945
1963
|
throw new Error(`Unsupported WEIGHTS_0 component type: ${i.componentType}`);
|
|
1946
1964
|
}
|
|
1947
|
-
function
|
|
1965
|
+
function dr(s, t, e) {
|
|
1948
1966
|
const i = s.accessors[e];
|
|
1949
1967
|
if (i.type !== "MAT4")
|
|
1950
1968
|
throw new Error(`Expected MAT4, got ${i.type}`);
|
|
1951
1969
|
if (i.componentType !== 5126)
|
|
1952
1970
|
throw new Error(`Expected FLOAT component type for MAT4, got ${i.componentType}`);
|
|
1953
|
-
const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count, o = new DataView(t, n, a * 64),
|
|
1954
|
-
for (let
|
|
1955
|
-
c
|
|
1956
|
-
return
|
|
1971
|
+
const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count, o = new DataView(t, n, a * 64), l = new Float32Array(a * 16);
|
|
1972
|
+
for (let c = 0; c < a * 16; c++)
|
|
1973
|
+
l[c] = o.getFloat32(c * 4, !0);
|
|
1974
|
+
return l;
|
|
1957
1975
|
}
|
|
1958
|
-
function
|
|
1976
|
+
function fr(s, t, e) {
|
|
1959
1977
|
const i = s.accessors[e];
|
|
1960
1978
|
if (i.type !== "SCALAR")
|
|
1961
1979
|
throw new Error(`Expected SCALAR, got ${i.type}`);
|
|
1962
1980
|
if (i.componentType !== 5126)
|
|
1963
1981
|
throw new Error(`Expected FLOAT component type for SCALAR, got ${i.componentType}`);
|
|
1964
|
-
const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count, o = new DataView(t, n, a * 4),
|
|
1965
|
-
for (let
|
|
1966
|
-
c
|
|
1967
|
-
return
|
|
1982
|
+
const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count, o = new DataView(t, n, a * 4), l = new Float32Array(a);
|
|
1983
|
+
for (let c = 0; c < a; c++)
|
|
1984
|
+
l[c] = o.getFloat32(c * 4, !0);
|
|
1985
|
+
return l;
|
|
1968
1986
|
}
|
|
1969
|
-
function
|
|
1987
|
+
function pr(s, t, e) {
|
|
1970
1988
|
const i = s.accessors[e], n = { VEC3: 3, VEC4: 4 }[i.type];
|
|
1971
1989
|
if (!n)
|
|
1972
1990
|
throw new Error(`Expected VEC3 or VEC4, got ${i.type}`);
|
|
1973
1991
|
if (i.componentType !== 5126)
|
|
1974
1992
|
throw new Error(`Expected FLOAT component type, got ${i.componentType}`);
|
|
1975
|
-
const o = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0),
|
|
1976
|
-
for (let S = 0; S <
|
|
1977
|
-
d[S] =
|
|
1993
|
+
const o = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), l = i.count, c = new DataView(t, o, l * n * 4), d = new Float32Array(l * n);
|
|
1994
|
+
for (let S = 0; S < l * n; S++)
|
|
1995
|
+
d[S] = c.getFloat32(S * 4, !0);
|
|
1978
1996
|
return d;
|
|
1979
1997
|
}
|
|
1980
|
-
function
|
|
1981
|
-
const i = s.skins[0], r = i.joints, n =
|
|
1998
|
+
function hr(s, t, e) {
|
|
1999
|
+
const i = s.skins[0], r = i.joints, n = dr(s, t, i.inverseBindMatrices), a = e.attributes.JOINTS_0 !== void 0 ? cr(s, t, e.attributes.JOINTS_0) : null, o = e.attributes.WEIGHTS_0 !== void 0 ? ur(s, t, e.attributes.WEIGHTS_0) : null;
|
|
1982
2000
|
if (!a || !o)
|
|
1983
2001
|
throw new Error("Mesh missing JOINTS_0 or WEIGHTS_0 attributes");
|
|
1984
|
-
const
|
|
2002
|
+
const l = s.nodes.map((d) => ({
|
|
1985
2003
|
translation: d.translation || [0, 0, 0],
|
|
1986
2004
|
rotation: d.rotation || [0, 0, 0, 1],
|
|
1987
2005
|
scale: d.scale || [1, 1, 1],
|
|
1988
2006
|
children: d.children || [],
|
|
1989
2007
|
name: d.name || ""
|
|
1990
|
-
})),
|
|
2008
|
+
})), c = [];
|
|
1991
2009
|
if (s.animations && s.animations.length > 0)
|
|
1992
2010
|
for (const d of s.animations) {
|
|
1993
2011
|
const S = [];
|
|
1994
2012
|
let b = 0;
|
|
1995
|
-
for (const
|
|
1996
|
-
const v = d.samplers[
|
|
1997
|
-
|
|
1998
|
-
targetNode:
|
|
1999
|
-
targetPath:
|
|
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
|
+
D > b && (b = D), S.push({
|
|
2016
|
+
targetNode: f.target.node,
|
|
2017
|
+
targetPath: f.target.path,
|
|
2000
2018
|
interpolation: v.interpolation || "LINEAR",
|
|
2001
|
-
timestamps:
|
|
2002
|
-
values:
|
|
2019
|
+
timestamps: C,
|
|
2020
|
+
values: z
|
|
2003
2021
|
});
|
|
2004
2022
|
}
|
|
2005
|
-
|
|
2006
|
-
name: d.name || `Animation ${
|
|
2023
|
+
c.push({
|
|
2024
|
+
name: d.name || `Animation ${c.length}`,
|
|
2007
2025
|
duration: b,
|
|
2008
2026
|
channels: S
|
|
2009
2027
|
});
|
|
@@ -2013,8 +2031,8 @@ function fr(s, t, e) {
|
|
|
2013
2031
|
inverseBindMatrices: n,
|
|
2014
2032
|
jointIndices: a,
|
|
2015
2033
|
jointWeights: o,
|
|
2016
|
-
nodes:
|
|
2017
|
-
animations:
|
|
2034
|
+
nodes: l,
|
|
2035
|
+
animations: c
|
|
2018
2036
|
};
|
|
2019
2037
|
}
|
|
2020
2038
|
async function Vi(s) {
|
|
@@ -2027,38 +2045,38 @@ async function Vi(s) {
|
|
|
2027
2045
|
const r = t.getUint32(8, !0);
|
|
2028
2046
|
let n = 12, a = null, o = null;
|
|
2029
2047
|
for (; n < r; ) {
|
|
2030
|
-
const
|
|
2048
|
+
const Z = t.getUint32(n, !0), T = t.getUint32(n + 4, !0), G = s.slice(n + 8, n + 8 + Z);
|
|
2031
2049
|
if (T === 1313821514) {
|
|
2032
|
-
const H = new TextDecoder("utf-8").decode(
|
|
2050
|
+
const H = new TextDecoder("utf-8").decode(G);
|
|
2033
2051
|
a = JSON.parse(H);
|
|
2034
|
-
} else T === 5130562 && (o =
|
|
2035
|
-
n += 8 +
|
|
2052
|
+
} else T === 5130562 && (o = G);
|
|
2053
|
+
n += 8 + Z;
|
|
2036
2054
|
}
|
|
2037
2055
|
if (!a)
|
|
2038
2056
|
throw new Error("GLB file missing JSON chunk");
|
|
2039
2057
|
if (!a.materials || a.materials.length === 0)
|
|
2040
2058
|
return null;
|
|
2041
|
-
const
|
|
2042
|
-
if (!
|
|
2059
|
+
const l = a.materials[0];
|
|
2060
|
+
if (!l.pbrMetallicRoughness || l.pbrMetallicRoughness.baseColorTexture === void 0)
|
|
2043
2061
|
return null;
|
|
2044
|
-
const
|
|
2045
|
-
if (!a.textures || !a.textures[
|
|
2062
|
+
const c = l.pbrMetallicRoughness.baseColorTexture.index;
|
|
2063
|
+
if (!a.textures || !a.textures[c])
|
|
2046
2064
|
return null;
|
|
2047
|
-
const S = a.textures[
|
|
2065
|
+
const S = a.textures[c].source;
|
|
2048
2066
|
if (S === void 0 || !a.images || !a.images[S])
|
|
2049
2067
|
return null;
|
|
2050
|
-
const b = a.images[S],
|
|
2068
|
+
const b = a.images[S], f = b.mimeType || "image/png";
|
|
2051
2069
|
if (b.bufferView === void 0)
|
|
2052
2070
|
return null;
|
|
2053
2071
|
if (!o)
|
|
2054
2072
|
throw new Error("GLB file missing BIN chunk (required for embedded textures)");
|
|
2055
|
-
const v = a.bufferViews[b.bufferView],
|
|
2056
|
-
return { imageBlob: new Blob([
|
|
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: f }), mimeType: f };
|
|
2057
2075
|
}
|
|
2058
|
-
function
|
|
2076
|
+
function mr(s, t, e, i) {
|
|
2059
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;
|
|
2060
2078
|
}
|
|
2061
|
-
function
|
|
2079
|
+
function yr(s, t, e, i) {
|
|
2062
2080
|
i = i || [0, 0, 0, 0];
|
|
2063
2081
|
let r = s[0] * t[0] + s[1] * t[1] + s[2] * t[2] + s[3] * t[3], n = 1;
|
|
2064
2082
|
if (r < 0 && (r = -r, n = -1), r > 0.9995) {
|
|
@@ -2066,16 +2084,16 @@ function hr(s, t, e, i) {
|
|
|
2066
2084
|
const d = Math.sqrt(i[0] * i[0] + i[1] * i[1] + i[2] * i[2] + i[3] * i[3]);
|
|
2067
2085
|
return d > 1e-4 ? (i[0] /= d, i[1] /= d, i[2] /= d, i[3] /= d) : (i[0] = 0, i[1] = 0, i[2] = 0, i[3] = 1), i;
|
|
2068
2086
|
}
|
|
2069
|
-
const a = Math.acos(r), o = Math.sin(a),
|
|
2070
|
-
return i[0] = s[0] *
|
|
2087
|
+
const a = Math.acos(r), o = Math.sin(a), l = Math.sin((1 - e) * a) / o, c = Math.sin(e * a) / o;
|
|
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;
|
|
2071
2089
|
}
|
|
2072
|
-
function
|
|
2073
|
-
const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i,
|
|
2074
|
-
return
|
|
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, 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;
|
|
2075
2093
|
}
|
|
2076
|
-
const
|
|
2077
|
-
function
|
|
2078
|
-
const r =
|
|
2094
|
+
const br = new Float32Array(16);
|
|
2095
|
+
function Sr(s, t, e, i) {
|
|
2096
|
+
const r = gr(t, br), n = i || new Float32Array(16);
|
|
2079
2097
|
return n[0] = r[0] * e[0], n[1] = r[1] * e[0], n[2] = r[2] * e[0], n[3] = 0, n[4] = r[4] * e[1], n[5] = r[5] * e[1], n[6] = r[6] * e[1], n[7] = 0, n[8] = r[8] * e[2], n[9] = r[9] * e[2], n[10] = r[10] * e[2], n[11] = 0, n[12] = s[0], n[13] = s[1], n[14] = s[2], n[15] = 1, n;
|
|
2080
2098
|
}
|
|
2081
2099
|
function Oi(s, t, e) {
|
|
@@ -2085,7 +2103,7 @@ function Oi(s, t, e) {
|
|
|
2085
2103
|
i[r * 4 + n] = s[0 + n] * t[r * 4 + 0] + s[4 + n] * t[r * 4 + 1] + s[8 + n] * t[r * 4 + 2] + s[12 + n] * t[r * 4 + 3];
|
|
2086
2104
|
return i;
|
|
2087
2105
|
}
|
|
2088
|
-
class
|
|
2106
|
+
class xr {
|
|
2089
2107
|
constructor(t) {
|
|
2090
2108
|
this.joints = t.joints, this.inverseBindMatrices = t.inverseBindMatrices, this.jointWeights = t.jointWeights, this.jointIndices = t.jointIndices, this.nodes = t.nodes, this.animations = t.animations, this.restPositions = null, this.restNormals = null, this.currentAnimIndex = 0, this.currentTime = 0, this.playing = !0, this.speed = 1, this.loop = !0, this.jointLocalTransforms = new Array(this.nodes.length), this.jointGlobalTransforms = new Array(this.nodes.length), this.jointFinalMatrices = new Array(this.joints.length);
|
|
2091
2109
|
for (let e = 0; e < this.nodes.length; e++)
|
|
@@ -2115,9 +2133,9 @@ class br {
|
|
|
2115
2133
|
try {
|
|
2116
2134
|
this._gpuDevice = t, this._gpuOutputBuffer = e;
|
|
2117
2135
|
const r = this.restPositions.length / 3, n = new Float32Array(r * 8);
|
|
2118
|
-
for (let
|
|
2119
|
-
const
|
|
2120
|
-
n[
|
|
2136
|
+
for (let l = 0; l < r; l++) {
|
|
2137
|
+
const c = l * 8, d = l * 3, S = l * 2;
|
|
2138
|
+
n[c] = this.restPositions[d], n[c + 1] = this.restPositions[d + 1], n[c + 2] = this.restPositions[d + 2], n[c + 3] = this.restNormals[d], n[c + 4] = this.restNormals[d + 1], n[c + 5] = this.restNormals[d + 2], n[c + 6] = i ? i[S] : 0, n[c + 7] = i ? i[S + 1] : 0;
|
|
2121
2139
|
}
|
|
2122
2140
|
this._gpuRestDataBuffer = t.createBuffer({
|
|
2123
2141
|
size: n.byteLength,
|
|
@@ -2129,8 +2147,8 @@ class br {
|
|
|
2129
2147
|
label: "skinning_jointWeights"
|
|
2130
2148
|
}), t.queue.writeBuffer(this._gpuJointWeightsBuffer, 0, this.jointWeights);
|
|
2131
2149
|
const a = new Uint32Array(this.jointIndices.length);
|
|
2132
|
-
for (let
|
|
2133
|
-
a[
|
|
2150
|
+
for (let l = 0; l < this.jointIndices.length; l++)
|
|
2151
|
+
a[l] = this.jointIndices[l];
|
|
2134
2152
|
this._gpuJointIndicesBuffer = t.createBuffer({
|
|
2135
2153
|
size: a.byteLength,
|
|
2136
2154
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
@@ -2152,7 +2170,7 @@ class br {
|
|
|
2152
2170
|
this._gpuSkinningPipeline = t.createComputePipeline({
|
|
2153
2171
|
layout: t.createPipelineLayout({ bindGroupLayouts: [o] }),
|
|
2154
2172
|
compute: {
|
|
2155
|
-
module: t.createShaderModule({ code:
|
|
2173
|
+
module: t.createShaderModule({ code: Qs }),
|
|
2156
2174
|
entryPoint: "main"
|
|
2157
2175
|
}
|
|
2158
2176
|
}), this._gpuSkinningBindGroup = t.createBindGroup({
|
|
@@ -2240,13 +2258,13 @@ class br {
|
|
|
2240
2258
|
return this._extractValue(n, 0, o, i);
|
|
2241
2259
|
if (e >= r[r.length - 1])
|
|
2242
2260
|
return this._extractValue(n, r.length - 1, o, i);
|
|
2243
|
-
let
|
|
2244
|
-
for (;
|
|
2245
|
-
const
|
|
2246
|
-
r[
|
|
2261
|
+
let l = 0, c = r.length - 1;
|
|
2262
|
+
for (; c - l > 1; ) {
|
|
2263
|
+
const C = Math.floor((l + c) / 2);
|
|
2264
|
+
r[C] <= e ? l = C : c = C;
|
|
2247
2265
|
}
|
|
2248
|
-
const d = r[
|
|
2249
|
-
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);
|
|
2250
2268
|
}
|
|
2251
2269
|
/**
|
|
2252
2270
|
* Extract value from values array at the given index.
|
|
@@ -2269,9 +2287,9 @@ class br {
|
|
|
2269
2287
|
for (let i = 0; i < this.nodes.length; i++) {
|
|
2270
2288
|
const r = this.nodes[i];
|
|
2271
2289
|
let n = r.translation, a = r.rotation, o = r.scale;
|
|
2272
|
-
for (const
|
|
2273
|
-
|
|
2274
|
-
|
|
2290
|
+
for (const l of e.channels)
|
|
2291
|
+
l.targetNode === i && (l.targetPath === "translation" ? n = this._sampleChannel(l, t, this._scrT) : l.targetPath === "rotation" ? a = this._sampleChannel(l, t, this._scrR) : l.targetPath === "scale" && (o = this._sampleChannel(l, t, this._scrS)));
|
|
2292
|
+
Sr(n, a, o, this.jointLocalTransforms[i]);
|
|
2275
2293
|
}
|
|
2276
2294
|
}
|
|
2277
2295
|
/**
|
|
@@ -2302,22 +2320,22 @@ class br {
|
|
|
2302
2320
|
* Inlined math, no temporary array allocations.
|
|
2303
2321
|
*/
|
|
2304
2322
|
_applySkinning() {
|
|
2305
|
-
const t = this.restPositions.length / 3, e = this.restPositions, i = this.restNormals, r = this.skinnedPositions, n = this.skinnedNormals, a = this.jointWeights, o = this.jointIndices,
|
|
2306
|
-
for (let
|
|
2307
|
-
const d =
|
|
2308
|
-
let
|
|
2309
|
-
for (let
|
|
2310
|
-
const
|
|
2311
|
-
if (
|
|
2312
|
-
const q =
|
|
2313
|
-
|
|
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
|
+
for (let c = 0; c < t; c++) {
|
|
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
|
+
for (let ne = 0; ne < 4; ne++) {
|
|
2328
|
+
const re = a[S + ne];
|
|
2329
|
+
if (re === 0) continue;
|
|
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;
|
|
2314
2332
|
}
|
|
2315
|
-
const
|
|
2316
|
-
|
|
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;
|
|
2317
2335
|
}
|
|
2318
2336
|
}
|
|
2319
2337
|
}
|
|
2320
|
-
class
|
|
2338
|
+
class vr {
|
|
2321
2339
|
constructor({ duration: t = 0, loop: e = !1, playbackRate: i = 1 } = {}) {
|
|
2322
2340
|
this.currentTime = 0, this.duration = t, this.loop = e, this.playbackRate = i, this.paused = !1, this._justLooped = !1;
|
|
2323
2341
|
}
|
|
@@ -2357,26 +2375,26 @@ const Li = {
|
|
|
2357
2375
|
return Math.pow(2, -10 * s) * Math.sin((s * 10 - 0.75) * t) + 1;
|
|
2358
2376
|
}
|
|
2359
2377
|
};
|
|
2360
|
-
function
|
|
2361
|
-
const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t,
|
|
2362
|
-
return (
|
|
2363
|
-
if (
|
|
2364
|
-
if (
|
|
2365
|
-
let v =
|
|
2366
|
-
for (let
|
|
2367
|
-
const
|
|
2368
|
-
if (Math.abs(
|
|
2369
|
-
const
|
|
2370
|
-
if (Math.abs(
|
|
2371
|
-
v -=
|
|
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 = (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
|
+
for (let C = 0; C < 8; C++) {
|
|
2385
|
+
const z = d(v) - f;
|
|
2386
|
+
if (Math.abs(z) < 1e-5) break;
|
|
2387
|
+
const D = b(v);
|
|
2388
|
+
if (Math.abs(D) < 1e-6) break;
|
|
2389
|
+
v -= z / D;
|
|
2372
2390
|
}
|
|
2373
2391
|
return S(v);
|
|
2374
2392
|
};
|
|
2375
2393
|
}
|
|
2376
|
-
function
|
|
2377
|
-
return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ?
|
|
2394
|
+
function $i(s, t) {
|
|
2395
|
+
return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ? Pr(s[0], s[1], s[2], s[3])(t) : (Li[s] || Li.linear)(t);
|
|
2378
2396
|
}
|
|
2379
|
-
function
|
|
2397
|
+
function _r(s, t) {
|
|
2380
2398
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2381
2399
|
if (s.length === 1 || t <= s[0].t) return s[0].v;
|
|
2382
2400
|
const e = s[s.length - 1];
|
|
@@ -2385,12 +2403,12 @@ function vr(s, t) {
|
|
|
2385
2403
|
const r = s[i], n = s[i + 1];
|
|
2386
2404
|
if (t >= r.t && t <= n.t) {
|
|
2387
2405
|
const a = n.t - r.t, o = a > 0 ? (t - r.t) / a : 0;
|
|
2388
|
-
return r.v + (n.v - r.v) *
|
|
2406
|
+
return r.v + (n.v - r.v) * $i(r.ease, o);
|
|
2389
2407
|
}
|
|
2390
2408
|
}
|
|
2391
2409
|
return e.v;
|
|
2392
2410
|
}
|
|
2393
|
-
function
|
|
2411
|
+
function Mr(s, t, e) {
|
|
2394
2412
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2395
2413
|
const i = s.length, r = s[i - 1];
|
|
2396
2414
|
let n, a, o;
|
|
@@ -2401,18 +2419,18 @@ function Pr(s, t, e) {
|
|
|
2401
2419
|
else {
|
|
2402
2420
|
n = a = r.v, o = 0;
|
|
2403
2421
|
for (let S = 0; S < i - 1; S++) {
|
|
2404
|
-
const b = s[S],
|
|
2405
|
-
if (t >= b.t && t <=
|
|
2406
|
-
const v =
|
|
2407
|
-
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);
|
|
2408
2426
|
break;
|
|
2409
2427
|
}
|
|
2410
2428
|
}
|
|
2411
2429
|
}
|
|
2412
|
-
const
|
|
2413
|
-
return e ? (e[0] =
|
|
2430
|
+
const l = n[0] + (a[0] - n[0]) * o, c = n[1] + (a[1] - n[1]) * o, d = n[2] + (a[2] - n[2]) * o;
|
|
2431
|
+
return e ? (e[0] = l, e[1] = c, e[2] = d, e) : [l, c, d];
|
|
2414
2432
|
}
|
|
2415
|
-
const
|
|
2433
|
+
const wr = [
|
|
2416
2434
|
"gravityStrength",
|
|
2417
2435
|
"emissionRate",
|
|
2418
2436
|
"damping",
|
|
@@ -2447,7 +2465,7 @@ const _r = [
|
|
|
2447
2465
|
"shapeStrokeAmplitude",
|
|
2448
2466
|
"shapeStrokeFrequency",
|
|
2449
2467
|
"shapeStrokeSpeed"
|
|
2450
|
-
],
|
|
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 };
|
|
2451
2469
|
function ki(s) {
|
|
2452
2470
|
const t = atob(s), e = new Uint8Array(t.length);
|
|
2453
2471
|
for (let i = 0; i < t.length; i++)
|
|
@@ -2480,7 +2498,7 @@ class ii {
|
|
|
2480
2498
|
// intensity (f32) + padding
|
|
2481
2499
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
2482
2500
|
label: "systemBloomIntensityBuffer"
|
|
2483
|
-
}), e.overrideXVelocity === void 0 && (e.overrideXVelocity = !1), e.overrideYVelocity === void 0 && (e.overrideYVelocity = !1), e.overrideZVelocity === void 0 && (e.overrideZVelocity = !1), e.xVelocity === void 0 && (e.xVelocity = 0), e.yVelocity === void 0 && (e.yVelocity = 0), e.zVelocity === void 0 && (e.zVelocity = 0), e.textureEnabled === void 0 && (e.textureEnabled = !1), e.glbModelEnabled === void 0 && (e.glbModelEnabled = !1), e.textureType === void 0 && (e.textureType = "image"), e.glbFileName === void 0 && (e.glbFileName = null), e.animationIndex === void 0 && (e.animationIndex = 0), e.animationSpeed === void 0 && (e.animationSpeed = 1), e.animationLoop === void 0 && (e.animationLoop = !0), e.useGlbTexture === void 0 && (e.useGlbTexture = !1), e.glbHasTexture === void 0 && (e.glbHasTexture = !1), e.particleShape === void 0 && (e.particleShape = "square"), e.particleShapeRotation !== void 0 && (e.rotation = (e.rotation || 0) + e.particleShapeRotation, delete e.particleShapeRotation), e.particleShapeRotationX === void 0 && (e.particleShapeRotationX = 0), e.particleShapeRotationY === void 0 && (e.particleShapeRotationY = 0), e.particleShapeRotationZ === void 0 && (e.particleShapeRotationZ = 0), e.particleColor === void 0 && (e.particleColor = [1, 1, 1]), e.startColor === void 0 && (e.startColor = [1, 0, 0]), e.endColor === void 0 && (e.endColor = [0, 0, 1]), e.fadeEnabled === void 0 && (e.fadeEnabled = !0), e.colorTransitionEnabled === void 0 && (e.colorTransitionEnabled = !1), e.randomColorEnabled === void 0 && (e.randomColorEnabled = !1), e.randomColors === void 0 && (e.randomColors = []), e.particleSize === void 0 && (e.particleSize = 0.1), e.particleSpeed === void 0 && (e.particleSpeed = 1), e.opacity === void 0 && (e.opacity = 1), e.aspectRatio === void 0 && (e.aspectRatio = 1), e.rotation === void 0 && (e.rotation = 0), e.rotationMode === void 0 && (e.rotationMode = "fixed"), e.minRotation === void 0 && (e.minRotation = 0), e.maxRotation === void 0 && (e.maxRotation = 90), e.orientX === void 0 && (e.orientX = 0), e.orientY === void 0 && (e.orientY = 0), e.orientZ === void 0 && (e.orientZ = 0), e.randomSize === void 0 && (e.randomSize = !1), e.minSize === void 0 && (e.minSize = 0.05), e.maxSize === void 0 && (e.maxSize = 0.15), e.randomSpeed === void 0 && (e.randomSpeed = !1), e.minSpeed === void 0 && (e.minSpeed = 0.1), e.maxSpeed === void 0 && (e.maxSpeed = 1), e.fadeSizeEnabled === void 0 && (e.fadeSizeEnabled = !1), e.increaseSizeEnabled === void 0 && (e.increaseSizeEnabled = !1), e.sizeLifetimeSpeed === void 0 && (e.sizeLifetimeSpeed = 1), e.bloomEnabled === void 0 && (e.bloomEnabled = !0), e.bloomIntensity === void 0 && (e.bloomIntensity = 1), e.bloomColor === void 0 && (e.bloomColor = [1, 1, 1]), e.gravityEnabled === void 0 && (e.gravityEnabled = !1), e.gravityStrength === void 0 && (e.gravityStrength = 2), e.dampingEnabled === void 0 && (e.dampingEnabled = !1), e.dampingStrength === void 0 && (e.dampingStrength = 1), e.attractorEnabled === void 0 && (e.attractorEnabled = !1), e.attractorStrength === void 0 && (e.attractorStrength = 1), e.attractorPosition === void 0 && (e.attractorPosition = [0, 0, 0]), e.attractorReverse === void 0 && (e.attractorReverse = !1), e.burstMode === void 0 && (e.burstMode = !1), e.emissionShape === void 0 && (e.emissionShape = "cube"), e.lifetime === void 0 && (e.lifetime = 5), e.emissionRate === void 0 && (e.emissionRate = 10), e.startAt === void 0 && (e.startAt = 0), e.emissionDuration === void 0 && (e.emissionDuration = 10), e.emissionDurationInfinite === void 0 && (e.emissionDurationInfinite = !1), e.emissionDuration > 300 && (e.emissionDurationInfinite = !0, e.emissionDuration = 10), e.outerLength === void 0 && (e.outerLength = e.cubeLength ?? 2), e.innerLength === void 0 && (e.innerLength = 0), e.outerRadius === void 0 && (e.outerRadius = 2), e.innerRadius === void 0 && (e.innerRadius = 0), e.squareSize === void 0 && (e.squareSize = 2), e.squareInnerSize === void 0 && (e.squareInnerSize = 0), e.circleInnerRadius === void 0 && (e.circleInnerRadius = 0), e.circleOuterRadius === void 0 && (e.circleOuterRadius = 2), e.circleVelocityDirection === void 0 && (e.circleVelocityDirection = "outward"), e.cylinderInnerRadius === void 0 && (e.cylinderInnerRadius = 0), e.cylinderOuterRadius === void 0 && (e.cylinderOuterRadius = 2), e.cylinderHeight === void 0 && (e.cylinderHeight = 4), e.cylinderVelocityDirection === void 0 && (e.cylinderVelocityDirection = "outward"), e.planeWidth === void 0 && (e.planeWidth = 2), e.planeDepth === void 0 && (e.planeDepth = 2), e.coneOuterRadius === void 0 && (e.coneOuterRadius = 2), e.coneInnerRadius === void 0 && (e.coneInnerRadius = 0), e.coneHeight === void 0 && (e.coneHeight = 4), e.torusMajorRadius === void 0 && (e.torusMajorRadius = 2), e.torusMinorRadius === void 0 && (e.torusMinorRadius = 0.5), e.lineLength === void 0 && (e.lineLength = 4), e.hemisphereOuterRadius === void 0 && (e.hemisphereOuterRadius = 2), e.hemisphereInnerRadius === void 0 && (e.hemisphereInnerRadius = 0), e.discRadius === void 0 && (e.discRadius = 2), e.annulusInnerRadius === void 0 && (e.annulusInnerRadius = 1), e.annulusOuterRadius === void 0 && (e.annulusOuterRadius = 2), e.capsuleRadius === void 0 && (e.capsuleRadius = 0.5), e.capsuleHeight === void 0 && (e.capsuleHeight = 4), e.arcStartAngle === void 0 && (e.arcStartAngle = 0), e.arcEndAngle === void 0 && (e.arcEndAngle = 180), e.arcInnerRadius === void 0 && (e.arcInnerRadius = 0), e.arcOuterRadius === void 0 && (e.arcOuterRadius = 2), e.spiralTurns === void 0 && (e.spiralTurns = 3), e.spiralRadiusStart === void 0 && (e.spiralRadiusStart = 0.5), e.spiralRadiusEnd === void 0 && (e.spiralRadiusEnd = 2), e.spiralHeight === void 0 && (e.spiralHeight = 4), e.frustumRadiusNear === void 0 && (e.frustumRadiusNear = 0.5), e.frustumRadiusFar === void 0 && (e.frustumRadiusFar = 2), e.frustumHeight === void 0 && (e.frustumHeight = 4), e.cubeSurfaceSize === void 0 && (e.cubeSurfaceSize = 2), e.sphereSurfaceRadius === void 0 && (e.sphereSurfaceRadius = 2), e.boxFrameSize === void 0 && (e.boxFrameSize = 2), e.polygonSides === void 0 && (e.polygonSides = 6), e.polygonRadius === void 0 && (e.polygonRadius = 2), e.emissionRotationX === void 0 && (e.emissionRotationX = 0), e.emissionRotationY === void 0 && (e.emissionRotationY = 0), e.emissionRotationZ === void 0 && (e.emissionRotationZ = 0), e.emissionPositionX === void 0 && (e.emissionPositionX = e.emissionTranslationX ?? 0), e.emissionPositionY === void 0 && (e.emissionPositionY = e.emissionTranslationY ?? 0), e.emissionPositionZ === void 0 && (e.emissionPositionZ = e.emissionTranslationZ ?? 0), e.pulseEnabled === void 0 && (e.pulseEnabled = !1), e.pulseAmplitude === void 0 && (e.pulseAmplitude = 0.5), e.pulseFrequency === void 0 && (e.pulseFrequency = 1), e.pulsePhaseRandom === void 0 && (e.pulsePhaseRandom = 0), e.pulseOpacity === void 0 && (e.pulseOpacity = !1), e.confinementEnabled === void 0 && (e.confinementEnabled = !1), e.confinementShape === void 0 && (e.confinementShape = "box"), e.confinementMode === void 0 && (e.confinementMode = "bounce"), e.confinementSpace === void 0 && (e.confinementSpace = "world"), e.confinementBoxHalfSize === void 0 && (e.confinementBoxHalfSize = [2, 2, 2]), e.confinementSphereRadius === void 0 && (e.confinementSphereRadius = 3), e.confinementRestitution === void 0 && (e.confinementRestitution = 0.8), e.confinementFriction === void 0 && (e.confinementFriction = 0.1), e.softBoundaryEnabled === void 0 && (e.softBoundaryEnabled = !1), e.softBoundaryStrength === void 0 && (e.softBoundaryStrength = 5), e.softBoundaryFalloff === void 0 && (e.softBoundaryFalloff = 0.5), e.depthWriteEnabled === void 0 && (e.depthWriteEnabled = !1), e.velocityStretchEnabled === void 0 && (e.velocityStretchEnabled = !1), e.velocityStretchFactor === void 0 && (e.velocityStretchFactor = 1), e.blendMode === void 0 && (e.blendMode = "normal"), e.noiseDistortEnabled === void 0 && (e.noiseDistortEnabled = !1), e.noiseTilingX === void 0 && (e.noiseTilingX = 3), e.noiseTilingY === void 0 && (e.noiseTilingY = 3), e.noiseSpeed === void 0 && (e.noiseSpeed = -1.5), e.noiseAmplitude === void 0 && (e.noiseAmplitude = 0.08), e.emissionTrailEnabled === void 0 && (e.emissionTrailEnabled = !1), e.emissionTrailDuration === void 0 && (e.emissionTrailDuration = 1), e.emissionTrailWidth === void 0 && (e.emissionTrailWidth = 0.3), e.emissionTrailMinDistance === void 0 && (e.emissionTrailMinDistance = 0.05), e.emissionTrailMaxPoints === void 0 && (e.emissionTrailMaxPoints = 256), e.emissionTrailSegments === void 0 && (e.emissionTrailSegments = 8), e.emissionTrailMode === void 0 && (e.emissionTrailMode = "ribbon"), e.emissionTrailShape === void 0 && (e.emissionTrailShape = "straight"), e.emissionTrailShapeAmplitude === void 0 && (e.emissionTrailShapeAmplitude = 0.1), e.emissionTrailShapeFrequency === void 0 && (e.emissionTrailShapeFrequency = 4), e.emissionTrailShapeSpeed === void 0 && (e.emissionTrailShapeSpeed = 0), e.shapeStrokeEnabled === void 0 && (e.shapeStrokeEnabled = !1), e.shapeStrokeWidth === void 0 && (e.shapeStrokeWidth = 0.08), e.shapeStrokeSegments === void 0 && (e.shapeStrokeSegments = 96), e.shapeStrokeShape === void 0 && (e.shapeStrokeShape = "straight"), e.shapeStrokeAmplitude === void 0 && (e.shapeStrokeAmplitude = 0.08), e.shapeStrokeFrequency === void 0 && (e.shapeStrokeFrequency = 10), e.shapeStrokeSpeed === void 0 && (e.shapeStrokeSpeed = 0), e.shapeDisplay === void 0 && (e.shapeDisplay = !0), e.followSystemTranslation === void 0 && (e.followSystemTranslation = !0), e.followSystemId === void 0 && (e.followSystemId = null), this._newEmissions = [], this._emptyEmissions = [], this._pendingFollowEmissions = this._emptyEmissions, this.glbVertexBuffer = null, this.glbIndexBuffer = null, this.glbIndexCount = 0, this.glbIndexFormat = "uint16", this.glbMeshData = null, this.glbRawArrayBuffer = null, this.glbAnimator = null, this.glbAnimated = !1, this._glbInterleavedData = null, this._appearanceData = new Float32Array(56), this._bloomIntensityData = new Float32Array(16), this._simPosition = [0, 0, 0], this._simVelocity = [0, 0, 0], this._simRotMatrix = null, this._simRotX = 0, this._simRotZ = 0, this._emitSimRotY = 0, this.emitter = new Ys(e), this.physics = new Ks(t, this.MAX_PARTICLES), this.textureManager = new Qs(t), e.gravityEnabled && this.setGravity(e.gravityStrength || 0), e.dampingEnabled && this.physics.setDamping(e.dampingStrength || 0), e.attractorEnabled && e.attractorPosition && this.setAttractor(e.attractorStrength || 0, e.attractorPosition, e.attractorReverse), e.confinementEnabled && this.setConfinement({
|
|
2501
|
+
}), e.overrideXVelocity === void 0 && (e.overrideXVelocity = !1), e.overrideYVelocity === void 0 && (e.overrideYVelocity = !1), e.overrideZVelocity === void 0 && (e.overrideZVelocity = !1), e.xVelocity === void 0 && (e.xVelocity = 0), e.yVelocity === void 0 && (e.yVelocity = 0), e.zVelocity === void 0 && (e.zVelocity = 0), e.textureEnabled === void 0 && (e.textureEnabled = !1), e.glbModelEnabled === void 0 && (e.glbModelEnabled = !1), e.textureType === void 0 && (e.textureType = "image"), e.glbFileName === void 0 && (e.glbFileName = null), e.animationIndex === void 0 && (e.animationIndex = 0), e.animationSpeed === void 0 && (e.animationSpeed = 1), e.animationLoop === void 0 && (e.animationLoop = !0), e.useGlbTexture === void 0 && (e.useGlbTexture = !1), e.glbHasTexture === void 0 && (e.glbHasTexture = !1), e.particleShape === void 0 && (e.particleShape = "square"), e.particleShapeRotation !== void 0 && (e.rotation = (e.rotation || 0) + e.particleShapeRotation, delete e.particleShapeRotation), e.particleShapeRotationX === void 0 && (e.particleShapeRotationX = 0), e.particleShapeRotationY === void 0 && (e.particleShapeRotationY = 0), e.particleShapeRotationZ === void 0 && (e.particleShapeRotationZ = 0), e.particleColor === void 0 && (e.particleColor = [1, 1, 1]), e.startColor === void 0 && (e.startColor = [1, 0, 0]), e.endColor === void 0 && (e.endColor = [0, 0, 1]), e.fadeEnabled === void 0 && (e.fadeEnabled = !0), e.colorTransitionEnabled === void 0 && (e.colorTransitionEnabled = !1), e.randomColorEnabled === void 0 && (e.randomColorEnabled = !1), e.randomColors === void 0 && (e.randomColors = []), e.particleSize === void 0 && (e.particleSize = 0.1), e.particleSpeed === void 0 && (e.particleSpeed = 1), e.opacity === void 0 && (e.opacity = 1), e.aspectRatio === void 0 && (e.aspectRatio = 1), e.rotation === void 0 && (e.rotation = 0), e.rotationMode === void 0 && (e.rotationMode = "fixed"), e.minRotation === void 0 && (e.minRotation = 0), e.maxRotation === void 0 && (e.maxRotation = 90), e.orientX === void 0 && (e.orientX = 0), e.orientY === void 0 && (e.orientY = 0), e.orientZ === void 0 && (e.orientZ = 0), e.randomSize === void 0 && (e.randomSize = !1), e.minSize === void 0 && (e.minSize = 0.05), e.maxSize === void 0 && (e.maxSize = 0.15), e.randomSpeed === void 0 && (e.randomSpeed = !1), e.minSpeed === void 0 && (e.minSpeed = 0.1), e.maxSpeed === void 0 && (e.maxSpeed = 1), e.fadeSizeEnabled === void 0 && (e.fadeSizeEnabled = !1), e.increaseSizeEnabled === void 0 && (e.increaseSizeEnabled = !1), e.sizeLifetimeSpeed === void 0 && (e.sizeLifetimeSpeed = 1), e.bloomEnabled === void 0 && (e.bloomEnabled = !0), e.bloomIntensity === void 0 && (e.bloomIntensity = 1), e.bloomColor === void 0 && (e.bloomColor = [1, 1, 1]), e.gravityEnabled === void 0 && (e.gravityEnabled = !1), e.gravityStrength === void 0 && (e.gravityStrength = 2), e.dampingEnabled === void 0 && (e.dampingEnabled = !1), e.dampingStrength === void 0 && (e.dampingStrength = 1), e.attractorEnabled === void 0 && (e.attractorEnabled = !1), e.attractorStrength === void 0 && (e.attractorStrength = 1), e.attractorPosition === void 0 && (e.attractorPosition = [0, 0, 0]), e.attractorReverse === void 0 && (e.attractorReverse = !1), e.burstMode === void 0 && (e.burstMode = !1), e.emissionShape === void 0 && (e.emissionShape = "cube"), e.lifetime === void 0 && (e.lifetime = 5), e.emissionRate === void 0 && (e.emissionRate = 10), e.startAt === void 0 && (e.startAt = 0), e.emissionDuration === void 0 && (e.emissionDuration = 10), e.emissionDurationInfinite === void 0 && (e.emissionDurationInfinite = !1), e.emissionDuration > 300 && (e.emissionDurationInfinite = !0, e.emissionDuration = 10), e.outerLength === void 0 && (e.outerLength = e.cubeLength ?? 2), e.innerLength === void 0 && (e.innerLength = 0), e.outerRadius === void 0 && (e.outerRadius = 2), e.innerRadius === void 0 && (e.innerRadius = 0), e.squareSize === void 0 && (e.squareSize = 2), e.squareInnerSize === void 0 && (e.squareInnerSize = 0), e.circleInnerRadius === void 0 && (e.circleInnerRadius = 0), e.circleOuterRadius === void 0 && (e.circleOuterRadius = 2), e.circleVelocityDirection === void 0 && (e.circleVelocityDirection = "outward"), e.cylinderInnerRadius === void 0 && (e.cylinderInnerRadius = 0), e.cylinderOuterRadius === void 0 && (e.cylinderOuterRadius = 2), e.cylinderHeight === void 0 && (e.cylinderHeight = 4), e.cylinderVelocityDirection === void 0 && (e.cylinderVelocityDirection = "outward"), e.planeWidth === void 0 && (e.planeWidth = 2), e.planeDepth === void 0 && (e.planeDepth = 2), e.coneOuterRadius === void 0 && (e.coneOuterRadius = 2), e.coneInnerRadius === void 0 && (e.coneInnerRadius = 0), e.coneHeight === void 0 && (e.coneHeight = 4), e.torusMajorRadius === void 0 && (e.torusMajorRadius = 2), e.torusMinorRadius === void 0 && (e.torusMinorRadius = 0.5), e.lineLength === void 0 && (e.lineLength = 4), e.hemisphereOuterRadius === void 0 && (e.hemisphereOuterRadius = 2), e.hemisphereInnerRadius === void 0 && (e.hemisphereInnerRadius = 0), e.discRadius === void 0 && (e.discRadius = 2), e.annulusInnerRadius === void 0 && (e.annulusInnerRadius = 1), e.annulusOuterRadius === void 0 && (e.annulusOuterRadius = 2), e.capsuleRadius === void 0 && (e.capsuleRadius = 0.5), e.capsuleHeight === void 0 && (e.capsuleHeight = 4), e.arcStartAngle === void 0 && (e.arcStartAngle = 0), e.arcEndAngle === void 0 && (e.arcEndAngle = 180), e.arcInnerRadius === void 0 && (e.arcInnerRadius = 0), e.arcOuterRadius === void 0 && (e.arcOuterRadius = 2), e.spiralTurns === void 0 && (e.spiralTurns = 3), e.spiralRadiusStart === void 0 && (e.spiralRadiusStart = 0.5), e.spiralRadiusEnd === void 0 && (e.spiralRadiusEnd = 2), e.spiralHeight === void 0 && (e.spiralHeight = 4), e.frustumRadiusNear === void 0 && (e.frustumRadiusNear = 0.5), e.frustumRadiusFar === void 0 && (e.frustumRadiusFar = 2), e.frustumHeight === void 0 && (e.frustumHeight = 4), e.cubeSurfaceSize === void 0 && (e.cubeSurfaceSize = 2), e.sphereSurfaceRadius === void 0 && (e.sphereSurfaceRadius = 2), e.boxFrameSize === void 0 && (e.boxFrameSize = 2), e.polygonSides === void 0 && (e.polygonSides = 6), e.polygonRadius === void 0 && (e.polygonRadius = 2), e.emissionRotationX === void 0 && (e.emissionRotationX = 0), e.emissionRotationY === void 0 && (e.emissionRotationY = 0), e.emissionRotationZ === void 0 && (e.emissionRotationZ = 0), e.emissionPositionX === void 0 && (e.emissionPositionX = e.emissionTranslationX ?? 0), e.emissionPositionY === void 0 && (e.emissionPositionY = e.emissionTranslationY ?? 0), e.emissionPositionZ === void 0 && (e.emissionPositionZ = e.emissionTranslationZ ?? 0), e.pulseEnabled === void 0 && (e.pulseEnabled = !1), e.pulseAmplitude === void 0 && (e.pulseAmplitude = 0.5), e.pulseFrequency === void 0 && (e.pulseFrequency = 1), e.pulsePhaseRandom === void 0 && (e.pulsePhaseRandom = 0), e.pulseOpacity === void 0 && (e.pulseOpacity = !1), e.confinementEnabled === void 0 && (e.confinementEnabled = !1), e.confinementShape === void 0 && (e.confinementShape = "box"), e.confinementMode === void 0 && (e.confinementMode = "bounce"), e.confinementSpace === void 0 && (e.confinementSpace = "world"), e.confinementBoxHalfSize === void 0 && (e.confinementBoxHalfSize = [2, 2, 2]), e.confinementSphereRadius === void 0 && (e.confinementSphereRadius = 3), e.confinementRestitution === void 0 && (e.confinementRestitution = 0.8), e.confinementFriction === void 0 && (e.confinementFriction = 0.1), e.softBoundaryEnabled === void 0 && (e.softBoundaryEnabled = !1), e.softBoundaryStrength === void 0 && (e.softBoundaryStrength = 5), e.softBoundaryFalloff === void 0 && (e.softBoundaryFalloff = 0.5), e.depthWriteEnabled === void 0 && (e.depthWriteEnabled = !1), e.velocityStretchEnabled === void 0 && (e.velocityStretchEnabled = !1), e.velocityStretchFactor === void 0 && (e.velocityStretchFactor = 1), e.blendMode === void 0 && (e.blendMode = "normal"), e.noiseDistortEnabled === void 0 && (e.noiseDistortEnabled = !1), e.noiseTilingX === void 0 && (e.noiseTilingX = 3), e.noiseTilingY === void 0 && (e.noiseTilingY = 3), e.noiseSpeed === void 0 && (e.noiseSpeed = -1.5), e.noiseAmplitude === void 0 && (e.noiseAmplitude = 0.08), e.emissionTrailEnabled === void 0 && (e.emissionTrailEnabled = !1), e.emissionTrailDuration === void 0 && (e.emissionTrailDuration = 1), e.emissionTrailWidth === void 0 && (e.emissionTrailWidth = 0.3), e.emissionTrailMinDistance === void 0 && (e.emissionTrailMinDistance = 0.05), e.emissionTrailMaxPoints === void 0 && (e.emissionTrailMaxPoints = 256), e.emissionTrailSegments === void 0 && (e.emissionTrailSegments = 8), e.emissionTrailMode === void 0 && (e.emissionTrailMode = "ribbon"), e.emissionTrailShape === void 0 && (e.emissionTrailShape = "straight"), e.emissionTrailShapeAmplitude === void 0 && (e.emissionTrailShapeAmplitude = 0.1), e.emissionTrailShapeFrequency === void 0 && (e.emissionTrailShapeFrequency = 4), e.emissionTrailShapeSpeed === void 0 && (e.emissionTrailShapeSpeed = 0), e.shapeStrokeEnabled === void 0 && (e.shapeStrokeEnabled = !1), e.shapeStrokeWidth === void 0 && (e.shapeStrokeWidth = 0.08), e.shapeStrokeSegments === void 0 && (e.shapeStrokeSegments = 96), e.shapeStrokeShape === void 0 && (e.shapeStrokeShape = "straight"), e.shapeStrokeAmplitude === void 0 && (e.shapeStrokeAmplitude = 0.08), e.shapeStrokeFrequency === void 0 && (e.shapeStrokeFrequency = 10), e.shapeStrokeSpeed === void 0 && (e.shapeStrokeSpeed = 0), e.shapeDisplay === void 0 && (e.shapeDisplay = !0), e.followSystemTranslation === void 0 && (e.followSystemTranslation = !0), e.followSystemId === void 0 && (e.followSystemId = null), this._newEmissions = [], this._emptyEmissions = [], this._pendingFollowEmissions = this._emptyEmissions, this.glbVertexBuffer = null, this.glbIndexBuffer = null, this.glbIndexCount = 0, this.glbIndexFormat = "uint16", this.glbMeshData = null, this.glbRawArrayBuffer = null, this.glbAnimator = null, this.glbAnimated = !1, this._glbInterleavedData = null, this._appearanceData = new Float32Array(56), this._bloomIntensityData = new Float32Array(16), this._simPosition = [0, 0, 0], this._simVelocity = [0, 0, 0], this._simRotMatrix = null, this._simRotX = 0, this._simRotZ = 0, this._emitSimRotY = 0, this.emitter = new qs(e), this.physics = new er(t, this.MAX_PARTICLES), this.textureManager = new tr(t), e.gravityEnabled && this.setGravity(e.gravityStrength || 0), e.dampingEnabled && this.physics.setDamping(e.dampingStrength || 0), e.attractorEnabled && e.attractorPosition && this.setAttractor(e.attractorStrength || 0, e.attractorPosition, e.attractorReverse), e.confinementEnabled && this.setConfinement({
|
|
2484
2502
|
enabled: !0,
|
|
2485
2503
|
shape: e.confinementShape,
|
|
2486
2504
|
mode: e.confinementMode,
|
|
@@ -2514,7 +2532,7 @@ class ii {
|
|
|
2514
2532
|
async setGLBModel(t) {
|
|
2515
2533
|
try {
|
|
2516
2534
|
this.glbRawArrayBuffer = t;
|
|
2517
|
-
const e = await
|
|
2535
|
+
const e = await or(t);
|
|
2518
2536
|
this.glbMeshData = e, this.config.glbHasTexture = e.hasBaseColorTexture || !1;
|
|
2519
2537
|
const i = new Float32Array(e.vertexCount * 8);
|
|
2520
2538
|
for (let r = 0; r < e.vertexCount; r++) {
|
|
@@ -2530,7 +2548,7 @@ class ii {
|
|
|
2530
2548
|
usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST,
|
|
2531
2549
|
label: "glbIndexBuffer"
|
|
2532
2550
|
}), this.device.queue.writeBuffer(this.glbIndexBuffer, 0, e.indices), this.glbIndexCount = e.indexCount, this.glbIndexFormat = e.indices instanceof Uint32Array ? "uint32" : "uint16", this.config.glbModelEnabled = !0, this.config.textureType = "glb", e.animationData) {
|
|
2533
|
-
this.glbAnimator = new
|
|
2551
|
+
this.glbAnimator = new xr(e.animationData), this.glbAnimator.setRestPose(e.positions, e.normals), this.glbAnimated = !0, this.config.glbAnimated = !0, this.glbAnimator.loop = this.config.animationLoop, this._glbInterleavedData = new Float32Array(e.vertexCount * 8);
|
|
2534
2552
|
try {
|
|
2535
2553
|
await this.glbAnimator.initGPUSkinning(this.device, this.glbVertexBuffer, e.texCoords);
|
|
2536
2554
|
} catch (r) {
|
|
@@ -2592,7 +2610,7 @@ class ii {
|
|
|
2592
2610
|
if (this.destroyed) return;
|
|
2593
2611
|
let t = 0;
|
|
2594
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);
|
|
2595
|
-
const e =
|
|
2613
|
+
const e = Br[this.config.particleShape] ?? 0, i = this._appearanceData;
|
|
2596
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;
|
|
2597
2615
|
const r = this.config.followSystemTranslation ?? !0;
|
|
2598
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);
|
|
@@ -2615,7 +2633,7 @@ class ii {
|
|
|
2615
2633
|
const r = 500;
|
|
2616
2634
|
for (let n = 0; n < e; n++)
|
|
2617
2635
|
if (this.emitParticle(), i++, i >= r || n === e - 1) {
|
|
2618
|
-
const a = n - i + 1, o = a * 8,
|
|
2636
|
+
const a = n - i + 1, o = a * 8, l = a * 4;
|
|
2619
2637
|
this.device.queue.writeBuffer(
|
|
2620
2638
|
this.instanceBuffer,
|
|
2621
2639
|
o * 4,
|
|
@@ -2625,10 +2643,10 @@ class ii {
|
|
|
2625
2643
|
i * 8
|
|
2626
2644
|
), this.device.queue.writeBuffer(
|
|
2627
2645
|
this.velocityBuffer,
|
|
2628
|
-
|
|
2646
|
+
l * 4,
|
|
2629
2647
|
// Offset in bytes
|
|
2630
2648
|
this.particleVelocities,
|
|
2631
|
-
|
|
2649
|
+
l,
|
|
2632
2650
|
i * 4
|
|
2633
2651
|
), i = 0;
|
|
2634
2652
|
}
|
|
@@ -2654,8 +2672,8 @@ class ii {
|
|
|
2654
2672
|
this._emitSimRotY = this._simRotY || 0;
|
|
2655
2673
|
const e = t * 8, i = t * 4;
|
|
2656
2674
|
if (this._simRotMatrix) {
|
|
2657
|
-
const r = this._simRotMatrix, n = this.particleData[e], a = this.particleData[e + 1], o = this.particleData[e + 2],
|
|
2658
|
-
this.particleData[e] = r[0] * n + r[1] * a + r[2] * o, this.particleData[e + 1] = r[3] * n + r[4] * a + r[5] * o, this.particleData[e + 2] = r[6] * n + r[7] * a + r[8] * o, this.particleVelocities[i] = r[0] *
|
|
2675
|
+
const r = this._simRotMatrix, n = this.particleData[e], a = this.particleData[e + 1], o = this.particleData[e + 2], l = this.particleVelocities[i], c = this.particleVelocities[i + 1], d = this.particleVelocities[i + 2];
|
|
2676
|
+
this.particleData[e] = r[0] * n + r[1] * a + r[2] * o, this.particleData[e + 1] = r[3] * n + r[4] * a + r[5] * o, this.particleData[e + 2] = r[6] * n + r[7] * a + r[8] * o, this.particleVelocities[i] = r[0] * l + r[1] * c + r[2] * d, this.particleVelocities[i + 1] = r[3] * l + r[4] * c + r[5] * d, this.particleVelocities[i + 2] = r[6] * l + r[7] * c + r[8] * d;
|
|
2659
2677
|
}
|
|
2660
2678
|
(this.config.followSystemTranslation ?? !0) || (this.particleData[e] += this._simPosition[0], this.particleData[e + 1] += this._simPosition[1], this.particleData[e + 2] += this._simPosition[2]);
|
|
2661
2679
|
}
|
|
@@ -2680,8 +2698,8 @@ class ii {
|
|
|
2680
2698
|
if (this.activeParticles >= this.particleCount) return !1;
|
|
2681
2699
|
const r = this.activeParticles * 8, n = t + (this.config.emissionPositionX || 0), a = e + (this.config.emissionPositionY || 0), o = i + (this.config.emissionPositionZ || 0);
|
|
2682
2700
|
this.particleData[r] = n, this.particleData[r + 1] = a, this.particleData[r + 2] = o;
|
|
2683
|
-
const
|
|
2684
|
-
return this.emitter.calculateVelocity(n, a, o, this.particleVelocities,
|
|
2701
|
+
const l = this.activeParticles * 4;
|
|
2702
|
+
return this.emitter.calculateVelocity(n, a, o, this.particleVelocities, l), this.emitter.setParticleColor(this.particleData, r), this.emitter.setParticleLifetime(this.particleData, r), this.activeParticles++, !0;
|
|
2685
2703
|
}
|
|
2686
2704
|
updateParticles(t, e, i = 0) {
|
|
2687
2705
|
const r = this.config.startAt || 0, n = r > 0 && i < r;
|
|
@@ -2691,7 +2709,7 @@ class ii {
|
|
|
2691
2709
|
if (d > 0 && this._scriptTime >= d && !this._scriptConfigRestored)
|
|
2692
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));
|
|
2693
2711
|
else if (!this._scriptConfigRestored) {
|
|
2694
|
-
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(
|
|
2695
2713
|
t,
|
|
2696
2714
|
this._scriptTime,
|
|
2697
2715
|
this._scriptFrame,
|
|
@@ -2700,7 +2718,7 @@ class ii {
|
|
|
2700
2718
|
this._scriptVelocityData,
|
|
2701
2719
|
this.activeParticles
|
|
2702
2720
|
);
|
|
2703
|
-
|
|
2721
|
+
f && this.activeParticles > 0 && (this.device.queue.writeBuffer(
|
|
2704
2722
|
this.instanceBuffer,
|
|
2705
2723
|
0,
|
|
2706
2724
|
this._scriptParticleData,
|
|
@@ -2716,7 +2734,7 @@ class ii {
|
|
|
2716
2734
|
}
|
|
2717
2735
|
}
|
|
2718
2736
|
this.physics.physicsAccumulator += t;
|
|
2719
|
-
const a = performance.now() / 1e3,
|
|
2737
|
+
const a = performance.now() / 1e3, l = a - this.physics.lastUpdateTime > 1 / this.physics.minUpdatesPerSecond, c = this.activeParticles;
|
|
2720
2738
|
if (!n && !this.emitting && !this.config.burstMode && !this.config.followSystemId && this.currentEmissionTime < this.effectiveEmissionDuration && (this.emitting = !0), !n && this.emitting)
|
|
2721
2739
|
if (this.currentEmissionTime += t, this.currentEmissionTime < this.effectiveEmissionDuration) {
|
|
2722
2740
|
const d = this.activeParticles;
|
|
@@ -2724,8 +2742,8 @@ class ii {
|
|
|
2724
2742
|
if (this.config.followSystemId) {
|
|
2725
2743
|
if (this._pendingFollowEmissions.length > 0) {
|
|
2726
2744
|
const b = this._pendingFollowEmissions.length / 6;
|
|
2727
|
-
for (let
|
|
2728
|
-
const v =
|
|
2745
|
+
for (let f = 0; f < b; f++) {
|
|
2746
|
+
const v = f * 6;
|
|
2729
2747
|
if (this.emitFollowerParticle(
|
|
2730
2748
|
this._pendingFollowEmissions[v],
|
|
2731
2749
|
this._pendingFollowEmissions[v + 1],
|
|
@@ -2738,8 +2756,8 @@ class ii {
|
|
|
2738
2756
|
}
|
|
2739
2757
|
} else {
|
|
2740
2758
|
let b = 0;
|
|
2741
|
-
const
|
|
2742
|
-
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);
|
|
2743
2761
|
for (let v = 0; v < b; v++)
|
|
2744
2762
|
if (this.emitParticle())
|
|
2745
2763
|
S = !0;
|
|
@@ -2749,13 +2767,13 @@ class ii {
|
|
|
2749
2767
|
}
|
|
2750
2768
|
}
|
|
2751
2769
|
if (S) {
|
|
2752
|
-
const b = this.activeParticles - d,
|
|
2770
|
+
const b = this.activeParticles - d, f = d * 8, v = d * 4;
|
|
2753
2771
|
this.device.queue.writeBuffer(
|
|
2754
2772
|
this.instanceBuffer,
|
|
2755
|
-
|
|
2773
|
+
f * 4,
|
|
2756
2774
|
// Offset in bytes (float32 = 4 bytes)
|
|
2757
2775
|
this.particleData,
|
|
2758
|
-
|
|
2776
|
+
f,
|
|
2759
2777
|
b * 8
|
|
2760
2778
|
), this.device.queue.writeBuffer(
|
|
2761
2779
|
this.velocityBuffer,
|
|
@@ -2771,15 +2789,15 @@ class ii {
|
|
|
2771
2789
|
for (; this.physics.physicsAccumulator >= this.physics.fixedDeltaTime; )
|
|
2772
2790
|
this.physics.updatePhysics(
|
|
2773
2791
|
this.physics.fixedDeltaTime,
|
|
2774
|
-
|
|
2792
|
+
c,
|
|
2775
2793
|
this.config,
|
|
2776
2794
|
this.instanceBuffer,
|
|
2777
2795
|
this.velocityBuffer,
|
|
2778
2796
|
e
|
|
2779
2797
|
), this.physics.physicsAccumulator -= this.physics.fixedDeltaTime, this.physics.physicsClock += this.physics.fixedDeltaTime;
|
|
2780
|
-
|
|
2798
|
+
l && c > 0 && (this.physics.updatePhysics(
|
|
2781
2799
|
this.physics.fixedDeltaTime,
|
|
2782
|
-
|
|
2800
|
+
c,
|
|
2783
2801
|
this.config,
|
|
2784
2802
|
this.instanceBuffer,
|
|
2785
2803
|
this.velocityBuffer,
|
|
@@ -2817,10 +2835,10 @@ class ii {
|
|
|
2817
2835
|
continue;
|
|
2818
2836
|
}
|
|
2819
2837
|
if (e !== r) {
|
|
2820
|
-
const o = r * 8,
|
|
2821
|
-
this.particleData.copyWithin(
|
|
2822
|
-
const
|
|
2823
|
-
this.particleVelocities.copyWithin(d,
|
|
2838
|
+
const o = r * 8, l = e * 8;
|
|
2839
|
+
this.particleData.copyWithin(l, o, o + 8);
|
|
2840
|
+
const c = r * 4, d = e * 4;
|
|
2841
|
+
this.particleVelocities.copyWithin(d, c, c + 4), i = !0;
|
|
2824
2842
|
}
|
|
2825
2843
|
e++;
|
|
2826
2844
|
}
|
|
@@ -2849,12 +2867,12 @@ class ii {
|
|
|
2849
2867
|
}
|
|
2850
2868
|
updateParticleVelocities() {
|
|
2851
2869
|
for (let t = 0; t < this.activeParticles; t++) {
|
|
2852
|
-
const e = t * 8, i = t * 4, r = this.particleData[e], n = this.particleData[e + 1], a = this.particleData[e + 2], o = this.particleVelocities[i],
|
|
2853
|
-
o * o +
|
|
2870
|
+
const e = t * 8, i = t * 4, r = this.particleData[e], n = this.particleData[e + 1], a = this.particleData[e + 2], o = this.particleVelocities[i], l = this.particleVelocities[i + 1], c = this.particleVelocities[i + 2], d = Math.sqrt(
|
|
2871
|
+
o * o + l * l + c * c
|
|
2854
2872
|
);
|
|
2855
2873
|
if (d > 1e-3) {
|
|
2856
2874
|
const S = this.config.particleSpeed * 2;
|
|
2857
|
-
this.particleVelocities[i] = o / d * S, this.particleVelocities[i + 1] =
|
|
2875
|
+
this.particleVelocities[i] = o / d * S, this.particleVelocities[i + 1] = l / d * S, this.particleVelocities[i + 2] = c / d * S;
|
|
2858
2876
|
} else {
|
|
2859
2877
|
const S = Math.sqrt(r * r + n * n + a * a);
|
|
2860
2878
|
if (S > 1e-3) {
|
|
@@ -2904,9 +2922,9 @@ class ii {
|
|
|
2904
2922
|
this.physics.setSoftBoundary(t);
|
|
2905
2923
|
}
|
|
2906
2924
|
}
|
|
2907
|
-
class
|
|
2925
|
+
class Rr {
|
|
2908
2926
|
constructor(t) {
|
|
2909
|
-
this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new
|
|
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;
|
|
2910
2928
|
}
|
|
2911
2929
|
createParticleSystem(t = {}) {
|
|
2912
2930
|
const e = this.systemCounter++, i = t.name || `System ${e + 1}`, r = {
|
|
@@ -2974,20 +2992,20 @@ class wr {
|
|
|
2974
2992
|
const r = this.clock ? this.clock.currentTime : 0, n = this.clock ? this.clock.duration : 0;
|
|
2975
2993
|
if (this.clock && n > 0 && isFinite(n)) {
|
|
2976
2994
|
const a = Math.min(1, this.clock.currentTime / n);
|
|
2977
|
-
for (const { system: o, config:
|
|
2978
|
-
this._applyKeyframesToSystem(o,
|
|
2995
|
+
for (const { system: o, config: l } of this.particleSystems)
|
|
2996
|
+
this._applyKeyframesToSystem(o, l, a);
|
|
2979
2997
|
}
|
|
2980
2998
|
for (const { system: a, config: o } of this.particleSystems) {
|
|
2981
2999
|
if (o.hidden || o.followSystemId) continue;
|
|
2982
|
-
const
|
|
2983
|
-
a.updateParticles(t, e, r), (
|
|
3000
|
+
const l = a.activeParticles > 0;
|
|
3001
|
+
a.updateParticles(t, e, r), (l || a.activeParticles > 0) && (i = !0);
|
|
2984
3002
|
}
|
|
2985
3003
|
for (const { system: a, config: o } of this.particleSystems) {
|
|
2986
3004
|
if (o.hidden || !o.followSystemId) continue;
|
|
2987
|
-
const
|
|
2988
|
-
|
|
2989
|
-
const
|
|
2990
|
-
a.updateParticles(t, e, r), (
|
|
3005
|
+
const l = this.getSystemById(o.followSystemId);
|
|
3006
|
+
l && (a._pendingFollowEmissions = l.system._newEmissions);
|
|
3007
|
+
const c = a.activeParticles > 0;
|
|
3008
|
+
a.updateParticles(t, e, r), (c || a.activeParticles > 0) && (i = !0);
|
|
2991
3009
|
}
|
|
2992
3010
|
i && this.device.queue.submit([e.finish()]);
|
|
2993
3011
|
for (const { system: a } of this.particleSystems)
|
|
@@ -3051,8 +3069,8 @@ class wr {
|
|
|
3051
3069
|
try {
|
|
3052
3070
|
const o = await Vi(a);
|
|
3053
3071
|
if (o) {
|
|
3054
|
-
const
|
|
3055
|
-
await r.setTexture(
|
|
3072
|
+
const l = await createImageBitmap(o.imageBlob);
|
|
3073
|
+
await r.setTexture(l), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${n.name}`);
|
|
3056
3074
|
}
|
|
3057
3075
|
} catch (o) {
|
|
3058
3076
|
console.warn(`Failed to restore GLB texture for ${n.name}:`, o), n.useGlbTexture = !1;
|
|
@@ -3066,8 +3084,8 @@ class wr {
|
|
|
3066
3084
|
if (n.textureEnabled && !n.glbModelEnabled && n.textureImageData)
|
|
3067
3085
|
try {
|
|
3068
3086
|
const a = new Image();
|
|
3069
|
-
await new Promise((
|
|
3070
|
-
a.onload =
|
|
3087
|
+
await new Promise((l, c) => {
|
|
3088
|
+
a.onload = l, a.onerror = c, a.src = n.textureImageData;
|
|
3071
3089
|
});
|
|
3072
3090
|
const o = await createImageBitmap(a);
|
|
3073
3091
|
await r.setTexture(o);
|
|
@@ -3098,76 +3116,76 @@ class wr {
|
|
|
3098
3116
|
const i = [];
|
|
3099
3117
|
try {
|
|
3100
3118
|
for (const o of t.systems) {
|
|
3101
|
-
const
|
|
3102
|
-
i.push(
|
|
3103
|
-
const
|
|
3119
|
+
const l = this.systemCounter++;
|
|
3120
|
+
i.push(l);
|
|
3121
|
+
const c = {
|
|
3104
3122
|
...o,
|
|
3105
|
-
id:
|
|
3123
|
+
id: l,
|
|
3106
3124
|
// Apply world-space offset to emission translation
|
|
3107
3125
|
emissionPositionX: (o.emissionPositionX || 0) + e[0],
|
|
3108
3126
|
emissionPositionY: (o.emissionPositionY || 0) + e[1],
|
|
3109
3127
|
emissionPositionZ: (o.emissionPositionZ || 0) + e[2]
|
|
3110
3128
|
};
|
|
3111
|
-
o.attractorEnabled && o.attractorPosition && (
|
|
3129
|
+
o.attractorEnabled && o.attractorPosition && (c.attractorPosition = [
|
|
3112
3130
|
o.attractorPosition[0] + e[0],
|
|
3113
3131
|
o.attractorPosition[1] + e[1],
|
|
3114
3132
|
o.attractorPosition[2] + e[2]
|
|
3115
|
-
]), o.confinementEnabled && o.confinementSpace === "world" && Array.isArray(o.confinementCenter) && (
|
|
3133
|
+
]), o.confinementEnabled && o.confinementSpace === "world" && Array.isArray(o.confinementCenter) && (c.confinementCenter = [
|
|
3116
3134
|
(o.confinementCenter[0] || 0) + e[0],
|
|
3117
3135
|
(o.confinementCenter[1] || 0) + e[1],
|
|
3118
3136
|
(o.confinementCenter[2] || 0) + e[2]
|
|
3119
3137
|
]);
|
|
3120
|
-
const d = new ii(this.device,
|
|
3138
|
+
const d = new ii(this.device, c);
|
|
3121
3139
|
this.particleSystems.push({
|
|
3122
3140
|
system: d,
|
|
3123
|
-
config:
|
|
3124
|
-
}), this.onSystemCreated && typeof this.onSystemCreated == "function" && this.onSystemCreated(
|
|
3141
|
+
config: c
|
|
3142
|
+
}), this.onSystemCreated && typeof this.onSystemCreated == "function" && this.onSystemCreated(l, c);
|
|
3125
3143
|
}
|
|
3126
3144
|
const n = this.particleSystems.length - t.systems.length, a = {};
|
|
3127
|
-
t.systems.forEach((o,
|
|
3128
|
-
a[o.id] = this.particleSystems[n +
|
|
3145
|
+
t.systems.forEach((o, l) => {
|
|
3146
|
+
a[o.id] = this.particleSystems[n + l].config.id;
|
|
3129
3147
|
});
|
|
3130
3148
|
for (let o = n; o < this.particleSystems.length; o++) {
|
|
3131
|
-
const { config:
|
|
3132
|
-
|
|
3149
|
+
const { config: l } = this.particleSystems[o];
|
|
3150
|
+
l.followSystemId && a[l.followSystemId] !== void 0 && (l.followSystemId = a[l.followSystemId]);
|
|
3133
3151
|
}
|
|
3134
|
-
for (const { system: o, config:
|
|
3135
|
-
if (
|
|
3152
|
+
for (const { system: o, config: l } of this.particleSystems)
|
|
3153
|
+
if (l.glbModelEnabled && !o.glbMeshData)
|
|
3136
3154
|
try {
|
|
3137
|
-
let
|
|
3138
|
-
if (
|
|
3139
|
-
|
|
3140
|
-
else if (
|
|
3141
|
-
const d = await fetch(`/${
|
|
3142
|
-
d.ok ?
|
|
3155
|
+
let c = null;
|
|
3156
|
+
if (l.glbModelData)
|
|
3157
|
+
c = ki(l.glbModelData);
|
|
3158
|
+
else if (l.glbFileName) {
|
|
3159
|
+
const d = await fetch(`/${l.glbFileName}`);
|
|
3160
|
+
d.ok ? c = await d.arrayBuffer() : console.warn(`GLB file not found: ${l.glbFileName}`);
|
|
3143
3161
|
}
|
|
3144
|
-
if (
|
|
3145
|
-
if (await o.setGLBModel(
|
|
3162
|
+
if (c) {
|
|
3163
|
+
if (await o.setGLBModel(c), l.animationIndex !== void 0 && o.glbAnimator && o.glbAnimator.setAnimation(l.animationIndex), l.animationSpeed !== void 0 && o.glbAnimator && (o.glbAnimator.speed = l.animationSpeed), l.animationLoop !== void 0 && o.glbAnimator && (o.glbAnimator.loop = l.animationLoop), l.useGlbTexture && (l.textureEnabled = !0), l.useGlbTexture && ((r = o.glbMeshData) != null && r.hasBaseColorTexture))
|
|
3146
3164
|
try {
|
|
3147
|
-
const d = await Vi(
|
|
3165
|
+
const d = await Vi(c);
|
|
3148
3166
|
if (d) {
|
|
3149
3167
|
const S = await createImageBitmap(d.imageBlob);
|
|
3150
|
-
await o.setTexture(S), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${
|
|
3168
|
+
await o.setTexture(S), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${l.name}`);
|
|
3151
3169
|
}
|
|
3152
3170
|
} catch (d) {
|
|
3153
|
-
console.warn(`Failed to restore GLB texture for ${
|
|
3171
|
+
console.warn(`Failed to restore GLB texture for ${l.name}:`, d), l.useGlbTexture = !1;
|
|
3154
3172
|
}
|
|
3155
3173
|
} else
|
|
3156
|
-
|
|
3157
|
-
} catch (
|
|
3158
|
-
console.warn(`Failed to load GLB for ${
|
|
3174
|
+
l.glbModelEnabled = !1;
|
|
3175
|
+
} catch (c) {
|
|
3176
|
+
console.warn(`Failed to load GLB for ${l.name}:`, c), l.glbModelEnabled = !1;
|
|
3159
3177
|
}
|
|
3160
|
-
for (const { system: o, config:
|
|
3161
|
-
if (
|
|
3178
|
+
for (const { system: o, config: l } of this.particleSystems)
|
|
3179
|
+
if (l.textureEnabled && !l.glbModelEnabled && l.textureImageData && !o._textureRestored)
|
|
3162
3180
|
try {
|
|
3163
|
-
const
|
|
3181
|
+
const c = new Image();
|
|
3164
3182
|
await new Promise((S, b) => {
|
|
3165
|
-
|
|
3183
|
+
c.onload = S, c.onerror = b, c.src = l.textureImageData;
|
|
3166
3184
|
});
|
|
3167
|
-
const d = await createImageBitmap(
|
|
3185
|
+
const d = await createImageBitmap(c);
|
|
3168
3186
|
await o.setTexture(d), o._textureRestored = !0;
|
|
3169
|
-
} catch (
|
|
3170
|
-
console.warn(`Failed to restore texture for ${
|
|
3187
|
+
} catch (c) {
|
|
3188
|
+
console.warn(`Failed to restore texture for ${l.name}:`, c), l.textureEnabled = !1;
|
|
3171
3189
|
}
|
|
3172
3190
|
return i;
|
|
3173
3191
|
} catch (n) {
|
|
@@ -3179,27 +3197,27 @@ class wr {
|
|
|
3179
3197
|
_applyKeyframesToSystem(t, e, i) {
|
|
3180
3198
|
const r = e.keyframes;
|
|
3181
3199
|
if (!r || e.keyframesEnabled === !1) return;
|
|
3182
|
-
let n = !1, a = !1, o = !1,
|
|
3183
|
-
for (const d of
|
|
3200
|
+
let n = !1, a = !1, o = !1, l = !1, c = !1;
|
|
3201
|
+
for (const d of wr) {
|
|
3184
3202
|
const S = r[d];
|
|
3185
3203
|
if (!S || !S.length) continue;
|
|
3186
|
-
const b =
|
|
3204
|
+
const b = _r(S, i);
|
|
3187
3205
|
if (b !== void 0) {
|
|
3188
3206
|
if (d === "damping") {
|
|
3189
|
-
e.dampingStrength = b,
|
|
3207
|
+
e.dampingStrength = b, l = !0;
|
|
3190
3208
|
continue;
|
|
3191
3209
|
}
|
|
3192
|
-
e[d] = b, (d === "particleSize" || d === "opacity") && (n = !0), d === "bloomIntensity" && (a = !0), d === "gravityStrength" && (o = !0), d === "dampingStrength" && (
|
|
3210
|
+
e[d] = b, (d === "particleSize" || d === "opacity") && (n = !0), d === "bloomIntensity" && (a = !0), d === "gravityStrength" && (o = !0), d === "dampingStrength" && (l = !0), (d === "attractorStrength" || d === "attractorReverse") && (c = !0);
|
|
3193
3211
|
}
|
|
3194
3212
|
}
|
|
3195
3213
|
if (r.particleColor && r.particleColor.length) {
|
|
3196
|
-
const d = e.particleColor, S = d && typeof d.length == "number" && d.length >= 3 ? d : void 0, b =
|
|
3214
|
+
const d = e.particleColor, S = d && typeof d.length == "number" && d.length >= 3 ? d : void 0, b = Mr(r.particleColor, i, S);
|
|
3197
3215
|
b && (e.particleColor = b, n = !0);
|
|
3198
3216
|
}
|
|
3199
|
-
n && t.updateAppearanceUniform(), a && t.updateBloomIntensity(), o && e.gravityEnabled && t.setGravity(e.gravityStrength),
|
|
3217
|
+
n && t.updateAppearanceUniform(), a && t.updateBloomIntensity(), o && e.gravityEnabled && t.setGravity(e.gravityStrength), l && e.dampingEnabled && t.physics.setDamping(e.dampingStrength), c && e.attractorEnabled && e.attractorPosition && t.setAttractor(e.attractorStrength, e.attractorPosition, e.attractorReverse);
|
|
3200
3218
|
}
|
|
3201
3219
|
}
|
|
3202
|
-
async function
|
|
3220
|
+
async function Tr(s) {
|
|
3203
3221
|
if (!s)
|
|
3204
3222
|
throw new Error("canvas is required for initWebGPU()");
|
|
3205
3223
|
if (!navigator.gpu)
|
|
@@ -3211,30 +3229,33 @@ async function Br(s) {
|
|
|
3211
3229
|
alphaMode: "premultiplied"
|
|
3212
3230
|
}), { device: i, context: t, format: r, canvas: s };
|
|
3213
3231
|
}
|
|
3214
|
-
const
|
|
3215
|
-
|
|
3232
|
+
const Xe = "rgba16float", Xi = 0.5, Ji = (s, t) => [
|
|
3233
|
+
Math.max(1, Math.round(s * Xi)),
|
|
3234
|
+
Math.max(1, Math.round(t * Xi))
|
|
3235
|
+
];
|
|
3236
|
+
function Ni(s, t, e, i) {
|
|
3216
3237
|
const r = s.createTexture({
|
|
3217
3238
|
size: [e, i],
|
|
3218
|
-
format:
|
|
3239
|
+
format: Xe,
|
|
3219
3240
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3220
3241
|
mipLevelCount: 1,
|
|
3221
3242
|
sampleCount: 1
|
|
3222
|
-
}), n = s.createTexture({
|
|
3223
|
-
size: [
|
|
3224
|
-
format:
|
|
3243
|
+
}), [n, a] = Ji(e, i), o = s.createTexture({
|
|
3244
|
+
size: [n, a],
|
|
3245
|
+
format: Xe,
|
|
3225
3246
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3226
3247
|
mipLevelCount: 1,
|
|
3227
3248
|
sampleCount: 1
|
|
3228
|
-
}),
|
|
3229
|
-
size: [
|
|
3230
|
-
format:
|
|
3249
|
+
}), l = s.createTexture({
|
|
3250
|
+
size: [n, a],
|
|
3251
|
+
format: Xe,
|
|
3231
3252
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3232
3253
|
mipLevelCount: 1,
|
|
3233
3254
|
sampleCount: 1
|
|
3234
3255
|
});
|
|
3235
|
-
return { sceneTexture: r, bloomTexA:
|
|
3256
|
+
return { sceneTexture: r, bloomTexA: o, bloomTexB: l };
|
|
3236
3257
|
}
|
|
3237
|
-
function
|
|
3258
|
+
function Yi(s, t, e) {
|
|
3238
3259
|
return s.createTexture({
|
|
3239
3260
|
size: [t, e],
|
|
3240
3261
|
format: "depth24plus",
|
|
@@ -3249,7 +3270,7 @@ function St(s, t, e) {
|
|
|
3249
3270
|
});
|
|
3250
3271
|
return new t.constructor(i.getMappedRange()).set(t), i.unmap(), i;
|
|
3251
3272
|
}
|
|
3252
|
-
const
|
|
3273
|
+
const Er = `
|
|
3253
3274
|
struct Uniforms {
|
|
3254
3275
|
transform: mat4x4<f32>,
|
|
3255
3276
|
cameraPosition: vec3<f32>,
|
|
@@ -3311,7 +3332,7 @@ const Rr = `
|
|
|
3311
3332
|
|
|
3312
3333
|
return finalColor;
|
|
3313
3334
|
}
|
|
3314
|
-
`,
|
|
3335
|
+
`, Ar = `
|
|
3315
3336
|
struct Uniforms {
|
|
3316
3337
|
transform: mat4x4<f32>,
|
|
3317
3338
|
cameraPosition: vec3<f32>,
|
|
@@ -3548,7 +3569,7 @@ const Rr = `
|
|
|
3548
3569
|
return finalColor;
|
|
3549
3570
|
}
|
|
3550
3571
|
`;
|
|
3551
|
-
function
|
|
3572
|
+
function Cr(s) {
|
|
3552
3573
|
const t = s.createBindGroupLayout({
|
|
3553
3574
|
entries: [
|
|
3554
3575
|
{
|
|
@@ -3634,34 +3655,34 @@ function Ar(s) {
|
|
|
3634
3655
|
object3dBindGroupLayout: r
|
|
3635
3656
|
};
|
|
3636
3657
|
}
|
|
3637
|
-
function
|
|
3658
|
+
function Ur(s, t, e, i = {}) {
|
|
3638
3659
|
const { depthCompare: r } = i, n = r || "less", {
|
|
3639
3660
|
particleBindGroupLayout: a,
|
|
3640
3661
|
bloomBindGroupLayout: o,
|
|
3641
|
-
compositeBindGroupLayout:
|
|
3642
|
-
object3dBindGroupLayout:
|
|
3662
|
+
compositeBindGroupLayout: l,
|
|
3663
|
+
object3dBindGroupLayout: c
|
|
3643
3664
|
} = e, d = s.createPipelineLayout({
|
|
3644
3665
|
bindGroupLayouts: [a]
|
|
3645
3666
|
}), S = s.createPipelineLayout({
|
|
3646
3667
|
bindGroupLayouts: [o]
|
|
3647
3668
|
}), b = s.createPipelineLayout({
|
|
3648
|
-
bindGroupLayouts: [
|
|
3649
|
-
}),
|
|
3650
|
-
code:
|
|
3669
|
+
bindGroupLayouts: [l]
|
|
3670
|
+
}), f = s.createShaderModule({
|
|
3671
|
+
code: Hs
|
|
3651
3672
|
}), v = s.createShaderModule({
|
|
3652
|
-
code: qs
|
|
3653
|
-
}), E = s.createShaderModule({
|
|
3654
3673
|
code: Zs
|
|
3655
|
-
}),
|
|
3656
|
-
code:
|
|
3674
|
+
}), C = s.createShaderModule({
|
|
3675
|
+
code: Ws
|
|
3657
3676
|
}), z = s.createShaderModule({
|
|
3658
|
-
code:
|
|
3659
|
-
}),
|
|
3660
|
-
code:
|
|
3661
|
-
}),
|
|
3677
|
+
code: $s
|
|
3678
|
+
}), D = s.createShaderModule({
|
|
3679
|
+
code: Er
|
|
3680
|
+
}), M = s.createShaderModule({
|
|
3681
|
+
code: Ar
|
|
3682
|
+
}), Z = (kt) => s.createRenderPipeline({
|
|
3662
3683
|
layout: d,
|
|
3663
3684
|
vertex: {
|
|
3664
|
-
module:
|
|
3685
|
+
module: f,
|
|
3665
3686
|
entryPoint: "vs_main",
|
|
3666
3687
|
buffers: [
|
|
3667
3688
|
{
|
|
@@ -3722,10 +3743,10 @@ function Er(s, t, e, i = {}) {
|
|
|
3722
3743
|
]
|
|
3723
3744
|
},
|
|
3724
3745
|
fragment: {
|
|
3725
|
-
module:
|
|
3746
|
+
module: f,
|
|
3726
3747
|
entryPoint: "fs_main",
|
|
3727
3748
|
targets: [{
|
|
3728
|
-
format:
|
|
3749
|
+
format: Xe,
|
|
3729
3750
|
blend: kt
|
|
3730
3751
|
}]
|
|
3731
3752
|
},
|
|
@@ -3738,7 +3759,7 @@ function Er(s, t, e, i = {}) {
|
|
|
3738
3759
|
depthCompare: n,
|
|
3739
3760
|
format: "depth24plus"
|
|
3740
3761
|
}
|
|
3741
|
-
}), T =
|
|
3762
|
+
}), T = Z({
|
|
3742
3763
|
color: {
|
|
3743
3764
|
srcFactor: "src-alpha",
|
|
3744
3765
|
dstFactor: "one-minus-src-alpha",
|
|
@@ -3749,7 +3770,7 @@ function Er(s, t, e, i = {}) {
|
|
|
3749
3770
|
dstFactor: "one-minus-src-alpha",
|
|
3750
3771
|
operation: "add"
|
|
3751
3772
|
}
|
|
3752
|
-
}),
|
|
3773
|
+
}), G = Z({
|
|
3753
3774
|
color: {
|
|
3754
3775
|
srcFactor: "src-alpha",
|
|
3755
3776
|
dstFactor: "one",
|
|
@@ -3760,10 +3781,10 @@ function Er(s, t, e, i = {}) {
|
|
|
3760
3781
|
dstFactor: "one-minus-src-alpha",
|
|
3761
3782
|
operation: "add"
|
|
3762
3783
|
}
|
|
3763
|
-
}),
|
|
3784
|
+
}), F = s.createRenderPipeline({
|
|
3764
3785
|
layout: d,
|
|
3765
3786
|
vertex: {
|
|
3766
|
-
module:
|
|
3787
|
+
module: f,
|
|
3767
3788
|
entryPoint: "vs_main",
|
|
3768
3789
|
buffers: [
|
|
3769
3790
|
{
|
|
@@ -3824,10 +3845,10 @@ function Er(s, t, e, i = {}) {
|
|
|
3824
3845
|
]
|
|
3825
3846
|
},
|
|
3826
3847
|
fragment: {
|
|
3827
|
-
module:
|
|
3848
|
+
module: f,
|
|
3828
3849
|
entryPoint: "fs_main",
|
|
3829
3850
|
targets: [{
|
|
3830
|
-
format:
|
|
3851
|
+
format: Xe,
|
|
3831
3852
|
writeMask: 0
|
|
3832
3853
|
// No color write — depth only
|
|
3833
3854
|
}]
|
|
@@ -3852,23 +3873,23 @@ function Er(s, t, e, i = {}) {
|
|
|
3852
3873
|
module: v,
|
|
3853
3874
|
entryPoint: "fs_main",
|
|
3854
3875
|
targets: [{
|
|
3855
|
-
format:
|
|
3876
|
+
format: Xe
|
|
3856
3877
|
}]
|
|
3857
3878
|
},
|
|
3858
3879
|
primitive: {
|
|
3859
3880
|
topology: "triangle-list"
|
|
3860
3881
|
}
|
|
3861
|
-
}),
|
|
3882
|
+
}), se = s.createRenderPipeline({
|
|
3862
3883
|
layout: b,
|
|
3863
3884
|
vertex: {
|
|
3864
|
-
module:
|
|
3885
|
+
module: C,
|
|
3865
3886
|
entryPoint: "vs_main"
|
|
3866
3887
|
},
|
|
3867
3888
|
fragment: {
|
|
3868
|
-
module:
|
|
3889
|
+
module: C,
|
|
3869
3890
|
entryPoint: "fs_main",
|
|
3870
3891
|
targets: [{
|
|
3871
|
-
format:
|
|
3892
|
+
format: Xe,
|
|
3872
3893
|
blend: {
|
|
3873
3894
|
color: {
|
|
3874
3895
|
srcFactor: "one",
|
|
@@ -3886,17 +3907,17 @@ function Er(s, t, e, i = {}) {
|
|
|
3886
3907
|
primitive: {
|
|
3887
3908
|
topology: "triangle-list"
|
|
3888
3909
|
}
|
|
3889
|
-
}),
|
|
3910
|
+
}), ne = s.createRenderPipeline({
|
|
3890
3911
|
layout: b,
|
|
3891
3912
|
vertex: {
|
|
3892
|
-
module:
|
|
3913
|
+
module: z,
|
|
3893
3914
|
entryPoint: "vs_main"
|
|
3894
3915
|
},
|
|
3895
3916
|
fragment: {
|
|
3896
|
-
module:
|
|
3917
|
+
module: z,
|
|
3897
3918
|
entryPoint: "fs_main",
|
|
3898
3919
|
targets: [{
|
|
3899
|
-
format:
|
|
3920
|
+
format: Xe,
|
|
3900
3921
|
blend: {
|
|
3901
3922
|
color: {
|
|
3902
3923
|
srcFactor: "one",
|
|
@@ -3914,11 +3935,11 @@ function Er(s, t, e, i = {}) {
|
|
|
3914
3935
|
primitive: {
|
|
3915
3936
|
topology: "triangle-list"
|
|
3916
3937
|
}
|
|
3917
|
-
}),
|
|
3938
|
+
}), re = s.createShaderModule({ code: Js }), q = s.createRenderPipeline({
|
|
3918
3939
|
layout: b,
|
|
3919
|
-
vertex: { module:
|
|
3940
|
+
vertex: { module: re, entryPoint: "vs_main" },
|
|
3920
3941
|
fragment: {
|
|
3921
|
-
module:
|
|
3942
|
+
module: re,
|
|
3922
3943
|
entryPoint: "fs_main",
|
|
3923
3944
|
targets: [{
|
|
3924
3945
|
format: t,
|
|
@@ -3930,11 +3951,11 @@ function Er(s, t, e, i = {}) {
|
|
|
3930
3951
|
},
|
|
3931
3952
|
primitive: { topology: "triangle-list" }
|
|
3932
3953
|
}), tt = s.createPipelineLayout({
|
|
3933
|
-
bindGroupLayouts: [
|
|
3954
|
+
bindGroupLayouts: [c]
|
|
3934
3955
|
}), xt = s.createRenderPipeline({
|
|
3935
3956
|
layout: tt,
|
|
3936
3957
|
vertex: {
|
|
3937
|
-
module:
|
|
3958
|
+
module: D,
|
|
3938
3959
|
entryPoint: "vs_main",
|
|
3939
3960
|
buffers: [
|
|
3940
3961
|
{
|
|
@@ -3959,10 +3980,10 @@ function Er(s, t, e, i = {}) {
|
|
|
3959
3980
|
]
|
|
3960
3981
|
},
|
|
3961
3982
|
fragment: {
|
|
3962
|
-
module:
|
|
3983
|
+
module: D,
|
|
3963
3984
|
entryPoint: "fs_main",
|
|
3964
3985
|
targets: [{
|
|
3965
|
-
format:
|
|
3986
|
+
format: Xe,
|
|
3966
3987
|
blend: {
|
|
3967
3988
|
color: {
|
|
3968
3989
|
srcFactor: "src-alpha",
|
|
@@ -3986,10 +4007,10 @@ function Er(s, t, e, i = {}) {
|
|
|
3986
4007
|
depthCompare: n,
|
|
3987
4008
|
format: "depth24plus"
|
|
3988
4009
|
}
|
|
3989
|
-
}),
|
|
4010
|
+
}), at = s.createRenderPipeline({
|
|
3990
4011
|
layout: d,
|
|
3991
4012
|
vertex: {
|
|
3992
|
-
module:
|
|
4013
|
+
module: M,
|
|
3993
4014
|
entryPoint: "vs_main",
|
|
3994
4015
|
buffers: [
|
|
3995
4016
|
{
|
|
@@ -4061,10 +4082,10 @@ function Er(s, t, e, i = {}) {
|
|
|
4061
4082
|
]
|
|
4062
4083
|
},
|
|
4063
4084
|
fragment: {
|
|
4064
|
-
module:
|
|
4085
|
+
module: M,
|
|
4065
4086
|
entryPoint: "fs_main",
|
|
4066
4087
|
targets: [{
|
|
4067
|
-
format:
|
|
4088
|
+
format: Xe,
|
|
4068
4089
|
blend: {
|
|
4069
4090
|
color: {
|
|
4070
4091
|
srcFactor: "src-alpha",
|
|
@@ -4091,14 +4112,14 @@ function Er(s, t, e, i = {}) {
|
|
|
4091
4112
|
});
|
|
4092
4113
|
return {
|
|
4093
4114
|
particlePipeline: T,
|
|
4094
|
-
particleAdditivePipeline:
|
|
4095
|
-
particleDepthWritePipeline:
|
|
4115
|
+
particleAdditivePipeline: G,
|
|
4116
|
+
particleDepthWritePipeline: F,
|
|
4096
4117
|
blurPipeline: H,
|
|
4097
|
-
compositePipeline:
|
|
4098
|
-
directRenderPipeline:
|
|
4118
|
+
compositePipeline: se,
|
|
4119
|
+
directRenderPipeline: ne,
|
|
4099
4120
|
finalCompositePipeline: q,
|
|
4100
4121
|
object3dPipeline: xt,
|
|
4101
|
-
glbMeshPipeline:
|
|
4122
|
+
glbMeshPipeline: at
|
|
4102
4123
|
};
|
|
4103
4124
|
}
|
|
4104
4125
|
function si(s, t, e, i) {
|
|
@@ -4107,9 +4128,9 @@ function si(s, t, e, i) {
|
|
|
4107
4128
|
appearanceUniformBuffer: n,
|
|
4108
4129
|
horizontalBlurUniformBuffer: a,
|
|
4109
4130
|
verticalBlurUniformBuffer: o,
|
|
4110
|
-
bloomIntensityBuffer:
|
|
4131
|
+
bloomIntensityBuffer: l
|
|
4111
4132
|
} = e, {
|
|
4112
|
-
sceneTexture:
|
|
4133
|
+
sceneTexture: c,
|
|
4113
4134
|
bloomTexA: d,
|
|
4114
4135
|
bloomTexB: S
|
|
4115
4136
|
} = i, b = s.createBindGroup({
|
|
@@ -4137,7 +4158,7 @@ function si(s, t, e, i) {
|
|
|
4137
4158
|
resource: { buffer: n }
|
|
4138
4159
|
}
|
|
4139
4160
|
]
|
|
4140
|
-
}),
|
|
4161
|
+
}), f = s.createBindGroup({
|
|
4141
4162
|
layout: s.createBindGroupLayout({
|
|
4142
4163
|
entries: [
|
|
4143
4164
|
{
|
|
@@ -4164,7 +4185,7 @@ function si(s, t, e, i) {
|
|
|
4164
4185
|
},
|
|
4165
4186
|
{
|
|
4166
4187
|
binding: 1,
|
|
4167
|
-
resource:
|
|
4188
|
+
resource: c.createView()
|
|
4168
4189
|
},
|
|
4169
4190
|
{
|
|
4170
4191
|
binding: 2,
|
|
@@ -4205,7 +4226,7 @@ function si(s, t, e, i) {
|
|
|
4205
4226
|
resource: { buffer: o }
|
|
4206
4227
|
}
|
|
4207
4228
|
]
|
|
4208
|
-
}),
|
|
4229
|
+
}), C = s.createBindGroup({
|
|
4209
4230
|
layout: s.createBindGroupLayout({
|
|
4210
4231
|
entries: [
|
|
4211
4232
|
{
|
|
@@ -4237,7 +4258,7 @@ function si(s, t, e, i) {
|
|
|
4237
4258
|
},
|
|
4238
4259
|
{
|
|
4239
4260
|
binding: 1,
|
|
4240
|
-
resource:
|
|
4261
|
+
resource: c.createView()
|
|
4241
4262
|
},
|
|
4242
4263
|
{
|
|
4243
4264
|
binding: 2,
|
|
@@ -4245,10 +4266,10 @@ function si(s, t, e, i) {
|
|
|
4245
4266
|
},
|
|
4246
4267
|
{
|
|
4247
4268
|
binding: 3,
|
|
4248
|
-
resource: { buffer:
|
|
4269
|
+
resource: { buffer: l }
|
|
4249
4270
|
}
|
|
4250
4271
|
]
|
|
4251
|
-
}),
|
|
4272
|
+
}), z = s.createBindGroup({
|
|
4252
4273
|
layout: s.createBindGroupLayout({
|
|
4253
4274
|
entries: [
|
|
4254
4275
|
{
|
|
@@ -4280,7 +4301,7 @@ function si(s, t, e, i) {
|
|
|
4280
4301
|
},
|
|
4281
4302
|
{
|
|
4282
4303
|
binding: 1,
|
|
4283
|
-
resource:
|
|
4304
|
+
resource: c.createView()
|
|
4284
4305
|
},
|
|
4285
4306
|
{
|
|
4286
4307
|
binding: 2,
|
|
@@ -4288,19 +4309,19 @@ function si(s, t, e, i) {
|
|
|
4288
4309
|
},
|
|
4289
4310
|
{
|
|
4290
4311
|
binding: 3,
|
|
4291
|
-
resource: { buffer:
|
|
4312
|
+
resource: { buffer: l }
|
|
4292
4313
|
}
|
|
4293
4314
|
]
|
|
4294
4315
|
});
|
|
4295
4316
|
return {
|
|
4296
4317
|
particleBindGroup: b,
|
|
4297
|
-
horizontalBlurBindGroup:
|
|
4318
|
+
horizontalBlurBindGroup: f,
|
|
4298
4319
|
verticalBlurBindGroup: v,
|
|
4299
|
-
compositeBindGroup:
|
|
4300
|
-
directRenderBindGroup:
|
|
4320
|
+
compositeBindGroup: C,
|
|
4321
|
+
directRenderBindGroup: z
|
|
4301
4322
|
};
|
|
4302
4323
|
}
|
|
4303
|
-
function
|
|
4324
|
+
function Ir(s) {
|
|
4304
4325
|
return s.createSampler({
|
|
4305
4326
|
magFilter: "linear",
|
|
4306
4327
|
minFilter: "linear",
|
|
@@ -4310,7 +4331,7 @@ function Cr(s) {
|
|
|
4310
4331
|
maxAnisotropy: 16
|
|
4311
4332
|
});
|
|
4312
4333
|
}
|
|
4313
|
-
function
|
|
4334
|
+
function zr() {
|
|
4314
4335
|
const s = new Float32Array([
|
|
4315
4336
|
// Front face (z = 0.5)
|
|
4316
4337
|
-0.5,
|
|
@@ -4508,13 +4529,13 @@ function Ur() {
|
|
|
4508
4529
|
]);
|
|
4509
4530
|
return { vertices: s, indices: t };
|
|
4510
4531
|
}
|
|
4511
|
-
function
|
|
4532
|
+
function Dr(s = 16, t = 16) {
|
|
4512
4533
|
const e = [], i = [];
|
|
4513
4534
|
for (let r = 0; r <= s; r++) {
|
|
4514
4535
|
const n = r * Math.PI / s, a = Math.sin(n), o = Math.cos(n);
|
|
4515
|
-
for (let
|
|
4516
|
-
const
|
|
4517
|
-
e.push(b * 0.5,
|
|
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, f = o, v = d * a;
|
|
4538
|
+
e.push(b * 0.5, f * 0.5, v * 0.5), e.push(b, f, v);
|
|
4518
4539
|
}
|
|
4519
4540
|
}
|
|
4520
4541
|
for (let r = 0; r < s; r++)
|
|
@@ -4527,7 +4548,7 @@ function Ir(s = 16, t = 16) {
|
|
|
4527
4548
|
indices: new Uint16Array(i)
|
|
4528
4549
|
};
|
|
4529
4550
|
}
|
|
4530
|
-
class
|
|
4551
|
+
class Gr {
|
|
4531
4552
|
constructor(t, e, i, r, n) {
|
|
4532
4553
|
this.id = t, this.type = e, this.position = i, this.scale = r, this.color = n, this.rotation = [0, 0, 0];
|
|
4533
4554
|
}
|
|
@@ -4535,9 +4556,9 @@ class zr {
|
|
|
4535
4556
|
* Get the model matrix for this object
|
|
4536
4557
|
*/
|
|
4537
4558
|
getModelMatrix() {
|
|
4538
|
-
const { position: t, scale: e, rotation: i } = this, r = this.createTranslationMatrix(t), n = this.createRotationMatrixX(i[0]), a = this.createRotationMatrixY(i[1]), o = this.createRotationMatrixZ(i[2]),
|
|
4539
|
-
let
|
|
4540
|
-
return
|
|
4559
|
+
const { position: t, scale: e, rotation: i } = this, r = this.createTranslationMatrix(t), n = this.createRotationMatrixX(i[0]), a = this.createRotationMatrixY(i[1]), o = this.createRotationMatrixZ(i[2]), l = this.createScaleMatrix(e);
|
|
4560
|
+
let c = r;
|
|
4561
|
+
return c = this.multiplyMatrices(c, o), c = this.multiplyMatrices(c, a), c = this.multiplyMatrices(c, n), c = this.multiplyMatrices(c, l), c;
|
|
4541
4562
|
}
|
|
4542
4563
|
/**
|
|
4543
4564
|
* Get the normal matrix (inverse transpose of model matrix)
|
|
@@ -4661,7 +4682,7 @@ class zr {
|
|
|
4661
4682
|
return i;
|
|
4662
4683
|
}
|
|
4663
4684
|
}
|
|
4664
|
-
class
|
|
4685
|
+
class Nr {
|
|
4665
4686
|
constructor(t) {
|
|
4666
4687
|
this.device = t, this.objects = [], this.nextId = 0, this.initializeGeometry(), this.onObjectAdded = null, this.onObjectRemoved = null, this.onObjectUpdated = null;
|
|
4667
4688
|
}
|
|
@@ -4669,7 +4690,7 @@ class kr {
|
|
|
4669
4690
|
* Initialize geometry buffers for cube and sphere
|
|
4670
4691
|
*/
|
|
4671
4692
|
initializeGeometry() {
|
|
4672
|
-
const t =
|
|
4693
|
+
const t = zr(), e = Dr(16, 16);
|
|
4673
4694
|
this.cubeVertexBuffer = St(
|
|
4674
4695
|
this.device,
|
|
4675
4696
|
t.vertices,
|
|
@@ -4697,7 +4718,7 @@ class kr {
|
|
|
4697
4718
|
* @returns {Object3D} The created object
|
|
4698
4719
|
*/
|
|
4699
4720
|
addObject(t, e = [0, 0, 0], i = [1, 1, 1], r = [1, 1, 1, 1]) {
|
|
4700
|
-
const n = new
|
|
4721
|
+
const n = new Gr(this.nextId++, t, e, i, r);
|
|
4701
4722
|
return n.uniformBuffer = this.device.createBuffer({
|
|
4702
4723
|
size: 192,
|
|
4703
4724
|
// modelMatrix (64) + normalMatrix (64) + color (16) + padding (48)
|
|
@@ -4775,32 +4796,32 @@ class kr {
|
|
|
4775
4796
|
{ binding: 1, resource: { buffer: n.uniformBuffer } }
|
|
4776
4797
|
]
|
|
4777
4798
|
});
|
|
4778
|
-
let o,
|
|
4799
|
+
let o, l, c;
|
|
4779
4800
|
if (n.type === "cube")
|
|
4780
|
-
o = this.cubeVertexBuffer,
|
|
4801
|
+
o = this.cubeVertexBuffer, l = this.cubeIndexBuffer, c = this.cubeIndexCount;
|
|
4781
4802
|
else if (n.type === "sphere")
|
|
4782
|
-
o = this.sphereVertexBuffer,
|
|
4803
|
+
o = this.sphereVertexBuffer, l = this.sphereIndexBuffer, c = this.sphereIndexCount;
|
|
4783
4804
|
else
|
|
4784
4805
|
continue;
|
|
4785
|
-
t.setPipeline(e), t.setBindGroup(0, a), t.setVertexBuffer(0, o), t.setIndexBuffer(
|
|
4806
|
+
t.setPipeline(e), t.setBindGroup(0, a), t.setVertexBuffer(0, o), t.setIndexBuffer(l, "uint16"), t.drawIndexed(c);
|
|
4786
4807
|
}
|
|
4787
4808
|
}
|
|
4788
4809
|
}
|
|
4789
|
-
function
|
|
4810
|
+
function Yr(s) {
|
|
4790
4811
|
const t = parseInt(s.slice(1, 3), 16) / 255, e = parseInt(s.slice(3, 5), 16) / 255, i = parseInt(s.slice(5, 7), 16) / 255;
|
|
4791
4812
|
return [t, e, i];
|
|
4792
4813
|
}
|
|
4793
|
-
function
|
|
4814
|
+
function jr(s) {
|
|
4794
4815
|
if (!s) return "#ffffff";
|
|
4795
4816
|
const t = Math.round(s[0] * 255).toString(16).padStart(2, "0"), e = Math.round(s[1] * 255).toString(16).padStart(2, "0"), i = Math.round(s[2] * 255).toString(16).padStart(2, "0");
|
|
4796
4817
|
return `#${t}${e}${i}`;
|
|
4797
4818
|
}
|
|
4798
|
-
function
|
|
4799
|
-
const i =
|
|
4819
|
+
function qr(s, t, e) {
|
|
4820
|
+
const i = ji([
|
|
4800
4821
|
s[0] - t[0],
|
|
4801
4822
|
s[1] - t[1],
|
|
4802
4823
|
s[2] - t[2]
|
|
4803
|
-
]), r =
|
|
4824
|
+
]), r = ji(qi(e, i)), n = qi(i, r);
|
|
4804
4825
|
return new Float32Array([
|
|
4805
4826
|
r[0],
|
|
4806
4827
|
n[0],
|
|
@@ -4820,7 +4841,7 @@ function Yr(s, t, e) {
|
|
|
4820
4841
|
1
|
|
4821
4842
|
]);
|
|
4822
4843
|
}
|
|
4823
|
-
function
|
|
4844
|
+
function Hr(s, t = Math.PI / 4) {
|
|
4824
4845
|
const r = 1 / Math.tan(t / 2);
|
|
4825
4846
|
return new Float32Array([
|
|
4826
4847
|
r * s,
|
|
@@ -4841,11 +4862,11 @@ function jr(s, t = Math.PI / 4) {
|
|
|
4841
4862
|
0
|
|
4842
4863
|
]);
|
|
4843
4864
|
}
|
|
4844
|
-
function
|
|
4865
|
+
function ji(s) {
|
|
4845
4866
|
const t = Math.sqrt(s[0] * s[0] + s[1] * s[1] + s[2] * s[2]);
|
|
4846
4867
|
return [s[0] / t, s[1] / t, s[2] / t];
|
|
4847
4868
|
}
|
|
4848
|
-
function
|
|
4869
|
+
function qi(s, t) {
|
|
4849
4870
|
return [
|
|
4850
4871
|
s[1] * t[2] - s[2] * t[1],
|
|
4851
4872
|
s[2] * t[0] - s[0] * t[2],
|
|
@@ -4866,7 +4887,7 @@ function Fr(s, t) {
|
|
|
4866
4887
|
}
|
|
4867
4888
|
return e;
|
|
4868
4889
|
}
|
|
4869
|
-
const ai = 1481005640,
|
|
4890
|
+
const ai = 1481005640, Ki = 1, Qi = 1313821514, es = 5130562, At = "$hzfxAsset", ts = (s) => typeof atob == "function" ? Uint8Array.from(atob(s), (t) => t.charCodeAt(0)) : new Uint8Array(Buffer.from(s, "base64")), Hi = (s) => {
|
|
4870
4891
|
if (typeof btoa == "function") {
|
|
4871
4892
|
let t = "";
|
|
4872
4893
|
for (let e = 0; e < s.length; e++) t += String.fromCharCode(s[e]);
|
|
@@ -4874,94 +4895,94 @@ const ai = 1481005640, $i = 1, Ji = 1313821514, Ki = 5130562, Et = "$hzfxAsset",
|
|
|
4874
4895
|
}
|
|
4875
4896
|
return Buffer.from(s).toString("base64");
|
|
4876
4897
|
};
|
|
4877
|
-
function
|
|
4878
|
-
const t = s.indexOf(","), e = s.slice(5, t), i = e.split(";")[0] || "application/octet-stream", r = s.slice(t + 1), a = /;base64/i.test(e) ?
|
|
4898
|
+
function Vr(s) {
|
|
4899
|
+
const t = s.indexOf(","), e = s.slice(5, t), i = e.split(";")[0] || "application/octet-stream", r = s.slice(t + 1), a = /;base64/i.test(e) ? ts(r) : new TextEncoder().encode(decodeURIComponent(r));
|
|
4879
4900
|
return { mime: i, bytes: a };
|
|
4880
4901
|
}
|
|
4881
4902
|
function Zi(s) {
|
|
4882
4903
|
return (4 - s % 4) % 4;
|
|
4883
4904
|
}
|
|
4884
|
-
async function
|
|
4905
|
+
async function Or(s, t = {}) {
|
|
4885
4906
|
const { textureFormat: e = "keep", quality: i = 0.85 } = t, r = [], n = [];
|
|
4886
4907
|
let a = 0;
|
|
4887
|
-
const o = (
|
|
4888
|
-
const
|
|
4889
|
-
r.push({ offset:
|
|
4890
|
-
const
|
|
4891
|
-
return
|
|
4892
|
-
},
|
|
4893
|
-
for (const
|
|
4894
|
-
const
|
|
4895
|
-
if (typeof
|
|
4896
|
-
let { mime: H, bytes:
|
|
4897
|
-
if (
|
|
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
|
+
const re = Zi(ne);
|
|
4912
|
+
return re && (n.push(new Uint8Array(re)), a += re), r.length - 1;
|
|
4913
|
+
}, l = e === "webp" && typeof OffscreenCanvas < "u" && typeof createImageBitmap == "function", c = [];
|
|
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
|
+
if (l && H !== "image/webp")
|
|
4898
4919
|
try {
|
|
4899
|
-
const
|
|
4900
|
-
|
|
4901
|
-
const q = await
|
|
4902
|
-
tt.length <
|
|
4920
|
+
const ne = await createImageBitmap(new Blob([se], { type: H })), re = new OffscreenCanvas(ne.width, ne.height);
|
|
4921
|
+
re.getContext("2d").drawImage(ne, 0, 0);
|
|
4922
|
+
const q = await re.convertToBlob({ type: "image/webp", quality: i }), tt = new Uint8Array(await q.arrayBuffer());
|
|
4923
|
+
tt.length < se.length && (se = tt, H = "image/webp");
|
|
4903
4924
|
} catch {
|
|
4904
4925
|
}
|
|
4905
|
-
|
|
4926
|
+
F.textureImageData = { [At]: o(se, H, "texture") };
|
|
4906
4927
|
}
|
|
4907
|
-
if (typeof
|
|
4908
|
-
const H =
|
|
4909
|
-
|
|
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") };
|
|
4910
4931
|
}
|
|
4911
|
-
|
|
4932
|
+
c.push(F);
|
|
4912
4933
|
}
|
|
4913
|
-
const d = { ...s, systems:
|
|
4934
|
+
const d = { ...s, systems: c, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)), b = Zi(S.length), f = new Uint8Array(a);
|
|
4914
4935
|
let v = 0;
|
|
4915
|
-
for (const
|
|
4916
|
-
|
|
4917
|
-
const
|
|
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);
|
|
4918
4939
|
let T = 0;
|
|
4919
|
-
|
|
4920
|
-
for (let
|
|
4921
|
-
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;
|
|
4922
4943
|
}
|
|
4923
|
-
function
|
|
4944
|
+
function is(s) {
|
|
4924
4945
|
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === ai;
|
|
4925
4946
|
}
|
|
4926
|
-
function
|
|
4947
|
+
function ss(s) {
|
|
4927
4948
|
const t = new DataView(s);
|
|
4928
4949
|
if (t.getUint32(0, !0) !== ai) throw new Error("[unpackHZFX] bad magic — not an .hzfx file");
|
|
4929
4950
|
const e = t.getUint32(4, !0);
|
|
4930
|
-
if (e !==
|
|
4951
|
+
if (e !== Ki) throw new Error(`[unpackHZFX] unsupported version ${e}`);
|
|
4931
4952
|
let i = 12, r = null, n = -1;
|
|
4932
4953
|
const a = new Uint8Array(s);
|
|
4933
4954
|
for (; i + 8 <= s.byteLength; ) {
|
|
4934
4955
|
const b = t.getUint32(i, !0);
|
|
4935
4956
|
i += 4;
|
|
4936
|
-
const
|
|
4937
|
-
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;
|
|
4938
4959
|
}
|
|
4939
4960
|
if (!r) throw new Error("[unpackHZFX] missing JSON chunk");
|
|
4940
|
-
const o = r.assets || [],
|
|
4941
|
-
const
|
|
4942
|
-
return !
|
|
4943
|
-
},
|
|
4944
|
-
const
|
|
4945
|
-
if (
|
|
4946
|
-
const v =
|
|
4947
|
-
|
|
4961
|
+
const o = r.assets || [], l = (b) => {
|
|
4962
|
+
const f = o[b];
|
|
4963
|
+
return !f || n < 0 ? null : { ...f, bytes: a.subarray(n + f.offset, n + f.offset + f.length) };
|
|
4964
|
+
}, c = (b) => b && typeof b == "object" && typeof b[At] == "number", d = (r.systems || []).map((b) => {
|
|
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;
|
|
4948
4969
|
}
|
|
4949
|
-
if (
|
|
4950
|
-
const v =
|
|
4951
|
-
|
|
4970
|
+
if (c(f.glbModelData)) {
|
|
4971
|
+
const v = l(f.glbModelData[At]);
|
|
4972
|
+
f.glbModelData = v ? Hi(v.bytes) : void 0;
|
|
4952
4973
|
}
|
|
4953
|
-
return
|
|
4974
|
+
return f;
|
|
4954
4975
|
}), S = { ...r, systems: d };
|
|
4955
4976
|
return delete S.assets, S;
|
|
4956
4977
|
}
|
|
4957
|
-
function
|
|
4978
|
+
function Lr(s) {
|
|
4958
4979
|
const t = new Uint8Array(s);
|
|
4959
4980
|
let e = "";
|
|
4960
4981
|
for (let i = 0; i < t.byteLength; i++)
|
|
4961
4982
|
e += String.fromCharCode(t[i]);
|
|
4962
4983
|
return btoa(e);
|
|
4963
4984
|
}
|
|
4964
|
-
function
|
|
4985
|
+
function kr(s) {
|
|
4965
4986
|
return {
|
|
4966
4987
|
name: s.name,
|
|
4967
4988
|
id: s.id,
|
|
@@ -5147,7 +5168,7 @@ function Or(s) {
|
|
|
5147
5168
|
displayUnit: s.displayUnit || "m"
|
|
5148
5169
|
};
|
|
5149
5170
|
}
|
|
5150
|
-
async function
|
|
5171
|
+
async function Zr(s, t, e = "hzfx") {
|
|
5151
5172
|
if (!s || !s.particleSystems || s.particleSystems.length === 0) {
|
|
5152
5173
|
alert("No particle systems to save.");
|
|
5153
5174
|
return;
|
|
@@ -5157,11 +5178,11 @@ async function qr(s, t, e = "hzfx") {
|
|
|
5157
5178
|
version: "1.0",
|
|
5158
5179
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5159
5180
|
systems: s.particleSystems.map(({ config: d, system: S }) => ({
|
|
5160
|
-
...
|
|
5181
|
+
...kr(d),
|
|
5161
5182
|
// single source of truth for config fields
|
|
5162
5183
|
// Binary assets embedded so replaceSystems() can restore them
|
|
5163
5184
|
textureImageData: d.textureEnabled && !d.glbModelEnabled && d.textureImageData ? d.textureImageData : void 0,
|
|
5164
|
-
glbModelData: d.glbModelEnabled && S.glbRawArrayBuffer ?
|
|
5185
|
+
glbModelData: d.glbModelEnabled && S.glbRawArrayBuffer ? Lr(S.glbRawArrayBuffer) : void 0
|
|
5165
5186
|
})),
|
|
5166
5187
|
activeSystemIndex: s.activeSystemIndex,
|
|
5167
5188
|
loop: s.loop || !1
|
|
@@ -5169,7 +5190,7 @@ async function qr(s, t, e = "hzfx") {
|
|
|
5169
5190
|
}, r = e === "json" ? "json" : "hzfx";
|
|
5170
5191
|
let n;
|
|
5171
5192
|
if (r === "hzfx") {
|
|
5172
|
-
const d = await
|
|
5193
|
+
const d = await Or(i, { textureFormat: "webp" });
|
|
5173
5194
|
n = new Blob([d], { type: "application/octet-stream" });
|
|
5174
5195
|
} else
|
|
5175
5196
|
n = new Blob([JSON.stringify(i, null, 2)], { type: "application/json" });
|
|
@@ -5180,13 +5201,13 @@ async function qr(s, t, e = "hzfx") {
|
|
|
5180
5201
|
const d = /* @__PURE__ */ new Date();
|
|
5181
5202
|
a = `particle-scene_${`${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, "0")}-${d.getDate().toString().padStart(2, "0")}_${d.getHours().toString().padStart(2, "0")}${d.getMinutes().toString().padStart(2, "0")}`}`;
|
|
5182
5203
|
}
|
|
5183
|
-
const o = `${a}.${r}`,
|
|
5184
|
-
|
|
5204
|
+
const o = `${a}.${r}`, l = URL.createObjectURL(n), c = document.createElement("a");
|
|
5205
|
+
c.href = l, c.download = o, document.body.appendChild(c), c.click(), document.body.removeChild(c), URL.revokeObjectURL(l);
|
|
5185
5206
|
} catch (i) {
|
|
5186
5207
|
console.error("Error saving scene:", i), alert("Error saving scene. See console for details.");
|
|
5187
5208
|
}
|
|
5188
5209
|
}
|
|
5189
|
-
function
|
|
5210
|
+
function Wr(s) {
|
|
5190
5211
|
return new Promise((t, e) => {
|
|
5191
5212
|
try {
|
|
5192
5213
|
const i = s.target.files[0];
|
|
@@ -5199,7 +5220,7 @@ function Zr(s) {
|
|
|
5199
5220
|
try {
|
|
5200
5221
|
const a = n.target.result;
|
|
5201
5222
|
let o;
|
|
5202
|
-
if (
|
|
5223
|
+
if (is(a) ? o = ss(a) : o = JSON.parse(new TextDecoder().decode(a)), !Array.isArray(o.systems) || o.systems.length === 0)
|
|
5203
5224
|
throw new Error("No valid particle systems found in the file");
|
|
5204
5225
|
t({
|
|
5205
5226
|
systems: o.systems.slice(),
|
|
@@ -5217,7 +5238,7 @@ function Zr(s) {
|
|
|
5217
5238
|
}
|
|
5218
5239
|
});
|
|
5219
5240
|
}
|
|
5220
|
-
async function
|
|
5241
|
+
async function $r(s) {
|
|
5221
5242
|
if (!s || typeof s != "string")
|
|
5222
5243
|
throw new Error("[fetchPreset] url must be a non-empty string");
|
|
5223
5244
|
const t = await fetch(s);
|
|
@@ -5225,7 +5246,7 @@ async function Hr(s) {
|
|
|
5225
5246
|
throw new Error(`[fetchPreset] HTTP ${t.status}: ${t.statusText}`);
|
|
5226
5247
|
const e = await t.arrayBuffer();
|
|
5227
5248
|
let i;
|
|
5228
|
-
if (
|
|
5249
|
+
if (is(e) ? i = ss(e) : i = JSON.parse(new TextDecoder().decode(e)), !Array.isArray(i.systems) || i.systems.length === 0)
|
|
5229
5250
|
throw new Error('[fetchPreset] Invalid preset: "systems" must be a non-empty array');
|
|
5230
5251
|
return {
|
|
5231
5252
|
version: i.version,
|
|
@@ -5233,7 +5254,7 @@ async function Hr(s) {
|
|
|
5233
5254
|
activeSystemIndex: i.activeSystemIndex ?? 0
|
|
5234
5255
|
};
|
|
5235
5256
|
}
|
|
5236
|
-
const
|
|
5257
|
+
const Xr = (s) => `
|
|
5237
5258
|
@vertex fn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
|
|
5238
5259
|
var p = array<vec2f, 3>(vec2f(-1.0, -3.0), vec2f(-1.0, 1.0), vec2f(3.0, 1.0));
|
|
5239
5260
|
return vec4f(p[i], 0.0, 1.0);
|
|
@@ -5243,51 +5264,53 @@ const Lr = (s) => `
|
|
|
5243
5264
|
return textureLoad(src, vec2i(pos.xy), 0);
|
|
5244
5265
|
}
|
|
5245
5266
|
`;
|
|
5246
|
-
async function
|
|
5267
|
+
async function Jr(s, t = {}) {
|
|
5247
5268
|
const { getSceneDepth: e = null, autoRespawn: i = !0 } = t;
|
|
5248
5269
|
let r, n, a;
|
|
5249
5270
|
const o = !!(s && s.device && s.context);
|
|
5250
|
-
o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await
|
|
5251
|
-
const
|
|
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 Rr(r), d = { layouts: {}, pipelines: {} };
|
|
5252
5273
|
function S(u) {
|
|
5253
|
-
const
|
|
5254
|
-
if (!d.pipelines[
|
|
5255
|
-
const
|
|
5274
|
+
const p = u ? "ms" : "ss";
|
|
5275
|
+
if (!d.pipelines[p]) {
|
|
5276
|
+
const y = r.createShaderModule({ code: Xr(u) }), h = r.createBindGroupLayout({
|
|
5256
5277
|
entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: u } }]
|
|
5257
5278
|
});
|
|
5258
|
-
d.layouts[
|
|
5259
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5260
|
-
vertex: { module:
|
|
5261
|
-
fragment: { module:
|
|
5279
|
+
d.layouts[p] = h, d.pipelines[p] = r.createRenderPipeline({
|
|
5280
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [h] }),
|
|
5281
|
+
vertex: { module: y, entryPoint: "vs" },
|
|
5282
|
+
fragment: { module: y, entryPoint: "fs", targets: [] },
|
|
5262
5283
|
primitive: { topology: "triangle-list" },
|
|
5263
5284
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !0, depthCompare: "always" }
|
|
5264
5285
|
});
|
|
5265
5286
|
}
|
|
5266
|
-
return { pipeline: d.pipelines[
|
|
5287
|
+
return { pipeline: d.pipelines[p], layout: d.layouts[p] };
|
|
5267
5288
|
}
|
|
5268
5289
|
const b = {
|
|
5269
5290
|
bloomSourceTextures: {},
|
|
5270
5291
|
bloomCompositeTextures: {},
|
|
5271
5292
|
combinedTexture: null,
|
|
5272
|
-
getBloomSourceTexture(u,
|
|
5273
|
-
|
|
5274
|
-
|
|
5293
|
+
getBloomSourceTexture(u, p, y) {
|
|
5294
|
+
const h = u;
|
|
5295
|
+
return this.bloomSourceTextures[h] || (this.bloomSourceTextures[h] = r.createTexture({
|
|
5296
|
+
size: [p, y],
|
|
5275
5297
|
format: "rgba16float",
|
|
5276
5298
|
// HDR chain (see webgpu.js HDR_FORMAT) — avoids additive clip
|
|
5277
5299
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5278
|
-
})), this.bloomSourceTextures[
|
|
5300
|
+
})), this.bloomSourceTextures[h];
|
|
5279
5301
|
},
|
|
5280
|
-
getBloomCompositeTexture(u,
|
|
5281
|
-
|
|
5282
|
-
|
|
5302
|
+
getBloomCompositeTexture(u, p, y) {
|
|
5303
|
+
const h = u;
|
|
5304
|
+
return this.bloomCompositeTextures[h] || (this.bloomCompositeTextures[h] = r.createTexture({
|
|
5305
|
+
size: [p, y],
|
|
5283
5306
|
format: "rgba16float",
|
|
5284
5307
|
// HDR chain
|
|
5285
5308
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5286
|
-
})), this.bloomCompositeTextures[
|
|
5309
|
+
})), this.bloomCompositeTextures[h];
|
|
5287
5310
|
},
|
|
5288
|
-
getCombinedTexture(u,
|
|
5311
|
+
getCombinedTexture(u, p) {
|
|
5289
5312
|
return this.combinedTexture || (this.combinedTexture = r.createTexture({
|
|
5290
|
-
size: [u,
|
|
5313
|
+
size: [u, p],
|
|
5291
5314
|
format: "rgba16float",
|
|
5292
5315
|
// HDR chain — tonemapped to canvas in the final pass
|
|
5293
5316
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
@@ -5296,7 +5319,7 @@ async function Wr(s, t = {}) {
|
|
|
5296
5319
|
resizeTextures() {
|
|
5297
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;
|
|
5298
5321
|
}
|
|
5299
|
-
},
|
|
5322
|
+
}, f = {
|
|
5300
5323
|
systemBindGroups: {},
|
|
5301
5324
|
systemBloomHorizontalBindGroups: {},
|
|
5302
5325
|
secondHorizontalBindGroups: {},
|
|
@@ -5312,320 +5335,321 @@ async function Wr(s, t = {}) {
|
|
|
5312
5335
|
clear() {
|
|
5313
5336
|
this.systemBindGroups = {}, this.systemBloomHorizontalBindGroups = {}, this.secondHorizontalBindGroups = {}, this.systemBloomCompositeBindGroups = {}, this.combinedBloomCompositeBindGroups = {}, this.combinedInitialBindGroup = null, this.finalBindGroup = null, this.textureStates = {}, this.textureRefs = {};
|
|
5314
5337
|
}
|
|
5315
|
-
}, v = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }),
|
|
5316
|
-
|
|
5317
|
-
T[u] || (T[u] =
|
|
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
|
+
c.onSystemCreated = (u) => {
|
|
5340
|
+
T[u] || (T[u] = G());
|
|
5318
5341
|
};
|
|
5319
|
-
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 = [];
|
|
5320
5343
|
function oi(u) {
|
|
5321
|
-
for (const
|
|
5344
|
+
for (const p of _e) if (p.ids.has(u)) return p;
|
|
5322
5345
|
return null;
|
|
5323
5346
|
}
|
|
5324
|
-
function
|
|
5347
|
+
function rs(u, p) {
|
|
5325
5348
|
if (!u.pos) return;
|
|
5326
|
-
u.hist.push({ t:
|
|
5327
|
-
const
|
|
5328
|
-
for (; u.hist.length > 2 && u.hist[0].t <
|
|
5329
|
-
}
|
|
5330
|
-
function li(u,
|
|
5331
|
-
const
|
|
5332
|
-
if (
|
|
5333
|
-
const
|
|
5334
|
-
return
|
|
5349
|
+
u.hist.push({ t: p, x: u.pos[0], y: u.pos[1], z: u.pos[2] });
|
|
5350
|
+
const y = p - kt;
|
|
5351
|
+
for (; u.hist.length > 2 && u.hist[0].t < y; ) u.hist.shift();
|
|
5352
|
+
}
|
|
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;
|
|
5335
5358
|
}
|
|
5336
|
-
let
|
|
5337
|
-
if (
|
|
5338
|
-
return
|
|
5339
|
-
if (
|
|
5340
|
-
return
|
|
5341
|
-
for (let
|
|
5342
|
-
if (
|
|
5343
|
-
const
|
|
5344
|
-
return
|
|
5359
|
+
let g;
|
|
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;
|
|
5345
5368
|
}
|
|
5346
|
-
return
|
|
5369
|
+
return g = h[0], y[0] = g.x, y[1] = g.y, y[2] = g.z, y;
|
|
5347
5370
|
}
|
|
5348
|
-
const pt = Math.PI * 2,
|
|
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);
|
|
5349
5372
|
new Array(257), new Array(257), new Array(257);
|
|
5350
|
-
const
|
|
5351
|
-
function
|
|
5352
|
-
const
|
|
5353
|
-
if (!
|
|
5354
|
-
const
|
|
5373
|
+
const Ae = [0, 0, 0];
|
|
5374
|
+
function ns(u) {
|
|
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(_);
|
|
5355
5378
|
return [
|
|
5356
|
-
|
|
5357
|
-
x *
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
x *
|
|
5361
|
-
|
|
5362
|
-
-
|
|
5363
|
-
x *
|
|
5364
|
-
|
|
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
|
+
-m,
|
|
5386
|
+
x * R,
|
|
5387
|
+
B * R
|
|
5365
5388
|
];
|
|
5366
5389
|
}
|
|
5367
|
-
function Ut(u,
|
|
5368
|
-
return
|
|
5369
|
-
}
|
|
5370
|
-
function
|
|
5371
|
-
let
|
|
5372
|
-
|
|
5373
|
-
const
|
|
5374
|
-
return
|
|
5375
|
-
}
|
|
5376
|
-
function
|
|
5377
|
-
let
|
|
5378
|
-
return
|
|
5379
|
-
}
|
|
5380
|
-
function jt(u,
|
|
5381
|
-
const
|
|
5382
|
-
let x = (u % 1 + 1) % 1 *
|
|
5383
|
-
return x <
|
|
5384
|
-
}
|
|
5385
|
-
function
|
|
5386
|
-
const
|
|
5387
|
-
let
|
|
5388
|
-
const
|
|
5389
|
-
if (
|
|
5390
|
-
|
|
5391
|
-
const
|
|
5392
|
-
for (let x = 0; x <
|
|
5393
|
-
const
|
|
5394
|
-
|
|
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
|
+
}
|
|
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
|
+
const m = g._simPosition;
|
|
5397
|
+
return _[0] = B + (m ? m[0] : 0), _[1] = x + (m ? m[1] : 0), _[2] = R + (m ? m[2] : 0), _;
|
|
5398
|
+
}
|
|
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
|
+
}
|
|
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
|
+
}
|
|
5408
|
+
function ls(u) {
|
|
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;
|
|
5395
5418
|
}
|
|
5396
|
-
} else if (
|
|
5397
|
-
|
|
5398
|
-
const
|
|
5399
|
-
for (let x = 0; x <
|
|
5400
|
-
const
|
|
5401
|
-
|
|
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;
|
|
5402
5425
|
}
|
|
5403
|
-
} else if (
|
|
5404
|
-
|
|
5405
|
-
const
|
|
5406
|
-
for (let
|
|
5407
|
-
const w =
|
|
5408
|
-
|
|
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;
|
|
5409
5432
|
}
|
|
5410
|
-
} else if (
|
|
5411
|
-
|
|
5412
|
-
const
|
|
5413
|
-
for (let
|
|
5414
|
-
const
|
|
5415
|
-
|
|
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;
|
|
5416
5439
|
}
|
|
5417
|
-
} else if (
|
|
5418
|
-
|
|
5419
|
-
const
|
|
5420
|
-
for (let x = 0; x <
|
|
5421
|
-
jt(x /
|
|
5422
|
-
} else if (
|
|
5423
|
-
|
|
5424
|
-
const
|
|
5425
|
-
for (let
|
|
5426
|
-
jt(
|
|
5427
|
-
} else if (
|
|
5428
|
-
|
|
5429
|
-
const
|
|
5430
|
-
for (let
|
|
5431
|
-
jt(
|
|
5432
|
-
} else if (
|
|
5433
|
-
|
|
5434
|
-
const
|
|
5435
|
-
for (let x = 0; x <
|
|
5436
|
-
const
|
|
5437
|
-
|
|
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;
|
|
5438
5461
|
}
|
|
5439
|
-
} else if (
|
|
5440
|
-
|
|
5441
|
-
const
|
|
5442
|
-
for (let
|
|
5443
|
-
const
|
|
5444
|
-
|
|
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;
|
|
5445
5468
|
}
|
|
5446
5469
|
} else
|
|
5447
|
-
|
|
5448
|
-
return { count:
|
|
5449
|
-
}
|
|
5450
|
-
function
|
|
5451
|
-
if (!
|
|
5452
|
-
const { count:
|
|
5453
|
-
if (
|
|
5454
|
-
const
|
|
5470
|
+
h = 0;
|
|
5471
|
+
return { count: h, closed: g, planeNormal: P };
|
|
5472
|
+
}
|
|
5473
|
+
function cs(u, p, y) {
|
|
5474
|
+
if (!y.shapeStrokeEnabled || y.hidden) return u;
|
|
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);
|
|
5455
5478
|
if (x <= 0) return u;
|
|
5456
|
-
|
|
5457
|
-
let
|
|
5458
|
-
const
|
|
5459
|
-
for (let
|
|
5460
|
-
|
|
5461
|
-
const
|
|
5462
|
-
if (
|
|
5463
|
-
const
|
|
5464
|
-
for (let
|
|
5465
|
-
const pe =
|
|
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
|
+
const I = y.shapeStrokeAmplitude ?? 0.08, K = y.shapeStrokeFrequency ?? 10, Ie = y.shapeStrokeSpeed ?? 0;
|
|
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;
|
|
5466
5489
|
let he = 0, me = 0;
|
|
5467
|
-
|
|
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;
|
|
5468
5491
|
}
|
|
5469
5492
|
}
|
|
5470
|
-
const
|
|
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;
|
|
5471
5494
|
let it = 0;
|
|
5472
|
-
for (let
|
|
5473
|
-
const
|
|
5474
|
-
it += Math.hypot(
|
|
5495
|
+
for (let I = 0; I < X; I++) {
|
|
5496
|
+
const K = g ? (I + 1) % h : I + 1;
|
|
5497
|
+
it += Math.hypot(ae[K] - ae[I], oe[K] - oe[I], le[K] - le[I]);
|
|
5475
5498
|
}
|
|
5476
|
-
const Qt =
|
|
5499
|
+
const Qt = g ? Math.max(1, Math.round(it / _t)) : Math.max(it / _t, 1e-6), Mt = it > 1e-6 ? Qt / it : 0;
|
|
5477
5500
|
let qe = 0, wt = !1, ut = 0, Ue = 0, dt = 0;
|
|
5478
|
-
for (let
|
|
5479
|
-
const
|
|
5480
|
-
let
|
|
5481
|
-
const
|
|
5482
|
-
|
|
5483
|
-
let
|
|
5484
|
-
if (
|
|
5485
|
-
const
|
|
5486
|
-
|
|
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
|
+
if (te < 1e-5) {
|
|
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);
|
|
5487
5510
|
}
|
|
5488
|
-
if (
|
|
5489
|
-
const
|
|
5490
|
-
|
|
5511
|
+
if (te < 1e-5) {
|
|
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;
|
|
5491
5514
|
}
|
|
5492
|
-
|
|
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;
|
|
5493
5516
|
}
|
|
5494
|
-
for (let
|
|
5495
|
-
const
|
|
5496
|
-
let
|
|
5497
|
-
const
|
|
5498
|
-
|
|
5499
|
-
const
|
|
5500
|
-
let Me,
|
|
5501
|
-
|
|
5502
|
-
const Bt = Xt[
|
|
5503
|
-
Ce[u++] = A, Ce[u++] =
|
|
5517
|
+
for (let I = 0; I < X && !(u + 54 > Ce.length); I++) {
|
|
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
|
+
const ce = Math.hypot(Q, J, te) || 1;
|
|
5521
|
+
Q /= ce, J /= ce, te /= ce;
|
|
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;
|
|
5504
5527
|
};
|
|
5505
|
-
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;
|
|
5506
5529
|
}
|
|
5507
5530
|
return u;
|
|
5508
5531
|
}
|
|
5509
|
-
const
|
|
5510
|
-
function
|
|
5511
|
-
xt.clear(),
|
|
5512
|
-
let u = 0,
|
|
5513
|
-
|
|
5514
|
-
for (const { system:
|
|
5515
|
-
if (
|
|
5516
|
-
if (
|
|
5517
|
-
|
|
5518
|
-
const
|
|
5519
|
-
if (
|
|
5520
|
-
const
|
|
5532
|
+
const us = 0.41421356;
|
|
5533
|
+
function ds() {
|
|
5534
|
+
xt.clear(), at.clear();
|
|
5535
|
+
let u = 0, p = 0, y = 0;
|
|
5536
|
+
V.position[0], V.position[1], V.position[2];
|
|
5537
|
+
for (const { system: h, config: g } of c.particleSystems) {
|
|
5538
|
+
if (g.hidden) continue;
|
|
5539
|
+
if (g.emissionTrailEnabled && !g.glbModelEnabled) {
|
|
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);
|
|
5521
5544
|
for (let ut = 0; ut < x; ut++) {
|
|
5522
|
-
const Ue = ut * 8, dt =
|
|
5523
|
-
let
|
|
5524
|
-
const
|
|
5525
|
-
if (
|
|
5526
|
-
const
|
|
5527
|
-
if (
|
|
5528
|
-
const A =
|
|
5529
|
-
|
|
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
|
+
if (Q >= J || J <= 0) continue;
|
|
5549
|
+
const te = Q / J;
|
|
5550
|
+
if (g.colorTransitionEnabled) {
|
|
5551
|
+
const A = g.startColor ?? [1, 0, 0], k = g.endColor ?? [0, 0, 1];
|
|
5552
|
+
ee = A[0] + (k[0] - A[0]) * te, ge = A[1] + (k[1] - A[1]) * te, $ = A[2] + (k[2] - A[2]) * te;
|
|
5530
5553
|
}
|
|
5531
|
-
|
|
5532
|
-
let
|
|
5533
|
-
if (
|
|
5534
|
-
const A = Math.sin(
|
|
5535
|
-
|
|
5554
|
+
ee = Math.min(1, ee * X), ge = Math.min(1, ge * X), $ = Math.min(1, $ * X);
|
|
5555
|
+
let ce = N;
|
|
5556
|
+
if (g.randomSize) {
|
|
5557
|
+
const A = Math.sin(J * 54321.67) * 43758.5453 % 1, k = A < 0 ? A + 1 : A;
|
|
5558
|
+
ce = (g.minSize ?? 0.1) + ((g.maxSize ?? 0.5) - (g.minSize ?? 0.1)) * k;
|
|
5536
5559
|
}
|
|
5537
|
-
if (
|
|
5538
|
-
const A = Math.max(0.01, Math.min(10,
|
|
5539
|
-
|
|
5560
|
+
if (g.fadeSizeEnabled) {
|
|
5561
|
+
const A = Math.max(0.01, Math.min(10, g.sizeLifetimeSpeed ?? 1));
|
|
5562
|
+
ce *= 1 - Math.pow(te, 1 / A);
|
|
5540
5563
|
}
|
|
5541
|
-
if (
|
|
5542
|
-
const A = Math.max(0.01, Math.min(10,
|
|
5543
|
-
|
|
5564
|
+
if (g.increaseSizeEnabled) {
|
|
5565
|
+
const A = Math.max(0.01, Math.min(10, g.sizeLifetimeSpeed ?? 1));
|
|
5566
|
+
ce *= 1 + Math.pow(te, 1 / A);
|
|
5544
5567
|
}
|
|
5545
|
-
if (
|
|
5546
|
-
const
|
|
5547
|
-
let
|
|
5548
|
-
if (
|
|
5549
|
-
const
|
|
5568
|
+
if (ce <= 0 || te > 0.9) continue;
|
|
5569
|
+
const be = Math.min((0.9 - te) * (1 / 0.2), 1), ve = 0.75 * ce * us * be;
|
|
5570
|
+
let ue = E;
|
|
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);
|
|
5550
5573
|
if (Bt < 1e-3) continue;
|
|
5551
|
-
const gt = 1 / Bt,
|
|
5552
|
-
let Tt = Rt *
|
|
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);
|
|
5553
5576
|
if (st < 0.2) {
|
|
5554
|
-
const A =
|
|
5555
|
-
Re = A - Y *
|
|
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;
|
|
5556
5579
|
}
|
|
5557
|
-
Re /= st, Te /= st,
|
|
5558
|
-
const rt = Math.min(w,
|
|
5580
|
+
Re /= st, Te /= st, Ee /= st;
|
|
5581
|
+
const rt = Math.min(w, Q);
|
|
5559
5582
|
if (rt < 1e-3) continue;
|
|
5560
|
-
const
|
|
5561
|
-
if (
|
|
5562
|
-
const A =
|
|
5563
|
-
for (let
|
|
5564
|
-
const j = li(qe, Ve -
|
|
5565
|
-
|
|
5583
|
+
const Et = g.gravityEnabled && g.gravityStrength || 0, Ze = _s, We = Ms, $e = ws;
|
|
5584
|
+
if (g.orientToDirection && g.burstMode && wt) {
|
|
5585
|
+
const A = h._emitSimRotY || 0, k = Bs, de = Rs, Y = Ts;
|
|
5586
|
+
for (let L = 0; L <= O; L++) {
|
|
5587
|
+
const j = li(qe, Ve - L / O * rt, Pi);
|
|
5588
|
+
k[L] = j[0], de[L] = j[1], Y[L] = j[2];
|
|
5566
5589
|
}
|
|
5567
|
-
for (let
|
|
5568
|
-
const j =
|
|
5569
|
-
let Je =
|
|
5570
|
-
const nt = (Math.hypot(Je, Ke) > 1e-5 ? Math.atan2(Je, Ke) : Math.atan2(it, Mt)) - A,
|
|
5571
|
-
|
|
5590
|
+
for (let L = 0; L <= O; L++) {
|
|
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];
|
|
5572
5595
|
}
|
|
5573
|
-
} else for (let A = 0; A <=
|
|
5574
|
-
const
|
|
5596
|
+
} else for (let A = 0; A <= O; A++) {
|
|
5597
|
+
const k = A / O * rt, de = -0.5 * Et * k * k;
|
|
5575
5598
|
if (wt) {
|
|
5576
|
-
const Y = li(qe, Ve -
|
|
5577
|
-
|
|
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];
|
|
5578
5601
|
} else
|
|
5579
|
-
|
|
5602
|
+
Ze[A] = Ie - me * k, We[A] = W - we * k + de, $e[A] = pe - Be * k;
|
|
5580
5603
|
}
|
|
5581
|
-
if (
|
|
5582
|
-
const A =
|
|
5583
|
-
let Y = -ze,
|
|
5584
|
-
|
|
5585
|
-
const Je =
|
|
5586
|
-
for (let Pe = 1; Pe <=
|
|
5587
|
-
const nt = Pe /
|
|
5604
|
+
if (U !== "straight") {
|
|
5605
|
+
const A = g.emissionTrailShapeAmplitude ?? 0.1, k = g.emissionTrailShapeFrequency ?? 4, de = g.emissionTrailShapeSpeed ?? 0;
|
|
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
|
+
for (let Pe = 1; Pe <= O; Pe++) {
|
|
5610
|
+
const nt = Pe / O * rt, De = 2 * Math.PI * k * (Ve - nt) + de * Ve;
|
|
5588
5611
|
let Ge = 0, et = 0;
|
|
5589
|
-
|
|
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;
|
|
5590
5613
|
}
|
|
5591
5614
|
}
|
|
5592
|
-
if (
|
|
5593
|
-
for (let A = 1; A <=
|
|
5594
|
-
const
|
|
5595
|
-
H[j] =
|
|
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++;
|
|
5596
5619
|
}
|
|
5597
5620
|
else
|
|
5598
|
-
for (let A = 0; A <
|
|
5599
|
-
const
|
|
5600
|
-
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;
|
|
5601
5624
|
};
|
|
5602
|
-
bt(Ge, et, ei, nt), 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);
|
|
5603
5626
|
}
|
|
5604
5627
|
}
|
|
5605
|
-
|
|
5628
|
+
R && u > m && xt.set(g.id, { first: m, count: u - m });
|
|
5606
5629
|
}
|
|
5607
5630
|
}
|
|
5608
|
-
const
|
|
5609
|
-
|
|
5631
|
+
const P = y;
|
|
5632
|
+
y = cs(y, h, g), y > P && at.set(g.id, { first: P / 9, count: (y - P) / 9 });
|
|
5610
5633
|
}
|
|
5611
|
-
u > 0 && (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);
|
|
5612
5635
|
}
|
|
5613
5636
|
const ci = () => {
|
|
5614
|
-
|
|
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]));
|
|
5615
5639
|
};
|
|
5616
5640
|
ci();
|
|
5617
5641
|
const ui = new Float32Array(16).fill(0);
|
|
5618
|
-
ui[0] = 1, r.queue.writeBuffer(
|
|
5619
|
-
const
|
|
5620
|
-
particlePipeline:
|
|
5621
|
-
particleAdditivePipeline:
|
|
5622
|
-
particleDepthWritePipeline:
|
|
5642
|
+
ui[0] = 1, r.queue.writeBuffer(M, 0, ui);
|
|
5643
|
+
const Fe = Ir(r), Ne = Cr(r), {
|
|
5644
|
+
particlePipeline: fs,
|
|
5645
|
+
particleAdditivePipeline: ps,
|
|
5646
|
+
particleDepthWritePipeline: hs,
|
|
5623
5647
|
blurPipeline: It,
|
|
5624
|
-
compositePipeline:
|
|
5648
|
+
compositePipeline: ms,
|
|
5625
5649
|
directRenderPipeline: di,
|
|
5626
|
-
finalCompositePipeline:
|
|
5627
|
-
glbMeshPipeline:
|
|
5628
|
-
} =
|
|
5650
|
+
finalCompositePipeline: ys,
|
|
5651
|
+
glbMeshPipeline: gs
|
|
5652
|
+
} = Ur(r, l, Ne), fi = r.createShaderModule({ code: `
|
|
5629
5653
|
struct U { mvp: mat4x4<f32> };
|
|
5630
5654
|
@group(0) @binding(0) var<uniform> u: U;
|
|
5631
5655
|
struct VIn { @location(0) pos: vec3<f32>, @location(1) col: vec4<f32> };
|
|
@@ -5634,7 +5658,7 @@ async function Wr(s, t = {}) {
|
|
|
5634
5658
|
@fragment fn fs(i: VOut) -> @location(0) vec4<f32> { return i.col; }
|
|
5635
5659
|
` }), pi = r.createBindGroupLayout({
|
|
5636
5660
|
entries: [{ binding: 0, visibility: GPUShaderStage.VERTEX, buffer: { type: "uniform" } }]
|
|
5637
|
-
}),
|
|
5661
|
+
}), bs = r.createRenderPipeline({
|
|
5638
5662
|
layout: r.createPipelineLayout({ bindGroupLayouts: [pi] }),
|
|
5639
5663
|
vertex: {
|
|
5640
5664
|
module: fi,
|
|
@@ -5661,7 +5685,7 @@ async function Wr(s, t = {}) {
|
|
|
5661
5685
|
size: hi * 7 * 4,
|
|
5662
5686
|
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
5663
5687
|
label: "ribbonBuffer"
|
|
5664
|
-
}),
|
|
5688
|
+
}), Ss = r.createBindGroup({
|
|
5665
5689
|
layout: pi,
|
|
5666
5690
|
entries: [{ binding: 0, resource: { buffer: v } }]
|
|
5667
5691
|
});
|
|
@@ -5744,8 +5768,20 @@ async function Wr(s, t = {}) {
|
|
|
5744
5768
|
@location(3) noiseOffset: vec2<f32>,
|
|
5745
5769
|
};
|
|
5746
5770
|
|
|
5771
|
+
// Hachage SANS TRANSCENDANTAL (Dave Hoskins) — jumeau de celui de modules/shaders.js.
|
|
5772
|
+
//
|
|
5773
|
+
// ⚠️ IL Y EN A DEUX EXEMPLAIRES DANS CETTE BIBLIOTHÈQUE, et je ne m'en suis aperçu qu'en cherchant
|
|
5774
|
+
// pourquoi le premier correctif ne changeait rien au bundle : ce shader-ci est INLINE dans
|
|
5775
|
+
// l'overlay, l'autre vit dans modules/shaders.js. Corriger un seul laisse le defaut entier sur le
|
|
5776
|
+
// chemin qui sert reellement au jeu. Toute modification de l'un doit etre portee a l'autre.
|
|
5777
|
+
//
|
|
5778
|
+
// Le fract(sin(dot(...))) remplace coutait HUIT sin par pixel couvert (2 valueNoise x 4 hash21).
|
|
5779
|
+
// Mesure sur la map du proprietaire : ~19 ecrans pleins de recouvrement, soit ~150 sin par pixel
|
|
5780
|
+
// d'ecran et par image. Il rapportait que ca ramait, et eteindre le bruit supprimait le probleme.
|
|
5747
5781
|
fn hash21(p: vec2<f32>) -> f32 {
|
|
5748
|
-
|
|
5782
|
+
var p3 = fract(vec3<f32>(p.x, p.y, p.x) * 0.1031);
|
|
5783
|
+
p3 = p3 + dot(p3, vec3<f32>(p3.y, p3.z, p3.x) + 33.33);
|
|
5784
|
+
return fract((p3.x + p3.y) * p3.z);
|
|
5749
5785
|
}
|
|
5750
5786
|
|
|
5751
5787
|
fn valueNoise(p: vec2<f32>) -> f32 {
|
|
@@ -5813,26 +5849,26 @@ async function Wr(s, t = {}) {
|
|
|
5813
5849
|
},
|
|
5814
5850
|
primitive: { topology: "triangle-list" },
|
|
5815
5851
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
|
|
5816
|
-
}),
|
|
5852
|
+
}), xs = yi({
|
|
5817
5853
|
color: { srcFactor: "src-alpha", dstFactor: "one-minus-src-alpha", operation: "add" },
|
|
5818
5854
|
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
5819
|
-
}),
|
|
5855
|
+
}), vs = yi({
|
|
5820
5856
|
color: { srcFactor: "src-alpha", dstFactor: "one", operation: "add" },
|
|
5821
5857
|
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
5822
|
-
}), gi = 256 * 256 * 6, Ce = new Float32Array(gi * 9),
|
|
5858
|
+
}), gi = 256 * 256 * 6, Ce = new Float32Array(gi * 9), Ht = r.createBuffer({
|
|
5823
5859
|
size: gi * 9 * 4,
|
|
5824
5860
|
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
5825
5861
|
label: "shapeStrokeBuffer"
|
|
5826
5862
|
});
|
|
5827
|
-
let bi = 0, { sceneTexture:
|
|
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;
|
|
5828
5864
|
const xi = () => {
|
|
5829
|
-
const u = (
|
|
5830
|
-
ht = u(
|
|
5865
|
+
const u = (p) => p.createView();
|
|
5866
|
+
ht = u(ot), Si = u(lt), Dt = u(ct), Pt = u(zt);
|
|
5831
5867
|
};
|
|
5832
5868
|
xi();
|
|
5833
|
-
const
|
|
5834
|
-
let Gt = si(r,
|
|
5835
|
-
const
|
|
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
|
+
const V = {
|
|
5836
5872
|
mvp: new Float32Array(16),
|
|
5837
5873
|
position: new Float32Array([0, 0, 10]),
|
|
5838
5874
|
right: new Float32Array([1, 0, 0]),
|
|
@@ -5840,189 +5876,195 @@ async function Wr(s, t = {}) {
|
|
|
5840
5876
|
up: new Float32Array([0, 1, 0]),
|
|
5841
5877
|
hasCamera: !1
|
|
5842
5878
|
};
|
|
5843
|
-
let Ve = 0,
|
|
5844
|
-
const mt = new Float32Array(5), vi = new Float32Array(16),
|
|
5845
|
-
let _i = !1, Wt = !0,
|
|
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), 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;
|
|
5846
5882
|
function Mi() {
|
|
5847
|
-
const u = [
|
|
5848
|
-
|
|
5849
|
-
let
|
|
5850
|
-
const
|
|
5851
|
-
if (!
|
|
5852
|
-
|
|
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
|
+
let y = !1;
|
|
5886
|
+
const h = () => {
|
|
5887
|
+
if (!y) {
|
|
5888
|
+
y = !0, requestAnimationFrame(h);
|
|
5853
5889
|
return;
|
|
5854
5890
|
}
|
|
5855
|
-
u.forEach((
|
|
5891
|
+
u.forEach((g) => g.destroy());
|
|
5856
5892
|
};
|
|
5857
|
-
requestAnimationFrame(
|
|
5893
|
+
requestAnimationFrame(h);
|
|
5858
5894
|
}
|
|
5859
|
-
function
|
|
5860
|
-
|
|
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;
|
|
5861
5897
|
}
|
|
5862
|
-
function
|
|
5863
|
-
|
|
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;
|
|
5864
5900
|
}
|
|
5865
5901
|
async function Kt(u) {
|
|
5866
|
-
if (
|
|
5902
|
+
if (Ft) {
|
|
5867
5903
|
Vt = u;
|
|
5868
5904
|
return;
|
|
5869
5905
|
}
|
|
5870
|
-
|
|
5906
|
+
Ft = !0;
|
|
5871
5907
|
try {
|
|
5872
|
-
for (const
|
|
5873
|
-
|
|
5874
|
-
for (const
|
|
5875
|
-
await
|
|
5876
|
-
for (const { config:
|
|
5877
|
-
T[
|
|
5878
|
-
Wt = !0,
|
|
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
|
+
Wt = !0, c.respawnAllSystems();
|
|
5879
5915
|
} finally {
|
|
5880
|
-
if (
|
|
5881
|
-
const
|
|
5882
|
-
Vt = null, Kt(
|
|
5916
|
+
if (Ft = !1, Vt) {
|
|
5917
|
+
const p = Vt;
|
|
5918
|
+
Vt = null, Kt(p);
|
|
5883
5919
|
}
|
|
5884
5920
|
}
|
|
5885
5921
|
}
|
|
5886
|
-
async function
|
|
5887
|
-
return Kt([{ preset: u, position:
|
|
5922
|
+
async function Cs(u, p = [0, 0, 0]) {
|
|
5923
|
+
return Kt([{ preset: u, position: p }]);
|
|
5888
5924
|
}
|
|
5889
|
-
function
|
|
5890
|
-
if (_i ||
|
|
5891
|
-
const
|
|
5892
|
-
if (
|
|
5925
|
+
function Us(u) {
|
|
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;
|
|
5893
5929
|
if ((a.width !== $t || a.height !== Jt) && ($t = a.width, Jt = a.height, Mi()), Ve += u, _e.length) {
|
|
5894
|
-
for (const
|
|
5895
|
-
if (
|
|
5896
|
-
const w =
|
|
5897
|
-
w ? (
|
|
5930
|
+
for (const m of _e) {
|
|
5931
|
+
if (m.getPosition) {
|
|
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;
|
|
5898
5934
|
}
|
|
5899
|
-
|
|
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);
|
|
5900
5936
|
}
|
|
5901
|
-
for (const { system:
|
|
5902
|
-
const
|
|
5903
|
-
if (!(!
|
|
5904
|
-
let
|
|
5905
|
-
if (
|
|
5906
|
-
const
|
|
5907
|
-
Math.hypot(
|
|
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
|
+
if (E.orientToDirection && E.vel) {
|
|
5942
|
+
const X = E.vel[0], O = E.vel[2];
|
|
5943
|
+
Math.hypot(X, O) > 1e-4 && (N = [0, 0, Math.atan2(X, O)]);
|
|
5908
5944
|
}
|
|
5909
|
-
|
|
5945
|
+
m.setSimulationTransform({ position: E.pos, velocity: E.vel, rotation: N }), m.updateAppearanceUniform(), (E.justResumed || m.activeParticles === 0) && m.spawnParticles();
|
|
5910
5946
|
}
|
|
5911
5947
|
}
|
|
5912
|
-
for (const
|
|
5913
|
-
|
|
5914
|
-
if (globalThis.__HZFX_DEBUG && (
|
|
5915
|
-
const
|
|
5916
|
-
console.info(`[HZFX] movingGroups(${_e.length})=[${
|
|
5948
|
+
for (const m of _e)
|
|
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
|
+
if (globalThis.__HZFX_DEBUG && (Ps++ & 63) === 0) {
|
|
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)}`);
|
|
5917
5953
|
}
|
|
5918
5954
|
}
|
|
5919
|
-
if (
|
|
5920
|
-
const
|
|
5921
|
-
(
|
|
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;
|
|
5922
5958
|
}
|
|
5923
|
-
for (const { system:
|
|
5924
|
-
w.glbModelEnabled &&
|
|
5925
|
-
r.queue.writeBuffer(v, 0,
|
|
5926
|
-
const
|
|
5927
|
-
|
|
5928
|
-
), y = r.createCommandEncoder();
|
|
5929
|
-
let R = !1;
|
|
5959
|
+
for (const { system: m, config: w } of c.particleSystems)
|
|
5960
|
+
w.glbModelEnabled && m.glbAnimator && (m.glbAnimator.update(u), m.updateAnimatedGLBBuffer());
|
|
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 h = r.createCommandEncoder();
|
|
5963
|
+
let g = !1;
|
|
5930
5964
|
if (e)
|
|
5931
5965
|
try {
|
|
5932
|
-
const
|
|
5933
|
-
if (
|
|
5934
|
-
let w = null,
|
|
5935
|
-
if (
|
|
5936
|
-
const { pipeline:
|
|
5937
|
-
(yt.key !== w || yt.ms !==
|
|
5938
|
-
layout:
|
|
5939
|
-
entries: [{ binding: 0, resource:
|
|
5966
|
+
const m = e();
|
|
5967
|
+
if (m) {
|
|
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
|
+
layout: O,
|
|
5973
|
+
entries: [{ binding: 0, resource: E() }]
|
|
5940
5974
|
}));
|
|
5941
|
-
const
|
|
5975
|
+
const U = h.beginRenderPass({
|
|
5942
5976
|
colorAttachments: [],
|
|
5943
5977
|
depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5944
5978
|
});
|
|
5945
|
-
|
|
5979
|
+
U.setPipeline(X), U.setBindGroup(0, yt.bindGroup), U.draw(3), U.end(), g = !0;
|
|
5946
5980
|
}
|
|
5947
5981
|
}
|
|
5948
5982
|
} catch {
|
|
5949
5983
|
}
|
|
5950
|
-
const P =
|
|
5984
|
+
const P = h.beginRenderPass({
|
|
5951
5985
|
colorAttachments: [{ view: ht, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5952
|
-
depthStencilAttachment:
|
|
5986
|
+
depthStencilAttachment: g ? { view: Pt, depthLoadOp: "load", depthStoreOp: "store" } : { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5953
5987
|
});
|
|
5954
|
-
for (const { system:
|
|
5955
|
-
w.bloomEnabled || w.hidden ||
|
|
5956
|
-
|
|
5957
|
-
|
|
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
|
+
}
|
|
5997
|
+
if (_.size > 0) {
|
|
5998
|
+
const m = {
|
|
5958
5999
|
colorAttachments: [{ view: Si, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5959
6000
|
}, w = {
|
|
5960
|
-
colorAttachments: [{ view:
|
|
6001
|
+
colorAttachments: [{ view: Dt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5961
6002
|
};
|
|
5962
|
-
for (const
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
colorAttachments: [{ view: L.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
6003
|
+
for (const [E, N] of _) {
|
|
6004
|
+
const X = b.getBloomSourceTexture(E, a.width, a.height), O = h.beginRenderPass({
|
|
6005
|
+
colorAttachments: [{ view: X.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5966
6006
|
depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
|
|
5967
6007
|
});
|
|
5968
|
-
|
|
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({
|
|
5969
6011
|
layout: Ne.bloomBindGroupLayout,
|
|
5970
6012
|
entries: [
|
|
5971
|
-
{ binding: 0, resource:
|
|
5972
|
-
{ binding: 1, resource:
|
|
5973
|
-
{ binding: 2, resource: { buffer:
|
|
6013
|
+
{ binding: 0, resource: Fe },
|
|
6014
|
+
{ binding: 1, resource: X.createView() },
|
|
6015
|
+
{ binding: 2, resource: { buffer: z } }
|
|
5974
6016
|
]
|
|
5975
6017
|
}));
|
|
5976
|
-
let
|
|
5977
|
-
|
|
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({
|
|
5978
6020
|
layout: Ne.bloomBindGroupLayout,
|
|
5979
6021
|
entries: [
|
|
5980
|
-
{ binding: 0, resource:
|
|
5981
|
-
{ binding: 1, resource:
|
|
5982
|
-
{ binding: 2, resource: { buffer:
|
|
6022
|
+
{ binding: 0, resource: Fe },
|
|
6023
|
+
{ binding: 1, resource: Dt },
|
|
6024
|
+
{ binding: 2, resource: { buffer: z } }
|
|
5983
6025
|
]
|
|
5984
|
-
})),
|
|
5985
|
-
const xe = b.getBloomCompositeTexture(
|
|
5986
|
-
|
|
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({
|
|
5987
6029
|
colorAttachments: [{ view: xe.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5988
|
-
}),
|
|
6030
|
+
}), U.setPipeline(ms), f.systemBloomCompositeBindGroups[ye] || (f.systemBloomCompositeBindGroups[ye] = r.createBindGroup({
|
|
5989
6031
|
layout: Ne.compositeBindGroupLayout,
|
|
5990
6032
|
entries: [
|
|
5991
|
-
{ binding: 0, resource:
|
|
5992
|
-
{ binding: 1, resource:
|
|
5993
|
-
{ binding: 2, resource:
|
|
5994
|
-
|
|
6033
|
+
{ binding: 0, resource: Fe },
|
|
6034
|
+
{ binding: 1, resource: X.createView() },
|
|
6035
|
+
{ binding: 2, resource: Dt },
|
|
6036
|
+
// ⚠️ L'uniforme du PREMIER membre : la clé de groupe garantit que tous portent la même
|
|
6037
|
+
// intensité et la même couleur, donc n'importe lequel convient — mais il en faut un VRAI,
|
|
6038
|
+
// écrit par `particleSystem`, pas le tampon partagé qui ne porte que l'intensité.
|
|
6039
|
+
{ binding: 3, resource: { buffer: N.premier.bloomIntensityBuffer } }
|
|
5995
6040
|
]
|
|
5996
|
-
})),
|
|
6041
|
+
})), U.setBindGroup(0, f.systemBloomCompositeBindGroups[ye]), U.draw(3), U.end();
|
|
5997
6042
|
}
|
|
5998
6043
|
}
|
|
5999
|
-
const
|
|
6000
|
-
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 } }]
|
|
6001
6046
|
});
|
|
6002
|
-
x.setPipeline(di),
|
|
6047
|
+
x.setPipeline(di), f.combinedInitialBindGroup || (f.combinedInitialBindGroup = r.createBindGroup({
|
|
6003
6048
|
layout: Ne.compositeBindGroupLayout,
|
|
6004
6049
|
entries: [
|
|
6005
|
-
{ binding: 0, resource:
|
|
6050
|
+
{ binding: 0, resource: Fe },
|
|
6006
6051
|
{ binding: 1, resource: ht },
|
|
6007
6052
|
{ binding: 2, resource: ht },
|
|
6008
|
-
{ binding: 3, resource: { buffer:
|
|
6053
|
+
{ binding: 3, resource: { buffer: M } }
|
|
6009
6054
|
]
|
|
6010
|
-
})), x.setBindGroup(0,
|
|
6011
|
-
for (const
|
|
6012
|
-
|
|
6013
|
-
const C = w.config.id;
|
|
6014
|
-
x.setPipeline(di), p.combinedBloomCompositeBindGroups[C] || (p.combinedBloomCompositeBindGroups[C] = r.createBindGroup({
|
|
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({
|
|
6015
6058
|
layout: Ne.compositeBindGroupLayout,
|
|
6016
6059
|
entries: [
|
|
6017
|
-
{ binding: 0, resource:
|
|
6018
|
-
{ binding: 1, resource: b.getBloomCompositeTexture(
|
|
6060
|
+
{ binding: 0, resource: Fe },
|
|
6061
|
+
{ binding: 1, resource: b.getBloomCompositeTexture(m, a.width, a.height).createView() },
|
|
6019
6062
|
{ binding: 2, resource: ht },
|
|
6020
|
-
{ binding: 3, resource: { buffer:
|
|
6063
|
+
{ binding: 3, resource: { buffer: M } }
|
|
6021
6064
|
]
|
|
6022
|
-
})), x.setBindGroup(0,
|
|
6023
|
-
}
|
|
6065
|
+
})), x.setBindGroup(0, f.combinedBloomCompositeBindGroups[m]), x.draw(3);
|
|
6024
6066
|
x.end();
|
|
6025
|
-
const
|
|
6067
|
+
const R = h.beginRenderPass({
|
|
6026
6068
|
colorAttachments: [{
|
|
6027
6069
|
view: n.getCurrentTexture().createView(),
|
|
6028
6070
|
loadOp: o ? "load" : "clear",
|
|
@@ -6030,151 +6072,156 @@ async function Wr(s, t = {}) {
|
|
|
6030
6072
|
clearValue: { r: 0, g: 0, b: 0, a: 0 }
|
|
6031
6073
|
}]
|
|
6032
6074
|
});
|
|
6033
|
-
|
|
6075
|
+
R.setPipeline(ys), f.finalBindGroup || (f.finalBindGroup = r.createBindGroup({
|
|
6034
6076
|
layout: Ne.compositeBindGroupLayout,
|
|
6035
6077
|
entries: [
|
|
6036
|
-
{ binding: 0, resource:
|
|
6037
|
-
{ binding: 1, resource:
|
|
6078
|
+
{ binding: 0, resource: Fe },
|
|
6079
|
+
{ binding: 1, resource: B.createView() },
|
|
6038
6080
|
{ binding: 2, resource: ht },
|
|
6039
|
-
{ binding: 3, resource: { buffer:
|
|
6081
|
+
{ binding: 3, resource: { buffer: M } }
|
|
6040
6082
|
]
|
|
6041
|
-
})),
|
|
6083
|
+
})), R.setBindGroup(0, f.finalBindGroup), R.draw(3), R.end(), r.queue.submit([h.finish()]);
|
|
6042
6084
|
}
|
|
6043
|
-
function wi(u,
|
|
6044
|
-
const
|
|
6045
|
-
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({
|
|
6046
6088
|
layout: Ne.particleBindGroupLayout,
|
|
6047
6089
|
entries: [
|
|
6048
6090
|
{ binding: 0, resource: { buffer: v } },
|
|
6049
6091
|
{ binding: 1, resource: { buffer: u.appearanceUniformBuffer } },
|
|
6050
6092
|
{ binding: 2, resource: u.particleTexture.createView() },
|
|
6051
|
-
{ binding: 3, resource:
|
|
6093
|
+
{ binding: 3, resource: Fe }
|
|
6052
6094
|
]
|
|
6053
|
-
})),
|
|
6095
|
+
})), f.systemBindGroups[y];
|
|
6054
6096
|
}
|
|
6055
|
-
function Bi(u,
|
|
6056
|
-
const
|
|
6057
|
-
if (
|
|
6058
|
-
|
|
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
|
+
if (g)
|
|
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));
|
|
6059
6101
|
else {
|
|
6060
|
-
u.setPipeline(
|
|
6061
|
-
const
|
|
6062
|
-
|
|
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));
|
|
6063
6105
|
}
|
|
6064
6106
|
}
|
|
6065
|
-
function Ri(u,
|
|
6066
|
-
const
|
|
6067
|
-
!
|
|
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));
|
|
6068
6110
|
}
|
|
6069
|
-
function
|
|
6111
|
+
function Is() {
|
|
6070
6112
|
$t = a.width, Jt = a.height, Mi();
|
|
6071
6113
|
}
|
|
6072
|
-
function
|
|
6073
|
-
|
|
6114
|
+
function zs() {
|
|
6115
|
+
f.clear();
|
|
6074
6116
|
}
|
|
6075
|
-
function
|
|
6076
|
-
_i = !0,
|
|
6117
|
+
function Ds() {
|
|
6118
|
+
_i = !0, c.destroy(), [ot, lt, ct, zt].forEach((u) => u == null ? void 0 : u.destroy()), b.resizeTextures(), [
|
|
6077
6119
|
v,
|
|
6078
|
-
|
|
6079
|
-
I,
|
|
6120
|
+
C,
|
|
6080
6121
|
z,
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6122
|
+
D,
|
|
6123
|
+
M,
|
|
6124
|
+
Z,
|
|
6125
|
+
re,
|
|
6084
6126
|
q,
|
|
6085
6127
|
tt,
|
|
6086
6128
|
qt,
|
|
6087
|
-
|
|
6129
|
+
Ht
|
|
6088
6130
|
].forEach((u) => u == null ? void 0 : u.destroy()), Object.values(T).forEach((u) => u == null ? void 0 : u.destroy());
|
|
6089
6131
|
}
|
|
6090
|
-
async function Ti(u,
|
|
6091
|
-
const
|
|
6092
|
-
for (const { config:
|
|
6093
|
-
T[
|
|
6094
|
-
return
|
|
6095
|
-
}
|
|
6096
|
-
function
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
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
|
+
return c.respawnAllSystems(), new Set(Array.isArray(y) ? y : []);
|
|
6137
|
+
}
|
|
6138
|
+
function Ei(u) {
|
|
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];
|
|
6100
6147
|
}
|
|
6101
6148
|
}
|
|
6102
|
-
async function
|
|
6103
|
-
const
|
|
6149
|
+
async function Gs(u, p = [0, 0, 0]) {
|
|
6150
|
+
const y = await Ti(u, p);
|
|
6104
6151
|
return { remove() {
|
|
6105
|
-
|
|
6152
|
+
Ei(y);
|
|
6106
6153
|
} };
|
|
6107
6154
|
}
|
|
6108
|
-
async function Fs(u,
|
|
6109
|
-
const
|
|
6110
|
-
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...
|
|
6111
|
-
const
|
|
6112
|
-
return _e.push(
|
|
6113
|
-
setPosition(
|
|
6114
|
-
|
|
6155
|
+
async function Fs(u, p = {}) {
|
|
6156
|
+
const y = await Ti(u, [0, 0, 0]);
|
|
6157
|
+
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...y]}]`);
|
|
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), {
|
|
6160
|
+
setPosition(g) {
|
|
6161
|
+
g && (h.pos = Array.isArray(g) ? [g[0], g[1], g[2]] : [g.x, g.y, g.z]);
|
|
6115
6162
|
},
|
|
6116
|
-
setOrientToDirection(
|
|
6117
|
-
|
|
6163
|
+
setOrientToDirection(g) {
|
|
6164
|
+
h.orientToDirection = !!g;
|
|
6118
6165
|
},
|
|
6119
6166
|
remove() {
|
|
6120
|
-
|
|
6121
|
-
const
|
|
6122
|
-
|
|
6167
|
+
Ei(y);
|
|
6168
|
+
const g = _e.indexOf(h);
|
|
6169
|
+
g >= 0 && _e.splice(g, 1);
|
|
6123
6170
|
}
|
|
6124
6171
|
};
|
|
6125
6172
|
}
|
|
6126
|
-
function
|
|
6127
|
-
const
|
|
6128
|
-
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), {
|
|
6129
6176
|
remove() {
|
|
6130
|
-
const
|
|
6131
|
-
|
|
6177
|
+
const g = _e.indexOf(h);
|
|
6178
|
+
g >= 0 && _e.splice(g, 1);
|
|
6132
6179
|
},
|
|
6133
6180
|
// Update which systems this history group covers WITHOUT losing the accumulated path
|
|
6134
6181
|
// history. Needed when the scene's systems change (e.g. duplicate/add/remove) while the
|
|
6135
6182
|
// group is active — otherwise a newly-added system's id isn't in the set and its trail
|
|
6136
6183
|
// can't follow the recorded movement path (it falls back to straight extrapolation).
|
|
6137
|
-
setIds(
|
|
6138
|
-
|
|
6184
|
+
setIds(g) {
|
|
6185
|
+
h.ids = g instanceof Set ? g : new Set(g);
|
|
6139
6186
|
}
|
|
6140
6187
|
};
|
|
6141
6188
|
}
|
|
6142
6189
|
return {
|
|
6143
|
-
manager:
|
|
6190
|
+
manager: c,
|
|
6144
6191
|
device: r,
|
|
6145
6192
|
context: n,
|
|
6146
|
-
setCamera:
|
|
6147
|
-
setCameraMVP:
|
|
6193
|
+
setCamera: Es,
|
|
6194
|
+
setCameraMVP: As,
|
|
6148
6195
|
setEmitters: Kt,
|
|
6149
|
-
loadPreset:
|
|
6150
|
-
addEmitter:
|
|
6196
|
+
loadPreset: Cs,
|
|
6197
|
+
addEmitter: Gs,
|
|
6151
6198
|
addMovingEmitter: Fs,
|
|
6152
|
-
render:
|
|
6153
|
-
resize:
|
|
6154
|
-
clearCaches:
|
|
6155
|
-
trackHistoryGroup:
|
|
6156
|
-
destroy:
|
|
6199
|
+
render: Us,
|
|
6200
|
+
resize: Is,
|
|
6201
|
+
clearCaches: zs,
|
|
6202
|
+
trackHistoryGroup: Vs,
|
|
6203
|
+
destroy: Ds
|
|
6157
6204
|
};
|
|
6158
6205
|
}
|
|
6159
|
-
function
|
|
6206
|
+
function Kr(s) {
|
|
6160
6207
|
return () => {
|
|
6161
|
-
var t, e, i, r, n, a, o,
|
|
6208
|
+
var t, e, i, r, n, a, o, l;
|
|
6162
6209
|
try {
|
|
6163
|
-
const
|
|
6164
|
-
if (!
|
|
6210
|
+
const c = s.backend;
|
|
6211
|
+
if (!c) return null;
|
|
6165
6212
|
const d = s.domElement.width, S = s.domElement.height, b = (typeof s._getFrameBufferTarget == "function" ? s._getFrameBufferTarget() : null) || s._frameBufferTarget || null;
|
|
6166
6213
|
if (s.needsFrameBufferTarget && b) {
|
|
6167
|
-
const
|
|
6168
|
-
(r =
|
|
6169
|
-
|
|
6170
|
-
(n =
|
|
6171
|
-
|
|
6214
|
+
const C = c.get(b), z = ((i = (e = (t = s._textures) == null ? void 0 : t.get) == null ? void 0 : e.call(t, b)) == null ? void 0 : i.depthTexture) || b.depthTexture, D = [
|
|
6215
|
+
(r = C == null ? void 0 : C.depthTexture) == null ? void 0 : r.texture,
|
|
6216
|
+
C == null ? void 0 : C.depthTexture,
|
|
6217
|
+
(n = C == null ? void 0 : C.depthBuffer) == null ? void 0 : n.texture,
|
|
6218
|
+
z ? (a = c.get(z)) == null ? void 0 : a.texture : null
|
|
6172
6219
|
];
|
|
6173
|
-
for (const
|
|
6174
|
-
if (
|
|
6220
|
+
for (const M of D)
|
|
6221
|
+
if (M && typeof M.createView == "function" && M.width === d && M.height === S) return M;
|
|
6175
6222
|
return null;
|
|
6176
6223
|
}
|
|
6177
|
-
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;
|
|
6178
6225
|
return v ? { view: v, multisampled: (s.currentSamples ?? 0) > 1 } : null;
|
|
6179
6226
|
} catch {
|
|
6180
6227
|
return null;
|
|
@@ -6182,46 +6229,46 @@ function $r(s) {
|
|
|
6182
6229
|
};
|
|
6183
6230
|
}
|
|
6184
6231
|
export {
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6232
|
+
xr as GLBAnimator,
|
|
6233
|
+
vr as HZClock,
|
|
6234
|
+
Nr as Objects3DManager,
|
|
6235
|
+
qs as ParticleEmitter,
|
|
6236
|
+
er as ParticlePhysics,
|
|
6190
6237
|
Gi as ParticleScript,
|
|
6191
6238
|
ii as ParticleSystem,
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6239
|
+
Rr as ParticleSystemManager,
|
|
6240
|
+
tr as ParticleTextureManager,
|
|
6241
|
+
Zs as blurShader,
|
|
6242
|
+
Ws as compositeShader,
|
|
6243
|
+
Cr as createBindGroupLayouts,
|
|
6197
6244
|
si as createBindGroups,
|
|
6198
6245
|
St as createBuffer,
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6246
|
+
zr as createCubeGeometry,
|
|
6247
|
+
Yi as createDepthTexture,
|
|
6248
|
+
qr as createLookAtMatrix,
|
|
6249
|
+
Hr as createProjectionMatrix,
|
|
6250
|
+
Ur as createRenderPipelines,
|
|
6251
|
+
Ni as createRenderTextures,
|
|
6252
|
+
Ir as createSampler,
|
|
6253
|
+
Dr as createSphereGeometry,
|
|
6254
|
+
$s as directRenderShader,
|
|
6208
6255
|
Vi as extractGLBTexture,
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6256
|
+
$r as fetchPreset,
|
|
6257
|
+
Ar as glbMeshParticleShader,
|
|
6258
|
+
Yr as hexToRgb,
|
|
6259
|
+
Jr as initHzFxOverlay,
|
|
6260
|
+
Tr as initWebGPU,
|
|
6261
|
+
is as isHZFX,
|
|
6262
|
+
Wr as loadScene,
|
|
6263
|
+
Kr as makeThreeSceneDepth,
|
|
6217
6264
|
Fr as multiplyMatrices,
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6265
|
+
Er as object3dShader,
|
|
6266
|
+
Or as packHZFX,
|
|
6267
|
+
or as parseGLB,
|
|
6268
|
+
Ks as particlePhysicsShader,
|
|
6269
|
+
Hs as particleShader,
|
|
6270
|
+
jr as rgbToHex,
|
|
6271
|
+
Zr as saveScene,
|
|
6272
|
+
kr as serializeSystemConfig,
|
|
6273
|
+
ss as unpackHZFX
|
|
6227
6274
|
};
|