@adatechnology/game-destruction-three 0.26.0 → 0.26.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 +45 -8
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -4752,6 +4752,7 @@ var STEADY_SECONDS2 = 1.5;
|
|
|
4752
4752
|
var HARD_LANDING2 = 3;
|
|
4753
4753
|
var SLOP = 2e-3;
|
|
4754
4754
|
var NARROW2 = 0.3;
|
|
4755
|
+
var SUPPORT_MARGIN = 0.05;
|
|
4755
4756
|
var TOPPLE2 = 3;
|
|
4756
4757
|
var TIP_ACCELERATION = 30;
|
|
4757
4758
|
var TIP_LYING = 0.25;
|
|
@@ -4761,6 +4762,15 @@ var WARM_SLOTS = 8 + 12 * 7;
|
|
|
4761
4762
|
var SOLVER_PASSES = 10;
|
|
4762
4763
|
var SIDE_BOUNCE = 0.1;
|
|
4763
4764
|
var EDGE_POINTS = [-0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75];
|
|
4765
|
+
var EDGE_SPACING = 0.05;
|
|
4766
|
+
var MAX_EDGE_POINTS = 31;
|
|
4767
|
+
var THIN_HALF = 0.03;
|
|
4768
|
+
var edgeFractions = (half, thin) => {
|
|
4769
|
+
if (thin > THIN_HALF) return EDGE_POINTS;
|
|
4770
|
+
const count = Math.min(MAX_EDGE_POINTS, Math.ceil(2 * half / EDGE_SPACING) - 1);
|
|
4771
|
+
if (count <= EDGE_POINTS.length) return EDGE_POINTS;
|
|
4772
|
+
return Array.from({ length: count }, (_, i) => -1 + 2 * (i + 1) / (count + 1));
|
|
4773
|
+
};
|
|
4764
4774
|
var SUPPORT_CHECKS2 = 16;
|
|
4765
4775
|
var SUPPORT_GAP2 = 0.02;
|
|
4766
4776
|
var KEEP_EVERY = 0.5;
|
|
@@ -5282,8 +5292,9 @@ var PieceSystem = class {
|
|
|
5282
5292
|
for (let axis = 0; axis < 3; axis++) {
|
|
5283
5293
|
const a1 = (axis + 1) % 3;
|
|
5284
5294
|
const a2 = (axis + 2) % 3;
|
|
5295
|
+
const fractions = edgeFractions(h[axis], Math.min(hx, hy, hz));
|
|
5285
5296
|
for (let k = 0; k < 4; k++) {
|
|
5286
|
-
for (const f of
|
|
5297
|
+
for (const f of fractions) {
|
|
5287
5298
|
const p = [0, 0, 0];
|
|
5288
5299
|
p[axis] = f * h[axis];
|
|
5289
5300
|
p[a1] = k & 1 ? h[a1] : -h[a1];
|
|
@@ -6001,7 +6012,9 @@ var PieceSystem = class {
|
|
|
6001
6012
|
const height = -low;
|
|
6002
6013
|
const wx = x1 - x0;
|
|
6003
6014
|
const wz = z1 - z0;
|
|
6004
|
-
|
|
6015
|
+
const pastX = x0 > -SUPPORT_MARGIN * wx || x1 < SUPPORT_MARGIN * wx;
|
|
6016
|
+
const pastZ = z0 > -SUPPORT_MARGIN * wz || z1 < SUPPORT_MARGIN * wz;
|
|
6017
|
+
unstable = !b.round && (Math.min(wx, wz) < NARROW2 * height || pastX || pastZ);
|
|
6005
6018
|
if (b.tipping) {
|
|
6006
6019
|
b.tipping.seconds -= h;
|
|
6007
6020
|
const [hx, hy, hz] = b.halfExtents;
|
|
@@ -6017,7 +6030,8 @@ var PieceSystem = class {
|
|
|
6017
6030
|
const dirX = x0 + x1 > 0 ? -1 : 1;
|
|
6018
6031
|
const dirZ = z0 + z1 > 0 ? -1 : 1;
|
|
6019
6032
|
const k = TOPPLE2 * Math.min(height, 1) * h;
|
|
6020
|
-
|
|
6033
|
+
const overZ = pastX === pastZ ? wx <= wz : pastX;
|
|
6034
|
+
if (overZ) w[2] -= dirX * k;
|
|
6021
6035
|
else w[0] += dirZ * k;
|
|
6022
6036
|
}
|
|
6023
6037
|
if (b.round) {
|
|
@@ -6174,8 +6188,7 @@ var PieceSystem = class {
|
|
|
6174
6188
|
}
|
|
6175
6189
|
/** The corners of `b` (its own frame, or its own `contacts`) that have the ground, a piece or a fixed top within `SUPPORT_GAP` under them now; the points along its edges when no corner has. */
|
|
6176
6190
|
restPointsOf(b) {
|
|
6177
|
-
|
|
6178
|
-
return corners.length > 0 ? corners : this.samples(b, true).filter((point) => this.supportsPoint(b, point));
|
|
6191
|
+
return this.samples(b, true).filter((point) => this.supportsPoint(b, point));
|
|
6179
6192
|
}
|
|
6180
6193
|
/** Whether the point of `b` (its own frame) has the ground, a piece or a fixed top within `SUPPORT_GAP` under it. */
|
|
6181
6194
|
supportsPoint(b, [sx, sy, sz]) {
|
|
@@ -8808,6 +8821,8 @@ var STAND_LEAN = 0.1;
|
|
|
8808
8821
|
var EDGE_NUDGE = 1;
|
|
8809
8822
|
var TIP_MIN_HEIGHT = 0.3;
|
|
8810
8823
|
var TIP_NARROW = 0.3;
|
|
8824
|
+
var TIP_STANDING_FEET = 0.1;
|
|
8825
|
+
var TIP_CENTRED = 0.15;
|
|
8811
8826
|
var HINGE_STILL_SPEED = 0.2;
|
|
8812
8827
|
var HINGE_STILL_SPIN = 0.5;
|
|
8813
8828
|
var PREFIT_SLICE_MS = 1;
|
|
@@ -10911,7 +10926,7 @@ var Renderer = class {
|
|
|
10911
10926
|
if (!this.splittingAtLoad) old.sleeping = false;
|
|
10912
10927
|
} else if (kitOriginOf3(b.root)?.kind === "furniture" && !this.splittingAtLoad) {
|
|
10913
10928
|
const piece = this.makePiece(objectId);
|
|
10914
|
-
this.tipIfTopHeavy(b);
|
|
10929
|
+
this.tipIfTopHeavy(b, true);
|
|
10915
10930
|
this.o.onLoosened?.(objectId, piece, "apart");
|
|
10916
10931
|
}
|
|
10917
10932
|
}
|
|
@@ -11486,9 +11501,10 @@ var Renderer = class {
|
|
|
11486
11501
|
}
|
|
11487
11502
|
/**
|
|
11488
11503
|
* A piece of furniture standing on feet too close for its height (a board on two legs in a line, a lone leg) does not stay up: the box of a piece hides that its weight is up
|
|
11489
|
-
* high and its feet are thin, so it gets the start of the fall, across the line of its feet.
|
|
11504
|
+
* high and its feet are thin, so it gets the start of the fall, across the line of its feet. `isStandingWhenCentred`: what is left after a part came off stands when it is
|
|
11505
|
+
* centred over feet wide enough (`TIP_STANDING_FEET`, `TIP_CENTRED`).
|
|
11490
11506
|
*/
|
|
11491
|
-
tipIfTopHeavy(b) {
|
|
11507
|
+
tipIfTopHeavy(b, isStandingWhenCentred = false) {
|
|
11492
11508
|
const piece = b.piece;
|
|
11493
11509
|
if (!piece) return;
|
|
11494
11510
|
const box = new this.THREE.Box3();
|
|
@@ -11503,6 +11519,8 @@ var Renderer = class {
|
|
|
11503
11519
|
if (height < TIP_MIN_HEIGHT || Math.min(spanX, spanZ) >= TIP_NARROW * height) return;
|
|
11504
11520
|
const across = spanX <= spanZ ? 0 : 2;
|
|
11505
11521
|
const lean = across === 0 ? box.min.x + box.max.x - feet.min.x - feet.max.x : box.min.z + box.max.z - feet.min.z - feet.max.z;
|
|
11522
|
+
const span = Math.min(spanX, spanZ);
|
|
11523
|
+
if (isStandingWhenCentred && span >= TIP_STANDING_FEET && Math.abs(lean) / 2 < TIP_CENTRED * span) return;
|
|
11506
11524
|
const away = lean < 0 ? -1 : 1;
|
|
11507
11525
|
if (across === 0) this.pieceSys.tip(piece, 0, -away);
|
|
11508
11526
|
else this.pieceSys.tip(piece, away, 0);
|