@adatechnology/game-floorplan-three 0.8.0 → 0.8.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.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) => list.push({ x: mask.alongU ? centre : mid, y, z: mask.alongU ? mid : centre, sx: mask.alongU ? s : d, sy: dy, sz: mask.alongU ? d : s, 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(),