@adatechnology/game-destruction-three 0.26.0 → 0.26.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.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.global.js
CHANGED
|
@@ -15391,6 +15391,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15391
15391
|
var HARD_LANDING2 = 3;
|
|
15392
15392
|
var SLOP = 2e-3;
|
|
15393
15393
|
var NARROW2 = 0.3;
|
|
15394
|
+
var SUPPORT_MARGIN = 0.05;
|
|
15394
15395
|
var TOPPLE2 = 3;
|
|
15395
15396
|
var TIP_ACCELERATION = 30;
|
|
15396
15397
|
var TIP_LYING = 0.25;
|
|
@@ -15400,6 +15401,15 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15400
15401
|
var SOLVER_PASSES = 10;
|
|
15401
15402
|
var SIDE_BOUNCE = 0.1;
|
|
15402
15403
|
var EDGE_POINTS = [-0.75, -0.5, -0.25, 0, 0.25, 0.5, 0.75];
|
|
15404
|
+
var EDGE_SPACING = 0.05;
|
|
15405
|
+
var MAX_EDGE_POINTS = 31;
|
|
15406
|
+
var THIN_HALF = 0.03;
|
|
15407
|
+
var edgeFractions = (half, thin) => {
|
|
15408
|
+
if (thin > THIN_HALF) return EDGE_POINTS;
|
|
15409
|
+
const count = Math.min(MAX_EDGE_POINTS, Math.ceil(2 * half / EDGE_SPACING) - 1);
|
|
15410
|
+
if (count <= EDGE_POINTS.length) return EDGE_POINTS;
|
|
15411
|
+
return Array.from({ length: count }, (_, i) => -1 + 2 * (i + 1) / (count + 1));
|
|
15412
|
+
};
|
|
15403
15413
|
var SUPPORT_CHECKS2 = 16;
|
|
15404
15414
|
var SUPPORT_GAP2 = 0.02;
|
|
15405
15415
|
var KEEP_EVERY = 0.5;
|
|
@@ -15921,8 +15931,9 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15921
15931
|
for (let axis2 = 0; axis2 < 3; axis2++) {
|
|
15922
15932
|
const a1 = (axis2 + 1) % 3;
|
|
15923
15933
|
const a2 = (axis2 + 2) % 3;
|
|
15934
|
+
const fractions = edgeFractions(h[axis2], Math.min(hx, hy, hz2));
|
|
15924
15935
|
for (let k = 0; k < 4; k++) {
|
|
15925
|
-
for (const f of
|
|
15936
|
+
for (const f of fractions) {
|
|
15926
15937
|
const p = [0, 0, 0];
|
|
15927
15938
|
p[axis2] = f * h[axis2];
|
|
15928
15939
|
p[a1] = k & 1 ? h[a1] : -h[a1];
|
|
@@ -16640,7 +16651,9 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
16640
16651
|
const height = -low;
|
|
16641
16652
|
const wx = x1 - x0;
|
|
16642
16653
|
const wz = z1 - z0;
|
|
16643
|
-
|
|
16654
|
+
const pastX = x0 > -SUPPORT_MARGIN * wx || x1 < SUPPORT_MARGIN * wx;
|
|
16655
|
+
const pastZ = z0 > -SUPPORT_MARGIN * wz || z1 < SUPPORT_MARGIN * wz;
|
|
16656
|
+
unstable = !b.round && (Math.min(wx, wz) < NARROW2 * height || pastX || pastZ);
|
|
16644
16657
|
if (b.tipping) {
|
|
16645
16658
|
b.tipping.seconds -= h;
|
|
16646
16659
|
const [hx, hy, hz2] = b.halfExtents;
|
|
@@ -16656,7 +16669,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
16656
16669
|
const dirX = x0 + x1 > 0 ? -1 : 1;
|
|
16657
16670
|
const dirZ = z0 + z1 > 0 ? -1 : 1;
|
|
16658
16671
|
const k = TOPPLE2 * Math.min(height, 1) * h;
|
|
16659
|
-
|
|
16672
|
+
const overZ = pastX === pastZ ? wx <= wz : pastX;
|
|
16673
|
+
if (overZ) w[2] -= dirX * k;
|
|
16660
16674
|
else w[0] += dirZ * k;
|
|
16661
16675
|
}
|
|
16662
16676
|
if (b.round) {
|
|
@@ -16813,8 +16827,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
16813
16827
|
}
|
|
16814
16828
|
/** 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. */
|
|
16815
16829
|
restPointsOf(b) {
|
|
16816
|
-
|
|
16817
|
-
return corners.length > 0 ? corners : this.samples(b, true).filter((point) => this.supportsPoint(b, point));
|
|
16830
|
+
return this.samples(b, true).filter((point) => this.supportsPoint(b, point));
|
|
16818
16831
|
}
|
|
16819
16832
|
/** Whether the point of `b` (its own frame) has the ground, a piece or a fixed top within `SUPPORT_GAP` under it. */
|
|
16820
16833
|
supportsPoint(b, [sx, sy, sz]) {
|
|
@@ -26027,6 +26040,25 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
26027
26040
|
return j.st.progress;
|
|
26028
26041
|
}).value;
|
|
26029
26042
|
},
|
|
26043
|
+
take(objectId, partId) {
|
|
26044
|
+
if (impls.has(objectId)) return null;
|
|
26045
|
+
const o = getObj(objectId);
|
|
26046
|
+
const part = o.byId.get(partId);
|
|
26047
|
+
const hands = part?.spec.hands;
|
|
26048
|
+
if (!part || !hands || isLost(part)) return null;
|
|
26049
|
+
const holding = (o.byPart.get(partId) ?? []).filter((j) => !j.st.open);
|
|
26050
|
+
if (holding.length === 0 || holding.some((j) => !j.spec.tools.includes("hand"))) return null;
|
|
26051
|
+
run(() => {
|
|
26052
|
+
for (const j of holding) {
|
|
26053
|
+
j.st.progress = 1;
|
|
26054
|
+
j.st.open = true;
|
|
26055
|
+
j.st.openedBy = "tool";
|
|
26056
|
+
}
|
|
26057
|
+
loosened(o, holding, "tool");
|
|
26058
|
+
collapseCheck(o);
|
|
26059
|
+
});
|
|
26060
|
+
return hands;
|
|
26061
|
+
},
|
|
26030
26062
|
workableJoints(objectId, tool) {
|
|
26031
26063
|
const im = impls.get(objectId);
|
|
26032
26064
|
if (im) {
|
|
@@ -28617,6 +28649,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
28617
28649
|
var EDGE_NUDGE = 1;
|
|
28618
28650
|
var TIP_MIN_HEIGHT = 0.3;
|
|
28619
28651
|
var TIP_NARROW = 0.3;
|
|
28652
|
+
var TIP_STANDING_FEET = 0.1;
|
|
28653
|
+
var TIP_CENTRED = 0.15;
|
|
28620
28654
|
var HINGE_STILL_SPEED = 0.2;
|
|
28621
28655
|
var HINGE_STILL_SPIN = 0.5;
|
|
28622
28656
|
var PREFIT_SLICE_MS = 1;
|
|
@@ -30720,7 +30754,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
30720
30754
|
if (!this.splittingAtLoad) old.sleeping = false;
|
|
30721
30755
|
} else if (kitOriginOf(b.root)?.kind === "furniture" && !this.splittingAtLoad) {
|
|
30722
30756
|
const piece = this.makePiece(objectId);
|
|
30723
|
-
this.tipIfTopHeavy(b);
|
|
30757
|
+
this.tipIfTopHeavy(b, true);
|
|
30724
30758
|
this.o.onLoosened?.(objectId, piece, "apart");
|
|
30725
30759
|
}
|
|
30726
30760
|
}
|
|
@@ -31295,9 +31329,10 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
31295
31329
|
}
|
|
31296
31330
|
/**
|
|
31297
31331
|
* 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
|
|
31298
|
-
* high and its feet are thin, so it gets the start of the fall, across the line of its feet.
|
|
31332
|
+
* 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
|
|
31333
|
+
* centred over feet wide enough (`TIP_STANDING_FEET`, `TIP_CENTRED`).
|
|
31299
31334
|
*/
|
|
31300
|
-
tipIfTopHeavy(b) {
|
|
31335
|
+
tipIfTopHeavy(b, isStandingWhenCentred = false) {
|
|
31301
31336
|
const piece = b.piece;
|
|
31302
31337
|
if (!piece) return;
|
|
31303
31338
|
const box = new this.THREE.Box3();
|
|
@@ -31312,6 +31347,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
31312
31347
|
if (height < TIP_MIN_HEIGHT || Math.min(spanX, spanZ) >= TIP_NARROW * height) return;
|
|
31313
31348
|
const across = spanX <= spanZ ? 0 : 2;
|
|
31314
31349
|
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;
|
|
31350
|
+
const span = Math.min(spanX, spanZ);
|
|
31351
|
+
if (isStandingWhenCentred && span >= TIP_STANDING_FEET && Math.abs(lean) / 2 < TIP_CENTRED * span) return;
|
|
31315
31352
|
const away = lean < 0 ? -1 : 1;
|
|
31316
31353
|
if (across === 0) this.pieceSys.tip(piece, 0, -away);
|
|
31317
31354
|
else this.pieceSys.tip(piece, away, 0);
|