@adatechnology/game-destruction-three 0.26.3 → 0.26.4
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 +50 -4
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +50 -4
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.global.js
CHANGED
|
@@ -15409,6 +15409,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15409
15409
|
var SUPPORT_MARGIN = 0.05;
|
|
15410
15410
|
var TOPPLE2 = 3;
|
|
15411
15411
|
var TIP_ACCELERATION = 30;
|
|
15412
|
+
var TIP_RISING = 0.02;
|
|
15413
|
+
var TIP_RISE_AFTER = 0.5;
|
|
15412
15414
|
var TIP_LYING = 0.25;
|
|
15413
15415
|
var TIP_SECONDS = 3;
|
|
15414
15416
|
var STEP = 0.03;
|
|
@@ -15427,6 +15429,9 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15427
15429
|
};
|
|
15428
15430
|
var SUPPORT_CHECKS2 = 16;
|
|
15429
15431
|
var SUPPORT_GAP2 = 0.02;
|
|
15432
|
+
var STEEP_MARGIN = 1.1;
|
|
15433
|
+
var SLOPE_MIN_NORMAL = 0.5;
|
|
15434
|
+
var LIES_FLAT = 0.985;
|
|
15430
15435
|
var KEEP_EVERY = 0.5;
|
|
15431
15436
|
var WAKE_ABOVE_SPEED = 0.05;
|
|
15432
15437
|
var WAKE_ABOVE_SPIN = 0.1;
|
|
@@ -15557,6 +15562,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15557
15562
|
/** The surface normal and the friction of what the last `supportAt` found under the point (the ground and fixed tops are level: up, and no piece). */
|
|
15558
15563
|
__publicField(this, "supportNormal", UP16);
|
|
15559
15564
|
__publicField(this, "supportFriction", null);
|
|
15565
|
+
__publicField(this, "supportBody", null);
|
|
15560
15566
|
/** The terrain's surfaces by rolling resistance and damping (`terrainSurface`), one object each. */
|
|
15561
15567
|
__publicField(this, "terrainSurfaces", /* @__PURE__ */ new Map());
|
|
15562
15568
|
/** The terrain's surface by ground tile (`groundTileKey`) this update, null for the default: read once per tile, not per contact per substep. */
|
|
@@ -15745,6 +15751,10 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
15745
15751
|
get(objectId) {
|
|
15746
15752
|
return this.list.find((b) => b.objectId === objectId) ?? null;
|
|
15747
15753
|
}
|
|
15754
|
+
/** Whether `upper` lies flat on a top of `lower` that is steeper than its friction holds: what it slides on, not a wall in its way. */
|
|
15755
|
+
slidesOn(upper, lower) {
|
|
15756
|
+
return this.restsOn(upper, lower, false) && this.onSteepSupport(upper);
|
|
15757
|
+
}
|
|
15748
15758
|
/** Sets a piece falling over, about the world axes x and z (a unit axis): its feet are thinner than the box that stands for it, so the box alone would hold it up. */
|
|
15749
15759
|
tip(body, x, z) {
|
|
15750
15760
|
body.tipping = { x, z, seconds: TIP_SECONDS };
|
|
@@ -16214,9 +16224,11 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
16214
16224
|
for (let k = 0; k < Math.min(SUPPORT_CHECKS2, n); k++) {
|
|
16215
16225
|
this.supportTurn = (this.supportTurn + 1) % n;
|
|
16216
16226
|
const b = this.list[this.supportTurn];
|
|
16217
|
-
if (!b.sleeping || b.held
|
|
16227
|
+
if (!b.sleeping || b.held) continue;
|
|
16218
16228
|
const rest = b.restPoints;
|
|
16219
|
-
|
|
16229
|
+
const budgeted = !!rest && rest.length > 0;
|
|
16230
|
+
const held = onlyBudget && !budgeted ? true : budgeted ? rest.every((point) => this.supportsPoint(b, point)) : this.supported(b, false) || this.supported(b, true);
|
|
16231
|
+
if (held && !this.onSteepSupport(b)) continue;
|
|
16220
16232
|
b.sleeping = false;
|
|
16221
16233
|
b.still = 0;
|
|
16222
16234
|
b.calmAt = null;
|
|
@@ -16339,6 +16351,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
16339
16351
|
if (fixed >= top) on = null;
|
|
16340
16352
|
this.supportNormal = on ? faceNormal(on, face) : UP16;
|
|
16341
16353
|
this.supportFriction = on?.body.friction ?? null;
|
|
16354
|
+
this.supportBody = on?.body ?? null;
|
|
16342
16355
|
return Math.max(top, fixed);
|
|
16343
16356
|
}
|
|
16344
16357
|
/** Stops a piece that ran into something on its way from `start` to `pos` (`sweep`): moves it back to where it met it and takes the speed into it. */
|
|
@@ -16673,7 +16686,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
16673
16686
|
b.tipping.seconds -= h;
|
|
16674
16687
|
const [hx, hy, hz2] = b.halfExtents;
|
|
16675
16688
|
const upHalf = Math.abs(e[1]) * hx + Math.abs(e[5]) * hy + Math.abs(e[9]) * hz2;
|
|
16676
|
-
|
|
16689
|
+
const rising = TIP_SECONDS - b.tipping.seconds > TIP_RISE_AFTER && v[1] > TIP_RISING;
|
|
16690
|
+
if (upHalf < TIP_LYING || b.tipping.seconds <= 0 || rising) b.tipping = null;
|
|
16677
16691
|
else {
|
|
16678
16692
|
w[0] += b.tipping.x * TIP_ACCELERATION * h;
|
|
16679
16693
|
w[2] += b.tipping.z * TIP_ACCELERATION * h;
|
|
@@ -16723,7 +16737,31 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
16723
16737
|
b.balancing = unstable;
|
|
16724
16738
|
this.keepsTilt(b, q, dt);
|
|
16725
16739
|
const held = (touched || propped !== void 0) && !b.tipping;
|
|
16726
|
-
if (!b.hinge && (b.still >= SLEEP_AFTER || this.staysInPlace(b, held, pos, q, dt))) this.sleep(b);
|
|
16740
|
+
if (!b.hinge && (b.still >= SLEEP_AFTER || this.staysInPlace(b, held, pos, q, dt)) && !this.onSteepSupport(b)) this.sleep(b);
|
|
16741
|
+
}
|
|
16742
|
+
/**
|
|
16743
|
+
* Whether `b` lies flat on a settled top (asleep) tilted past what the friction of the two holds (a laptop on a table top gone over at 42 degrees, held by 0.49 up to 26),
|
|
16744
|
+
* with every corner that touches on it: it slides, it does not sleep there, and one asleep there wakes. Held by anything else (the floor, a flat top, a side it leans on, a
|
|
16745
|
+
* pile still moving) it is not this case: the contacts hold or move it.
|
|
16746
|
+
*/
|
|
16747
|
+
onSteepSupport(b) {
|
|
16748
|
+
const c = this.centerOf(b, this.p);
|
|
16749
|
+
const e = this.m.makeRotationFromQuaternion(b.root.quaternion).elements;
|
|
16750
|
+
let touching = false;
|
|
16751
|
+
for (const [sx, sy, sz] of this.samples(b, false)) {
|
|
16752
|
+
const y = c.y + e[1] * sx + e[5] * sy + e[9] * sz;
|
|
16753
|
+
if (this.supportAt(b, c.x + e[0] * sx + e[4] * sy + e[8] * sz, y, c.z + e[2] * sx + e[6] * sy + e[10] * sz, STEP) < y - SUPPORT_GAP2) continue;
|
|
16754
|
+
if (this.supportBody && !this.supportBody.sleeping) return false;
|
|
16755
|
+
const n = this.supportNormal;
|
|
16756
|
+
const ny = n[1];
|
|
16757
|
+
const holds = pairFriction(b.friction, this.supportFriction).static;
|
|
16758
|
+
if (ny >= 1 - 1e-6 || ny < SLOPE_MIN_NORMAL || Math.sqrt(Math.max(0, 1 - ny * ny)) / ny <= holds * STEEP_MARGIN) return false;
|
|
16759
|
+
let flat = 0;
|
|
16760
|
+
for (let axis2 = 0; axis2 < 12; axis2 += 4) flat = Math.max(flat, Math.abs(e[axis2] * n[0] + e[axis2 + 1] * n[1] + e[axis2 + 2] * n[2]));
|
|
16761
|
+
if (flat < LIES_FLAT) return false;
|
|
16762
|
+
touching = true;
|
|
16763
|
+
}
|
|
16764
|
+
return touching;
|
|
16727
16765
|
}
|
|
16728
16766
|
/** The piece sleeps where it lies: its speeds are dropped, nothing moves it. */
|
|
16729
16767
|
sleep(b) {
|
|
@@ -17164,6 +17202,12 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
17164
17202
|
if (resting) return;
|
|
17165
17203
|
const [upper, c, up] = n[1] > 0 ? [a, ca, n] : [b, cb, [-n[0], -n[1], -n[2]]];
|
|
17166
17204
|
if (upper.held || upper.sleeping) return;
|
|
17205
|
+
const otherCentre = upper === a ? cb : ca;
|
|
17206
|
+
if (c[1] < otherCentre[1] - SLOP) {
|
|
17207
|
+
const level = boxesApartAlongGround(sa, sb);
|
|
17208
|
+
if (level) this.slideApart(a, b, ima, imb, level);
|
|
17209
|
+
return;
|
|
17210
|
+
}
|
|
17167
17211
|
upper.propped = up;
|
|
17168
17212
|
const e = this.m.makeRotationFromQuaternion(upper.root.quaternion).elements;
|
|
17169
17213
|
const r = [hit.point[0] - c[0], hit.point[1] - c[1], hit.point[2] - c[2]];
|
|
@@ -28543,6 +28587,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
28543
28587
|
this.batcher?.update();
|
|
28544
28588
|
this.sinceMade += dt;
|
|
28545
28589
|
if (!this.options.enabled || this.sinceMade < this.options.intervalSeconds) return;
|
|
28590
|
+
if (this.queue.pending() > 0) return;
|
|
28546
28591
|
const meshes = atRest().filter((mesh2) => isBatchableDebris(mesh2, this.options.maxVertices) || this.batched(mesh2));
|
|
28547
28592
|
const outside = meshes.length - (this.batcher?.stats().batched ?? 0);
|
|
28548
28593
|
if (outside < this.options.minMeshes) return;
|
|
@@ -29492,6 +29537,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
29492
29537
|
if (!hit) return null;
|
|
29493
29538
|
const other = this.pieceSys.get(hit.object);
|
|
29494
29539
|
if (other && (p.round || other.round)) return null;
|
|
29540
|
+
if (other && this.pieceSys.slidesOn(p, other)) return null;
|
|
29495
29541
|
const material = this.world.part(hit.object, hit.part)?.material;
|
|
29496
29542
|
const restitution = material === void 0 ? void 0 : surfaceOf(material, this.world.materials.get(material))?.restitution;
|
|
29497
29543
|
return { object: hit.object, part: hit.part, distance: hit.distance, point: hit.point, normal: hit.normal, ...restitution === void 0 ? {} : { restitution } };
|