@adatechnology/game-vfx 0.19.0 → 0.20.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 +1 -0
- package/dist/index.global.js +151 -70
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +151 -70
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4308,8 +4308,36 @@ var BODYWORK_IMPACT = {
|
|
|
4308
4308
|
loop: 2,
|
|
4309
4309
|
timeline: [call2("bodywork_impact", [0, 0, 0], NORMAL, [variable("dx"), variable("dy"), variable("dz")], variable("bore"), variable("paint"), variable("metal"))]
|
|
4310
4310
|
};
|
|
4311
|
+
var GLASS_PIECE = 11061464;
|
|
4312
|
+
var GLASS_DUST = 12572386;
|
|
4313
|
+
var HIT = [0, 0, 0];
|
|
4314
|
+
var VEHICLE_GLASS_CHIP = {
|
|
4315
|
+
id: "vehicle_glass_chip",
|
|
4316
|
+
pageId: "vehicle:vehicle_glass_chip",
|
|
4317
|
+
team: "vehicles",
|
|
4318
|
+
budget: { particles: 16, debris: 6 },
|
|
4319
|
+
loop: 2,
|
|
4320
|
+
timeline: [
|
|
4321
|
+
burst("add", 6, { p: HIT, box: [0.04, 0.04, 0.04], size: [8e-3, 0.02], life: [0.12, 0.3], c0: 16777215, a: 0.9, fi: 0.3 }),
|
|
4322
|
+
burst("normal", 6, { p: HIT, dir: NORMAL, sp: [0.3, 0.9], drag: 3, life: [0.4, 0.8], size: [0.04, 0.08], grow: 2, c0: GLASS_DUST, a: 0.18 }),
|
|
4323
|
+
repeat(6, debris({ p: HIT, box: [0.03, 0.03, 0.03], dir: NORMAL, cone: 0.6, sp: [0.4, 1.4], size: [rnd(2e-3, 4e-3), 2e-3, rnd(2e-3, 4e-3)], c: GLASS_PIECE, spin: 20, life: 6, bounce: 0.2 }))
|
|
4324
|
+
]
|
|
4325
|
+
};
|
|
4326
|
+
var VEHICLE_GLASS_SHATTER = {
|
|
4327
|
+
id: "vehicle_glass_shatter",
|
|
4328
|
+
pageId: "vehicle:vehicle_glass_shatter",
|
|
4329
|
+
team: "vehicles",
|
|
4330
|
+
budget: { particles: 40, debris: 0 },
|
|
4331
|
+
loop: 2,
|
|
4332
|
+
timeline: [
|
|
4333
|
+
burst("add", 24, { p: HIT, box: [0.5, 0.3, 0.5], size: [0.01, 0.03], life: [0.15, 0.5], c0: 16777215, a: 0.9, fi: 0.3 }),
|
|
4334
|
+
burst("normal", 10, { p: [0, -0.15, 0], box: [0.5, 0.2, 0.5], sp: [0.1, 0.4], drag: 2, life: [0.6, 1.1], size: [0.08, 0.14], grow: 2.5, c0: GLASS_DUST, a: 0.14 })
|
|
4335
|
+
]
|
|
4336
|
+
};
|
|
4311
4337
|
var VEHICLE_EFFECTS = [
|
|
4312
4338
|
BODYWORK_IMPACT,
|
|
4339
|
+
VEHICLE_GLASS_CHIP,
|
|
4340
|
+
VEHICLE_GLASS_SHATTER,
|
|
4313
4341
|
/** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
|
|
4314
4342
|
aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
|
|
4315
4343
|
/** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
|
|
@@ -5830,6 +5858,112 @@ function addScrape(store, spec) {
|
|
|
5830
5858
|
store.add({ kind: "scrape", ...spec, y: spec.y + 2e-3 + nextLift(store) * 2e-4 });
|
|
5831
5859
|
}
|
|
5832
5860
|
|
|
5861
|
+
// src/pools/chunk-motion.ts
|
|
5862
|
+
var RESTITUTION = -0.32;
|
|
5863
|
+
var GROUND_FRICTION = 0.5;
|
|
5864
|
+
var REST_SPEED = 0.6;
|
|
5865
|
+
var REST_SLIDE = 0.5;
|
|
5866
|
+
var TRAIL_SECONDS = 1.8;
|
|
5867
|
+
var TRAIL_STEP = 0.025;
|
|
5868
|
+
var QUARTER_TURN3 = Math.PI / 2;
|
|
5869
|
+
var TOP_FACING = 0.7;
|
|
5870
|
+
var MOVE2 = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
5871
|
+
function bounce(core, chunk, floor2) {
|
|
5872
|
+
chunk.y = floor2;
|
|
5873
|
+
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
5874
|
+
chunk.splat = true;
|
|
5875
|
+
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
5876
|
+
}
|
|
5877
|
+
chunk.vy *= RESTITUTION;
|
|
5878
|
+
chunk.vx *= GROUND_FRICTION;
|
|
5879
|
+
chunk.vz *= GROUND_FRICTION;
|
|
5880
|
+
chunk.ax *= GROUND_FRICTION;
|
|
5881
|
+
chunk.ay *= GROUND_FRICTION;
|
|
5882
|
+
chunk.az *= GROUND_FRICTION;
|
|
5883
|
+
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
5884
|
+
chunk.rest = true;
|
|
5885
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5886
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5887
|
+
}
|
|
5888
|
+
}
|
|
5889
|
+
var chunkPad = (chunk) => Math.max(chunk.sx, chunk.sy, chunk.sz) * 0.45;
|
|
5890
|
+
function hitFace(chunk, out) {
|
|
5891
|
+
chunk.x = out.x;
|
|
5892
|
+
chunk.y = out.y;
|
|
5893
|
+
chunk.z = out.z;
|
|
5894
|
+
const into = chunk.vx * out.nx + chunk.vy * out.ny + chunk.vz * out.nz;
|
|
5895
|
+
if (into >= 0) return;
|
|
5896
|
+
const tx = chunk.vx - into * out.nx;
|
|
5897
|
+
const ty = chunk.vy - into * out.ny;
|
|
5898
|
+
const tz = chunk.vz - into * out.nz;
|
|
5899
|
+
const back = into * RESTITUTION;
|
|
5900
|
+
chunk.vx = tx * GROUND_FRICTION + back * out.nx;
|
|
5901
|
+
chunk.vy = ty * GROUND_FRICTION + back * out.ny;
|
|
5902
|
+
chunk.vz = tz * GROUND_FRICTION + back * out.nz;
|
|
5903
|
+
chunk.ax *= GROUND_FRICTION;
|
|
5904
|
+
chunk.ay *= GROUND_FRICTION;
|
|
5905
|
+
chunk.az *= GROUND_FRICTION;
|
|
5906
|
+
if (out.ny > TOP_FACING && Math.abs(back) < REST_SPEED && Math.sqrt(tx * tx + tz * tz) * GROUND_FRICTION < REST_SLIDE) {
|
|
5907
|
+
chunk.rest = true;
|
|
5908
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5909
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5910
|
+
}
|
|
5911
|
+
}
|
|
5912
|
+
function leaveTrail(core, chunk, dt) {
|
|
5913
|
+
chunk.trail -= dt;
|
|
5914
|
+
if (chunk.trail > 0) return;
|
|
5915
|
+
chunk.trail = TRAIL_STEP;
|
|
5916
|
+
const random = chunk.rng;
|
|
5917
|
+
addSpark(core, {
|
|
5918
|
+
x: chunk.x,
|
|
5919
|
+
y: chunk.y,
|
|
5920
|
+
z: chunk.z,
|
|
5921
|
+
vx: chunk.vx * 0.15,
|
|
5922
|
+
vy: chunk.vy * 0.15,
|
|
5923
|
+
vz: chunk.vz * 0.15,
|
|
5924
|
+
life: random.between(0.25, 0.45),
|
|
5925
|
+
w: 0.05 + chunk.sx * 0.2,
|
|
5926
|
+
st: 0.05,
|
|
5927
|
+
kind: 0,
|
|
5928
|
+
g: 0,
|
|
5929
|
+
drag: 1,
|
|
5930
|
+
source: chunk.source
|
|
5931
|
+
});
|
|
5932
|
+
if (random.next() < 0.25) {
|
|
5933
|
+
addPuff(core, random, { x: chunk.x, y: chunk.y, z: chunk.z, s0: 0.04, s1: 0.14 + chunk.sx * 0.3, sg: 0.15, life: random.between(1, 1.6), drag: 2, buoy: 0.6, color: SMOKE_COLORS.grey, kind: 0, source: chunk.source });
|
|
5934
|
+
}
|
|
5935
|
+
}
|
|
5936
|
+
function updateChunks(core, dt) {
|
|
5937
|
+
const confiner = core.confiner;
|
|
5938
|
+
const confining = !confiner.empty;
|
|
5939
|
+
const chunks = core.chunks.items;
|
|
5940
|
+
for (let index = 0; index < chunks.length; index++) {
|
|
5941
|
+
const chunk = chunks[index];
|
|
5942
|
+
chunk.t += dt;
|
|
5943
|
+
if (chunk.rest) continue;
|
|
5944
|
+
MOVE2.x0 = chunk.x;
|
|
5945
|
+
MOVE2.y0 = chunk.y;
|
|
5946
|
+
MOVE2.z0 = chunk.z;
|
|
5947
|
+
chunk.vy -= core.gravity * dt;
|
|
5948
|
+
chunk.x += chunk.vx * dt;
|
|
5949
|
+
chunk.y += chunk.vy * dt;
|
|
5950
|
+
chunk.z += chunk.vz * dt;
|
|
5951
|
+
chunk.rx += chunk.ax * dt;
|
|
5952
|
+
chunk.ry += chunk.ay * dt;
|
|
5953
|
+
chunk.rz += chunk.az * dt;
|
|
5954
|
+
if (confining) {
|
|
5955
|
+
MOVE2.x1 = chunk.x;
|
|
5956
|
+
MOVE2.y1 = chunk.y;
|
|
5957
|
+
MOVE2.z1 = chunk.z;
|
|
5958
|
+
MOVE2.pad = chunkPad(chunk);
|
|
5959
|
+
if (confiner.confineMove(MOVE2, dt)) hitFace(chunk, confiner.out);
|
|
5960
|
+
}
|
|
5961
|
+
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
5962
|
+
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
5963
|
+
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
5964
|
+
}
|
|
5965
|
+
}
|
|
5966
|
+
|
|
5833
5967
|
// src/pools/rings.ts
|
|
5834
5968
|
function createRingPool(capacity) {
|
|
5835
5969
|
return new OrderedPool(capacity, () => ({ x: 0, z: 0, y0: 0, rise: 0, rk: 0, R0: 0, R1: 0, r: 0, roll: 0, t: 0, life: 0 }));
|
|
@@ -5964,6 +6098,18 @@ function bornFrom(core, puff3, ox, oy, oz) {
|
|
|
5964
6098
|
puff3.z = out.z;
|
|
5965
6099
|
slideInto(out, puff3);
|
|
5966
6100
|
}
|
|
6101
|
+
function chunkBornFrom(core, chunk, ox, oy, oz) {
|
|
6102
|
+
const confiner = core.confiner;
|
|
6103
|
+
if (confiner.empty) return;
|
|
6104
|
+
BIRTH.x0 = ox;
|
|
6105
|
+
BIRTH.y0 = oy;
|
|
6106
|
+
BIRTH.z0 = oz;
|
|
6107
|
+
BIRTH.x1 = chunk.x;
|
|
6108
|
+
BIRTH.y1 = chunk.y;
|
|
6109
|
+
BIRTH.z1 = chunk.z;
|
|
6110
|
+
BIRTH.pad = chunkPad(chunk);
|
|
6111
|
+
if (confiner.confineMove(BIRTH, 0)) hitFace(chunk, confiner.out);
|
|
6112
|
+
}
|
|
5967
6113
|
function composeFireballs(context) {
|
|
5968
6114
|
const { core, def, random, x, y, z, size, scale, direction } = context;
|
|
5969
6115
|
if (!core.layers.fire || !def.fireballs) return;
|
|
@@ -6148,7 +6294,7 @@ function composeDebris(context) {
|
|
|
6148
6294
|
const sy = plate ? s * 0.3 : s * random.between(0.6, 1);
|
|
6149
6295
|
const color = hexToRgb(chunks.colors.length > 0 ? pick2(random, chunks.colors) : DEFAULT_CHUNK_COLOR);
|
|
6150
6296
|
const hot = random.next() < chunks.hot;
|
|
6151
|
-
addChunk(core, random, {
|
|
6297
|
+
const chunk = addChunk(core, random, {
|
|
6152
6298
|
x: x + d.x * 0.2,
|
|
6153
6299
|
y: y + 0.2,
|
|
6154
6300
|
z: z + d.z * 0.2,
|
|
@@ -6162,10 +6308,11 @@ function composeDebris(context) {
|
|
|
6162
6308
|
plate,
|
|
6163
6309
|
hot
|
|
6164
6310
|
});
|
|
6311
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
6165
6312
|
}
|
|
6166
6313
|
}
|
|
6167
6314
|
function composeRimDebris(context) {
|
|
6168
|
-
const { core, random, x, z } = context;
|
|
6315
|
+
const { core, random, x, y, z } = context;
|
|
6169
6316
|
const radius = context.def.mark.crater ?? 0;
|
|
6170
6317
|
if (!core.layers.shrapnel) return;
|
|
6171
6318
|
const speedScale = context.def.chunks.speed ?? 1;
|
|
@@ -6176,7 +6323,7 @@ function composeRimDebris(context) {
|
|
|
6176
6323
|
const s = random.between(0.12, 0.28);
|
|
6177
6324
|
const vy2 = random.between(4, 10);
|
|
6178
6325
|
const color = hexToRgb(random.next() < 0.6 ? ROCK_COLORS[0] : ROCK_COLORS[1]);
|
|
6179
|
-
addChunk(core, random, {
|
|
6326
|
+
const chunk = addChunk(core, random, {
|
|
6180
6327
|
x: x + Math.cos(angle) * 0.3,
|
|
6181
6328
|
y: 0.1,
|
|
6182
6329
|
z: z + Math.sin(angle) * 0.3,
|
|
@@ -6189,6 +6336,7 @@ function composeRimDebris(context) {
|
|
|
6189
6336
|
color,
|
|
6190
6337
|
plate: true
|
|
6191
6338
|
});
|
|
6339
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
6192
6340
|
}
|
|
6193
6341
|
}
|
|
6194
6342
|
function composeMushroom(context, spec) {
|
|
@@ -6320,73 +6468,6 @@ function composeExplosion(core, def, call3) {
|
|
|
6320
6468
|
return scale;
|
|
6321
6469
|
}
|
|
6322
6470
|
|
|
6323
|
-
// src/pools/chunk-motion.ts
|
|
6324
|
-
var RESTITUTION = -0.32;
|
|
6325
|
-
var GROUND_FRICTION = 0.5;
|
|
6326
|
-
var REST_SPEED = 0.6;
|
|
6327
|
-
var REST_SLIDE = 0.5;
|
|
6328
|
-
var TRAIL_SECONDS = 1.8;
|
|
6329
|
-
var TRAIL_STEP = 0.025;
|
|
6330
|
-
var QUARTER_TURN3 = Math.PI / 2;
|
|
6331
|
-
function bounce(core, chunk, floor2) {
|
|
6332
|
-
chunk.y = floor2;
|
|
6333
|
-
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
6334
|
-
chunk.splat = true;
|
|
6335
|
-
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
6336
|
-
}
|
|
6337
|
-
chunk.vy *= RESTITUTION;
|
|
6338
|
-
chunk.vx *= GROUND_FRICTION;
|
|
6339
|
-
chunk.vz *= GROUND_FRICTION;
|
|
6340
|
-
chunk.ax *= GROUND_FRICTION;
|
|
6341
|
-
chunk.ay *= GROUND_FRICTION;
|
|
6342
|
-
chunk.az *= GROUND_FRICTION;
|
|
6343
|
-
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
6344
|
-
chunk.rest = true;
|
|
6345
|
-
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6346
|
-
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6347
|
-
}
|
|
6348
|
-
}
|
|
6349
|
-
function leaveTrail(core, chunk, dt) {
|
|
6350
|
-
chunk.trail -= dt;
|
|
6351
|
-
if (chunk.trail > 0) return;
|
|
6352
|
-
chunk.trail = TRAIL_STEP;
|
|
6353
|
-
const random = chunk.rng;
|
|
6354
|
-
addSpark(core, {
|
|
6355
|
-
x: chunk.x,
|
|
6356
|
-
y: chunk.y,
|
|
6357
|
-
z: chunk.z,
|
|
6358
|
-
vx: chunk.vx * 0.15,
|
|
6359
|
-
vy: chunk.vy * 0.15,
|
|
6360
|
-
vz: chunk.vz * 0.15,
|
|
6361
|
-
life: random.between(0.25, 0.45),
|
|
6362
|
-
w: 0.05 + chunk.sx * 0.2,
|
|
6363
|
-
st: 0.05,
|
|
6364
|
-
kind: 0,
|
|
6365
|
-
g: 0,
|
|
6366
|
-
drag: 1,
|
|
6367
|
-
source: chunk.source
|
|
6368
|
-
});
|
|
6369
|
-
if (random.next() < 0.25) {
|
|
6370
|
-
addPuff(core, random, { x: chunk.x, y: chunk.y, z: chunk.z, s0: 0.04, s1: 0.14 + chunk.sx * 0.3, sg: 0.15, life: random.between(1, 1.6), drag: 2, buoy: 0.6, color: SMOKE_COLORS.grey, kind: 0, source: chunk.source });
|
|
6371
|
-
}
|
|
6372
|
-
}
|
|
6373
|
-
function updateChunks(core, dt) {
|
|
6374
|
-
for (const chunk of core.chunks.items) {
|
|
6375
|
-
chunk.t += dt;
|
|
6376
|
-
if (chunk.rest) continue;
|
|
6377
|
-
chunk.vy -= core.gravity * dt;
|
|
6378
|
-
chunk.x += chunk.vx * dt;
|
|
6379
|
-
chunk.y += chunk.vy * dt;
|
|
6380
|
-
chunk.z += chunk.vz * dt;
|
|
6381
|
-
chunk.rx += chunk.ax * dt;
|
|
6382
|
-
chunk.ry += chunk.ay * dt;
|
|
6383
|
-
chunk.rz += chunk.az * dt;
|
|
6384
|
-
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
6385
|
-
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
6386
|
-
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
6387
|
-
}
|
|
6388
|
-
}
|
|
6389
|
-
|
|
6390
6471
|
// src/screen.ts
|
|
6391
6472
|
var DECAY = { shake: 5, white: 7, red: 2.2, side: 3, chroma: 3, desat: 0.7, gasSeconds: 5, beat: 6 };
|
|
6392
6473
|
var INITIAL_FLASH_DECAY = 6;
|