@adatechnology/game-vfx 0.1.3 → 0.3.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/dist/index.js CHANGED
@@ -1360,77 +1360,77 @@ function createPuffPool(capacity) {
1360
1360
  }));
1361
1361
  }
1362
1362
  function spawnPuff(pool, random, init) {
1363
- const puff2 = pool.acquire();
1364
- puff2.x = init.x ?? 0;
1365
- puff2.y = init.y ?? 0;
1366
- puff2.z = init.z ?? 0;
1367
- puff2.vx = init.vx ?? 0;
1368
- puff2.vy = init.vy ?? 0;
1369
- puff2.vz = init.vz ?? 0;
1370
- puff2.s0 = init.s0 ?? 0.2;
1371
- puff2.s1 = init.s1 ?? 1;
1372
- puff2.sg = init.sg ?? 0.1;
1373
- puff2.gk = init.gk ?? 6;
1374
- puff2.life = init.life ?? 3;
1375
- puff2.t = 0;
1376
- puff2.h0 = init.h0 ?? 0;
1377
- puff2.hl = init.hl ?? 0.4;
1378
- puff2.drag = init.drag ?? 3;
1379
- puff2.buoy = init.buoy ?? 0.5;
1380
- puff2.grav = init.grav ?? 0;
1381
- puff2.kind = init.kind ?? 0;
1382
- puff2.seed = random.next();
1383
- puff2.wind = init.wind ?? 1;
1384
- puff2.color = init.color ?? SMOKE_COLORS.grey;
1385
- puff2.ring = init.ring ?? null;
1386
- puff2.ph = init.ph ?? 0;
1387
- puff2.th = init.th ?? 0;
1388
- puff2.rng = random;
1389
- puff2.age = 0;
1390
- puff2.heat = 0;
1391
- puff2.size = 0;
1392
- return puff2;
1393
- }
1394
- function ageOrKeep2(puff2, dt) {
1395
- puff2.t += dt;
1396
- return puff2.t < puff2.life;
1397
- }
1398
- function moveOnRing(puff2, ring2, wind) {
1363
+ const puff3 = pool.acquire();
1364
+ puff3.x = init.x ?? 0;
1365
+ puff3.y = init.y ?? 0;
1366
+ puff3.z = init.z ?? 0;
1367
+ puff3.vx = init.vx ?? 0;
1368
+ puff3.vy = init.vy ?? 0;
1369
+ puff3.vz = init.vz ?? 0;
1370
+ puff3.s0 = init.s0 ?? 0.2;
1371
+ puff3.s1 = init.s1 ?? 1;
1372
+ puff3.sg = init.sg ?? 0.1;
1373
+ puff3.gk = init.gk ?? 6;
1374
+ puff3.life = init.life ?? 3;
1375
+ puff3.t = 0;
1376
+ puff3.h0 = init.h0 ?? 0;
1377
+ puff3.hl = init.hl ?? 0.4;
1378
+ puff3.drag = init.drag ?? 3;
1379
+ puff3.buoy = init.buoy ?? 0.5;
1380
+ puff3.grav = init.grav ?? 0;
1381
+ puff3.kind = init.kind ?? 0;
1382
+ puff3.seed = random.next();
1383
+ puff3.wind = init.wind ?? 1;
1384
+ puff3.color = init.color ?? SMOKE_COLORS.grey;
1385
+ puff3.ring = init.ring ?? null;
1386
+ puff3.ph = init.ph ?? 0;
1387
+ puff3.th = init.th ?? 0;
1388
+ puff3.rng = random;
1389
+ puff3.age = 0;
1390
+ puff3.heat = 0;
1391
+ puff3.size = 0;
1392
+ return puff3;
1393
+ }
1394
+ function ageOrKeep2(puff3, dt) {
1395
+ puff3.t += dt;
1396
+ return puff3.t < puff3.life;
1397
+ }
1398
+ function moveOnRing(puff3, ring2, wind) {
1399
1399
  const ringTime = ring2.t;
1400
1400
  const centerY = ring2.y0 + ring2.rise * (1 - Math.exp(-ringTime * ring2.rk));
1401
1401
  const majorRadius = ring2.R0 + (ring2.R1 - ring2.R0) * (1 - Math.exp(-ringTime * 1.6));
1402
- const theta = puff2.th + ringTime * ring2.roll;
1402
+ const theta = puff3.th + ringTime * ring2.roll;
1403
1403
  const minorRadius = ring2.r * (0.8 + 0.4 * Math.min(1, ringTime));
1404
1404
  const radius = majorRadius + minorRadius * Math.cos(theta);
1405
- puff2.x = ring2.x + Math.cos(puff2.ph) * radius + wind.x * ringTime * 0.6;
1406
- puff2.z = ring2.z + Math.sin(puff2.ph) * radius + wind.z * ringTime * 0.6;
1407
- puff2.y = centerY + minorRadius * Math.sin(theta);
1408
- }
1409
- function moveFree(puff2, dt, age, heat, wind) {
1410
- const damping = Math.exp(-puff2.drag * dt);
1411
- puff2.vx *= damping;
1412
- puff2.vy *= damping;
1413
- puff2.vz *= damping;
1414
- puff2.vy += (puff2.buoy * (heat > 0 ? 1.6 : 1) - puff2.grav) * dt;
1415
- puff2.x += (puff2.vx + wind.x * puff2.wind * age) * dt;
1416
- puff2.y += puff2.vy * dt;
1417
- puff2.z += (puff2.vz + wind.z * puff2.wind * age) * dt;
1418
- if (puff2.y < puff2.s0 * FLOOR_FRACTION) {
1419
- puff2.y = puff2.s0 * FLOOR_FRACTION;
1420
- if (puff2.vy < 0) puff2.vy *= FLOOR_BOUNCE;
1405
+ puff3.x = ring2.x + Math.cos(puff3.ph) * radius + wind.x * ringTime * 0.6;
1406
+ puff3.z = ring2.z + Math.sin(puff3.ph) * radius + wind.z * ringTime * 0.6;
1407
+ puff3.y = centerY + minorRadius * Math.sin(theta);
1408
+ }
1409
+ function moveFree(puff3, dt, age, heat, wind) {
1410
+ const damping = Math.exp(-puff3.drag * dt);
1411
+ puff3.vx *= damping;
1412
+ puff3.vy *= damping;
1413
+ puff3.vz *= damping;
1414
+ puff3.vy += (puff3.buoy * (heat > 0 ? 1.6 : 1) - puff3.grav) * dt;
1415
+ puff3.x += (puff3.vx + wind.x * puff3.wind * age) * dt;
1416
+ puff3.y += puff3.vy * dt;
1417
+ puff3.z += (puff3.vz + wind.z * puff3.wind * age) * dt;
1418
+ if (puff3.y < puff3.s0 * FLOOR_FRACTION) {
1419
+ puff3.y = puff3.s0 * FLOOR_FRACTION;
1420
+ if (puff3.vy < 0) puff3.vy *= FLOOR_BOUNCE;
1421
1421
  }
1422
1422
  }
1423
1423
  function updatePuffs(pool, dt, wind) {
1424
1424
  pool.compact(ageOrKeep2, dt);
1425
- for (const puff2 of pool.items) {
1426
- const age = puff2.t / puff2.life;
1427
- const heat = puff2.h0 > 0 ? puff2.h0 * Math.pow(Math.max(0, 1 - puff2.t / puff2.hl), 1.25) : 0;
1428
- if (puff2.ring) moveOnRing(puff2, puff2.ring, wind);
1429
- else moveFree(puff2, dt, age, heat, wind);
1430
- const size = puff2.s0 + (puff2.s1 - puff2.s0) * (1 - Math.exp(-puff2.t * puff2.gk)) + puff2.sg * Math.min(puff2.t, GROWTH_CAP_SECONDS);
1431
- puff2.size = size * Math.min(1, puff2.t * ARRIVAL_FRAME + ARRIVAL_BASE);
1432
- puff2.age = age;
1433
- puff2.heat = heat;
1425
+ for (const puff3 of pool.items) {
1426
+ const age = puff3.t / puff3.life;
1427
+ const heat = puff3.h0 > 0 ? puff3.h0 * Math.pow(Math.max(0, 1 - puff3.t / puff3.hl), 1.25) : 0;
1428
+ if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
1429
+ else moveFree(puff3, dt, age, heat, wind);
1430
+ const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
1431
+ puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
1432
+ puff3.age = age;
1433
+ puff3.heat = heat;
1434
1434
  }
1435
1435
  }
1436
1436
 
@@ -1491,9 +1491,9 @@ function updateSparks(pool, step) {
1491
1491
  var HOT_GLOW_COLOR = [1, 0.45, 0.12];
1492
1492
  function addPuff(core, random, init) {
1493
1493
  core.spawned.puffs++;
1494
- const puff2 = spawnPuff(core.puffs, random, init);
1495
- core.trace?.puff?.(puff2);
1496
- return puff2;
1494
+ const puff3 = spawnPuff(core.puffs, random, init);
1495
+ core.trace?.puff?.(puff3);
1496
+ return puff3;
1497
1497
  }
1498
1498
  function addSpark(core, init) {
1499
1499
  core.spawned.sparks++;
@@ -1679,6 +1679,7 @@ var mod = call("mod");
1679
1679
  var neg = call("neg");
1680
1680
  var abs = call("abs");
1681
1681
  var sqrt = call("sqrt");
1682
+ var exp = call("exp");
1682
1683
  var sin = call("sin");
1683
1684
  var cos = call("cos");
1684
1685
  var atan2 = call("atan2");
@@ -1724,12 +1725,14 @@ var DELTA = { $: "dt" };
1724
1725
  var INDEX = { $: "index" };
1725
1726
  var QUALITY = { $: "quality" };
1726
1727
  var FRESH = { $: "fresh" };
1728
+ var DIRECTION = { $: "direction" };
1727
1729
  var CAMERA_POSITION = { $: "cameraPosition" };
1728
1730
 
1729
1731
  // src/effects/steps.ts
1730
1732
  var burst = (system, count, spawn2) => ({ op: "burst", system, count, spawn: spawn2 });
1731
1733
  var spawn = (system, options) => ({ op: "spawn", system, spawn: options });
1732
1734
  var emit = (key, system, rate, options) => ({ op: "emit", key, system, rate, spawn: options });
1735
+ var mesh = (options) => ({ op: "mesh", spawn: options });
1733
1736
  var debris = (options) => ({ op: "debris", spawn: options });
1734
1737
  var decal = (...args) => ({ op: "decal", args });
1735
1738
  var ring = (...args) => ({ op: "ring", args });
@@ -2798,6 +2801,256 @@ var BUILDING_FIRE = {
2798
2801
  ]
2799
2802
  };
2800
2803
 
2804
+ // src/effects/world/fog-and-ash.ts
2805
+ var SPOTS_X = [-3, 1, 5];
2806
+ var SPOTS_Z = [-1, -2.4, 0.4];
2807
+ var FOG_AND_ASH = {
2808
+ id: "fog_and_ash",
2809
+ pageId: "neblina",
2810
+ team: "world",
2811
+ budget: { particles: 120, lights: 1 },
2812
+ loop: 0,
2813
+ view: { eye: [3, 1.8, 7.5], target: [-3, 1.2, -1] },
2814
+ setup: [
2815
+ cue("fog", { density: 0.075 }),
2816
+ cue("lamp_cone", { visible: true }),
2817
+ cue("zombie_visible", { index: -1, visible: false }),
2818
+ repeat(
2819
+ SPOTS_X.length,
2820
+ set("turn", rnd(-0.6, 0.6)),
2821
+ behavior("walkers", "place", { index: INDEX, x: pick(SPOTS_X, INDEX), z: pick(SPOTS_Z, INDEX), facing: variable("turn") })
2822
+ )
2823
+ ],
2824
+ timeline: [],
2825
+ tick: [
2826
+ emit("fog", "normal", 5, { p: [rnd(-14, 10), rnd(0.2, 1.1), rnd(-3, 8)], v: [rnd(0.15, 0.35), 0, rnd(-0.05, 0.05)], sp: 0, life: [9, 13], size: [3, 5], grow: 1.4, c0: 8227488, a: 0.13, fi: 0.35 }),
2827
+ emit("ash", "normal", 14, { p: [rnd(-10, 8), rnd(4, 6), rnd(-3, 7)], v: [rnd(0.1, 0.4), -0.35, rnd(-0.1, 0.1)], sp: [0.05, 0.15], life: [8, 12], size: [0.025, 0.04], c0: 10525328, a: 0.75, fi: 0.1, gnd: 1 })
2828
+ ]
2829
+ };
2830
+
2831
+ // src/workshop/rain.ts
2832
+ var RAIN_CAPACITY = 4e3;
2833
+ var FALL_SPEED = 15;
2834
+ var WIND_PER_FALL = 0.07;
2835
+ var STREAK_SLANT = 0.04;
2836
+ var STREAK_LENGTH = 0.6;
2837
+ var BOX_X = [-15, 15];
2838
+ var BOX_Z = [-6, 16];
2839
+ var START_HEIGHT = [0, 16];
2840
+ var REENTRY_HEIGHT = [14, 17];
2841
+ var SPLASH_CHANCE = 0.35;
2842
+ var SPLASH_RANGE = 12;
2843
+ var SPRITE_CHANCE = 0.5;
2844
+ var UP9 = [0, 1, 0];
2845
+ var WORKSHOP_PUDDLES = [
2846
+ [-1.5, 2.2, 1.6, 0.9],
2847
+ [3, 3.6, 1.1, 0.7],
2848
+ [-6, 3.2, 1.3, 0.8],
2849
+ [1.4, -2.2, 0.9, 0.5]
2850
+ ];
2851
+ var inPuddle = (puddles, x, z) => puddles.some((p) => ((x - p[0]) / p[2]) ** 2 + ((z - p[1]) / p[3]) ** 2 < 1);
2852
+ var RainField = class {
2853
+ constructor(engine) {
2854
+ __publicField(this, "engine", engine);
2855
+ /** Two points per streak: x, y, z of the top and x, y, z of the bottom. */
2856
+ __publicField(this, "positions", new Float32Array(RAIN_CAPACITY * 6));
2857
+ /** Streaks alive. */
2858
+ __publicField(this, "count", 0);
2859
+ /** The slant (the wind along x in the Workshop's units). */
2860
+ __publicField(this, "wind", 1);
2861
+ __publicField(this, "on", false);
2862
+ /** Where the box is centred (the Workshop leaves it at the origin; a game follows the camera). */
2863
+ __publicField(this, "centerX", 0);
2864
+ __publicField(this, "centerZ", 0);
2865
+ __publicField(this, "puddles", WORKSHOP_PUDDLES);
2866
+ /** Replaces the puddle test (a game knows its own wet spots). */
2867
+ __publicField(this, "puddleAt");
2868
+ }
2869
+ /** `initRain` (W321): `count` streaks (thinned by the quality), each drawn at a random place in the box. */
2870
+ init(count, wind) {
2871
+ const { random } = this.engine;
2872
+ this.count = Math.min(RAIN_CAPACITY, Math.round(count * this.engine.context.quality.mult));
2873
+ this.wind = wind;
2874
+ this.on = true;
2875
+ for (let index = 0; index < this.count; index++) {
2876
+ const offset = index * 6;
2877
+ const x = random.between(BOX_X[0], BOX_X[1]);
2878
+ const y = random.between(START_HEIGHT[0], START_HEIGHT[1]);
2879
+ const z = random.between(BOX_Z[0], BOX_Z[1]);
2880
+ this.set(offset, x, y, z);
2881
+ }
2882
+ }
2883
+ /**
2884
+ * What a game does with the field every frame: the box follows the camera (`centerX`, `centerZ`), the streaks thin or thicken to `count` (a new streak
2885
+ * starts at a random place of the box, as `init` draws it) and the wind slants them. The golden never calls it.
2886
+ */
2887
+ drive(count, wind, centerX, centerZ) {
2888
+ const { random } = this.engine;
2889
+ const target = Math.max(0, Math.min(RAIN_CAPACITY, Math.round(count * this.engine.context.quality.mult)));
2890
+ this.wind = wind;
2891
+ this.centerX = centerX;
2892
+ this.centerZ = centerZ;
2893
+ this.on = target > 0;
2894
+ for (let index = this.count; index < target; index++) {
2895
+ this.set(index * 6, random.between(BOX_X[0], BOX_X[1]) + centerX, random.between(START_HEIGHT[0], START_HEIGHT[1]), random.between(BOX_Z[0], BOX_Z[1]) + centerZ);
2896
+ }
2897
+ this.count = target;
2898
+ }
2899
+ /** `updateRain` (W322-329). `camera` is where the eye is; `splash` lets the drops that land leave a splash. */
2900
+ update(dt, splash, camera2) {
2901
+ if (!this.on) return;
2902
+ const { random, context } = this.engine;
2903
+ const positions = this.positions;
2904
+ const fall = FALL_SPEED * dt;
2905
+ const slant = this.wind * fall * WIND_PER_FALL;
2906
+ const reach = SPLASH_RANGE / (1 + context.quality.level);
2907
+ for (let index = 0; index < this.count; index++) {
2908
+ const o = index * 6;
2909
+ positions[o] += slant;
2910
+ positions[o + 3] += slant;
2911
+ positions[o + 1] -= fall;
2912
+ positions[o + 4] -= fall;
2913
+ const ground = context.groundAt(positions[o], positions[o + 2]);
2914
+ if (positions[o + 4] < ground) {
2915
+ const x = positions[o];
2916
+ const z = positions[o + 2];
2917
+ if (splash && random.next() < SPLASH_CHANCE) {
2918
+ const distance = Math.hypot(x - camera2[0], z - camera2[2]);
2919
+ if (distance < reach) {
2920
+ if (random.next() < SPRITE_CHANCE) {
2921
+ this.engine.spawn("normal", { p: [x, ground + 0.01, z], dir: UP9, cone: 0.6, sp: [0.6, 1.3], life: [0.18, 0.3], size: 0.035, c0: 12110044, a: 0.6, g: 9.8, fi: 0 });
2922
+ }
2923
+ if (this.puddleAt ? this.puddleAt(x, z) : inPuddle(this.puddles, x, z)) {
2924
+ this.engine.ring([[x, ground + 0.012, z], 0.01, random.between(0.12, 0.25), random.between(0.4, 0.6), 6978192]);
2925
+ }
2926
+ }
2927
+ }
2928
+ const nx = random.between(BOX_X[0], BOX_X[1]) + this.centerX;
2929
+ const ny = random.between(REENTRY_HEIGHT[0], REENTRY_HEIGHT[1]);
2930
+ const nz = random.between(BOX_Z[0], BOX_Z[1]) + this.centerZ;
2931
+ this.set(o, nx, ny, nz);
2932
+ }
2933
+ }
2934
+ }
2935
+ /** `rain.visible = false; RN.on = false` (W440): the field stops; the streaks stay where they were. */
2936
+ clear() {
2937
+ this.on = false;
2938
+ }
2939
+ set(offset, x, y, z) {
2940
+ const positions = this.positions;
2941
+ positions[offset] = x;
2942
+ positions[offset + 1] = y;
2943
+ positions[offset + 2] = z;
2944
+ positions[offset + 3] = x + this.wind * STREAK_SLANT;
2945
+ positions[offset + 4] = y - STREAK_LENGTH;
2946
+ positions[offset + 5] = z;
2947
+ }
2948
+ };
2949
+
2950
+ // src/effects/world/rain.ts
2951
+ var DROPS = [900, 2200, 4e3];
2952
+ var SLANT = [0.3, 1.2, 4.5];
2953
+ var STORM = 2;
2954
+ var FLASH_STEPS = ite(lt(variable("flash"), 0.08), 1, ite(lt(variable("flash"), 0.16), 0.2, ite(lt(variable("flash"), 0.26), 0.8, 0)));
2955
+ var RAIN_AND_PUDDLES = {
2956
+ id: "rain_and_puddles",
2957
+ pageId: "chuva",
2958
+ team: "world",
2959
+ params: { id: "intensity", options: ["drizzle", "rain", "storm"], default: 1 },
2960
+ budget: { particles: 4e3, decals: 4 },
2961
+ loop: 0,
2962
+ view: { eye: [2, 2, 7], target: [-1, 0.6, 1] },
2963
+ setup: [
2964
+ cue("lamp_cone", { visible: true }),
2965
+ ...WORKSHOP_PUDDLES.map(([x, z, radiusX, radiusZ]) => decal(x, 0, z, radiusX * 2, 790550, { grow: 0, life: 1e6, ar: radiusZ / radiusX }))
2966
+ ],
2967
+ timeline: [
2968
+ behavior("rain", "init", { count: ite(eq(PARAM, 0), DROPS[0], ite(eq(PARAM, 1), DROPS[1], DROPS[2])), wind: ite(eq(PARAM, 0), SLANT[0], ite(eq(PARAM, 1), SLANT[1], SLANT[2])) }),
2969
+ set("nextStrike", rnd(2, 4)),
2970
+ set("flash", -1)
2971
+ ],
2972
+ tick: [
2973
+ behavior("rain", "update", { dt: DELTA, splash: gt(PARAM, 0) }),
2974
+ when(eq(PARAM, STORM), [
2975
+ when(gt(TIME, variable("nextStrike")), [set("nextStrike", add(TIME, rnd(3.5, 6))), set("flash", 0)]),
2976
+ when(ge(variable("flash"), 0), [
2977
+ set("flash", add(variable("flash"), DELTA)),
2978
+ set("light", FLASH_STEPS),
2979
+ cue("lightning", { intensity: variable("light") }),
2980
+ screen({ max: { white: mul(variable("light"), 0.12) } }),
2981
+ when(gt(variable("flash"), 0.4), [set("flash", -1), cue("lightning", { intensity: 0 })])
2982
+ ]),
2983
+ emit("sheet", "normal", 2.5, { p: [-12, 2.5, rnd(-1, 8)], box: [0, 2, 0], v: [7, -0.5, 0], sp: 0, life: [3, 4], size: [3, 5], grow: 1.3, c0: 9083568, a: 0.06, fi: 0.3 })
2984
+ ])
2985
+ ]
2986
+ };
2987
+
2988
+ // src/effects/vehicles/car.ts
2989
+ var CAR_ORIGIN2 = [5.6, 0, 0.8];
2990
+ var CAR_ROTATION2 = [0, -0.4, 0];
2991
+ var carPoint = (x, y, z) => localToWorld(CAR_ORIGIN2, CAR_ROTATION2, [x, y, z]);
2992
+ var carDirection = (from, to) => normalized([to[0] - from[0], to[1] - from[1], to[2] - from[2]]);
2993
+
2994
+ // src/effects/vehicles/headlights.ts
2995
+ var BEAM_FROM = carPoint(0, 0.74, 2.15);
2996
+ var BEAM_DIRECTION = carDirection(BEAM_FROM, carPoint(0, 0.74, 3.15));
2997
+ var BEAM_SIDE = [BEAM_DIRECTION[2], 0, -BEAM_DIRECTION[0]];
2998
+ var WALKERS = 6;
2999
+ var WALK_SPEED2 = 0.7;
3000
+ var DROPS2 = 1800;
3001
+ var SLANT2 = 0.8;
3002
+ var startWalking = [
3003
+ set("spot", query("car", "point", rnd(-2, 2), 0, rnd(8, 18))),
3004
+ set("goal", query("car", "point", rnd(-0.6, 0.6), 0, 2.6)),
3005
+ behavior("walkers", "place", { index: INDEX, x: pick(variable("spot"), 0), z: pick(variable("spot"), 2), facing: 0 }),
3006
+ behavior("walkers", "walk", { index: INDEX, to: variable("goal"), speed: WALK_SPEED2 })
3007
+ ];
3008
+ var HEADLIGHTS_IN_RAIN = {
3009
+ id: "headlights_in_rain",
3010
+ pageId: "farol",
3011
+ team: "vehicles",
3012
+ budget: { particles: 600, lights: 2 },
3013
+ loop: 0,
3014
+ view: { eye: [-2.5, 2, 5.5], target: [4, 1, 6] },
3015
+ setup: [
3016
+ cue("fog", { density: 0.05 }),
3017
+ cue("headlights", { on: true, intensity: 2.4, color: 16773584 }),
3018
+ behavior("rain", "init", { count: DROPS2, wind: SLANT2 }),
3019
+ repeat(WALKERS, ...startWalking)
3020
+ ],
3021
+ timeline: [],
3022
+ tick: [
3023
+ behavior("rain", "update", { dt: DELTA, splash: true }),
3024
+ emit(
3025
+ "lit",
3026
+ "streak",
3027
+ 600,
3028
+ local(
3029
+ "depth",
3030
+ rnd(1, 13),
3031
+ local(
3032
+ "spread",
3033
+ mul(variable("depth"), 0.33, sqrt(rand())),
3034
+ local(
3035
+ "turn",
3036
+ rnd(0, 6.283),
3037
+ local("base", vadd(BEAM_FROM, vscale(BEAM_DIRECTION, variable("depth")), vscale(BEAM_SIDE, mul(cos(variable("turn")), variable("spread")))), {
3038
+ p: vwith(variable("base"), 1, add(vy(variable("base")), mul(sin(variable("turn")), variable("spread"), 0.6))),
3039
+ v: [0.8, -14, 0],
3040
+ sp: 0,
3041
+ life: 0.06,
3042
+ len: 0.035,
3043
+ c0: 13622512,
3044
+ a: 0.9
3045
+ })
3046
+ )
3047
+ )
3048
+ )
3049
+ ),
3050
+ repeat(WALKERS, when(not(query("walkers", "is_walking", INDEX)), startWalking))
3051
+ ]
3052
+ };
3053
+
2801
3054
  // src/effects/vehicles/scraping-sparks.ts
2802
3055
  var YAW = -Math.PI / 2;
2803
3056
  var COS = Math.cos(YAW);
@@ -2827,12 +3080,6 @@ var SCRAPING_SPARKS = {
2827
3080
  ]
2828
3081
  };
2829
3082
 
2830
- // src/effects/vehicles/car.ts
2831
- var CAR_ORIGIN2 = [5.6, 0, 0.8];
2832
- var CAR_ROTATION2 = [0, -0.4, 0];
2833
- var carPoint = (x, y, z) => localToWorld(CAR_ORIGIN2, CAR_ROTATION2, [x, y, z]);
2834
- var carDirection = (from, to) => normalized([to[0] - from[0], to[1] - from[1], to[2] - from[2]]);
2835
-
2836
3083
  // src/effects/vehicles/engine-smoke.ts
2837
3084
  var HOOD = carPoint(0, 1.02, 1.4);
2838
3085
  var EXHAUST = carPoint(0.5, 0.3, -2.2);
@@ -2869,7 +3116,7 @@ var ENGINE_SMOKE = {
2869
3116
  };
2870
3117
 
2871
3118
  // src/effects/vehicles/boom.ts
2872
- var UP9 = [0, 1, 0];
3119
+ var UP10 = [0, 1, 0];
2873
3120
  var doorVelocity = (side) => {
2874
3121
  const out = carPoint(side * 4, 3, 0.3);
2875
3122
  const centre = carPoint(0, 0, 0.3);
@@ -2879,7 +3126,7 @@ var VEHICLE_BOOM = [
2879
3126
  call2("explode", vadd(query("car", "position"), [0, 0.6, 0]), 1.8, 2759188),
2880
3127
  cue("car_burnt"),
2881
3128
  behavior("car", "launch", { rise: 4.5, spin: 0.9 }),
2882
- repeat(scaled(30), debris({ p: vadd(query("car", "position"), [0, 1.3, 0]), dir: UP9, cone: 1.3, sp: [2, 6], size: [0.06, 6e-3, 0.06], c: 11061464, life: 20 })),
3129
+ repeat(scaled(30), debris({ p: vadd(query("car", "position"), [0, 1.3, 0]), dir: UP10, cone: 1.3, sp: [2, 6], size: [0.06, 6e-3, 0.06], c: 11061464, life: 20 })),
2883
3130
  debris({ p: carPoint(0, 1, 1.4), v: [rnd(-1, 1), 9, rnd(-1, 1)], sp: 0, size: [1.6, 0.06, 1.2], c: 3808536, spin: 6, life: 20, bounce: 0.2 }),
2884
3131
  ...[-1, 1].map((side) => debris({ p: carPoint(side * 0.95, 0.7, 0.3), v: doorVelocity(side), sp: 0, size: [0.06, 0.7, 1.1], c: 3808536, spin: 5, life: 20, bounce: 0.2 })),
2885
3132
  debris({ p: carPoint(0.95, 0.38, 1.35), v: [3, 4, 2], sp: 0, size: [0.3, 0.76, 0.76], c: 1118481, spin: 8, life: 20, bounce: 0.4 })
@@ -3061,7 +3308,7 @@ var INFECTION_PHASES = {
3061
3308
  };
3062
3309
 
3063
3310
  // src/effects/screen/panic.ts
3064
- var WALKERS = 6;
3311
+ var WALKERS2 = 6;
3065
3312
  var NEAR = 9;
3066
3313
  var RANGE = 7;
3067
3314
  var RESTING_BPM = 70;
@@ -3077,7 +3324,7 @@ var PANIC = {
3077
3324
  setup: [
3078
3325
  cue("zombie_visible", { index: -1, visible: false }),
3079
3326
  repeat(
3080
- WALKERS,
3327
+ WALKERS2,
3081
3328
  set("startX", rnd(-4, 4)),
3082
3329
  set("startZ", sub(rnd(-4, -2), mul(INDEX, 0.6))),
3083
3330
  behavior("walkers", "place", { index: INDEX, x: variable("startX"), z: variable("startZ"), facing: 0 }),
@@ -3087,7 +3334,7 @@ var PANIC = {
3087
3334
  timeline: [],
3088
3335
  tick: [
3089
3336
  set("nearest", 99),
3090
- repeat(WALKERS, set("nearest", min(variable("nearest"), vdist(walkerPoint, CAMERA_POSITION)))),
3337
+ repeat(WALKERS2, set("nearest", min(variable("nearest"), vdist(walkerPoint, CAMERA_POSITION)))),
3091
3338
  set("fear", clamp(div(sub(NEAR, variable("nearest")), RANGE), 0, 1)),
3092
3339
  set("bpm", add(RESTING_BPM, mul(BPM_RISE, variable("fear")))),
3093
3340
  when(lt(mod(div(mul(TIME, variable("bpm")), 60), 1), div(mul(DELTA, variable("bpm")), 60)), [screen({ set: { beat: add(0.4, mul(0.6, variable("fear"))) } })]),
@@ -3162,7 +3409,7 @@ var COUGH_AND_BREATH = {
3162
3409
 
3163
3410
  // src/effects/events.ts
3164
3411
  var FACING4 = [0, 0, 1];
3165
- var UP10 = [0, 1, 0];
3412
+ var UP11 = [0, 1, 0];
3166
3413
  var ORIGIN = [0, 0, 0];
3167
3414
  var FORWARD4 = [0, 0, -1];
3168
3415
  var IMPACT_MATERIALS = ["concrete", "metal", "wood", "glass", "flesh", "water"];
@@ -3292,14 +3539,163 @@ var EVENT_EFFECTS = [
3292
3539
  team: "destruction",
3293
3540
  budget: { particles: 20, debris: 8 },
3294
3541
  loop: 2,
3295
- timeline: [call2("chips", ORIGIN, UP10, 8, 0.9), call2("rust_at", ORIGIN, 6)]
3542
+ timeline: [call2("chips", ORIGIN, UP11, 8, 0.9), call2("rust_at", ORIGIN, 6)]
3296
3543
  }
3297
3544
  ];
3298
3545
 
3546
+ // src/effects/weapons/viewmodel.ts
3547
+ var PI = Math.PI;
3548
+ var SMOKE = { color: 9079430, width: 10, height: 8, gravity: -0.08, drag: 2.2, growth: 2.1 };
3549
+ var FLASH_SECONDS = 0.055;
3550
+ var FLASH_RAMP = [0.6, 0.9];
3551
+ var FLASH_OPACITY = 0.95;
3552
+ var FLAME_COLORS = [16742946, 16760896, 13121050, 16773296];
3553
+ var FLAME_ADDITIVE = 3;
3554
+ var ORIGIN2 = [0, 0, 0];
3555
+ var SIZE = variable("size");
3556
+ var wide = (width) => mul(sub(rand(), 0.5), width);
3557
+ var puff2 = (point, velocity, world, radius, life, opacity) => mesh({
3558
+ shape: "sphere",
3559
+ p: point,
3560
+ v: velocity,
3561
+ wv: world,
3562
+ r: radius,
3563
+ seg: SMOKE.width,
3564
+ seg2: SMOKE.height,
3565
+ life,
3566
+ c0: SMOKE.color,
3567
+ a: opacity,
3568
+ fade: true,
3569
+ lit: true,
3570
+ g: SMOKE.gravity,
3571
+ drag: SMOKE.drag,
3572
+ grow: SMOKE.growth
3573
+ });
3574
+ var flameBit = (point, velocity, world, radius, life) => [
3575
+ set("bitPoint", point),
3576
+ set("bitVelocity", velocity),
3577
+ set("bitWorld", world),
3578
+ set("bitRadius", radius),
3579
+ set("bitLife", life),
3580
+ set("bitColour", floor(mul(rand(), FLAME_COLORS.length))),
3581
+ mesh({
3582
+ shape: "icosahedron",
3583
+ p: variable("bitPoint"),
3584
+ v: variable("bitVelocity"),
3585
+ wv: variable("bitWorld"),
3586
+ r: variable("bitRadius"),
3587
+ seg: 1,
3588
+ rot: [mul(rand(), 3), mul(rand(), 3), 0],
3589
+ spin: [3, 4, 2],
3590
+ life: variable("bitLife"),
3591
+ c0: pick(FLAME_COLORS, variable("bitColour")),
3592
+ add: eq(variable("bitColour"), FLAME_ADDITIVE),
3593
+ a: 0.9,
3594
+ fade: true,
3595
+ g: -1.4,
3596
+ drag: 1.4,
3597
+ grow: 2.2
3598
+ })
3599
+ ];
3600
+ var flashPiece = (shape, radius, height, width, at3, rot, color) => mesh({ shape, r: radius, ...height === void 0 ? {} : { h: height }, seg: width, seg2: shape === "sphere" ? 8 : 1, p: ORIGIN2, at: at3, rot, roll: variable("roll"), ramp: FLASH_RAMP, life: FLASH_SECONDS, c0: color, a: FLASH_OPACITY, add: true });
3601
+ var MUZZLE_FLASH2 = {
3602
+ id: "viewmodel_muzzle_flash",
3603
+ pageId: "event:viewmodel_muzzle_flash",
3604
+ team: "weapons",
3605
+ budget: { particles: 12, lights: 1 },
3606
+ loop: 0.1,
3607
+ timeline: [
3608
+ set("angles", []),
3609
+ repeat(4, append("angles", add(div(mul(INDEX, PI), 2), mul(rand(), 0.6)))),
3610
+ set("roll", mul(rand(), PI)),
3611
+ flash(ORIGIN2, 16756832, mul(4, SIZE), FLASH_SECONDS, mul(2, SIZE), true, true),
3612
+ flashPiece("cone_open", mul(0.013, SIZE), mul(0.085, SIZE), 10, [mul(0.042, SIZE), 0, 0], [0, 0, -PI / 2], 16757575),
3613
+ repeat(
3614
+ 4,
3615
+ set("angle", pick(variable("angles"), INDEX)),
3616
+ flashPiece(
3617
+ "cone",
3618
+ mul(5e-3, SIZE),
3619
+ mul(0.04, SIZE),
3620
+ 6,
3621
+ [mul(0.012, SIZE), mul(cos(variable("angle")), 0.016, SIZE), mul(sin(variable("angle")), 0.016, SIZE)],
3622
+ [variable("angle"), 0, -PI / 2],
3623
+ 16757575
3624
+ )
3625
+ ),
3626
+ flashPiece("sphere", mul(0.016, SIZE), void 0, 12, [mul(8e-3, SIZE), 0, 0], [0, 0, 0], 16773568),
3627
+ repeat(
3628
+ 6,
3629
+ puff2(
3630
+ ORIGIN2,
3631
+ [add(0.15, mul(rand(), 0.35)), add(0.03, mul(rand(), 0.12)), mul(sub(rand(), 0.5), 0.14)],
3632
+ [0, 0, 0],
3633
+ mul(0.013, SIZE),
3634
+ add(1.3, mul(rand(), 0.6)),
3635
+ 0.45
3636
+ )
3637
+ )
3638
+ ]
3639
+ };
3640
+ var SMOKE_PUFF = {
3641
+ id: "weapon_smoke_puff",
3642
+ pageId: "event:weapon_smoke_puff",
3643
+ team: "weapons",
3644
+ budget: { particles: 1 },
3645
+ loop: 0.1,
3646
+ timeline: [puff2(ORIGIN2, void 0, [variable("vx"), variable("vy"), variable("vz")], variable("radius"), variable("life"), variable("opacity"))]
3647
+ };
3648
+ var BACKBLAST = {
3649
+ id: "launcher_backblast",
3650
+ pageId: "event:launcher_backblast",
3651
+ team: "weapons",
3652
+ budget: { particles: 40 },
3653
+ loop: 0.1,
3654
+ timeline: [
3655
+ repeat(26, puff2(ORIGIN2, [neg(add(1.5, mul(rand(), 3))), 0, 0], [wide(1.4), wide(0.8), wide(1.4)], add(0.03, mul(rand(), 0.03)), add(1.8, mul(rand(), 1.4)), 0.5)),
3656
+ repeat(14, ...flameBit(ORIGIN2, [neg(add(2, mul(rand(), 2))), 0, 0], [wide(1), wide(0.6), wide(1)], 0.02, 0.25))
3657
+ ]
3658
+ };
3659
+ var FLAME_JET = {
3660
+ id: "flame_jet",
3661
+ pageId: "event:flame_jet",
3662
+ team: "weapons",
3663
+ budget: { particles: 30 },
3664
+ loop: 0.1,
3665
+ timeline: [
3666
+ repeat(
3667
+ floor(mul(420, variable("dt"), variable("scale"))),
3668
+ set("speed", mul(add(2.2, mul(rand(), 1.1)), variable("scale"))),
3669
+ ...flameBit(
3670
+ [mul(rand(), variable("speed"), min(variable("dt"), 0.3)), 0, 0],
3671
+ [variable("speed"), 0, 0],
3672
+ [wide(0.35), mul(sub(rand(), 0.3), 0.3), wide(0.35)],
3673
+ add(0.02, mul(rand(), 0.022)),
3674
+ add(0.4, mul(rand(), 0.35))
3675
+ )
3676
+ ),
3677
+ when(lt(rand(), 0.5), [
3678
+ puff2([add(mul(1.1, variable("scale")), mul(rand(), 0.4)), 0, 0], void 0, [mul(vx(DIRECTION), 0.6), 0.35, mul(vz(DIRECTION), 0.6)], 0.03, 1.6, 0.4)
3679
+ ])
3680
+ ]
3681
+ };
3682
+ var VIEWMODEL_EFFECTS = [MUZZLE_FLASH2, SMOKE_PUFF, BACKBLAST, FLAME_JET];
3683
+
3684
+ // src/effects/vehicles/game-effects.ts
3685
+ var aliasOf = (base, id, changes) => ({ ...base, id, pageId: `vehicle:${id}`, anchor: CAR_ORIGIN2, ...changes });
3686
+ var VEHICLE_EFFECTS = [
3687
+ /** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
3688
+ aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
3689
+ /** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
3690
+ aliasOf(ENGINE_SMOKE, "vehicle_exhaust", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 0 }, loop: 0.5 }),
3691
+ /** A hole in the tank: the page's own petrol leak (drips, pool, sparks, fire running to the tank). */
3692
+ aliasOf(FUEL_LEAK, "vehicle_leak", {})
3693
+ ];
3694
+
3299
3695
  // src/effects/catalog.ts
3300
- var ALL_EFFECTS = [BLOOD_HIT, HEADSHOT, DISMEMBER, BLOATER_CLOUD, SCREAMER_SHRIEK, CORPSE_DECAY, REANIMATION, EYES_IN_FOG, MUZZLE_FLASH, IMPACT_BY_MATERIAL, PENETRATION, CASINGS_AND_MAGAZINE, MOLOTOV, GRENADE, EXPLOSIVE_BARREL, SHOPFRONT_GLASS, DOOR_STAGES, BUILDING_COLLAPSE, BLOCK_WALL, METAL_DOOR_EFFECT, IRON_RAILING, WOODEN_FENCE, HIT_POINT_BREAKAGE, PRESSURE_CYLINDERS, BUILDING_FIRE, SCRAPING_SPARKS, ENGINE_SMOKE, FUEL_LEAK, CAR_EXPLOSION, WINDSHIELD, DAMAGE_AND_BITE, INFECTION_PHASES, PANIC, BLOATER_BLINDNESS, CAMPFIRE, COUGH_AND_BREATH];
3696
+ var ALL_EFFECTS = [BLOOD_HIT, HEADSHOT, DISMEMBER, BLOATER_CLOUD, SCREAMER_SHRIEK, CORPSE_DECAY, REANIMATION, EYES_IN_FOG, MUZZLE_FLASH, IMPACT_BY_MATERIAL, PENETRATION, CASINGS_AND_MAGAZINE, MOLOTOV, GRENADE, EXPLOSIVE_BARREL, SHOPFRONT_GLASS, DOOR_STAGES, BUILDING_COLLAPSE, BLOCK_WALL, METAL_DOOR_EFFECT, IRON_RAILING, WOODEN_FENCE, HIT_POINT_BREAKAGE, PRESSURE_CYLINDERS, BUILDING_FIRE, RAIN_AND_PUDDLES, FOG_AND_ASH, SCRAPING_SPARKS, ENGINE_SMOKE, FUEL_LEAK, CAR_EXPLOSION, WINDSHIELD, HEADLIGHTS_IN_RAIN, DAMAGE_AND_BITE, INFECTION_PHASES, PANIC, BLOATER_BLINDNESS, CAMPFIRE, COUGH_AND_BREATH];
3301
3697
  var WORKSHOP_EFFECTS = Object.fromEntries(ALL_EFFECTS.map((effect) => [effect.id, effect]));
3302
- var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries(EVENT_EFFECTS.map((effect) => [effect.id, effect])) };
3698
+ var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries([...EVENT_EFFECTS, ...VIEWMODEL_EFFECTS, ...VEHICLE_EFFECTS].map((effect) => [effect.id, effect])) };
3303
3699
  function patchEffects(base, changes) {
3304
3700
  const result = { ...base };
3305
3701
  for (const [id, change] of Object.entries(changes)) {
@@ -3437,7 +3833,7 @@ function impact(engine, material, point, normal, scale = 1, age = 0) {
3437
3833
  // src/effects/behaviors/blocks.ts
3438
3834
  var COLUMNS = 6;
3439
3835
  var ROWS = 5;
3440
- var ORIGIN2 = [-2.2, 0, 2.6];
3836
+ var ORIGIN3 = [-2.2, 0, 2.6];
3441
3837
  var BLOCK_SIZE = [0.5, 0.44, 0.25];
3442
3838
  var OBJECT_ID_DRAWS2 = 4;
3443
3839
  var FLOOR2 = 0.13;
@@ -3480,7 +3876,7 @@ function createBlocksBehavior() {
3480
3876
  const chipScale = random.between(0.8, 1.3) * scale;
3481
3877
  for (let draw = 0; draw < OBJECT_ID_DRAWS2; draw++) random.next();
3482
3878
  best.holes.push({ x: offsetX, y: offsetY, scale, chipTurn, chipScale });
3483
- impact(host.engine, "concrete", [ORIGIN2[0] + x, y, ORIGIN2[2] + 0.13], [0, 0, 1], 0.8);
3879
+ impact(host.engine, "concrete", [ORIGIN3[0] + x, y, ORIGIN3[2] + 0.13], [0, 0, 1], 0.8);
3484
3880
  } else if (action === "collapse") {
3485
3881
  const { x, y } = args;
3486
3882
  for (const block of blocks) {
@@ -3532,7 +3928,7 @@ function createBlocksBehavior() {
3532
3928
  }
3533
3929
 
3534
3930
  // src/effects/behaviors/car.ts
3535
- var ORIGIN3 = [5.6, 0, 0.8];
3931
+ var ORIGIN4 = [5.6, 0, 0.8];
3536
3932
  var MAX_TILT = 0.25;
3537
3933
  function createCarBehavior() {
3538
3934
  let y = 0;
@@ -3564,8 +3960,13 @@ function createCarBehavior() {
3564
3960
  }
3565
3961
  }
3566
3962
  },
3567
- query(_host, name) {
3568
- if (name === "position") return [ORIGIN3[0], y, ORIGIN3[2]];
3963
+ query(_host, name, args) {
3964
+ if (name === "position") return [ORIGIN4[0], y, ORIGIN4[2]];
3965
+ if (name === "point") {
3966
+ const [x, py, z] = args;
3967
+ const point = carPoint(x, py, z);
3968
+ return [point[0], point[1] + y, point[2]];
3969
+ }
3569
3970
  if (name === "roll") return roll;
3570
3971
  throw new Error(`car: unknown query ${name}`);
3571
3972
  },
@@ -3774,6 +4175,31 @@ function createPlateBehavior(geometry = METAL_DOOR) {
3774
4175
  };
3775
4176
  }
3776
4177
 
4178
+ // src/effects/behaviors/rain.ts
4179
+ function createRainBehavior() {
4180
+ return {
4181
+ reset() {
4182
+ },
4183
+ act(host, action, args) {
4184
+ const { engine, camera: camera2 } = host;
4185
+ if (action === "init") {
4186
+ const { count, wind } = args;
4187
+ engine.rain.init(count, wind);
4188
+ } else if (action === "update") {
4189
+ const { dt, splash } = args;
4190
+ engine.rain.update(dt, splash, camera2.position);
4191
+ }
4192
+ },
4193
+ query(host, name) {
4194
+ if (name === "count") return host.engine.rain.count;
4195
+ if (name === "on") return host.engine.rain.on;
4196
+ throw new Error(`rain: unknown query ${name}`);
4197
+ },
4198
+ update() {
4199
+ }
4200
+ };
4201
+ }
4202
+
3777
4203
  // src/effects/behaviors/walkers.ts
3778
4204
  var WALKER_COUNT = 10;
3779
4205
  var ARRIVAL_DISTANCE = 0.05;
@@ -3842,7 +4268,8 @@ var WORKSHOP_BEHAVIORS = {
3842
4268
  blocks: () => createBlocksBehavior(),
3843
4269
  plate: () => createPlateBehavior(),
3844
4270
  cylinder: () => createCylinderBehavior(),
3845
- car: () => createCarBehavior()
4271
+ car: () => createCarBehavior(),
4272
+ rain: () => createRainBehavior()
3846
4273
  };
3847
4274
  function createWorkshopBehaviors(factories = WORKSHOP_BEHAVIORS) {
3848
4275
  return Object.fromEntries(Object.entries(factories).map(([id, make]) => [id, make()]));
@@ -3920,6 +4347,8 @@ function evaluateCall(name, args) {
3920
4347
  return Math.abs(asNumber(first));
3921
4348
  case "sqrt":
3922
4349
  return Math.sqrt(asNumber(first));
4350
+ case "exp":
4351
+ return Math.exp(asNumber(first));
3923
4352
  case "sin":
3924
4353
  return Math.sin(asNumber(first));
3925
4354
  case "cos":
@@ -4040,7 +4469,7 @@ function resolve(value, context) {
4040
4469
  }
4041
4470
 
4042
4471
  // src/effects/builders/fire.ts
4043
- var UP11 = [0, 1, 0];
4472
+ var UP12 = [0, 1, 0];
4044
4473
  var ZERO = [0, 0, 0];
4045
4474
  var FULL_TURN_DRAWN = 6.283;
4046
4475
  function scaledSizes(range, factor) {
@@ -4053,7 +4482,7 @@ function fireEmit(engine, key, dt, centre, radius, factor, options = {}) {
4053
4482
  p: centre,
4054
4483
  r: radius,
4055
4484
  flat: true,
4056
- dir: options.dir ?? UP11,
4485
+ dir: options.dir ?? UP12,
4057
4486
  cone: 0.35,
4058
4487
  sp: [0.4, 1.4],
4059
4488
  v: wind,
@@ -4070,7 +4499,7 @@ function fireEmit(engine, key, dt, centre, radius, factor, options = {}) {
4070
4499
  p: centre,
4071
4500
  r: radius * 0.6,
4072
4501
  flat: true,
4073
- dir: UP11,
4502
+ dir: UP12,
4074
4503
  cone: 0.3,
4075
4504
  sp: [0.3, 0.8],
4076
4505
  life: [0.2, 0.4],
@@ -4085,14 +4514,14 @@ function fireEmit(engine, key, dt, centre, radius, factor, options = {}) {
4085
4514
  if (engine.quality < 2) {
4086
4515
  engine.emit(`${key}e`, "streak", 10 * factor, dt, () => {
4087
4516
  const jitter = plus(wind, engine.random.between(-0.4, 0.4), 0, engine.random.between(-0.4, 0.4));
4088
- return { p: centre, box: [radius, 0, radius], dir: UP11, cone: 0.5, sp: [1.5, 3.5], v: jitter, life: [0.8, 1.8], len: 0.03, c0: 16756816, c1: 6295552, g: -0.6, drag: 0.4 };
4517
+ return { p: centre, box: [radius, 0, radius], dir: UP12, cone: 0.5, sp: [1.5, 3.5], v: jitter, life: [0.8, 1.8], len: 0.03, c0: 16756816, c1: 6295552, g: -0.6, drag: 0.4 };
4089
4518
  });
4090
4519
  }
4091
4520
  if (options.noSmoke) return;
4092
4521
  engine.emit(`${key}s`, "normal", (options.smoke || 14) * factor, dt, () => ({
4093
4522
  p: plus(centre, 0, 0.8 * sqrtFactor, 0),
4094
4523
  r: radius * 0.7,
4095
- dir: UP11,
4524
+ dir: UP12,
4096
4525
  cone: 0.35,
4097
4526
  sp: [0.6, 1.4],
4098
4527
  v: wind,
@@ -4132,15 +4561,15 @@ function explode(engine, point, scale, cameraPosition, chipColor) {
4132
4561
  engine.screen.shake += 0.7 * scale;
4133
4562
  engine.screen.white += 0.18 * scale;
4134
4563
  engine.burst("add", 55 * scale, { p: point, r: 0.3 * scale, sp: [2, 7 * scale], drag: 4, life: [0.25, 0.6], size: [0.7 * scale, 1.4 * scale], grow: 1.7, c0: 16773296, c1: 10103304, fi: 0.04 });
4135
- engine.burst("add", 28 * scale, { p: plus(point, 0, 0.3, 0), r: 0.3, dir: UP11, cone: 0.7, sp: [2, 5 * scale], drag: 1.5, life: [0.6, 1.1], size: [0.6 * scale, 1 * scale], grow: 1.3, c0: 16760928, c1: 5902853, g: -2, fi: 0.05 });
4564
+ engine.burst("add", 28 * scale, { p: plus(point, 0, 0.3, 0), r: 0.3, dir: UP12, cone: 0.7, sp: [2, 5 * scale], drag: 1.5, life: [0.6, 1.1], size: [0.6 * scale, 1 * scale], grow: 1.3, c0: 16760928, c1: 5902853, g: -2, fi: 0.05 });
4136
4565
  engine.ring([plus(point, 0, 0.05, 0), 0.3, 7 * scale, 0.55, 16767136]);
4137
4566
  const toCamera = normalized([cameraPosition[0] - point[0], cameraPosition[1] - point[1], cameraPosition[2] - point[2]]);
4138
4567
  engine.ring([plus(point, 0, 1, 0), 0.3, 5 * scale, 0.35, 16773328, toCamera]);
4139
- engine.burst("normal", 32 * scale, { p: plus(point, 0, 0.6, 0), r: 0.8 * scale, dir: UP11, cone: 1.1, sp: [1, 3], drag: 1.2, life: [3, 6], size: [1 * scale, 1.8 * scale], grow: 2.6, c0: 2828068, c1: 987155, a: 0.6, fi: 0.18, g: -0.35 });
4568
+ engine.burst("normal", 32 * scale, { p: plus(point, 0, 0.6, 0), r: 0.8 * scale, dir: UP12, cone: 1.1, sp: [1, 3], drag: 1.2, life: [3, 6], size: [1 * scale, 1.8 * scale], grow: 2.6, c0: 2828068, c1: 987155, a: 0.6, fi: 0.18, g: -0.35 });
4140
4569
  ringOfDust(engine, point, scale);
4141
- if (engine.quality < 2) engine.burst("streak", 44 * scale, { p: point, dir: UP11, cone: 1.45, sp: [10, 26], life: [0.3, 0.7], len: 0.03, c0: 16760944, c1: 8396800, g: 9.8, gnd: 2 });
4570
+ if (engine.quality < 2) engine.burst("streak", 44 * scale, { p: point, dir: UP12, cone: 1.45, sp: [10, 26], life: [0.3, 0.7], len: 0.03, c0: 16760944, c1: 8396800, g: 9.8, gnd: 2 });
4142
4571
  for (let index = 0; index < engine.scaled(16 * scale); index++) {
4143
- engine.debrisPiece({ p: point, dir: UP11, cone: 1.2, sp: [3, 9], size: [0.12, 0.06, 0.1], k: [0.6, 1.6], c: chipColor || 2762274, life: 9 });
4572
+ engine.debrisPiece({ p: point, dir: UP12, cone: 1.2, sp: [3, 9], size: [0.12, 0.06, 0.1], k: [0.6, 1.6], c: chipColor || 2762274, life: 9 });
4144
4573
  }
4145
4574
  engine.decal([point[0], engine.context.groundAt(point[0], point[2]), point[2], 3 * scale, 657930, { grow: 0.15, life: 60 }]);
4146
4575
  }
@@ -4291,6 +4720,7 @@ var EffectInstance = class {
4291
4720
  if (!def) return;
4292
4721
  this.schedule.clear();
4293
4722
  this.variables.clear();
4723
+ for (const [name, value] of Object.entries(this.setup.values ?? {})) this.variables.set(name, value);
4294
4724
  for (const behavior2 of this.deps.behaviors()) behavior2.reset(this.host);
4295
4725
  this.time = 0;
4296
4726
  this.within(() => {
@@ -4349,6 +4779,10 @@ var EffectInstance = class {
4349
4779
  return engine.spawn(step.system, this.value(step.spawn));
4350
4780
  case "emit":
4351
4781
  return engine.emit(step.key, step.system, this.value(step.rate), this.dt, () => this.value(step.spawn));
4782
+ case "mesh": {
4783
+ engine.mesh(this.value(step.spawn));
4784
+ return;
4785
+ }
4352
4786
  case "debris":
4353
4787
  return engine.debrisPiece(this.value(step.spawn));
4354
4788
  case "decal":
@@ -4432,7 +4866,7 @@ var EffectInstance = class {
4432
4866
  };
4433
4867
 
4434
4868
  // src/effects/player.ts
4435
- var ORIGIN4 = [0, 0, 0];
4869
+ var ORIGIN5 = [0, 0, 0];
4436
4870
  var DEFAULT_HEADING = [0, 0, -1];
4437
4871
  var DEFAULT_MAX_INSTANCES = 48;
4438
4872
  var ENDLESS_SECONDS = 60;
@@ -4477,7 +4911,7 @@ function createEffectPlayer(options) {
4477
4911
  }
4478
4912
  function placementOf(entry) {
4479
4913
  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;
4480
- return { origin, anchor: entry.anchor, yaw: entry.yaw };
4914
+ return { origin, anchor: entry.anchor, yaw: entry.yaw, ...entry.orientation ? { orientation: entry.orientation } : {} };
4481
4915
  }
4482
4916
  function drawing(entry, action) {
4483
4917
  const context = engine.context;
@@ -4501,8 +4935,9 @@ function createEffectPlayer(options) {
4501
4935
  random: playOptions.seed !== void 0 ? streamOf(playOptions.seed) : void 0,
4502
4936
  follow: playOptions.follow,
4503
4937
  origin: point,
4504
- anchor: def.anchor ?? ORIGIN4,
4938
+ anchor: def.anchor ?? ORIGIN5,
4505
4939
  yaw: yawOf(heading, playOptions.direction),
4940
+ orientation: playOptions.orientation,
4506
4941
  seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS)
4507
4942
  };
4508
4943
  playing.push(entry);
@@ -4511,7 +4946,8 @@ function createEffectPlayer(options) {
4511
4946
  () => instance.begin(def, paramIndex(def, playOptions.param), {
4512
4947
  placement: placementOf(entry),
4513
4948
  ...playOptions.direction ? { direction: playOptions.direction } : {},
4514
- ...playOptions.normal ? { normal: playOptions.normal } : {}
4949
+ ...playOptions.normal ? { normal: playOptions.normal } : {},
4950
+ ...playOptions.values ? { values: playOptions.values } : {}
4515
4951
  })
4516
4952
  );
4517
4953
  return entry.handle;
@@ -4782,15 +5218,15 @@ function spawnShock(pool, spec) {
4782
5218
  return shock;
4783
5219
  }
4784
5220
  function pushPuffs(puffs, shock, reach, dt, age) {
4785
- for (const puff2 of puffs) {
4786
- if (puff2.ring || puff2.t > PUSH_AGE_LIMIT) continue;
4787
- const dx = puff2.x - shock.x;
4788
- const dz = puff2.z - shock.z;
5221
+ for (const puff3 of puffs) {
5222
+ if (puff3.ring || puff3.t > PUSH_AGE_LIMIT) continue;
5223
+ const dx = puff3.x - shock.x;
5224
+ const dz = puff3.z - shock.z;
4789
5225
  const distance = Math.hypot(dx, dz) + 1e-3;
4790
- if (Math.abs(distance - reach) < PUSH_BAND && puff2.y < PUSH_CEILING) {
5226
+ if (Math.abs(distance - reach) < PUSH_BAND && puff3.y < PUSH_CEILING) {
4791
5227
  const strength = 4 * dt * (1 - age);
4792
- puff2.vx += dx / distance * strength * 6;
4793
- puff2.vz += dz / distance * strength * 6;
5228
+ puff3.vx += dx / distance * strength * 6;
5229
+ puff3.vz += dz / distance * strength * 6;
4794
5230
  }
4795
5231
  }
4796
5232
  }
@@ -5092,10 +5528,10 @@ function composeMushroom(context, spec) {
5092
5528
  const life = random.between(ring2.life * 0.75, ring2.life);
5093
5529
  const h0 = random.between(1, 1.25);
5094
5530
  const hl = random.between(0.9, 1.6);
5095
- const puff2 = addPuff(core, random, { x, y, z, s0: spec.radius * 0.2, s1, sg: spec.radius * 0.06, gk: 3, life, h0, hl, color, kind: 0 });
5096
- puff2.ring = ring2;
5097
- puff2.ph = random.next() * Math.PI * 2;
5098
- puff2.th = random.next() * Math.PI * 2;
5531
+ const puff3 = addPuff(core, random, { x, y, z, s0: spec.radius * 0.2, s1, sg: spec.radius * 0.06, gk: 3, life, h0, hl, color, kind: 0 });
5532
+ puff3.ring = ring2;
5533
+ puff3.ph = random.next() * Math.PI * 2;
5534
+ puff3.th = random.next() * Math.PI * 2;
5099
5535
  }
5100
5536
  const stemCount = Math.round((spec.stem || 18) * Math.max(lod, 0.4));
5101
5537
  for (let index = 0; index < stemCount; index++) {
@@ -5919,7 +6355,7 @@ var SpriteKindSystem = class {
5919
6355
  // src/workshop/direction.ts
5920
6356
  var TWO_PI_ROUNDED = 6.2832;
5921
6357
  var WIDE_CONE = 3.1;
5922
- var UP12 = [0, 1, 0];
6358
+ var UP13 = [0, 1, 0];
5923
6359
  function drawRange(random, range) {
5924
6360
  if (Array.isArray(range)) return random.between(range[0], range[1]);
5925
6361
  return range || 0;
@@ -5947,7 +6383,7 @@ function cross(out, a, b) {
5947
6383
  }
5948
6384
  function coneDirection(random, direction, cone, out) {
5949
6385
  if (cone >= WIDE_CONE) return randomUnit(random, out);
5950
- const [dx, dy, dz] = direction ?? UP12;
6386
+ const [dx, dy, dz] = direction ?? UP13;
5951
6387
  const cosTilt = 1 - random.next() * (1 - Math.cos(cone));
5952
6388
  const sinTilt = Math.sqrt(1 - cosTilt * cosTilt);
5953
6389
  const phase = random.next() * TWO_PI_ROUNDED;
@@ -6071,12 +6507,12 @@ var DebrisPool = class {
6071
6507
 
6072
6508
  // src/workshop/decals.ts
6073
6509
  var CAPACITY2 = 400;
6074
- var UP13 = [0, 1, 0];
6510
+ var UP14 = [0, 1, 0];
6075
6511
  var DEFAULT_LIFE2 = 60;
6076
6512
  var DEFAULT_GROW = 1.2;
6077
6513
  var EVAPORATION = { fuel: [6, 5], water: [40, 20] };
6078
6514
  function createDecal() {
6079
- return { on: false, x: 0, y: 0, z: 0, sx: 0, sy: 0, t: 0, life: 0, grow: 0, color: 0, normal: UP13, fluid: void 0, dryColor: -1, dryAt: 0, dryTime: 0 };
6515
+ return { on: false, x: 0, y: 0, z: 0, sx: 0, sy: 0, t: 0, life: 0, grow: 0, color: 0, normal: UP14, fluid: void 0, dryColor: -1, dryAt: 0, dryTime: 0 };
6080
6516
  }
6081
6517
  var DecalPool = class {
6082
6518
  constructor(context) {
@@ -6089,7 +6525,7 @@ var DecalPool = class {
6089
6525
  const random = this.context.random;
6090
6526
  const index = this.next++ % CAPACITY2;
6091
6527
  const decal2 = this.decals[index];
6092
- const normal = options.n ?? UP13;
6528
+ const normal = options.n ?? UP14;
6093
6529
  random.between(0, 6.28);
6094
6530
  const offset = 4e-3 + index % 40 * 4e-4;
6095
6531
  decal2.on = true;
@@ -6131,6 +6567,96 @@ var DecalPool = class {
6131
6567
  }
6132
6568
  };
6133
6569
 
6570
+ // src/workshop/meshes.ts
6571
+ var CAPACITY3 = 400;
6572
+ var IDENTITY = [0, 0, 0, 1];
6573
+ function multiply(a, b) {
6574
+ const [ax, ay, az, aw] = a;
6575
+ const [bx, by, bz, bw] = b;
6576
+ return [aw * bx + ax * bw + ay * bz - az * by, aw * by - ax * bz + ay * bw + az * bx, aw * bz + ax * by - ay * bx + az * bw, aw * bw - ax * bx - ay * by - az * bz];
6577
+ }
6578
+ var aboutX = (angle) => [Math.sin(angle / 2), 0, 0, Math.cos(angle / 2)];
6579
+ var MeshPool = class {
6580
+ constructor(capacity = CAPACITY3) {
6581
+ __publicField(this, "capacity", capacity);
6582
+ __publicField(this, "particles", []);
6583
+ __publicField(this, "serial", 0);
6584
+ }
6585
+ get count() {
6586
+ return this.particles.length;
6587
+ }
6588
+ spawn(options, frame = IDENTITY) {
6589
+ const velocity = options.v ?? [0, 0, 0];
6590
+ const world = options.wv ?? [0, 0, 0];
6591
+ const particle = {
6592
+ id: ++this.serial,
6593
+ shape: options.shape,
6594
+ radius: options.r,
6595
+ height: options.h ?? 0,
6596
+ segments: options.seg ?? 0,
6597
+ segments2: options.seg2 ?? 0,
6598
+ color: options.c0,
6599
+ additive: options.add === true,
6600
+ lit: options.lit === true,
6601
+ x: options.p[0],
6602
+ y: options.p[1],
6603
+ z: options.p[2],
6604
+ frame: options.roll ? multiply(frame, aboutX(options.roll)) : frame,
6605
+ at: options.at ?? [0, 0, 0],
6606
+ rx: options.rot?.[0] ?? 0,
6607
+ ry: options.rot?.[1] ?? 0,
6608
+ rz: options.rot?.[2] ?? 0,
6609
+ scale: 1,
6610
+ opacity: options.a,
6611
+ age: 0,
6612
+ life: options.life,
6613
+ vx: velocity[0] + world[0],
6614
+ vy: velocity[1] + world[1],
6615
+ vz: velocity[2] + world[2],
6616
+ spin: options.spin ?? [0, 0, 0],
6617
+ gravity: options.g ?? 0,
6618
+ drag: options.drag ?? 0,
6619
+ grow: options.grow ?? 0,
6620
+ ramp: options.ramp,
6621
+ fade: options.fade === true,
6622
+ startOpacity: options.a
6623
+ };
6624
+ this.particles.push(particle);
6625
+ if (this.particles.length > this.capacity) this.particles.shift();
6626
+ return particle;
6627
+ }
6628
+ update(dt) {
6629
+ const live = this.particles;
6630
+ for (let index = 0; index < live.length; index++) {
6631
+ const particle = live[index];
6632
+ particle.age += dt;
6633
+ if (particle.ramp ? particle.age >= particle.life : particle.age > particle.life) {
6634
+ live.splice(index--, 1);
6635
+ continue;
6636
+ }
6637
+ if (particle.fade) particle.opacity = Math.max(0, particle.startOpacity * (1 - particle.age / particle.life));
6638
+ particle.vy -= particle.gravity * dt;
6639
+ if (particle.drag) {
6640
+ const keep = Math.max(0, 1 - particle.drag * dt);
6641
+ particle.vx *= keep;
6642
+ particle.vy *= keep;
6643
+ particle.vz *= keep;
6644
+ }
6645
+ particle.x += particle.vx * dt;
6646
+ particle.y += particle.vy * dt;
6647
+ particle.z += particle.vz * dt;
6648
+ particle.rx += particle.spin[0] * dt;
6649
+ particle.ry += particle.spin[1] * dt;
6650
+ particle.rz += particle.spin[2] * dt;
6651
+ if (particle.grow) particle.scale *= 1 + particle.grow * dt;
6652
+ if (particle.ramp) particle.scale = particle.ramp[0] + Math.min(1, particle.age / particle.life) * particle.ramp[1];
6653
+ }
6654
+ }
6655
+ clear() {
6656
+ this.particles.length = 0;
6657
+ }
6658
+ };
6659
+
6134
6660
  // src/workshop/sprites.ts
6135
6661
  var DEFAULT_FADE_IN = 0.1;
6136
6662
  var FLOATS_PER_VECTOR = 3;
@@ -6427,11 +6953,11 @@ var StreakPool = class {
6427
6953
  // src/workshop/waves.ts
6428
6954
  var RING_CAPACITY = 120;
6429
6955
  var LIGHT_CAPACITY = 4;
6430
- var UP14 = [0, 1, 0];
6956
+ var UP15 = [0, 1, 0];
6431
6957
  var DEFAULT_LIGHT_DISTANCE = 14;
6432
6958
  var WaveRingPool = class {
6433
6959
  constructor() {
6434
- __publicField(this, "rings", Array.from({ length: RING_CAPACITY }, () => ({ on: false, point: UP14, from: 0, to: 0, t: 0, duration: 1, color: 0, normal: UP14, hold: 0 })));
6960
+ __publicField(this, "rings", Array.from({ length: RING_CAPACITY }, () => ({ on: false, point: UP15, from: 0, to: 0, t: 0, duration: 1, color: 0, normal: UP15, hold: 0 })));
6435
6961
  __publicField(this, "count", 0);
6436
6962
  __publicField(this, "next", 0);
6437
6963
  }
@@ -6444,7 +6970,7 @@ var WaveRingPool = class {
6444
6970
  ring2.t = 0;
6445
6971
  ring2.duration = duration;
6446
6972
  ring2.color = color;
6447
- ring2.normal = normal ?? UP14;
6973
+ ring2.normal = normal ?? UP15;
6448
6974
  ring2.hold = hold || 0;
6449
6975
  }
6450
6976
  clear() {
@@ -6464,7 +6990,7 @@ var WaveRingPool = class {
6464
6990
  var FlashLightPool = class {
6465
6991
  constructor(context) {
6466
6992
  __publicField(this, "context", context);
6467
- __publicField(this, "lights", Array.from({ length: LIGHT_CAPACITY }, () => ({ x: 0, y: 0, z: 0, color: 16760944, distance: DEFAULT_LIGHT_DISTANCE, peak: 0, duration: 1, t: 0, intensity: 0 })));
6993
+ __publicField(this, "lights", Array.from({ length: LIGHT_CAPACITY }, () => ({ x: 0, y: 0, z: 0, color: 16760944, distance: DEFAULT_LIGHT_DISTANCE, peak: 0, duration: 1, t: 0, intensity: 0, steady: false })));
6468
6994
  __publicField(this, "fire", [
6469
6995
  { x: 0, y: 0, z: 0, intensity: 0 },
6470
6996
  { x: 0, y: 0, z: 0, intensity: 0 }
@@ -6474,7 +7000,7 @@ var FlashLightPool = class {
6474
7000
  get lit() {
6475
7001
  return this.lights.filter((light) => light.intensity > 0).length;
6476
7002
  }
6477
- flash(point, color, intensity, duration, distance, force) {
7003
+ flash(point, color, intensity, duration, distance, force, steady) {
6478
7004
  const { level } = this.context.quality;
6479
7005
  if (level >= 1 && !force) return;
6480
7006
  if (level >= 2 && force !== "boom") return;
@@ -6487,6 +7013,7 @@ var FlashLightPool = class {
6487
7013
  light.peak = intensity;
6488
7014
  light.duration = duration;
6489
7015
  light.t = 0;
7016
+ light.steady = steady === true;
6490
7017
  light.intensity = intensity;
6491
7018
  }
6492
7019
  clear() {
@@ -6498,7 +7025,7 @@ var FlashLightPool = class {
6498
7025
  if (light.intensity <= 0) continue;
6499
7026
  light.t += dt;
6500
7027
  const age = light.t / light.duration;
6501
- light.intensity = age >= 1 ? 0 : light.peak * (1 - age) * (1 - age);
7028
+ light.intensity = age >= 1 ? 0 : light.steady ? light.peak : light.peak * (1 - age) * (1 - age);
6502
7029
  }
6503
7030
  }
6504
7031
  };
@@ -6508,6 +7035,14 @@ var QUALITY_MULTIPLIERS = [1, 0.5, 0.2];
6508
7035
  var FIRE_FLICKER_SWAY = 0.25;
6509
7036
  var FIRE_FLICKER_JITTER = 0.08;
6510
7037
  var LENS_FADE = 0.16;
7038
+ function rotate(q, v) {
7039
+ const [qx, qy, qz, qw] = q;
7040
+ const ix = qw * v[0] + qy * v[2] - qz * v[1];
7041
+ const iy = qw * v[1] + qz * v[0] - qx * v[2];
7042
+ const iz = qw * v[2] + qx * v[1] - qy * v[0];
7043
+ const iw = -qx * v[0] - qy * v[1] - qz * v[2];
7044
+ 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];
7045
+ }
6511
7046
  function workshopGround(x, z) {
6512
7047
  return z < -2.9 && z > -4.5 && Math.abs(x) < 13 ? 0.12 : 0;
6513
7048
  }
@@ -6521,6 +7056,8 @@ var WorkshopEngine = class {
6521
7056
  __publicField(this, "decals");
6522
7057
  __publicField(this, "rings", new WaveRingPool());
6523
7058
  __publicField(this, "lights");
7059
+ __publicField(this, "rain", new RainField(this));
7060
+ __publicField(this, "meshes", new MeshPool());
6524
7061
  __publicField(this, "screen", createScreenState());
6525
7062
  __publicField(this, "lens", []);
6526
7063
  __publicField(this, "post", {});
@@ -6554,7 +7091,11 @@ var WorkshopEngine = class {
6554
7091
  place(point) {
6555
7092
  const placement = this.placement;
6556
7093
  if (!placement) return point;
6557
- const { anchor, origin, yaw } = placement;
7094
+ const { anchor, origin, yaw, orientation } = placement;
7095
+ if (orientation) {
7096
+ const turned = rotate(orientation, [point[0] - anchor[0], point[1] - anchor[1], point[2] - anchor[2]]);
7097
+ return [origin[0] + turned[0], origin[1] + turned[1], origin[2] + turned[2]];
7098
+ }
6558
7099
  const x = point[0] - anchor[0];
6559
7100
  const z = point[2] - anchor[2];
6560
7101
  const cos2 = Math.cos(yaw);
@@ -6565,6 +7106,7 @@ var WorkshopEngine = class {
6565
7106
  turn(vector) {
6566
7107
  const placement = this.placement;
6567
7108
  if (!placement) return vector;
7109
+ if (placement.orientation) return rotate(placement.orientation, vector);
6568
7110
  const cos2 = Math.cos(placement.yaw);
6569
7111
  const sin2 = Math.sin(placement.yaw);
6570
7112
  return [cos2 * vector[0] + sin2 * vector[2], vector[1], -sin2 * vector[0] + cos2 * vector[2]];
@@ -6593,6 +7135,14 @@ var WorkshopEngine = class {
6593
7135
  }
6594
7136
  this.accumulators.set(key, carried);
6595
7137
  }
7138
+ /** A solid particle (a cone, a sphere): the group sits at `p` turned by the placement, `v` is turned with it and `wv` is not. */
7139
+ mesh(recipe) {
7140
+ const placement = this.placement;
7141
+ const options = placement ? { ...recipe, p: this.place(recipe.p), ...recipe.v ? { v: this.turn(recipe.v) } : {} } : recipe;
7142
+ this.context.trace?.("mesh", [options]);
7143
+ const grouped = recipe.at !== void 0 || recipe.roll !== void 0;
7144
+ return this.meshes.spawn(options, placement && grouped ? placement.orientation ?? [0, Math.sin(placement.yaw / 2), 0, Math.cos(placement.yaw / 2)] : void 0);
7145
+ }
6596
7146
  debrisPiece(recipe) {
6597
7147
  const options = this.placed(recipe);
6598
7148
  this.context.trace?.("debris", [options]);
@@ -6613,10 +7163,11 @@ var WorkshopEngine = class {
6613
7163
  this.context.trace?.("ring", args);
6614
7164
  this.rings.add(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
6615
7165
  }
7166
+ /** `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. */
6616
7167
  flash(recipe) {
6617
- const args = this.placement ? [this.place(recipe[0]), recipe[1], recipe[2], recipe[3], recipe[4], recipe[5]] : recipe;
6618
- this.context.trace?.("flash", args);
6619
- this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5]);
7168
+ const args = this.placement ? [this.place(recipe[0]), recipe[1], recipe[2], recipe[3], recipe[4], recipe[5], recipe[6]] : recipe;
7169
+ this.context.trace?.("flash", args.slice(0, 6));
7170
+ this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
6620
7171
  }
6621
7172
  /** `fireLight` (W400): sways with the clock and flickers with one draw. */
6622
7173
  fireLight(slot, recipe, intensity, time) {
@@ -6641,6 +7192,7 @@ var WorkshopEngine = class {
6641
7192
  this.debris.update(dt);
6642
7193
  this.decals.update(dt);
6643
7194
  this.rings.update(dt);
7195
+ this.meshes.update(dt);
6644
7196
  this.lights.update(dt);
6645
7197
  updateScreen(this.screen, dt);
6646
7198
  for (let index = this.lens.length - 1; index >= 0; index--) {
@@ -6657,7 +7209,9 @@ var WorkshopEngine = class {
6657
7209
  this.debris.clear();
6658
7210
  this.decals.clear();
6659
7211
  this.rings.clear();
7212
+ this.meshes.clear();
6660
7213
  this.lights.clear();
7214
+ this.rain.clear();
6661
7215
  this.accumulators.clear();
6662
7216
  resetScreenState(this.screen);
6663
7217
  this.lens.length = 0;
@@ -6807,16 +7361,16 @@ function createVfx(options = {}) {
6807
7361
  },
6808
7362
  push(point, radius, speed) {
6809
7363
  spriteSystem.push(point, radius, speed);
6810
- for (const puff2 of core.puffs.items) {
6811
- const dx = puff2.x - point[0];
6812
- const dy = puff2.y - point[1];
6813
- const dz = puff2.z - point[2];
7364
+ for (const puff3 of core.puffs.items) {
7365
+ const dx = puff3.x - point[0];
7366
+ const dy = puff3.y - point[1];
7367
+ const dz = puff3.z - point[2];
6814
7368
  const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
6815
7369
  if (distance >= radius) continue;
6816
7370
  const strength = speed * (1 - distance / radius) / (distance + 1e-3);
6817
- puff2.vx += dx * strength;
6818
- puff2.vy += dy * strength;
6819
- puff2.vz += dz * strength;
7371
+ puff3.vx += dx * strength;
7372
+ puff3.vy += dy * strength;
7373
+ puff3.vz += dz * strength;
6820
7374
  }
6821
7375
  },
6822
7376
  stop(handle) {
@@ -6833,6 +7387,12 @@ function createVfx(options = {}) {
6833
7387
  camera2.y = position[1];
6834
7388
  camera2.z = position[2];
6835
7389
  },
7390
+ setWind(next) {
7391
+ wind.x = next[0];
7392
+ wind.y = next[1];
7393
+ wind.z = next[2];
7394
+ },
7395
+ wind: () => [wind.x, wind.y, wind.z],
6836
7396
  forceLod(scale) {
6837
7397
  core.clock.forcedLod = scale;
6838
7398
  },
@@ -7184,6 +7744,27 @@ var en = {
7184
7744
  budget: "Up to 600 particles per building and 2 fire lights. Beyond 80 m only the smoke column and the glow of the windows remain, which become a landmark.",
7185
7745
  network: "A fire entity on the server per building, with a spread state."
7186
7746
  },
7747
+ rain_and_puddles: {
7748
+ name: "Rain, splashes and puddles",
7749
+ short: "Drops with wind, splashes and rings only near the camera, lightning in the storm.",
7750
+ cost: "\u2264 4,000 drops",
7751
+ costNote: "splash up to 12 m",
7752
+ paramLabel: "Intensity",
7753
+ when: "The weather of the world. Rain raises the background noise and masks footsteps (it can be used for stealth).",
7754
+ look: "A fine drizzle, almost vertical. Rain with splashes on the asphalt and rings in the puddles, which are dark and mirror-like. A storm with drops slanted by the wind, sheets of water passing and a double flash of lightning that lights the scene for 0.2 s and reveals the horde.",
7755
+ budget: "Up to 4,000 drops tied to the camera in a 30 m box. Splashes and rings only within 12 m and only on what the camera sees.",
7756
+ network: "The server sends the weather and the lightning seed, so everyone sees the same flash."
7757
+ },
7758
+ fog_and_ash: {
7759
+ name: "Fog and ash",
7760
+ short: "Low layered mist, ash falling and the lamp post with its cone of light.",
7761
+ cost: "\u2264 120 sprites",
7762
+ costNote: "1 cone of light",
7763
+ when: "Before dawn, near the river and in burnt zones (ash). It cuts the sight of the zombies and of the player.",
7764
+ look: "The engine fog plus a layer of low mist that moves slowly, fine ash falling in a spiral and the beam of the lamp posts in view. Zombie silhouettes show before their details.",
7765
+ budget: "Up to 60 large mist sprites (half resolution) and 60 of ash. The lamp cone is an additive mesh, not real volumetric light.",
7766
+ network: "The weather comes from the server. The density is local, by zone."
7767
+ },
7187
7768
  scraping_sparks: {
7188
7769
  name: "Scraping sparks",
7189
7770
  short: "A bumper dragging on the asphalt: a river of bouncing sparks and a mark on the ground.",
@@ -7235,6 +7816,16 @@ var en = {
7235
7816
  budget: "Texture only: a crack mask with 4 stages and a blood decal on the glass. Glass dust: 6 particles per blow.",
7236
7817
  network: "The server sends the glass health. Blood on the glass is local."
7237
7818
  },
7819
+ headlights_in_rain: {
7820
+ name: "Headlights in the rain",
7821
+ short: "A visible beam, drops lit inside the cone and the horde walking into the light.",
7822
+ cost: "\u2264 600 lit drops",
7823
+ costNote: "2 spots, no shadow",
7824
+ when: "Headlights on at night, with rain or fog.",
7825
+ look: "Two cones of light in the air, rain drops that shine only inside the beam and zombie silhouettes that light up when they enter the light. Outside the cone the rain almost disappears.",
7826
+ budget: "2 spotlights without shadow, 2 additive cones and up to 600 extra drops only inside the cone. Headlights of cars beyond 40 m stay as a cone only, with no real light.",
7827
+ network: "The state of the headlights is already replicated with the car."
7828
+ },
7238
7829
  damage_and_bite: {
7239
7830
  name: "Damage and bite",
7240
7831
  short: "A red edge on the side of the blow, blood on the lens and the pulse of the bite.",
@@ -7554,6 +8145,27 @@ var ptBR = {
7554
8145
  budget: "At\xE9 600 part\xEDculas por pr\xE9dio e 2 luzes de fogo. Al\xE9m de 80 m fica s\xF3 a coluna de fuma\xE7a e o brilho das janelas, que viram ponto de refer\xEAncia.",
7555
8146
  network: "Entidade de fogo no servidor por pr\xE9dio, com estado de espalhar."
7556
8147
  },
8148
+ rain_and_puddles: {
8149
+ name: "Chuva, respingos e po\xE7as",
8150
+ short: "Gotas com vento, respingos e an\xE9is s\xF3 perto da c\xE2mera, rel\xE2mpago no temporal.",
8151
+ cost: "\u2264 4.000 gotas",
8152
+ costNote: "respingo at\xE9 12 m",
8153
+ paramLabel: "Intensidade",
8154
+ when: "Clima do mundo. Chuva aumenta o ru\xEDdo de fundo e mascara passos (d\xE1 para usar na furtividade).",
8155
+ look: "Garoa fina quase vertical. Chuva com respingos no asfalto e an\xE9is nas po\xE7as, que ficam escuras e espelhadas. Temporal com gotas inclinadas pelo vento, cortinas de \xE1gua passando e rel\xE2mpago duplo que clareia a cena por 0,2 s e revela a horda.",
8156
+ budget: "At\xE9 4.000 gotas presas \xE0 c\xE2mera numa caixa de 30 m. Respingos e an\xE9is s\xF3 a menos de 12 m e s\xF3 em cima do que a c\xE2mera v\xEA.",
8157
+ network: "O servidor manda o clima e a semente do rel\xE2mpago, para todos verem o mesmo clar\xE3o."
8158
+ },
8159
+ fog_and_ash: {
8160
+ name: "Neblina e cinzas",
8161
+ short: "N\xE9voa rasteira em camadas, cinza caindo e o poste com cone de luz.",
8162
+ cost: "\u2264 120 sprites",
8163
+ costNote: "1 cone de luz",
8164
+ when: "Madrugada, perto de rio e em zonas queimadas (cinza). Reduz a vis\xE3o dos zumbis e do jogador.",
8165
+ look: "Neblina do motor mais uma camada de n\xE9voa baixa que se move devagar, cinza fina caindo em espiral e o feixe dos postes vis\xEDvel. Silhuetas de zumbis aparecem antes dos detalhes.",
8166
+ budget: "At\xE9 60 sprites grandes de n\xE9voa (meia resolu\xE7\xE3o) e 60 de cinza. O cone do poste \xE9 uma malha aditiva, n\xE3o luz volum\xE9trica real.",
8167
+ network: "Clima vem do servidor. Densidade \xE9 local por zona."
8168
+ },
7557
8169
  scraping_sparks: {
7558
8170
  name: "Fa\xEDscas de raspagem",
7559
8171
  short: "Para-choque arrastando no asfalto: rio de fa\xEDscas que quicam e marca no ch\xE3o.",
@@ -7605,6 +8217,16 @@ var ptBR = {
7605
8217
  budget: "S\xF3 textura: uma m\xE1scara de rachadura com 4 est\xE1gios e um decal de sangue no vidro. P\xF3 de vidro: 6 part\xEDculas por golpe.",
7606
8218
  network: "O servidor manda a vida do vidro. Sangue no vidro \xE9 local."
7607
8219
  },
8220
+ headlights_in_rain: {
8221
+ name: "Far\xF3is na chuva",
8222
+ short: "Feixe vis\xEDvel, gotas acesas dentro do cone e a horda entrando na luz.",
8223
+ cost: "\u2264 600 gotas acesas",
8224
+ costNote: "2 spots sem sombra",
8225
+ when: "Far\xF3is ligados \xE0 noite, com chuva ou neblina.",
8226
+ look: "Dois cones de luz vis\xEDveis no ar, gotas de chuva que brilham s\xF3 dentro do feixe e silhuetas de zumbi que acendem quando entram na luz. Fora do cone, a chuva quase some.",
8227
+ budget: "2 spotlights sem sombra, 2 cones aditivos e at\xE9 600 gotas extras s\xF3 dentro do cone. Far\xF3is de carros a mais de 40 m ficam s\xF3 como cone, sem luz real.",
8228
+ network: "Estado do farol j\xE1 \xE9 replicado com o carro."
8229
+ },
7608
8230
  damage_and_bite: {
7609
8231
  name: "Dano e mordida",
7610
8232
  short: "Borda vermelha do lado do golpe, sangue na lente e o pulso da mordida.",
@@ -7704,7 +8326,7 @@ function ease3(value) {
7704
8326
  function mix(from, to, amount) {
7705
8327
  return [from[0] + (to[0] - from[0]) * amount, from[1] + (to[1] - from[1]) * amount, from[2] + (to[2] - from[2]) * amount];
7706
8328
  }
7707
- function rotate(local2, x, y, z, w) {
8329
+ function rotate2(local2, x, y, z, w) {
7708
8330
  const [vx2, vy2, vz2] = local2;
7709
8331
  const ix = w * vx2 + y * vz2 - z * vy2;
7710
8332
  const iy = w * vy2 + z * vx2 - x * vz2;
@@ -7762,7 +8384,7 @@ var EffectCamera = class {
7762
8384
  /** A direction given in the camera's own axes, in world axes. */
7763
8385
  forward(local2) {
7764
8386
  const [x, y, z, w] = lookAtQuaternion(this.position, this.target);
7765
- return rotate(local2, x, y, z, w);
8387
+ return rotate2(local2, x, y, z, w);
7766
8388
  }
7767
8389
  };
7768
8390
 
@@ -7924,15 +8546,20 @@ export {
7924
8546
  GAME_EFFECTS,
7925
8547
  LOD_GAME,
7926
8548
  LOD_LAB,
8549
+ MeshPool,
7927
8550
  OrderedPool,
7928
8551
  PROFILES,
8552
+ RAIN_CAPACITY,
8553
+ RainField,
7929
8554
  SMOKE_COLORS,
7930
8555
  SPRITE_KINDS,
7931
8556
  SpriteKindPool,
7932
8557
  SpriteKindSystem,
7933
8558
  VFX_LAYERS,
8559
+ VIEWMODEL_EFFECTS,
7934
8560
  WORKSHOP_BEHAVIORS,
7935
8561
  WORKSHOP_EFFECTS,
8562
+ WORKSHOP_PUDDLES,
7936
8563
  WorkshopEngine,
7937
8564
  colorOfChunk,
7938
8565
  composeExplosion,
@@ -7947,6 +8574,7 @@ export {
7947
8574
  estimateCost,
7948
8575
  hexToLinearRgb,
7949
8576
  hexToRgb,
8577
+ inPuddle,
7950
8578
  lcg,
7951
8579
  lehmer,
7952
8580
  locales,