@adatechnology/game-vfx-three 0.11.2 → 0.11.3
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/dist/index.global.js +149 -68
- package/dist/index.global.js.map +1 -1
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -4278,8 +4278,36 @@ var GameVfxThree = (() => {
|
|
|
4278
4278
|
loop: 2,
|
|
4279
4279
|
timeline: [call2("bodywork_impact", [0, 0, 0], NORMAL, [variable("dx"), variable("dy"), variable("dz")], variable("bore"), variable("paint"), variable("metal"))]
|
|
4280
4280
|
};
|
|
4281
|
+
var GLASS_PIECE = 11061464;
|
|
4282
|
+
var GLASS_DUST = 12572386;
|
|
4283
|
+
var HIT = [0, 0, 0];
|
|
4284
|
+
var VEHICLE_GLASS_CHIP = {
|
|
4285
|
+
id: "vehicle_glass_chip",
|
|
4286
|
+
pageId: "vehicle:vehicle_glass_chip",
|
|
4287
|
+
team: "vehicles",
|
|
4288
|
+
budget: { particles: 16, debris: 6 },
|
|
4289
|
+
loop: 2,
|
|
4290
|
+
timeline: [
|
|
4291
|
+
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 }),
|
|
4292
|
+
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 }),
|
|
4293
|
+
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 }))
|
|
4294
|
+
]
|
|
4295
|
+
};
|
|
4296
|
+
var VEHICLE_GLASS_SHATTER = {
|
|
4297
|
+
id: "vehicle_glass_shatter",
|
|
4298
|
+
pageId: "vehicle:vehicle_glass_shatter",
|
|
4299
|
+
team: "vehicles",
|
|
4300
|
+
budget: { particles: 40, debris: 0 },
|
|
4301
|
+
loop: 2,
|
|
4302
|
+
timeline: [
|
|
4303
|
+
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 }),
|
|
4304
|
+
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 })
|
|
4305
|
+
]
|
|
4306
|
+
};
|
|
4281
4307
|
var VEHICLE_EFFECTS = [
|
|
4282
4308
|
BODYWORK_IMPACT,
|
|
4309
|
+
VEHICLE_GLASS_CHIP,
|
|
4310
|
+
VEHICLE_GLASS_SHATTER,
|
|
4283
4311
|
/** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
|
|
4284
4312
|
aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
|
|
4285
4313
|
/** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
|
|
@@ -5737,6 +5765,110 @@ var GameVfxThree = (() => {
|
|
|
5737
5765
|
function addScrape(store, spec) {
|
|
5738
5766
|
store.add({ kind: "scrape", ...spec, y: spec.y + 2e-3 + nextLift(store) * 2e-4 });
|
|
5739
5767
|
}
|
|
5768
|
+
var RESTITUTION = -0.32;
|
|
5769
|
+
var GROUND_FRICTION = 0.5;
|
|
5770
|
+
var REST_SPEED = 0.6;
|
|
5771
|
+
var REST_SLIDE = 0.5;
|
|
5772
|
+
var TRAIL_SECONDS = 1.8;
|
|
5773
|
+
var TRAIL_STEP = 0.025;
|
|
5774
|
+
var QUARTER_TURN3 = Math.PI / 2;
|
|
5775
|
+
var TOP_FACING = 0.7;
|
|
5776
|
+
var MOVE2 = { x0: 0.5, y0: 0.5, z0: 0.5, x1: 0.5, y1: 0.5, z1: 0.5, pad: 0.5 };
|
|
5777
|
+
function bounce(core, chunk, floor2) {
|
|
5778
|
+
chunk.y = floor2;
|
|
5779
|
+
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
5780
|
+
chunk.splat = true;
|
|
5781
|
+
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
5782
|
+
}
|
|
5783
|
+
chunk.vy *= RESTITUTION;
|
|
5784
|
+
chunk.vx *= GROUND_FRICTION;
|
|
5785
|
+
chunk.vz *= GROUND_FRICTION;
|
|
5786
|
+
chunk.ax *= GROUND_FRICTION;
|
|
5787
|
+
chunk.ay *= GROUND_FRICTION;
|
|
5788
|
+
chunk.az *= GROUND_FRICTION;
|
|
5789
|
+
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
5790
|
+
chunk.rest = true;
|
|
5791
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5792
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5793
|
+
}
|
|
5794
|
+
}
|
|
5795
|
+
var chunkPad = (chunk) => Math.max(chunk.sx, chunk.sy, chunk.sz) * 0.45;
|
|
5796
|
+
function hitFace(chunk, out) {
|
|
5797
|
+
chunk.x = out.x;
|
|
5798
|
+
chunk.y = out.y;
|
|
5799
|
+
chunk.z = out.z;
|
|
5800
|
+
const into = chunk.vx * out.nx + chunk.vy * out.ny + chunk.vz * out.nz;
|
|
5801
|
+
if (into >= 0) return;
|
|
5802
|
+
const tx = chunk.vx - into * out.nx;
|
|
5803
|
+
const ty = chunk.vy - into * out.ny;
|
|
5804
|
+
const tz = chunk.vz - into * out.nz;
|
|
5805
|
+
const back = into * RESTITUTION;
|
|
5806
|
+
chunk.vx = tx * GROUND_FRICTION + back * out.nx;
|
|
5807
|
+
chunk.vy = ty * GROUND_FRICTION + back * out.ny;
|
|
5808
|
+
chunk.vz = tz * GROUND_FRICTION + back * out.nz;
|
|
5809
|
+
chunk.ax *= GROUND_FRICTION;
|
|
5810
|
+
chunk.ay *= GROUND_FRICTION;
|
|
5811
|
+
chunk.az *= GROUND_FRICTION;
|
|
5812
|
+
if (out.ny > TOP_FACING && Math.abs(back) < REST_SPEED && Math.sqrt(tx * tx + tz * tz) * GROUND_FRICTION < REST_SLIDE) {
|
|
5813
|
+
chunk.rest = true;
|
|
5814
|
+
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5815
|
+
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
5816
|
+
}
|
|
5817
|
+
}
|
|
5818
|
+
function leaveTrail(core, chunk, dt) {
|
|
5819
|
+
chunk.trail -= dt;
|
|
5820
|
+
if (chunk.trail > 0) return;
|
|
5821
|
+
chunk.trail = TRAIL_STEP;
|
|
5822
|
+
const random = chunk.rng;
|
|
5823
|
+
addSpark(core, {
|
|
5824
|
+
x: chunk.x,
|
|
5825
|
+
y: chunk.y,
|
|
5826
|
+
z: chunk.z,
|
|
5827
|
+
vx: chunk.vx * 0.15,
|
|
5828
|
+
vy: chunk.vy * 0.15,
|
|
5829
|
+
vz: chunk.vz * 0.15,
|
|
5830
|
+
life: random.between(0.25, 0.45),
|
|
5831
|
+
w: 0.05 + chunk.sx * 0.2,
|
|
5832
|
+
st: 0.05,
|
|
5833
|
+
kind: 0,
|
|
5834
|
+
g: 0,
|
|
5835
|
+
drag: 1,
|
|
5836
|
+
source: chunk.source
|
|
5837
|
+
});
|
|
5838
|
+
if (random.next() < 0.25) {
|
|
5839
|
+
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 });
|
|
5840
|
+
}
|
|
5841
|
+
}
|
|
5842
|
+
function updateChunks(core, dt) {
|
|
5843
|
+
const confiner = core.confiner;
|
|
5844
|
+
const confining = !confiner.empty;
|
|
5845
|
+
const chunks = core.chunks.items;
|
|
5846
|
+
for (let index = 0; index < chunks.length; index++) {
|
|
5847
|
+
const chunk = chunks[index];
|
|
5848
|
+
chunk.t += dt;
|
|
5849
|
+
if (chunk.rest) continue;
|
|
5850
|
+
MOVE2.x0 = chunk.x;
|
|
5851
|
+
MOVE2.y0 = chunk.y;
|
|
5852
|
+
MOVE2.z0 = chunk.z;
|
|
5853
|
+
chunk.vy -= core.gravity * dt;
|
|
5854
|
+
chunk.x += chunk.vx * dt;
|
|
5855
|
+
chunk.y += chunk.vy * dt;
|
|
5856
|
+
chunk.z += chunk.vz * dt;
|
|
5857
|
+
chunk.rx += chunk.ax * dt;
|
|
5858
|
+
chunk.ry += chunk.ay * dt;
|
|
5859
|
+
chunk.rz += chunk.az * dt;
|
|
5860
|
+
if (confining) {
|
|
5861
|
+
MOVE2.x1 = chunk.x;
|
|
5862
|
+
MOVE2.y1 = chunk.y;
|
|
5863
|
+
MOVE2.z1 = chunk.z;
|
|
5864
|
+
MOVE2.pad = chunkPad(chunk);
|
|
5865
|
+
if (confiner.confineMove(MOVE2, dt)) hitFace(chunk, confiner.out);
|
|
5866
|
+
}
|
|
5867
|
+
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
5868
|
+
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
5869
|
+
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
5870
|
+
}
|
|
5871
|
+
}
|
|
5740
5872
|
function createRingPool(capacity) {
|
|
5741
5873
|
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 }));
|
|
5742
5874
|
}
|
|
@@ -5866,6 +5998,18 @@ var GameVfxThree = (() => {
|
|
|
5866
5998
|
puff3.z = out.z;
|
|
5867
5999
|
slideInto(out, puff3);
|
|
5868
6000
|
}
|
|
6001
|
+
function chunkBornFrom(core, chunk, ox, oy, oz) {
|
|
6002
|
+
const confiner = core.confiner;
|
|
6003
|
+
if (confiner.empty) return;
|
|
6004
|
+
BIRTH.x0 = ox;
|
|
6005
|
+
BIRTH.y0 = oy;
|
|
6006
|
+
BIRTH.z0 = oz;
|
|
6007
|
+
BIRTH.x1 = chunk.x;
|
|
6008
|
+
BIRTH.y1 = chunk.y;
|
|
6009
|
+
BIRTH.z1 = chunk.z;
|
|
6010
|
+
BIRTH.pad = chunkPad(chunk);
|
|
6011
|
+
if (confiner.confineMove(BIRTH, 0)) hitFace(chunk, confiner.out);
|
|
6012
|
+
}
|
|
5869
6013
|
function composeFireballs(context) {
|
|
5870
6014
|
const { core, def, random, x, y, z, size, scale, direction } = context;
|
|
5871
6015
|
if (!core.layers.fire || !def.fireballs) return;
|
|
@@ -6050,7 +6194,7 @@ var GameVfxThree = (() => {
|
|
|
6050
6194
|
const sy = plate ? s * 0.3 : s * random.between(0.6, 1);
|
|
6051
6195
|
const color = hexToRgb(chunks.colors.length > 0 ? pick2(random, chunks.colors) : DEFAULT_CHUNK_COLOR);
|
|
6052
6196
|
const hot = random.next() < chunks.hot;
|
|
6053
|
-
addChunk(core, random, {
|
|
6197
|
+
const chunk = addChunk(core, random, {
|
|
6054
6198
|
x: x + d.x * 0.2,
|
|
6055
6199
|
y: y + 0.2,
|
|
6056
6200
|
z: z + d.z * 0.2,
|
|
@@ -6064,10 +6208,11 @@ var GameVfxThree = (() => {
|
|
|
6064
6208
|
plate,
|
|
6065
6209
|
hot
|
|
6066
6210
|
});
|
|
6211
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
6067
6212
|
}
|
|
6068
6213
|
}
|
|
6069
6214
|
function composeRimDebris(context) {
|
|
6070
|
-
const { core, random, x, z } = context;
|
|
6215
|
+
const { core, random, x, y, z } = context;
|
|
6071
6216
|
const radius = context.def.mark.crater ?? 0;
|
|
6072
6217
|
if (!core.layers.shrapnel) return;
|
|
6073
6218
|
const speedScale = context.def.chunks.speed ?? 1;
|
|
@@ -6078,7 +6223,7 @@ var GameVfxThree = (() => {
|
|
|
6078
6223
|
const s = random.between(0.12, 0.28);
|
|
6079
6224
|
const vy2 = random.between(4, 10);
|
|
6080
6225
|
const color = hexToRgb(random.next() < 0.6 ? ROCK_COLORS[0] : ROCK_COLORS[1]);
|
|
6081
|
-
addChunk(core, random, {
|
|
6226
|
+
const chunk = addChunk(core, random, {
|
|
6082
6227
|
x: x + Math.cos(angle) * 0.3,
|
|
6083
6228
|
y: 0.1,
|
|
6084
6229
|
z: z + Math.sin(angle) * 0.3,
|
|
@@ -6091,6 +6236,7 @@ var GameVfxThree = (() => {
|
|
|
6091
6236
|
color,
|
|
6092
6237
|
plate: true
|
|
6093
6238
|
});
|
|
6239
|
+
chunkBornFrom(core, chunk, x, y, z);
|
|
6094
6240
|
}
|
|
6095
6241
|
}
|
|
6096
6242
|
function composeMushroom(context, spec) {
|
|
@@ -6221,71 +6367,6 @@ var GameVfxThree = (() => {
|
|
|
6221
6367
|
emitRequests(context);
|
|
6222
6368
|
return scale;
|
|
6223
6369
|
}
|
|
6224
|
-
var RESTITUTION = -0.32;
|
|
6225
|
-
var GROUND_FRICTION = 0.5;
|
|
6226
|
-
var REST_SPEED = 0.6;
|
|
6227
|
-
var REST_SLIDE = 0.5;
|
|
6228
|
-
var TRAIL_SECONDS = 1.8;
|
|
6229
|
-
var TRAIL_STEP = 0.025;
|
|
6230
|
-
var QUARTER_TURN3 = Math.PI / 2;
|
|
6231
|
-
function bounce(core, chunk, floor2) {
|
|
6232
|
-
chunk.y = floor2;
|
|
6233
|
-
if (chunk.blood && !chunk.splat && core.layers.mark) {
|
|
6234
|
-
chunk.splat = true;
|
|
6235
|
-
addBloodSplat(core.marks, core.ground, chunk.rng, { x: chunk.x, z: chunk.z, radius: chunk.rng.between(0.06, 0.13) });
|
|
6236
|
-
}
|
|
6237
|
-
chunk.vy *= RESTITUTION;
|
|
6238
|
-
chunk.vx *= GROUND_FRICTION;
|
|
6239
|
-
chunk.vz *= GROUND_FRICTION;
|
|
6240
|
-
chunk.ax *= GROUND_FRICTION;
|
|
6241
|
-
chunk.ay *= GROUND_FRICTION;
|
|
6242
|
-
chunk.az *= GROUND_FRICTION;
|
|
6243
|
-
if (Math.abs(chunk.vy) < REST_SPEED && Math.hypot(chunk.vx, chunk.vz) < REST_SLIDE) {
|
|
6244
|
-
chunk.rest = true;
|
|
6245
|
-
chunk.rx = Math.round(chunk.rx / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6246
|
-
chunk.rz = Math.round(chunk.rz / QUARTER_TURN3) * QUARTER_TURN3;
|
|
6247
|
-
}
|
|
6248
|
-
}
|
|
6249
|
-
function leaveTrail(core, chunk, dt) {
|
|
6250
|
-
chunk.trail -= dt;
|
|
6251
|
-
if (chunk.trail > 0) return;
|
|
6252
|
-
chunk.trail = TRAIL_STEP;
|
|
6253
|
-
const random = chunk.rng;
|
|
6254
|
-
addSpark(core, {
|
|
6255
|
-
x: chunk.x,
|
|
6256
|
-
y: chunk.y,
|
|
6257
|
-
z: chunk.z,
|
|
6258
|
-
vx: chunk.vx * 0.15,
|
|
6259
|
-
vy: chunk.vy * 0.15,
|
|
6260
|
-
vz: chunk.vz * 0.15,
|
|
6261
|
-
life: random.between(0.25, 0.45),
|
|
6262
|
-
w: 0.05 + chunk.sx * 0.2,
|
|
6263
|
-
st: 0.05,
|
|
6264
|
-
kind: 0,
|
|
6265
|
-
g: 0,
|
|
6266
|
-
drag: 1,
|
|
6267
|
-
source: chunk.source
|
|
6268
|
-
});
|
|
6269
|
-
if (random.next() < 0.25) {
|
|
6270
|
-
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 });
|
|
6271
|
-
}
|
|
6272
|
-
}
|
|
6273
|
-
function updateChunks(core, dt) {
|
|
6274
|
-
for (const chunk of core.chunks.items) {
|
|
6275
|
-
chunk.t += dt;
|
|
6276
|
-
if (chunk.rest) continue;
|
|
6277
|
-
chunk.vy -= core.gravity * dt;
|
|
6278
|
-
chunk.x += chunk.vx * dt;
|
|
6279
|
-
chunk.y += chunk.vy * dt;
|
|
6280
|
-
chunk.z += chunk.vz * dt;
|
|
6281
|
-
chunk.rx += chunk.ax * dt;
|
|
6282
|
-
chunk.ry += chunk.ay * dt;
|
|
6283
|
-
chunk.rz += chunk.az * dt;
|
|
6284
|
-
const floor2 = chunk.sy * 0.45 + core.groundAt(chunk.x, chunk.z);
|
|
6285
|
-
if (chunk.y < floor2) bounce(core, chunk, floor2);
|
|
6286
|
-
if (chunk.hot && chunk.t < TRAIL_SECONDS && core.layers.smoke) leaveTrail(core, chunk, dt);
|
|
6287
|
-
}
|
|
6288
|
-
}
|
|
6289
6370
|
var DECAY = { shake: 5, white: 7, red: 2.2, side: 3, chroma: 3, desat: 0.7, gasSeconds: 5, beat: 6 };
|
|
6290
6371
|
var INITIAL_FLASH_DECAY = 6;
|
|
6291
6372
|
function createScreenState() {
|