@adatechnology/game-weapons-three 0.21.6 → 0.21.7

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.
@@ -26647,7 +26647,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26647
26647
  if (partSphereMiss(lo, ld, p, maxDist)) continue;
26648
26648
  const r = rayPart(o, p, origin, d);
26649
26649
  if (!r || r.t0 < 0 || r.t0 > maxDist) continue;
26650
- if (p.st.opening && insideOpening(o, p, vec.madd(origin, d, r.t0))) continue;
26650
+ if (p.st.opening && insideOpening(o, p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
26651
+ if (p.spec.apertures && throughAperture(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
26651
26652
  if (p.st.chipped && insideChip(p, objLocal(o, vec.madd(origin, d, r.t0)))) continue;
26652
26653
  if (!best || r.t0 < best.distance) best = { object: o.id, part: p.spec.id, point: vec.madd(origin, d, r.t0), normal: r.n, distance: r.t0, pathLen: r.t1 - r.t0 };
26653
26654
  }
@@ -26919,6 +26920,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26919
26920
  const lc = toLocal(p.pos, p.q, op.center);
26920
26921
  return Math.hypot(lp[u] - lc[u], lp[v] - lc[v]) <= op.radius;
26921
26922
  };
26923
+ const throughAperture = (p, objectPoint) => {
26924
+ const [u, v] = planeAxes(p.thin);
26925
+ const lp = toLocal(p.pos, p.q, objectPoint);
26926
+ return (p.spec.apertures ?? []).some((ap) => {
26927
+ const du = lp[u] - (ap.offset?.[0] ?? 0);
26928
+ const dv = lp[v] - (ap.offset?.[1] ?? 0);
26929
+ if (Math.abs(du) > ap.size[0] / 2 || Math.abs(dv) > ap.size[1] / 2) return false;
26930
+ if (!ap.bars || ap.bars.spacing <= 0) return true;
26931
+ const along = ap.bars.axis === 0 ? du + ap.size[0] / 2 : dv + ap.size[1] / 2;
26932
+ return Math.abs(along - Math.round(along / ap.bars.spacing) * ap.bars.spacing) > ap.bars.width / 2;
26933
+ });
26934
+ };
26922
26935
  const breachAreaOf = (p, damage, blast) => damage / (p.mat.hpPerKg * p.mat.density) / Math.max(p.thickness, 5e-3) * (blast ? breachBlastFactor : 1);
26923
26936
  const localHolesOf = (p) => p.st.holes.map((h) => ({ point: toLocal(p.pos, p.q, h.point), normal: rotateVec(quat.conjugate(p.q), h.normal), diameter: h.diameter }));
26924
26937
  const unitsOf2 = (p) => p.spec.units ?? { size: [p.mat.fragmentSize?.[1] ?? 0.2, p.mat.fragmentSize?.[1] ?? 0.2, p.thickness], bond: "stack" };
@@ -28025,7 +28038,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
28025
28038
  const path = Math.min(r.t1, L) - t0;
28026
28039
  if (path < shelter.minPath) continue;
28027
28040
  const mid = vec.madd(point, d, t0 + path / 2);
28028
- const opening = p.st.opening && insideOpening(o, p, mid);
28041
+ const opening = p.st.opening && insideOpening(o, p, objLocal(o, mid));
28029
28042
  if (opening && was & FLAG_OPEN) continue;
28030
28043
  if (p.st.stripped && was & FLAG_OPEN) continue;
28031
28044
  const resistance = p.mat.hpPerKg * p.mat.density * path * (p.mat.damageScale?.shelter ?? 1);
@@ -30336,6 +30349,42 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30336
30349
  }
30337
30350
  return { ...next, capacities };
30338
30351
  }
