@adatechnology/game-terrain 0.9.12 → 0.9.14
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.global.js +20 -10
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +20 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.global.js
CHANGED
|
@@ -874,6 +874,9 @@ var GameTerrain = (() => {
|
|
|
874
874
|
var RIM_REACH = 1.45;
|
|
875
875
|
var FLAME_MINIMUM = 200;
|
|
876
876
|
var FLAME_REACH = 0.6;
|
|
877
|
+
var SCORCH_STEPS = 64;
|
|
878
|
+
var BURN_AWAY_STEPS = 1e3;
|
|
879
|
+
var visibleStep = (value, steps) => Math.floor(value * steps);
|
|
877
880
|
var BLAST_HEIGHT_REACH = 0.35;
|
|
878
881
|
var BLAST_SOOT_REACH = 1.2;
|
|
879
882
|
var BLAST_SOOT = 0.9;
|
|
@@ -1762,19 +1765,25 @@ var GameTerrain = (() => {
|
|
|
1762
1765
|
}
|
|
1763
1766
|
function burn(spec) {
|
|
1764
1767
|
if (spec.temperature < FLAME_MINIMUM) return;
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
const
|
|
1768
|
+
burnDisc(spec.x, spec.z, spec.radius, spec.seconds);
|
|
1769
|
+
}
|
|
1770
|
+
function burnDisc(x, z, radius, seconds) {
|
|
1771
|
+
const column0 = clampIndex(Math.floor((x - radius - x0) / cellSize), columns);
|
|
1772
|
+
const column1 = clampIndex(Math.ceil((x + radius - x0) / cellSize), columns);
|
|
1773
|
+
const row0 = clampIndex(Math.floor((z - radius - z0) / cellSize), rows);
|
|
1774
|
+
const row1 = clampIndex(Math.ceil((z + radius - z0) / cellSize), rows);
|
|
1775
|
+
const reach = radius * radius;
|
|
1769
1776
|
let melted = false;
|
|
1770
1777
|
for (let row = row0; row <= row1; row++) {
|
|
1778
|
+
const dz = z0 + row * cellSize - z;
|
|
1771
1779
|
for (let column = column0; column <= column1; column++) {
|
|
1772
|
-
|
|
1780
|
+
const dx = x0 + column * cellSize - x;
|
|
1781
|
+
if (dx * dx + dz * dz > reach) continue;
|
|
1773
1782
|
if (hasWater && base[row * stride + column] < surface[row * stride + column]) continue;
|
|
1774
|
-
melted = burnVertex(column, row,
|
|
1783
|
+
melted = burnVertex(column, row, seconds) || melted;
|
|
1775
1784
|
}
|
|
1776
1785
|
}
|
|
1777
|
-
if (melted) emitDeform(
|
|
1786
|
+
if (melted) emitDeform(x, z, radius);
|
|
1778
1787
|
}
|
|
1779
1788
|
function soot(x, z, radius) {
|
|
1780
1789
|
if (radius <= 0) return;
|
|
@@ -1801,8 +1810,9 @@ var GameTerrain = (() => {
|
|
|
1801
1810
|
if (!response) return false;
|
|
1802
1811
|
const before = scorch[index];
|
|
1803
1812
|
scorch[index] = Math.max(before, Math.min(response.maxScorch, before + response.scorchPerSecond * seconds));
|
|
1813
|
+
const dugBefore = dug[index];
|
|
1804
1814
|
if (response.burnsAway) removeFromVertex(index, response.burnsAway * seconds);
|
|
1805
|
-
if (scorch[index] !== before ||
|
|
1815
|
+
if (visibleStep(scorch[index], SCORCH_STEPS) !== visibleStep(before, SCORCH_STEPS) || visibleStep(dug[index], BURN_AWAY_STEPS) !== visibleStep(dugBefore, BURN_AWAY_STEPS)) touchVertex(column, row);
|
|
1806
1816
|
if (response.flammable) ignite(x0 + column * cellSize, z0 + row * cellSize);
|
|
1807
1817
|
return (response.burnsAway ?? 0) > 0;
|
|
1808
1818
|
}
|
|
@@ -1831,7 +1841,7 @@ var GameTerrain = (() => {
|
|
|
1831
1841
|
const cellColumn = key - cellRow * 65536;
|
|
1832
1842
|
const x = x0 + (cellColumn + 0.5) * FIRE_CELL;
|
|
1833
1843
|
const z = z0 + (cellRow + 0.5) * FIRE_CELL;
|
|
1834
|
-
|
|
1844
|
+
burnDisc(x, z, FIRE_CELL * 0.75, dt);
|
|
1835
1845
|
if (random() < FIRE_SPREAD_PER_SECOND * dt) {
|
|
1836
1846
|
const angle = Math.floor(random() * 4) * (Math.PI / 2);
|
|
1837
1847
|
const nextX = x + Math.cos(angle) * FIRE_CELL;
|
|
@@ -1939,7 +1949,7 @@ var GameTerrain = (() => {
|
|
|
1939
1949
|
case "fire":
|
|
1940
1950
|
case "heat":
|
|
1941
1951
|
if (y - heightAt(x, z) > (hit.radius ?? 0.2) + FLAME_REACH) return null;
|
|
1942
|
-
|
|
1952
|
+
if ((hit.temperature ?? 0) >= FLAME_MINIMUM) burnDisc(x, z, hit.radius ?? 0.2, hit.duration ?? 0.016);
|
|
1943
1953
|
return null;
|
|
1944
1954
|
default:
|
|
1945
1955
|
return null;
|