@adatechnology/game-player 0.13.5 → 0.15.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.
@@ -25,7 +25,11 @@ var GamePlayer = (() => {
25
25
  DOOR_ARM_REACH: () => DOOR_ARM_REACH,
26
26
  DOOR_SHOULDER_HEIGHT: () => DOOR_SHOULDER_HEIGHT,
27
27
  DOOR_USE_DEFAULTS: () => DOOR_USE_DEFAULTS,
28
+ DRIVING_HANDS_DEFAULTS: () => DRIVING_HANDS_DEFAULTS,
28
29
  FURNITURE_PUSH_DEFAULTS: () => FURNITURE_PUSH_DEFAULTS,
30
+ GESTURE_ARM_REACH: () => GESTURE_ARM_REACH,
31
+ GESTURE_TIMING: () => GESTURE_TIMING,
32
+ HANDS_BY_HANDLE: () => HANDS_BY_HANDLE,
29
33
  HANDS_DEFAULTS: () => HANDS_DEFAULTS,
30
34
  HANDS_TIMING: () => HANDS_TIMING,
31
35
  ITEM_GRIP: () => ITEM_GRIP,
@@ -39,6 +43,7 @@ var GamePlayer = (() => {
39
43
  SLING_SLOT: () => SLING_SLOT,
40
44
  SLOT_FALLBACKS: () => SLOT_FALLBACKS,
41
45
  STEP_POSE_DEFAULTS: () => STEP_POSE_DEFAULTS,
46
+ VEHICLE_BOARDING_DEFAULTS: () => VEHICLE_BOARDING_DEFAULTS,
42
47
  WALKER_JUMP_SPEED: () => WALKER_JUMP_SPEED,
43
48
  advanceNeeds: () => advanceNeeds,
44
49
  applyItemEffect: () => applyItemEffect,
@@ -48,7 +53,10 @@ var GamePlayer = (() => {
48
53
  conjugateQuaternion: () => conjugateQuaternion,
49
54
  createBodyVitals: () => createBodyVitals,
50
55
  createDoorUse: () => createDoorUse,
56
+ createDrivingHands: () => createDrivingHands,
51
57
  createFurniturePush: () => createFurniturePush,
58
+ createGestureHands: () => createGestureHands,
59
+ createGestureTimeline: () => createGestureTimeline,
52
60
  createNeedsState: () => createNeedsState,
53
61
  createPhysicsController: () => createPhysicsController,
54
62
  createPlayer: () => createPlayer,
@@ -56,6 +64,7 @@ var GamePlayer = (() => {
56
64
  createRng: () => createRng,
57
65
  createStepPose: () => createStepPose,
58
66
  createTakeTimeline: () => createTakeTimeline,
67
+ createVehicleBoarding: () => createVehicleBoarding,
59
68
  createWalker: () => createWalker,
60
69
  deriveVitals: () => deriveVitals,
61
70
  dragMarkFor: () => dragMarkFor,
@@ -63,8 +72,12 @@ var GamePlayer = (() => {
63
72
  drawWound: () => drawWound,
64
73
  easeInOut: () => easeInOut,
65
74
  footRestHeight: () => footRestHeight,
75
+ freeHandOf: () => freeHandOf,
66
76
  frictionFor: () => frictionFor,
77
+ gestureHandOf: () => gestureHandOf,
78
+ gestureHandPose: () => gestureHandPose,
67
79
  gripOfItem: () => gripOfItem,
80
+ gripOnHandle: () => gripOnHandle,
68
81
  gripSecondsFor: () => gripSecondsFor,
69
82
  handPoseOnItem: () => handPoseOnItem,
70
83
  interactionHandsFor: () => interactionHandsFor,
@@ -1878,11 +1891,13 @@ var GamePlayer = (() => {
1878
1891
  }
1879
1892
 
1880
1893
  // src/hands.ts
1881
- var HANDS_DEFAULTS = { oneHand: { maxKg: 4, maxLength: 0.7 } };
1894
+ var HANDS_BY_HANDLE = { maxKg: 25 };
1895
+ var HANDS_DEFAULTS = { oneHand: { maxKg: 4, maxLength: 0.7 }, byHandle: HANDS_BY_HANDLE };
1882
1896
  var SLOT_FALLBACKS = { sling: ["back"], hip: ["belt"] };
1883
1897
  var BELT_SLOT = "belt";
1884
1898
  var SLING_SLOT = "sling";
1885
1899
  function interactionHandsFor(thing, rules = HANDS_DEFAULTS) {
1900
+ if (thing.handle) return thing.massKg > (rules.byHandle ?? HANDS_BY_HANDLE).maxKg ? 2 : 1;
1886
1901
  const longest = Math.max(0, ...thing.size ?? []);
1887
1902
  return thing.massKg > rules.oneHand.maxKg || longest > rules.oneHand.maxLength ? 2 : 1;
1888
1903
  }
@@ -2004,7 +2019,16 @@ var GamePlayer = (() => {
2004
2019
  ];
2005
2020
  var cross = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
2006
2021
  var scaled = (v, k) => [v[0] * k, v[1] * k, v[2] * k];
2007
- function gripOfItem(size, hand) {
2022
+ function gripOnHandle(handle, hand) {
2023
+ const up = hand === "R" ? [0, 0, -1] : [0, 0, 1];
2024
+ const along = [1, 0, 0];
2025
+ const quaternion = quaternionOfBasis(along, up, cross(along, up));
2026
+ const local = { position: [0, 0, 0], quaternion };
2027
+ const handleInHand = composePose(local, { position: [handle[0] ?? 0, handle[1] ?? 0, handle[2] ?? 0], quaternion: [0, 0, 0, 1] }).position;
2028
+ return { local: { position: [-handleInHand[0], -handleInHand[1] - ITEM_GRIP.palm, -handleInHand[2]], quaternion }, grip: ITEM_GRIP.closed, hanging: true };
2029
+ }
2030
+ function gripOfItem(size, hand, handle) {
2031
+ if (handle) return gripOnHandle(handle, hand);
2008
2032
  const sides = [0, 1, 2].map((axis) => ({ axis, length: Math.max(0, size[axis] ?? 0) })).sort((a, b) => b.length - a.length);
2009
2033
  const [long, mid, thin] = sides;
2010
2034
  const thumb = hand === "R" ? [0, 0, -1] : [0, 0, 1];
@@ -2100,6 +2124,424 @@ var GamePlayer = (() => {
2100
2124
  }
2101
2125
  };
2102
2126
  }
2127
+
2128
+ // src/vehicle-boarding.ts
2129
+ var VEHICLE_BOARDING_DEFAULTS = { rattleSeconds: 0.75, endTolerance: 0.02 };
2130
+ function createVehicleBoarding(ports, rules = {}) {
2131
+ const r = { ...VEHICLE_BOARDING_DEFAULTS, ...rules };
2132
+ let phase = "out";
2133
+ let clock = 0;
2134
+ const isOpen = () => ports.doorOpenness() >= 1 - r.endTolerance;
2135
+ const isShut = () => ports.doorOpenness() <= r.endTolerance;
2136
+ const sitDown = (events) => {
2137
+ if (ports.sit()) phase = "sit";
2138
+ else {
2139
+ phase = "out";
2140
+ events.push({ type: "refused", reason: "no_seat" });
2141
+ }
2142
+ };
2143
+ const pending = [];
2144
+ return {
2145
+ get phase() {
2146
+ return phase;
2147
+ },
2148
+ get driving() {
2149
+ return phase === "in";
2150
+ },
2151
+ get handOnDoor() {
2152
+ return phase === "shut" || phase === "unlatch";
2153
+ },
2154
+ enter() {
2155
+ if (phase !== "out") return false;
2156
+ if (!ports.hasDoor) {
2157
+ if (!ports.sit()) return false;
2158
+ phase = "sit";
2159
+ return true;
2160
+ }
2161
+ if (isOpen()) {
2162
+ phase = "open";
2163
+ return true;
2164
+ }
2165
+ phase = "reach";
2166
+ const locked = ports.doorLocked();
2167
+ ports.reachHandle({
2168
+ pull: true,
2169
+ locked,
2170
+ onGrip: () => {
2171
+ if (phase !== "reach") return;
2172
+ if (locked) {
2173
+ phase = "refused";
2174
+ clock = 0;
2175
+ return;
2176
+ }
2177
+ ports.swingDoor(true);
2178
+ phase = "open";
2179
+ },
2180
+ onMiss: () => {
2181
+ if (phase !== "reach") return;
2182
+ phase = "out";
2183
+ pending.push({ type: "refused", reason: "blocked" });
2184
+ }
2185
+ });
2186
+ return true;
2187
+ },
2188
+ takeSeat() {
2189
+ if (phase !== "out" || !ports.sit()) return false;
2190
+ phase = "sit";
2191
+ return true;
2192
+ },
2193
+ leave() {
2194
+ if (phase !== "in") return false;
2195
+ if (!ports.hasDoor) {
2196
+ if (!ports.stand()) {
2197
+ pending.push({ type: "refused", reason: "blocked" });
2198
+ return false;
2199
+ }
2200
+ phase = "stand";
2201
+ return true;
2202
+ }
2203
+ ports.swingDoor(true);
2204
+ phase = "unlatch";
2205
+ return true;
2206
+ },
2207
+ dropped() {
2208
+ if (phase === "out") return;
2209
+ phase = "out";
2210
+ pending.push({ type: "out" });
2211
+ },
2212
+ update(dt) {
2213
+ const events = pending.splice(0);
2214
+ switch (phase) {
2215
+ case "refused":
2216
+ clock += dt;
2217
+ if (clock >= r.rattleSeconds) {
2218
+ phase = "out";
2219
+ events.push({ type: "refused", reason: "locked" });
2220
+ }
2221
+ break;
2222
+ case "open":
2223
+ if (isOpen()) sitDown(events);
2224
+ break;
2225
+ case "sit":
2226
+ if (ports.seated() >= 1) {
2227
+ if (ports.hasDoor && !isShut()) {
2228
+ ports.swingDoor(false);
2229
+ phase = "shut";
2230
+ } else {
2231
+ phase = "in";
2232
+ events.push({ type: "in" });
2233
+ }
2234
+ }
2235
+ break;
2236
+ case "shut":
2237
+ if (isShut()) {
2238
+ phase = "in";
2239
+ events.push({ type: "in" });
2240
+ }
2241
+ break;
2242
+ case "unlatch":
2243
+ if (!isOpen()) break;
2244
+ if (ports.stand()) phase = "stand";
2245
+ else {
2246
+ ports.swingDoor(false);
2247
+ phase = "shut";
2248
+ events.push({ type: "refused", reason: "blocked" });
2249
+ }
2250
+ break;
2251
+ case "stand":
2252
+ if (ports.seated() > 0) break;
2253
+ if (!ports.hasDoor) {
2254
+ phase = "out";
2255
+ events.push({ type: "out" });
2256
+ break;
2257
+ }
2258
+ phase = "close";
2259
+ ports.reachHandle({
2260
+ pull: false,
2261
+ locked: false,
2262
+ onGrip: () => {
2263
+ if (phase === "close") ports.swingDoor(false);
2264
+ },
2265
+ // the door out of reach stays open: the driver is out all the same
2266
+ onMiss: () => {
2267
+ if (phase !== "close") return;
2268
+ phase = "out";
2269
+ pending.push({ type: "out" });
2270
+ }
2271
+ });
2272
+ break;
2273
+ case "close":
2274
+ if (isShut()) {
2275
+ phase = "out";
2276
+ events.push({ type: "out" });
2277
+ }
2278
+ break;
2279
+ default:
2280
+ break;
2281
+ }
2282
+ return events;
2283
+ }
2284
+ };
2285
+ }
2286
+
2287
+ // src/driving-hands.ts
2288
+ var DRIVING_HANDS_DEFAULTS = { regripAt: 1.75, firstAt: 0.7, lead: 0.9, stillRate: 0.3, settleAt: 0.25, reachLimit: 2.3, regripSeconds: 0.24, leverReachSeconds: 0.22, leverHoldSeconds: 0.26 };
2289
+ var smooth = (k) => k * k * (3 - 2 * k);
2290
+ function createDrivingHands(rules = {}) {
2291
+ const r = { ...DRIVING_HANDS_DEFAULTS, ...rules };
2292
+ const hands = { left: { at: 0, hold: 1, toLever: 0, regrip: -1, from: 0, to: 0 }, right: { at: 0, hold: 1, toLever: 0, regrip: -1, from: 0, to: 0 } };
2293
+ let last = 0;
2294
+ let shifting = null;
2295
+ const busy = (h) => h.regrip >= 0 || h.toLever > 0;
2296
+ const total = r.leverReachSeconds * 2 + r.leverHoldSeconds;
2297
+ return {
2298
+ left: hands.left,
2299
+ right: hands.right,
2300
+ get leverThrow() {
2301
+ if (!shifting) return 1;
2302
+ return smooth(Math.max(0, Math.min(1, (shifting.clock - r.leverReachSeconds) / r.leverHoldSeconds)));
2303
+ },
2304
+ shift(hand) {
2305
+ if (shifting) return;
2306
+ shifting = { hand, clock: 0 };
2307
+ hands[hand].regrip = -1;
2308
+ },
2309
+ reset(wheel) {
2310
+ last = wheel;
2311
+ shifting = null;
2312
+ for (const h of [hands.left, hands.right]) Object.assign(h, { at: 0, hold: 1, toLever: 0, regrip: -1, from: 0, to: 0 });
2313
+ },
2314
+ update(dt, wheel) {
2315
+ const turned = wheel - last;
2316
+ last = wheel;
2317
+ if (shifting) {
2318
+ shifting.clock += dt;
2319
+ const h = hands[shifting.hand];
2320
+ const c = shifting.clock;
2321
+ const out = smooth(Math.min(1, c / r.leverReachSeconds));
2322
+ const back = smooth(Math.max(0, Math.min(1, (c - r.leverReachSeconds - r.leverHoldSeconds) / r.leverReachSeconds)));
2323
+ h.toLever = out * (1 - back);
2324
+ h.hold = 1 - h.toLever;
2325
+ h.at = 0;
2326
+ if (c >= total) {
2327
+ h.toLever = 0;
2328
+ h.hold = 1;
2329
+ shifting = null;
2330
+ }
2331
+ }
2332
+ for (const side of ["left", "right"]) {
2333
+ const h = hands[side];
2334
+ const other = hands[side === "left" ? "right" : "left"];
2335
+ if (h.toLever > 0) continue;
2336
+ if (h.regrip >= 0) {
2337
+ h.regrip += dt;
2338
+ const k = Math.min(1, h.regrip / r.regripSeconds);
2339
+ h.at = h.from + (h.to - h.from) * smooth(k);
2340
+ h.hold = Math.abs(2 * k - 1);
2341
+ if (k >= 1) {
2342
+ h.regrip = -1;
2343
+ h.at = h.to;
2344
+ h.hold = 1;
2345
+ }
2346
+ continue;
2347
+ }
2348
+ h.at += turned;
2349
+ const far = Math.abs(h.at);
2350
+ const rate = dt > 0 ? turned / dt : 0;
2351
+ const turning = Math.abs(rate) > r.stillRate;
2352
+ const goesDown = turning && side === "left" === rate > 0 && Math.sign(h.at) === Math.sign(rate);
2353
+ const wants = far > (goesDown ? r.firstAt : r.regripAt) || !turning && far > r.settleAt;
2354
+ if (wants && !busy(other) || far > r.reachLimit) {
2355
+ h.regrip = 0;
2356
+ h.from = h.at;
2357
+ h.to = turning ? -Math.sign(rate) * r.lead : 0;
2358
+ }
2359
+ }
2360
+ }
2361
+ };
2362
+ }
2363
+
2364
+ // src/gesture.ts
2365
+ var GESTURE_TIMING = {
2366
+ reach: 0.32,
2367
+ back: 0.3,
2368
+ act: { press: 0.22, turn: 0.4, flip: 0.2, strike: 0.35, pour: 0.7, put_in: 0.3, tip: 0.7, stow: 0.25, read: 1.2, pull: 0.45 }
2369
+ };
2370
+ var ACTS_AT_START = /* @__PURE__ */ new Set(["read"]);
2371
+ var GESTURE_ARM_REACH = 0.62;
2372
+ function createGestureTimeline(gesture, timing = GESTURE_TIMING) {
2373
+ const reach = timing.reach;
2374
+ const act = timing.act[gesture];
2375
+ const duration = reach + act + timing.back;
2376
+ const actsAt = ACTS_AT_START.has(gesture) ? reach : reach + act;
2377
+ let time = 0;
2378
+ let fired = false;
2379
+ return {
2380
+ gesture,
2381
+ duration,
2382
+ advance(dt) {
2383
+ time = Math.min(duration, time + Math.max(0, dt));
2384
+ const acted = !fired && time >= actsAt;
2385
+ if (acted) fired = true;
2386
+ const phase = time < reach ? "reach" : time < reach + act ? "act" : "back";
2387
+ const start = phase === "reach" ? 0 : phase === "act" ? reach : reach + act;
2388
+ const length = phase === "reach" ? reach : phase === "act" ? act : timing.back;
2389
+ return { phase, progress: easeInOut((time - start) / Math.max(1e-6, length)), acted, done: time >= duration };
2390
+ }
2391
+ };
2392
+ }
2393
+ var WITH_THE_HELD_THING = /* @__PURE__ */ new Set(["put_in", "pour"]);
2394
+ function freeHandOf(busy) {
2395
+ if (!busy.R) return "R";
2396
+ return busy.L ? null : "L";
2397
+ }
2398
+ function gestureHandOf(choice) {
2399
+ if (WITH_THE_HELD_THING.has(choice.gesture)) return choice.carrying ?? null;
2400
+ return freeHandOf(choice.busy);
2401
+ }
2402
+ var add = (a, b, k = 1) => [a[0] + b[0] * k, a[1] + b[1] * k, a[2] + b[2] * k];
2403
+ var cross2 = (a, b) => [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]];
2404
+ var axisTurn = (axis, angle) => {
2405
+ const s = Math.sin(angle / 2);
2406
+ return [axis[0] * s, axis[1] * s, axis[2] * s, Math.cos(angle / 2)];
2407
+ };
2408
+ var UP = [0, 1, 0];
2409
+ var actPose = (gesture, frame, k) => {
2410
+ const { at, way, side, q } = frame;
2411
+ switch (gesture) {
2412
+ case "press":
2413
+ return { position: add(at, way, -0.06 + 0.05 * Math.sin(Math.PI * k)), quaternion: q };
2414
+ case "turn":
2415
+ return { position: add(at, way, -0.02), quaternion: multiplyQuaternions(axisTurn(way, -k * Math.PI * 0.5), q) };
2416
+ case "flip":
2417
+ return { position: add(add(at, way, -0.02), UP, -0.03 * k), quaternion: q };
2418
+ case "strike":
2419
+ return { position: add(add(at, way, -0.04), side, 0.08 * (k - 0.5)), quaternion: q };
2420
+ case "pour":
2421
+ return { position: add(at, UP, 0.15), quaternion: multiplyQuaternions(axisTurn(side, -k * Math.PI * 0.4), q) };
2422
+ case "tip":
2423
+ return { position: add(at, UP, 0.05 * k), quaternion: multiplyQuaternions(axisTurn(side, -k * Math.PI * 0.55), q) };
2424
+ case "pull":
2425
+ return { position: add(at, way, -0.02 - 0.15 * k), quaternion: q };
2426
+ case "put_in":
2427
+ case "stow":
2428
+ return { position: [at[0], at[1], at[2]], quaternion: q };
2429
+ case "read":
2430
+ return { position: [at[0], at[1], at[2]], quaternion: multiplyQuaternions(axisTurn(way, Math.PI * 0.5), q) };
2431
+ }
2432
+ };
2433
+ var GRIP = {
2434
+ press: [0.85, 0.85],
2435
+ turn: [0.9, 0.9],
2436
+ flip: [0.55, 0.55],
2437
+ strike: [0.95, 0.95],
2438
+ pour: [1, 1],
2439
+ tip: [1, 1],
2440
+ put_in: [1, 0.15],
2441
+ stow: [0.2, 0.95],
2442
+ read: [0.7, 0.7],
2443
+ pull: [0.9, 0.9]
2444
+ };
2445
+ var OPEN_HAND = 0.2;
2446
+ function frameOf(params) {
2447
+ const { shoulder } = params;
2448
+ const flatX = params.at[0] - shoulder[0];
2449
+ const flatZ = params.at[2] - shoulder[2];
2450
+ const flat = Math.hypot(flatX, flatZ);
2451
+ const way = flat < 1e-4 ? [-Math.sin(params.yaw), 0, -Math.cos(params.yaw)] : [flatX / flat, 0, flatZ / flat];
2452
+ const little = params.hand === "R" ? [0, -1, 0] : [0, 1, 0];
2453
+ const side = cross2(little, way);
2454
+ const toward = [params.at[0] - shoulder[0], params.at[1] - shoulder[1], params.at[2] - shoulder[2]];
2455
+ const reach = Math.hypot(toward[0], toward[1], toward[2]);
2456
+ const at = reach > GESTURE_ARM_REACH ? add(shoulder, toward, GESTURE_ARM_REACH / reach) : params.at;
2457
+ return { at, way, side, q: quaternionOfBasis(way, side, little) };
2458
+ }
2459
+ function gestureHandPose(params) {
2460
+ const { rest, phase, progress, gesture } = params;
2461
+ const frame = frameOf(params);
2462
+ const [gripIn, gripOut] = GRIP[gesture];
2463
+ const index = gesture === "press" ? 0 : gesture === "flip" ? 0.2 : 1;
2464
+ if (phase === "reach") return { pose: blendPoses(rest, actPose(gesture, frame, 0), progress), grip: OPEN_HAND + (gripIn - OPEN_HAND) * progress, index: 1 + (index - 1) * progress };
2465
+ if (phase === "act") return { pose: actPose(gesture, frame, progress), grip: gripIn + (gripOut - gripIn) * progress, index };
2466
+ const stowed = gesture === "stow";
2467
+ const home = stowed ? { position: add(rest.position, UP, -0.3), quaternion: rest.quaternion } : rest;
2468
+ const grip = stowed ? gripOut : gripOut + (OPEN_HAND - gripOut) * progress;
2469
+ return { pose: blendPoses(actPose(gesture, frame, 1), home, progress), grip, index: index + (1 - index) * progress };
2470
+ }
2471
+
2472
+ // src/gesture-hands.ts
2473
+ var STAND_OFF = 0.5;
2474
+ var STEP_SPEED = 2.5;
2475
+ var MAX_WALK_SECONDS = 1.5;
2476
+ var TURN_RATE = 8;
2477
+ var STOOP_BELOW = 0.5;
2478
+ function stepUp(body, now, dt) {
2479
+ if (!body) return true;
2480
+ const point = now.start.at();
2481
+ body.face(point, Math.min(1, dt * TURN_RATE));
2482
+ const [x, z] = body.at();
2483
+ const dx = point[0] - x;
2484
+ const dz = point[2] - z;
2485
+ const d = Math.hypot(dx, dz);
2486
+ if (d <= STAND_OFF + 0.03 || now.walked > MAX_WALK_SECONDS) return true;
2487
+ const go = Math.min(d - STAND_OFF, STEP_SPEED * dt);
2488
+ if (go < 1e-4) return false;
2489
+ body.moveBy(dx / d * go, dz / d * go);
2490
+ const [x1, z1] = body.at();
2491
+ now.walked += dt;
2492
+ return Math.hypot(x1 - x, z1 - z) < go * 0.2;
2493
+ }
2494
+ function createGestureHands(deps) {
2495
+ let going = null;
2496
+ const stop = () => {
2497
+ going = null;
2498
+ deps.body?.stoop?.(false);
2499
+ };
2500
+ return {
2501
+ get busy() {
2502
+ return going !== null;
2503
+ },
2504
+ get hand() {
2505
+ return going?.hand ?? null;
2506
+ },
2507
+ start(start) {
2508
+ if (going) return { ok: false, reason: "busy" };
2509
+ const hand = gestureHandOf({ busy: deps.holding(), gesture: start.gesture, carrying: deps.carrying?.() ?? null });
2510
+ if (!hand) return { ok: false, reason: "hands_full" };
2511
+ const shoulder = deps.shoulder(hand);
2512
+ if (!shoulder || deps.body?.able?.() === false) return { ok: false, reason: "no_body" };
2513
+ const timeline = createGestureTimeline(start.gesture);
2514
+ going = { start, hand, timeline, progress: timeline.advance(0), walked: 0, there: false };
2515
+ if (shoulder[1] - start.at()[1] > STOOP_BELOW) deps.body?.stoop?.(true);
2516
+ return { ok: true, hand };
2517
+ },
2518
+ step(dt) {
2519
+ if (!going) return;
2520
+ const now = going;
2521
+ if (deps.body?.able?.() === false) return stop();
2522
+ if (!now.there) {
2523
+ now.there = stepUp(deps.body, now, dt);
2524
+ if (!now.there) return;
2525
+ }
2526
+ now.progress = now.timeline.advance(dt);
2527
+ if (now.progress.acted) now.start.onAct();
2528
+ if (now.progress.done && going === now) stop();
2529
+ },
2530
+ targets(base) {
2531
+ if (!going) return base;
2532
+ const { hand, start, progress } = going;
2533
+ const shoulder = deps.shoulder(hand);
2534
+ if (!shoulder) return base;
2535
+ const rest = base?.[hand] ?? deps.restOf(hand);
2536
+ const worked = gestureHandPose({ gesture: start.gesture, hand, phase: progress.phase, progress: progress.progress, shoulder, rest, at: start.at(), yaw: deps.yaw() });
2537
+ const [x, y, z] = worked.pose.position;
2538
+ const [qx, qy, qz, qw] = worked.pose.quaternion;
2539
+ const pose = { position: [x, y, z], quaternion: [qx, qy, qz, qw] };
2540
+ return hand === "R" ? { ...base ?? {}, R: pose, grip: worked.grip, fingers: { index: worked.index } } : { ...base ?? {}, L: pose, gripL: worked.grip, fingersL: { index: worked.index }, slideL: null };
2541
+ },
2542
+ cancel: stop
2543
+ };
2544
+ }
2103
2545
  return __toCommonJS(index_exports);
2104
2546
  })();
2105
2547
  //# sourceMappingURL=index.global.js.map