roamwright 0.60.0 → 0.61.1

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.
@@ -0,0 +1,192 @@
1
+ /**
2
+ * Build a dromedary pack camel's saddle blanket, wooden pack-saddle tree, belly girth, stuffed pannier sacks and lashed bedrolls.
3
+ * @module
4
+ */
5
+
6
+ import { lerp, sstep } from '../math/scalar.js';
7
+ import { tube } from './animal-skin.js';
8
+ import { BONE } from '../motion/quadruped.js';
9
+
10
+ const BLANKET = [0.46, 0.4, 0.32],
11
+ SACK = [0.62, 0.55, 0.44],
12
+ RUGS = [
13
+ [0.36, 0.3, 0.24],
14
+ [0.56, 0.5, 0.41],
15
+ ],
16
+ WOOD = [0.32, 0.22, 0.13],
17
+ ROPE = [0.46, 0.38, 0.27];
18
+
19
+ /**
20
+ * Append a pack camel's load (woven blanket, belly girth, wooden saddle arches, stuffed pannier sacks and rolled rugs) to `b`
21
+ * on the chest bone, following the camel's hump lift function.
22
+ * @param {import('./builder.js').GeometryBuilder} b Target geometry builder in withers units.
23
+ * @param {number} q Detail level (0 far, 1 mid, 2 near).
24
+ * @param {(x: number, y: number, z: number, extra?: number) => number} humpLift Vertical lift of the dromedary hump.
25
+ * @param {{ blanket?: number[], rugs?: number[][] }} [colours] Optional linear [r, g, b] colours for the blanket and rolled rugs.
26
+ */
27
+ function camelPack(b, q, humpLift, { blanket = BLANKET, rugs = RUGS } = {}) {
28
+ const drape = (z, top, bottom, w, out = 0.015) => [
29
+ (top + bottom) / 2,
30
+ z,
31
+ w + out,
32
+ (top - bottom) / 2 + out,
33
+ (top - bottom) / 2 + out,
34
+ 0,
35
+ 2.3,
36
+ ];
37
+ b.tv = 0.8;
38
+ // Woven striped saddle blanket following the trunk and hump closely (the trunk's stations over the ribs, 0.015 outside them).
39
+ tube(
40
+ b,
41
+ [
42
+ drape(-0.22, 0.955, 0.6, 0.14),
43
+ drape(-0.08, 0.98, 0.545, 0.16),
44
+ drape(0.06, 0.985, 0.51, 0.17),
45
+ drape(0.19, 0.98, 0.5, 0.165),
46
+ drape(0.28, 0.96, 0.53, 0.15),
47
+ ],
48
+ {
49
+ chain: [BONE.chest],
50
+ around: [8, 12, 16][q],
51
+ sub: [1, 2, 2][q],
52
+ arc: [0.05, Math.PI - 0.05],
53
+ warp: (Q, k) => {
54
+ Q[k + 1] += humpLift(Q[k], Q[k + 1], Q[k + 2], 0.022) * 1.04;
55
+ },
56
+ coat: (col, x, y, z) => {
57
+ const stripe = Math.sin((z + 0.22) * 70) > 0.72 ? 0.48 : 1,
58
+ hem = sstep(0.92, 0.86, y);
59
+ for (let i = 0; i < 3; i++) col[i] = lerp(blanket[i] * stripe, 0.68, hem * 0.45);
60
+ col[3] = 0.8;
61
+ },
62
+ },
63
+ );
64
+ // Snug woven belly girth strap hugging the barrel tightly behind the elbows (never floating off the belly).
65
+ const ropeCoat = col => {
66
+ col[0] = ROPE[0];
67
+ col[1] = ROPE[1];
68
+ col[2] = ROPE[2];
69
+ col[3] = 0.65;
70
+ };
71
+ tube(
72
+ b,
73
+ [
74
+ [(0.985 + 0.51) / 2, 0.09, 0.179, (0.985 - 0.51) / 2 + 0.011, (0.985 - 0.51) / 2 + 0.011, 0, 2.5],
75
+ [(0.98 + 0.505) / 2, 0.14, 0.177, (0.98 - 0.505) / 2 + 0.011, (0.98 - 0.505) / 2 + 0.011, 0, 2.5],
76
+ ],
77
+ {
78
+ chain: [BONE.chest],
79
+ around: [8, 10, 12][q],
80
+ sub: 1,
81
+ arc: [-Math.PI - 0.08, 0.08],
82
+ coat: ropeCoat,
83
+ },
84
+ );
85
+ const woodCoat = col => {
86
+ col[0] = WOOD[0];
87
+ col[1] = WOOD[1];
88
+ col[2] = WOOD[2];
89
+ col[3] = 0.35;
90
+ };
91
+ const bagSeg = [6, 7, 9][q],
92
+ bagSub = [1, 2, 2][q],
93
+ rollSeg = [6, 7, 9][q];
94
+ // Wooden pack-saddle side rails resting snugly on the blanket, plus fitted wooden saddle-tree arches hugging the hump.
95
+ for (const s of [-1, 1]) {
96
+ tube(
97
+ b,
98
+ [
99
+ [0.955, -0.22, 0, 0, 0, 0],
100
+ [0.955, -0.2, 0.013, 0.017, 0.017, 0, 2.6],
101
+ [0.97, 0.0, 0.014, 0.017, 0.017, 0, 2.6],
102
+ [0.965, 0.17, 0.013, 0.017, 0.017, 0, 2.6],
103
+ [0.965, 0.19, 0, 0, 0, 0],
104
+ ],
105
+ { x: s * 0.182, side: s, chain: [BONE.chest], around: [4, 5, 5][q], sub: 1, coat: woodCoat },
106
+ );
107
+ // Front and rear wooden saddle-tree arms curving tightly along the blanket over the front and back of the hump.
108
+ for (const zArch of [-0.19, 0.15]) {
109
+ const zOff = zArch < 0 ? -0.01 : 0.01;
110
+ tube(
111
+ b,
112
+ [
113
+ [0.93, zArch, 0, 0, 0, 0, 2, 0.185],
114
+ [0.95, zArch, 0.012, 0.013, 0.013, 0, 2.4, 0.18],
115
+ [1.045, zArch + zOff * 0.5, 0.012, 0.013, 0.013, 0, 2.4, 0.1],
116
+ [1.11, zArch + zOff, 0.011, 0.011, 0.011, 0, 2.4, 0.014],
117
+ [1.135, zArch + zOff, 0.009, 0.009, 0.009, 0, 2.2, -0.018],
118
+ [1.15, zArch + zOff, 0, 0, 0, 0, 2, -0.03],
119
+ ],
120
+ { x: 0, side: s, chain: [BONE.chest], around: [4, 5, 5][q], sub: 1, coat: woodCoat },
121
+ );
122
+ }
123
+ // Stuffed woven main pannier sack: lofted along z with softly slumped belly, tied ends, and woven grain.
124
+ const sackCoat = (col, x, y, z) => {
125
+ const weave = 0.92 + 0.12 * Math.sin(z * 110 + y * 90),
126
+ band = Math.abs(z + 0.08) < 0.014 || Math.abs(z - 0.09) < 0.014 ? 1 : 0;
127
+ for (let i = 0; i < 3; i++) col[i] = lerp(SACK[i] * weave, ROPE[i], band);
128
+ col[3] = lerp(0.75, 0.55, band);
129
+ };
130
+ tube(
131
+ b,
132
+ [
133
+ [0.85, -0.22, 0, 0, 0, 0],
134
+ [0.85, -0.195, 0.045, 0.068, 0.078, 0, 2.3],
135
+ [0.855, -0.11, 0.084, 0.112, 0.132, 0, 2.4, 0.015],
136
+ [0.86, 0.02, 0.088, 0.116, 0.136, 0, 2.4, 0.018],
137
+ [0.865, 0.13, 0.078, 0.102, 0.118, 0, 2.35, 0.012],
138
+ [0.865, 0.195, 0.036, 0.056, 0.064, 0, 2.2],
139
+ [0.865, 0.215, 0, 0, 0, 0],
140
+ ],
141
+ {
142
+ x: s * 0.245,
143
+ side: s,
144
+ chain: [BONE.chest],
145
+ around: bagSeg,
146
+ sub: bagSub,
147
+ coat: sackCoat,
148
+ // Gentle weight sag and lashing cinch where the two ropes bind the bag.
149
+ warp: (Q, k) => {
150
+ const cinch = Math.max(sstep(0.024, 0.004, Math.abs(Q[k + 2] + 0.08)), sstep(0.024, 0.004, Math.abs(Q[k + 2] - 0.09)));
151
+ Q[k] -= Math.sign(Q[k]) * 0.008 * cinch;
152
+ Q[k + 1] -= 0.012 * sstep(0.9, 0.74, Q[k + 1]);
153
+ },
154
+ },
155
+ );
156
+ // Rolled woven rug / canvas bale lashed along the upper flank with softly closed folded fabric ends.
157
+ const rug = rugs[s > 0 ? 0 : 1],
158
+ rugCoat = (col, x, y, z) => {
159
+ const stripe = Math.sin(z * 55) > 0.65 ? 0.72 : 1,
160
+ tie = Math.abs(z + 0.1) < 0.012 || Math.abs(z - 0.09) < 0.012 ? 1 : 0;
161
+ for (let i = 0; i < 3; i++) col[i] = lerp(rug[i] * stripe, ROPE[i], tie);
162
+ col[3] = lerp(0.8, 0.55, tie);
163
+ };
164
+ tube(
165
+ b,
166
+ [
167
+ [1.015, -0.225, 0, 0, 0, 0],
168
+ [1.015, -0.205, 0.04, 0.038, 0.038, 0, 2.1],
169
+ [1.018, -0.15, 0.056, 0.054, 0.054, 0, 2.15],
170
+ [1.02, 0.0, 0.058, 0.056, 0.056, 0, 2.15],
171
+ [1.02, 0.14, 0.055, 0.053, 0.053, 0, 2.15],
172
+ [1.018, 0.195, 0.038, 0.036, 0.036, 0, 2.1],
173
+ [1.018, 0.215, 0, 0, 0, 0],
174
+ ],
175
+ {
176
+ x: s * 0.238,
177
+ side: s,
178
+ chain: [BONE.chest],
179
+ around: rollSeg,
180
+ sub: [1, 1, 2][q],
181
+ coat: rugCoat,
182
+ warp: (Q, k) => {
183
+ const cinch = Math.max(sstep(0.022, 0.004, Math.abs(Q[k + 2] + 0.1)), sstep(0.022, 0.004, Math.abs(Q[k + 2] - 0.09)));
184
+ Q[k] -= Math.sign(Q[k]) * 0.005 * cinch;
185
+ Q[k + 1] -= 0.004 * cinch;
186
+ },
187
+ },
188
+ );
189
+ }
190
+ }
191
+
192
+ export { camelPack };
@@ -4,10 +4,12 @@ import { GB } from './builder.js';
4
4
  import { TRS } from './primitives.js';
