@adatechnology/game-urban-three 0.3.0 → 0.3.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/{chunk-6VTMXFGC.js → chunk-XUITKOBO.js} +15 -10
- package/dist/chunk-XUITKOBO.js.map +1 -0
- package/dist/index.d.ts +18 -12
- package/dist/index.global.js +39 -30
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{testing-BzxRwx1k.d.ts → testing-ZS5dhCJM.d.ts} +7 -6
- package/dist/testing.d.ts +2 -1
- package/dist/testing.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-6VTMXFGC.js.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -162,7 +162,7 @@ var GameUrbanThree = (() => {
|
|
|
162
162
|
}
|
|
163
163
|
var EFFECT_STEP_SECONDS = 1 / 50;
|
|
164
164
|
|
|
165
|
-
// ../game-shapes/dist/chunk-
|
|
165
|
+
// ../game-shapes/dist/chunk-M5N2SHNL.js
|
|
166
166
|
function canonicalJson(value) {
|
|
167
167
|
if (value === null) return "null";
|
|
168
168
|
if (typeof value === "number") return Object.is(value, -0) ? "-0" : Number.isFinite(value) ? String(value) : JSON.stringify(String(value));
|
|
@@ -1409,8 +1409,8 @@ var GameUrbanThree = (() => {
|
|
|
1409
1409
|
groups: []
|
|
1410
1410
|
};
|
|
1411
1411
|
}
|
|
1412
|
-
function make(
|
|
1413
|
-
switch (kind) {
|
|
1412
|
+
function make(p) {
|
|
1413
|
+
switch (p.kind) {
|
|
1414
1414
|
case "box": {
|
|
1415
1415
|
const size = p.size ?? [1, 1, 1];
|
|
1416
1416
|
const segments = p.segments ?? [1, 1, 1];
|
|
@@ -1439,7 +1439,7 @@ var GameUrbanThree = (() => {
|
|
|
1439
1439
|
case "mesh":
|
|
1440
1440
|
return mesh(p);
|
|
1441
1441
|
default:
|
|
1442
|
-
throw new Error(`game-shapes: unknown primitive kind "${String(kind)}"`);
|
|
1442
|
+
throw new Error(`game-shapes: unknown primitive kind "${String(p.kind)}"`);
|
|
1443
1443
|
}
|
|
1444
1444
|
}
|
|
1445
1445
|
var templates = /* @__PURE__ */ new Map();
|
|
@@ -1447,7 +1447,7 @@ var GameUrbanThree = (() => {
|
|
|
1447
1447
|
var stats = { hits: 0, misses: 0 };
|
|
1448
1448
|
function buildPrimitive(node, options = {}) {
|
|
1449
1449
|
const parameters = primitiveParameters(node, options);
|
|
1450
|
-
if (node.kind === "mesh" || templateLimit === 0) return make(node
|
|
1450
|
+
if (node.kind === "mesh" || templateLimit === 0) return make({ ...node, ...parameters });
|
|
1451
1451
|
const key = `${node.kind}:${canonicalJson(parameters)}`;
|
|
1452
1452
|
const cached = templates.get(key);
|
|
1453
1453
|
if (cached) {
|
|
@@ -1457,7 +1457,7 @@ var GameUrbanThree = (() => {
|
|
|
1457
1457
|
return cached;
|
|
1458
1458
|
}
|
|
1459
1459
|
stats.misses++;
|
|
1460
|
-
const built = make(node
|
|
1460
|
+
const built = make({ ...node, ...parameters });
|
|
1461
1461
|
templates.set(key, built);
|
|
1462
1462
|
if (templates.size > templateLimit) templates.delete(templates.keys().next().value);
|
|
1463
1463
|
return built;
|
|
@@ -1816,6 +1816,7 @@ var GameUrbanThree = (() => {
|
|
|
1816
1816
|
canvas.width = o.width;
|
|
1817
1817
|
canvas.height = o.height;
|
|
1818
1818
|
const g = canvas.getContext("2d");
|
|
1819
|
+
if (!g) throw new Error("game-urban-three: the canvas has no 2D context");
|
|
1819
1820
|
g.fillStyle = o.background;
|
|
1820
1821
|
g.fillRect(0, 0, o.width, o.height);
|
|
1821
1822
|
g.fillStyle = o.foreground;
|
|
@@ -2109,7 +2110,9 @@ var GameUrbanThree = (() => {
|
|
|
2109
2110
|
lights,
|
|
2110
2111
|
animate: (t) => animators.forEach((step) => step(t)),
|
|
2111
2112
|
dispose: () => {
|
|
2112
|
-
if (options.lights)
|
|
2113
|
+
if (options.lights) {
|
|
2114
|
+
for (const lamp of lights) if ("source" in lamp) lamp.source.remove();
|
|
2115
|
+
}
|
|
2113
2116
|
root.parent?.remove(root);
|
|
2114
2117
|
for (const item of disposables.splice(0)) item.dispose?.();
|
|
2115
2118
|
for (const geometry of geometries.values()) geometry.dispose();
|
|
@@ -2122,7 +2125,7 @@ var GameUrbanThree = (() => {
|
|
|
2122
2125
|
return { THREE, draw };
|
|
2123
2126
|
}
|
|
2124
2127
|
|
|
2125
|
-
// ../game-vegetation/dist/chunk-
|
|
2128
|
+
// ../game-vegetation/dist/chunk-CJRLKDWB.js
|
|
2126
2129
|
var __defProp2 = Object.defineProperty;
|
|
2127
2130
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2128
2131
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -9328,6 +9331,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
9328
9331
|
var MAX_CANDIDATES = 80;
|
|
9329
9332
|
function carCandidates(slot, item, car) {
|
|
9330
9333
|
const front = [slot.frontU, slot.frontV];
|
|
9334
|
+
if (!slot._cell) throw new Error("Slot without a cell: " + slot.id);
|
|
9331
9335
|
const zone = slot._cell.R;
|
|
9332
9336
|
const alongV = Math.abs(front[1]) === 1;
|
|
9333
9337
|
const [extentU, extentV] = extent([item.w, item.d], front);
|
|
@@ -9547,6 +9551,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
9547
9551
|
}
|
|
9548
9552
|
function itemRect(slot, it, shift) {
|
|
9549
9553
|
const c = slot._cell;
|
|
9554
|
+
if (!c) throw new Error("Slot without a cell: " + slot.id);
|
|
9550
9555
|
const f = c.f;
|
|
9551
9556
|
const [extentU, extentV] = extent([it.w, it.d], f);
|
|
9552
9557
|
const R = c.R;
|
|
@@ -9651,7 +9656,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
9651
9656
|
if (!parent) return null;
|
|
9652
9657
|
for (const { it } of cands) {
|
|
9653
9658
|
if (it.w > parent.w + EPS || it.d > parent.d + EPS) continue;
|
|
9654
|
-
const f = [parent.frontU, parent.frontV];
|
|
9659
|
+
const f = [parent.frontU ?? 0, parent.frontV ?? 1];
|
|
9655
9660
|
const r = parent.aabb;
|
|
9656
9661
|
const [extentU, extentV] = extent([it.w, it.d], f);
|
|
9657
9662
|
const cu = (r[0] + r[2]) / 2 - f[0] * (parent.d / 2 - it.d / 2);
|
|
@@ -9685,7 +9690,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
9685
9690
|
if (!car && !relax && s.clearance > 0 && !it.low) {
|
|
9686
9691
|
cl2 = clearRect(r3, f, s.clearance);
|
|
9687
9692
|
if (!insideUnion(cl2, inners)) continue;
|
|
9688
|
-
if (items.some((m2) => !m2.low && !m2.flat && !m2.on && overlaps(cl2, m2._r))) continue;
|
|
9693
|
+
if (items.some((m2) => !m2.low && !m2.flat && !m2.on && overlaps(cl2, m2._r ?? m2.aabb))) continue;
|
|
9689
9694
|
}
|
|
9690
9695
|
if (!it.low && reserves.some((q) => overlaps(r3, q))) continue;
|
|
9691
9696
|
let rimRect2 = null;
|
|
@@ -9869,7 +9874,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
9869
9874
|
if (!(opts.without && opts.without(r))) return r;
|
|
9870
9875
|
continue;
|
|
9871
9876
|
}
|
|
9872
|
-
if (occupied.some((m) => !m.low && !m.flat && !m.on && !m.decor && m.clearance > 0 && overlaps(r, clearRect(m._r, [m.frontU, m.frontV], m.clearance)))) continue;
|
|
9877
|
+
if (occupied.some((m) => !m.low && !m.flat && !m.on && !m.decor && (m.clearance ?? 0) > 0 && overlaps(r, clearRect(m._r, [m.frontU ?? 0, m.frontV ?? 1], m.clearance ?? 0)))) continue;
|
|
9873
9878
|
if (opts.without && opts.without(r)) continue;
|
|
9874
9879
|
if (!reachable(opts.railing || gridOf(room), solidList.concat([r]), room.outdoor ? 0.16 : plan.playerRadius)) continue;
|
|
9875
9880
|
return r;
|
|
@@ -10130,7 +10135,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
10130
10135
|
const far = m.built / area3;
|
|
10131
10136
|
if (far > zone.maxFar + 1e-9) out.push({ rule: "far", actual: r2(far), limit: zone.maxFar });
|
|
10132
10137
|
let permeable = 0;
|
|
10133
|
-
for (const z of lot.zones) if (registries().PERMEABLE_GROUNDS.has(z.ground)) for (const p of z.parts) permeable += (p[2] - p[0]) * (p[3] - p[1]);
|
|
10138
|
+
for (const z of lot.zones) if (z.ground && registries().PERMEABLE_GROUNDS.has(z.ground)) for (const p of z.parts) permeable += (p[2] - p[0]) * (p[3] - p[1]);
|
|
10134
10139
|
const permeability = permeable / area3;
|
|
10135
10140
|
if (permeability < zone.permeableMin - 1e-9) out.push({ rule: "permeable", actual: r2(permeability), limit: zone.permeableMin });
|
|
10136
10141
|
return out;
|
|
@@ -10173,12 +10178,12 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
10173
10178
|
const [u0, v0, u1, v1] = lot.rect;
|
|
10174
10179
|
const area3 = (u1 - u0) * (v1 - v0);
|
|
10175
10180
|
const areaOfZone = (z) => z.parts.reduce((s, p) => s + (p[2] - p[0]) * (p[3] - p[1]), 0);
|
|
10176
|
-
let permeable = zones.filter((z) => registries().PERMEABLE_GROUNDS.has(z.ground)).reduce((s, z) => s + areaOfZone(z), 0);
|
|
10181
|
+
let permeable = zones.filter((z) => z.ground != null && registries().PERMEABLE_GROUNDS.has(z.ground)).reduce((s, z) => s + areaOfZone(z), 0);
|
|
10177
10182
|
if (permeable / area3 >= zone.permeableMin) return;
|
|
10178
|
-
const candidates = zones.filter((z) => ADJUSTABLE_ZONES.has(z.type) && !registries().PERMEABLE_GROUNDS.has(z.ground)).sort((a, b) => areaOfZone(b) - areaOfZone(a));
|
|
10183
|
+
const candidates = zones.filter((z) => ADJUSTABLE_ZONES.has(z.type) && !(z.ground != null && registries().PERMEABLE_GROUNDS.has(z.ground))).sort((a, b) => areaOfZone(b) - areaOfZone(a));
|
|
10179
10184
|
for (const z of candidates) {
|
|
10180
10185
|
if (permeable / area3 >= zone.permeableMin) break;
|
|
10181
|
-
adjustments.push({ field: "ground:" + z.id, from: z.ground, to: target, reason: "permeable_min" });
|
|
10186
|
+
adjustments.push({ field: "ground:" + z.id, from: z.ground ?? "", to: target, reason: "permeable_min" });
|
|
10182
10187
|
z.ground = target;
|
|
10183
10188
|
permeable += areaOfZone(z);
|
|
10184
10189
|
}
|
|
@@ -10445,9 +10450,9 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
10445
10450
|
height: type === "pedestrian" ? style.height : Math.min(style.height, 2.2),
|
|
10446
10451
|
side,
|
|
10447
10452
|
to: toTarget || null,
|
|
10448
|
-
material: "iron"
|
|
10453
|
+
material: "iron",
|
|
10454
|
+
zones: openingZones(u, v, "u", width, openingDepth(width, type === "pedestrian" ? width : 0))
|
|
10449
10455
|
};
|
|
10450
|
-
g.zones = openingZones(u, v, "u", width, openingDepth(width, type === "pedestrian" ? width : 0));
|
|
10451
10456
|
gates.push(g);
|
|
10452
10457
|
return g;
|
|
10453
10458
|
};
|
|
@@ -10730,7 +10735,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
10730
10735
|
};
|
|
10731
10736
|
const invalid = (m) => Object.assign(base, { valid: false, reason: m, x: 0, z: 0, ry: 0, w: 0, d: 0, frontU: 0, frontV: 1, aabb: [0, 0, 0, 0], _cell: null });
|
|
10732
10737
|
if (def.anchor === "on" || def.anchor === "inside") {
|
|
10733
|
-
const parent = byId2[def.parent];
|
|
10738
|
+
const parent = def.parent ? byId2[def.parent] : void 0;
|
|
10734
10739
|
if (!parent || !parent.valid) return invalid("invalid_parent");
|
|
10735
10740
|
return Object.assign(base, { x: parent.x, z: parent.z, ry: parent.ry, w: parent.w, d: parent.d, frontU: parent.frontU, frontV: parent.frontV, aabb: parent.aabb, _cell: parent._cell });
|
|
10736
10741
|
}
|
|
@@ -10771,9 +10776,10 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
10771
10776
|
const windowList = windowsOfRoom(plan, room);
|
|
10772
10777
|
win = windowList[def.n];
|
|
10773
10778
|
if (!win) return invalid("no_window");
|
|
10779
|
+
const found2 = win;
|
|
10774
10780
|
side = room.outdoor ? SIDE_OPPOSITE[win.side] : WINDOW_SIDE[win.side];
|
|
10775
10781
|
const cand = room.parts.map(inner).find(
|
|
10776
|
-
(r) => (
|
|
10782
|
+
(r) => (found2.axis === "u" ? found2.u >= r[0] - TOL && found2.u <= r[2] + TOL : found2.v >= r[1] - TOL && found2.v <= r[3] + TOL) && (side === "left" && eq(r[0], found2.pos + MARGIN) || side === "right" && eq(r[2], found2.pos - MARGIN) || side === "front" && eq(r[1], found2.pos + MARGIN) || side === "back" && eq(r[3], found2.pos - MARGIN))
|
|
10777
10783
|
);
|
|
10778
10784
|
if (!cand) return invalid("window_outside_room");
|
|
10779
10785
|
R = cand;
|
|
@@ -10965,7 +10971,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
10965
10971
|
if (m.category) out.color = colorOf(m, seed);
|
|
10966
10972
|
return out;
|
|
10967
10973
|
});
|
|
10968
|
-
const
|
|
10974
|
+
const base = {
|
|
10969
10975
|
template: tpl.id,
|
|
10970
10976
|
name: translate("templates", tpl.id, locale),
|
|
10971
10977
|
use: useOf(tpl),
|
|
@@ -11002,8 +11008,8 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
11002
11008
|
building: tpl.building ? tpl.building(plan.w, plan.d, op) : null,
|
|
11003
11009
|
missing
|
|
11004
11010
|
};
|
|
11005
|
-
if (tpl.singleFloor)
|
|
11006
|
-
result.partyWalls
|
|
11011
|
+
if (tpl.singleFloor) base.floorNumber = op.floor || 3;
|
|
11012
|
+
const result = Object.assign(base, { partyWalls: tpl.partyWalls || [] });
|
|
11007
11013
|
if (plan.config) result.config = plan.config;
|
|
11008
11014
|
runResultExtensions(plan, result, seed, op);
|
|
11009
11015
|
if (zone) {
|
|
@@ -20747,6 +20753,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
20747
20753
|
hood: true
|
|
20748
20754
|
},
|
|
20749
20755
|
function(c) {
|
|
20756
|
+
c.meta.armor = "III";
|
|
20750
20757
|
const f = 3.75, W = 2.32, len2 = 1.85, ax = 2.5, wr = 0.506, ww = 0.28, col = "#56616b";
|
|
20751
20758
|
c.meta.bullet = true;
|
|
20752
20759
|
c.meta.cabLength = len2 + 0.15;
|
|
@@ -40477,6 +40484,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
40477
40484
|
var VIEW_FAR = 600;
|
|
40478
40485
|
var GRID = { block: 36, count: 2, width: 10 };
|
|
40479
40486
|
var LAMP_SHARES = { pattern: void 0, all: 1, half: 0.5, none: 0 };
|
|
40487
|
+
var isMesh = (o) => o.isMesh === true;
|
|
40480
40488
|
function createUrbanTestModule(options = {}) {
|
|
40481
40489
|
const locale = (options.locale ?? "pt-BR").toLowerCase().startsWith("en") ? "en" : "pt-BR";
|
|
40482
40490
|
const text2 = TEXT[locale];
|
|
@@ -40542,7 +40550,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
40542
40550
|
movable: false,
|
|
40543
40551
|
build: (THREE) => {
|
|
40544
40552
|
three = THREE;
|
|
40545
|
-
const made = sample(
|
|
40553
|
+
const made = sample(three, id);
|
|
40546
40554
|
made.root.userData.urbanItem = id;
|
|
40547
40555
|
placed.set(made.root.uuid, made);
|
|
40548
40556
|
return made.root;
|
|
@@ -40643,7 +40651,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
40643
40651
|
}
|
|
40644
40652
|
if (host.bench.layer("light_radius")) {
|
|
40645
40653
|
for (const lamp of entry.drawn.lights) {
|
|
40646
|
-
const light =
|
|
40654
|
+
const light = "bulb" in lamp ? { node: lamp.bulb, distance: lamp.part.distance, color: lamp.part.color } : lamp.isLight ? { node: lamp, distance: lamp.distance, color: lamp.color } : null;
|
|
40647
40655
|
if (!light) continue;
|
|
40648
40656
|
const reach = new three.Mesh(new (shapeGeometries(three)).SphereGeometry(Math.min(light.distance || 10, 60), 14, 8), new three.MeshBasicMaterial({ color: light.color ?? 16764006, wireframe: true, transparent: true, opacity: 0.25 }));
|
|
40649
40657
|
reach.position.copy(light.node.position);
|
|
@@ -40658,7 +40666,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
40658
40666
|
for (const entry of roots()) entry.drawn.animate(clock);
|
|
40659
40667
|
for (const [id, entry] of placed) {
|
|
40660
40668
|
if (entry.root.parent) continue;
|
|
40661
|
-
for (const lamp of entry.drawn.lights) lamp.source
|
|
40669
|
+
for (const lamp of entry.drawn.lights) if ("source" in lamp) lamp.source.remove();
|
|
40662
40670
|
placed.delete(id);
|
|
40663
40671
|
}
|
|
40664
40672
|
if (host?.bench && boxKey() !== helpersShown && (host.bench.layer("light_radius") || host.bench.layer("bounds") || helpersShown !== "")) refreshLayers();
|
|
@@ -40671,15 +40679,16 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
40671
40679
|
for (const entry of roots()) {
|
|
40672
40680
|
entry.root.traverse((o) => {
|
|
40673
40681
|
if (o.isLight) lights += 1;
|
|
40674
|
-
if (!o
|
|
40682
|
+
if (!isMesh(o) || o.userData.helper) return;
|
|
40675
40683
|
for (let p = o; p; p = p.parent) if (p.visible === false) return;
|
|
40676
40684
|
drawCalls += 1;
|
|
40677
|
-
|
|
40685
|
+
const instanced = o.isInstancedMesh === true;
|
|
40686
|
+
if (instanced) instances += o.count;
|
|
40678
40687
|
const g = o.geometry;
|
|
40679
40688
|
const perInstance = (g.index ? g.index.count : g.attributes.position.count) / 3;
|
|
40680
|
-
triangles += perInstance * (
|
|
40689
|
+
triangles += perInstance * (instanced ? o.count : 1);
|
|
40681
40690
|
});
|
|
40682
|
-
lights += entry.drawn.lights.filter((lamp) => lamp
|
|
40691
|
+
lights += entry.drawn.lights.filter((lamp) => "source" in lamp).length;
|
|
40683
40692
|
}
|
|
40684
40693
|
return { drawCalls, triangles: Math.round(triangles), lights, instances };
|
|
40685
40694
|
};
|
|
@@ -40752,7 +40761,7 @@ gl_Position = projectionMatrix * mvPosition;
|
|
|
40752
40761
|
}
|
|
40753
40762
|
resolvers.plant?.dispose?.();
|
|
40754
40763
|
resolvers.vehicle?.dispose?.();
|
|
40755
|
-
for (const entry of placed.values()) for (const lamp of entry.drawn.lights) lamp.source
|
|
40764
|
+
for (const entry of placed.values()) for (const lamp of entry.drawn.lights) if ("source" in lamp) lamp.source.remove();
|
|
40756
40765
|
placed.clear();
|
|
40757
40766
|
host = null;
|
|
40758
40767
|
};
|