hz-particles 1.4.3 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/dist-lib/hz-particles-r3f.cjs +2 -2
- package/dist-lib/hz-particles-r3f.mjs +119 -117
- package/dist-lib/hz-particles.cjs +143 -14
- package/dist-lib/hz-particles.d.ts +7 -0
- package/dist-lib/hz-particles.mjs +1282 -949
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class ks {
|
|
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,15 +10,15 @@ class ms {
|
|
|
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), c = Math.sin(r), l = Math.cos(n),
|
|
13
|
+
const r = t * Math.PI / 180, n = e * Math.PI / 180, a = i * Math.PI / 180, o = Math.cos(r), c = Math.sin(r), l = Math.cos(n), d = Math.sin(n), S = Math.cos(a), g = Math.sin(a);
|
|
14
14
|
this._rotMatrix = [
|
|
15
|
-
l *
|
|
16
|
-
c *
|
|
17
|
-
o *
|
|
18
|
-
l *
|
|
19
|
-
c *
|
|
20
|
-
o *
|
|
21
|
-
-
|
|
15
|
+
l * S,
|
|
16
|
+
c * d * S - o * g,
|
|
17
|
+
o * d * S + c * g,
|
|
18
|
+
l * g,
|
|
19
|
+
c * d * g + o * S,
|
|
20
|
+
o * d * g - c * S,
|
|
21
|
+
-d,
|
|
22
22
|
c * l,
|
|
23
23
|
o * l
|
|
24
24
|
], this._invRotMatrix = [
|
|
@@ -37,8 +37,8 @@ class ms {
|
|
|
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, c = r[0], l = r[1],
|
|
41
|
-
r[0] = o[0] * c + o[1] * l + o[2] *
|
|
40
|
+
const o = this._rotMatrix, c = r[0], l = r[1], d = r[2];
|
|
41
|
+
r[0] = o[0] * c + o[1] * l + o[2] * d, r[1] = o[3] * c + o[4] * l + o[5] * d, r[2] = o[6] * c + o[7] * l + 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;
|
|
@@ -91,8 +91,8 @@ class ms {
|
|
|
91
91
|
o = n, c = -0.5, l = a;
|
|
92
92
|
break;
|
|
93
93
|
}
|
|
94
|
-
const
|
|
95
|
-
t[0] = o *
|
|
94
|
+
const d = Math.random(), S = e + d * (i - e);
|
|
95
|
+
t[0] = o * S, t[1] = c * S, t[2] = l * 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
|
}
|
|
@@ -137,8 +137,8 @@ class ms {
|
|
|
137
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, c = i * (1 - a);
|
|
138
138
|
let l;
|
|
139
139
|
if (e > 0) {
|
|
140
|
-
const
|
|
141
|
-
l =
|
|
140
|
+
const d = e * (1 - a);
|
|
141
|
+
l = d + (c - d) * Math.random();
|
|
142
142
|
} else
|
|
143
143
|
l = c * Math.sqrt(Math.random());
|
|
144
144
|
t[0] = Math.cos(n) * l, t[1] = o, t[2] = Math.sin(n) * l;
|
|
@@ -170,8 +170,8 @@ class ms {
|
|
|
170
170
|
const c = Math.random() * Math.PI * 2, l = e * Math.sqrt(Math.random());
|
|
171
171
|
t[0] = Math.cos(c) * l, t[1] = (Math.random() - 0.5) * i, t[2] = Math.sin(c) * l;
|
|
172
172
|
} else {
|
|
173
|
-
const c = Math.random() * Math.PI * 2, l = Math.acos(2 * Math.random() - 1),
|
|
174
|
-
t[0] =
|
|
173
|
+
const c = Math.random() * Math.PI * 2, l = Math.acos(2 * Math.random() - 1), d = e * Math.cbrt(Math.random());
|
|
174
|
+
t[0] = d * Math.sin(l) * Math.cos(c), t[1] = d * Math.cos(l), t[2] = d * Math.sin(l) * Math.sin(c), t[1] += t[1] >= 0 ? r : -r;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
_emitFromArc(t) {
|
|
@@ -193,11 +193,11 @@ class ms {
|
|
|
193
193
|
if (Math.abs(a) < 1e-6 || o <= 1e-6)
|
|
194
194
|
c = Math.random();
|
|
195
195
|
else {
|
|
196
|
-
const
|
|
197
|
-
c = (-
|
|
196
|
+
const S = Math.random(), g = 0.5 * a, p = e, v = -S * o, A = Math.max(0, p * p - 4 * g * v);
|
|
197
|
+
c = (-p + Math.sqrt(A)) / (2 * g), Number.isFinite(c) || (c = Math.random()), c = Math.min(1, Math.max(0, c));
|
|
198
198
|
}
|
|
199
|
-
const l = c * r,
|
|
200
|
-
t[0] = Math.cos(n) *
|
|
199
|
+
const l = c * r, d = e + a * c;
|
|
200
|
+
t[0] = Math.cos(n) * d, t[1] = l, 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;
|
|
@@ -243,8 +243,8 @@ class ms {
|
|
|
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
244
|
let o = Math.random(), c = Math.random();
|
|
245
245
|
o + c > 1 && (o = 1 - o, c = 1 - c);
|
|
246
|
-
const l = o * Math.cos(n) + c * Math.cos(a),
|
|
247
|
-
t[0] = l * i, t[1] =
|
|
246
|
+
const l = o * Math.cos(n) + c * Math.cos(a), d = o * Math.sin(n) + c * Math.sin(a);
|
|
247
|
+
t[0] = l * 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 ms {
|
|
|
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, c = this.config.emissionPositionZ || 0, l = t - a,
|
|
260
|
-
let
|
|
261
|
-
if (
|
|
262
|
-
let
|
|
259
|
+
const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, c = this.config.emissionPositionZ || 0, l = t - a, d = e - o, S = i - c, g = Math.sqrt(l * l + d * d + S * S);
|
|
260
|
+
let p, v, A;
|
|
261
|
+
if (g > 1e-4) {
|
|
262
|
+
let I = !1;
|
|
263
263
|
if (this.config.emissionShape === "circle" && this.config.circleVelocityDirection === "tangential") {
|
|
264
|
-
const
|
|
265
|
-
if (
|
|
266
|
-
const
|
|
267
|
-
|
|
264
|
+
const _ = this.inverseRotation(l, d, S), $ = Math.sqrt(_[0] * _[0] + _[1] * _[1]);
|
|
265
|
+
if ($ > 1e-4) {
|
|
266
|
+
const T = -_[1] / $, z = _[0] / $, F = this.applyRotation(T, z, 0);
|
|
267
|
+
p = F[0], v = F[1], A = F[2], I = !0;
|
|
268
268
|
}
|
|
269
269
|
} else if (this.config.emissionShape === "cylinder" && this.config.cylinderVelocityDirection === "tangential") {
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
const
|
|
273
|
-
|
|
270
|
+
const _ = this.inverseRotation(l, d, S), $ = Math.sqrt(_[0] * _[0] + _[2] * _[2]);
|
|
271
|
+
if ($ > 1e-4) {
|
|
272
|
+
const T = -_[2] / $, z = _[0] / $, F = this.applyRotation(T, 0, z);
|
|
273
|
+
p = F[0], v = F[1], A = F[2], I = !0;
|
|
274
274
|
} else {
|
|
275
|
-
const
|
|
276
|
-
|
|
275
|
+
const T = Math.random() * Math.PI * 2, z = this.applyRotation(Math.cos(T), 0, Math.sin(T));
|
|
276
|
+
p = z[0], v = z[1], A = z[2], I = !0;
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
|
|
279
|
+
I || (p = l / g, v = d / g, A = S / g);
|
|
280
280
|
} else {
|
|
281
|
-
const
|
|
282
|
-
|
|
281
|
+
const I = Math.random() * Math.PI * 2, _ = Math.acos(2 * Math.random() - 1);
|
|
282
|
+
p = Math.sin(_) * Math.cos(I), v = Math.sin(_) * Math.sin(I), A = Math.cos(_);
|
|
283
283
|
}
|
|
284
|
-
let
|
|
285
|
-
this.config.randomSpeed ?
|
|
284
|
+
let U;
|
|
285
|
+
this.config.randomSpeed ? U = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : U = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity : p * U, r[n + 1] = this.config.overrideYVelocity ? this.config.yVelocity : v * U, r[n + 2] = this.config.overrideZVelocity ? this.config.zVelocity : A * U, 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 ms {
|
|
|
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 Xs = `
|
|
299
299
|
struct Uniforms {
|
|
300
300
|
transform: mat4x4<f32>,
|
|
301
301
|
cameraPosition: vec3<f32>,
|
|
@@ -719,7 +719,7 @@ const ys = `
|
|
|
719
719
|
return vec4<f32>(input.color, alpha);
|
|
720
720
|
}
|
|
721
721
|
}
|
|
722
|
-
`,
|
|
722
|
+
`, Ns = `
|
|
723
723
|
struct BloomUniforms {
|
|
724
724
|
direction: vec2<f32>,
|
|
725
725
|
resolution: vec2<f32>,
|
|
@@ -779,7 +779,7 @@ const ys = `
|
|
|
779
779
|
|
|
780
780
|
return result / totalWeight * 1.1;
|
|
781
781
|
}
|
|
782
|
-
`,
|
|
782
|
+
`, Ys = `
|
|
783
783
|
struct BloomIntensityUniforms {
|
|
784
784
|
intensity: f32,
|
|
785
785
|
color: vec3<f32>,
|
|
@@ -825,7 +825,7 @@ const ys = `
|
|
|
825
825
|
|
|
826
826
|
return vec4<f32>(originalColor.rgb + (mappedBloom * bloomUniforms.intensity), originalColor.a);
|
|
827
827
|
}
|
|
828
|
-
`,
|
|
828
|
+
`, js = `
|
|
829
829
|
struct BloomIntensityUniforms {
|
|
830
830
|
intensity: f32,
|
|
831
831
|
color: vec3<f32>,
|
|
@@ -866,7 +866,7 @@ const ys = `
|
|
|
866
866
|
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
867
867
|
return textureSample(originalTexture, texSampler, input.texCoord);
|
|
868
868
|
}
|
|
869
|
-
`,
|
|
869
|
+
`, qs = `
|
|
870
870
|
@binding(0) @group(0) var texSampler: sampler;
|
|
871
871
|
@binding(1) @group(0) var originalTexture: texture_2d<f32>;
|
|
872
872
|
@binding(2) @group(0) var blurredTexture: texture_2d<f32>;
|
|
@@ -898,7 +898,7 @@ const ys = `
|
|
|
898
898
|
let c = textureSample(originalTexture, texSampler, input.texCoord);
|
|
899
899
|
return vec4<f32>(aces(c.rgb), c.a);
|
|
900
900
|
}
|
|
901
|
-
`,
|
|
901
|
+
`, Hs = `
|
|
902
902
|
struct PhysicsUniforms {
|
|
903
903
|
deltaTime: f32,
|
|
904
904
|
particleSpeed: f32,
|
|
@@ -1108,7 +1108,7 @@ const ys = `
|
|
|
1108
1108
|
particleBuffer[baseIndex + 1u] = newPos.y;
|
|
1109
1109
|
particleBuffer[baseIndex + 2u] = newPos.z;
|
|
1110
1110
|
}
|
|
1111
|
-
`,
|
|
1111
|
+
`, Zs = `
|
|
1112
1112
|
@group(0) @binding(0) var<storage, read> restData: array<f32>;
|
|
1113
1113
|
@group(0) @binding(1) var<storage, read> jointWeightsData: array<f32>;
|
|
1114
1114
|
@group(0) @binding(2) var<storage, read> jointIndicesData: array<u32>;
|
|
@@ -1165,7 +1165,7 @@ const ys = `
|
|
|
1165
1165
|
outputData[outBase + 7u] = uv_v;
|
|
1166
1166
|
}
|
|
1167
1167
|
`;
|
|
1168
|
-
class
|
|
1168
|
+
class $s {
|
|
1169
1169
|
constructor(t, e = 1e4) {
|
|
1170
1170
|
this.device = t, this.physicsSettings = {
|
|
1171
1171
|
deltaTime: 0.016,
|
|
@@ -1254,7 +1254,7 @@ class _s {
|
|
|
1254
1254
|
}),
|
|
1255
1255
|
compute: {
|
|
1256
1256
|
module: this.device.createShaderModule({
|
|
1257
|
-
code:
|
|
1257
|
+
code: Hs
|
|
1258
1258
|
}),
|
|
1259
1259
|
entryPoint: "main"
|
|
1260
1260
|
}
|
|
@@ -1285,10 +1285,10 @@ class _s {
|
|
|
1285
1285
|
return;
|
|
1286
1286
|
const o = this._physicsData, c = this.physicsSettings;
|
|
1287
1287
|
o[0] = t, o[1] = i.particleSpeed, o[2] = c.gravity, o[3] = c.turbulence, o[4] = c.attractorStrength, o[5] = c.damping, o[6] = c.attractorPosition[0], o[7] = c.attractorPosition[1], o[8] = c.attractorPosition[2], this._physicsDataU32View[9] = e, o[10] = c.confinementEnabled ? 1 : 0, o[11] = c.confinementShape === "sphere" ? 1 : 0, o[12] = c.confinementMode === "kill" ? 1 : 0, o[13] = c.confinementSpace === "local" ? 1 : 0, o[14] = c.confinementBoxHalfSize[0], o[15] = c.confinementBoxHalfSize[1], o[16] = c.confinementBoxHalfSize[2], o[17] = c.confinementSphereRadius, o[18] = c.confinementRestitution, o[19] = c.confinementFriction, o[20] = c.confinementCenter[0], o[21] = c.confinementCenter[1], o[22] = c.confinementCenter[2], o[23] = c.softBoundaryEnabled ? 1 : 0, o[24] = c.softBoundaryStrength, o[25] = c.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);
|
|
1288
|
-
const l = a || this.device.createCommandEncoder({ label: "ParticlePhysicsEncoder" }),
|
|
1289
|
-
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1288
|
+
const l = a || this.device.createCommandEncoder({ label: "ParticlePhysicsEncoder" }), d = l.beginComputePass({ label: "ParticlePhysicsPass" });
|
|
1289
|
+
d.setPipeline(this.computePipeline), d.setBindGroup(0, this.computeBindGroup);
|
|
1290
|
+
const S = Math.max(1, Math.ceil(e / 64));
|
|
1291
|
+
d.dispatchWorkgroups(S, 1, 1), d.end(), a || this.device.queue.submit([l.finish()]), this.lastUpdateTime = performance.now() / 1e3;
|
|
1292
1292
|
}
|
|
1293
1293
|
async readbackAndProcessParticles(t, e, i, r, n) {
|
|
1294
1294
|
if (t <= 0)
|
|
@@ -1461,7 +1461,7 @@ class _s {
|
|
|
1461
1461
|
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
1462
|
}
|
|
1463
1463
|
}
|
|
1464
|
-
class
|
|
1464
|
+
class Ws {
|
|
1465
1465
|
constructor(t) {
|
|
1466
1466
|
this.device = t, this.defaultTexture = null, this.createDefaultTexture();
|
|
1467
1467
|
}
|
|
@@ -1500,7 +1500,7 @@ class ws {
|
|
|
1500
1500
|
t && t.label !== "defaultParticleTexture" && t.destroy();
|
|
1501
1501
|
}
|
|
1502
1502
|
}
|
|
1503
|
-
const
|
|
1503
|
+
const ji = Object.freeze({
|
|
1504
1504
|
sin: Math.sin,
|
|
1505
1505
|
cos: Math.cos,
|
|
1506
1506
|
abs: Math.abs,
|
|
@@ -1521,10 +1521,10 @@ const Pi = Object.freeze({
|
|
|
1521
1521
|
return s + (t - s) * e;
|
|
1522
1522
|
},
|
|
1523
1523
|
smoothstep(s, t, e) {
|
|
1524
|
-
const i =
|
|
1524
|
+
const i = ji.clamp((e - s) / (t - s), 0, 1);
|
|
1525
1525
|
return i * i * (3 - 2 * i);
|
|
1526
1526
|
}
|
|
1527
|
-
}),
|
|
1527
|
+
}), At = /* @__PURE__ */ new Set([
|
|
1528
1528
|
"particleSize",
|
|
1529
1529
|
"particleSpeed",
|
|
1530
1530
|
"particleColor",
|
|
@@ -1541,7 +1541,7 @@ const Pi = Object.freeze({
|
|
|
1541
1541
|
"pulseFrequency",
|
|
1542
1542
|
"bloomIntensity"
|
|
1543
1543
|
]);
|
|
1544
|
-
class
|
|
1544
|
+
class Js {
|
|
1545
1545
|
constructor(t) {
|
|
1546
1546
|
this._collection = t, this._pd = null, this._vd = null, this._pi = 0, this._vi = 0;
|
|
1547
1547
|
}
|
|
@@ -1619,9 +1619,9 @@ class Bs {
|
|
|
1619
1619
|
this._vd[this._vi + 2] = t, this._collection._dirty = !0;
|
|
1620
1620
|
}
|
|
1621
1621
|
}
|
|
1622
|
-
class
|
|
1622
|
+
class Ks {
|
|
1623
1623
|
constructor() {
|
|
1624
|
-
this._proxy = new
|
|
1624
|
+
this._proxy = new Js(this), this._pd = null, this._vd = null, this.count = 0, this._dirty = !1;
|
|
1625
1625
|
}
|
|
1626
1626
|
_bind(t, e, i) {
|
|
1627
1627
|
this._pd = t, this._vd = e, this.count = i, this._dirty = !1;
|
|
@@ -1630,14 +1630,14 @@ class Ms {
|
|
|
1630
1630
|
return t < 0 || t >= this.count ? null : this._proxy._bind(this._pd, this._vd, t);
|
|
1631
1631
|
}
|
|
1632
1632
|
}
|
|
1633
|
-
const
|
|
1634
|
-
function
|
|
1633
|
+
const Qs = 1e6;
|
|
1634
|
+
function er(s) {
|
|
1635
1635
|
let t = 0;
|
|
1636
1636
|
return s.replace(
|
|
1637
1637
|
/\b(for|while)\s*\([^)]*\)\s*\{/g,
|
|
1638
1638
|
(e) => {
|
|
1639
1639
|
const i = `__lc${t++}`;
|
|
1640
|
-
return `${e} if(++${i}>${
|
|
1640
|
+
return `${e} if(++${i}>${Qs})throw new Error("Loop limit exceeded");`;
|
|
1641
1641
|
}
|
|
1642
1642
|
).replace(
|
|
1643
1643
|
/\b(for|while)\s*\([^)]*\)\s*\{/g,
|
|
@@ -1654,10 +1654,10 @@ function Ts(s) {
|
|
|
1654
1654
|
}
|
|
1655
1655
|
);
|
|
1656
1656
|
}
|
|
1657
|
-
const
|
|
1658
|
-
for (const s of
|
|
1659
|
-
|
|
1660
|
-
function
|
|
1657
|
+
const ii = /* @__PURE__ */ new Map();
|
|
1658
|
+
for (const s of At)
|
|
1659
|
+
ii.set(s.toLowerCase(), s);
|
|
1660
|
+
function tr(s) {
|
|
1661
1661
|
const t = { value: !1 }, e = /* @__PURE__ */ new Set();
|
|
1662
1662
|
return new Proxy(s, {
|
|
1663
1663
|
get(r, n) {
|
|
@@ -1666,16 +1666,16 @@ function Es(s) {
|
|
|
1666
1666
|
t.value = !1;
|
|
1667
1667
|
};
|
|
1668
1668
|
if (typeof n != "string") return;
|
|
1669
|
-
if (
|
|
1670
|
-
const a =
|
|
1669
|
+
if (At.has(n)) return r[n];
|
|
1670
|
+
const a = ii.get(n.toLowerCase());
|
|
1671
1671
|
if (a)
|
|
1672
1672
|
return e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${a}?`)), r[a];
|
|
1673
1673
|
},
|
|
1674
1674
|
set(r, n, a) {
|
|
1675
1675
|
if (typeof n != "string") return !0;
|
|
1676
1676
|
let o = n;
|
|
1677
|
-
if (
|
|
1678
|
-
const c =
|
|
1677
|
+
if (!At.has(o)) {
|
|
1678
|
+
const c = ii.get(o.toLowerCase());
|
|
1679
1679
|
if (c)
|
|
1680
1680
|
e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${c}?`)), o = c;
|
|
1681
1681
|
else
|
|
@@ -1685,14 +1685,14 @@ function Es(s) {
|
|
|
1685
1685
|
}
|
|
1686
1686
|
});
|
|
1687
1687
|
}
|
|
1688
|
-
class
|
|
1688
|
+
class Ii {
|
|
1689
1689
|
/**
|
|
1690
1690
|
* @param {string} source - User script source code
|
|
1691
1691
|
* @param {object} config - ParticleSystem config (will be proxied)
|
|
1692
1692
|
* @param {number} maxParticles - Max particle count for pre-allocation
|
|
1693
1693
|
*/
|
|
1694
1694
|
constructor(t, e, i) {
|
|
1695
|
-
this._particles = new
|
|
1695
|
+
this._particles = new Ks(), this._configProxy = tr(e), this._configSnapshot = null, this._fn = null, this._error = !1, this.compile(t);
|
|
1696
1696
|
}
|
|
1697
1697
|
/**
|
|
1698
1698
|
* Compile script source into a sandboxed function.
|
|
@@ -1708,7 +1708,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1708
1708
|
var deltaTime = __deltaTime, time = __time;
|
|
1709
1709
|
var currentFrame = __currentFrame, totalFrames = __totalFrames;
|
|
1710
1710
|
var particles = __particles, config = __config, math = __math;
|
|
1711
|
-
${
|
|
1711
|
+
${er(t)}
|
|
1712
1712
|
};`, r = new Function(i);
|
|
1713
1713
|
this._fn = r();
|
|
1714
1714
|
} catch (e) {
|
|
@@ -1730,7 +1730,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1730
1730
|
if (!this._fn || this._error) return { configDirty: !1, particlesDirty: !1 };
|
|
1731
1731
|
this._particles._bind(n, a, o), this._configProxy.__resetDirty();
|
|
1732
1732
|
try {
|
|
1733
|
-
this._fn(t, e, i, r, this._particles, this._configProxy,
|
|
1733
|
+
this._fn(t, e, i, r, this._particles, this._configProxy, ji);
|
|
1734
1734
|
} catch (c) {
|
|
1735
1735
|
console.warn("[ParticleScript] Runtime error:", c.message);
|
|
1736
1736
|
}
|
|
@@ -1744,7 +1744,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1744
1744
|
*/
|
|
1745
1745
|
snapshotConfig(t) {
|
|
1746
1746
|
const e = {};
|
|
1747
|
-
for (const i of
|
|
1747
|
+
for (const i of At) {
|
|
1748
1748
|
const r = t[i];
|
|
1749
1749
|
r !== void 0 && (e[i] = Array.isArray(r) ? [...r] : r);
|
|
1750
1750
|
}
|
|
@@ -1755,7 +1755,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1755
1755
|
*/
|
|
1756
1756
|
restoreConfig(t) {
|
|
1757
1757
|
if (this._configSnapshot) {
|
|
1758
|
-
for (const e of
|
|
1758
|
+
for (const e of At)
|
|
1759
1759
|
if (e in this._configSnapshot) {
|
|
1760
1760
|
const i = this._configSnapshot[e];
|
|
1761
1761
|
t[e] = Array.isArray(i) ? [...i] : i;
|
|
@@ -1769,7 +1769,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1769
1769
|
this._fn = null, this._particles = null, this._configProxy = null, this._configSnapshot = null;
|
|
1770
1770
|
}
|
|
1771
1771
|
}
|
|
1772
|
-
async function
|
|
1772
|
+
async function ir(s) {
|
|
1773
1773
|
const t = new DataView(s);
|
|
1774
1774
|
if (t.getUint32(0, !0) !== 1179937895)
|
|
1775
1775
|
throw new Error("Invalid GLB file: incorrect magic number");
|
|
@@ -1779,12 +1779,12 @@ async function As(s) {
|
|
|
1779
1779
|
const r = t.getUint32(8, !0);
|
|
1780
1780
|
let n = 12, a = null, o = null;
|
|
1781
1781
|
for (; n < r; ) {
|
|
1782
|
-
const
|
|
1783
|
-
if (
|
|
1784
|
-
const
|
|
1785
|
-
a = JSON.parse(
|
|
1786
|
-
} else
|
|
1787
|
-
n += 8 +
|
|
1782
|
+
const T = t.getUint32(n, !0), z = t.getUint32(n + 4, !0), F = s.slice(n + 8, n + 8 + T);
|
|
1783
|
+
if (z === 1313821514) {
|
|
1784
|
+
const J = new TextDecoder("utf-8").decode(F);
|
|
1785
|
+
a = JSON.parse(J);
|
|
1786
|
+
} else z === 5130562 && (o = F);
|
|
1787
|
+
n += 8 + T;
|
|
1788
1788
|
}
|
|
1789
1789
|
if (!a)
|
|
1790
1790
|
throw new Error("GLB file missing JSON chunk");
|
|
@@ -1793,50 +1793,50 @@ async function As(s) {
|
|
|
1793
1793
|
const l = a.meshes[0].primitives[0];
|
|
1794
1794
|
if (!l)
|
|
1795
1795
|
throw new Error("First mesh has no primitives");
|
|
1796
|
-
const
|
|
1797
|
-
if (
|
|
1796
|
+
const d = l.attributes.POSITION;
|
|
1797
|
+
if (d === void 0)
|
|
1798
1798
|
throw new Error("Mesh primitive missing POSITION attribute");
|
|
1799
|
-
const
|
|
1800
|
-
let
|
|
1799
|
+
const S = Kt(a, o, d, 3, 5126);
|
|
1800
|
+
let g;
|
|
1801
1801
|
if (l.attributes.NORMAL !== void 0)
|
|
1802
|
-
|
|
1802
|
+
g = Kt(a, o, l.attributes.NORMAL, 3, 5126);
|
|
1803
1803
|
else {
|
|
1804
|
-
const
|
|
1805
|
-
if (
|
|
1804
|
+
const T = l.indices;
|
|
1805
|
+
if (T === void 0)
|
|
1806
1806
|
throw new Error("Cannot generate normals without indices");
|
|
1807
|
-
const
|
|
1808
|
-
|
|
1807
|
+
const z = zi(a, o, T);
|
|
1808
|
+
g = sr(S, z);
|
|
1809
1809
|
}
|
|
1810
|
-
const
|
|
1811
|
-
if (
|
|
1810
|
+
const p = l.indices;
|
|
1811
|
+
if (p === void 0)
|
|
1812
1812
|
throw new Error("Mesh primitive missing indices");
|
|
1813
|
-
const
|
|
1814
|
-
let
|
|
1815
|
-
l.attributes.TEXCOORD_0 !== void 0 && (
|
|
1816
|
-
let
|
|
1813
|
+
const v = zi(a, o, p), A = S.length / 3, U = v.length;
|
|
1814
|
+
let I = null;
|
|
1815
|
+
l.attributes.TEXCOORD_0 !== void 0 && (I = Kt(a, o, l.attributes.TEXCOORD_0, 2, 5126));
|
|
1816
|
+
let _ = !1;
|
|
1817
1817
|
if (a.materials && a.materials.length > 0) {
|
|
1818
|
-
const
|
|
1819
|
-
|
|
1818
|
+
const T = a.materials[0];
|
|
1819
|
+
T.pbrMetallicRoughness && T.pbrMetallicRoughness.baseColorTexture !== void 0 && (_ = !0);
|
|
1820
1820
|
}
|
|
1821
|
-
let
|
|
1821
|
+
let $ = null;
|
|
1822
1822
|
if (a.skins && a.skins.length > 0)
|
|
1823
1823
|
try {
|
|
1824
|
-
|
|
1825
|
-
} catch (
|
|
1826
|
-
console.warn("Failed to extract animation data:",
|
|
1824
|
+
$ = cr(a, o, l), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", $);
|
|
1825
|
+
} catch (T) {
|
|
1826
|
+
console.warn("Failed to extract animation data:", T);
|
|
1827
1827
|
}
|
|
1828
1828
|
return {
|
|
1829
|
-
positions:
|
|
1830
|
-
normals:
|
|
1831
|
-
indices:
|
|
1832
|
-
texCoords:
|
|
1833
|
-
vertexCount:
|
|
1834
|
-
indexCount:
|
|
1835
|
-
animationData:
|
|
1836
|
-
hasBaseColorTexture:
|
|
1829
|
+
positions: S,
|
|
1830
|
+
normals: g,
|
|
1831
|
+
indices: v,
|
|
1832
|
+
texCoords: I,
|
|
1833
|
+
vertexCount: A,
|
|
1834
|
+
indexCount: U,
|
|
1835
|
+
animationData: $,
|
|
1836
|
+
hasBaseColorTexture: _
|
|
1837
1837
|
};
|
|
1838
1838
|
}
|
|
1839
|
-
function
|
|
1839
|
+
function Kt(s, t, e, i, r) {
|
|
1840
1840
|
const n = s.accessors[e], o = {
|
|
1841
1841
|
SCALAR: 1,
|
|
1842
1842
|
VEC2: 2,
|
|
@@ -1847,12 +1847,12 @@ function xt(s, t, e, i, r) {
|
|
|
1847
1847
|
throw new Error(`Attribute accessor type mismatch: expected ${i} components, got ${o}`);
|
|
1848
1848
|
if (n.componentType !== r)
|
|
1849
1849
|
throw new Error(`Attribute component type mismatch: expected ${r}, got ${n.componentType}`);
|
|
1850
|
-
const l = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0),
|
|
1851
|
-
for (let
|
|
1852
|
-
|
|
1853
|
-
return
|
|
1850
|
+
const l = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), d = n.count, S = new DataView(t, l, d * i * 4), g = new Float32Array(d * i);
|
|
1851
|
+
for (let p = 0; p < d * i; p++)
|
|
1852
|
+
g[p] = S.getFloat32(p * 4, !0);
|
|
1853
|
+
return g;
|
|
1854
1854
|
}
|
|
1855
|
-
function
|
|
1855
|
+
function zi(s, t, e) {
|
|
1856
1856
|
const i = s.accessors[e];
|
|
1857
1857
|
if (i.type !== "SCALAR")
|
|
1858
1858
|
throw new Error(`Indices accessor must be SCALAR, got ${i.type}`);
|
|
@@ -1870,19 +1870,19 @@ function di(s, t, e) {
|
|
|
1870
1870
|
} else
|
|
1871
1871
|
throw new Error(`Unsupported index component type: ${i.componentType}`);
|
|
1872
1872
|
}
|
|
1873
|
-
function
|
|
1873
|
+
function sr(s, t) {
|
|
1874
1874
|
const e = new Float32Array(s.length);
|
|
1875
1875
|
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]], c = [s[n], s[n + 1], s[n + 2]], l = [s[a], s[a + 1], s[a + 2]],
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
],
|
|
1881
|
-
|
|
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]], c = [s[n], s[n + 1], s[n + 2]], l = [s[a], s[a + 1], s[a + 2]], d = [c[0] - o[0], c[1] - o[1], c[2] - o[2]], S = [l[0] - o[0], l[1] - o[1], l[2] - o[2]], g = [
|
|
1877
|
+
d[1] * S[2] - d[2] * S[1],
|
|
1878
|
+
d[2] * S[0] - d[0] * S[2],
|
|
1879
|
+
d[0] * S[1] - d[1] * S[0]
|
|
1880
|
+
], p = Math.sqrt(g[0] * g[0] + g[1] * g[1] + g[2] * g[2]);
|
|
1881
|
+
p > 0 && (g[0] /= p, g[1] /= p, g[2] /= p), e[r] = e[n] = e[a] = g[0], e[r + 1] = e[n + 1] = e[a + 1] = g[1], e[r + 2] = e[n + 2] = e[a + 2] = g[2];
|
|
1882
1882
|
}
|
|
1883
1883
|
return e;
|
|
1884
1884
|
}
|
|
1885
|
-
function
|
|
1885
|
+
function rr(s, t, e) {
|
|
1886
1886
|
const i = s.accessors[e];
|
|
1887
1887
|
if (i.type !== "VEC4")
|
|
1888
1888
|
throw new Error(`JOINTS_0 must be VEC4, got ${i.type}`);
|
|
@@ -1900,7 +1900,7 @@ function Us(s, t, e) {
|
|
|
1900
1900
|
} else
|
|
1901
1901
|
throw new Error(`Unsupported JOINTS_0 component type: ${i.componentType}`);
|
|
1902
1902
|
}
|
|
1903
|
-
function
|
|
1903
|
+
function nr(s, t, e) {
|
|
1904
1904
|
const i = s.accessors[e];
|
|
1905
1905
|
if (i.type !== "VEC4")
|
|
1906
1906
|
throw new Error(`WEIGHTS_0 must be VEC4, got ${i.type}`);
|
|
@@ -1918,7 +1918,7 @@ function Is(s, t, e) {
|
|
|
1918
1918
|
} else
|
|
1919
1919
|
throw new Error(`Unsupported WEIGHTS_0 component type: ${i.componentType}`);
|
|
1920
1920
|
}
|
|
1921
|
-
function
|
|
1921
|
+
function ar(s, t, e) {
|
|
1922
1922
|
const i = s.accessors[e];
|
|
1923
1923
|
if (i.type !== "MAT4")
|
|
1924
1924
|
throw new Error(`Expected MAT4, got ${i.type}`);
|
|
@@ -1929,7 +1929,7 @@ function zs(s, t, e) {
|
|
|
1929
1929
|
c[l] = o.getFloat32(l * 4, !0);
|
|
1930
1930
|
return c;
|
|
1931
1931
|
}
|
|
1932
|
-
function
|
|
1932
|
+
function or(s, t, e) {
|
|
1933
1933
|
const i = s.accessors[e];
|
|
1934
1934
|
if (i.type !== "SCALAR")
|
|
1935
1935
|
throw new Error(`Expected SCALAR, got ${i.type}`);
|
|
@@ -1940,46 +1940,46 @@ function Gs(s, t, e) {
|
|
|
1940
1940
|
c[l] = o.getFloat32(l * 4, !0);
|
|
1941
1941
|
return c;
|
|
1942
1942
|
}
|
|
1943
|
-
function
|
|
1943
|
+
function lr(s, t, e) {
|
|
1944
1944
|
const i = s.accessors[e], n = { VEC3: 3, VEC4: 4 }[i.type];
|
|
1945
1945
|
if (!n)
|
|
1946
1946
|
throw new Error(`Expected VEC3 or VEC4, got ${i.type}`);
|
|
1947
1947
|
if (i.componentType !== 5126)
|
|
1948
1948
|
throw new Error(`Expected FLOAT component type, got ${i.componentType}`);
|
|
1949
|
-
const o = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), c = i.count, l = new DataView(t, o, c * n * 4),
|
|
1950
|
-
for (let
|
|
1951
|
-
|
|
1952
|
-
return
|
|
1949
|
+
const o = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), c = i.count, l = new DataView(t, o, c * n * 4), d = new Float32Array(c * n);
|
|
1950
|
+
for (let S = 0; S < c * n; S++)
|
|
1951
|
+
d[S] = l.getFloat32(S * 4, !0);
|
|
1952
|
+
return d;
|
|
1953
1953
|
}
|
|
1954
|
-
function
|
|
1955
|
-
const i = s.skins[0], r = i.joints, n =
|
|
1954
|
+
function cr(s, t, e) {
|
|
1955
|
+
const i = s.skins[0], r = i.joints, n = ar(s, t, i.inverseBindMatrices), a = e.attributes.JOINTS_0 !== void 0 ? rr(s, t, e.attributes.JOINTS_0) : null, o = e.attributes.WEIGHTS_0 !== void 0 ? nr(s, t, e.attributes.WEIGHTS_0) : null;
|
|
1956
1956
|
if (!a || !o)
|
|
1957
1957
|
throw new Error("Mesh missing JOINTS_0 or WEIGHTS_0 attributes");
|
|
1958
|
-
const c = s.nodes.map((
|
|
1959
|
-
translation:
|
|
1960
|
-
rotation:
|
|
1961
|
-
scale:
|
|
1962
|
-
children:
|
|
1963
|
-
name:
|
|
1958
|
+
const c = s.nodes.map((d) => ({
|
|
1959
|
+
translation: d.translation || [0, 0, 0],
|
|
1960
|
+
rotation: d.rotation || [0, 0, 0, 1],
|
|
1961
|
+
scale: d.scale || [1, 1, 1],
|
|
1962
|
+
children: d.children || [],
|
|
1963
|
+
name: d.name || ""
|
|
1964
1964
|
})), l = [];
|
|
1965
1965
|
if (s.animations && s.animations.length > 0)
|
|
1966
|
-
for (const
|
|
1967
|
-
const
|
|
1968
|
-
let
|
|
1969
|
-
for (const
|
|
1970
|
-
const
|
|
1971
|
-
|
|
1972
|
-
targetNode:
|
|
1973
|
-
targetPath:
|
|
1974
|
-
interpolation:
|
|
1975
|
-
timestamps:
|
|
1976
|
-
values:
|
|
1966
|
+
for (const d of s.animations) {
|
|
1967
|
+
const S = [];
|
|
1968
|
+
let g = 0;
|
|
1969
|
+
for (const p of d.channels) {
|
|
1970
|
+
const v = d.samplers[p.sampler], A = or(s, t, v.input), U = lr(s, t, v.output), I = A[A.length - 1];
|
|
1971
|
+
I > g && (g = I), S.push({
|
|
1972
|
+
targetNode: p.target.node,
|
|
1973
|
+
targetPath: p.target.path,
|
|
1974
|
+
interpolation: v.interpolation || "LINEAR",
|
|
1975
|
+
timestamps: A,
|
|
1976
|
+
values: U
|
|
1977
1977
|
});
|
|
1978
1978
|
}
|
|
1979
1979
|
l.push({
|
|
1980
|
-
name:
|
|
1981
|
-
duration:
|
|
1982
|
-
channels:
|
|
1980
|
+
name: d.name || `Animation ${l.length}`,
|
|
1981
|
+
duration: g,
|
|
1982
|
+
channels: S
|
|
1983
1983
|
});
|
|
1984
1984
|
}
|
|
1985
1985
|
return {
|
|
@@ -1991,7 +1991,7 @@ function Ds(s, t, e) {
|
|
|
1991
1991
|
animations: l
|
|
1992
1992
|
};
|
|
1993
1993
|
}
|
|
1994
|
-
async function
|
|
1994
|
+
async function Fi(s) {
|
|
1995
1995
|
const t = new DataView(s);
|
|
1996
1996
|
if (t.getUint32(0, !0) !== 1179937895)
|
|
1997
1997
|
throw new Error("Invalid GLB file: incorrect magic number");
|
|
@@ -2001,12 +2001,12 @@ async function fi(s) {
|
|
|
2001
2001
|
const r = t.getUint32(8, !0);
|
|
2002
2002
|
let n = 12, a = null, o = null;
|
|
2003
2003
|
for (; n < r; ) {
|
|
2004
|
-
const
|
|
2005
|
-
if (
|
|
2006
|
-
const
|
|
2007
|
-
a = JSON.parse(
|
|
2008
|
-
} else
|
|
2009
|
-
n += 8 +
|
|
2004
|
+
const $ = t.getUint32(n, !0), T = t.getUint32(n + 4, !0), z = s.slice(n + 8, n + 8 + $);
|
|
2005
|
+
if (T === 1313821514) {
|
|
2006
|
+
const Z = new TextDecoder("utf-8").decode(z);
|
|
2007
|
+
a = JSON.parse(Z);
|
|
2008
|
+
} else T === 5130562 && (o = z);
|
|
2009
|
+
n += 8 + $;
|
|
2010
2010
|
}
|
|
2011
2011
|
if (!a)
|
|
2012
2012
|
throw new Error("GLB file missing JSON chunk");
|
|
@@ -2018,48 +2018,48 @@ async function fi(s) {
|
|
|
2018
2018
|
const l = c.pbrMetallicRoughness.baseColorTexture.index;
|
|
2019
2019
|
if (!a.textures || !a.textures[l])
|
|
2020
2020
|
return null;
|
|
2021
|
-
const
|
|
2022
|
-
if (
|
|
2021
|
+
const S = a.textures[l].source;
|
|
2022
|
+
if (S === void 0 || !a.images || !a.images[S])
|
|
2023
2023
|
return null;
|
|
2024
|
-
const
|
|
2025
|
-
if (
|
|
2024
|
+
const g = a.images[S], p = g.mimeType || "image/png";
|
|
2025
|
+
if (g.bufferView === void 0)
|
|
2026
2026
|
return null;
|
|
2027
2027
|
if (!o)
|
|
2028
2028
|
throw new Error("GLB file missing BIN chunk (required for embedded textures)");
|
|
2029
|
-
const
|
|
2030
|
-
return { imageBlob: new Blob([
|
|
2029
|
+
const v = a.bufferViews[g.bufferView], A = v.byteOffset || 0, U = v.byteLength, I = o.slice(A, A + U);
|
|
2030
|
+
return { imageBlob: new Blob([I], { type: p }), mimeType: p };
|
|
2031
2031
|
}
|
|
2032
|
-
function
|
|
2032
|
+
function ur(s, t, e, i) {
|
|
2033
2033
|
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
2034
|
}
|
|
2035
|
-
function
|
|
2035
|
+
function dr(s, t, e, i) {
|
|
2036
2036
|
i = i || [0, 0, 0, 0];
|
|
2037
2037
|
let r = s[0] * t[0] + s[1] * t[1] + s[2] * t[2] + s[3] * t[3], n = 1;
|
|
2038
2038
|
if (r < 0 && (r = -r, n = -1), r > 0.9995) {
|
|
2039
2039
|
i[0] = s[0] + (n * t[0] - s[0]) * e, i[1] = s[1] + (n * t[1] - s[1]) * e, i[2] = s[2] + (n * t[2] - s[2]) * e, i[3] = s[3] + (n * t[3] - s[3]) * e;
|
|
2040
|
-
const
|
|
2041
|
-
return
|
|
2040
|
+
const d = Math.sqrt(i[0] * i[0] + i[1] * i[1] + i[2] * i[2] + i[3] * i[3]);
|
|
2041
|
+
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
2042
|
}
|
|
2043
2043
|
const a = Math.acos(r), o = Math.sin(a), c = Math.sin((1 - e) * a) / o, l = Math.sin(e * a) / o;
|
|
2044
2044
|
return i[0] = s[0] * c + n * t[0] * l, i[1] = s[1] * c + n * t[1] * l, i[2] = s[2] * c + n * t[2] * l, i[3] = s[3] * c + n * t[3] * l, i;
|
|
2045
2045
|
}
|
|
2046
|
-
function
|
|
2047
|
-
const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i, c = r + r, l = e * a,
|
|
2048
|
-
return
|
|
2046
|
+
function fr(s, t) {
|
|
2047
|
+
const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i, c = r + r, l = e * a, d = e * o, S = e * c, g = i * o, p = i * c, v = r * c, A = n * a, U = n * o, I = n * c, _ = t || new Float32Array(16);
|
|
2048
|
+
return _[0] = 1 - (g + v), _[1] = d + I, _[2] = S - U, _[3] = 0, _[4] = d - I, _[5] = 1 - (l + v), _[6] = p + A, _[7] = 0, _[8] = S + U, _[9] = p - A, _[10] = 1 - (l + g), _[11] = 0, _[12] = 0, _[13] = 0, _[14] = 0, _[15] = 1, _;
|
|
2049
2049
|
}
|
|
2050
|
-
const
|
|
2051
|
-
function
|
|
2052
|
-
const r =
|
|
2050
|
+
const pr = new Float32Array(16);
|
|
2051
|
+
function hr(s, t, e, i) {
|
|
2052
|
+
const r = fr(t, pr), n = i || new Float32Array(16);
|
|
2053
2053
|
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
2054
|
}
|
|
2055
|
-
function
|
|
2055
|
+
function Gi(s, t, e) {
|
|
2056
2056
|
const i = e || new Float32Array(16);
|
|
2057
2057
|
for (let r = 0; r < 4; r++)
|
|
2058
2058
|
for (let n = 0; n < 4; n++)
|
|
2059
2059
|
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
2060
|
return i;
|
|
2061
2061
|
}
|
|
2062
|
-
class
|
|
2062
|
+
class mr {
|
|
2063
2063
|
constructor(t) {
|
|
2064
2064
|
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
2065
|
for (let e = 0; e < this.nodes.length; e++)
|
|
@@ -2090,8 +2090,8 @@ class ks {
|
|
|
2090
2090
|
this._gpuDevice = t, this._gpuOutputBuffer = e;
|
|
2091
2091
|
const r = this.restPositions.length / 3, n = new Float32Array(r * 8);
|
|
2092
2092
|
for (let c = 0; c < r; c++) {
|
|
2093
|
-
const l = c * 8,
|
|
2094
|
-
n[l] = this.restPositions[
|
|
2093
|
+
const l = c * 8, d = c * 3, S = c * 2;
|
|
2094
|
+
n[l] = this.restPositions[d], n[l + 1] = this.restPositions[d + 1], n[l + 2] = this.restPositions[d + 2], n[l + 3] = this.restNormals[d], n[l + 4] = this.restNormals[d + 1], n[l + 5] = this.restNormals[d + 2], n[l + 6] = i ? i[S] : 0, n[l + 7] = i ? i[S + 1] : 0;
|
|
2095
2095
|
}
|
|
2096
2096
|
this._gpuRestDataBuffer = t.createBuffer({
|
|
2097
2097
|
size: n.byteLength,
|
|
@@ -2126,7 +2126,7 @@ class ks {
|
|
|
2126
2126
|
this._gpuSkinningPipeline = t.createComputePipeline({
|
|
2127
2127
|
layout: t.createPipelineLayout({ bindGroupLayouts: [o] }),
|
|
2128
2128
|
compute: {
|
|
2129
|
-
module: t.createShaderModule({ code:
|
|
2129
|
+
module: t.createShaderModule({ code: Zs }),
|
|
2130
2130
|
entryPoint: "main"
|
|
2131
2131
|
}
|
|
2132
2132
|
}), this._gpuSkinningBindGroup = t.createBindGroup({
|
|
@@ -2216,11 +2216,11 @@ class ks {
|
|
|
2216
2216
|
return this._extractValue(n, r.length - 1, o, i);
|
|
2217
2217
|
let c = 0, l = r.length - 1;
|
|
2218
2218
|
for (; l - c > 1; ) {
|
|
2219
|
-
const
|
|
2220
|
-
r[
|
|
2219
|
+
const A = Math.floor((c + l) / 2);
|
|
2220
|
+
r[A] <= e ? c = A : l = A;
|
|
2221
2221
|
}
|
|
2222
|
-
const
|
|
2223
|
-
return a === "STEP" ? (i[0] =
|
|
2222
|
+
const d = r[c], S = r[l], g = (e - d) / (S - d), p = this._extractValue(n, c, o, this._sV0), v = this._extractValue(n, l, o, this._sV1);
|
|
2223
|
+
return a === "STEP" ? (i[0] = p[0], i[1] = p[1], i[2] = p[2], o === "rotation" && (i[3] = p[3]), i) : o === "rotation" ? dr(p, v, g, i) : ur(p, v, g, i);
|
|
2224
2224
|
}
|
|
2225
2225
|
/**
|
|
2226
2226
|
* Extract value from values array at the given index.
|
|
@@ -2245,7 +2245,7 @@ class ks {
|
|
|
2245
2245
|
let n = r.translation, a = r.rotation, o = r.scale;
|
|
2246
2246
|
for (const c of e.channels)
|
|
2247
2247
|
c.targetNode === i && (c.targetPath === "translation" ? n = this._sampleChannel(c, t, this._scrT) : c.targetPath === "rotation" ? a = this._sampleChannel(c, t, this._scrR) : c.targetPath === "scale" && (o = this._sampleChannel(c, t, this._scrS)));
|
|
2248
|
-
|
|
2248
|
+
hr(n, a, o, this.jointLocalTransforms[i]);
|
|
2249
2249
|
}
|
|
2250
2250
|
}
|
|
2251
2251
|
/**
|
|
@@ -2255,7 +2255,7 @@ class ks {
|
|
|
2255
2255
|
const t = this._parentMap;
|
|
2256
2256
|
for (const e of this.topologicalOrder) {
|
|
2257
2257
|
const i = t[e];
|
|
2258
|
-
i === -1 ? this.jointGlobalTransforms[e].set(this.jointLocalTransforms[e]) :
|
|
2258
|
+
i === -1 ? this.jointGlobalTransforms[e].set(this.jointLocalTransforms[e]) : Gi(
|
|
2259
2259
|
this.jointGlobalTransforms[i],
|
|
2260
2260
|
this.jointLocalTransforms[e],
|
|
2261
2261
|
this.jointGlobalTransforms[e]
|
|
@@ -2268,7 +2268,7 @@ class ks {
|
|
|
2268
2268
|
_computeFinalMatrices() {
|
|
2269
2269
|
for (let t = 0; t < this.joints.length; t++) {
|
|
2270
2270
|
const e = this.joints[t], i = this.jointGlobalTransforms[e];
|
|
2271
|
-
|
|
2271
|
+
Gi(i, this._invBindViews[t], this.jointFinalMatrices[t]);
|
|
2272
2272
|
}
|
|
2273
2273
|
}
|
|
2274
2274
|
/**
|
|
@@ -2278,20 +2278,20 @@ class ks {
|
|
|
2278
2278
|
_applySkinning() {
|
|
2279
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, c = this.jointFinalMatrices;
|
|
2280
2280
|
for (let l = 0; l < t; l++) {
|
|
2281
|
-
const
|
|
2282
|
-
let
|
|
2283
|
-
for (let
|
|
2284
|
-
const
|
|
2285
|
-
if (
|
|
2286
|
-
const
|
|
2287
|
-
|
|
2281
|
+
const d = l * 3, S = l * 4, g = e[d], p = e[d + 1], v = e[d + 2], A = i[d], U = i[d + 1], I = i[d + 2];
|
|
2282
|
+
let _ = 0, $ = 0, T = 0, z = 0, F = 0, Z = 0;
|
|
2283
|
+
for (let ee = 0; ee < 4; ee++) {
|
|
2284
|
+
const K = a[S + ee];
|
|
2285
|
+
if (K === 0) continue;
|
|
2286
|
+
const q = c[o[S + ee]];
|
|
2287
|
+
_ += (q[0] * g + q[4] * p + q[8] * v + q[12]) * K, $ += (q[1] * g + q[5] * p + q[9] * v + q[13]) * K, T += (q[2] * g + q[6] * p + q[10] * v + q[14]) * K, z += (q[0] * A + q[4] * U + q[8] * I) * K, F += (q[1] * A + q[5] * U + q[9] * I) * K, Z += (q[2] * A + q[6] * U + q[10] * I) * K;
|
|
2288
2288
|
}
|
|
2289
|
-
const
|
|
2290
|
-
|
|
2289
|
+
const J = Math.sqrt(z * z + F * F + Z * Z);
|
|
2290
|
+
J > 1e-4 && (n[d] = z / J, n[d + 1] = F / J, n[d + 2] = Z / J), r[d] = _, r[d + 1] = $, r[d + 2] = T;
|
|
2291
2291
|
}
|
|
2292
2292
|
}
|
|
2293
2293
|
}
|
|
2294
|
-
class
|
|
2294
|
+
class yr {
|
|
2295
2295
|
constructor({ duration: t = 0, loop: e = !1, playbackRate: i = 1 } = {}) {
|
|
2296
2296
|
this.currentTime = 0, this.duration = t, this.loop = e, this.playbackRate = i, this.paused = !1, this._justLooped = !1;
|
|
2297
2297
|
}
|
|
@@ -2312,7 +2312,7 @@ class js {
|
|
|
2312
2312
|
this.currentTime = Math.max(0, t || 0), this._justLooped = !1;
|
|
2313
2313
|
}
|
|
2314
2314
|
}
|
|
2315
|
-
const
|
|
2315
|
+
const Di = {
|
|
2316
2316
|
linear: (s) => s,
|
|
2317
2317
|
easeInQuad: (s) => s * s,
|
|
2318
2318
|
easeOutQuad: (s) => 1 - (1 - s) * (1 - s),
|
|
@@ -2331,26 +2331,26 @@ const pi = {
|
|
|
2331
2331
|
return Math.pow(2, -10 * s) * Math.sin((s * 10 - 0.75) * t) + 1;
|
|
2332
2332
|
}
|
|
2333
2333
|
};
|
|
2334
|
-
function
|
|
2335
|
-
const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, c = 3 * (i - t) - o, l = 1 - o - c,
|
|
2336
|
-
return (
|
|
2337
|
-
if (
|
|
2338
|
-
if (
|
|
2339
|
-
let
|
|
2340
|
-
for (let
|
|
2341
|
-
const
|
|
2342
|
-
if (Math.abs(
|
|
2343
|
-
const
|
|
2344
|
-
if (Math.abs(
|
|
2345
|
-
|
|
2334
|
+
function gr(s, t, e, i) {
|
|
2335
|
+
const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, c = 3 * (i - t) - o, l = 1 - o - c, d = (p) => ((a * p + n) * p + r) * p, S = (p) => ((l * p + c) * p + o) * p, g = (p) => (3 * a * p + 2 * n) * p + r;
|
|
2336
|
+
return (p) => {
|
|
2337
|
+
if (p <= 0) return 0;
|
|
2338
|
+
if (p >= 1) return 1;
|
|
2339
|
+
let v = p;
|
|
2340
|
+
for (let A = 0; A < 8; A++) {
|
|
2341
|
+
const U = d(v) - p;
|
|
2342
|
+
if (Math.abs(U) < 1e-5) break;
|
|
2343
|
+
const I = g(v);
|
|
2344
|
+
if (Math.abs(I) < 1e-6) break;
|
|
2345
|
+
v -= U / I;
|
|
2346
2346
|
}
|
|
2347
|
-
return
|
|
2347
|
+
return S(v);
|
|
2348
2348
|
};
|
|
2349
2349
|
}
|
|
2350
|
-
function
|
|
2351
|
-
return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ?
|
|
2350
|
+
function qi(s, t) {
|
|
2351
|
+
return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ? gr(s[0], s[1], s[2], s[3])(t) : (Di[s] || Di.linear)(t);
|
|
2352
2352
|
}
|
|
2353
|
-
function
|
|
2353
|
+
function br(s, t) {
|
|
2354
2354
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2355
2355
|
if (s.length === 1 || t <= s[0].t) return s[0].v;
|
|
2356
2356
|
const e = s[s.length - 1];
|
|
@@ -2359,12 +2359,12 @@ function qs(s, t) {
|
|
|
2359
2359
|
const r = s[i], n = s[i + 1];
|
|
2360
2360
|
if (t >= r.t && t <= n.t) {
|
|
2361
2361
|
const a = n.t - r.t, o = a > 0 ? (t - r.t) / a : 0;
|
|
2362
|
-
return r.v + (n.v - r.v) *
|
|
2362
|
+
return r.v + (n.v - r.v) * qi(r.ease, o);
|
|
2363
2363
|
}
|
|
2364
2364
|
}
|
|
2365
2365
|
return e.v;
|
|
2366
2366
|
}
|
|
2367
|
-
function
|
|
2367
|
+
function Sr(s, t, e) {
|
|
2368
2368
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2369
2369
|
const i = s.length, r = s[i - 1];
|
|
2370
2370
|
let n, a, o;
|
|
@@ -2374,26 +2374,26 @@ function Hs(s, t, e) {
|
|
|
2374
2374
|
n = a = r.v, o = 0;
|
|
2375
2375
|
else {
|
|
2376
2376
|
n = a = r.v, o = 0;
|
|
2377
|
-
for (let
|
|
2378
|
-
const
|
|
2379
|
-
if (t >=
|
|
2380
|
-
const
|
|
2381
|
-
n =
|
|
2377
|
+
for (let S = 0; S < i - 1; S++) {
|
|
2378
|
+
const g = s[S], p = s[S + 1];
|
|
2379
|
+
if (t >= g.t && t <= p.t) {
|
|
2380
|
+
const v = p.t - g.t;
|
|
2381
|
+
n = g.v, a = p.v, o = qi(g.ease, v > 0 ? (t - g.t) / v : 0);
|
|
2382
2382
|
break;
|
|
2383
2383
|
}
|
|
2384
2384
|
}
|
|
2385
2385
|
}
|
|
2386
|
-
const c = n[0] + (a[0] - n[0]) * o, l = n[1] + (a[1] - n[1]) * o,
|
|
2387
|
-
return e ? (e[0] = c, e[1] = l, e[2] =
|
|
2386
|
+
const c = n[0] + (a[0] - n[0]) * o, l = n[1] + (a[1] - n[1]) * o, d = n[2] + (a[2] - n[2]) * o;
|
|
2387
|
+
return e ? (e[0] = c, e[1] = l, e[2] = d, e) : [c, l, d];
|
|
2388
2388
|
}
|
|
2389
|
-
const
|
|
2390
|
-
function
|
|
2389
|
+
const xr = ["gravityStrength", "emissionRate", "damping", "particleSize", "particleSpeed"], vr = { 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 };
|
|
2390
|
+
function Vi(s) {
|
|
2391
2391
|
const t = atob(s), e = new Uint8Array(t.length);
|
|
2392
2392
|
for (let i = 0; i < t.length; i++)
|
|
2393
2393
|
e[i] = t.charCodeAt(i);
|
|
2394
2394
|
return e.buffer;
|
|
2395
2395
|
}
|
|
2396
|
-
class
|
|
2396
|
+
class Qt {
|
|
2397
2397
|
constructor(t, e) {
|
|
2398
2398
|
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
2399
|
size: this.MAX_PARTICLES * 8 * 4,
|
|
@@ -2419,7 +2419,7 @@ class vt {
|
|
|
2419
2419
|
// intensity (f32) + padding
|
|
2420
2420
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
2421
2421
|
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.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 ms(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({
|
|
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({
|
|
2423
2423
|
enabled: !0,
|
|
2424
2424
|
shape: e.confinementShape,
|
|
2425
2425
|
mode: e.confinementMode,
|
|
@@ -2432,7 +2432,7 @@ class vt {
|
|
|
2432
2432
|
enabled: !0,
|
|
2433
2433
|
strength: e.softBoundaryStrength,
|
|
2434
2434
|
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
|
|
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 Ii(e.script, e, this.MAX_PARTICLES)), this.initComputePipeline(t);
|
|
2436
2436
|
}
|
|
2437
2437
|
async initComputePipeline(t) {
|
|
2438
2438
|
this.computeReady = await this.physics.initComputePipeline(this.instanceBuffer, this.velocityBuffer, this.trailBuffer);
|
|
@@ -2442,7 +2442,7 @@ class vt {
|
|
|
2442
2442
|
* @param {string|null} source - Script source code, or null to disable
|
|
2443
2443
|
*/
|
|
2444
2444
|
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
|
|
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 Ii(t, this.config, this.MAX_PARTICLES), this._particleScript.snapshotConfig(this.config)) : delete this.config.script;
|
|
2446
2446
|
}
|
|
2447
2447
|
async setTexture(t) {
|
|
2448
2448
|
this.destroyed || (this.textureManager.destroyTexture(this.particleTexture), this.particleTexture = await this.textureManager.loadTexture(t), this.config.textureEnabled = !0, this.updateAppearanceUniform(), this.updateBuffers());
|
|
@@ -2453,7 +2453,7 @@ class vt {
|
|
|
2453
2453
|
async setGLBModel(t) {
|
|
2454
2454
|
try {
|
|
2455
2455
|
this.glbRawArrayBuffer = t;
|
|
2456
|
-
const e = await
|
|
2456
|
+
const e = await ir(t);
|
|
2457
2457
|
this.glbMeshData = e, this.config.glbHasTexture = e.hasBaseColorTexture || !1;
|
|
2458
2458
|
const i = new Float32Array(e.vertexCount * 8);
|
|
2459
2459
|
for (let r = 0; r < e.vertexCount; r++) {
|
|
@@ -2469,7 +2469,7 @@ class vt {
|
|
|
2469
2469
|
usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST,
|
|
2470
2470
|
label: "glbIndexBuffer"
|
|
2471
2471
|
}), 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
|
|
2472
|
+
this.glbAnimator = new mr(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
2473
|
try {
|
|
2474
2474
|
await this.glbAnimator.initGPUSkinning(this.device, this.glbVertexBuffer, e.texCoords);
|
|
2475
2475
|
} catch (r) {
|
|
@@ -2531,7 +2531,7 @@ class vt {
|
|
|
2531
2531
|
if (this.destroyed) return;
|
|
2532
2532
|
let t = 0;
|
|
2533
2533
|
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 =
|
|
2534
|
+
const e = vr[this.config.particleShape] ?? 0, i = this._appearanceData;
|
|
2535
2535
|
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
2536
|
const r = this.config.followSystemTranslation ?? !0;
|
|
2537
2537
|
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);
|
|
@@ -2593,8 +2593,8 @@ class vt {
|
|
|
2593
2593
|
this._emitSimRotY = this._simRotY || 0;
|
|
2594
2594
|
const e = t * 8, i = t * 4;
|
|
2595
2595
|
if (this._simRotMatrix) {
|
|
2596
|
-
const r = this._simRotMatrix, n = this.particleData[e], a = this.particleData[e + 1], o = this.particleData[e + 2], c = this.particleVelocities[i], l = this.particleVelocities[i + 1],
|
|
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] * c + r[1] * l + r[2] *
|
|
2596
|
+
const r = this._simRotMatrix, n = this.particleData[e], a = this.particleData[e + 1], o = this.particleData[e + 2], c = this.particleVelocities[i], l = this.particleVelocities[i + 1], d = this.particleVelocities[i + 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] * c + r[1] * l + r[2] * d, this.particleVelocities[i + 1] = r[3] * c + r[4] * l + r[5] * d, this.particleVelocities[i + 2] = r[6] * c + r[7] * l + r[8] * d;
|
|
2598
2598
|
}
|
|
2599
2599
|
(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
2600
|
}
|
|
@@ -2626,20 +2626,20 @@ class vt {
|
|
|
2626
2626
|
const r = this.config.startAt || 0, n = r > 0 && i < r;
|
|
2627
2627
|
if (this._particleScript && this._scriptReadbackReady) {
|
|
2628
2628
|
this._scriptReadbackReady = !1, this._scriptTime += t, this._scriptFrame++;
|
|
2629
|
-
const
|
|
2630
|
-
if (
|
|
2629
|
+
const d = this.config.emissionDurationInfinite ? 1 / 0 : (this.config.emissionDuration || 0) + (this.config.lifetime || 0);
|
|
2630
|
+
if (d > 0 && this._scriptTime >= d && !this._scriptConfigRestored)
|
|
2631
2631
|
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
2632
|
else if (!this._scriptConfigRestored) {
|
|
2633
|
-
const
|
|
2633
|
+
const S = d > 0 ? Math.ceil(d / 0.016666666666666666) : 0, { configDirty: g, particlesDirty: p } = this._particleScript.execute(
|
|
2634
2634
|
t,
|
|
2635
2635
|
this._scriptTime,
|
|
2636
2636
|
this._scriptFrame,
|
|
2637
|
-
|
|
2637
|
+
S,
|
|
2638
2638
|
this._scriptParticleData,
|
|
2639
2639
|
this._scriptVelocityData,
|
|
2640
2640
|
this.activeParticles
|
|
2641
2641
|
);
|
|
2642
|
-
|
|
2642
|
+
p && this.activeParticles > 0 && (this.device.queue.writeBuffer(
|
|
2643
2643
|
this.instanceBuffer,
|
|
2644
2644
|
0,
|
|
2645
2645
|
this._scriptParticleData,
|
|
@@ -2651,58 +2651,58 @@ class vt {
|
|
|
2651
2651
|
this._scriptVelocityData,
|
|
2652
2652
|
0,
|
|
2653
2653
|
this.activeParticles * 4
|
|
2654
|
-
)),
|
|
2654
|
+
)), g && (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
2655
|
}
|
|
2656
2656
|
}
|
|
2657
2657
|
this.physics.physicsAccumulator += t;
|
|
2658
2658
|
const a = performance.now() / 1e3, c = a - this.physics.lastUpdateTime > 1 / this.physics.minUpdatesPerSecond, l = this.activeParticles;
|
|
2659
2659
|
if (!n && !this.emitting && !this.config.burstMode && !this.config.followSystemId && this.currentEmissionTime < this.effectiveEmissionDuration && (this.emitting = !0), !n && this.emitting)
|
|
2660
2660
|
if (this.currentEmissionTime += t, this.currentEmissionTime < this.effectiveEmissionDuration) {
|
|
2661
|
-
const
|
|
2662
|
-
let
|
|
2661
|
+
const d = this.activeParticles;
|
|
2662
|
+
let S = !1;
|
|
2663
2663
|
if (this.config.followSystemId) {
|
|
2664
2664
|
if (this._pendingFollowEmissions.length > 0) {
|
|
2665
|
-
const
|
|
2666
|
-
for (let
|
|
2667
|
-
const
|
|
2665
|
+
const g = this._pendingFollowEmissions.length / 6;
|
|
2666
|
+
for (let p = 0; p < g; p++) {
|
|
2667
|
+
const v = p * 6;
|
|
2668
2668
|
if (this.emitFollowerParticle(
|
|
2669
|
-
this._pendingFollowEmissions[
|
|
2670
|
-
this._pendingFollowEmissions[
|
|
2671
|
-
this._pendingFollowEmissions[
|
|
2669
|
+
this._pendingFollowEmissions[v],
|
|
2670
|
+
this._pendingFollowEmissions[v + 1],
|
|
2671
|
+
this._pendingFollowEmissions[v + 2]
|
|
2672
2672
|
))
|
|
2673
|
-
|
|
2673
|
+
S = !0;
|
|
2674
2674
|
else
|
|
2675
2675
|
break;
|
|
2676
2676
|
}
|
|
2677
2677
|
}
|
|
2678
2678
|
} else {
|
|
2679
|
-
let
|
|
2680
|
-
const
|
|
2681
|
-
this.activeParticles < this.particleCount &&
|
|
2682
|
-
for (let
|
|
2679
|
+
let g = 0;
|
|
2680
|
+
const p = Math.max(0, this.config.emissionRate || 0);
|
|
2681
|
+
this.activeParticles < this.particleCount && p > 0 ? (this.emissionAccumulator += p * t, g = Math.floor(this.emissionAccumulator + 1e-9), g > 0 && (this.emissionAccumulator -= g)) : this.activeParticles >= this.particleCount && (this.emissionAccumulator = 0);
|
|
2682
|
+
for (let v = 0; v < g; v++)
|
|
2683
2683
|
if (this.emitParticle())
|
|
2684
|
-
|
|
2684
|
+
S = !0;
|
|
2685
2685
|
else {
|
|
2686
2686
|
this.emissionAccumulator = 0;
|
|
2687
2687
|
break;
|
|
2688
2688
|
}
|
|
2689
2689
|
}
|
|
2690
|
-
if (
|
|
2691
|
-
const
|
|
2690
|
+
if (S) {
|
|
2691
|
+
const g = this.activeParticles - d, p = d * 8, v = d * 4;
|
|
2692
2692
|
this.device.queue.writeBuffer(
|
|
2693
2693
|
this.instanceBuffer,
|
|
2694
|
-
|
|
2694
|
+
p * 4,
|
|
2695
2695
|
// Offset in bytes (float32 = 4 bytes)
|
|
2696
2696
|
this.particleData,
|
|
2697
|
-
|
|
2698
|
-
|
|
2697
|
+
p,
|
|
2698
|
+
g * 8
|
|
2699
2699
|
), this.device.queue.writeBuffer(
|
|
2700
2700
|
this.velocityBuffer,
|
|
2701
|
-
|
|
2701
|
+
v * 4,
|
|
2702
2702
|
// Offset in bytes (float32 = 4 bytes)
|
|
2703
2703
|
this.particleVelocities,
|
|
2704
|
-
|
|
2705
|
-
|
|
2704
|
+
v,
|
|
2705
|
+
g * 4
|
|
2706
2706
|
);
|
|
2707
2707
|
}
|
|
2708
2708
|
} else
|
|
@@ -2729,8 +2729,8 @@ class vt {
|
|
|
2729
2729
|
this._scriptVelocityData,
|
|
2730
2730
|
this.instanceBuffer,
|
|
2731
2731
|
this.velocityBuffer
|
|
2732
|
-
).then((
|
|
2733
|
-
this._scriptReadbackPending = !1,
|
|
2732
|
+
).then((d) => {
|
|
2733
|
+
this._scriptReadbackPending = !1, d.shouldUpdate && (this._scriptReadbackReady = !0);
|
|
2734
2734
|
}).catch(() => {
|
|
2735
2735
|
this._scriptReadbackPending = !1;
|
|
2736
2736
|
}));
|
|
@@ -2758,8 +2758,8 @@ class vt {
|
|
|
2758
2758
|
if (e !== r) {
|
|
2759
2759
|
const o = r * 8, c = e * 8;
|
|
2760
2760
|
this.particleData.copyWithin(c, o, o + 8);
|
|
2761
|
-
const l = r * 4,
|
|
2762
|
-
this.particleVelocities.copyWithin(
|
|
2761
|
+
const l = r * 4, d = e * 4;
|
|
2762
|
+
this.particleVelocities.copyWithin(d, l, l + 4), i = !0;
|
|
2763
2763
|
}
|
|
2764
2764
|
e++;
|
|
2765
2765
|
}
|
|
@@ -2788,17 +2788,17 @@ class vt {
|
|
|
2788
2788
|
}
|
|
2789
2789
|
updateParticleVelocities() {
|
|
2790
2790
|
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], c = this.particleVelocities[i + 1], l = this.particleVelocities[i + 2],
|
|
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], c = this.particleVelocities[i + 1], l = this.particleVelocities[i + 2], d = Math.sqrt(
|
|
2792
2792
|
o * o + c * c + l * l
|
|
2793
2793
|
);
|
|
2794
|
-
if (
|
|
2795
|
-
const
|
|
2796
|
-
this.particleVelocities[i] = o /
|
|
2794
|
+
if (d > 1e-3) {
|
|
2795
|
+
const S = this.config.particleSpeed * 2;
|
|
2796
|
+
this.particleVelocities[i] = o / d * S, this.particleVelocities[i + 1] = c / d * S, this.particleVelocities[i + 2] = l / d * S;
|
|
2797
2797
|
} else {
|
|
2798
|
-
const
|
|
2799
|
-
if (
|
|
2800
|
-
const
|
|
2801
|
-
this.particleVelocities[i] = r /
|
|
2798
|
+
const S = Math.sqrt(r * r + n * n + a * a);
|
|
2799
|
+
if (S > 1e-3) {
|
|
2800
|
+
const g = this.config.particleSpeed * 2;
|
|
2801
|
+
this.particleVelocities[i] = r / S * g, this.particleVelocities[i + 1] = n / S * g, this.particleVelocities[i + 2] = a / S * g;
|
|
2802
2802
|
} else
|
|
2803
2803
|
this.particleVelocities[i] = 0, this.particleVelocities[i + 1] = this.config.particleSpeed * 2, this.particleVelocities[i + 2] = 0;
|
|
2804
2804
|
}
|
|
@@ -2843,16 +2843,16 @@ class vt {
|
|
|
2843
2843
|
this.physics.setSoftBoundary(t);
|
|
2844
2844
|
}
|
|
2845
2845
|
}
|
|
2846
|
-
class
|
|
2846
|
+
class Pr {
|
|
2847
2847
|
constructor(t) {
|
|
2848
|
-
this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new
|
|
2848
|
+
this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new yr({ loop: !!this.loop }), this.ready = !0;
|
|
2849
2849
|
}
|
|
2850
2850
|
createParticleSystem(t = {}) {
|
|
2851
2851
|
const e = this.systemCounter++, i = t.name || `System ${e + 1}`, r = {
|
|
2852
2852
|
...t,
|
|
2853
2853
|
name: i,
|
|
2854
2854
|
id: e
|
|
2855
|
-
}, n = new
|
|
2855
|
+
}, n = new Qt(this.device, r);
|
|
2856
2856
|
return this.particleSystems.push({
|
|
2857
2857
|
system: n,
|
|
2858
2858
|
config: r
|
|
@@ -2916,16 +2916,16 @@ class Ws {
|
|
|
2916
2916
|
for (const { system: o, config: c } of this.particleSystems) {
|
|
2917
2917
|
const l = c.keyframes;
|
|
2918
2918
|
if (!(!l || c.keyframesEnabled === !1)) {
|
|
2919
|
-
for (const
|
|
2920
|
-
const
|
|
2921
|
-
if (
|
|
2922
|
-
const
|
|
2923
|
-
|
|
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
2924
|
}
|
|
2925
2925
|
}
|
|
2926
2926
|
if (l.particleColor && l.particleColor.length) {
|
|
2927
|
-
const
|
|
2928
|
-
|
|
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
2929
|
}
|
|
2930
2930
|
}
|
|
2931
2931
|
}
|
|
@@ -2976,7 +2976,7 @@ class Ws {
|
|
|
2976
2976
|
const n = this.systemCounter++, a = {
|
|
2977
2977
|
...r,
|
|
2978
2978
|
id: n
|
|
2979
|
-
}, o = new
|
|
2979
|
+
}, o = new Qt(this.device, a);
|
|
2980
2980
|
this.particleSystems.push({
|
|
2981
2981
|
system: o,
|
|
2982
2982
|
config: a
|
|
@@ -2994,7 +2994,7 @@ class Ws {
|
|
|
2994
2994
|
try {
|
|
2995
2995
|
let a = null;
|
|
2996
2996
|
if (n.glbModelData)
|
|
2997
|
-
a =
|
|
2997
|
+
a = Vi(n.glbModelData);
|
|
2998
2998
|
else if (n.glbFileName) {
|
|
2999
2999
|
const o = await fetch(`/${n.glbFileName}`);
|
|
3000
3000
|
o.ok ? a = await o.arrayBuffer() : console.warn(`GLB file not found: ${n.glbFileName}`);
|
|
@@ -3002,7 +3002,7 @@ class Ws {
|
|
|
3002
3002
|
if (a) {
|
|
3003
3003
|
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
3004
|
try {
|
|
3005
|
-
const o = await
|
|
3005
|
+
const o = await Fi(a);
|
|
3006
3006
|
if (o) {
|
|
3007
3007
|
const c = await createImageBitmap(o.imageBlob);
|
|
3008
3008
|
await r.setTexture(c), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${n.name}`);
|
|
@@ -3070,9 +3070,9 @@ class Ws {
|
|
|
3070
3070
|
(o.confinementCenter[1] || 0) + e[1],
|
|
3071
3071
|
(o.confinementCenter[2] || 0) + e[2]
|
|
3072
3072
|
]);
|
|
3073
|
-
const
|
|
3073
|
+
const d = new Qt(this.device, l);
|
|
3074
3074
|
this.particleSystems.push({
|
|
3075
|
-
system:
|
|
3075
|
+
system: d,
|
|
3076
3076
|
config: l
|
|
3077
3077
|
}), this.onSystemCreated && typeof this.onSystemCreated == "function" && this.onSystemCreated(c, l);
|
|
3078
3078
|
}
|
|
@@ -3089,21 +3089,21 @@ class Ws {
|
|
|
3089
3089
|
try {
|
|
3090
3090
|
let l = null;
|
|
3091
3091
|
if (c.glbModelData)
|
|
3092
|
-
l =
|
|
3092
|
+
l = Vi(c.glbModelData);
|
|
3093
3093
|
else if (c.glbFileName) {
|
|
3094
|
-
const
|
|
3095
|
-
|
|
3094
|
+
const d = await fetch(`/${c.glbFileName}`);
|
|
3095
|
+
d.ok ? l = await d.arrayBuffer() : console.warn(`GLB file not found: ${c.glbFileName}`);
|
|
3096
3096
|
}
|
|
3097
3097
|
if (l) {
|
|
3098
3098
|
if (await o.setGLBModel(l), c.animationIndex !== void 0 && o.glbAnimator && o.glbAnimator.setAnimation(c.animationIndex), c.animationSpeed !== void 0 && o.glbAnimator && (o.glbAnimator.speed = c.animationSpeed), c.animationLoop !== void 0 && o.glbAnimator && (o.glbAnimator.loop = c.animationLoop), c.useGlbTexture && (c.textureEnabled = !0), c.useGlbTexture && ((r = o.glbMeshData) != null && r.hasBaseColorTexture))
|
|
3099
3099
|
try {
|
|
3100
|
-
const
|
|
3101
|
-
if (
|
|
3102
|
-
const
|
|
3103
|
-
await o.setTexture(
|
|
3100
|
+
const d = await Fi(l);
|
|
3101
|
+
if (d) {
|
|
3102
|
+
const S = await createImageBitmap(d.imageBlob);
|
|
3103
|
+
await o.setTexture(S), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${c.name}`);
|
|
3104
3104
|
}
|
|
3105
|
-
} catch (
|
|
3106
|
-
console.warn(`Failed to restore GLB texture for ${c.name}:`,
|
|
3105
|
+
} catch (d) {
|
|
3106
|
+
console.warn(`Failed to restore GLB texture for ${c.name}:`, d), c.useGlbTexture = !1;
|
|
3107
3107
|
}
|
|
3108
3108
|
} else
|
|
3109
3109
|
c.glbModelEnabled = !1;
|
|
@@ -3114,11 +3114,11 @@ class Ws {
|
|
|
3114
3114
|
if (c.textureEnabled && !c.glbModelEnabled && c.textureImageData && !o._textureRestored)
|
|
3115
3115
|
try {
|
|
3116
3116
|
const l = new Image();
|
|
3117
|
-
await new Promise((
|
|
3118
|
-
l.onload =
|
|
3117
|
+
await new Promise((S, g) => {
|
|
3118
|
+
l.onload = S, l.onerror = g, l.src = c.textureImageData;
|
|
3119
3119
|
});
|
|
3120
|
-
const
|
|
3121
|
-
await o.setTexture(
|
|
3120
|
+
const d = await createImageBitmap(l);
|
|
3121
|
+
await o.setTexture(d), o._textureRestored = !0;
|
|
3122
3122
|
} catch (l) {
|
|
3123
3123
|
console.warn(`Failed to restore texture for ${c.name}:`, l), c.textureEnabled = !1;
|
|
3124
3124
|
}
|
|
@@ -3130,7 +3130,7 @@ class Ws {
|
|
|
3130
3130
|
}
|
|
3131
3131
|
}
|
|
3132
3132
|
}
|
|
3133
|
-
async function
|
|
3133
|
+
async function _r(s) {
|
|
3134
3134
|
if (!s)
|
|
3135
3135
|
throw new Error("canvas is required for initWebGPU()");
|
|
3136
3136
|
if (!navigator.gpu)
|
|
@@ -3142,37 +3142,37 @@ async function Js(s) {
|
|
|
3142
3142
|
alphaMode: "premultiplied"
|
|
3143
3143
|
}), { device: i, context: t, format: r, canvas: s };
|
|
3144
3144
|
}
|
|
3145
|
-
const
|
|
3146
|
-
function
|
|
3145
|
+
const Ne = "rgba16float";
|
|
3146
|
+
function Oi(s, t, e, i) {
|
|
3147
3147
|
const r = s.createTexture({
|
|
3148
3148
|
size: [e, i],
|
|
3149
|
-
format:
|
|
3149
|
+
format: Ne,
|
|
3150
3150
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3151
3151
|
mipLevelCount: 1,
|
|
3152
3152
|
sampleCount: 1
|
|
3153
3153
|
}), n = s.createTexture({
|
|
3154
3154
|
size: [e, i],
|
|
3155
|
-
format:
|
|
3155
|
+
format: Ne,
|
|
3156
3156
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3157
3157
|
mipLevelCount: 1,
|
|
3158
3158
|
sampleCount: 1
|
|
3159
3159
|
}), a = s.createTexture({
|
|
3160
3160
|
size: [e, i],
|
|
3161
|
-
format:
|
|
3161
|
+
format: Ne,
|
|
3162
3162
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3163
3163
|
mipLevelCount: 1,
|
|
3164
3164
|
sampleCount: 1
|
|
3165
3165
|
});
|
|
3166
3166
|
return { sceneTexture: r, bloomTexA: n, bloomTexB: a };
|
|
3167
3167
|
}
|
|
3168
|
-
function
|
|
3168
|
+
function Li(s, t, e) {
|
|
3169
3169
|
return s.createTexture({
|
|
3170
3170
|
size: [t, e],
|
|
3171
3171
|
format: "depth24plus",
|
|
3172
3172
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
3173
3173
|
});
|
|
3174
3174
|
}
|
|
3175
|
-
function
|
|
3175
|
+
function vt(s, t, e) {
|
|
3176
3176
|
const i = s.createBuffer({
|
|
3177
3177
|
size: t.byteLength,
|
|
3178
3178
|
usage: e,
|
|
@@ -3180,7 +3180,7 @@ function Ge(s, t, e) {
|
|
|
3180
3180
|
});
|
|
3181
3181
|
return new t.constructor(i.getMappedRange()).set(t), i.unmap(), i;
|
|
3182
3182
|
}
|
|
3183
|
-
const
|
|
3183
|
+
const Mr = `
|
|
3184
3184
|
struct Uniforms {
|
|
3185
3185
|
transform: mat4x4<f32>,
|
|
3186
3186
|
cameraPosition: vec3<f32>,
|
|
@@ -3242,7 +3242,7 @@ const Qs = `
|
|
|
3242
3242
|
|
|
3243
3243
|
return finalColor;
|
|
3244
3244
|
}
|
|
3245
|
-
`,
|
|
3245
|
+
`, wr = `
|
|
3246
3246
|
struct Uniforms {
|
|
3247
3247
|
transform: mat4x4<f32>,
|
|
3248
3248
|
cameraPosition: vec3<f32>,
|
|
@@ -3479,7 +3479,7 @@ const Qs = `
|
|
|
3479
3479
|
return finalColor;
|
|
3480
3480
|
}
|
|
3481
3481
|
`;
|
|
3482
|
-
function
|
|
3482
|
+
function Br(s) {
|
|
3483
3483
|
const t = s.createBindGroupLayout({
|
|
3484
3484
|
entries: [
|
|
3485
3485
|
{
|
|
@@ -3565,34 +3565,34 @@ function er(s) {
|
|
|
3565
3565
|
object3dBindGroupLayout: r
|
|
3566
3566
|
};
|
|
3567
3567
|
}
|
|
3568
|
-
function
|
|
3568
|
+
function Rr(s, t, e, i = {}) {
|
|
3569
3569
|
const { depthCompare: r } = i, n = r || "less", {
|
|
3570
3570
|
particleBindGroupLayout: a,
|
|
3571
3571
|
bloomBindGroupLayout: o,
|
|
3572
3572
|
compositeBindGroupLayout: c,
|
|
3573
3573
|
object3dBindGroupLayout: l
|
|
3574
|
-
} = e,
|
|
3574
|
+
} = e, d = s.createPipelineLayout({
|
|
3575
3575
|
bindGroupLayouts: [a]
|
|
3576
|
-
}),
|
|
3576
|
+
}), S = s.createPipelineLayout({
|
|
3577
3577
|
bindGroupLayouts: [o]
|
|
3578
|
-
}),
|
|
3578
|
+
}), g = s.createPipelineLayout({
|
|
3579
3579
|
bindGroupLayouts: [c]
|
|
3580
|
-
}),
|
|
3581
|
-
code:
|
|
3582
|
-
}),
|
|
3583
|
-
code:
|
|
3580
|
+
}), p = s.createShaderModule({
|
|
3581
|
+
code: Xs
|
|
3582
|
+
}), v = s.createShaderModule({
|
|
3583
|
+
code: Ns
|
|
3584
|
+
}), A = s.createShaderModule({
|
|
3585
|
+
code: Ys
|
|
3586
|
+
}), U = s.createShaderModule({
|
|
3587
|
+
code: js
|
|
3588
|
+
}), I = s.createShaderModule({
|
|
3589
|
+
code: Mr
|
|
3584
3590
|
}), _ = s.createShaderModule({
|
|
3585
|
-
code:
|
|
3586
|
-
}),
|
|
3587
|
-
|
|
3588
|
-
}), R = s.createShaderModule({
|
|
3589
|
-
code: Qs
|
|
3590
|
-
}), x = s.createShaderModule({
|
|
3591
|
-
code: Ks
|
|
3592
|
-
}), L = (W) => s.createRenderPipeline({
|
|
3593
|
-
layout: u,
|
|
3591
|
+
code: wr
|
|
3592
|
+
}), $ = (kt) => s.createRenderPipeline({
|
|
3593
|
+
layout: d,
|
|
3594
3594
|
vertex: {
|
|
3595
|
-
module:
|
|
3595
|
+
module: p,
|
|
3596
3596
|
entryPoint: "vs_main",
|
|
3597
3597
|
buffers: [
|
|
3598
3598
|
{
|
|
@@ -3653,11 +3653,11 @@ function tr(s, t, e, i = {}) {
|
|
|
3653
3653
|
]
|
|
3654
3654
|
},
|
|
3655
3655
|
fragment: {
|
|
3656
|
-
module:
|
|
3656
|
+
module: p,
|
|
3657
3657
|
entryPoint: "fs_main",
|
|
3658
3658
|
targets: [{
|
|
3659
|
-
format:
|
|
3660
|
-
blend:
|
|
3659
|
+
format: Ne,
|
|
3660
|
+
blend: kt
|
|
3661
3661
|
}]
|
|
3662
3662
|
},
|
|
3663
3663
|
primitive: {
|
|
@@ -3669,7 +3669,7 @@ function tr(s, t, e, i = {}) {
|
|
|
3669
3669
|
depthCompare: n,
|
|
3670
3670
|
format: "depth24plus"
|
|
3671
3671
|
}
|
|
3672
|
-
}),
|
|
3672
|
+
}), T = $({
|
|
3673
3673
|
color: {
|
|
3674
3674
|
srcFactor: "src-alpha",
|
|
3675
3675
|
dstFactor: "one-minus-src-alpha",
|
|
@@ -3680,7 +3680,7 @@ function tr(s, t, e, i = {}) {
|
|
|
3680
3680
|
dstFactor: "one-minus-src-alpha",
|
|
3681
3681
|
operation: "add"
|
|
3682
3682
|
}
|
|
3683
|
-
}),
|
|
3683
|
+
}), z = $({
|
|
3684
3684
|
color: {
|
|
3685
3685
|
srcFactor: "src-alpha",
|
|
3686
3686
|
dstFactor: "one",
|
|
@@ -3691,10 +3691,10 @@ function tr(s, t, e, i = {}) {
|
|
|
3691
3691
|
dstFactor: "one-minus-src-alpha",
|
|
3692
3692
|
operation: "add"
|
|
3693
3693
|
}
|
|
3694
|
-
}),
|
|
3695
|
-
layout:
|
|
3694
|
+
}), F = s.createRenderPipeline({
|
|
3695
|
+
layout: d,
|
|
3696
3696
|
vertex: {
|
|
3697
|
-
module:
|
|
3697
|
+
module: p,
|
|
3698
3698
|
entryPoint: "vs_main",
|
|
3699
3699
|
buffers: [
|
|
3700
3700
|
{
|
|
@@ -3755,10 +3755,10 @@ function tr(s, t, e, i = {}) {
|
|
|
3755
3755
|
]
|
|
3756
3756
|
},
|
|
3757
3757
|
fragment: {
|
|
3758
|
-
module:
|
|
3758
|
+
module: p,
|
|
3759
3759
|
entryPoint: "fs_main",
|
|
3760
3760
|
targets: [{
|
|
3761
|
-
format:
|
|
3761
|
+
format: Ne,
|
|
3762
3762
|
writeMask: 0
|
|
3763
3763
|
// No color write — depth only
|
|
3764
3764
|
}]
|
|
@@ -3773,33 +3773,33 @@ function tr(s, t, e, i = {}) {
|
|
|
3773
3773
|
// Always write depth (don't self-occlude)
|
|
3774
3774
|
format: "depth24plus"
|
|
3775
3775
|
}
|
|
3776
|
-
}),
|
|
3777
|
-
layout:
|
|
3776
|
+
}), Z = s.createRenderPipeline({
|
|
3777
|
+
layout: S,
|
|
3778
3778
|
vertex: {
|
|
3779
|
-
module:
|
|
3779
|
+
module: v,
|
|
3780
3780
|
entryPoint: "vs_main"
|
|
3781
3781
|
},
|
|
3782
3782
|
fragment: {
|
|
3783
|
-
module:
|
|
3783
|
+
module: v,
|
|
3784
3784
|
entryPoint: "fs_main",
|
|
3785
3785
|
targets: [{
|
|
3786
|
-
format:
|
|
3786
|
+
format: Ne
|
|
3787
3787
|
}]
|
|
3788
3788
|
},
|
|
3789
3789
|
primitive: {
|
|
3790
3790
|
topology: "triangle-list"
|
|
3791
3791
|
}
|
|
3792
|
-
}),
|
|
3793
|
-
layout:
|
|
3792
|
+
}), J = s.createRenderPipeline({
|
|
3793
|
+
layout: g,
|
|
3794
3794
|
vertex: {
|
|
3795
|
-
module:
|
|
3795
|
+
module: A,
|
|
3796
3796
|
entryPoint: "vs_main"
|
|
3797
3797
|
},
|
|
3798
3798
|
fragment: {
|
|
3799
|
-
module:
|
|
3799
|
+
module: A,
|
|
3800
3800
|
entryPoint: "fs_main",
|
|
3801
3801
|
targets: [{
|
|
3802
|
-
format:
|
|
3802
|
+
format: Ne,
|
|
3803
3803
|
blend: {
|
|
3804
3804
|
color: {
|
|
3805
3805
|
srcFactor: "one",
|
|
@@ -3817,17 +3817,17 @@ function tr(s, t, e, i = {}) {
|
|
|
3817
3817
|
primitive: {
|
|
3818
3818
|
topology: "triangle-list"
|
|
3819
3819
|
}
|
|
3820
|
-
}),
|
|
3821
|
-
layout:
|
|
3820
|
+
}), ee = s.createRenderPipeline({
|
|
3821
|
+
layout: g,
|
|
3822
3822
|
vertex: {
|
|
3823
|
-
module:
|
|
3823
|
+
module: U,
|
|
3824
3824
|
entryPoint: "vs_main"
|
|
3825
3825
|
},
|
|
3826
3826
|
fragment: {
|
|
3827
|
-
module:
|
|
3827
|
+
module: U,
|
|
3828
3828
|
entryPoint: "fs_main",
|
|
3829
3829
|
targets: [{
|
|
3830
|
-
format:
|
|
3830
|
+
format: Ne,
|
|
3831
3831
|
blend: {
|
|
3832
3832
|
color: {
|
|
3833
3833
|
srcFactor: "one",
|
|
@@ -3845,11 +3845,11 @@ function tr(s, t, e, i = {}) {
|
|
|
3845
3845
|
primitive: {
|
|
3846
3846
|
topology: "triangle-list"
|
|
3847
3847
|
}
|
|
3848
|
-
}),
|
|
3849
|
-
layout:
|
|
3850
|
-
vertex: { module:
|
|
3848
|
+
}), K = s.createShaderModule({ code: qs }), q = s.createRenderPipeline({
|
|
3849
|
+
layout: g,
|
|
3850
|
+
vertex: { module: K, entryPoint: "vs_main" },
|
|
3851
3851
|
fragment: {
|
|
3852
|
-
module:
|
|
3852
|
+
module: K,
|
|
3853
3853
|
entryPoint: "fs_main",
|
|
3854
3854
|
targets: [{
|
|
3855
3855
|
format: t,
|
|
@@ -3860,12 +3860,12 @@ function tr(s, t, e, i = {}) {
|
|
|
3860
3860
|
}]
|
|
3861
3861
|
},
|
|
3862
3862
|
primitive: { topology: "triangle-list" }
|
|
3863
|
-
}),
|
|
3863
|
+
}), Ke = s.createPipelineLayout({
|
|
3864
3864
|
bindGroupLayouts: [l]
|
|
3865
|
-
}),
|
|
3866
|
-
layout:
|
|
3865
|
+
}), Pt = s.createRenderPipeline({
|
|
3866
|
+
layout: Ke,
|
|
3867
3867
|
vertex: {
|
|
3868
|
-
module:
|
|
3868
|
+
module: I,
|
|
3869
3869
|
entryPoint: "vs_main",
|
|
3870
3870
|
buffers: [
|
|
3871
3871
|
{
|
|
@@ -3890,10 +3890,10 @@ function tr(s, t, e, i = {}) {
|
|
|
3890
3890
|
]
|
|
3891
3891
|
},
|
|
3892
3892
|
fragment: {
|
|
3893
|
-
module:
|
|
3893
|
+
module: I,
|
|
3894
3894
|
entryPoint: "fs_main",
|
|
3895
3895
|
targets: [{
|
|
3896
|
-
format:
|
|
3896
|
+
format: Ne,
|
|
3897
3897
|
blend: {
|
|
3898
3898
|
color: {
|
|
3899
3899
|
srcFactor: "src-alpha",
|
|
@@ -3917,10 +3917,10 @@ function tr(s, t, e, i = {}) {
|
|
|
3917
3917
|
depthCompare: n,
|
|
3918
3918
|
format: "depth24plus"
|
|
3919
3919
|
}
|
|
3920
|
-
}),
|
|
3921
|
-
layout:
|
|
3920
|
+
}), Ye = s.createRenderPipeline({
|
|
3921
|
+
layout: d,
|
|
3922
3922
|
vertex: {
|
|
3923
|
-
module:
|
|
3923
|
+
module: _,
|
|
3924
3924
|
entryPoint: "vs_main",
|
|
3925
3925
|
buffers: [
|
|
3926
3926
|
{
|
|
@@ -3992,10 +3992,10 @@ function tr(s, t, e, i = {}) {
|
|
|
3992
3992
|
]
|
|
3993
3993
|
},
|
|
3994
3994
|
fragment: {
|
|
3995
|
-
module:
|
|
3995
|
+
module: _,
|
|
3996
3996
|
entryPoint: "fs_main",
|
|
3997
3997
|
targets: [{
|
|
3998
|
-
format:
|
|
3998
|
+
format: Ne,
|
|
3999
3999
|
blend: {
|
|
4000
4000
|
color: {
|
|
4001
4001
|
srcFactor: "src-alpha",
|
|
@@ -4021,18 +4021,18 @@ function tr(s, t, e, i = {}) {
|
|
|
4021
4021
|
}
|
|
4022
4022
|
});
|
|
4023
4023
|
return {
|
|
4024
|
-
particlePipeline:
|
|
4025
|
-
particleAdditivePipeline:
|
|
4026
|
-
particleDepthWritePipeline:
|
|
4027
|
-
blurPipeline:
|
|
4028
|
-
compositePipeline:
|
|
4029
|
-
directRenderPipeline:
|
|
4030
|
-
finalCompositePipeline:
|
|
4031
|
-
object3dPipeline:
|
|
4032
|
-
glbMeshPipeline:
|
|
4024
|
+
particlePipeline: T,
|
|
4025
|
+
particleAdditivePipeline: z,
|
|
4026
|
+
particleDepthWritePipeline: F,
|
|
4027
|
+
blurPipeline: Z,
|
|
4028
|
+
compositePipeline: J,
|
|
4029
|
+
directRenderPipeline: ee,
|
|
4030
|
+
finalCompositePipeline: q,
|
|
4031
|
+
object3dPipeline: Pt,
|
|
4032
|
+
glbMeshPipeline: Ye
|
|
4033
4033
|
};
|
|
4034
4034
|
}
|
|
4035
|
-
function
|
|
4035
|
+
function ei(s, t, e, i) {
|
|
4036
4036
|
const {
|
|
4037
4037
|
uniformBuffer: r,
|
|
4038
4038
|
appearanceUniformBuffer: n,
|
|
@@ -4041,9 +4041,9 @@ function Pt(s, t, e, i) {
|
|
|
4041
4041
|
bloomIntensityBuffer: c
|
|
4042
4042
|
} = e, {
|
|
4043
4043
|
sceneTexture: l,
|
|
4044
|
-
bloomTexA:
|
|
4045
|
-
bloomTexB:
|
|
4046
|
-
} = i,
|
|
4044
|
+
bloomTexA: d,
|
|
4045
|
+
bloomTexB: S
|
|
4046
|
+
} = i, g = s.createBindGroup({
|
|
4047
4047
|
layout: s.createBindGroupLayout({
|
|
4048
4048
|
entries: [
|
|
4049
4049
|
{
|
|
@@ -4068,7 +4068,7 @@ function Pt(s, t, e, i) {
|
|
|
4068
4068
|
resource: { buffer: n }
|
|
4069
4069
|
}
|
|
4070
4070
|
]
|
|
4071
|
-
}),
|
|
4071
|
+
}), p = s.createBindGroup({
|
|
4072
4072
|
layout: s.createBindGroupLayout({
|
|
4073
4073
|
entries: [
|
|
4074
4074
|
{
|
|
@@ -4102,7 +4102,7 @@ function Pt(s, t, e, i) {
|
|
|
4102
4102
|
resource: { buffer: a }
|
|
4103
4103
|
}
|
|
4104
4104
|
]
|
|
4105
|
-
}),
|
|
4105
|
+
}), v = s.createBindGroup({
|
|
4106
4106
|
layout: s.createBindGroupLayout({
|
|
4107
4107
|
entries: [
|
|
4108
4108
|
{
|
|
@@ -4129,14 +4129,14 @@ function Pt(s, t, e, i) {
|
|
|
4129
4129
|
},
|
|
4130
4130
|
{
|
|
4131
4131
|
binding: 1,
|
|
4132
|
-
resource:
|
|
4132
|
+
resource: d.createView()
|
|
4133
4133
|
},
|
|
4134
4134
|
{
|
|
4135
4135
|
binding: 2,
|
|
4136
4136
|
resource: { buffer: o }
|
|
4137
4137
|
}
|
|
4138
4138
|
]
|
|
4139
|
-
}),
|
|
4139
|
+
}), A = s.createBindGroup({
|
|
4140
4140
|
layout: s.createBindGroupLayout({
|
|
4141
4141
|
entries: [
|
|
4142
4142
|
{
|
|
@@ -4172,14 +4172,14 @@ function Pt(s, t, e, i) {
|
|
|
4172
4172
|
},
|
|
4173
4173
|
{
|
|
4174
4174
|
binding: 2,
|
|
4175
|
-
resource:
|
|
4175
|
+
resource: S.createView()
|
|
4176
4176
|
},
|
|
4177
4177
|
{
|
|
4178
4178
|
binding: 3,
|
|
4179
4179
|
resource: { buffer: c }
|
|
4180
4180
|
}
|
|
4181
4181
|
]
|
|
4182
|
-
}),
|
|
4182
|
+
}), U = s.createBindGroup({
|
|
4183
4183
|
layout: s.createBindGroupLayout({
|
|
4184
4184
|
entries: [
|
|
4185
4185
|
{
|
|
@@ -4215,7 +4215,7 @@ function Pt(s, t, e, i) {
|
|
|
4215
4215
|
},
|
|
4216
4216
|
{
|
|
4217
4217
|
binding: 2,
|
|
4218
|
-
resource:
|
|
4218
|
+
resource: S.createView()
|
|
4219
4219
|
},
|
|
4220
4220
|
{
|
|
4221
4221
|
binding: 3,
|
|
@@ -4224,14 +4224,14 @@ function Pt(s, t, e, i) {
|
|
|
4224
4224
|
]
|
|
4225
4225
|
});
|
|
4226
4226
|
return {
|
|
4227
|
-
particleBindGroup:
|
|
4228
|
-
horizontalBlurBindGroup:
|
|
4229
|
-
verticalBlurBindGroup:
|
|
4230
|
-
compositeBindGroup:
|
|
4231
|
-
directRenderBindGroup:
|
|
4227
|
+
particleBindGroup: g,
|
|
4228
|
+
horizontalBlurBindGroup: p,
|
|
4229
|
+
verticalBlurBindGroup: v,
|
|
4230
|
+
compositeBindGroup: A,
|
|
4231
|
+
directRenderBindGroup: U
|
|
4232
4232
|
};
|
|
4233
4233
|
}
|
|
4234
|
-
function
|
|
4234
|
+
function Tr(s) {
|
|
4235
4235
|
return s.createSampler({
|
|
4236
4236
|
magFilter: "linear",
|
|
4237
4237
|
minFilter: "linear",
|
|
@@ -4241,7 +4241,7 @@ function ir(s) {
|
|
|
4241
4241
|
maxAnisotropy: 16
|
|
4242
4242
|
});
|
|
4243
4243
|
}
|
|
4244
|
-
function
|
|
4244
|
+
function Er() {
|
|
4245
4245
|
const s = new Float32Array([
|
|
4246
4246
|
// Front face (z = 0.5)
|
|
4247
4247
|
-0.5,
|
|
@@ -4439,13 +4439,13 @@ function sr() {
|
|
|
4439
4439
|
]);
|
|
4440
4440
|
return { vertices: s, indices: t };
|
|
4441
4441
|
}
|
|
4442
|
-
function
|
|
4442
|
+
function Ar(s = 16, t = 16) {
|
|
4443
4443
|
const e = [], i = [];
|
|
4444
4444
|
for (let r = 0; r <= s; r++) {
|
|
4445
4445
|
const n = r * Math.PI / s, a = Math.sin(n), o = Math.cos(n);
|
|
4446
4446
|
for (let c = 0; c <= t; c++) {
|
|
4447
|
-
const l = c * 2 * Math.PI / t,
|
|
4448
|
-
e.push(
|
|
4447
|
+
const l = c * 2 * Math.PI / t, d = Math.sin(l), g = Math.cos(l) * a, p = o, v = d * a;
|
|
4448
|
+
e.push(g * 0.5, p * 0.5, v * 0.5), e.push(g, p, v);
|
|
4449
4449
|
}
|
|
4450
4450
|
}
|
|
4451
4451
|
for (let r = 0; r < s; r++)
|
|
@@ -4458,7 +4458,7 @@ function rr(s = 16, t = 16) {
|
|
|
4458
4458
|
indices: new Uint16Array(i)
|
|
4459
4459
|
};
|
|
4460
4460
|
}
|
|
4461
|
-
class
|
|
4461
|
+
class Cr {
|
|
4462
4462
|
constructor(t, e, i, r, n) {
|
|
4463
4463
|
this.id = t, this.type = e, this.position = i, this.scale = r, this.color = n, this.rotation = [0, 0, 0];
|
|
4464
4464
|
}
|
|
@@ -4592,7 +4592,7 @@ class nr {
|
|
|
4592
4592
|
return i;
|
|
4593
4593
|
}
|
|
4594
4594
|
}
|
|
4595
|
-
class
|
|
4595
|
+
class Vr {
|
|
4596
4596
|
constructor(t) {
|
|
4597
4597
|
this.device = t, this.objects = [], this.nextId = 0, this.initializeGeometry(), this.onObjectAdded = null, this.onObjectRemoved = null, this.onObjectUpdated = null;
|
|
4598
4598
|
}
|
|
@@ -4600,20 +4600,20 @@ class hr {
|
|
|
4600
4600
|
* Initialize geometry buffers for cube and sphere
|
|
4601
4601
|
*/
|
|
4602
4602
|
initializeGeometry() {
|
|
4603
|
-
const t =
|
|
4604
|
-
this.cubeVertexBuffer =
|
|
4603
|
+
const t = Er(), e = Ar(16, 16);
|
|
4604
|
+
this.cubeVertexBuffer = vt(
|
|
4605
4605
|
this.device,
|
|
4606
4606
|
t.vertices,
|
|
4607
4607
|
GPUBufferUsage.VERTEX
|
|
4608
|
-
), this.cubeIndexBuffer =
|
|
4608
|
+
), this.cubeIndexBuffer = vt(
|
|
4609
4609
|
this.device,
|
|
4610
4610
|
t.indices,
|
|
4611
4611
|
GPUBufferUsage.INDEX
|
|
4612
|
-
), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer =
|
|
4612
|
+
), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer = vt(
|
|
4613
4613
|
this.device,
|
|
4614
4614
|
e.vertices,
|
|
4615
4615
|
GPUBufferUsage.VERTEX
|
|
4616
|
-
), this.sphereIndexBuffer =
|
|
4616
|
+
), this.sphereIndexBuffer = vt(
|
|
4617
4617
|
this.device,
|
|
4618
4618
|
e.indices,
|
|
4619
4619
|
GPUBufferUsage.INDEX
|
|
@@ -4628,7 +4628,7 @@ class hr {
|
|
|
4628
4628
|
* @returns {Object3D} The created object
|
|
4629
4629
|
*/
|
|
4630
4630
|
addObject(t, e = [0, 0, 0], i = [1, 1, 1], r = [1, 1, 1, 1]) {
|
|
4631
|
-
const n = new
|
|
4631
|
+
const n = new Cr(this.nextId++, t, e, i, r);
|
|
4632
4632
|
return n.uniformBuffer = this.device.createBuffer({
|
|
4633
4633
|
size: 192,
|
|
4634
4634
|
// modelMatrix (64) + normalMatrix (64) + color (16) + padding (48)
|
|
@@ -4717,21 +4717,21 @@ class hr {
|
|
|
4717
4717
|
}
|
|
4718
4718
|
}
|
|
4719
4719
|
}
|
|
4720
|
-
function
|
|
4720
|
+
function Or(s) {
|
|
4721
4721
|
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
4722
|
return [t, e, i];
|
|
4723
4723
|
}
|
|
4724
|
-
function
|
|
4724
|
+
function Lr(s) {
|
|
4725
4725
|
if (!s) return "#ffffff";
|
|
4726
4726
|
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
4727
|
return `#${t}${e}${i}`;
|
|
4728
4728
|
}
|
|
4729
|
-
function
|
|
4730
|
-
const i =
|
|
4729
|
+
function kr(s, t, e) {
|
|
4730
|
+
const i = ki([
|
|
4731
4731
|
s[0] - t[0],
|
|
4732
4732
|
s[1] - t[1],
|
|
4733
4733
|
s[2] - t[2]
|
|
4734
|
-
]), r =
|
|
4734
|
+
]), r = ki(Xi(e, i)), n = Xi(i, r);
|
|
4735
4735
|
return new Float32Array([
|
|
4736
4736
|
r[0],
|
|
4737
4737
|
n[0],
|
|
@@ -4745,13 +4745,13 @@ function yr(s, t, e) {
|
|
|
4745
4745
|
n[2],
|
|
4746
4746
|
i[2],
|
|
4747
4747
|
0,
|
|
4748
|
-
-
|
|
4749
|
-
-
|
|
4750
|
-
-
|
|
4748
|
+
-ti(r, s),
|
|
4749
|
+
-ti(n, s),
|
|
4750
|
+
-ti(i, s),
|
|
4751
4751
|
1
|
|
4752
4752
|
]);
|
|
4753
4753
|
}
|
|
4754
|
-
function
|
|
4754
|
+
function Xr(s, t = Math.PI / 4) {
|
|
4755
4755
|
const r = 1 / Math.tan(t / 2);
|
|
4756
4756
|
return new Float32Array([
|
|
4757
4757
|
r * s,
|
|
@@ -4772,21 +4772,21 @@ function gr(s, t = Math.PI / 4) {
|
|
|
4772
4772
|
0
|
|
4773
4773
|
]);
|
|
4774
4774
|
}
|
|
4775
|
-
function
|
|
4775
|
+
function ki(s) {
|
|
4776
4776
|
const t = Math.sqrt(s[0] * s[0] + s[1] * s[1] + s[2] * s[2]);
|
|
4777
4777
|
return [s[0] / t, s[1] / t, s[2] / t];
|
|
4778
4778
|
}
|
|
4779
|
-
function
|
|
4779
|
+
function Xi(s, t) {
|
|
4780
4780
|
return [
|
|
4781
4781
|
s[1] * t[2] - s[2] * t[1],
|
|
4782
4782
|
s[2] * t[0] - s[0] * t[2],
|
|
4783
4783
|
s[0] * t[1] - s[1] * t[0]
|
|
4784
4784
|
];
|
|
4785
4785
|
}
|
|
4786
|
-
function
|
|
4786
|
+
function ti(s, t) {
|
|
4787
4787
|
return s[0] * t[0] + s[1] * t[1] + s[2] * t[2];
|
|
4788
4788
|
}
|
|
4789
|
-
function
|
|
4789
|
+
function Ur(s, t) {
|
|
4790
4790
|
const e = new Float32Array(16);
|
|
4791
4791
|
for (let i = 0; i < 4; i++)
|
|
4792
4792
|
for (let r = 0; r < 4; r++) {
|
|
@@ -4797,7 +4797,7 @@ function ar(s, t) {
|
|
|
4797
4797
|
}
|
|
4798
4798
|
return e;
|
|
4799
4799
|
}
|
|
4800
|
-
const
|
|
4800
|
+
const si = 1481005640, Hi = 1, Zi = 1313821514, $i = 5130562, Et = "$hzfxAsset", Wi = (s) => typeof atob == "function" ? Uint8Array.from(atob(s), (t) => t.charCodeAt(0)) : new Uint8Array(Buffer.from(s, "base64")), Ni = (s) => {
|
|
4801
4801
|
if (typeof btoa == "function") {
|
|
4802
4802
|
let t = "";
|
|
4803
4803
|
for (let e = 0; e < s.length; e++) t += String.fromCharCode(s[e]);
|
|
@@ -4805,94 +4805,94 @@ const Bt = 1481005640, wi = 1, Bi = 1313821514, Mi = 5130562, Ze = "$hzfxAsset",
|
|
|
4805
4805
|
}
|
|
4806
4806
|
return Buffer.from(s).toString("base64");
|
|
4807
4807
|
};
|
|
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) ?
|
|
4808
|
+
function Ir(s) {
|
|
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) ? Wi(r) : new TextEncoder().encode(decodeURIComponent(r));
|
|
4810
4810
|
return { mime: i, bytes: a };
|
|
4811
4811
|
}
|
|
4812
|
-
function
|
|
4812
|
+
function Yi(s) {
|
|
4813
4813
|
return (4 - s % 4) % 4;
|
|
4814
4814
|
}
|
|
4815
|
-
async function
|
|
4815
|
+
async function zr(s, t = {}) {
|
|
4816
4816
|
const { textureFormat: e = "keep", quality: i = 0.85 } = t, r = [], n = [];
|
|
4817
4817
|
let a = 0;
|
|
4818
|
-
const o = (
|
|
4819
|
-
const
|
|
4820
|
-
r.push({ offset:
|
|
4821
|
-
const
|
|
4822
|
-
return
|
|
4818
|
+
const o = (z, F, Z) => {
|
|
4819
|
+
const J = a, ee = z.length;
|
|
4820
|
+
r.push({ offset: J, length: ee, mime: F, kind: Z }), n.push(z), a += ee;
|
|
4821
|
+
const K = Yi(ee);
|
|
4822
|
+
return K && (n.push(new Uint8Array(K)), a += K), r.length - 1;
|
|
4823
4823
|
}, c = e === "webp" && typeof OffscreenCanvas < "u" && typeof createImageBitmap == "function", l = [];
|
|
4824
|
-
for (const
|
|
4825
|
-
const
|
|
4826
|
-
if (typeof
|
|
4827
|
-
let { mime:
|
|
4828
|
-
if (c &&
|
|
4824
|
+
for (const z of s.systems || []) {
|
|
4825
|
+
const F = { ...z };
|
|
4826
|
+
if (typeof F.textureImageData == "string" && F.textureImageData.startsWith("data:")) {
|
|
4827
|
+
let { mime: Z, bytes: J } = Ir(F.textureImageData);
|
|
4828
|
+
if (c && Z !== "image/webp")
|
|
4829
4829
|
try {
|
|
4830
|
-
const
|
|
4831
|
-
|
|
4832
|
-
const
|
|
4833
|
-
|
|
4830
|
+
const ee = await createImageBitmap(new Blob([J], { type: Z })), K = new OffscreenCanvas(ee.width, ee.height);
|
|
4831
|
+
K.getContext("2d").drawImage(ee, 0, 0);
|
|
4832
|
+
const q = await K.convertToBlob({ type: "image/webp", quality: i }), Ke = new Uint8Array(await q.arrayBuffer());
|
|
4833
|
+
Ke.length < J.length && (J = Ke, Z = "image/webp");
|
|
4834
4834
|
} catch {
|
|
4835
4835
|
}
|
|
4836
|
-
|
|
4836
|
+
F.textureImageData = { [Et]: o(J, Z, "texture") };
|
|
4837
4837
|
}
|
|
4838
|
-
if (typeof
|
|
4839
|
-
const
|
|
4840
|
-
|
|
4838
|
+
if (typeof F.glbModelData == "string" && F.glbModelData.length > 0) {
|
|
4839
|
+
const Z = Wi(F.glbModelData);
|
|
4840
|
+
F.glbModelData = { [Et]: o(Z, "model/gltf-binary", "glb") };
|
|
4841
4841
|
}
|
|
4842
|
-
l.push(
|
|
4843
|
-
}
|
|
4844
|
-
const
|
|
4845
|
-
let
|
|
4846
|
-
for (const
|
|
4847
|
-
|
|
4848
|
-
const
|
|
4849
|
-
let
|
|
4850
|
-
|
|
4851
|
-
for (let
|
|
4852
|
-
return
|
|
4842
|
+
l.push(F);
|
|
4843
|
+
}
|
|
4844
|
+
const d = { ...s, systems: l, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)), g = Yi(S.length), p = new Uint8Array(a);
|
|
4845
|
+
let v = 0;
|
|
4846
|
+
for (const z of n)
|
|
4847
|
+
p.set(z, v), v += z.length;
|
|
4848
|
+
const A = S.length + g, U = 20 + A + 8 + a, I = new ArrayBuffer(U), _ = new DataView(I), $ = new Uint8Array(I);
|
|
4849
|
+
let T = 0;
|
|
4850
|
+
_.setUint32(T, si, !0), T += 4, _.setUint32(T, Hi, !0), T += 4, _.setUint32(T, U, !0), T += 4, _.setUint32(T, A, !0), T += 4, _.setUint32(T, Zi, !0), T += 4, $.set(S, T), T += S.length;
|
|
4851
|
+
for (let z = 0; z < g; z++) $[T++] = 32;
|
|
4852
|
+
return _.setUint32(T, a, !0), T += 4, _.setUint32(T, $i, !0), T += 4, $.set(p, T), T += a, I;
|
|
4853
4853
|
}
|
|
4854
|
-
function
|
|
4855
|
-
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) ===
|
|
4854
|
+
function Ji(s) {
|
|
4855
|
+
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === si;
|
|
4856
4856
|
}
|
|
4857
|
-
function
|
|
4857
|
+
function Ki(s) {
|
|
4858
4858
|
const t = new DataView(s);
|
|
4859
|
-
if (t.getUint32(0, !0) !==
|
|
4859
|
+
if (t.getUint32(0, !0) !== si) throw new Error("[unpackHZFX] bad magic — not an .hzfx file");
|
|
4860
4860
|
const e = t.getUint32(4, !0);
|
|
4861
|
-
if (e !==
|
|
4861
|
+
if (e !== Hi) throw new Error(`[unpackHZFX] unsupported version ${e}`);
|
|
4862
4862
|
let i = 12, r = null, n = -1;
|
|
4863
4863
|
const a = new Uint8Array(s);
|
|
4864
4864
|
for (; i + 8 <= s.byteLength; ) {
|
|
4865
|
-
const
|
|
4865
|
+
const g = t.getUint32(i, !0);
|
|
4866
4866
|
i += 4;
|
|
4867
|
-
const
|
|
4868
|
-
i += 4,
|
|
4867
|
+
const p = t.getUint32(i, !0);
|
|
4868
|
+
i += 4, p === Zi ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + g))) : p === $i && (n = i), i += g;
|
|
4869
4869
|
}
|
|
4870
4870
|
if (!r) throw new Error("[unpackHZFX] missing JSON chunk");
|
|
4871
|
-
const o = r.assets || [], c = (
|
|
4872
|
-
const
|
|
4873
|
-
return !
|
|
4874
|
-
}, l = (
|
|
4875
|
-
const
|
|
4876
|
-
if (l(
|
|
4877
|
-
const
|
|
4878
|
-
|
|
4871
|
+
const o = r.assets || [], c = (g) => {
|
|
4872
|
+
const p = o[g];
|
|
4873
|
+
return !p || n < 0 ? null : { ...p, bytes: a.subarray(n + p.offset, n + p.offset + p.length) };
|
|
4874
|
+
}, l = (g) => g && typeof g == "object" && typeof g[Et] == "number", d = (r.systems || []).map((g) => {
|
|
4875
|
+
const p = { ...g };
|
|
4876
|
+
if (l(p.textureImageData)) {
|
|
4877
|
+
const v = c(p.textureImageData[Et]);
|
|
4878
|
+
p.textureImageData = v ? `data:${v.mime};base64,${Ni(v.bytes)}` : void 0;
|
|
4879
4879
|
}
|
|
4880
|
-
if (l(
|
|
4881
|
-
const
|
|
4882
|
-
|
|
4880
|
+
if (l(p.glbModelData)) {
|
|
4881
|
+
const v = c(p.glbModelData[Et]);
|
|
4882
|
+
p.glbModelData = v ? Ni(v.bytes) : void 0;
|
|
4883
4883
|
}
|
|
4884
|
-
return
|
|
4885
|
-
}),
|
|
4886
|
-
return delete
|
|
4884
|
+
return p;
|
|
4885
|
+
}), S = { ...r, systems: d };
|
|
4886
|
+
return delete S.assets, S;
|
|
4887
4887
|
}
|
|
4888
|
-
function
|
|
4888
|
+
function Fr(s) {
|
|
4889
4889
|
const t = new Uint8Array(s);
|
|
4890
4890
|
let e = "";
|
|
4891
4891
|
for (let i = 0; i < t.byteLength; i++)
|
|
4892
4892
|
e += String.fromCharCode(t[i]);
|
|
4893
4893
|
return btoa(e);
|
|
4894
4894
|
}
|
|
4895
|
-
function
|
|
4895
|
+
function Gr(s) {
|
|
4896
4896
|
return {
|
|
4897
4897
|
name: s.name,
|
|
4898
4898
|
id: s.id,
|
|
@@ -5043,6 +5043,13 @@ function ur(s) {
|
|
|
5043
5043
|
emissionTrailShapeAmplitude: s.emissionTrailShapeAmplitude ?? 0.1,
|
|
5044
5044
|
emissionTrailShapeFrequency: s.emissionTrailShapeFrequency ?? 4,
|
|
5045
5045
|
emissionTrailShapeSpeed: s.emissionTrailShapeSpeed ?? 0,
|
|
5046
|
+
shapeStrokeEnabled: s.shapeStrokeEnabled || !1,
|
|
5047
|
+
shapeStrokeWidth: s.shapeStrokeWidth ?? 0.08,
|
|
5048
|
+
shapeStrokeSegments: s.shapeStrokeSegments ?? 96,
|
|
5049
|
+
shapeStrokeShape: s.shapeStrokeShape ?? "straight",
|
|
5050
|
+
shapeStrokeAmplitude: s.shapeStrokeAmplitude ?? 0.08,
|
|
5051
|
+
shapeStrokeFrequency: s.shapeStrokeFrequency ?? 10,
|
|
5052
|
+
shapeStrokeSpeed: s.shapeStrokeSpeed ?? 0,
|
|
5046
5053
|
shapeDisplay: s.shapeDisplay ?? !0,
|
|
5047
5054
|
blendMode: s.blendMode ?? "normal",
|
|
5048
5055
|
noiseDistortEnabled: s.noiseDistortEnabled || !1,
|
|
@@ -5071,7 +5078,7 @@ function ur(s) {
|
|
|
5071
5078
|
displayUnit: s.displayUnit || "m"
|
|
5072
5079
|
};
|
|
5073
5080
|
}
|
|
5074
|
-
async function
|
|
5081
|
+
async function Nr(s, t, e = "hzfx") {
|
|
5075
5082
|
if (!s || !s.particleSystems || s.particleSystems.length === 0) {
|
|
5076
5083
|
alert("No particle systems to save.");
|
|
5077
5084
|
return;
|
|
@@ -5080,12 +5087,12 @@ async function br(s, t, e = "hzfx") {
|
|
|
5080
5087
|
const i = {
|
|
5081
5088
|
version: "1.0",
|
|
5082
5089
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5083
|
-
systems: s.particleSystems.map(({ config:
|
|
5084
|
-
...
|
|
5090
|
+
systems: s.particleSystems.map(({ config: d, system: S }) => ({
|
|
5091
|
+
...Gr(d),
|
|
5085
5092
|
// single source of truth for config fields
|
|
5086
5093
|
// Binary assets embedded so replaceSystems() can restore them
|
|
5087
|
-
textureImageData:
|
|
5088
|
-
glbModelData:
|
|
5094
|
+
textureImageData: d.textureEnabled && !d.glbModelEnabled && d.textureImageData ? d.textureImageData : void 0,
|
|
5095
|
+
glbModelData: d.glbModelEnabled && S.glbRawArrayBuffer ? Fr(S.glbRawArrayBuffer) : void 0
|
|
5089
5096
|
})),
|
|
5090
5097
|
activeSystemIndex: s.activeSystemIndex,
|
|
5091
5098
|
loop: s.loop || !1
|
|
@@ -5093,16 +5100,16 @@ async function br(s, t, e = "hzfx") {
|
|
|
5093
5100
|
}, r = e === "json" ? "json" : "hzfx";
|
|
5094
5101
|
let n;
|
|
5095
5102
|
if (r === "hzfx") {
|
|
5096
|
-
const
|
|
5097
|
-
n = new Blob([
|
|
5103
|
+
const d = await zr(i, { textureFormat: "webp" });
|
|
5104
|
+
n = new Blob([d], { type: "application/octet-stream" });
|
|
5098
5105
|
} else
|
|
5099
5106
|
n = new Blob([JSON.stringify(i, null, 2)], { type: "application/json" });
|
|
5100
5107
|
let a;
|
|
5101
5108
|
if (t)
|
|
5102
5109
|
a = t;
|
|
5103
5110
|
else {
|
|
5104
|
-
const
|
|
5105
|
-
a = `particle-scene_${`${
|
|
5111
|
+
const d = /* @__PURE__ */ new Date();
|
|
5112
|
+
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")}`}`;
|
|
5106
5113
|
}
|
|
5107
5114
|
const o = `${a}.${r}`, c = URL.createObjectURL(n), l = document.createElement("a");
|
|
5108
5115
|
l.href = c, l.download = o, document.body.appendChild(l), l.click(), document.body.removeChild(l), URL.revokeObjectURL(c);
|
|
@@ -5110,7 +5117,7 @@ async function br(s, t, e = "hzfx") {
|
|
|
5110
5117
|
console.error("Error saving scene:", i), alert("Error saving scene. See console for details.");
|
|
5111
5118
|
}
|
|
5112
5119
|
}
|
|
5113
|
-
function
|
|
5120
|
+
function Yr(s) {
|
|
5114
5121
|
return new Promise((t, e) => {
|
|
5115
5122
|
try {
|
|
5116
5123
|
const i = s.target.files[0];
|
|
@@ -5123,7 +5130,7 @@ function Sr(s) {
|
|
|
5123
5130
|
try {
|
|
5124
5131
|
const a = n.target.result;
|
|
5125
5132
|
let o;
|
|
5126
|
-
if (
|
|
5133
|
+
if (Ji(a) ? o = Ki(a) : o = JSON.parse(new TextDecoder().decode(a)), !Array.isArray(o.systems) || o.systems.length === 0)
|
|
5127
5134
|
throw new Error("No valid particle systems found in the file");
|
|
5128
5135
|
t({
|
|
5129
5136
|
systems: o.systems.slice(),
|
|
@@ -5141,7 +5148,7 @@ function Sr(s) {
|
|
|
5141
5148
|
}
|
|
5142
5149
|
});
|
|
5143
5150
|
}
|
|
5144
|
-
async function
|
|
5151
|
+
async function jr(s) {
|
|
5145
5152
|
if (!s || typeof s != "string")
|
|
5146
5153
|
throw new Error("[fetchPreset] url must be a non-empty string");
|
|
5147
5154
|
const t = await fetch(s);
|
|
@@ -5149,7 +5156,7 @@ async function xr(s) {
|
|
|
5149
5156
|
throw new Error(`[fetchPreset] HTTP ${t.status}: ${t.statusText}`);
|
|
5150
5157
|
const e = await t.arrayBuffer();
|
|
5151
5158
|
let i;
|
|
5152
|
-
if (
|
|
5159
|
+
if (Ji(e) ? i = Ki(e) : i = JSON.parse(new TextDecoder().decode(e)), !Array.isArray(i.systems) || i.systems.length === 0)
|
|
5153
5160
|
throw new Error('[fetchPreset] Invalid preset: "systems" must be a non-empty array');
|
|
5154
5161
|
return {
|
|
5155
5162
|
version: i.version,
|
|
@@ -5157,7 +5164,7 @@ async function xr(s) {
|
|
|
5157
5164
|
activeSystemIndex: i.activeSystemIndex ?? 0
|
|
5158
5165
|
};
|
|
5159
5166
|
}
|
|
5160
|
-
const
|
|
5167
|
+
const Dr = (s) => `
|
|
5161
5168
|
@vertex fn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
|
|
5162
5169
|
var p = array<vec2f, 3>(vec2f(-1.0, -3.0), vec2f(-1.0, 1.0), vec2f(3.0, 1.0));
|
|
5163
5170
|
return vec4f(p[i], 0.0, 1.0);
|
|
@@ -5167,60 +5174,60 @@ const dr = (s) => `
|
|
|
5167
5174
|
return textureLoad(src, vec2i(pos.xy), 0);
|
|
5168
5175
|
}
|
|
5169
5176
|
`;
|
|
5170
|
-
async function
|
|
5177
|
+
async function qr(s, t = {}) {
|
|
5171
5178
|
const { getSceneDepth: e = null, autoRespawn: i = !0 } = t;
|
|
5172
5179
|
let r, n, a;
|
|
5173
5180
|
const o = !!(s && s.device && s.context);
|
|
5174
|
-
o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await
|
|
5175
|
-
const c = navigator.gpu.getPreferredCanvasFormat(), l = t.manager || new
|
|
5176
|
-
function
|
|
5177
|
-
const
|
|
5178
|
-
if (!
|
|
5179
|
-
const
|
|
5180
|
-
entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled:
|
|
5181
|
+
o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await _r(a));
|
|
5182
|
+
const c = navigator.gpu.getPreferredCanvasFormat(), l = t.manager || new Pr(r), d = { layouts: {}, pipelines: {} };
|
|
5183
|
+
function S(u) {
|
|
5184
|
+
const f = u ? "ms" : "ss";
|
|
5185
|
+
if (!d.pipelines[f]) {
|
|
5186
|
+
const h = r.createShaderModule({ code: Dr(u) }), b = r.createBindGroupLayout({
|
|
5187
|
+
entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: u } }]
|
|
5181
5188
|
});
|
|
5182
|
-
|
|
5183
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5184
|
-
vertex: { module:
|
|
5185
|
-
fragment: { module:
|
|
5189
|
+
d.layouts[f] = b, d.pipelines[f] = r.createRenderPipeline({
|
|
5190
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [b] }),
|
|
5191
|
+
vertex: { module: h, entryPoint: "vs" },
|
|
5192
|
+
fragment: { module: h, entryPoint: "fs", targets: [] },
|
|
5186
5193
|
primitive: { topology: "triangle-list" },
|
|
5187
5194
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !0, depthCompare: "always" }
|
|
5188
5195
|
});
|
|
5189
5196
|
}
|
|
5190
|
-
return { pipeline:
|
|
5197
|
+
return { pipeline: d.pipelines[f], layout: d.layouts[f] };
|
|
5191
5198
|
}
|
|
5192
|
-
const
|
|
5199
|
+
const g = {
|
|
5193
5200
|
bloomSourceTextures: {},
|
|
5194
5201
|
bloomCompositeTextures: {},
|
|
5195
5202
|
combinedTexture: null,
|
|
5196
|
-
getBloomSourceTexture(
|
|
5197
|
-
return this.bloomSourceTextures[
|
|
5198
|
-
size: [
|
|
5203
|
+
getBloomSourceTexture(u, f, h) {
|
|
5204
|
+
return this.bloomSourceTextures[u] || (this.bloomSourceTextures[u] = r.createTexture({
|
|
5205
|
+
size: [f, h],
|
|
5199
5206
|
format: "rgba16float",
|
|
5200
5207
|
// HDR chain (see webgpu.js HDR_FORMAT) — avoids additive clip
|
|
5201
5208
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5202
|
-
})), this.bloomSourceTextures[
|
|
5209
|
+
})), this.bloomSourceTextures[u];
|
|
5203
5210
|
},
|
|
5204
|
-
getBloomCompositeTexture(
|
|
5205
|
-
return this.bloomCompositeTextures[
|
|
5206
|
-
size: [
|
|
5211
|
+
getBloomCompositeTexture(u, f, h) {
|
|
5212
|
+
return this.bloomCompositeTextures[u] || (this.bloomCompositeTextures[u] = r.createTexture({
|
|
5213
|
+
size: [f, h],
|
|
5207
5214
|
format: "rgba16float",
|
|
5208
5215
|
// HDR chain
|
|
5209
5216
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5210
|
-
})), this.bloomCompositeTextures[
|
|
5217
|
+
})), this.bloomCompositeTextures[u];
|
|
5211
5218
|
},
|
|
5212
|
-
getCombinedTexture(
|
|
5219
|
+
getCombinedTexture(u, f) {
|
|
5213
5220
|
return this.combinedTexture || (this.combinedTexture = r.createTexture({
|
|
5214
|
-
size: [
|
|
5221
|
+
size: [u, f],
|
|
5215
5222
|
format: "rgba16float",
|
|
5216
5223
|
// HDR chain — tonemapped to canvas in the final pass
|
|
5217
5224
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5218
5225
|
})), this.combinedTexture;
|
|
5219
5226
|
},
|
|
5220
5227
|
resizeTextures() {
|
|
5221
|
-
Object.values(this.bloomSourceTextures).forEach((
|
|
5228
|
+
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;
|
|
5222
5229
|
}
|
|
5223
|
-
},
|
|
5230
|
+
}, p = {
|
|
5224
5231
|
systemBindGroups: {},
|
|
5225
5232
|
systemBloomHorizontalBindGroups: {},
|
|
5226
5233
|
secondHorizontalBindGroups: {},
|
|
@@ -5236,166 +5243,323 @@ async function vr(s, t = {}) {
|
|
|
5236
5243
|
clear() {
|
|
5237
5244
|
this.systemBindGroups = {}, this.systemBloomHorizontalBindGroups = {}, this.secondHorizontalBindGroups = {}, this.systemBloomCompositeBindGroups = {}, this.combinedBloomCompositeBindGroups = {}, this.combinedInitialBindGroup = null, this.finalBindGroup = null, this.textureStates = {}, this.textureRefs = {};
|
|
5238
5245
|
}
|
|
5239
|
-
},
|
|
5240
|
-
l.onSystemCreated = (
|
|
5241
|
-
|
|
5246
|
+
}, v = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), A = r.createBuffer({ size: 208, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), U = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), I = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), _ = r.createBuffer({ size: 64, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), $ = vt(r, new Uint16Array([0, 1, 2, 0, 2, 3]), GPUBufferUsage.INDEX), T = {}, z = () => vt(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);
|
|
5247
|
+
l.onSystemCreated = (u) => {
|
|
5248
|
+
T[u] || (T[u] = z());
|
|
5242
5249
|
};
|
|
5243
|
-
const
|
|
5244
|
-
function
|
|
5245
|
-
for (const
|
|
5250
|
+
const F = 4e4, Z = new Float32Array(F * 8), J = new Float32Array(F * 4), ee = new Float32Array(F * 4), K = r.createBuffer({ size: F * 8 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), q = r.createBuffer({ size: F * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), Ke = r.createBuffer({ size: F * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), Pt = /* @__PURE__ */ new Map(), Ye = /* @__PURE__ */ new Map(), kt = 8, Se = [];
|
|
5251
|
+
function ri(u) {
|
|
5252
|
+
for (const f of Se) if (f.ids.has(u)) return f;
|
|
5246
5253
|
return null;
|
|
5247
5254
|
}
|
|
5248
|
-
function
|
|
5249
|
-
if (!
|
|
5250
|
-
|
|
5251
|
-
const
|
|
5252
|
-
for (;
|
|
5253
|
-
}
|
|
5254
|
-
function
|
|
5255
|
-
const
|
|
5256
|
-
if (
|
|
5257
|
-
const
|
|
5258
|
-
return
|
|
5255
|
+
function Qi(u, f) {
|
|
5256
|
+
if (!u.pos) return;
|
|
5257
|
+
u.hist.push({ t: f, x: u.pos[0], y: u.pos[1], z: u.pos[2] });
|
|
5258
|
+
const h = f - kt;
|
|
5259
|
+
for (; u.hist.length > 2 && u.hist[0].t < h; ) u.hist.shift();
|
|
5260
|
+
}
|
|
5261
|
+
function ni(u, f, h) {
|
|
5262
|
+
const b = u.hist;
|
|
5263
|
+
if (b.length === 0) {
|
|
5264
|
+
const R = u.pos;
|
|
5265
|
+
return R && (h[0] = R[0], h[1] = R[1], h[2] = R[2]), h;
|
|
5259
5266
|
}
|
|
5260
|
-
let
|
|
5261
|
-
if (
|
|
5262
|
-
return
|
|
5263
|
-
if (
|
|
5264
|
-
return
|
|
5265
|
-
for (let
|
|
5266
|
-
if (
|
|
5267
|
-
const
|
|
5268
|
-
return
|
|
5267
|
+
let y;
|
|
5268
|
+
if (f >= b[b.length - 1].t)
|
|
5269
|
+
return y = b[b.length - 1], h[0] = y.x, h[1] = y.y, h[2] = y.z, h;
|
|
5270
|
+
if (f <= b[0].t)
|
|
5271
|
+
return y = b[0], h[0] = y.x, h[1] = y.y, h[2] = y.z, h;
|
|
5272
|
+
for (let R = b.length - 1; R > 0; R--)
|
|
5273
|
+
if (b[R - 1].t <= f) {
|
|
5274
|
+
const P = b[R - 1], M = b[R], x = (f - P.t) / Math.max(1e-6, M.t - P.t);
|
|
5275
|
+
return h[0] = P.x + (M.x - P.x) * x, h[1] = P.y + (M.y - P.y) * x, h[2] = P.z + (M.z - P.z) * x, h;
|
|
5269
5276
|
}
|
|
5270
|
-
return
|
|
5271
|
-
}
|
|
5272
|
-
const
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5277
|
+
return y = b[0], h[0] = y.x, h[1] = y.y, h[2] = y.z, h;
|
|
5278
|
+
}
|
|
5279
|
+
const ft = Math.PI * 2, se = new Array(257), re = new Array(257), ne = new Array(257);
|
|
5280
|
+
new Array(257), new Array(257), new Array(257);
|
|
5281
|
+
const Re = [0, 0, 0];
|
|
5282
|
+
function es(u) {
|
|
5283
|
+
const f = u.emissionRotationX || 0, h = u.emissionRotationY || 0, b = u.emissionRotationZ || 0;
|
|
5284
|
+
if (!f && !h && !b) return null;
|
|
5285
|
+
const y = f * Math.PI / 180, R = h * Math.PI / 180, P = b * Math.PI / 180, M = Math.cos(y), x = Math.sin(y), w = Math.cos(R), m = Math.sin(R), B = Math.cos(P), C = Math.sin(P);
|
|
5286
|
+
return [
|
|
5287
|
+
w * B,
|
|
5288
|
+
x * m * B - M * C,
|
|
5289
|
+
M * m * B + x * C,
|
|
5290
|
+
w * C,
|
|
5291
|
+
x * m * C + M * B,
|
|
5292
|
+
M * m * C - x * B,
|
|
5293
|
+
-m,
|
|
5294
|
+
x * w,
|
|
5295
|
+
M * w
|
|
5296
|
+
];
|
|
5297
|
+
}
|
|
5298
|
+
function Ct(u, f, h, b, y) {
|
|
5299
|
+
return y[0] = u[0] * f + u[1] * h + u[2] * b, y[1] = u[3] * f + u[4] * h + u[5] * b, y[2] = u[6] * f + u[7] * h + u[8] * b, y;
|
|
5300
|
+
}
|
|
5301
|
+
function ts(u, f, h, b, y, R, P) {
|
|
5302
|
+
let M = u, x = f, w = h;
|
|
5303
|
+
b && (Ct(b, M, x, w, P), M = P[0], x = P[1], w = P[2]), M += R.emissionPositionX || 0, x += R.emissionPositionY || 0, w += R.emissionPositionZ || 0, y._simRotMatrix && (Ct(y._simRotMatrix, M, x, w, P), M = P[0], x = P[1], w = P[2]);
|
|
5304
|
+
const m = y._simPosition;
|
|
5305
|
+
return P[0] = M + (m ? m[0] : 0), P[1] = x + (m ? m[1] : 0), P[2] = w + (m ? m[2] : 0), P;
|
|
5306
|
+
}
|
|
5307
|
+
function is(u, f, h, b, y, R) {
|
|
5308
|
+
let P = u, M = f, x = h;
|
|
5309
|
+
return b && (Ct(b, P, M, x, R), P = R[0], M = R[1], x = R[2]), y._simRotMatrix && (Ct(y._simRotMatrix, P, M, x, R), P = R[0], M = R[1], x = R[2]), R[0] = P, R[1] = M, R[2] = x, R;
|
|
5310
|
+
}
|
|
5311
|
+
function Xt(u, f, h, b, y) {
|
|
5312
|
+
const R = f * 2, P = h * 2, M = 2 * (R + P);
|
|
5313
|
+
let x = (u % 1 + 1) % 1 * M, w = 0, m = 0;
|
|
5314
|
+
return x < R ? (w = -f + x, m = h) : (x -= R) < P ? (w = f, m = h - x) : (x -= P) < R ? (w = f - x, m = -h) : (x -= R, w = -f, m = -h + x), b === "xz" ? (y[0] = w, y[1] = 0, y[2] = m) : (y[0] = w, y[1] = m, y[2] = 0), y;
|
|
5315
|
+
}
|
|
5316
|
+
function ss(u) {
|
|
5317
|
+
const f = u.emissionShape, h = Math.max(1, Math.min(256, Math.floor(u.shapeStrokeSegments ?? 96)));
|
|
5318
|
+
let b = 0, y = !1, R = [0, 0, 1];
|
|
5319
|
+
const P = Re;
|
|
5320
|
+
if (f === "circle") {
|
|
5321
|
+
y = !0, b = Math.max(3, h), R = [0, 0, 1];
|
|
5322
|
+
const M = u.circleOuterRadius ?? 2;
|
|
5323
|
+
for (let x = 0; x < b; x++) {
|
|
5324
|
+
const w = x / b * ft;
|
|
5325
|
+
se[x] = Math.cos(w) * M, re[x] = Math.sin(w) * M, ne[x] = 0;
|
|
5326
|
+
}
|
|
5327
|
+
} else if (f === "disc") {
|
|
5328
|
+
y = !0, b = Math.max(3, h), R = [0, 1, 0];
|
|
5329
|
+
const M = u.discRadius ?? 2;
|
|
5330
|
+
for (let x = 0; x < b; x++) {
|
|
5331
|
+
const w = x / b * ft;
|
|
5332
|
+
se[x] = Math.cos(w) * M, re[x] = 0, ne[x] = Math.sin(w) * M;
|
|
5333
|
+
}
|
|
5334
|
+
} else if (f === "annulus") {
|
|
5335
|
+
y = !0, b = Math.max(3, h), R = [0, 1, 0];
|
|
5336
|
+
const M = u.annulusInnerRadius ?? 1, x = u.annulusOuterRadius ?? 2, w = M + (x - M) * 0.5;
|
|
5337
|
+
for (let m = 0; m < b; m++) {
|
|
5338
|
+
const B = m / b * ft;
|
|
5339
|
+
se[m] = Math.cos(B) * w, re[m] = 0, ne[m] = Math.sin(B) * w;
|
|
5340
|
+
}
|
|
5341
|
+
} else if (f === "arc") {
|
|
5342
|
+
y = !1, b = Math.max(2, h + 1), R = [0, 0, 1];
|
|
5343
|
+
const M = u.arcInnerRadius ?? 0, x = u.arcOuterRadius ?? 2, w = M > 0 ? M + (x - M) * 0.5 : x, m = (u.arcStartAngle ?? 0) * Math.PI / 180, B = (u.arcEndAngle ?? 180) * Math.PI / 180;
|
|
5344
|
+
for (let C = 0; C < b; C++) {
|
|
5345
|
+
const H = b > 1 ? C / (b - 1) : 0, V = m + (B - m) * H;
|
|
5346
|
+
se[C] = Math.cos(V) * w, re[C] = Math.sin(V) * w, ne[C] = 0;
|
|
5347
|
+
}
|
|
5348
|
+
} else if (f === "square") {
|
|
5349
|
+
y = !0, b = Math.max(4, h), R = [0, 0, 1];
|
|
5350
|
+
const M = u.squareSize ?? 2;
|
|
5351
|
+
for (let x = 0; x < b; x++)
|
|
5352
|
+
Xt(x / b, M, M, "xy", P), se[x] = P[0], re[x] = P[1], ne[x] = P[2];
|
|
5353
|
+
} else if (f === "rectangle") {
|
|
5354
|
+
y = !0, b = Math.max(4, h), R = [0, 0, 1];
|
|
5355
|
+
const M = (u.rectangleWidth ?? 2) * 0.5, x = (u.rectangleHeight ?? 2) * 0.5;
|
|
5356
|
+
for (let w = 0; w < b; w++)
|
|
5357
|
+
Xt(w / b, M, x, "xy", P), se[w] = P[0], re[w] = P[1], ne[w] = P[2];
|
|
5358
|
+
} else if (f === "plain") {
|
|
5359
|
+
y = !0, b = Math.max(4, h), R = [0, 1, 0];
|
|
5360
|
+
const M = (u.planeWidth ?? 2) * 0.5, x = (u.planeDepth ?? 2) * 0.5;
|
|
5361
|
+
for (let w = 0; w < b; w++)
|
|
5362
|
+
Xt(w / b, M, x, "xz", P), se[w] = P[0], re[w] = P[1], ne[w] = P[2];
|
|
5363
|
+
} else if (f === "line") {
|
|
5364
|
+
y = !1, b = Math.max(2, h + 1), R = [0, 0, 1];
|
|
5365
|
+
const M = u.lineLength ?? 4;
|
|
5366
|
+
for (let x = 0; x < b; x++) {
|
|
5367
|
+
const w = b > 1 ? x / (b - 1) : 0;
|
|
5368
|
+
se[x] = 0, re[x] = (w - 0.5) * M, ne[x] = 0;
|
|
5369
|
+
}
|
|
5370
|
+
} else if (f === "polygon") {
|
|
5371
|
+
y = !0, b = Math.max(3, h), R = [0, 0, 1];
|
|
5372
|
+
const M = Math.max(3, Math.floor(u.polygonSides ?? 6)), x = u.polygonRadius ?? 2;
|
|
5373
|
+
for (let w = 0; w < b; w++) {
|
|
5374
|
+
const m = w / b * M, B = Math.floor(m), C = m - B, H = B / M * ft, V = (B + 1) / M * ft, L = Math.cos(H) * x, N = Math.sin(H) * x, D = Math.cos(V) * x, pe = Math.sin(V) * x;
|
|
5375
|
+
se[w] = L + (D - L) * C, re[w] = N + (pe - N) * C, ne[w] = 0;
|
|
5376
|
+
}
|
|
5377
|
+
} else
|
|
5378
|
+
b = 0;
|
|
5379
|
+
return { count: b, closed: y, planeNormal: R };
|
|
5380
|
+
}
|
|
5381
|
+
function rs(u, f, h) {
|
|
5382
|
+
if (!h.shapeStrokeEnabled || h.hidden) return u;
|
|
5383
|
+
const { count: b, closed: y, planeNormal: R } = ss(h);
|
|
5384
|
+
if (b < 2) return u;
|
|
5385
|
+
const P = es(h), M = Math.max(1e-4, h.shapeStrokeWidth ?? 0.08), x = Math.max(0, h.opacity ?? 1);
|
|
5386
|
+
if (x <= 0) return u;
|
|
5387
|
+
is(R[0], R[1], R[2], P, f, Re);
|
|
5388
|
+
let w = Math.hypot(Re[0], Re[1], Re[2]) || 1;
|
|
5389
|
+
const m = Re[0] / w, B = Re[1] / w, C = Re[2] / w;
|
|
5390
|
+
for (let X = 0; X < b; X++)
|
|
5391
|
+
ts(se[X], re[X], ne[X], P, f, h, Re), se[X] = Re[0], re[X] = Re[1], ne[X] = Re[2];
|
|
5392
|
+
const H = h.shapeStrokeShape ?? "straight";
|
|
5393
|
+
if (H !== "straight") {
|
|
5394
|
+
const X = h.shapeStrokeAmplitude ?? 0.08, ae = h.shapeStrokeFrequency ?? 10, he = h.shapeStrokeSpeed ?? 0;
|
|
5395
|
+
for (let te = 0; te < b; te++) {
|
|
5396
|
+
const Ie = te === 0 ? y ? b - 1 : 0 : te - 1, Te = te === b - 1 ? y ? 0 : b - 1 : te + 1, et = se[Te] - se[Ie], tt = re[Te] - re[Ie], ze = ne[Te] - ne[Ie], de = B * ze - C * tt, fe = C * et - m * ze, me = m * tt - B * et, Ee = Math.hypot(de, fe, me) || 1, Fe = de / Ee, xe = fe / Ee, Ge = me / Ee, ve = y ? te / b : te / Math.max(1, b - 1), oe = ft * ae * ve + he * ke;
|
|
5397
|
+
let Q = 0, ye = 0;
|
|
5398
|
+
H === "zigzag" ? Q = X * Math.sign(Math.sin(oe) || 1) : H === "sine" ? Q = X * Math.sin(oe) : H === "spiral" && (Q = X * Math.sin(oe), ye = X * Math.cos(oe)), se[te] += Fe * Q + m * ye, re[te] += xe * Q + B * ye, ne[te] += Ge * Q + C * ye;
|
|
5399
|
+
}
|
|
5400
|
+
}
|
|
5401
|
+
const V = y ? b : b - 1, L = h.bloomIntensity || 1, N = h.startColor ?? h.particleColor ?? [1, 1, 1], D = h.endColor ?? N, pe = h.particleColor ?? N, lt = h.randomColorEnabled && Array.isArray(h.randomColors) && h.randomColors.length > 0 ? h.randomColors[0] : null, ue = M * 0.5, wt = Math.max(M * 4, 1e-4), He = (h.shapeStrokeSpeed ?? 0) * ke;
|
|
5402
|
+
let Qe = 0;
|
|
5403
|
+
for (let X = 0; X < V; X++) {
|
|
5404
|
+
const ae = y ? (X + 1) % b : X + 1;
|
|
5405
|
+
Qe += Math.hypot(se[ae] - se[X], re[ae] - re[X], ne[ae] - ne[X]);
|
|
5406
|
+
}
|
|
5407
|
+
const Wt = y ? Math.max(1, Math.round(Qe / wt)) : Math.max(Qe / wt, 1e-6), Bt = Qe > 1e-6 ? Wt / Qe : 0;
|
|
5408
|
+
let Ze = 0;
|
|
5409
|
+
for (let X = 0; X < V && !(u + 54 > Ue.length); X++) {
|
|
5410
|
+
const ae = y ? (X + 1) % b : X + 1, he = se[X], te = re[X], Ie = ne[X], Te = se[ae], et = re[ae], tt = ne[ae];
|
|
5411
|
+
let ze = Te - he, de = et - te, fe = tt - Ie;
|
|
5412
|
+
const me = Math.hypot(ze, de, fe) || 1;
|
|
5413
|
+
ze /= me, de /= me, fe /= me;
|
|
5414
|
+
const Ee = G.right[0], Fe = G.right[1], xe = G.right[2];
|
|
5415
|
+
let Ge = Ee * ze + Fe * de + xe * fe, ve = Ee - Ge * ze, oe = Fe - Ge * de, Q = xe - Ge * fe, ye = Math.hypot(ve, oe, Q);
|
|
5416
|
+
if (ye < 0.2) {
|
|
5417
|
+
const Ce = G.up[0], Tt = G.up[1], E = G.up[2], O = Ce * ze + Tt * de + E * fe;
|
|
5418
|
+
ve = Ce - O * ze, oe = Tt - O * de, Q = E - O * fe, ye = Math.hypot(ve, oe, Q) || 1;
|
|
5419
|
+
}
|
|
5420
|
+
ve /= ye, oe /= ye, Q /= ye;
|
|
5421
|
+
const yt = y ? X / b : X / Math.max(1, b - 1), gt = y ? ae / b : ae / Math.max(1, b - 1), bt = Ze * Bt + He, it = (Ze + me) * Bt + He;
|
|
5422
|
+
let Pe, _e, De, Ae, le, ce;
|
|
5423
|
+
lt ? (Pe = Ae = lt[0], _e = le = lt[1], De = ce = lt[2]) : h.colorTransitionEnabled ? (Pe = N[0] + (D[0] - N[0]) * yt, _e = N[1] + (D[1] - N[1]) * yt, De = N[2] + (D[2] - N[2]) * yt, Ae = N[0] + (D[0] - N[0]) * gt, le = N[1] + (D[1] - N[1]) * gt, ce = N[2] + (D[2] - N[2]) * gt) : (Pe = Ae = pe[0], _e = le = pe[1], De = ce = pe[2]), Pe = Math.min(1, Pe * L), _e = Math.min(1, _e * L), De = Math.min(1, De * L), Ae = Math.min(1, Ae * L), le = Math.min(1, le * L), ce = Math.min(1, ce * L);
|
|
5424
|
+
const Xe = he + ve * ue, Vt = te + oe * ue, Ot = Ie + Q * ue, Rt = he - ve * ue, St = te - oe * ue, Me = Ie - Q * ue, we = Te + ve * ue, Be = et + oe * ue, st = tt + Q * ue, ct = Te - ve * ue, Lt = et - oe * ue, $e = tt - Q * ue, ge = (Ce, Tt, E, O, ie, Y, k, j, W) => {
|
|
5425
|
+
Ue[u++] = Ce, Ue[u++] = Tt, Ue[u++] = E, Ue[u++] = O, Ue[u++] = ie, Ue[u++] = Y, Ue[u++] = k, Ue[u++] = j, Ue[u++] = W;
|
|
5426
|
+
};
|
|
5427
|
+
ge(Xe, Vt, Ot, Pe, _e, De, x, bt, 0), ge(Rt, St, Me, Pe, _e, De, x, bt, 1), ge(we, Be, st, Ae, le, ce, x, it, 0), ge(Rt, St, Me, Pe, _e, De, x, bt, 1), ge(ct, Lt, $e, Ae, le, ce, x, it, 1), ge(we, Be, st, Ae, le, ce, x, it, 0), Ze += me;
|
|
5428
|
+
}
|
|
5429
|
+
return u;
|
|
5430
|
+
}
|
|
5431
|
+
const ns = 0.41421356;
|
|
5432
|
+
function as() {
|
|
5433
|
+
Pt.clear(), Ye.clear();
|
|
5434
|
+
let u = 0, f = 0, h = 0;
|
|
5435
|
+
G.position[0], G.position[1], G.position[2];
|
|
5436
|
+
for (const { system: b, config: y } of l.particleSystems) {
|
|
5437
|
+
if (y.hidden) continue;
|
|
5438
|
+
if (y.emissionTrailEnabled && !y.glbModelEnabled) {
|
|
5439
|
+
b.readbackAndProcessParticles();
|
|
5440
|
+
const P = b.particleData, M = b.particleVelocities, x = b.activeParticles;
|
|
5441
|
+
if (P && M && x > 0) {
|
|
5442
|
+
const w = y.emissionTrailMode === "particles", m = u, B = y.emissionTrailDuration ?? 1, C = y.opacity ?? 1, H = y.particleSize ?? 0.5, V = y.bloomIntensity || 1, L = Math.max(1, Math.min(64, y.emissionTrailSegments ?? 8)), N = y.emissionTrailShape || "straight", D = y.followSystemTranslation ?? !0, pe = b._simPosition, lt = D && pe ? pe[0] : 0, ue = D && pe ? pe[1] : 0, wt = D && pe ? pe[2] : 0, He = b._simVelocity, Qe = He ? He[0] : 0, Wt = He ? He[1] : 0, Bt = He ? He[2] : 0, Ze = ri(y.id), X = !!(D && Ze && Ze.hist && Ze.hist.length > 1);
|
|
5443
|
+
for (let ae = 0; ae < x; ae++) {
|
|
5444
|
+
const he = ae * 8, te = P[he], Ie = P[he + 1], Te = P[he + 2], et = te + lt, tt = Ie + ue, ze = Te + wt;
|
|
5445
|
+
let de = P[he + 3], fe = P[he + 4], me = P[he + 5];
|
|
5446
|
+
const Ee = P[he + 6], Fe = P[he + 7];
|
|
5447
|
+
if (Ee >= Fe || Fe <= 0) continue;
|
|
5448
|
+
const xe = Ee / Fe;
|
|
5449
|
+
if (y.colorTransitionEnabled) {
|
|
5450
|
+
const E = y.startColor ?? [1, 0, 0], O = y.endColor ?? [0, 0, 1];
|
|
5451
|
+
de = E[0] + (O[0] - E[0]) * xe, fe = E[1] + (O[1] - E[1]) * xe, me = E[2] + (O[2] - E[2]) * xe;
|
|
5452
|
+
}
|
|
5453
|
+
de = Math.min(1, de * V), fe = Math.min(1, fe * V), me = Math.min(1, me * V);
|
|
5454
|
+
let Ge = H;
|
|
5455
|
+
if (y.randomSize) {
|
|
5456
|
+
const E = Math.sin(Fe * 54321.67) * 43758.5453 % 1, O = E < 0 ? E + 1 : E;
|
|
5457
|
+
Ge = (y.minSize ?? 0.1) + ((y.maxSize ?? 0.5) - (y.minSize ?? 0.1)) * O;
|
|
5458
|
+
}
|
|
5459
|
+
if (y.fadeSizeEnabled) {
|
|
5460
|
+
const E = Math.max(0.01, Math.min(10, y.sizeLifetimeSpeed ?? 1));
|
|
5461
|
+
Ge *= 1 - Math.pow(xe, 1 / E);
|
|
5462
|
+
}
|
|
5463
|
+
if (y.increaseSizeEnabled) {
|
|
5464
|
+
const E = Math.max(0.01, Math.min(10, y.sizeLifetimeSpeed ?? 1));
|
|
5465
|
+
Ge *= 1 + Math.pow(xe, 1 / E);
|
|
5466
|
+
}
|
|
5467
|
+
if (Ge <= 0 || xe > 0.9) continue;
|
|
5468
|
+
const ve = Math.min((0.9 - xe) * (1 / 0.2), 1), oe = 0.75 * Ge * ns * ve;
|
|
5469
|
+
let Q = C;
|
|
5470
|
+
if (y.fadeEnabled && (Q *= Math.max(0, 1 - xe)), Q *= ve, Q < 0.01) continue;
|
|
5471
|
+
const ye = ae * 4, yt = M[ye], gt = M[ye + 1], bt = M[ye + 2], it = yt + Qe, Pe = gt + Wt, _e = bt + Bt, De = Math.sqrt(it * it + Pe * Pe + _e * _e);
|
|
5472
|
+
if (De < 1e-3) continue;
|
|
5473
|
+
const Ae = 1 / De, le = it * Ae, ce = Pe * Ae, Xe = _e * Ae, Vt = G.right[0], Ot = G.right[1], Rt = G.right[2];
|
|
5474
|
+
let St = Vt * le + Ot * ce + Rt * Xe, Me = Vt - St * le, we = Ot - St * ce, Be = Rt - St * Xe, st = Math.sqrt(Me * Me + we * we + Be * Be);
|
|
5475
|
+
if (st < 0.2) {
|
|
5476
|
+
const E = G.up[0], O = G.up[1], ie = G.up[2], Y = E * le + O * ce + ie * Xe;
|
|
5477
|
+
Me = E - Y * le, we = O - Y * ce, Be = ie - Y * Xe, st = Math.sqrt(Me * Me + we * we + Be * Be) || 1;
|
|
5478
|
+
}
|
|
5479
|
+
Me /= st, we /= st, Be /= st;
|
|
5480
|
+
const ct = Math.min(B, Ee);
|
|
5481
|
+
if (ct < 1e-3) continue;
|
|
5482
|
+
const Lt = y.gravityEnabled && y.gravityStrength || 0, $e = bs, ge = Ss, Ce = xs;
|
|
5483
|
+
if (y.orientToDirection && y.burstMode && X) {
|
|
5484
|
+
const E = b._emitSimRotY || 0, O = vs, ie = Ps, Y = _s;
|
|
5485
|
+
for (let k = 0; k <= L; k++) {
|
|
5486
|
+
const j = ni(Ze, ke - k / L * ct, Si);
|
|
5487
|
+
O[k] = j[0], ie[k] = j[1], Y[k] = j[2];
|
|
5488
|
+
}
|
|
5489
|
+
for (let k = 0; k <= L; k++) {
|
|
5490
|
+
const j = k > 0 ? k - 1 : 0, W = k < L ? k + 1 : L;
|
|
5491
|
+
let ut = O[j] - O[W], dt = Y[j] - Y[W];
|
|
5492
|
+
const rt = (Math.hypot(ut, dt) > 1e-5 ? Math.atan2(ut, dt) : Math.atan2(Qe, Bt)) - E, Ve = Math.cos(rt), Oe = Math.sin(rt), Je = k / L * ct, Jt = -0.5 * Lt * Je * Je;
|
|
5493
|
+
$e[k] = Ve * te + Oe * Te + O[k], ge[k] = Ie + Jt + ie[k], Ce[k] = -Oe * te + Ve * Te + Y[k];
|
|
5494
|
+
}
|
|
5495
|
+
} else for (let E = 0; E <= L; E++) {
|
|
5496
|
+
const O = E / L * ct, ie = -0.5 * Lt * O * O;
|
|
5497
|
+
if (X) {
|
|
5498
|
+
const Y = ni(Ze, ke - O, Si);
|
|
5499
|
+
$e[E] = te - yt * O + Y[0], ge[E] = Ie - gt * O + ie + Y[1], Ce[E] = Te - bt * O + Y[2];
|
|
5500
|
+
} else
|
|
5501
|
+
$e[E] = et - it * O, ge[E] = tt - Pe * O + ie, Ce[E] = ze - _e * O;
|
|
5502
|
+
}
|
|
5503
|
+
if (N !== "straight") {
|
|
5504
|
+
const E = y.emissionTrailShapeAmplitude ?? 0.1, O = y.emissionTrailShapeFrequency ?? 4, ie = y.emissionTrailShapeSpeed ?? 0;
|
|
5505
|
+
let Y = -Xe, k = 0, j = le, W = Math.sqrt(Y * Y + j * j);
|
|
5506
|
+
W < 1e-6 && (Y = 0, k = Xe, j = -ce, W = Math.sqrt(Y * Y + k * k + j * j) || 1), Y /= W, k /= W, j /= W;
|
|
5507
|
+
const ut = ce * j - Xe * k, dt = Xe * Y - le * j, We = le * k - ce * Y;
|
|
5508
|
+
for (let be = 1; be <= L; be++) {
|
|
5509
|
+
const rt = be / L * ct, Ve = 2 * Math.PI * O * (ke - rt) + ie * ke;
|
|
5510
|
+
let Oe = 0, Je = 0;
|
|
5511
|
+
N === "zigzag" ? Oe = E * Math.sign(Math.sin(Ve)) : N === "sine" ? Oe = E * Math.sin(Ve) : N === "spiral" && (Oe = E * Math.sin(Ve), Je = E * Math.cos(Ve)), $e[be] += Y * Oe + ut * Je, ge[be] += k * Oe + dt * Je, Ce[be] += j * Oe + We * Je;
|
|
5512
|
+
}
|
|
5513
|
+
}
|
|
5514
|
+
if (w)
|
|
5515
|
+
for (let E = 1; E <= L && u < F; E++) {
|
|
5516
|
+
const O = E / L, ie = $e[E] - lt, Y = ge[E] - ue, k = Ce[E] - wt, j = u * 8, W = u * 4;
|
|
5517
|
+
Z[j] = ie, Z[j + 1] = Y, Z[j + 2] = k, Z[j + 3] = de, Z[j + 4] = fe, Z[j + 5] = me, Z[j + 6] = Ee + (Fe - Ee) * O, Z[j + 7] = Fe, J[W] = 0, J[W + 1] = 0, J[W + 2] = 0, J[W + 3] = 0, ee[W] = ie, ee[W + 1] = Y, ee[W + 2] = k, ee[W + 3] = 0, u++;
|
|
5518
|
+
}
|
|
5519
|
+
else
|
|
5520
|
+
for (let E = 0; E < L && !(f + 42 > qe.length); E++) {
|
|
5521
|
+
const O = E / L, ie = (E + 1) / L, Y = $e[E], k = ge[E], j = Ce[E], W = $e[E + 1], ut = ge[E + 1], dt = Ce[E + 1], We = oe * (1 - O), be = oe * (1 - ie), rt = Q * (1 - O) * (1 - O), Ve = Q * (1 - ie) * (1 - ie), Oe = Y + Me * We, Je = k + we * We, Jt = j + Be * We, Ri = Y - Me * We, Ti = k - we * We, Ei = j - Be * We, Ai = W + Me * be, Ci = ut + we * be, Ui = dt + Be * be, zs = W - Me * be, Fs = ut - we * be, Gs = dt - Be * be, xt = (Ds, Vs, Os, Ls) => {
|
|
5522
|
+
qe[f++] = Ds, qe[f++] = Vs, qe[f++] = Os, qe[f++] = de, qe[f++] = fe, qe[f++] = me, qe[f++] = Ls;
|
|
5523
|
+
};
|
|
5524
|
+
xt(Oe, Je, Jt, rt), xt(Ri, Ti, Ei, rt), xt(Ai, Ci, Ui, Ve), xt(Ri, Ti, Ei, rt), xt(zs, Fs, Gs, Ve), xt(Ai, Ci, Ui, Ve);
|
|
5525
|
+
}
|
|
5352
5526
|
}
|
|
5527
|
+
w && u > m && Pt.set(y.id, { first: m, count: u - m });
|
|
5353
5528
|
}
|
|
5354
|
-
if (Q)
|
|
5355
|
-
for (let w = 1; w <= I && f < E; w++) {
|
|
5356
|
-
const z = w / I, $ = _e[w] - X, V = we[w] - it, A = Be[w] - jt, O = f * 8, H = f * 4;
|
|
5357
|
-
D[O] = $, D[O + 1] = V, D[O + 2] = A, D[O + 3] = Le, D[O + 4] = Xe, D[O + 5] = Ne, D[O + 6] = ke + (Ie - ke) * z, D[O + 7] = Ie, N[H] = 0, N[H + 1] = 0, N[H + 2] = 0, N[H + 3] = 0, Y[H] = $, Y[H + 1] = V, Y[H + 2] = A, Y[H + 3] = 0, f++;
|
|
5358
|
-
}
|
|
5359
|
-
else
|
|
5360
|
-
for (let w = 0; w < I && !(m + 42 > le.length); w++) {
|
|
5361
|
-
const z = w / I, $ = (w + 1) / I, V = _e[w], A = we[w], O = Be[w], H = _e[w + 1], Me = we[w + 1], Re = Be[w + 1], ce = $t * (1 - z), ee = $t * (1 - $), ge = Ye * (1 - z) * (1 - z), te = Ye * (1 - $) * (1 - $), ie = V + re * ce, ue = A + ne * ce, St = O + ae * ce, ri = V - re * ce, ni = A - ne * ce, ai = O - ae * ce, oi = H + re * ee, li = Me + ne * ee, ci = Re + ae * ee, ls = H - re * ee, cs = Me - ne * ee, us = Re - ae * ee, ze = (ds, fs, hs, ps) => {
|
|
5362
|
-
le[m++] = ds, le[m++] = fs, le[m++] = hs, le[m++] = Le, le[m++] = Xe, le[m++] = Ne, le[m++] = ps;
|
|
5363
|
-
};
|
|
5364
|
-
ze(ie, ue, St, ge), ze(ri, ni, ai, ge), ze(oi, li, ci, te), ze(ri, ni, ai, ge), ze(ls, cs, us, te), ze(oi, li, ci, te);
|
|
5365
|
-
}
|
|
5366
5529
|
}
|
|
5367
|
-
|
|
5530
|
+
const R = h;
|
|
5531
|
+
h = rs(h, b, y), h > R && Ye.set(y.id, { first: R / 9, count: (h - R) / 9 });
|
|
5368
5532
|
}
|
|
5369
|
-
|
|
5533
|
+
u > 0 && (r.queue.writeBuffer(K, 0, Z, 0, u * 8), r.queue.writeBuffer(q, 0, J, 0, u * 4), r.queue.writeBuffer(Ke, 0, ee, 0, u * 4)), _t = f / 7, _t > 0 && r.queue.writeBuffer(Nt, 0, qe, 0, f), mi = h / 9, mi > 0 && r.queue.writeBuffer(Yt, 0, Ue, 0, h);
|
|
5370
5534
|
}
|
|
5371
|
-
const
|
|
5372
|
-
r.queue.writeBuffer(
|
|
5535
|
+
const ai = () => {
|
|
5536
|
+
r.queue.writeBuffer(U, 0, new Float32Array([1, 0, a.width, a.height, 0, 0, 0, 0])), r.queue.writeBuffer(I, 0, new Float32Array([0, 1, a.width, a.height, 0, 0, 0, 0]));
|
|
5373
5537
|
};
|
|
5374
|
-
|
|
5375
|
-
const
|
|
5376
|
-
|
|
5377
|
-
const
|
|
5378
|
-
particlePipeline:
|
|
5379
|
-
particleAdditivePipeline:
|
|
5380
|
-
particleDepthWritePipeline:
|
|
5381
|
-
blurPipeline:
|
|
5382
|
-
compositePipeline:
|
|
5383
|
-
directRenderPipeline:
|
|
5384
|
-
finalCompositePipeline:
|
|
5385
|
-
glbMeshPipeline:
|
|
5386
|
-
} =
|
|
5538
|
+
ai();
|
|
5539
|
+
const oi = new Float32Array(16).fill(0);
|
|
5540
|
+
oi[0] = 1, r.queue.writeBuffer(_, 0, oi);
|
|
5541
|
+
const Le = Tr(r), je = Br(r), {
|
|
5542
|
+
particlePipeline: os,
|
|
5543
|
+
particleAdditivePipeline: ls,
|
|
5544
|
+
particleDepthWritePipeline: cs,
|
|
5545
|
+
blurPipeline: Ut,
|
|
5546
|
+
compositePipeline: us,
|
|
5547
|
+
directRenderPipeline: li,
|
|
5548
|
+
finalCompositePipeline: ds,
|
|
5549
|
+
glbMeshPipeline: fs
|
|
5550
|
+
} = Rr(r, c, je), ci = r.createShaderModule({ code: `
|
|
5387
5551
|
struct U { mvp: mat4x4<f32> };
|
|
5388
5552
|
@group(0) @binding(0) var<uniform> u: U;
|
|
5389
5553
|
struct VIn { @location(0) pos: vec3<f32>, @location(1) col: vec4<f32> };
|
|
5390
5554
|
struct VOut { @builtin(position) pos: vec4<f32>, @location(0) col: vec4<f32> };
|
|
5391
5555
|
@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; }
|
|
5392
5556
|
@fragment fn fs(i: VOut) -> @location(0) vec4<f32> { return i.col; }
|
|
5393
|
-
` }),
|
|
5557
|
+
` }), ui = r.createBindGroupLayout({
|
|
5394
5558
|
entries: [{ binding: 0, visibility: GPUShaderStage.VERTEX, buffer: { type: "uniform" } }]
|
|
5395
|
-
}),
|
|
5396
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5559
|
+
}), ps = r.createRenderPipeline({
|
|
5560
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [ui] }),
|
|
5397
5561
|
vertex: {
|
|
5398
|
-
module:
|
|
5562
|
+
module: ci,
|
|
5399
5563
|
entryPoint: "vs",
|
|
5400
5564
|
buffers: [{ arrayStride: 28, attributes: [
|
|
5401
5565
|
{ shaderLocation: 0, offset: 0, format: "float32x3" },
|
|
@@ -5403,7 +5567,7 @@ async function vr(s, t = {}) {
|
|
|
5403
5567
|
] }]
|
|
5404
5568
|
},
|
|
5405
5569
|
fragment: {
|
|
5406
|
-
module:
|
|
5570
|
+
module: ci,
|
|
5407
5571
|
entryPoint: "fs",
|
|
5408
5572
|
targets: [{ format: "rgba16float", blend: {
|
|
5409
5573
|
// renders into the HDR sceneTexture
|
|
@@ -5415,23 +5579,182 @@ async function vr(s, t = {}) {
|
|
|
5415
5579
|
// depth24plus to match the non-bloom pass; test against the resolved scene depth
|
|
5416
5580
|
// (occlusion) but don't write (transparent ribbon).
|
|
5417
5581
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
|
|
5418
|
-
}),
|
|
5419
|
-
size:
|
|
5582
|
+
}), di = 512 * 64 * 6, qe = new Float32Array(di * 7), Nt = r.createBuffer({
|
|
5583
|
+
size: di * 7 * 4,
|
|
5420
5584
|
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
5421
5585
|
label: "ribbonBuffer"
|
|
5422
|
-
}),
|
|
5423
|
-
layout:
|
|
5424
|
-
entries: [{ binding: 0, resource: { buffer:
|
|
5586
|
+
}), hs = r.createBindGroup({
|
|
5587
|
+
layout: ui,
|
|
5588
|
+
entries: [{ binding: 0, resource: { buffer: v } }]
|
|
5425
5589
|
});
|
|
5426
|
-
let
|
|
5427
|
-
const
|
|
5428
|
-
|
|
5429
|
-
|
|
5590
|
+
let _t = 0;
|
|
5591
|
+
const fi = r.createShaderModule({ code: `
|
|
5592
|
+
struct Uniforms {
|
|
5593
|
+
transform: mat4x4<f32>,
|
|
5594
|
+
cameraPosition: vec3<f32>,
|
|
5595
|
+
aspectRatio: f32,
|
|
5596
|
+
elapsedTime: f32,
|
|
5597
|
+
}
|
|
5598
|
+
|
|
5599
|
+
struct AppearanceUniforms {
|
|
5600
|
+
fadeEnabled: f32,
|
|
5601
|
+
colorTransitionEnabled: f32,
|
|
5602
|
+
particleSize: f32,
|
|
5603
|
+
textureEnabled: f32,
|
|
5604
|
+
singleColor: vec3<f32>,
|
|
5605
|
+
rotation: f32,
|
|
5606
|
+
startColor: vec3<f32>,
|
|
5607
|
+
rotationMode: f32,
|
|
5608
|
+
endColor: vec3<f32>,
|
|
5609
|
+
minRotation: f32,
|
|
5610
|
+
maxRotation: f32,
|
|
5611
|
+
aspectRatio: f32,
|
|
5612
|
+
randomSize: f32,
|
|
5613
|
+
minSize: f32,
|
|
5614
|
+
maxSize: f32,
|
|
5615
|
+
fadeSizeEnabled: f32,
|
|
5616
|
+
opacity: f32,
|
|
5617
|
+
increaseSizeEnabled: f32,
|
|
5618
|
+
sizeLifetimeSpeed: f32,
|
|
5619
|
+
particleShape: f32,
|
|
5620
|
+
particleShapeRotation: f32,
|
|
5621
|
+
pulseEnabled: f32,
|
|
5622
|
+
pulseAmplitude: f32,
|
|
5623
|
+
pulseFrequency: f32,
|
|
5624
|
+
pulsePhaseRandom: f32,
|
|
5625
|
+
pulseOpacity: f32,
|
|
5626
|
+
glbRotationX: f32,
|
|
5627
|
+
glbRotationY: f32,
|
|
5628
|
+
glbRotationZ: f32,
|
|
5629
|
+
_pad0: f32,
|
|
5630
|
+
systemOffset: vec3<f32>,
|
|
5631
|
+
_pad1: f32,
|
|
5632
|
+
simRotX: f32,
|
|
5633
|
+
simRotZ: f32,
|
|
5634
|
+
velocityStretchEnabled: f32,
|
|
5635
|
+
velocityStretchFactor: f32,
|
|
5636
|
+
noiseDistortEnabled: f32,
|
|
5637
|
+
noiseTilingX: f32,
|
|
5638
|
+
noiseTilingY: f32,
|
|
5639
|
+
noiseSpeed: f32,
|
|
5640
|
+
noiseAmplitude: f32,
|
|
5641
|
+
systemVelX: f32,
|
|
5642
|
+
systemVelY: f32,
|
|
5643
|
+
systemVelZ: f32,
|
|
5644
|
+
orientX: f32,
|
|
5645
|
+
orientY: f32,
|
|
5646
|
+
orientZ: f32,
|
|
5647
|
+
_pad2: f32,
|
|
5648
|
+
}
|
|
5649
|
+
|
|
5650
|
+
@group(0) @binding(0) var<uniform> uniforms : Uniforms;
|
|
5651
|
+
@group(0) @binding(1) var<uniform> appearance : AppearanceUniforms;
|
|
5652
|
+
@group(0) @binding(2) var particleTexture: texture_2d<f32>;
|
|
5653
|
+
@group(0) @binding(3) var particleSampler: sampler;
|
|
5654
|
+
|
|
5655
|
+
struct VIn {
|
|
5656
|
+
@location(0) pos: vec3<f32>,
|
|
5657
|
+
@location(1) col: vec4<f32>,
|
|
5658
|
+
@location(2) uv: vec2<f32>,
|
|
5659
|
+
};
|
|
5660
|
+
|
|
5661
|
+
struct VOut {
|
|
5662
|
+
@builtin(position) pos: vec4<f32>,
|
|
5663
|
+
@location(0) col: vec3<f32>,
|
|
5664
|
+
@location(1) alpha: f32,
|
|
5665
|
+
@location(2) uv: vec2<f32>,
|
|
5666
|
+
@location(3) noiseOffset: vec2<f32>,
|
|
5667
|
+
};
|
|
5668
|
+
|
|
5669
|
+
fn hash21(p: vec2<f32>) -> f32 {
|
|
5670
|
+
return fract(sin(dot(p, vec2<f32>(127.1, 311.7))) * 43758.5453);
|
|
5671
|
+
}
|
|
5672
|
+
|
|
5673
|
+
fn valueNoise(p: vec2<f32>) -> f32 {
|
|
5674
|
+
let i = floor(p);
|
|
5675
|
+
let f = fract(p);
|
|
5676
|
+
let u = f * f * (3.0 - 2.0 * f);
|
|
5677
|
+
let a = hash21(i);
|
|
5678
|
+
let b = hash21(i + vec2<f32>(1.0, 0.0));
|
|
5679
|
+
let c = hash21(i + vec2<f32>(0.0, 1.0));
|
|
5680
|
+
let d = hash21(i + vec2<f32>(1.0, 1.0));
|
|
5681
|
+
return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
|
|
5682
|
+
}
|
|
5683
|
+
|
|
5684
|
+
@vertex
|
|
5685
|
+
fn vs(v: VIn) -> VOut {
|
|
5686
|
+
var o: VOut;
|
|
5687
|
+
o.pos = uniforms.transform * vec4<f32>(v.pos, 1.0);
|
|
5688
|
+
o.col = v.col.rgb;
|
|
5689
|
+
o.alpha = v.col.a;
|
|
5690
|
+
o.uv = v.uv;
|
|
5691
|
+
o.noiseOffset = vec2<f32>(
|
|
5692
|
+
uniforms.elapsedTime * appearance.noiseSpeed,
|
|
5693
|
+
uniforms.elapsedTime * appearance.noiseSpeed * 0.5
|
|
5694
|
+
);
|
|
5695
|
+
return o;
|
|
5696
|
+
}
|
|
5697
|
+
|
|
5698
|
+
@fragment
|
|
5699
|
+
fn fs(i: VOut) -> @location(0) vec4<f32> {
|
|
5700
|
+
let baseUV = vec2<f32>(fract(i.uv.x), clamp(i.uv.y, 0.001, 0.999));
|
|
5701
|
+
var sampleUV = baseUV;
|
|
5702
|
+
if (appearance.textureEnabled > 0.5) {
|
|
5703
|
+
if (appearance.noiseDistortEnabled > 0.5) {
|
|
5704
|
+
let nUV = baseUV * vec2<f32>(
|
|
5705
|
+
max(appearance.noiseTilingX, 0.0001),
|
|
5706
|
+
max(appearance.noiseTilingY, 0.0001)
|
|
5707
|
+
) + i.noiseOffset;
|
|
5708
|
+
let n1 = valueNoise(nUV) - 0.5;
|
|
5709
|
+
let n2 = valueNoise(nUV + vec2<f32>(13.7, 7.3)) - 0.5;
|
|
5710
|
+
sampleUV = vec2<f32>(
|
|
5711
|
+
fract(sampleUV.x + n1 * appearance.noiseAmplitude),
|
|
5712
|
+
clamp(sampleUV.y + n2 * appearance.noiseAmplitude, 0.001, 0.999)
|
|
5713
|
+
);
|
|
5714
|
+
}
|
|
5715
|
+
let texColor = textureSample(particleTexture, particleSampler, sampleUV);
|
|
5716
|
+
return vec4<f32>(i.col * texColor.rgb, i.alpha * texColor.a);
|
|
5717
|
+
}
|
|
5718
|
+
return vec4<f32>(i.col, i.alpha);
|
|
5719
|
+
}
|
|
5720
|
+
` }), pi = (u) => r.createRenderPipeline({
|
|
5721
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [je.particleBindGroupLayout] }),
|
|
5722
|
+
vertex: {
|
|
5723
|
+
module: fi,
|
|
5724
|
+
entryPoint: "vs",
|
|
5725
|
+
buffers: [{ arrayStride: 36, attributes: [
|
|
5726
|
+
{ shaderLocation: 0, offset: 0, format: "float32x3" },
|
|
5727
|
+
{ shaderLocation: 1, offset: 12, format: "float32x4" },
|
|
5728
|
+
{ shaderLocation: 2, offset: 28, format: "float32x2" }
|
|
5729
|
+
] }]
|
|
5730
|
+
},
|
|
5731
|
+
fragment: {
|
|
5732
|
+
module: fi,
|
|
5733
|
+
entryPoint: "fs",
|
|
5734
|
+
targets: [{ format: "rgba16float", blend: u }]
|
|
5735
|
+
},
|
|
5736
|
+
primitive: { topology: "triangle-list" },
|
|
5737
|
+
depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
|
|
5738
|
+
}), ms = pi({
|
|
5739
|
+
color: { srcFactor: "src-alpha", dstFactor: "one-minus-src-alpha", operation: "add" },
|
|
5740
|
+
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
5741
|
+
}), ys = pi({
|
|
5742
|
+
color: { srcFactor: "src-alpha", dstFactor: "one", operation: "add" },
|
|
5743
|
+
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
5744
|
+
}), hi = 256 * 256 * 6, Ue = new Float32Array(hi * 9), Yt = r.createBuffer({
|
|
5745
|
+
size: hi * 9 * 4,
|
|
5746
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
5747
|
+
label: "shapeStrokeBuffer"
|
|
5748
|
+
});
|
|
5749
|
+
let mi = 0, { sceneTexture: nt, bloomTexA: at, bloomTexB: ot } = Oi(r, c, a.width, a.height), It = Li(r, a.width, a.height), pt, yi, zt, Mt;
|
|
5750
|
+
const gi = () => {
|
|
5751
|
+
const u = (f) => f.createView();
|
|
5752
|
+
pt = u(nt), yi = u(at), zt = u(ot), Mt = u(It);
|
|
5430
5753
|
};
|
|
5431
|
-
|
|
5432
|
-
const
|
|
5433
|
-
let
|
|
5434
|
-
const
|
|
5754
|
+
gi();
|
|
5755
|
+
const jt = { uniformBuffer: v, appearanceUniformBuffer: A, horizontalBlurUniformBuffer: U, verticalBlurUniformBuffer: I, bloomIntensityBuffer: _ };
|
|
5756
|
+
let Ft = ei(r, Le, jt, { sceneTexture: nt, bloomTexA: at, bloomTexB: ot });
|
|
5757
|
+
const G = {
|
|
5435
5758
|
mvp: new Float32Array(16),
|
|
5436
5759
|
position: new Float32Array([0, 0, 10]),
|
|
5437
5760
|
right: new Float32Array([1, 0, 0]),
|
|
@@ -5439,187 +5762,189 @@ async function vr(s, t = {}) {
|
|
|
5439
5762
|
up: new Float32Array([0, 1, 0]),
|
|
5440
5763
|
hasCamera: !1
|
|
5441
5764
|
};
|
|
5442
|
-
let
|
|
5443
|
-
const
|
|
5444
|
-
let
|
|
5445
|
-
function
|
|
5446
|
-
const
|
|
5447
|
-
|
|
5448
|
-
let
|
|
5449
|
-
const
|
|
5450
|
-
if (!
|
|
5451
|
-
|
|
5765
|
+
let ke = 0, gs = 0;
|
|
5766
|
+
const ht = new Float32Array(5), bi = new Float32Array(16), bs = new Array(65), Ss = new Array(65), xs = new Array(65), vs = new Array(65), Ps = new Array(65), _s = new Array(65), Si = [0, 0, 0], mt = { key: null, ms: !1, bindGroup: null };
|
|
5767
|
+
let xi = !1, qt = !0, Gt = !1, Dt = null, Ht = a.width, Zt = a.height;
|
|
5768
|
+
function vi() {
|
|
5769
|
+
const u = [nt, at, ot, It], f = Oi(r, c, a.width, a.height);
|
|
5770
|
+
nt = f.sceneTexture, at = f.bloomTexA, ot = f.bloomTexB, It = Li(r, a.width, a.height), gi(), ai(), p.clear(), g.resizeTextures(), Ft = ei(r, Le, jt, { sceneTexture: nt, bloomTexA: at, bloomTexB: ot });
|
|
5771
|
+
let h = !1;
|
|
5772
|
+
const b = () => {
|
|
5773
|
+
if (!h) {
|
|
5774
|
+
h = !0, requestAnimationFrame(b);
|
|
5452
5775
|
return;
|
|
5453
5776
|
}
|
|
5454
|
-
|
|
5777
|
+
u.forEach((y) => y.destroy());
|
|
5455
5778
|
};
|
|
5456
|
-
requestAnimationFrame(
|
|
5779
|
+
requestAnimationFrame(b);
|
|
5457
5780
|
}
|
|
5458
|
-
function
|
|
5459
|
-
|
|
5781
|
+
function Ms(u, f, h) {
|
|
5782
|
+
G.mvp.set(Ur(u, f)), f && f.length >= 10 && (G.right[0] = f[0], G.right[1] = f[4], G.right[2] = f[8], G.up[0] = f[1], G.up[1] = f[5], G.up[2] = f[9]), h && (G.position[0] = h.x ?? h[0], G.position[1] = h.y ?? h[1], G.position[2] = h.z ?? h[2]), G.hasCamera = !0;
|
|
5460
5783
|
}
|
|
5461
|
-
function
|
|
5462
|
-
|
|
5784
|
+
function ws(u, f) {
|
|
5785
|
+
G.mvp.set(u), f && (G.position[0] = f.x ?? f[0], G.position[1] = f.y ?? f[1], G.position[2] = f.z ?? f[2]), G.hasCamera = !0;
|
|
5463
5786
|
}
|
|
5464
|
-
async function
|
|
5465
|
-
if (
|
|
5466
|
-
|
|
5787
|
+
async function $t(u) {
|
|
5788
|
+
if (Gt) {
|
|
5789
|
+
Dt = u;
|
|
5467
5790
|
return;
|
|
5468
5791
|
}
|
|
5469
|
-
|
|
5792
|
+
Gt = !0;
|
|
5470
5793
|
try {
|
|
5471
|
-
for (const
|
|
5472
|
-
|
|
5473
|
-
for (const
|
|
5474
|
-
await l.addSystems(
|
|
5475
|
-
for (const { config:
|
|
5476
|
-
|
|
5477
|
-
|
|
5794
|
+
for (const f in T) delete T[f];
|
|
5795
|
+
p.clear(), g.resizeTextures(), Ft = ei(r, Le, jt, { sceneTexture: nt, bloomTexA: at, bloomTexB: ot }), await l.replaceSystems({ systems: [], activeSystemIndex: 0 });
|
|
5796
|
+
for (const f of u)
|
|
5797
|
+
await l.addSystems(f.preset, f.position || [0, 0, 0]);
|
|
5798
|
+
for (const { config: f } of l.particleSystems)
|
|
5799
|
+
T[f.id] || (T[f.id] = z());
|
|
5800
|
+
qt = !0, l.respawnAllSystems();
|
|
5478
5801
|
} finally {
|
|
5479
|
-
if (
|
|
5480
|
-
const
|
|
5481
|
-
|
|
5802
|
+
if (Gt = !1, Dt) {
|
|
5803
|
+
const f = Dt;
|
|
5804
|
+
Dt = null, $t(f);
|
|
5482
5805
|
}
|
|
5483
5806
|
}
|
|
5484
5807
|
}
|
|
5485
|
-
async function
|
|
5486
|
-
return
|
|
5487
|
-
}
|
|
5488
|
-
function
|
|
5489
|
-
if (
|
|
5490
|
-
const
|
|
5491
|
-
if (
|
|
5492
|
-
if ((a.width !==
|
|
5493
|
-
for (const
|
|
5494
|
-
if (
|
|
5495
|
-
const B =
|
|
5496
|
-
B ? (
|
|
5808
|
+
async function Bs(u, f = [0, 0, 0]) {
|
|
5809
|
+
return $t([{ preset: u, position: f }]);
|
|
5810
|
+
}
|
|
5811
|
+
function Rs(u) {
|
|
5812
|
+
if (xi || Gt || !l.ready || u <= 0 || l.particleSystems.length === 0) return;
|
|
5813
|
+
const f = l.clock;
|
|
5814
|
+
if (f && (f.loop = l.loop ?? i, f.duration = l.getTotalDuration(), u = f.tick(u)), u > 0.1 && (u = 0.1), u <= 0) return;
|
|
5815
|
+
if ((a.width !== Ht || a.height !== Zt) && (Ht = a.width, Zt = a.height, vi()), ke += u, Se.length) {
|
|
5816
|
+
for (const m of Se) {
|
|
5817
|
+
if (m.getPosition) {
|
|
5818
|
+
const B = m.getPosition();
|
|
5819
|
+
B ? (m.pos || (m.pos = m._posBuf), Array.isArray(B) ? (m.pos[0] = B[0], m.pos[1] = B[1], m.pos[2] = B[2]) : (m.pos[0] = B.x, m.pos[1] = B.y, m.pos[2] = B.z)) : m.pos = null;
|
|
5497
5820
|
}
|
|
5498
|
-
|
|
5821
|
+
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);
|
|
5499
5822
|
}
|
|
5500
|
-
for (const { system:
|
|
5501
|
-
const
|
|
5502
|
-
if (!(!
|
|
5503
|
-
let
|
|
5504
|
-
if (
|
|
5505
|
-
const
|
|
5506
|
-
Math.hypot(
|
|
5823
|
+
for (const { system: m, config: B } of l.particleSystems) {
|
|
5824
|
+
const C = ri(B.id);
|
|
5825
|
+
if (!(!C || C.historyOnly) && (B.hidden = !C.pos, C.pos)) {
|
|
5826
|
+
let H = null;
|
|
5827
|
+
if (C.orientToDirection && C.vel) {
|
|
5828
|
+
const V = C.vel[0], L = C.vel[2];
|
|
5829
|
+
Math.hypot(V, L) > 1e-4 && (H = [0, 0, Math.atan2(V, L)]);
|
|
5507
5830
|
}
|
|
5508
|
-
|
|
5831
|
+
m.setSimulationTransform({ position: C.pos, velocity: C.vel, rotation: H }), m.updateAppearanceUniform(), (C.justResumed || m.activeParticles === 0) && m.spawnParticles();
|
|
5509
5832
|
}
|
|
5510
5833
|
}
|
|
5511
|
-
for (const
|
|
5512
|
-
|
|
5513
|
-
if (globalThis.__HZFX_DEBUG && (
|
|
5514
|
-
const
|
|
5515
|
-
console.info(`[HZFX] movingGroups(${
|
|
5834
|
+
for (const m of Se)
|
|
5835
|
+
m.pos ? Qi(m, ke) : 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;
|
|
5836
|
+
if (globalThis.__HZFX_DEBUG && (gs++ & 63) === 0) {
|
|
5837
|
+
const m = l.particleSystems.reduce((V, L) => V + (L.system.activeParticles | 0), 0), B = Se.find((V) => V.pos), C = B ? Math.hypot(G.position[0] - B.pos[0], G.position[1] - B.pos[1], G.position[2] - B.pos[2]).toFixed(1) : "-", H = Se.map((V) => `{ids:[${[...V.ids]}],pos:${V.pos ? "1" : "0"},hist:${V.hist.length}}`).join(",");
|
|
5838
|
+
console.info(`[HZFX] movingGroups(${Se.length})=[${H}] activeParticles=${m} systems=${l.particleSystems.length} ribbonVerts=${_t} camDist=${C} t=${ke.toFixed(1)}`);
|
|
5516
5839
|
}
|
|
5517
5840
|
}
|
|
5518
|
-
if (l.updateAllSystems(
|
|
5519
|
-
const
|
|
5520
|
-
(
|
|
5841
|
+
if (l.updateAllSystems(u), f ? f.loop : l.loop ?? i) {
|
|
5842
|
+
const m = l.particleSystems.length > 0 && l.particleSystems.every(({ system: B }) => B.activeParticles === 0 && !B.emitting);
|
|
5843
|
+
(f && f.justLooped || m && qt) && l.respawnAllSystems(), qt = !m;
|
|
5521
5844
|
}
|
|
5522
|
-
for (const { system:
|
|
5523
|
-
B.glbModelEnabled &&
|
|
5524
|
-
r.queue.writeBuffer(
|
|
5525
|
-
const
|
|
5526
|
-
|
|
5845
|
+
for (const { system: m, config: B } of l.particleSystems)
|
|
5846
|
+
B.glbModelEnabled && m.glbAnimator && (m.glbAnimator.update(u), m.updateAnimatedGLBBuffer());
|
|
5847
|
+
r.queue.writeBuffer(v, 0, G.mvp), ht[0] = G.position[0], ht[1] = G.position[1], ht[2] = G.position[2], ht[3] = a.height / Math.max(1, a.width), ht[4] = ke, r.queue.writeBuffer(v, 64, ht), as();
|
|
5848
|
+
const b = l.particleSystems.some(
|
|
5849
|
+
({ system: m, config: B }) => B.bloomEnabled && !B.hidden && (m.activeParticles > 0 || Ye.has(B.id))
|
|
5850
|
+
), y = r.createCommandEncoder();
|
|
5851
|
+
let R = !1;
|
|
5527
5852
|
if (e)
|
|
5528
5853
|
try {
|
|
5529
|
-
const
|
|
5530
|
-
if (
|
|
5531
|
-
let B = null,
|
|
5532
|
-
if (
|
|
5533
|
-
const { pipeline:
|
|
5534
|
-
(
|
|
5535
|
-
layout:
|
|
5536
|
-
entries: [{ binding: 0, resource:
|
|
5854
|
+
const m = e();
|
|
5855
|
+
if (m) {
|
|
5856
|
+
let B = null, C = null, H = !1;
|
|
5857
|
+
if (m instanceof GPUTexture ? m.width === a.width && m.height === a.height && (B = m, C = () => m.createView({ aspect: "depth-only" }), H = m.sampleCount > 1) : m.view && (B = m.view, C = () => m.view, H = !!m.multisampled), B) {
|
|
5858
|
+
const { pipeline: V, layout: L } = S(H);
|
|
5859
|
+
(mt.key !== B || mt.ms !== H) && (mt.key = B, mt.ms = H, mt.bindGroup = r.createBindGroup({
|
|
5860
|
+
layout: L,
|
|
5861
|
+
entries: [{ binding: 0, resource: C() }]
|
|
5537
5862
|
}));
|
|
5538
|
-
const
|
|
5863
|
+
const N = y.beginRenderPass({
|
|
5539
5864
|
colorAttachments: [],
|
|
5540
|
-
depthStencilAttachment: { view:
|
|
5865
|
+
depthStencilAttachment: { view: Mt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5541
5866
|
});
|
|
5542
|
-
|
|
5867
|
+
N.setPipeline(V), N.setBindGroup(0, mt.bindGroup), N.draw(3), N.end(), R = !0;
|
|
5543
5868
|
}
|
|
5544
5869
|
}
|
|
5545
5870
|
} catch {
|
|
5546
5871
|
}
|
|
5547
|
-
const
|
|
5548
|
-
colorAttachments: [{ view:
|
|
5549
|
-
depthStencilAttachment:
|
|
5872
|
+
const P = y.beginRenderPass({
|
|
5873
|
+
colorAttachments: [{ view: pt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5874
|
+
depthStencilAttachment: R ? { view: Mt, depthLoadOp: "load", depthStoreOp: "store" } : { view: Mt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5550
5875
|
});
|
|
5551
|
-
for (const { system:
|
|
5552
|
-
B.bloomEnabled || B.hidden ||
|
|
5553
|
-
if (
|
|
5554
|
-
const
|
|
5555
|
-
colorAttachments: [{ view:
|
|
5876
|
+
for (const { system: m, config: B } of l.particleSystems)
|
|
5877
|
+
B.bloomEnabled || B.hidden || m.activeParticles === 0 && !Ye.has(B.id) || (_i(P, m, B), Mi(P, m, B));
|
|
5878
|
+
if (_t > 0 && (P.setPipeline(ps), P.setBindGroup(0, hs), P.setVertexBuffer(0, Nt), P.draw(_t)), P.end(), b) {
|
|
5879
|
+
const m = {
|
|
5880
|
+
colorAttachments: [{ view: yi, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5556
5881
|
}, B = {
|
|
5557
|
-
colorAttachments: [{ view:
|
|
5882
|
+
colorAttachments: [{ view: zt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5558
5883
|
};
|
|
5559
|
-
for (const { system:
|
|
5560
|
-
if (!
|
|
5561
|
-
const
|
|
5562
|
-
colorAttachments: [{ view:
|
|
5563
|
-
depthStencilAttachment: { view:
|
|
5884
|
+
for (const { system: C, config: H } of l.particleSystems) {
|
|
5885
|
+
if (!H.bloomEnabled || H.hidden || C.activeParticles === 0 && !Ye.has(H.id)) continue;
|
|
5886
|
+
const V = C.config.id, L = g.getBloomSourceTexture(V, a.width, a.height), N = y.beginRenderPass({
|
|
5887
|
+
colorAttachments: [{ view: L.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5888
|
+
depthStencilAttachment: { view: Mt, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
|
|
5564
5889
|
});
|
|
5565
|
-
|
|
5566
|
-
layout:
|
|
5890
|
+
_i(N, C, H), Mi(N, C, H), N.end(), bi[0] = H.bloomIntensity, r.queue.writeBuffer(_, 0, bi), p.systemBloomHorizontalBindGroups[V] || (p.systemBloomHorizontalBindGroups[V] = r.createBindGroup({
|
|
5891
|
+
layout: je.bloomBindGroupLayout,
|
|
5567
5892
|
entries: [
|
|
5568
|
-
{ binding: 0, resource:
|
|
5569
|
-
{ binding: 1, resource:
|
|
5570
|
-
{ binding: 2, resource: { buffer:
|
|
5893
|
+
{ binding: 0, resource: Le },
|
|
5894
|
+
{ binding: 1, resource: L.createView() },
|
|
5895
|
+
{ binding: 2, resource: { buffer: U } }
|
|
5571
5896
|
]
|
|
5572
5897
|
}));
|
|
5573
|
-
let
|
|
5574
|
-
|
|
5575
|
-
layout:
|
|
5898
|
+
let D = y.beginRenderPass(m);
|
|
5899
|
+
D.setPipeline(Ut), D.setBindGroup(0, p.systemBloomHorizontalBindGroups[V]), D.draw(3), D.end(), D = y.beginRenderPass(B), D.setPipeline(Ut), D.setBindGroup(0, Ft.verticalBlurBindGroup), D.draw(3), D.end(), p.secondHorizontalBindGroups[V] || (p.secondHorizontalBindGroups[V] = r.createBindGroup({
|
|
5900
|
+
layout: je.bloomBindGroupLayout,
|
|
5576
5901
|
entries: [
|
|
5577
|
-
{ binding: 0, resource:
|
|
5578
|
-
{ binding: 1, resource:
|
|
5579
|
-
{ binding: 2, resource: { buffer:
|
|
5902
|
+
{ binding: 0, resource: Le },
|
|
5903
|
+
{ binding: 1, resource: zt },
|
|
5904
|
+
{ binding: 2, resource: { buffer: U } }
|
|
5580
5905
|
]
|
|
5581
|
-
})),
|
|
5582
|
-
const
|
|
5583
|
-
|
|
5584
|
-
colorAttachments: [{ view:
|
|
5585
|
-
}),
|
|
5586
|
-
layout:
|
|
5906
|
+
})), D = y.beginRenderPass(m), D.setPipeline(Ut), D.setBindGroup(0, p.secondHorizontalBindGroups[V]), D.draw(3), D.end(), D = y.beginRenderPass(B), D.setPipeline(Ut), D.setBindGroup(0, Ft.verticalBlurBindGroup), D.draw(3), D.end();
|
|
5907
|
+
const pe = g.getBloomCompositeTexture(V, a.width, a.height);
|
|
5908
|
+
D = y.beginRenderPass({
|
|
5909
|
+
colorAttachments: [{ view: pe.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5910
|
+
}), D.setPipeline(us), p.systemBloomCompositeBindGroups[V] || (p.systemBloomCompositeBindGroups[V] = r.createBindGroup({
|
|
5911
|
+
layout: je.compositeBindGroupLayout,
|
|
5587
5912
|
entries: [
|
|
5588
|
-
{ binding: 0, resource:
|
|
5589
|
-
{ binding: 1, resource:
|
|
5590
|
-
{ binding: 2, resource:
|
|
5591
|
-
{ binding: 3, resource: { buffer:
|
|
5913
|
+
{ binding: 0, resource: Le },
|
|
5914
|
+
{ binding: 1, resource: L.createView() },
|
|
5915
|
+
{ binding: 2, resource: zt },
|
|
5916
|
+
{ binding: 3, resource: { buffer: C.bloomIntensityBuffer } }
|
|
5592
5917
|
]
|
|
5593
|
-
})),
|
|
5918
|
+
})), D.setBindGroup(0, p.systemBloomCompositeBindGroups[V]), D.draw(3), D.end();
|
|
5594
5919
|
}
|
|
5595
5920
|
}
|
|
5596
|
-
const
|
|
5597
|
-
colorAttachments: [{ view:
|
|
5921
|
+
const M = g.getCombinedTexture(a.width, a.height), x = y.beginRenderPass({
|
|
5922
|
+
colorAttachments: [{ view: M.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5598
5923
|
});
|
|
5599
|
-
|
|
5600
|
-
layout:
|
|
5924
|
+
x.setPipeline(li), p.combinedInitialBindGroup || (p.combinedInitialBindGroup = r.createBindGroup({
|
|
5925
|
+
layout: je.compositeBindGroupLayout,
|
|
5601
5926
|
entries: [
|
|
5602
|
-
{ binding: 0, resource:
|
|
5603
|
-
{ binding: 1, resource:
|
|
5604
|
-
{ binding: 2, resource:
|
|
5605
|
-
{ binding: 3, resource: { buffer:
|
|
5927
|
+
{ binding: 0, resource: Le },
|
|
5928
|
+
{ binding: 1, resource: pt },
|
|
5929
|
+
{ binding: 2, resource: pt },
|
|
5930
|
+
{ binding: 3, resource: { buffer: _ } }
|
|
5606
5931
|
]
|
|
5607
|
-
})),
|
|
5608
|
-
for (const { config:
|
|
5609
|
-
if (!
|
|
5610
|
-
const
|
|
5611
|
-
|
|
5612
|
-
layout:
|
|
5932
|
+
})), x.setBindGroup(0, p.combinedInitialBindGroup), x.draw(3);
|
|
5933
|
+
for (const { config: m, system: B } of l.particleSystems) {
|
|
5934
|
+
if (!m.bloomEnabled || m.hidden || B.activeParticles === 0 && !Ye.has(m.id)) continue;
|
|
5935
|
+
const C = B.config.id;
|
|
5936
|
+
x.setPipeline(li), p.combinedBloomCompositeBindGroups[C] || (p.combinedBloomCompositeBindGroups[C] = r.createBindGroup({
|
|
5937
|
+
layout: je.compositeBindGroupLayout,
|
|
5613
5938
|
entries: [
|
|
5614
|
-
{ binding: 0, resource:
|
|
5615
|
-
{ binding: 1, resource:
|
|
5616
|
-
{ binding: 2, resource:
|
|
5617
|
-
{ binding: 3, resource: { buffer:
|
|
5939
|
+
{ binding: 0, resource: Le },
|
|
5940
|
+
{ binding: 1, resource: g.getBloomCompositeTexture(C, a.width, a.height).createView() },
|
|
5941
|
+
{ binding: 2, resource: pt },
|
|
5942
|
+
{ binding: 3, resource: { buffer: _ } }
|
|
5618
5943
|
]
|
|
5619
|
-
})),
|
|
5944
|
+
})), x.setBindGroup(0, p.combinedBloomCompositeBindGroups[C]), x.draw(3);
|
|
5620
5945
|
}
|
|
5621
|
-
|
|
5622
|
-
const
|
|
5946
|
+
x.end();
|
|
5947
|
+
const w = y.beginRenderPass({
|
|
5623
5948
|
colorAttachments: [{
|
|
5624
5949
|
view: n.getCurrentTexture().createView(),
|
|
5625
5950
|
loadOp: o ? "load" : "clear",
|
|
@@ -5627,104 +5952,112 @@ async function vr(s, t = {}) {
|
|
|
5627
5952
|
clearValue: { r: 0, g: 0, b: 0, a: 0 }
|
|
5628
5953
|
}]
|
|
5629
5954
|
});
|
|
5630
|
-
|
|
5631
|
-
layout:
|
|
5955
|
+
w.setPipeline(ds), p.finalBindGroup || (p.finalBindGroup = r.createBindGroup({
|
|
5956
|
+
layout: je.compositeBindGroupLayout,
|
|
5632
5957
|
entries: [
|
|
5633
|
-
{ binding: 0, resource:
|
|
5634
|
-
{ binding: 1, resource:
|
|
5635
|
-
{ binding: 2, resource:
|
|
5636
|
-
{ binding: 3, resource: { buffer:
|
|
5958
|
+
{ binding: 0, resource: Le },
|
|
5959
|
+
{ binding: 1, resource: M.createView() },
|
|
5960
|
+
{ binding: 2, resource: pt },
|
|
5961
|
+
{ binding: 3, resource: { buffer: _ } }
|
|
5637
5962
|
]
|
|
5638
|
-
})),
|
|
5963
|
+
})), w.setBindGroup(0, p.finalBindGroup), w.draw(3), w.end(), r.queue.submit([y.finish()]);
|
|
5639
5964
|
}
|
|
5640
|
-
function
|
|
5641
|
-
const
|
|
5642
|
-
|
|
5643
|
-
layout:
|
|
5965
|
+
function Pi(u, f) {
|
|
5966
|
+
const h = u.config.id, b = !p.systemBindGroups[h] || p.textureStates[h] !== f.textureEnabled || p.textureRefs[h] !== u.particleTexture;
|
|
5967
|
+
return p.textureStates[h] = f.textureEnabled, p.textureRefs[h] = u.particleTexture, b && (p.systemBindGroups[h] = r.createBindGroup({
|
|
5968
|
+
layout: je.particleBindGroupLayout,
|
|
5644
5969
|
entries: [
|
|
5645
|
-
{ binding: 0, resource: { buffer:
|
|
5646
|
-
{ binding: 1, resource: { buffer:
|
|
5647
|
-
{ binding: 2, resource:
|
|
5648
|
-
{ binding: 3, resource:
|
|
5970
|
+
{ binding: 0, resource: { buffer: v } },
|
|
5971
|
+
{ binding: 1, resource: { buffer: u.appearanceUniformBuffer } },
|
|
5972
|
+
{ binding: 2, resource: u.particleTexture.createView() },
|
|
5973
|
+
{ binding: 3, resource: Le }
|
|
5649
5974
|
]
|
|
5650
|
-
}));
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5975
|
+
})), p.systemBindGroups[h];
|
|
5976
|
+
}
|
|
5977
|
+
function _i(u, f, h) {
|
|
5978
|
+
const b = f.config.id, y = h.glbModelEnabled && f.glbMeshData, R = Pi(f, h), P = h.shapeDisplay !== !1;
|
|
5979
|
+
if (y)
|
|
5980
|
+
P && (u.setPipeline(fs), u.setBindGroup(0, R), 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));
|
|
5654
5981
|
else {
|
|
5655
|
-
|
|
5656
|
-
const
|
|
5657
|
-
|
|
5982
|
+
u.setPipeline(h.blendMode === "additive" ? ls : os), u.setIndexBuffer($, "uint16"), T[b] || (T[b] = z()), u.setVertexBuffer(0, T[b]), u.setBindGroup(0, R), P && (u.setVertexBuffer(1, f.instanceBuffer), u.setVertexBuffer(2, f.velocityBuffer), u.setVertexBuffer(3, f.trailBuffer), u.drawIndexed(6, f.activeParticles));
|
|
5983
|
+
const M = Pt.get(b);
|
|
5984
|
+
M && (u.setVertexBuffer(1, K), u.setVertexBuffer(2, q), u.setVertexBuffer(3, Ke), u.drawIndexed(6, M.count, 0, 0, M.first)), P && h.depthWriteEnabled && (u.setPipeline(cs), u.drawIndexed(6, f.activeParticles));
|
|
5658
5985
|
}
|
|
5659
5986
|
}
|
|
5660
|
-
function
|
|
5661
|
-
|
|
5987
|
+
function Mi(u, f, h) {
|
|
5988
|
+
const b = Ye.get(h.id);
|
|
5989
|
+
!b || b.count <= 0 || (u.setPipeline(h.blendMode === "additive" ? ys : ms), u.setBindGroup(0, Pi(f, h)), u.setVertexBuffer(0, Yt), u.draw(b.count, 1, b.first, 0));
|
|
5990
|
+
}
|
|
5991
|
+
function Ts() {
|
|
5992
|
+
Ht = a.width, Zt = a.height, vi();
|
|
5662
5993
|
}
|
|
5663
|
-
function
|
|
5664
|
-
|
|
5994
|
+
function Es() {
|
|
5995
|
+
p.clear();
|
|
5665
5996
|
}
|
|
5666
|
-
function
|
|
5667
|
-
|
|
5668
|
-
|
|
5997
|
+
function As() {
|
|
5998
|
+
xi = !0, l.destroy(), [nt, at, ot, It].forEach((u) => u == null ? void 0 : u.destroy()), g.resizeTextures(), [
|
|
5999
|
+
v,
|
|
6000
|
+
A,
|
|
6001
|
+
U,
|
|
6002
|
+
I,
|
|
5669
6003
|
_,
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
const
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
S >= 0 && l.removeSystem(S);
|
|
6004
|
+
$,
|
|
6005
|
+
K,
|
|
6006
|
+
q,
|
|
6007
|
+
Ke,
|
|
6008
|
+
Nt,
|
|
6009
|
+
Yt
|
|
6010
|
+
].forEach((u) => u == null ? void 0 : u.destroy()), Object.values(T).forEach((u) => u == null ? void 0 : u.destroy());
|
|
6011
|
+
}
|
|
6012
|
+
async function wi(u, f) {
|
|
6013
|
+
const h = await l.addSystems(u, f);
|
|
6014
|
+
for (const { config: b } of l.particleSystems)
|
|
6015
|
+
T[b.id] || (T[b.id] = z());
|
|
6016
|
+
return l.respawnAllSystems(), new Set(Array.isArray(h) ? h : []);
|
|
6017
|
+
}
|
|
6018
|
+
function Bi(u) {
|
|
6019
|
+
for (const f of u) {
|
|
6020
|
+
const h = l.particleSystems.findIndex((b) => b.config.id === f);
|
|
6021
|
+
h >= 0 && l.removeSystem(h);
|
|
5689
6022
|
}
|
|
5690
6023
|
}
|
|
5691
|
-
async function
|
|
5692
|
-
const
|
|
6024
|
+
async function Cs(u, f = [0, 0, 0]) {
|
|
6025
|
+
const h = await wi(u, f);
|
|
5693
6026
|
return { remove() {
|
|
5694
|
-
|
|
6027
|
+
Bi(h);
|
|
5695
6028
|
} };
|
|
5696
6029
|
}
|
|
5697
|
-
async function
|
|
5698
|
-
const
|
|
5699
|
-
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(
|
|
5700
|
-
const
|
|
5701
|
-
return
|
|
5702
|
-
setPosition(
|
|
5703
|
-
|
|
6030
|
+
async function Us(u, f = {}) {
|
|
6031
|
+
const h = await wi(u, [0, 0, 0]);
|
|
6032
|
+
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...h]}]`);
|
|
6033
|
+
const b = { ids: h, pos: null, hist: [], getPosition: f.getPosition || null, orientToDirection: !!f.orientToDirection, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
|
|
6034
|
+
return Se.push(b), {
|
|
6035
|
+
setPosition(y) {
|
|
6036
|
+
y && (b.pos = Array.isArray(y) ? [y[0], y[1], y[2]] : [y.x, y.y, y.z]);
|
|
5704
6037
|
},
|
|
5705
|
-
setOrientToDirection(
|
|
5706
|
-
|
|
6038
|
+
setOrientToDirection(y) {
|
|
6039
|
+
b.orientToDirection = !!y;
|
|
5707
6040
|
},
|
|
5708
6041
|
remove() {
|
|
5709
|
-
|
|
5710
|
-
const
|
|
5711
|
-
|
|
6042
|
+
Bi(h);
|
|
6043
|
+
const y = Se.indexOf(b);
|
|
6044
|
+
y >= 0 && Se.splice(y, 1);
|
|
5712
6045
|
}
|
|
5713
6046
|
};
|
|
5714
6047
|
}
|
|
5715
|
-
function
|
|
5716
|
-
const
|
|
5717
|
-
return
|
|
6048
|
+
function Is(u, f) {
|
|
6049
|
+
const b = { 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] };
|
|
6050
|
+
return Se.push(b), {
|
|
5718
6051
|
remove() {
|
|
5719
|
-
const
|
|
5720
|
-
|
|
6052
|
+
const y = Se.indexOf(b);
|
|
6053
|
+
y >= 0 && Se.splice(y, 1);
|
|
5721
6054
|
},
|
|
5722
6055
|
// Update which systems this history group covers WITHOUT losing the accumulated path
|
|
5723
6056
|
// history. Needed when the scene's systems change (e.g. duplicate/add/remove) while the
|
|
5724
6057
|
// group is active — otherwise a newly-added system's id isn't in the set and its trail
|
|
5725
6058
|
// can't follow the recorded movement path (it falls back to straight extrapolation).
|
|
5726
|
-
setIds(
|
|
5727
|
-
|
|
6059
|
+
setIds(y) {
|
|
6060
|
+
b.ids = y instanceof Set ? y : new Set(y);
|
|
5728
6061
|
}
|
|
5729
6062
|
};
|
|
5730
6063
|
}
|
|
@@ -5732,85 +6065,85 @@ async function vr(s, t = {}) {
|
|
|
5732
6065
|
manager: l,
|
|
5733
6066
|
device: r,
|
|
5734
6067
|
context: n,
|
|
5735
|
-
setCamera:
|
|
5736
|
-
setCameraMVP:
|
|
5737
|
-
setEmitters:
|
|
5738
|
-
loadPreset:
|
|
5739
|
-
addEmitter:
|
|
5740
|
-
addMovingEmitter:
|
|
5741
|
-
render:
|
|
5742
|
-
resize:
|
|
5743
|
-
clearCaches:
|
|
5744
|
-
trackHistoryGroup:
|
|
5745
|
-
destroy:
|
|
6068
|
+
setCamera: Ms,
|
|
6069
|
+
setCameraMVP: ws,
|
|
6070
|
+
setEmitters: $t,
|
|
6071
|
+
loadPreset: Bs,
|
|
6072
|
+
addEmitter: Cs,
|
|
6073
|
+
addMovingEmitter: Us,
|
|
6074
|
+
render: Rs,
|
|
6075
|
+
resize: Ts,
|
|
6076
|
+
clearCaches: Es,
|
|
6077
|
+
trackHistoryGroup: Is,
|
|
6078
|
+
destroy: As
|
|
5746
6079
|
};
|
|
5747
6080
|
}
|
|
5748
|
-
function
|
|
6081
|
+
function Hr(s) {
|
|
5749
6082
|
return () => {
|
|
5750
6083
|
var t, e, i, r, n, a, o, c;
|
|
5751
6084
|
try {
|
|
5752
6085
|
const l = s.backend;
|
|
5753
6086
|
if (!l) return null;
|
|
5754
|
-
const
|
|
5755
|
-
if (s.needsFrameBufferTarget &&
|
|
5756
|
-
const
|
|
5757
|
-
(r =
|
|
5758
|
-
|
|
5759
|
-
(n =
|
|
5760
|
-
|
|
6087
|
+
const d = s.domElement.width, S = s.domElement.height, g = (typeof s._getFrameBufferTarget == "function" ? s._getFrameBufferTarget() : null) || s._frameBufferTarget || null;
|
|
6088
|
+
if (s.needsFrameBufferTarget && g) {
|
|
6089
|
+
const A = l.get(g), U = ((i = (e = (t = s._textures) == null ? void 0 : t.get) == null ? void 0 : e.call(t, g)) == null ? void 0 : i.depthTexture) || g.depthTexture, I = [
|
|
6090
|
+
(r = A == null ? void 0 : A.depthTexture) == null ? void 0 : r.texture,
|
|
6091
|
+
A == null ? void 0 : A.depthTexture,
|
|
6092
|
+
(n = A == null ? void 0 : A.depthBuffer) == null ? void 0 : n.texture,
|
|
6093
|
+
U ? (a = l.get(U)) == null ? void 0 : a.texture : null
|
|
5761
6094
|
];
|
|
5762
|
-
for (const
|
|
5763
|
-
if (
|
|
6095
|
+
for (const _ of I)
|
|
6096
|
+
if (_ && typeof _.createView == "function" && _.width === d && _.height === S) return _;
|
|
5764
6097
|
return null;
|
|
5765
6098
|
}
|
|
5766
|
-
const
|
|
5767
|
-
return
|
|
6099
|
+
const p = s.getCanvasTarget ? l.get(s.getCanvasTarget()) : null, v = ((c = (o = p == null ? void 0 : p.descriptor) == null ? void 0 : o.depthStencilAttachment) == null ? void 0 : c.view) ?? null;
|
|
6100
|
+
return v ? { view: v, multisampled: (s.currentSamples ?? 0) > 1 } : null;
|
|
5768
6101
|
} catch {
|
|
5769
6102
|
return null;
|
|
5770
6103
|
}
|
|
5771
6104
|
};
|
|
5772
6105
|
}
|
|
5773
6106
|
export {
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
6107
|
+
mr as GLBAnimator,
|
|
6108
|
+
yr as HZClock,
|
|
6109
|
+
Vr as Objects3DManager,
|
|
6110
|
+
ks as ParticleEmitter,
|
|
6111
|
+
$s as ParticlePhysics,
|
|
6112
|
+
Ii as ParticleScript,
|
|
6113
|
+
Qt as ParticleSystem,
|
|
6114
|
+
Pr as ParticleSystemManager,
|
|
6115
|
+
Ws as ParticleTextureManager,
|
|
6116
|
+
Ns as blurShader,
|
|
6117
|
+
Ys as compositeShader,
|
|
6118
|
+
Br as createBindGroupLayouts,
|
|
6119
|
+
ei as createBindGroups,
|
|
6120
|
+
vt as createBuffer,
|
|
6121
|
+
Er as createCubeGeometry,
|
|
6122
|
+
Li as createDepthTexture,
|
|
6123
|
+
kr as createLookAtMatrix,
|
|
6124
|
+
Xr as createProjectionMatrix,
|
|
6125
|
+
Rr as createRenderPipelines,
|
|
6126
|
+
Oi as createRenderTextures,
|
|
6127
|
+
Tr as createSampler,
|
|
6128
|
+
Ar as createSphereGeometry,
|
|
6129
|
+
js as directRenderShader,
|
|
6130
|
+
Fi as extractGLBTexture,
|
|
6131
|
+
jr as fetchPreset,
|
|
6132
|
+
wr as glbMeshParticleShader,
|
|
6133
|
+
Or as hexToRgb,
|
|
6134
|
+
qr as initHzFxOverlay,
|
|
6135
|
+
_r as initWebGPU,
|
|
6136
|
+
Ji as isHZFX,
|
|
6137
|
+
Yr as loadScene,
|
|
6138
|
+
Hr as makeThreeSceneDepth,
|
|
6139
|
+
Ur as multiplyMatrices,
|
|
6140
|
+
Mr as object3dShader,
|
|
6141
|
+
zr as packHZFX,
|
|
6142
|
+
ir as parseGLB,
|
|
6143
|
+
Hs as particlePhysicsShader,
|
|
6144
|
+
Xs as particleShader,
|
|
6145
|
+
Lr as rgbToHex,
|
|
6146
|
+
Nr as saveScene,
|
|
6147
|
+
Gr as serializeSystemConfig,
|
|
6148
|
+
Ki as unpackHZFX
|
|
5816
6149
|
};
|