@adatechnology/game-items-three 0.9.1 → 0.10.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.
@@ -51,6 +51,7 @@ var GameItemsThree = (() => {
51
51
  composeThumbnailScene: () => composeThumbnailScene,
52
52
  countDrawCalls: () => countDrawCalls,
53
53
  countTriangles: () => countTriangles,
54
+ createContainedItemModel: () => createContainedItemModel,
54
55
  createItemKit: () => createItemKit,
55
56
  createItemModels: () => createItemModels,
56
57
  createItemsTestModule: () => createItemsTestModule,
@@ -10105,6 +10106,19 @@ var GameItemsThree = (() => {
10105
10106
  return { root, kind, ...shape ? { shape } : {}, size: item.size, materials };
10106
10107
  }
10107
10108
 
10109
+ // src/contained.ts
10110
+ function createContainedItemModel(items, options = {}) {
10111
+ const byId = /* @__PURE__ */ new Map();
10112
+ for (const item of items) byId.set(item.id, item);
10113
+ return (stack, T2) => {
10114
+ const item = byId.get(stack.type);
10115
+ if (!item) return null;
10116
+ const model = buildItem(T2, item, options);
10117
+ model.root.userData.item = { id: item.id, kind: model.kind };
10118
+ return model.root;
10119
+ };
10120
+ }
10121
+
10108
10122
  // src/item-models.ts
10109
10123
  var itemModels = { has: hasItemModel, build: buildItem };
10110
10124
 
@@ -17506,7 +17520,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17506
17520
  const dz = Math.max(box4.min[2] - loss.z, 0, loss.z - box4.max[2]);
17507
17521
  return Math.hypot(dx, dz) < loss.radius + loss.depth * groundCfg.spread;
17508
17522
  };
17509
- const footprintOf = (o, b, loss) => {
17523
+ const footprintOf2 = (o, b, loss) => {
17510
17524
  const box4 = aabbOf(b.p.spec.shape, b.p.pos, b.p.q);
17511
17525
  const long = box4.max[0] - box4.min[0] >= box4.max[2] - box4.min[2] ? 0 : 2;
17512
17526
  const across2 = long === 0 ? 2 : 0;
@@ -17949,7 +17963,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17949
17963
  const opened = [];
17950
17964
  const settled = [];
17951
17965
  let lost = false;
17952
- const touched = bearersOf(o).filter((b) => nearLoss(o, b.p, loss)).map((b) => ({ b, fp: footprintOf(o, b, loss) })).filter(({ fp }) => fp.share > 0 || fp.drop >= SUBSIDE_MIN);
17966
+ const touched = bearersOf(o).filter((b) => nearLoss(o, b.p, loss)).map((b) => ({ b, fp: footprintOf2(o, b, loss) })).filter(({ fp }) => fp.share > 0 || fp.drop >= SUBSIDE_MIN);
17953
17967
  const bearers = bearersOf(o);
17954
17968
  const pillarFirst = (b) => b.p.spec.structure?.role === "column" ? 0 : 1;
17955
17969
  const order2 = [...touched].sort((x, y) => pillarFirst(x.b) - pillarFirst(y.b));
@@ -43628,7 +43642,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
43628
43642
  h: 4.4,
43629
43643
  y: 0,
43630
43644
  solid: true,
43631
- massKg: 14
43645
+ massKg: 14,
43646
+ fixed: true
43632
43647
  },
43633
43648
  {
43634
43649
  id: "electrical_panel",
@@ -44483,6 +44498,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44483
44498
  // was `maquina`
44484
44499
  });
44485
44500
  var OWN_TYPES = Object.freeze({ lamp: true, gas_piped: true });
44501
+ var KITCHEN_SINK_WORKTOP = 0.9;
44486
44502
  var sourceOf = (result) => result;
44487
44503
  var ADAPTER_VERSION = "0.3.0";
44488
44504
  var r3 = (n) => Math.round(n * 1e3) / 1e3;
@@ -44873,7 +44889,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44873
44889
  list2.push(sink);
44874
44890
  let cabinet2 = null;
44875
44891
  if (rest2 >= 0.35) {
44876
- cabinet2 = part(m.id + "#cabinet", "kitchen_cabinet_base", rest2, m.d, m.h, 0, left ? width / 2 - rest2 / 2 : -(width / 2) + rest2 / 2, 0);
44892
+ cabinet2 = part(m.id + "#cabinet", "kitchen_cabinet_base", rest2, m.d, opts.visor ? m.h : KITCHEN_SINK_WORKTOP, 0, left ? width / 2 - rest2 / 2 : -(width / 2) + rest2 / 2, 0);
44877
44893
  list2.push(cabinet2);
44878
44894
  }
44879
44895
  if (contents[m.id]) store(cabinet2 ? [["kitchen_cabinet_base", cabinet2.item], ["sink_kitchen", sink.item]] : [["sink_kitchen", sink.item]], contents[m.id]);
@@ -45387,9 +45403,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
45387
45403
  { type: "sofa_3seat", category: "sofa", w: 2.1, d: 0.9, h: 0.85, color: { role: "fabric_main" } },
45388
45404
  { type: "sofa_2seat", category: "sofa", w: 1.6, d: 0.85, h: 0.85, color: { role: "fabric_main" } },
45389
45405
  { type: "sofa_l", category: "sofa", w: 2.4, d: 0.95, h: 0.85, color: { role: "fabric_main" } },
45390
- { type: "tv_unit", category: "tv_unit", w: 1.6, d: 0.45, h: 0.55 },
45391
- { type: "tv_unit_small", category: "tv_unit", w: 1.2, d: 0.4, h: 0.5 },
45392
- { type: "tv_unit_large", category: "tv_unit", w: 1.9, d: 0.45, h: 0.6 },
45406
+ { type: "tv_unit", category: "tv_unit", w: 1.6, d: 0.45, h: 0.55, opening: 0.4 },
45407
+ { type: "tv_unit_small", category: "tv_unit", w: 1.2, d: 0.4, h: 0.5, opening: 0.4 },
45408
+ { type: "tv_unit_large", category: "tv_unit", w: 1.9, d: 0.45, h: 0.6, opening: 0.4 },
45393
45409
  { type: "tv", category: "tv", w: 0.9, d: 0.1, h: 0.55 },
45394
45410
  { type: "tv_large", category: "tv", w: 1.2, d: 0.1, h: 0.7 },
45395
45411
  { type: "coffee_table", category: "coffee_table", w: 0.9, d: 0.55, h: 0.42 },
@@ -45401,33 +45417,33 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
45401
45417
  { type: "shelf_unit", category: "shelf_unit", w: 1.4, d: 0.4, h: 1.8 },
45402
45418
  { type: "shelf_unit_small", category: "shelf_unit", w: 1, d: 0.35, h: 1.5 },
45403
45419
  { type: "floor_lamp", category: "lamp", w: 0.3, d: 0.3, h: 1.5 },
45404
- { type: "sideboard", category: "sideboard", w: 1.2, d: 0.4, h: 0.85 },
45420
+ { type: "sideboard", category: "sideboard", w: 1.2, d: 0.4, h: 0.85, opening: 0.4 },
45405
45421
  { type: "console_table", category: "console_table", w: 0.9, d: 0.3, h: 0.85 },
45406
45422
  { type: "bench", category: "bench", w: 1, d: 0.35, h: 0.45 },
45407
45423
  { type: "workbench", category: "workbench", w: 1.2, d: 0.6, h: 0.95 },
45408
45424
  { type: "floor_mirror", category: "mirror", w: 0.5, d: 0.12, h: 1.8 },
45409
- { type: "fridge", category: "fridge", w: 0.7, d: 0.68, h: 1.8, color: { role: "metal" } },
45410
- { type: "fridge_large", category: "fridge", w: 0.8, d: 0.72, h: 1.85, color: { role: "metal" } },
45411
- { type: "stove", category: "stove", w: 0.62, d: 0.6, h: 0.95, color: { role: "metal" } },
45412
- { type: "stove_4burner", category: "stove", w: 0.7, d: 0.62, h: 0.95, color: { role: "metal" } },
45413
- { type: "kitchen_cabinet", category: "kitchen_cabinet", overhead: true, w: 1.6, d: 0.6, h: 0.95, color: { role: "metal" } },
45414
- { type: "kitchen_cabinet_large", category: "kitchen_cabinet", overhead: true, w: 2, d: 0.6, h: 0.95, color: { role: "metal" } },
45415
- { type: "kitchen_cabinet_small", category: "kitchen_cabinet", overhead: true, w: 1.2, d: 0.6, h: 0.95, color: { role: "metal" } },
45425
+ { type: "fridge", category: "fridge", w: 0.7, d: 0.68, h: 1.8, opening: 0.6, color: { role: "metal" } },
45426
+ { type: "fridge_large", category: "fridge", w: 0.8, d: 0.72, h: 1.85, opening: 0.6, color: { role: "metal" } },
45427
+ { type: "stove", category: "stove", w: 0.62, d: 0.6, h: 0.95, opening: 0.5, color: { role: "metal" } },
45428
+ { type: "stove_4burner", category: "stove", w: 0.7, d: 0.62, h: 0.95, opening: 0.5, color: { role: "metal" } },
45429
+ { type: "kitchen_cabinet", category: "kitchen_cabinet", overhead: true, w: 1.6, d: 0.6, h: 0.95, opening: 0.5, color: { role: "metal" } },
45430
+ { type: "kitchen_cabinet_large", category: "kitchen_cabinet", overhead: true, w: 2, d: 0.6, h: 0.95, opening: 0.5, color: { role: "metal" } },
45431
+ { type: "kitchen_cabinet_small", category: "kitchen_cabinet", overhead: true, w: 1.2, d: 0.6, h: 0.95, opening: 0.5, color: { role: "metal" } },
45416
45432
  { type: "dining_table", category: "dining_table", w: 1.1, d: 0.8, h: 0.78 },
45417
45433
  { type: "dining_table_small", category: "dining_table", w: 0.9, d: 0.7, h: 0.75 },
45418
45434
  { type: "dining_table_round", category: "dining_table", w: 0.9, d: 0.9, h: 0.75 },
45419
45435
  { type: "microwave", category: "appliance", w: 0.5, d: 0.4, h: 0.3, color: { role: "metal" } },
45420
45436
  { type: "trash_bin", category: "trash_bin", w: 0.3, d: 0.3, h: 0.6 },
45421
- { type: "pantry", category: "pantry", w: 1.2, d: 0.4, h: 2 },
45437
+ { type: "pantry", category: "pantry", w: 1.2, d: 0.4, h: 2, opening: 0.5 },
45422
45438
  { type: "double_bed", category: "bed", w: 1.6, d: 2.05, h: 0.62, color: { role: "fabric_main" } },
45423
45439
  { type: "queen_bed", category: "bed", w: 1.8, d: 2.1, h: 0.62, color: { role: "fabric_main" } },
45424
45440
  { type: "single_bed", category: "bed", w: 0.95, d: 2, h: 0.55, color: { role: "fabric_main" } },
45425
45441
  { type: "king_bed", category: "bed_king", w: 2, d: 2.15, h: 0.65, color: { role: "fabric_main" } },
45426
- { type: "nightstand", category: "nightstand", w: 0.45, d: 0.42, h: 0.6 },
45427
- { type: "wardrobe", category: "wardrobe", w: 1.6, d: 0.6, h: 2 },
45428
- { type: "wardrobe_small", category: "wardrobe", w: 1, d: 0.55, h: 1.9 },
45429
- { type: "wardrobe_large", category: "wardrobe_large", w: 2.4, d: 0.65, h: 2.1 },
45430
- { type: "dresser", category: "dresser", w: 1, d: 0.45, h: 0.85 },
45442
+ { type: "nightstand", category: "nightstand", w: 0.45, d: 0.42, h: 0.6, opening: 0.45 },
45443
+ { type: "wardrobe", category: "wardrobe", w: 1.6, d: 0.6, h: 2, opening: 0.5 },
45444
+ { type: "wardrobe_small", category: "wardrobe", w: 1, d: 0.55, h: 1.9, opening: 0.5 },
45445
+ { type: "wardrobe_large", category: "wardrobe_large", w: 2.4, d: 0.65, h: 2.1, opening: 0.5 },
45446
+ { type: "dresser", category: "dresser", w: 1, d: 0.45, h: 0.85, opening: 0.5 },
45431
45447
  { type: "desk", category: "desk", w: 1.1, d: 0.6, h: 0.75 },
45432
45448
  { type: "vanity_table", category: "vanity_table", w: 1, d: 0.5, h: 0.8 },
45433
45449
  { type: "toilet", category: "toilet", w: 0.4, d: 0.62, h: 0.75, color: { role: "ceiling" } },
@@ -45437,8 +45453,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
45437
45453
  { type: "shower_large", category: "shower", windowHeight: 1.95, w: 1.1, d: 1.1, h: 0.1, color: { role: "ceiling" } },
45438
45454
  { type: "hamper", category: "hamper", w: 0.35, d: 0.3, h: 0.5 },
45439
45455
  { type: "laundry_tub", category: "laundry_tub", w: 0.6, d: 0.55, h: 0.9, color: { role: "metal" } },
45440
- { type: "washing_machine", category: "washing_machine", w: 0.6, d: 0.65, h: 0.9, color: { role: "metal" } },
45441
- { type: "laundry_cabinet", category: "laundry_cabinet", w: 0.8, d: 0.4, h: 1.8 },
45456
+ { type: "washing_machine", category: "washing_machine", w: 0.6, d: 0.65, h: 0.9, opening: 0.5, color: { role: "metal" } },
45457
+ { type: "laundry_cabinet", category: "laundry_cabinet", w: 0.8, d: 0.4, h: 1.8, opening: 0.45 },
45442
45458
  { type: "laundry_shelf", category: "laundry_shelf", w: 1, d: 0.35, h: 1.6 },
45443
45459
  { type: "car", category: "car", w: 1.85, d: 4.3, h: 1.5, color: { pick: [1842206, 15263974, 10132897, 8003359, 2046559, 4016698, 12103834] } },
45444
45460
  { type: "car_small", category: "car", w: 1.7, d: 3.8, h: 1.45, color: { pick: [1842206, 15263974, 10132897, 8003359, 2046559, 4016698, 12103834] } },
@@ -45448,10 +45464,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
45448
45464
  { type: "office_desk", category: "office_desk", w: 1.4, d: 0.7, h: 0.75 },
45449
45465
  { type: "office_desk_large", category: "office_desk", w: 1.6, d: 0.8, h: 0.75 },
45450
45466
  { type: "bookcase", category: "bookcase", w: 1.2, d: 0.35, h: 2 },
45451
- { type: "filing_cabinet", category: "filing_cabinet", w: 0.5, d: 0.6, h: 1.3 },
45467
+ { type: "filing_cabinet", category: "filing_cabinet", w: 0.5, d: 0.6, h: 1.3, opening: 0.5 },
45452
45468
  { type: "dining_table_large", category: "dining_table_large", w: 2.4, d: 1.1, h: 0.78 },
45453
- { type: "buffet", category: "buffet", w: 1.6, d: 0.5, h: 0.9 },
45454
- { type: "china_cabinet", category: "china_cabinet", w: 1.2, d: 0.45, h: 2 },
45469
+ { type: "buffet", category: "buffet", w: 1.6, d: 0.5, h: 0.9, opening: 0.45 },
45470
+ { type: "china_cabinet", category: "china_cabinet", w: 1.2, d: 0.45, h: 2, opening: 0.45 },
45455
45471
  { type: "stairs", category: "stairs", w: 1, d: 3.2, h: 2.8 },
45456
45472
  { type: "planter_bed", category: "planter_bed", w: 3, d: 0.7, h: 0.4, color: { role: "dirt" } },
45457
45473
  { type: "planter_bed_small", category: "planter_bed", w: 1.8, d: 0.6, h: 0.4, color: { role: "dirt" } },
@@ -45491,7 +45507,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
45491
45507
  { type: "breakfast_bar", category: "breakfast_bar", w: 2, d: 0.55, h: 1, window: true },
45492
45508
  { type: "sauna", category: "sauna", w: 2, d: 2, h: 2.1 },
45493
45509
  { type: "soaking_tub", category: "soaking_tub", w: 1.6, d: 1.6, h: 0.8 },
45494
- { type: "closet_wardrobe", category: "wardrobe_large", w: 2, d: 0.6, h: 2.2 },
45510
+ { type: "closet_wardrobe", category: "wardrobe_large", w: 2, d: 0.6, h: 2.2, opening: 0.5 },
45495
45511
  { type: "sofa_xl", category: "sofa", w: 3, d: 1, h: 0.85, color: { role: "fabric_main" } },
45496
45512
  { type: "gourmet_counter", category: "gourmet", w: 3, d: 0.7, h: 1, window: true, equip: ["bbq_grill", "kitchen_cabinet"] },
45497
45513
  { type: "gourmet_counter_small", category: "gourmet", w: 1.8, d: 0.65, h: 1, window: true, equip: ["bbq_grill", "kitchen_cabinet"] },
@@ -46568,7 +46584,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46568
46584
  }
46569
46585
  var residentialTower = residentialTowerTemplate();
46570
46586
 
46571
- // ../game-floorplan-three/dist/chunk-RQNZIQZ5.js
46587
+ // ../game-floorplan-three/dist/chunk-6GFCK5NZ.js
46572
46588
  var __defProp3 = Object.defineProperty;
46573
46589
  var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
46574
46590
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -48317,10 +48333,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
48317
48333
  }
