@adatechnology/game-items-three 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -342,6 +342,264 @@ function tagMakeupParts(root, modelId) {
342
342
  });
343
343
  }
344
344
 
345
+ // src/shapes.ts
346
+ var SHAPES = [
347
+ "can",
348
+ "bag",
349
+ "box",
350
+ "bottle",
351
+ "tool",
352
+ "roll",
353
+ "dish",
354
+ "cloth",
355
+ "shoe",
356
+ "jar",
357
+ "paper",
358
+ "fruit",
359
+ "cup",
360
+ "tube",
361
+ "blade",
362
+ "long_tool",
363
+ "garment",
364
+ "backpack",
365
+ "jerrycan",
366
+ "tank",
367
+ "book",
368
+ "key",
369
+ "battery",
370
+ "plank",
371
+ "device"
372
+ ];
373
+ var DEFAULT_COLOR = 9080724;
374
+ var PI = Math.PI;
375
+ function shade(color, factor) {
376
+ const channel = (shift) => Math.max(0, Math.min(255, Math.round((color >> shift & 255) * factor)));
377
+ return channel(16) << 16 | channel(8) << 8 | channel(0);
378
+ }
379
+ var PROUD = 2e-3;
380
+ var seg = (c, n) => Math.max(5, Math.round(n * c.detail));
381
+ function canonicalFrame(size) {
382
+ const [w, h, d] = size;
383
+ if (h >= w && h >= d) return { axis: 1, L: h, a: w, b: d };
384
+ if (d >= w && d >= h) return { axis: 2, L: d, a: h, b: w };
385
+ return { axis: 0, L: w, a: h, b: d };
386
+ }
387
+ function orient(c, group, axis) {
388
+ if (axis === 0) return group;
389
+ const holder = c.k.G(group);
390
+ if (axis === 1) holder.rotation.z = PI / 2;
391
+ else holder.rotation.y = -PI / 2;
392
+ return holder;
393
+ }
394
+ var alongLong = (draw) => (c) => {
395
+ const { axis, L, a, b } = canonicalFrame([c.w, c.h, c.d]);
396
+ return orient(c, draw(c, L, a, b), axis);
397
+ };
398
+ var across = (c, group) => {
399
+ group.scale.set(c.w, 1, c.d);
400
+ return c.k.G(group);
401
+ };
402
+ var can = (c) => {
403
+ const { k, h } = c;
404
+ const body = k.metal(9277590);
405
+ const r = 0.5 - PROUD / Math.min(c.w, c.d);
406
+ return across(c, k.G(k.mesh(k.cyl(r, r, h * 0.94, seg(c, 14)), body), k.mesh(k.cyl(0.5, 0.5, h * 0.5, seg(c, 14)), k.food(c.color)), k.mesh(k.cyl(0.5, 0.5, h * 0.03, seg(c, 14)), body, [0, h * 0.485, 0]), k.mesh(k.cyl(0.5, 0.5, h * 0.03, seg(c, 14)), body, [0, -h * 0.485, 0])));
407
+ };
408
+ var bottle = (c) => {
409
+ const { k, h } = c;
410
+ const r = 0.5;
411
+ const profile = [[0, -h / 2], [r, -h / 2], [r, h * 0.12], [r * 0.45, h * 0.3], [r * 0.4, h * 0.4], [0, h * 0.4]];
412
+ return across(c, k.G(k.mesh(k.lathe(profile, seg(c, 14)), k.glass(c.color, 0.6)), k.mesh(k.cyl(r * 0.42, r * 0.42, h * 0.1, seg(c, 10)), k.plastic(shade(c.color, 0.5)), [0, h * 0.45, 0])));
413
+ };
414
+ var jar = (c) => {
415
+ const { k, h } = c;
416
+ return across(c, k.G(k.mesh(k.cyl(0.5, 0.5, h * 0.82, seg(c, 14)), k.glass(c.color, 0.55), [0, -h * 0.09, 0]), k.mesh(k.cyl(0.5, 0.5, h * 0.18, seg(c, 14)), k.metal(12095802), [0, h * 0.41, 0])));
417
+ };
418
+ var bag = (c) => {
419
+ const { k, w, h, d } = c;
420
+ return k.G(k.mesh(k.bx(w, h * 0.88, d - 2 * PROUD), k.paper(c.color), [0, -h * 0.06, 0]), k.mesh(k.bx(w * 1, h * 0.12, d * 0.5), k.paper(shade(c.color, 0.85)), [0, h * 0.44, 0]), k.mesh(k.bx(w * 0.7, h * 0.3, d), k.paper(shade(c.color, 1.2)), [0, 0, 0]));
421
+ };
422
+ var box = (c) => {
423
+ const { k, w, h, d } = c;
424
+ return k.G(k.mesh(k.bx(w - 2 * PROUD, h - PROUD, d - 2 * PROUD), k.paper(c.color), [0, -PROUD / 2, 0]), k.mesh(k.bx(w, h * 0.12, d), k.paper(shade(c.color, 0.8)), [0, h * 0.44, 0]), k.mesh(k.bx(w * 0.62, h * 0.4, d), k.paper(shade(c.color, 1.25)), [0, -h * 0.02, 0]));
425
+ };
426
+ var cloth = (c) => {
427
+ const { k, w, h, d } = c;
428
+ const material = k.cloth(c.color);
429
+ return k.G(k.mesh(k.bx(w, h * 0.55, d), material, [0, -h * 0.225, 0]), k.mesh(k.bx(w * 0.96, h * 0.45, d * 0.96), k.cloth(shade(c.color, 0.9)), [0, h * 0.275, 0]));
430
+ };
431
+ var paper = (c) => {
432
+ const { k, w, h, d } = c;
433
+ const sheet = k.paper(c.color);
434
+ return k.G(k.mesh(k.bx(w, h / 3, d), sheet, [0, -h / 3, 0]), k.mesh(k.bx(w * 0.98, h / 3, d * 0.98), k.paper(shade(c.color, 0.95)), [0, 0, 0]), k.mesh(k.bx(w, h / 3, d), sheet, [0, h / 3, 0]));
435
+ };
436
+ var fruit = (c) => {
437
+ const { k, w, h, d } = c;
438
+ const sphere = new k.T.SphereGeometry(0.5, seg(c, 12), seg(c, 8));
439
+ return k.G(k.mesh(sphere, k.food(c.color), [0, -h * 0.04, 0], [0, 0, 0], [w, h * 0.92, d]), k.mesh(k.cyl(h * 0.02, h * 0.02, h * 0.1, 6), k.wood(5913122), [0, h * 0.45, 0]));
440
+ };
441
+ var dish = (c) => {
442
+ const { k, w, h, d } = c;
443
+ return k.G(k.mesh(k.cyl(0.5, 0.35, h, seg(c, 16)), k.plastic(c.color), [0, 0, 0], [0, 0, 0], [w, 1, d]));
444
+ };
445
+ var CUP_FLOOR_SHARE = 0.06;
446
+ var cup = (c) => {
447
+ const { k, w, h, d } = c;
448
+ const floor = -h / 2 + h * CUP_FLOOR_SHARE;
449
+ const profile = [[0, -h / 2], [0.38, -h / 2], [0.5, h / 2], [0.44, h / 2], [0.33, floor], [0, floor]];
450
+ return k.G(k.mesh(k.lathe(profile, seg(c, 14)), k.plastic(c.color), [0, 0, 0], [0, 0, 0], [w, 1, d]));
451
+ };
452
+ var tube = (c) => {
453
+ const { k, h } = c;
454
+ const material = k.plastic(c.color);
455
+ return across(c, k.G(k.mesh(k.cyl(0.5, 0.42, h * 0.86, seg(c, 12)), material, [0, -h * 0.04, 0]), k.mesh(k.cyl(0.35, 0.35, h * 0.12, seg(c, 12)), k.plastic(shade(c.color, 0.6)), [0, h * 0.44, 0]), k.mesh(k.bx(1, h * 0.06, 0.25), material, [0, -h * 0.47, 0])));
456
+ };
457
+ var roll = (c) => {
458
+ const { k, w, h, d } = c;
459
+ const body = k.G(k.mesh(k.cyl(0.5, 0.5, 1, seg(c, 18)), k.paper(c.color)), k.mesh(k.cyl(0.18, 0.18, 0.98, seg(c, 12)), k.paper(11902328)));
460
+ if (h <= w && h <= d) body.scale.set(w, h, d);
461
+ else if (w <= d) {
462
+ body.rotation.z = PI / 2;
463
+ body.scale.set(h, w, d);
464
+ } else {
465
+ body.rotation.x = PI / 2;
466
+ body.scale.set(w, d, h);
467
+ }
468
+ return k.G(body);
469
+ };
470
+ var shoe = (c) => {
471
+ const { k, w, h, d } = c;
472
+ const upper = k.cloth(c.color);
473
+ return k.G(k.mesh(k.bx(w, h * 0.22, d), k.plastic(2237727), [0, -h * 0.39, 0]), k.mesh(k.bx(w * 0.42, h * 0.78, d * 0.96), upper, [-w * 0.29, h * 0.11, 0]), k.mesh(k.bx(w * 0.5, h * 0.5, d * 0.96), upper, [w * 0.25, -h * 0.03, 0]));
474
+ };
475
+ var tool = alongLong((c, L, a, b) => {
476
+ const { k } = c;
477
+ const radius = Math.max(4e-3, Math.min(a, b) / 2);
478
+ return k.G(k.mesh(k.cyl(radius, radius, L * 0.74, seg(c, 10)), k.wood(9069628), [-L * 0.13, 0, 0], [0, 0, PI / 2]), k.mesh(k.bx(L * 0.26, a, b), k.metal(shade(c.color, 1)), [L * 0.37, 0, 0]));
479
+ });
480
+ var longTool = alongLong((c, L, a, b) => {
481
+ const { k } = c;
482
+ const radius = Math.max(4e-3, Math.min(a, b) / 2) * 0.55;
483
+ return k.G(k.mesh(k.cyl(radius, radius, L * 0.94, seg(c, 10)), k.wood(10122312), [0, 0, 0], [0, 0, PI / 2]), k.mesh(k.bx(L * 0.12, a, b), k.metal(c.color), [L * 0.44, 0, 0]));
484
+ });
485
+ var blade = alongLong((c, L, a, b) => {
486
+ const { k } = c;
487
+ const edge = Math.min(2e-4, b * 0.05);
488
+ const steel = k.extrude([[0, 0], [L * 0.66, 0], [L * 0.68, a * 0.4], [0, a]], Math.max(5e-4, b * 0.4 - 2 * edge), edge);
489
+ return k.G(k.mesh(steel, k.metal(11120048), [-L * 0.18, -a / 2, -b * 0.2 + edge]), k.mesh(k.bx(L * 0.34, a * 0.6, b), k.wood(3877408), [-L * 0.33, 0, 0]));
490
+ });
491
+ var garment = (c) => {
492
+ const { k, w, h, d } = c;
493
+ const material = k.cloth(c.color);
494
+ return k.G(k.mesh(k.bx(w * 0.56, h, d), material), k.mesh(k.bx(w * 0.22, h * 0.42, d * 0.9), material, [-w * 0.39, h * 0.29, 0]), k.mesh(k.bx(w * 0.22, h * 0.42, d * 0.9), material, [w * 0.39, h * 0.29, 0]));
495
+ };
496
+ var backpack = (c) => {
497
+ const { k, w, h, d } = c;
498
+ const material = k.cloth(c.color);
499
+ const dome = new k.T.SphereGeometry(0.5, seg(c, 12), seg(c, 6), 0, PI * 2, 0, PI / 2);
500
+ const strap = k.cloth(shade(c.color, 0.6));
501
+ return k.G(k.mesh(k.bx(w, h * 0.78, d * 0.68), material, [0, -h * 0.11, -d * 0.14]), k.mesh(dome, material, [0, h * 0.28, -d * 0.14], [0, 0, 0], [w, h * 0.44, d * 0.68]), k.mesh(k.bx(w * 0.7, h * 0.4, d * 0.3), k.cloth(shade(c.color, 0.75)), [0, -h * 0.18, d * 0.35]), k.mesh(k.bx(w * 0.1, h * 0.7, d * 0.04), strap, [-w * 0.25, -h * 0.05, -d * 0.48]), k.mesh(k.bx(w * 0.1, h * 0.7, d * 0.04), strap, [w * 0.25, -h * 0.05, -d * 0.48]));
502
+ };
503
+ var jerrycan = (c) => {
504
+ const { k, w, h, d } = c;
505
+ const material = k.plastic(c.color);
506
+ return k.G(k.mesh(k.bx(w, h * 0.86, d), material, [0, -h * 0.07, 0]), k.mesh(k.bx(w * 0.4, h * 0.1, d * 0.5), material, [-w * 0.2, h * 0.45, 0]), k.mesh(k.cyl(d * 0.14, d * 0.18, h * 0.12, seg(c, 10)), k.plastic(14263361), [w * 0.3, h * 0.44, 0]));
507
+ };
508
+ var tank = (c) => {
509
+ const { k, h } = c;
510
+ const r = 0.5;
511
+ const profile = [[0, -h / 2], [r * 0.9, -h / 2], [r, -h * 0.4], [r, h * 0.22], [r * 0.6, h * 0.36], [r * 0.2, h * 0.4], [0, h * 0.4]];
512
+ const metal = k.metal(c.color);
513
+ return across(c, k.G(k.mesh(k.lathe(profile, seg(c, 14)), metal), k.mesh(k.cyl(r * 0.62, r * 0.62, h * 0.05, seg(c, 14)), metal, [0, h * 0.3, 0]), k.mesh(k.cyl(r * 0.18, r * 0.18, h * 0.12, seg(c, 8)), k.metal(12095802), [0, h * 0.44, 0])));
514
+ };
515
+ var book = (c) => {
516
+ const { k, w, h, d } = c;
517
+ const cover = k.paper(c.color);
518
+ return k.G(k.mesh(k.bx(w - PROUD, h - 2 * PROUD, d * 0.14), cover, [PROUD / 2, 0, d * 0.43 - PROUD]), k.mesh(k.bx(w - PROUD, h - 2 * PROUD, d * 0.14), cover, [PROUD / 2, 0, -d * 0.43 + PROUD]), k.mesh(k.bx(w * 0.94, h * 0.96, d * 0.72), k.paper(15327692), [w * 0.02, 0, 0]), k.mesh(k.bx(w * 0.08, h, d), k.paper(shade(c.color, 0.8)), [-w * 0.46, 0, 0]));
519
+ };
520
+ var key = alongLong((c, L, a, b) => {
521
+ const { k } = c;
522
+ const metal = k.metal(12095802);
523
+ const ring = a * 0.5;
524
+ const tube2 = Math.min(b * 0.4, ring * 0.2);
525
+ return k.G(k.mesh(new c.k.T.TorusGeometry(ring * 0.8, tube2, 5, seg(c, 10)), k.metal(10132896), [-L / 2 + ring * 0.8 + tube2, 0, 0]), k.mesh(k.bx(L * 0.62, a * 0.28, b), metal, [L * 0.12, 0, 0]), k.mesh(k.bx(L * 0.08, a * 0.17, b), metal, [L * 0.36, -a * 0.225, 0]), k.mesh(k.bx(L * 0.06, a * 0.17, b), metal, [L * 0.2, -a * 0.225, 0]));
526
+ });
527
+ var battery = alongLong((c, L, a, b) => {
528
+ const { k } = c;
529
+ const r = Math.min(a, b) / 2;
530
+ return k.G(k.mesh(k.cyl(r, r, L * 0.94, seg(c, 14)), k.metal(c.color), [0, 0, 0], [0, 0, PI / 2]), k.mesh(k.cyl(r * 0.36, r * 0.36, L * 0.06, seg(c, 8)), k.metal(12172736), [L * 0.47, 0, 0], [0, 0, PI / 2]));
531
+ });
532
+ var plank = alongLong((c, L, a, b) => {
533
+ const { k } = c;
534
+ const nail = k.metal(8225158);
535
+ return k.G(k.mesh(k.bx(L, a, b), k.wood(11043929)), k.mesh(k.cyl(Math.min(a, b) * 0.1, Math.min(a, b) * 0.1, b * 0.98, 6), nail, [-L * 0.4, 0, 0], [PI / 2, 0, 0]), k.mesh(k.cyl(Math.min(a, b) * 0.1, Math.min(a, b) * 0.1, b * 0.98, 6), nail, [L * 0.4, 0, 0], [PI / 2, 0, 0]));
536
+ });
537
+ var device = (c) => {
538
+ const { k, w, h, d } = c;
539
+ const screen = k.M(10469258, "glass", { emissive: 3099170, emissiveIntensity: 0.6, roughness: 0.2 });
540
+ return k.G(k.mesh(k.bx(w, h, d * 0.96), k.plastic(c.color), [0, 0, -d * 0.02]), k.mesh(k.bx(w * 0.7, h * 0.32, d * 0.06), screen, [0, h * 0.22, d * 0.47]), k.mesh(k.cyl(Math.min(w, h) * 0.08, Math.min(w, h) * 0.08, d * 0.1, seg(c, 8)), k.metal(12172736), [w * 0.25, -h * 0.18, d * 0.45], [PI / 2, 0, 0]));
541
+ };
542
+ var DRAWERS = {
543
+ can,
544
+ bag,
545
+ box,
546
+ bottle,
547
+ tool,
548
+ roll,
549
+ dish,
550
+ cloth,
551
+ shoe,
552
+ jar,
553
+ paper,
554
+ fruit,
555
+ cup,
556
+ tube,
557
+ blade,
558
+ long_tool: longTool,
559
+ garment,
560
+ backpack,
561
+ jerrycan,
562
+ tank,
563
+ book,
564
+ key,
565
+ battery,
566
+ plank,
567
+ device
568
+ };
569
+ var isShape = (value) => value !== void 0 && value in DRAWERS;
570
+ function shapeOf(subject) {
571
+ const hint = subject.shape;
572
+ if (!isShape(hint)) return "box";
573
+ const [w, h, d] = subject.size;
574
+ const { L, a, b } = canonicalFrame(subject.size);
575
+ const long = L / Math.max(a, b, 1e-6) >= 4;
576
+ const flat = Math.min(w, h, d) / Math.max(w, h, d) <= 0.2;
577
+ switch (hint) {
578
+ case "tool":
579
+ if (subject.category === "keys") return "key";
580
+ if (subject.category === "electronics") return "device";
581
+ if (long) return subject.category === "melee" && Math.min(a, b) / L <= 0.1 && flat ? "blade" : "long_tool";
582
+ return hint;
583
+ case "cloth":
584
+ return subject.category === "clothing" ? "garment" : hint;
585
+ case "bag":
586
+ return subject.category === "bags" ? "backpack" : hint;
587
+ case "box":
588
+ if (subject.category === "electronics") return "device";
589
+ if (subject.category === "books") return "book";
590
+ if (subject.category === "keys") return "key";
591
+ return hint;
592
+ case "paper":
593
+ return subject.category === "books" ? "book" : hint;
594
+ default:
595
+ return hint;
596
+ }
597
+ }
598
+ function drawShape(k, shape, size, options = {}) {
599
+ const [w, h, d] = size;
600
+ return DRAWERS[shape]({ k, w, h, d, color: options.color ?? DEFAULT_COLOR, detail: options.detail ?? 1 });
601
+ }
602
+
345
603
  // src/destruction.ts
