@adatechnology/game-terrain 0.5.2 → 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.d.ts +11 -8
- package/dist/index.global.js +14 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -534,6 +534,12 @@ var GRAVITY = 9.81;
|
|
|
534
534
|
var FINE_CELLS = 1.5;
|
|
535
535
|
var FINE_DEPTH_CELLS = 0.4;
|
|
536
536
|
var RIGID_WIDENING = 2.5;
|
|
537
|
+
var REFERENCE_CALIBER = 7.62;
|
|
538
|
+
var CALIBER_ASPECT_POWER = 0.5;
|
|
539
|
+
var CALIBER_ASPECT_RANGE = [0.6, 1.6];
|
|
540
|
+
var CALIBERS_ACROSS = 2.5;
|
|
541
|
+
var caliberAspect = (caliber) => caliber && caliber > 0 ? Math.min(CALIBER_ASPECT_RANGE[1], Math.max(CALIBER_ASPECT_RANGE[0], (REFERENCE_CALIBER / caliber) ** CALIBER_ASPECT_POWER)) : 1;
|
|
542
|
+
var caliberRadius = (caliber) => caliber && caliber > 0 ? caliber / 1e3 * CALIBERS_ACROSS / 2 : 0;
|
|
537
543
|
var COLLAPSE_DEPTH_SHARE = 0.75;
|
|
538
544
|
var COLLAPSE_SPREAD_BEND = 0.5;
|
|
539
545
|
var BARS_SHARE_REACH = 0.6;
|
|
@@ -906,16 +912,17 @@ function createTerrain(options) {
|
|
|
906
912
|
const pastCover = bars !== void 0 && depth - layer.top >= bars.cover - 1e-6;
|
|
907
913
|
const specificEnergy = response.specificEnergy * (pastCover ? bars.resistance : 1);
|
|
908
914
|
const limit = bars && !pastCover ? Math.min(room, layer.top + bars.cover - depth) : room;
|
|
915
|
+
const aspect = response.aspect * caliberAspect(spec.caliber);
|
|
909
916
|
const volume = energy / specificEnergy;
|
|
910
|
-
const wanted = Math.cbrt(2 * volume / (Math.PI *
|
|
911
|
-
const wantedDepth = wanted *
|
|
917
|
+
const wanted = Math.cbrt(2 * volume / (Math.PI * aspect));
|
|
918
|
+
const wantedDepth = wanted * aspect;
|
|
912
919
|
const takenDepth = Math.min(wantedDepth, limit);
|
|
913
|
-
const takenRadius = takenDepth < wantedDepth ? takenDepth /
|
|
920
|
+
const takenRadius = takenDepth < wantedDepth ? takenDepth / aspect : wanted;
|
|
914
921
|
const takenVolume = Math.PI * takenRadius * takenRadius * takenDepth / 2;
|
|
915
922
|
energy -= takenVolume * specificEnergy;
|
|
916
923
|
depth += takenDepth;
|
|
917
924
|
carved += takenDepth;
|
|
918
|
-
radius = Math.max(radius, takenRadius, response.minRadius ?? 0, spec.contactRadius ?? 0);
|
|
925
|
+
radius = Math.max(radius, takenRadius, response.minRadius ?? 0, spec.contactRadius ?? 0, caliberRadius(spec.caliber));
|
|
919
926
|
const last = removed[removed.length - 1];
|
|
920
927
|
if (last?.material === material.id) last.volume += takenVolume;
|
|
921
928
|
else removed.push({ material: material.id, volume: takenVolume });
|
|
@@ -971,7 +978,7 @@ function createTerrain(options) {
|
|
|
971
978
|
const bottom = layer.top + layer.stratum.thickness;
|
|
972
979
|
const miss = { point, radius: 0, depth: 0, totalDepth: layer.top, removed: [], exposed: material.id, atLimit: false, rebarExposed: false, collapsed: false, fine: true };
|
|
973
980
|
if (!response || energy < (response.thresholdJoules ?? 0)) return miss;
|
|
974
|
-
const reach = Math.max(spec.contactRadius ?? 0, response.minRadius ?? 0, Math.cbrt(2 * energy / response.specificEnergy / (Math.PI * response.aspect)));
|
|
981
|
+
const reach = Math.max(spec.contactRadius ?? 0, response.minRadius ?? 0, caliberRadius(spec.caliber), Math.cbrt(2 * energy / response.specificEnergy / (Math.PI * response.aspect * caliberAspect(spec.caliber))));
|
|
975
982
|
const rowFirst = Math.floor((z - reach) / units.width);
|
|
976
983
|
const rowLast = Math.floor((z + reach) / units.width);
|
|
977
984
|
let loosened = 0;
|
|
@@ -1305,7 +1312,8 @@ function createTerrain(options) {
|
|
|
1305
1312
|
case "slash": {
|
|
1306
1313
|
if (!hit.energy) return null;
|
|
1307
1314
|
const contactRadius = hit.type === "blunt" ? hit.radius : void 0;
|
|
1308
|
-
|
|
1315
|
+
const caliber = hit.type === "ballistic" ? hit.caliber : void 0;
|
|
1316
|
+
return strike(hit.type, { x, z, energy: hit.energy, ...hit.direction ? { direction: hit.direction } : {}, ...contactRadius !== void 0 ? { contactRadius } : {}, ...caliber !== void 0 ? { caliber } : {} });
|
|
1309
1317
|
}
|
|
1310
1318
|
case "explosive": {
|
|
1311
1319
|
if (!hit.energy) return null;
|