@adatechnology/game-urban 0.5.4 → 0.6.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.
package/dist/index.js
CHANGED
|
@@ -117,8 +117,12 @@ function createUrbanBuilder(random, options = {}) {
|
|
|
117
117
|
for (const part of silhouette.parts) parts.push(part.parent < 0 ? part : { ...part, parent: part.parent + offset });
|
|
118
118
|
for (const window of silhouette.windows) (window.isLit ? windows.lit : windows.dark).push(window);
|
|
119
119
|
};
|
|
120
|
+
const covers = [];
|
|
121
|
+
const cover = (footprint) => {
|
|
122
|
+
covers.push(footprint);
|
|
123
|
+
};
|
|
120
124
|
const scene = () => ({ parts, items, windows });
|
|
121
|
-
return { random, pick, lights, parts, items, windows, group, box, cylinder, cone, prism, plane, vault, terrain, crown, line, label, light, spot, place, item, fence, add, scene };
|
|
125
|
+
return { random, pick, lights, parts, items, windows, covers, cover, group, box, cylinder, cone, prism, plane, vault, terrain, crown, line, label, light, spot, place, item, fence, add, scene };
|
|
122
126
|
}
|
|
123
127
|
|
|
124
128
|
// src/networks/slots.ts
|
|
@@ -381,6 +385,7 @@ var HEIGHT_CURVE = 1.6;
|
|
|
381
385
|
var DEFAULT_STOREY_PRESETS = { commercial: "office", residential: "residential" };
|
|
382
386
|
function drawBuilding(b, x, z, width, depth, height, color, options = {}) {
|
|
383
387
|
b.add(createCityBuilding({ x, z, width, depth, height, color, random: b.random, shopChance: options.shop, litChance: options.lit }));
|
|
388
|
+
b.cover({ x, z, halfX: width / 2, halfZ: depth / 2, yaw: 0, top: height });
|
|
384
389
|
return { x, z, width, depth, height, color };
|
|
385
390
|
}
|
|
386
391
|
function pickUse(b, uses) {
|
|
@@ -451,6 +456,7 @@ function drawFence(b, x0, z0, x1, z1, height, color) {
|
|
|
451
456
|
}
|
|
452
457
|
function drawTent(b, x, z, ry, w, d, color, c) {
|
|
453
458
|
b.prism(x, 0, z, w, w * 0.7, d, color ?? colors(c).tent, -1, ry);
|
|
459
|
+
b.cover({ x, z, halfX: w / 2, halfZ: d / 2, yaw: -ry, top: w * 0.7 });
|
|
454
460
|
}
|
|
455
461
|
function drawPine(b, x, z, scale = 1, y = 0, c) {
|
|
456
462
|
const palette = colors(c);
|
|
@@ -468,12 +474,14 @@ function drawContainer(b, x, y, z, ry, color) {
|
|
|
468
474
|
const group = b.group(x, y, z, ry);
|
|
469
475
|
b.box(0, 0, 0, 2.44, 2.6, 6.06, color, { parent: group, style: { roughness: 0.7, metalness: 0.3 } });
|
|
470
476
|
for (let k = -2; k <= 2; k++) b.box(k * 0.5, 0, 3.04, 0.06, 2.6, 0.04, 1710618, { parent: group });
|
|
477
|
+
b.cover({ x, z, halfX: 1.22, halfZ: 3.03, yaw: -ry, top: y + 2.6 });
|
|
471
478
|
}
|
|
472
479
|
function drawWatchtower(b, x, z, searchlight = false, c) {
|
|
473
480
|
const palette = colors(c).watchtower;
|
|
474
481
|
for (const a of [-1, 1]) for (const d of [-1, 1]) b.box(x + a * 1.2, 0, z + d * 1.2, 0.25, 7, 0.25, palette.leg);
|
|
475
482
|
b.box(x, 7, z, 3.2, 1.2, 3.2, palette.cabin);
|
|
476
483
|
b.box(x, 8.2, z, 3.6, 0.15, 3.6, palette.deck);
|
|
484
|
+
b.cover({ x, z, halfX: 1.8, halfZ: 1.8, yaw: 0, top: 8.35 });
|
|
477
485
|
for (const side of [-1.5, 1.5]) b.box(x + side, 8.2, z, 0.15, 1.6, 0.15, palette.deck);
|
|
478
486
|
if (searchlight) b.spot({ x, y: 9, z, color: 15134463, intensity: 2.4, distance: 70, decay: 1.2, angle: 0.35, penumbra: 0.5, target: { x: x + 20, y: 0, z: z + 20 }, sweep: { speed: 0.5, radius: 25 } });
|
|
479
487
|
}
|
|
@@ -1480,7 +1488,12 @@ function createUrban(options = {}) {
|
|
|
1480
1488
|
const propColors = { ...DEFAULT_PROP_COLORS, ...options.props };
|
|
1481
1489
|
const towers = options.towers ? options.towers === true ? {} : options.towers : null;
|
|
1482
1490
|
const building = (b, x, z, width, depth, height, color, o) => drawBuilding(b, x, z, width, depth, height, color, o);
|
|
1483
|
-
const
|
|
1491
|
+
const towerDrawer = towers ? createTowerDrawer(towers, building) : null;
|
|
1492
|
+
const drawBlockBuilding = towerDrawer ? (b, x, z, width, depth, height, color, o) => {
|
|
1493
|
+
const built = towerDrawer(b, x, z, width, depth, height, color, o);
|
|
1494
|
+
b.cover({ x, z, halfX: width / 2, halfZ: depth / 2, yaw: 0, top: built.height });
|
|
1495
|
+
return built;
|
|
1496
|
+
} : building;
|
|
1484
1497
|
const poles = {
|
|
1485
1498
|
ids: () => [...entries.keys()],
|
|
1486
1499
|
list: () => [...entries.values()],
|