346
604
  var DESTRUCTION_MATERIAL_BY_TAG = {
347
605
  metal: "steel",
@@ -350,12 +608,13 @@ var DESTRUCTION_MATERIAL_BY_TAG = {
350
608
  paper: "paper",
351
609
  plastic: "plastic",
352
610
  cloth: "fabric",
611
+ rubber: "rubber",
353
612
  food: "flesh_fruit"
354
613
  };
355
614
  var FAMILIES = destruction_default.families;
356
615
  var CONTENTS = destruction_default.contents;
357
- var SHAPES = destruction_default.shapes;
358
- var shapeDestruction = (shapeId) => SHAPES[shapeId];
616
+ var SHAPES2 = destruction_default.shapes;
617
+ var shapeDestruction = (shapeId) => SHAPES2[shapeId];
359
618
  var FAMILY_OF_MODEL = new Map(Object.entries(FAMILIES).flatMap(([family, entry]) => entry.models.map((model) => [model, family])));
360
619
  var itemFamily = (modelId) => FAMILY_OF_MODEL.get(modelId);
361
620
  var itemDestruction = (modelId) => {
@@ -385,6 +644,16 @@ function itemContents(subject) {
385
644
  };
386
645
  return { container, liquid: contents.liquid, liters };
387
646
  }
647
+ var VESSEL_FLOORS = { cup: CUP_FLOOR_SHARE };
648
+ function itemVessel(subject) {
649
+ const capacity = subject.capacityLiters;
650
+ const floor = subject.shape === void 0 ? void 0 : VESSEL_FLOORS[subject.shape];
651
+ if (capacity === void 0 || !(capacity > 0) || floor === void 0) return void 0;
652
+ const [width, height, depth] = subject.size;
653
+ const radius = Math.min(width, depth) / 2 * WALL_SHARE;
654
+ const container = { capacity, liters: 0, shape: { kind: "cylinder", radius, height: height * WALL_SHARE }, opening: radius, closed: false };
655
+ return { container, offset: [0, height * floor, 0] };
656
+ }
388
657
  function tagOf(mesh) {
389
658
  const material = Array.isArray(mesh.material) ? mesh.material[0] : mesh.material;
390
659
  const tag = material?.userData?.tag;
@@ -3057,7 +3326,17 @@ var models_default = [
3057
3326
  0.553
3058
3327
  ],
3059
3328
  scale: 0.092308
3060
- }
3329
+ },
3330
+ {
3331
+ id: "plunger",
3332
+ teamId: "desentupidor",
3333
+ teamBox: [
3334
+ 1.4,
3335
+ 5.5,
3336
+ 1.4
3337
+ ],
3338
+ scale: 0.1
3339
+ }
3061
3340
  ];
