@adatechnology/game-vfx 0.11.0 → 0.12.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 +3 -1
- package/dist/index.d.ts +55 -6
- package/dist/index.global.js +105 -15
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +105 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,7 +62,9 @@ material, a place and a turn inside a group, a scale ramp, growth, drag, gravity
|
|
|
62
62
|
the order of the gallery's `Particles`. `play` can also take the thing's whole turn (`orientation`, a unit quaternion, pitch and roll included, instead of the turn
|
|
63
63
|
about the vertical axis `direction` gives) and named numbers (`values`, read with `variable(name)`). `VIEWMODEL_EFFECTS` use all three: the first-person muzzle flash
|
|
64
64
|
(`viewmodel_muzzle_flash`: an open cone, four small cones and a core for 55 ms, a light that holds, six spheres of smoke), `weapon_smoke_puff`, `launcher_backblast` and
|
|
65
|
-
`flame_jet`, written in the weapon's own axes (x along the barrel) with the Arsenal gallery's numbers and the order it drew them in.
|
|
65
|
+
`flame_jet`, written in the weapon's own axes (x along the barrel) with the Arsenal gallery's numbers and the order it drew them in. With `track` (a function
|
|
66
|
+
answering where the thing is now, asked every frame) an effect rides on the thing it belongs to: its grouped pieces and its light keep their place on it (a muzzle
|
|
67
|
+
flash stays on the muzzle the view turns), and the smoke it throws stays in the air; `world.follow()` puts them where the thing is after the frame moved it.
|
|
66
68
|
|
|
67
69
|
`vfx.burst(kind, point, normal, count, speed?)` and `vfx.spawn(kind, point, velocity)` are the **sprite kinds** that destruction, fluids and weapons share
|
|
68
70
|
(debris, sparks, ash, steam, drips, leaks...: `data/sprite-kinds.json`, `patchSpriteKinds`), with `onLand(owner, ...)` to hear where a drop touched the ground.
|
package/dist/index.d.ts
CHANGED
|
@@ -851,6 +851,22 @@ interface WorkshopContext {
|
|
|
851
851
|
readonly confiner?: Confiner;
|
|
852
852
|
}
|
|
853
853
|
|
|
854
|
+
/** A unit quaternion `[x, y, z, w]`. */
|
|
855
|
+
type Quaternion = readonly [number, number, number, number];
|
|
856
|
+
/**
|
|
857
|
+
* The live pose of the thing an effect belongs to (the muzzle of a gun in the hands), moved by whoever plays the effect while it lives: the pieces drawn in
|
|
858
|
+
* its own axes (the cones of a muzzle flash) and its lights ride on it, and what is thrown free (smoke) stays in the world.
|
|
859
|
+
*/
|
|
860
|
+
interface Carrier {
|
|
861
|
+
origin: Vec3Tuple;
|
|
862
|
+
orientation: Quaternion | undefined;
|
|
863
|
+
}
|
|
864
|
+
/** What a piece keeps to ride on a carrier: the carrier and where the piece sits in the recipe's space (from the recipe's anchor). */
|
|
865
|
+
interface Carried {
|
|
866
|
+
readonly carrier: Carrier;
|
|
867
|
+
readonly local: Vec3Tuple;
|
|
868
|
+
}
|
|
869
|
+
|
|
854
870
|
interface DebrisPiece {
|
|
855
871
|
on: boolean;
|
|
856
872
|
x: number;
|
|
@@ -966,8 +982,6 @@ declare class RainField {
|
|
|
966
982
|
private set;
|
|
967
983
|
}
|
|
968
984
|
|
|
969
|
-
/** A unit quaternion `[x, y, z, w]`. */
|
|
970
|
-
type Quaternion = readonly [number, number, number, number];
|
|
971
985
|
/** One solid particle as the pool keeps it; a renderer draws it from these fields and never changes them. */
|
|
972
986
|
interface MeshParticle {
|
|
973
987
|
/** Grows by one for every particle ever spawned: a renderer knows a new one by it. */
|
|
@@ -984,7 +998,7 @@ interface MeshParticle {
|
|
|
984
998
|
x: number;
|
|
985
999
|
y: number;
|
|
986
1000
|
z: number;
|
|
987
|
-
|
|
1001
|
+
frame: Quaternion;
|
|
988
1002
|
readonly at: Vec3Tuple;
|
|
989
1003
|
rx: number;
|
|
990
1004
|
ry: number;
|
|
@@ -1003,6 +1017,10 @@ interface MeshParticle {
|
|
|
1003
1017
|
readonly ramp: readonly [number, number] | undefined;
|
|
1004
1018
|
readonly fade: boolean;
|
|
1005
1019
|
readonly startOpacity: number;
|
|
1020
|
+
/** A piece of a group that rides on the effect's carrier (a muzzle flash on the gun in the hands): its own roll in the group, and how far it moved from its place on the carrier. */
|
|
1021
|
+
readonly carried: Carried | undefined;
|
|
1022
|
+
readonly roll: Quaternion | undefined;
|
|
1023
|
+
readonly drift: [number, number, number];
|
|
1006
1024
|
}
|
|
1007
1025
|
/**
|
|
1008
1026
|
* The solids of the Workshop's recipes: the gallery's `Particles` (thrown with a velocity and a spin, slowed, lifted by a negative gravity, grown and faded) without
|
|
@@ -1014,9 +1032,15 @@ declare class MeshPool {
|
|
|
1014
1032
|
private serial;
|
|
1015
1033
|
constructor(capacity?: number);
|
|
1016
1034
|
get count(): number;
|
|
1017
|
-
spawn(options: MeshSpawn, frame?: Quaternion): MeshParticle;
|
|
1035
|
+
spawn(options: MeshSpawn, frame?: Quaternion, carried?: Carried): MeshParticle;
|
|
1018
1036
|
update(dt: number): void;
|
|
1019
1037
|
clear(): void;
|
|
1038
|
+
/** Puts every carried piece where its carrier is now (after the frame moved the thing it belongs to). */
|
|
1039
|
+
follow(): void;
|
|
1040
|
+
/** A carried piece: how far its own velocity took it, then its place on the carrier. */
|
|
1041
|
+
private ride;
|
|
1042
|
+
/** A carried piece's place on the carrier now plus its drift, turned with the carrier. */
|
|
1043
|
+
private place;
|
|
1020
1044
|
}
|
|
1021
1045
|
|
|
1022
1046
|
interface DecalFromSprite {
|
|
@@ -1125,6 +1149,8 @@ interface FlashLight {
|
|
|
1125
1149
|
intensity: number;
|
|
1126
1150
|
/** Holds `peak` until `duration` is over. */
|
|
1127
1151
|
steady: boolean;
|
|
1152
|
+
/** Rides on the effect's carrier while it burns (a muzzle flash on the gun in the hands). */
|
|
1153
|
+
carried?: Carried | undefined;
|
|
1128
1154
|
}
|
|
1129
1155
|
interface FireLightSlot {
|
|
1130
1156
|
x: number;
|
|
@@ -1140,8 +1166,10 @@ declare class FlashLightPool {
|
|
|
1140
1166
|
private next;
|
|
1141
1167
|
constructor(context: WorkshopContext);
|
|
1142
1168
|
get lit(): number;
|
|
1143
|
-
flash(point: Vec3Tuple, color: number, intensity: number, duration: number, distance?: number, force?: boolean | 'boom', steady?: boolean):
|
|
1169
|
+
flash(point: Vec3Tuple, color: number, intensity: number, duration: number, distance?: number, force?: boolean | 'boom', steady?: boolean): FlashLight | undefined;
|
|
1144
1170
|
clear(): void;
|
|
1171
|
+
/** Puts every carried light that burns where its carrier is now. */
|
|
1172
|
+
follow(): void;
|
|
1145
1173
|
update(dt: number): void;
|
|
1146
1174
|
}
|
|
1147
1175
|
|
|
@@ -1176,6 +1204,8 @@ interface Placement {
|
|
|
1176
1204
|
readonly anchor: Vec3Tuple;
|
|
1177
1205
|
readonly yaw: number;
|
|
1178
1206
|
readonly orientation?: Quaternion;
|
|
1207
|
+
/** The live pose the effect rides on while it lives (`origin` and `orientation` move with it): its grouped pieces and its lights follow it. */
|
|
1208
|
+
readonly carrier?: Carrier;
|
|
1179
1209
|
}
|
|
1180
1210
|
interface WorkshopOptions {
|
|
1181
1211
|
readonly random: RandomStream;
|
|
@@ -1216,6 +1246,8 @@ declare class WorkshopEngine {
|
|
|
1216
1246
|
scaled(count: number): number;
|
|
1217
1247
|
/** A point of the recipe's space in the world (`undefined` placement: as is). */
|
|
1218
1248
|
place(point: Vec3Tuple): Vec3Tuple;
|
|
1249
|
+
/** A point of the recipe's space from the anchor, turned by the placement's yaw when it has no orientation (the carrier turns the rest). */
|
|
1250
|
+
private local;
|
|
1219
1251
|
/** A direction or velocity of the recipe's space in the world. */
|
|
1220
1252
|
turn(vector: Vec3Tuple): Vec3Tuple;
|
|
1221
1253
|
private placed;
|
|
@@ -1464,6 +1496,11 @@ interface Behavior {
|
|
|
1464
1496
|
update(host: BehaviorHost, dt: number, elapsed: number): void;
|
|
1465
1497
|
}
|
|
1466
1498
|
|
|
1499
|
+
/** Where the thing an effect belongs to is now (a muzzle), asked every frame the effect lives; `null` leaves the effect where it was last put. */
|
|
1500
|
+
type EffectTrack = () => {
|
|
1501
|
+
readonly point: Vec3Tuple;
|
|
1502
|
+
readonly orientation?: readonly [number, number, number, number];
|
|
1503
|
+
} | null;
|
|
1467
1504
|
interface PlayOptions {
|
|
1468
1505
|
/** Which way the effect points in the world (the muzzle's barrel, the spray of a jet). */
|
|
1469
1506
|
readonly direction?: Vec3Tuple;
|
|
@@ -1479,6 +1516,11 @@ interface PlayOptions {
|
|
|
1479
1516
|
readonly values?: Readonly<Record<string, number>>;
|
|
1480
1517
|
/** Moves with a thing: the effect sits at its position plus the point it was played at. */
|
|
1481
1518
|
readonly follow?: Follow;
|
|
1519
|
+
/**
|
|
1520
|
+
* Rides on the thing it belongs to while it lives (the muzzle of a gun in the hands, which the view turns and the kick moves): the effect's grouped pieces (the
|
|
1521
|
+
* flash's cones) and its lights keep their place on it, and what it throws free (smoke) is thrown from where the thing is and stays in the world.
|
|
1522
|
+
*/
|
|
1523
|
+
readonly track?: EffectTrack;
|
|
1482
1524
|
/** Stops after this many seconds (default: the recipe's loop). */
|
|
1483
1525
|
readonly seconds?: number;
|
|
1484
1526
|
}
|
|
@@ -1499,6 +1541,8 @@ interface EffectPlayer {
|
|
|
1499
1541
|
stop(handle: number): void;
|
|
1500
1542
|
/** Runs the timers and ticks of every live effect (the engine's pools are aged by its owner). */
|
|
1501
1543
|
update(dt: number): void;
|
|
1544
|
+
/** Moves the carrier of every tracked effect to where its thing is now (after the frame moved it); the engine's `follow` then puts the carried pieces there. True when one is live. */
|
|
1545
|
+
retrack(): boolean;
|
|
1502
1546
|
clear(): void;
|
|
1503
1547
|
readonly active: number;
|
|
1504
1548
|
has(id: string): boolean;
|
|
@@ -1742,6 +1786,11 @@ interface VfxWorld {
|
|
|
1742
1786
|
* (`workshop()`); `null` when the id is unknown. Returns a handle for `stop`.
|
|
1743
1787
|
*/
|
|
1744
1788
|
play(id: string, point: Vec3Like, options?: PlayOptions): number | null;
|
|
1789
|
+
/**
|
|
1790
|
+
* Puts what rides on a thing (an effect played with `track`: a muzzle flash) where the thing is now. `update` does it as it steps; call this too after the frame moved
|
|
1791
|
+
* the things (the gun posed, the view turned) and before drawing, so the flash is drawn on the muzzle of this frame and not of the last. True when something rides.
|
|
1792
|
+
*/
|
|
1793
|
+
follow(): boolean;
|
|
1745
1794
|
/** The Workshop's pools (sprites, streaks, debris, decals, rings, lights, screen): what the renderer draws for `play`. Made on first use. */
|
|
1746
1795
|
workshop(): WorkshopEngine;
|
|
1747
1796
|
/** The Workshop engine if something already made it (`play`, `workshop()`); never creates it. */
|
|
@@ -1989,4 +2038,4 @@ declare const SMOKE_COLORS: {
|
|
|
1989
2038
|
readonly gas: Rgb;
|
|
1990
2039
|
};
|
|
1991
2040
|
|
|
1992
|
-
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, 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, 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 };
|
|
2041
|
+
export { AREA_CAP_GAME, type AreaCap, type AreaCapTracker, type Behavior, type BehaviorHost, type BlastLight, type BloodMark, type Carrier, 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 EffectTrack, 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, 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, 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 };
|
package/dist/index.global.js
CHANGED
|
@@ -5242,9 +5242,17 @@ var GameVfx = (() => {
|
|
|
5242
5242
|
});
|
|
5243
5243
|
}
|
|
5244
5244
|
function placementOf(entry) {
|
|
5245
|
+
const carrier = entry.carrier;
|
|
5246
|
+
if (carrier) return { origin: carrier.origin, anchor: entry.anchor, yaw: entry.yaw, carrier, ...carrier.orientation ? { orientation: carrier.orientation } : {} };
|
|
5245
5247
|
const origin = entry.follow ? [entry.origin[0] + positionOf2(entry.follow)[0], entry.origin[1] + positionOf2(entry.follow)[1], entry.origin[2] + positionOf2(entry.follow)[2]] : entry.origin;
|
|
5246
5248
|
return { origin, anchor: entry.anchor, yaw: entry.yaw, ...entry.orientation ? { orientation: entry.orientation } : {} };
|
|
5247
5249
|
}
|
|
5250
|
+
function moveCarrier(entry) {
|
|
5251
|
+
const pose = entry.track?.();
|
|
5252
|
+
if (!pose || !entry.carrier) return;
|
|
5253
|
+
entry.carrier.origin = [pose.point[0], pose.point[1], pose.point[2]];
|
|
5254
|
+
if (pose.orientation) entry.carrier.orientation = pose.orientation;
|
|
5255
|
+
}
|
|
5248
5256
|
function drawing(entry, action) {
|
|
5249
5257
|
const context = engine.context;
|
|
5250
5258
|
const shared = context.random;
|
|
@@ -5270,7 +5278,9 @@ var GameVfx = (() => {
|
|
|
5270
5278
|
anchor: def.anchor ?? ORIGIN5,
|
|
5271
5279
|
yaw: yawOf(heading, playOptions.direction),
|
|
5272
5280
|
orientation: playOptions.orientation,
|
|
5273
|
-
seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS)
|
|
5281
|
+
seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS),
|
|
5282
|
+
track: playOptions.track,
|
|
5283
|
+
carrier: playOptions.track ? { origin: point, orientation: playOptions.orientation } : void 0
|
|
5274
5284
|
};
|
|
5275
5285
|
playing.push(entry);
|
|
5276
5286
|
drawing(
|
|
@@ -5292,11 +5302,21 @@ var GameVfx = (() => {
|
|
|
5292
5302
|
for (let index = playing.length - 1; index >= 0; index--) {
|
|
5293
5303
|
const entry = playing[index];
|
|
5294
5304
|
const instance = entry.instance;
|
|
5305
|
+
moveCarrier(entry);
|
|
5295
5306
|
instance.setup = { ...instance.setup, placement: placementOf(entry) };
|
|
5296
5307
|
drawing(entry, () => instance.step(dt));
|
|
5297
5308
|
if (instance.time >= entry.seconds) playing.splice(index, 1);
|
|
5298
5309
|
}
|
|
5299
5310
|
},
|
|
5311
|
+
retrack() {
|
|
5312
|
+
let tracked = false;
|
|
5313
|
+
for (const entry of playing) {
|
|
5314
|
+
if (!entry.carrier) continue;
|
|
5315
|
+
moveCarrier(entry);
|
|
5316
|
+
tracked = true;
|
|
5317
|
+
}
|
|
5318
|
+
return tracked;
|
|
5319
|
+
},
|
|
5300
5320
|
clear() {
|
|
5301
5321
|
playing.length = 0;
|
|
5302
5322
|
},
|
|
@@ -6949,6 +6969,21 @@ var GameVfx = (() => {
|
|
|
6949
6969
|
}
|
|
6950
6970
|
};
|
|
6951
6971
|
|
|
6972
|
+
// src/workshop/carrier.ts
|
|
6973
|
+
function rotate(q, v) {
|
|
6974
|
+
const [qx, qy, qz, qw] = q;
|
|
6975
|
+
const ix = qw * v[0] + qy * v[2] - qz * v[1];
|
|
6976
|
+
const iy = qw * v[1] + qz * v[0] - qx * v[2];
|
|
6977
|
+
const iz = qw * v[2] + qx * v[1] - qy * v[0];
|
|
6978
|
+
const iw = -qx * v[0] - qy * v[1] - qz * v[2];
|
|
6979
|
+
return [ix * qw + iw * -qx + iy * -qz - iz * -qy, iy * qw + iw * -qy + iz * -qx - ix * -qz, iz * qw + iw * -qz + ix * -qy - iy * -qx];
|
|
6980
|
+
}
|
|
6981
|
+
function carriedPoint(carried) {
|
|
6982
|
+
const { carrier, local: local2 } = carried;
|
|
6983
|
+
const turned = carrier.orientation ? rotate(carrier.orientation, local2) : local2;
|
|
6984
|
+
return [carrier.origin[0] + turned[0], carrier.origin[1] + turned[1], carrier.origin[2] + turned[2]];
|
|
6985
|
+
}
|
|
6986
|
+
|
|
6952
6987
|
// src/workshop/meshes.ts
|
|
6953
6988
|
var CAPACITY3 = 400;
|
|
6954
6989
|
var IDENTITY = [0, 0, 0, 1];
|
|
@@ -6967,7 +7002,7 @@ var GameVfx = (() => {
|
|
|
6967
7002
|
get count() {
|
|
6968
7003
|
return this.particles.length;
|
|
6969
7004
|
}
|
|
6970
|
-
spawn(options, frame = IDENTITY) {
|
|
7005
|
+
spawn(options, frame = IDENTITY, carried) {
|
|
6971
7006
|
const velocity = options.v ?? [0, 0, 0];
|
|
6972
7007
|
const world = options.wv ?? [0, 0, 0];
|
|
6973
7008
|
const particle = {
|
|
@@ -6984,6 +7019,9 @@ var GameVfx = (() => {
|
|
|
6984
7019
|
y: options.p[1],
|
|
6985
7020
|
z: options.p[2],
|
|
6986
7021
|
frame: options.roll ? multiply(frame, aboutX(options.roll)) : frame,
|
|
7022
|
+
roll: options.roll ? aboutX(options.roll) : void 0,
|
|
7023
|
+
carried,
|
|
7024
|
+
drift: [0, 0, 0],
|
|
6987
7025
|
at: options.at ?? [0, 0, 0],
|
|
6988
7026
|
rx: options.rot?.[0] ?? 0,
|
|
6989
7027
|
ry: options.rot?.[1] ?? 0,
|
|
@@ -7024,9 +7062,12 @@ var GameVfx = (() => {
|
|
|
7024
7062
|
particle.vy *= keep;
|
|
7025
7063
|
particle.vz *= keep;
|
|
7026
7064
|
}
|
|
7027
|
-
particle.
|
|
7028
|
-
|
|
7029
|
-
|
|
7065
|
+
if (particle.carried) this.ride(particle, dt);
|
|
7066
|
+
else {
|
|
7067
|
+
particle.x += particle.vx * dt;
|
|
7068
|
+
particle.y += particle.vy * dt;
|
|
7069
|
+
particle.z += particle.vz * dt;
|
|
7070
|
+
}
|
|
7030
7071
|
particle.rx += particle.spin[0] * dt;
|
|
7031
7072
|
particle.ry += particle.spin[1] * dt;
|
|
7032
7073
|
particle.rz += particle.spin[2] * dt;
|
|
@@ -7037,6 +7078,30 @@ var GameVfx = (() => {
|
|
|
7037
7078
|
clear() {
|
|
7038
7079
|
this.particles.length = 0;
|
|
7039
7080
|
}
|
|
7081
|
+
/** Puts every carried piece where its carrier is now (after the frame moved the thing it belongs to). */
|
|
7082
|
+
follow() {
|
|
7083
|
+
for (const particle of this.particles) if (particle.carried) this.place(particle);
|
|
7084
|
+
}
|
|
7085
|
+
/** A carried piece: how far its own velocity took it, then its place on the carrier. */
|
|
7086
|
+
ride(particle, dt) {
|
|
7087
|
+
const drift = particle.drift;
|
|
7088
|
+
drift[0] += particle.vx * dt;
|
|
7089
|
+
drift[1] += particle.vy * dt;
|
|
7090
|
+
drift[2] += particle.vz * dt;
|
|
7091
|
+
this.place(particle);
|
|
7092
|
+
}
|
|
7093
|
+
/** A carried piece's place on the carrier now plus its drift, turned with the carrier. */
|
|
7094
|
+
place(particle) {
|
|
7095
|
+
const carried = particle.carried;
|
|
7096
|
+
if (!carried) return;
|
|
7097
|
+
const drift = particle.drift;
|
|
7098
|
+
const [x, y, z] = carriedPoint(carried);
|
|
7099
|
+
particle.x = x + drift[0];
|
|
7100
|
+
particle.y = y + drift[1];
|
|
7101
|
+
particle.z = z + drift[2];
|
|
7102
|
+
const turn = carried.carrier.orientation;
|
|
7103
|
+
if (turn) particle.frame = particle.roll ? multiply(turn, particle.roll) : turn;
|
|
7104
|
+
}
|
|
7040
7105
|
};
|
|
7041
7106
|
|
|
7042
7107
|
// src/workshop/sprites.ts
|
|
@@ -7405,8 +7470,8 @@ var GameVfx = (() => {
|
|
|
7405
7470
|
}
|
|
7406
7471
|
flash(point, color, intensity, duration, distance, force, steady) {
|
|
7407
7472
|
const { level } = this.context.quality;
|
|
7408
|
-
if (level >= 1 && !force) return;
|
|
7409
|
-
if (level >= 2 && force !== "boom") return;
|
|
7473
|
+
if (level >= 1 && !force) return void 0;
|
|
7474
|
+
if (level >= 2 && force !== "boom") return void 0;
|
|
7410
7475
|
const light = this.lights[this.next++ % LIGHT_CAPACITY];
|
|
7411
7476
|
light.x = point[0];
|
|
7412
7477
|
light.y = point[1];
|
|
@@ -7418,17 +7483,24 @@ var GameVfx = (() => {
|
|
|
7418
7483
|
light.t = 0;
|
|
7419
7484
|
light.steady = steady === true;
|
|
7420
7485
|
light.intensity = intensity;
|
|
7486
|
+
light.carried = void 0;
|
|
7487
|
+
return light;
|
|
7421
7488
|
}
|
|
7422
7489
|
clear() {
|
|
7423
7490
|
for (const light of this.lights) light.intensity = 0;
|
|
7424
7491
|
for (const light of this.fire) light.intensity = 0;
|
|
7425
7492
|
}
|
|
7493
|
+
/** Puts every carried light that burns where its carrier is now. */
|
|
7494
|
+
follow() {
|
|
7495
|
+
for (const light of this.lights) if (light.intensity > 0 && light.carried) [light.x, light.y, light.z] = carriedPoint(light.carried);
|
|
7496
|
+
}
|
|
7426
7497
|
update(dt) {
|
|
7427
7498
|
for (const light of this.lights) {
|
|
7428
7499
|
if (light.intensity <= 0) continue;
|
|
7429
7500
|
light.t += dt;
|
|
7430
7501
|
const age = light.t / light.duration;
|
|
7431
7502
|
light.intensity = age >= 1 ? 0 : light.steady ? light.peak : light.peak * (1 - age) * (1 - age);
|
|
7503
|
+
if (light.carried) [light.x, light.y, light.z] = carriedPoint(light.carried);
|
|
7432
7504
|
}
|
|
7433
7505
|
}
|
|
7434
7506
|
};
|
|
@@ -7438,7 +7510,7 @@ var GameVfx = (() => {
|
|
|
7438
7510
|
var FIRE_FLICKER_SWAY = 0.25;
|
|
7439
7511
|
var FIRE_FLICKER_JITTER = 0.08;
|
|
7440
7512
|
var LENS_FADE = 0.16;
|
|
7441
|
-
function
|
|
7513
|
+
function rotate2(q, v) {
|
|
7442
7514
|
const [qx, qy, qz, qw] = q;
|
|
7443
7515
|
const ix = qw * v[0] + qy * v[2] - qz * v[1];
|
|
7444
7516
|
const iy = qw * v[1] + qz * v[0] - qx * v[2];
|
|
@@ -7496,7 +7568,7 @@ var GameVfx = (() => {
|
|
|
7496
7568
|
if (!placement) return point;
|
|
7497
7569
|
const { anchor, origin, yaw, orientation } = placement;
|
|
7498
7570
|
if (orientation) {
|
|
7499
|
-
const turned =
|
|
7571
|
+
const turned = rotate2(orientation, [point[0] - anchor[0], point[1] - anchor[1], point[2] - anchor[2]]);
|
|
7500
7572
|
return [origin[0] + turned[0], origin[1] + turned[1], origin[2] + turned[2]];
|
|
7501
7573
|
}
|
|
7502
7574
|
const x = point[0] - anchor[0];
|
|
@@ -7505,11 +7577,20 @@ var GameVfx = (() => {
|
|
|
7505
7577
|
const sin2 = Math.sin(yaw);
|
|
7506
7578
|
return [origin[0] + cos2 * x + sin2 * z, origin[1] + point[1] - anchor[1], origin[2] - sin2 * x + cos2 * z];
|
|
7507
7579
|
}
|
|
7580
|
+
/** A point of the recipe's space from the anchor, turned by the placement's yaw when it has no orientation (the carrier turns the rest). */
|
|
7581
|
+
local(point) {
|
|
7582
|
+
const placement = this.placement;
|
|
7583
|
+
if (!placement) return point;
|
|
7584
|
+
const offset = [point[0] - placement.anchor[0], point[1] - placement.anchor[1], point[2] - placement.anchor[2]];
|
|
7585
|
+
if (placement.carrier?.orientation) return offset;
|
|
7586
|
+
const turned = this.place(point);
|
|
7587
|
+
return [turned[0] - placement.origin[0], turned[1] - placement.origin[1], turned[2] - placement.origin[2]];
|
|
7588
|
+
}
|
|
7508
7589
|
/** A direction or velocity of the recipe's space in the world. */
|
|
7509
7590
|
turn(vector2) {
|
|
7510
7591
|
const placement = this.placement;
|
|
7511
7592
|
if (!placement) return vector2;
|
|
7512
|
-
if (placement.orientation) return
|
|
7593
|
+
if (placement.orientation) return rotate2(placement.orientation, vector2);
|
|
7513
7594
|
const cos2 = Math.cos(placement.yaw);
|
|
7514
7595
|
const sin2 = Math.sin(placement.yaw);
|
|
7515
7596
|
return [cos2 * vector2[0] + sin2 * vector2[2], vector2[1], -sin2 * vector2[0] + cos2 * vector2[2]];
|
|
@@ -7544,7 +7625,8 @@ var GameVfx = (() => {
|
|
|
7544
7625
|
const options = placement ? { ...recipe, p: this.place(recipe.p), ...recipe.v ? { v: this.turn(recipe.v) } : {} } : recipe;
|
|
7545
7626
|
this.context.trace?.("mesh", [options]);
|
|
7546
7627
|
const grouped = recipe.at !== void 0 || recipe.roll !== void 0;
|
|
7547
|
-
|
|
7628
|
+
const carried = placement?.carrier && grouped ? { carrier: placement.carrier, local: this.local(recipe.p) } : void 0;
|
|
7629
|
+
return this.meshes.spawn(options, placement && grouped ? placement.orientation ?? [0, Math.sin(placement.yaw / 2), 0, Math.cos(placement.yaw / 2)] : void 0, carried);
|
|
7548
7630
|
}
|
|
7549
7631
|
debrisPiece(recipe) {
|
|
7550
7632
|
const options = this.placed(recipe);
|
|
@@ -7568,9 +7650,11 @@ var GameVfx = (() => {
|
|
|
7568
7650
|
}
|
|
7569
7651
|
/** `steady` (a seventh number): the light holds its intensity for its duration and goes out, where the Workshop's fades with the square of its age. */
|
|
7570
7652
|
flash(recipe) {
|
|
7571
|
-
const
|
|
7653
|
+
const placement = this.placement;
|
|
7654
|
+
const args = placement ? [this.place(recipe[0]), recipe[1], recipe[2], recipe[3], recipe[4], recipe[5], recipe[6]] : recipe;
|
|
7572
7655
|
this.context.trace?.("flash", args.slice(0, 6));
|
|
7573
|
-
this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
7656
|
+
const light = this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
|
|
7657
|
+
if (light && placement?.carrier) light.carried = { carrier: placement.carrier, local: this.local(recipe[0]) };
|
|
7574
7658
|
}
|
|
7575
7659
|
/** `fireLight` (W400): sways with the clock and flickers with one draw. */
|
|
7576
7660
|
fireLight(slot, recipe, intensity, time) {
|
|
@@ -7733,6 +7817,12 @@ var GameVfx = (() => {
|
|
|
7733
7817
|
const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
|
|
7734
7818
|
return effectPlayer().play(id, [point[0], point[1], point[2]], { ...playOptions, ...seed !== void 0 ? { seed } : {} });
|
|
7735
7819
|
},
|
|
7820
|
+
follow() {
|
|
7821
|
+
if (!engine || !player?.retrack()) return false;
|
|
7822
|
+
engine.meshes.follow();
|
|
7823
|
+
engine.lights.follow();
|
|
7824
|
+
return true;
|
|
7825
|
+
},
|
|
7736
7826
|
burst: (kind, point, normal, count, speed, spriteOptions) => spriteSystem.burst(kind, point, normal, count, speed, spriteOptions),
|
|
7737
7827
|
spawn: (kind, point, velocity, spriteOptions) => spriteSystem.spawn(kind, point, velocity, spriteOptions),
|
|
7738
7828
|
onLand: (owner, listener) => spriteSystem.onLand(owner, listener),
|
|
@@ -8739,7 +8829,7 @@ var GameVfx = (() => {
|
|
|
8739
8829
|
function mix(from, to, amount) {
|
|
8740
8830
|
return [from[0] + (to[0] - from[0]) * amount, from[1] + (to[1] - from[1]) * amount, from[2] + (to[2] - from[2]) * amount];
|
|
8741
8831
|
}
|
|
8742
|
-
function
|
|
8832
|
+
function rotate3(local2, x, y, z, w) {
|
|
8743
8833
|
const [vx2, vy2, vz2] = local2;
|
|
8744
8834
|
const ix = w * vx2 + y * vz2 - z * vy2;
|
|
8745
8835
|
const iy = w * vy2 + z * vx2 - x * vz2;
|
|
@@ -8797,7 +8887,7 @@ var GameVfx = (() => {
|
|
|
8797
8887
|
/** A direction given in the camera's own axes, in world axes. */
|
|
8798
8888
|
forward(local2) {
|
|
8799
8889
|
const [x, y, z, w] = lookAtQuaternion(this.position, this.target);
|
|
8800
|
-
return
|
|
8890
|
+
return rotate3(local2, x, y, z, w);
|
|
8801
8891
|
}
|
|
8802
8892
|
};
|
|
8803
8893
|
|