48318
48334
  function floorLamp(M, A) {
48319
48335
  const K2 = kit2(M, A, M.y || 0), color2 = colorTemperature(M), id = "lamp_pe_" + M.seed, h = Math.min(1.6, M.h || 1.5), meta = { id, room: M.room, on: !!M.on, color: color2, lightType: "floor", hidden: !M.on };
48320
- K2.c("metal", 0, 0, 0, 0.13, 0.025, 2763308);
48336
+ const shade3 = M.visorScene ? 0.17 : Math.min(0.17, Math.min(M.w || 0.34, M.d || 0.34) / 2 - 6e-3);
48337
+ K2.c("metal", 0, 0, 0, Math.min(0.13, shade3), 0.025, 2763308);
48321
48338
  K2.c("metal", 0, 0.025, 0, 0.011, h - 0.3, 2763308);
48322
- K2.c("plain", 0, h - 0.28, 0, 0.17, 0.26, 15656656);
48323
- K2.part("lamp", 0, h - 0.28, 0, () => K2.c("emissive", 0, h - 0.28, 0, 0.173, 0.262, color2), meta);
48339
+ K2.c("plain", 0, h - 0.28, 0, shade3, 0.26, 15656656);
48340
+ K2.part("lamp", 0, h - 0.28, 0, () => K2.c("emissive", 0, h - 0.28, 0, shade3 + 3e-3, 0.262, color2), meta);
48324
48341
  if (M.on && A.light) A.light(Object.assign({}, M, { lampId: id }), 0, h - 0.15, 0, color2, 5, "floor");
48325
48342
  }
