@adatechnology/game-items-three 0.12.0 → 0.13.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.
@@ -21,6 +21,7 @@ var GameItemsThree = (() => {
21
21
  // src/index.ts
22
22
  var index_exports = {};
23
23
  __export(index_exports, {
24
+ CUP_FLOOR_SHARE: () => CUP_FLOOR_SHARE,
24
25
  DESTRUCTION_MATERIAL_BY_TAG: () => DESTRUCTION_MATERIAL_BY_TAG,
25
26
  FINDS_TABLE_ID: () => FINDS_TABLE_ID,
26
27
  HUMAN_HEIGHT: () => HUMAN_HEIGHT,
@@ -40,6 +41,7 @@ var GameItemsThree = (() => {
40
41
  SHIPPED_MODELS: () => SHIPPED_MODELS,
41
42
  SHOWCASE_PREFIX: () => SHOWCASE_PREFIX,
42
43
  SHOWCASE_STAND_ID: () => SHOWCASE_STAND_ID,
44
+ WASH_NAME: () => WASH_NAME,
43
45
  WEAR_AMOUNT: () => WEAR_AMOUNT,
44
46
  WEAR_TAGS: () => WEAR_TAGS,
45
47
  WEAR_TARGET: () => WEAR_TARGET,
@@ -70,12 +72,15 @@ var GameItemsThree = (() => {
70
72
  itemOpening: () => itemOpening,
71
73
  itemThumbnail: () => itemThumbnail,
72
74
  itemThumbnailSvg: () => itemThumbnailSvg,
75
+ itemVessel: () => itemVessel,
73
76
  listItemModels: () => listItemModels,
74
77
  makeupSpec: () => makeupSpec,
75
78
  mergeItem: () => mergeItem,
76
79
  openItem: () => openItem,
77
80
  registerItemModel: () => registerItemModel,
78
81
  renderItemThumbnail: () => renderItemThumbnail,
82
+ setItemDirt: () => setItemDirt,
83
+ setItemFoam: () => setItemFoam,
79
84
  setOpeningContents: () => setOpeningContents,
80
85
  setWear: () => setWear,
81
86
  shade: () => shade,
@@ -2201,13 +2206,16 @@ var GameItemsThree = (() => {
2201
2206
  for (const u of Object.values(uniforms)) if (isTexture(u?.value)) out.add(u.value);
2202
2207
  }
2203
2208
  }
2209
+ var isInstanced = (o) => o.isInstancedMesh === true;
2204
2210
  function collect(roots) {
2205
2211
  const geometries = /* @__PURE__ */ new Set();
2206
2212
  const materials = /* @__PURE__ */ new Set();
2207
2213
  const textures = /* @__PURE__ */ new Set();
2208
2214
  const skeletons = /* @__PURE__ */ new Set();
2215
+ const instanced = /* @__PURE__ */ new Set();
2209
2216
  for (const root of roots) {
2210
2217
  root.traverse((object2) => {
2218
+ if (isInstanced(object2)) instanced.add(object2);
2211
2219
  const o = object2;
2212
2220
  if (o.geometry && typeof o.geometry.dispose === "function") geometries.add(o.geometry);
2213
2221
  if (o.skeleton && typeof o.skeleton.dispose === "function") skeletons.add(o.skeleton);
@@ -2219,7 +2227,7 @@ var GameItemsThree = (() => {
2219
2227
  }
2220
2228
  });
2221
2229
  }
2222
- return { geometries, materials, textures, skeletons };
2230
+ return { geometries, materials, textures, skeletons, instanced };
2223
2231
  }
2224
2232
  var marked = /* @__PURE__ */ new WeakSet();
2225
2233
  function markShared(...resources) {
@@ -2268,6 +2276,7 @@ var GameItemsThree = (() => {
2268
2276
  report.textures++;
2269
2277
  }
2270
2278
  for (const s of found.skeletons) s.dispose();
2279
+ for (const mesh2 of found.instanced) mesh2.dispose();
2271
2280
  return report;
2272
2281
  }
2273
2282
  function discardObject3D(objects, options = {}) {
@@ -2357,7 +2366,7 @@ var GameItemsThree = (() => {
2357
2366
  }
2358
2367
 
2359
2368
  // src/wear.ts
2360
- var WEAR_TARGET = { food: 6122286, metal: 8011293, wood: 4141862, cloth: 4866099, plastic: 7038294, paper: 9075282, glass: 5591098 };
2369
+ var WEAR_TARGET = { food: 6122286, metal: 8011293, wood: 4141862, cloth: 4866099, plastic: 7038294, paper: 9075282, glass: 5591098, rubber: 4860452 };
2361
2370
  var WEAR_AMOUNT = [0, 0.3, 0.62];
2362
2371
  var hexToRgb = (hex3) => [(hex3 >> 16 & 255) / 255, (hex3 >> 8 & 255) / 255, (hex3 & 255) / 255];
2363
2372
  var dataOf = (material) => {
@@ -2490,9 +2499,11 @@ var GameItemsThree = (() => {
2490
2499
  const { k, w, h, d } = c;
2491
2500
  return k.G(k.mesh(k.cyl(0.5, 0.35, h, seg(c, 16)), k.plastic(c.color), [0, 0, 0], [0, 0, 0], [w, 1, d]));
2492
2501
  };
2502
+ var CUP_FLOOR_SHARE = 0.06;
2493
2503
  var cup = (c) => {
2494
2504
  const { k, w, h, d } = c;
2495
- const profile = [[0, -h / 2], [0.38, -h / 2], [0.5, h / 2], [0.44, h / 2], [0.33, -h / 2 + h * 0.06], [0, -h / 2 + h * 0.06]];
2505
+ const floor = -h / 2 + h * CUP_FLOOR_SHARE;
2506
+ const profile = [[0, -h / 2], [0.38, -h / 2], [0.5, h / 2], [0.44, h / 2], [0.33, floor], [0, floor]];
2496
2507
  return k.G(k.mesh(k.lathe(profile, seg(c, 14)), k.plastic(c.color), [0, 0, 0], [0, 0, 0], [w, 1, d]));
2497
2508
  };
2498
2509
  var tube = (c) => {
@@ -3612,6 +3623,7 @@ var GameItemsThree = (() => {
3612
3623
  paper: "paper",
3613
3624
  plastic: "plastic",
3614
3625
  cloth: "fabric",
3626
+ rubber: "rubber",
3615
3627
  food: "flesh_fruit"
3616
3628
  };
3617
3629
  var FAMILIES = destruction_default.families;
@@ -3647,6 +3659,16 @@ var GameItemsThree = (() => {
3647
3659
  };
3648
3660
  return { container, liquid: contents.liquid, liters };
3649
3661
  }
3662
+ var VESSEL_FLOORS = { cup: CUP_FLOOR_SHARE };
3663
+ function itemVessel(subject) {
3664
+ const capacity = subject.capacityLiters;
3665
+ const floor = subject.shape === void 0 ? void 0 : VESSEL_FLOORS[subject.shape];
3666
+ if (capacity === void 0 || !(capacity > 0) || floor === void 0) return void 0;
3667
+ const [width, height, depth] = subject.size;
3668
+ const radius = Math.min(width, depth) / 2 * WALL_SHARE;
3669
+ const container = { capacity, liters: 0, shape: { kind: "cylinder", radius, height: height * WALL_SHARE }, opening: radius, closed: false };
3670
+ return { container, offset: [0, height * floor, 0] };
3671
+ }
3650
3672
  function tagOf(mesh2) {
3651
3673
  const material = Array.isArray(mesh2.material) ? mesh2.material[0] : mesh2.material;
3652
3674
  const tag = material?.userData?.tag;
@@ -6263,6 +6285,16 @@ var GameItemsThree = (() => {
6263
6285
  0.553
6264
6286
  ],
6265
6287
  scale: 0.092308
6288
+ },
6289
+ {
6290
+ id: "plunger",
6291
+ teamId: "desentupidor",
6292
+ teamBox: [
6293
+ 1.4,
6294
+ 5.5,
6295
+ 1.4
6296
+ ],
6297
+ scale: 0.1
6266
6298
  }
6267
6299
  ];
6268
6300
 
@@ -7444,6 +7476,16 @@ var GameItemsThree = (() => {
7444
7476
  return G(bottle2, label, stripe, cap, nozzle);
7445
7477
  };
7446
7478
 
7479
+ // src/models/plunger.ts
7480
+ var plunger = ({ mesh: mesh2, cyl, G, M, wood }) => {
7481
+ const rubber = M(11545120, "rubber", { roughness: 0.75 });
7482
+ const cup2 = mesh2(cyl(0.3, 0.7, 0.75, 16), rubber, [0, 0.455, 0]);
7483
+ const lip = mesh2(cyl(0.7, 0.7, 0.08, 16), M(9314841, "rubber", { roughness: 0.8 }), [0, 0.04, 0]);
7484
+ const neck = mesh2(cyl(0.2, 0.3, 0.3, 12), rubber, [0, 0.98, 0]);
7485
+ const handle = mesh2(cyl(0.15, 0.15, 4.4, 10), wood(10122312), [0, 3.3, 0]);
7486
+ return G(cup2, lip, neck, handle);
7487
+ };
7488
+
7447
7489
  // src/models/can-opener.ts
7448
7490
  var canOpener = ({ mesh: mesh2, bx, cyl, G, metal, plastic }) => {
7449
7491
  const steel = metal(11120050);
@@ -10120,7 +10162,8 @@ var GameItemsThree = (() => {
10120
10162
  tshirt,
10121
10163
  watering_can: wateringCan,
10122
10164
  wheelbarrow,
10123
- windup_alarm_clock: windupAlarmClock
10165
+ windup_alarm_clock: windupAlarmClock,
10166
+ plunger
10124
10167
  };
10125
10168
  var SHIPPED_MODELS = models_default.map((entry2) => {
10126
10169
  const builder = BUILDERS[entry2.id];
@@ -10190,6 +10233,153 @@ var GameItemsThree = (() => {
10190
10233
  return { root, kind, ...shape ? { shape } : {}, size: item.size, materials };
10191
10234
  }
10192
10235
 
10236
+ // src/wash.ts
10237
+ var WASH_NAME = "item_wash";
10238
+ var STAIN_LIFT = 15e-4;
10239
+ var SPOTS = [
10240
+ [0, 0],
10241
+ [0.5, 0],
10242
+ [0.155, 0.476],
10243
+ [-0.405, 0.294],
10244
+ [-0.405, -0.294],
10245
+ [0.155, -0.476]
10246
+ ];
10247
+ var STAIN_RADIUS = 0.12;
10248
+ var BUBBLE_RADIUS = 0.1;
10249
+ var BUBBLE_CLUSTER = [
10250
+ [0, 0, 1],
10251
+ [1.1, 0.3, 0.7],
10252
+ [-0.6, 0.9, 0.6]
10253
+ ];
10254
+ var STAIN_COLORS = [8014370, 10903070, 6175260, 12088362, 9067050, 10243866];
10255
+ var FOAM_COLOR = 16054008;
10256
+ var overlays = /* @__PURE__ */ new WeakMap();
10257
+ var isOwnMesh = (mesh2) => !mesh2.userData.destructionDebris && mesh2.parent?.name !== WASH_NAME;
10258
+ function localBox2(T2, root) {
10259
+ root.updateMatrixWorld(true);
10260
+ const toRoot = new T2.Matrix4().copy(root.matrixWorld).invert();
10261
+ const box4 = new T2.Box3();
10262
+ const part = new T2.Box3();
10263
+ const m = new T2.Matrix4();
10264
+ root.traverse((o) => {
10265
+ const mesh2 = o;
10266
+ if (!mesh2.isMesh || !isOwnMesh(mesh2)) return;
10267
+ if (!mesh2.geometry.boundingBox) mesh2.geometry.computeBoundingBox();
10268
+ const bounds = mesh2.geometry.boundingBox;
10269
+ if (!bounds) return;
10270
+ part.copy(bounds).applyMatrix4(m.multiplyMatrices(toRoot, mesh2.matrixWorld));
10271
+ box4.union(part);
10272
+ });
10273
+ return box4;
10274
+ }
10275
+ function spotsOn(T2, root, box4) {
10276
+ const meshes = [];
10277
+ root.traverse((o) => {
10278
+ const mesh2 = o;
10279
+ if (mesh2.isMesh && isOwnMesh(mesh2)) meshes.push(mesh2);
10280
+ });
10281
+ const toRoot = new T2.Matrix4().copy(root.matrixWorld).invert();
10282
+ const down2 = new T2.Vector3(0, -1, 0).transformDirection(root.matrixWorld);
10283
+ const ray = new T2.Raycaster();
10284
+ const centre = box4.getCenter(new T2.Vector3());
10285
+ const half = box4.getSize(new T2.Vector3()).multiplyScalar(0.5);
10286
+ const above = box4.max.y + half.y + 0.01;
10287
+ const spots = [];
10288
+ for (const [x, z] of SPOTS) {
10289
+ const origin = new T2.Vector3(centre.x + x * half.x, above, centre.z + z * half.z).applyMatrix4(root.matrixWorld);
10290
+ ray.set(origin, down2);
10291
+ const hit = ray.intersectObjects(meshes, false)[0];
10292
+ if (!hit?.face) continue;
10293
+ const normal = hit.face.normal.clone().transformDirection(hit.object.matrixWorld);
10294
+ if (normal.dot(down2) > 0) normal.negate();
10295
+ const point = hit.point.clone().addScaledVector(normal, STAIN_LIFT).applyMatrix4(toRoot);
10296
+ spots.push({ point, normal: normal.transformDirection(toRoot) });
10297
+ }
10298
+ return spots;
10299
+ }
10300
+ function layerOf(T2, geometry, material, bases, name) {
10301
+ const mesh2 = new T2.InstancedMesh(geometry, material, bases.length);
10302
+ mesh2.name = name;
10303
+ bases.forEach((base2, i) => mesh2.setMatrixAt(i, base2));
10304
+ mesh2.computeBoundingSphere();
10305
+ mesh2.visible = false;
10306
+ mesh2.userData.destructionDebris = true;
10307
+ mesh2.raycast = () => {
10308
+ };
10309
+ return { mesh: mesh2, bases, value: 0 };
10310
+ }
10311
+ function blotGeometry(T2) {
10312
+ const geometry = new T2.CircleGeometry(1, 9);
10313
+ const position = geometry.getAttribute("position");
10314
+ for (let i = 1; i < position.count; i++) {
10315
+ const wobble = 0.75 + 0.25 * Math.abs(Math.sin(i * 2.3));
10316
+ position.setXY(i, position.getX(i) * wobble, position.getY(i) * wobble);
10317
+ }
10318
+ return geometry.rotateX(-Math.PI / 2);
10319
+ }
10320
+ function createOverlay(T2, root) {
10321
+ const scratch = { matrix: new T2.Matrix4(), scale: new T2.Matrix4() };
10322
+ const box4 = localBox2(T2, root);
10323
+ const spots = box4.isEmpty() ? [] : spotsOn(T2, root, box4);
10324
+ if (spots.length === 0) return { dirt: void 0, foam: void 0, scratch };
10325
+ const size = box4.getSize(new T2.Vector3());
10326
+ const small = Math.min(size.x, size.z) / 2;
10327
+ const up = new T2.Vector3(0, 1, 0);
10328
+ const turn = (normal, spin) => new T2.Quaternion().setFromUnitVectors(up, normal).multiply(new T2.Quaternion().setFromAxisAngle(up, spin));
10329
+ const stains = spots.map((spot, i) => {
10330
+ const r = small * STAIN_RADIUS;
10331
+ return new T2.Matrix4().compose(spot.point, turn(spot.normal, i * 1.7), new T2.Vector3(r, 1, r * (0.65 + 0.35 * (i * 0.37 % 1))));
10332
+ });
10333
+ const bubbleRadius = small * BUBBLE_RADIUS;
10334
+ const bubbles = spots.flatMap((spot, i) => {
10335
+ const q = turn(spot.normal, i * 1.1);
10336
+ return BUBBLE_CLUSTER.map(([along2, across2, share]) => {
10337
+ const r = bubbleRadius * share;
10338
+ const at2 = new T2.Vector3(along2 * bubbleRadius, r * 0.4 - STAIN_LIFT, across2 * bubbleRadius).applyQuaternion(q).add(spot.point);
10339
+ return new T2.Matrix4().compose(at2, q, new T2.Vector3(r, r, r));
10340
+ });
10341
+ });
10342
+ const group = new T2.Group();
10343
+ group.name = WASH_NAME;
10344
+ group.userData.destructionIgnore = true;
10345
+ const dirt = layerOf(T2, blotGeometry(T2), new T2.MeshStandardMaterial({ roughness: 0.95, metalness: 0 }), stains, "item_dirt");
10346
+ stains.forEach((_, i) => dirt.mesh.setColorAt(i, new T2.Color(STAIN_COLORS[i % STAIN_COLORS.length])));
10347
+ const foam = layerOf(T2, new T2.SphereGeometry(1, 8, 6), new T2.MeshStandardMaterial({ color: FOAM_COLOR, roughness: 0.55, metalness: 0 }), bubbles, "item_foam");
10348
+ group.add(dirt.mesh, foam.mesh);
10349
+ root.add(group);
10350
+ return { dirt, foam, scratch };
10351
+ }
10352
+ function overlayOf(T2, root) {
10353
+ const found = overlays.get(root);
10354
+ if (found) return found;
10355
+ const created = createOverlay(T2, root);
10356
+ overlays.set(root, created);
10357
+ return created;
10358
+ }
10359
+ function showLayer(layer, value, scratch) {
10360
+ if (!layer) return;
10361
+ const share = Math.max(0, Math.min(1, value));
10362
+ if (share === layer.value) return;
10363
+ layer.value = share;
10364
+ layer.mesh.visible = share > 0;
10365
+ if (share === 0) return;
10366
+ const grow = 0.45 + 0.55 * share;
10367
+ scratch.scale.makeScale(grow, grow, grow);
10368
+ layer.bases.forEach((base2, i) => {
10369
+ scratch.matrix.copy(base2).multiply(scratch.scale);
10370
+ layer.mesh.setMatrixAt(i, scratch.matrix);
10371
+ });
10372
+ layer.mesh.instanceMatrix.needsUpdate = true;
10373
+ }
10374
+ function setItemDirt(T2, root, dirt) {
10375
+ const overlay = overlayOf(T2, root);
10376
+ showLayer(overlay.dirt, dirt, overlay.scratch);
10377
+ }
10378
+ function setItemFoam(T2, root, amount) {
10379
+ const overlay = overlayOf(T2, root);
10380
+ showLayer(overlay.foam, amount, overlay.scratch);
10381
+ }
10382
+
10193
10383
  // src/contained.ts
10194
10384
  function createContainedItemModel(items, options = {}) {
10195
10385
  const byId = /* @__PURE__ */ new Map();
@@ -10199,6 +10389,8 @@ var GameItemsThree = (() => {
10199
10389
  if (!item) return null;
10200
10390
  const model = buildItem(T2, item, options);
10201
10391
  model.root.userData.item = { id: item.id, kind: model.kind };
10392
+ const dirt = stack.data?.["dirt"];
10393
+ if (typeof dirt === "number" && dirt > 0) setItemDirt(T2, model.root, dirt);
10202
10394
  return model.root;
10203
10395
  };
10204
10396
  }
@@ -13062,7 +13254,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13062
13254
  };
13063
13255
  var JOINT_GAP = 1e-4;
13064
13256
  var MIN_BEARING_SHARE = 0.25;
13065
- var unsupportedCells = (cells, thin, dims, standing) => {
13257
+ var unsupportedCells = (cells, thin, dims, standing, bears) => {
13066
13258
  if (thin === 1) return unheldSlabCells(cells, dims, standing);
13067
13259
  const [u, v] = planeAxes(thin);
13068
13260
  const bottom = -dims[v] / 2;
@@ -13080,6 +13272,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13080
13272
  const held = /* @__PURE__ */ new Set();
13081
13273
  const queue = [];
13082
13274
  for (const i of rows.get(0) ?? []) {
13275
+ if (bears && !bears(i)) continue;
13083
13276
  held.add(i);
13084
13277
  queue.push(i);
13085
13278
  }
@@ -14434,19 +14627,31 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
14434
14627
  var clampNumber = (v, a, b) => Math.max(a, Math.min(b, v));
14435
14628
  var settlementAt = (settlement, point) => {
14436
14629
  const d = [settlement.to[0] - settlement.from[0], settlement.to[1] - settlement.from[1], settlement.to[2] - settlement.from[2]];
14630
+ const px = point[0] - settlement.from[0];
14631
+ const py = point[1] - settlement.from[1];
14632
+ const pz = point[2] - settlement.from[2];
14437
14633
  const length2 = d[0] * d[0] + d[1] * d[1] + d[2] * d[2];
14438
- const t = length2 > 0 ? clampNumber(((point[0] - settlement.from[0]) * d[0] + (point[1] - settlement.from[1]) * d[1] + (point[2] - settlement.from[2]) * d[2]) / length2, 0, 1) : 0;
14634
+ const along2 = length2 > 0 ? (px * d[0] + py * d[1] + pz * d[2]) / length2 : 0;
14635
+ const t = clampNumber(along2, 0, 1);
14439
14636
  const drops = settlement.drop;
14440
14637
  if (drops.length === 0) return 0;
14441
14638
  const at2 = t * (drops.length - 1);
14442
14639
  const i = Math.floor(at2);
14443
14640
  const j = Math.min(drops.length - 1, i + 1);
14444
- return drops[i] + (drops[j] - drops[i]) * (at2 - i);
14641
+ const f = at2 - i;
14642
+ const drop = drops[i] + (drops[j] - drops[i]) * f;
14643
+ const turn = settlement.turn;
14644
+ if (!turn || turn.length !== drops.length) return drop;
14645
+ const a = turn[i];
14646
+ const b = turn[j];
14647
+ const armX = px - d[0] * along2;
14648
+ const armZ = pz - d[2] * along2;
14649
+ return drop - ((a[2] + (b[2] - a[2]) * f) * armX - (a[0] + (b[0] - a[0]) * f) * armZ);
14445
14650
  };
14446
14651
  var mergeSettlement = (old, next) => {
14447
14652
  if (!old) return next;
14448
14653
  const same = old.from.every((v, k) => Math.abs(v - next.from[k]) < 1e-6) && old.to.every((v, k) => Math.abs(v - next.to[k]) < 1e-6);
14449
- if (same && old.drop.length === next.drop.length) return { from: old.from, to: old.to, drop: old.drop.map((v, k) => Math.max(v, next.drop[k])) };
14654
+ if (same && old.drop.length === next.drop.length && !old.turn && !next.turn) return { from: old.from, to: old.to, drop: old.drop.map((v, k) => Math.max(v, next.drop[k])) };
14450
14655
  const mean = (line) => line.drop.reduce((sum, v) => sum + v, 0) / Math.max(1, line.drop.length);
14451
14656
  return mean(old) >= mean(next) ? old : next;
14452
14657
  };
@@ -15178,7 +15383,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15178
15383
  tearJoules: 80
15179
15384
  }
15180
15385
  },
15181
- failureMPa: 40
15386
+ failureMPa: 40,
15387
+ elastic: {
15388
+ alongGPa: 6.96,
15389
+ shearGPa: 0.44
15390
+ }
15182
15391
  },
15183
15392
  {
15184
15393
  id: "mdf",
@@ -15225,7 +15434,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15225
15434
  tearJoules: 20
15226
15435
  }
15227
15436
  },
15228
- failureMPa: 25
15437
+ failureMPa: 25,
15438
+ elastic: {
15439
+ alongGPa: 3,
15440
+ shearGPa: 0.8
15441
+ }
15229
15442
  },
15230
15443
  {
15231
15444
  id: "glass",
@@ -16766,17 +16979,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16766
16979
  const index = shape.placeOf(i, j);
16767
16980
  k[index] = k[index] + value;
16768
16981
  }
16769
- function halfQuadratic(shape, k, x) {
16982
+ function multiply2(shape, k, x, out) {
16770
16983
  const { n, start, rows } = shape;
16771
- let total = 0;
16984
+ for (let j = 0; j < n; j++) out[j] = k[j] * x[j];
16772
16985
  for (let j = 0; j < n; j++) {
16773
16986
  const xj = x[j];
16774
- if (xj === 0) continue;
16775
- let column = 0.5 * k[j] * xj;
16776
- for (let p = start[j]; p < start[j + 1]; p++) column += k[n + p] * x[rows[p]];
16777
- total += xj * column;
16987
+ for (let p = start[j]; p < start[j + 1]; p++) {
16988
+ const i = rows[p];
16989
+ const value = k[n + p];
16990
+ out[i] = out[i] + value * xj;
16991
+ out[j] = out[j] + value * x[i];
16992
+ }
16778
16993
  }
16779
- return total;
16780
16994
  }
16781
16995
  function factor(shape, k, from, to) {
16782
16996
  const { n, start, rows, beforeStart, before } = shape;
@@ -16830,7 +17044,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16830
17044
  placeOf: (i, j) => placeOf(shape, i, j),
16831
17045
  factor: (k, from, to) => factor(shape, k, from, to),
16832
17046
  substitute: (k, f) => substitute(shape, k, f),
16833
- halfQuadratic: (k, x) => halfQuadratic(shape, k, x)
17047
+ multiply: (k, x, out) => multiply2(shape, k, x, out)
16834
17048
  };
16835
17049
  };
16836
17050
  function hullOf(points) {
@@ -17018,14 +17232,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17018
17232
  const delta = new Float64Array(n);
17019
17233
  for (let i = 0; i < n; i++) delta[i] = after.u[i] - before.u[i];
17020
17234
  for (const beam of beams.values()) if (!after.standing.has(beam.part.id)) for (const node of beam.nodes) for (const dof of dofsOf(node)) delta[dof] = 0;
17021
- const potential = (x) => {
17022
- let height = 0;
17023
- for (let i = 0; i < n; i++) height += after.load[i] * x[i];
17024
- return frame2.shape.halfQuadratic(after.structure, x) - height;
17025
- };
17026
- const had = new Float64Array(n);
17027
- for (let i = 0; i < n; i++) had[i] = after.u[i] - delta[i];
17028
- released = Math.max(0, potential(had) - potential(after.u));
17235
+ const d = new Float64Array(n);
17236
+ for (let i = 0; i < n; i++) d[i] = -delta[i];
17237
+ const kd = new Float64Array(n);
17238
+ frame2.shape.multiply(after.structure, d, kd);
17239
+ const ku = new Float64Array(n);
17240
+ frame2.shape.multiply(after.structure, after.u, ku);
17241
+ let change = 0;
17242
+ for (let i = 0; i < n; i++) change += d[i] * (0.5 * kd[i] + (ku[i] - after.load[i]));
17243
+ released = Math.max(0, change);
17029
17244
  spin = spinOf({ frame: frame2, after, delta, released, centre: allCentre, mass: all, floor, g });
17030
17245
  }
17031
17246
  return {
@@ -17049,12 +17264,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17049
17264
  const from = vec.madd(beam.part.position, beam.axis, -beam.length / 2);
17050
17265
  const to = vec.madd(beam.part.position, beam.axis, beam.length / 2);
17051
17266
  const drop = [];
17267
+ const turn = [];
17052
17268
  for (let i = 0; i < SAG_STATIONS; i++) {
17053
17269
  const point = vec.madd(from, beam.axis, beam.length * i / (SAG_STATIONS - 1));
17054
17270
  const node = carrier ? carrier.node : nearest(beam, point);
17055
17271
  drop.push(-moved(after, { part: id, node, arm: vec.sub(point, nodes[node].at), mass: 0 })[1]);
17272
+ const base2 = order2[node] * 6;
17273
+ turn.push([after.u[base2 + 3], after.u[base2 + 4], after.u[base2 + 5]]);
17056
17274
  }
17057
- return { from, to, drop };
17275
+ return { from, to, drop, turn };
17058
17276
  }
17059
17277
  };
17060
17278
  }
@@ -19253,6 +19471,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19253
19471
  } else emit({ ...base2(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
19254
19472
  debris(o, p, p.mat.breakDebris, worldCenter, [0, 1, 0], 14, 2, src);
19255
19473
  if (p.spec.reinforcement) exposeRebar(o, p, src);
19474
+ dropOverOpening(o, p, src);
19256
19475
  };
19257
19476
  const distort = (o, q, beta, at2, toward, src) => {
19258
19477
  const prior = q.rt.distortion ?? 0;
@@ -20494,7 +20713,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20494
20713
  const faceArea = (cell) => cell.size[u] * cell.size[v];
20495
20714
  const total = cells.reduce((sum, cell) => sum + faceArea(cell), 0) || 1;
20496
20715
  const shape = p.spec.units ? "chunk" : FRAGMENT_SHAPE[p.mat.fracture] ?? "chunk";
20497
- const laid = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
20716
+ const laid2 = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
20498
20717
  const pieces = shape === "shard" && bondedPlate(o, p) ? cells.flatMap((cell) => shardsOfCell(cell, u, v)) : cells;
20499
20718
  return pieces.map((cell, i) => {
20500
20719
  const cw = toWorld(c, q, cell.center);
@@ -20503,7 +20722,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20503
20722
  const k = speed * (0.6 + 0.8 * rnd());
20504
20723
  const marks = marksInBox(cell.center, cell.size, void 0, holes);
20505
20724
  const size = [cell.size[0], cell.size[1], cell.size[2]];
20506
- if (laid) for (const a of [u, v]) size[a] = Math.max(size[a] * MIN_UNIT_SHARE, size[a] - MORTAR_JOINT);
20725
+ if (laid2) for (const a of [u, v]) size[a] = Math.max(size[a] * MIN_UNIT_SHARE, size[a] - MORTAR_JOINT);
20507
20726
  return {
20508
20727
  id: `${p.spec.id}#${tag}${i}`,
20509
20728
  part: p.spec.id,
@@ -20516,7 +20735,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20516
20735
  angularVelocity: bornSpin(cell.size, 8, rnd),
20517
20736
  mass: mass * faceArea(cell) / total,
20518
20737
  ...marks.length > 0 ? { marks } : {},
20519
- ...inner && laid ? { unit: true } : inner ? { inner } : {}
20738
+ ...inner && laid2 ? { unit: true } : inner ? { inner } : {}
20520
20739
  };
20521
20740
  });
20522
20741
  };
@@ -20927,7 +21146,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20927
21146
  if (p.st.stripped) bars = [...bars, ...stirrups];
20928
21147
  else for (const box4 of [...p.st.chipped ?? [], ...p.rt.bared ?? []]) bars.push(...clipBarsToVolume(stirrups, box4.center, box4.size));
20929
21148
  }
20930
- emit({ ...base2(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
21149
+ emit({ ...base2(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, belowCut(p, bars)) });
21150
+ };
21151
+ const belowCut = (p, bars) => {
21152
+ const cut = p.rt.cutThrough;
21153
+ if (cut === void 0) return bars.map(([a, b]) => [a, b]);
21154
+ const height = (x) => p.pos[1] + rotateVec(p.q, x)[1];
21155
+ return bars.flatMap(([a, b]) => {
21156
+ const ha = height(a) - cut, hb = height(b) - cut;
21157
+ if (ha <= 0 && hb <= 0) return [[a, b]];
21158
+ if (ha > 0 && hb > 0) return [];
21159
+ const at2 = vec.add(a, vec.scale(vec.sub(b, a), ha / (ha - hb)));
21160
+ return [ha <= 0 ? [a, at2] : [at2, b]];
21161
+ });
20931
21162
  };
20932
21163
  const openBreach = (o, p, center, total, energy, dir, src) => {
20933
21164
  const [u, v] = planeAxes(p.thin);
@@ -20956,6 +21187,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20956
21187
  setStage(o, p, 2, { opening: { center: worldCenter, radius }, fragments }, src);
20957
21188
  debris(o, p, p.mat.breakDebris, worldCenter, vec.scale(dir ?? [0, 1, 0], -1), 14, 3, src);
20958
21189
  dropUnsupported(o, p, src);
21190
+ dropOverOpening(o, p, src);
20959
21191
  const reinforcement = p.spec.reinforcement;
20960
21192
  if (reinforcement) exposeRebar(o, p, src);
20961
21193
  if (p.structural) solveStructure(o);
@@ -21181,6 +21413,28 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21181
21413
  }
21182
21414
  return false;
21183
21415
  };
21416
+ const bedOverHoles = (o, p, grid) => {
21417
+ const bases = (o.byPart.get(p.spec.id) ?? []).filter((j) => j.bears === "a_on_b" && j.spec.a === p.spec.id && !j.st.open).map((j) => o.parts[j.ib]).filter((q) => !!q.st.opening);
21418
+ if (bases.length === 0) return void 0;
21419
+ const [, v] = planeAxes(p.thin);
21420
+ const bed = [0, 0, 0];
21421
+ return (i) => {
21422
+ const cell = grid[i];
21423
+ bed[0] = cell.center[0];
21424
+ bed[1] = cell.center[1];
21425
+ bed[2] = cell.center[2];
21426
+ bed[v] = cell.center[v] - cell.size[v] / 2;
21427
+ const at2 = toWorld(p.pos, p.q, bed);
21428
+ return !bases.some((q) => insideOpening(o, q, at2));
21429
+ };
21430
+ };
21431
+ const dropOverOpening = (o, q, src) => {
21432
+ for (const j of o.byPart.get(q.spec.id) ?? []) {
21433
+ if (j.bears !== "a_on_b" || j.spec.b !== q.spec.id || j.st.open) continue;
21434
+ const p = o.parts[j.ia];
21435
+ if (p.spec.units && !isLost(p)) dropUnsupported(o, p, src);
21436
+ }
21437
+ };
21184
21438
  const dropUnsupported = (o, p, src) => {
21185
21439
  var _a, _b;
21186
21440
  if (!p.spec.units || p.spec.units.mortar === p.spec.material || p.st.stripped || isLost(p)) return 0;
@@ -21190,7 +21444,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21190
21444
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
21191
21445
  const opened = (cell) => !!op && !!p.st.opening && Math.hypot(cell.center[u] - op[u], cell.center[v] - op[v]) <= p.st.opening.radius;
21192
21446
  const castHere = castCells(p);
21193
- const loose = wedgedUnder(o, p, unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !opened(grid[i]))).filter((i) => !castHere.has(i));
21447
+ const loose = wedgedUnder(o, p, unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !opened(grid[i]), bedOverHoles(o, p, grid))).filter((i) => !castHere.has(i));
21194
21448
  if (loose.length === 0) return 0;
21195
21449
  for (const i of loose) worn[i] = -1;
21196
21450
  const fallen = loose.map((i) => grid[i]);
@@ -21356,7 +21610,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21356
21610
  const cell = grid[i];
21357
21611
  return vec.add(p.pos, rotateVec(p.q, cell.center))[1] - (Math.abs(ax[0]) * cell.size[0] + Math.abs(ax[1]) * cell.size[1] + Math.abs(ax[2]) * cell.size[2]) / 2;
21358
21612
  }));
21359
- knockOutUnits(o, p, wp, 0, above, src, [0, -1, 0], 0, { point: [p.pos[0], floor, p.pos[2]], normal: [0, 1, 0] });
21613
+ p.rt.cutThrough = floor;
21614
+ const severed = { point: toWorld(o.st.position, o.st.rotation, [p.pos[0], floor, p.pos[2]]), normal: rotateVec(o.st.rotation, [0, 1, 0]) };
21615
+ knockOutUnits(o, p, wp, 0, above, src, [0, -1, 0], 0, severed);
21616
+ exposeRebar(o, p, src);
21360
21617
  };
21361
21618
  const giveAtCut = (o, p, src, cut) => {
21362
21619
  if (!p.spec.reinforcement || !p.spec.units || !p.st.chipped?.length || sectionLoss(p) <= 0) return false;
@@ -37276,6 +37533,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37276
37533
  material: "glass",
37277
37534
  thickness: 3e-3
37278
37535
  }
37536
+ ],
37537
+ container: {
37538
+ capacityLiters: 0.3
37539
+ },
37540
+ estimated: [
37541
+ "container"
37279
37542
  ]
37280
37543
  },
37281
37544
  {
@@ -37527,8 +37790,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37527
37790
  }
37528
37791
  ],
37529
37792
  estimated: [
37530
- "parts"
37531
- ]
37793
+ "parts",
37794
+ "consumable"
37795
+ ],
37796
+ consumable: {
37797
+ form: "liquid",
37798
+ unit: "ml",
37799
+ amount: 450,
37800
+ dose: 5,
37801
+ emptyKg: 0.03,
37802
+ density: 1.03
37803
+ }
37532
37804
  },
37533
37805
  {
37534
37806
  id: "bleach",
@@ -39018,8 +39290,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
39018
39290
  thickness: 2e-3
39019
39291
  }
39020
39292
  ],
39293
+ container: {
39294
+ capacityLiters: 0.35
39295
+ },
39021
39296
  estimated: [
39022
- "parts"
39297
+ "parts",
39298
+ "container"
39023
39299
  ]
39024
39300
  },
39025
39301
  {
@@ -39166,6 +39442,41 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
39166
39442
  },
39167
39443
  weapon: "brass_knuckles",
39168
39444
  model: "brass_knuckles"
39445
+ },
39446
+ {
39447
+ id: "plunger",
39448
+ category: "tools",
39449
+ kind: "tool",
39450
+ tags: [
39451
+ "cleaning"
39452
+ ],
39453
+ tools: [
39454
+ "plunger"
39455
+ ],
39456
+ size: [
39457
+ 0.14,
39458
+ 0.55,
39459
+ 0.14
39460
+ ],
39461
+ weight: 0.45,
39462
+ stack: 1,
39463
+ shape: "tool",
39464
+ color: 11545120,
39465
+ rarity: "common",
39466
+ finds: {
39467
+ places: [
39468
+ "house",
39469
+ "apartment"
39470
+ ]
39471
+ },
39472
+ parts: [
39473
+ {
39474
+ id: "body",
39475
+ material: "rubber",
39476
+ thickness: 4e-3
39477
+ }
39478
+ ],
39479
+ model: "plunger"
39169
39480
  }
39170
39481
  ];
39171
39482
  var kinds_default = [
@@ -40849,6 +41160,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
40849
41160
  "alicate"
40850
41161
  ]
40851
41162
  },
41163
+ plunger: {
41164
+ created: true,
41165
+ idSource: "decision",
41166
+ sizeSource: "REF",
41167
+ vc3: [
41168
+ "desentupidor"
41169
+ ]
41170
+ },
40852
41171
  adjustable_wrench: {
40853
41172
  ite: "chave_inglesa",
40854
41173
  idSource: "decision",
@@ -44268,6 +44587,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44268
44587
  "item.toothbrush": "Toothbrush",
44269
44588
  "item.deodorant": "Deodorant",
44270
44589
  "item.toilet_paper": "Toilet paper",
44590
+ "item.plunger": "Toilet plunger",
44271
44591
  "item.towel": "Towel",
44272
44592
  "item.detergent": "Detergent",
44273
44593
  "item.bleach": "Bleach",
@@ -44776,6 +45096,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44776
45096
  "item.toothbrush": "Escova de dente",
44777
45097
  "item.deodorant": "Desodorante",
44778
45098
  "item.toilet_paper": "Papel higi\xEAnico",
45099
+ "item.plunger": "Desentupidor",
44779
45100
  "item.towel": "Toalha",
44780
45101
  "item.detergent": "Detergente",
44781
45102
  "item.bleach": "\xC1gua sanit\xE1ria",
@@ -45076,7 +45397,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
45076
45397
  },
45077
45398
  toilet: {
45078
45399
  body: { material: "ceramic", joint: "bolt" },
45079
- parts: [["lid", door("plastic", "hinge", "lid")], ["flush_button", { material: "plastic", joint: "clip", piece: "button" }]]
45400
+ parts: [["lid", door("plastic", "hinge", "lid")], ["seat_ring", door("plastic", "hinge", "lid")], ["flush_button", { material: "plastic", joint: "clip", piece: "button" }]]
45080
45401
  },
45081
45402
  wall_socket: { body: { material: "plastic", joint: "screw" }, parts: [] },
45082
45403
  wall_switch: { body: { material: "plastic", joint: "screw" }, parts: [["rocker", { material: "plastic", joint: "clip", piece: "rocker" }]] },
@@ -45245,6 +45566,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
45245
45566
  "prompt.toilet_lid": "Toilet lid",
45246
45567
  "prompt.toilet_lid.open": "Close the lid",
45247
45568
  "prompt.toilet_lid.closed": "Lift the lid",
45569
+ "prompt.toilet_seat": "Toilet seat",
45570
+ "prompt.toilet_seat.open": "Lower the seat",
45571
+ "prompt.toilet_seat.closed": "Lift the seat",
45248
45572
  "prompt.switch": "Light switch",
45249
45573
  "prompt.switch.on": "Switch off",
45250
45574
  "prompt.switch.on.verb": "Switch off",
@@ -45503,6 +45827,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
45503
45827
  "prompt.toilet_lid": "Tampa do vaso",
45504
45828
  "prompt.toilet_lid.open": "Fechar a tampa",
45505
45829
  "prompt.toilet_lid.closed": "Levantar a tampa",
45830
+ "prompt.toilet_seat": "Assento do vaso",
45831
+ "prompt.toilet_seat.open": "Abaixar o assento",
45832
+ "prompt.toilet_seat.closed": "Levantar o assento",
45506
45833
  "prompt.switch": "Interruptor",
45507
45834
  "prompt.switch.on": "Desligar a luz",
45508
45835
  "prompt.switch.on.verb": "Desligar",
@@ -46323,6 +46650,25 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46323
46650
  }
46324
46651
  ];
46325
46652
  var WALL_PLATE = { width: 0.075, height: 0.12, thickness: 0.012, sink: 5e-3 };
46653
+ var DIRTY_PLATE = 0.8;
46654
+ var DIRTY_CUP = 0.5;
46655
+ var DIRTY_CUTLERY = 0.6;
46656
+ function goodsSize(id) {
46657
+ const item = GOODS_ITEMS.find((candidate) => candidate.id === id);
46658
+ if (!item) throw new Error(`game-interactables-household: the sinks lay "${id}", which the goods catalogue does not have`);
46659
+ return [item.size[0], item.size[1], item.size[2]];
46660
+ }
46661
+ var laid = (type, data) => ({ stack: { type, qty: 1, ...data ? { data } : {} }, size: goodsSize(type) });
46662
+ var DIRTY_DISHES = [
46663
+ laid("plate", { dirt: DIRTY_PLATE }),
46664
+ laid("cup", { dirt: DIRTY_CUP }),
46665
+ laid("cutlery", { dirt: DIRTY_CUTLERY })
46666
+ ];
46667
+ var WASHING_THINGS = [
46668
+ laid("detergent"),
46669
+ laid("sponge"),
46670
+ laid("cup")
46671
+ ];
46326
46672
  var DEFS2 = types_default;
46327
46673
  var HOUSEHOLD_ITEMS = GOODS_ITEMS.filter((item) => GOODS_PROVENANCE[item.id]?.household !== void 0);
46328
46674
  var itemTexts = (locale) => Object.fromEntries(HOUSEHOLD_ITEMS.map((item) => [`item.${item.id}`, GOODS_STRINGS[locale][`item.${item.id}`] ?? item.id]));
@@ -48926,7 +49272,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
48926
49272
  }
