@adatechnology/game-vfx 0.18.0 → 0.19.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 CHANGED
@@ -310,6 +310,8 @@ interface ConfineResult {
310
310
  nx: number;
311
311
  ny: number;
312
312
  nz: number;
313
+ /** Offset of the face the particle met (`n · p` of a point on it): the plane the face lies in. */
314
+ d: number;
313
315
  }
314
316
  /** One particle's step for {@link Confiner.confineMove}: from `(x0, y0, z0)` to `(x1, y1, z1)`, kept `pad` metres off the walls. */
315
317
  interface ConfineMove {
@@ -619,6 +621,17 @@ interface Chunk {
619
621
  /** `_hotCol` (L399-400): the colour of a hot piece, blended towards the glow while it is young. */
620
622
  declare function colorOfChunk(chunk: Chunk): readonly [number, number, number];
621
623
 
624
+ /** The face of a wall a puff's drawn ball is cut at: unit normal towards the puff and offset (`n · point`). `on` false: no face. */
625
+ interface PuffCut {
626
+ on: boolean;
627
+ nx: number;
628
+ ny: number;
629
+ nz: number;
630
+ d: number;
631
+ }
632
+ /** How far a puff's drawn surface reaches from its middle, in sizes: the renderer bulges the ball by up to this much (`game-vfx-three`'s puff shader). */
633
+ declare const PUFF_REACH = 1.28;
634
+
622
635
  /** The ring a mushroom cloud's puffs travel on (L722-735). */
623
636
  interface Ring {
624
637
  x: number;
@@ -668,6 +681,11 @@ interface Puff {
668
681
  size: number;
669
682
  /** The thing it was made for (a burning part's object): `VfxWorld.clearSource` takes it away when that thing leaves. */
670
683
  source: string | undefined;
684
+ /**
685
+ * The faces of the walls (host solids, closed spaces) within the puff's reach, up to two (a wall and the skirting in front of it): the drawn ball is cut at
686
+ * them, so smoke against a wall flattens on it instead of growing through to its other side. See `puff-cuts.ts`.
687
+ */
688
+ readonly cuts: readonly [PuffCut, PuffCut];
671
689
  }
672
690
 
673
691
  /** A shock wave: an air shell that grows to the lethal radius in 120 ms, and a dust ring on the ground (L319-348). The last block is what the renderer reads. */
@@ -1743,6 +1761,8 @@ declare class SpriteKindPool {
1743
1761
  private readonly bounced;
1744
1762
  private readonly floor;
1745
1763
  private readonly riseMul;
1764
+ /** The ground under each sprite as last asked (`GROUND_RESAMPLE`): x and z where it was asked, and its height. NaN x: not asked yet. */
1765
+ private readonly ground;
1746
1766
  constructor(capacity: number, defs: readonly SpriteKindDef[], owners: string[], sources?: SpriteSources);
1747
1767
  spawn(kind: number, p: readonly number[], v: readonly number[], random: () => number, options?: SpriteSpawnOptions): void;
1748
1768
  private ownerIndex;
@@ -2520,4 +2540,4 @@ declare function resolveWaterShotProfile(profile: string | WaterShotProfile, tab
2520
2540
  /** Changes a profile table without touching the kit's: `null` removes an entry, a partial entry is merged over the old one. */
2521
2541
  declare function patchWaterShotProfiles(base: Readonly<Record<string, WaterShotProfile>>, changes: Readonly<Record<string, Partial<WaterShotProfile> | null>>): Record<string, WaterShotProfile>;
2522
2542
 
2523
- export { AREA_CAP_GAME, type AreaCap, type AreaCapTracker, type Behavior, type BehaviorHost, type BlastLight, type BloodMark, type Carrier, type Chunk, type ConfineMove, type ConfineResult, type Confiner, type CueRequest, DEBRIS_COLOR_VARIABLE, DEBRIS_EFFECT_FAMILIES, DUST_COLOR_VARIABLE, type DebrisEffectFamily, type DebrisObstacle, type DebrisSpawn, type Decal, type DecalOptions, type DirtMark, EVENT_BUDGET, EVENT_EFFECTS, EVENT_EFFECTS_MAP, EXPLOSIONS, EXPLOSION_ALIASES, EffectCamera, type EffectDef, EffectInstance, type EffectPlayer, type EffectPlayerOptions, EffectRunner, type EffectRunnerOptions, type EffectStep, type EffectTexts, type EffectTrack, type EffectView, Enclosures, type ExplosionCall, type ExplosionDef, type ExplosionOptions, type Fire, type FireBody, type FireLight, type FireOptions, type FireSpec, type Follow, GAME_EFFECTS, type GameEvent, type Glow, type GroundField, type GroundFieldOptions, type InstanceDeps, type InstanceSetup, type KindPoolHost, LOD_GAME, LOD_LAB, type LandListener, type LensBlob, type LightGlow, type LightPool, type LodBands, MATERIAL_EVENT_EFFECTS, type Mark, type MarkEvent, type MarkStore, type MeshParticle, MeshPool, type MeshShape, type MeshSpawn, type MushroomSpec, type MutableVec3, OrderedPool, PIECES_DRAWN_VARIABLE, PROFILES, type Placement, type PlayOptions, type PostProcess, type Puddle, type Puff, type Quaternion, RAIN_CAPACITY, RainField, type RandomStream, type Rgb, type Ring, type RockMark, SCRAPE_LIMIT, SMOKE_COLORS, SPRITE_KINDS, type Schedule, type ScorchMark, type ScrapeMark, type ScreenState, type SheetLabels, type Shock, type Spark, type SpriteGround, type SpriteKind, type SpriteKindDef, SpriteKindPool, SpriteKindSystem, type SpriteKindSystemOptions, type SpriteSpawn, type SpriteSpawnOptions, type SpriteSystem, VFX_LAYERS, VIEWMODEL_EFFECTS, type Vec3Like, type Vec3Tuple, type VfxEnclosure, type VfxEnclosureBox, type VfxLayer, type VfxLocale, type VfxOptions, type VfxPoolsView, type VfxProfile, type VfxProfileName, type VfxSideRequest, type VfxSolidQuery, type VfxStats, type VfxStrings, type VfxTrace, type VfxWorld, WATER_BLASTS, WATER_BLAST_KINDS, WATER_LIMITS, WATER_SHOT_BY_CALIBER, WATER_SHOT_PROFILES, WORKSHOP_BEHAVIORS, WORKSHOP_EFFECTS, WORKSHOP_PUDDLES, type WaterBlastCharge, type WaterBlastKind, type WaterBlastKindId, type WaterBlastParams, type WaterBlastPlan, type WaterBubble, type WaterColumn, type WaterDrop, type WaterEffects, type WaterEffectsLimits, type WaterEffectsOptions, type WaterEffectsStats, type WaterFoam, type WaterMist, type WaterRing, type WaterRound, type WaterShotClass, type WaterShotParams, type WaterShotPlan, type WaterShotProfile, type WaterVec3, type WaterWave, type WaterWaveSample, type WorkshopContext, WorkshopEngine, type WorkshopOptions, type WorkshopTrace, colorOfChunk, composeExplosion, createAreaCap, createEffectPlayer, createGroundField, createSchedule, createScreenState, createVfx, createWaterEffects, createWorkshopBehaviors, effectForEvent, estimateCost, explosionEffectIds, hexToLinearRgb, hexToRgb, inPuddle, lcg, lehmer, locales, lodScale, patchEffects, patchExplosions, patchSpriteKinds, patchWaterShotProfiles, planWaterBlast, planWaterShot, resolveStrings, resolveWaterBlast, resolveWaterShotProfile, slideAlong, slideInto, streamFor, updateScreen, waterShotClassOf, workshopGround };
2543
+ export { AREA_CAP_GAME, type AreaCap, type AreaCapTracker, type Behavior, type BehaviorHost, type BlastLight, type BloodMark, type Carrier, type Chunk, type ConfineMove, type ConfineResult, type Confiner, type CueRequest, DEBRIS_COLOR_VARIABLE, DEBRIS_EFFECT_FAMILIES, DUST_COLOR_VARIABLE, type DebrisEffectFamily, type DebrisObstacle, type DebrisSpawn, type Decal, type DecalOptions, type DirtMark, EVENT_BUDGET, EVENT_EFFECTS, EVENT_EFFECTS_MAP, EXPLOSIONS, EXPLOSION_ALIASES, EffectCamera, type EffectDef, EffectInstance, type EffectPlayer, type EffectPlayerOptions, EffectRunner, type EffectRunnerOptions, type EffectStep, type EffectTexts, type EffectTrack, type EffectView, Enclosures, type ExplosionCall, type ExplosionDef, type ExplosionOptions, type Fire, type FireBody, type FireLight, type FireOptions, type FireSpec, type Follow, GAME_EFFECTS, type GameEvent, type Glow, type GroundField, type GroundFieldOptions, type InstanceDeps, type InstanceSetup, type KindPoolHost, LOD_GAME, LOD_LAB, type LandListener, type LensBlob, type LightGlow, type LightPool, type LodBands, MATERIAL_EVENT_EFFECTS, type Mark, type MarkEvent, type MarkStore, type MeshParticle, MeshPool, type MeshShape, type MeshSpawn, type MushroomSpec, type MutableVec3, OrderedPool, PIECES_DRAWN_VARIABLE, PROFILES, PUFF_REACH, type Placement, type PlayOptions, type PostProcess, type Puddle, type Puff, type PuffCut, type Quaternion, RAIN_CAPACITY, RainField, type RandomStream, type Rgb, type Ring, type RockMark, SCRAPE_LIMIT, SMOKE_COLORS, SPRITE_KINDS, type Schedule, type ScorchMark, type ScrapeMark, type ScreenState, type SheetLabels, type Shock, type Spark, type SpriteGround, type SpriteKind, type SpriteKindDef, SpriteKindPool, SpriteKindSystem, type SpriteKindSystemOptions, type SpriteSpawn, type SpriteSpawnOptions, type SpriteSystem, VFX_LAYERS, VIEWMODEL_EFFECTS, type Vec3Like, type Vec3Tuple, type VfxEnclosure, type VfxEnclosureBox, type VfxLayer, type VfxLocale, type VfxOptions, type VfxPoolsView, type VfxProfile, type VfxProfileName, type VfxSideRequest, type VfxSolidQuery, type VfxStats, type VfxStrings, type VfxTrace, type VfxWorld, WATER_BLASTS, WATER_BLAST_KINDS, WATER_LIMITS, WATER_SHOT_BY_CALIBER, WATER_SHOT_PROFILES, WORKSHOP_BEHAVIORS, WORKSHOP_EFFECTS, WORKSHOP_PUDDLES, type WaterBlastCharge, type WaterBlastKind, type WaterBlastKindId, type WaterBlastParams, type WaterBlastPlan, type WaterBubble, type WaterColumn, type WaterDrop, type WaterEffects, type WaterEffectsLimits, type WaterEffectsOptions, type WaterEffectsStats, type WaterFoam, type WaterMist, type WaterRing, type WaterRound, type WaterShotClass, type WaterShotParams, type WaterShotPlan, type WaterShotProfile, type WaterVec3, type WaterWave, type WaterWaveSample, type WorkshopContext, WorkshopEngine, type WorkshopOptions, type WorkshopTrace, colorOfChunk, composeExplosion, createAreaCap, createEffectPlayer, createGroundField, createSchedule, createScreenState, createVfx, createWaterEffects, createWorkshopBehaviors, effectForEvent, estimateCost, explosionEffectIds, hexToLinearRgb, hexToRgb, inPuddle, lcg, lehmer, locales, lodScale, patchEffects, patchExplosions, patchSpriteKinds, patchWaterShotProfiles, planWaterBlast, planWaterShot, resolveStrings, resolveWaterBlast, resolveWaterShotProfile, slideAlong, slideInto, streamFor, updateScreen, waterShotClassOf, workshopGround };
@@ -44,6 +44,7 @@ var GameVfx = (() => {
44
44
  OrderedPool: () => OrderedPool,
45
45
  PIECES_DRAWN_VARIABLE: () => PIECES_DRAWN_VARIABLE,
46
46
  PROFILES: () => PROFILES,
47
+ PUFF_REACH: () => PUFF_REACH,
47
48
  RAIN_CAPACITY: () => RAIN_CAPACITY,
48
49
  RainField: () => RainField,
49
50
  SCRAPE_LIMIT: () => SCRAPE_LIMIT,
@@ -1203,11 +1204,11 @@ var GameVfx = (() => {
1203
1204
  this.spare.push(record);
1204
1205
  }
1205
1206
  /** Keeps the records `keep` accepts, in the same order, without allocating. `context` goes to `keep` so no closure is needed per frame. */
1206
- compact(keep, context) {
1207
+ compact(keep2, context) {
1207
1208
  let write = 0;
1208
1209
  for (let read = 0; read < this.items.length; read++) {
1209
1210
  const record = this.items[read];
1210
- if (keep(record, context)) {
1211
+ if (keep2(record, context)) {
1211
1212
  this.items[write++] = record;
1212
1213
  continue;
1213
1214
  }
@@ -1493,12 +1494,14 @@ var GameVfx = (() => {
1493
1494
  }
1494
1495
 
1495
1496
  // src/solids.ts
1497
+ var MAX_PAD = 0.45;
1496
1498
  var SKIN = 5e-3;
1497
1499
  var Solids = class {
1498
1500
  constructor() {
1499
1501
  __publicField(this, "queries", /* @__PURE__ */ new Map());
1500
1502
  __publicField(this, "list", []);
1501
- __publicField(this, "hit", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
1503
+ // fractions from the start: the fields hold fractions, and a field that held a whole number first boxes each fraction written to it
1504
+ __publicField(this, "hit", { x: 0.5, y: 0.5, z: 0.5, nx: 0.5, ny: 0.5, nz: 0.5, d: 0.5 });
1502
1505
  }
1503
1506
  get empty() {
1504
1507
  return this.list.length === 0;
@@ -1514,18 +1517,19 @@ var GameVfx = (() => {
1514
1517
  this.list = [];
1515
1518
  }
1516
1519
  /**
1517
- * Stops a step that goes into a solid: `out` gets the nearest hit, put back `pad` metres off the surface (never behind where the step began) and
1520
+ * Stops a step that goes into a solid: `out` gets the nearest hit, put back the step's `pad` metres (at most `MAX_PAD`) off the surface (never behind where the step began) and
1518
1521
  * the surface's normal. Answers whether the step was stopped.
1519
1522
  */
1520
- stop(move, pad, out) {
1523
+ stop(move, out) {
1521
1524
  const dx = move.x1 - move.x0;
1522
1525
  const dy = move.y1 - move.y0;
1523
1526
  const dz = move.z1 - move.z0;
1524
- const length = Math.hypot(dx, dy, dz);
1527
+ const length = Math.sqrt(dx * dx + dy * dy + dz * dz);
1525
1528
  if (!(length > 0)) return false;
1526
1529
  let nearest = Infinity;
1527
- for (const query2 of this.list) {
1528
- if (!query2(move, this.hit)) continue;
1530
+ const list = this.list;
1531
+ for (let index = 0; index < list.length; index++) {
1532
+ if (!list[index](move, this.hit)) continue;
1529
1533
  const reached = ((this.hit.x - move.x0) * dx + (this.hit.y - move.y0) * dy + (this.hit.z - move.z0) * dz) / length;
1530
1534
  if (reached >= nearest) continue;
1531
1535
  nearest = reached;
@@ -1537,17 +1541,26 @@ var GameVfx = (() => {
1537
1541
  out.nz = this.hit.nz;
1538
1542
  }
1539
1543
  if (nearest === Infinity) return false;
1540
- const back = Math.min(Math.max(pad, 0) + SKIN, Math.max(nearest, 0));
1544
+ const hitX2 = out.x;
1545
+ const hitY2 = out.y;
1546
+ const hitZ = out.z;
1547
+ out.d = out.nx * hitX2 + out.ny * hitY2 + out.nz * hitZ;
1548
+ const back = Math.min(Math.min(Math.max(move.pad, 0), MAX_PAD) + SKIN, Math.max(nearest, 0));
1541
1549
  out.x -= dx / length * back;
1542
1550
  out.y -= dy / length * back;
1543
1551
  out.z -= dz / length * back;
1552
+ const off = (out.x - hitX2) * out.nx + (out.y - hitY2) * out.ny + (out.z - hitZ) * out.nz;
1553
+ if (off < SKIN) {
1554
+ out.x += out.nx * (SKIN - off);
1555
+ out.y += out.ny * (SKIN - off);
1556
+ out.z += out.nz * (SKIN - off);
1557
+ }
1544
1558
  return true;
1545
1559
  }
1546
1560
  };
1547
1561
 
1548
1562
  // src/enclosures.ts
1549
1563
  var SKIN2 = 5e-3;
1550
- var MAX_PAD = 0.45;
1551
1564
  function rotation(q) {
1552
1565
  const [x, y, z, w] = q ?? [0, 0, 0, 1];
1553
1566
  const n = Math.hypot(x, y, z, w) || 1;
@@ -1572,7 +1585,7 @@ var GameVfx = (() => {
1572
1585
  __publicField(this, "spaces", /* @__PURE__ */ new Map());
1573
1586
  __publicField(this, "list", []);
1574
1587
  __publicField(this, "random");
1575
- __publicField(this, "out", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
1588
+ __publicField(this, "out", { x: 0.5, y: 0.5, z: 0.5, nx: 0.5, ny: 0.5, nz: 0.5, d: 0.5 });
1576
1589
  __publicField(this, "l0", new Float64Array(3));
1577
1590
  __publicField(this, "l1", new Float64Array(3));
1578
1591
  __publicField(this, "q", new Float64Array(3));
@@ -1647,7 +1660,7 @@ var GameVfx = (() => {
1647
1660
  }
1648
1661
  /** Passes at `rate` per second. */
1649
1662
  chance(rate, dt) {
1650
- return rate > 0 && this.random.next() < 1 - Math.exp(-rate * dt);
1663
+ return rate > 0 && dt > 0 && this.random.next() < 1 - Math.exp(-rate * dt);
1651
1664
  }
1652
1665
  /** The opening the wall point `q` (local) is in lets it through now. */
1653
1666
  through(s, q, dt) {
@@ -1670,7 +1683,7 @@ var GameVfx = (() => {
1670
1683
  }
1671
1684
  confineMove(move, dt) {
1672
1685
  if (this.confineSpaces(move, dt)) return true;
1673
- return !this.solids.empty && this.solids.stop(move, Math.min(Math.max(0, move.pad), MAX_PAD), this.out);
1686
+ return !this.solids.empty && this.solids.stop(move, this.out);
1674
1687
  }
1675
1688
  confineSpaces(move, dt) {
1676
1689
  const list = this.list;
@@ -1740,6 +1753,7 @@ var GameVfx = (() => {
1740
1753
  out.nx = r[axis2] * sign;
1741
1754
  out.ny = r[3 + axis2] * sign;
1742
1755
  out.nz = r[6 + axis2] * sign;
1756
+ out.d = out.nx * s.cx + out.ny * s.cy + out.nz * s.cz + (in0 ? -h[axis2] : h[axis2]);
1743
1757
  return true;
1744
1758
  }
1745
1759
  return false;
@@ -1758,6 +1772,129 @@ var GameVfx = (() => {
1758
1772
  return [vx2 - into * out.nx, vy2 - into * out.ny, vz2 - into * out.nz];
1759
1773
  }
1760
1774
 
1775
+ // src/pools/puff-cuts.ts
1776
+ var PUFF_REACH = 1.28;
1777
+ var PROBES = [{ x: 1, y: 0, z: 0 }, { x: -1, y: 0, z: 0 }, { x: 0, y: 0, z: 1 }, { x: 0, y: 0, z: -1 }, { x: 0, y: 1, z: 0 }];
1778
+ var PROBES_PER_SECOND = 60;
1779
+ var FRAMES_PER_PROBE = 3;
1780
+ var GROUND_FACING = 0.7;
1781
+ var SAME_WALL = 0.9;
1782
+ var PROBE = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
1783
+ var KeptCut = class {
1784
+ constructor() {
1785
+ __publicField(this, "on", false);
1786
+ __publicField(this, "nx", 0.5);
1787
+ __publicField(this, "ny", 0.5);
1788
+ __publicField(this, "nz", 0.5);
1789
+ __publicField(this, "d", 0.5);
1790
+ }
1791
+ };
1792
+ function createCut() {
1793
+ return new KeptCut();
1794
+ }
1795
+ function clearCuts(puff3) {
1796
+ puff3.cuts[0].on = false;
1797
+ puff3.cuts[1].on = false;
1798
+ }
1799
+ var WrittenWay = class {
1800
+ constructor() {
1801
+ __publicField(this, "x", 0.5);
1802
+ __publicField(this, "y", 0.5);
1803
+ __publicField(this, "z", 0.5);
1804
+ }
1805
+ };
1806
+ var WAY = new WrittenWay();
1807
+ function probe(confiner, puff3, way) {
1808
+ const reach = puff3.size * PUFF_REACH;
1809
+ if (!(reach > 0)) return false;
1810
+ PROBE.x0 = puff3.x;
1811
+ PROBE.y0 = puff3.y;
1812
+ PROBE.z0 = puff3.z;
1813
+ PROBE.x1 = puff3.x + way.x * reach;
1814
+ PROBE.y1 = puff3.y + way.y * reach;
1815
+ PROBE.z1 = puff3.z + way.z * reach;
1816
+ PROBE.pad = 0;
1817
+ return confiner.confineMove(PROBE, 0) && confiner.out.ny <= GROUND_FACING;
1818
+ }
1819
+ var isFartherFrom = (puff3, a, b) => a.nx * puff3.x + a.ny * puff3.y + a.nz * puff3.z - a.d > b.nx * puff3.x + b.ny * puff3.y + b.nz * puff3.z - b.d;
1820
+ var isBehind = (puff3, face) => face.nx * puff3.x + face.ny * puff3.y + face.nz * puff3.z < face.d;
1821
+ var sameWall = (cut, face) => cut.on && cut.nx * face.nx + cut.ny * face.ny + cut.nz * face.nz > SAME_WALL;
1822
+ function cutFor(puff3, face) {
1823
+ const first = puff3.cuts[0];
1824
+ const second = puff3.cuts[1];
1825
+ if (sameWall(first, face)) return first;
1826
+ if (sameWall(second, face)) return second;
1827
+ if (!first.on) return first;
1828
+ if (!second.on) return second;
1829
+ const farther = isFartherFrom(puff3, first, second) ? first : second;
1830
+ return isFartherFrom(puff3, farther, face) ? farther : void 0;
1831
+ }
1832
+ function cutAtFace(puff3, face) {
1833
+ if (face.ny > GROUND_FACING) return;
1834
+ const cut = cutFor(puff3, face);
1835
+ if (!cut) return;
1836
+ cut.on = true;
1837
+ cut.nx = face.nx;
1838
+ cut.ny = face.ny;
1839
+ cut.nz = face.nz;
1840
+ cut.d = face.d;
1841
+ }
1842
+ function cutFrom(puff3, out) {
1843
+ cutAtFace(puff3, out);
1844
+ }
1845
+ function cutAt(confiner, puff3, way) {
1846
+ if (!probe(confiner, puff3, way)) return false;
1847
+ cutAtFace(puff3, confiner.out);
1848
+ return true;
1849
+ }
1850
+ function backward(puff3) {
1851
+ const speed = Math.sqrt(puff3.vx * puff3.vx + puff3.vy * puff3.vy + puff3.vz * puff3.vz);
1852
+ if (!(speed > 0)) return null;
1853
+ WAY.x = -puff3.vx / speed;
1854
+ WAY.y = -puff3.vy / speed;
1855
+ WAY.z = -puff3.vz / speed;
1856
+ return WAY;
1857
+ }
1858
+ function along(cut, sign) {
1859
+ WAY.x = sign * cut.nx;
1860
+ WAY.y = sign * cut.ny;
1861
+ WAY.z = sign * cut.nz;
1862
+ return WAY;
1863
+ }
1864
+ function dropPassed(confiner, puff3) {
1865
+ for (let i = 0; i < 2; i++) {
1866
+ const cut = puff3.cuts[i];
1867
+ if (!cut.on || !isBehind(puff3, cut)) continue;
1868
+ cut.on = false;
1869
+ cutAt(confiner, puff3, along(cut, 1));
1870
+ }
1871
+ }
1872
+ function keep(confiner, puff3, cut) {
1873
+ if (!cut.on) return;
1874
+ if (!probe(confiner, puff3, along(cut, -1))) {
1875
+ cut.on = false;
1876
+ return;
1877
+ }
1878
+ cut.d = confiner.out.d;
1879
+ }
1880
+ function lookForWalls(confiner, puff3) {
1881
+ dropPassed(confiner, puff3);
1882
+ const turn = Math.round(puff3.t * PROBES_PER_SECOND);
1883
+ if (turn <= 1) {
1884
+ const back = backward(puff3);
1885
+ if (back) cutAt(confiner, puff3, back);
1886
+ for (let i = 0; i < PROBES.length; i++) cutAt(confiner, puff3, PROBES[i]);
1887
+ return;
1888
+ }
1889
+ if (turn % FRAMES_PER_PROBE !== 0) return;
1890
+ const slot = turn / FRAMES_PER_PROBE % (PROBES.length + 3);
1891
+ if (slot < 2) keep(confiner, puff3, puff3.cuts[slot]);
1892
+ else if (slot === 2) {
1893
+ const back = backward(puff3);
1894
+ if (back) cutAt(confiner, puff3, back);
1895
+ } else cutAt(confiner, puff3, PROBES[slot - 3]);
1896
+ }
1897
+
1761
1898
  // src/pools/puffs.ts
1762
1899
  var FLOOR_FRACTION = 0.4;
1763
1900
  var FLOOR_BOUNCE = -0.2;
@@ -1798,7 +1935,8 @@ var GameVfx = (() => {
1798
1935
  age: 0,
1799
1936
  heat: 0,
1800
1937
  size: 0,
1801
- source: void 0
1938
+ source: void 0,
1939
+ cuts: [createCut(), createCut()]
1802
1940
  }));
1803
1941
  }
1804
1942
  function spawnPuff(pool, random, init) {
@@ -1832,6 +1970,7 @@ var GameVfx = (() => {
1832
1970
  puff3.heat = 0;
1833
1971
  puff3.size = 0;
1834
1972
  puff3.source = init.source;
1973
+ clearCuts(puff3);
1835
1974
  return puff3;
1836
1975
  }
1837
1976
  function ageOrKeep2(puff3, dt) {
@@ -1881,17 +2020,21 @@ var GameVfx = (() => {
1881
2020
  MOVE.z0 = puff3.z;
1882
2021
  if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
1883
2022
  else moveFree(puff3, dt, age, heat, wind);
1884
- if (confining && CARRIED_KINDS[puff3.kind] && confine(confiner, puff3, dt)) {
2023
+ const carried = confining && CARRIED_KINDS[puff3.kind];
2024
+ if (carried && confine(confiner, puff3, dt)) {
1885
2025
  const out = confiner.out;
1886
2026
  puff3.x = out.x;
1887
2027
  puff3.y = out.y;
1888
2028
  puff3.z = out.z;
1889
2029
  slideInto(out, puff3);
2030
+ cutFrom(puff3, out);
1890
2031
  }
1891
2032
  const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
1892
2033
  puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
1893
2034
  puff3.age = age;
1894
2035
  puff3.heat = heat;
2036
+ if (carried) lookForWalls(confiner, puff3);
2037
+ else clearCuts(puff3);
1895
2038
  }
1896
2039
  }
1897
2040
 
@@ -5019,10 +5162,10 @@ var GameVfx = (() => {
5019
5162
  var MAX_SCALE = 3;
5020
5163
  var MIN_SCALE = 0.6;
5021
5164
  function reflected(direction, normal) {
5022
- const along = direction[0] * normal[0] + direction[1] * normal[1] + direction[2] * normal[2];
5023
- const out = [direction[0] - 2 * along * normal[0], direction[1] - 2 * along * normal[1], direction[2] - 2 * along * normal[2]];
5165
+ const along2 = direction[0] * normal[0] + direction[1] * normal[1] + direction[2] * normal[2];
5166
+ const out = [direction[0] - 2 * along2 * normal[0], direction[1] - 2 * along2 * normal[1], direction[2] - 2 * along2 * normal[2]];
5024
5167
  const length = Math.hypot(out[0], out[1], out[2]);
5025
- if (length < 1e-6 || Math.abs(along) > 0.98) return normal;
5168
+ if (length < 1e-6 || Math.abs(along2) > 0.98) return normal;
5026
5169
  return [out[0] / length, out[1] / length, out[2] / length];
5027
5170
  }
5028
5171
  var numberOr = (value, fallback2) => typeof value === "number" && Number.isFinite(value) ? value : fallback2;
@@ -5999,7 +6142,7 @@ var GameVfx = (() => {
5999
6142
  spawnShock(core.shocks, spec);
6000
6143
  }
6001
6144
  function composeDust(context) {
6002
- const { core, def, random, x, z, size, scale } = context;
6145
+ const { core, def, random, x, y, z, size, scale } = context;
6003
6146
  if (!core.layers.smoke || !def.dust.count || !(scale > 0.15)) return;
6004
6147
  const count = Math.round(def.dust.count * scale);
6005
6148
  const color = hexToLinearRgb(def.dust.color);
@@ -6029,7 +6172,7 @@ var GameVfx = (() => {
6029
6172
  color,
6030
6173
  kind: 1
6031
6174
  });
6032
- bornFrom(core, dust, x, 0.15, z);
6175
+ bornFrom(core, dust, x, y, z);
6033
6176
  }
6034
6177
  }
6035
6178
  function coneAngle(context) {
@@ -6366,6 +6509,9 @@ var GameVfx = (() => {
6366
6509
 
6367
6510
  // src/sprites/kind-pool.ts
6368
6511
  var PAD_OF_SIZE2 = 0.35;
6512
+ var STEP = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
6513
+ var GROUND_RESAMPLE = 0.1;
6514
+ var VELOCITY = { vx: 0.5, vy: 0.5, vz: 0.5 };
6369
6515
  var clamp4 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
6370
6516
  var lerp4 = (a, b, t) => a + (b - a) * t;
6371
6517
  function rgb(hex) {
@@ -6413,6 +6559,8 @@ var GameVfx = (() => {
6413
6559
  __publicField(this, "bounced");
6414
6560
  __publicField(this, "floor");
6415
6561
  __publicField(this, "riseMul");
6562
+ /** The ground under each sprite as last asked (`GROUND_RESAMPLE`): x and z where it was asked, and its height. NaN x: not asked yet. */
6563
+ __publicField(this, "ground");
6416
6564
  const n = Math.max(1, capacity);
6417
6565
  this.position = new Float32Array(n * 3);
6418
6566
  this.color = new Float32Array(n * 3);
@@ -6435,6 +6583,7 @@ var GameVfx = (() => {
6435
6583
  this.bounced = new Uint8Array(n);
6436
6584
  this.floor = new Float32Array(n);
6437
6585
  this.riseMul = new Float32Array(n);
6586
+ this.ground = new Float32Array(n * 3);
6438
6587
  }
6439
6588
  spawn(kind, p, v, random, options) {
6440
6589
  if (this.capacity <= 0) return;
@@ -6462,6 +6611,7 @@ var GameVfx = (() => {
6462
6611
  this.bounced[i] = 0;
6463
6612
  this.floor[i] = options?.floor ?? Number.NaN;
6464
6613
  this.riseMul[i] = options?.rise ?? 1;
6614
+ this.ground[i * 3] = Number.NaN;
6465
6615
  this.size[i] = this.size0[i];
6466
6616
  this.alpha[i] = 0;
6467
6617
  }
@@ -6555,18 +6705,36 @@ var GameVfx = (() => {
6555
6705
  let z = this.position[i3 + 2] + vz2 * dt;
6556
6706
  const confiner = host.confiner;
6557
6707
  if (def.carried && confiner && !confiner.empty) {
6558
- const pad = this.size0[i] * lerp4(1, def.grow, t) * PAD_OF_SIZE2;
6559
- if (confiner.confine(this.position[i3], this.position[i3 + 1], this.position[i3 + 2], x, y, z, pad, dt)) {
6708
+ STEP.x0 = this.position[i3];
6709
+ STEP.y0 = this.position[i3 + 1];
6710
+ STEP.z0 = this.position[i3 + 2];
6711
+ STEP.x1 = x;
6712
+ STEP.y1 = y;
6713
+ STEP.z1 = z;
6714
+ STEP.pad = this.size0[i] * (1 + (def.grow - 1) * t) * PAD_OF_SIZE2;
6715
+ if (confiner.confineMove(STEP, dt)) {
6560
6716
  const out = confiner.out;
6561
6717
  x = out.x;
6562
6718
  y = out.y;
6563
6719
  z = out.z;
6564
- [vx2, vy2, vz2] = slideAlong(out, vx2, vy2, vz2);
6720
+ VELOCITY.vx = vx2;
6721
+ VELOCITY.vy = vy2;
6722
+ VELOCITY.vz = vz2;
6723
+ slideInto(out, VELOCITY);
6724
+ vx2 = VELOCITY.vx;
6725
+ vy2 = VELOCITY.vy;
6726
+ vz2 = VELOCITY.vz;
6565
6727
  }
6566
6728
  }
6567
6729
  if (def.ground !== "none") {
6568
6730
  const own = this.floor[i];
6569
- const gy = Number.isNaN(own) ? host.groundAt(x, z) + 5e-3 : own;
6731
+ const ground = this.ground;
6732
+ if (Number.isNaN(own) && !(Math.abs(x - ground[i3]) < GROUND_RESAMPLE && Math.abs(z - ground[i3 + 1]) < GROUND_RESAMPLE)) {
6733
+ ground[i3] = x;
6734
+ ground[i3 + 1] = z;
6735
+ ground[i3 + 2] = host.groundAt(x, z);
6736
+ }
6737
+ const gy = Number.isNaN(own) ? ground[i3 + 2] + 5e-3 : own;
6570
6738
  if (y < gy) {
6571
6739
  if (def.ground === "land") {
6572
6740
  const tag = this.tag[i];
@@ -7438,10 +7606,10 @@ var GameVfx = (() => {
7438
7606
  if (particle.fade) particle.opacity = Math.max(0, particle.startOpacity * (1 - particle.age / particle.life));
7439
7607
  particle.vy -= particle.gravity * dt;
7440
7608
  if (particle.drag) {
7441
- const keep = Math.max(0, 1 - particle.drag * dt);
7442
- particle.vx *= keep;
7443
- particle.vy *= keep;
7444
- particle.vz *= keep;
7609
+ const keep2 = Math.max(0, 1 - particle.drag * dt);
7610
+ particle.vx *= keep2;
7611
+ particle.vy *= keep2;
7612
+ particle.vz *= keep2;
7445
7613
  }
7446
7614
  if (particle.carried) this.ride(particle, dt);
7447
7615
  else {
@@ -8300,10 +8468,10 @@ var GameVfx = (() => {
8300
8468
  for (let index = fires.items.length - 1; index >= 0; index--) if (fires.items[index].handle === handle) fires.removeAt(index);
8301
8469
  },
8302
8470
  clearSource(source) {
8303
- const keep = (record, gone) => record.source !== gone;
8471
+ const keep2 = (record, gone) => record.source !== gone;
8304
8472
  const drop = (pool) => {
8305
8473
  const before = pool.count;
8306
- pool.compact(keep, source);
8474
+ pool.compact(keep2, source);
8307
8475
  return before - pool.count;
8308
8476
  };
8309
8477
  return drop(core.fires) + drop(core.puffs) + drop(core.sparks) + drop(core.chunks) + drop(core.glows) + spriteSystem.clearSource(source);
@@ -9477,10 +9645,10 @@ var GameVfx = (() => {
9477
9645
  function moveDrop(drop, context) {
9478
9646
  const { dt } = context;
9479
9647
  drop.age += dt;
9480
- const keep = Math.exp(-DROP_DRAG * dt);
9481
- drop.vx *= keep;
9482
- drop.vz *= keep;
9483
- drop.vy = drop.vy * keep - WATER_GRAVITY * dt;
9648
+ const keep2 = Math.exp(-DROP_DRAG * dt);
9649
+ drop.vx *= keep2;
9650
+ drop.vz *= keep2;
9651
+ drop.vy = drop.vy * keep2 - WATER_GRAVITY * dt;
9484
9652
  drop.x += drop.vx * dt;
9485
9653
  drop.y += drop.vy * dt;
9486
9654
  drop.z += drop.vz * dt;
@@ -9540,10 +9708,10 @@ var GameVfx = (() => {
9540
9708
  }
9541
9709
  function ageMist(mist, dt) {
9542
9710
  mist.age += dt;
9543
- const keep = Math.exp(-MIST_DRAG * dt);
9544
- mist.vx *= keep;
9545
- mist.vy = mist.vy * keep - 0.15 * dt;
9546
- mist.vz *= keep;
9711
+ const keep2 = Math.exp(-MIST_DRAG * dt);
9712
+ mist.vx *= keep2;
9713
+ mist.vy = mist.vy * keep2 - 0.15 * dt;
9714
+ mist.vz *= keep2;
9547
9715
  mist.x += mist.vx * dt;
9548
9716
  mist.y += mist.vy * dt;
9549
9717
  mist.z += mist.vz * dt;
@@ -9916,10 +10084,10 @@ var GameVfx = (() => {
9916
10084
  const count = Math.min(TRAIL_BUBBLES_MAX, Math.round(plan.profile.bubblesPerMetre * plan.trailLength * context.detail));
9917
10085
  const [ex, ey, ez] = plan.trailEnd;
9918
10086
  for (let index = 0; index < count; index++) {
9919
- const along = random.next() ** 1.6;
9920
- const jitter = 0.01 + 0.02 * along;
9921
- const at3 = [point[0] + (ex - point[0]) * along + random.between(-jitter, jitter), point[1] + (ey - point[1]) * along, point[2] + (ez - point[2]) * along + random.between(-jitter, jitter)];
9922
- addBubble(context, at3, point[1], along * 0.05, random.between(3e-3, 0.01));
10087
+ const along2 = random.next() ** 1.6;
10088
+ const jitter = 0.01 + 0.02 * along2;
10089
+ const at3 = [point[0] + (ex - point[0]) * along2 + random.between(-jitter, jitter), point[1] + (ey - point[1]) * along2, point[2] + (ez - point[2]) * along2 + random.between(-jitter, jitter)];
10090
+ addBubble(context, at3, point[1], along2 * 0.05, random.between(3e-3, 0.01));
9923
10091
  }
9924
10092
  }
9925
10093
  function spawnBlast(context, point, level, plan) {