48326
48343
  function sconce(M, A) {
@@ -52297,7 +52314,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52297
52314
  dresser(M, A) {
52298
52315
  const { b: lb, c: lc } = kk(M, A), w = M.w, d = M.d, h = M.h, wood = paletteColor(M, "wood", 6965812), ng = h > 0.7 ? 3 : 2, gh = (h - 0.12) / ng;
52299
52316
  lb("wood", 0, 0.04, 0, w, h - 0.08, d, wood);
52300
- lb("wood", 0, h - 0.04, 0, w + 0.03, 0.04, d + 0.03, sh(wood, 1.15));
52317
+ if (M.visorScene) lb("wood", 0, h - 0.04, 0, w + 0.03, 0.04, d + 0.03, sh(wood, 1.15));
52318
+ else lb("wood", 0, h - 0.04, 75e-4, w, 0.04, d + 0.015, sh(wood, 1.15));
52301
52319
  for (const sx of [-1, 1]) for (const sz of [-1, 1]) lb("wood", sx * (w / 2 - 0.04), 0, sz * (d / 2 - 0.04), 0.04, 0.04, 0.04, sh(wood, 0.4));
52302
52320
  for (let k = 0; k < ng; k++) {
52303
52321
  lb("wood", 0, 0.08 + k * gh, d / 2 + 5e-3, w - 0.06, gh - 0.03, 0.012, sh(wood, 1.12));
@@ -52562,10 +52580,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52562
52580
  lb("plain", 0, h - 0.18, d / 2 + 5e-3, w - 0.1, 0.1, 0.01, 3816e3);
52563
52581
  },
52564
52582
  hamper(M, A) {
52565
- const { c: lc } = kk(M, A);
52566
- lc("plain", 0, 0, 0, M.w / 2, M.h, paletteColor(M, "fabric_accent", 10127978));
52567
- lc("plain", 0, M.h - 0.01, 0, M.w / 2 - 0.03, 0.02, 2763306);
52583
+ const { c: lc } = kk(M, A), r = M.visorScene ? M.w / 2 : Math.min(M.w, M.d) / 2;
52584
+ lc("plain", 0, 0, 0, r, M.h, paletteColor(M, "fabric_accent", 10127978));
52585
+ lc("plain", 0, M.h - 0.01, 0, r - 0.03, 0.02, 2763306);
52568
52586
  },
52587
+ // (outside the Visor's scene the round basket fits its footprint's narrow side: it stood 2.5 cm in the wall behind it)
52569
52588
  trash_bin(M, A) {
52570
52589
  const { c: lc } = kk(M, A);
52571
52590
  lc("plain", 0, 0, 0, M.w / 2, M.h, 6974574);
@@ -53107,6 +53126,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53107
53126
  return (r * r + r0 * r0 - d * d) / (2 * r * r0) > BLOB_CROSSING;
53108
53127
  });
53109
53128
  }
53129
+ var FICUS_SPREAD = 1.32;
53110
53130
  function installFurniturePlants(K, shared2) {
53111
53131
  const seedKey = (id) => K.seedKey(id);
53112
53132
  const { SEED, kit2, rngString, sh } = K;
@@ -53203,19 +53223,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53203
53223
  }
53204
53224
  function potPlant(M, A, o = {}) {
53205
53225
  const K2 = kit2(M, A), rnd = rngString(SEED() + "|" + seedKey(M.seed) + "|vaso"), h = M.h || 0.9, r = Math.min(0.26, Math.min(M.w || 0.4, M.d || 0.4) * 0.42), pot2 = M.color != null ? M.color : [11886652, 11034686, 15262420, 4868684, 8030860][rnd() * 5 | 0];
53206
- const ph = Math.min(0.34, h * 0.38), top = potModel(K2, 0, 0, 0, r, ph, pot2), green2 = M.palette && M.palette.plant != null ? M.palette.plant : GREENS2[rnd() * 5 | 0], type = o.type || ["ficus", "dracena", "samambaia"][rnd() * 3 | 0];
53226
+ const reach2 = M.visorScene || M.reach == null ? Number.POSITIVE_INFINITY : M.reach, rp = Math.min(r, reach2 / 1.1);
53227
+ const ph = Math.min(0.34, h * 0.38), top = potModel(K2, 0, 0, 0, rp, ph, pot2), green2 = M.palette && M.palette.plant != null ? M.palette.plant : GREENS2[rnd() * 5 | 0], type = o.type || ["ficus", "dracena", "samambaia"][rnd() * 3 | 0];
53207
53228
  if (type === "ficus") {
53208
53229
  K2.t("wood", [0, top, 0], [0.02, top + (h - ph) * 0.45, 0], 0.014, 6965808);
53209
- blobs(K2, 0, top + (h - ph) * 0.35, 0, Math.max(0.2, (h - ph) * 0.4), 9, green2, rnd);
53230
+ blobs(K2, 0, top + (h - ph) * 0.35, 0, Math.min(Math.max(0.2, (h - ph) * 0.4), reach2 / FICUS_SPREAD), 9, green2, rnd);
53210
53231
  } else if (type === "dracena") {
53211
53232
  for (let i = 0; i < 3; i++) {
53212
53233
  const a = i * 2.1, hh = (h - ph) * (0.5 + 0.2 * i / 2);
53213
53234
  const foot = M.visorScene ? 0 : 0.02;
53214
53235
  K2.t("wood", [Math.cos(a) * foot, top, Math.sin(a) * foot], [Math.cos(a) * 0.04, top + hh, Math.sin(a) * 0.04], 0.012, 8022600);
53215
- for (let k = 0; k < 7; k++) arcLeaf(K2, Math.cos(a) * 0.04, top + hh, Math.sin(a) * 0.04, k * 0.9 + a, 0.22 + rnd() * 0.08, 0.35 - k % 3 * 0.1, 0.3, 0.028, sh(green2, 0.85 + rnd() * 0.3), false, 4);
53236
+ for (let k = 0; k < 7; k++) arcLeaf(K2, Math.cos(a) * 0.04, top + hh, Math.sin(a) * 0.04, k * 0.9 + a, (0.22 + rnd() * 0.08) * Math.min(1, (reach2 - 0.04) / 0.3), 0.35 - k % 3 * 0.1, 0.3, 0.028, sh(green2, 0.85 + rnd() * 0.3), false, 4);
53216
53237
  }
53217
53238
  } else {
53218
- for (let k = 0; k < 11; k++) arcLeaf(K2, 0, top, 0, k * 0.6 + rnd() * 0.3, (h - ph) * (0.7 + rnd() * 0.4), 0.9 - k % 3 * 0.25, 1.2, 0.05, sh(green2, 0.8 + rnd() * 0.35), true, 6);
53239
+ for (let k = 0; k < 11; k++) arcLeaf(K2, 0, top, 0, k * 0.6 + rnd() * 0.3, (h - ph) * (0.7 + rnd() * 0.4) * Math.min(1, reach2 / ((h - ph) * 1.1)), 0.9 - k % 3 * 0.25, 1.2, 0.05, sh(green2, 0.8 + rnd() * 0.35), true, 6);
53219
53240
  }
53220
53241
  }
