@cazala/party 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/modules/forces/fluids.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6679,9 +6679,17 @@ class Fluids extends Module {
|
|
|
6679
6679
|
gradY = gradY + dir.y * weight * pressureFactor;
|
|
6680
6680
|
}
|
|
6681
6681
|
|
|
6682
|
-
//
|
|
6683
|
-
|
|
6684
|
-
|
|
6682
|
+
// Clamp acceleration magnitude (units: velocity / second) to avoid dt-dependent instability
|
|
6683
|
+
// (notably visible at lower FPS / larger dt near boundaries).
|
|
6684
|
+
let maxAccel = 30000.0;
|
|
6685
|
+
var grad = vec2<f32>(gradX, gradY);
|
|
6686
|
+
let gl = length(grad);
|
|
6687
|
+
if (gl > maxAccel) {
|
|
6688
|
+
grad = grad * (maxAccel / max(gl, 1e-6));
|
|
6689
|
+
}
|
|
6690
|
+
|
|
6691
|
+
newVelX = newVelX + grad.x * ${dtVar};
|
|
6692
|
+
newVelY = newVelY + grad.y * ${dtVar};
|
|
6685
6693
|
}
|
|
6686
6694
|
|
|
6687
6695
|
${particleVar}.velocity.x = newVelX;
|
|
@@ -6926,7 +6934,15 @@ class Fluids extends Module {
|
|
|
6926
6934
|
gradX += dirX * weight * pressureFactor;
|
|
6927
6935
|
gradY += dirY * weight * pressureFactor;
|
|
6928
6936
|
}
|
|
6929
|
-
//
|
|
6937
|
+
// Clamp acceleration magnitude (units: velocity / second) to avoid dt-dependent instability
|
|
6938
|
+
// (notably visible at lower FPS / larger dt near boundaries).
|
|
6939
|
+
const maxAccel = 20000.0;
|
|
6940
|
+
const gradLen = Math.hypot(gradX, gradY);
|
|
6941
|
+
if (gradLen > maxAccel && gradLen > 1e-6) {
|
|
6942
|
+
const s = maxAccel / gradLen;
|
|
6943
|
+
gradX *= s;
|
|
6944
|
+
gradY *= s;
|
|
6945
|
+
}
|
|
6930
6946
|
newVelX += gradX * dt;
|
|
6931
6947
|
newVelY += gradY * dt;
|
|
6932
6948
|
}
|