@adatechnology/game-vfx 0.17.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/README.md CHANGED
@@ -115,6 +115,12 @@ of its size off a wall it is outside of, so its edge does not show through the g
115
115
  `enclose(id, null)` ends it, and `clear()` keeps the spaces (they are the scene, not effects). The same shape is `Enclosure` of the contracts,
116
116
  and `game-vfx-three`'s renderer forwards `EffectSink.enclose` here.
117
117
 
118
+ `world.solid(id, query)` hands the effects the host's solid world (`VfxSolidQuery`: does this step of a particle go into something solid, and
119
+ where, with which normal). The carried smoke, dust, steam and gas of every pool stop at it and slide along, and an explosion's smoke is born on
120
+ the blast's side of it: a puff thrown across a wall is put back on the near face. A hole in the solid is no solid, so the smoke goes through a
121
+ hole a blast opened and nowhere else. `game-destruction-three`'s renderer declares its destruction world here (`world.raycast`, which passes
122
+ where units were taken out); `solid(id, null)` ends it.
123
+
118
124
  ## Install
119
125
 
120
126
  ```sh
package/dist/index.d.ts CHANGED
@@ -301,6 +301,113 @@ interface Fire {
301
301
  source: string | undefined;
302
302
  }
303
303
 
304
+ /** What a particle that was stopped at a wall ends up with: where it is now and the wall's outward... or inward normal it pressed on, in world space. */
305
+ interface ConfineResult {
306
+ x: number;
307
+ y: number;
308
+ z: number;
309
+ /** Unit normal of the wall, pointing back to where the particle came from: the caller takes the velocity into it away. */
310
+ nx: number;
311
+ ny: number;
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;
315
+ }
316
+ /** One particle's step for {@link Confiner.confineMove}: from `(x0, y0, z0)` to `(x1, y1, z1)`, kept `pad` metres off the walls. */
317
+ interface ConfineMove {
318
+ x0: number;
319
+ y0: number;
320
+ z0: number;
321
+ x1: number;
322
+ y1: number;
323
+ z1: number;
324
+ pad: number;
325
+ }
326
+ /**
327
+ * The host's solid world as the air sees it (the walls, slabs and furniture of a destruction world): whether the straight step of `move` from
328
+ * `(x0, y0, z0)` to `(x1, y1, z1)` goes into something solid. On a hit it fills `hit` with the point where the step meets the solid's surface and
329
+ * that surface's unit normal pointing back to where the step came from, and answers `true`. A hole in the solid is no solid: the step goes through.
330
+ */
331
+ type VfxSolidQuery = (move: Readonly<ConfineMove>, hit: ConfineResult) => boolean;
332
+
333
+ /** A box in the frame of a {@link VfxEnclosure}: offset from its centre along its axes, half size, and how much gets through (absent: open). */
334
+ interface VfxEnclosureBox {
335
+ readonly center: Vec3Like;
336
+ readonly halfSize: Vec3Like;
337
+ /** Share per second of what presses on it that gets through (a bullet hole). Absent: open, everything passes. */
338
+ readonly rate?: number;
339
+ }
340
+ /**
341
+ * A closed space the smoke, dust and steam do not cross (a car cabin, a closed room): a turned box whose walls let them through only at `openings`
342
+ * and seep at `leak` elsewhere. The same shape as `Enclosure` of `@adatechnology/game-contracts`.
343
+ */
344
+ interface VfxEnclosure {
345
+ readonly center: Vec3Like;
346
+ readonly halfSize: Vec3Like;
347
+ /** Unit quaternion `[x, y, z, w]` (default not turned). */
348
+ readonly orientation?: readonly [number, number, number, number];
349
+ readonly openings?: readonly VfxEnclosureBox[];
350
+ /** Share per second of what presses on a closed wall that seeps through (default 0: sealed). */
351
+ readonly leak?: number;
352
+ }
353
+ /** Stops what the air carries at the walls of the closed spaces. `confine` answers `true` and fills `out` when a step was stopped. */
354
+ interface Confiner {
355
+ /** No space is declared: callers skip the work. */
356
+ readonly empty: boolean;
357
+ /**
358
+ * The step of one particle from `(x0, y0, z0)` to `(x1, y1, z1)` over `dt` seconds. `pad` (metres) keeps an outside particle that far off the
359
+ * walls (a puff is a ball, not a point: its middle stops before its edge goes through the glass).
360
+ */
361
+ confine(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, pad: number, dt: number): boolean;
362
+ /** `confine` with the step in an object the caller reuses: eight numbers passed to a call are boxed on the heap, one object is not. `move` is only read during the call: it is not kept. */
363
+ confineMove(move: ConfineMove, dt: number): boolean;
364
+ readonly out: ConfineResult;
365
+ }
366
+ /**
367
+ * The closed spaces of a world by id, and the solids its hosts declare (`solid`). Each step of a carried particle that would cross a wall is tested: through an opening it passes (a hole only at
368
+ * its rate), through a closed wall only at the leak; otherwise it stays on its side, put back on the wall and sliding along it.
369
+ */
370
+ declare class Enclosures implements Confiner {
371
+ private readonly spaces;
372
+ private list;
373
+ private readonly random;
374
+ readonly out: ConfineResult;
375
+ private readonly l0;
376
+ private readonly l1;
377
+ private readonly q;
378
+ private readonly h;
379
+ private readonly move;
380
+ private readonly solids;
381
+ constructor(seed?: number);
382
+ get empty(): boolean;
383
+ /** Declares or (with `null`) ends the host solids `id` answers for (a destruction world's walls): what is carried stops at them and passes only their holes. */
384
+ solid(id: string, query: VfxSolidQuery | null): void;
385
+ get size(): number;
386
+ /** Declares, moves or (with `null`) ends the space `id`. */
387
+ set(id: string, enclosure: VfxEnclosure | null): void;
388
+ get(id: string): VfxEnclosure | undefined;
389
+ ids(): string[];
390
+ clear(): void;
391
+ /** Whether a point is inside any space (on the inside of its walls). */
392
+ inside(x: number, y: number, z: number): boolean;
393
+ private toLocal;
394
+ /** Passes at `rate` per second. */
395
+ private chance;
396
+ /** The opening the wall point `q` (local) is in lets it through now. */
397
+ private through;
398
+ confine(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, pad: number, dt: number): boolean;
399
+ confineMove(move: ConfineMove, dt: number): boolean;
400
+ private confineSpaces;
401
+ }
402
+ /** {@link slideAlong} written back into the particle's own velocity, nothing allocated. */
403
+ declare function slideInto(out: ConfineResult, velocity: {
404
+ vx: number;
405
+ vy: number;
406
+ vz: number;
407
+ }): void;
408
+ /** Takes the part of a velocity that runs into the wall away (what is left slides along it). */
409
+ declare function slideAlong(out: ConfineResult, vx: number, vy: number, vz: number): [number, number, number];
410
+
304
411
  interface GroundFieldOptions {
305
412
  /** Side of the deformable patch in metres (the Lab's 60). */
306
413
  readonly size?: number;
@@ -514,99 +621,16 @@ interface Chunk {
514
621
  /** `_hotCol` (L399-400): the colour of a hot piece, blended towards the glow while it is young. */
515
622
  declare function colorOfChunk(chunk: Chunk): readonly [number, number, number];
516
623
 
517
- /** A box in the frame of a {@link VfxEnclosure}: offset from its centre along its axes, half size, and how much gets through (absent: open). */
518
- interface VfxEnclosureBox {
519
- readonly center: Vec3Like;
520
- readonly halfSize: Vec3Like;
521
- /** Share per second of what presses on it that gets through (a bullet hole). Absent: open, everything passes. */
522
- readonly rate?: number;
523
- }
524
- /**
525
- * A closed space the smoke, dust and steam do not cross (a car cabin, a closed room): a turned box whose walls let them through only at `openings`
526
- * and seep at `leak` elsewhere. The same shape as `Enclosure` of `@adatechnology/game-contracts`.
527
- */
528
- interface VfxEnclosure {
529
- readonly center: Vec3Like;
530
- readonly halfSize: Vec3Like;
531
- /** Unit quaternion `[x, y, z, w]` (default not turned). */
532
- readonly orientation?: readonly [number, number, number, number];
533
- readonly openings?: readonly VfxEnclosureBox[];
534
- /** Share per second of what presses on a closed wall that seeps through (default 0: sealed). */
535
- readonly leak?: number;
536
- }
537
- /** What a particle that was stopped at a wall ends up with: where it is now and the wall's outward... or inward normal it pressed on, in world space. */
538
- interface ConfineResult {
539
- x: number;
540
- y: number;
541
- z: number;
542
- /** Unit normal of the wall, pointing back to where the particle came from: the caller takes the velocity into it away. */
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;
543
627
  nx: number;
544
628
  ny: number;
545
629
  nz: number;
630
+ d: number;
546
631
  }
547
- /** Stops what the air carries at the walls of the closed spaces. `confine` answers `true` and fills `out` when a step was stopped. */
548
- interface Confiner {
549
- /** No space is declared: callers skip the work. */
550
- readonly empty: boolean;
551
- /**
552
- * The step of one particle from `(x0, y0, z0)` to `(x1, y1, z1)` over `dt` seconds. `pad` (metres) keeps an outside particle that far off the
553
- * walls (a puff is a ball, not a point: its middle stops before its edge goes through the glass).
554
- */
555
- confine(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, pad: number, dt: number): boolean;
556
- /** `confine` with the step in an object the caller reuses: eight numbers passed to a call are boxed on the heap, one object is not. `move` is only read during the call: it is not kept. */
557
- confineMove(move: ConfineMove, dt: number): boolean;
558
- readonly out: ConfineResult;
559
- }
560
- /** One particle's step for {@link Confiner.confineMove}: from `(x0, y0, z0)` to `(x1, y1, z1)`, kept `pad` metres off the walls. */
561
- interface ConfineMove {
562
- x0: number;
563
- y0: number;
564
- z0: number;
565
- x1: number;
566
- y1: number;
567
- z1: number;
568
- pad: number;
569
- }
570
- /**
571
- * The closed spaces of a world by id. Each step of a carried particle that would cross a wall is tested: through an opening it passes (a hole only at
572
- * its rate), through a closed wall only at the leak; otherwise it stays on its side, put back on the wall and sliding along it.
573
- */
574
- declare class Enclosures implements Confiner {
575
- private readonly spaces;
576
- private list;
577
- private readonly random;
578
- readonly out: ConfineResult;
579
- private readonly l0;
580
- private readonly l1;
581
- private readonly q;
582
- private readonly h;
583
- private readonly move;
584
- constructor(seed?: number);
585
- get empty(): boolean;
586
- get size(): number;
587
- /** Declares, moves or (with `null`) ends the space `id`. */
588
- set(id: string, enclosure: VfxEnclosure | null): void;
589
- get(id: string): VfxEnclosure | undefined;
590
- ids(): string[];
591
- clear(): void;
592
- /** Whether a point is inside any space (on the inside of its walls). */
593
- inside(x: number, y: number, z: number): boolean;
594
- private toLocal;
595
- /** Passes at `rate` per second. */
596
- private chance;
597
- /** The opening the wall point `q` (local) is in lets it through now. */
598
- private through;
599
- confine(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, pad: number, dt: number): boolean;
600
- confineMove(move: ConfineMove, dt: number): boolean;
601
- }
602
- /** {@link slideAlong} written back into the particle's own velocity, nothing allocated. */
603
- declare function slideInto(out: ConfineResult, velocity: {
604
- vx: number;
605
- vy: number;
606
- vz: number;
607
- }): void;
608
- /** Takes the part of a velocity that runs into the wall away (what is left slides along it). */
609
- declare function slideAlong(out: ConfineResult, vx: number, vy: number, vz: number): [number, number, number];
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;
610
634
 
611
635
  /** The ring a mushroom cloud's puffs travel on (L722-735). */
612
636
  interface Ring {
@@ -657,6 +681,11 @@ interface Puff {
657
681
  size: number;
658
682
  /** The thing it was made for (a burning part's object): `VfxWorld.clearSource` takes it away when that thing leaves. */
659
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];
660
689
  }
661
690
 
662
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. */
@@ -733,6 +762,8 @@ type RandomMode = 'per_event' | 'shared';
733
762
  /** What every part of the effects reads and writes: the pools, lights, screen, marks, clock and the few settings. Internal; the host sees `VfxWorld`. */
734
763
  interface VfxCore {
735
764
  readonly profile: VfxProfile;
765
+ /** The closed spaces and host solids what the air carries stops at (`VfxWorld.enclose`, `VfxWorld.solid`). */
766
+ readonly confiner: Confiner;
736
767
  readonly puffs: OrderedPool<Puff>;
737
768
  readonly sparks: OrderedPool<Spark>;
738
769
  readonly glows: OrderedPool<Glow>;
@@ -1730,6 +1761,8 @@ declare class SpriteKindPool {
1730
1761
  private readonly bounced;
1731
1762
  private readonly floor;
1732
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;
1733
1766
  constructor(capacity: number, defs: readonly SpriteKindDef[], owners: string[], sources?: SpriteSources);
1734
1767
  spawn(kind: number, p: readonly number[], v: readonly number[], random: () => number, options?: SpriteSpawnOptions): void;
1735
1768
  private ownerIndex;
@@ -1904,6 +1937,11 @@ interface VfxWorld {
1904
1937
  * round it and cross its walls only through its openings, or seep at its leak. Call again whenever it moves or opens. `clear` keeps the spaces.
1905
1938
  */
1906
1939
  enclose(id: string, enclosure: VfxEnclosure | null): void;
1940
+ /**
1941
+ * Declares or (with `null`) ends the solids `id` answers for (a destruction world's walls and slabs): the smoke, dust, steam and gas of every pool,
1942
+ * and the smoke an explosion throws out, stop at them and slide along, passing only through their holes. See {@link VfxSolidQuery}.
1943
+ */
1944
+ solid(id: string, query: VfxSolidQuery | null): void;
1907
1945
  /** The closed spaces declared now. */
1908
1946
  enclosures(): Enclosures;
1909
1947
  stop(handle: number): void;
@@ -2502,4 +2540,4 @@ declare function resolveWaterShotProfile(profile: string | WaterShotProfile, tab
2502
2540
  /** Changes a profile table without touching the kit's: `null` removes an entry, a partial entry is merged over the old one. */
2503
2541
  declare function patchWaterShotProfiles(base: Readonly<Record<string, WaterShotProfile>>, changes: Readonly<Record<string, Partial<WaterShotProfile> | null>>): Record<string, WaterShotProfile>;
2504
2542
 
2505
- 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 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 };