hz-particles 1.5.0 → 1.5.2
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 +1298 -1178
- 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 ks {
|
|
|
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 *
|
|
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 ks {
|
|
|
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 ks {
|
|
|
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 ks {
|
|
|
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 ks {
|
|
|
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 ks {
|
|
|
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(),
|
|
197
|
-
|
|
196
|
+
const S = Math.random(), b = 0.5 * a, h = e, v = -S * o, C = Math.max(0, h * h - 4 * b * v);
|
|
197
|
+
l = (-h + 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 ks {
|
|
|
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 ks {
|
|
|
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
|
|
261
|
-
if (
|
|
262
|
-
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 h, v, C;
|
|
261
|
+
if (b > 1e-4) {
|
|
262
|
+
let D = !1;
|
|
263
263
|
if (this.config.emissionShape === "circle" && this.config.circleVelocityDirection === "tangential") {
|
|
264
|
-
const _ = this.inverseRotation(
|
|
265
|
-
if (
|
|
266
|
-
const T = -_[1] /
|
|
267
|
-
|
|
264
|
+
const _ = this.inverseRotation(c, d, S), Z = Math.sqrt(_[0] * _[0] + _[1] * _[1]);
|
|
265
|
+
if (Z > 1e-4) {
|
|
266
|
+
const T = -_[1] / Z, F = _[0] / Z, G = this.applyRotation(T, F, 0);
|
|
267
|
+
h = G[0], v = G[1], C = G[2], D = !0;
|
|
268
268
|
}
|
|
269
269
|
} else if (this.config.emissionShape === "cylinder" && this.config.cylinderVelocityDirection === "tangential") {
|
|
270
|
-
const _ = this.inverseRotation(
|
|
271
|
-
if (
|
|
272
|
-
const T = -_[2] /
|
|
273
|
-
|
|
270
|
+
const _ = this.inverseRotation(c, d, S), Z = Math.sqrt(_[0] * _[0] + _[2] * _[2]);
|
|
271
|
+
if (Z > 1e-4) {
|
|
272
|
+
const T = -_[2] / Z, F = _[0] / Z, G = this.applyRotation(T, 0, F);
|
|
273
|
+
h = G[0], v = G[1], C = G[2], D = !0;
|
|
274
274
|
} else {
|
|
275
|
-
const T = Math.random() * Math.PI * 2,
|
|
276
|
-
|
|
275
|
+
const T = Math.random() * Math.PI * 2, F = this.applyRotation(Math.cos(T), 0, Math.sin(T));
|
|
276
|
+
h = F[0], v = F[1], C = F[2], D = !0;
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
|
|
279
|
+
D || (h = c / b, v = d / b, C = S / b);
|
|
280
280
|
} else {
|
|
281
|
-
const
|
|
282
|
-
|
|
281
|
+
const D = Math.random() * Math.PI * 2, _ = Math.acos(2 * Math.random() - 1);
|
|
282
|
+
h = Math.sin(_) * Math.cos(D), v = Math.sin(_) * Math.sin(D), C = Math.cos(_);
|
|
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 : h * 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 ks {
|
|
|
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 Xs = `
|
|
|
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 Xs = `
|
|
|
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 Xs = `
|
|
|
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 Xs = `
|
|
|
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 Xs = `
|
|
|
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 Xs = `
|
|
|
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 Xs = `
|
|
|
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 Xs = `
|
|
|
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 $s {
|
|
|
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 $s {
|
|
|
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 $s {
|
|
|
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 $s {
|
|
|
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 $s {
|
|
|
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 $s {
|
|
|
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 Ws {
|
|
|
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,10 +1539,10 @@ const ji = 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([
|
|
1528
1546
|
"particleSize",
|
|
1529
1547
|
"particleSpeed",
|
|
1530
1548
|
"particleColor",
|
|
@@ -1539,9 +1557,35 @@ const ji = Object.freeze({
|
|
|
1539
1557
|
"attractorPosition",
|
|
1540
1558
|
"pulseAmplitude",
|
|
1541
1559
|
"pulseFrequency",
|
|
1542
|
-
"bloomIntensity"
|
|
1560
|
+
"bloomIntensity",
|
|
1561
|
+
"emissionPositionX",
|
|
1562
|
+
"emissionPositionY",
|
|
1563
|
+
"emissionPositionZ",
|
|
1564
|
+
"emissionRotationX",
|
|
1565
|
+
"emissionRotationY",
|
|
1566
|
+
"emissionRotationZ",
|
|
1567
|
+
"circleInnerRadius",
|
|
1568
|
+
"circleOuterRadius",
|
|
1569
|
+
"discRadius",
|
|
1570
|
+
"annulusInnerRadius",
|
|
1571
|
+
"annulusOuterRadius",
|
|
1572
|
+
"arcStartAngle",
|
|
1573
|
+
"arcEndAngle",
|
|
1574
|
+
"arcInnerRadius",
|
|
1575
|
+
"arcOuterRadius",
|
|
1576
|
+
"squareSize",
|
|
1577
|
+
"rectangleWidth",
|
|
1578
|
+
"rectangleHeight",
|
|
1579
|
+
"planeWidth",
|
|
1580
|
+
"planeDepth",
|
|
1581
|
+
"lineLength",
|
|
1582
|
+
"polygonRadius",
|
|
1583
|
+
"shapeStrokeWidth",
|
|
1584
|
+
"shapeStrokeAmplitude",
|
|
1585
|
+
"shapeStrokeFrequency",
|
|
1586
|
+
"shapeStrokeSpeed"
|
|
1543
1587
|
]);
|
|
1544
|
-
class
|
|
1588
|
+
class ir {
|
|
1545
1589
|
constructor(t) {
|
|
1546
1590
|
this._collection = t, this._pd = null, this._vd = null, this._pi = 0, this._vi = 0;
|
|
1547
1591
|
}
|
|
@@ -1619,9 +1663,9 @@ class Js {
|
|
|
1619
1663
|
this._vd[this._vi + 2] = t, this._collection._dirty = !0;
|
|
1620
1664
|
}
|
|
1621
1665
|
}
|
|
1622
|
-
class
|
|
1666
|
+
class sr {
|
|
1623
1667
|
constructor() {
|
|
1624
|
-
this._proxy = new
|
|
1668
|
+
this._proxy = new ir(this), this._pd = null, this._vd = null, this.count = 0, this._dirty = !1;
|
|
1625
1669
|
}
|
|
1626
1670
|
_bind(t, e, i) {
|
|
1627
1671
|
this._pd = t, this._vd = e, this.count = i, this._dirty = !1;
|
|
@@ -1630,14 +1674,14 @@ class Ks {
|
|
|
1630
1674
|
return t < 0 || t >= this.count ? null : this._proxy._bind(this._pd, this._vd, t);
|
|
1631
1675
|
}
|
|
1632
1676
|
}
|
|
1633
|
-
const
|
|
1634
|
-
function
|
|
1677
|
+
const rr = 1e6;
|
|
1678
|
+
function nr(s) {
|
|
1635
1679
|
let t = 0;
|
|
1636
1680
|
return s.replace(
|
|
1637
1681
|
/\b(for|while)\s*\([^)]*\)\s*\{/g,
|
|
1638
1682
|
(e) => {
|
|
1639
1683
|
const i = `__lc${t++}`;
|
|
1640
|
-
return `${e} if(++${i}>${
|
|
1684
|
+
return `${e} if(++${i}>${rr})throw new Error("Loop limit exceeded");`;
|
|
1641
1685
|
}
|
|
1642
1686
|
).replace(
|
|
1643
1687
|
/\b(for|while)\s*\([^)]*\)\s*\{/g,
|
|
@@ -1654,10 +1698,10 @@ function er(s) {
|
|
|
1654
1698
|
}
|
|
1655
1699
|
);
|
|
1656
1700
|
}
|
|
1657
|
-
const
|
|
1658
|
-
for (const s of
|
|
1659
|
-
|
|
1660
|
-
function
|
|
1701
|
+
const ni = /* @__PURE__ */ new Map();
|
|
1702
|
+
for (const s of Ct)
|
|
1703
|
+
ni.set(s.toLowerCase(), s);
|
|
1704
|
+
function ar(s) {
|
|
1661
1705
|
const t = { value: !1 }, e = /* @__PURE__ */ new Set();
|
|
1662
1706
|
return new Proxy(s, {
|
|
1663
1707
|
get(r, n) {
|
|
@@ -1666,18 +1710,18 @@ function tr(s) {
|
|
|
1666
1710
|
t.value = !1;
|
|
1667
1711
|
};
|
|
1668
1712
|
if (typeof n != "string") return;
|
|
1669
|
-
if (
|
|
1670
|
-
const a =
|
|
1713
|
+
if (Ct.has(n)) return r[n];
|
|
1714
|
+
const a = ni.get(n.toLowerCase());
|
|
1671
1715
|
if (a)
|
|
1672
1716
|
return e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${a}?`)), r[a];
|
|
1673
1717
|
},
|
|
1674
1718
|
set(r, n, a) {
|
|
1675
1719
|
if (typeof n != "string") return !0;
|
|
1676
1720
|
let o = n;
|
|
1677
|
-
if (!
|
|
1678
|
-
const
|
|
1679
|
-
if (
|
|
1680
|
-
e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${
|
|
1721
|
+
if (!Ct.has(o)) {
|
|
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;
|
|
1681
1725
|
else
|
|
1682
1726
|
return !0;
|
|
1683
1727
|
}
|
|
@@ -1685,14 +1729,14 @@ function tr(s) {
|
|
|
1685
1729
|
}
|
|
1686
1730
|
});
|
|
1687
1731
|
}
|
|
1688
|
-
class
|
|
1732
|
+
class Fi {
|
|
1689
1733
|
/**
|
|
1690
1734
|
* @param {string} source - User script source code
|
|
1691
1735
|
* @param {object} config - ParticleSystem config (will be proxied)
|
|
1692
1736
|
* @param {number} maxParticles - Max particle count for pre-allocation
|
|
1693
1737
|
*/
|
|
1694
1738
|
constructor(t, e, i) {
|
|
1695
|
-
this._particles = new
|
|
1739
|
+
this._particles = new sr(), this._configProxy = ar(e), this._configSnapshot = null, this._fn = null, this._error = !1, this.compile(t);
|
|
1696
1740
|
}
|
|
1697
1741
|
/**
|
|
1698
1742
|
* Compile script source into a sandboxed function.
|
|
@@ -1708,7 +1752,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1708
1752
|
var deltaTime = __deltaTime, time = __time;
|
|
1709
1753
|
var currentFrame = __currentFrame, totalFrames = __totalFrames;
|
|
1710
1754
|
var particles = __particles, config = __config, math = __math;
|
|
1711
|
-
${
|
|
1755
|
+
${nr(t)}
|
|
1712
1756
|
};`, r = new Function(i);
|
|
1713
1757
|
this._fn = r();
|
|
1714
1758
|
} catch (e) {
|
|
@@ -1730,9 +1774,9 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1730
1774
|
if (!this._fn || this._error) return { configDirty: !1, particlesDirty: !1 };
|
|
1731
1775
|
this._particles._bind(n, a, o), this._configProxy.__resetDirty();
|
|
1732
1776
|
try {
|
|
1733
|
-
this._fn(t, e, i, r, this._particles, this._configProxy,
|
|
1734
|
-
} catch (
|
|
1735
|
-
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);
|
|
1736
1780
|
}
|
|
1737
1781
|
return {
|
|
1738
1782
|
configDirty: this._configProxy.__dirty,
|
|
@@ -1744,7 +1788,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1744
1788
|
*/
|
|
1745
1789
|
snapshotConfig(t) {
|
|
1746
1790
|
const e = {};
|
|
1747
|
-
for (const i of
|
|
1791
|
+
for (const i of Ct) {
|
|
1748
1792
|
const r = t[i];
|
|
1749
1793
|
r !== void 0 && (e[i] = Array.isArray(r) ? [...r] : r);
|
|
1750
1794
|
}
|
|
@@ -1755,7 +1799,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1755
1799
|
*/
|
|
1756
1800
|
restoreConfig(t) {
|
|
1757
1801
|
if (this._configSnapshot) {
|
|
1758
|
-
for (const e of
|
|
1802
|
+
for (const e of Ct)
|
|
1759
1803
|
if (e in this._configSnapshot) {
|
|
1760
1804
|
const i = this._configSnapshot[e];
|
|
1761
1805
|
t[e] = Array.isArray(i) ? [...i] : i;
|
|
@@ -1769,7 +1813,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1769
1813
|
this._fn = null, this._particles = null, this._configProxy = null, this._configSnapshot = null;
|
|
1770
1814
|
}
|
|
1771
1815
|
}
|
|
1772
|
-
async function
|
|
1816
|
+
async function or(s) {
|
|
1773
1817
|
const t = new DataView(s);
|
|
1774
1818
|
if (t.getUint32(0, !0) !== 1179937895)
|
|
1775
1819
|
throw new Error("Invalid GLB file: incorrect magic number");
|
|
@@ -1779,64 +1823,64 @@ async function ir(s) {
|
|
|
1779
1823
|
const r = t.getUint32(8, !0);
|
|
1780
1824
|
let n = 12, a = null, o = null;
|
|
1781
1825
|
for (; n < r; ) {
|
|
1782
|
-
const T = t.getUint32(n, !0),
|
|
1783
|
-
if (
|
|
1784
|
-
const
|
|
1785
|
-
a = JSON.parse(
|
|
1786
|
-
} else
|
|
1826
|
+
const T = t.getUint32(n, !0), F = t.getUint32(n + 4, !0), G = s.slice(n + 8, n + 8 + T);
|
|
1827
|
+
if (F === 1313821514) {
|
|
1828
|
+
const se = new TextDecoder("utf-8").decode(G);
|
|
1829
|
+
a = JSON.parse(se);
|
|
1830
|
+
} else F === 5130562 && (o = G);
|
|
1787
1831
|
n += 8 + T;
|
|
1788
1832
|
}
|
|
1789
1833
|
if (!a)
|
|
1790
1834
|
throw new Error("GLB file missing JSON chunk");
|
|
1791
1835
|
if (!a.meshes || a.meshes.length === 0)
|
|
1792
1836
|
throw new Error("GLB file contains no meshes");
|
|
1793
|
-
const
|
|
1794
|
-
if (!
|
|
1837
|
+
const c = a.meshes[0].primitives[0];
|
|
1838
|
+
if (!c)
|
|
1795
1839
|
throw new Error("First mesh has no primitives");
|
|
1796
|
-
const d =
|
|
1840
|
+
const d = c.attributes.POSITION;
|
|
1797
1841
|
if (d === void 0)
|
|
1798
1842
|
throw new Error("Mesh primitive missing POSITION attribute");
|
|
1799
|
-
const S =
|
|
1800
|
-
let
|
|
1801
|
-
if (
|
|
1802
|
-
|
|
1843
|
+
const S = ti(a, o, d, 3, 5126);
|
|
1844
|
+
let b;
|
|
1845
|
+
if (c.attributes.NORMAL !== void 0)
|
|
1846
|
+
b = ti(a, o, c.attributes.NORMAL, 3, 5126);
|
|
1803
1847
|
else {
|
|
1804
|
-
const T =
|
|
1848
|
+
const T = c.indices;
|
|
1805
1849
|
if (T === void 0)
|
|
1806
1850
|
throw new Error("Cannot generate normals without indices");
|
|
1807
|
-
const
|
|
1808
|
-
|
|
1851
|
+
const F = Gi(a, o, T);
|
|
1852
|
+
b = lr(S, F);
|
|
1809
1853
|
}
|
|
1810
|
-
const
|
|
1811
|
-
if (
|
|
1854
|
+
const h = c.indices;
|
|
1855
|
+
if (h === void 0)
|
|
1812
1856
|
throw new Error("Mesh primitive missing indices");
|
|
1813
|
-
const v =
|
|
1814
|
-
let
|
|
1815
|
-
|
|
1857
|
+
const v = Gi(a, o, h), 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));
|
|
1816
1860
|
let _ = !1;
|
|
1817
1861
|
if (a.materials && a.materials.length > 0) {
|
|
1818
1862
|
const T = a.materials[0];
|
|
1819
1863
|
T.pbrMetallicRoughness && T.pbrMetallicRoughness.baseColorTexture !== void 0 && (_ = !0);
|
|
1820
1864
|
}
|
|
1821
|
-
let
|
|
1865
|
+
let Z = null;
|
|
1822
1866
|
if (a.skins && a.skins.length > 0)
|
|
1823
1867
|
try {
|
|
1824
|
-
|
|
1868
|
+
Z = hr(a, o, c), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", Z);
|
|
1825
1869
|
} catch (T) {
|
|
1826
1870
|
console.warn("Failed to extract animation data:", T);
|
|
1827
1871
|
}
|
|
1828
1872
|
return {
|
|
1829
1873
|
positions: S,
|
|
1830
|
-
normals:
|
|
1874
|
+
normals: b,
|
|
1831
1875
|
indices: v,
|
|
1832
|
-
texCoords:
|
|
1833
|
-
vertexCount:
|
|
1834
|
-
indexCount:
|
|
1835
|
-
animationData:
|
|
1876
|
+
texCoords: D,
|
|
1877
|
+
vertexCount: C,
|
|
1878
|
+
indexCount: z,
|
|
1879
|
+
animationData: Z,
|
|
1836
1880
|
hasBaseColorTexture: _
|
|
1837
1881
|
};
|
|
1838
1882
|
}
|
|
1839
|
-
function
|
|
1883
|
+
function ti(s, t, e, i, r) {
|
|
1840
1884
|
const n = s.accessors[e], o = {
|
|
1841
1885
|
SCALAR: 1,
|
|
1842
1886
|
VEC2: 2,
|
|
@@ -1847,138 +1891,138 @@ function Kt(s, t, e, i, r) {
|
|
|
1847
1891
|
throw new Error(`Attribute accessor type mismatch: expected ${i} components, got ${o}`);
|
|
1848
1892
|
if (n.componentType !== r)
|
|
1849
1893
|
throw new Error(`Attribute component type mismatch: expected ${r}, got ${n.componentType}`);
|
|
1850
|
-
const
|
|
1851
|
-
for (let
|
|
1852
|
-
|
|
1853
|
-
return
|
|
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 h = 0; h < d * i; h++)
|
|
1896
|
+
b[h] = S.getFloat32(h * 4, !0);
|
|
1897
|
+
return b;
|
|
1854
1898
|
}
|
|
1855
|
-
function
|
|
1899
|
+
function Gi(s, t, e) {
|
|
1856
1900
|
const i = s.accessors[e];
|
|
1857
1901
|
if (i.type !== "SCALAR")
|
|
1858
1902
|
throw new Error(`Indices accessor must be SCALAR, got ${i.type}`);
|
|
1859
1903
|
const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count;
|
|
1860
1904
|
if (i.componentType === 5123) {
|
|
1861
|
-
const o = new DataView(t, n, a * 2),
|
|
1862
|
-
for (let
|
|
1863
|
-
c
|
|
1864
|
-
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;
|
|
1865
1909
|
} else if (i.componentType === 5125) {
|
|
1866
|
-
const o = new DataView(t, n, a * 4),
|
|
1867
|
-
for (let
|
|
1868
|
-
c
|
|
1869
|
-
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;
|
|
1870
1914
|
} else
|
|
1871
1915
|
throw new Error(`Unsupported index component type: ${i.componentType}`);
|
|
1872
1916
|
}
|
|
1873
|
-
function
|
|
1917
|
+
function lr(s, t) {
|
|
1874
1918
|
const e = new Float32Array(s.length);
|
|
1875
1919
|
for (let i = 0; i < t.length; i += 3) {
|
|
1876
|
-
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 = [
|
|
1877
1921
|
d[1] * S[2] - d[2] * S[1],
|
|
1878
1922
|
d[2] * S[0] - d[0] * S[2],
|
|
1879
1923
|
d[0] * S[1] - d[1] * S[0]
|
|
1880
|
-
],
|
|
1881
|
-
|
|
1924
|
+
], h = Math.sqrt(b[0] * b[0] + b[1] * b[1] + b[2] * b[2]);
|
|
1925
|
+
h > 0 && (b[0] /= h, b[1] /= h, b[2] /= h), 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];
|
|
1882
1926
|
}
|
|
1883
1927
|
return e;
|
|
1884
1928
|
}
|
|
1885
|
-
function
|
|
1929
|
+
function cr(s, t, e) {
|
|
1886
1930
|
const i = s.accessors[e];
|
|
1887
1931
|
if (i.type !== "VEC4")
|
|
1888
1932
|
throw new Error(`JOINTS_0 must be VEC4, got ${i.type}`);
|
|
1889
1933
|
const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count;
|
|
1890
1934
|
if (i.componentType === 5121) {
|
|
1891
|
-
const o = new DataView(t, n, a * 4),
|
|
1892
|
-
for (let
|
|
1893
|
-
c
|
|
1894
|
-
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;
|
|
1895
1939
|
} else if (i.componentType === 5123) {
|
|
1896
|
-
const o = new DataView(t, n, a * 8),
|
|
1897
|
-
for (let
|
|
1898
|
-
c
|
|
1899
|
-
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;
|
|
1900
1944
|
} else
|
|
1901
1945
|
throw new Error(`Unsupported JOINTS_0 component type: ${i.componentType}`);
|
|
1902
1946
|
}
|
|
1903
|
-
function
|
|
1947
|
+
function ur(s, t, e) {
|
|
1904
1948
|
const i = s.accessors[e];
|
|
1905
1949
|
if (i.type !== "VEC4")
|
|
1906
1950
|
throw new Error(`WEIGHTS_0 must be VEC4, got ${i.type}`);
|
|
1907
1951
|
const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count;
|
|
1908
1952
|
if (i.componentType === 5126) {
|
|
1909
|
-
const o = new DataView(t, n, a * 16),
|
|
1910
|
-
for (let
|
|
1911
|
-
c
|
|
1912
|
-
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;
|
|
1913
1957
|
} else if (i.componentType === 5121) {
|
|
1914
|
-
const o = new DataView(t, n, a * 4),
|
|
1915
|
-
for (let
|
|
1916
|
-
c
|
|
1917
|
-
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;
|
|
1918
1962
|
} else
|
|
1919
1963
|
throw new Error(`Unsupported WEIGHTS_0 component type: ${i.componentType}`);
|
|
1920
1964
|
}
|
|
1921
|
-
function
|
|
1965
|
+
function dr(s, t, e) {
|
|
1922
1966
|
const i = s.accessors[e];
|
|
1923
1967
|
if (i.type !== "MAT4")
|
|
1924
1968
|
throw new Error(`Expected MAT4, got ${i.type}`);
|
|
1925
1969
|
if (i.componentType !== 5126)
|
|
1926
1970
|
throw new Error(`Expected FLOAT component type for MAT4, got ${i.componentType}`);
|
|
1927
|
-
const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count, o = new DataView(t, n, a * 64),
|
|
1928
|
-
for (let
|
|
1929
|
-
c
|
|
1930
|
-
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;
|
|
1931
1975
|
}
|
|
1932
|
-
function
|
|
1976
|
+
function fr(s, t, e) {
|
|
1933
1977
|
const i = s.accessors[e];
|
|
1934
1978
|
if (i.type !== "SCALAR")
|
|
1935
1979
|
throw new Error(`Expected SCALAR, got ${i.type}`);
|
|
1936
1980
|
if (i.componentType !== 5126)
|
|
1937
1981
|
throw new Error(`Expected FLOAT component type for SCALAR, got ${i.componentType}`);
|
|
1938
|
-
const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count, o = new DataView(t, n, a * 4),
|
|
1939
|
-
for (let
|
|
1940
|
-
c
|
|
1941
|
-
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;
|
|
1942
1986
|
}
|
|
1943
|
-
function
|
|
1987
|
+
function pr(s, t, e) {
|
|
1944
1988
|
const i = s.accessors[e], n = { VEC3: 3, VEC4: 4 }[i.type];
|
|
1945
1989
|
if (!n)
|
|
1946
1990
|
throw new Error(`Expected VEC3 or VEC4, got ${i.type}`);
|
|
1947
1991
|
if (i.componentType !== 5126)
|
|
1948
1992
|
throw new Error(`Expected FLOAT component type, got ${i.componentType}`);
|
|
1949
|
-
const o = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0),
|
|
1950
|
-
for (let S = 0; S <
|
|
1951
|
-
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);
|
|
1952
1996
|
return d;
|
|
1953
1997
|
}
|
|
1954
|
-
function
|
|
1955
|
-
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;
|
|
1956
2000
|
if (!a || !o)
|
|
1957
2001
|
throw new Error("Mesh missing JOINTS_0 or WEIGHTS_0 attributes");
|
|
1958
|
-
const
|
|
2002
|
+
const l = s.nodes.map((d) => ({
|
|
1959
2003
|
translation: d.translation || [0, 0, 0],
|
|
1960
2004
|
rotation: d.rotation || [0, 0, 0, 1],
|
|
1961
2005
|
scale: d.scale || [1, 1, 1],
|
|
1962
2006
|
children: d.children || [],
|
|
1963
2007
|
name: d.name || ""
|
|
1964
|
-
})),
|
|
2008
|
+
})), c = [];
|
|
1965
2009
|
if (s.animations && s.animations.length > 0)
|
|
1966
2010
|
for (const d of s.animations) {
|
|
1967
2011
|
const S = [];
|
|
1968
|
-
let
|
|
1969
|
-
for (const
|
|
1970
|
-
const v = d.samplers[
|
|
1971
|
-
|
|
1972
|
-
targetNode:
|
|
1973
|
-
targetPath:
|
|
2012
|
+
let b = 0;
|
|
2013
|
+
for (const h of d.channels) {
|
|
2014
|
+
const v = d.samplers[h.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: h.target.node,
|
|
2017
|
+
targetPath: h.target.path,
|
|
1974
2018
|
interpolation: v.interpolation || "LINEAR",
|
|
1975
|
-
timestamps:
|
|
1976
|
-
values:
|
|
2019
|
+
timestamps: C,
|
|
2020
|
+
values: z
|
|
1977
2021
|
});
|
|
1978
2022
|
}
|
|
1979
|
-
|
|
1980
|
-
name: d.name || `Animation ${
|
|
1981
|
-
duration:
|
|
2023
|
+
c.push({
|
|
2024
|
+
name: d.name || `Animation ${c.length}`,
|
|
2025
|
+
duration: b,
|
|
1982
2026
|
channels: S
|
|
1983
2027
|
});
|
|
1984
2028
|
}
|
|
@@ -1987,11 +2031,11 @@ function cr(s, t, e) {
|
|
|
1987
2031
|
inverseBindMatrices: n,
|
|
1988
2032
|
jointIndices: a,
|
|
1989
2033
|
jointWeights: o,
|
|
1990
|
-
nodes:
|
|
1991
|
-
animations:
|
|
2034
|
+
nodes: l,
|
|
2035
|
+
animations: c
|
|
1992
2036
|
};
|
|
1993
2037
|
}
|
|
1994
|
-
async function
|
|
2038
|
+
async function Vi(s) {
|
|
1995
2039
|
const t = new DataView(s);
|
|
1996
2040
|
if (t.getUint32(0, !0) !== 1179937895)
|
|
1997
2041
|
throw new Error("Invalid GLB file: incorrect magic number");
|
|
@@ -2001,38 +2045,38 @@ async function Fi(s) {
|
|
|
2001
2045
|
const r = t.getUint32(8, !0);
|
|
2002
2046
|
let n = 12, a = null, o = null;
|
|
2003
2047
|
for (; n < r; ) {
|
|
2004
|
-
const
|
|
2048
|
+
const Z = t.getUint32(n, !0), T = t.getUint32(n + 4, !0), F = s.slice(n + 8, n + 8 + Z);
|
|
2005
2049
|
if (T === 1313821514) {
|
|
2006
|
-
const
|
|
2007
|
-
a = JSON.parse(
|
|
2008
|
-
} else T === 5130562 && (o =
|
|
2009
|
-
n += 8 +
|
|
2050
|
+
const H = new TextDecoder("utf-8").decode(F);
|
|
2051
|
+
a = JSON.parse(H);
|
|
2052
|
+
} else T === 5130562 && (o = F);
|
|
2053
|
+
n += 8 + Z;
|
|
2010
2054
|
}
|
|
2011
2055
|
if (!a)
|
|
2012
2056
|
throw new Error("GLB file missing JSON chunk");
|
|
2013
2057
|
if (!a.materials || a.materials.length === 0)
|
|
2014
2058
|
return null;
|
|
2015
|
-
const
|
|
2016
|
-
if (!
|
|
2059
|
+
const l = a.materials[0];
|
|
2060
|
+
if (!l.pbrMetallicRoughness || l.pbrMetallicRoughness.baseColorTexture === void 0)
|
|
2017
2061
|
return null;
|
|
2018
|
-
const
|
|
2019
|
-
if (!a.textures || !a.textures[
|
|
2062
|
+
const c = l.pbrMetallicRoughness.baseColorTexture.index;
|
|
2063
|
+
if (!a.textures || !a.textures[c])
|
|
2020
2064
|
return null;
|
|
2021
|
-
const S = a.textures[
|
|
2065
|
+
const S = a.textures[c].source;
|
|
2022
2066
|
if (S === void 0 || !a.images || !a.images[S])
|
|
2023
2067
|
return null;
|
|
2024
|
-
const
|
|
2025
|
-
if (
|
|
2068
|
+
const b = a.images[S], h = b.mimeType || "image/png";
|
|
2069
|
+
if (b.bufferView === void 0)
|
|
2026
2070
|
return null;
|
|
2027
2071
|
if (!o)
|
|
2028
2072
|
throw new Error("GLB file missing BIN chunk (required for embedded textures)");
|
|
2029
|
-
const v = a.bufferViews[
|
|
2030
|
-
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: h }), mimeType: h };
|
|
2031
2075
|
}
|
|
2032
|
-
function
|
|
2076
|
+
function mr(s, t, e, i) {
|
|
2033
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;
|
|
2034
2078
|
}
|
|
2035
|
-
function
|
|
2079
|
+
function yr(s, t, e, i) {
|
|
2036
2080
|
i = i || [0, 0, 0, 0];
|
|
2037
2081
|
let r = s[0] * t[0] + s[1] * t[1] + s[2] * t[2] + s[3] * t[3], n = 1;
|
|
2038
2082
|
if (r < 0 && (r = -r, n = -1), r > 0.9995) {
|
|
@@ -2040,26 +2084,26 @@ function dr(s, t, e, i) {
|
|
|
2040
2084
|
const d = Math.sqrt(i[0] * i[0] + i[1] * i[1] + i[2] * i[2] + i[3] * i[3]);
|
|
2041
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;
|
|
2042
2086
|
}
|
|
2043
|
-
const a = Math.acos(r), o = Math.sin(a),
|
|
2044
|
-
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;
|
|
2045
2089
|
}
|
|
2046
|
-
function
|
|
2047
|
-
const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i,
|
|
2048
|
-
return _[0] = 1 - (
|
|
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, h = i * l, v = r * l, C = n * a, z = n * o, D = n * l, _ = t || new Float32Array(16);
|
|
2092
|
+
return _[0] = 1 - (b + v), _[1] = d + D, _[2] = S - z, _[3] = 0, _[4] = d - D, _[5] = 1 - (c + v), _[6] = h + C, _[7] = 0, _[8] = S + z, _[9] = h - C, _[10] = 1 - (c + b), _[11] = 0, _[12] = 0, _[13] = 0, _[14] = 0, _[15] = 1, _;
|
|
2049
2093
|
}
|
|
2050
|
-
const
|
|
2051
|
-
function
|
|
2052
|
-
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);
|
|
2053
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;
|
|
2054
2098
|
}
|
|
2055
|
-
function
|
|
2099
|
+
function Oi(s, t, e) {
|
|
2056
2100
|
const i = e || new Float32Array(16);
|
|
2057
2101
|
for (let r = 0; r < 4; r++)
|
|
2058
2102
|
for (let n = 0; n < 4; n++)
|
|
2059
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];
|
|
2060
2104
|
return i;
|
|
2061
2105
|
}
|
|
2062
|
-
class
|
|
2106
|
+
class xr {
|
|
2063
2107
|
constructor(t) {
|
|
2064
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);
|
|
2065
2109
|
for (let e = 0; e < this.nodes.length; e++)
|
|
@@ -2089,9 +2133,9 @@ class mr {
|
|
|
2089
2133
|
try {
|
|
2090
2134
|
this._gpuDevice = t, this._gpuOutputBuffer = e;
|
|
2091
2135
|
const r = this.restPositions.length / 3, n = new Float32Array(r * 8);
|
|
2092
|
-
for (let
|
|
2093
|
-
const
|
|
2094
|
-
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;
|
|
2095
2139
|
}
|
|
2096
2140
|
this._gpuRestDataBuffer = t.createBuffer({
|
|
2097
2141
|
size: n.byteLength,
|
|
@@ -2103,8 +2147,8 @@ class mr {
|
|
|
2103
2147
|
label: "skinning_jointWeights"
|
|
2104
2148
|
}), t.queue.writeBuffer(this._gpuJointWeightsBuffer, 0, this.jointWeights);
|
|
2105
2149
|
const a = new Uint32Array(this.jointIndices.length);
|
|
2106
|
-
for (let
|
|
2107
|
-
a[
|
|
2150
|
+
for (let l = 0; l < this.jointIndices.length; l++)
|
|
2151
|
+
a[l] = this.jointIndices[l];
|
|
2108
2152
|
this._gpuJointIndicesBuffer = t.createBuffer({
|
|
2109
2153
|
size: a.byteLength,
|
|
2110
2154
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
|
|
@@ -2126,7 +2170,7 @@ class mr {
|
|
|
2126
2170
|
this._gpuSkinningPipeline = t.createComputePipeline({
|
|
2127
2171
|
layout: t.createPipelineLayout({ bindGroupLayouts: [o] }),
|
|
2128
2172
|
compute: {
|
|
2129
|
-
module: t.createShaderModule({ code:
|
|
2173
|
+
module: t.createShaderModule({ code: Qs }),
|
|
2130
2174
|
entryPoint: "main"
|
|
2131
2175
|
}
|
|
2132
2176
|
}), this._gpuSkinningBindGroup = t.createBindGroup({
|
|
@@ -2214,13 +2258,13 @@ class mr {
|
|
|
2214
2258
|
return this._extractValue(n, 0, o, i);
|
|
2215
2259
|
if (e >= r[r.length - 1])
|
|
2216
2260
|
return this._extractValue(n, r.length - 1, o, i);
|
|
2217
|
-
let
|
|
2218
|
-
for (;
|
|
2219
|
-
const
|
|
2220
|
-
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;
|
|
2221
2265
|
}
|
|
2222
|
-
const d = r[
|
|
2223
|
-
return a === "STEP" ? (i[0] =
|
|
2266
|
+
const d = r[l], S = r[c], b = (e - d) / (S - d), h = this._extractValue(n, l, o, this._sV0), v = this._extractValue(n, c, o, this._sV1);
|
|
2267
|
+
return a === "STEP" ? (i[0] = h[0], i[1] = h[1], i[2] = h[2], o === "rotation" && (i[3] = h[3]), i) : o === "rotation" ? yr(h, v, b, i) : mr(h, v, b, i);
|
|
2224
2268
|
}
|
|
2225
2269
|
/**
|
|
2226
2270
|
* Extract value from values array at the given index.
|
|
@@ -2243,9 +2287,9 @@ class mr {
|
|
|
2243
2287
|
for (let i = 0; i < this.nodes.length; i++) {
|
|
2244
2288
|
const r = this.nodes[i];
|
|
2245
2289
|
let n = r.translation, a = r.rotation, o = r.scale;
|
|
2246
|
-
for (const
|
|
2247
|
-
|
|
2248
|
-
|
|
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]);
|
|
2249
2293
|
}
|
|
2250
2294
|
}
|
|
2251
2295
|
/**
|
|
@@ -2255,7 +2299,7 @@ class mr {
|
|
|
2255
2299
|
const t = this._parentMap;
|
|
2256
2300
|
for (const e of this.topologicalOrder) {
|
|
2257
2301
|
const i = t[e];
|
|
2258
|
-
i === -1 ? this.jointGlobalTransforms[e].set(this.jointLocalTransforms[e]) :
|
|
2302
|
+
i === -1 ? this.jointGlobalTransforms[e].set(this.jointLocalTransforms[e]) : Oi(
|
|
2259
2303
|
this.jointGlobalTransforms[i],
|
|
2260
2304
|
this.jointLocalTransforms[e],
|
|
2261
2305
|
this.jointGlobalTransforms[e]
|
|
@@ -2268,7 +2312,7 @@ class mr {
|
|
|
2268
2312
|
_computeFinalMatrices() {
|
|
2269
2313
|
for (let t = 0; t < this.joints.length; t++) {
|
|
2270
2314
|
const e = this.joints[t], i = this.jointGlobalTransforms[e];
|
|
2271
|
-
|
|
2315
|
+
Oi(i, this._invBindViews[t], this.jointFinalMatrices[t]);
|
|
2272
2316
|
}
|
|
2273
2317
|
}
|
|
2274
2318
|
/**
|
|
@@ -2276,22 +2320,22 @@ class mr {
|
|
|
2276
2320
|
* Inlined math, no temporary array allocations.
|
|
2277
2321
|
*/
|
|
2278
2322
|
_applySkinning() {
|
|
2279
|
-
const t = this.restPositions.length / 3, e = this.restPositions, i = this.restNormals, r = this.skinnedPositions, n = this.skinnedNormals, a = this.jointWeights, o = this.jointIndices,
|
|
2280
|
-
for (let
|
|
2281
|
-
const d =
|
|
2282
|
-
let _ = 0,
|
|
2283
|
-
for (let
|
|
2284
|
-
const
|
|
2285
|
-
if (
|
|
2286
|
-
const
|
|
2287
|
-
_ += (
|
|
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], h = e[d + 1], v = e[d + 2], C = i[d], z = i[d + 1], D = i[d + 2];
|
|
2326
|
+
let _ = 0, Z = 0, T = 0, F = 0, G = 0, H = 0;
|
|
2327
|
+
for (let ne = 0; ne < 4; ne++) {
|
|
2328
|
+
const re = a[S + ne];
|
|
2329
|
+
if (re === 0) continue;
|
|
2330
|
+
const j = l[o[S + ne]];
|
|
2331
|
+
_ += (j[0] * b + j[4] * h + j[8] * v + j[12]) * re, Z += (j[1] * b + j[5] * h + j[9] * v + j[13]) * re, T += (j[2] * b + j[6] * h + j[10] * v + j[14]) * re, F += (j[0] * C + j[4] * z + j[8] * D) * re, G += (j[1] * C + j[5] * z + j[9] * D) * re, H += (j[2] * C + j[6] * z + j[10] * D) * re;
|
|
2288
2332
|
}
|
|
2289
|
-
const
|
|
2290
|
-
|
|
2333
|
+
const se = Math.sqrt(F * F + G * G + H * H);
|
|
2334
|
+
se > 1e-4 && (n[d] = F / se, n[d + 1] = G / se, n[d + 2] = H / se), r[d] = _, r[d + 1] = Z, r[d + 2] = T;
|
|
2291
2335
|
}
|
|
2292
2336
|
}
|
|
2293
2337
|
}
|
|
2294
|
-
class
|
|
2338
|
+
class vr {
|
|
2295
2339
|
constructor({ duration: t = 0, loop: e = !1, playbackRate: i = 1 } = {}) {
|
|
2296
2340
|
this.currentTime = 0, this.duration = t, this.loop = e, this.playbackRate = i, this.paused = !1, this._justLooped = !1;
|
|
2297
2341
|
}
|
|
@@ -2312,7 +2356,7 @@ class yr {
|
|
|
2312
2356
|
this.currentTime = Math.max(0, t || 0), this._justLooped = !1;
|
|
2313
2357
|
}
|
|
2314
2358
|
}
|
|
2315
|
-
const
|
|
2359
|
+
const Li = {
|
|
2316
2360
|
linear: (s) => s,
|
|
2317
2361
|
easeInQuad: (s) => s * s,
|
|
2318
2362
|
easeOutQuad: (s) => 1 - (1 - s) * (1 - s),
|
|
@@ -2331,26 +2375,26 @@ const Di = {
|
|
|
2331
2375
|
return Math.pow(2, -10 * s) * Math.sin((s * 10 - 0.75) * t) + 1;
|
|
2332
2376
|
}
|
|
2333
2377
|
};
|
|
2334
|
-
function
|
|
2335
|
-
const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t,
|
|
2336
|
-
return (
|
|
2337
|
-
if (
|
|
2338
|
-
if (
|
|
2339
|
-
let v =
|
|
2340
|
-
for (let
|
|
2341
|
-
const
|
|
2342
|
-
if (Math.abs(
|
|
2343
|
-
const
|
|
2344
|
-
if (Math.abs(
|
|
2345
|
-
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 = (h) => ((a * h + n) * h + r) * h, S = (h) => ((c * h + l) * h + o) * h, b = (h) => (3 * a * h + 2 * n) * h + r;
|
|
2380
|
+
return (h) => {
|
|
2381
|
+
if (h <= 0) return 0;
|
|
2382
|
+
if (h >= 1) return 1;
|
|
2383
|
+
let v = h;
|
|
2384
|
+
for (let C = 0; C < 8; C++) {
|
|
2385
|
+
const z = d(v) - h;
|
|
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;
|
|
2346
2390
|
}
|
|
2347
2391
|
return S(v);
|
|
2348
2392
|
};
|
|
2349
2393
|
}
|
|
2350
|
-
function
|
|
2351
|
-
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);
|
|
2352
2396
|
}
|
|
2353
|
-
function
|
|
2397
|
+
function _r(s, t) {
|
|
2354
2398
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2355
2399
|
if (s.length === 1 || t <= s[0].t) return s[0].v;
|
|
2356
2400
|
const e = s[s.length - 1];
|
|
@@ -2359,12 +2403,12 @@ function br(s, t) {
|
|
|
2359
2403
|
const r = s[i], n = s[i + 1];
|
|
2360
2404
|
if (t >= r.t && t <= n.t) {
|
|
2361
2405
|
const a = n.t - r.t, o = a > 0 ? (t - r.t) / a : 0;
|
|
2362
|
-
return r.v + (n.v - r.v) *
|
|
2406
|
+
return r.v + (n.v - r.v) * $i(r.ease, o);
|
|
2363
2407
|
}
|
|
2364
2408
|
}
|
|
2365
2409
|
return e.v;
|
|
2366
2410
|
}
|
|
2367
|
-
function
|
|
2411
|
+
function Mr(s, t, e) {
|
|
2368
2412
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2369
2413
|
const i = s.length, r = s[i - 1];
|
|
2370
2414
|
let n, a, o;
|
|
@@ -2375,25 +2419,60 @@ function Sr(s, t, e) {
|
|
|
2375
2419
|
else {
|
|
2376
2420
|
n = a = r.v, o = 0;
|
|
2377
2421
|
for (let S = 0; S < i - 1; S++) {
|
|
2378
|
-
const
|
|
2379
|
-
if (t >=
|
|
2380
|
-
const v =
|
|
2381
|
-
n =
|
|
2422
|
+
const b = s[S], h = s[S + 1];
|
|
2423
|
+
if (t >= b.t && t <= h.t) {
|
|
2424
|
+
const v = h.t - b.t;
|
|
2425
|
+
n = b.v, a = h.v, o = $i(b.ease, v > 0 ? (t - b.t) / v : 0);
|
|
2382
2426
|
break;
|
|
2383
2427
|
}
|
|
2384
2428
|
}
|
|
2385
2429
|
}
|
|
2386
|
-
const
|
|
2387
|
-
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];
|
|
2388
2432
|
}
|
|
2389
|
-
const
|
|
2390
|
-
|
|
2433
|
+
const wr = [
|
|
2434
|
+
"gravityStrength",
|
|
2435
|
+
"emissionRate",
|
|
2436
|
+
"damping",
|
|
2437
|
+
"dampingStrength",
|
|
2438
|
+
"particleSize",
|
|
2439
|
+
"particleSpeed",
|
|
2440
|
+
"opacity",
|
|
2441
|
+
"bloomIntensity",
|
|
2442
|
+
"emissionPositionX",
|
|
2443
|
+
"emissionPositionY",
|
|
2444
|
+
"emissionPositionZ",
|
|
2445
|
+
"emissionRotationX",
|
|
2446
|
+
"emissionRotationY",
|
|
2447
|
+
"emissionRotationZ",
|
|
2448
|
+
"circleInnerRadius",
|
|
2449
|
+
"circleOuterRadius",
|
|
2450
|
+
"discRadius",
|
|
2451
|
+
"annulusInnerRadius",
|
|
2452
|
+
"annulusOuterRadius",
|
|
2453
|
+
"arcStartAngle",
|
|
2454
|
+
"arcEndAngle",
|
|
2455
|
+
"arcInnerRadius",
|
|
2456
|
+
"arcOuterRadius",
|
|
2457
|
+
"squareSize",
|
|
2458
|
+
"rectangleWidth",
|
|
2459
|
+
"rectangleHeight",
|
|
2460
|
+
"planeWidth",
|
|
2461
|
+
"planeDepth",
|
|
2462
|
+
"lineLength",
|
|
2463
|
+
"polygonRadius",
|
|
2464
|
+
"shapeStrokeWidth",
|
|
2465
|
+
"shapeStrokeAmplitude",
|
|
2466
|
+
"shapeStrokeFrequency",
|
|
2467
|
+
"shapeStrokeSpeed"
|
|
2468
|
+
], Rr = { square: 0, circle: 1, triangle: 2, diamond: 3, star: 4, hexagon: 5, ring: 6, heart: 7, cross: 8, spark: 9, leaf: 10, capsule: 11, crescent: 12, line: 13, "curved-line": 14 };
|
|
2469
|
+
function ki(s) {
|
|
2391
2470
|
const t = atob(s), e = new Uint8Array(t.length);
|
|
2392
2471
|
for (let i = 0; i < t.length; i++)
|
|
2393
2472
|
e[i] = t.charCodeAt(i);
|
|
2394
2473
|
return e.buffer;
|
|
2395
2474
|
}
|
|
2396
|
-
class
|
|
2475
|
+
class ii {
|
|
2397
2476
|
constructor(t, e) {
|
|
2398
2477
|
this.device = t, this.config = e, this.MAX_PARTICLES = e.maxParticles || 1e4, this.particleCount = e.particleCount || 100, this.activeParticles = 0, this.emitting = !1, this.currentEmissionTime = 0, this.emissionAccumulator = 0, this.destroyed = !1, this.particleData = new Float32Array(this.MAX_PARTICLES * 8), this.particleVelocities = new Float32Array(this.MAX_PARTICLES * 4), this.instanceBuffer = t.createBuffer({
|
|
2399
2478
|
size: this.MAX_PARTICLES * 8 * 4,
|
|
@@ -2419,7 +2498,7 @@ class Qt {
|
|
|
2419
2498
|
// intensity (f32) + padding
|
|
2420
2499
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
2421
2500
|
label: "systemBloomIntensityBuffer"
|
|
2422
|
-
}), 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 ks(e), this.physics = new $s(t, this.MAX_PARTICLES), this.textureManager = new Ws(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({
|
|
2423
2502
|
enabled: !0,
|
|
2424
2503
|
shape: e.confinementShape,
|
|
2425
2504
|
mode: e.confinementMode,
|
|
@@ -2432,7 +2511,7 @@ class Qt {
|
|
|
2432
2511
|
enabled: !0,
|
|
2433
2512
|
strength: e.softBoundaryStrength,
|
|
2434
2513
|
falloff: e.softBoundaryFalloff
|
|
2435
|
-
}), this.particleTexture = this.textureManager.getDefaultTexture(), this.updateBloomIntensity(), this.updateAppearanceUniform(), this.frameCount = 0, this.shouldReset = !1, this._scriptParticleData = new Float32Array(this.MAX_PARTICLES * 8), this._scriptVelocityData = new Float32Array(this.MAX_PARTICLES * 4), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, this._particleScript = null, e.script && (this._particleScript = new
|
|
2514
|
+
}), this.particleTexture = this.textureManager.getDefaultTexture(), this.updateBloomIntensity(), this.updateAppearanceUniform(), this.frameCount = 0, this.shouldReset = !1, this._scriptParticleData = new Float32Array(this.MAX_PARTICLES * 8), this._scriptVelocityData = new Float32Array(this.MAX_PARTICLES * 4), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, this._particleScript = null, e.script && (this._particleScript = new Fi(e.script, e, this.MAX_PARTICLES)), this.initComputePipeline(t);
|
|
2436
2515
|
}
|
|
2437
2516
|
async initComputePipeline(t) {
|
|
2438
2517
|
this.computeReady = await this.physics.initComputePipeline(this.instanceBuffer, this.velocityBuffer, this.trailBuffer);
|
|
@@ -2442,7 +2521,7 @@ class Qt {
|
|
|
2442
2521
|
* @param {string|null} source - Script source code, or null to disable
|
|
2443
2522
|
*/
|
|
2444
2523
|
setScript(t) {
|
|
2445
|
-
this._particleScript && (this._particleScript.destroy(), this._particleScript = null), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, t ? (this.config.script = t, this._particleScript = new
|
|
2524
|
+
this._particleScript && (this._particleScript.destroy(), this._particleScript = null), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, t ? (this.config.script = t, this._particleScript = new Fi(t, this.config, this.MAX_PARTICLES), this._particleScript.snapshotConfig(this.config)) : delete this.config.script;
|
|
2446
2525
|
}
|
|
2447
2526
|
async setTexture(t) {
|
|
2448
2527
|
this.destroyed || (this.textureManager.destroyTexture(this.particleTexture), this.particleTexture = await this.textureManager.loadTexture(t), this.config.textureEnabled = !0, this.updateAppearanceUniform(), this.updateBuffers());
|
|
@@ -2453,7 +2532,7 @@ class Qt {
|
|
|
2453
2532
|
async setGLBModel(t) {
|
|
2454
2533
|
try {
|
|
2455
2534
|
this.glbRawArrayBuffer = t;
|
|
2456
|
-
const e = await
|
|
2535
|
+
const e = await or(t);
|
|
2457
2536
|
this.glbMeshData = e, this.config.glbHasTexture = e.hasBaseColorTexture || !1;
|
|
2458
2537
|
const i = new Float32Array(e.vertexCount * 8);
|
|
2459
2538
|
for (let r = 0; r < e.vertexCount; r++) {
|
|
@@ -2469,7 +2548,7 @@ class Qt {
|
|
|
2469
2548
|
usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST,
|
|
2470
2549
|
label: "glbIndexBuffer"
|
|
2471
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) {
|
|
2472
|
-
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);
|
|
2473
2552
|
try {
|
|
2474
2553
|
await this.glbAnimator.initGPUSkinning(this.device, this.glbVertexBuffer, e.texCoords);
|
|
2475
2554
|
} catch (r) {
|
|
@@ -2531,7 +2610,7 @@ class Qt {
|
|
|
2531
2610
|
if (this.destroyed) return;
|
|
2532
2611
|
let t = 0;
|
|
2533
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);
|
|
2534
|
-
const e =
|
|
2613
|
+
const e = Rr[this.config.particleShape] ?? 0, i = this._appearanceData;
|
|
2535
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;
|
|
2536
2615
|
const r = this.config.followSystemTranslation ?? !0;
|
|
2537
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);
|
|
@@ -2542,40 +2621,40 @@ class Qt {
|
|
|
2542
2621
|
const e = this.config.bloomColor || [1, 1, 1];
|
|
2543
2622
|
t[4] = e[0], t[5] = e[1], t[6] = e[2], this.device.queue.writeBuffer(this.bloomIntensityBuffer, 0, t);
|
|
2544
2623
|
}
|
|
2545
|
-
spawnParticles() {
|
|
2546
|
-
if (this.activeParticles = 0, this.currentEmissionTime = 0, this.emissionAccumulator = 0, this._newEmissions.length = 0, this._pendingFollowEmissions = this._emptyEmissions, this._scriptFrame = 0, this._scriptTime = 0, this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptConfigRestored = !1, this._particleScript && (this._particleScript._configSnapshot ? (this._particleScript.restoreConfig(this.config), 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), this.updateAppearanceUniform(), this.updateBloomIntensity()) : this._particleScript.snapshotConfig(this.config)), this.device.queue.writeBuffer(this.trailBuffer, 0, this._trailResetData, 0, this.MAX_PARTICLES * 4), this.glbAnimator && (this.glbAnimator.currentTime = 0, this.glbAnimator.playing = !0), this.config.followSystemId) {
|
|
2624
|
+
spawnParticles(t) {
|
|
2625
|
+
if (this.activeParticles = 0, this.currentEmissionTime = 0, this.emissionAccumulator = 0, this._newEmissions.length = 0, this._pendingFollowEmissions = this._emptyEmissions, this._scriptFrame = 0, this._scriptTime = 0, this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptConfigRestored = !1, this._particleScript && (this._particleScript._configSnapshot ? (this._particleScript.restoreConfig(this.config), 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), this.updateAppearanceUniform(), this.updateBloomIntensity()) : this._particleScript.snapshotConfig(this.config)), typeof t == "function" && t(this), this.device.queue.writeBuffer(this.trailBuffer, 0, this._trailResetData, 0, this.MAX_PARTICLES * 4), this.glbAnimator && (this.glbAnimator.currentTime = 0, this.glbAnimator.playing = !0), this.config.followSystemId) {
|
|
2547
2626
|
this.emitting = !0, this.particleCount = this.MAX_PARTICLES;
|
|
2548
2627
|
return;
|
|
2549
2628
|
}
|
|
2550
2629
|
if (this.config.burstMode) {
|
|
2551
|
-
const
|
|
2552
|
-
this.particleCount =
|
|
2553
|
-
let
|
|
2554
|
-
const
|
|
2555
|
-
for (let
|
|
2556
|
-
if (this.emitParticle(),
|
|
2557
|
-
const
|
|
2630
|
+
const e = this.config.particleCount;
|
|
2631
|
+
this.particleCount = e;
|
|
2632
|
+
let i = 0;
|
|
2633
|
+
const r = 500;
|
|
2634
|
+
for (let n = 0; n < e; n++)
|
|
2635
|
+
if (this.emitParticle(), i++, i >= r || n === e - 1) {
|
|
2636
|
+
const a = n - i + 1, o = a * 8, l = a * 4;
|
|
2558
2637
|
this.device.queue.writeBuffer(
|
|
2559
2638
|
this.instanceBuffer,
|
|
2560
|
-
|
|
2639
|
+
o * 4,
|
|
2561
2640
|
// Offset in bytes
|
|
2562
2641
|
this.particleData,
|
|
2563
|
-
|
|
2564
|
-
|
|
2642
|
+
o,
|
|
2643
|
+
i * 8
|
|
2565
2644
|
), this.device.queue.writeBuffer(
|
|
2566
2645
|
this.velocityBuffer,
|
|
2567
|
-
|
|
2646
|
+
l * 4,
|
|
2568
2647
|
// Offset in bytes
|
|
2569
2648
|
this.particleVelocities,
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
),
|
|
2649
|
+
l,
|
|
2650
|
+
i * 4
|
|
2651
|
+
), i = 0;
|
|
2573
2652
|
}
|
|
2574
2653
|
this.emitting = !1;
|
|
2575
2654
|
} else {
|
|
2576
2655
|
this.emitting = !0;
|
|
2577
|
-
const
|
|
2578
|
-
this.particleCount = Math.min(Math.ceil((this.config.emissionRate || 10) *
|
|
2656
|
+
const e = this.config.lifetime || 5, i = this.config.emissionDurationInfinite ? e : Math.min(this.config.emissionDuration || 10, e);
|
|
2657
|
+
this.particleCount = Math.min(Math.ceil((this.config.emissionRate || 10) * i), this.MAX_PARTICLES);
|
|
2579
2658
|
}
|
|
2580
2659
|
}
|
|
2581
2660
|
// Effective emission window: Infinity when "Infinite Duration" is on (emits forever).
|
|
@@ -2593,8 +2672,8 @@ class Qt {
|
|
|
2593
2672
|
this._emitSimRotY = this._simRotY || 0;
|
|
2594
2673
|
const e = t * 8, i = t * 4;
|
|
2595
2674
|
if (this._simRotMatrix) {
|
|
2596
|
-
const r = this._simRotMatrix, n = this.particleData[e], a = this.particleData[e + 1], o = this.particleData[e + 2],
|
|
2597
|
-
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;
|
|
2598
2677
|
}
|
|
2599
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]);
|
|
2600
2679
|
}
|
|
@@ -2619,8 +2698,8 @@ class Qt {
|
|
|
2619
2698
|
if (this.activeParticles >= this.particleCount) return !1;
|
|
2620
2699
|
const r = this.activeParticles * 8, n = t + (this.config.emissionPositionX || 0), a = e + (this.config.emissionPositionY || 0), o = i + (this.config.emissionPositionZ || 0);
|
|
2621
2700
|
this.particleData[r] = n, this.particleData[r + 1] = a, this.particleData[r + 2] = o;
|
|
2622
|
-
const
|
|
2623
|
-
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;
|
|
2624
2703
|
}
|
|
2625
2704
|
updateParticles(t, e, i = 0) {
|
|
2626
2705
|
const r = this.config.startAt || 0, n = r > 0 && i < r;
|
|
@@ -2630,7 +2709,7 @@ class Qt {
|
|
|
2630
2709
|
if (d > 0 && this._scriptTime >= d && !this._scriptConfigRestored)
|
|
2631
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));
|
|
2632
2711
|
else if (!this._scriptConfigRestored) {
|
|
2633
|
-
const S = d > 0 ? Math.ceil(d / 0.016666666666666666) : 0, { configDirty:
|
|
2712
|
+
const S = d > 0 ? Math.ceil(d / 0.016666666666666666) : 0, { configDirty: b, particlesDirty: h } = this._particleScript.execute(
|
|
2634
2713
|
t,
|
|
2635
2714
|
this._scriptTime,
|
|
2636
2715
|
this._scriptFrame,
|
|
@@ -2639,7 +2718,7 @@ class Qt {
|
|
|
2639
2718
|
this._scriptVelocityData,
|
|
2640
2719
|
this.activeParticles
|
|
2641
2720
|
);
|
|
2642
|
-
|
|
2721
|
+
h && this.activeParticles > 0 && (this.device.queue.writeBuffer(
|
|
2643
2722
|
this.instanceBuffer,
|
|
2644
2723
|
0,
|
|
2645
2724
|
this._scriptParticleData,
|
|
@@ -2651,20 +2730,20 @@ class Qt {
|
|
|
2651
2730
|
this._scriptVelocityData,
|
|
2652
2731
|
0,
|
|
2653
2732
|
this.activeParticles * 4
|
|
2654
|
-
)),
|
|
2733
|
+
)), b && (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));
|
|
2655
2734
|
}
|
|
2656
2735
|
}
|
|
2657
2736
|
this.physics.physicsAccumulator += t;
|
|
2658
|
-
const a = performance.now() / 1e3,
|
|
2737
|
+
const a = performance.now() / 1e3, l = a - this.physics.lastUpdateTime > 1 / this.physics.minUpdatesPerSecond, c = this.activeParticles;
|
|
2659
2738
|
if (!n && !this.emitting && !this.config.burstMode && !this.config.followSystemId && this.currentEmissionTime < this.effectiveEmissionDuration && (this.emitting = !0), !n && this.emitting)
|
|
2660
2739
|
if (this.currentEmissionTime += t, this.currentEmissionTime < this.effectiveEmissionDuration) {
|
|
2661
2740
|
const d = this.activeParticles;
|
|
2662
2741
|
let S = !1;
|
|
2663
2742
|
if (this.config.followSystemId) {
|
|
2664
2743
|
if (this._pendingFollowEmissions.length > 0) {
|
|
2665
|
-
const
|
|
2666
|
-
for (let
|
|
2667
|
-
const v =
|
|
2744
|
+
const b = this._pendingFollowEmissions.length / 6;
|
|
2745
|
+
for (let h = 0; h < b; h++) {
|
|
2746
|
+
const v = h * 6;
|
|
2668
2747
|
if (this.emitFollowerParticle(
|
|
2669
2748
|
this._pendingFollowEmissions[v],
|
|
2670
2749
|
this._pendingFollowEmissions[v + 1],
|
|
@@ -2676,10 +2755,10 @@ class Qt {
|
|
|
2676
2755
|
}
|
|
2677
2756
|
}
|
|
2678
2757
|
} else {
|
|
2679
|
-
let
|
|
2680
|
-
const
|
|
2681
|
-
this.activeParticles < this.particleCount &&
|
|
2682
|
-
for (let v = 0; v <
|
|
2758
|
+
let b = 0;
|
|
2759
|
+
const h = Math.max(0, this.config.emissionRate || 0);
|
|
2760
|
+
this.activeParticles < this.particleCount && h > 0 ? (this.emissionAccumulator += h * t, b = Math.floor(this.emissionAccumulator + 1e-9), b > 0 && (this.emissionAccumulator -= b)) : this.activeParticles >= this.particleCount && (this.emissionAccumulator = 0);
|
|
2761
|
+
for (let v = 0; v < b; v++)
|
|
2683
2762
|
if (this.emitParticle())
|
|
2684
2763
|
S = !0;
|
|
2685
2764
|
else {
|
|
@@ -2688,21 +2767,21 @@ class Qt {
|
|
|
2688
2767
|
}
|
|
2689
2768
|
}
|
|
2690
2769
|
if (S) {
|
|
2691
|
-
const
|
|
2770
|
+
const b = this.activeParticles - d, h = d * 8, v = d * 4;
|
|
2692
2771
|
this.device.queue.writeBuffer(
|
|
2693
2772
|
this.instanceBuffer,
|
|
2694
|
-
|
|
2773
|
+
h * 4,
|
|
2695
2774
|
// Offset in bytes (float32 = 4 bytes)
|
|
2696
2775
|
this.particleData,
|
|
2697
|
-
|
|
2698
|
-
|
|
2776
|
+
h,
|
|
2777
|
+
b * 8
|
|
2699
2778
|
), this.device.queue.writeBuffer(
|
|
2700
2779
|
this.velocityBuffer,
|
|
2701
2780
|
v * 4,
|
|
2702
2781
|
// Offset in bytes (float32 = 4 bytes)
|
|
2703
2782
|
this.particleVelocities,
|
|
2704
2783
|
v,
|
|
2705
|
-
|
|
2784
|
+
b * 4
|
|
2706
2785
|
);
|
|
2707
2786
|
}
|
|
2708
2787
|
} else
|
|
@@ -2710,15 +2789,15 @@ class Qt {
|
|
|
2710
2789
|
for (; this.physics.physicsAccumulator >= this.physics.fixedDeltaTime; )
|
|
2711
2790
|
this.physics.updatePhysics(
|
|
2712
2791
|
this.physics.fixedDeltaTime,
|
|
2713
|
-
|
|
2792
|
+
c,
|
|
2714
2793
|
this.config,
|
|
2715
2794
|
this.instanceBuffer,
|
|
2716
2795
|
this.velocityBuffer,
|
|
2717
2796
|
e
|
|
2718
2797
|
), this.physics.physicsAccumulator -= this.physics.fixedDeltaTime, this.physics.physicsClock += this.physics.fixedDeltaTime;
|
|
2719
|
-
|
|
2798
|
+
l && c > 0 && (this.physics.updatePhysics(
|
|
2720
2799
|
this.physics.fixedDeltaTime,
|
|
2721
|
-
|
|
2800
|
+
c,
|
|
2722
2801
|
this.config,
|
|
2723
2802
|
this.instanceBuffer,
|
|
2724
2803
|
this.velocityBuffer,
|
|
@@ -2756,10 +2835,10 @@ class Qt {
|
|
|
2756
2835
|
continue;
|
|
2757
2836
|
}
|
|
2758
2837
|
if (e !== r) {
|
|
2759
|
-
const o = r * 8,
|
|
2760
|
-
this.particleData.copyWithin(
|
|
2761
|
-
const
|
|
2762
|
-
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;
|
|
2763
2842
|
}
|
|
2764
2843
|
e++;
|
|
2765
2844
|
}
|
|
@@ -2788,17 +2867,17 @@ class Qt {
|
|
|
2788
2867
|
}
|
|
2789
2868
|
updateParticleVelocities() {
|
|
2790
2869
|
for (let t = 0; t < this.activeParticles; t++) {
|
|
2791
|
-
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],
|
|
2792
|
-
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
|
|
2793
2872
|
);
|
|
2794
2873
|
if (d > 1e-3) {
|
|
2795
2874
|
const S = this.config.particleSpeed * 2;
|
|
2796
|
-
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;
|
|
2797
2876
|
} else {
|
|
2798
2877
|
const S = Math.sqrt(r * r + n * n + a * a);
|
|
2799
2878
|
if (S > 1e-3) {
|
|
2800
|
-
const
|
|
2801
|
-
this.particleVelocities[i] = r / S *
|
|
2879
|
+
const b = this.config.particleSpeed * 2;
|
|
2880
|
+
this.particleVelocities[i] = r / S * b, this.particleVelocities[i + 1] = n / S * b, this.particleVelocities[i + 2] = a / S * b;
|
|
2802
2881
|
} else
|
|
2803
2882
|
this.particleVelocities[i] = 0, this.particleVelocities[i + 1] = this.config.particleSpeed * 2, this.particleVelocities[i + 2] = 0;
|
|
2804
2883
|
}
|
|
@@ -2843,16 +2922,16 @@ class Qt {
|
|
|
2843
2922
|
this.physics.setSoftBoundary(t);
|
|
2844
2923
|
}
|
|
2845
2924
|
}
|
|
2846
|
-
class
|
|
2925
|
+
class Br {
|
|
2847
2926
|
constructor(t) {
|
|
2848
|
-
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;
|
|
2849
2928
|
}
|
|
2850
2929
|
createParticleSystem(t = {}) {
|
|
2851
2930
|
const e = this.systemCounter++, i = t.name || `System ${e + 1}`, r = {
|
|
2852
2931
|
...t,
|
|
2853
2932
|
name: i,
|
|
2854
2933
|
id: e
|
|
2855
|
-
}, n = new
|
|
2934
|
+
}, n = new ii(this.device, r);
|
|
2856
2935
|
return this.particleSystems.push({
|
|
2857
2936
|
system: n,
|
|
2858
2937
|
config: r
|
|
@@ -2891,9 +2970,9 @@ class Pr {
|
|
|
2891
2970
|
}
|
|
2892
2971
|
respawnAllSystems() {
|
|
2893
2972
|
var t;
|
|
2894
|
-
for (const { system: e } of this.particleSystems)
|
|
2895
|
-
e.spawnParticles();
|
|
2896
2973
|
(t = this.clock) == null || t.reset();
|
|
2974
|
+
for (const { system: e, config: i } of this.particleSystems)
|
|
2975
|
+
e.spawnParticles(() => this._applyKeyframesToSystem(e, i, 0));
|
|
2897
2976
|
}
|
|
2898
2977
|
// Total effect duration in seconds for the timeline/loop (Infinity if any system emits
|
|
2899
2978
|
// forever). Burst/one-only systems last only their lifetime (they emit at t=0). This is the
|
|
@@ -2913,34 +2992,20 @@ class Pr {
|
|
|
2913
2992
|
const r = this.clock ? this.clock.currentTime : 0, n = this.clock ? this.clock.duration : 0;
|
|
2914
2993
|
if (this.clock && n > 0 && isFinite(n)) {
|
|
2915
2994
|
const a = Math.min(1, this.clock.currentTime / n);
|
|
2916
|
-
for (const { system: o, config:
|
|
2917
|
-
|
|
2918
|
-
if (!(!l || c.keyframesEnabled === !1)) {
|
|
2919
|
-
for (const d of xr) {
|
|
2920
|
-
const S = l[d];
|
|
2921
|
-
if (S && S.length) {
|
|
2922
|
-
const g = br(S, a);
|
|
2923
|
-
g !== void 0 && (c[d] = g);
|
|
2924
|
-
}
|
|
2925
|
-
}
|
|
2926
|
-
if (l.particleColor && l.particleColor.length) {
|
|
2927
|
-
const d = c.particleColor, S = d && typeof d.length == "number" && d.length >= 3 ? d : void 0, g = Sr(l.particleColor, a, S);
|
|
2928
|
-
g && (c.particleColor = g, o.updateAppearanceUniform());
|
|
2929
|
-
}
|
|
2930
|
-
}
|
|
2931
|
-
}
|
|
2995
|
+
for (const { system: o, config: l } of this.particleSystems)
|
|
2996
|
+
this._applyKeyframesToSystem(o, l, a);
|
|
2932
2997
|
}
|
|
2933
2998
|
for (const { system: a, config: o } of this.particleSystems) {
|
|
2934
2999
|
if (o.hidden || o.followSystemId) continue;
|
|
2935
|
-
const
|
|
2936
|
-
a.updateParticles(t, e, r), (
|
|
3000
|
+
const l = a.activeParticles > 0;
|
|
3001
|
+
a.updateParticles(t, e, r), (l || a.activeParticles > 0) && (i = !0);
|
|
2937
3002
|
}
|
|
2938
3003
|
for (const { system: a, config: o } of this.particleSystems) {
|
|
2939
3004
|
if (o.hidden || !o.followSystemId) continue;
|
|
2940
|
-
const
|
|
2941
|
-
|
|
2942
|
-
const
|
|
2943
|
-
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);
|
|
2944
3009
|
}
|
|
2945
3010
|
i && this.device.queue.submit([e.finish()]);
|
|
2946
3011
|
for (const { system: a } of this.particleSystems)
|
|
@@ -2976,7 +3041,7 @@ class Pr {
|
|
|
2976
3041
|
const n = this.systemCounter++, a = {
|
|
2977
3042
|
...r,
|
|
2978
3043
|
id: n
|
|
2979
|
-
}, o = new
|
|
3044
|
+
}, o = new ii(this.device, a);
|
|
2980
3045
|
this.particleSystems.push({
|
|
2981
3046
|
system: o,
|
|
2982
3047
|
config: a
|
|
@@ -2994,7 +3059,7 @@ class Pr {
|
|
|
2994
3059
|
try {
|
|
2995
3060
|
let a = null;
|
|
2996
3061
|
if (n.glbModelData)
|
|
2997
|
-
a =
|
|
3062
|
+
a = ki(n.glbModelData);
|
|
2998
3063
|
else if (n.glbFileName) {
|
|
2999
3064
|
const o = await fetch(`/${n.glbFileName}`);
|
|
3000
3065
|
o.ok ? a = await o.arrayBuffer() : console.warn(`GLB file not found: ${n.glbFileName}`);
|
|
@@ -3002,10 +3067,10 @@ class Pr {
|
|
|
3002
3067
|
if (a) {
|
|
3003
3068
|
if (await r.setGLBModel(a), n.animationIndex !== void 0 && r.glbAnimator && r.glbAnimator.setAnimation(n.animationIndex), n.animationSpeed !== void 0 && r.glbAnimator && (r.glbAnimator.speed = n.animationSpeed), n.animationLoop !== void 0 && r.glbAnimator && (r.glbAnimator.loop = n.animationLoop), n.useGlbTexture && (n.textureEnabled = !0), n.useGlbTexture && ((e = r.glbMeshData) != null && e.hasBaseColorTexture))
|
|
3004
3069
|
try {
|
|
3005
|
-
const o = await
|
|
3070
|
+
const o = await Vi(a);
|
|
3006
3071
|
if (o) {
|
|
3007
|
-
const
|
|
3008
|
-
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}`);
|
|
3009
3074
|
}
|
|
3010
3075
|
} catch (o) {
|
|
3011
3076
|
console.warn(`Failed to restore GLB texture for ${n.name}:`, o), n.useGlbTexture = !1;
|
|
@@ -3019,8 +3084,8 @@ class Pr {
|
|
|
3019
3084
|
if (n.textureEnabled && !n.glbModelEnabled && n.textureImageData)
|
|
3020
3085
|
try {
|
|
3021
3086
|
const a = new Image();
|
|
3022
|
-
await new Promise((
|
|
3023
|
-
a.onload =
|
|
3087
|
+
await new Promise((l, c) => {
|
|
3088
|
+
a.onload = l, a.onerror = c, a.src = n.textureImageData;
|
|
3024
3089
|
});
|
|
3025
3090
|
const o = await createImageBitmap(a);
|
|
3026
3091
|
await r.setTexture(o);
|
|
@@ -3051,76 +3116,76 @@ class Pr {
|
|
|
3051
3116
|
const i = [];
|
|
3052
3117
|
try {
|
|
3053
3118
|
for (const o of t.systems) {
|
|
3054
|
-
const
|
|
3055
|
-
i.push(
|
|
3056
|
-
const
|
|
3119
|
+
const l = this.systemCounter++;
|
|
3120
|
+
i.push(l);
|
|
3121
|
+
const c = {
|
|
3057
3122
|
...o,
|
|
3058
|
-
id:
|
|
3123
|
+
id: l,
|
|
3059
3124
|
// Apply world-space offset to emission translation
|
|
3060
3125
|
emissionPositionX: (o.emissionPositionX || 0) + e[0],
|
|
3061
3126
|
emissionPositionY: (o.emissionPositionY || 0) + e[1],
|
|
3062
3127
|
emissionPositionZ: (o.emissionPositionZ || 0) + e[2]
|
|
3063
3128
|
};
|
|
3064
|
-
o.attractorEnabled && o.attractorPosition && (
|
|
3129
|
+
o.attractorEnabled && o.attractorPosition && (c.attractorPosition = [
|
|
3065
3130
|
o.attractorPosition[0] + e[0],
|
|
3066
3131
|
o.attractorPosition[1] + e[1],
|
|
3067
3132
|
o.attractorPosition[2] + e[2]
|
|
3068
|
-
]), o.confinementEnabled && o.confinementSpace === "world" && Array.isArray(o.confinementCenter) && (
|
|
3133
|
+
]), o.confinementEnabled && o.confinementSpace === "world" && Array.isArray(o.confinementCenter) && (c.confinementCenter = [
|
|
3069
3134
|
(o.confinementCenter[0] || 0) + e[0],
|
|
3070
3135
|
(o.confinementCenter[1] || 0) + e[1],
|
|
3071
3136
|
(o.confinementCenter[2] || 0) + e[2]
|
|
3072
3137
|
]);
|
|
3073
|
-
const d = new
|
|
3138
|
+
const d = new ii(this.device, c);
|
|
3074
3139
|
this.particleSystems.push({
|
|
3075
3140
|
system: d,
|
|
3076
|
-
config:
|
|
3077
|
-
}), this.onSystemCreated && typeof this.onSystemCreated == "function" && this.onSystemCreated(
|
|
3141
|
+
config: c
|
|
3142
|
+
}), this.onSystemCreated && typeof this.onSystemCreated == "function" && this.onSystemCreated(l, c);
|
|
3078
3143
|
}
|
|
3079
3144
|
const n = this.particleSystems.length - t.systems.length, a = {};
|
|
3080
|
-
t.systems.forEach((o,
|
|
3081
|
-
a[o.id] = this.particleSystems[n +
|
|
3145
|
+
t.systems.forEach((o, l) => {
|
|
3146
|
+
a[o.id] = this.particleSystems[n + l].config.id;
|
|
3082
3147
|
});
|
|
3083
3148
|
for (let o = n; o < this.particleSystems.length; o++) {
|
|
3084
|
-
const { config:
|
|
3085
|
-
|
|
3149
|
+
const { config: l } = this.particleSystems[o];
|
|
3150
|
+
l.followSystemId && a[l.followSystemId] !== void 0 && (l.followSystemId = a[l.followSystemId]);
|
|
3086
3151
|
}
|
|
3087
|
-
for (const { system: o, config:
|
|
3088
|
-
if (
|
|
3152
|
+
for (const { system: o, config: l } of this.particleSystems)
|
|
3153
|
+
if (l.glbModelEnabled && !o.glbMeshData)
|
|
3089
3154
|
try {
|
|
3090
|
-
let
|
|
3091
|
-
if (
|
|
3092
|
-
|
|
3093
|
-
else if (
|
|
3094
|
-
const d = await fetch(`/${
|
|
3095
|
-
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}`);
|
|
3096
3161
|
}
|
|
3097
|
-
if (
|
|
3098
|
-
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))
|
|
3099
3164
|
try {
|
|
3100
|
-
const d = await
|
|
3165
|
+
const d = await Vi(c);
|
|
3101
3166
|
if (d) {
|
|
3102
3167
|
const S = await createImageBitmap(d.imageBlob);
|
|
3103
|
-
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}`);
|
|
3104
3169
|
}
|
|
3105
3170
|
} catch (d) {
|
|
3106
|
-
console.warn(`Failed to restore GLB texture for ${
|
|
3171
|
+
console.warn(`Failed to restore GLB texture for ${l.name}:`, d), l.useGlbTexture = !1;
|
|
3107
3172
|
}
|
|
3108
3173
|
} else
|
|
3109
|
-
|
|
3110
|
-
} catch (
|
|
3111
|
-
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;
|
|
3112
3177
|
}
|
|
3113
|
-
for (const { system: o, config:
|
|
3114
|
-
if (
|
|
3178
|
+
for (const { system: o, config: l } of this.particleSystems)
|
|
3179
|
+
if (l.textureEnabled && !l.glbModelEnabled && l.textureImageData && !o._textureRestored)
|
|
3115
3180
|
try {
|
|
3116
|
-
const
|
|
3117
|
-
await new Promise((S,
|
|
3118
|
-
|
|
3181
|
+
const c = new Image();
|
|
3182
|
+
await new Promise((S, b) => {
|
|
3183
|
+
c.onload = S, c.onerror = b, c.src = l.textureImageData;
|
|
3119
3184
|
});
|
|
3120
|
-
const d = await createImageBitmap(
|
|
3185
|
+
const d = await createImageBitmap(c);
|
|
3121
3186
|
await o.setTexture(d), o._textureRestored = !0;
|
|
3122
|
-
} catch (
|
|
3123
|
-
console.warn(`Failed to restore texture for ${
|
|
3187
|
+
} catch (c) {
|
|
3188
|
+
console.warn(`Failed to restore texture for ${l.name}:`, c), l.textureEnabled = !1;
|
|
3124
3189
|
}
|
|
3125
3190
|
return i;
|
|
3126
3191
|
} catch (n) {
|
|
@@ -3129,8 +3194,30 @@ class Pr {
|
|
|
3129
3194
|
this.ready = !0;
|
|
3130
3195
|
}
|
|
3131
3196
|
}
|
|
3197
|
+
_applyKeyframesToSystem(t, e, i) {
|
|
3198
|
+
const r = e.keyframes;
|
|
3199
|
+
if (!r || e.keyframesEnabled === !1) return;
|
|
3200
|
+
let n = !1, a = !1, o = !1, l = !1, c = !1;
|
|
3201
|
+
for (const d of wr) {
|
|
3202
|
+
const S = r[d];
|
|
3203
|
+
if (!S || !S.length) continue;
|
|
3204
|
+
const b = _r(S, i);
|
|
3205
|
+
if (b !== void 0) {
|
|
3206
|
+
if (d === "damping") {
|
|
3207
|
+
e.dampingStrength = b, l = !0;
|
|
3208
|
+
continue;
|
|
3209
|
+
}
|
|
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);
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
if (r.particleColor && r.particleColor.length) {
|
|
3214
|
+
const d = e.particleColor, S = d && typeof d.length == "number" && d.length >= 3 ? d : void 0, b = Mr(r.particleColor, i, S);
|
|
3215
|
+
b && (e.particleColor = b, n = !0);
|
|
3216
|
+
}
|
|
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);
|
|
3218
|
+
}
|
|
3132
3219
|
}
|
|
3133
|
-
async function
|
|
3220
|
+
async function Tr(s) {
|
|
3134
3221
|
if (!s)
|
|
3135
3222
|
throw new Error("canvas is required for initWebGPU()");
|
|
3136
3223
|
if (!navigator.gpu)
|
|
@@ -3142,37 +3229,40 @@ async function _r(s) {
|
|
|
3142
3229
|
alphaMode: "premultiplied"
|
|
3143
3230
|
}), { device: i, context: t, format: r, canvas: s };
|
|
3144
3231
|
}
|
|
3145
|
-
const
|
|
3146
|
-
|
|
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) {
|
|
3147
3237
|
const r = s.createTexture({
|
|
3148
3238
|
size: [e, i],
|
|
3149
|
-
format:
|
|
3239
|
+
format: Xe,
|
|
3150
3240
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3151
3241
|
mipLevelCount: 1,
|
|
3152
3242
|
sampleCount: 1
|
|
3153
|
-
}), n = s.createTexture({
|
|
3154
|
-
size: [
|
|
3155
|
-
format:
|
|
3243
|
+
}), [n, a] = Ji(e, i), o = s.createTexture({
|
|
3244
|
+
size: [n, a],
|
|
3245
|
+
format: Xe,
|
|
3156
3246
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3157
3247
|
mipLevelCount: 1,
|
|
3158
3248
|
sampleCount: 1
|
|
3159
|
-
}),
|
|
3160
|
-
size: [
|
|
3161
|
-
format:
|
|
3249
|
+
}), l = s.createTexture({
|
|
3250
|
+
size: [n, a],
|
|
3251
|
+
format: Xe,
|
|
3162
3252
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3163
3253
|
mipLevelCount: 1,
|
|
3164
3254
|
sampleCount: 1
|
|
3165
3255
|
});
|
|
3166
|
-
return { sceneTexture: r, bloomTexA:
|
|
3256
|
+
return { sceneTexture: r, bloomTexA: o, bloomTexB: l };
|
|
3167
3257
|
}
|
|
3168
|
-
function
|
|
3258
|
+
function Yi(s, t, e) {
|
|
3169
3259
|
return s.createTexture({
|
|
3170
3260
|
size: [t, e],
|
|
3171
3261
|
format: "depth24plus",
|
|
3172
3262
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
3173
3263
|
});
|
|
3174
3264
|
}
|
|
3175
|
-
function
|
|
3265
|
+
function St(s, t, e) {
|
|
3176
3266
|
const i = s.createBuffer({
|
|
3177
3267
|
size: t.byteLength,
|
|
3178
3268
|
usage: e,
|
|
@@ -3180,7 +3270,7 @@ function vt(s, t, e) {
|
|
|
3180
3270
|
});
|
|
3181
3271
|
return new t.constructor(i.getMappedRange()).set(t), i.unmap(), i;
|
|
3182
3272
|
}
|
|
3183
|
-
const
|
|
3273
|
+
const Er = `
|
|
3184
3274
|
struct Uniforms {
|
|
3185
3275
|
transform: mat4x4<f32>,
|
|
3186
3276
|
cameraPosition: vec3<f32>,
|
|
@@ -3242,7 +3332,7 @@ const Mr = `
|
|
|
3242
3332
|
|
|
3243
3333
|
return finalColor;
|
|
3244
3334
|
}
|
|
3245
|
-
`,
|
|
3335
|
+
`, Ar = `
|
|
3246
3336
|
struct Uniforms {
|
|
3247
3337
|
transform: mat4x4<f32>,
|
|
3248
3338
|
cameraPosition: vec3<f32>,
|
|
@@ -3479,7 +3569,7 @@ const Mr = `
|
|
|
3479
3569
|
return finalColor;
|
|
3480
3570
|
}
|
|
3481
3571
|
`;
|
|
3482
|
-
function
|
|
3572
|
+
function Cr(s) {
|
|
3483
3573
|
const t = s.createBindGroupLayout({
|
|
3484
3574
|
entries: [
|
|
3485
3575
|
{
|
|
@@ -3565,34 +3655,34 @@ function Br(s) {
|
|
|
3565
3655
|
object3dBindGroupLayout: r
|
|
3566
3656
|
};
|
|
3567
3657
|
}
|
|
3568
|
-
function
|
|
3658
|
+
function Ur(s, t, e, i = {}) {
|
|
3569
3659
|
const { depthCompare: r } = i, n = r || "less", {
|
|
3570
3660
|
particleBindGroupLayout: a,
|
|
3571
3661
|
bloomBindGroupLayout: o,
|
|
3572
|
-
compositeBindGroupLayout:
|
|
3573
|
-
object3dBindGroupLayout:
|
|
3662
|
+
compositeBindGroupLayout: l,
|
|
3663
|
+
object3dBindGroupLayout: c
|
|
3574
3664
|
} = e, d = s.createPipelineLayout({
|
|
3575
3665
|
bindGroupLayouts: [a]
|
|
3576
3666
|
}), S = s.createPipelineLayout({
|
|
3577
3667
|
bindGroupLayouts: [o]
|
|
3578
|
-
}),
|
|
3579
|
-
bindGroupLayouts: [
|
|
3580
|
-
}),
|
|
3581
|
-
code:
|
|
3668
|
+
}), b = s.createPipelineLayout({
|
|
3669
|
+
bindGroupLayouts: [l]
|
|
3670
|
+
}), h = s.createShaderModule({
|
|
3671
|
+
code: Hs
|
|
3582
3672
|
}), v = s.createShaderModule({
|
|
3583
|
-
code:
|
|
3584
|
-
}),
|
|
3585
|
-
code:
|
|
3586
|
-
}),
|
|
3587
|
-
code:
|
|
3588
|
-
}),
|
|
3589
|
-
code:
|
|
3673
|
+
code: Zs
|
|
3674
|
+
}), C = s.createShaderModule({
|
|
3675
|
+
code: Ws
|
|
3676
|
+
}), z = s.createShaderModule({
|
|
3677
|
+
code: $s
|
|
3678
|
+
}), D = s.createShaderModule({
|
|
3679
|
+
code: Er
|
|
3590
3680
|
}), _ = s.createShaderModule({
|
|
3591
|
-
code:
|
|
3592
|
-
}),
|
|
3681
|
+
code: Ar
|
|
3682
|
+
}), Z = (kt) => s.createRenderPipeline({
|
|
3593
3683
|
layout: d,
|
|
3594
3684
|
vertex: {
|
|
3595
|
-
module:
|
|
3685
|
+
module: h,
|
|
3596
3686
|
entryPoint: "vs_main",
|
|
3597
3687
|
buffers: [
|
|
3598
3688
|
{
|
|
@@ -3653,10 +3743,10 @@ function Rr(s, t, e, i = {}) {
|
|
|
3653
3743
|
]
|
|
3654
3744
|
},
|
|
3655
3745
|
fragment: {
|
|
3656
|
-
module:
|
|
3746
|
+
module: h,
|
|
3657
3747
|
entryPoint: "fs_main",
|
|
3658
3748
|
targets: [{
|
|
3659
|
-
format:
|
|
3749
|
+
format: Xe,
|
|
3660
3750
|
blend: kt
|
|
3661
3751
|
}]
|
|
3662
3752
|
},
|
|
@@ -3669,7 +3759,7 @@ function Rr(s, t, e, i = {}) {
|
|
|
3669
3759
|
depthCompare: n,
|
|
3670
3760
|
format: "depth24plus"
|
|
3671
3761
|
}
|
|
3672
|
-
}), T =
|
|
3762
|
+
}), T = Z({
|
|
3673
3763
|
color: {
|
|
3674
3764
|
srcFactor: "src-alpha",
|
|
3675
3765
|
dstFactor: "one-minus-src-alpha",
|
|
@@ -3680,7 +3770,7 @@ function Rr(s, t, e, i = {}) {
|
|
|
3680
3770
|
dstFactor: "one-minus-src-alpha",
|
|
3681
3771
|
operation: "add"
|
|
3682
3772
|
}
|
|
3683
|
-
}),
|
|
3773
|
+
}), F = Z({
|
|
3684
3774
|
color: {
|
|
3685
3775
|
srcFactor: "src-alpha",
|
|
3686
3776
|
dstFactor: "one",
|
|
@@ -3691,10 +3781,10 @@ function Rr(s, t, e, i = {}) {
|
|
|
3691
3781
|
dstFactor: "one-minus-src-alpha",
|
|
3692
3782
|
operation: "add"
|
|
3693
3783
|
}
|
|
3694
|
-
}),
|
|
3784
|
+
}), G = s.createRenderPipeline({
|
|
3695
3785
|
layout: d,
|
|
3696
3786
|
vertex: {
|
|
3697
|
-
module:
|
|
3787
|
+
module: h,
|
|
3698
3788
|
entryPoint: "vs_main",
|
|
3699
3789
|
buffers: [
|
|
3700
3790
|
{
|
|
@@ -3755,10 +3845,10 @@ function Rr(s, t, e, i = {}) {
|
|
|
3755
3845
|
]
|
|
3756
3846
|
},
|
|
3757
3847
|
fragment: {
|
|
3758
|
-
module:
|
|
3848
|
+
module: h,
|
|
3759
3849
|
entryPoint: "fs_main",
|
|
3760
3850
|
targets: [{
|
|
3761
|
-
format:
|
|
3851
|
+
format: Xe,
|
|
3762
3852
|
writeMask: 0
|
|
3763
3853
|
// No color write — depth only
|
|
3764
3854
|
}]
|
|
@@ -3773,7 +3863,7 @@ function Rr(s, t, e, i = {}) {
|
|
|
3773
3863
|
// Always write depth (don't self-occlude)
|
|
3774
3864
|
format: "depth24plus"
|
|
3775
3865
|
}
|
|
3776
|
-
}),
|
|
3866
|
+
}), H = s.createRenderPipeline({
|
|
3777
3867
|
layout: S,
|
|
3778
3868
|
vertex: {
|
|
3779
3869
|
module: v,
|
|
@@ -3783,23 +3873,23 @@ function Rr(s, t, e, i = {}) {
|
|
|
3783
3873
|
module: v,
|
|
3784
3874
|
entryPoint: "fs_main",
|
|
3785
3875
|
targets: [{
|
|
3786
|
-
format:
|
|
3876
|
+
format: Xe
|
|
3787
3877
|
}]
|
|
3788
3878
|
},
|
|
3789
3879
|
primitive: {
|
|
3790
3880
|
topology: "triangle-list"
|
|
3791
3881
|
}
|
|
3792
|
-
}),
|
|
3793
|
-
layout:
|
|
3882
|
+
}), se = s.createRenderPipeline({
|
|
3883
|
+
layout: b,
|
|
3794
3884
|
vertex: {
|
|
3795
|
-
module:
|
|
3885
|
+
module: C,
|
|
3796
3886
|
entryPoint: "vs_main"
|
|
3797
3887
|
},
|
|
3798
3888
|
fragment: {
|
|
3799
|
-
module:
|
|
3889
|
+
module: C,
|
|
3800
3890
|
entryPoint: "fs_main",
|
|
3801
3891
|
targets: [{
|
|
3802
|
-
format:
|
|
3892
|
+
format: Xe,
|
|
3803
3893
|
blend: {
|
|
3804
3894
|
color: {
|
|
3805
3895
|
srcFactor: "one",
|
|
@@ -3817,17 +3907,17 @@ function Rr(s, t, e, i = {}) {
|
|
|
3817
3907
|
primitive: {
|
|
3818
3908
|
topology: "triangle-list"
|
|
3819
3909
|
}
|
|
3820
|
-
}),
|
|
3821
|
-
layout:
|
|
3910
|
+
}), ne = s.createRenderPipeline({
|
|
3911
|
+
layout: b,
|
|
3822
3912
|
vertex: {
|
|
3823
|
-
module:
|
|
3913
|
+
module: z,
|
|
3824
3914
|
entryPoint: "vs_main"
|
|
3825
3915
|
},
|
|
3826
3916
|
fragment: {
|
|
3827
|
-
module:
|
|
3917
|
+
module: z,
|
|
3828
3918
|
entryPoint: "fs_main",
|
|
3829
3919
|
targets: [{
|
|
3830
|
-
format:
|
|
3920
|
+
format: Xe,
|
|
3831
3921
|
blend: {
|
|
3832
3922
|
color: {
|
|
3833
3923
|
srcFactor: "one",
|
|
@@ -3845,11 +3935,11 @@ function Rr(s, t, e, i = {}) {
|
|
|
3845
3935
|
primitive: {
|
|
3846
3936
|
topology: "triangle-list"
|
|
3847
3937
|
}
|
|
3848
|
-
}),
|
|
3849
|
-
layout:
|
|
3850
|
-
vertex: { module:
|
|
3938
|
+
}), re = s.createShaderModule({ code: Js }), j = s.createRenderPipeline({
|
|
3939
|
+
layout: b,
|
|
3940
|
+
vertex: { module: re, entryPoint: "vs_main" },
|
|
3851
3941
|
fragment: {
|
|
3852
|
-
module:
|
|
3942
|
+
module: re,
|
|
3853
3943
|
entryPoint: "fs_main",
|
|
3854
3944
|
targets: [{
|
|
3855
3945
|
format: t,
|
|
@@ -3860,12 +3950,12 @@ function Rr(s, t, e, i = {}) {
|
|
|
3860
3950
|
}]
|
|
3861
3951
|
},
|
|
3862
3952
|
primitive: { topology: "triangle-list" }
|
|
3863
|
-
}),
|
|
3864
|
-
bindGroupLayouts: [
|
|
3865
|
-
}),
|
|
3866
|
-
layout:
|
|
3953
|
+
}), tt = s.createPipelineLayout({
|
|
3954
|
+
bindGroupLayouts: [c]
|
|
3955
|
+
}), xt = s.createRenderPipeline({
|
|
3956
|
+
layout: tt,
|
|
3867
3957
|
vertex: {
|
|
3868
|
-
module:
|
|
3958
|
+
module: D,
|
|
3869
3959
|
entryPoint: "vs_main",
|
|
3870
3960
|
buffers: [
|
|
3871
3961
|
{
|
|
@@ -3890,10 +3980,10 @@ function Rr(s, t, e, i = {}) {
|
|
|
3890
3980
|
]
|
|
3891
3981
|
},
|
|
3892
3982
|
fragment: {
|
|
3893
|
-
module:
|
|
3983
|
+
module: D,
|
|
3894
3984
|
entryPoint: "fs_main",
|
|
3895
3985
|
targets: [{
|
|
3896
|
-
format:
|
|
3986
|
+
format: Xe,
|
|
3897
3987
|
blend: {
|
|
3898
3988
|
color: {
|
|
3899
3989
|
srcFactor: "src-alpha",
|
|
@@ -3917,7 +4007,7 @@ function Rr(s, t, e, i = {}) {
|
|
|
3917
4007
|
depthCompare: n,
|
|
3918
4008
|
format: "depth24plus"
|
|
3919
4009
|
}
|
|
3920
|
-
}),
|
|
4010
|
+
}), at = s.createRenderPipeline({
|
|
3921
4011
|
layout: d,
|
|
3922
4012
|
vertex: {
|
|
3923
4013
|
module: _,
|
|
@@ -3995,7 +4085,7 @@ function Rr(s, t, e, i = {}) {
|
|
|
3995
4085
|
module: _,
|
|
3996
4086
|
entryPoint: "fs_main",
|
|
3997
4087
|
targets: [{
|
|
3998
|
-
format:
|
|
4088
|
+
format: Xe,
|
|
3999
4089
|
blend: {
|
|
4000
4090
|
color: {
|
|
4001
4091
|
srcFactor: "src-alpha",
|
|
@@ -4022,28 +4112,28 @@ function Rr(s, t, e, i = {}) {
|
|
|
4022
4112
|
});
|
|
4023
4113
|
return {
|
|
4024
4114
|
particlePipeline: T,
|
|
4025
|
-
particleAdditivePipeline:
|
|
4026
|
-
particleDepthWritePipeline:
|
|
4027
|
-
blurPipeline:
|
|
4028
|
-
compositePipeline:
|
|
4029
|
-
directRenderPipeline:
|
|
4030
|
-
finalCompositePipeline:
|
|
4031
|
-
object3dPipeline:
|
|
4032
|
-
glbMeshPipeline:
|
|
4115
|
+
particleAdditivePipeline: F,
|
|
4116
|
+
particleDepthWritePipeline: G,
|
|
4117
|
+
blurPipeline: H,
|
|
4118
|
+
compositePipeline: se,
|
|
4119
|
+
directRenderPipeline: ne,
|
|
4120
|
+
finalCompositePipeline: j,
|
|
4121
|
+
object3dPipeline: xt,
|
|
4122
|
+
glbMeshPipeline: at
|
|
4033
4123
|
};
|
|
4034
4124
|
}
|
|
4035
|
-
function
|
|
4125
|
+
function si(s, t, e, i) {
|
|
4036
4126
|
const {
|
|
4037
4127
|
uniformBuffer: r,
|
|
4038
4128
|
appearanceUniformBuffer: n,
|
|
4039
4129
|
horizontalBlurUniformBuffer: a,
|
|
4040
4130
|
verticalBlurUniformBuffer: o,
|
|
4041
|
-
bloomIntensityBuffer:
|
|
4131
|
+
bloomIntensityBuffer: l
|
|
4042
4132
|
} = e, {
|
|
4043
|
-
sceneTexture:
|
|
4133
|
+
sceneTexture: c,
|
|
4044
4134
|
bloomTexA: d,
|
|
4045
4135
|
bloomTexB: S
|
|
4046
|
-
} = i,
|
|
4136
|
+
} = i, b = s.createBindGroup({
|
|
4047
4137
|
layout: s.createBindGroupLayout({
|
|
4048
4138
|
entries: [
|
|
4049
4139
|
{
|
|
@@ -4068,7 +4158,7 @@ function ei(s, t, e, i) {
|
|
|
4068
4158
|
resource: { buffer: n }
|
|
4069
4159
|
}
|
|
4070
4160
|
]
|
|
4071
|
-
}),
|
|
4161
|
+
}), h = s.createBindGroup({
|
|
4072
4162
|
layout: s.createBindGroupLayout({
|
|
4073
4163
|
entries: [
|
|
4074
4164
|
{
|
|
@@ -4095,7 +4185,7 @@ function ei(s, t, e, i) {
|
|
|
4095
4185
|
},
|
|
4096
4186
|
{
|
|
4097
4187
|
binding: 1,
|
|
4098
|
-
resource:
|
|
4188
|
+
resource: c.createView()
|
|
4099
4189
|
},
|
|
4100
4190
|
{
|
|
4101
4191
|
binding: 2,
|
|
@@ -4136,7 +4226,7 @@ function ei(s, t, e, i) {
|
|
|
4136
4226
|
resource: { buffer: o }
|
|
4137
4227
|
}
|
|
4138
4228
|
]
|
|
4139
|
-
}),
|
|
4229
|
+
}), C = s.createBindGroup({
|
|
4140
4230
|
layout: s.createBindGroupLayout({
|
|
4141
4231
|
entries: [
|
|
4142
4232
|
{
|
|
@@ -4168,7 +4258,7 @@ function ei(s, t, e, i) {
|
|
|
4168
4258
|
},
|
|
4169
4259
|
{
|
|
4170
4260
|
binding: 1,
|
|
4171
|
-
resource:
|
|
4261
|
+
resource: c.createView()
|
|
4172
4262
|
},
|
|
4173
4263
|
{
|
|
4174
4264
|
binding: 2,
|
|
@@ -4176,10 +4266,10 @@ function ei(s, t, e, i) {
|
|
|
4176
4266
|
},
|
|
4177
4267
|
{
|
|
4178
4268
|
binding: 3,
|
|
4179
|
-
resource: { buffer:
|
|
4269
|
+
resource: { buffer: l }
|
|
4180
4270
|
}
|
|
4181
4271
|
]
|
|
4182
|
-
}),
|
|
4272
|
+
}), z = s.createBindGroup({
|
|
4183
4273
|
layout: s.createBindGroupLayout({
|
|
4184
4274
|
entries: [
|
|
4185
4275
|
{
|
|
@@ -4211,7 +4301,7 @@ function ei(s, t, e, i) {
|
|
|
4211
4301
|
},
|
|
4212
4302
|
{
|
|
4213
4303
|
binding: 1,
|
|
4214
|
-
resource:
|
|
4304
|
+
resource: c.createView()
|
|
4215
4305
|
},
|
|
4216
4306
|
{
|
|
4217
4307
|
binding: 2,
|
|
@@ -4219,19 +4309,19 @@ function ei(s, t, e, i) {
|
|
|
4219
4309
|
},
|
|
4220
4310
|
{
|
|
4221
4311
|
binding: 3,
|
|
4222
|
-
resource: { buffer:
|
|
4312
|
+
resource: { buffer: l }
|
|
4223
4313
|
}
|
|
4224
4314
|
]
|
|
4225
4315
|
});
|
|
4226
4316
|
return {
|
|
4227
|
-
particleBindGroup:
|
|
4228
|
-
horizontalBlurBindGroup:
|
|
4317
|
+
particleBindGroup: b,
|
|
4318
|
+
horizontalBlurBindGroup: h,
|
|
4229
4319
|
verticalBlurBindGroup: v,
|
|
4230
|
-
compositeBindGroup:
|
|
4231
|
-
directRenderBindGroup:
|
|
4320
|
+
compositeBindGroup: C,
|
|
4321
|
+
directRenderBindGroup: z
|
|
4232
4322
|
};
|
|
4233
4323
|
}
|
|
4234
|
-
function
|
|
4324
|
+
function Ir(s) {
|
|
4235
4325
|
return s.createSampler({
|
|
4236
4326
|
magFilter: "linear",
|
|
4237
4327
|
minFilter: "linear",
|
|
@@ -4241,7 +4331,7 @@ function Tr(s) {
|
|
|
4241
4331
|
maxAnisotropy: 16
|
|
4242
4332
|
});
|
|
4243
4333
|
}
|
|
4244
|
-
function
|
|
4334
|
+
function zr() {
|
|
4245
4335
|
const s = new Float32Array([
|
|
4246
4336
|
// Front face (z = 0.5)
|
|
4247
4337
|
-0.5,
|
|
@@ -4439,13 +4529,13 @@ function Er() {
|
|
|
4439
4529
|
]);
|
|
4440
4530
|
return { vertices: s, indices: t };
|
|
4441
4531
|
}
|
|
4442
|
-
function
|
|
4532
|
+
function Dr(s = 16, t = 16) {
|
|
4443
4533
|
const e = [], i = [];
|
|
4444
4534
|
for (let r = 0; r <= s; r++) {
|
|
4445
4535
|
const n = r * Math.PI / s, a = Math.sin(n), o = Math.cos(n);
|
|
4446
|
-
for (let
|
|
4447
|
-
const
|
|
4448
|
-
e.push(
|
|
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, h = o, v = d * a;
|
|
4538
|
+
e.push(b * 0.5, h * 0.5, v * 0.5), e.push(b, h, v);
|
|
4449
4539
|
}
|
|
4450
4540
|
}
|
|
4451
4541
|
for (let r = 0; r < s; r++)
|
|
@@ -4458,7 +4548,7 @@ function Ar(s = 16, t = 16) {
|
|
|
4458
4548
|
indices: new Uint16Array(i)
|
|
4459
4549
|
};
|
|
4460
4550
|
}
|
|
4461
|
-
class
|
|
4551
|
+
class Fr {
|
|
4462
4552
|
constructor(t, e, i, r, n) {
|
|
4463
4553
|
this.id = t, this.type = e, this.position = i, this.scale = r, this.color = n, this.rotation = [0, 0, 0];
|
|
4464
4554
|
}
|
|
@@ -4466,9 +4556,9 @@ class Cr {
|
|
|
4466
4556
|
* Get the model matrix for this object
|
|
4467
4557
|
*/
|
|
4468
4558
|
getModelMatrix() {
|
|
4469
|
-
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]),
|
|
4470
|
-
let
|
|
4471
|
-
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;
|
|
4472
4562
|
}
|
|
4473
4563
|
/**
|
|
4474
4564
|
* Get the normal matrix (inverse transpose of model matrix)
|
|
@@ -4592,7 +4682,7 @@ class Cr {
|
|
|
4592
4682
|
return i;
|
|
4593
4683
|
}
|
|
4594
4684
|
}
|
|
4595
|
-
class
|
|
4685
|
+
class Nr {
|
|
4596
4686
|
constructor(t) {
|
|
4597
4687
|
this.device = t, this.objects = [], this.nextId = 0, this.initializeGeometry(), this.onObjectAdded = null, this.onObjectRemoved = null, this.onObjectUpdated = null;
|
|
4598
4688
|
}
|
|
@@ -4600,20 +4690,20 @@ class Vr {
|
|
|
4600
4690
|
* Initialize geometry buffers for cube and sphere
|
|
4601
4691
|
*/
|
|
4602
4692
|
initializeGeometry() {
|
|
4603
|
-
const t =
|
|
4604
|
-
this.cubeVertexBuffer =
|
|
4693
|
+
const t = zr(), e = Dr(16, 16);
|
|
4694
|
+
this.cubeVertexBuffer = St(
|
|
4605
4695
|
this.device,
|
|
4606
4696
|
t.vertices,
|
|
4607
4697
|
GPUBufferUsage.VERTEX
|
|
4608
|
-
), this.cubeIndexBuffer =
|
|
4698
|
+
), this.cubeIndexBuffer = St(
|
|
4609
4699
|
this.device,
|
|
4610
4700
|
t.indices,
|
|
4611
4701
|
GPUBufferUsage.INDEX
|
|
4612
|
-
), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer =
|
|
4702
|
+
), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer = St(
|
|
4613
4703
|
this.device,
|
|
4614
4704
|
e.vertices,
|
|
4615
4705
|
GPUBufferUsage.VERTEX
|
|
4616
|
-
), this.sphereIndexBuffer =
|
|
4706
|
+
), this.sphereIndexBuffer = St(
|
|
4617
4707
|
this.device,
|
|
4618
4708
|
e.indices,
|
|
4619
4709
|
GPUBufferUsage.INDEX
|
|
@@ -4628,7 +4718,7 @@ class Vr {
|
|
|
4628
4718
|
* @returns {Object3D} The created object
|
|
4629
4719
|
*/
|
|
4630
4720
|
addObject(t, e = [0, 0, 0], i = [1, 1, 1], r = [1, 1, 1, 1]) {
|
|
4631
|
-
const n = new
|
|
4721
|
+
const n = new Fr(this.nextId++, t, e, i, r);
|
|
4632
4722
|
return n.uniformBuffer = this.device.createBuffer({
|
|
4633
4723
|
size: 192,
|
|
4634
4724
|
// modelMatrix (64) + normalMatrix (64) + color (16) + padding (48)
|
|
@@ -4706,32 +4796,32 @@ class Vr {
|
|
|
4706
4796
|
{ binding: 1, resource: { buffer: n.uniformBuffer } }
|
|
4707
4797
|
]
|
|
4708
4798
|
});
|
|
4709
|
-
let o,
|
|
4799
|
+
let o, l, c;
|
|
4710
4800
|
if (n.type === "cube")
|
|
4711
|
-
o = this.cubeVertexBuffer,
|
|
4801
|
+
o = this.cubeVertexBuffer, l = this.cubeIndexBuffer, c = this.cubeIndexCount;
|
|
4712
4802
|
else if (n.type === "sphere")
|
|
4713
|
-
o = this.sphereVertexBuffer,
|
|
4803
|
+
o = this.sphereVertexBuffer, l = this.sphereIndexBuffer, c = this.sphereIndexCount;
|
|
4714
4804
|
else
|
|
4715
4805
|
continue;
|
|
4716
|
-
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);
|
|
4717
4807
|
}
|
|
4718
4808
|
}
|
|
4719
4809
|
}
|
|
4720
|
-
function
|
|
4810
|
+
function Yr(s) {
|
|
4721
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;
|
|
4722
4812
|
return [t, e, i];
|
|
4723
4813
|
}
|
|
4724
|
-
function
|
|
4814
|
+
function jr(s) {
|
|
4725
4815
|
if (!s) return "#ffffff";
|
|
4726
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");
|
|
4727
4817
|
return `#${t}${e}${i}`;
|
|
4728
4818
|
}
|
|
4729
|
-
function
|
|
4730
|
-
const i =
|
|
4819
|
+
function qr(s, t, e) {
|
|
4820
|
+
const i = ji([
|
|
4731
4821
|
s[0] - t[0],
|
|
4732
4822
|
s[1] - t[1],
|
|
4733
4823
|
s[2] - t[2]
|
|
4734
|
-
]), r =
|
|
4824
|
+
]), r = ji(qi(e, i)), n = qi(i, r);
|
|
4735
4825
|
return new Float32Array([
|
|
4736
4826
|
r[0],
|
|
4737
4827
|
n[0],
|
|
@@ -4745,13 +4835,13 @@ function kr(s, t, e) {
|
|
|
4745
4835
|
n[2],
|
|
4746
4836
|
i[2],
|
|
4747
4837
|
0,
|
|
4748
|
-
-
|
|
4749
|
-
-
|
|
4750
|
-
-
|
|
4838
|
+
-ri(r, s),
|
|
4839
|
+
-ri(n, s),
|
|
4840
|
+
-ri(i, s),
|
|
4751
4841
|
1
|
|
4752
4842
|
]);
|
|
4753
4843
|
}
|
|
4754
|
-
function
|
|
4844
|
+
function Hr(s, t = Math.PI / 4) {
|
|
4755
4845
|
const r = 1 / Math.tan(t / 2);
|
|
4756
4846
|
return new Float32Array([
|
|
4757
4847
|
r * s,
|
|
@@ -4772,21 +4862,21 @@ function Xr(s, t = Math.PI / 4) {
|
|
|
4772
4862
|
0
|
|
4773
4863
|
]);
|
|
4774
4864
|
}
|
|
4775
|
-
function
|
|
4865
|
+
function ji(s) {
|
|
4776
4866
|
const t = Math.sqrt(s[0] * s[0] + s[1] * s[1] + s[2] * s[2]);
|
|
4777
4867
|
return [s[0] / t, s[1] / t, s[2] / t];
|
|
4778
4868
|
}
|
|
4779
|
-
function
|
|
4869
|
+
function qi(s, t) {
|
|
4780
4870
|
return [
|
|
4781
4871
|
s[1] * t[2] - s[2] * t[1],
|
|
4782
4872
|
s[2] * t[0] - s[0] * t[2],
|
|
4783
4873
|
s[0] * t[1] - s[1] * t[0]
|
|
4784
4874
|
];
|
|
4785
4875
|
}
|
|
4786
|
-
function
|
|
4876
|
+
function ri(s, t) {
|
|
4787
4877
|
return s[0] * t[0] + s[1] * t[1] + s[2] * t[2];
|
|
4788
4878
|
}
|
|
4789
|
-
function
|
|
4879
|
+
function Gr(s, t) {
|
|
4790
4880
|
const e = new Float32Array(16);
|
|
4791
4881
|
for (let i = 0; i < 4; i++)
|
|
4792
4882
|
for (let r = 0; r < 4; r++) {
|
|
@@ -4797,7 +4887,7 @@ function Ur(s, t) {
|
|
|
4797
4887
|
}
|
|
4798
4888
|
return e;
|
|
4799
4889
|
}
|
|
4800
|
-
const
|
|
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) => {
|
|
4801
4891
|
if (typeof btoa == "function") {
|
|
4802
4892
|
let t = "";
|
|
4803
4893
|
for (let e = 0; e < s.length; e++) t += String.fromCharCode(s[e]);
|
|
@@ -4805,94 +4895,94 @@ const si = 1481005640, Hi = 1, Zi = 1313821514, $i = 5130562, Et = "$hzfxAsset",
|
|
|
4805
4895
|
}
|
|
4806
4896
|
return Buffer.from(s).toString("base64");
|
|
4807
4897
|
};
|
|
4808
|
-
function
|
|
4809
|
-
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));
|
|
4810
4900
|
return { mime: i, bytes: a };
|
|
4811
4901
|
}
|
|
4812
|
-
function
|
|
4902
|
+
function Zi(s) {
|
|
4813
4903
|
return (4 - s % 4) % 4;
|
|
4814
4904
|
}
|
|
4815
|
-
async function
|
|
4905
|
+
async function Or(s, t = {}) {
|
|
4816
4906
|
const { textureFormat: e = "keep", quality: i = 0.85 } = t, r = [], n = [];
|
|
4817
4907
|
let a = 0;
|
|
4818
|
-
const o = (
|
|
4819
|
-
const
|
|
4820
|
-
r.push({ offset:
|
|
4821
|
-
const
|
|
4822
|
-
return
|
|
4823
|
-
},
|
|
4824
|
-
for (const
|
|
4825
|
-
const
|
|
4826
|
-
if (typeof
|
|
4827
|
-
let { mime:
|
|
4828
|
-
if (
|
|
4908
|
+
const o = (F, G, H) => {
|
|
4909
|
+
const se = a, ne = F.length;
|
|
4910
|
+
r.push({ offset: se, length: ne, mime: G, kind: H }), n.push(F), 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 F of s.systems || []) {
|
|
4915
|
+
const G = { ...F };
|
|
4916
|
+
if (typeof G.textureImageData == "string" && G.textureImageData.startsWith("data:")) {
|
|
4917
|
+
let { mime: H, bytes: se } = Vr(G.textureImageData);
|
|
4918
|
+
if (l && H !== "image/webp")
|
|
4829
4919
|
try {
|
|
4830
|
-
const
|
|
4831
|
-
|
|
4832
|
-
const
|
|
4833
|
-
|
|
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 j = await re.convertToBlob({ type: "image/webp", quality: i }), tt = new Uint8Array(await j.arrayBuffer());
|
|
4923
|
+
tt.length < se.length && (se = tt, H = "image/webp");
|
|
4834
4924
|
} catch {
|
|
4835
4925
|
}
|
|
4836
|
-
|
|
4926
|
+
G.textureImageData = { [At]: o(se, H, "texture") };
|
|
4837
4927
|
}
|
|
4838
|
-
if (typeof
|
|
4839
|
-
const
|
|
4840
|
-
|
|
4928
|
+
if (typeof G.glbModelData == "string" && G.glbModelData.length > 0) {
|
|
4929
|
+
const H = ts(G.glbModelData);
|
|
4930
|
+
G.glbModelData = { [At]: o(H, "model/gltf-binary", "glb") };
|
|
4841
4931
|
}
|
|
4842
|
-
|
|
4932
|
+
c.push(G);
|
|
4843
4933
|
}
|
|
4844
|
-
const d = { ...s, systems:
|
|
4934
|
+
const d = { ...s, systems: c, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)), b = Zi(S.length), h = new Uint8Array(a);
|
|
4845
4935
|
let v = 0;
|
|
4846
|
-
for (const
|
|
4847
|
-
|
|
4848
|
-
const
|
|
4936
|
+
for (const F of n)
|
|
4937
|
+
h.set(F, v), v += F.length;
|
|
4938
|
+
const C = S.length + b, z = 20 + C + 8 + a, D = new ArrayBuffer(z), _ = new DataView(D), Z = new Uint8Array(D);
|
|
4849
4939
|
let T = 0;
|
|
4850
|
-
_.setUint32(T,
|
|
4851
|
-
for (let
|
|
4852
|
-
return _.setUint32(T, a, !0), T += 4, _.setUint32(T,
|
|
4940
|
+
_.setUint32(T, ai, !0), T += 4, _.setUint32(T, Ki, !0), T += 4, _.setUint32(T, z, !0), T += 4, _.setUint32(T, C, !0), T += 4, _.setUint32(T, Qi, !0), T += 4, Z.set(S, T), T += S.length;
|
|
4941
|
+
for (let F = 0; F < b; F++) Z[T++] = 32;
|
|
4942
|
+
return _.setUint32(T, a, !0), T += 4, _.setUint32(T, es, !0), T += 4, Z.set(h, T), T += a, D;
|
|
4853
4943
|
}
|
|
4854
|
-
function
|
|
4855
|
-
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) ===
|
|
4944
|
+
function is(s) {
|
|
4945
|
+
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === ai;
|
|
4856
4946
|
}
|
|
4857
|
-
function
|
|
4947
|
+
function ss(s) {
|
|
4858
4948
|
const t = new DataView(s);
|
|
4859
|
-
if (t.getUint32(0, !0) !==
|
|
4949
|
+
if (t.getUint32(0, !0) !== ai) throw new Error("[unpackHZFX] bad magic — not an .hzfx file");
|
|
4860
4950
|
const e = t.getUint32(4, !0);
|
|
4861
|
-
if (e !==
|
|
4951
|
+
if (e !== Ki) throw new Error(`[unpackHZFX] unsupported version ${e}`);
|
|
4862
4952
|
let i = 12, r = null, n = -1;
|
|
4863
4953
|
const a = new Uint8Array(s);
|
|
4864
4954
|
for (; i + 8 <= s.byteLength; ) {
|
|
4865
|
-
const
|
|
4955
|
+
const b = t.getUint32(i, !0);
|
|
4866
4956
|
i += 4;
|
|
4867
|
-
const
|
|
4868
|
-
i += 4,
|
|
4957
|
+
const h = t.getUint32(i, !0);
|
|
4958
|
+
i += 4, h === Qi ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + b))) : h === es && (n = i), i += b;
|
|
4869
4959
|
}
|
|
4870
4960
|
if (!r) throw new Error("[unpackHZFX] missing JSON chunk");
|
|
4871
|
-
const o = r.assets || [],
|
|
4872
|
-
const
|
|
4873
|
-
return !
|
|
4874
|
-
},
|
|
4875
|
-
const
|
|
4876
|
-
if (
|
|
4877
|
-
const v =
|
|
4878
|
-
|
|
4961
|
+
const o = r.assets || [], l = (b) => {
|
|
4962
|
+
const h = o[b];
|
|
4963
|
+
return !h || n < 0 ? null : { ...h, bytes: a.subarray(n + h.offset, n + h.offset + h.length) };
|
|
4964
|
+
}, c = (b) => b && typeof b == "object" && typeof b[At] == "number", d = (r.systems || []).map((b) => {
|
|
4965
|
+
const h = { ...b };
|
|
4966
|
+
if (c(h.textureImageData)) {
|
|
4967
|
+
const v = l(h.textureImageData[At]);
|
|
4968
|
+
h.textureImageData = v ? `data:${v.mime};base64,${Hi(v.bytes)}` : void 0;
|
|
4879
4969
|
}
|
|
4880
|
-
if (
|
|
4881
|
-
const v =
|
|
4882
|
-
|
|
4970
|
+
if (c(h.glbModelData)) {
|
|
4971
|
+
const v = l(h.glbModelData[At]);
|
|
4972
|
+
h.glbModelData = v ? Hi(v.bytes) : void 0;
|
|
4883
4973
|
}
|
|
4884
|
-
return
|
|
4974
|
+
return h;
|
|
4885
4975
|
}), S = { ...r, systems: d };
|
|
4886
4976
|
return delete S.assets, S;
|
|
4887
4977
|
}
|
|
4888
|
-
function
|
|
4978
|
+
function Lr(s) {
|
|
4889
4979
|
const t = new Uint8Array(s);
|
|
4890
4980
|
let e = "";
|
|
4891
4981
|
for (let i = 0; i < t.byteLength; i++)
|
|
4892
4982
|
e += String.fromCharCode(t[i]);
|
|
4893
4983
|
return btoa(e);
|
|
4894
4984
|
}
|
|
4895
|
-
function
|
|
4985
|
+
function kr(s) {
|
|
4896
4986
|
return {
|
|
4897
4987
|
name: s.name,
|
|
4898
4988
|
id: s.id,
|
|
@@ -5078,7 +5168,7 @@ function Gr(s) {
|
|
|
5078
5168
|
displayUnit: s.displayUnit || "m"
|
|
5079
5169
|
};
|
|
5080
5170
|
}
|
|
5081
|
-
async function
|
|
5171
|
+
async function Zr(s, t, e = "hzfx") {
|
|
5082
5172
|
if (!s || !s.particleSystems || s.particleSystems.length === 0) {
|
|
5083
5173
|
alert("No particle systems to save.");
|
|
5084
5174
|
return;
|
|
@@ -5088,11 +5178,11 @@ async function Nr(s, t, e = "hzfx") {
|
|
|
5088
5178
|
version: "1.0",
|
|
5089
5179
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5090
5180
|
systems: s.particleSystems.map(({ config: d, system: S }) => ({
|
|
5091
|
-
...
|
|
5181
|
+
...kr(d),
|
|
5092
5182
|
// single source of truth for config fields
|
|
5093
5183
|
// Binary assets embedded so replaceSystems() can restore them
|
|
5094
5184
|
textureImageData: d.textureEnabled && !d.glbModelEnabled && d.textureImageData ? d.textureImageData : void 0,
|
|
5095
|
-
glbModelData: d.glbModelEnabled && S.glbRawArrayBuffer ?
|
|
5185
|
+
glbModelData: d.glbModelEnabled && S.glbRawArrayBuffer ? Lr(S.glbRawArrayBuffer) : void 0
|
|
5096
5186
|
})),
|
|
5097
5187
|
activeSystemIndex: s.activeSystemIndex,
|
|
5098
5188
|
loop: s.loop || !1
|
|
@@ -5100,7 +5190,7 @@ async function Nr(s, t, e = "hzfx") {
|
|
|
5100
5190
|
}, r = e === "json" ? "json" : "hzfx";
|
|
5101
5191
|
let n;
|
|
5102
5192
|
if (r === "hzfx") {
|
|
5103
|
-
const d = await
|
|
5193
|
+
const d = await Or(i, { textureFormat: "webp" });
|
|
5104
5194
|
n = new Blob([d], { type: "application/octet-stream" });
|
|
5105
5195
|
} else
|
|
5106
5196
|
n = new Blob([JSON.stringify(i, null, 2)], { type: "application/json" });
|
|
@@ -5111,13 +5201,13 @@ async function Nr(s, t, e = "hzfx") {
|
|
|
5111
5201
|
const d = /* @__PURE__ */ new Date();
|
|
5112
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")}`}`;
|
|
5113
5203
|
}
|
|
5114
|
-
const o = `${a}.${r}`,
|
|
5115
|
-
|
|
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);
|
|
5116
5206
|
} catch (i) {
|
|
5117
5207
|
console.error("Error saving scene:", i), alert("Error saving scene. See console for details.");
|
|
5118
5208
|
}
|
|
5119
5209
|
}
|
|
5120
|
-
function
|
|
5210
|
+
function Wr(s) {
|
|
5121
5211
|
return new Promise((t, e) => {
|
|
5122
5212
|
try {
|
|
5123
5213
|
const i = s.target.files[0];
|
|
@@ -5130,7 +5220,7 @@ function Yr(s) {
|
|
|
5130
5220
|
try {
|
|
5131
5221
|
const a = n.target.result;
|
|
5132
5222
|
let o;
|
|
5133
|
-
if (
|
|
5223
|
+
if (is(a) ? o = ss(a) : o = JSON.parse(new TextDecoder().decode(a)), !Array.isArray(o.systems) || o.systems.length === 0)
|
|
5134
5224
|
throw new Error("No valid particle systems found in the file");
|
|
5135
5225
|
t({
|
|
5136
5226
|
systems: o.systems.slice(),
|
|
@@ -5148,7 +5238,7 @@ function Yr(s) {
|
|
|
5148
5238
|
}
|
|
5149
5239
|
});
|
|
5150
5240
|
}
|
|
5151
|
-
async function
|
|
5241
|
+
async function $r(s) {
|
|
5152
5242
|
if (!s || typeof s != "string")
|
|
5153
5243
|
throw new Error("[fetchPreset] url must be a non-empty string");
|
|
5154
5244
|
const t = await fetch(s);
|
|
@@ -5156,7 +5246,7 @@ async function jr(s) {
|
|
|
5156
5246
|
throw new Error(`[fetchPreset] HTTP ${t.status}: ${t.statusText}`);
|
|
5157
5247
|
const e = await t.arrayBuffer();
|
|
5158
5248
|
let i;
|
|
5159
|
-
if (
|
|
5249
|
+
if (is(e) ? i = ss(e) : i = JSON.parse(new TextDecoder().decode(e)), !Array.isArray(i.systems) || i.systems.length === 0)
|
|
5160
5250
|
throw new Error('[fetchPreset] Invalid preset: "systems" must be a non-empty array');
|
|
5161
5251
|
return {
|
|
5162
5252
|
version: i.version,
|
|
@@ -5164,7 +5254,7 @@ async function jr(s) {
|
|
|
5164
5254
|
activeSystemIndex: i.activeSystemIndex ?? 0
|
|
5165
5255
|
};
|
|
5166
5256
|
}
|
|
5167
|
-
const
|
|
5257
|
+
const Xr = (s) => `
|
|
5168
5258
|
@vertex fn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
|
|
5169
5259
|
var p = array<vec2f, 3>(vec2f(-1.0, -3.0), vec2f(-1.0, 1.0), vec2f(3.0, 1.0));
|
|
5170
5260
|
return vec4f(p[i], 0.0, 1.0);
|
|
@@ -5174,47 +5264,49 @@ const Dr = (s) => `
|
|
|
5174
5264
|
return textureLoad(src, vec2i(pos.xy), 0);
|
|
5175
5265
|
}
|
|
5176
5266
|
`;
|
|
5177
|
-
async function
|
|
5267
|
+
async function Jr(s, t = {}) {
|
|
5178
5268
|
const { getSceneDepth: e = null, autoRespawn: i = !0 } = t;
|
|
5179
5269
|
let r, n, a;
|
|
5180
5270
|
const o = !!(s && s.device && s.context);
|
|
5181
|
-
o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await
|
|
5182
|
-
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 Br(r), d = { layouts: {}, pipelines: {} };
|
|
5183
5273
|
function S(u) {
|
|
5184
5274
|
const f = u ? "ms" : "ss";
|
|
5185
5275
|
if (!d.pipelines[f]) {
|
|
5186
|
-
const
|
|
5276
|
+
const y = r.createShaderModule({ code: Xr(u) }), p = r.createBindGroupLayout({
|
|
5187
5277
|
entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: u } }]
|
|
5188
5278
|
});
|
|
5189
|
-
d.layouts[f] =
|
|
5190
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5191
|
-
vertex: { module:
|
|
5192
|
-
fragment: { module:
|
|
5279
|
+
d.layouts[f] = p, d.pipelines[f] = r.createRenderPipeline({
|
|
5280
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [p] }),
|
|
5281
|
+
vertex: { module: y, entryPoint: "vs" },
|
|
5282
|
+
fragment: { module: y, entryPoint: "fs", targets: [] },
|
|
5193
5283
|
primitive: { topology: "triangle-list" },
|
|
5194
5284
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !0, depthCompare: "always" }
|
|
5195
5285
|
});
|
|
5196
5286
|
}
|
|
5197
5287
|
return { pipeline: d.pipelines[f], layout: d.layouts[f] };
|
|
5198
5288
|
}
|
|
5199
|
-
const
|
|
5289
|
+
const b = {
|
|
5200
5290
|
bloomSourceTextures: {},
|
|
5201
5291
|
bloomCompositeTextures: {},
|
|
5202
5292
|
combinedTexture: null,
|
|
5203
|
-
getBloomSourceTexture(u, f,
|
|
5204
|
-
|
|
5205
|
-
|
|
5293
|
+
getBloomSourceTexture(u, f, y) {
|
|
5294
|
+
const p = u;
|
|
5295
|
+
return this.bloomSourceTextures[p] || (this.bloomSourceTextures[p] = r.createTexture({
|
|
5296
|
+
size: [f, y],
|
|
5206
5297
|
format: "rgba16float",
|
|
5207
5298
|
// HDR chain (see webgpu.js HDR_FORMAT) — avoids additive clip
|
|
5208
5299
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5209
|
-
})), this.bloomSourceTextures[
|
|
5300
|
+
})), this.bloomSourceTextures[p];
|
|
5210
5301
|
},
|
|
5211
|
-
getBloomCompositeTexture(u, f,
|
|
5212
|
-
|
|
5213
|
-
|
|
5302
|
+
getBloomCompositeTexture(u, f, y) {
|
|
5303
|
+
const p = u;
|
|
5304
|
+
return this.bloomCompositeTextures[p] || (this.bloomCompositeTextures[p] = r.createTexture({
|
|
5305
|
+
size: [f, y],
|
|
5214
5306
|
format: "rgba16float",
|
|
5215
5307
|
// HDR chain
|
|
5216
5308
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5217
|
-
})), this.bloomCompositeTextures[
|
|
5309
|
+
})), this.bloomCompositeTextures[p];
|
|
5218
5310
|
},
|
|
5219
5311
|
getCombinedTexture(u, f) {
|
|
5220
5312
|
return this.combinedTexture || (this.combinedTexture = r.createTexture({
|
|
@@ -5227,7 +5319,7 @@ async function qr(s, t = {}) {
|
|
|
5227
5319
|
resizeTextures() {
|
|
5228
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;
|
|
5229
5321
|
}
|
|
5230
|
-
},
|
|
5322
|
+
}, h = {
|
|
5231
5323
|
systemBindGroups: {},
|
|
5232
5324
|
systemBloomHorizontalBindGroups: {},
|
|
5233
5325
|
secondHorizontalBindGroups: {},
|
|
@@ -5243,323 +5335,333 @@ async function qr(s, t = {}) {
|
|
|
5243
5335
|
clear() {
|
|
5244
5336
|
this.systemBindGroups = {}, this.systemBloomHorizontalBindGroups = {}, this.secondHorizontalBindGroups = {}, this.systemBloomCompositeBindGroups = {}, this.combinedBloomCompositeBindGroups = {}, this.combinedInitialBindGroup = null, this.finalBindGroup = null, this.textureStates = {}, this.textureRefs = {};
|
|
5245
5337
|
}
|
|
5246
|
-
}, v = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }),
|
|
5247
|
-
|
|
5248
|
-
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 }), _ = r.createBuffer({ size: 64, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), Z = St(r, new Uint16Array([0, 1, 2, 0, 2, 3]), GPUBufferUsage.INDEX), T = {}, F = () => 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] = F());
|
|
5249
5341
|
};
|
|
5250
|
-
const
|
|
5251
|
-
function
|
|
5252
|
-
for (const f of
|
|
5342
|
+
const G = 4e4, H = new Float32Array(G * 8), se = new Float32Array(G * 4), ne = new Float32Array(G * 4), re = r.createBuffer({ size: G * 8 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), j = r.createBuffer({ size: G * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), tt = r.createBuffer({ size: G * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), xt = /* @__PURE__ */ new Map(), at = /* @__PURE__ */ new Map(), kt = 8, _e = [];
|
|
5343
|
+
function oi(u) {
|
|
5344
|
+
for (const f of _e) if (f.ids.has(u)) return f;
|
|
5253
5345
|
return null;
|
|
5254
5346
|
}
|
|
5255
|
-
function
|
|
5347
|
+
function rs(u, f) {
|
|
5256
5348
|
if (!u.pos) return;
|
|
5257
5349
|
u.hist.push({ t: f, x: u.pos[0], y: u.pos[1], z: u.pos[2] });
|
|
5258
|
-
const
|
|
5259
|
-
for (; u.hist.length > 2 && u.hist[0].t <
|
|
5260
|
-
}
|
|
5261
|
-
function
|
|
5262
|
-
const
|
|
5263
|
-
if (
|
|
5264
|
-
const
|
|
5265
|
-
return
|
|
5350
|
+
const y = f - kt;
|
|
5351
|
+
for (; u.hist.length > 2 && u.hist[0].t < y; ) u.hist.shift();
|
|
5352
|
+
}
|
|
5353
|
+
function li(u, f, y) {
|
|
5354
|
+
const p = u.hist;
|
|
5355
|
+
if (p.length === 0) {
|
|
5356
|
+
const w = u.pos;
|
|
5357
|
+
return w && (y[0] = w[0], y[1] = w[1], y[2] = w[2]), y;
|
|
5266
5358
|
}
|
|
5267
|
-
let
|
|
5268
|
-
if (f >=
|
|
5269
|
-
return
|
|
5270
|
-
if (f <=
|
|
5271
|
-
return
|
|
5272
|
-
for (let
|
|
5273
|
-
if (
|
|
5274
|
-
const P =
|
|
5275
|
-
return
|
|
5359
|
+
let g;
|
|
5360
|
+
if (f >= p[p.length - 1].t)
|
|
5361
|
+
return g = p[p.length - 1], y[0] = g.x, y[1] = g.y, y[2] = g.z, y;
|
|
5362
|
+
if (f <= p[0].t)
|
|
5363
|
+
return g = p[0], y[0] = g.x, y[1] = g.y, y[2] = g.z, y;
|
|
5364
|
+
for (let w = p.length - 1; w > 0; w--)
|
|
5365
|
+
if (p[w - 1].t <= f) {
|
|
5366
|
+
const P = p[w - 1], R = p[w], x = (f - P.t) / Math.max(1e-6, R.t - P.t);
|
|
5367
|
+
return y[0] = P.x + (R.x - P.x) * x, y[1] = P.y + (R.y - P.y) * x, y[2] = P.z + (R.z - P.z) * x, y;
|
|
5276
5368
|
}
|
|
5277
|
-
return
|
|
5369
|
+
return g = p[0], y[0] = g.x, y[1] = g.y, y[2] = g.z, y;
|
|
5278
5370
|
}
|
|
5279
|
-
const
|
|
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);
|
|
5280
5372
|
new Array(257), new Array(257), new Array(257);
|
|
5281
|
-
const
|
|
5282
|
-
function
|
|
5283
|
-
const f = u.emissionRotationX || 0,
|
|
5284
|
-
if (!f && !
|
|
5285
|
-
const
|
|
5373
|
+
const Ae = [0, 0, 0];
|
|
5374
|
+
function ns(u) {
|
|
5375
|
+
const f = u.emissionRotationX || 0, y = u.emissionRotationY || 0, p = u.emissionRotationZ || 0;
|
|
5376
|
+
if (!f && !y && !p) return null;
|
|
5377
|
+
const g = f * Math.PI / 180, w = y * Math.PI / 180, P = p * Math.PI / 180, R = Math.cos(g), x = Math.sin(g), B = Math.cos(w), m = Math.sin(w), M = Math.cos(P), E = Math.sin(P);
|
|
5286
5378
|
return [
|
|
5287
|
-
|
|
5288
|
-
x * m *
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
x * m *
|
|
5292
|
-
|
|
5379
|
+
B * M,
|
|
5380
|
+
x * m * M - R * E,
|
|
5381
|
+
R * m * M + x * E,
|
|
5382
|
+
B * E,
|
|
5383
|
+
x * m * E + R * M,
|
|
5384
|
+
R * m * E - x * M,
|
|
5293
5385
|
-m,
|
|
5294
|
-
x *
|
|
5295
|
-
|
|
5386
|
+
x * B,
|
|
5387
|
+
R * B
|
|
5296
5388
|
];
|
|
5297
5389
|
}
|
|
5298
|
-
function
|
|
5299
|
-
return
|
|
5390
|
+
function Ut(u, f, y, p, g) {
|
|
5391
|
+
return g[0] = u[0] * f + u[1] * y + u[2] * p, g[1] = u[3] * f + u[4] * y + u[5] * p, g[2] = u[6] * f + u[7] * y + u[8] * p, g;
|
|
5300
5392
|
}
|
|
5301
|
-
function
|
|
5302
|
-
let
|
|
5303
|
-
|
|
5304
|
-
const m =
|
|
5305
|
-
return P[0] =
|
|
5393
|
+
function as(u, f, y, p, g, w, P) {
|
|
5394
|
+
let R = u, x = f, B = y;
|
|
5395
|
+
p && (Ut(p, R, x, B, P), R = P[0], x = P[1], B = P[2]), R += w.emissionPositionX || 0, x += w.emissionPositionY || 0, B += w.emissionPositionZ || 0, g._simRotMatrix && (Ut(g._simRotMatrix, R, x, B, P), R = P[0], x = P[1], B = P[2]);
|
|
5396
|
+
const m = g._simPosition;
|
|
5397
|
+
return P[0] = R + (m ? m[0] : 0), P[1] = x + (m ? m[1] : 0), P[2] = B + (m ? m[2] : 0), P;
|
|
5306
5398
|
}
|
|
5307
|
-
function
|
|
5308
|
-
let P = u,
|
|
5309
|
-
return
|
|
5399
|
+
function os(u, f, y, p, g, w) {
|
|
5400
|
+
let P = u, R = f, x = y;
|
|
5401
|
+
return p && (Ut(p, P, R, x, w), P = w[0], R = w[1], x = w[2]), g._simRotMatrix && (Ut(g._simRotMatrix, P, R, x, w), P = w[0], R = w[1], x = w[2]), w[0] = P, w[1] = R, w[2] = x, w;
|
|
5310
5402
|
}
|
|
5311
|
-
function
|
|
5312
|
-
const
|
|
5313
|
-
let x = (u % 1 + 1) % 1 *
|
|
5314
|
-
return x <
|
|
5403
|
+
function jt(u, f, y, p, g) {
|
|
5404
|
+
const w = f * 2, P = y * 2, R = 2 * (w + P);
|
|
5405
|
+
let x = (u % 1 + 1) % 1 * R, B = 0, m = 0;
|
|
5406
|
+
return x < w ? (B = -f + x, m = y) : (x -= w) < P ? (B = f, m = y - x) : (x -= P) < w ? (B = f - x, m = -y) : (x -= w, B = -f, m = -y + x), p === "xz" ? (g[0] = B, g[1] = 0, g[2] = m) : (g[0] = B, g[1] = m, g[2] = 0), g;
|
|
5315
5407
|
}
|
|
5316
|
-
function
|
|
5317
|
-
const f = u.emissionShape,
|
|
5318
|
-
let
|
|
5319
|
-
const P =
|
|
5408
|
+
function ls(u) {
|
|
5409
|
+
const f = u.emissionShape, y = Math.max(1, Math.min(256, Math.floor(u.shapeStrokeSegments ?? 96)));
|
|
5410
|
+
let p = 0, g = !1, w = [0, 0, 1];
|
|
5411
|
+
const P = Ae;
|
|
5320
5412
|
if (f === "circle") {
|
|
5321
|
-
|
|
5322
|
-
const
|
|
5323
|
-
for (let x = 0; x <
|
|
5324
|
-
const
|
|
5325
|
-
|
|
5413
|
+
g = !0, p = Math.max(3, y), w = [0, 0, 1];
|
|
5414
|
+
const R = u.circleOuterRadius ?? 2;
|
|
5415
|
+
for (let x = 0; x < p; x++) {
|
|
5416
|
+
const B = x / p * pt;
|
|
5417
|
+
ae[x] = Math.cos(B) * R, oe[x] = Math.sin(B) * R, le[x] = 0;
|
|
5326
5418
|
}
|
|
5327
5419
|
} else if (f === "disc") {
|
|
5328
|
-
|
|
5329
|
-
const
|
|
5330
|
-
for (let x = 0; x <
|
|
5331
|
-
const
|
|
5332
|
-
|
|
5420
|
+
g = !0, p = Math.max(3, y), w = [0, 1, 0];
|
|
5421
|
+
const R = u.discRadius ?? 2;
|
|
5422
|
+
for (let x = 0; x < p; x++) {
|
|
5423
|
+
const B = x / p * pt;
|
|
5424
|
+
ae[x] = Math.cos(B) * R, oe[x] = 0, le[x] = Math.sin(B) * R;
|
|
5333
5425
|
}
|
|
5334
5426
|
} else if (f === "annulus") {
|
|
5335
|
-
|
|
5336
|
-
const
|
|
5337
|
-
for (let m = 0; m <
|
|
5338
|
-
const
|
|
5339
|
-
|
|
5427
|
+
g = !0, p = Math.max(3, y), w = [0, 1, 0];
|
|
5428
|
+
const R = u.annulusInnerRadius ?? 1, x = u.annulusOuterRadius ?? 2, B = R + (x - R) * 0.5;
|
|
5429
|
+
for (let m = 0; m < p; m++) {
|
|
5430
|
+
const M = m / p * pt;
|
|
5431
|
+
ae[m] = Math.cos(M) * B, oe[m] = 0, le[m] = Math.sin(M) * B;
|
|
5340
5432
|
}
|
|
5341
5433
|
} else if (f === "arc") {
|
|
5342
|
-
|
|
5343
|
-
const
|
|
5344
|
-
for (let
|
|
5345
|
-
const
|
|
5346
|
-
|
|
5434
|
+
g = !1, p = Math.max(2, y + 1), w = [0, 0, 1];
|
|
5435
|
+
const R = u.arcInnerRadius ?? 0, x = u.arcOuterRadius ?? 2, B = R > 0 ? R + (x - R) * 0.5 : x, m = (u.arcStartAngle ?? 0) * Math.PI / 180, M = (u.arcEndAngle ?? 180) * Math.PI / 180;
|
|
5436
|
+
for (let E = 0; E < p; E++) {
|
|
5437
|
+
const q = p > 1 ? E / (p - 1) : 0, X = m + (M - m) * q;
|
|
5438
|
+
ae[E] = Math.cos(X) * B, oe[E] = Math.sin(X) * B, le[E] = 0;
|
|
5347
5439
|
}
|
|
5348
5440
|
} else if (f === "square") {
|
|
5349
|
-
|
|
5350
|
-
const
|
|
5351
|
-
for (let x = 0; x <
|
|
5352
|
-
|
|
5441
|
+
g = !0, p = Math.max(4, y), w = [0, 0, 1];
|
|
5442
|
+
const R = u.squareSize ?? 2;
|
|
5443
|
+
for (let x = 0; x < p; x++)
|
|
5444
|
+
jt(x / p, R, R, "xy", P), ae[x] = P[0], oe[x] = P[1], le[x] = P[2];
|
|
5353
5445
|
} else if (f === "rectangle") {
|
|
5354
|
-
|
|
5355
|
-
const
|
|
5356
|
-
for (let
|
|
5357
|
-
|
|
5446
|
+
g = !0, p = Math.max(4, y), w = [0, 0, 1];
|
|
5447
|
+
const R = (u.rectangleWidth ?? 2) * 0.5, x = (u.rectangleHeight ?? 2) * 0.5;
|
|
5448
|
+
for (let B = 0; B < p; B++)
|
|
5449
|
+
jt(B / p, R, x, "xy", P), ae[B] = P[0], oe[B] = P[1], le[B] = P[2];
|
|
5358
5450
|
} else if (f === "plain") {
|
|
5359
|
-
|
|
5360
|
-
const
|
|
5361
|
-
for (let
|
|
5362
|
-
|
|
5451
|
+
g = !0, p = Math.max(4, y), w = [0, 1, 0];
|
|
5452
|
+
const R = (u.planeWidth ?? 2) * 0.5, x = (u.planeDepth ?? 2) * 0.5;
|
|
5453
|
+
for (let B = 0; B < p; B++)
|
|
5454
|
+
jt(B / p, R, x, "xz", P), ae[B] = P[0], oe[B] = P[1], le[B] = P[2];
|
|
5363
5455
|
} else if (f === "line") {
|
|
5364
|
-
|
|
5365
|
-
const
|
|
5366
|
-
for (let x = 0; x <
|
|
5367
|
-
const
|
|
5368
|
-
|
|
5456
|
+
g = !1, p = Math.max(2, y + 1), w = [0, 0, 1];
|
|
5457
|
+
const R = u.lineLength ?? 4;
|
|
5458
|
+
for (let x = 0; x < p; x++) {
|
|
5459
|
+
const B = p > 1 ? x / (p - 1) : 0;
|
|
5460
|
+
ae[x] = 0, oe[x] = (B - 0.5) * R, le[x] = 0;
|
|
5369
5461
|
}
|
|
5370
5462
|
} else if (f === "polygon") {
|
|
5371
|
-
|
|
5372
|
-
const
|
|
5373
|
-
for (let
|
|
5374
|
-
const m =
|
|
5375
|
-
|
|
5463
|
+
g = !0, p = Math.max(3, y), w = [0, 0, 1];
|
|
5464
|
+
const R = Math.max(3, Math.floor(u.polygonSides ?? 6)), x = u.polygonRadius ?? 2;
|
|
5465
|
+
for (let B = 0; B < p; B++) {
|
|
5466
|
+
const m = B / p * R, M = Math.floor(m), E = m - M, q = M / R * pt, X = (M + 1) / R * pt, O = Math.cos(q) * x, U = Math.sin(q) * x, be = Math.cos(X) * x, Se = Math.sin(X) * x;
|
|
5467
|
+
ae[B] = O + (be - O) * E, oe[B] = U + (Se - U) * E, le[B] = 0;
|
|
5376
5468
|
}
|
|
5377
5469
|
} else
|
|
5378
|
-
|
|
5379
|
-
return { count:
|
|
5380
|
-
}
|
|
5381
|
-
function
|
|
5382
|
-
if (!
|
|
5383
|
-
const { count:
|
|
5384
|
-
if (
|
|
5385
|
-
const P =
|
|
5470
|
+
p = 0;
|
|
5471
|
+
return { count: p, closed: g, planeNormal: w };
|
|
5472
|
+
}
|
|
5473
|
+
function cs(u, f, y) {
|
|
5474
|
+
if (!y.shapeStrokeEnabled || y.hidden) return u;
|
|
5475
|
+
const { count: p, closed: g, planeNormal: w } = ls(y);
|
|
5476
|
+
if (p < 2) return u;
|
|
5477
|
+
const P = ns(y), R = Math.max(1e-4, y.shapeStrokeWidth ?? 0.08), x = Math.max(0, y.opacity ?? 1);
|
|
5386
5478
|
if (x <= 0) return u;
|
|
5387
|
-
|
|
5388
|
-
let
|
|
5389
|
-
const m =
|
|
5390
|
-
for (let
|
|
5391
|
-
|
|
5392
|
-
const
|
|
5393
|
-
if (
|
|
5394
|
-
const
|
|
5395
|
-
for (let
|
|
5396
|
-
const
|
|
5397
|
-
let
|
|
5398
|
-
|
|
5479
|
+
os(w[0], w[1], w[2], P, f, Ae);
|
|
5480
|
+
let B = Math.hypot(Ae[0], Ae[1], Ae[2]) || 1;
|
|
5481
|
+
const m = Ae[0] / B, M = Ae[1] / B, E = Ae[2] / B;
|
|
5482
|
+
for (let I = 0; I < p; I++)
|
|
5483
|
+
as(ae[I], oe[I], le[I], P, f, y, Ae), ae[I] = Ae[0], oe[I] = Ae[1], le[I] = Ae[2];
|
|
5484
|
+
const q = y.shapeStrokeShape ?? "straight";
|
|
5485
|
+
if (q !== "straight") {
|
|
5486
|
+
const I = y.shapeStrokeAmplitude ?? 0.08, K = y.shapeStrokeFrequency ?? 10, Ie = y.shapeStrokeSpeed ?? 0;
|
|
5487
|
+
for (let W = 0; W < p; W++) {
|
|
5488
|
+
const fe = W === 0 ? g ? p - 1 : 0 : W - 1, ee = W === p - 1 ? g ? 0 : p - 1 : W + 1, me = ae[ee] - ae[fe], $ = oe[ee] - oe[fe], Q = le[ee] - le[fe], J = M * Q - E * $, te = E * me - m * Q, ce = m * $ - M * me, ye = Math.hypot(J, te, ce) || 1, ve = J / ye, ue = te / ye, He = ce / ye, Me = g ? W / p : W / Math.max(1, p - 1), ge = pt * K * Me + Ie * Ve;
|
|
5489
|
+
let pe = 0, he = 0;
|
|
5490
|
+
q === "zigzag" ? pe = I * Math.sign(Math.sin(ge) || 1) : q === "sine" ? pe = I * Math.sin(ge) : q === "spiral" && (pe = I * Math.sin(ge), he = I * Math.cos(ge)), ae[W] += ve * pe + m * he, oe[W] += ue * pe + M * he, le[W] += He * pe + E * he;
|
|
5399
5491
|
}
|
|
5400
5492
|
}
|
|
5401
|
-
const
|
|
5402
|
-
let
|
|
5403
|
-
for (let
|
|
5404
|
-
const
|
|
5405
|
-
|
|
5493
|
+
const X = g ? p : p - 1, O = y.bloomIntensity || 1, U = y.startColor ?? y.particleColor ?? [1, 1, 1], be = y.endColor ?? U, Se = y.particleColor ?? U, Oe = y.randomColorEnabled && Array.isArray(y.randomColors) && y.randomColors.length > 0 ? y.randomColors[0] : null, xe = R * 0.5, _t = Math.max(R * 4, 1e-4), je = (y.shapeStrokeSpeed ?? 0) * Ve;
|
|
5494
|
+
let it = 0;
|
|
5495
|
+
for (let I = 0; I < X; I++) {
|
|
5496
|
+
const K = g ? (I + 1) % p : I + 1;
|
|
5497
|
+
it += Math.hypot(ae[K] - ae[I], oe[K] - oe[I], le[K] - le[I]);
|
|
5406
5498
|
}
|
|
5407
|
-
const
|
|
5408
|
-
let
|
|
5409
|
-
for (let
|
|
5410
|
-
const
|
|
5411
|
-
let
|
|
5412
|
-
const me = Math.hypot(
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5499
|
+
const Qt = g ? Math.max(1, Math.round(it / _t)) : Math.max(it / _t, 1e-6), Mt = it > 1e-6 ? Qt / it : 0;
|
|
5500
|
+
let qe = 0, wt = !1, ut = 0, Ue = 0, dt = 0;
|
|
5501
|
+
for (let I = 0; I < p; I++) {
|
|
5502
|
+
const K = I === 0 ? g ? p - 1 : 0 : I - 1, Ie = I === p - 1 ? g ? 0 : p - 1 : I + 1;
|
|
5503
|
+
let W = ae[Ie] - ae[K], fe = oe[Ie] - oe[K], ee = le[Ie] - le[K];
|
|
5504
|
+
const me = Math.hypot(W, fe, ee) || 1;
|
|
5505
|
+
W /= me, fe /= me, ee /= me;
|
|
5506
|
+
let $ = M * ee - E * fe, Q = E * W - m * ee, J = m * fe - M * W, te = Math.hypot($, Q, J);
|
|
5507
|
+
if (te < 1e-5) {
|
|
5508
|
+
const ce = V.right[0], ye = V.right[1], ve = V.right[2], ue = ce * W + ye * fe + ve * ee;
|
|
5509
|
+
$ = ce - ue * W, Q = ye - ue * fe, J = ve - ue * ee, te = Math.hypot($, Q, J);
|
|
5510
|
+
}
|
|
5511
|
+
if (te < 1e-5) {
|
|
5512
|
+
const ce = V.up[0], ye = V.up[1], ve = V.up[2], ue = ce * W + ye * fe + ve * ee;
|
|
5513
|
+
$ = ce - ue * W, Q = ye - ue * fe, J = ve - ue * ee, te = Math.hypot($, Q, J) || 1;
|
|
5419
5514
|
}
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5515
|
+
$ /= te, Q /= te, J /= te, wt && ut * $ + Ue * Q + dt * J < 0 && ($ = -$, Q = -Q, J = -J), Xt[I] = $, Nt[I] = Q, Yt[I] = J, ut = $, Ue = Q, dt = J, wt = !0;
|
|
5516
|
+
}
|
|
5517
|
+
for (let I = 0; I < X && !(u + 54 > Ce.length); I++) {
|
|
5518
|
+
const K = g ? (I + 1) % p : I + 1, Ie = ae[I], W = oe[I], fe = le[I], ee = ae[K], me = oe[K], $ = le[K];
|
|
5519
|
+
let Q = ee - Ie, J = me - W, te = $ - fe;
|
|
5520
|
+
const ce = Math.hypot(Q, J, te) || 1;
|
|
5521
|
+
Q /= ce, J /= ce, te /= ce;
|
|
5522
|
+
const ye = g ? I / p : I / Math.max(1, p - 1), ve = g ? K / p : K / Math.max(1, p - 1), ue = qe * Mt + je, He = (qe + ce) * Mt + je;
|
|
5523
|
+
let Me, ge, pe, he, we, Re;
|
|
5524
|
+
Oe ? (Me = he = Oe[0], ge = we = Oe[1], pe = Re = Oe[2]) : y.colorTransitionEnabled ? (Me = U[0] + (be[0] - U[0]) * ye, ge = U[1] + (be[1] - U[1]) * ye, pe = U[2] + (be[2] - U[2]) * ye, he = U[0] + (be[0] - U[0]) * ve, we = U[1] + (be[1] - U[1]) * ve, Re = U[2] + (be[2] - U[2]) * ve) : (Me = he = Se[0], ge = we = Se[1], pe = Re = Se[2]), Me = Math.min(1, Me * O), ge = Math.min(1, ge * O), pe = Math.min(1, pe * O), he = Math.min(1, he * O), we = Math.min(1, we * O), Re = Math.min(1, Re * O);
|
|
5525
|
+
const Rt = Xt[I], gt = Nt[I], Le = Yt[I], ke = Xt[K], ze = Nt[K], Bt = Yt[K], Ot = Ie + Rt * xe, Lt = W + gt * xe, Tt = fe + Le * xe, Be = Ie - Rt * xe, Te = W - gt * xe, Ee = fe - Le * xe, st = ee + ke * xe, rt = me + ze * xe, Et = $ + Bt * xe, Ze = ee - ke * xe, We = me - ze * xe, $e = $ - Bt * xe, ft = (A, k, de, N, L, Y, ie, Je, Ke) => {
|
|
5526
|
+
Ce[u++] = A, Ce[u++] = k, Ce[u++] = de, Ce[u++] = N, Ce[u++] = L, Ce[u++] = Y, Ce[u++] = ie, Ce[u++] = Je, Ce[u++] = Ke;
|
|
5426
5527
|
};
|
|
5427
|
-
|
|
5528
|
+
ft(Ot, Lt, Tt, Me, ge, pe, x, ue, 0), ft(Be, Te, Ee, Me, ge, pe, x, ue, 1), ft(st, rt, Et, he, we, Re, x, He, 0), ft(Be, Te, Ee, Me, ge, pe, x, ue, 1), ft(Ze, We, $e, he, we, Re, x, He, 1), ft(st, rt, Et, he, we, Re, x, He, 0), qe += ce;
|
|
5428
5529
|
}
|
|
5429
5530
|
return u;
|
|
5430
5531
|
}
|
|
5431
|
-
const
|
|
5432
|
-
function
|
|
5433
|
-
|
|
5434
|
-
let u = 0, f = 0,
|
|
5435
|
-
|
|
5436
|
-
for (const { system:
|
|
5437
|
-
if (
|
|
5438
|
-
if (
|
|
5439
|
-
|
|
5440
|
-
const P =
|
|
5441
|
-
if (P &&
|
|
5442
|
-
const
|
|
5443
|
-
for (let
|
|
5444
|
-
const
|
|
5445
|
-
let
|
|
5446
|
-
const
|
|
5447
|
-
if (
|
|
5448
|
-
const
|
|
5449
|
-
if (
|
|
5450
|
-
const
|
|
5451
|
-
|
|
5532
|
+
const us = 0.41421356;
|
|
5533
|
+
function ds() {
|
|
5534
|
+
xt.clear(), at.clear();
|
|
5535
|
+
let u = 0, f = 0, y = 0;
|
|
5536
|
+
V.position[0], V.position[1], V.position[2];
|
|
5537
|
+
for (const { system: p, config: g } of c.particleSystems) {
|
|
5538
|
+
if (g.hidden) continue;
|
|
5539
|
+
if (g.emissionTrailEnabled && !g.glbModelEnabled) {
|
|
5540
|
+
p.readbackAndProcessParticles();
|
|
5541
|
+
const P = p.particleData, R = p.particleVelocities, x = p.activeParticles;
|
|
5542
|
+
if (P && R && x > 0) {
|
|
5543
|
+
const B = g.emissionTrailMode === "particles", m = u, M = g.emissionTrailDuration ?? 1, E = g.opacity ?? 1, q = g.particleSize ?? 0.5, X = g.bloomIntensity || 1, O = Math.max(1, Math.min(64, g.emissionTrailSegments ?? 8)), U = g.emissionTrailShape || "straight", be = g.followSystemTranslation ?? !0, Se = p._simPosition, Oe = be && Se ? Se[0] : 0, xe = be && Se ? Se[1] : 0, _t = be && Se ? Se[2] : 0, je = p._simVelocity, it = je ? je[0] : 0, Qt = je ? je[1] : 0, Mt = je ? je[2] : 0, qe = oi(g.id), wt = !!(be && qe && qe.hist && qe.hist.length > 1);
|
|
5544
|
+
for (let ut = 0; ut < x; ut++) {
|
|
5545
|
+
const Ue = ut * 8, dt = P[Ue], I = P[Ue + 1], K = P[Ue + 2], Ie = dt + Oe, W = I + xe, fe = K + _t;
|
|
5546
|
+
let ee = P[Ue + 3], me = P[Ue + 4], $ = P[Ue + 5];
|
|
5547
|
+
const Q = P[Ue + 6], J = P[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, me = A[1] + (k[1] - A[1]) * te, $ = A[2] + (k[2] - A[2]) * te;
|
|
5452
5553
|
}
|
|
5453
|
-
|
|
5454
|
-
let
|
|
5455
|
-
if (
|
|
5456
|
-
const
|
|
5457
|
-
|
|
5554
|
+
ee = Math.min(1, ee * X), me = Math.min(1, me * X), $ = Math.min(1, $ * X);
|
|
5555
|
+
let ce = q;
|
|
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;
|
|
5458
5559
|
}
|
|
5459
|
-
if (
|
|
5460
|
-
const
|
|
5461
|
-
|
|
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);
|
|
5462
5563
|
}
|
|
5463
|
-
if (
|
|
5464
|
-
const
|
|
5465
|
-
|
|
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);
|
|
5466
5567
|
}
|
|
5467
|
-
if (
|
|
5468
|
-
const
|
|
5469
|
-
let
|
|
5470
|
-
if (
|
|
5471
|
-
const
|
|
5472
|
-
if (
|
|
5473
|
-
const
|
|
5474
|
-
let
|
|
5568
|
+
if (ce <= 0 || te > 0.9) continue;
|
|
5569
|
+
const ye = Math.min((0.9 - te) * (1 / 0.2), 1), ve = 0.75 * ce * us * ye;
|
|
5570
|
+
let ue = E;
|
|
5571
|
+
if (g.fadeEnabled && (ue *= Math.max(0, 1 - te)), ue *= ye, ue < 0.01) continue;
|
|
5572
|
+
const He = ut * 4, Me = R[He], ge = R[He + 1], pe = R[He + 2], he = Me + it, we = ge + Qt, Re = pe + Mt, Rt = Math.sqrt(he * he + we * we + Re * Re);
|
|
5573
|
+
if (Rt < 1e-3) continue;
|
|
5574
|
+
const gt = 1 / Rt, Le = he * gt, ke = we * gt, ze = Re * gt, Bt = V.right[0], Ot = V.right[1], Lt = V.right[2];
|
|
5575
|
+
let Tt = Bt * Le + Ot * ke + Lt * ze, Be = Bt - Tt * Le, Te = Ot - Tt * ke, Ee = Lt - Tt * ze, st = Math.sqrt(Be * Be + Te * Te + Ee * Ee);
|
|
5475
5576
|
if (st < 0.2) {
|
|
5476
|
-
const
|
|
5477
|
-
|
|
5577
|
+
const A = V.up[0], k = V.up[1], de = V.up[2], N = A * Le + k * ke + de * ze;
|
|
5578
|
+
Be = A - N * Le, Te = k - N * ke, Ee = de - N * ze, st = Math.sqrt(Be * Be + Te * Te + Ee * Ee) || 1;
|
|
5478
5579
|
}
|
|
5479
|
-
|
|
5480
|
-
const
|
|
5481
|
-
if (
|
|
5482
|
-
const
|
|
5483
|
-
if (
|
|
5484
|
-
const
|
|
5485
|
-
for (let
|
|
5486
|
-
const
|
|
5487
|
-
|
|
5580
|
+
Be /= st, Te /= st, Ee /= st;
|
|
5581
|
+
const rt = Math.min(M, Q);
|
|
5582
|
+
if (rt < 1e-3) continue;
|
|
5583
|
+
const Et = g.gravityEnabled && g.gravityStrength || 0, Ze = _s, We = Ms, $e = ws;
|
|
5584
|
+
if (g.orientToDirection && g.burstMode && wt) {
|
|
5585
|
+
const A = p._emitSimRotY || 0, k = Rs, de = Bs, N = Ts;
|
|
5586
|
+
for (let L = 0; L <= O; L++) {
|
|
5587
|
+
const Y = li(qe, Ve - L / O * rt, Pi);
|
|
5588
|
+
k[L] = Y[0], de[L] = Y[1], N[L] = Y[2];
|
|
5488
5589
|
}
|
|
5489
|
-
for (let
|
|
5490
|
-
const
|
|
5491
|
-
let
|
|
5492
|
-
const
|
|
5493
|
-
|
|
5590
|
+
for (let L = 0; L <= O; L++) {
|
|
5591
|
+
const Y = L > 0 ? L - 1 : 0, ie = L < O ? L + 1 : O;
|
|
5592
|
+
let Je = k[Y] - k[ie], Ke = N[Y] - N[ie];
|
|
5593
|
+
const nt = (Math.hypot(Je, Ke) > 1e-5 ? Math.atan2(Je, Ke) : Math.atan2(it, Mt)) - A, De = Math.cos(nt), Fe = Math.sin(nt), et = L / O * rt, ei = -0.5 * Et * et * et;
|
|
5594
|
+
Ze[L] = De * dt + Fe * K + k[L], We[L] = I + ei + de[L], $e[L] = -Fe * dt + De * K + N[L];
|
|
5494
5595
|
}
|
|
5495
|
-
} else for (let
|
|
5496
|
-
const
|
|
5497
|
-
if (
|
|
5498
|
-
const
|
|
5499
|
-
|
|
5596
|
+
} else for (let A = 0; A <= O; A++) {
|
|
5597
|
+
const k = A / O * rt, de = -0.5 * Et * k * k;
|
|
5598
|
+
if (wt) {
|
|
5599
|
+
const N = li(qe, Ve - k, Pi);
|
|
5600
|
+
Ze[A] = dt - Me * k + N[0], We[A] = I - ge * k + de + N[1], $e[A] = K - pe * k + N[2];
|
|
5500
5601
|
} else
|
|
5501
|
-
|
|
5602
|
+
Ze[A] = Ie - he * k, We[A] = W - we * k + de, $e[A] = fe - Re * k;
|
|
5502
5603
|
}
|
|
5503
|
-
if (
|
|
5504
|
-
const
|
|
5505
|
-
let
|
|
5506
|
-
|
|
5507
|
-
const
|
|
5508
|
-
for (let
|
|
5509
|
-
const
|
|
5510
|
-
let
|
|
5511
|
-
|
|
5604
|
+
if (U !== "straight") {
|
|
5605
|
+
const A = g.emissionTrailShapeAmplitude ?? 0.1, k = g.emissionTrailShapeFrequency ?? 4, de = g.emissionTrailShapeSpeed ?? 0;
|
|
5606
|
+
let N = -ze, L = 0, Y = Le, ie = Math.sqrt(N * N + Y * Y);
|
|
5607
|
+
ie < 1e-6 && (N = 0, L = ze, Y = -ke, ie = Math.sqrt(N * N + L * L + Y * Y) || 1), N /= ie, L /= ie, Y /= ie;
|
|
5608
|
+
const Je = ke * Y - ze * L, Ke = ze * N - Le * Y, Qe = Le * L - ke * N;
|
|
5609
|
+
for (let Pe = 1; Pe <= O; Pe++) {
|
|
5610
|
+
const nt = Pe / O * rt, De = 2 * Math.PI * k * (Ve - nt) + de * Ve;
|
|
5611
|
+
let Fe = 0, et = 0;
|
|
5612
|
+
U === "zigzag" ? Fe = A * Math.sign(Math.sin(De)) : U === "sine" ? Fe = A * Math.sin(De) : U === "spiral" && (Fe = A * Math.sin(De), et = A * Math.cos(De)), Ze[Pe] += N * Fe + Je * et, We[Pe] += L * Fe + Ke * et, $e[Pe] += Y * Fe + Qe * et;
|
|
5512
5613
|
}
|
|
5513
5614
|
}
|
|
5514
|
-
if (
|
|
5515
|
-
for (let
|
|
5516
|
-
const
|
|
5517
|
-
|
|
5615
|
+
if (B)
|
|
5616
|
+
for (let A = 1; A <= O && u < G; A++) {
|
|
5617
|
+
const k = A / O, de = Ze[A] - Oe, N = We[A] - xe, L = $e[A] - _t, Y = u * 8, ie = u * 4;
|
|
5618
|
+
H[Y] = de, H[Y + 1] = N, H[Y + 2] = L, H[Y + 3] = ee, H[Y + 4] = me, H[Y + 5] = $, H[Y + 6] = Q + (J - Q) * k, H[Y + 7] = J, se[ie] = 0, se[ie + 1] = 0, se[ie + 2] = 0, se[ie + 3] = 0, ne[ie] = de, ne[ie + 1] = N, ne[ie + 2] = L, ne[ie + 3] = 0, u++;
|
|
5518
5619
|
}
|
|
5519
5620
|
else
|
|
5520
|
-
for (let
|
|
5521
|
-
const
|
|
5522
|
-
|
|
5621
|
+
for (let A = 0; A < O && !(f + 42 > Ye.length); A++) {
|
|
5622
|
+
const k = A / O, de = (A + 1) / O, N = Ze[A], L = We[A], Y = $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), Fe = N + Be * Qe, et = L + Te * Qe, ei = Y + Ee * Qe, Ai = N - Be * Qe, Ci = L - Te * Qe, Ui = Y - Ee * Qe, Ii = ie + Be * Pe, zi = Je + Te * Pe, Di = Ke + Ee * Pe, Os = ie - Be * Pe, Ls = Je - Te * Pe, ks = Ke - Ee * Pe, bt = (Xs, Ns, Ys, js) => {
|
|
5623
|
+
Ye[f++] = Xs, Ye[f++] = Ns, Ye[f++] = Ys, Ye[f++] = ee, Ye[f++] = me, Ye[f++] = $, Ye[f++] = js;
|
|
5523
5624
|
};
|
|
5524
|
-
|
|
5625
|
+
bt(Fe, 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);
|
|
5525
5626
|
}
|
|
5526
5627
|
}
|
|
5527
|
-
|
|
5628
|
+
B && u > m && xt.set(g.id, { first: m, count: u - m });
|
|
5528
5629
|
}
|
|
5529
5630
|
}
|
|
5530
|
-
const
|
|
5531
|
-
|
|
5631
|
+
const w = y;
|
|
5632
|
+
y = cs(y, p, g), y > w && at.set(g.id, { first: w / 9, count: (y - w) / 9 });
|
|
5532
5633
|
}
|
|
5533
|
-
u > 0 && (r.queue.writeBuffer(
|
|
5634
|
+
u > 0 && (r.queue.writeBuffer(re, 0, H, 0, u * 8), r.queue.writeBuffer(j, 0, se, 0, u * 4), r.queue.writeBuffer(tt, 0, ne, 0, u * 4)), vt = f / 7, vt > 0 && r.queue.writeBuffer(qt, 0, Ye, 0, f), bi = y / 9, bi > 0 && r.queue.writeBuffer(Ht, 0, Ce, 0, y);
|
|
5534
5635
|
}
|
|
5535
|
-
const
|
|
5536
|
-
|
|
5636
|
+
const ci = () => {
|
|
5637
|
+
const [u, f] = Ji(a.width, a.height);
|
|
5638
|
+
r.queue.writeBuffer(z, 0, new Float32Array([1, 0, u, f, 0, 0, 0, 0])), r.queue.writeBuffer(D, 0, new Float32Array([0, 1, u, f, 0, 0, 0, 0]));
|
|
5537
5639
|
};
|
|
5538
|
-
|
|
5539
|
-
const
|
|
5540
|
-
|
|
5541
|
-
const
|
|
5542
|
-
particlePipeline:
|
|
5543
|
-
particleAdditivePipeline:
|
|
5544
|
-
particleDepthWritePipeline:
|
|
5545
|
-
blurPipeline:
|
|
5546
|
-
compositePipeline:
|
|
5547
|
-
directRenderPipeline:
|
|
5548
|
-
finalCompositePipeline:
|
|
5549
|
-
glbMeshPipeline:
|
|
5550
|
-
} =
|
|
5640
|
+
ci();
|
|
5641
|
+
const ui = new Float32Array(16).fill(0);
|
|
5642
|
+
ui[0] = 1, r.queue.writeBuffer(_, 0, ui);
|
|
5643
|
+
const Ge = Ir(r), Ne = Cr(r), {
|
|
5644
|
+
particlePipeline: fs,
|
|
5645
|
+
particleAdditivePipeline: ps,
|
|
5646
|
+
particleDepthWritePipeline: hs,
|
|
5647
|
+
blurPipeline: It,
|
|
5648
|
+
compositePipeline: ms,
|
|
5649
|
+
directRenderPipeline: di,
|
|
5650
|
+
finalCompositePipeline: ys,
|
|
5651
|
+
glbMeshPipeline: gs
|
|
5652
|
+
} = Ur(r, l, Ne), fi = r.createShaderModule({ code: `
|
|
5551
5653
|
struct U { mvp: mat4x4<f32> };
|
|
5552
5654
|
@group(0) @binding(0) var<uniform> u: U;
|
|
5553
5655
|
struct VIn { @location(0) pos: vec3<f32>, @location(1) col: vec4<f32> };
|
|
5554
5656
|
struct VOut { @builtin(position) pos: vec4<f32>, @location(0) col: vec4<f32> };
|
|
5555
5657
|
@vertex fn vs(v: VIn) -> VOut { var o: VOut; o.pos = u.mvp * vec4<f32>(v.pos, 1.0); o.col = v.col; return o; }
|
|
5556
5658
|
@fragment fn fs(i: VOut) -> @location(0) vec4<f32> { return i.col; }
|
|
5557
|
-
` }),
|
|
5659
|
+
` }), pi = r.createBindGroupLayout({
|
|
5558
5660
|
entries: [{ binding: 0, visibility: GPUShaderStage.VERTEX, buffer: { type: "uniform" } }]
|
|
5559
|
-
}),
|
|
5560
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5661
|
+
}), bs = r.createRenderPipeline({
|
|
5662
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [pi] }),
|
|
5561
5663
|
vertex: {
|
|
5562
|
-
module:
|
|
5664
|
+
module: fi,
|
|
5563
5665
|
entryPoint: "vs",
|
|
5564
5666
|
buffers: [{ arrayStride: 28, attributes: [
|
|
5565
5667
|
{ shaderLocation: 0, offset: 0, format: "float32x3" },
|
|
@@ -5567,7 +5669,7 @@ async function qr(s, t = {}) {
|
|
|
5567
5669
|
] }]
|
|
5568
5670
|
},
|
|
5569
5671
|
fragment: {
|
|
5570
|
-
module:
|
|
5672
|
+
module: fi,
|
|
5571
5673
|
entryPoint: "fs",
|
|
5572
5674
|
targets: [{ format: "rgba16float", blend: {
|
|
5573
5675
|
// renders into the HDR sceneTexture
|
|
@@ -5579,16 +5681,16 @@ async function qr(s, t = {}) {
|
|
|
5579
5681
|
// depth24plus to match the non-bloom pass; test against the resolved scene depth
|
|
5580
5682
|
// (occlusion) but don't write (transparent ribbon).
|
|
5581
5683
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
|
|
5582
|
-
}),
|
|
5583
|
-
size:
|
|
5684
|
+
}), hi = 512 * 64 * 6, Ye = new Float32Array(hi * 7), qt = r.createBuffer({
|
|
5685
|
+
size: hi * 7 * 4,
|
|
5584
5686
|
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
5585
5687
|
label: "ribbonBuffer"
|
|
5586
|
-
}),
|
|
5587
|
-
layout:
|
|
5688
|
+
}), Ss = r.createBindGroup({
|
|
5689
|
+
layout: pi,
|
|
5588
5690
|
entries: [{ binding: 0, resource: { buffer: v } }]
|
|
5589
5691
|
});
|
|
5590
|
-
let
|
|
5591
|
-
const
|
|
5692
|
+
let vt = 0;
|
|
5693
|
+
const mi = r.createShaderModule({ code: `
|
|
5592
5694
|
struct Uniforms {
|
|
5593
5695
|
transform: mat4x4<f32>,
|
|
5594
5696
|
cameraPosition: vec3<f32>,
|
|
@@ -5666,8 +5768,20 @@ async function qr(s, t = {}) {
|
|
|
5666
5768
|
@location(3) noiseOffset: vec2<f32>,
|
|
5667
5769
|
};
|
|
5668
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.
|
|
5669
5781
|
fn hash21(p: vec2<f32>) -> f32 {
|
|
5670
|
-
|
|
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);
|
|
5671
5785
|
}
|
|
5672
5786
|
|
|
5673
5787
|
fn valueNoise(p: vec2<f32>) -> f32 {
|
|
@@ -5717,10 +5831,10 @@ async function qr(s, t = {}) {
|
|
|
5717
5831
|
}
|
|
5718
5832
|
return vec4<f32>(i.col, i.alpha);
|
|
5719
5833
|
}
|
|
5720
|
-
` }),
|
|
5721
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5834
|
+
` }), yi = (u) => r.createRenderPipeline({
|
|
5835
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [Ne.particleBindGroupLayout] }),
|
|
5722
5836
|
vertex: {
|
|
5723
|
-
module:
|
|
5837
|
+
module: mi,
|
|
5724
5838
|
entryPoint: "vs",
|
|
5725
5839
|
buffers: [{ arrayStride: 36, attributes: [
|
|
5726
5840
|
{ shaderLocation: 0, offset: 0, format: "float32x3" },
|
|
@@ -5729,32 +5843,32 @@ async function qr(s, t = {}) {
|
|
|
5729
5843
|
] }]
|
|
5730
5844
|
},
|
|
5731
5845
|
fragment: {
|
|
5732
|
-
module:
|
|
5846
|
+
module: mi,
|
|
5733
5847
|
entryPoint: "fs",
|
|
5734
5848
|
targets: [{ format: "rgba16float", blend: u }]
|
|
5735
5849
|
},
|
|
5736
5850
|
primitive: { topology: "triangle-list" },
|
|
5737
5851
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
|
|
5738
|
-
}),
|
|
5852
|
+
}), xs = yi({
|
|
5739
5853
|
color: { srcFactor: "src-alpha", dstFactor: "one-minus-src-alpha", operation: "add" },
|
|
5740
5854
|
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
5741
|
-
}),
|
|
5855
|
+
}), vs = yi({
|
|
5742
5856
|
color: { srcFactor: "src-alpha", dstFactor: "one", operation: "add" },
|
|
5743
5857
|
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
5744
|
-
}),
|
|
5745
|
-
size:
|
|
5858
|
+
}), gi = 256 * 256 * 6, Ce = new Float32Array(gi * 9), Ht = r.createBuffer({
|
|
5859
|
+
size: gi * 9 * 4,
|
|
5746
5860
|
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
5747
5861
|
label: "shapeStrokeBuffer"
|
|
5748
5862
|
});
|
|
5749
|
-
let
|
|
5750
|
-
const
|
|
5863
|
+
let bi = 0, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct } = Ni(r, l, a.width, a.height), zt = Yi(r, a.width, a.height), ht, Si, Dt, Pt;
|
|
5864
|
+
const xi = () => {
|
|
5751
5865
|
const u = (f) => f.createView();
|
|
5752
|
-
|
|
5866
|
+
ht = u(ot), Si = u(lt), Dt = u(ct), Pt = u(zt);
|
|
5753
5867
|
};
|
|
5754
|
-
|
|
5755
|
-
const
|
|
5756
|
-
let Ft =
|
|
5757
|
-
const
|
|
5868
|
+
xi();
|
|
5869
|
+
const Zt = { uniformBuffer: v, appearanceUniformBuffer: C, horizontalBlurUniformBuffer: z, verticalBlurUniformBuffer: D, bloomIntensityBuffer: _ };
|
|
5870
|
+
let Ft = si(r, Ge, Zt, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct });
|
|
5871
|
+
const V = {
|
|
5758
5872
|
mvp: new Float32Array(16),
|
|
5759
5873
|
position: new Float32Array([0, 0, 10]),
|
|
5760
5874
|
right: new Float32Array([1, 0, 0]),
|
|
@@ -5762,189 +5876,195 @@ async function qr(s, t = {}) {
|
|
|
5762
5876
|
up: new Float32Array([0, 1, 0]),
|
|
5763
5877
|
hasCamera: !1
|
|
5764
5878
|
};
|
|
5765
|
-
let
|
|
5766
|
-
const
|
|
5767
|
-
let
|
|
5768
|
-
function
|
|
5769
|
-
const u = [
|
|
5770
|
-
|
|
5771
|
-
let
|
|
5772
|
-
const
|
|
5773
|
-
if (!
|
|
5774
|
-
|
|
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), Rs = new Array(65), Bs = new Array(65), Ts = new Array(65), Pi = [0, 0, 0], yt = { key: null, ms: !1, bindGroup: null };
|
|
5881
|
+
let _i = !1, Wt = !0, Gt = !1, Vt = null, $t = a.width, Jt = a.height;
|
|
5882
|
+
function Mi() {
|
|
5883
|
+
const u = [ot, lt, ct, zt], f = Ni(r, l, a.width, a.height);
|
|
5884
|
+
ot = f.sceneTexture, lt = f.bloomTexA, ct = f.bloomTexB, zt = Yi(r, a.width, a.height), xi(), ci(), h.clear(), b.resizeTextures(), Ft = si(r, Ge, Zt, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct });
|
|
5885
|
+
let y = !1;
|
|
5886
|
+
const p = () => {
|
|
5887
|
+
if (!y) {
|
|
5888
|
+
y = !0, requestAnimationFrame(p);
|
|
5775
5889
|
return;
|
|
5776
5890
|
}
|
|
5777
|
-
u.forEach((
|
|
5891
|
+
u.forEach((g) => g.destroy());
|
|
5778
5892
|
};
|
|
5779
|
-
requestAnimationFrame(
|
|
5893
|
+
requestAnimationFrame(p);
|
|
5780
5894
|
}
|
|
5781
|
-
function
|
|
5782
|
-
|
|
5895
|
+
function Es(u, f, y) {
|
|
5896
|
+
V.mvp.set(Gr(u, f)), f && f.length >= 10 && (V.right[0] = f[0], V.right[1] = f[4], V.right[2] = f[8], V.up[0] = f[1], V.up[1] = f[5], V.up[2] = f[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;
|
|
5783
5897
|
}
|
|
5784
|
-
function
|
|
5785
|
-
|
|
5898
|
+
function As(u, f) {
|
|
5899
|
+
V.mvp.set(u), f && (V.position[0] = f.x ?? f[0], V.position[1] = f.y ?? f[1], V.position[2] = f.z ?? f[2]), V.hasCamera = !0;
|
|
5786
5900
|
}
|
|
5787
|
-
async function
|
|
5901
|
+
async function Kt(u) {
|
|
5788
5902
|
if (Gt) {
|
|
5789
|
-
|
|
5903
|
+
Vt = u;
|
|
5790
5904
|
return;
|
|
5791
5905
|
}
|
|
5792
5906
|
Gt = !0;
|
|
5793
5907
|
try {
|
|
5794
5908
|
for (const f in T) delete T[f];
|
|
5795
|
-
|
|
5909
|
+
h.clear(), b.resizeTextures(), Ft = si(r, Ge, Zt, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct }), await c.replaceSystems({ systems: [], activeSystemIndex: 0 });
|
|
5796
5910
|
for (const f of u)
|
|
5797
|
-
await
|
|
5798
|
-
for (const { config: f } of
|
|
5799
|
-
T[f.id] || (T[f.id] =
|
|
5800
|
-
|
|
5911
|
+
await c.addSystems(f.preset, f.position || [0, 0, 0]);
|
|
5912
|
+
for (const { config: f } of c.particleSystems)
|
|
5913
|
+
T[f.id] || (T[f.id] = F());
|
|
5914
|
+
Wt = !0, c.respawnAllSystems();
|
|
5801
5915
|
} finally {
|
|
5802
|
-
if (Gt = !1,
|
|
5803
|
-
const f =
|
|
5804
|
-
|
|
5916
|
+
if (Gt = !1, Vt) {
|
|
5917
|
+
const f = Vt;
|
|
5918
|
+
Vt = null, Kt(f);
|
|
5805
5919
|
}
|
|
5806
5920
|
}
|
|
5807
5921
|
}
|
|
5808
|
-
async function
|
|
5809
|
-
return
|
|
5810
|
-
}
|
|
5811
|
-
function
|
|
5812
|
-
if (
|
|
5813
|
-
const f =
|
|
5814
|
-
if (f && (f.loop =
|
|
5815
|
-
if ((a.width !==
|
|
5816
|
-
for (const m of
|
|
5922
|
+
async function Cs(u, f = [0, 0, 0]) {
|
|
5923
|
+
return Kt([{ preset: u, position: f }]);
|
|
5924
|
+
}
|
|
5925
|
+
function Us(u) {
|
|
5926
|
+
if (_i || Gt || !c.ready || u <= 0 || c.particleSystems.length === 0) return;
|
|
5927
|
+
const f = c.clock;
|
|
5928
|
+
if (f && (f.loop = c.loop ?? i, f.duration = c.getTotalDuration(), u = f.tick(u)), u > 0.1 && (u = 0.1), u <= 0) return;
|
|
5929
|
+
if ((a.width !== $t || a.height !== Jt) && ($t = a.width, Jt = a.height, Mi()), Ve += u, _e.length) {
|
|
5930
|
+
for (const m of _e) {
|
|
5817
5931
|
if (m.getPosition) {
|
|
5818
|
-
const
|
|
5819
|
-
|
|
5932
|
+
const M = m.getPosition();
|
|
5933
|
+
M ? (m.pos || (m.pos = m._posBuf), Array.isArray(M) ? (m.pos[0] = M[0], m.pos[1] = M[1], m.pos[2] = M[2]) : (m.pos[0] = M.x, m.pos[1] = M.y, m.pos[2] = M.z)) : m.pos = null;
|
|
5820
5934
|
}
|
|
5821
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);
|
|
5822
5936
|
}
|
|
5823
|
-
for (const { system: m, config:
|
|
5824
|
-
const
|
|
5825
|
-
if (!(!
|
|
5826
|
-
let
|
|
5827
|
-
if (
|
|
5828
|
-
const
|
|
5829
|
-
Math.hypot(
|
|
5937
|
+
for (const { system: m, config: M } of c.particleSystems) {
|
|
5938
|
+
const E = oi(M.id);
|
|
5939
|
+
if (!(!E || E.historyOnly) && (M.hidden = !E.pos, E.pos)) {
|
|
5940
|
+
let q = null;
|
|
5941
|
+
if (E.orientToDirection && E.vel) {
|
|
5942
|
+
const X = E.vel[0], O = E.vel[2];
|
|
5943
|
+
Math.hypot(X, O) > 1e-4 && (q = [0, 0, Math.atan2(X, O)]);
|
|
5830
5944
|
}
|
|
5831
|
-
m.setSimulationTransform({ position:
|
|
5945
|
+
m.setSimulationTransform({ position: E.pos, velocity: E.vel, rotation: q }), m.updateAppearanceUniform(), (E.justResumed || m.activeParticles === 0) && m.spawnParticles();
|
|
5832
5946
|
}
|
|
5833
5947
|
}
|
|
5834
|
-
for (const m of
|
|
5835
|
-
m.pos ?
|
|
5836
|
-
if (globalThis.__HZFX_DEBUG && (
|
|
5837
|
-
const m =
|
|
5838
|
-
console.info(`[HZFX] movingGroups(${
|
|
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), M = _e.find((X) => X.pos), E = M ? Math.hypot(V.position[0] - M.pos[0], V.position[1] - M.pos[1], V.position[2] - M.pos[2]).toFixed(1) : "-", q = _e.map((X) => `{ids:[${[...X.ids]}],pos:${X.pos ? "1" : "0"},hist:${X.hist.length}}`).join(",");
|
|
5952
|
+
console.info(`[HZFX] movingGroups(${_e.length})=[${q}] activeParticles=${m} systems=${c.particleSystems.length} ribbonVerts=${vt} camDist=${E} t=${Ve.toFixed(1)}`);
|
|
5839
5953
|
}
|
|
5840
5954
|
}
|
|
5841
|
-
if (
|
|
5842
|
-
const m =
|
|
5843
|
-
(f && f.justLooped || m &&
|
|
5955
|
+
if (c.updateAllSystems(u), f ? f.loop : c.loop ?? i) {
|
|
5956
|
+
const m = c.particleSystems.length > 0 && c.particleSystems.every(({ system: M }) => M.activeParticles === 0 && !M.emitting);
|
|
5957
|
+
(f && f.justLooped || m && Wt) && c.respawnAllSystems(), Wt = !m;
|
|
5844
5958
|
}
|
|
5845
|
-
for (const { system: m, config:
|
|
5846
|
-
|
|
5847
|
-
r.queue.writeBuffer(v, 0,
|
|
5848
|
-
const
|
|
5849
|
-
|
|
5850
|
-
), y = r.createCommandEncoder();
|
|
5851
|
-
let R = !1;
|
|
5959
|
+
for (const { system: m, config: M } of c.particleSystems)
|
|
5960
|
+
M.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 p = r.createCommandEncoder();
|
|
5963
|
+
let g = !1;
|
|
5852
5964
|
if (e)
|
|
5853
5965
|
try {
|
|
5854
5966
|
const m = e();
|
|
5855
5967
|
if (m) {
|
|
5856
|
-
let
|
|
5857
|
-
if (m instanceof GPUTexture ? m.width === a.width && m.height === a.height && (
|
|
5858
|
-
const { pipeline:
|
|
5859
|
-
(
|
|
5860
|
-
layout:
|
|
5861
|
-
entries: [{ binding: 0, resource:
|
|
5968
|
+
let M = null, E = null, q = !1;
|
|
5969
|
+
if (m instanceof GPUTexture ? m.width === a.width && m.height === a.height && (M = m, E = () => m.createView({ aspect: "depth-only" }), q = m.sampleCount > 1) : m.view && (M = m.view, E = () => m.view, q = !!m.multisampled), M) {
|
|
5970
|
+
const { pipeline: X, layout: O } = S(q);
|
|
5971
|
+
(yt.key !== M || yt.ms !== q) && (yt.key = M, yt.ms = q, yt.bindGroup = r.createBindGroup({
|
|
5972
|
+
layout: O,
|
|
5973
|
+
entries: [{ binding: 0, resource: E() }]
|
|
5862
5974
|
}));
|
|
5863
|
-
const
|
|
5975
|
+
const U = p.beginRenderPass({
|
|
5864
5976
|
colorAttachments: [],
|
|
5865
|
-
depthStencilAttachment: { view:
|
|
5977
|
+
depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5866
5978
|
});
|
|
5867
|
-
|
|
5979
|
+
U.setPipeline(X), U.setBindGroup(0, yt.bindGroup), U.draw(3), U.end(), g = !0;
|
|
5868
5980
|
}
|
|
5869
5981
|
}
|
|
5870
5982
|
} catch {
|
|
5871
5983
|
}
|
|
5872
|
-
const
|
|
5873
|
-
colorAttachments: [{ view:
|
|
5874
|
-
depthStencilAttachment:
|
|
5984
|
+
const w = p.beginRenderPass({
|
|
5985
|
+
colorAttachments: [{ view: ht, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5986
|
+
depthStencilAttachment: g ? { view: Pt, depthLoadOp: "load", depthStoreOp: "store" } : { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5875
5987
|
});
|
|
5876
|
-
for (const { system: m, config:
|
|
5877
|
-
|
|
5878
|
-
|
|
5988
|
+
for (const { system: m, config: M } of c.particleSystems)
|
|
5989
|
+
M.bloomEnabled || M.hidden || m.activeParticles === 0 && !at.has(M.id) || (Ri(w, m, M), Bi(w, m, M));
|
|
5990
|
+
vt > 0 && (w.setPipeline(bs), w.setBindGroup(0, Ss), w.setVertexBuffer(0, qt), w.draw(vt)), w.end();
|
|
5991
|
+
const P = /* @__PURE__ */ new Map();
|
|
5992
|
+
for (const { system: m, config: M } of c.particleSystems) {
|
|
5993
|
+
if (!M.bloomEnabled || M.hidden || m.activeParticles === 0 && !at.has(M.id)) continue;
|
|
5994
|
+
const E = M.bloomColor || [1, 1, 1], q = `b${M.bloomIntensity ?? 1}|${E[0]}|${E[1]}|${E[2]}`, X = P.get(q);
|
|
5995
|
+
X ? X.membres.push({ system: m, config: M }) : P.set(q, { membres: [{ system: m, config: M }], premier: m });
|
|
5996
|
+
}
|
|
5997
|
+
if (P.size > 0) {
|
|
5879
5998
|
const m = {
|
|
5880
|
-
colorAttachments: [{ view:
|
|
5881
|
-
},
|
|
5882
|
-
colorAttachments: [{ view:
|
|
5999
|
+
colorAttachments: [{ view: Si, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6000
|
+
}, M = {
|
|
6001
|
+
colorAttachments: [{ view: Dt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5883
6002
|
};
|
|
5884
|
-
for (const
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
depthStencilAttachment: { view: Mt, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
|
|
6003
|
+
for (const [E, q] of P) {
|
|
6004
|
+
const X = b.getBloomSourceTexture(E, a.width, a.height), O = p.beginRenderPass({
|
|
6005
|
+
colorAttachments: [{ view: X.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
6006
|
+
depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
|
|
5889
6007
|
});
|
|
5890
|
-
|
|
5891
|
-
|
|
6008
|
+
for (const { system: Se, config: Oe } of q.membres)
|
|
6009
|
+
Ri(O, Se, Oe), Bi(O, Se, Oe);
|
|
6010
|
+
O.end(), vi[0] = q.membres[0].config.bloomIntensity, r.queue.writeBuffer(_, 0, vi), h.systemBloomHorizontalBindGroups[E] || (h.systemBloomHorizontalBindGroups[E] = r.createBindGroup({
|
|
6011
|
+
layout: Ne.bloomBindGroupLayout,
|
|
5892
6012
|
entries: [
|
|
5893
|
-
{ binding: 0, resource:
|
|
5894
|
-
{ binding: 1, resource:
|
|
5895
|
-
{ binding: 2, resource: { buffer:
|
|
6013
|
+
{ binding: 0, resource: Ge },
|
|
6014
|
+
{ binding: 1, resource: X.createView() },
|
|
6015
|
+
{ binding: 2, resource: { buffer: z } }
|
|
5896
6016
|
]
|
|
5897
6017
|
}));
|
|
5898
|
-
let
|
|
5899
|
-
|
|
5900
|
-
layout:
|
|
6018
|
+
let U = p.beginRenderPass(m);
|
|
6019
|
+
U.setPipeline(It), U.setBindGroup(0, h.systemBloomHorizontalBindGroups[E]), U.draw(3), U.end(), U = p.beginRenderPass(M), U.setPipeline(It), U.setBindGroup(0, Ft.verticalBlurBindGroup), U.draw(3), U.end(), h.secondHorizontalBindGroups[E] || (h.secondHorizontalBindGroups[E] = r.createBindGroup({
|
|
6020
|
+
layout: Ne.bloomBindGroupLayout,
|
|
5901
6021
|
entries: [
|
|
5902
|
-
{ binding: 0, resource:
|
|
5903
|
-
{ binding: 1, resource:
|
|
5904
|
-
{ binding: 2, resource: { buffer:
|
|
6022
|
+
{ binding: 0, resource: Ge },
|
|
6023
|
+
{ binding: 1, resource: Dt },
|
|
6024
|
+
{ binding: 2, resource: { buffer: z } }
|
|
5905
6025
|
]
|
|
5906
|
-
})),
|
|
5907
|
-
const
|
|
5908
|
-
|
|
5909
|
-
colorAttachments: [{ view:
|
|
5910
|
-
}),
|
|
5911
|
-
layout:
|
|
6026
|
+
})), U = p.beginRenderPass(m), U.setPipeline(It), U.setBindGroup(0, h.secondHorizontalBindGroups[E]), U.draw(3), U.end(), U = p.beginRenderPass(M), U.setPipeline(It), U.setBindGroup(0, Ft.verticalBlurBindGroup), U.draw(3), U.end();
|
|
6027
|
+
const be = b.getBloomCompositeTexture(E, a.width, a.height);
|
|
6028
|
+
U = p.beginRenderPass({
|
|
6029
|
+
colorAttachments: [{ view: be.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6030
|
+
}), U.setPipeline(ms), h.systemBloomCompositeBindGroups[E] || (h.systemBloomCompositeBindGroups[E] = r.createBindGroup({
|
|
6031
|
+
layout: Ne.compositeBindGroupLayout,
|
|
5912
6032
|
entries: [
|
|
5913
|
-
{ binding: 0, resource:
|
|
5914
|
-
{ binding: 1, resource:
|
|
5915
|
-
{ binding: 2, resource:
|
|
5916
|
-
|
|
6033
|
+
{ binding: 0, resource: Ge },
|
|
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: q.premier.bloomIntensityBuffer } }
|
|
5917
6040
|
]
|
|
5918
|
-
})),
|
|
6041
|
+
})), U.setBindGroup(0, h.systemBloomCompositeBindGroups[E]), U.draw(3), U.end();
|
|
5919
6042
|
}
|
|
5920
6043
|
}
|
|
5921
|
-
const
|
|
5922
|
-
colorAttachments: [{ view:
|
|
6044
|
+
const R = b.getCombinedTexture(a.width, a.height), x = p.beginRenderPass({
|
|
6045
|
+
colorAttachments: [{ view: R.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5923
6046
|
});
|
|
5924
|
-
x.setPipeline(
|
|
5925
|
-
layout:
|
|
6047
|
+
x.setPipeline(di), h.combinedInitialBindGroup || (h.combinedInitialBindGroup = r.createBindGroup({
|
|
6048
|
+
layout: Ne.compositeBindGroupLayout,
|
|
5926
6049
|
entries: [
|
|
5927
|
-
{ binding: 0, resource:
|
|
5928
|
-
{ binding: 1, resource:
|
|
5929
|
-
{ binding: 2, resource:
|
|
6050
|
+
{ binding: 0, resource: Ge },
|
|
6051
|
+
{ binding: 1, resource: ht },
|
|
6052
|
+
{ binding: 2, resource: ht },
|
|
5930
6053
|
{ binding: 3, resource: { buffer: _ } }
|
|
5931
6054
|
]
|
|
5932
|
-
})), x.setBindGroup(0,
|
|
5933
|
-
for (const
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
x.setPipeline(li), p.combinedBloomCompositeBindGroups[C] || (p.combinedBloomCompositeBindGroups[C] = r.createBindGroup({
|
|
5937
|
-
layout: je.compositeBindGroupLayout,
|
|
6055
|
+
})), x.setBindGroup(0, h.combinedInitialBindGroup), x.draw(3);
|
|
6056
|
+
for (const m of P.keys())
|
|
6057
|
+
x.setPipeline(di), h.combinedBloomCompositeBindGroups[m] || (h.combinedBloomCompositeBindGroups[m] = r.createBindGroup({
|
|
6058
|
+
layout: Ne.compositeBindGroupLayout,
|
|
5938
6059
|
entries: [
|
|
5939
|
-
{ binding: 0, resource:
|
|
5940
|
-
{ binding: 1, resource:
|
|
5941
|
-
{ binding: 2, resource:
|
|
6060
|
+
{ binding: 0, resource: Ge },
|
|
6061
|
+
{ binding: 1, resource: b.getBloomCompositeTexture(m, a.width, a.height).createView() },
|
|
6062
|
+
{ binding: 2, resource: ht },
|
|
5942
6063
|
{ binding: 3, resource: { buffer: _ } }
|
|
5943
6064
|
]
|
|
5944
|
-
})), x.setBindGroup(0,
|
|
5945
|
-
}
|
|
6065
|
+
})), x.setBindGroup(0, h.combinedBloomCompositeBindGroups[m]), x.draw(3);
|
|
5946
6066
|
x.end();
|
|
5947
|
-
const
|
|
6067
|
+
const B = p.beginRenderPass({
|
|
5948
6068
|
colorAttachments: [{
|
|
5949
6069
|
view: n.getCurrentTexture().createView(),
|
|
5950
6070
|
loadOp: o ? "load" : "clear",
|
|
@@ -5952,151 +6072,151 @@ async function qr(s, t = {}) {
|
|
|
5952
6072
|
clearValue: { r: 0, g: 0, b: 0, a: 0 }
|
|
5953
6073
|
}]
|
|
5954
6074
|
});
|
|
5955
|
-
|
|
5956
|
-
layout:
|
|
6075
|
+
B.setPipeline(ys), h.finalBindGroup || (h.finalBindGroup = r.createBindGroup({
|
|
6076
|
+
layout: Ne.compositeBindGroupLayout,
|
|
5957
6077
|
entries: [
|
|
5958
|
-
{ binding: 0, resource:
|
|
5959
|
-
{ binding: 1, resource:
|
|
5960
|
-
{ binding: 2, resource:
|
|
6078
|
+
{ binding: 0, resource: Ge },
|
|
6079
|
+
{ binding: 1, resource: R.createView() },
|
|
6080
|
+
{ binding: 2, resource: ht },
|
|
5961
6081
|
{ binding: 3, resource: { buffer: _ } }
|
|
5962
6082
|
]
|
|
5963
|
-
})),
|
|
6083
|
+
})), B.setBindGroup(0, h.finalBindGroup), B.draw(3), B.end(), r.queue.submit([p.finish()]);
|
|
5964
6084
|
}
|
|
5965
|
-
function
|
|
5966
|
-
const
|
|
5967
|
-
return
|
|
5968
|
-
layout:
|
|
6085
|
+
function wi(u, f) {
|
|
6086
|
+
const y = u.config.id, p = !h.systemBindGroups[y] || h.textureStates[y] !== f.textureEnabled || h.textureRefs[y] !== u.particleTexture;
|
|
6087
|
+
return h.textureStates[y] = f.textureEnabled, h.textureRefs[y] = u.particleTexture, p && (h.systemBindGroups[y] = r.createBindGroup({
|
|
6088
|
+
layout: Ne.particleBindGroupLayout,
|
|
5969
6089
|
entries: [
|
|
5970
6090
|
{ binding: 0, resource: { buffer: v } },
|
|
5971
6091
|
{ binding: 1, resource: { buffer: u.appearanceUniformBuffer } },
|
|
5972
6092
|
{ binding: 2, resource: u.particleTexture.createView() },
|
|
5973
|
-
{ binding: 3, resource:
|
|
6093
|
+
{ binding: 3, resource: Ge }
|
|
5974
6094
|
]
|
|
5975
|
-
})),
|
|
6095
|
+
})), h.systemBindGroups[y];
|
|
5976
6096
|
}
|
|
5977
|
-
function
|
|
5978
|
-
const
|
|
5979
|
-
if (
|
|
5980
|
-
P && (u.setPipeline(
|
|
6097
|
+
function Ri(u, f, y) {
|
|
6098
|
+
const p = f.config.id, g = y.glbModelEnabled && f.glbMeshData, w = wi(f, y), P = y.shapeDisplay !== !1;
|
|
6099
|
+
if (g)
|
|
6100
|
+
P && (u.setPipeline(gs), u.setBindGroup(0, w), u.setVertexBuffer(0, f.glbVertexBuffer), u.setVertexBuffer(1, f.instanceBuffer), u.setVertexBuffer(2, f.velocityBuffer), u.setIndexBuffer(f.glbIndexBuffer, f.glbIndexFormat), u.drawIndexed(f.glbIndexCount, f.activeParticles));
|
|
5981
6101
|
else {
|
|
5982
|
-
u.setPipeline(
|
|
5983
|
-
const
|
|
5984
|
-
|
|
6102
|
+
u.setPipeline(y.blendMode === "additive" ? ps : fs), u.setIndexBuffer(Z, "uint16"), T[p] || (T[p] = F()), u.setVertexBuffer(0, T[p]), u.setBindGroup(0, w), P && (u.setVertexBuffer(1, f.instanceBuffer), u.setVertexBuffer(2, f.velocityBuffer), u.setVertexBuffer(3, f.trailBuffer), u.drawIndexed(6, f.activeParticles));
|
|
6103
|
+
const R = xt.get(p);
|
|
6104
|
+
R && (u.setVertexBuffer(1, re), u.setVertexBuffer(2, j), u.setVertexBuffer(3, tt), u.drawIndexed(6, R.count, 0, 0, R.first)), P && y.depthWriteEnabled && (u.setPipeline(hs), u.drawIndexed(6, f.activeParticles));
|
|
5985
6105
|
}
|
|
5986
6106
|
}
|
|
5987
|
-
function
|
|
5988
|
-
const
|
|
5989
|
-
!
|
|
6107
|
+
function Bi(u, f, y) {
|
|
6108
|
+
const p = at.get(y.id);
|
|
6109
|
+
!p || p.count <= 0 || (u.setPipeline(y.blendMode === "additive" ? vs : xs), u.setBindGroup(0, wi(f, y)), u.setVertexBuffer(0, Ht), u.draw(p.count, 1, p.first, 0));
|
|
5990
6110
|
}
|
|
5991
|
-
function
|
|
5992
|
-
|
|
6111
|
+
function Is() {
|
|
6112
|
+
$t = a.width, Jt = a.height, Mi();
|
|
5993
6113
|
}
|
|
5994
|
-
function
|
|
5995
|
-
|
|
6114
|
+
function zs() {
|
|
6115
|
+
h.clear();
|
|
5996
6116
|
}
|
|
5997
|
-
function
|
|
5998
|
-
|
|
6117
|
+
function Ds() {
|
|
6118
|
+
_i = !0, c.destroy(), [ot, lt, ct, zt].forEach((u) => u == null ? void 0 : u.destroy()), b.resizeTextures(), [
|
|
5999
6119
|
v,
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6120
|
+
C,
|
|
6121
|
+
z,
|
|
6122
|
+
D,
|
|
6003
6123
|
_,
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6124
|
+
Z,
|
|
6125
|
+
re,
|
|
6126
|
+
j,
|
|
6127
|
+
tt,
|
|
6128
|
+
qt,
|
|
6129
|
+
Ht
|
|
6010
6130
|
].forEach((u) => u == null ? void 0 : u.destroy()), Object.values(T).forEach((u) => u == null ? void 0 : u.destroy());
|
|
6011
6131
|
}
|
|
6012
|
-
async function
|
|
6013
|
-
const
|
|
6014
|
-
for (const { config:
|
|
6015
|
-
T[
|
|
6016
|
-
return
|
|
6132
|
+
async function Ti(u, f) {
|
|
6133
|
+
const y = await c.addSystems(u, f);
|
|
6134
|
+
for (const { config: p } of c.particleSystems)
|
|
6135
|
+
T[p.id] || (T[p.id] = F());
|
|
6136
|
+
return c.respawnAllSystems(), new Set(Array.isArray(y) ? y : []);
|
|
6017
6137
|
}
|
|
6018
|
-
function
|
|
6138
|
+
function Ei(u) {
|
|
6019
6139
|
for (const f of u) {
|
|
6020
|
-
const
|
|
6021
|
-
|
|
6140
|
+
const y = c.particleSystems.findIndex((p) => p.config.id === f);
|
|
6141
|
+
y >= 0 && c.removeSystem(y);
|
|
6022
6142
|
}
|
|
6023
6143
|
}
|
|
6024
|
-
async function
|
|
6025
|
-
const
|
|
6144
|
+
async function Fs(u, f = [0, 0, 0]) {
|
|
6145
|
+
const y = await Ti(u, f);
|
|
6026
6146
|
return { remove() {
|
|
6027
|
-
|
|
6147
|
+
Ei(y);
|
|
6028
6148
|
} };
|
|
6029
6149
|
}
|
|
6030
|
-
async function
|
|
6031
|
-
const
|
|
6032
|
-
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...
|
|
6033
|
-
const
|
|
6034
|
-
return
|
|
6035
|
-
setPosition(
|
|
6036
|
-
|
|
6150
|
+
async function Gs(u, f = {}) {
|
|
6151
|
+
const y = await Ti(u, [0, 0, 0]);
|
|
6152
|
+
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...y]}]`);
|
|
6153
|
+
const p = { ids: y, pos: null, hist: [], getPosition: f.getPosition || null, orientToDirection: !!f.orientToDirection, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
|
|
6154
|
+
return _e.push(p), {
|
|
6155
|
+
setPosition(g) {
|
|
6156
|
+
g && (p.pos = Array.isArray(g) ? [g[0], g[1], g[2]] : [g.x, g.y, g.z]);
|
|
6037
6157
|
},
|
|
6038
|
-
setOrientToDirection(
|
|
6039
|
-
|
|
6158
|
+
setOrientToDirection(g) {
|
|
6159
|
+
p.orientToDirection = !!g;
|
|
6040
6160
|
},
|
|
6041
6161
|
remove() {
|
|
6042
|
-
|
|
6043
|
-
const
|
|
6044
|
-
|
|
6162
|
+
Ei(y);
|
|
6163
|
+
const g = _e.indexOf(p);
|
|
6164
|
+
g >= 0 && _e.splice(g, 1);
|
|
6045
6165
|
}
|
|
6046
6166
|
};
|
|
6047
6167
|
}
|
|
6048
|
-
function
|
|
6049
|
-
const
|
|
6050
|
-
return
|
|
6168
|
+
function Vs(u, f) {
|
|
6169
|
+
const p = { ids: u instanceof Set ? u : new Set(u), pos: null, hist: [], getPosition: f, historyOnly: !0, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
|
|
6170
|
+
return _e.push(p), {
|
|
6051
6171
|
remove() {
|
|
6052
|
-
const
|
|
6053
|
-
|
|
6172
|
+
const g = _e.indexOf(p);
|
|
6173
|
+
g >= 0 && _e.splice(g, 1);
|
|
6054
6174
|
},
|
|
6055
6175
|
// Update which systems this history group covers WITHOUT losing the accumulated path
|
|
6056
6176
|
// history. Needed when the scene's systems change (e.g. duplicate/add/remove) while the
|
|
6057
6177
|
// group is active — otherwise a newly-added system's id isn't in the set and its trail
|
|
6058
6178
|
// can't follow the recorded movement path (it falls back to straight extrapolation).
|
|
6059
|
-
setIds(
|
|
6060
|
-
|
|
6179
|
+
setIds(g) {
|
|
6180
|
+
p.ids = g instanceof Set ? g : new Set(g);
|
|
6061
6181
|
}
|
|
6062
6182
|
};
|
|
6063
6183
|
}
|
|
6064
6184
|
return {
|
|
6065
|
-
manager:
|
|
6185
|
+
manager: c,
|
|
6066
6186
|
device: r,
|
|
6067
6187
|
context: n,
|
|
6068
|
-
setCamera:
|
|
6069
|
-
setCameraMVP:
|
|
6070
|
-
setEmitters:
|
|
6071
|
-
loadPreset:
|
|
6072
|
-
addEmitter:
|
|
6073
|
-
addMovingEmitter:
|
|
6074
|
-
render:
|
|
6075
|
-
resize:
|
|
6076
|
-
clearCaches:
|
|
6077
|
-
trackHistoryGroup:
|
|
6078
|
-
destroy:
|
|
6188
|
+
setCamera: Es,
|
|
6189
|
+
setCameraMVP: As,
|
|
6190
|
+
setEmitters: Kt,
|
|
6191
|
+
loadPreset: Cs,
|
|
6192
|
+
addEmitter: Fs,
|
|
6193
|
+
addMovingEmitter: Gs,
|
|
6194
|
+
render: Us,
|
|
6195
|
+
resize: Is,
|
|
6196
|
+
clearCaches: zs,
|
|
6197
|
+
trackHistoryGroup: Vs,
|
|
6198
|
+
destroy: Ds
|
|
6079
6199
|
};
|
|
6080
6200
|
}
|
|
6081
|
-
function
|
|
6201
|
+
function Kr(s) {
|
|
6082
6202
|
return () => {
|
|
6083
|
-
var t, e, i, r, n, a, o,
|
|
6203
|
+
var t, e, i, r, n, a, o, l;
|
|
6084
6204
|
try {
|
|
6085
|
-
const
|
|
6086
|
-
if (!
|
|
6087
|
-
const d = s.domElement.width, S = s.domElement.height,
|
|
6088
|
-
if (s.needsFrameBufferTarget &&
|
|
6089
|
-
const
|
|
6090
|
-
(r =
|
|
6091
|
-
|
|
6092
|
-
(n =
|
|
6093
|
-
|
|
6205
|
+
const c = s.backend;
|
|
6206
|
+
if (!c) return null;
|
|
6207
|
+
const d = s.domElement.width, S = s.domElement.height, b = (typeof s._getFrameBufferTarget == "function" ? s._getFrameBufferTarget() : null) || s._frameBufferTarget || null;
|
|
6208
|
+
if (s.needsFrameBufferTarget && b) {
|
|
6209
|
+
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 = [
|
|
6210
|
+
(r = C == null ? void 0 : C.depthTexture) == null ? void 0 : r.texture,
|
|
6211
|
+
C == null ? void 0 : C.depthTexture,
|
|
6212
|
+
(n = C == null ? void 0 : C.depthBuffer) == null ? void 0 : n.texture,
|
|
6213
|
+
z ? (a = c.get(z)) == null ? void 0 : a.texture : null
|
|
6094
6214
|
];
|
|
6095
|
-
for (const _ of
|
|
6215
|
+
for (const _ of D)
|
|
6096
6216
|
if (_ && typeof _.createView == "function" && _.width === d && _.height === S) return _;
|
|
6097
6217
|
return null;
|
|
6098
6218
|
}
|
|
6099
|
-
const
|
|
6219
|
+
const h = s.getCanvasTarget ? c.get(s.getCanvasTarget()) : null, v = ((l = (o = h == null ? void 0 : h.descriptor) == null ? void 0 : o.depthStencilAttachment) == null ? void 0 : l.view) ?? null;
|
|
6100
6220
|
return v ? { view: v, multisampled: (s.currentSamples ?? 0) > 1 } : null;
|
|
6101
6221
|
} catch {
|
|
6102
6222
|
return null;
|
|
@@ -6104,46 +6224,46 @@ function Hr(s) {
|
|
|
6104
6224
|
};
|
|
6105
6225
|
}
|
|
6106
6226
|
export {
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6227
|
+
xr as GLBAnimator,
|
|
6228
|
+
vr as HZClock,
|
|
6229
|
+
Nr as Objects3DManager,
|
|
6230
|
+
qs as ParticleEmitter,
|
|
6231
|
+
er as ParticlePhysics,
|
|
6232
|
+
Fi as ParticleScript,
|
|
6233
|
+
ii as ParticleSystem,
|
|
6234
|
+
Br as ParticleSystemManager,
|
|
6235
|
+
tr as ParticleTextureManager,
|
|
6236
|
+
Zs as blurShader,
|
|
6237
|
+
Ws as compositeShader,
|
|
6238
|
+
Cr as createBindGroupLayouts,
|
|
6239
|
+
si as createBindGroups,
|
|
6240
|
+
St as createBuffer,
|
|
6241
|
+
zr as createCubeGeometry,
|
|
6242
|
+
Yi as createDepthTexture,
|
|
6243
|
+
qr as createLookAtMatrix,
|
|
6244
|
+
Hr as createProjectionMatrix,
|
|
6245
|
+
Ur as createRenderPipelines,
|
|
6246
|
+
Ni as createRenderTextures,
|
|
6247
|
+
Ir as createSampler,
|
|
6248
|
+
Dr as createSphereGeometry,
|
|
6249
|
+
$s as directRenderShader,
|
|
6250
|
+
Vi as extractGLBTexture,
|
|
6251
|
+
$r as fetchPreset,
|
|
6252
|
+
Ar as glbMeshParticleShader,
|
|
6253
|
+
Yr as hexToRgb,
|
|
6254
|
+
Jr as initHzFxOverlay,
|
|
6255
|
+
Tr as initWebGPU,
|
|
6256
|
+
is as isHZFX,
|
|
6257
|
+
Wr as loadScene,
|
|
6258
|
+
Kr as makeThreeSceneDepth,
|
|
6259
|
+
Gr as multiplyMatrices,
|
|
6260
|
+
Er as object3dShader,
|
|
6261
|
+
Or as packHZFX,
|
|
6262
|
+
or as parseGLB,
|
|
6263
|
+
Ks as particlePhysicsShader,
|
|
6264
|
+
Hs as particleShader,
|
|
6265
|
+
jr as rgbToHex,
|
|
6266
|
+
Zr as saveScene,
|
|
6267
|
+
kr as serializeSystemConfig,
|
|
6268
|
+
ss as unpackHZFX
|
|
6149
6269
|
};
|