53221
53242
  function tablePot(M, A) {
@@ -53538,6 +53559,57 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53538
53559
  const defined = { extraTypes };
53539
53560
  Object.assign(K, defined);
53540
53561
  }
53562
+ var POTTED_PLANT_TYPES = /* @__PURE__ */ new Set(["floor_plant", "floor_plant_tall", "floor_plant_low", "plant_tall", "plant_short", "outdoor_pot", "table_plant"]);
53563
+ var PLANT_CLEAR = 0.04;
53564
+ var PLANT_MIN_REACH = 0.14;
53565
+ var PLANT_SPAN = [0.03, 2.4];
53566
+ function footprintOf(m) {
53567
+ const c = Math.abs(Math.cos(m.ry || 0)), s = Math.abs(Math.sin(m.ry || 0)), hx = ((m.w || 0) * c + (m.d || 0) * s) / 2, hz = ((m.w || 0) * s + (m.d || 0) * c) / 2;
53568
+ return [m.x - hx, m.z - hz, m.x + hx, m.z + hz];
53569
+ }
53570
+ var reachTo = (x, z, x0, z0, x1, z1) => Math.hypot(Math.max(x0 - x, 0, x - x1), Math.max(z0 - z, 0, z - z1));
53571
+ function freeReachOf(p) {
53572
+ const y0 = p.y + PLANT_SPAN[0], y1 = p.y + PLANT_SPAN[1];
53573
+ let reach2 = Number.POSITIVE_INFINITY;
53574
+ for (const b of p.boxes) if (b[1] < y1 && b[4] > y0) reach2 = Math.min(reach2, reachTo(p.x, p.z, b[0], b[2], b[3], b[5]));
53575
+ for (const m of p.items) {
53576
+ if (m === p.self || m.id === p.self.id || m.floor !== p.self.floor || m.flat || m.category === "ground_cover" || m.w == null || m.d == null) continue;
53577
+ const bottom = p.base + (m.y || 0), top = bottom + (m.h || 0);
53578
+ if (bottom >= y1 || top <= y0) continue;
53579
+ const r = footprintOf(m);
53580
+ reach2 = Math.min(reach2, reachTo(p.x, p.z, r[0], r[1], r[2], r[3]));
53581
+ }
53582
+ return reach2 - PLANT_CLEAR;
53583
+ }
53584
+ function vertexMark(accs) {
53585
+ const mark = /* @__PURE__ */ new Map();
53586
+ for (const a of accs.values()) mark.set(a, a.nv);
53587
+ return mark;
53588
+ }
53589
+ function partToHouse(parts2, group, p) {
53590
+ let at2 = p, name = group;
53591
+ for (let part = parts2.get(name); part; part = parts2.get(name)) {
53592
+ const c = Math.cos(part.ry), s = Math.sin(part.ry);
53593
+ at2 = [at2[0] * c + at2[2] * s + (part.pos[0] ?? 0), at2[1] + (part.pos[1] ?? 0), -at2[0] * s + at2[2] * c + (part.pos[2] ?? 0)];
53594
+ name = part.parent;
53595
+ }
53596
+ return at2;
53597
+ }
53598
+ function boundsSince(accs, mark, parts2) {
53599
+ const byName = new Map(parts2.map((p) => [p.name, p]));
53600
+ const box4 = [Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity];
53601
+ for (const a of accs.values()) {
53602
+ for (let v = mark.get(a) ?? 0; v < a.nv; v++) {
53603
+ const local = [a.p[v * 3], a.p[v * 3 + 1], a.p[v * 3 + 2]];
53604
+ const p = a.group.startsWith("part:") ? partToHouse(byName, a.group, local) : local;
53605
+ for (let k = 0; k < 3; k++) {
53606
+ box4[k] = Math.min(box4[k], p[k]);
53607
+ box4[k + 3] = Math.max(box4[k + 3], p[k]);
53608
+ }
53609
+ }
53610
+ }
53611
+ return box4[0] <= box4[3] ? box4 : null;
53612
+ }
53541
53613
  var COVER_STEP = 3e-3;
53542
53614
  var PANEL_CLEAR = 0.05;
53543
53615
  function installFurniturePlaceItems(K, shared2) {
@@ -53584,6 +53656,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53584
53656
  M.base += COVER_STEP * under;
53585
53657
  covers.push(own);
53586
53658
  }
53659
+ if (!shared2.ctx.visorScene && POTTED_PLANT_TYPES.has(m.type)) {
53660
+ const reach2 = freeReachOf({ x: M.x, z: M.z, y: M.base + (M.y ?? 0), boxes: (exterior ? shared2.ctx.occupied : keepOut).concat((drawn.get(cursor.group) ?? []).flat()), items: list2, self: m, base: M.base });
53661
+ if (reach2 < PLANT_MIN_REACH) continue;
53662
+ M.reach = reach2;
53663
+ }
53587
53664
  if (shared2.ctx.veg && vegItem(m, M, exterior ? "lot" : "f" + f)) continue;
53588
53665
  if (m.type === "cooking_gas_cylinder" && m.shelter && T2.gas_shelter) {
53589
53666
  const st = cursor.stage;
@@ -53635,8 +53712,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53635
53712
  }
53636
53713
  const mine = shared2.ctx.itemBoxes;
53637
53714
  if (mine) drawn.set(cursor.group, (drawn.get(cursor.group) ?? []).concat([mine]));
53715
+ const mark = shared2.ctx.itemBounds ? vertexMark(cursor.accs) : null;
53638
53716
  try {
53639
53717
  buildItem2(m, M, ent, api, cursor.group);
53718
+ if (mark) recordBounds(m, mark);
53640
53719
  } catch (e) {
53641
53720
  cursor.group = exterior ? "lot" : "f" + f;
53642
53721
  console.warn("builder", m.type, e);
@@ -53665,6 +53744,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53665
53744
  }
53666
53745
  return noModel;
53667
53746
  }
53747
+ function recordBounds(m, mark) {
53748
+ const box4 = boundsSince(cursor.accs, mark, K.PARTS);
53749
+ if (box4) shared2.ctx.itemBounds?.push({ id: m.id, type: m.type, category: m.category ?? null, room: m.room ?? null, floor: m.floor, by: "furniture", box: box4 });
53750
+ }
53668
53751
  const ROOF_CLEAR = 0.06;
53669
53752
  function overRoof(m, M, f) {
53670
53753
  const R = shared2.ctx.r, inside22 = (rooms) => rooms.find((c) => rectsOf2(c).some((r) => r[0] < m.x && m.x < r[2] && r[1] < m.z && m.z < r[3]));
@@ -53780,6 +53863,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53780
53863
  const defined = { houseItems, waterTankOfHouse, hashColor, labeledBox };
53781
53864
  Object.assign(K, defined);
53782
53865
  }
53866
+ var PLANT_RADIUS_MARGIN = 1.08;
53867
+ var PLANT_MIN_SCALE = 0.4;
53783
53868
  function installVegetationBridge(K, shared2) {
53784
53869
  const seedKey = (id) => K.seedKey(id);
53785
53870
  const { THREE, SEED, rngString } = K;
@@ -53794,7 +53879,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53794
53879
  floor_plant_tall: VEG_POT,
53795
53880
  floor_plant: VEG_POT,
53796
53881
  outdoor_pot: VEG_POT,
53797
- toilet: VEG_POT,
53798
53882
  floor_plant_low: ["potted_succulents", "potted_cactus"],
53799
53883
  table_plant: ["potted_succulents", "potted_cactus"],
53800
53884
  clump: ["lawn_tuft"],
@@ -53843,9 +53927,41 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53843
53927
  }
53844
53928
  return true;
53845
53929
  }
53846
- G.pl.push({ species: pick2(lst), x: M.x, z: M.z, ry: M.ry || 0, scale: 1, seed: sd });
53930
+ if (M.reach != null) {
53931
+ const fit = fitted(V, lst, pick2(lst), sd, M.reach);
53932
+ if (!fit) return true;
53933
+ G.pl.push({ species: fit.species, x: M.x, z: M.z, ry: M.ry || 0, scale: fit.scale, seed: sd });
53934
+ const r = fit.radius * fit.scale;
53935
+ shared2.ctx.itemBounds?.push({ id: m.id, type: m.type, category: m.category ?? null, room: m.room ?? null, floor: m.floor, by: "vegetation", box: [M.x - r, y, M.z - r, M.x + r, y + fit.height * fit.scale, M.z + r] });
53936
+ return true;
53937
+ }
53938
+ const species = pick2(lst);
53939
+ G.pl.push({ species, x: M.x, z: M.z, ry: M.ry || 0, scale: 1, seed: sd });
53940
+ if (shared2.ctx.itemBounds) {
53941
+ const size = speciesSize(V, species, sd);
53942
+ shared2.ctx.itemBounds.push({ id: m.id, type: m.type, category: m.category ?? null, room: m.room ?? null, floor: m.floor, by: "vegetation", box: [M.x - size.radius, y, M.z - size.radius, M.x + size.radius, y + size.height, M.z + size.radius] });
53943
+ }
53847
53944
  return true;
