@adatechnology/game-destruction-three 0.28.2 → 0.29.0
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/README.md +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.global.js +28 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3233,15 +3233,18 @@ function shapeContact(a, b) {
|
|
|
3233
3233
|
import { createImpactReader } from "@adatechnology/game-physics";
|
|
3234
3234
|
var DEFAULT_MIN_IMPULSE = 30;
|
|
3235
3235
|
var DEFAULT_HITS_MAX = 32;
|
|
3236
|
+
var DEFAULT_MIN_APPROACH = 1.5;
|
|
3236
3237
|
var DEFAULT_CONTACT_RADIUS = 0.1;
|
|
3237
3238
|
var createEngineImpacts = (loop, statics, destruction, options = {}) => {
|
|
3238
3239
|
const hitsMax = options.hitsMax ?? DEFAULT_HITS_MAX;
|
|
3239
3240
|
const radius = options.contactRadius ?? DEFAULT_CONTACT_RADIUS;
|
|
3241
|
+
const minApproach = options.minApproach ?? DEFAULT_MIN_APPROACH;
|
|
3240
3242
|
return createImpactReader(loop, {
|
|
3241
3243
|
minImpulse: options.minImpulse ?? DEFAULT_MIN_IMPULSE,
|
|
3242
3244
|
bodiesMax: hitsMax,
|
|
3243
3245
|
accepts: (body) => statics.ownerOf.has(body),
|
|
3244
3246
|
onImpact: (impact2) => {
|
|
3247
|
+
if (impact2.approach < minApproach) return;
|
|
3245
3248
|
const object = statics.ownerOf.get(impact2.body);
|
|
3246
3249
|
const part = statics.partOf.get(impact2.body);
|
|
3247
3250
|
if (object === void 0 || part === void 0 || destruction.part(object, part) === null) return;
|
|
@@ -3781,6 +3784,14 @@ var EnginePieces = class {
|
|
|
3781
3784
|
if (tile.patch) this.schedule?.givePatch(tile.patch.heights);
|
|
3782
3785
|
this.tiles.delete(key);
|
|
3783
3786
|
}
|
|
3787
|
+
/** The piece a body of the engine is, or undefined (a fixed body, someone else's). */
|
|
3788
|
+
pieceOfBody(body) {
|
|
3789
|
+
return this.byBody.get(body);
|
|
3790
|
+
}
|
|
3791
|
+
/** Whether the piece has a body in the engine yet (a piece made this frame has none until the next update). */
|
|
3792
|
+
hasBody(piece) {
|
|
3793
|
+
return this.links.has(piece);
|
|
3794
|
+
}
|
|
3784
3795
|
/** The fixed bodies as a broad phase for the destruction world's rays (`engine-rays.ts`). */
|
|
3785
3796
|
rayBroadPhase() {
|
|
3786
3797
|
return createEngineRayBroadPhase(this.world, this.statics);
|
|
@@ -5336,6 +5347,21 @@ var PieceSystem = class {
|
|
|
5336
5347
|
contactHits(destruction, options) {
|
|
5337
5348
|
return this.engine && this.loop ? createEngineImpacts(this.loop, this.engine.statics, destruction, options) : null;
|
|
5338
5349
|
}
|
|
5350
|
+
/**
|
|
5351
|
+
* The pieces a blast at `point` can reach: the bodies the engine's `blastQuery` finds within `radius` (the pieces among them), in the order of `list`, and the pieces that have no
|
|
5352
|
+
* body yet. The pieces are not walked one by one to measure each one's distance; the caller still takes the distance to the centre of each, as before.
|
|
5353
|
+
*/
|
|
5354
|
+
piecesInBlast(blastQuery, point, radius) {
|
|
5355
|
+
const engine = this.engine;
|
|
5356
|
+
if (!engine) return [...this.list];
|
|
5357
|
+
const found = blastQuery.run({ origin: point, radius });
|
|
5358
|
+
const reached = /* @__PURE__ */ new Set();
|
|
5359
|
+
for (let i = 0; i < found.bodyCount; i++) {
|
|
5360
|
+
const piece = engine.pieceOfBody(found.bodies[i]);
|
|
5361
|
+
if (piece) reached.add(piece);
|
|
5362
|
+
}
|
|
5363
|
+
return this.list.filter((piece) => reached.has(piece) || !engine.hasBody(piece));
|
|
5364
|
+
}
|
|
5339
5365
|
/** The engine's fixed bodies as the broad phase of the world's rays, or null when the pieces are not in the engine. */
|
|
5340
5366
|
rayBroadPhase() {
|
|
5341
5367
|
return this.engine?.rayBroadPhase() ?? null;
|
|
@@ -12054,7 +12080,8 @@ var Renderer = class {
|
|
|
12054
12080
|
const point = [c.x + (this.rng() - 0.5) * spread, c.y + spread * 0.5, c.z + (this.rng() - 0.5) * spread];
|
|
12055
12081
|
reach(distance, { objectId: pc.objectId, generation: pc.generation, impulse, point }, [c.x, c.y, c.z]);
|
|
12056
12082
|
};
|
|
12057
|
-
|
|
12083
|
+
const reached = this.o.blastQuery ? this.pieceSys.piecesInBlast(this.o.blastQuery, p, ev.radius) : [...this.pieceSys.list];
|
|
12084
|
+
for (const pc of reached) shove(pc);
|
|
12058
12085
|
if (this.o.shoveable) this.loosen(p, ev.radius, energy, reachOf2, policy, reach);
|
|
12059
12086
|
this.advanceWakes(0);
|
|
12060
12087
|
this.fragments.blast(p, ev.radius, Math.min(20, Math.sqrt(energy) * 0.08));
|