@adatechnology/game-destruction-three 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.global.js +14 -5
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -837,6 +837,8 @@ var SHARD_SHAPES = 6;
|
|
|
837
837
|
var SWEEP_MIN_SPEED = 1;
|
|
838
838
|
var WALL_RESTITUTION = 0.25;
|
|
839
839
|
var WALL_GLIDE = 0.7;
|
|
840
|
+
var TUMBLE_REACH = 0.1;
|
|
841
|
+
var LAID_GAP = 5e-3;
|
|
840
842
|
var STAND_RATIO = 0.6;
|
|
841
843
|
var SETTLE_SECONDS = 0.4;
|
|
842
844
|
var isSlow = (f) => f.vel.lengthSq() < 0.012 && f.ang.lengthSq() < 0.2;
|
|
@@ -1317,6 +1319,7 @@ var FragmentSystem = class {
|
|
|
1317
1319
|
const gy = Math.max(floor, pile);
|
|
1318
1320
|
const tip = pile > floor ? this.offEdge : null;
|
|
1319
1321
|
let contact = false;
|
|
1322
|
+
let turning = false;
|
|
1320
1323
|
if (mesh.position.y - ext < gy) {
|
|
1321
1324
|
contact = true;
|
|
1322
1325
|
mesh.position.y = gy + ext;
|
|
@@ -1325,8 +1328,9 @@ var FragmentSystem = class {
|
|
|
1325
1328
|
f.vel.x *= 0.7;
|
|
1326
1329
|
f.vel.z *= 0.7;
|
|
1327
1330
|
f.ang.multiplyScalar(0.55);
|
|
1328
|
-
|
|
1329
|
-
f.ang.
|
|
1331
|
+
const tumble = Math.min(1, TUMBLE_REACH / Math.max(h.x, h.y, h.z));
|
|
1332
|
+
f.ang.x += (this.rng() - 0.5) * 2 * tumble;
|
|
1333
|
+
f.ang.z += (this.rng() - 0.5) * 2 * tumble;
|
|
1330
1334
|
} else {
|
|
1331
1335
|
f.vel.y = 0;
|
|
1332
1336
|
const sliding = Math.hypot(f.vel.x, f.vel.z);
|
|
@@ -1344,9 +1348,13 @@ var FragmentSystem = class {
|
|
|
1344
1348
|
f.vel.z += tip.z * TIP_SPEED * dt * 10;
|
|
1345
1349
|
f.ang.x += tip.z * TIP_TURN * dt * 10;
|
|
1346
1350
|
f.ang.z -= tip.x * TIP_TURN * dt * 10;
|
|
1347
|
-
} else if (contact && f.vel.lengthSq() < 4)
|
|
1351
|
+
} else if (contact && f.vel.lengthSq() < 4) {
|
|
1352
|
+
turning = this.settle(f, dt);
|
|
1353
|
+
this.m.makeRotationFromQuaternion(mesh.quaternion);
|
|
1354
|
+
mesh.position.y = gy + (Math.abs(e[1]) * h.x + Math.abs(e[5]) * h.y + Math.abs(e[9]) * h.z) * sc;
|
|
1355
|
+
}
|
|
1348
1356
|
f.contact = contact;
|
|
1349
|
-
if (contact && isSlow(f)) {
|
|
1357
|
+
if (contact && !turning && isSlow(f)) {
|
|
1350
1358
|
f.still += dt;
|
|
1351
1359
|
if (f.still > SETTLE_SECONDS) this.sleep(f);
|
|
1352
1360
|
} else {
|
|
@@ -1424,7 +1432,7 @@ var FragmentSystem = class {
|
|
|
1424
1432
|
f.ang.x += (this.rng() - 0.5) * SHEET_SWAY * 4 * dt;
|
|
1425
1433
|
f.ang.z += (this.rng() - 0.5) * SHEET_SWAY * 4 * dt;
|
|
1426
1434
|
}
|
|
1427
|
-
/** Tip the fragment towards lying on its flattest face. */
|
|
1435
|
+
/** Tip the fragment towards lying on its flattest face. True while its end is still more than `LAID_GAP` from lying. */
|
|
1428
1436
|
settle(f, dt) {
|
|
1429
1437
|
const mesh = f.mesh;
|
|
1430
1438
|
this.m.makeRotationFromQuaternion(mesh.quaternion);
|
|
@@ -1446,6 +1454,7 @@ var FragmentSystem = class {
|
|
|
1446
1454
|
this.dq.setFromUnitVectors(this.v, this.w);
|
|
1447
1455
|
this.q.copy(this.dq).multiply(mesh.quaternion);
|
|
1448
1456
|
mesh.quaternion.slerp(this.q, clamp(dt * 7, 0, 1));
|
|
1457
|
+
return Math.sqrt(Math.max(0, 1 - this.v.y * this.v.y)) * Math.max(half[0], half[1], half[2]) > LAID_GAP;
|
|
1449
1458
|
}
|
|
1450
1459
|
/** Remove the fragments of one object (after `restore`). */
|
|
1451
1460
|
removeHome(home) {
|