53848
53945
  }
53946
+ function speciesSize(V, id, seed) {
53947
+ const key2 = id + "|" + seed;
53948
+ let r = V.sizes.get(key2);
53949
+ if (!r) {
53950
+ r = V.G.generate ? V.G.generate(V.S.toSpec(id), { seed }).bounds : { radius: 0, height: 0 };
53951
+ V.sizes.set(key2, r);
53952
+ }
53953
+ return r;
53954
+ }
53955
+ function fitted(V, species, first, seed, reach2) {
53956
+ const sizeOf = (id) => speciesSize(V, id, seed);
53957
+ let best = null;
53958
+ for (const id of [first, ...species.filter((s) => s !== first)]) {
53959
+ const size = sizeOf(id), r = size.radius * PLANT_RADIUS_MARGIN, scale = r > reach2 ? reach2 / r : 1;
53960
+ if (scale === 1) return { species: id, scale, ...size };
53961
+ if (!best || scale > best.scale) best = { species: id, scale, ...size };
53962
+ }
53963
+ return best && best.scale >= PLANT_MIN_SCALE ? best : null;
53964
+ }
53849
53965
  function assembleVegetation(groups) {
53850
53966
  const V = shared2.ctx.veg;
53851
53967
  if (!V) return;
@@ -53882,7 +53998,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53882
53998
  shared2.partState = /* @__PURE__ */ new Map();
53883
53999
  const newInteractiveState = () => ({ defs: /* @__PURE__ */ new Map(), items: [], pieces: [], lights: /* @__PURE__ */ new Map(), litRooms: /* @__PURE__ */ new Set(), objs: [], anim: /* @__PURE__ */ new Set(), msg: null, target: null });
53884
54000
  shared2.inter = newInteractiveState();
53885
- const MESSAGE_MS = 2200;
54001
+ const MESSAGE_MS = 2200, LAMP_OFF_COLOR = 15658214, LAMP_DIFFUSER_MATERIAL = "glass";
53886
54002
  UV_SCALE.doorWood = 1;
53887
54003
  UV_SCALE.doorPaint = 1;
53888
54004
  function createInteractiveMaterials(mats) {
@@ -53933,6 +54049,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53933
54049
  mats.doorWood = new THREE.MeshLambertMaterial({ vertexColors: true, map: wood });
53934
54050
  mats.doorPaint = new THREE.MeshLambertMaterial({ vertexColors: true, map: paint });
53935
54051
  mats.off = new THREE.MeshBasicMaterial({ vertexColors: true, color: 9078656 });
54052
+ mats.lampOff = new THREE.MeshPhongMaterial({ color: LAMP_OFF_COLOR, shininess: 70, specular: 6710886, transparent: true, opacity: 0.9 });
53936
54053
  }
53937
54054
  const _EY = new THREE.Vector3(0, 1, 0), _UM3 = new THREE.Vector3(1, 1, 1);
53938
54055
  const hudMessage = (text) => {
@@ -53973,6 +54090,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53973
54090
  o.geometry.applyMatrix4(inv);
53974
54091
  o.userData.piece = def;
53975
54092
  def.meshes.push(o);
54093
+ if (def.roomId && o.name.endsWith("/emissive")) o.userData.destructionMaterial = LAMP_DIFFUSER_MATERIAL;
53976
54094
  }
53977
54095
  });
53978
54096
  outer.add(g);
@@ -54059,7 +54177,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54059
54177
  };
54060
54178
  function applyLight(roomId) {
54061
54179
  const on = lightOn(roomId), inter = I(), mats = shared2.mats;
54062
- for (const d of inter.lights.get(roomId) || []) for (const m of d.meshes) if (m.name.endsWith("/emissive")) m.material = on ? mats.emissive : mats.off;
54180
+ for (const d of inter.lights.get(roomId) || []) for (const m of d.meshes) if (m.name.endsWith("/emissive")) m.material = on ? mats.emissive : shared2.ctx.visorScene ? mats.off : mats.lampOff;
54063
54181
  const sw = inter.defs.get("ix:int:" + roomId);
54064
54182
  if (sw) {
54065
54183
  sw.target = on ? 1 : 0;
@@ -54564,7 +54682,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54564
54682
  Object.assign(K, defined);
54565
54683
  }
54566
54684
  function installInteractablesBridge(K, shared2) {
54567
- const { t, THREE, invalidate, invalidateShadow, cfg, DOC, LIGHT_TYPES, _Y, _q, _v3, accFor, applyLight, cursor, hashString: hashString2, hudMessage, lightBase, pieceRecord, put, rgbOf, sh, wallBlocks } = K;
54685
+ const { t, THREE, invalidate, invalidateShadow, cfg, DOC, LIGHT_TYPES, _Y, _q, _v3, accFor, applyLight, cursor, hashString: hashString2, hudMessage, lightBase, pieceRecord, rgbOf, wallBlocks } = K;
54568
54686
  const enter = (...a) => K.enter(...a);
54569
54687
  const roomLightMask = (...a) => K.roomLightMask(...a);
54570
54688
  const IV_MATERIAL = { plain: "plain", metal: "metal", wood: "wood", glass: "glass", fabric: "fabric", plant: "plant", water: "water", emissive: "emissive", atlas_picture: "picture", atlas_floor: "floor" };
@@ -54618,7 +54736,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54618
54736
  void world0;
54619
54737
  const source = r;
54620
54738
  const plane2 = A.plan(source, { seed: r.seed });
54621
- const IV = { k: ik, plane: plane2, world: null, water, entries: /* @__PURE__ */ new Map(), roots: [], replace: /* @__PURE__ */ new Set(), roomStates: /* @__PURE__ */ new Map(), lampRoom: /* @__PURE__ */ new Map(), anim: /* @__PURE__ */ new Map(), screens: /* @__PURE__ */ new Map(), efx: null, items: null, itemsDirty: true, itemsT: 0, dirty: true, list: null, listT: 0, t: 0, circuits: [], switchRooms: /* @__PURE__ */ new Set(), warnings: [], tBuild: 0 };
54739
+ const IV = { k: ik, plane: plane2, world: null, water, entries: /* @__PURE__ */ new Map(), roots: [], replace: /* @__PURE__ */ new Set(), roomStates: /* @__PURE__ */ new Map(), lampRoom: /* @__PURE__ */ new Map(), anim: /* @__PURE__ */ new Map(), screens: /* @__PURE__ */ new Map(), efx: null, contents: /* @__PURE__ */ new Map(), itemsDirty: true, itemsT: 0, dirty: true, list: null, listT: 0, t: 0, circuits: [], switchRooms: /* @__PURE__ */ new Set(), warnings: [], tBuild: 0 };
54622
54740
  h.IV = IV;
54623
54741
  const t0 = performance.now();
54624
54742
  const lamps = new Set(plane2.items.filter((e) => e.type === "lamp").map((e) => e.id));
@@ -54788,20 +54906,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54788
54906
  if (!d.plug) continue;
54789
54907
  const wire = (spec.wires || []).find((x) => x.id === d.id + "_cord"), pts = (wire ? wire.points : [d.plug]).map((p) => wl(o, p));
54790
54908
  const sid = w.power.pluggedInto(E.id, d.id);
54791
- if (sid) {
54792
- const cut = sid.indexOf(":"), so = w.get(sid.slice(0, cut)), sk = so && (so.spec.sockets || []).find((s) => s.id === sid.slice(cut + 1));
54793
- if (so && sk) {
54794
- const sp = wl(so, sk.pos), dir = [Math.sin(so.transform.ry), Math.cos(so.transform.ry)], last = pts[pts.length - 1];
54795
- if (last[1] < 0.3 + E.pos[1]) {
54796
- const foot = [sp[0] + dir[0] * 0.035, E.pos[1] + 0.012, sp[2] + dir[1] * 0.035];
54797
- pts.push([last[0] + (foot[0] - last[0]) * 0.4, E.pos[1] + 0.012, last[2] + (foot[2] - last[2]) * 0.4], [last[0] + (foot[0] - last[0]) * 0.75, E.pos[1] + 0.012, last[2] + (foot[2] - last[2]) * 0.75], foot, [foot[0], Math.max(E.pos[1] + 0.1, sp[1] - 0.04), foot[2]], [sp[0] + dir[0] * 0.012, sp[1] - 0.01, sp[2] + dir[1] * 0.012]);
54798
- } else {
54799
- const hang = ik.gfx.catenary(last, [sp[0] + dir[0] * 0.012, sp[1] - 0.01, sp[2] + dir[1] * 0.012], 0.1, 8);
54800
- hang.shift();
54801
- for (const p of hang) pts.push(p);
54802
- }
54803
- }
54909
+ const cut = sid ? sid.indexOf(":") : -1, so = sid ? w.get(sid.slice(0, cut)) : void 0, sk = sid && so ? (so.spec.sockets || []).find((s) => s.id === sid.slice(cut + 1)) : void 0;
54910
+ if (!so || !sk) continue;
54911
+ const sp = wl(so, sk.pos), dir = [Math.sin(so.transform.ry), Math.cos(so.transform.ry)], last = pts[pts.length - 1];
54912
+ if (last[1] < 0.3 + E.pos[1]) {
54913
+ const foot = [sp[0] + dir[0] * 0.035, E.pos[1] + 0.012, sp[2] + dir[1] * 0.035];
54914
+ pts.push([last[0] + (foot[0] - last[0]) * 0.4, E.pos[1] + 0.012, last[2] + (foot[2] - last[2]) * 0.4], [last[0] + (foot[0] - last[0]) * 0.75, E.pos[1] + 0.012, last[2] + (foot[2] - last[2]) * 0.75], foot, [foot[0], Math.max(E.pos[1] + 0.1, sp[1] - 0.04), foot[2]], [sp[0] + dir[0] * 0.012, sp[1] - 0.01, sp[2] + dir[1] * 0.012]);
54915
+ } else {
54916
+ const hang = ik.gfx.catenary(last, [sp[0] + dir[0] * 0.012, sp[1] - 0.01, sp[2] + dir[1] * 0.012], 0.1, 8);
54917
+ hang.shift();
54918
+ for (const p of hang) pts.push(p);
54804
54919
  }
54920
+ shared2.ctx.cordPaths?.push({ object: E.id, device: d.id, points: pts.map((p) => [p[0], p[1], p[2]]) });
54805
54921
  tube2(pts, 6e-3, IV_WIRE.cord, 0, 0, 0, 0);
54806
54922
  }
54807
54923
  }
@@ -54837,12 +54953,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54837
54953
  }
