@adatechnology/game-vfx 0.5.0 → 0.7.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 +11 -0
- package/dist/index.d.ts +94 -2
- package/dist/index.global.js +378 -114
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +378 -114
- package/dist/index.js.map +1 -1
- package/package.json +2 -5
package/README.md
CHANGED
|
@@ -77,6 +77,17 @@ is the recipes plus these, what a world plays by default. Texts of every recipe
|
|
|
77
77
|
`vehicle_leak` is the page's pool and drips without the fire and the explosion (`FUEL_LEAK_ONLY`: the same `decal` and `emit` steps); `vehicle_leak_ignited` is the whole sequence (the spark, the fire running along
|
|
78
78
|
the pool to the tank and the blast at 7.2 s), played when the leak catches fire.
|
|
79
79
|
|
|
80
|
+
## Closed spaces (a shut car keeps the smoke out)
|
|
81
|
+
|
|
82
|
+
`world.enclose(id, { center, halfSize, orientation, openings, leak })` declares a closed space: a turned box the smoke, dust, steam and gas do not
|
|
83
|
+
cross. It works on all three particle systems: the puffs (kinds smoke, dust and gas; not blood or bile), the sprite kinds marked `carried`
|
|
84
|
+
(`smoke`, `dust`, `steam`, `ash`) and the Workshop's light normal-blend sprites (`g` under 3). A step that would cross a wall is put back on the
|
|
85
|
+
wall and slides along it; it passes only inside an opening (an opening with a `rate` passes that share per second of what presses on it, like a
|
|
86
|
+
bullet hole), or through a closed wall at `leak` per second (the gaps of a shut door). What starts inside stays inside. A puff stops about a third
|
|
87
|
+
of its size off a wall it is outside of, so its edge does not show through the glass. Call `enclose` again each time the space moves or opens;
|
|
88
|
+
`enclose(id, null)` ends it, and `clear()` keeps the spaces (they are the scene, not effects). The same shape is `Enclosure` of the contracts,
|
|
89
|
+
and `game-vfx-three`'s renderer forwards `EffectSink.enclose` here.
|
|
90
|
+
|
|
80
91
|
## Install
|
|
81
92
|
|
|
82
93
|
```sh
|
package/dist/index.d.ts
CHANGED
|
@@ -479,6 +479,79 @@ interface Chunk {
|
|
|
479
479
|
/** `_hotCol` (L399-400): the colour of a hot piece, blended towards the glow while it is young. */
|
|
480
480
|
declare function colorOfChunk(chunk: Chunk): readonly [number, number, number];
|
|
481
481
|
|
|
482
|
+
/** 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). */
|
|
483
|
+
interface VfxEnclosureBox {
|
|
484
|
+
readonly center: Vec3Like;
|
|
485
|
+
readonly halfSize: Vec3Like;
|
|
486
|
+
/** Share per second of what presses on it that gets through (a bullet hole). Absent: open, everything passes. */
|
|
487
|
+
readonly rate?: number;
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* 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`
|
|
491
|
+
* and seep at `leak` elsewhere. The same shape as `Enclosure` of `@adatechnology/game-contracts`.
|
|
492
|
+
*/
|
|
493
|
+
interface VfxEnclosure {
|
|
494
|
+
readonly center: Vec3Like;
|
|
495
|
+
readonly halfSize: Vec3Like;
|
|
496
|
+
/** Unit quaternion `[x, y, z, w]` (default not turned). */
|
|
497
|
+
readonly orientation?: readonly [number, number, number, number];
|
|
498
|
+
readonly openings?: readonly VfxEnclosureBox[];
|
|
499
|
+
/** Share per second of what presses on a closed wall that seeps through (default 0: sealed). */
|
|
500
|
+
readonly leak?: number;
|
|
501
|
+
}
|
|
502
|
+
/** 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. */
|
|
503
|
+
interface ConfineResult {
|
|
504
|
+
x: number;
|
|
505
|
+
y: number;
|
|
506
|
+
z: number;
|
|
507
|
+
/** Unit normal of the wall, pointing back to where the particle came from: the caller takes the velocity into it away. */
|
|
508
|
+
nx: number;
|
|
509
|
+
ny: number;
|
|
510
|
+
nz: number;
|
|
511
|
+
}
|
|
512
|
+
/** Stops what the air carries at the walls of the closed spaces. `confine` answers `true` and fills `out` when a step was stopped. */
|
|
513
|
+
interface Confiner {
|
|
514
|
+
/** No space is declared: callers skip the work. */
|
|
515
|
+
readonly empty: boolean;
|
|
516
|
+
/**
|
|
517
|
+
* 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
|
|
518
|
+
* walls (a puff is a ball, not a point: its middle stops before its edge goes through the glass).
|
|
519
|
+
*/
|
|
520
|
+
confine(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, pad: number, dt: number): boolean;
|
|
521
|
+
readonly out: ConfineResult;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* 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
|
|
525
|
+
* 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.
|
|
526
|
+
*/
|
|
527
|
+
declare class Enclosures implements Confiner {
|
|
528
|
+
private readonly spaces;
|
|
529
|
+
private list;
|
|
530
|
+
private readonly random;
|
|
531
|
+
readonly out: ConfineResult;
|
|
532
|
+
private readonly l0;
|
|
533
|
+
private readonly l1;
|
|
534
|
+
private readonly q;
|
|
535
|
+
constructor(seed?: number);
|
|
536
|
+
get empty(): boolean;
|
|
537
|
+
get size(): number;
|
|
538
|
+
/** Declares, moves or (with `null`) ends the space `id`. */
|
|
539
|
+
set(id: string, enclosure: VfxEnclosure | null): void;
|
|
540
|
+
get(id: string): VfxEnclosure | undefined;
|
|
541
|
+
ids(): string[];
|
|
542
|
+
clear(): void;
|
|
543
|
+
/** Whether a point is inside any space (on the inside of its walls). */
|
|
544
|
+
inside(x: number, y: number, z: number): boolean;
|
|
545
|
+
private toLocal;
|
|
546
|
+
/** Passes at `rate` per second. */
|
|
547
|
+
private chance;
|
|
548
|
+
/** The opening the wall point `q` (local) is in lets it through now. */
|
|
549
|
+
private through;
|
|
550
|
+
confine(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, pad: number, dt: number): boolean;
|
|
551
|
+
}
|
|
552
|
+
/** Takes the part of a velocity that runs into the wall away (what is left slides along it). */
|
|
553
|
+
declare function slideAlong(out: ConfineResult, vx: number, vy: number, vz: number): [number, number, number];
|
|
554
|
+
|
|
482
555
|
/** The ring a mushroom cloud's puffs travel on (L722-735). */
|
|
483
556
|
interface Ring {
|
|
484
557
|
x: number;
|
|
@@ -754,6 +827,8 @@ interface WorkshopContext {
|
|
|
754
827
|
mult: number;
|
|
755
828
|
};
|
|
756
829
|
readonly trace: WorkshopTrace | undefined;
|
|
830
|
+
/** The closed spaces the carried sprites (smoke, dust, steam) do not cross; absent: none. */
|
|
831
|
+
readonly confiner?: Confiner;
|
|
757
832
|
}
|
|
758
833
|
|
|
759
834
|
interface DebrisPiece {
|
|
@@ -937,6 +1012,7 @@ interface DecalFromSprite {
|
|
|
937
1012
|
declare class SpritePool {
|
|
938
1013
|
readonly capacity: number;
|
|
939
1014
|
private readonly context;
|
|
1015
|
+
private readonly carried;
|
|
940
1016
|
count: number;
|
|
941
1017
|
readonly position: Float32Array;
|
|
942
1018
|
readonly velocity: Float32Array;
|
|
@@ -960,7 +1036,8 @@ declare class SpritePool {
|
|
|
960
1036
|
private readonly scalarArrays;
|
|
961
1037
|
private readonly direction;
|
|
962
1038
|
private readonly unit;
|
|
963
|
-
|
|
1039
|
+
/** `carried`: the normal-blend pool (smoke, dust, steam), whose light sprites go round the closed spaces; the additive one (flames, sparks) does not. */
|
|
1040
|
+
constructor(capacity: number, context: WorkshopContext, carried?: boolean);
|
|
964
1041
|
spawn(options: SpriteSpawn): void;
|
|
965
1042
|
kill(index: number): void;
|
|
966
1043
|
clear(): void;
|
|
@@ -1085,6 +1162,8 @@ interface WorkshopOptions {
|
|
|
1085
1162
|
readonly profile?: VfxProfile;
|
|
1086
1163
|
readonly groundAt?: (x: number, z: number) => number;
|
|
1087
1164
|
readonly trace?: WorkshopTrace;
|
|
1165
|
+
/** The closed spaces the smoke and dust sprites go round (`VfxWorld.enclose`). */
|
|
1166
|
+
readonly confiner?: Confiner;
|
|
1088
1167
|
}
|
|
1089
1168
|
/** The default ground of the Workshop scene: a raised kerb 12 cm high between z -4.5 and -2.9 (W29). */
|
|
1090
1169
|
declare function workshopGround(x: number, z: number): number;
|
|
@@ -1441,6 +1520,8 @@ interface SpriteKindDef {
|
|
|
1441
1520
|
readonly ground: SpriteGround;
|
|
1442
1521
|
readonly flutter?: number;
|
|
1443
1522
|
readonly flicker?: number;
|
|
1523
|
+
/** Carried by the air (smoke, dust, steam, ash): a closed space (`VfxWorld.enclose`, a shut car) keeps it out, or in. */
|
|
1524
|
+
readonly carried?: boolean;
|
|
1444
1525
|
}
|
|
1445
1526
|
declare const SPRITE_KINDS: Readonly<Record<SpriteKind, SpriteKindDef>>;
|
|
1446
1527
|
/** A copy of the kinds with some changed (a partial replaces the fields it names), added or removed (`null`); a game tunes its sprites without touching the core. */
|
|
@@ -1469,6 +1550,8 @@ interface KindPoolHost {
|
|
|
1469
1550
|
groundAt(x: number, z: number): number;
|
|
1470
1551
|
gravity: number;
|
|
1471
1552
|
land(owner: string, x: number, y: number, z: number, color: number, tag: number): void;
|
|
1553
|
+
/** The closed spaces the carried kinds (`SpriteKindDef.carried`) go round. */
|
|
1554
|
+
confiner?: Confiner;
|
|
1472
1555
|
}
|
|
1473
1556
|
/**
|
|
1474
1557
|
* One fixed-size ring of sprites of the game's kinds, in typed arrays a renderer draws as points: `position`, `color`, `alpha` and `size` are what it
|
|
@@ -1523,6 +1606,8 @@ interface SpriteKindSystemOptions {
|
|
|
1523
1606
|
readonly groundAt: (x: number, z: number) => number;
|
|
1524
1607
|
readonly gravity: number;
|
|
1525
1608
|
readonly kinds?: Readonly<Record<string, SpriteKindDef>>;
|
|
1609
|
+
/** The closed spaces the carried kinds go round. */
|
|
1610
|
+
readonly confiner?: Confiner;
|
|
1526
1611
|
}
|
|
1527
1612
|
type LandListener = (x: number, y: number, z: number, color: number, tag: number) => void;
|
|
1528
1613
|
/**
|
|
@@ -1649,6 +1734,13 @@ interface VfxWorld {
|
|
|
1649
1734
|
sprites(): SpriteKindSystem;
|
|
1650
1735
|
/** Pushes the smoke and dust within `radius` of `point` outwards, as fast as `speed` at the centre. */
|
|
1651
1736
|
push(point: Vec3Like, radius: number, speed: number): void;
|
|
1737
|
+
/**
|
|
1738
|
+
* Declares, moves or (with `null`) ends the closed space `id` (a shut car's cabin, a closed room): the smoke, dust, steam and gas of every pool go
|
|
1739
|
+
* 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.
|
|
1740
|
+
*/
|
|
1741
|
+
enclose(id: string, enclosure: VfxEnclosure | null): void;
|
|
1742
|
+
/** The closed spaces declared now. */
|
|
1743
|
+
enclosures(): Enclosures;
|
|
1652
1744
|
stop(handle: number): void;
|
|
1653
1745
|
setLayer(layer: VfxLayer, on: boolean): void;
|
|
1654
1746
|
layer(layer: VfxLayer): boolean;
|
|
@@ -1869,4 +1961,4 @@ declare const SMOKE_COLORS: {
|
|
|
1869
1961
|
readonly gas: Rgb;
|
|
1870
1962
|
};
|
|
1871
1963
|
|
|
1872
|
-
export { AREA_CAP_GAME, type AreaCap, type AreaCapTracker, type Behavior, type BehaviorHost, type BlastLight, type BloodMark, type Chunk, type CueRequest, 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 EffectView, type ExplosionCall, type ExplosionDef, type ExplosionOptions, type Fire, 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, type Mark, type MarkEvent, type MarkStore, type MeshParticle, MeshPool, type MeshShape, type MeshSpawn, type MushroomSpec, type MutableVec3, OrderedPool, PROFILES, type Placement, type PlayOptions, type PostProcess, type Puddle, type Puff, type Quaternion, RAIN_CAPACITY, RainField, type RandomStream, type Rgb, type Ring, type RockMark, SMOKE_COLORS, SPRITE_KINDS, type Schedule, type ScorchMark, 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 VfxLayer, type VfxLocale, type VfxOptions, type VfxPoolsView, type VfxProfile, type VfxProfileName, type VfxSideRequest, type VfxStats, type VfxStrings, type VfxTrace, type VfxWorld, WORKSHOP_BEHAVIORS, WORKSHOP_EFFECTS, WORKSHOP_PUDDLES, type WorkshopContext, WorkshopEngine, type WorkshopOptions, type WorkshopTrace, colorOfChunk, composeExplosion, createAreaCap, createEffectPlayer, createGroundField, createSchedule, createScreenState, createVfx, createWorkshopBehaviors, effectForEvent, estimateCost, hexToLinearRgb, hexToRgb, inPuddle, lcg, lehmer, locales, lodScale, patchEffects, patchExplosions, patchSpriteKinds, resolveStrings, streamFor, updateScreen, workshopGround };
|
|
1964
|
+
export { AREA_CAP_GAME, type AreaCap, type AreaCapTracker, type Behavior, type BehaviorHost, type BlastLight, type BloodMark, type Chunk, type ConfineResult, type Confiner, type CueRequest, 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 EffectView, Enclosures, type ExplosionCall, type ExplosionDef, type ExplosionOptions, type Fire, 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, type Mark, type MarkEvent, type MarkStore, type MeshParticle, MeshPool, type MeshShape, type MeshSpawn, type MushroomSpec, type MutableVec3, OrderedPool, PROFILES, type Placement, type PlayOptions, type PostProcess, type Puddle, type Puff, type Quaternion, RAIN_CAPACITY, RainField, type RandomStream, type Rgb, type Ring, type RockMark, SMOKE_COLORS, SPRITE_KINDS, type Schedule, type ScorchMark, 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, WORKSHOP_BEHAVIORS, WORKSHOP_EFFECTS, WORKSHOP_PUDDLES, type WorkshopContext, WorkshopEngine, type WorkshopOptions, type WorkshopTrace, colorOfChunk, composeExplosion, createAreaCap, createEffectPlayer, createGroundField, createSchedule, createScreenState, createVfx, createWorkshopBehaviors, effectForEvent, estimateCost, hexToLinearRgb, hexToRgb, inPuddle, lcg, lehmer, locales, lodScale, patchEffects, patchExplosions, patchSpriteKinds, resolveStrings, slideAlong, streamFor, updateScreen, workshopGround };
|