48927
49273
  var residentialTower = residentialTowerTemplate();
48928
49274
 
48929
- // ../game-floorplan-three/dist/chunk-3EJGIA6V.js
49275
+ // ../game-floorplan-three/dist/chunk-KOJFBQRC.js
48930
49276
  var __defProp3 = Object.defineProperty;
48931
49277
  var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
48932
49278
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -49020,13 +49366,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49020
49366
  return out;
49021
49367
  }
49022
49368
  function exclusiveBoxes(solids) {
49023
- const laid = [];
49369
+ const laid2 = [];
49024
49370
  for (const solid of solids) {
49025
49371
  let pieces = [solid.box];
49026
- for (const before of laid) pieces = pieces.flatMap((piece22) => subtractBox(piece22, before.box));
49027
- for (const box4 of pieces) laid.push({ ...solid, box: box4 });
49372
+ for (const before of laid2) pieces = pieces.flatMap((piece22) => subtractBox(piece22, before.box));
49373
+ for (const box4 of pieces) laid2.push({ ...solid, box: box4 });
49028
49374
  }
49029
- return laid;
49375
+ return laid2;
49030
49376
  }
49031
49377
  function outsideBoxes(box4, taken) {
49032
49378
  let pieces = [box4];
@@ -52724,7 +53070,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52724
53070
  function addSpoil(THREE, parent, trenches, material, site) {
52725
53071
  const heap = new BoxBatch();
52726
53072
  const rects = trenches.map((t) => t.rect);
52727
- const laid = [];
53073
+ const laid2 = [];
52728
53074
  trenches.forEach(({ rect: r }, i) => {
52729
53075
  const others = rects.filter((_, k) => k !== i);
52730
53076
  for (const e of openEdges(r, others, site.solids)) {
@@ -52733,10 +53079,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52733
53079
  const w = TRENCH.berm.width;
52734
53080
  const heapAt = ox ? [ox > 0 ? x1 + SPOIL_CLEAR : x0 - SPOIL_CLEAR - w, z0, ox > 0 ? x1 + SPOIL_CLEAR + w : x0 - SPOIL_CLEAR, z1] : [x0, oz > 0 ? z1 + SPOIL_CLEAR : z0 - SPOIL_CLEAR - w, x1, oz > 0 ? z1 + SPOIL_CLEAR + w : z0 - SPOIL_CLEAR];
52735
53081
  const onBuilding = [site.footprint, ...site.buildings].some(([bx0, bz0, bx1, bz1]) => heapAt[2] > bx0 - 0.4 && heapAt[0] < bx1 + 0.4 && heapAt[3] > bz0 - 0.4 && heapAt[1] < bz1 + 0.4);
52736
- if (!onBuilding) for (const piece22 of rectMinus(heapAt, [...rects.map((t) => [t[0] - SPOIL_CLEAR, t[1] - SPOIL_CLEAR, t[2] + SPOIL_CLEAR, t[3] + SPOIL_CLEAR]), ...laid])) {
53082
+ if (!onBuilding) for (const piece22 of rectMinus(heapAt, [...rects.map((t) => [t[0] - SPOIL_CLEAR, t[1] - SPOIL_CLEAR, t[2] + SPOIL_CLEAR, t[3] + SPOIL_CLEAR]), ...laid2])) {
52737
53083
  if (Math.min(piece22[2] - piece22[0], piece22[3] - piece22[1]) < TRENCH.berm.crest * 2) continue;
52738
53084
  addHumps(heap, piece22);
52739
- laid.push(piece22);
53085
+ laid2.push(piece22);
52740
53086
  }
52741
53087
  }
52742
53088
  });
@@ -53578,8 +53924,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53578
53924
  const isBlock = part.assembly === "concrete_block_wall" || part.material === "concrete";
53579
53925
  const coreTh = coreWidthOf(th, unitId);
53580
53926
  for (const r of slivers) chased(batches.mortar, r.a0 + SLIVER_CLEAR, r.y0 + SLIVER_CLEAR, r.a1 - SLIVER_CLEAR, r.y1 - SLIVER_CLEAR, coreTh * 0.98, MORTAR_CHASE_INSET);
53581
- const laid = coursingOf(unitId, getAssembly(part.assembly ?? (isBlock ? "concrete_block_wall" : "brick_wall_plastered"))?.units);
53582
- const coursing = { courseH: laid.courseHeight, unitLen: laid.unitLength, joint: 0.012, courseBase };
53927
+ const laid2 = coursingOf(unitId, getAssembly(part.assembly ?? (isBlock ? "concrete_block_wall" : "brick_wall_plastered"))?.units);
53928
+ const coursing = { courseH: laid2.courseHeight, unitLen: laid2.unitLength, joint: 0.012, courseBase };
53583
53929
  const unit = isBlock ? batches.block : batches.brick;
53584
53930
  for (const r of pieces) {
53585
53931
  unitEnds.length = 0;
@@ -53898,13 +54244,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53898
54244
  const lintels = beamParts.filter((p) => isLintel(p.id)).map(solidOf).map(toCoreWidth).map(inWall).map((l) => fitLintel(l, beams, columns, wallCores.filter((w) => wallLineOf(w.aabb).alongU !== wallLineOf(l.aabb).alongU))).filter((l) => l !== null);
53899
54245
  for (const l of lintels) addStageBox(THREE, masonry, l.aabb[0], l.y0, l.aabb[1], l.aabb[2], l.y1, l.aabb[3], mats.lintel, l.id);
53900
54246
  const batches = createMasonryBatches();
53901
- const laid = [];
54247
+ const laid2 = [];
53902
54248
  const solids = [...foundations, ...columns, ...beams, ...slabs, ...lintels];
53903
54249
  for (const run of wallRuns(wallParts)) {
53904
54250
  const p = run.part;
53905
54251
  const wall = wallLineOf(p.aabb);
53906
54252
  const cuts = [...run.gaps];
53907
- for (const s of [...solids, ...laid]) {
54253
+ for (const s of [...solids, ...laid2]) {
53908
54254
  const top = columns.includes(s) ? s.y1 + 0.3 : s.y1;
53909
54255
  const cut = cutOf(wall, s.aabb, s.y0, top);
53910
54256
  if (cut) cuts.push(cut);
@@ -53917,7 +54263,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53917
54263
  const coreLine = coreLineOf(wall, p, columns, coreWidth);
53918
54264
  const filled = buildMasonryPanel(batches, p, { cuts, courseBase: (p.floor ?? 0) === 0 ? FOUNDATION_TOP : p.y0, unitId: unit, coreLine, chases: chasesIn(wall, { line: coreLine, width: coreWidth, y0: p.y0, y1: p.y1 }, runs) });
53919
54265
  const half = coreWidth / 2;
53920
- for (const r of filled) laid.push({ id: p.id, aabb: wall.alongU ? [r.a0, coreLine - half, r.a1, coreLine + half] : [coreLine - half, r.a0, coreLine + half, r.a1], y0: r.y0, y1: r.y1, floor: p.floor ?? 0 });
54266
+ for (const r of filled) laid2.push({ id: p.id, aabb: wall.alongU ? [r.a0, coreLine - half, r.a1, coreLine + half] : [coreLine - half, r.a0, coreLine + half, r.a1], y0: r.y0, y1: r.y1, floor: p.floor ?? 0 });
53921
54267
  }
53922
54268
  for (const mesh2 of masonryMeshes(THREE, batches, mats, "masonry")) masonry.add(mesh2);
53923
54269
  return groups;
@@ -54366,7 +54712,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54366
54712
  };
54367
54713
  for (const A of ws) for (const [side, sd] of [[A.w.sides[0], -1], [A.w.sides[1], 1]]) {
54368
54714
  if (!sideOf(side, false).exterior) continue;
54369
- const strip = (k, y1, y2, o0, o1, mat, c, piece22, laid = BASEBOARD_TILES) => {
54715
+ const strip = (k, y1, y2, o0, o1, mat, c, piece22, laid2 = BASEBOARD_TILES) => {
54370
54716
  const ea = junction(A, A.a, sd) > 0 ? A.th / 2 + k : junction(A, A.a, sd) < 0 ? -A.th / 2 : 0, eb = junction(A, A.b, sd) > 0 ? A.th / 2 + k : junction(A, A.b, sd) < 0 ? -A.th / 2 : 0;
54371
54717
  const s0 = A.a - ea, s1 = A.b + eb, f0 = A.L + sd * (A.th / 2 + o0), f1 = A.L + sd * (A.th / 2 + o1), lo = Math.min(f0, f1), hi = Math.max(f0, f1);
54372
54718
  if (s1 - s0 < 1e-3) return;
@@ -54376,14 +54722,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54376
54722
  if (!shared2.ctx.visorScene) (mat === "sidewalk" ? shared2.ctx.paving : shared2.ctx.baseboards)?.push(p);
54377
54723
  }
54378
54724
  };
54379
- const tag = laid === BASEBOARD_TILES ? "baseboard" : "sidewalk";
54725
+ const tag = laid2 === BASEBOARD_TILES ? "baseboard" : "sidewalk";
54380
54726
  const tile = (id, a, b) => {
54381
- cursor.pc = pieceRecord(id, laid.material, null, { floor: 0, mass: Math.round((b - a) * (y2 - y1) * (hi - lo) * laid.density * 100) / 100, tags: [tag] });
54727
+ cursor.pc = pieceRecord(id, laid2.material, null, { floor: 0, mass: Math.round((b - a) * (y2 - y1) * (hi - lo) * laid2.density * 100) / 100, tags: [tag] });
54382
54728
  box4(a, b);
54383
54729
  };
54384
54730
  const runs = [];
54385
54731
  let from = s0;
54386
- if (laid === BASEBOARD_TILES) for (const d of doorsInWall(R.doors, A.w, A.L, A.a, A.b).sort((p, q) => p.at - q.at)) {
54732
+ if (laid2 === BASEBOARD_TILES) for (const d of doorsInWall(R.doors, A.w, A.L, A.a, A.b).sort((p, q) => p.at - q.at)) {
54387
54733
  runs.push([from, d.at - d.width / 2]);
54388
54734
  from = d.at + d.width / 2;
54389
54735
  }
@@ -54394,7 +54740,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54394
54740
  if (!id) box4(r0, r1);
54395
54741
  else if (shared2.ctx.baseboardBand) tile(id, r0, r1);
54396
54742
  else {
54397
- const n = Math.max(1, Math.round((r1 - r0) / laid.length)), w = (r1 - r0) / n, j = laid.joint / 2;
54743
+ const n = Math.max(1, Math.round((r1 - r0) / laid2.length)), w = (r1 - r0) / n, j = laid2.joint / 2;
54398
54744
  for (let i = 0; i < n; i++) tile(`${id}:${i}`, r0 + i * w + (i > 0 ? j : 0), r0 + (i + 1) * w - (i < n - 1 ? j : 0));
54399
54745
  }
54400
54746
  });
@@ -55509,8 +55855,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55509
55855
  }
55510
55856
  var BLOB_LEANS = [[0.06, 0], [-0.06, 0], [0, 0.06], [0, -0.06], [0.06, 0.06], [-0.06, -0.06], [0.06, -0.06], [-0.06, 0.06], [0.12, 0], [0, 0.12]];
55511
55857
  var BLOB_CROSSING = Math.cos(20 * Math.PI / 180);
55512
- function grazes(laid, x, y, z, r) {
55513
- return laid.some(([x0, y0, z0, r0]) => {
55858
+ function grazes(laid2, x, y, z, r) {
55859
+ return laid2.some(([x0, y0, z0, r0]) => {
55514
55860
  const d = Math.hypot(x - x0, y - y0, z - z0);
55515
55861
  if (d <= Math.abs(r - r0) || d >= r + r0) return false;
55516
55862
  return (r * r + r0 * r0 - d * d) / (2 * r * r0) > BLOB_CROSSING;
@@ -55523,14 +55869,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55523
55869
  const GREENS2 = [4160058, 3107376, 5212738, 5936200, 3832396];
55524
55870
  const FLOWERS = [14700682, 15909424, 16118506, 14168874, 9067216, 15764026];
55525
55871
  function blobs(K2, cx, cy, cz, R, n, green2, rnd, o = {}) {
55526
- const laid = [];
55872
+ const laid2 = [];
55527
55873
  for (let i = 0; i < n; i++) {
55528
55874
  const a = rnd() * 6.283, u = Math.sqrt(rnd()), ph = (rnd() - 0.2) * 1.2, dx = Math.cos(a) * u * R * 0.75, dz = Math.sin(a) * u * R * 0.75, dy = (o.flatten ? 0.35 : 0.55) * R * (Math.sin(ph) * 0.5 + 0.5) * 1.5 - R * 0.15;
55529
55875
  const r = R * (0.34 + rnd() * 0.22) * (1 - u * 0.25), alt = r * 2 * (o.flatten ? 0.75 : 0.95), f = 0.72 + Math.min(1, (dy + R * 0.2) / (R * 1.2)) * 0.32 + rnd() * 0.12;
55530
- const shown2 = shared2.ctx.visorScene || !grazes(laid, cx + dx, cy + dy + r * 0.5, cz + dz, r);
55876
+ const shown2 = shared2.ctx.visorScene || !grazes(laid2, cx + dx, cy + dy + r * 0.5, cz + dz, r);
55531
55877
  if (shared2.ctx.visorScene) K2.e("plant", cx + dx, cy + dy + r * 0.5, cz + dz, r, alt, sh(green2, f));
55532
55878
  else if (shown2) {
55533
- laid.push([cx + dx, cy + dy + r * 0.5, cz + dz, r]);
55879
+ laid2.push([cx + dx, cy + dy + r * 0.5, cz + dz, r]);
55534
55880
  const [wx, , wz] = K2.W(cx + dx, 0, cz + dz), lean = BLOB_LEANS[i % BLOB_LEANS.length];
55535
55881
  K2.A.cylinder({ ...K2.M, x: wx, z: wz, ry: K2.M.ry + i / n * (Math.PI / 5) }, "plant", 0, K2.y0 + cy + dy + r * 0.5, 0, r, alt, sh(green2, f), lean[0], lean[1], "sphere");
55536
55882
  }
@@ -58834,6 +59180,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58834
59180
  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 };
58835
59181
  }
58836
59182
  var axisVector = (axis) => [axis === 0 ? 1 : 0, axis === 1 ? 1 : 0, axis === 2 ? 1 : 0];
59183
+ function isSliver(unit, size) {
59184
+ return Math.min(unit.sx, unit.sy, unit.sz) < 0.5 * Math.min(...size);
59185
+ }
59186
+ function overlapsStone(a, b) {
59187
+ const reach2 = 0.62 * (Math.max(a.sx, a.sy, a.sz) + Math.max(b.sx, b.sy, b.sz));
59188
+ return Math.hypot(a.x - b.x, a.y - b.y, a.z - b.z) < reach2;
59189
+ }
58837
59190
  function unitBoxOf(axes, centre, size, colour) {
58838
59191
  const [x, y, z] = pointOf2(axes, centre[0], centre[1], centre[2]), [sx, sy, sz] = pointOf2(axes, size[0], size[1], size[2]);
58839
59192
  return { x, y, z, sx, sy, sz, colour };
@@ -58844,6 +59197,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58844
59197
  inner[axes.along + 3] = bounds2[axes.along + 3] - COVER2;
58845
59198
  inner[axes.up + 3] = bounds2[axes.up + 3] - COVER2;
58846
59199
  if (axes.up !== 1) inner[axes.up] = bounds2[axes.up] + COVER2;
59200
+ inner[axes.across] = bounds2[axes.across] + COVER2;
59201
+ inner[axes.across + 3] = bounds2[axes.across + 3] - COVER2;
58847
59202
  return inner;
58848
59203
  }
58849
59204
  function installDestructionBreach(K, _shared) {
@@ -59450,7 +59805,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59450
59805
  const stone = (s, y, d, size, r) => {
59451
59806
  const centre = mask.start + s;
59452
59807
  const unit = clipToBox(unitBoxOf(mask.axes, [centre, y, d], size, tmp.c.setHex(grey).multiplyScalar(0.85 + 0.2 * r(7)).getHex()), bounds2);
59453
- if (unit) out.push(unit);
59808
+ if (unit && !isSliver(unit, size) && !out.some((k) => overlapsStone(k, unit))) out.push(unit);
59454
59809
  };
59455
59810
  for (const { c, part, thick, mid } of gone) {
59456
59811
  const [from, to] = extentOf(part, mask.axes.along), [up0, up1] = extentOf(part, mask.axes.up);
@@ -62610,11 +62965,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62610
62965
  const id = item.seal?.openWith?.find((tool2) => catalog.has(tool2));
62611
62966
  return id === void 0 ? void 0 : catalog.get(id);
62612
62967
  };
62613
- const laid = items.flatMap((item) => {
62968
+ const laid2 = items.flatMap((item) => {
62614
62969
  const opener = openerOf(item);
62615
62970
  return opener ? [item, { id: opener.id, category: item.category, size: opener.size }] : [item];
62616
62971
  });
62617
- const shelves = shelvesLayout(laid, categories);
62972
+ const shelves = shelvesLayout(laid2, categories);
62618
62973
  const showcase = modelSet.list().map((id) => ({ id, size: sizeOfModel(modelSet, id), def: catalog.has(id) ? catalog.get(id) : void 0 }));
62619
62974
  const state = {
62620
62975
  category: CATEGORY_ALL,
@@ -62665,6 +63020,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62665
63020
  const contents = itemContents(subject);
62666
63021
  return contents ? { fluid: { container: contents.container, part: SHELL_PART_ID } } : {};
62667
63022
  };
63023
+ const vesselOf = (def) => {
63024
+ const shape = def.model !== void 0 && modelSet.builder(def.model) ? void 0 : shapeOf(def);
63025
+ const vessel = itemVessel({ size: def.size, ...def.container?.capacityLiters === void 0 ? {} : { capacityLiters: def.container.capacityLiters }, ...shape === void 0 ? {} : { shape } });
63026
+ return vessel ? { fluid: { container: vessel.container, uses: ["drink", "sip", "pour", "pour_out"], offset: vessel.offset } } : {};
63027
+ };
63028
+ const washable = options.washable ?? ((def) => def.category !== "food" && (def.tags?.includes("kitchen") ?? false));
63029
+ const washOf = (def) => {
63030
+ if (!washable(def)) return {};
63031
+ const wash = {
63032
+ dirt: (root, dirt) => void (latestTHREE && setItemDirt(latestTHREE, root, dirt)),
63033
+ foam: (root, amount) => void (latestTHREE && setItemFoam(latestTHREE, root, amount))
63034
+ };
63035
+ return { wash };
63036
+ };
62668
63037
  const sealOf = (def, fluid) => {
62669
63038
  const model = def.model;
62670
63039
  if (!def.seal || model === void 0 || !itemOpening(model)) return fluid;
@@ -62686,7 +63055,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62686
63055
  };
62687
63056
  const usesOf = (def) => {
62688
63057
  const use = options.itemUse?.(def);
62689
- const liquid = sealOf(def, fluidOf({ ...def.model === void 0 ? {} : { model: def.model }, size: def.size, weight: def.weight }));
63058
+ const contents = fluidOf({ ...def.model === void 0 ? {} : { model: def.model }, size: def.size, weight: def.weight });
63059
+ const liquid = sealOf(def, contents.fluid ? contents : vesselOf(def));
62690
63060
  if (!use) return liquid;
62691
63061
  const edible2 = def.category === "food" || def.category === "drink";
62692
63062
  return { ...liquid, ...liquid.fluid && !edible2 ? { fluid: { ...liquid.fluid, uses: ["pour", "pour_out"] } } : {}, use };
@@ -62697,10 +63067,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62697
63067
  movable: true,
62698
63068
  thumbnail: itemThumbnailSvg(drawable(def)),
62699
63069
  ...usesOf(def),
63070
+ ...washOf(def),
63071
+ catalogId: def.id,
63072
+ // what the item spends at each use (detergent, soap): the room takes its doses and shows what is left
63073
+ ...def.consumable ? { consumable: def.consumable } : {},
62700
63074
  // an item with a make-up (a shovel: ash handle riveted to a steel blade) is that spec, not the parts guessed from its meshes
62701
63075
  ...makeupSpecOf(def.model),
62702
63076
  // an item that is also a tool of the arsenal (a shovel) is picked up as that tool
62703
63077
  ...def.weapon ? { weapon: def.weapon } : {},
63078
+ ...def.tools ? { tools: def.tools } : {},
62704
63079
  physical: { weightKg: def.weight, size: def.size, ...def.volume === void 0 ? {} : { litres: def.volume } },
62705
63080
  build: (THREE) => {
62706
63081
  const T2 = THREE;