54838
54954
  IV.dirty = true;
54839
54955
  switch (e.type) {
54840
- case "part":
54956
+ case "part": {
54841
54957
  if (e.part === "_x") break;
54842
54958
  IV.anim.set(e.object + "|" + e.part, { object: e.object, part: e.part, target: e.target, t0: IV.t });
54843
54959
  IV.itemsDirty = true;
54960
+ const E = e.target > 0 ? IV.entries.get(e.object) : void 0;
54961
+ if (E) ivContents(IV, E)?.sync();
54844
54962
  invalidate();
54845
54963
  break;
54964
+ }
54965
+ // the contents are drawn before the part moves, so they ride it from its first frame
54846
54966
  case "device": {
54847
54967
  const roomId = IV.lampRoom.get(e.object);
54848
54968
  if (roomId) shared2.partState.set("light:" + roomId, !!e.on);
@@ -54853,6 +54973,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54853
54973
  hudMessage(e.text);
54854
54974
  break;
54855
54975
  case "pickup":
54976
+ IV.contents.get(e.object)?.sync();
54856
54977
  IV.itemsDirty = true;
54857
54978
  if (e.actor === "player" && e.stack) {
54858
54979
  const d = IV.world.t("item." + e.stack.type);
@@ -54897,6 +55018,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54897
55018
  for (const [k, a] of IV.anim) {
54898
55019
  const E = IV.entries.get(a.object);
54899
55020
  if (E && E.parts) ik.gfx.syncObject(w, a.object, E.parts, { time: IV.t });
55021
+ IV.contents.get(a.object)?.sync();
54900
55022
  if (w.partT(a.object, a.part) === a.target || IV.t - a.t0 > 4) IV.anim.delete(k);
54901
55023
  }
54902
55024
  invalidateShadow();
@@ -54936,28 +55058,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54936
55058
  invalidate();
54937
55059
  }
54938
55060
  }
54939
- if (ivk.items && IV.itemsDirty && IV.t - IV.itemsT > 0.1 && !IV.anim.size) ivItems(IV, h);
54940
- }
54941
- const IV_SHAPE = {
54942
- can: [["cyl", 1, 1, 1, 0, 1]],
54943
- bottle: [["cyl", 0.9, 0.72, 0.9, 0, 1], ["cyl", 0.36, 0.3, 0.36, 0.7, 0.55]],
54944
- jar: [["cyl", 1, 0.86, 1, 0, 1], ["cyl", 1.02, 0.14, 1.02, 0.86, 0.6]],
54945
- cup: [["cyl", 1, 1, 1, 0, 1]],
54946
- dish: [["cyl", 1, 0.3, 1, 0, 1]],
54947
- roll: [["cyl", 1, 1, 1, 0, 1]],
54948
- tube: [["cyl", 0.6, 1, 0.6, 0, 1]],
54949
- fruit: [["sphere", 1, 1, 1, 0, 1]],
54950
- bag: [["box", 1, 0.9, 1, 0, 1], ["box", 0.9, 0.1, 0.5, 0.9, 0.7]],
54951
- box: [["box", 1, 1, 1, 0, 1]],
54952
- cloth: [["box", 1, 1, 1, 0, 1]],
54953
- paper: [["box", 1, 1, 1, 0, 1]],
54954
- tool: [["box", 1, 1, 1, 0, 1]],
54955
- shoe: [["box", 1, 0.7, 1, 0, 1]]
54956
- };
55061
+ if (ivk.items && IV.itemsDirty && IV.t - IV.itemsT > 0.1) ivItems(IV, h);
55062
+ }
55063
+ function ivContents(IV, E) {
55064
+ const had = IV.contents.get(E.id);
55065
+ if (had) return had;
55066
+ const ik = IV.k, make3 = ik.GT.createContentsView;
55067
+ if (!ik.items || !ik.itemModel || !make3 || !(E.spec.containers || []).length) return null;
55068
+ const view = make3(THREE, { world: IV.world, objectId: E.id, root: E.root, buildItem: ik.itemModel });
55069
+ IV.contents.set(E.id, view);
55070
+ view.sync();
55071
+ invalidateShadow();
55072
+ return view;
55073
+ }
54957
55074
  function ivItems(IV, h) {
54958
55075
  IV.itemsDirty = false;
54959
55076
  IV.itemsT = IV.t;
54960
- const w = IV.world, items = IV.k.A.household.items, f = IV.focus, g0 = cursor.group, list2 = [];
55077
+ const w = IV.world, f = IV.focus;
54961
55078
  let fl = null;
54962
55079
  if (f) {
54963
55080
  h.houseGroup.updateWorldMatrix(true, false);
@@ -54965,57 +55082,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54965
55082
  h.houseGroup.worldToLocal(fl);
54966
55083
  }
54967
55084
  for (const E of IV.entries.values()) {
55085
+ const view = IV.contents.get(E.id);
55086
+ if (view) {
55087
+ view.sync();
55088
+ continue;
55089
+ }
54968
55090
  if (fl && E.floor >= 0 && Math.hypot(E.pos[0] - fl.x, E.pos[2] - fl.z) > 14) continue;
54969
55091
  for (const c of E.spec.containers || []) {
54970
- if (!w.accessible(E.id, c.id)) continue;
54971
- if (c.access && w.partT(E.id, c.access) < 0.02) continue;
54972
- const st = w.contents(E.id, c.id);
54973
- for (let i = 0; i < st.length; i++) {
54974
- const stack = st[i];
54975
- if (stack && items[stack.type]) list2.push([E, c.id, i, items[stack.type]]);
55092
+ if (c.access && w.partT(E.id, c.access) <= 0) continue;
55093
+ if (w.contents(E.id, c.id).some((st) => st !== null)) {
55094
+ ivContents(IV, E);
55095
+ break;
54976
55096
  }
54977
55097
  }
54978
55098
  }
54979
- if (!list2.length) {
54980
- if (IV.items) IV.items.visible = false;
54981
- return;
54982
- }
54983
- cursor.group = "iv-items";
54984
- try {
54985
- for (const [E, cid, slot, def] of list2) {
54986
- const p = w.slotPosition(E.id, cid, slot), form = IV_SHAPE[def.shape] || IV_SHAPE.box;
54987
- for (const [geo, fx, fy, fz, y0, tone] of form) {
54988
- const sx = def.size[0] * fx, sy = def.size[1] * fy, sz = def.size[2] * fz;
54989
- _q.setFromAxisAngle(_Y, E.ry);
54990
- const color2 = def.color == null ? 13421772 : def.color;
54991
- put("plain", geo, p[0], p[1] + def.size[1] * y0 + sy / 2, p[2], _q, sx, sy, sz, tone === 1 ? color2 : sh(color2, tone));
54992
- }
54993
- }
54994
- const A = cursor.accs.get("iv-items|plain");
54995
- cursor.accs.delete("iv-items|plain");
54996
- const gm = new THREE.BufferGeometry();
54997
- gm.setAttribute("position", new THREE.BufferAttribute(A.p.slice(0, A.nv * 3), 3));
54998
- gm.setAttribute("normal", new THREE.BufferAttribute(A.n.slice(0, A.nv * 3), 3));
54999
- gm.setAttribute("color", new THREE.BufferAttribute(A.c.slice(0, A.nv * 3), 3));
55000
- gm.setAttribute("uv", new THREE.BufferAttribute(A.u.slice(0, A.nv * 2), 2));
55001
- gm.setIndex(new THREE.BufferAttribute(A.i.slice(0, A.ni), 1));
55002
- gm.computeBoundingSphere();
55003
- if (!IV.items) {
55004
- const mesh2 = new THREE.Mesh(gm, shared2.mats.plain);
55005
- IV.items = mesh2;
55006
- mesh2.name = "iv-items";
55007
- mesh2.castShadow = false;
55008
- mesh2.receiveShadow = true;
55009
- mesh2.frustumCulled = false;
55010
- h.houseGroup.add(mesh2);
55011
- } else {
55012
- IV.items.geometry.dispose();
55013
- IV.items.geometry = gm;
55014
- }
55015
- IV.items.visible = true;
55016
- } finally {
55017
- cursor.group = g0;
55018
- }
55019
55099
  invalidateShadow();
55020
55100
  }
55021
55101
  function ivTarget(IV, o, opt) {
@@ -55074,7 +55154,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55074
55154
  }
55075
55155
  }
