@adatechnology/game-interactables 0.6.7 → 0.6.9

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
@@ -1,3 +1,39 @@
1
+ // src/fixture-emitters.ts
2
+ var FLUSH_RUN_SECONDS = 2;
3
+ var START_OPENING = 0.05;
4
+ var PRESSED = 0.5;
5
+ var FLUSH_FADE = 0.4;
6
+ function createFixtureEmitters(spec) {
7
+ const fixtures = new Map((spec.fixtures ?? []).map((fixture) => [fixture.id, fixture]));
8
+ const driven = [];
9
+ for (const emitter of spec.emitters ?? []) {
10
+ if (emitter.kind !== "water") continue;
11
+ const fixture = fixtures.get(emitter.source);
12
+ if (!fixture?.part) continue;
13
+ driven.push({ emitter, fixture: { ...fixture, part: fixture.part }, left: 0, down: false });
14
+ }
15
+ return {
16
+ runs: driven.length > 0,
17
+ update(dt, opening) {
18
+ const out = [];
19
+ for (const d of driven) {
20
+ const open = Math.min(1, Math.max(0, opening(d.fixture.part)));
21
+ if (d.fixture.kind === "flush") {
22
+ const down = open >= PRESSED;
23
+ if (down && !d.down) d.left = FLUSH_RUN_SECONDS;
24
+ d.down = down;
25
+ if (d.left <= 0) continue;
26
+ d.left = Math.max(0, d.left - dt);
27
+ out.push({ emitter: d.emitter, intensity: Math.min(1, (d.left + 1e-6) / FLUSH_FADE) });
28
+ continue;
29
+ }
30
+ if (open > START_OPENING) out.push({ emitter: d.emitter, intensity: open });
31
+ }
32
+ return out;
33
+ }
34
+ };
35
+ }
36
+
1
37
  // src/colliders.ts
2
38
  var volume = (b) => (b.u1 - b.u0) * (b.v1 - b.v0) * (b.y1 - b.y0);
3
39
  var overlap = (a0, a1, b0, b1) => Math.max(0, Math.min(a1, b1) - Math.max(a0, b0));
@@ -264,7 +300,7 @@ var TAKE_RADIUS = 0.6;
264
300
  var AUTO_RANGE = 2;
265
301
  var SOCKET_BEHIND = 0.05;
266
302
  var SMOKE_TAIL = 20;
267
- var FLUSH_SECONDS = 2;
303
+ var FLUSH_SECONDS = FLUSH_RUN_SECONDS;
268
304
  var ACTOR_HEIGHT = 1.7;
269
305
  var PUSH_GAIN = 1.2;
270
306
  var SWEEP_STEPS = 24;
@@ -1422,7 +1458,7 @@ function createWorld(options = {}) {
1422
1458
  }
1423
1459
  if (intensity <= 0) continue;
1424
1460
  const dir = rotY(e.dir ?? [0, 1, 0], o.public.transform.ry);
1425
- out.push({ id: gid(o, e.id), object: o.id, kind: e.kind, pos: toWorld(o, e.pos), dir, size: e.size ?? 0.3, ...e.reach !== void 0 ? { reach: e.reach } : {}, intensity: clamp(intensity, 0, 1) });
1461
+ out.push({ id: gid(o, e.id), object: o.id, kind: e.kind, pos: toWorld(o, e.pos), dir, size: e.size ?? 0.3, ...e.reach !== void 0 ? { reach: e.reach } : {}, ...e.bowl ? { bowl: e.bowl } : {}, intensity: clamp(intensity, 0, 1) });
1426
1462
  }
1427
1463
  }
1428
1464
  return out;
@@ -2201,10 +2237,12 @@ function attachLeaf(world, options, request) {
2201
2237
  return createLeafDriver({ world, leaf, frame, ownsFrame, joint, onDispose: request.onDispose, drive: { isHinge, axis, pivot, centre, range, speed, base: rotation } });
2202
2238
  }
2203
2239
  export {
2240
+ FLUSH_RUN_SECONDS,
2204
2241
  alignY,
2205
2242
  buildChain,
2206
2243
  chainPoints,
2207
2244
  createEnginePartPhysics,
2245
+ createFixtureEmitters,
2208
2246
  createWorld,
2209
2247
  disposeChain,
2210
2248
  fitsSize,