@adatechnology/game-interactables-household 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +121 -2
- package/dist/index.global.js +1146 -114
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +693 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.global.js
CHANGED
|
@@ -28,16 +28,17 @@ var GameInteractablesHousehold = (() => {
|
|
|
28
28
|
HOUSEHOLD_TYPES: () => HOUSEHOLD_TYPES,
|
|
29
29
|
STOVE_WALL_GAP: () => STOVE_WALL_GAP,
|
|
30
30
|
WALL_PLATE: () => WALL_PLATE,
|
|
31
|
+
assembleHouseholdType: () => assembleHouseholdType,
|
|
31
32
|
cornersOf: () => cornersOf,
|
|
32
33
|
createHousehold: () => createHousehold,
|
|
34
|
+
createHouseholdAssemblies: () => createHouseholdAssemblies,
|
|
33
35
|
createRecorder: () => createRecorder,
|
|
36
|
+
drawHouseholdAssembly: () => drawHouseholdAssembly,
|
|
34
37
|
motionPoint: () => motionPoint,
|
|
35
38
|
sweepOf: () => sweepOf
|
|
36
39
|
});
|
|
37
40
|
|
|
38
|
-
// ../game-contracts/
|
|
39
|
-
var DEFAULT_BLAST_IMPULSE = { bodyArea: 0.7, lift: 0.15, minSpeed: 0.3, tntPerJoule: 0.24 / 2e5 };
|
|
40
|
-
var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
|
|
41
|
+
// ../game-contracts/src/spec.ts
|
|
41
42
|
var STRUCTURE_ROLES = ["foundation", "column", "beam", "slab", "wall", "partition", "roof", "stair", "none"];
|
|
42
43
|
var BEARS = [true, false, "a_on_b", "b_on_a"];
|
|
43
44
|
var finite = (n) => typeof n === "number" && Number.isFinite(n);
|
|
@@ -140,48 +141,16 @@ var GameInteractablesHousehold = (() => {
|
|
|
140
141
|
}
|
|
141
142
|
return { ok: problems.length === 0, problems, warnings };
|
|
142
143
|
};
|
|
144
|
+
|
|
145
|
+
// ../game-contracts/src/seal.ts
|
|
143
146
|
var sealBlock = (seal, state) => {
|
|
144
147
|
if (seal.spoilsWhenBreached && state.breached) return "breached";
|
|
145
148
|
if (seal.spoilsWhenBreached && state.leaked) return "leaked";
|
|
146
149
|
if (!state.opened) return "sealed";
|
|
147
150
|
return void 0;
|
|
148
151
|
};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
BREACH_PAINT: "floorplan.breach-paint",
|
|
152
|
-
BREACH_CUT: "floorplan.breach-cut",
|
|
153
|
-
AUDIO_VOICES: "audio.voices",
|
|
154
|
-
VEHICLE_CREASE: "vehicles.crease",
|
|
155
|
-
AUDIO_OCCLUSION: "audio.occlusion",
|
|
156
|
-
FLUID_FILM: "fluids.film",
|
|
157
|
-
VEHICLE_LOD_BATCH: "vehicles.lod-batch",
|
|
158
|
-
SETTLED_BATCH: "destruction.settled-batch",
|
|
159
|
-
STATIC_BATCH: "render.static-batch",
|
|
160
|
-
ANIMALS_STATIC_BATCH: "animals.static-batch",
|
|
161
|
-
CHARACTERS_STATIC_BATCH: "characters.static-batch",
|
|
162
|
-
HOUSE_SHADOW_BATCH: "floorplan.shadow-batch",
|
|
163
|
-
DESTRUCTION_PREFIT: "destruction.prefit"
|
|
164
|
-
};
|
|
165
|
-
var DEFERRED_PRIORITY = {
|
|
166
|
-
[DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS]: { priority: 300, phase: "present" },
|
|
167
|
-
// every frame: the walls cut since the last frame are painted once each, and a hole must show in the frame of the blast
|
|
168
|
-
[DEFERRED_QUEUE_ID.BREACH_CUT]: { priority: 260, phase: "present", minEveryFrames: 1 },
|
|
169
|
-
[DEFERRED_QUEUE_ID.BREACH_PAINT]: { priority: 250, phase: "present", minEveryFrames: 1 },
|
|
170
|
-
[DEFERRED_QUEUE_ID.AUDIO_VOICES]: { priority: 200, phase: "idle", reserveMs: 1 },
|
|
171
|
-
[DEFERRED_QUEUE_ID.AUDIO_OCCLUSION]: { priority: 190, phase: "idle", minEveryFrames: 8 },
|
|
172
|
-
[DEFERRED_QUEUE_ID.FLUID_FILM]: { priority: 120, phase: "idle", minEveryFrames: 2 },
|
|
173
|
-
[DEFERRED_QUEUE_ID.VEHICLE_CREASE]: { priority: 100, phase: "idle" },
|
|
174
|
-
[DEFERRED_QUEUE_ID.VEHICLE_LOD_BATCH]: { priority: 90, phase: "idle", minEveryFrames: 4 },
|
|
175
|
-
[DEFERRED_QUEUE_ID.SETTLED_BATCH]: { priority: 70, phase: "idle", minEveryFrames: 8 },
|
|
176
|
-
[DEFERRED_QUEUE_ID.STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
177
|
-
[DEFERRED_QUEUE_ID.ANIMALS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
178
|
-
[DEFERRED_QUEUE_ID.CHARACTERS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
179
|
-
[DEFERRED_QUEUE_ID.HOUSE_SHADOW_BATCH]: { priority: 50, phase: "idle", minEveryFrames: 8 },
|
|
180
|
-
[DEFERRED_QUEUE_ID.DESTRUCTION_PREFIT]: { priority: 40, phase: "idle", minEveryFrames: 30 }
|
|
181
|
-
};
|
|
182
|
-
var MUST_DRAIN_QUEUE_IDS = /* @__PURE__ */ new Set([DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS, DEFERRED_QUEUE_ID.BREACH_CUT]);
|
|
183
|
-
var BODY_FOAM_SURFACES = ["hands", "arms", "torso", "hair", "mouth"];
|
|
184
|
-
var WASH_SURFACES = [...BODY_FOAM_SURFACES, "brush"];
|
|
152
|
+
|
|
153
|
+
// ../game-contracts/src/warn.ts
|
|
185
154
|
var WARNED_KEY = /* @__PURE__ */ Symbol.for("@adatechnology/game-contracts.warned");
|
|
186
155
|
var warnedKeys = () => {
|
|
187
156
|
const holder = globalThis;
|
|
@@ -202,6 +171,8 @@ var GameInteractablesHousehold = (() => {
|
|
|
202
171
|
seen.add(key);
|
|
203
172
|
console.warn(`[game-kit] ${message}`);
|
|
204
173
|
};
|
|
174
|
+
|
|
175
|
+
// ../game-contracts/src/registry.ts
|
|
205
176
|
var UNSAFE_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
206
177
|
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
207
178
|
var deepMerge = (base, patch) => {
|
|
@@ -231,6 +202,8 @@ var GameInteractablesHousehold = (() => {
|
|
|
231
202
|
if (!entries.delete(id)) warnOnce(`registry.remove.${id}`, `remove of "${id}" ignored: no entry has that id`);
|
|
232
203
|
}
|
|
233
204
|
};
|
|
205
|
+
|
|
206
|
+
// ../game-contracts/src/categories.ts
|
|
234
207
|
var defineCategories = (defs, options = {}) => {
|
|
235
208
|
const problems = [];
|
|
236
209
|
const duplicates = (list) => {
|
|
@@ -294,60 +267,55 @@ var GameInteractablesHousehold = (() => {
|
|
|
294
267
|
return registry;
|
|
295
268
|
};
|
|
296
269
|
var resolveEntry = (registry, entry, kindField = "kind") => deepMerge(registry.defaults(String(entry[kindField])), entry);
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
var
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
[WORKER_KIND_ID.STATIC_COLLIDERS]: { lane: "build", priority: 150, late: "sync" },
|
|
347
|
-
[WORKER_KIND_ID.SHAPES_GENERATE]: { lane: "build", priority: 100, late: "sync" },
|
|
348
|
-
[WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" },
|
|
349
|
-
[WORKER_KIND_ID.VEHICLE_HULL_PLAN]: { lane: "build", priority: 120, late: "keep-waiting" }
|
|
350
|
-
};
|
|
270
|
+
|
|
271
|
+
// ../game-interactables/src/math.ts
|
|
272
|
+
var DEFAULT_AXIS = [0, 1, 0];
|
|
273
|
+
function poseOf(motion, t) {
|
|
274
|
+
const tt = Math.max(0, Math.min(1, t));
|
|
275
|
+
const axis = motion.axis ?? DEFAULT_AXIS;
|
|
276
|
+
const pose = { position: [0, 0, 0], rotation: { axis: [axis[0], axis[1], axis[2]], angle: 0 }, scale: [1, 1, 1] };
|
|
277
|
+
switch (motion.kind) {
|
|
278
|
+
case "hinge":
|
|
279
|
+
case "rocker":
|
|
280
|
+
case "knob":
|
|
281
|
+
pose.rotation.angle = (motion.angle ?? Math.PI / 2) * tt;
|
|
282
|
+
break;
|
|
283
|
+
case "slide": {
|
|
284
|
+
const d = (motion.distance ?? 0.4) * tt;
|
|
285
|
+
pose.position = [axis[0] * d, axis[1] * d, axis[2] * d];
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
case "scale": {
|
|
289
|
+
const k = 1 + ((motion.scale ?? 0.2) - 1) * tt;
|
|
290
|
+
pose.scale = [axis[0] !== 0 ? k : 1, axis[1] !== 0 ? k : 1, axis[2] !== 0 ? k : 1];
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return pose;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// ../game-interactables/src/cast-with-member.ts
|
|
298
|
+
var COLLAR_REACH = 0.03;
|
|
299
|
+
var END_GAP = 5e-3;
|
|
300
|
+
function centredOn(member, other) {
|
|
301
|
+
for (const k of [0, 2]) {
|
|
302
|
+
if (other[k] < member[k] - COLLAR_REACH || other[k + 3] > member[k + 3] + COLLAR_REACH) return false;
|
|
303
|
+
if (Math.abs((other[k] + other[k + 3]) / 2 - (member[k] + member[k + 3]) / 2) > COLLAR_REACH) return false;
|
|
304
|
+
}
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
function wrapsMember(member, collar) {
|
|
308
|
+
const overlap = Math.min(collar[4], member[4]) - Math.max(collar[1], member[1]);
|
|
309
|
+
return overlap >= (collar[4] - collar[1]) / 2 && centredOn(member, collar);
|
|
310
|
+
}
|
|
311
|
+
function endsMember(member, end) {
|
|
312
|
+
const under = Math.abs(end[4] - member[1]) <= END_GAP;
|
|
313
|
+
const over = Math.abs(end[1] - member[4]) <= END_GAP;
|
|
314
|
+
return (under || over) && end[4] - end[1] <= member[4] - member[1] && centredOn(member, end);
|
|
315
|
+
}
|
|
316
|
+
function castWithMember(member, other) {
|
|
317
|
+
return wrapsMember(member, other) || endsMember(member, other);
|
|
318
|
+
}
|
|
351
319
|
|
|
352
320
|
// ../game-items/dist/index.js
|
|
353
321
|
var DEFAULT_RULES = {
|
|
@@ -458,6 +426,11 @@ var GameInteractablesHousehold = (() => {
|
|
|
458
426
|
}
|
|
459
427
|
}
|
|
460
428
|
};
|
|
429
|
+
var consumableLiters = (spec) => spec?.form === "liquid" && spec.unit === "ml" ? spec.amount / 1e3 : void 0;
|
|
430
|
+
var itemFluid = (item) => {
|
|
431
|
+
if (!item.fluid) return void 0;
|
|
432
|
+
return { liquid: item.fluid.liquid, liters: consumableLiters(item.consumable) ?? item.fluid.liters ?? 0 };
|
|
433
|
+
};
|
|
461
434
|
var FRESH_NUTRITION = { satietyFactor: 1, poisonChance: 0, morale: 0, isEdible: true };
|
|
462
435
|
var nutritionOf = (item, context, rules) => {
|
|
463
436
|
const state = context.freshness ?? "fresh";
|
|
@@ -600,6 +573,121 @@ var GameInteractablesHousehold = (() => {
|
|
|
600
573
|
}
|
|
601
574
|
]
|
|
602
575
|
},
|
|
576
|
+
{
|
|
577
|
+
id: "eat_with_cutlery",
|
|
578
|
+
body: "mouth",
|
|
579
|
+
duration: 3.1,
|
|
580
|
+
note: "the fork or spoon in the working hand to the food the other hand holds before the chest, a mouthful to the mouth, three times",
|
|
581
|
+
keys: [
|
|
582
|
+
{
|
|
583
|
+
t: 0,
|
|
584
|
+
position: [
|
|
585
|
+
0.22,
|
|
586
|
+
-0.2,
|
|
587
|
+
-0.4
|
|
588
|
+
],
|
|
589
|
+
rotation: [
|
|
590
|
+
0,
|
|
591
|
+
0,
|
|
592
|
+
0
|
|
593
|
+
]
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
t: 0.35,
|
|
597
|
+
position: [
|
|
598
|
+
-0.04,
|
|
599
|
+
-0.3,
|
|
600
|
+
-0.36
|
|
601
|
+
],
|
|
602
|
+
rotation: [
|
|
603
|
+
0.25,
|
|
604
|
+
0,
|
|
605
|
+
0
|
|
606
|
+
]
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
t: 0.8,
|
|
610
|
+
position: [
|
|
611
|
+
0.01,
|
|
612
|
+
0,
|
|
613
|
+
-0.17
|
|
614
|
+
],
|
|
615
|
+
rotation: [
|
|
616
|
+
-0.3,
|
|
617
|
+
0,
|
|
618
|
+
0
|
|
619
|
+
],
|
|
620
|
+
action: "bite"
|
|
621
|
+
},
|
|
622
|
+
{
|
|
623
|
+
t: 1.2,
|
|
624
|
+
position: [
|
|
625
|
+
-0.04,
|
|
626
|
+
-0.3,
|
|
627
|
+
-0.36
|
|
628
|
+
],
|
|
629
|
+
rotation: [
|
|
630
|
+
0.25,
|
|
631
|
+
0,
|
|
632
|
+
0
|
|
633
|
+
]
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
t: 1.65,
|
|
637
|
+
position: [
|
|
638
|
+
0.01,
|
|
639
|
+
0,
|
|
640
|
+
-0.17
|
|
641
|
+
],
|
|
642
|
+
rotation: [
|
|
643
|
+
-0.3,
|
|
644
|
+
0,
|
|
645
|
+
0
|
|
646
|
+
],
|
|
647
|
+
action: "bite"
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
t: 2.05,
|
|
651
|
+
position: [
|
|
652
|
+
-0.04,
|
|
653
|
+
-0.3,
|
|
654
|
+
-0.36
|
|
655
|
+
],
|
|
656
|
+
rotation: [
|
|
657
|
+
0.25,
|
|
658
|
+
0,
|
|
659
|
+
0
|
|
660
|
+
]
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
t: 2.5,
|
|
664
|
+
position: [
|
|
665
|
+
0.01,
|
|
666
|
+
0,
|
|
667
|
+
-0.17
|
|
668
|
+
],
|
|
669
|
+
rotation: [
|
|
670
|
+
-0.3,
|
|
671
|
+
0,
|
|
672
|
+
0
|
|
673
|
+
],
|
|
674
|
+
action: "bite"
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
t: 3.1,
|
|
678
|
+
position: [
|
|
679
|
+
0.22,
|
|
680
|
+
-0.2,
|
|
681
|
+
-0.4
|
|
682
|
+
],
|
|
683
|
+
rotation: [
|
|
684
|
+
0,
|
|
685
|
+
0,
|
|
686
|
+
0
|
|
687
|
+
]
|
|
688
|
+
}
|
|
689
|
+
]
|
|
690
|
+
},
|
|
603
691
|
{
|
|
604
692
|
id: "drink",
|
|
605
693
|
body: "mouth",
|
|
@@ -1656,6 +1744,111 @@ var GameInteractablesHousehold = (() => {
|
|
|
1656
1744
|
}
|
|
1657
1745
|
]
|
|
1658
1746
|
},
|
|
1747
|
+
{
|
|
1748
|
+
id: "rinse_dish",
|
|
1749
|
+
body: "two_hands",
|
|
1750
|
+
duration: 3,
|
|
1751
|
+
note: "the scrubbed dish brought under the running tap and turned so the water runs over one face and then the other, the foam and the rest of the dirt going with it, and back; played again while foam is left; the rinsing keys reach under the tap (aimHandUse)",
|
|
1752
|
+
keys: [
|
|
1753
|
+
{
|
|
1754
|
+
t: 0,
|
|
1755
|
+
position: [
|
|
1756
|
+
0.22,
|
|
1757
|
+
-0.2,
|
|
1758
|
+
-0.4
|
|
1759
|
+
],
|
|
1760
|
+
rotation: [
|
|
1761
|
+
0,
|
|
1762
|
+
0,
|
|
1763
|
+
0
|
|
1764
|
+
]
|
|
1765
|
+
},
|
|
1766
|
+
{
|
|
1767
|
+
t: 0.4,
|
|
1768
|
+
position: [
|
|
1769
|
+
0,
|
|
1770
|
+
-0.55,
|
|
1771
|
+
-0.43
|
|
1772
|
+
],
|
|
1773
|
+
rotation: [
|
|
1774
|
+
-0.5,
|
|
1775
|
+
0,
|
|
1776
|
+
0
|
|
1777
|
+
],
|
|
1778
|
+
reach: true
|
|
1779
|
+
},
|
|
1780
|
+
{
|
|
1781
|
+
t: 0.95,
|
|
1782
|
+
position: [
|
|
1783
|
+
0.02,
|
|
1784
|
+
-0.55,
|
|
1785
|
+
-0.43
|
|
1786
|
+
],
|
|
1787
|
+
rotation: [
|
|
1788
|
+
-0.9,
|
|
1789
|
+
0,
|
|
1790
|
+
0.25
|
|
1791
|
+
],
|
|
1792
|
+
reach: true
|
|
1793
|
+
},
|
|
1794
|
+
{
|
|
1795
|
+
t: 1.5,
|
|
1796
|
+
position: [
|
|
1797
|
+
-0.02,
|
|
1798
|
+
-0.55,
|
|
1799
|
+
-0.43
|
|
1800
|
+
],
|
|
1801
|
+
rotation: [
|
|
1802
|
+
-0.2,
|
|
1803
|
+
0,
|
|
1804
|
+
-0.25
|
|
1805
|
+
],
|
|
1806
|
+
reach: true,
|
|
1807
|
+
action: "rinse"
|
|
1808
|
+
},
|
|
1809
|
+
{
|
|
1810
|
+
t: 2.05,
|
|
1811
|
+
position: [
|
|
1812
|
+
0.02,
|
|
1813
|
+
-0.55,
|
|
1814
|
+
-0.43
|
|
1815
|
+
],
|
|
1816
|
+
rotation: [
|
|
1817
|
+
-0.9,
|
|
1818
|
+
0,
|
|
1819
|
+
0.25
|
|
1820
|
+
],
|
|
1821
|
+
reach: true
|
|
1822
|
+
},
|
|
1823
|
+
{
|
|
1824
|
+
t: 2.6,
|
|
1825
|
+
position: [
|
|
1826
|
+
0,
|
|
1827
|
+
-0.55,
|
|
1828
|
+
-0.43
|
|
1829
|
+
],
|
|
1830
|
+
rotation: [
|
|
1831
|
+
-0.5,
|
|
1832
|
+
0,
|
|
1833
|
+
0
|
|
1834
|
+
],
|
|
1835
|
+
reach: true
|
|
1836
|
+
},
|
|
1837
|
+
{
|
|
1838
|
+
t: 3,
|
|
1839
|
+
position: [
|
|
1840
|
+
0.22,
|
|
1841
|
+
-0.2,
|
|
1842
|
+
-0.4
|
|
1843
|
+
],
|
|
1844
|
+
rotation: [
|
|
1845
|
+
0,
|
|
1846
|
+
0,
|
|
1847
|
+
0
|
|
1848
|
+
]
|
|
1849
|
+
}
|
|
1850
|
+
]
|
|
1851
|
+
},
|
|
1659
1852
|
{
|
|
1660
1853
|
id: "fill_cup",
|
|
1661
1854
|
body: "hand",
|
|
@@ -3291,6 +3484,26 @@ var GameInteractablesHousehold = (() => {
|
|
|
3291
3484
|
"brake_fluid"
|
|
3292
3485
|
]
|
|
3293
3486
|
},
|
|
3487
|
+
{
|
|
3488
|
+
id: "detergent",
|
|
3489
|
+
color: 15916378,
|
|
3490
|
+
opacity: 0.6,
|
|
3491
|
+
stainColor: 14077068,
|
|
3492
|
+
viscosity: 400,
|
|
3493
|
+
density: 1030,
|
|
3494
|
+
dryTime: 1800,
|
|
3495
|
+
gloss: 0.95,
|
|
3496
|
+
leavesMark: true,
|
|
3497
|
+
drink: {
|
|
3498
|
+
thirst: 0,
|
|
3499
|
+
effects: [
|
|
3500
|
+
"poison"
|
|
3501
|
+
]
|
|
3502
|
+
},
|
|
3503
|
+
tags: [
|
|
3504
|
+
"soap"
|
|
3505
|
+
]
|
|
3506
|
+
},
|
|
3294
3507
|
{
|
|
3295
3508
|
id: "shampoo",
|
|
3296
3509
|
color: 6069216,
|
|
@@ -3312,6 +3525,65 @@ var GameInteractablesHousehold = (() => {
|
|
|
3312
3525
|
"sticky"
|
|
3313
3526
|
]
|
|
3314
3527
|
},
|
|
3528
|
+
{
|
|
3529
|
+
id: "fabric_softener",
|
|
3530
|
+
color: 9225452,
|
|
3531
|
+
opacity: 0.8,
|
|
3532
|
+
stainColor: 11061470,
|
|
3533
|
+
viscosity: 80,
|
|
3534
|
+
density: 1e3,
|
|
3535
|
+
dryTime: 1800,
|
|
3536
|
+
gloss: 0.8,
|
|
3537
|
+
leavesMark: true,
|
|
3538
|
+
drink: {
|
|
3539
|
+
thirst: 0,
|
|
3540
|
+
effects: [
|
|
3541
|
+
"poison"
|
|
3542
|
+
]
|
|
3543
|
+
},
|
|
3544
|
+
tags: [
|
|
3545
|
+
"soap"
|
|
3546
|
+
]
|
|
3547
|
+
},
|
|
3548
|
+
{
|
|
3549
|
+
id: "disinfectant",
|
|
3550
|
+
color: 14205040,
|
|
3551
|
+
opacity: 0.6,
|
|
3552
|
+
stainColor: 13154442,
|
|
3553
|
+
viscosity: 1.5,
|
|
3554
|
+
density: 1e3,
|
|
3555
|
+
dryTime: 600,
|
|
3556
|
+
gloss: 0.85,
|
|
3557
|
+
leavesMark: true,
|
|
3558
|
+
drink: {
|
|
3559
|
+
thirst: 0,
|
|
3560
|
+
effects: [
|
|
3561
|
+
"poison"
|
|
3562
|
+
]
|
|
3563
|
+
},
|
|
3564
|
+
tags: [
|
|
3565
|
+
"corrosive"
|
|
3566
|
+
]
|
|
3567
|
+
},
|
|
3568
|
+
{
|
|
3569
|
+
id: "yogurt",
|
|
3570
|
+
color: 15986404,
|
|
3571
|
+
opacity: 1,
|
|
3572
|
+
stainColor: 15130576,
|
|
3573
|
+
viscosity: 1500,
|
|
3574
|
+
density: 1040,
|
|
3575
|
+
dryTime: 7200,
|
|
3576
|
+
gloss: 0.5,
|
|
3577
|
+
leavesMark: true,
|
|
3578
|
+
drink: {
|
|
3579
|
+
thirst: 10,
|
|
3580
|
+
effects: []
|
|
3581
|
+
},
|
|
3582
|
+
tags: [
|
|
3583
|
+
"food",
|
|
3584
|
+
"sticky"
|
|
3585
|
+
]
|
|
3586
|
+
},
|
|
3315
3587
|
{
|
|
3316
3588
|
id: "toothpaste",
|
|
3317
3589
|
color: 16054008,
|
|
@@ -4343,6 +4615,19 @@ var GameInteractablesHousehold = (() => {
|
|
|
4343
4615
|
isTakeable: true,
|
|
4344
4616
|
weight: 0.7,
|
|
4345
4617
|
isSupply: false
|
|
4618
|
+
},
|
|
4619
|
+
{
|
|
4620
|
+
type: "talheres",
|
|
4621
|
+
item: "cutlery",
|
|
4622
|
+
name: "Talheres",
|
|
4623
|
+
qty: [
|
|
4624
|
+
1,
|
|
4625
|
+
2
|
|
4626
|
+
],
|
|
4627
|
+
viewerCategory: "utensilio",
|
|
4628
|
+
isTakeable: true,
|
|
4629
|
+
weight: 1.5,
|
|
4630
|
+
isSupply: false
|
|
4346
4631
|
}
|
|
4347
4632
|
],
|
|
4348
4633
|
aereo: [
|
|
@@ -14163,15 +14448,28 @@ var GameInteractablesHousehold = (() => {
|
|
|
14163
14448
|
shape: "jar",
|
|
14164
14449
|
color: 15786216,
|
|
14165
14450
|
rarity: "common",
|
|
14451
|
+
parts: [
|
|
14452
|
+
{
|
|
14453
|
+
id: "body",
|
|
14454
|
+
material: "plastic",
|
|
14455
|
+
thickness: 6e-4
|
|
14456
|
+
}
|
|
14457
|
+
],
|
|
14166
14458
|
nutrition: {
|
|
14167
14459
|
satiety: 10,
|
|
14168
14460
|
hydration: 5
|
|
14169
14461
|
},
|
|
14170
14462
|
shelfLife: 28,
|
|
14171
14463
|
estimated: [
|
|
14464
|
+
"parts",
|
|
14172
14465
|
"nutrition",
|
|
14173
|
-
"shelfLife"
|
|
14174
|
-
|
|
14466
|
+
"shelfLife",
|
|
14467
|
+
"fluid"
|
|
14468
|
+
],
|
|
14469
|
+
fluid: {
|
|
14470
|
+
liquid: "yogurt",
|
|
14471
|
+
liters: 0.17
|
|
14472
|
+
}
|
|
14175
14473
|
},
|
|
14176
14474
|
{
|
|
14177
14475
|
id: "apple",
|
|
@@ -14273,12 +14571,20 @@ var GameInteractablesHousehold = (() => {
|
|
|
14273
14571
|
shape: "jar",
|
|
14274
14572
|
color: 15784160,
|
|
14275
14573
|
rarity: "common",
|
|
14574
|
+
parts: [
|
|
14575
|
+
{
|
|
14576
|
+
id: "body",
|
|
14577
|
+
material: "plastic",
|
|
14578
|
+
thickness: 6e-4
|
|
14579
|
+
}
|
|
14580
|
+
],
|
|
14276
14581
|
nutrition: {
|
|
14277
14582
|
satiety: 10,
|
|
14278
14583
|
hydration: 4
|
|
14279
14584
|
},
|
|
14280
14585
|
shelfLife: 180,
|
|
14281
14586
|
estimated: [
|
|
14587
|
+
"parts",
|
|
14282
14588
|
"nutrition",
|
|
14283
14589
|
"shelfLife"
|
|
14284
14590
|
]
|
|
@@ -14512,8 +14818,12 @@ var GameInteractablesHousehold = (() => {
|
|
|
14512
14818
|
}
|
|
14513
14819
|
],
|
|
14514
14820
|
estimated: [
|
|
14821
|
+
"fluid",
|
|
14515
14822
|
"parts"
|
|
14516
|
-
]
|
|
14823
|
+
],
|
|
14824
|
+
fluid: {
|
|
14825
|
+
liquid: "shampoo"
|
|
14826
|
+
}
|
|
14517
14827
|
},
|
|
14518
14828
|
{
|
|
14519
14829
|
id: "toothpaste",
|
|
@@ -14690,8 +15000,12 @@ var GameInteractablesHousehold = (() => {
|
|
|
14690
15000
|
],
|
|
14691
15001
|
estimated: [
|
|
14692
15002
|
"parts",
|
|
15003
|
+
"fluid",
|
|
14693
15004
|
"consumable"
|
|
14694
15005
|
],
|
|
15006
|
+
fluid: {
|
|
15007
|
+
liquid: "detergent"
|
|
15008
|
+
},
|
|
14695
15009
|
consumable: {
|
|
14696
15010
|
form: "liquid",
|
|
14697
15011
|
unit: "ml",
|
|
@@ -14726,8 +15040,13 @@ var GameInteractablesHousehold = (() => {
|
|
|
14726
15040
|
}
|
|
14727
15041
|
],
|
|
14728
15042
|
estimated: [
|
|
14729
|
-
"parts"
|
|
14730
|
-
|
|
15043
|
+
"parts",
|
|
15044
|
+
"fluid"
|
|
15045
|
+
],
|
|
15046
|
+
fluid: {
|
|
15047
|
+
liquid: "bleach",
|
|
15048
|
+
liters: 1
|
|
15049
|
+
}
|
|
14731
15050
|
},
|
|
14732
15051
|
{
|
|
14733
15052
|
id: "sponge",
|
|
@@ -15330,7 +15649,14 @@ var GameInteractablesHousehold = (() => {
|
|
|
15330
15649
|
stack: 1,
|
|
15331
15650
|
shape: "can",
|
|
15332
15651
|
color: 15261904,
|
|
15333
|
-
rarity: "common"
|
|
15652
|
+
rarity: "common",
|
|
15653
|
+
estimated: [
|
|
15654
|
+
"fluid"
|
|
15655
|
+
],
|
|
15656
|
+
fluid: {
|
|
15657
|
+
liquid: "paint",
|
|
15658
|
+
liters: 3.6
|
|
15659
|
+
}
|
|
15334
15660
|
},
|
|
15335
15661
|
{
|
|
15336
15662
|
id: "ice_pack",
|
|
@@ -15690,8 +16016,13 @@ var GameInteractablesHousehold = (() => {
|
|
|
15690
16016
|
}
|
|
15691
16017
|
],
|
|
15692
16018
|
estimated: [
|
|
15693
|
-
"parts"
|
|
15694
|
-
|
|
16019
|
+
"parts",
|
|
16020
|
+
"fluid"
|
|
16021
|
+
],
|
|
16022
|
+
fluid: {
|
|
16023
|
+
liquid: "disinfectant",
|
|
16024
|
+
liters: 0.5
|
|
16025
|
+
}
|
|
15695
16026
|
},
|
|
15696
16027
|
{
|
|
15697
16028
|
id: "seasoning",
|
|
@@ -15911,8 +16242,12 @@ var GameInteractablesHousehold = (() => {
|
|
|
15911
16242
|
}
|
|
15912
16243
|
],
|
|
15913
16244
|
estimated: [
|
|
15914
|
-
"parts"
|
|
15915
|
-
|
|
16245
|
+
"parts",
|
|
16246
|
+
"powder"
|
|
16247
|
+
],
|
|
16248
|
+
powder: {
|
|
16249
|
+
color: 15659508
|
|
16250
|
+
}
|
|
15916
16251
|
},
|
|
15917
16252
|
{
|
|
15918
16253
|
id: "broom",
|
|
@@ -16024,8 +16359,13 @@ var GameInteractablesHousehold = (() => {
|
|
|
16024
16359
|
}
|
|
16025
16360
|
],
|
|
16026
16361
|
estimated: [
|
|
16027
|
-
"parts"
|
|
16028
|
-
|
|
16362
|
+
"parts",
|
|
16363
|
+
"fluid"
|
|
16364
|
+
],
|
|
16365
|
+
fluid: {
|
|
16366
|
+
liquid: "fabric_softener",
|
|
16367
|
+
liters: 2
|
|
16368
|
+
}
|
|
16029
16369
|
},
|
|
16030
16370
|
{
|
|
16031
16371
|
id: "clothespins",
|
|
@@ -16452,9 +16792,8 @@ var GameInteractablesHousehold = (() => {
|
|
|
16452
16792
|
shed: false
|
|
16453
16793
|
},
|
|
16454
16794
|
use: {
|
|
16455
|
-
clip: "
|
|
16795
|
+
clip: "eat_food",
|
|
16456
16796
|
sounds: [
|
|
16457
|
-
"can_open",
|
|
16458
16797
|
"chew"
|
|
16459
16798
|
]
|
|
16460
16799
|
},
|
|
@@ -16622,9 +16961,8 @@ var GameInteractablesHousehold = (() => {
|
|
|
16622
16961
|
shed: false
|
|
16623
16962
|
},
|
|
16624
16963
|
use: {
|
|
16625
|
-
clip: "
|
|
16964
|
+
clip: "drink",
|
|
16626
16965
|
sounds: [
|
|
16627
|
-
"can_open",
|
|
16628
16966
|
"gulp"
|
|
16629
16967
|
]
|
|
16630
16968
|
},
|
|
@@ -20933,6 +21271,17 @@ var GameInteractablesHousehold = (() => {
|
|
|
20933
21271
|
clip: "turn_key"
|
|
20934
21272
|
}
|
|
20935
21273
|
},
|
|
21274
|
+
{
|
|
21275
|
+
id: "eat_with_cutlery",
|
|
21276
|
+
effect: "eat_with",
|
|
21277
|
+
consumes: false,
|
|
21278
|
+
items: [
|
|
21279
|
+
"cutlery"
|
|
21280
|
+
],
|
|
21281
|
+
params: {
|
|
21282
|
+
clip: "eat_with_cutlery"
|
|
21283
|
+
}
|
|
21284
|
+
},
|
|
20936
21285
|
{
|
|
20937
21286
|
id: "swap_bag",
|
|
20938
21287
|
effect: "swap_bag",
|
|
@@ -21117,7 +21466,7 @@ var GameInteractablesHousehold = (() => {
|
|
|
21117
21466
|
var liquidContainer = {
|
|
21118
21467
|
id: "liquid_container",
|
|
21119
21468
|
check: (item) => {
|
|
21120
|
-
const fluid = item
|
|
21469
|
+
const fluid = itemFluid(item);
|
|
21121
21470
|
if (fluid) {
|
|
21122
21471
|
const problems = [];
|
|
21123
21472
|
if (typeof fluid.liquid !== "string" || !SNAKE_CASE.test(fluid.liquid)) problems.push("fluid.liquid must be a liquid id");
|
|
@@ -22239,7 +22588,7 @@ var GameInteractablesHousehold = (() => {
|
|
|
22239
22588
|
};
|
|
22240
22589
|
var GOODS_STRINGS = { en: en_default, "pt-BR": pt_BR_default };
|
|
22241
22590
|
var drinkHydrationOf = (item, liquids = LIQUIDS) => {
|
|
22242
|
-
const fluid = item
|
|
22591
|
+
const fluid = itemFluid(item);
|
|
22243
22592
|
const drink = fluid ? liquids.find((liquid) => liquid.id === fluid.liquid)?.drink : void 0;
|
|
22244
22593
|
if (!fluid || !drink) return void 0;
|
|
22245
22594
|
const doses = item.durability?.kind === "doses" ? Math.max(1, item.durability.amount ?? 1) : 1;
|
|
@@ -22398,7 +22747,7 @@ var GameInteractablesHousehold = (() => {
|
|
|
22398
22747
|
return m(16) << 16 | m(8) << 8 | m(0);
|
|
22399
22748
|
}
|
|
22400
22749
|
var round3 = (n) => Math.round(n * 1e3) / 1e3;
|
|
22401
|
-
function
|
|
22750
|
+
function rotateAxis2(p, o, axis, ang) {
|
|
22402
22751
|
const l = Math.hypot(axis[0], axis[1], axis[2]) || 1;
|
|
22403
22752
|
const k = [axis[0] / l, axis[1] / l, axis[2] / l];
|
|
22404
22753
|
const v = [p[0] - o[0], p[1] - o[1], p[2] - o[2]];
|
|
@@ -22462,7 +22811,7 @@ var GameInteractablesHousehold = (() => {
|
|
|
22462
22811
|
const dot = (p[0] - pivot[0]) * k[0] + (p[1] - pivot[1]) * k[1] + (p[2] - pivot[2]) * k[2];
|
|
22463
22812
|
return [p[0] + k[0] * dot * s, p[1] + k[1] * dot * s, p[2] + k[2] * dot * s];
|
|
22464
22813
|
}
|
|
22465
|
-
return
|
|
22814
|
+
return rotateAxis2(p, pivot, axis, (m.angle ?? 0) * t);
|
|
22466
22815
|
}
|
|
22467
22816
|
function sweepOf(points, pivot, m, margin = 0.01) {
|
|
22468
22817
|
let x0 = Infinity;
|
|
@@ -25354,7 +25703,8 @@ var GameInteractablesHousehold = (() => {
|
|
|
25354
25703
|
label: "use.wash_dishes",
|
|
25355
25704
|
needs: [...DISH_NEEDS],
|
|
25356
25705
|
dose: { need: 0 },
|
|
25357
|
-
dishes: { ids: [...DISHES], basin: basin.id, rack }
|
|
25706
|
+
dishes: { ids: [...DISHES], basin: basin.id, rack },
|
|
25707
|
+
rinse: { clip: "rinse_dish", seconds: scrubSecondsOf("rinse_dish") }
|
|
25358
25708
|
});
|
|
25359
25709
|
}
|
|
25360
25710
|
function tap2(c, x, y, z, id, partId, basin) {
|
|
@@ -28151,6 +28501,688 @@ var GameInteractablesHousehold = (() => {
|
|
|
28151
28501
|
};
|
|
28152
28502
|
return { api, primitives, parts: parts2 };
|
|
28153
28503
|
}
|
|
28504
|
+
|
|
28505
|
+
// src/assembly/geometry.ts
|
|
28506
|
+
var round = (value, digits = 4) => Math.round(value * 10 ** digits) / 10 ** digits;
|
|
28507
|
+
var sanitize = (id) => String(id).trim().toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
28508
|
+
var rotateX = (v, angle) => [v[0], v[1] * Math.cos(angle) - v[2] * Math.sin(angle), v[1] * Math.sin(angle) + v[2] * Math.cos(angle)];
|
|
28509
|
+
var rotateY = (v, angle) => [v[0] * Math.cos(angle) + v[2] * Math.sin(angle), v[1], -v[0] * Math.sin(angle) + v[2] * Math.cos(angle)];
|
|
28510
|
+
var rotateZ = (v, angle) => [v[0] * Math.cos(angle) - v[1] * Math.sin(angle), v[0] * Math.sin(angle) + v[1] * Math.cos(angle), v[2]];
|
|
28511
|
+
function aabbOfBox(center, size, turn = {}) {
|
|
28512
|
+
const { ry = 0, rx = 0, rz = 0 } = turn;
|
|
28513
|
+
const lo = [Infinity, Infinity, Infinity];
|
|
28514
|
+
const hi = [-Infinity, -Infinity, -Infinity];
|
|
28515
|
+
for (const sx of [-0.5, 0.5])
|
|
28516
|
+
for (const sy of [-0.5, 0.5])
|
|
28517
|
+
for (const sz of [-0.5, 0.5]) {
|
|
28518
|
+
let v = [sx * size[0], sy * size[1], sz * size[2]];
|
|
28519
|
+
if (rz) v = rotateZ(v, rz);
|
|
28520
|
+
if (rx) v = rotateX(v, rx);
|
|
28521
|
+
if (ry) v = rotateY(v, ry);
|
|
28522
|
+
for (let k = 0; k < 3; k++) {
|
|
28523
|
+
lo[k] = Math.min(lo[k], center[k] + v[k]);
|
|
28524
|
+
hi[k] = Math.max(hi[k], center[k] + v[k]);
|
|
28525
|
+
}
|
|
28526
|
+
}
|
|
28527
|
+
return [...lo, ...hi];
|
|
28528
|
+
}
|
|
28529
|
+
function latheShape(args) {
|
|
28530
|
+
const [, material, x, y, z, points] = args;
|
|
28531
|
+
const radius = Math.max(...points.map((q) => q[0]));
|
|
28532
|
+
const heights = points.map((q) => q[1]);
|
|
28533
|
+
const lo = Math.min(...heights);
|
|
28534
|
+
const hi = Math.max(...heights);
|
|
28535
|
+
let moment = 0;
|
|
28536
|
+
for (let i = 0; i < points.length; i++) {
|
|
28537
|
+
const [r0, y0] = points[i];
|
|
28538
|
+
const [r1, y1] = points[(i + 1) % points.length];
|
|
28539
|
+
moment += (r0 * y1 - r1 * y0) * (r0 + r1) / 6;
|
|
28540
|
+
}
|
|
28541
|
+
return { key: material, aabb: [x - radius, y + lo, z - radius, x + radius, y + hi, z + radius], vol: Math.max(1e-6, 2 * Math.PI * Math.abs(moment)) };
|
|
28542
|
+
}
|
|
28543
|
+
function describePrimitive(fn, args) {
|
|
28544
|
+
if (fn === "box") {
|
|
28545
|
+
const [, material, x2, y2, z2, w2, h2, d, , ry2 = 0, rx = 0, rz = 0] = args;
|
|
28546
|
+
return { key: material, aabb: aabbOfBox([x2, y2 + h2 / 2, z2], [w2, h2, d], { ry: ry2, rx, rz }), vol: w2 * h2 * d };
|
|
28547
|
+
}
|
|
28548
|
+
if (fn === "cylinder") {
|
|
28549
|
+
const [, material, x2, y2, z2, r, h2, , rx = 0, rz = 0, shape] = args;
|
|
28550
|
+
const tilted = rx || rz;
|
|
28551
|
+
const share = shape === "cone" ? 1 / 3 : shape === "sphere" ? 2 / 3 : 1;
|
|
28552
|
+
return { key: material, aabb: aabbOfBox([x2, tilted ? y2 : y2 + h2 / 2, z2], [2 * r, h2, 2 * r], { rx, rz }), vol: Math.PI * r * r * h2 * share };
|
|
28553
|
+
}
|
|
28554
|
+
if (fn === "plane") {
|
|
28555
|
+
const [, material, x2, y2, z2, w2, h2, , ry2 = 0, rx = 0, rz = 0] = args;
|
|
28556
|
+
return { key: material, aabb: aabbOfBox([x2, y2, z2], [w2, h2, 0.012], { ry: ry2, rx, rz }), vol: w2 * h2 * 0.012 };
|
|
28557
|
+
}
|
|
28558
|
+
if (fn === "lathe") return latheShape(args);
|
|
28559
|
+
const [, x, y, z, w, h, , ry = 0] = args;
|
|
28560
|
+
return { key: "plant", aabb: aabbOfBox([x, y + h / 2, z], [w, h, w * 0.2], { ry }), vol: w * h * w * 0.1 };
|
|
28561
|
+
}
|
|
28562
|
+
var unionBox = (a, b) => [Math.min(a[0], b[0]), Math.min(a[1], b[1]), Math.min(a[2], b[2]), Math.max(a[3], b[3]), Math.max(a[4], b[4]), Math.max(a[5], b[5])];
|
|
28563
|
+
var thinnestOf = (b) => Math.min(b[3] - b[0], b[4] - b[1], b[5] - b[2]);
|
|
28564
|
+
var boxVolume = (b) => Math.max(1e-9, (b[3] - b[0]) * (b[4] - b[1]) * (b[5] - b[2]));
|
|
28565
|
+
var centre = (b) => [(b[0] + b[3]) / 2, (b[1] + b[4]) / 2, (b[2] + b[5]) / 2];
|
|
28566
|
+
function coverOf(skin, under) {
|
|
28567
|
+
const sizes = [skin[3] - skin[0], skin[4] - skin[1], skin[5] - skin[2]];
|
|
28568
|
+
const thin = sizes.indexOf(Math.min(...sizes));
|
|
28569
|
+
let share = 1;
|
|
28570
|
+
for (let k = 0; k < 3; k++) {
|
|
28571
|
+
if (k === thin) continue;
|
|
28572
|
+
const overlap = Math.max(0, Math.min(skin[k + 3], under[k + 3]) - Math.max(skin[k], under[k]));
|
|
28573
|
+
share *= overlap / Math.max(sizes[k], 1e-9);
|
|
28574
|
+
}
|
|
28575
|
+
return share;
|
|
28576
|
+
}
|
|
28577
|
+
function boxGap(a, b) {
|
|
28578
|
+
const dx = Math.max(0, a[0] - b[3], b[0] - a[3]);
|
|
28579
|
+
const dy = Math.max(0, a[1] - b[4], b[1] - a[4]);
|
|
28580
|
+
const dz = Math.max(0, a[2] - b[5], b[2] - a[5]);
|
|
28581
|
+
return Math.hypot(dx, dy, dz);
|
|
28582
|
+
}
|
|
28583
|
+
var SOLID_MIN = 2e-3;
|
|
28584
|
+
function solidsOf(prims, box) {
|
|
28585
|
+
if (prims.length < 2) return void 0;
|
|
28586
|
+
const c = centre(box);
|
|
28587
|
+
return prims.map((p) => {
|
|
28588
|
+
const at = centre(p.aabb);
|
|
28589
|
+
return {
|
|
28590
|
+
center: [round(at[0] - c[0]), round(at[1] - c[1]), round(at[2] - c[2])],
|
|
28591
|
+
size: [0, 1, 2].map((k) => round(Math.max(SOLID_MIN, p.aabb[k + 3] - p.aabb[k])))
|
|
28592
|
+
};
|
|
28593
|
+
});
|
|
28594
|
+
}
|
|
28595
|
+
function primitiveBoxInObject(mover, prim) {
|
|
28596
|
+
let box;
|
|
28597
|
+
for (const sx of [prim.aabb[0], prim.aabb[3]])
|
|
28598
|
+
for (const sy of [prim.aabb[1], prim.aabb[4]])
|
|
28599
|
+
for (const sz of [prim.aabb[2], prim.aabb[5]]) {
|
|
28600
|
+
const v = mover.ry ? rotateY([sx, sy, sz], mover.ry) : [sx, sy, sz];
|
|
28601
|
+
const w = [v[0] + mover.pivot[0], v[1] + mover.pivot[1], v[2] + mover.pivot[2]];
|
|
28602
|
+
box = box ? unionBox(box, [...w, ...w]) : [...w, ...w];
|
|
28603
|
+
}
|
|
28604
|
+
return box;
|
|
28605
|
+
}
|
|
28606
|
+
function moverBox(mover) {
|
|
28607
|
+
let box;
|
|
28608
|
+
for (const p of mover.prims) {
|
|
28609
|
+
const b = primitiveBoxInObject(mover, p);
|
|
28610
|
+
box = box ? unionBox(box, b) : b;
|
|
28611
|
+
}
|
|
28612
|
+
return box;
|
|
28613
|
+
}
|
|
28614
|
+
|
|
28615
|
+
// src/assembly/animations.ts
|
|
28616
|
+
var SOUND = { door: "door", drawer: "drawer", lid: "lid", flap: "flap", knob: "knob", button: "click", rocker: "click", breaker: "click" };
|
|
28617
|
+
var OWN_CLIPS_MAX = 8;
|
|
28618
|
+
function quaternionOf(motion) {
|
|
28619
|
+
const pose = poseOf(motion, 1);
|
|
28620
|
+
const [x, y, z] = pose.rotation.axis;
|
|
28621
|
+
const length = Math.hypot(x, y, z) || 1;
|
|
28622
|
+
const s = Math.sin(pose.rotation.angle / 2);
|
|
28623
|
+
return { position: [...pose.position], quaternion: [x / length * s, y / length * s, z / length * s, Math.cos(pose.rotation.angle / 2)] };
|
|
28624
|
+
}
|
|
28625
|
+
function eulerOf([x, y, z, w]) {
|
|
28626
|
+
const m13 = 2 * (x * z + w * y);
|
|
28627
|
+
const ey = Math.asin(Math.max(-1, Math.min(1, m13)));
|
|
28628
|
+
const ex = Math.abs(m13) < 0.9999999 ? Math.atan2(-2 * (y * z - w * x), 1 - 2 * (x * x + y * y)) : Math.atan2(2 * (y * z + w * x), 1 - 2 * (x * x + z * z));
|
|
28629
|
+
const ez = Math.abs(m13) < 0.9999999 ? Math.atan2(-2 * (x * y - w * z), 1 - 2 * (y * y + z * z)) : 0;
|
|
28630
|
+
return [round(ex), round(ey), round(ez)];
|
|
28631
|
+
}
|
|
28632
|
+
function partMotionPose(motion, ry) {
|
|
28633
|
+
const { position: p, quaternion } = quaternionOf(motion);
|
|
28634
|
+
const [x, y, z, w] = quaternion;
|
|
28635
|
+
const px = p[0] * Math.cos(ry) + p[2] * Math.sin(ry);
|
|
28636
|
+
const pz = -p[0] * Math.sin(ry) + p[2] * Math.cos(ry);
|
|
28637
|
+
const position = [round(px), round(p[1]), round(pz)];
|
|
28638
|
+
const along = [x, y, z].map((c) => Math.abs(c) > 1e-9);
|
|
28639
|
+
if (along.filter(Boolean).length <= 1) {
|
|
28640
|
+
const turn = [x, y, z].map((c) => Math.abs(c) > 1e-9 ? 2 * Math.atan2(c, w) : 0);
|
|
28641
|
+
return { position, rotation: [round(turn[0]), round(turn[1]), round(turn[2])] };
|
|
28642
|
+
}
|
|
28643
|
+
return { position, rotation: eulerOf(quaternion) };
|
|
28644
|
+
}
|
|
28645
|
+
function staged(list) {
|
|
28646
|
+
const bySource = new Map(list.map((p) => [p.source, p]));
|
|
28647
|
+
const start = (p) => {
|
|
28648
|
+
const before = p.requires ? bySource.get(p.requires) : void 0;
|
|
28649
|
+
return before ? start(before) + 0.5 : 0;
|
|
28650
|
+
};
|
|
28651
|
+
return list.map((p) => ({ ...p, start: start(p), end: start(p) + p.seconds }));
|
|
28652
|
+
}
|
|
28653
|
+
function clipOf({ id, list, closing, sound }) {
|
|
28654
|
+
const parts2 = staged(list);
|
|
28655
|
+
const duration = Math.max(...parts2.map((p) => p.end));
|
|
28656
|
+
const times = [.../* @__PURE__ */ new Set([0, duration, ...parts2.flatMap((p) => [p.start, p.end])])].sort((a, b) => a - b);
|
|
28657
|
+
const keys = times.map((t) => ({
|
|
28658
|
+
t: round(t, 3),
|
|
28659
|
+
parts: Object.fromEntries(
|
|
28660
|
+
parts2.map((p) => {
|
|
28661
|
+
const share = Math.max(0, Math.min(1, (t - p.start) / (p.end - p.start)));
|
|
28662
|
+
const f = closing ? 1 - share : share;
|
|
28663
|
+
return [p.id, { position: p.pose.position.map((v) => round(v * f)), rotation: p.pose.rotation.map((v) => round(v * f)) }];
|
|
28664
|
+
})
|
|
28665
|
+
)
|
|
28666
|
+
}));
|
|
28667
|
+
return { id, duration: round(duration, 3), keys, events: [{ t: 0, type: "sound", data: { key: `${sound}_${closing ? "close" : "open"}` } }] };
|
|
28668
|
+
}
|
|
28669
|
+
function buildAnimations({ spec, ids, present }) {
|
|
28670
|
+
const movers = (spec.parts ?? []).filter((p) => p.motion.kind !== "scale" && present.has(p.id));
|
|
28671
|
+
if (movers.length === 0) return [];
|
|
28672
|
+
const info = movers.map((p) => {
|
|
28673
|
+
const kind = p.motion.kind;
|
|
28674
|
+
const on = kind === "knob" || kind === "rocker";
|
|
28675
|
+
const piece2 = p.destruction?.piece ?? (kind === "slide" ? "drawer" : "door");
|
|
28676
|
+
return {
|
|
28677
|
+
source: p.id,
|
|
28678
|
+
id: ids.get(p.id) ?? p.id,
|
|
28679
|
+
on,
|
|
28680
|
+
pose: partMotionPose(p.motion, p.ry ?? 0),
|
|
28681
|
+
seconds: on ? 0.4 : kind === "slide" ? 0.8 : 1.1,
|
|
28682
|
+
sound: SOUND[piece2] ?? "door",
|
|
28683
|
+
requires: p.requires
|
|
28684
|
+
};
|
|
28685
|
+
});
|
|
28686
|
+
const clips = [];
|
|
28687
|
+
const doors = info.filter((p) => !p.on);
|
|
28688
|
+
const knobs = info.filter((p) => p.on);
|
|
28689
|
+
if (doors.length) clips.push(clipOf({ id: "open_all", list: doors, closing: false, sound: "door" }), clipOf({ id: "close_all", list: doors, closing: true, sound: "door" }));
|
|
28690
|
+
if (knobs.length) clips.push(clipOf({ id: "on_all", list: knobs, closing: false, sound: "switch" }), clipOf({ id: "off_all", list: knobs, closing: true, sound: "switch" }));
|
|
28691
|
+
if (info.length > OWN_CLIPS_MAX) return clips;
|
|
28692
|
+
for (const p of info) {
|
|
28693
|
+
clips.push(
|
|
28694
|
+
clipOf({ id: `${p.on ? "on" : "open"}_${p.id}`, list: [p], closing: false, sound: p.sound }),
|
|
28695
|
+
clipOf({ id: `${p.on ? "off" : "close"}_${p.id}`, list: [p], closing: true, sound: p.sound })
|
|
28696
|
+
);
|
|
28697
|
+
}
|
|
28698
|
+
return clips;
|
|
28699
|
+
}
|
|
28700
|
+
|
|
28701
|
+
// src/assembly/cluster.ts
|
|
28702
|
+
var MAX_PIECES = {
|
|
28703
|
+
service_entrance: 32,
|
|
28704
|
+
service_mast: 24,
|
|
28705
|
+
bbq: 30,
|
|
28706
|
+
clothesline: 24,
|
|
28707
|
+
dog_house: 24,
|
|
28708
|
+
gas_bottle: 6,
|
|
28709
|
+
microwave: 10,
|
|
28710
|
+
washing_machine: 12,
|
|
28711
|
+
tv: 8,
|
|
28712
|
+
fridge_compact: 12,
|
|
28713
|
+
utility_sink: 12,
|
|
28714
|
+
wall_socket: 3,
|
|
28715
|
+
wall_switch: 3
|
|
28716
|
+
};
|
|
28717
|
+
var DEFAULT_MAX_PIECES = 18;
|
|
28718
|
+
var STRETCH_DIAMETERS = 2.5;
|
|
28719
|
+
var SKIN_MAX = 4e-3;
|
|
28720
|
+
var SKIN_GAP = 1e-3;
|
|
28721
|
+
var SKIN_COVER = 0.9;
|
|
28722
|
+
var SPECK = 0.02;
|
|
28723
|
+
function layInStretches(statics) {
|
|
28724
|
+
let member = 0;
|
|
28725
|
+
for (let i = statics.length - 1; i >= 0; i--) {
|
|
28726
|
+
const prim = statics[i];
|
|
28727
|
+
if (prim.fn !== "cylinder") continue;
|
|
28728
|
+
const [, , , y, , r, h, , rx = 0, rz = 0, shape] = prim.args;
|
|
28729
|
+
if (rx || rz || shape !== void 0 && shape !== "cyl" && shape !== "cyl6" || h < 2 * STRETCH_DIAMETERS * 2 * r) continue;
|
|
28730
|
+
const count = Math.floor(h / (STRETCH_DIAMETERS * 2 * r));
|
|
28731
|
+
const id = member++;
|
|
28732
|
+
const stretches = Array.from({ length: count }, (_, k) => {
|
|
28733
|
+
const args = prim.args.slice();
|
|
28734
|
+
args[3] = y + h * k / count;
|
|
28735
|
+
args[6] = h / count;
|
|
28736
|
+
return { fn: prim.fn, args, member: id, ...describePrimitive(prim.fn, args) };
|
|
28737
|
+
});
|
|
28738
|
+
statics.splice(i, 1, ...stretches);
|
|
28739
|
+
}
|
|
28740
|
+
}
|
|
28741
|
+
var glassy = (p) => p.keys.has("glass") || p.keys.has("emissive");
|
|
28742
|
+
var sizeOf = (p) => Math.max(p.box[3] - p.box[0], p.box[4] - p.box[1], p.box[5] - p.box[2]);
|
|
28743
|
+
function merge(into, from) {
|
|
28744
|
+
into.indices.push(...from.indices);
|
|
28745
|
+
into.box = unionBox(into.box, from.box);
|
|
28746
|
+
into.vol += from.vol;
|
|
28747
|
+
for (const k of from.keys) into.keys.add(k);
|
|
28748
|
+
for (const [k, v] of Object.entries(from.area)) into.area[k] = (into.area[k] ?? 0) + v;
|
|
28749
|
+
}
|
|
28750
|
+
function hostOf(pieces, small) {
|
|
28751
|
+
let best;
|
|
28752
|
+
let bestScore = Infinity;
|
|
28753
|
+
for (const q of pieces) {
|
|
28754
|
+
if (q === small || glassy(q) !== glassy(small)) continue;
|
|
28755
|
+
const score = boxGap(small.box, q.box) * 1e3 - Math.log(boxVolume(q.box));
|
|
28756
|
+
if (score < bestScore) {
|
|
28757
|
+
bestScore = score;
|
|
28758
|
+
best = q;
|
|
28759
|
+
}
|
|
28760
|
+
}
|
|
28761
|
+
return best;
|
|
28762
|
+
}
|
|
28763
|
+
function clusterStatics({ type, statics, castWith }) {
|
|
28764
|
+
const max = MAX_PIECES[type] ?? DEFAULT_MAX_PIECES;
|
|
28765
|
+
let pieces = statics.map((p, i) => ({ indices: [i], box: p.aabb.slice(), vol: p.vol, keys: /* @__PURE__ */ new Set([p.key]), area: { [p.key]: p.vol } }));
|
|
28766
|
+
const join = (host, piece2) => {
|
|
28767
|
+
merge(host, piece2);
|
|
28768
|
+
pieces = pieces.filter((q) => q !== piece2);
|
|
28769
|
+
};
|
|
28770
|
+
const absorb = (small) => {
|
|
28771
|
+
const host = hostOf(pieces, small);
|
|
28772
|
+
if (!host) return false;
|
|
28773
|
+
join(host, small);
|
|
28774
|
+
return true;
|
|
28775
|
+
};
|
|
28776
|
+
for (const p of pieces.slice()) {
|
|
28777
|
+
if (glassy(p) || pieces.length < 2) continue;
|
|
28778
|
+
const thin = thinnestOf(p.box);
|
|
28779
|
+
if (thin > SKIN_MAX) continue;
|
|
28780
|
+
const host = pieces.find((q) => q !== p && !glassy(q) && thinnestOf(q.box) > thin && boxGap(p.box, q.box) <= SKIN_GAP && coverOf(p.box, q.box) >= SKIN_COVER);
|
|
28781
|
+
if (host) join(host, p);
|
|
28782
|
+
}
|
|
28783
|
+
for (const p of pieces.slice()) {
|
|
28784
|
+
if (p.indices.length !== 1 || statics[p.indices[0]].member !== void 0) continue;
|
|
28785
|
+
const host = pieces.find((q) => q !== p && q.indices.some((i) => statics[i].member !== void 0) && castWith?.(q.box, p.box));
|
|
28786
|
+
if (host) join(host, p);
|
|
28787
|
+
}
|
|
28788
|
+
for (const p of pieces.slice()) if (sizeOf(p) < SPECK && pieces.length > 1 && !glassy(p)) absorb(p);
|
|
28789
|
+
while (pieces.length > max) {
|
|
28790
|
+
const candidates = pieces.filter((p) => !glassy(p) || pieces.filter(glassy).length > 3);
|
|
28791
|
+
const small = (candidates.length ? candidates : pieces).reduce((m, p) => boxVolume(p.box) < boxVolume(m.box) ? p : m);
|
|
28792
|
+
if (!absorb(small)) break;
|
|
28793
|
+
}
|
|
28794
|
+
return pieces.sort((a, b) => boxVolume(b.box) - boxVolume(a.box));
|
|
28795
|
+
}
|
|
28796
|
+
|
|
28797
|
+
// src/assembly/draw-recorder.ts
|
|
28798
|
+
var KINDS2 = ["box", "cylinder", "plane", "leaf", "lathe"];
|
|
28799
|
+
var NOOP_API = { part: (_id, _pivot, _ry, draw) => draw(), box() {
|
|
28800
|
+
}, cylinder() {
|
|
28801
|
+
}, plane() {
|
|
28802
|
+
}, leaf() {
|
|
28803
|
+
}, light() {
|
|
28804
|
+
}, lathe() {
|
|
28805
|
+
} };
|
|
28806
|
+
var callOf = (api, kind) => api[kind];
|
|
28807
|
+
function createDrawRecorder(inner) {
|
|
28808
|
+
const statics = [];
|
|
28809
|
+
const movers = /* @__PURE__ */ new Map();
|
|
28810
|
+
const stack = [];
|
|
28811
|
+
const api = {
|
|
28812
|
+
light: (...args) => inner.light?.(...args),
|
|
28813
|
+
part(id, pivot, ry, draw) {
|
|
28814
|
+
stack.push(id);
|
|
28815
|
+
movers.set(id, { id, pivot: [...pivot], ry: ry || 0, prims: [] });
|
|
28816
|
+
inner.part(id, pivot, ry, draw);
|
|
28817
|
+
stack.pop();
|
|
28818
|
+
}
|
|
28819
|
+
};
|
|
28820
|
+
for (const fn of KINDS2) {
|
|
28821
|
+
;
|
|
28822
|
+
api[fn] = (...args) => {
|
|
28823
|
+
const prim = { fn, args, ...describePrimitive(fn, args) };
|
|
28824
|
+
const open = stack[stack.length - 1];
|
|
28825
|
+
if (open === void 0) {
|
|
28826
|
+
statics.push(prim);
|
|
28827
|
+
return;
|
|
28828
|
+
}
|
|
28829
|
+
movers.get(open)?.prims.push(prim);
|
|
28830
|
+
callOf(inner, fn)(...args);
|
|
28831
|
+
};
|
|
28832
|
+
}
|
|
28833
|
+
const flush = (pieces, laid2 = statics) => {
|
|
28834
|
+
for (const piece2 of pieces) {
|
|
28835
|
+
inner.part(piece2.id, [0, 0, 0], 0, () => {
|
|
28836
|
+
for (const i of piece2.indices) callOf(inner, laid2[i].fn)(...laid2[i].args);
|
|
28837
|
+
});
|
|
28838
|
+
}
|
|
28839
|
+
};
|
|
28840
|
+
return { api, statics, movers, flush };
|
|
28841
|
+
}
|
|
28842
|
+
|
|
28843
|
+
// src/assembly/fluid.ts
|
|
28844
|
+
var BOWL_FILL_MAX = 0.7;
|
|
28845
|
+
var WATER_TEMPERATURE = 18;
|
|
28846
|
+
var FLUIDS = {
|
|
28847
|
+
sink_kitchen: { liters: 4, capacity: 14, size: [0.5, 0.16, 0.36], opening: 0.2 },
|
|
28848
|
+
sink_bathroom: { liters: 2, capacity: 6, size: [0.34, 0.12, 0.28], opening: 0.15 },
|
|
28849
|
+
utility_sink: { liters: 8, capacity: 28, size: [0.5, 0.25, 0.4], opening: 0.22 },
|
|
28850
|
+
toilet: { liters: 3, capacity: 6, size: [0.3, 0.18, 0.3], opening: 0.14 }
|
|
28851
|
+
};
|
|
28852
|
+
function fluidOf({ type, basin, parts: parts2, basinPiece }) {
|
|
28853
|
+
const fixture = FLUIDS[type];
|
|
28854
|
+
if (!fixture) return void 0;
|
|
28855
|
+
if (basin) return bowlFluid(fixture, basin, parts2);
|
|
28856
|
+
const part = parts2.find((p) => p.id === basinPiece);
|
|
28857
|
+
if (!part) return void 0;
|
|
28858
|
+
const top = part.position[1] + part.shape.size[1] / 2;
|
|
28859
|
+
return {
|
|
28860
|
+
container: { capacity: fixture.capacity, liquid: "water", liters: fixture.liters, temperature: WATER_TEMPERATURE, shape: { kind: "box", size: [...fixture.size] }, opening: fixture.opening },
|
|
28861
|
+
part: part.id,
|
|
28862
|
+
uses: ["pour"],
|
|
28863
|
+
offset: [part.position[0], round(top - fixture.size[1] - 0.01), part.position[2]]
|
|
28864
|
+
};
|
|
28865
|
+
}
|
|
28866
|
+
var isInside = (offset, part) => [0, 1, 2].every((k) => Math.abs(offset[k] + (k === 1 ? 5e-3 : 0) - part.position[k]) <= part.shape.size[k] / 2 + 0.01);
|
|
28867
|
+
function bowlFluid(fixture, bowl, parts2) {
|
|
28868
|
+
const size = [0, 1, 2].map((k) => round(bowl.to[k] - bowl.from[k]));
|
|
28869
|
+
const offset = [round((bowl.from[0] + bowl.to[0]) / 2), round(bowl.from[1]), round((bowl.from[2] + bowl.to[2]) / 2)];
|
|
28870
|
+
const radius = round(Math.min(size[0], size[2]) / 2);
|
|
28871
|
+
const isRound = bowl.shape === "round";
|
|
28872
|
+
const capacity = round((isRound ? Math.PI * radius * radius * size[1] : size[0] * size[1] * size[2]) * 1e3, 2);
|
|
28873
|
+
const part = parts2.find((p) => isInside(offset, p)) ?? parts2[0];
|
|
28874
|
+
return {
|
|
28875
|
+
container: {
|
|
28876
|
+
capacity,
|
|
28877
|
+
liquid: "water",
|
|
28878
|
+
liters: Math.min(fixture.liters, round(capacity * BOWL_FILL_MAX, 2)),
|
|
28879
|
+
temperature: WATER_TEMPERATURE,
|
|
28880
|
+
shape: isRound ? { kind: "cylinder", radius, height: size[1] } : { kind: "box", size },
|
|
28881
|
+
opening: Math.min(fixture.opening, radius)
|
|
28882
|
+
},
|
|
28883
|
+
...part ? { part: part.id } : {},
|
|
28884
|
+
uses: ["pour"],
|
|
28885
|
+
offset
|
|
28886
|
+
};
|
|
28887
|
+
}
|
|
28888
|
+
|
|
28889
|
+
// src/assembly/joints.ts
|
|
28890
|
+
var TOUCH = 0.01;
|
|
28891
|
+
var DEGREE_MAX = 5;
|
|
28892
|
+
var STRETCH_JOINT = { reinforced: "rebar", plain: "weld" };
|
|
28893
|
+
function createGroups(ids) {
|
|
28894
|
+
const parent = new Map(ids.map((id) => [id, id]));
|
|
28895
|
+
const find = (id) => {
|
|
28896
|
+
const up = parent.get(id) ?? id;
|
|
28897
|
+
if (up === id) return id;
|
|
28898
|
+
const root = find(up);
|
|
28899
|
+
parent.set(id, root);
|
|
28900
|
+
return root;
|
|
28901
|
+
};
|
|
28902
|
+
return { find, join: (a, b) => void parent.set(find(a), find(b)) };
|
|
28903
|
+
}
|
|
28904
|
+
function jointsOf({ spec, pieces, movers, statics }) {
|
|
28905
|
+
const body = spec.destruction ?? {};
|
|
28906
|
+
const cage = body.reinforcement;
|
|
28907
|
+
const bodyKind = body.joint ?? "screw";
|
|
28908
|
+
const memberOf = (piece2) => piece2.indices.map((i) => statics[i].member).find((member) => member !== void 0);
|
|
28909
|
+
const kindOf = (a, b) => {
|
|
28910
|
+
const member = memberOf(a);
|
|
28911
|
+
if (member !== void 0 && member === memberOf(b)) return cage ? STRETCH_JOINT.reinforced : STRETCH_JOINT.plain;
|
|
28912
|
+
if (a.material.includes("glass") || b.material.includes("glass")) return "clip";
|
|
28913
|
+
if (a.material === "foam" !== (b.material === "foam")) return "tie";
|
|
28914
|
+
return cage && (a.material !== body.material || b.material !== body.material) ? "bolt" : bodyKind;
|
|
28915
|
+
};
|
|
28916
|
+
const joints = [];
|
|
28917
|
+
const degree = /* @__PURE__ */ new Map();
|
|
28918
|
+
const groups = createGroups(pieces.map((p) => p.id));
|
|
28919
|
+
const edges = [];
|
|
28920
|
+
for (let i = 0; i < pieces.length; i++)
|
|
28921
|
+
for (let j = i + 1; j < pieces.length; j++) {
|
|
28922
|
+
const gap = boxGap(pieces[i].box, pieces[j].box);
|
|
28923
|
+
if (gap <= TOUCH) edges.push({ a: pieces[i], b: pieces[j], gap });
|
|
28924
|
+
}
|
|
28925
|
+
edges.sort((x, y) => x.gap - y.gap || Math.min(boxVolume(y.a.box), boxVolume(y.b.box)) - Math.min(boxVolume(x.a.box), boxVolume(x.b.box)));
|
|
28926
|
+
for (const e of edges) {
|
|
28927
|
+
if ((degree.get(e.a.id) ?? 0) >= DEGREE_MAX || (degree.get(e.b.id) ?? 0) >= DEGREE_MAX) continue;
|
|
28928
|
+
degree.set(e.a.id, (degree.get(e.a.id) ?? 0) + 1);
|
|
28929
|
+
degree.set(e.b.id, (degree.get(e.b.id) ?? 0) + 1);
|
|
28930
|
+
groups.join(e.a.id, e.b.id);
|
|
28931
|
+
joints.push({ a: e.a.id, b: e.b.id, kind: kindOf(e.a, e.b) });
|
|
28932
|
+
}
|
|
28933
|
+
joints.push(...bridgesOf(pieces, groups, kindOf));
|
|
28934
|
+
for (const m of movers) {
|
|
28935
|
+
const host = hostOf2(pieces, m);
|
|
28936
|
+
if (host) joints.push({ a: m.id, b: host.id, kind: m.tag.joint ?? "hinge" });
|
|
28937
|
+
}
|
|
28938
|
+
return joints;
|
|
28939
|
+
}
|
|
28940
|
+
function bridgesOf(pieces, groups, kindOf) {
|
|
28941
|
+
const bridges = [];
|
|
28942
|
+
while (new Set(pieces.map((p) => groups.find(p.id))).size > 1) {
|
|
28943
|
+
let best;
|
|
28944
|
+
for (const a of pieces)
|
|
28945
|
+
for (const b of pieces) {
|
|
28946
|
+
if (groups.find(a.id) === groups.find(b.id)) continue;
|
|
28947
|
+
const gap = boxGap(a.box, b.box);
|
|
28948
|
+
if (!best || gap < best.gap) best = { a, b, gap };
|
|
28949
|
+
}
|
|
28950
|
+
if (!best) break;
|
|
28951
|
+
groups.join(best.a.id, best.b.id);
|
|
28952
|
+
bridges.push({ a: best.a.id, b: best.b.id, kind: kindOf(best.a, best.b) });
|
|
28953
|
+
}
|
|
28954
|
+
return bridges;
|
|
28955
|
+
}
|
|
28956
|
+
function hostOf2(pieces, mover) {
|
|
28957
|
+
let best = pieces[0];
|
|
28958
|
+
let bestScore = Infinity;
|
|
28959
|
+
for (const h of pieces) {
|
|
28960
|
+
const score = boxGap(mover.box, h.box) * 1e3 - Math.log(boxVolume(h.box));
|
|
28961
|
+
if (score < bestScore) {
|
|
28962
|
+
bestScore = score;
|
|
28963
|
+
best = h;
|
|
28964
|
+
}
|
|
28965
|
+
}
|
|
28966
|
+
return best;
|
|
28967
|
+
}
|
|
28968
|
+
|
|
28969
|
+
// src/assembly/materials.ts
|
|
28970
|
+
var WOOD_FAMILY = /* @__PURE__ */ new Set(["wood_soft", "wood_hard", "mdf", "plywood"]);
|
|
28971
|
+
var METAL_FAMILY = /* @__PURE__ */ new Set(["steel", "aluminium", "cast_iron", "copper"]);
|
|
28972
|
+
var KEY_OVERRIDES = {
|
|
28973
|
+
shower: { plain: "ceramic", metal: "aluminium", glass: "tempered_glass" },
|
|
28974
|
+
sink_kitchen: { wood: "mdf" },
|
|
28975
|
+
sink_bathroom: { wood: "mdf" },
|
|
28976
|
+
mailbox: { wood: "steel" },
|
|
28977
|
+
sofa: { metal: "spring_steel" },
|
|
28978
|
+
armchair: { metal: "spring_steel" },
|
|
28979
|
+
bed_double: { metal: "spring_steel" },
|
|
28980
|
+
bed_single: { metal: "spring_steel" },
|
|
28981
|
+
box_bed: { metal: "spring_steel" }
|
|
28982
|
+
};
|
|
28983
|
+
var DENSITY = {
|
|
28984
|
+
steel: 7850,
|
|
28985
|
+
aluminium: 2700,
|
|
28986
|
+
cast_iron: 7200,
|
|
28987
|
+
copper: 8900,
|
|
28988
|
+
wood_soft: 550,
|
|
28989
|
+
wood_hard: 750,
|
|
28990
|
+
mdf: 700,
|
|
28991
|
+
plywood: 600,
|
|
28992
|
+
glass: 2500,
|
|
28993
|
+
tempered_glass: 2500,
|
|
28994
|
+
ceramic: 2300,
|
|
28995
|
+
plastic: 1e3,
|
|
28996
|
+
rubber: 1100,
|
|
28997
|
+
fabric: 250,
|
|
28998
|
+
foam: 40,
|
|
28999
|
+
brick: 1800,
|
|
29000
|
+
concrete: 2400,
|
|
29001
|
+
foliage: 100
|
|
29002
|
+
};
|
|
29003
|
+
var DEFAULT_DENSITY = 800;
|
|
29004
|
+
var THICKNESS = { steel: 12e-4, aluminium: 1e-3, copper: 2e-3, plastic: 3e-3, ceramic: 0.012, glass: 4e-3, tempered_glass: 6e-3 };
|
|
29005
|
+
function materialFor({ type, spec, key }) {
|
|
29006
|
+
const body = spec.destruction?.material ?? "plastic";
|
|
29007
|
+
const over = KEY_OVERRIDES[type]?.[key];
|
|
29008
|
+
if (over) return over;
|
|
29009
|
+
if (key === "glass" || key === "emissive") return body === "tempered_glass" ? "tempered_glass" : "glass";
|
|
29010
|
+
if (key === "metal") return METAL_FAMILY.has(body) ? body : "steel";
|
|
29011
|
+
if (key === "wood") return WOOD_FAMILY.has(body) ? body : "wood_soft";
|
|
29012
|
+
if (key === "foam") return "foam";
|
|
29013
|
+
if (key === "fabric") return "fabric";
|
|
29014
|
+
if (key === "plant") return "foliage";
|
|
29015
|
+
return body;
|
|
29016
|
+
}
|
|
29017
|
+
|
|
29018
|
+
// src/assembly/parts.ts
|
|
29019
|
+
var GROUND_TOUCH = 0.02;
|
|
29020
|
+
var CAGE_UNIT = 0.1;
|
|
29021
|
+
var CAGE_MIN = 0.1;
|
|
29022
|
+
var UPHOLSTERY_COVER = 2e-3;
|
|
29023
|
+
var GLASS_HP = { glass: 20, tempered_glass: 40 };
|
|
29024
|
+
function weightOf(piece2) {
|
|
29025
|
+
const [dx, dy, dz] = [piece2.box[3] - piece2.box[0], piece2.box[4] - piece2.box[1], piece2.box[5] - piece2.box[2]];
|
|
29026
|
+
const thin = THICKNESS[piece2.material];
|
|
29027
|
+
return (thin ? Math.min(piece2.vol, 2 * (dx * dy + dy * dz + dz * dx) * thin) : piece2.vol) * (DENSITY[piece2.material] ?? DEFAULT_DENSITY);
|
|
29028
|
+
}
|
|
29029
|
+
function shapeOf(type, piece2) {
|
|
29030
|
+
const size = [0, 1, 2].map((k) => Math.max(4e-3, piece2.box[k + 3] - piece2.box[k]));
|
|
29031
|
+
const fill = Math.max(0.03, Math.min(1, piece2.vol / (size[0] * size[1] * size[2])));
|
|
29032
|
+
return {
|
|
29033
|
+
id: piece2.id,
|
|
29034
|
+
material: piece2.material,
|
|
29035
|
+
shape: { kind: "box", size: size.map((v) => round(v)) },
|
|
29036
|
+
position: centre(piece2.box).map((v) => round(v)),
|
|
29037
|
+
fill: round(piece2.material === "foam" || piece2.material === "fabric" ? fill * 0.5 : fill, 3),
|
|
29038
|
+
tags: [type, ...piece2.mover && piece2.tag.piece ? [piece2.tag.piece] : []],
|
|
29039
|
+
...piece2.solids ? { solids: piece2.solids } : {}
|
|
29040
|
+
};
|
|
29041
|
+
}
|
|
29042
|
+
function bodyBuildOf(piece2, body) {
|
|
29043
|
+
if (piece2.mover || piece2.material !== body.material) return {};
|
|
29044
|
+
const side = Math.min(piece2.box[3] - piece2.box[0], piece2.box[4] - piece2.box[1], piece2.box[5] - piece2.box[2]);
|
|
29045
|
+
const cage = body.reinforcement;
|
|
29046
|
+
if (cage && side >= CAGE_MIN) {
|
|
29047
|
+
return {
|
|
29048
|
+
reinforcement: { material: cage.material, spacing: cage.spacing, diameter: cage.diameter },
|
|
29049
|
+
units: { size: [CAGE_UNIT, CAGE_UNIT, round(side)], bond: "stack", mortar: piece2.material },
|
|
29050
|
+
structure: { role: "column" }
|
|
29051
|
+
};
|
|
29052
|
+
}
|
|
29053
|
+
const laid2 = body.units;
|
|
29054
|
+
return laid2 ? { units: { size: [laid2.size[0], laid2.size[1], laid2.size[2]], bond: laid2.bond, mortar: laid2.mortar } } : {};
|
|
29055
|
+
}
|
|
29056
|
+
function partsOf({ type, spec, pieces, all, massKg, planted }) {
|
|
29057
|
+
const body = spec.destruction ?? {};
|
|
29058
|
+
const totalWeight = all.reduce((sum, piece2) => sum + weightOf(piece2), 0) || 1;
|
|
29059
|
+
const parts2 = all.map((piece2) => {
|
|
29060
|
+
const extra = {};
|
|
29061
|
+
if (planted && !piece2.mover && piece2.box[1] <= GROUND_TOUCH) extra.anchored = true;
|
|
29062
|
+
Object.assign(extra, bodyBuildOf(piece2, body));
|
|
29063
|
+
const own = piece2.mover ? piece2.tag : void 0;
|
|
29064
|
+
if (own?.explodes) extra.explodes = { ...own.explodes };
|
|
29065
|
+
if (own?.contains) extra.contains = { ...own.contains };
|
|
29066
|
+
if (massKg) extra.mass = round(Math.max(0.01, massKg * weightOf(piece2) / totalWeight), 3);
|
|
29067
|
+
if (!piece2.mover && piece2.key === "foam") extra.layers = [{ material: "fabric", thickness: UPHOLSTERY_COVER, faces: "all" }];
|
|
29068
|
+
const hp = GLASS_HP[piece2.material];
|
|
29069
|
+
if (hp) extra.hp = hp;
|
|
29070
|
+
const thin = THICKNESS[piece2.material];
|
|
29071
|
+
if (thin) extra.thickness = Math.min(thin, Math.max(5e-4, Math.min(piece2.box[3] - piece2.box[0], piece2.box[4] - piece2.box[1], piece2.box[5] - piece2.box[2])));
|
|
29072
|
+
return Object.assign(shapeOf(type, piece2), extra);
|
|
29073
|
+
});
|
|
29074
|
+
const shell2 = pieces.length ? parts2.find((p) => p.id === pieces[0].id) : void 0;
|
|
29075
|
+
if (shell2 && body.explodes) shell2.explodes = { ...body.explodes };
|
|
29076
|
+
if (shell2 && body.contains) shell2.contains = { ...body.contains };
|
|
29077
|
+
return parts2;
|
|
29078
|
+
}
|
|
29079
|
+
|
|
29080
|
+
// src/assembly/pieces.ts
|
|
29081
|
+
function createIds() {
|
|
29082
|
+
const used = /* @__PURE__ */ new Set();
|
|
29083
|
+
return (base) => {
|
|
29084
|
+
let id = base;
|
|
29085
|
+
for (let n = 2; used.has(id); n++) id = `${base}_${n}`;
|
|
29086
|
+
used.add(id);
|
|
29087
|
+
return id;
|
|
29088
|
+
};
|
|
29089
|
+
}
|
|
29090
|
+
function bodyPiecesOf({ type, spec, clusters, statics, unique }) {
|
|
29091
|
+
const pieces = clusters.map((c) => {
|
|
29092
|
+
const dominant = Object.entries(c.area).sort((a, b) => b[1] - a[1])[0][0];
|
|
29093
|
+
const material = materialFor({ type, spec, key: dominant });
|
|
29094
|
+
const solids = solidsOf(c.indices.map((i) => statics[i]), c.box);
|
|
29095
|
+
return { id: unique(dominant === "emissive" ? "screen" : material), indices: c.indices, box: c.box, vol: c.vol, material, key: dominant, mover: false, ...solids ? { solids } : {} };
|
|
29096
|
+
});
|
|
29097
|
+
return pieces.length ? pieces : wirePiecesOf({ spec, unique });
|
|
29098
|
+
}
|
|
29099
|
+
function wirePiecesOf({ spec, unique }) {
|
|
29100
|
+
const pieces = [];
|
|
29101
|
+
for (const w of spec.wires ?? []) {
|
|
29102
|
+
if (!w.points || w.points.length < 2) continue;
|
|
29103
|
+
const r = w.radius ?? 0.01;
|
|
29104
|
+
const lo = [Infinity, Infinity, Infinity];
|
|
29105
|
+
const hi = [-Infinity, -Infinity, -Infinity];
|
|
29106
|
+
let length = 0;
|
|
29107
|
+
w.points.forEach((q, i) => {
|
|
29108
|
+
for (let k = 0; k < 3; k++) {
|
|
29109
|
+
lo[k] = Math.min(lo[k], q[k] - r);
|
|
29110
|
+
hi[k] = Math.max(hi[k], q[k] + r);
|
|
29111
|
+
}
|
|
29112
|
+
if (i) length += Math.hypot(q[0] - w.points[i - 1][0], q[1] - w.points[i - 1][1], q[2] - w.points[i - 1][2]);
|
|
29113
|
+
});
|
|
29114
|
+
const material = spec.destruction?.material ?? "plastic";
|
|
29115
|
+
pieces.push({ id: unique(w.kind === "conduit" ? "conduit" : w.kind), indices: [], box: [...lo, ...hi], vol: Math.PI * r * r * length, material, key: "plain", mover: false });
|
|
29116
|
+
}
|
|
29117
|
+
return pieces;
|
|
29118
|
+
}
|
|
29119
|
+
function moverPiecesOf({ spec, recorded, partIds }) {
|
|
29120
|
+
const movers = [];
|
|
29121
|
+
for (const p of spec.parts ?? []) {
|
|
29122
|
+
const r = recorded.get(p.id);
|
|
29123
|
+
if (!r || r.prims.length === 0) continue;
|
|
29124
|
+
const box = p.bounds ?? moverBox(r);
|
|
29125
|
+
if (!box) continue;
|
|
29126
|
+
const vol = r.prims.reduce((sum, q) => sum + q.vol, 0);
|
|
29127
|
+
const tag = p.destruction ?? {};
|
|
29128
|
+
const solids = solidsOf(r.prims.map((q) => ({ aabb: primitiveBoxInObject(r, q) })), box);
|
|
29129
|
+
const id = partIds.get(p.id) ?? p.id;
|
|
29130
|
+
movers.push({ id, source: p, indices: [], box, vol, material: tag.material ?? spec.destruction?.material ?? "plastic", mover: true, tag, ...solids ? { solids } : {} });
|
|
29131
|
+
}
|
|
29132
|
+
return movers;
|
|
29133
|
+
}
|
|
29134
|
+
function partIdsOf(spec, unique) {
|
|
29135
|
+
const ids = /* @__PURE__ */ new Map();
|
|
29136
|
+
for (const p of spec.parts ?? []) ids.set(p.id, unique(sanitize(p.id)));
|
|
29137
|
+
return ids;
|
|
29138
|
+
}
|
|
29139
|
+
|
|
29140
|
+
// src/assembly/assemble.ts
|
|
29141
|
+
var ASSEMBLY_SEED = 1;
|
|
29142
|
+
function assembleHouseholdType({ household, type, castWith = castWithMember }) {
|
|
29143
|
+
const recorder = createDrawRecorder(NOOP_API);
|
|
29144
|
+
const spec = household.build(type, { seed: ASSEMBLY_SEED }, recorder.api);
|
|
29145
|
+
const def = household.types.find((t) => t.id === type);
|
|
29146
|
+
const planted = def?.fixed === true && def.y <= 0;
|
|
29147
|
+
if (planted) layInStretches(recorder.statics);
|
|
29148
|
+
const clusters = clusterStatics({ type, statics: recorder.statics, castWith });
|
|
29149
|
+
const unique = createIds();
|
|
29150
|
+
const partIds = partIdsOf(spec, unique);
|
|
29151
|
+
const pieces = bodyPiecesOf({ type, spec, clusters, statics: recorder.statics, unique });
|
|
29152
|
+
const movers = moverPiecesOf({ spec, recorded: recorder.movers, partIds });
|
|
29153
|
+
const parts2 = partsOf({ type, spec, pieces, all: [...pieces, ...movers], massKg: def?.massKg, planted });
|
|
29154
|
+
const joints = jointsOf({ spec, pieces, movers, statics: recorder.statics });
|
|
29155
|
+
const destructible2 = { name: type, parts: parts2, joints, tags: ["furniture", type], ...planted ? { fixed: true } : {} };
|
|
29156
|
+
const animations = buildAnimations({ spec, ids: partIds, present: new Set(movers.map((m) => m.source.id)) });
|
|
29157
|
+
const basinPiece = (pieces.find((p) => p.material === "ceramic") ?? pieces[0])?.id;
|
|
29158
|
+
const fluid = fluidOf({ type, basin: spec.basins?.[0], parts: parts2, basinPiece });
|
|
29159
|
+
return { type, spec, pieces, movers, partIds, destructible: destructible2, animations, fluid, statics: recorder.statics };
|
|
29160
|
+
}
|
|
29161
|
+
function drawHouseholdAssembly(params) {
|
|
29162
|
+
const { household, assembly, api } = params;
|
|
29163
|
+
const recorder = createDrawRecorder(api);
|
|
29164
|
+
const item = { seed: ASSEMBLY_SEED };
|
|
29165
|
+
const spec = household.build(assembly.type, item, recorder.api);
|
|
29166
|
+
recorder.flush(assembly.pieces, assembly.statics);
|
|
29167
|
+
return spec;
|
|
29168
|
+
}
|
|
29169
|
+
var REGION_OF = { en: "us", "pt-BR": "br" };
|
|
29170
|
+
function createHouseholdAssemblies(options = {}) {
|
|
29171
|
+
const households = {};
|
|
29172
|
+
const assemblies = /* @__PURE__ */ new Map();
|
|
29173
|
+
const household = (locale) => households[locale] ?? (households[locale] = createHousehold({ locale, region: REGION_OF[locale] }));
|
|
29174
|
+
const assemble = (locale, type) => {
|
|
29175
|
+
const key = `${locale}:${type}`;
|
|
29176
|
+
let assembly = assemblies.get(key);
|
|
29177
|
+
if (!assembly) assemblies.set(key, assembly = assembleHouseholdType({ household: household(locale), type, ...options.castWith ? { castWith: options.castWith } : {} }));
|
|
29178
|
+
return assembly;
|
|
29179
|
+
};
|
|
29180
|
+
return {
|
|
29181
|
+
household,
|
|
29182
|
+
assemble,
|
|
29183
|
+
draw: (locale, type, api) => drawHouseholdAssembly({ household: household(locale), assembly: assemble(locale, type), api })
|
|
29184
|
+
};
|
|
29185
|
+
}
|
|
28154
29186
|
return __toCommonJS(index_exports);
|
|
28155
29187
|
})();
|
|
28156
29188
|
//# sourceMappingURL=index.global.js.map
|