3062
3341
 
3063
3342
  // src/models/canned-beans.ts
@@ -4239,6 +4518,16 @@ var alcohol70 = ({ mesh, cyl, lathe, G, glass, plastic, paper: paper2 }) => {
4239
4518
  return G(bottle2, label, stripe, cap, nozzle);
4240
4519
  };
4241
4520
 
4521
+ // src/models/plunger.ts
4522
+ var plunger = ({ mesh, cyl, G, M, wood }) => {
4523
+ const rubber = M(11545120, "rubber", { roughness: 0.75 });
4524
+ const cup2 = mesh(cyl(0.3, 0.7, 0.75, 16), rubber, [0, 0.455, 0]);
4525
+ const lip = mesh(cyl(0.7, 0.7, 0.08, 16), M(9314841, "rubber", { roughness: 0.8 }), [0, 0.04, 0]);
4526
+ const neck = mesh(cyl(0.2, 0.3, 0.3, 12), rubber, [0, 0.98, 0]);
4527
+ const handle = mesh(cyl(0.15, 0.15, 4.4, 10), wood(10122312), [0, 3.3, 0]);
4528
+ return G(cup2, lip, neck, handle);
4529
+ };
4530
+
4242
4531
  // src/models/can-opener.ts
4243
4532
  var canOpener = ({ mesh, bx, cyl, G, metal, plastic }) => {
4244
4533
  const steel = metal(11120050);
@@ -5314,7 +5603,7 @@ var armyCamouflageUniform = ({ mesh, bx, G, cloth: cloth2 }) => {
5314
5603
  };
5315
5604
 
5316
5605
  // src/models/backpack.ts
5317
- var backpack = ({ mesh, bx, G, cloth: cloth2, plastic }) => {
5606
+ var backpack2 = ({ mesh, bx, G, cloth: cloth2, plastic }) => {
5318
5607
  const main = cloth2(3099243);
5319
5608
  const trim = cloth2(1976890);
5320
5609
  return G(
@@ -6828,7 +7117,7 @@ var BUILDERS = {
6828
7117
  rebar,
6829
7118
  lubricant_spray: lubricantSpray,
6830
7119
  army_camouflage_uniform: armyCamouflageUniform,
6831
- backpack,
7120
+ backpack: backpack2,
6832
7121
  ballistic_vest: ballisticVest,
6833
7122
  battery_9v: battery9V,
6834
7123
  bean_seeds: beanSeeds,
@@ -6915,7 +7204,8 @@ var BUILDERS = {
6915
7204
  tshirt,
6916
7205
  watering_can: wateringCan,
6917
7206
  wheelbarrow,
6918
- windup_alarm_clock: windupAlarmClock
7207
+ windup_alarm_clock: windupAlarmClock,
7208
+ plunger
6919
7209
  };
6920
7210
  var SHIPPED_MODELS = models_default.map((entry) => {
6921
7211
  const builder = BUILDERS[entry.id];
@@ -6947,264 +7237,8 @@ var itemModelBuilder = (id) => defaultItemModels().builder(id);
6947
7237
  var hasItemModel = (id) => defaultItemModels().has(id);
6948
7238
  var listItemModels = () => defaultItemModels().list();
6949
7239
 
6950
- // src/shapes.ts
6951
- var SHAPES2 = [
6952
- "can",
6953
- "bag",
6954
- "box",
6955
- "bottle",
6956
- "tool",
6957
- "roll",
6958
- "dish",
6959
- "cloth",
6960
- "shoe",
6961
- "jar",
6962
- "paper",
6963
- "fruit",
6964
- "cup",
6965
- "tube",
6966
- "blade",
6967
- "long_tool",
6968
- "garment",
6969
- "backpack",
6970
- "jerrycan",
6971
- "tank",
6972
- "book",
6973
- "key",
6974
- "battery",
6975
- "plank",
6976
- "device"
6977
- ];
6978
- var DEFAULT_COLOR = 9080724;
6979
- var PI = Math.PI;
6980
- function shade(color, factor) {
6981
- const channel = (shift) => Math.max(0, Math.min(255, Math.round((color >> shift & 255) * factor)));
6982
- return channel(16) << 16 | channel(8) << 8 | channel(0);
6983
- }
6984
- var PROUD = 2e-3;
6985
- var seg = (c, n) => Math.max(5, Math.round(n * c.detail));
6986
- function canonicalFrame(size) {
6987
- const [w, h, d] = size;
6988
- if (h >= w && h >= d) return { axis: 1, L: h, a: w, b: d };
6989
- if (d >= w && d >= h) return { axis: 2, L: d, a: h, b: w };
6990
- return { axis: 0, L: w, a: h, b: d };
6991
- }
6992
- function orient(c, group, axis) {
6993
- if (axis === 0) return group;
6994
- const holder = c.k.G(group);
6995
- if (axis === 1) holder.rotation.z = PI / 2;
6996
- else holder.rotation.y = -PI / 2;
6997
- return holder;
6998
- }
6999
- var alongLong = (draw) => (c) => {
7000
- const { axis, L, a, b } = canonicalFrame([c.w, c.h, c.d]);
7001
- return orient(c, draw(c, L, a, b), axis);
7002
- };
7003
- var across = (c, group) => {
7004
- group.scale.set(c.w, 1, c.d);
7005
- return c.k.G(group);
7006
- };
7007
- var can = (c) => {
7008
- const { k, h } = c;
7009
- const body = k.metal(9277590);
7010
- const r = 0.5 - PROUD / Math.min(c.w, c.d);
7011
- return across(c, k.G(k.mesh(k.cyl(r, r, h * 0.94, seg(c, 14)), body), k.mesh(k.cyl(0.5, 0.5, h * 0.5, seg(c, 14)), k.food(c.color)), k.mesh(k.cyl(0.5, 0.5, h * 0.03, seg(c, 14)), body, [0, h * 0.485, 0]), k.mesh(k.cyl(0.5, 0.5, h * 0.03, seg(c, 14)), body, [0, -h * 0.485, 0])));
7012
- };
7013
- var bottle = (c) => {
7014
- const { k, h } = c;
7015
- const r = 0.5;
7016
- const profile = [[0, -h / 2], [r, -h / 2], [r, h * 0.12], [r * 0.45, h * 0.3], [r * 0.4, h * 0.4], [0, h * 0.4]];
7017
- return across(c, k.G(k.mesh(k.lathe(profile, seg(c, 14)), k.glass(c.color, 0.6)), k.mesh(k.cyl(r * 0.42, r * 0.42, h * 0.1, seg(c, 10)), k.plastic(shade(c.color, 0.5)), [0, h * 0.45, 0])));
7018
- };
7019
- var jar = (c) => {
7020
- const { k, h } = c;
7021
- return across(c, k.G(k.mesh(k.cyl(0.5, 0.5, h * 0.82, seg(c, 14)), k.glass(c.color, 0.55), [0, -h * 0.09, 0]), k.mesh(k.cyl(0.5, 0.5, h * 0.18, seg(c, 14)), k.metal(12095802), [0, h * 0.41, 0])));
7022
- };
7023
- var bag = (c) => {
7024
- const { k, w, h, d } = c;
7025
- return k.G(k.mesh(k.bx(w, h * 0.88, d - 2 * PROUD), k.paper(c.color), [0, -h * 0.06, 0]), k.mesh(k.bx(w * 1, h * 0.12, d * 0.5), k.paper(shade(c.color, 0.85)), [0, h * 0.44, 0]), k.mesh(k.bx(w * 0.7, h * 0.3, d), k.paper(shade(c.color, 1.2)), [0, 0, 0]));
7026
- };
7027
- var box = (c) => {
7028
- const { k, w, h, d } = c;
7029
- return k.G(k.mesh(k.bx(w - 2 * PROUD, h - PROUD, d - 2 * PROUD), k.paper(c.color), [0, -PROUD / 2, 0]), k.mesh(k.bx(w, h * 0.12, d), k.paper(shade(c.color, 0.8)), [0, h * 0.44, 0]), k.mesh(k.bx(w * 0.62, h * 0.4, d), k.paper(shade(c.color, 1.25)), [0, -h * 0.02, 0]));
7030
- };
7031
- var cloth = (c) => {
7032
- const { k, w, h, d } = c;
7033
- const material = k.cloth(c.color);
7034
- return k.G(k.mesh(k.bx(w, h * 0.55, d), material, [0, -h * 0.225, 0]), k.mesh(k.bx(w * 0.96, h * 0.45, d * 0.96), k.cloth(shade(c.color, 0.9)), [0, h * 0.275, 0]));
7035
- };
7036
- var paper = (c) => {
7037
- const { k, w, h, d } = c;
7038
- const sheet = k.paper(c.color);
7039
- return k.G(k.mesh(k.bx(w, h / 3, d), sheet, [0, -h / 3, 0]), k.mesh(k.bx(w * 0.98, h / 3, d * 0.98), k.paper(shade(c.color, 0.95)), [0, 0, 0]), k.mesh(k.bx(w, h / 3, d), sheet, [0, h / 3, 0]));
7040
- };
7041
- var fruit = (c) => {
7042
- const { k, w, h, d } = c;
7043
- const sphere = new k.T.SphereGeometry(0.5, seg(c, 12), seg(c, 8));
7044
- return k.G(k.mesh(sphere, k.food(c.color), [0, -h * 0.04, 0], [0, 0, 0], [w, h * 0.92, d]), k.mesh(k.cyl(h * 0.02, h * 0.02, h * 0.1, 6), k.wood(5913122), [0, h * 0.45, 0]));
7045
- };
7046
- var dish = (c) => {
7047
- const { k, w, h, d } = c;
7048
- return k.G(k.mesh(k.cyl(0.5, 0.35, h, seg(c, 16)), k.plastic(c.color), [0, 0, 0], [0, 0, 0], [w, 1, d]));
7049
- };
7050
- var cup = (c) => {
7051
- const { k, w, h, d } = c;
7052
- const profile = [[0, -h / 2], [0.38, -h / 2], [0.5, h / 2], [0.44, h / 2], [0.33, -h / 2 + h * 0.06], [0, -h / 2 + h * 0.06]];
7053
- return k.G(k.mesh(k.lathe(profile, seg(c, 14)), k.plastic(c.color), [0, 0, 0], [0, 0, 0], [w, 1, d]));
7054
- };
7055
- var tube = (c) => {
7056
- const { k, h } = c;
7057
- const material = k.plastic(c.color);
7058
- return across(c, k.G(k.mesh(k.cyl(0.5, 0.42, h * 0.86, seg(c, 12)), material, [0, -h * 0.04, 0]), k.mesh(k.cyl(0.35, 0.35, h * 0.12, seg(c, 12)), k.plastic(shade(c.color, 0.6)), [0, h * 0.44, 0]), k.mesh(k.bx(1, h * 0.06, 0.25), material, [0, -h * 0.47, 0])));
7059
- };
7060
- var roll = (c) => {
7061
- const { k, w, h, d } = c;
7062
- const body = k.G(k.mesh(k.cyl(0.5, 0.5, 1, seg(c, 18)), k.paper(c.color)), k.mesh(k.cyl(0.18, 0.18, 0.98, seg(c, 12)), k.paper(11902328)));
7063
- if (h <= w && h <= d) body.scale.set(w, h, d);
7064
- else if (w <= d) {
7065
- body.rotation.z = PI / 2;
7066
- body.scale.set(h, w, d);
7067
- } else {
7068
- body.rotation.x = PI / 2;
7069
- body.scale.set(w, d, h);
7070
- }
7071
- return k.G(body);
7072
- };
7073
- var shoe = (c) => {
7074
- const { k, w, h, d } = c;
7075
- const upper = k.cloth(c.color);
7076
- return k.G(k.mesh(k.bx(w, h * 0.22, d), k.plastic(2237727), [0, -h * 0.39, 0]), k.mesh(k.bx(w * 0.42, h * 0.78, d * 0.96), upper, [-w * 0.29, h * 0.11, 0]), k.mesh(k.bx(w * 0.5, h * 0.5, d * 0.96), upper, [w * 0.25, -h * 0.03, 0]));
7077
- };
7078
- var tool = alongLong((c, L, a, b) => {
7079
- const { k } = c;
7080
- const radius = Math.max(4e-3, Math.min(a, b) / 2);
7081
- return k.G(k.mesh(k.cyl(radius, radius, L * 0.74, seg(c, 10)), k.wood(9069628), [-L * 0.13, 0, 0], [0, 0, PI / 2]), k.mesh(k.bx(L * 0.26, a, b), k.metal(shade(c.color, 1)), [L * 0.37, 0, 0]));
7082
- });
7083
- var longTool = alongLong((c, L, a, b) => {
7084
- const { k } = c;
7085
- const radius = Math.max(4e-3, Math.min(a, b) / 2) * 0.55;
7086
- return k.G(k.mesh(k.cyl(radius, radius, L * 0.94, seg(c, 10)), k.wood(10122312), [0, 0, 0], [0, 0, PI / 2]), k.mesh(k.bx(L * 0.12, a, b), k.metal(c.color), [L * 0.44, 0, 0]));
7087
- });
7088
- var blade = alongLong((c, L, a, b) => {
7089
- const { k } = c;
7090
- const edge = Math.min(2e-4, b * 0.05);
7091
- const steel = k.extrude([[0, 0], [L * 0.66, 0], [L * 0.68, a * 0.4], [0, a]], Math.max(5e-4, b * 0.4 - 2 * edge), edge);
7092
- return k.G(k.mesh(steel, k.metal(11120048), [-L * 0.18, -a / 2, -b * 0.2 + edge]), k.mesh(k.bx(L * 0.34, a * 0.6, b), k.wood(3877408), [-L * 0.33, 0, 0]));
7093
- });
7094
- var garment = (c) => {
7095
- const { k, w, h, d } = c;
7096
- const material = k.cloth(c.color);
7097
- return k.G(k.mesh(k.bx(w * 0.56, h, d), material), k.mesh(k.bx(w * 0.22, h * 0.42, d * 0.9), material, [-w * 0.39, h * 0.29, 0]), k.mesh(k.bx(w * 0.22, h * 0.42, d * 0.9), material, [w * 0.39, h * 0.29, 0]));
7098
- };
7099
- var backpack2 = (c) => {
7100
- const { k, w, h, d } = c;
7101
- const material = k.cloth(c.color);
7102
- const dome = new k.T.SphereGeometry(0.5, seg(c, 12), seg(c, 6), 0, PI * 2, 0, PI / 2);
7103
- const strap = k.cloth(shade(c.color, 0.6));
7104
- return k.G(k.mesh(k.bx(w, h * 0.78, d * 0.68), material, [0, -h * 0.11, -d * 0.14]), k.mesh(dome, material, [0, h * 0.28, -d * 0.14], [0, 0, 0], [w, h * 0.44, d * 0.68]), k.mesh(k.bx(w * 0.7, h * 0.4, d * 0.3), k.cloth(shade(c.color, 0.75)), [0, -h * 0.18, d * 0.35]), k.mesh(k.bx(w * 0.1, h * 0.7, d * 0.04), strap, [-w * 0.25, -h * 0.05, -d * 0.48]), k.mesh(k.bx(w * 0.1, h * 0.7, d * 0.04), strap, [w * 0.25, -h * 0.05, -d * 0.48]));
7105
- };
7106
- var jerrycan = (c) => {
7107
- const { k, w, h, d } = c;
7108
- const material = k.plastic(c.color);
7109
- return k.G(k.mesh(k.bx(w, h * 0.86, d), material, [0, -h * 0.07, 0]), k.mesh(k.bx(w * 0.4, h * 0.1, d * 0.5), material, [-w * 0.2, h * 0.45, 0]), k.mesh(k.cyl(d * 0.14, d * 0.18, h * 0.12, seg(c, 10)), k.plastic(14263361), [w * 0.3, h * 0.44, 0]));
7110
- };
7111
- var tank = (c) => {
7112
- const { k, h } = c;
7113
- const r = 0.5;
7114
- const profile = [[0, -h / 2], [r * 0.9, -h / 2], [r, -h * 0.4], [r, h * 0.22], [r * 0.6, h * 0.36], [r * 0.2, h * 0.4], [0, h * 0.4]];
7115
- const metal = k.metal(c.color);
7116
- return across(c, k.G(k.mesh(k.lathe(profile, seg(c, 14)), metal), k.mesh(k.cyl(r * 0.62, r * 0.62, h * 0.05, seg(c, 14)), metal, [0, h * 0.3, 0]), k.mesh(k.cyl(r * 0.18, r * 0.18, h * 0.12, seg(c, 8)), k.metal(12095802), [0, h * 0.44, 0])));
7117
- };
7118
- var book = (c) => {
7119
- const { k, w, h, d } = c;
7120
- const cover = k.paper(c.color);
7121
- return k.G(k.mesh(k.bx(w - PROUD, h - 2 * PROUD, d * 0.14), cover, [PROUD / 2, 0, d * 0.43 - PROUD]), k.mesh(k.bx(w - PROUD, h - 2 * PROUD, d * 0.14), cover, [PROUD / 2, 0, -d * 0.43 + PROUD]), k.mesh(k.bx(w * 0.94, h * 0.96, d * 0.72), k.paper(15327692), [w * 0.02, 0, 0]), k.mesh(k.bx(w * 0.08, h, d), k.paper(shade(c.color, 0.8)), [-w * 0.46, 0, 0]));
7122
- };
7123
- var key = alongLong((c, L, a, b) => {
7124
- const { k } = c;
7125
- const metal = k.metal(12095802);
7126
- const ring = a * 0.5;
7127
- const tube2 = Math.min(b * 0.4, ring * 0.2);
7128
- return k.G(k.mesh(new c.k.T.TorusGeometry(ring * 0.8, tube2, 5, seg(c, 10)), k.metal(10132896), [-L / 2 + ring * 0.8 + tube2, 0, 0]), k.mesh(k.bx(L * 0.62, a * 0.28, b), metal, [L * 0.12, 0, 0]), k.mesh(k.bx(L * 0.08, a * 0.17, b), metal, [L * 0.36, -a * 0.225, 0]), k.mesh(k.bx(L * 0.06, a * 0.17, b), metal, [L * 0.2, -a * 0.225, 0]));
7129
- });
7130
- var battery = alongLong((c, L, a, b) => {
7131
- const { k } = c;
7132
- const r = Math.min(a, b) / 2;
7133
- return k.G(k.mesh(k.cyl(r, r, L * 0.94, seg(c, 14)), k.metal(c.color), [0, 0, 0], [0, 0, PI / 2]), k.mesh(k.cyl(r * 0.36, r * 0.36, L * 0.06, seg(c, 8)), k.metal(12172736), [L * 0.47, 0, 0], [0, 0, PI / 2]));
7134
- });
7135
- var plank = alongLong((c, L, a, b) => {
7136
- const { k } = c;
7137
- const nail = k.metal(8225158);
7138
- return k.G(k.mesh(k.bx(L, a, b), k.wood(11043929)), k.mesh(k.cyl(Math.min(a, b) * 0.1, Math.min(a, b) * 0.1, b * 0.98, 6), nail, [-L * 0.4, 0, 0], [PI / 2, 0, 0]), k.mesh(k.cyl(Math.min(a, b) * 0.1, Math.min(a, b) * 0.1, b * 0.98, 6), nail, [L * 0.4, 0, 0], [PI / 2, 0, 0]));
7139
- });
7140
- var device = (c) => {
7141
- const { k, w, h, d } = c;
7142
- const screen = k.M(10469258, "glass", { emissive: 3099170, emissiveIntensity: 0.6, roughness: 0.2 });
7143
- return k.G(k.mesh(k.bx(w, h, d * 0.96), k.plastic(c.color), [0, 0, -d * 0.02]), k.mesh(k.bx(w * 0.7, h * 0.32, d * 0.06), screen, [0, h * 0.22, d * 0.47]), k.mesh(k.cyl(Math.min(w, h) * 0.08, Math.min(w, h) * 0.08, d * 0.1, seg(c, 8)), k.metal(12172736), [w * 0.25, -h * 0.18, d * 0.45], [PI / 2, 0, 0]));
7144
- };
7145
- var DRAWERS = {
7146
- can,
7147
- bag,
7148
- box,
7149
- bottle,
7150
- tool,
7151
- roll,
7152
- dish,
7153
- cloth,
7154
- shoe,
7155
- jar,
7156
- paper,
7157
- fruit,
7158
- cup,
7159
- tube,
7160
- blade,
7161
- long_tool: longTool,
7162
- garment,
7163
- backpack: backpack2,
7164
- jerrycan,
7165
- tank,
7166
- book,
7167
- key,
7168
- battery,
7169
- plank,
7170
- device
7171
- };
7172
- var isShape = (value) => value !== void 0 && value in DRAWERS;
7173
- function shapeOf(subject) {
7174
- const hint = subject.shape;
7175
- if (!isShape(hint)) return "box";
7176
- const [w, h, d] = subject.size;
7177
- const { L, a, b } = canonicalFrame(subject.size);
7178
- const long = L / Math.max(a, b, 1e-6) >= 4;
7179
- const flat = Math.min(w, h, d) / Math.max(w, h, d) <= 0.2;
7180
- switch (hint) {
7181
- case "tool":
7182
- if (subject.category === "keys") return "key";
7183
- if (subject.category === "electronics") return "device";
7184
- if (long) return subject.category === "melee" && Math.min(a, b) / L <= 0.1 && flat ? "blade" : "long_tool";
7185
- return hint;
7186
- case "cloth":
7187
- return subject.category === "clothing" ? "garment" : hint;
7188
- case "bag":
7189
- return subject.category === "bags" ? "backpack" : hint;
7190
- case "box":
7191
- if (subject.category === "electronics") return "device";
7192
- if (subject.category === "books") return "book";
7193
- if (subject.category === "keys") return "key";
7194
- return hint;
7195
- case "paper":
7196
- return subject.category === "books" ? "book" : hint;
7197
- default:
7198
- return hint;
7199
- }
7200
- }
7201
- function drawShape(k, shape, size, options = {}) {
7202
- const [w, h, d] = size;
7203
- return DRAWERS[shape]({ k, w, h, d, color: options.color ?? DEFAULT_COLOR, detail: options.detail ?? 1 });
7204
- }
7205
-
7206
7240
  // src/wear.ts
7207
- var WEAR_TARGET = { food: 6122286, metal: 8011293, wood: 4141862, cloth: 4866099, plastic: 7038294, paper: 9075282, glass: 5591098 };
7241
+ var WEAR_TARGET = { food: 6122286, metal: 8011293, wood: 4141862, cloth: 4866099, plastic: 7038294, paper: 9075282, glass: 5591098, rubber: 4860452 };
7208
7242
  var WEAR_AMOUNT = [0, 0.3, 0.62];
7209
7243
  var hexToRgb = (hex2) => [(hex2 >> 16 & 255) / 255, (hex2 >> 8 & 255) / 255, (hex2 & 255) / 255];
7210
7244
  var dataOf = (material) => {
@@ -7405,6 +7439,153 @@ function renderItemThumbnail(T, renderer, item, options = {}) {
7405
7439
  return renderer.domElement.toDataURL("image/png");
7406
7440
  }
7407
7441
 
7442
+ // src/wash.ts
7443
+ var WASH_NAME = "item_wash";
7444
+ var STAIN_LIFT = 15e-4;
7445
+ var SPOTS = [
7446
+ [0, 0],
7447
+ [0.5, 0],
7448
+ [0.155, 0.476],
7449
+ [-0.405, 0.294],
7450
+ [-0.405, -0.294],
7451
+ [0.155, -0.476]
7452
+ ];
7453
+ var STAIN_RADIUS = 0.12;
7454
+ var BUBBLE_RADIUS = 0.1;
7455
+ var BUBBLE_CLUSTER = [
7456
+ [0, 0, 1],
7457
+ [1.1, 0.3, 0.7],
7458
+ [-0.6, 0.9, 0.6]
7459
+ ];
7460
+ var STAIN_COLORS = [8014370, 10903070, 6175260, 12088362, 9067050, 10243866];
7461
+ var FOAM_COLOR = 16054008;
7462
+ var overlays = /* @__PURE__ */ new WeakMap();
7463
+ var isOwnMesh = (mesh) => !mesh.userData.destructionDebris && mesh.parent?.name !== WASH_NAME;
7464
+ function localBox2(T, root) {
7465
+ root.updateMatrixWorld(true);
7466
+ const toRoot = new T.Matrix4().copy(root.matrixWorld).invert();
7467
+ const box2 = new T.Box3();
7468
+ const part = new T.Box3();
7469
+ const m = new T.Matrix4();
7470
+ root.traverse((o) => {
7471
+ const mesh = o;
7472
+ if (!mesh.isMesh || !isOwnMesh(mesh)) return;
7473
+ if (!mesh.geometry.boundingBox) mesh.geometry.computeBoundingBox();
7474
+ const bounds = mesh.geometry.boundingBox;
7475
+ if (!bounds) return;
7476
+ part.copy(bounds).applyMatrix4(m.multiplyMatrices(toRoot, mesh.matrixWorld));
7477
+ box2.union(part);
7478
+ });
7479
+ return box2;
7480
+ }
7481
+ function spotsOn(T, root, box2) {
7482
+ const meshes = [];
7483
+ root.traverse((o) => {
7484
+ const mesh = o;
7485
+ if (mesh.isMesh && isOwnMesh(mesh)) meshes.push(mesh);
7486
+ });
7487
+ const toRoot = new T.Matrix4().copy(root.matrixWorld).invert();
7488
+ const down = new T.Vector3(0, -1, 0).transformDirection(root.matrixWorld);
7489
+ const ray = new T.Raycaster();
7490
+ const centre = box2.getCenter(new T.Vector3());
7491
+ const half = box2.getSize(new T.Vector3()).multiplyScalar(0.5);
7492
+ const above = box2.max.y + half.y + 0.01;
7493
+ const spots = [];
7494
+ for (const [x, z] of SPOTS) {
7495
+ const origin = new T.Vector3(centre.x + x * half.x, above, centre.z + z * half.z).applyMatrix4(root.matrixWorld);
7496
+ ray.set(origin, down);
7497
+ const hit = ray.intersectObjects(meshes, false)[0];
7498
+ if (!hit?.face) continue;
7499
+ const normal = hit.face.normal.clone().transformDirection(hit.object.matrixWorld);
7500
+ if (normal.dot(down) > 0) normal.negate();
7501
+ const point = hit.point.clone().addScaledVector(normal, STAIN_LIFT).applyMatrix4(toRoot);
7502
+ spots.push({ point, normal: normal.transformDirection(toRoot) });
7503
+ }
7504
+ return spots;
7505
+ }
7506
+ function layerOf(T, geometry, material, bases, name) {
7507
+ const mesh = new T.InstancedMesh(geometry, material, bases.length);
7508
+ mesh.name = name;
7509
+ bases.forEach((base, i) => mesh.setMatrixAt(i, base));
7510
+ mesh.computeBoundingSphere();
7511
+ mesh.visible = false;
7512
+ mesh.userData.destructionDebris = true;
7513
+ mesh.raycast = () => {
7514
+ };
7515
+ return { mesh, bases, value: 0 };
7516
+ }
7517
+ function blotGeometry(T) {
7518
+ const geometry = new T.CircleGeometry(1, 9);
7519
+ const position = geometry.getAttribute("position");
7520
+ for (let i = 1; i < position.count; i++) {
7521
+ const wobble = 0.75 + 0.25 * Math.abs(Math.sin(i * 2.3));
7522
+ position.setXY(i, position.getX(i) * wobble, position.getY(i) * wobble);
7523
+ }
7524
+ return geometry.rotateX(-Math.PI / 2);
7525
+ }
7526
+ function createOverlay(T, root) {
7527
+ const scratch = { matrix: new T.Matrix4(), scale: new T.Matrix4() };
7528
+ const box2 = localBox2(T, root);
7529
+ const spots = box2.isEmpty() ? [] : spotsOn(T, root, box2);
7530
+ if (spots.length === 0) return { dirt: void 0, foam: void 0, scratch };
7531
+ const size = box2.getSize(new T.Vector3());
7532
+ const small = Math.min(size.x, size.z) / 2;
7533
+ const up = new T.Vector3(0, 1, 0);
7534
+ const turn = (normal, spin) => new T.Quaternion().setFromUnitVectors(up, normal).multiply(new T.Quaternion().setFromAxisAngle(up, spin));
7535
+ const stains = spots.map((spot, i) => {
7536
+ const r = small * STAIN_RADIUS;
7537
+ return new T.Matrix4().compose(spot.point, turn(spot.normal, i * 1.7), new T.Vector3(r, 1, r * (0.65 + 0.35 * (i * 0.37 % 1))));
7538
+ });
7539
+ const bubbleRadius = small * BUBBLE_RADIUS;
7540
+ const bubbles = spots.flatMap((spot, i) => {
7541
+ const q = turn(spot.normal, i * 1.1);
7542
+ return BUBBLE_CLUSTER.map(([along, across2, share]) => {
7543
+ const r = bubbleRadius * share;
7544
+ const at = new T.Vector3(along * bubbleRadius, r * 0.4 - STAIN_LIFT, across2 * bubbleRadius).applyQuaternion(q).add(spot.point);
7545
+ return new T.Matrix4().compose(at, q, new T.Vector3(r, r, r));
7546
+ });
7547
+ });
7548
+ const group = new T.Group();
7549
+ group.name = WASH_NAME;
7550
+ group.userData.destructionIgnore = true;
7551
+ const dirt = layerOf(T, blotGeometry(T), new T.MeshStandardMaterial({ roughness: 0.95, metalness: 0 }), stains, "item_dirt");
7552
+ stains.forEach((_, i) => dirt.mesh.setColorAt(i, new T.Color(STAIN_COLORS[i % STAIN_COLORS.length])));
7553
+ const foam = layerOf(T, new T.SphereGeometry(1, 8, 6), new T.MeshStandardMaterial({ color: FOAM_COLOR, roughness: 0.55, metalness: 0 }), bubbles, "item_foam");
7554
+ group.add(dirt.mesh, foam.mesh);
7555
+ root.add(group);
7556
+ return { dirt, foam, scratch };
7557
+ }
7558
+ function overlayOf(T, root) {
7559
+ const found = overlays.get(root);
7560
+ if (found) return found;
7561
+ const created = createOverlay(T, root);
7562
+ overlays.set(root, created);
7563
+ return created;
7564
+ }
7565
+ function showLayer(layer, value, scratch) {
7566
+ if (!layer) return;
7567
+ const share = Math.max(0, Math.min(1, value));
7568
+ if (share === layer.value) return;
7569
+ layer.value = share;
7570
+ layer.mesh.visible = share > 0;
7571
+ if (share === 0) return;
7572
+ const grow = 0.45 + 0.55 * share;
7573
+ scratch.scale.makeScale(grow, grow, grow);
7574
+ layer.bases.forEach((base, i) => {
7575
+ scratch.matrix.copy(base).multiply(scratch.scale);
7576
+ layer.mesh.setMatrixAt(i, scratch.matrix);
7577
+ });
7578
+ layer.mesh.instanceMatrix.needsUpdate = true;
7579
+ }
7580
+ function setItemDirt(T, root, dirt) {
7581
+ const overlay = overlayOf(T, root);
7582
+ showLayer(overlay.dirt, dirt, overlay.scratch);
7583
+ }
7584
+ function setItemFoam(T, root, amount) {
7585
+ const overlay = overlayOf(T, root);
7586
+ showLayer(overlay.foam, amount, overlay.scratch);
7587
+ }
7588
+
7408
7589
  // src/test-area/area.ts
7409
7590
  var SHOWCASE_STAND_ID = "stand_models";
7410
7591
  var RULER_ID = "ruler_155";
@@ -7615,6 +7796,20 @@ function createItemsTestModule(options) {
7615
7796
  const contents = itemContents(subject);
7616
7797
  return contents ? { fluid: { container: contents.container, part: SHELL_PART_ID } } : {};
7617
7798
  };
7799
+ const vesselOf = (def) => {
7800
+ const shape = def.model !== void 0 && modelSet.builder(def.model) ? void 0 : shapeOf(def);
7801
+ const vessel = itemVessel({ size: def.size, ...def.container?.capacityLiters === void 0 ? {} : { capacityLiters: def.container.capacityLiters }, ...shape === void 0 ? {} : { shape } });
7802
+ return vessel ? { fluid: { container: vessel.container, uses: ["drink", "sip", "pour", "pour_out"], offset: vessel.offset } } : {};
7803
+ };
7804
+ const washable = options.washable ?? ((def) => def.category !== "food" && (def.tags?.includes("kitchen") ?? false));
7805
+ const washOf = (def) => {
7806
+ if (!washable(def)) return {};
7807
+ const wash = {
7808
+ dirt: (root, dirt) => void (latestTHREE && setItemDirt(latestTHREE, root, dirt)),
7809
+ foam: (root, amount) => void (latestTHREE && setItemFoam(latestTHREE, root, amount))
7810
+ };
7811
+ return { wash };
7812
+ };
7618
7813
  const sealOf = (def, fluid) => {
7619
7814
  const model = def.model;
7620
7815
  if (!def.seal || model === void 0 || !itemOpening(model)) return fluid;
@@ -7636,7 +7831,8 @@ function createItemsTestModule(options) {
7636
7831
  };
7637
7832
  const usesOf = (def) => {
7638
7833
  const use = options.itemUse?.(def);
7639
- const liquid = sealOf(def, fluidOf({ ...def.model === void 0 ? {} : { model: def.model }, size: def.size, weight: def.weight }));
7834
+ const contents = fluidOf({ ...def.model === void 0 ? {} : { model: def.model }, size: def.size, weight: def.weight });
7835
+ const liquid = sealOf(def, contents.fluid ? contents : vesselOf(def));
7640
7836
  if (!use) return liquid;
7641
7837
  const edible = def.category === "food" || def.category === "drink";
7642
7838
  return { ...liquid, ...liquid.fluid && !edible ? { fluid: { ...liquid.fluid, uses: ["pour", "pour_out"] } } : {}, use };
@@ -7647,10 +7843,15 @@ function createItemsTestModule(options) {
7647
7843
  movable: true,
7648
7844
  thumbnail: itemThumbnailSvg(drawable(def)),
7649
7845
  ...usesOf(def),
7846
+ ...washOf(def),
7847
+ catalogId: def.id,
7848
+ // what the item spends at each use (detergent, soap): the room takes its doses and shows what is left
7849
+ ...def.consumable ? { consumable: def.consumable } : {},
7650
7850
  // an item with a make-up (a shovel: ash handle riveted to a steel blade) is that spec, not the parts guessed from its meshes
7651
7851
  ...makeupSpecOf(def.model),
7652
7852
  // an item that is also a tool of the arsenal (a shovel) is picked up as that tool
7653
7853
  ...def.weapon ? { weapon: def.weapon } : {},
7854
+ ...def.tools ? { tools: def.tools } : {},
7654
7855
  physical: { weightKg: def.weight, size: def.size, ...def.volume === void 0 ? {} : { litres: def.volume } },
7655
7856
  build: (THREE) => {
7656
7857
  const T = THREE;
@@ -8141,9 +8342,10 @@ export {
8141
8342
  WEAR_AMOUNT,
8142
8343
  wearableMaterials,
8143
8344
  setWear,
8144
- SHAPES2 as SHAPES,
8345
+ SHAPES,
8145
8346
  shade,
8146
8347
  canonicalFrame,
8348
+ CUP_FLOOR_SHARE,
8147
8349
  isShape,
8148
8350
  shapeOf,
8149
8351
  drawShape,
@@ -8157,6 +8359,7 @@ export {
8157
8359
  ITEM_FAMILIES,
8158
8360
  SHELL_PART_ID,
8159
8361
  itemContents,
8362
+ itemVessel,
8160
8363
  tagForDestruction,
8161
8364
  itemOpening,
8162
8365
  OPENING_NAME,
@@ -8174,6 +8377,9 @@ export {
8174
8377
  hasItemModel,
8175
8378
  listItemModels,
8176
8379
  buildItem,
8380
+ WASH_NAME,
8381
+ setItemDirt,
8382
+ setItemFoam,
8177
8383
  ITEM_BUDGETS,
8178
8384
  sizeClassOf,
8179
8385
  triangleBudgetOf,
@@ -8202,4 +8408,4 @@ export {
8202
8408
  HUMAN_HEIGHT,
8203
8409
  createItemsTestModule
8204
8410
  };
8205
- //# sourceMappingURL=chunk-DBIE2ZMX.js.map
8411
+ //# sourceMappingURL=chunk-FCEKW7F6.js.map