@adatechnology/game-vfx 0.17.0 → 0.18.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 +6 -0
- package/dist/index.d.ts +113 -95
- package/dist/index.global.js +94 -7
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +94 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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,111 @@ 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
|
+
}
|
|
314
|
+
/** One particle's step for {@link Confiner.confineMove}: from `(x0, y0, z0)` to `(x1, y1, z1)`, kept `pad` metres off the walls. */
|
|
315
|
+
interface ConfineMove {
|
|
316
|
+
x0: number;
|
|
317
|
+
y0: number;
|
|
318
|
+
z0: number;
|
|
319
|
+
x1: number;
|
|
320
|
+
y1: number;
|
|
321
|
+
z1: number;
|
|
322
|
+
pad: number;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* 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
|
|
326
|
+
* `(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
|
|
327
|
+
* 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.
|
|
328
|
+
*/
|
|
329
|
+
type VfxSolidQuery = (move: Readonly<ConfineMove>, hit: ConfineResult) => boolean;
|
|
330
|
+
|
|
331
|
+
/** 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). */
|
|
332
|
+
interface VfxEnclosureBox {
|
|
333
|
+
readonly center: Vec3Like;
|
|
334
|
+
readonly halfSize: Vec3Like;
|
|
335
|
+
/** Share per second of what presses on it that gets through (a bullet hole). Absent: open, everything passes. */
|
|
336
|
+
readonly rate?: number;
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* 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`
|
|
340
|
+
* and seep at `leak` elsewhere. The same shape as `Enclosure` of `@adatechnology/game-contracts`.
|
|
341
|
+
*/
|
|
342
|
+
interface VfxEnclosure {
|
|
343
|
+
readonly center: Vec3Like;
|
|
344
|
+
readonly halfSize: Vec3Like;
|
|
345
|
+
/** Unit quaternion `[x, y, z, w]` (default not turned). */
|
|
346
|
+
readonly orientation?: readonly [number, number, number, number];
|
|
347
|
+
readonly openings?: readonly VfxEnclosureBox[];
|
|
348
|
+
/** Share per second of what presses on a closed wall that seeps through (default 0: sealed). */
|
|
349
|
+
readonly leak?: number;
|
|
350
|
+
}
|
|
351
|
+
/** Stops what the air carries at the walls of the closed spaces. `confine` answers `true` and fills `out` when a step was stopped. */
|
|
352
|
+
interface Confiner {
|
|
353
|
+
/** No space is declared: callers skip the work. */
|
|
354
|
+
readonly empty: boolean;
|
|
355
|
+
/**
|
|
356
|
+
* 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
|
|
357
|
+
* walls (a puff is a ball, not a point: its middle stops before its edge goes through the glass).
|
|
358
|
+
*/
|
|
359
|
+
confine(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, pad: number, dt: number): boolean;
|
|
360
|
+
/** `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. */
|
|
361
|
+
confineMove(move: ConfineMove, dt: number): boolean;
|
|
362
|
+
readonly out: ConfineResult;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* 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
|
|
366
|
+
* 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.
|
|
367
|
+
*/
|
|
368
|
+
declare class Enclosures implements Confiner {
|
|
369
|
+
private readonly spaces;
|
|
370
|
+
private list;
|
|
371
|
+
private readonly random;
|
|
372
|
+
readonly out: ConfineResult;
|
|
373
|
+
private readonly l0;
|
|
374
|
+
private readonly l1;
|
|
375
|
+
private readonly q;
|
|
376
|
+
private readonly h;
|
|
377
|
+
private readonly move;
|
|
378
|
+
private readonly solids;
|
|
379
|
+
constructor(seed?: number);
|
|
380
|
+
get empty(): boolean;
|
|
381
|
+
/** 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. */
|
|
382
|
+
solid(id: string, query: VfxSolidQuery | null): void;
|
|
383
|
+
get size(): number;
|
|
384
|
+
/** Declares, moves or (with `null`) ends the space `id`. */
|
|
385
|
+
set(id: string, enclosure: VfxEnclosure | null): void;
|
|
386
|
+
get(id: string): VfxEnclosure | undefined;
|
|
387
|
+
ids(): string[];
|
|
388
|
+
clear(): void;
|
|
389
|
+
/** Whether a point is inside any space (on the inside of its walls). */
|
|
390
|
+
inside(x: number, y: number, z: number): boolean;
|
|
391
|
+
private toLocal;
|
|
392
|
+
/** Passes at `rate` per second. */
|
|
393
|
+
private chance;
|
|
394
|
+
/** The opening the wall point `q` (local) is in lets it through now. */
|
|
395
|
+
private through;
|
|
396
|
+
confine(x0: number, y0: number, z0: number, x1: number, y1: number, z1: number, pad: number, dt: number): boolean;
|
|
397
|
+
confineMove(move: ConfineMove, dt: number): boolean;
|
|
398
|
+
private confineSpaces;
|
|
399
|
+
}
|
|
400
|
+
/** {@link slideAlong} written back into the particle's own velocity, nothing allocated. */
|
|
401
|
+
declare function slideInto(out: ConfineResult, velocity: {
|
|
402
|
+
vx: number;
|
|
403
|
+
vy: number;
|
|
404
|
+
vz: number;
|
|
405
|
+
}): void;
|
|
406
|
+
/** Takes the part of a velocity that runs into the wall away (what is left slides along it). */
|
|
407
|
+
declare function slideAlong(out: ConfineResult, vx: number, vy: number, vz: number): [number, number, number];
|
|
408
|
+
|
|
304
409
|
interface GroundFieldOptions {
|
|
305
410
|
/** Side of the deformable patch in metres (the Lab's 60). */
|
|
306
411
|
readonly size?: number;
|
|
@@ -514,100 +619,6 @@ interface Chunk {
|
|
|
514
619
|
/** `_hotCol` (L399-400): the colour of a hot piece, blended towards the glow while it is young. */
|
|
515
620
|
declare function colorOfChunk(chunk: Chunk): readonly [number, number, number];
|
|
516
621
|
|
|
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. */
|
|
543
|
-
nx: number;
|
|
544
|
-
ny: number;
|
|
545
|
-
nz: number;
|
|
546
|
-
}
|
|
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];
|
|
610
|
-
|
|
611
622
|
/** The ring a mushroom cloud's puffs travel on (L722-735). */
|
|
612
623
|
interface Ring {
|
|
613
624
|
x: number;
|
|
@@ -733,6 +744,8 @@ type RandomMode = 'per_event' | 'shared';
|
|
|
733
744
|
/** 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
745
|
interface VfxCore {
|
|
735
746
|
readonly profile: VfxProfile;
|
|
747
|
+
/** The closed spaces and host solids what the air carries stops at (`VfxWorld.enclose`, `VfxWorld.solid`). */
|
|
748
|
+
readonly confiner: Confiner;
|
|
736
749
|
readonly puffs: OrderedPool<Puff>;
|
|
737
750
|
readonly sparks: OrderedPool<Spark>;
|
|
738
751
|
readonly glows: OrderedPool<Glow>;
|
|
@@ -1904,6 +1917,11 @@ interface VfxWorld {
|
|
|
1904
1917
|
* 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
1918
|
*/
|
|
1906
1919
|
enclose(id: string, enclosure: VfxEnclosure | null): void;
|
|
1920
|
+
/**
|
|
1921
|
+
* 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,
|
|
1922
|
+
* and the smoke an explosion throws out, stop at them and slide along, passing only through their holes. See {@link VfxSolidQuery}.
|
|
1923
|
+
*/
|
|
1924
|
+
solid(id: string, query: VfxSolidQuery | null): void;
|
|
1907
1925
|
/** The closed spaces declared now. */
|
|
1908
1926
|
enclosures(): Enclosures;
|
|
1909
1927
|
stop(handle: number): void;
|
|
@@ -2502,4 +2520,4 @@ declare function resolveWaterShotProfile(profile: string | WaterShotProfile, tab
|
|
|
2502
2520
|
/** Changes a profile table without touching the kit's: `null` removes an entry, a partial entry is merged over the old one. */
|
|
2503
2521
|
declare function patchWaterShotProfiles(base: Readonly<Record<string, WaterShotProfile>>, changes: Readonly<Record<string, Partial<WaterShotProfile> | null>>): Record<string, WaterShotProfile>;
|
|
2504
2522
|
|
|
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 };
|
|
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 };
|
package/dist/index.global.js
CHANGED
|
@@ -1492,8 +1492,61 @@ var GameVfx = (() => {
|
|
|
1492
1492
|
return lehmer(mixEventSeed(eventSeed));
|
|
1493
1493
|
}
|
|
1494
1494
|
|
|
1495
|
-
// src/
|
|
1495
|
+
// src/solids.ts
|
|
1496
1496
|
var SKIN = 5e-3;
|
|
1497
|
+
var Solids = class {
|
|
1498
|
+
constructor() {
|
|
1499
|
+
__publicField(this, "queries", /* @__PURE__ */ new Map());
|
|
1500
|
+
__publicField(this, "list", []);
|
|
1501
|
+
__publicField(this, "hit", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
|
|
1502
|
+
}
|
|
1503
|
+
get empty() {
|
|
1504
|
+
return this.list.length === 0;
|
|
1505
|
+
}
|
|
1506
|
+
/** Declares or (with `null`) ends the solids `id` answers for. */
|
|
1507
|
+
set(id, query2) {
|
|
1508
|
+
if (query2) this.queries.set(id, query2);
|
|
1509
|
+
else this.queries.delete(id);
|
|
1510
|
+
this.list = [...this.queries.values()];
|
|
1511
|
+
}
|
|
1512
|
+
clear() {
|
|
1513
|
+
this.queries.clear();
|
|
1514
|
+
this.list = [];
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
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
|
|
1518
|
+
* the surface's normal. Answers whether the step was stopped.
|
|
1519
|
+
*/
|
|
1520
|
+
stop(move, pad, out) {
|
|
1521
|
+
const dx = move.x1 - move.x0;
|
|
1522
|
+
const dy = move.y1 - move.y0;
|
|
1523
|
+
const dz = move.z1 - move.z0;
|
|
1524
|
+
const length = Math.hypot(dx, dy, dz);
|
|
1525
|
+
if (!(length > 0)) return false;
|
|
1526
|
+
let nearest = Infinity;
|
|
1527
|
+
for (const query2 of this.list) {
|
|
1528
|
+
if (!query2(move, this.hit)) continue;
|
|
1529
|
+
const reached = ((this.hit.x - move.x0) * dx + (this.hit.y - move.y0) * dy + (this.hit.z - move.z0) * dz) / length;
|
|
1530
|
+
if (reached >= nearest) continue;
|
|
1531
|
+
nearest = reached;
|
|
1532
|
+
out.x = this.hit.x;
|
|
1533
|
+
out.y = this.hit.y;
|
|
1534
|
+
out.z = this.hit.z;
|
|
1535
|
+
out.nx = this.hit.nx;
|
|
1536
|
+
out.ny = this.hit.ny;
|
|
1537
|
+
out.nz = this.hit.nz;
|
|
1538
|
+
}
|
|
1539
|
+
if (nearest === Infinity) return false;
|
|
1540
|
+
const back = Math.min(Math.max(pad, 0) + SKIN, Math.max(nearest, 0));
|
|
1541
|
+
out.x -= dx / length * back;
|
|
1542
|
+
out.y -= dy / length * back;
|
|
1543
|
+
out.z -= dz / length * back;
|
|
1544
|
+
return true;
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
|
|
1548
|
+
// src/enclosures.ts
|
|
1549
|
+
var SKIN2 = 5e-3;
|
|
1497
1550
|
var MAX_PAD = 0.45;
|
|
1498
1551
|
function rotation(q) {
|
|
1499
1552
|
const [x, y, z, w] = q ?? [0, 0, 0, 1];
|
|
@@ -1525,10 +1578,15 @@ var GameVfx = (() => {
|
|
|
1525
1578
|
__publicField(this, "q", new Float64Array(3));
|
|
1526
1579
|
__publicField(this, "h", new Float64Array(3));
|
|
1527
1580
|
__publicField(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
|
|
1581
|
+
__publicField(this, "solids", new Solids());
|
|
1528
1582
|
this.random = lehmer(seed);
|
|
1529
1583
|
}
|
|
1530
1584
|
get empty() {
|
|
1531
|
-
return this.list.length === 0;
|
|
1585
|
+
return this.list.length === 0 && this.solids.empty;
|
|
1586
|
+
}
|
|
1587
|
+
/** 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. */
|
|
1588
|
+
solid(id, query2) {
|
|
1589
|
+
this.solids.set(id, query2);
|
|
1532
1590
|
}
|
|
1533
1591
|
get size() {
|
|
1534
1592
|
return this.list.length;
|
|
@@ -1611,6 +1669,10 @@ var GameVfx = (() => {
|
|
|
1611
1669
|
return this.confineMove(move, dt);
|
|
1612
1670
|
}
|
|
1613
1671
|
confineMove(move, dt) {
|
|
1672
|
+
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);
|
|
1674
|
+
}
|
|
1675
|
+
confineSpaces(move, dt) {
|
|
1614
1676
|
const list = this.list;
|
|
1615
1677
|
if (list.length === 0) return false;
|
|
1616
1678
|
const { x0, y0, z0, x1, y1, z1 } = move;
|
|
@@ -1651,7 +1713,7 @@ var GameVfx = (() => {
|
|
|
1651
1713
|
}
|
|
1652
1714
|
}
|
|
1653
1715
|
sign = l1[axis2] < 0 ? -1 : 1;
|
|
1654
|
-
for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] -
|
|
1716
|
+
for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] - SKIN2, Math.max(-(h[a] - SKIN2), l1[a]));
|
|
1655
1717
|
sign = -sign;
|
|
1656
1718
|
} else {
|
|
1657
1719
|
const padded0 = Math.abs(l0[0]) <= s.hx + p && Math.abs(l0[1]) <= s.hy + p && Math.abs(l0[2]) <= s.hz + p;
|
|
@@ -1668,7 +1730,7 @@ var GameVfx = (() => {
|
|
|
1668
1730
|
}
|
|
1669
1731
|
}
|
|
1670
1732
|
sign = l0[axis2] < 0 ? -1 : 1;
|
|
1671
|
-
l1[axis2] = sign * (h[axis2] + bound +
|
|
1733
|
+
l1[axis2] = sign * (h[axis2] + bound + SKIN2);
|
|
1672
1734
|
}
|
|
1673
1735
|
const r = s.r;
|
|
1674
1736
|
const out = this.out;
|
|
@@ -5839,6 +5901,24 @@ var GameVfx = (() => {
|
|
|
5839
5901
|
screen2.flashDecay = 0.5;
|
|
5840
5902
|
}
|
|
5841
5903
|
}
|
|
5904
|
+
var BIRTH = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
|
|
5905
|
+
function bornFrom(core, puff3, ox, oy, oz) {
|
|
5906
|
+
const confiner = core.confiner;
|
|
5907
|
+
if (confiner.empty) return;
|
|
5908
|
+
BIRTH.x0 = ox;
|
|
5909
|
+
BIRTH.y0 = oy;
|
|
5910
|
+
BIRTH.z0 = oz;
|
|
5911
|
+
BIRTH.x1 = puff3.x;
|
|
5912
|
+
BIRTH.y1 = puff3.y;
|
|
5913
|
+
BIRTH.z1 = puff3.z;
|
|
5914
|
+
BIRTH.pad = puff3.s0 * PAD_OF_SIZE;
|
|
5915
|
+
if (!confiner.confineMove(BIRTH, 0)) return;
|
|
5916
|
+
const out = confiner.out;
|
|
5917
|
+
puff3.x = out.x;
|
|
5918
|
+
puff3.y = out.y;
|
|
5919
|
+
puff3.z = out.z;
|
|
5920
|
+
slideInto(out, puff3);
|
|
5921
|
+
}
|
|
5842
5922
|
function composeFireballs(context) {
|
|
5843
5923
|
const { core, def, random, x, y, z, size, scale, direction } = context;
|
|
5844
5924
|
if (!core.layers.fire || !def.fireballs) return;
|
|
@@ -5855,7 +5935,7 @@ var GameVfx = (() => {
|
|
|
5855
5935
|
const life = random.between(def.smoke.life * 0.7, def.smoke.life);
|
|
5856
5936
|
const h0 = random.between(1.05, 1.35) * heat;
|
|
5857
5937
|
const hl = fuel ? random.between(0.8, 1.4) * (def.heatLifeScale ?? 1) : random.between(0.22, 0.42);
|
|
5858
|
-
addPuff(core, random, {
|
|
5938
|
+
const fireball = addPuff(core, random, {
|
|
5859
5939
|
x: x + d.x * size * 0.15,
|
|
5860
5940
|
y: y + size * 0.25 + d.y * size * 0.1,
|
|
5861
5941
|
z: z + d.z * size * 0.15,
|
|
@@ -5874,6 +5954,7 @@ var GameVfx = (() => {
|
|
|
5874
5954
|
color: context.smokeColor,
|
|
5875
5955
|
kind: 0
|
|
5876
5956
|
});
|
|
5957
|
+
bornFrom(core, fireball, x, y, z);
|
|
5877
5958
|
}
|
|
5878
5959
|
}
|
|
5879
5960
|
function composeSmoke(context) {
|
|
@@ -5887,7 +5968,7 @@ var GameVfx = (() => {
|
|
|
5887
5968
|
const s1 = size * random.between(0.55, 0.85);
|
|
5888
5969
|
const sg = size * random.between(0.18, 0.3);
|
|
5889
5970
|
const life = random.between(def.smoke.life * 0.7, def.smoke.life * 1.1);
|
|
5890
|
-
addPuff(core, random, {
|
|
5971
|
+
const smoke = addPuff(core, random, {
|
|
5891
5972
|
x: x + d.x * size * 0.6,
|
|
5892
5973
|
y: y + size * 0.4 + d.y * size * 0.5,
|
|
5893
5974
|
z: z + d.z * size * 0.6,
|
|
@@ -5906,6 +5987,7 @@ var GameVfx = (() => {
|
|
|
5906
5987
|
color: context.smokeColor,
|
|
5907
5988
|
kind: def.smoke.kind ?? 0
|
|
5908
5989
|
});
|
|
5990
|
+
bornFrom(core, smoke, x, y, z);
|
|
5909
5991
|
}
|
|
5910
5992
|
}
|
|
5911
5993
|
function composeShock(context) {
|
|
@@ -5930,7 +6012,7 @@ var GameVfx = (() => {
|
|
|
5930
6012
|
const s1 = size * random.between(0.5, 0.8);
|
|
5931
6013
|
const sg = size * random.between(0.2, 0.35);
|
|
5932
6014
|
const life = random.between(2.2, 4);
|
|
5933
|
-
addPuff(core, random, {
|
|
6015
|
+
const dust = addPuff(core, random, {
|
|
5934
6016
|
x: x + Math.cos(angle) * 0.3,
|
|
5935
6017
|
y: 0.15,
|
|
5936
6018
|
z: z + Math.sin(angle) * 0.3,
|
|
@@ -5947,6 +6029,7 @@ var GameVfx = (() => {
|
|
|
5947
6029
|
color,
|
|
5948
6030
|
kind: 1
|
|
5949
6031
|
});
|
|
6032
|
+
bornFrom(core, dust, x, 0.15, z);
|
|
5950
6033
|
}
|
|
5951
6034
|
}
|
|
5952
6035
|
function coneAngle(context) {
|
|
@@ -8066,6 +8149,7 @@ var GameVfx = (() => {
|
|
|
8066
8149
|
});
|
|
8067
8150
|
const core = {
|
|
8068
8151
|
profile,
|
|
8152
|
+
confiner: enclosures,
|
|
8069
8153
|
puffs: createPuffPool(profile.puffs),
|
|
8070
8154
|
sparks: createSparkPool(profile.sparks),
|
|
8071
8155
|
glows: createGlowPool(profile.glows),
|
|
@@ -8206,6 +8290,9 @@ var GameVfx = (() => {
|
|
|
8206
8290
|
enclose(id, enclosure) {
|
|
8207
8291
|
enclosures.set(id, enclosure);
|
|
8208
8292
|
},
|
|
8293
|
+
solid(id, query2) {
|
|
8294
|
+
enclosures.solid(id, query2);
|
|
8295
|
+
},
|
|
8209
8296
|
enclosures: () => enclosures,
|
|
8210
8297
|
stop(handle) {
|
|
8211
8298
|
player?.stop(handle);
|