@adatechnology/game-urban-three 0.2.6 → 0.2.8

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.
@@ -1587,6 +1587,90 @@ var GameUrbanThree = (() => {
1587
1587
  shims.add(result);
1588
1588
  return result;
1589
1589
  }
1590
+ var isTexture = (v) => !!v && typeof v === "object" && v.isTexture === true;
1591
+ function texturesOf(material, out) {
1592
+ for (const value of Object.values(material)) if (isTexture(value)) out.add(value);
1593
+ const uniforms = material.uniforms;
1594
+ if (uniforms) {
1595
+ for (const u of Object.values(uniforms)) if (isTexture(u?.value)) out.add(u.value);
1596
+ }
1597
+ }
1598
+ function collect(roots) {
1599
+ const geometries = /* @__PURE__ */ new Set();
1600
+ const materials = /* @__PURE__ */ new Set();
1601
+ const textures = /* @__PURE__ */ new Set();
1602
+ const skeletons = /* @__PURE__ */ new Set();
1603
+ for (const root of roots) {
1604
+ root.traverse((object2) => {
1605
+ const o = object2;
1606
+ if (o.geometry && typeof o.geometry.dispose === "function") geometries.add(o.geometry);
1607
+ if (o.skeleton && typeof o.skeleton.dispose === "function") skeletons.add(o.skeleton);
1608
+ const list2 = Array.isArray(o.material) ? o.material : o.material ? [o.material] : [];
1609
+ for (const m of list2) {
1610
+ if (!m || typeof m.dispose !== "function") continue;
1611
+ materials.add(m);
1612
+ texturesOf(m, textures);
1613
+ }
1614
+ });
1615
+ }
1616
+ return { geometries, materials, textures, skeletons };
1617
+ }
1618
+ var marked = /* @__PURE__ */ new WeakSet();
1619
+ var shared = (r) => r.userData?.shared === true || marked.has(r);
1620
+ function releaseObject3D(roots, options = {}) {
1621
+ const list2 = Array.isArray(roots) ? roots : [roots];
1622
+ const report = { geometries: 0, materials: 0, textures: 0 };
1623
+ if (list2.length === 0) return report;
1624
+ const found = collect(list2);
1625
+ const keepRoots = options.keep === void 0 ? [] : Array.isArray(options.keep) ? options.keep : [options.keep];
1626
+ const releasing = new Set(list2);
1627
+ for (const keep of keepRoots) {
1628
+ const walk = (o) => {
1629
+ if (releasing.has(o)) return;
1630
+ const owner = o;
1631
+ if (owner.geometry) found.geometries.delete(owner.geometry);
1632
+ if (owner.skeleton) found.skeletons.delete(owner.skeleton);
1633
+ const mats = Array.isArray(owner.material) ? owner.material : owner.material ? [owner.material] : [];
1634
+ for (const m of mats) {
1635
+ if (!m) continue;
1636
+ found.materials.delete(m);
1637
+ const t = /* @__PURE__ */ new Set();
1638
+ texturesOf(m, t);
1639
+ for (const x of t) found.textures.delete(x);
1640
+ }
1641
+ for (const c of o.children) walk(c);
1642
+ };
1643
+ walk(keep);
1644
+ }
1645
+ for (const g of found.geometries) {
1646
+ if (shared(g)) continue;
1647
+ g.dispose();
1648
+ report.geometries++;
1649
+ }
1650
+ for (const m of found.materials) {
1651
+ if (shared(m)) continue;
1652
+ m.dispose();
1653
+ report.materials++;
1654
+ }
1655
+ for (const t of found.textures) {
1656
+ if (shared(t)) continue;
1657
+ t.dispose();
1658
+ report.textures++;
1659
+ }
1660
+ for (const s of found.skeletons) s.dispose();
1661
+ return report;
1662
+ }
1663
+ function discardObject3D(objects, options = {}) {
1664
+ const list2 = Array.isArray(objects) ? objects : [objects];
1665
+ const keep = options.keep === void 0 ? [] : Array.isArray(options.keep) ? [...options.keep] : [options.keep];
1666
+ for (const object2 of list2) {
1667
+ let top = object2;
1668
+ while (top.parent) top = top.parent;
1669
+ object2.removeFromParent();
1670
+ if (top !== object2 && !keep.includes(top)) keep.push(top);
1671
+ }
1672
+ return releaseObject3D(list2, { keep });
1673
+ }
1590
1674
 
1591
1675
  // src/rounded-box.ts
1592
1676
  function createRoundedBox(THREE, width, height, depth, radius) {
@@ -12739,11 +12823,11 @@ gl_Position = projectionMatrix * mvPosition;
12739
12823
  function installBoatsExtra(fx) {
12740
12824
  const kit = fx.kit;
12741
12825
  const THREE = kit.THREE;
12742
- const shared = fx.shared;
12826
+ const shared2 = fx.shared;
12743
12827
  const trl = fx.t;
12744
12828
  const lbl = fx.label;
12745
- if (!kit || !shared.EA) return;
12746
- const V3 = kit.V3, PI = Math.PI, MT = kit.materials, CM = kit.makeMaterial, _G = kit.geo, DS = THREE.DoubleSide, EA = shared.EA, tb = EA.tab;
12829
+ if (!kit || !shared2.EA) return;
12830
+ const V3 = kit.V3, PI = Math.PI, MT = kit.materials, CM = kit.makeMaterial, _G = kit.geo, DS = THREE.DoubleSide, EA = shared2.EA, tb = EA.tab;
12747
12831
  function sailGeo(T, Hd, C, cam, o) {
12748
12832
  o = o || {};
12749
12833
  const nu = o.nu || 10, nv = o.nv || 16, pos = [], idx = [], roach = o.roach || 0;
@@ -18611,11 +18695,11 @@ gl_Position = projectionMatrix * mvPosition;
18611
18695
  function installHelicoptersExtra(fx) {
18612
18696
  const kit = fx.kit;
18613
18697
  const THREE = kit.THREE;
18614
- const shared = fx.shared;
18698
+ const shared2 = fx.shared;
18615
18699
  const trl = fx.t;
18616
18700
  const lbl = fx.label;
18617
18701
  const V3 = kit.V3, PI = Math.PI, MT = kit.materials, CM = kit.makeMaterial, G = kit.geo;
18618
- const GH = shared.GH;
18702
+ const GH = shared2.GH;
18619
18703
  function skids(c, o) {
18620
18704
  const mat = o.mat || MT.steel, z = o.z, y = o.y || 0.07, out = [];
18621
18705
  [1, -1].forEach(function(s) {
@@ -18762,7 +18846,7 @@ gl_Position = projectionMatrix * mvPosition;
18762
18846
  hood: false
18763
18847
  },
18764
18848
  function(c) {
18765
- const EA = shared.EA, col = "#1f4f8a", blue = c.paint(col), white = c.paint("#e9e7e0"), blk = CM("#1c1d1f", { roughness: 0.6 });
18849
+ const EA = shared2.EA, col = "#1f4f8a", blue = c.paint(col), white = c.paint("#e9e7e0"), blk = CM("#1c1d1f", { roughness: 0.6 });
18766
18850
  const ST = [
18767
18851
  [1.6, 0.84, 0.92, 0.06, 2],
18768
18852
  [1.5, 0.64, 1.22, 0.66, 2.2],
@@ -19097,7 +19181,7 @@ gl_Position = projectionMatrix * mvPosition;
19097
19181
  hood: false
19098
19182
  },
19099
19183
  function(c) {
19100
- const EA = shared.EA, wcol = "#eeece6", white = c.paint(wcol), mar = c.paint("#7a1e22"), gold = c.paint("#c49a3a"), blk = CM("#1c1d1f", { roughness: 0.6 });
19184
+ const EA = shared2.EA, wcol = "#eeece6", white = c.paint(wcol), mar = c.paint("#7a1e22"), gold = c.paint("#c49a3a"), blk = CM("#1c1d1f", { roughness: 0.6 });
19101
19185
  const ST = [
19102
19186
  [2.62, 0.95, 1.06, 0.08, 2],
19103
19187
  [2.48, 0.7, 1.45, 0.86, 2.2],
@@ -19482,7 +19566,7 @@ gl_Position = projectionMatrix * mvPosition;
19482
19566
  hood: false
19483
19567
  },
19484
19568
  function(c) {
19485
- const EA = shared.EA, navyC = "#1b2c52", navy = c.paint(navyC), white = c.paint("#ecebe6"), yel = c.paint("#d7b23a"), blk = CM("#1c1d1f", { roughness: 0.6 });
19569
+ const EA = shared2.EA, navyC = "#1b2c52", navy = c.paint(navyC), white = c.paint("#ecebe6"), yel = c.paint("#d7b23a"), blk = CM("#1c1d1f", { roughness: 0.6 });
19486
19570
  const ST = [
19487
19571
  [3.36, 1, 1.12, 0.08, 2],
19488
19572
  [3.22, 0.76, 1.56, 0.96, 2.4],
@@ -19926,7 +20010,7 @@ gl_Position = projectionMatrix * mvPosition;
19926
20010
  hood: false
19927
20011
  },
19928
20012
  function(c) {
19929
- const EA = shared.EA, blk = CM("#1a1b1d", { roughness: 0.6 });
20013
+ const EA = shared2.EA, blk = CM("#1a1b1d", { roughness: 0.6 });
19930
20014
  c.meta.matte = true;
19931
20015
  const cA = new THREE.Color("#3a4430"), cB = new THREE.Color("#66603f"), cC = new THREE.Color("#55613f"), cL = new THREE.Color("#8d958c");
19932
20016
  function camo(x, y, z, under) {
@@ -28982,7 +29066,7 @@ gl_Position = projectionMatrix * mvPosition;
28982
29066
  function installPlanesExtra(fx) {
28983
29067
  const kit = fx.kit;
28984
29068
  const THREE = kit.THREE;
28985
- const shared = fx.shared;
29069
+ const shared2 = fx.shared;
28986
29070
  const trl = fx.t;
28987
29071
  const lbl = fx.label;
28988
29072
  const V3 = kit.V3, PI = Math.PI, MT = kit.materials, CM = kit.makeMaterial, _G = kit.geo, _DS = THREE.DoubleSide;
@@ -29134,7 +29218,7 @@ gl_Position = projectionMatrix * mvPosition;
29134
29218
  m.rotation.y += -s * Math.atan2(a - b, w);
29135
29219
  return m;
29136
29220
  }
29137
- shared.GH = {
29221
+ shared2.GH = {
29138
29222
  pose3,
29139
29223
  starDecal,
29140
29224
  rrect,
@@ -29168,7 +29252,7 @@ gl_Position = projectionMatrix * mvPosition;
29168
29252
  hood: false
29169
29253
  },
29170
29254
  function(c) {
29171
- const EA = shared.EA, yel = "#f0bd22";
29255
+ const EA = shared2.EA, yel = "#f0bd22";
29172
29256
  const Q = pose3([1.62, -0.78], 0.25, [-3.24, -0.27], 0.075), P = Q.P, TH = Q.TH;
29173
29257
  const grp = new THREE.Group();
29174
29258
  grp.position.set(0, Q.Y0, 0);
@@ -29480,7 +29564,7 @@ gl_Position = projectionMatrix * mvPosition;
29480
29564
  });
29481
29565
  const pd = pod(
29482
29566
  c2,
29483
- shared.EA,
29567
+ shared2.EA,
29484
29568
  P(1.4, -0.6).x,
29485
29569
  P(-1.2, -0.45).x,
29486
29570
  P(0.1, -0.66).y,
@@ -29517,7 +29601,7 @@ gl_Position = projectionMatrix * mvPosition;
29517
29601
  hood: false
29518
29602
  },
29519
29603
  function(c) {
29520
- const EA = shared.EA, wcol = "#ecebe6", white = c.paint(wcol), blue = c.paint("#1d4f8c"), grey = c.paint("#8e959a"), blk = CM("#1c1d1f", { roughness: 0.6 });
29604
+ const EA = shared2.EA, wcol = "#ecebe6", white = c.paint(wcol), blue = c.paint("#1d4f8c"), grey = c.paint("#8e959a"), blk = CM("#1c1d1f", { roughness: 0.6 });
29521
29605
  const ST = [
29522
29606
  [7.58, 1.5, 1.62, 0.08, 2],
29523
29607
  [7.35, 1.3, 1.82, 0.56, 2.2],
@@ -29905,7 +29989,7 @@ gl_Position = projectionMatrix * mvPosition;
29905
29989
  hood: false
29906
29990
  },
29907
29991
  function(c) {
29908
- const EA = shared.EA, wcol = "#eceae3", white = c.paint(wcol), navy = c.paint("#1e2f55"), gold = c.paint("#c99a2e"), blk = CM("#1c1d1f", { roughness: 0.6 });
29992
+ const EA = shared2.EA, wcol = "#eceae3", white = c.paint(wcol), navy = c.paint("#1e2f55"), gold = c.paint("#c99a2e"), blk = CM("#1c1d1f", { roughness: 0.6 });
29909
29993
  const ST = [
29910
29994
  [5, 2.26, 2.86, 0.62, 2.2],
29911
29995
  [4.75, 2.08, 3, 0.98, 2.6],
@@ -30320,7 +30404,7 @@ gl_Position = projectionMatrix * mvPosition;
30320
30404
  hood: false
30321
30405
  },
30322
30406
  function(c) {
30323
- const EA = shared.EA, wcol = "#efeeea", white = c.paint(wcol), silver = c.paint("#7d868e", { metalness: 0.45, roughness: 0.35 }), navy = c.paint("#23324f"), blk = CM("#15161a", { roughness: 0.5 });
30407
+ const EA = shared2.EA, wcol = "#efeeea", white = c.paint(wcol), silver = c.paint("#7d868e", { metalness: 0.45, roughness: 0.35 }), navy = c.paint("#23324f"), blk = CM("#15161a", { roughness: 0.5 });
30324
30408
  const ST = [
30325
30409
  [6.3, 1.13, 1.2, 0.06, 2],
30326
30410
  [6, 0.92, 1.44, 0.6, 2.1],
@@ -30701,7 +30785,7 @@ gl_Position = projectionMatrix * mvPosition;
30701
30785
  hood: false
30702
30786
  },
30703
30787
  function(c) {
30704
- const EA = shared.EA, blk = CM("#1a1b1d", { roughness: 0.6 });
30788
+ const EA = shared2.EA, blk = CM("#1a1b1d", { roughness: 0.6 });
30705
30789
  c.meta.matte = true;
30706
30790
  const cA = new THREE.Color("#323f2b"), cB = new THREE.Color("#5f6d45"), cC = new THREE.Color("#7f8466"), cL = new THREE.Color("#a3abad");
30707
30791
  function camo(x, z, y, under) {
@@ -33359,7 +33443,7 @@ gl_Position = projectionMatrix * mvPosition;
33359
33443
  function installWaterAir(fx) {
33360
33444
  const kit = fx.kit;
33361
33445
  const THREE = kit.THREE;
33362
- const shared = fx.shared;
33446
+ const shared2 = fx.shared;
33363
33447
  const trl = fx.t;
33364
33448
  const lbl = fx.label;
33365
33449
  const V3 = kit.V3, PI = Math.PI, MT = kit.materials, CM = kit.makeMaterial, _paintCol = kit.paintColor, G = kit.geo, DS = THREE.DoubleSide, clamp4 = kit.clamp;
@@ -34034,7 +34118,7 @@ gl_Position = projectionMatrix * mvPosition;
34034
34118
  t.rotation.y += s > 0 ? -Math.atan(m) : Math.atan(m);
34035
34119
  return t;
34036
34120
  }
34037
- shared.EA = {
34121
+ shared2.EA = {
34038
34122
  colorize,
34039
34123
  tab,
34040
34124
  tabL,
@@ -34093,7 +34177,7 @@ gl_Position = projectionMatrix * mvPosition;
34093
34177
  hood: false
34094
34178
  },
34095
34179
  function(c) {
34096
- const EA = shared.EA, tb = EA.tab, alu = CM("#9aa1a6", { metalness: 0.65, roughness: 0.38, side: DS }), aluD = CM("#7d8489", { metalness: 0.6, roughness: 0.45, side: DS });
34180
+ const EA = shared2.EA, tb = EA.tab, alu = CM("#9aa1a6", { metalness: 0.65, roughness: 0.38, side: DS }), aluD = CM("#7d8489", { metalness: 0.6, roughness: 0.45, side: DS });
34097
34181
  const L = 5, x0 = -2.5;
34098
34182
  const H = EA.boatHull({
34099
34183
  x0,
@@ -34245,7 +34329,7 @@ gl_Position = projectionMatrix * mvPosition;
34245
34329
  hood: false
34246
34330
  },
34247
34331
  function(c) {
34248
- const EA = shared.EA, tb = EA.tab, L = 7.26, x0 = -3.63;
34332
+ const EA = shared2.EA, tb = EA.tab, L = 7.26, x0 = -3.63;
34249
34333
  const white = c.paint("#ecebe5", { roughness: 0.3, metalness: 0.1 }), navy = c.paint("#1f2f4a", { roughness: 0.3, metalness: 0.1 }), vinyl = CM("#e3ddd0", { roughness: 0.65 }), _vinylD = CM("#3c4a5c", { roughness: 0.65 }), teak = CM("#8a6a45", { roughness: 0.8 });
34250
34334
  const H = EA.boatHull({
34251
34335
  x0,
@@ -34492,7 +34576,7 @@ gl_Position = projectionMatrix * mvPosition;
34492
34576
  hood: false
34493
34577
  },
34494
34578
  function(c) {
34495
- const EA = shared.EA, tb = EA.tab, L = 11, x0 = -5.5;
34579
+ const EA = shared2.EA, tb = EA.tab, L = 11, x0 = -5.5;
34496
34580
  const blue = c.paint("#2f5e86", { roughness: 0.7, metalness: 0.05 }), wht = c.paint("#e6e3da", { roughness: 0.7, metalness: 0.05 }), redP = c.paint("#7a2219", { roughness: 0.8, metalness: 0.05 }), wood = CM("#6b4a2e", { roughness: 0.85 }), deckW = CM("#8a6e4c", { roughness: 0.9, side: DS });
34497
34581
  const H = EA.boatHull({
34498
34582
  x0,
@@ -34796,7 +34880,7 @@ gl_Position = projectionMatrix * mvPosition;
34796
34880
  hood: false
34797
34881
  },
34798
34882
  function(c) {
34799
- const EA = shared.EA, white = "#ecebe6";
34883
+ const EA = shared2.EA, white = "#ecebe6";
34800
34884
  const paintW = c.paint(white);
34801
34885
  const ST = [
34802
34886
  [2.3, 0.98, 1.46, 0.7, 2.4],
@@ -35125,7 +35209,7 @@ gl_Position = projectionMatrix * mvPosition;
35125
35209
  hood: false
35126
35210
  },
35127
35211
  function(c) {
35128
- const EA = shared.EA, TH = 0.19, X0 = 0.3, Y0 = 1, cs = Math.cos(TH), sn = Math.sin(TH);
35212
+ const EA = shared2.EA, TH = 0.19, X0 = 0.3, Y0 = 1, cs = Math.cos(TH), sn = Math.sin(TH);
35129
35213
  function P(x, y, z) {
35130
35214
  return new V3(x * cs - y * sn + X0, x * sn + y * cs + Y0, z || 0);
35131
35215
  }
@@ -35482,7 +35566,7 @@ gl_Position = projectionMatrix * mvPosition;
35482
35566
  hood: false
35483
35567
  },
35484
35568
  function(c) {
35485
- const EA = shared.EA, red = c.paint("#a9241e"), white = c.paint("#e9e7e0"), blk = CM("#1c1d1f", { roughness: 0.6 });
35569
+ const EA = shared2.EA, red = c.paint("#a9241e"), white = c.paint("#e9e7e0"), blk = CM("#1c1d1f", { roughness: 0.6 });
35486
35570
  const ST = [
35487
35571
  [1.96, 0.96, 1.06, 0.06, 2],
35488
35572
  [1.85, 0.76, 1.4, 0.76, 2.2],
@@ -35808,7 +35892,7 @@ gl_Position = projectionMatrix * mvPosition;
35808
35892
  hood: false
35809
35893
  },
35810
35894
  function(c) {
35811
- const EA = shared.EA, org = c.paint("#d0531e"), white = c.paint("#e8e6df"), blk = CM("#1c1d1f", { roughness: 0.6 });
35895
+ const EA = shared2.EA, org = c.paint("#d0531e"), white = c.paint("#e8e6df"), blk = CM("#1c1d1f", { roughness: 0.6 });
35812
35896
  const ST = [
35813
35897
  [3.34, 1, 1.12, 0.1, 2],
35814
35898
  [3.2, 0.82, 1.48, 0.95, 2.2],
@@ -36170,11 +36254,11 @@ gl_Position = projectionMatrix * mvPosition;
36170
36254
  const groups = new Set(options.groups || fleetGroupIds);
36171
36255
  const only = options.vehicles ? new Set(options.vehicles) : null;
36172
36256
  const skip = new Set(options.exclude || []);
36173
- const shared = {};
36257
+ const shared2 = {};
36174
36258
  const t = (key, vars) => kit.t("fleet." + key, vars);
36175
36259
  return {
36176
36260
  kit,
36177
- shared,
36261
+ shared: shared2,
36178
36262
  t,
36179
36263
  label: (key) => ({ key, label: t("labels." + key) }),
36180
36264
  register(spec, build) {
@@ -38181,7 +38265,7 @@ gl_Position = projectionMatrix * mvPosition;
38181
38265
  };
38182
38266
  const roots = () => [...[...placed.values()].filter((entry) => entry.root.parent), ...bench ? [bench] : []];
38183
38267
  const clearHelpers = () => {
38184
- for (const helper of helpers) helper.parent?.remove(helper);
38268
+ discardObject3D(helpers);
38185
38269
  helpers = [];
38186
38270
  helpersShown = "";
38187
38271
  };