@adatechnology/game-terrain 0.3.2 → 0.5.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/README.md +1 -1
- package/dist/index.d.ts +21 -2
- package/dist/index.global.js +95 -11
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +95 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -237,10 +237,14 @@ var TERRAIN_PROFILES = [
|
|
|
237
237
|
{ id: "dry_clay", strata: [{ material: "clay", thickness: 0.35 }, { material: "soil", thickness: 1.5 }, { material: "stone", thickness: 0.5 }] },
|
|
238
238
|
{ id: "snow", strata: [{ material: "snow", thickness: 0.3 }, { material: "soil", thickness: 1.5 }, { material: "stone", thickness: 0.5 }] },
|
|
239
239
|
{ id: "cobblestone", strata: [{ material: "cobble", thickness: 0.12 }, { material: "sand", thickness: 0.06 }, { material: "gravel", thickness: 0.2 }, { material: "soil", thickness: 1.2 }] },
|
|
240
|
+
// rock at the surface (an outcrop, a quarry floor): a blast only spalls it and a shot chips it
|
|
241
|
+
{ id: "bedrock", surfacePattern: "rock", strata: [{ material: "stone", thickness: 3 }] },
|
|
240
242
|
{ id: "paver_floor", strata: [{ material: "paver", thickness: 0.08 }, { material: "sand", thickness: 0.05 }, { material: "gravel", thickness: 0.15 }, { material: "soil", thickness: 1.2 }] },
|
|
241
243
|
{ id: "shallow_water", water: { liquid: "water", depth: 0.3, drag: 0.65, blowShare: WATER_BLOW_SHARE }, strata: [{ material: "mud", thickness: 0.15 }, { material: "soil", thickness: 1.5 }, { material: "stone", thickness: 0.5 }] }
|
|
242
244
|
];
|
|
243
245
|
var DEFAULT_BAR_YIELD_JOULES = 24e5;
|
|
246
|
+
var DEFAULT_BAR_DIAMETER = 0.01;
|
|
247
|
+
var DEFAULT_BAR_YIELD_PA = 5e8;
|
|
244
248
|
var DEFAULT_PROFILE = "concrete_slab";
|
|
245
249
|
|
|
246
250
|
// src/random.ts
|
|
@@ -532,6 +536,7 @@ var FINE_DEPTH_CELLS = 0.4;
|
|
|
532
536
|
var RIGID_WIDENING = 2.5;
|
|
533
537
|
var COLLAPSE_DEPTH_SHARE = 0.75;
|
|
534
538
|
var COLLAPSE_SPREAD_BEND = 0.5;
|
|
539
|
+
var BARS_SHARE_REACH = 0.6;
|
|
535
540
|
var RIM_REACH = 1.45;
|
|
536
541
|
var FLAME_MINIMUM = 200;
|
|
537
542
|
var FLAME_REACH = 0.6;
|
|
@@ -1051,19 +1056,95 @@ function createTerrain(options) {
|
|
|
1051
1056
|
}
|
|
1052
1057
|
}
|
|
1053
1058
|
}
|
|
1054
|
-
if (collapsed)
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1059
|
+
if (collapsed) giveWay({ x, z, reach, profile });
|
|
1060
|
+
return collapsed;
|
|
1061
|
+
}
|
|
1062
|
+
function giveWay(spec) {
|
|
1063
|
+
const { x, z, reach, profile } = spec;
|
|
1064
|
+
emitDeform(x, z, reach);
|
|
1065
|
+
if (profile.drop === void 0) return;
|
|
1066
|
+
const limit = maxDepthOfProfile(profile);
|
|
1067
|
+
const column0 = clampIndex(Math.floor((x - reach - x0) / cellSize), columns);
|
|
1068
|
+
const column1 = clampIndex(Math.ceil((x + reach - x0) / cellSize), columns);
|
|
1069
|
+
const row0 = clampIndex(Math.floor((z - reach - z0) / cellSize), rows);
|
|
1070
|
+
const row1 = clampIndex(Math.ceil((z + reach - z0) / cellSize), rows);
|
|
1071
|
+
for (let row = row0; row <= row1; row++) {
|
|
1072
|
+
for (let column = column0; column <= column1; column++) {
|
|
1073
|
+
const index = row * stride + column;
|
|
1074
|
+
if (barBend[index] >= COLLAPSE_SPREAD_BEND && dug[index] < limit + profile.drop) {
|
|
1075
|
+
dug[index] = limit + profile.drop;
|
|
1076
|
+
touchVertex(column, row);
|
|
1063
1077
|
}
|
|
1064
1078
|
}
|
|
1065
1079
|
}
|
|
1066
|
-
|
|
1080
|
+
}
|
|
1081
|
+
function barsOf(profile) {
|
|
1082
|
+
const bars = profile.strata.find((stratum) => stratum.reinforcement);
|
|
1083
|
+
if (!bars?.reinforcement) return null;
|
|
1084
|
+
let cover = bars.reinforcement.cover;
|
|
1085
|
+
for (const stratum of profile.strata) {
|
|
1086
|
+
if (stratum === bars) break;
|
|
1087
|
+
cover += stratum.thickness;
|
|
1088
|
+
}
|
|
1089
|
+
return { stratum: bars, cover };
|
|
1090
|
+
}
|
|
1091
|
+
function bearAll(loads) {
|
|
1092
|
+
const bends = /* @__PURE__ */ new Map();
|
|
1093
|
+
const touched2 = [];
|
|
1094
|
+
for (const load of loads) {
|
|
1095
|
+
const spread = spreadLoad(load, bends);
|
|
1096
|
+
if (spread) touched2.push({ load, ...spread });
|
|
1097
|
+
}
|
|
1098
|
+
let opened = false;
|
|
1099
|
+
for (const [index, bend] of bends) {
|
|
1100
|
+
if (barBend[index] >= bend) continue;
|
|
1101
|
+
barBend[index] = bend;
|
|
1102
|
+
const column = index % stride;
|
|
1103
|
+
const row = (index - column) / stride;
|
|
1104
|
+
touchVertex(column, row);
|
|
1105
|
+
const profile = profileList[profileIndex[index]];
|
|
1106
|
+
const limit = maxDepthOfProfile(profile);
|
|
1107
|
+
if (bend >= 1 && profile.drop !== void 0 && dug[index] >= limit * COLLAPSE_DEPTH_SHARE && dug[index] < limit + profile.drop) {
|
|
1108
|
+
dug[index] = limit + profile.drop;
|
|
1109
|
+
opened = true;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
if (opened) for (const { load, reach, profile } of touched2) giveWay({ x: load.x, z: load.z, reach, profile });
|
|
1113
|
+
return opened;
|
|
1114
|
+
}
|
|
1115
|
+
function spreadLoad(load, bends) {
|
|
1116
|
+
if (!contains(load.x, load.z) || load.newtons <= 0) return null;
|
|
1117
|
+
const profile = profileList[profileIndex[vertexOf(load.x, load.z).index]];
|
|
1118
|
+
const bars = barsOf(profile);
|
|
1119
|
+
if (!bars) return null;
|
|
1120
|
+
const reinforcement = bars.stratum.reinforcement;
|
|
1121
|
+
const moment = (reinforcement.yieldPa ?? DEFAULT_BAR_YIELD_PA) * (reinforcement.diameter ?? DEFAULT_BAR_DIAMETER) ** 3 / 6;
|
|
1122
|
+
const holds = 8 * moment / reinforcement.spacing;
|
|
1123
|
+
const footprint = load.radius * Math.SQRT2 + cellSize;
|
|
1124
|
+
const reach = Math.max(footprint, BARS_SHARE_REACH);
|
|
1125
|
+
const column0 = clampIndex(Math.floor((load.x - reach - x0) / cellSize), columns);
|
|
1126
|
+
const column1 = clampIndex(Math.ceil((load.x + reach - x0) / cellSize), columns);
|
|
1127
|
+
const row0 = clampIndex(Math.floor((load.z - reach - z0) / cellSize), rows);
|
|
1128
|
+
const row1 = clampIndex(Math.ceil((load.z + reach - z0) / cellSize), rows);
|
|
1129
|
+
const bare = [];
|
|
1130
|
+
let under = 0;
|
|
1131
|
+
let onBars = 0;
|
|
1132
|
+
for (let row = row0; row <= row1; row++) {
|
|
1133
|
+
for (let column = column0; column <= column1; column++) {
|
|
1134
|
+
const distance = Math.hypot(x0 + column * cellSize - load.x, z0 + row * cellSize - load.z);
|
|
1135
|
+
if (distance >= reach) continue;
|
|
1136
|
+
const index = row * stride + column;
|
|
1137
|
+
const isBare = dug[index] >= bars.cover;
|
|
1138
|
+
if (isBare) bare.push(index);
|
|
1139
|
+
if (distance >= footprint) continue;
|
|
1140
|
+
under++;
|
|
1141
|
+
if (isBare) onBars++;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
if (onBars === 0) return null;
|
|
1145
|
+
const bend = load.newtons * (onBars / under) / holds;
|
|
1146
|
+
for (const index of bare) bends.set(index, (bends.get(index) ?? 0) + bend);
|
|
1147
|
+
return { reach, profile };
|
|
1067
1148
|
}
|
|
1068
1149
|
const maxDepthOfProfile = (profile) => maxDepthOf[indexOfProfile.get(profile.id)];
|
|
1069
1150
|
function rebarShowing(profile, depth) {
|
|
@@ -1338,6 +1419,7 @@ function createTerrain(options) {
|
|
|
1338
1419
|
strike,
|
|
1339
1420
|
burn,
|
|
1340
1421
|
applyHit,
|
|
1422
|
+
bear: bearAll,
|
|
1341
1423
|
onDeform(listener) {
|
|
1342
1424
|
deformListeners.add(listener);
|
|
1343
1425
|
return () => deformListeners.delete(listener);
|
|
@@ -1485,7 +1567,7 @@ function createTerrainImpl(terrain, options) {
|
|
|
1485
1567
|
}
|
|
1486
1568
|
|
|
1487
1569
|
// src/types.ts
|
|
1488
|
-
var TERRAIN_PATTERNS = ["plain", "grass", "soil", "sand", "asphalt", "concrete", "tile", "planks", "stone", "mud", "gravel", "clay", "snow", "cobble", "paver"];
|
|
1570
|
+
var TERRAIN_PATTERNS = ["plain", "grass", "soil", "sand", "asphalt", "concrete", "tile", "planks", "stone", "mud", "gravel", "clay", "snow", "cobble", "paver", "rock"];
|
|
1489
1571
|
|
|
1490
1572
|
// src/footprints.ts
|
|
1491
1573
|
var STRIDE = 0.72;
|
|
@@ -1538,7 +1620,9 @@ function waterLift(params) {
|
|
|
1538
1620
|
}
|
|
1539
1621
|
export {
|
|
1540
1622
|
CRACK_REFERENCE_JOULES,
|
|
1623
|
+
DEFAULT_BAR_DIAMETER,
|
|
1541
1624
|
DEFAULT_BAR_YIELD_JOULES,
|
|
1625
|
+
DEFAULT_BAR_YIELD_PA,
|
|
1542
1626
|
DEFAULT_PROFILE,
|
|
1543
1627
|
DEFAULT_TERRAIN_BUDGET,
|
|
1544
1628
|
TERRAIN_MATERIALS,
|