@adatechnology/game-vfx 0.4.4 → 0.6.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 +99 -2
- package/dist/index.global.js +345 -88
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +345 -88
- 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 {
|
|
@@ -821,6 +896,11 @@ declare class DecalPool {
|
|
|
821
896
|
constructor(context: WorkshopContext);
|
|
822
897
|
add(x: number, y: number, z: number, size: number, color: number, options?: DecalOptions): void;
|
|
823
898
|
clear(): void;
|
|
899
|
+
/**
|
|
900
|
+
* Takes away the marks inside a box: world `center`, `half` extents along the axes of the world `rotation` (a quaternion, x y z w; none means the
|
|
901
|
+
* world axes). The surface they were on is gone (a brick came out of a wall with its bullet holes). Returns how many went.
|
|
902
|
+
*/
|
|
903
|
+
clearInside(center: Vec3Tuple, half: Vec3Tuple, rotation?: readonly [number, number, number, number]): number;
|
|
824
904
|
update(dt: number): void;
|
|
825
905
|
}
|
|
826
906
|
|
|
@@ -932,6 +1012,7 @@ interface DecalFromSprite {
|
|
|
932
1012
|
declare class SpritePool {
|
|
933
1013
|
readonly capacity: number;
|
|
934
1014
|
private readonly context;
|
|
1015
|
+
private readonly carried;
|
|
935
1016
|
count: number;
|
|
936
1017
|
readonly position: Float32Array;
|
|
937
1018
|
readonly velocity: Float32Array;
|
|
@@ -955,7 +1036,8 @@ declare class SpritePool {
|
|
|
955
1036
|
private readonly scalarArrays;
|
|
956
1037
|
private readonly direction;
|
|
957
1038
|
private readonly unit;
|
|
958
|
-
|
|
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);
|
|
959
1041
|
spawn(options: SpriteSpawn): void;
|
|
960
1042
|
kill(index: number): void;
|
|
961
1043
|
clear(): void;
|
|
@@ -1080,6 +1162,8 @@ interface WorkshopOptions {
|
|
|
1080
1162
|
readonly profile?: VfxProfile;
|
|
1081
1163
|
readonly groundAt?: (x: number, z: number) => number;
|
|
1082
1164
|
readonly trace?: WorkshopTrace;
|
|
1165
|
+
/** The closed spaces the smoke and dust sprites go round (`VfxWorld.enclose`). */
|
|
1166
|
+
readonly confiner?: Confiner;
|
|
1083
1167
|
}
|
|
1084
1168
|
/** The default ground of the Workshop scene: a raised kerb 12 cm high between z -4.5 and -2.9 (W29). */
|
|
1085
1169
|
declare function workshopGround(x: number, z: number): number;
|
|
@@ -1436,6 +1520,8 @@ interface SpriteKindDef {
|
|
|
1436
1520
|
readonly ground: SpriteGround;
|
|
1437
1521
|
readonly flutter?: number;
|
|
1438
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;
|
|
1439
1525
|
}
|
|
1440
1526
|
declare const SPRITE_KINDS: Readonly<Record<SpriteKind, SpriteKindDef>>;
|
|
1441
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. */
|
|
@@ -1464,6 +1550,8 @@ interface KindPoolHost {
|
|
|
1464
1550
|
groundAt(x: number, z: number): number;
|
|
1465
1551
|
gravity: number;
|
|
1466
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;
|
|
1467
1555
|
}
|
|
1468
1556
|
/**
|
|
1469
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
|
|
@@ -1518,6 +1606,8 @@ interface SpriteKindSystemOptions {
|
|
|
1518
1606
|
readonly groundAt: (x: number, z: number) => number;
|
|
1519
1607
|
readonly gravity: number;
|
|
1520
1608
|
readonly kinds?: Readonly<Record<string, SpriteKindDef>>;
|
|
1609
|
+
/** The closed spaces the carried kinds go round. */
|
|
1610
|
+
readonly confiner?: Confiner;
|
|
1521
1611
|
}
|
|
1522
1612
|
type LandListener = (x: number, y: number, z: number, color: number, tag: number) => void;
|
|
1523
1613
|
/**
|
|
@@ -1644,6 +1734,13 @@ interface VfxWorld {
|
|
|
1644
1734
|
sprites(): SpriteKindSystem;
|
|
1645
1735
|
/** Pushes the smoke and dust within `radius` of `point` outwards, as fast as `speed` at the centre. */
|
|
1646
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;
|
|
1647
1744
|
stop(handle: number): void;
|
|
1648
1745
|
setLayer(layer: VfxLayer, on: boolean): void;
|
|
1649
1746
|
layer(layer: VfxLayer): boolean;
|
|
@@ -1864,4 +1961,4 @@ declare const SMOKE_COLORS: {
|
|
|
1864
1961
|
readonly gas: Rgb;
|
|
1865
1962
|
};
|
|
1866
1963
|
|
|
1867
|
-
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 };
|