55076
55156
  for (const sc of IV.screens.values()) sc.dispose();
55077
- if (IV.items) IV.items.geometry.dispose();
55157
+ for (const view of IV.contents.values()) view.dispose();
55158
+ IV.contents.clear();
55078
55159
  }
55079
55160
  function ivPublish(h) {
55080
55161
  const IV = h.IV, w = IV.world, ik = IV.k, com = (fn) => (...a) => {
@@ -55141,7 +55222,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55141
55222
  };
55142
55223
  return IV.pub;
55143
55224
  }
55144
- const defined = { IV_MATERIAL, IV_WIRE, IV_DOOR, ivGroup, ivAccumulate, ivBuild, ivRoomEffective, ivDraw, ivCords, ivAssemble, ivScreen, ivEvent, ivSeat, ivUpdate, IV_SHAPE, ivItems, ivTarget, ivRoomLight, ivParts, ivDispose, ivPublish };
55225
+ const defined = { IV_MATERIAL, IV_WIRE, IV_DOOR, ivGroup, ivAccumulate, ivBuild, ivRoomEffective, ivDraw, ivCords, ivAssemble, ivScreen, ivEvent, ivSeat, ivUpdate, ivItems, ivContents, ivTarget, ivRoomLight, ivParts, ivDispose, ivPublish };
55145
55226
  Object.assign(K, defined);
55146
55227
  }
55147
55228
  function installAnimationClotheslines(K, shared2) {
@@ -55204,7 +55285,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55204
55285
  return null;
55205
55286
  }
55206
55287
  const A = AD.plan ? AD : AD.create({ ...o.adapterOptions || {}, GameInteractables: GI, GameInteractablesHousehold: HH, locale: o.locale || cfg.locale, region: o.region, ...cfg.seedKey ? { seedKey: cfg.seedKey } : {} });
55207
- return { GI, HH, GT, A, gfx: GT.createThreeAdapter(THREE, { document: DOC, Reflector }), items: o.items !== false, effects: o.effects !== false, effectSink: o.effectSink || null, camera: o.camera || null, onEvent: o.onEvent || null, onSeat: o.onSeat || null };
55288
+ return { GI, HH, GT, A, gfx: GT.createThreeAdapter(THREE, { document: DOC, Reflector }), items: o.items !== false, itemModel: o.itemModel || null, effects: o.effects !== false, effectSink: o.effectSink || null, camera: o.camera || null, onEvent: o.onEvent || null, onSeat: o.onSeat || null };
55208
55289
  })();
55209
55290
  const VEG = (() => {
55210
55291
  const l = cfg.vegetation || null, G = l && (l.GameVegetation || (l.buildLot ? l : null)), S = l && (l.GameVegetationSpecies || (l.toSpec ? l : null));
@@ -55762,14 +55843,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55762
55843
  }
55763
55844
  return best;
55764
55845
  };
55765
- const gapOf = (p, q) => Math.hypot(Math.max(0, q.aabb[0] - p.aabb[2], p.aabb[0] - q.aabb[2]), Math.max(0, q.y0 - p.y1, p.y0 - q.y1), Math.max(0, q.aabb[1] - p.aabb[3], p.aabb[1] - q.aabb[3]));
55846
+ const gapOf2 = (p, q) => Math.hypot(Math.max(0, q.aabb[0] - p.aabb[2], p.aabb[0] - q.aabb[2]), Math.max(0, q.y0 - p.y1, p.y0 - q.y1), Math.max(0, q.aabb[1] - p.aabb[3], p.aabb[1] - q.aabb[3]));
55766
55847
  const centreGapOf = (p, q) => Math.hypot((p.aabb[0] + p.aabb[2] - q.aabb[0] - q.aabb[2]) / 2, (p.y0 + p.y1 - q.y0 - q.y1) / 2, (p.aabb[1] + p.aabb[3] - q.aabb[1] - q.aabb[3]) / 2);