30352
+ var planeAxes2 = (thin) => thin === 1 ? [0, 2] : [thin === 0 ? 2 : 0, 1];
30353
+ function toPartFrame(part, point) {
30354
+ const dx = point[0] - part.position[0];
30355
+ const dz = point[2] - part.position[2];
30356
+ const angle = -(part.rotation?.[1] ?? 0);
30357
+ return [dx * Math.cos(angle) + dz * Math.sin(angle), point[1] - part.position[1], -dx * Math.sin(angle) + dz * Math.cos(angle)];
30358
+ }
30359
+ function wallApertures(part, windows) {
30360
+ if (part.shape.kind !== "box") return [];
30361
+ const size = part.shape.size;
30362
+ const thin = size.indexOf(Math.min(...size));
30363
+ if (thin === 1) return [];
30364
+ const [along] = planeAxes2(thin);
30365
+ const turn2 = part.rotation?.[1] ?? 0;
30366
+ const alongU = Math.abs(Math.cos(turn2)) * size[0] + Math.abs(Math.sin(turn2)) * size[2] >= Math.abs(Math.sin(turn2)) * size[0] + Math.abs(Math.cos(turn2)) * size[2];
30367
+ return windows.map((opening2) => {
30368
+ const middle = (opening2.from + opening2.to) / 2;
30369
+ const centre2 = alongU ? [middle, (opening2.y0 + opening2.y1) / 2, part.position[2]] : [part.position[0], (opening2.y0 + opening2.y1) / 2, middle];
30370
+ const local2 = toPartFrame(part, centre2);
30371
+ return { size: [opening2.to - opening2.from, opening2.y1 - opening2.y0], offset: [local2[along], local2[1]] };
30372
+ });
30373
+ }
30374
+ function withWindowApertures(spec, openings) {
30375
+ const byWall = /* @__PURE__ */ new Map();
30376
+ for (const opening2 of openings) if (opening2.kind === "window") byWall.set(opening2.wall, [...byWall.get(opening2.wall) ?? [], opening2]);
30377
+ if (!byWall.size) return spec;
30378
+ return {
30379
+ ...spec,
30380
+ parts: spec.parts.map((part) => {
30381
+ const windows = byWall.get(part.id);
30382
+ if (!windows) return part;
30383
+ const apertures = wallApertures(part, windows);
30384
+ return apertures.length ? { ...part, apertures: [...part.apertures ?? [], ...apertures] } : part;
30385
+ })
30386
+ };
30387
+ }
30339
30388
  var RAFT_THICKNESS = 0.25;
30340
30389
  var PILE_AREA = 9;
30341
30390
  var RAFT_MARGIN = 0.15;
@@ -30434,7 +30483,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
30434
30483
  const infill = new Set(portico && slabOptions ? kept.filter((part) => part.role === "wall").map((part) => part.id) : []);
30435
30484
  const beams = new Set(parts.filter((part) => part.role === "beam" && (part.beamKind === "bond_beam" || part.slab !== void 0)).map((part) => part.id));
30436
30485
  const joints = supports.filter((s) => present.has(s.part) && present.has(s.on)).map((s) => ({ id: `${s.part}~${s.on}`, a: s.part, b: s.on, kind: s.joint, bears: s.bears === false || beams.has(s.part) && infill.has(s.on) ? false : "a_on_b" }));
30437
- const spec = { name: options.name ?? "house", parts: specs, joints, tags: ["structure", "house"] };
30486
+ const built2 = { name: options.name ?? "house", parts: specs, joints, tags: ["structure", "house"] };
30487
+ const spec = detail === "coarse" && options.windowApertures !== false ? withWindowApertures(built2, structure.openings) : built2;
30438
30488
  return onSoil(withRebar(spec, structure, options, portico, slabOptions !== void 0), structure, options);
30439
30489
  }
30440
30490
  function withRebar(spec, structure, options, portico, panelled) {
@@ -32308,7 +32358,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
32308
32358
  }
32309
32359
  var residentialTower = residentialTowerTemplate();
32310
32360
 
32311
- // ../game-floorplan-three/dist/chunk-FUZURKX2.js
32361
+ // ../game-floorplan-three/dist/chunk-RZF4G6CY.js
32312
32362
  var __defProp4 = Object.defineProperty;
32313
32363
  var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
32314
32364
  var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -33364,6 +33414,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
