@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.js
CHANGED
|
@@ -738,6 +738,9 @@ var BARS_SHARE_REACH = 0.6;
|
|
|
738
738
|
var RIM_REACH = 1.45;
|
|
739
739
|
var FLAME_MINIMUM = 200;
|
|
740
740
|
var FLAME_REACH = 0.6;
|
|
741
|
+
var SCORCH_STEPS = 64;
|
|
742
|
+
var BURN_AWAY_STEPS = 1e3;
|
|
743
|
+
var visibleStep = (value, steps) => Math.floor(value * steps);
|
|
741
744
|
var BLAST_HEIGHT_REACH = 0.35;
|
|
742
745
|
var BLAST_SOOT_REACH = 1.2;
|
|
743
746
|
var BLAST_SOOT = 0.9;
|
|
@@ -1626,19 +1629,25 @@ function createTerrain(options) {
|
|
|
1626
1629
|
}
|
|
1627
1630
|
function burn(spec) {
|
|
1628
1631
|
if (spec.temperature < FLAME_MINIMUM) return;
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
const
|
|
1632
|
+
burnDisc(spec.x, spec.z, spec.radius, spec.seconds);
|
|
1633
|
+
}
|
|
1634
|
+
function burnDisc(x, z, radius, seconds) {
|
|
1635
|
+
const column0 = clampIndex(Math.floor((x - radius - x0) / cellSize), columns);
|
|
1636
|
+
const column1 = clampIndex(Math.ceil((x + radius - x0) / cellSize), columns);
|
|
1637
|
+
const row0 = clampIndex(Math.floor((z - radius - z0) / cellSize), rows);
|
|
1638
|
+
const row1 = clampIndex(Math.ceil((z + radius - z0) / cellSize), rows);
|
|
1639
|
+
const reach = radius * radius;
|
|
1633
1640
|
let melted = false;
|
|
1634
1641
|
for (let row = row0; row <= row1; row++) {
|
|
1642
|
+
const dz = z0 + row * cellSize - z;
|
|
1635
1643
|
for (let column = column0; column <= column1; column++) {
|
|
1636
|
-
|
|
1644
|
+
const dx = x0 + column * cellSize - x;
|
|
1645
|
+
if (dx * dx + dz * dz > reach) continue;
|
|
1637
1646
|
if (hasWater && base[row * stride + column] < surface[row * stride + column]) continue;
|
|
1638
|
-
melted = burnVertex(column, row,
|
|
1647
|
+
melted = burnVertex(column, row, seconds) || melted;
|
|
1639
1648
|
}
|
|
1640
1649
|
}
|
|
1641
|
-
if (melted) emitDeform(
|
|
1650
|
+
if (melted) emitDeform(x, z, radius);
|
|
1642
1651
|
}
|
|
1643
1652
|
function soot(x, z, radius) {
|
|
1644
1653
|
if (radius <= 0) return;
|
|
@@ -1665,8 +1674,9 @@ function createTerrain(options) {
|
|
|
1665
1674
|
if (!response) return false;
|
|
1666
1675
|
const before = scorch[index];
|
|
1667
1676
|
scorch[index] = Math.max(before, Math.min(response.maxScorch, before + response.scorchPerSecond * seconds));
|
|
1677
|
+
const dugBefore = dug[index];
|
|
1668
1678
|
if (response.burnsAway) removeFromVertex(index, response.burnsAway * seconds);
|
|
1669
|
-
if (scorch[index] !== before ||
|
|
1679
|
+
if (visibleStep(scorch[index], SCORCH_STEPS) !== visibleStep(before, SCORCH_STEPS) || visibleStep(dug[index], BURN_AWAY_STEPS) !== visibleStep(dugBefore, BURN_AWAY_STEPS)) touchVertex(column, row);
|
|
1670
1680
|
if (response.flammable) ignite(x0 + column * cellSize, z0 + row * cellSize);
|
|
1671
1681
|
return (response.burnsAway ?? 0) > 0;
|
|
1672
1682
|
}
|
|
@@ -1695,7 +1705,7 @@ function createTerrain(options) {
|
|
|
1695
1705
|
const cellColumn = key - cellRow * 65536;
|
|
1696
1706
|
const x = x0 + (cellColumn + 0.5) * FIRE_CELL;
|
|
1697
1707
|
const z = z0 + (cellRow + 0.5) * FIRE_CELL;
|
|
1698
|
-
|
|
1708
|
+
burnDisc(x, z, FIRE_CELL * 0.75, dt);
|
|
1699
1709
|
if (random() < FIRE_SPREAD_PER_SECOND * dt) {
|
|
1700
1710
|
const angle = Math.floor(random() * 4) * (Math.PI / 2);
|
|
1701
1711
|
const nextX = x + Math.cos(angle) * FIRE_CELL;
|
|
@@ -1803,7 +1813,7 @@ function createTerrain(options) {
|
|
|
1803
1813
|
case "fire":
|
|
1804
1814
|
case "heat":
|
|
1805
1815
|
if (y - heightAt(x, z) > (hit.radius ?? 0.2) + FLAME_REACH) return null;
|
|
1806
|
-
|
|
1816
|
+
if ((hit.temperature ?? 0) >= FLAME_MINIMUM) burnDisc(x, z, hit.radius ?? 0.2, hit.duration ?? 0.016);
|
|
1807
1817
|
return null;
|
|
1808
1818
|
default:
|
|
1809
1819
|
return null;
|