55767
55848
  const wallBeside = (p, reach2) => {
55768
55849
  for (const roles of [WALL_ROLES, SPAN_ROLES]) {
55769
55850
  let best = null, bd = Infinity, bc = Infinity;
55770
55851
  for (const q of parts2) {
55771
55852
  if (q === p || !(q.extra ? roles === WALL_ROLES && Array.isArray(q.tags) && q.tags.includes("wall") : roles.has(q.role))) continue;
55772
- const d = gapOf(p, q);
55853
+ const d = gapOf2(p, q);
55773
55854
  if (d > reach2) continue;
55774
55855
  const c = centreGapOf(p, q);
55775
55856
  if (d < bd || d === bd && (c < bc || c === bc && best !== null && q.id < best.id)) {
@@ -58050,8 +58131,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58050
58131
  shared2.ctx.pu = Math.max(0, pr.unit != null ? pr.unit : 0);
58051
58132
  shared2.ctx.showBuilding = shared2.ctx.apartment && (pr.showIt == null ? true : !!pr.showIt);
58052
58133
  shared2.ctx.limits = { x0: -2, z0: -2, x1: r.w + 2, z1: r.d + 2 };
58053
- shared2.ctx.veg = VEG ? { G: VEG.G, S: VEG.S, mats: vegMaterials, groups: /* @__PURE__ */ new Map(), ok: /* @__PURE__ */ new Map(), opts: shared2.quality === "game" ? { quality: "game" } : { quality: "high", lod: 0, triangleBudget: 6e4 } } : null;
58134
+ shared2.ctx.veg = VEG ? { G: VEG.G, S: VEG.S, mats: vegMaterials, groups: /* @__PURE__ */ new Map(), ok: /* @__PURE__ */ new Map(), sizes: /* @__PURE__ */ new Map(), opts: shared2.quality === "game" ? { quality: "game" } : { quality: "high", lod: 0, triangleBudget: 6e4 } } : null;
58054
58135
  shared2.ctx.vegInfo = null;
58136
+ shared2.ctx.itemBounds = opts.itemBounds ? [] : void 0;
58137
+ shared2.ctx.cordPaths = opts.itemBounds ? [] : void 0;
58055
58138
  const cs = !!(opts.constructionStages || opts.constructionLevel != null);
58056
58139
  shared2.ctx.constructionStages = cs;
58057
58140
  if (Y0(0) > 0 && !shared2.ctx.visorScene) shared2.ctx.unitGround = Y0(0);
@@ -58699,6 +58782,90 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58699
58782
  installBuildBuild(K, shared2);
58700
58783
  return buildApi(K, shared2);
58701
58784
  }
58785
+ var HOLD_REACH2 = 0.05;
58786
+ var BACK_TOUCH = 0.02;
58787
+ var SOFT = /* @__PURE__ */ new Set(["fabric", "paper", "foliage"]);
58788
+ var gapOf = (a, b) => Math.max(0, ...[0, 1, 2].map((k) => Math.max(a.min[k] - b.max[k], b.min[k] - a.max[k])));
58789
+ function groupsOf(parts2, joints) {
58790
+ const root = new Map(parts2.map((part) => [part.id, part.id]));
58791
+ const find = (id) => {
58792
+ let at2 = id;
58793
+ while (root.get(at2) !== at2) at2 = root.get(at2);
58794
+ root.set(id, at2);
58795
+ return at2;
58796
+ };
58797
+ for (const joint of joints) root.set(find(joint.a), find(joint.b));
58798
+ const groups = /* @__PURE__ */ new Map();
58799
+ for (const part of parts2) {
58800
+ const at2 = find(part.id);
58801
+ groups.set(at2, [...groups.get(at2) ?? [], part.id]);
58802
+ }
58803
+ return [...groups.values()];
58804
+ }
58805
+ function nearestJoint(loose, held, boxOf3, reach2) {
58806
+ let best = null;
58807
+ for (const a of loose) {
58808
+ for (const b of held) {
58809
+ const gap = gapOf(boxOf3(a.id), boxOf3(b.id));
58810
+ if (gap <= reach2 && (!best || gap < best.gap)) best = { gap, a, b };
58811
+ }
58812
+ }
58813
+ if (!best) return null;
58814
+ const [joint] = inferJoints([best.a, best.b], best.gap + 0.05);
58815
+ return joint ? { ...joint, id: `${best.a.id}~${best.b.id}` } : null;
58816
+ }
58817
+ var FLOOR_TOUCH = 5e-3;
58818
+ var STANDS_ALONE = 0.3;
58819
+ function standsAlone(group, boxOf3) {
58820
+ const feet = group.map((part) => boxOf3(part.id)).filter((box4) => box4.min[1] <= FLOOR_TOUCH);
58821
+ if (feet.length === 0) return false;
58822
+ const height = Math.max(...group.map((part) => boxOf3(part.id).max[1]));
58823
+ const across2 = (k) => Math.max(...feet.map((box4) => box4.max[k])) - Math.min(...feet.map((box4) => box4.min[k]));
58824
+ return Math.min(across2(0), across2(2)) >= STANDS_ALONE * height;
58825
+ }
58826
+ function joinBodies({ parts: parts2, joints, boxOf: boxOf3 }, byId) {
58827
+ const groups = groupsOf(parts2, joints).map((ids) => ids.map((id) => byId.get(id))).sort((a, b) => b.length - a.length);
58828
+ const [main, ...rest2] = groups;
58829
+ if (!main) return;
58830
+ for (const group of rest2) {
58831
+ if (standsAlone(group, boxOf3)) continue;
58832
+ const joint = nearestJoint(group, main, boxOf3, Infinity);
58833
+ if (joint) joints.push(joint);
58834
+ }
58835
+ }
58836
+ function holdLooseGroups(params) {
58837
+ const byId = new Map(params.parts.map((part) => [part.id, part]));
58838
+ holdHanging(params, byId);
58839
+ joinBodies(params, byId);
58840
+ }
58841
+ function holdHanging({ parts: parts2, joints, boxOf: boxOf3 }, byId) {
58842
+ const back = Math.min(...parts2.map((part) => boxOf3(part.id).min[2]));
58843
+ for (let pass = 0; pass < parts2.length; pass++) {
58844
+ const groups = groupsOf(parts2, joints).map((ids) => ids.map((id) => byId.get(id)));
58845
+ const held = groups.filter((group) => group.some((part) => part.anchored)).flat();
58846
+ const loose = groups.filter((group) => !group.some((part) => part.anchored));
58847
+ if (loose.length === 0) return;
58848
+ let changed = false;
58849
+ for (const group of loose) {
58850
+ const joint = nearestJoint(group, held, boxOf3, HOLD_REACH2);
58851
+ if (joint) {
58852
+ joints.push(joint);
58853
+ changed = true;
58854
+ continue;
58855
+ }
58856
+ const onWall = group.filter((part) => !SOFT.has(part.material) && boxOf3(part.id).min[2] <= back + BACK_TOUCH);
58857
+ if (onWall.length === 0) continue;
58858
+ for (const part of onWall) part.anchored = true;
58859
+ changed = true;
58860
+ }
58861
+ if (changed) continue;
58862
+ for (const group of loose) {
58863
+ const joint = nearestJoint(group, held, boxOf3, Infinity);
58864
+ if (joint) joints.push(joint);
58865
+ }
58866
+ return;
58867
+ }
58868
+ }
58702
58869
  var WOOD_THIN = 0.035;
58703
58870
  var BOARD_TOP_THICK = 0.07;
58704
58871
  var BOARD_TOP_WIDTH = 0.5;
@@ -58750,7 +58917,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58750
58917
  const channel = (shift) => Math.min(255, Math.round((color2 >> shift & 255) * k)) << shift;
58751
58918
  return channel(16) | channel(8) | channel(0);
58752
58919
  }
58753
- var FLOOR_TOUCH = 5e-3;
58920
+ var FLOOR_TOUCH2 = 5e-3;
58754
58921
  var LOOSE = /* @__PURE__ */ new Set(["paper"]);
58755
58922
  var BASE_MATERIAL = {
58756
58923
  wood: "wood_hard",
@@ -58835,7 +59002,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58835
59002
  else if (p.key === "wood" && material === "wood_hard" && thin < WOOD_THIN) material = "wood_soft";
58836
59003
  const part = { id: p.id, material, shape: p.shape, position: p.position };
58837
59004
  if (p.rotation) part.rotation = p.rotation;
58838
- if (!LOOSE.has(material) && p.min[1] <= FLOOR_TOUCH) part.anchored = true;
59005
+ if (!LOOSE.has(material) && p.min[1] <= FLOOR_TOUCH2) part.anchored = true;
58839
59006
  if (opts.carcass && LOOSE.has(material)) {
58840
59007
  part.hands = 1;
58841
59008
  part.tags = ["book"];
@@ -58858,6 +59025,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58858
59025
  }
58859
59026
  joints.push(j);
58860
59027
  }
59028
+ holdLooseGroups({ parts: parts2, joints, boxOf: (id) => byId.get(id) });
59029
+ const low = (part) => byId.get(part.id).min[1];
59030
+ const wallMounted = parts2.some((part) => part.anchored && low(part) > FLOOR_TOUCH2);
59031
+ const sunk = parts2.some((part) => low(part) < -FLOOR_TOUCH2);
59032
+ const rooted = parts2.some((part) => part.material === "foliage") && parts2.some((part) => part.material.startsWith("wood") && low(part) <= FLOOR_TOUCH2);
59033
+ const fixed = wallMounted || sunk || rooted;
58861
59034
  const all = drawn.reduce(
58862
59035
  (m, p) => ({ x0: Math.min(m.x0, p.min[0]), x1: Math.max(m.x1, p.max[0]), z0: Math.min(m.z0, p.min[2]), z1: Math.max(m.z1, p.max[2]) }),
58863
59036
  { x0: Infinity, x1: -Infinity, z0: Infinity, z1: -Infinity }
@@ -58879,7 +59052,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58879
59052
  if ((max[0] - min[0]) * (max[1] - min[1]) >= 0.6 * footprint && mid.max[1] >= 0.2) top = { part: mid.id, y: mid.max[1], parts: boards.map((b) => b.id) };
58880
59053
  }
58881
59054
  if (opts.carcass) carcass(parts2, byId);
58882
- const spec = { name, parts: parts2, joints, tags: ["furniture"] };
59055
+ const spec = { name, parts: parts2, joints, tags: ["furniture"], ...fixed ? { fixed } : {} };
58883
59056
  const colors = new Map(drawn.map((p) => [p.id, p.color]));
58884
59057
  const build = (T3) => {
58885
59058
  const group = markKitOrigin(new T3.Group(), { owner: "game-floorplan-three", kind: "furniture", id: name });
@@ -58909,7 +59082,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58909
59082
  }
58910
59083
  return group;
58911
59084
  };
58912
- return { spec, build, top };
59085
+ return { spec, build, top, fixed };
58913
59086
  }
58914
59087
  function furnitureSpec(THREE, type, opts = {}) {
58915
59088
  const renderer = rendererOf(THREE, opts.document);
@@ -58945,7 +59118,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58945
59118
  );
58946
59119
  const spouts = K.PARTS.slice(before).filter((p) => p.type === "water_tap").map((p) => [p.pos[0] - root.x, p.pos[1], p.pos[2] - root.z]);
58947
59120
  K.PARTS.length = before;
58948
- return { spec: made.spec, build: made.build, top: made.top, size: { w, d, h }, spouts };
59121
+ return { spec: made.spec, build: made.build, top: made.top, size: { w, d, h }, spouts, fixed: made.fixed };
58949
59122
  }
58950
59123
 
58951
59124
  // src/area-layout.ts