33364
33414
  function installHouseWindows(K, shared3) {
33365
33415
  const { EPS: EPS6, Y0, boxC, bx, cursor, pieceRecord, roomAt } = K;
33366
33416
  const FRAME_COLORS = { budget: 15856110, mid: 12830924, high: 2829875, commercial: 11844287 };
33417
+ const ALUMINIUM_PROFILE_KG_PER_M = 1.2, SILL_KG_PER_M = 6, STEEL_KG_PER_M3 = 7850, GRILLE_BAR = 0.016;
33367
33418
  const SILL_COLORS = { budget: 15131870, mid: 14277076, high: 3816770, commercial: 13225166 };
33368
33419
  function windows() {
33369
33420
  const R = shared3.ctx.r, cut = shared3.ctx.cut, C = shared3.ctx.colors, structure = R.style, fr = FRAME_COLORS[structure] || FRAME_COLORS.budget, pe_ = SILL_COLORS[structure] || SILL_COLORS.budget;
@@ -33379,7 +33430,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
33379
33430
  }
33380
33431
  const wref = R.walls.find((w) => w.floor === f && w.axis === j.axis && Math.abs((alongU ? w.v0 : w.u0) - L) < EPS6), th = wref ? wref.thickness || 0.15 : 0.15, t = 0.05, tt = th + 0.02;
33381
33432
  const bar2 = (u0, y_0, u1, y_1, mat, color2, tw = tt) => alongU ? bx(mat, u0, y0 + y_0, L - tw / 2, u1, y0 + y_1, L + tw / 2, color2) : bx(mat, L - tw / 2, y0 + y_0, u0, L + tw / 2, y0 + y_1, u1, color2);
33382
- const frame2 = pieceRecord("window_frame:" + j.id, "aluminium", null, { floor: f });
33433
+ const outside0 = !roomAt(f, alongU ? j.at : L + 0.4, alongU ? L + 0.4 : j.at) || !roomAt(f, alongU ? j.at : L - 0.4, alongU ? L - 0.4 : j.at);
33434
+ const frameMass = ALUMINIUM_PROFILE_KG_PER_M * (2 * (j.width + (yb - ya)) + j.width + (j.width > 0.9 ? yb - ya : 0)) + (outside0 ? SILL_KG_PER_M * (j.width + 0.1) : 0);
33435
+ const frame2 = pieceRecord("window_frame:" + j.id, "aluminium", null, { floor: f, mass: frameMass, aperture: { alongU, a: a + t, b: b - t, y0: y0 + ya + t, y1: y0 + yb - t } });
33383
33436
  cursor.pc = frame2;
33384
33437
  bar2(a, ya, a + t, yb, "metal", fr);
33385
33438
  bar2(b - t, ya, b, yb, "metal", fr);
@@ -33398,7 +33451,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
33398
33451
  if (alongU) bx("plaster", a - 0.05, y0 + ya - 0.04, L + (outside > 0 ? th / 2 : -th / 2 - 0.08), b + 0.05, y0 + ya, L + (outside > 0 ? th / 2 + 0.08 : -th / 2), pe_);
33399
33452
  else bx("plaster", L + (outside > 0 ? th / 2 : -th / 2 - 0.08), y0 + ya - 0.04, a - 0.05, L + (outside > 0 ? th / 2 + 0.08 : -th / 2), y0 + ya, b + 0.05, pe_);
33400
33453
  if (R.facade.grilles && !cut) {
33401
- const g = C.gate != null ? C.gate : 2763310, go = outside * (th / 2 + 0.07), n = Math.max(3, Math.round(j.width / 0.12));
33454
+ const g = C.gate != null ? C.gate : 2763310, go = outside * (th / 2 + 0.07), n = Math.max(3, Math.round(j.width / 0.12)), spacing = (j.width - 0.06) / n;
33455
+ cursor.pc = pieceRecord("window_grille:" + j.id, "steel", null, { floor: f, mass: STEEL_KG_PER_M3 * ((n + 1) * (yb - ya + 0.06) * GRILLE_BAR * GRILLE_BAR + 3 * j.width * 0.025 * 0.024), aperture: { alongU, a: a + 0.03, b: a + 0.03 + n * spacing, y0: y0 + ya - 0.03, y1: y0 + yb + 0.03, bars: { spacing, width: GRILLE_BAR } } });
33402
33456
  for (let k = 0; k <= n; k++) {
33403
33457
  const u = a + 0.03 + k * (j.width - 0.06) / n;
33404
33458
  if (alongU) bx("metal", u - 8e-3, y0 + ya - 0.03, L + go - 8e-3, u + 8e-3, y0 + yb + 0.03, L + go + 8e-3, g);
@@ -33408,6 +33462,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
33408
33462
  if (alongU) bx("metal", a, y0 + y, L + go - 0.012, b, y0 + y + 0.025, L + go + 0.012, g);
33409
33463
  else bx("metal", L + go - 0.012, y0 + y, a, L + go + 0.012, y0 + y + 0.025, b, g);
33410
33464
  }
33465
+ cursor.pc = frame2;
33411
33466
  }
33412
33467
  cursor.pc = null;
33413
33468
  }
