@adatechnology/game-floorplan-three 0.8.0 → 0.8.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 +54 -3
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +37 -3
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -6271,6 +6271,12 @@ var SPALL_MIN = 0.025;
|
|
|
6271
6271
|
var SPALL_RAGGED = 0.045;
|
|
6272
6272
|
var COVER = 0.015;
|
|
6273
6273
|
var MAX_FLAKES = 64;
|
|
6274
|
+
function clipToBox(unit, box) {
|
|
6275
|
+
const lo = [Math.max(unit.x - unit.sx / 2, box[0]), Math.max(unit.y - unit.sy / 2, box[1]), Math.max(unit.z - unit.sz / 2, box[2])];
|
|
6276
|
+
const hi = [Math.min(unit.x + unit.sx / 2, box[3]), Math.min(unit.y + unit.sy / 2, box[4]), Math.min(unit.z + unit.sz / 2, box[5])];
|
|
6277
|
+
if (hi[0] - lo[0] <= 1e-4 || hi[1] - lo[1] <= 1e-4 || hi[2] - lo[2] <= 1e-4) return null;
|
|
6278
|
+
return { x: (lo[0] + hi[0]) / 2, y: (lo[1] + hi[1]) / 2, z: (lo[2] + hi[2]) / 2, sx: hi[0] - lo[0], sy: hi[1] - lo[1], sz: hi[2] - lo[2], colour: unit.colour };
|
|
6279
|
+
}
|
|
6274
6280
|
function installDestructionBreach(K, _shared) {
|
|
6275
6281
|
const { THREE, fragmentMaterial, invalidate, invalidateShadow } = K;
|
|
6276
6282
|
function createBreachView(opts) {
|
|
@@ -6381,6 +6387,16 @@ function installDestructionBreach(K, _shared) {
|
|
|
6381
6387
|
material.userData.breachCore = core;
|
|
6382
6388
|
return material;
|
|
6383
6389
|
}
|
|
6390
|
+
function drawnBounds(items) {
|
|
6391
|
+
house.updateMatrixWorld(true);
|
|
6392
|
+
const box = new THREE.Box3(), toHouse = new THREE.Matrix4().copy(house.matrixWorld).invert();
|
|
6393
|
+
for (const it of items) {
|
|
6394
|
+
const a = it.mesh.userData._p0 || it.mesh.geometry.attributes.position.array;
|
|
6395
|
+
tmp.m.multiplyMatrices(toHouse, it.mesh.matrixWorld);
|
|
6396
|
+
for (let k = it.v0; k < it.v1; k++) box.expandByPoint(tmp.p.set(a[k * 3], a[k * 3 + 1], a[k * 3 + 2]).applyMatrix4(tmp.m));
|
|
6397
|
+
}
|
|
6398
|
+
return [box.min.x, box.min.y, box.min.z, box.max.x, box.max.y, box.max.z];
|
|
6399
|
+
}
|
|
6384
6400
|
function maskOf(hostId, parts) {
|
|
6385
6401
|
const host = structure.byId.get(hostId);
|
|
6386
6402
|
const [u0, v0, u1, v1] = host.aabb;
|
|
@@ -6468,7 +6484,10 @@ function installDestructionBreach(K, _shared) {
|
|
|
6468
6484
|
for (const { c, part, units: units2, thick, mid } of shown) {
|
|
6469
6485
|
if (!near(c)) continue;
|
|
6470
6486
|
const centre = mask.start + (c.a + c.b) / 2, y = (c.y0 + c.y1) / 2, len = c.b - c.a, h = c.y1 - c.y0;
|
|
6471
|
-
const at = (s, dy, d, colour) =>
|
|
6487
|
+
const at = (s, dy, d, colour) => {
|
|
6488
|
+
const unit = clipToBox({ x: mask.alongU ? centre : mid, y, z: mask.alongU ? mid : centre, sx: mask.alongU ? s : d, sy: dy, sz: mask.alongU ? d : s, colour }, view.bounds);
|
|
6489
|
+
if (unit) list.push(unit);
|
|
6490
|
+
};
|
|
6472
6491
|
const base = fragmentMaterial(part.material).color.getHex();
|
|
6473
6492
|
const n = noise2(centre * 3.1, y * 2.7, 0.07);
|
|
6474
6493
|
if (units2.mortar === "concrete") {
|
|
@@ -6535,6 +6554,7 @@ function installDestructionBreach(K, _shared) {
|
|
|
6535
6554
|
units: null,
|
|
6536
6555
|
gone: 0,
|
|
6537
6556
|
pits: 0,
|
|
6557
|
+
bounds: drawnBounds(items),
|
|
6538
6558
|
chips: new Map(parts.map((id) => [id, []])),
|
|
6539
6559
|
spalls: new Map(parts.map((id) => [id, []])),
|
|
6540
6560
|
openings: /* @__PURE__ */ new Map(),
|
|
@@ -8225,11 +8245,15 @@ function createHouseScenarios(text, at = SPECIMEN_AT) {
|
|
|
8225
8245
|
return { oid: so.objectId, parts, centre };
|
|
8226
8246
|
};
|
|
8227
8247
|
const role = (p) => p.structure && p.structure.role;
|
|
8248
|
+
const listening = [];
|
|
8228
8249
|
const events = (room) => {
|
|
8229
8250
|
const list = [];
|
|
8230
|
-
room.world.on("*", (e) => list.push(e));
|
|
8251
|
+
listening.push(room.world.on("*", (e) => list.push(e)));
|
|
8231
8252
|
return list;
|
|
8232
8253
|
};
|
|
8254
|
+
const stopListening = () => {
|
|
8255
|
+
for (const off of listening.splice(0)) off?.();
|
|
8256
|
+
};
|
|
8233
8257
|
const collapsed = (list) => list.filter((e) => e.type === "collapse").flatMap((e) => e.parts.map((p) => p.id || p));
|
|
8234
8258
|
const whole = (room, oid, pid) => {
|
|
8235
8259
|
const p = room.world.part(oid, pid);
|
|
@@ -8243,7 +8267,7 @@ function createHouseScenarios(text, at = SPECIMEN_AT) {
|
|
|
8243
8267
|
const bullet = (room, oid, pid, point, energy) => {
|
|
8244
8268
|
room.world.hitPart(oid, pid, { type: "ballistic", point, direction: [0, 0, -1], energy, caliber: 9 });
|
|
8245
8269
|
};
|
|
8246
|
-
|
|
8270
|
+
const scenarios = [
|
|
8247
8271
|
{
|
|
8248
8272
|
id: "house_one_pillar",
|
|
8249
8273
|
name: text.scenarios.house_one_pillar,
|
|
@@ -8337,6 +8361,16 @@ function createHouseScenarios(text, at = SPECIMEN_AT) {
|
|
|
8337
8361
|
}
|
|
8338
8362
|
}
|
|
8339
8363
|
];
|
|
8364
|
+
return scenarios.map((scenario) => ({
|
|
8365
|
+
...scenario,
|
|
8366
|
+
run(context) {
|
|
8367
|
+
try {
|
|
8368
|
+
return scenario.run(context);
|
|
8369
|
+
} finally {
|
|
8370
|
+
stopListening();
|
|
8371
|
+
}
|
|
8372
|
+
}
|
|
8373
|
+
}));
|
|
8340
8374
|
}
|
|
8341
8375
|
|
|
8342
8376
|
// src/test-area/specimens.ts
|