@adatechnology/game-terrain 0.4.0 → 0.5.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/index.d.ts +18 -1
- package/dist/index.global.js +92 -10
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +92 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -243,6 +243,8 @@ var TERRAIN_PROFILES = [
|
|
|
243
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 }] }
|
|
244
244
|
];
|
|
245
245
|
var DEFAULT_BAR_YIELD_JOULES = 24e5;
|
|
246
|
+
var DEFAULT_BAR_DIAMETER = 0.01;
|
|
247
|
+
var DEFAULT_BAR_YIELD_PA = 5e8;
|
|
246
248
|
var DEFAULT_PROFILE = "concrete_slab";
|
|
247
249
|
|
|
248
250
|
// src/random.ts
|
|
@@ -534,6 +536,7 @@ var FINE_DEPTH_CELLS = 0.4;
|
|
|
534
536
|
var RIGID_WIDENING = 2.5;
|
|
535
537
|
var COLLAPSE_DEPTH_SHARE = 0.75;
|
|
536
538
|
var COLLAPSE_SPREAD_BEND = 0.5;
|
|
539
|
+
var BARS_SHARE_REACH = 0.6;
|
|
537
540
|
var RIM_REACH = 1.45;
|
|
538
541
|
var FLAME_MINIMUM = 200;
|
|
539
542
|
var FLAME_REACH = 0.6;
|
|
@@ -1053,19 +1056,95 @@ function createTerrain(options) {
|
|
|
1053
1056
|
}
|
|
1054
1057
|
}
|
|
1055
1058
|
}
|
|
1056
|
-
if (collapsed)
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
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);
|
|
1065
1077
|
}
|
|
1066
1078
|
}
|
|
1067
1079
|
}
|
|
1068
|
-
|
|
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 };
|
|
1069
1148
|
}
|
|
1070
1149
|
const maxDepthOfProfile = (profile) => maxDepthOf[indexOfProfile.get(profile.id)];
|
|
1071
1150
|
function rebarShowing(profile, depth) {
|
|
@@ -1340,6 +1419,7 @@ function createTerrain(options) {
|
|
|
1340
1419
|
strike,
|
|
1341
1420
|
burn,
|
|
1342
1421
|
applyHit,
|
|
1422
|
+
bear: bearAll,
|
|
1343
1423
|
onDeform(listener) {
|
|
1344
1424
|
deformListeners.add(listener);
|
|
1345
1425
|
return () => deformListeners.delete(listener);
|
|
@@ -1540,7 +1620,9 @@ function waterLift(params) {
|
|
|
1540
1620
|
}
|
|
1541
1621
|
export {
|
|
1542
1622
|
CRACK_REFERENCE_JOULES,
|
|
1623
|
+
DEFAULT_BAR_DIAMETER,
|
|
1543
1624
|
DEFAULT_BAR_YIELD_JOULES,
|
|
1625
|
+
DEFAULT_BAR_YIELD_PA,
|
|
1544
1626
|
DEFAULT_PROFILE,
|
|
1545
1627
|
DEFAULT_TERRAIN_BUDGET,
|
|
1546
1628
|
TERRAIN_MATERIALS,
|