@@ -38662,6 +38717,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
38662
38717
  else if (def.kind === "swing" || def.kind === "drawer") tagObject(def.name, [def.outer], "mdf", null, { mass: 6 });
38663
38718
  }
38664
38719
  }
38720
+ function apertureOf(sp, ap) {
38721
+ if (!ap || sp.shape.kind !== "box") return null;
38722
+ const size = sp.shape.size, depth = ap.alongU ? 2 : 0;
38723
+ if (size[depth] > Math.min(size[ap.alongU ? 0 : 2], size[1])) return null;
38724
+ const out = { size: [ap.b - ap.a, ap.y1 - ap.y0], offset: [(ap.a + ap.b) / 2 - sp.position[ap.alongU ? 0 : 2], (ap.y0 + ap.y1) / 2 - sp.position[1]] };
38725
+ if (ap.bars) out.bars = { axis: 0, spacing: ap.bars.spacing, width: ap.bars.width };
38726
+ return out;
38727
+ }
38665
38728
  function assembleStructure(r0, root) {
38666
38729
  const E0 = r0.structure || { parts: [], supports: [], levels: [], elevation: 0 }, meshes = /* @__PURE__ */ new Map(), add2 = (id, it) => {
38667
38730
  let l = meshes.get(id);
@@ -38706,7 +38769,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
38706
38769
  if (!b) continue;
38707
38770
  const vol = Math.max(1e-6, (b[3] - b[0]) * (b[4] - b[1]) * (b[5] - b[2]));
38708
38771
  const p = { id, role: "none", material: pc.mat, aabb: [b[0], b[2], b[3], b[5]], y0: b[1], y1: b[4], floor: pc.floor != null ? pc.floor : floorAtY(b[1] + 0.1), mass: pc.mass != null ? pc.mass : Math.max(0.5, vol * (DENSITY[pc.mat] || 800) * (pc.fill != null ? pc.fill : 0.15)), meshes: meshes.get(id).length, extra: true };
38709
- for (const k of ["contains", "explodes", "tags", "form", "thickness", "fill", "units"]) if (pc[k] != null) p[k] = pc[k];
38772
+ for (const k of ["contains", "explodes", "tags", "form", "thickness", "fill", "units", "aperture"]) if (pc[k] != null) p[k] = pc[k];
38710
38773
  parts.push(p);
38711
38774
  byId.set(id, p);
38712
38775
  }
@@ -38779,6 +38842,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
38779
38842
  if (!pc0) return sp;
38780
38843
  const extra = {};
38781
38844
  for (const k of ["contains", "explodes", "thickness", "fill", "tags"]) if (pc0[k] != null && sp[k] == null) extra[k] = pc0[k];
38845
+ const aperture = apertureOf(sp, pc0.aperture);
38846
+ if (aperture) extra.apertures = [aperture];
38782
38847
  return Object.keys(extra).length ? { ...sp, ...extra } : sp;
38783
38848
  });
38784
38849
  spec.parts = spec.parts.map((sp) => {
@@ -38802,7 +38867,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
38802
38867
  return sp;
38803
38868
  }
38804
38869
  });
38805
- return spec;
38870
+ const walls = new Set((E0.openings ?? []).map((op) => op.wall));
38871
+ return withWindowApertures({ ...spec, parts: spec.parts.map((sp) => walls.has(sp.id) && sp.apertures ? (({ apertures: _gone, ...rest2 }) => rest2)(sp) : sp) }, E0.openings ?? []);
38806
38872
  }
38807
38873
  };
38808
38874
  return structure;