5
5
  import { SHAPES } from './animal-shapes.js';
6
6
  import { tube } from './animal-skin.js';
7
+ import { haunchStations } from './animal-haunch.js';
7
8
  import { LIMB, TAIL, TRUNK, breedOf, coatOf, hair } from './animal-canine-breeds.js';
8
9
  import { BLACK, SMOOTH, head, headPlan } from './animal-canine-head.js';
9
10
  import { BONE, LEGS, makeRig } from '../motion/quadruped.js';
10
11
  import { NO_ANIMAL_OPTIONS, animalNoise } from './animal-options.js';
12
+ import { catBodies, catRig } from './animal-cat-body.js';
11
13
 
12
14
  // ════════════════════════════════════════════════════════════════════════
13
15
  // A canine's body (rendering/animal-canine-figure.js puts it together): its plan from the look, where its joints are, and the arrays of its near and far
@@ -38,7 +40,7 @@ const WITHERS = 1.42, // a canine's withers in model units, before the figure's
38
40
  // hind right), rise, lift, flex] (motion/quadruped.js). A walk in lateral sequence, a trot on the diagonals, a gallop with both flights.
39
41
  const HABITS = {
40
42
  fore: { follow: 0.85, heel3: 0.35, fold3: 0.85, heel4: 0.7, fold4: 0.9, sink: 0, glide: 0.14 },
41
- hind: { follow: 0.55, heel3: 0.4, fold3: 0.3, heel4: 0.7, fold4: 0.8, sink: 0, glide: 0 },
43
+ hind: { follow: 0.55, heel3: 0.35, fold3: 0.28, heel4: 0.65, fold4: 0.75, sink: 0, glide: 0, paired: true, thigh: 0.52 },
42
44
  crouch: 0.05,
43
45
  gaits: [
44
46
  [0.1, 0.42, 0.7, [0.25, 0.75, 0, 0.5], 0.02, 0.07, 0.03],
@@ -50,38 +52,46 @@ const HABITS = {
50
52
  ],
51
53
  };
52
54
 
53
- // Where the joints are, in withers heights: [y, z] in the body's upright plane.
55
+ // Where the joints are, in withers heights: [y, z] in the body's upright plane; and the rump's section at the hips, for the thigh
56
+ // to hang inside (geometry/animal-haunch.js).
57
+ const RUMP_SQUARE = 2.6; // gently full rump so the muscular canine thigh merges smoothly without looking boxy
54
58
  function anatomy(p) {
55
59
  const e = p.leg,
60
+ low = Math.max(0, 0.42 - e), // short-legged breeds (such as a rat) drop their belly closer to the ground
56
61
  zF = 0.4 * p.long,
57
62
  zH = -0.56 * p.long,
58
63
  carriage = lerp(0.2, 1.1, p.neck[2]),
59
64
  reach = 0.4 * p.neck[0],
60
- neck = [0.87, zF + 0.09],
65
+ neck = [0.87 - low * 1.1, zF + 0.09],
61
66
  tailSlope = lerp(0.35, 2.5, p.tail[1]), // from hanging to carried over the back
62
- tailLen = 0.46 * p.tail[0];
67
+ tailLen = 0.46 * p.tail[0],
68
+ floor = Math.max(0.18, 1 - 0.47 * p.depth - low * 2.1),
69
+ rumpFloor = Math.max(floor + 0.01, 0.65 + p.croup - low * 2.0),
70
+ rumpY = Math.min(0.94 + p.croup - low * 0.9 - 0.05, Math.max(rumpFloor + 0.05, 0.87 - low * 1.15));
63
71
  return {
64
72
  zF,
65
73
  zH,
74
+ low,
66
75
  croup: p.croup,
67
76
  sx: 0.08 * p.girth,
68
- hx: 0.084 * p.girth,
69
- shoulder: [e + 0.19, zF + 0.11],
77
+ hx: 0.08 * p.girth,
78
+ shoulder: [e + 0.19 - low * 0.35, zF + 0.11],
70
79
  elbow: [e, zF - 0.045],
71
80
  wrist: [0.3 * e, zF - 0.012],
72
81
  knuckle: [0.052, zF + 0.02],
73
82
  pad: [0, zF + 0.05],
74
- hip: [0.84 + p.croup, zH + 0.17],
75
- stifle: [e - 0.01, zH + 0.3],
76
- hock: [p.hock * e, zH - 0.035],
77
- heel: [0.052, zH],
78
- hindPad: [0, zH + 0.038],
83
+ hip: [0.84 + p.croup - low * 1.35, zH + 0.15],
84
+ stifle: [e - 0.01 + low * 0.4, zH + 0.27 - low * 0.3],
85
+ hock: [p.hock * e, zH - 0.065 + low * 0.18],
86
+ heel: [0.052, zH - 0.005],
87
+ hindPad: [0, zH + 0.03],
79
88
  neck,
80
89
  poll: [neck[0] + reach * Math.sin(carriage), neck[1] + reach * Math.cos(carriage)],
81
- tail: [0.905 + p.croup, zH - 0.02],
90
+ tail: [0.895 + p.croup - low * 1.1, zH - 0.05],
82
91
  tailDir: [-Math.cos(tailSlope), -Math.sin(tailSlope)],
83
92
  tailLen,
84
- chestFloor: 1 - 0.47 * p.depth,
93
+ chestFloor: floor,
94
+ rump: { y: rumpY, h: rumpY - rumpFloor, w: 0.118 * p.girth, n: low > 0.05 ? 2.15 : RUMP_SQUARE },
85
95
  };
86
96
  }
87
97
 
@@ -123,29 +133,43 @@ function jointsAt(A, H, headAt) {
123
133
  // The trunk and neck: croup, loin, ribcage, shoulders, and the neck up to the poll, as one skin.
124
134
  function trunk(b, A, p, coat, detail) {
125
135
  const g = p.girth,
126
- up = p.croup, // the rump raised over a dog's
136
+ up = p.croup,
137
+ low = A.low,
127
138
  nt = p.neck[1],
128
139
  { zF, zH } = A,
129
140
  floor = A.chestFloor,
130
141
  tuck = floor + 0.15 * p.tuck,
131
- ring = (z, top, bottom, w, bone, sq = 2.15) => [(top + bottom) / 2, z, w, (top - bottom) / 2, (top - bottom) / 2, bone, sq],
132
- mid = [(A.neck[0] + A.poll[0]) / 2, (A.neck[1] + A.poll[1]) / 2];
142
+ // Keep the trunk centerline high near the neck root so rise stays small and z - ty * rise never reverses at the withers. The
143
+ // rump's rings are fuller than the barrel's, their sides near vertical down to the rump's floor, where a thigh leaves the rump
144
+ // in a fold (geometry/animal-haunch.js)
145
+ spine = 0.87 - low * 1.1,
146
+ band = (z, top, bottom, w, bone, sq = 2.15) => {
147
+ const y = Math.min(top - 0.05, Math.max(bottom + 0.05, spine));
148
+ return [y, z, w, top - y, y - bottom, bone, sq];
149
+ },
150
+ n0 = [lerp(spine, A.neck[0], 0.55), lerp(zF + 0.12, A.neck[1] + 0.08, 0.5)],
151
+ n1 = [lerp(A.neck[0], A.poll[0], 0.52), lerp(A.neck[1] + 0.06, A.poll[1], 0.52)];
152
+ const rumpTop = 0.94 + up * 0.8 - low * 0.9,
153
+ backTop = 0.96 + up * 0.45 - low * 0.95,
154
+ shoulderTop = 0.995 + p.hump - low * 1.15,
155
+ rump = A.rump,
156
+ rSq = rump.n;
133
157
  const S = [
134
- [0.84 + up, zH - 0.09, 0, 0, 0, 0],
135
- ring(zH - 0.065, 0.9 + up, 0.72 + up, 0.066 * g, 0),
136
- ring(zH + 0.04, 0.94 + up, 0.65 + up, 0.108 * g, 0),
137
- ring(zH + 0.17, 0.958 + up, tuck - 0.01, 0.114 * g, 0),
138
- ring(zH + 0.36, 0.96 + up * 0.8, tuck, 0.094 * g ** 0.8, 0.5, 2),
139
- ring(zH + 0.56, 0.968 + up * 0.4, lerp(tuck, floor, 0.62), 0.116 * g, 0.85),
140
- ring(zF - 0.22, 0.98, floor + 0.01, 0.122 * g, 1),
141
- ring(zF - 0.06, 0.996 + p.hump * 0.5, floor - 0.005, 0.12 * g, 1),
142
- ring(zF + 0.07, 1.005 + p.hump, floor + 0.03, 0.114 * g, 1),
143
- ring(zF + 0.165, 0.995 + p.hump * 0.6, floor + 0.13, 0.092 * g * nt ** 0.5, 1.4, 2),
144
- [A.neck[0] + 0.03, A.neck[1] + 0.085, 0.094 * nt, 0.115 * nt, 0.15 * nt, 2],
145
- [mid[0], mid[1], 0.082 * nt, 0.098 * nt, 0.108 * nt, 3],
146
- [A.poll[0] - 0.014, A.poll[1] - 0.014, 0.07 * nt ** 0.7, 0.078 * nt ** 0.7, 0.084 * nt ** 0.7, 3.8],
147
- [A.poll[0] - 0.02, A.poll[1] + 0.05, 0.05, 0.05, 0.05, 4],
148
- [A.poll[0] - 0.025, A.poll[1] + 0.08, 0, 0, 0, 4],
158
+ [0.82 + up * 0.5 - low * 1.25, zH - 0.115, 0, 0, 0, 0],
159
+ band(zH - 0.075, 0.89 + up * 0.6 - low * 1.0, Math.max(floor + 0.04, 0.7 + up - low * 1.9), 0.076 * g, 0, Math.min(2.4, rSq)),
160
+ band(zH + 0.04, rumpTop, rump.y - rump.h, rump.w, 0, rSq),
161
+ band(zH + 0.18, rumpTop + 0.015, tuck - 0.01, 0.12 * g, 0, Math.min(2.5, rSq)),
162
+ band(zH + 0.36, backTop, tuck, 0.102 * g ** 0.8, 0.5, 2.3),
163
+ band(zH + 0.56, lerp(backTop, shoulderTop, 0.4), lerp(tuck, floor, 0.62), 0.116 * g, 0.85),
164
+ band(zF - 0.22, lerp(backTop, shoulderTop, 0.72), floor + 0.01, 0.122 * g, 1),
165
+ band(zF - 0.06, shoulderTop - p.hump * 0.4, floor - 0.005, 0.12 * g, 1),
166
+ band(zF + 0.07, shoulderTop, floor + 0.035, 0.112 * g, 1),
167
+ [spine + 0.005 + p.hump * 0.2, zF + 0.155, 0.096 * g * nt ** 0.45, 0.115 * nt ** 0.5, Math.max(0.14, spine - floor - 0.08), 1.55, 2.05],
168
+ [n0[0] + 0.015, Math.max(zF + 0.21, n0[1]), 0.084 * nt, 0.098 * nt, 0.132 * nt, 2.1, 2.05],
169
+ [n1[0], Math.max(zF + 0.26, n1[1]), 0.076 * nt, 0.088 * nt, 0.1 * nt, 3, 2.05],
170
+ [A.poll[0] - 0.012, A.poll[1] - 0.014, 0.068 * nt ** 0.7, 0.075 * nt ** 0.7, 0.082 * nt ** 0.7, 3.8],
171
+ [A.poll[0] - 0.018, A.poll[1] + 0.045, 0.048, 0.048, 0.048, 4],
172
+ [A.poll[0] - 0.022, A.poll[1] + 0.075, 0, 0, 0, 4],
149
173
  ];
150
174
  tube(b, S, {
151
175
  chain: [BONE.hips, BONE.chest, BONE.neck, BONE.neck2, BONE.head],
@@ -178,38 +202,55 @@ function trunk(b, A, p, coat, detail) {
178
202
  });
179
203
  }
180
204
 
205
+ // A hind leg's thigh as rounded slices (geometry/animal-haunch.js): height, front edge, back edge, half-width, lean, squareness,
206
+ // level. Real proportions of a dog, in withers heights: hip 0.84, stifle 0.55 forward under the waist, hock 0.26 well behind the
207
+ // heel; the plump rounded thigh grows smoothly out of the rump's side and tapers into a backward-sloping muscular gaskin and
208
+ // slender Achilles curve above the hock. Plantigrade breeds (rat, bear) keep naturally low hocks and compact rounded haunches.
209
+ function thighOf(A, p) {
210
+ const h = A.hip,
211
+ s = A.stifle,
212
+ k = A.hock,
213
+ g = p.girth ** 0.7, // a broad breed's thigh grows more slowly than its girth
214
+ b = p.bone ** 0.65,
215
+ hs = Math.max(0.12, h[0] - s[0]),
216
+ compact = A.low > 0.05 ? 0.72 : 1; // short-legged breeds (such as a rat) keep a compact rounded haunch
217
+ return [
218
+ [h[0] + 0.08 * hs, h[1] + 0.04 * compact, h[1] - 0.11 * compact, 0, -0.055 * g, 2], // closed inside the upper rump
219
+ [h[0] - 0.08 * hs, h[1] + 0.085 * compact, h[1] - 0.155 * compact, 0.058 * g, -0.034 * g, 2], // upper haunch under tail root
220
+ [h[0] - 0.45 * hs, lerp(h[1] + 0.09 * compact, s[1] + 0.035 * b, 0.55), h[1] - 0.15 * compact, 0.06 * g, -0.02 * g, 2], // plump rounded mid-thigh & buttock merging tangentially with rump
221
+ [s[0], s[1] + 0.034 * b, lerp(h[1] - 0.135 * compact, s[1] - 0.085 * compact, 0.46), 0.046 * g, -0.006 * g, 2], // rounded stifle forward under waist, curving cleanly into the tibia
222
+ [lerp(s[0], k[0], 0.4), lerp(s[1], k[1], 0.44) + 0.03 * b, lerp(s[1] - 0.105 * compact, k[1] - 0.042 * b, 0.52), 0.033 * b, 0, 2], // muscular upper gaskin sloping clearly back along the tibia
223
+ [lerp(s[0], k[0], 0.76), lerp(s[1], k[1], 0.78) + 0.025 * b, k[1] - 0.036 * b, 0.025 * b, 0, 2], // slender Achilles above hock
224
+ ];
225
+ }
226
+
181
227
  // A leg from the shoulder blade or the rump to the knuckle, then the paw: pads, toes and claws.
182
228
  function leg(b, A, p, coat, detail, s, hind) {
183
229
  const t = p.bone,
184
230
  f = LEGS[(hind ? 2 : 0) + (s > 0 ? 1 : 0)],
185
231
  mix = (P, Q, k, dz = 0) => [P[0] + (Q[0] - P[0]) * k, P[1] + (Q[1] - P[1]) * k + dz],
186
- at = (P, w, front, back, bone, dz = 0) => [P[0], P[1] + dz, w * t, front * t, back * t, bone];
232
+ at = (P, w, front, back, bone, dz = 0, level = 0) => [P[0], P[1] + dz, w * t, front * t, back * t, bone, 2, 0, level];
187
233
  const S = hind
188
234
  ? [
189
- [0.935 + p.croup, A.hip[1] - 0.04, 0, 0, 0, 0],
190
- [A.hip[0] + 0.045, A.hip[1] - 0.03, 0.04 * t, 0.1, 0.12, 0.3, 2, -0.03 * p.girth],
191
- [...at(mix(A.hip, A.stifle, 0.35), 0.056, 0.088, 0.14, 1, -0.03), 2, -0.012 * p.girth],
192
- at(mix(A.hip, A.stifle, 0.75), 0.055, 0.066, 0.118, 1, -0.02),
193
- at(A.stifle, 0.042, 0.046, 0.085, 1.5, -0.012),
194
- at(mix(A.stifle, A.hock, 0.42), 0.04, 0.044, 0.06, 2),
195
- at(mix(A.stifle, A.hock, 0.8), 0.03, 0.03, 0.04, 2),
196
- at(A.hock, 0.03, 0.031, 0.044, 2.5),
197
- at(mix(A.hock, A.heel, 0.5), 0.026, 0.026, 0.029, 3),
198
- at(A.heel, 0.032, 0.031, 0.031, 3),
199
- [A.heel[0] - 0.03, A.heel[1] + 0.004, 0, 0, 0, 3],
235
+ // the rounded thigh & backward-sloping gaskin (above), then the crisp backward-pointing hock and near-vertical cannon
236
+ ...haunchStations(thighOf(A, p), { x: A.hx, hip: A.hip[0], stifle: A.stifle[0], hock: A.hock[0] }, A.rump, detail === 0),
237
+ at(A.hock, 0.026, 0.026, 0.044, 2.5, 0, 1),
238
+ at(mix(A.hock, A.heel, 0.52), 0.023, 0.023, 0.026, 3, 0, 0.4),
239
+ at(A.heel, 0.029, 0.029, 0.029, 3),
240
+ [A.heel[0] - 0.025, A.heel[1] + 0.004, 0, 0, 0, 3],
200
241
  ]
201
242
  : [
202
- [0.955, A.zF, 0, 0, 0, 0],
203
- [0.9, A.zF + 0.01, 0.028 * t, 0.075, 0.07, 0, 2, -0.03 * p.girth],
204
- [...at(mix(A.shoulder, A.elbow, -0.2), 0.04, 0.078, 0.088, 0.5, -0.02), 2, -0.012 * p.girth],
205
- at(mix(A.shoulder, A.elbow, 0.5), 0.048, 0.066, 0.1, 1),
206
- at(A.elbow, 0.042, 0.052, 0.068, 1.5),
207
- at(mix(A.elbow, A.wrist, 0.25), 0.04, 0.044, 0.05, 2),
208
- at(mix(A.elbow, A.wrist, 0.75), 0.031, 0.031, 0.034, 2),
209
- at(A.wrist, 0.032, 0.033, 0.037, 2.5),
210
- at(mix(A.wrist, A.knuckle, 0.5), 0.029, 0.028, 0.029, 3),
211
- at(A.knuckle, 0.034, 0.032, 0.032, 3),
212
- [A.knuckle[0] - 0.03, A.knuckle[1] + 0.004, 0, 0, 0, 3],
243
+ [A.shoulder[0] + 0.215, A.zF, 0, 0, 0, 0, 2, -0.052 * p.girth],
244
+ [A.shoulder[0] + 0.16, A.zF + 0.01, 0.03 * t, 0.07, 0.068, 0.15, 2, -0.038 * p.girth],
245
+ [...at(mix(A.shoulder, A.elbow, -0.15), 0.04, 0.072, 0.082, 0.55, -0.016), 2, -0.018 * p.girth],
246
+ at(mix(A.shoulder, A.elbow, 0.52), 0.045, 0.062, 0.088, 1),
247
+ at(A.elbow, 0.04, 0.048, 0.06, 1.5),
248
+ at(mix(A.elbow, A.wrist, 0.28), 0.036, 0.04, 0.045, 2),
249
+ at(mix(A.elbow, A.wrist, 0.76), 0.028, 0.029, 0.031, 2),
250
+ at(A.wrist, 0.029, 0.03, 0.034, 2.5),
251
+ at(mix(A.wrist, A.knuckle, 0.5), 0.027, 0.026, 0.027, 3),
252
+ at(A.knuckle, 0.03, 0.029, 0.029, 3),
253
+ [A.knuckle[0] - 0.025, A.knuckle[1] + 0.004, 0, 0, 0, 3],
213
254
  ];
214
255
  tube(b, S, {
215
256
  x: s * (hind ? A.hx : A.sx),
@@ -225,7 +266,7 @@ function leg(b, A, p, coat, detail, s, hind) {
225
266
  ((out, x, y, z, nx, ny, nz, a) => {
226
267
  const back = sstep(-0.3, -0.8, Math.sin(a)),
227
268
  len = p.fur * (0.016 + 0.03 * back * sstep(0.15, 0.45, y) + 0.012 * hair(x, y, z));
228
- if (len < 0.024 || y < 0.12) return false;
269
+ if (len < (hind ? 0.026 : 0.024) || y < 0.12) return false;
229
270
  out[0] = len;
230
271
  out[1] = 0.2;
231
272
  out[2] = len * 0.3;
@@ -237,16 +278,16 @@ function leg(b, A, p, coat, detail, s, hind) {
237
278
  }
238
279
 
239
280
  function paw(b, A, p, coat, detail, s, hind, bone) {
240
- const k = 1.3 * p.bone ** 0.7 * p.paw,
281
+ const k = 1.0 * p.bone ** 0.55 * p.paw,
241
282
  P = hind ? A.heel : A.knuckle,
242
283
  x = s * (hind ? A.hx : A.sx),
243
284
  z = P[1],
244
285
  S = [
245
- [0.038, z - 0.032 * k, 0, 0, 0, 0],
246
- [0.038, z - 0.014 * k, 0.03 * k, 0.03, 0.036, 0],
247
- [0.034, z + 0.026 * k, 0.038 * k, 0.034, 0.034, 0],
248
- [0.024, z + 0.056 * k, 0.036 * k, 0.026, 0.024, 0],
249
- [0.02, z + 0.07 * k, 0, 0, 0, 0],
286
+ [0.034, z - 0.026 * k, 0, 0, 0, 0],
287
+ [0.034, z - 0.01 * k, 0.03 * k, 0.028, 0.032, 0],
288
+ [0.03, z + 0.024 * k, 0.036 * k, 0.03, 0.03, 0],
289
+ [0.022, z + 0.05 * k, 0.033 * k, 0.022, 0.022, 0],
290
+ [0.018, z + 0.062 * k, 0, 0, 0, 0],
250
291
  ];
251
292
  tube(b, S, {
252
293
  x,
@@ -257,25 +298,34 @@ function paw(b, A, p, coat, detail, s, hind, bone) {
257
298
  coat: coat(LIMB),
258
299
  // the toes: the fore part of the paw is parted into four
259
300
  warp: (Q, q, a, v) => {
260
- const toe = Math.abs(Math.sin(((Q[q] - x) / (0.038 * k)) * Math.PI * 1.5)),
261
- part = sstep(0.45, 0.8, v) * (1 - toe) * 0.3;
262
- Q[q + 1] -= (Q[q + 1] - 0.01) * part;
263
- Q[q + 2] -= part * 0.012 * k;
301
+ const toe = Math.abs(Math.sin(((Q[q] - x) / (0.036 * k)) * Math.PI * 1.5)),
302
+ part = sstep(0.45, 0.8, v) * (1 - toe) * 0.28;
303
+ Q[q + 1] = Math.max(0, Q[q + 1] - (Q[q + 1] - 0.008) * part);
304
+ Q[q + 2] -= part * 0.01 * k;
264
305
  },
265
306
  });
266
307
  if (detail < NEAR) return;
267
308
  b.bone = bone;
268
309
  b.tv = SMOOTH;
269
310
  for (let i = 0; i < 4; i++) {
270
- const cx = x + (i - 1.5) * 0.018 * k;
271
- b.add(SHAPES.cone6, BLACK, TRS(cx, 0.017, z + (0.062 - 0.007 * Math.abs(i - 1.5)) * k, 0.007 * k, 0.02 * k, 0.007 * k, 0, 1.25));
311
+ const cx = x + (i - 1.5) * 0.016 * k;
312
+ b.add(SHAPES.cone6, BLACK, TRS(cx, 0.014, z + (0.054 - 0.006 * Math.abs(i - 1.5)) * k, 0.006 * k, 0.016 * k, 0.006 * k, 0, 1.35));
272
313
  }
273
314
  }
274
315
 
275
316
  function tail(b, A, p, coat, detail) {
276
- const r = 0.036 * p.tail[2] * p.bone ** 0.5,
277
- at = (u, k, bone) => [A.tail[0] + A.tailDir[0] * A.tailLen * u, A.tail[1] + A.tailDir[1] * A.tailLen * u, r * k, r * k, r * k, bone];
278
- tube(b, [at(-0.04, 0, 0.5), at(0.03, 0.75, 0.7), at(0.3, 0.95, 1.4), at(0.65, 1, 2.5), at(0.93, 0.6, 3), at(1, 0, 3)], {
317
+ const r = 0.035 * p.tail[2] * p.bone ** 0.45,
318
+ // Gentle organic arch/droop along the tail so it never reads as a straight wooden stick.
319
+ curve = u => Math.sin(Math.PI * u) * (p.tail[1] > 0.35 ? 0.06 : -0.04) * A.tailLen,
320
+ at = (u, k, bone) => [
321
+ A.tail[0] + A.tailDir[0] * A.tailLen * u + curve(u),
322
+ A.tail[1] + A.tailDir[1] * A.tailLen * u,
323
+ r * k,
324
+ r * k,
325
+ r * k,
326
+ bone,
327
+ ];
328
+ tube(b, [at(-0.04, 0, 0.5), at(0.03, 0.78, 0.7), at(0.3, 0.95, 1.4), at(0.65, 0.92, 2.5), at(0.92, 0.55, 3), at(1, 0, 3)], {
279
329
  chain: [BONE.hips, BONE.tail, BONE.tail + 1, BONE.tail + 2],
280
330
  around: RINGS.tail[detail][0],
281
331
  sub: RINGS.tail[detail][1],
@@ -284,11 +334,11 @@ function tail(b, A, p, coat, detail) {
284
334
  fur:
285
335
  detail === NEAR &&
286
336
  ((out, x, y, z) => {
287
- const len = p.fur * p.tail[2] * (0.03 + 0.025 * hair(x, y, z));
337
+ const len = Math.min(0.048, p.fur * p.tail[2] * (0.025 + 0.02 * hair(x, y, z)));
288
338
  if (len < 0.02) return false;
289
339
  out[0] = len;
290
- out[1] = 0.22;
291
- out[2] = len * 0.3;
340
+ out[1] = 0.2;
341
+ out[2] = len * 0.28;
292
342
  out[3] = 3;
293
343
  return true;
294
344
  }),
@@ -336,6 +386,7 @@ function caninePlan(L, options) {
336
386
  * head's plan, the head's matrix, and the joints at rest.
337
387
  */
338
388
  function canineRig(L, options = NO_ANIMAL_OPTIONS) {
389
+ if (L?.breed === 'cat') return catRig(L);
339
390
  const { p, A, H, HM } = caninePlan(L, options),
340
391
  headAt = (x, y, z) => new THREE.Vector3(x, y, z).applyMatrix4(HM).toArray(),
341
392
  { joints, feet } = jointsAt(A, H, headAt),
@@ -353,6 +404,7 @@ function canineRig(L, options = NO_ANIMAL_OPTIONS) {
353
404
  * @param {import('./animal-options.js').AnimalKitOptions} [options]
354
405
  */
355
406
  function canineBodies(L, near = NEAR, twoFaced = false, options = NO_ANIMAL_OPTIONS) {
407
+ if (L?.breed === 'cat') return catBodies(L, near, options);
356
408
  const { p, A, H, HM } = caninePlan(L, options),
357
409
  far = canineParts(L, p, A, H, HM, 0, twoFaced, options);
358
410
  return [far, near ? canineParts(L, p, A, H, HM, near, twoFaced, options) : far];
@@ -99,29 +99,29 @@ export const CANINE_BREEDS = {
99
99
  mottle: 0.6,
100
100
  scars: 3,
101
101
  },
102
- // a lapdog: all hair, a pushed-in nose, a ratty tail carried over the back
102
+ // a lapdog: soft shaggy coat, short muzzle, hanging ears, curved tail over the back
103
103
  lapdog: {
104
104
  leg: 0.4,
105
105
  depth: 0.9,
106
106
  girth: 1.15,
107
107
  tuck: 0.3,
108
- bone: 1.15,
108
+ bone: 1.05,
109
109
  long: 1.02,
110
- neck: [0.7, 1.2, 0.6],
111
- head: 1.55,
112
- muzzle: 0.32,
113
- stop: 2.2,
114
- skull: 1.25,
115
- jowl: 0.6,
116
- ear: ['drop', 1.3],
117
- tail: [0.75, 0.85, 0.5],
118
- fur: 3.2,
119
- ruff: 1.2,
120
- fang: 0.6,
110
+ neck: [0.7, 1.15, 0.6],
111
+ head: 1.4,
112
+ muzzle: 0.38,
113
+ stop: 1.9,
114
+ skull: 1.2,
115
+ jowl: 0.45,
116
+ ear: ['drop', 1.2],
117
+ tail: [0.75, 0.85, 0.55],
118
+ fur: 1.35,
119
+ ruff: 0.75,
120
+ fang: 0.55,
121
121
  saddle: 0.15,
122
122
  pale: 0.3,
123
- mask: 0.5,
124
- mange: 0.3,
123
+ mask: 0.45,
124
+ mange: 0.15,
125
125
  },
126
126
  // a street cur: rangy, short in the coat, a tail carried in a curve
127
127
  cur: {
@@ -181,49 +181,52 @@ export const CANINE_BREEDS = {
181
181
  pale: 0.5,
182
182
  mottle: 0.3,
183
183
  },
184
- // a rat, as large as a swarm's may be drawn: low and long, a pointed face, round ears, a bare tail
184
+ // a rat: low and pear-shaped, pointed snout, rounded cup ears, dark bead eyes, short tucked legs, long bare tapered tail
185
185
  rat: {
186
- leg: 0.34,
187
- depth: 0.9,
188
- girth: 1.2,
189
- tuck: 0.2,
190
- bone: 0.9,
191
- long: 1.15,
192
- neck: [0.6, 1.3, 0.15],
193
- head: 1.15,
194
- muzzle: 1.1,
195
- stop: 0.4,
196
- skull: 0.9,
186
+ leg: 0.28,
187
+ depth: 1.05,
188
+ girth: 1.32,
189
+ tuck: 0.1,
190
+ bone: 0.68,
191
+ long: 1.0,
192
+ neck: [0.42, 1.25, 0.14],
193
+ head: 0.98,
194
+ muzzle: 0.74,
195
+ stop: 0.28,
196
+ skull: 0.86,
197
197
  jowl: 0,
198
- ear: ['round', 1],
199
- tail: [1.9, 0.02, 0.28],
200
- fur: 0.5,
201
- ruff: 0.2,
202
- fang: 0.5,
198
+ ear: ['round', 1.25],
199
+ tail: [1.85, 0.06, 0.24],
200
+ fur: 0.25,
201
+ ruff: 0.08,
202
+ fang: 0.35,
203
+ croup: 0.08,
204
+ paw: 0.68,
205
+ darkEye: 1,
203
206
  saddle: 0.3,
204
207
  pale: 0.4,
205
208
  },
206
- // a bear, on the same bones: a great barrel on short thick legs, a humped shoulder, small round ears, hardly a tail
209
+ // a bear, on the same bones: a great barrel on sturdy limbs with broad ursine paws, humped shoulder, small round ears, stubby tail
207
210
  bear: {
208
- leg: 0.43,
211
+ leg: 0.44,
209
212
  depth: 1.12,
210
- girth: 1.55,
213
+ girth: 1.5,
211
214
  tuck: 0.2,
212
- bone: 2,
215
+ bone: 1.65,
213
216
  long: 0.96,
214
- neck: [0.62, 1.75, 0.22],
217
+ neck: [0.62, 1.65, 0.22],
215
218
  head: 1.12,
216
219
  muzzle: 0.78,
217
220
  stop: 1,
218
- skull: 1.35,
219
- jowl: 0.3,
220
- ear: ['round', 0.6],
221
+ skull: 1.32,
222
+ jowl: 0.25,
223
+ ear: ['round', 0.78],
221
224
  tail: [0.15, 0, 0.5],
222
- fur: 1.5,
223
- ruff: 1.3,
225
+ fur: 1.2,
226
+ ruff: 0.85,
224
227
  fang: 1.2,
225
228
  hock: 0.34,
226
- paw: 1.7,
229
+ paw: 1.15,
227
230
  hump: 0.07,
228
231
  saddle: 0.35,
229
232
  pale: 0.2,