roamwright 0.61.7 → 0.61.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.
@@ -199,8 +199,14 @@ export function createBipedStride({ rig, foot, pace, ground }) {
199
199
  sinL = Math.sin(lean),
200
200
  cosL = Math.cos(lean),
201
201
  hipAt = rig.hipHeight * sinL + hipZ, // the hips forward of the point between the feet; a stride is taken under them
202
- landing = hipAt * go + (v < 0 ? -sweep : sweep) / 2,
203
- drift = ((v < 0 ? sweep : -sweep) * (1 - duty)) / duty,
202
+ // a walker's foot is planted as far ahead of the hips as it will leave the ground behind them; a runner's lands nearer
203
+ // under them, the knee still bent, and pushes off further behind (`runLanding`: the share of the foot's time on the ground
204
+ // spent ahead of the hips at a full run), so the leg never reaches out straight before the foot comes down
205
+ plantAhead = lerp(0.5, pace.runLanding ?? 0.5, run),
206
+ landing = hipAt * go + (v < 0 ? -sweep : sweep) * plantAhead,
207
+ // the swinging foot is drawn back to meet the ground moving as the ground does; over a run's long flight that pull, at
208
+ // full strength, first throws the foot far out ahead of where it lands (`runRetract`: the share of it kept at a full run)
209
+ drift = (((v < 0 ? sweep : -sweep) * (1 - duty)) / duty) * lerp(1, pace.runRetract ?? 1, run),
204
210
  gone = (actor.fwd * deltaSeconds) / h,
205
211
  leftFirst = Math.abs(stanceL - feet[0]) >= Math.abs(stanceR - feet[1]); // of two feet out of place, the one further out steps first
206
212
  footAt(
@@ -188,7 +188,8 @@ function createFigureArms({ gestureOf, seat, blade, flier = () => false, dropInt
188
188
  }
189
189
  w.foreL = foreL;
190
190
  w.foreR = foreR;
191
- if (seated > FELT) seatedArms(a, w, a.cur[TRUNK]);
191
+ // an act has the arms it names even in the saddle or on a seat: the seat keeps only the rest
192
+ if (seated > FELT) seatedArms(a, w, a.cur[TRUNK], act ? 1 - act[HAS_LEFT] : 1, act ? 1 - act[HAS_RIGHT] : 1);
192
193
  const flatL = (held && held.r && !held.stow && (held.both || held.left)) || (held && held.flat),
193
194
  flatR = held && held.r && !held.stow && !held.left;
194
195
  let turnL = seated * onTable(a, true) * (0.42 + a.seed * 0.2) + (gesture ? gesture[LY] : 0) + recTurnL,
@@ -74,6 +74,8 @@ const FIGURE_STRIDE = {
74
74
  runBob: 0.03,
75
75
  walkLift: 0.085,
76
76
  runLift: 0.4,
77
+ runLanding: 0.3,
78
+ runRetract: 0.35,
77
79
  hipResponse: 18,
78
80
  idleRate: 1.4,
79
81
  runLean: 0.2,
@@ -58,7 +58,7 @@ const FLAT = () => 0,
58
58
  * metres, table: the height of a table before it, if any }) is in the place being shown; every seat is, by default.
59
59
  * @returns {object} seatTarget(a, w, t) and kneelTarget(a, w, footGround): the pose's targets for this frame on a seat (a
60
60
  * stool, a horse: `a.mount`) or on one knee, with `a.joints` solved; groundUnderKnee(a, size): the ground under a kneeling
61
- * figure's forward foot (and into `a.y` under its knee); seatedArms(a, w, lean); onTable(a, left); kneeOf(a, left);
61
+ * figure's forward foot (and into `a.y` under its knee); seatedArms(a, w, lean, freeL, freeR) (freeL, freeR: each arm's share left to the seat, 1 by default; an act takes the rest); onTable(a, left); kneeOf(a, left);
62
62
  * freeKnees(a, thighL, thighR); conformGroundPosture(a, w, target) and groundConformState(): a
63
63
  * crawler's or a lying body's fit to the slope under it.
64
64
  */
@@ -186,15 +186,16 @@ function createFigureSeat({ ground = FLAT, seatHere = ANY_SEAT } = {}) {
186
186
  CLOSEST = 0.14; // and one nearer the shoulder than this is taken as this far
187
187
  const armIK = (forward, up) => solveTwoBone(reach, UPPER_ARM, FOREARM, forward, up, CLOSEST, (UPPER_ARM + FOREARM) * FULL_REACH);
188
188
  // A seated figure's arms reach for where its hands rest (seatTarget), as far as it is seated.
189
- function seatedArms(a, w, lean) {
189
+ function seatedArms(a, w, lean, freeL = 1, freeR = 1) {
190
190
  const joints = a.joints,
191
- seated = w.seated;
191
+ seatedL = w.seated * freeL,
192
+ seatedR = w.seated * freeR;
192
193
  let solved = armIK(joints[HAND_L_FWD], joints[HAND_L_UP]);
193
- w.armL = lerp(w.armL, -solved[0] - lean, seated);
194
- w.foreL = lerp(w.foreL, -solved[1], seated);
194
+ w.armL = lerp(w.armL, -solved[0] - lean, seatedL);
195
+ w.foreL = lerp(w.foreL, -solved[1], seatedL);
195
196
  solved = armIK(joints[HAND_R_FWD], joints[HAND_R_UP]);
196
- w.armR = lerp(w.armR, -solved[0] - lean, seated);
197
- w.foreR = lerp(w.foreR, -solved[1], seated);
197
+ w.armR = lerp(w.armR, -solved[0] - lean, seatedR);
198
+ w.foreR = lerp(w.foreR, -solved[1], seatedR);
198
199
  }
199
200
  // How far each seated forearm lies on the table (0 to 1).
200
201
  const onTable = (a, left) => a.joints[left ? TABLE_L : TABLE_R];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roamwright",
3
- "version": "0.61.7",
3
+ "version": "0.61.9",
4
4
  "description": "A procedural worldbuilding engine built on top of Three.js. Generate landscapes with rivers and changing weather, animate crowds, and explore on foot or in flight.",
5
5
  "keywords": [
6
6
  "threejs",