roamwright 0.59.0 → 0.61.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.
@@ -2,41 +2,28 @@ import * as THREE from 'three';
2
2
  import { lerp, sstep } from '../math/scalar.js';
3
3
  import { GB } from './builder.js';
4
4
  import { tube } from './animal-skin.js';
5
+ import { haunchStations } from './animal-haunch.js';
5
6
  import { COAT, HARD, SHORT } from './animal-cattle-coat.js';
6
7
  import { cattleHead } from './animal-cattle-head.js';
7
8
  import { BONE, LEGS } from '../motion/quadruped.js';
8
9
 
9
10
  // ════════════════════════════════════════════════════════════════════════
10
- // Cattle, built on the four-legged skeleton (motion/quadruped.js): nose to +z, hooves at y 0. Laid out in withers heights and
11
- // scaled to its size: a farm's cow stands 1.32 m at the withers, an ox of the plough or a baggage train taller and heavier,
12
- // with longer horns. A level back between the shoulders and the hip bones, a deep barrel slung low, a square rump with
13
- // its pin bones and a high tailhead; a short deep neck with the dewlap hanging from it to the brisket; a broad flat brow
14
- // between the horns, ears held out sideways, a wide wet muzzle; legs short against the body, on cloven hooves. Its coat is
15
- // near white, so that an instance's colour gives the breed; the points (muzzle, hooves, horn tips) keep their own.
11
+ // Cattle and sheep built on the four-legged skeleton (motion/quadruped.js): nose to +z, hooves at y = 0. Laid out in withers
12
+ // heights: a farm cow stands 1.32 m at the withers, an ox taller and heavier with wider horns, a sheep 0.73 m under a rounded
13
+ // fleece. Level back, deep firm barrel, modest brisket dewlap, smooth thigh-to-croup transition with paired stifle-hock hind
14
+ // legs, slender tendon-backed cannons, dark downward-tucked dewclaws, and angled cloven hooves resting flush on y = 0.
16
15
  // ════════════════════════════════════════════════════════════════════════
17
16
  const WITHERS = 1.32, // a cow's withers, metres
18
17
  HOOF = [0.06, 0.05, 0.045],
19
18
  zF = 0.42, // where the fore hooves stand along the body,
20
19
  zH = -0.5, // and the hind ones
21
- GRAZE_BEND = [1.15, 0.25, -0.25], // the neck, its upper half and the head bent to the grass (motion/animal-bearing.js)
22
- WOOL_DEPTH = 0.4, // how much of the fleece's thickening a leg takes fore and aft, against across
23
- SHEEP_GRAZE = [0.94, 0.64, -0.6], // a sheep's short thick neck bends along its length, not at the withers, where the fleece would fold
24
- WOOL_ROUND = 2.15; // how square a fleeced body's sections may be: rounder than a cow's
20
+ GRAZE_BEND = [1.15, 0.25, -0.25], // neck, upper neck and head bent to graze (motion/animal-bearing.js)
21
+ WOOL_DEPTH = 0.16, // how much of the fleece's thickening a sheep's upper leg takes fore-and-aft (keeps thighs flush in the fleece)
22
+ SHEEP_GRAZE = [0.94, 0.64, -0.6], // a sheep's short thick neck bends along its length so the fleece does not fold at the withers
23
+ WOOL_ROUND = 2.15; // rounder body sections for a fleeced sheep
25
24
 
26
- // Lengths in withers heights. size: against a cow; girth, bone: the barrel's and the legs' thickness; neck: thickness; head, ear:
27
- // their size; narrow: the head's width against a cow's; horn: [length, how far it sweeps forward, how far it rises], or none;
28
- // dewlap: how deep it hangs; udder: a cow's, or none; tail: its length against a cow's; wool: a fleece down to `woolLine` (withers
29
- // heights) over a bare face and shanks of the colour `bare`; dip: how far the face slopes down from level (radians); carry: the
30
- // poll raised and drawn back from a cow's; belly: the barrel's underline lowered; hump: the withers raised in a hump of muscle;
31
- // rump: the hindquarters' width against the forequarters'; grazeBend: how the neck and head bend to graze, if not as a cow's.
32
- //
33
- // A world's own build (a wild ox of the plains, say) may also bring its own coat and long hair, as functions of the build's row p:
34
- // - coat(p, vnoise): { hide, bare }, the colour and tag of a point of the body and of the head, as animal-cattle-coat.js's hideOf
35
- // gives them (vnoise: the world's value noise);
36
- // - furs: { trunk(p), chaps(p, knee), head(p, k) }, each a tube's fur (animal-skin.js) or false: the long hair of the trunk and
37
- // neck, of the forelegs down to the knee (withers heights), and of the head (k: the head's length), grown near and between only.
38
25
  /** The cattle builds the kit knows, by name: `cow`, `ox` and `sheep`; a world passes rows of its own in `cattleBuilds`
39
- * (geometry/animal-options.js), with the numbers and hooks above. */
26
+ * (geometry/animal-options.js). */
40
27
  export const CATTLE_BUILDS = {
41
28
  cow: {
42
29
  ...{ size: 1, girth: 1, bone: 1, neck: 1, head: 1, narrow: 1, ear: 1, horn: [0.19, 0.75, 0.55], dewlap: 1, udder: 1, tail: 1 },
@@ -48,14 +35,14 @@ export const CATTLE_BUILDS = {
48
35
  },
49
36
  sheep: {
50
37
  ...{ size: 0.55, girth: 1.24, bone: 0.93, neck: 1.3, head: 1.1, narrow: 0.72, ear: 0.85, horn: null, dewlap: 0, udder: 0, tail: 0.4 },
51
- ...{ wool: 1, woolLine: 0.43, bare: [0.23, 0.18, 0.14], dip: 0.77, carry: [0.06, 0.05], belly: 0.025, grazeBend: SHEEP_GRAZE },
38
+ ...{ wool: 1, woolLine: 0.44, bare: [0.23, 0.18, 0.14], dip: 0.77, carry: [0.06, 0.05], belly: 0.02, grazeBend: SHEEP_GRAZE },
52
39
  },
53
40
  };
54
41
 
55
- // How cattle's legs go, and its gaits (motion/quadruped.js): a walk of four beats, an unwilling trot on the diagonals.
42
+ // Four-beat walk and diagonal trot. Paired hind stifle/hock linkage prevents human-knee forward buckling at the hock.
56
43
  const HABITS = {
57
44
  fore: { follow: 1, heel3: 0.1, fold3: 1.1, heel4: 0.7, fold4: 0.6, sink: 0.12, glide: 0.1 },
58
- hind: { follow: 0.6, heel3: 0.25, fold3: 0.3, heel4: 0.7, fold4: 0.5, sink: 0.12, glide: 0 },
45
+ hind: { follow: 0.6, heel3: 0.22, fold3: 0.25, heel4: 0.65, fold4: 0.45, sink: 0.12, glide: 0, paired: true, thigh: 0.45 },
59
46
  crouch: 0.02,
60
47
  gaits: [
61
48
  [0.08, 0.5, 0.7, [0.25, 0.75, 0, 0.5], 0.012, 0.05, 0.02],
@@ -65,26 +52,42 @@ const HABITS = {
65
52
  ],
66
53
  };
67
54
 
68
- // 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 (the ring over
56
+ // them in trunkStations), for the thigh to hang inside (geometry/animal-haunch.js).
69
57
  function anatomy(p) {
58
+ const top = 0.995 + humpAt(p, zH + 0.02),
59
+ bottom = 0.56 - p.belly * 0.5;
70
60
  return {
71
- sx: 0.13 * p.girth,
72
- hx: (p.wool ? 0.121 : 0.13) * p.girth,
73
- shoulder: [0.66, zF + 0.12],
74
- elbow: [0.5, zF - 0.02],
75
- knee: [0.27, zF],
76
- fetlock: [0.085, zF + 0.005],
77
- hoof: [0, zF + 0.035],
78
- hip: [0.8, zH - 0.04],
79
- stifle: p.wool ? [0.55, zH + 0.085] : [0.53, zH + 0.13],
80
- hock: p.wool ? [0.31, zH - 0.062] : [0.37, zH - 0.09],
81
- hindFetlock: [0.085, zH - (p.wool ? 0.055 : 0.02)],
82
- hindHoof: [0, zH + (p.wool ? 0.005 : 0.035)],
83
- neck: [0.7, zF + 0.1],
61
+ sx: 0.125 * p.girth,
62
+ hx: (p.wool ? 0.112 : 0.125) * p.girth,
63
+ shoulder: [0.68, zF + 0.1],
64
+ elbow: [0.51, zF - 0.02],
65
+ knee: [0.275, zF],
66
+ fetlock: [0.092, zF + 0.005],
67
+ hoof: [0, zF + 0.038],
68
+ hip: [0.83, zH - 0.02],
69
+ stifle: p.wool ? [0.56, zH + 0.09] : [0.56, zH + 0.115],
70
+ hock: p.wool ? [0.32, zH - 0.08] : [0.35, zH - 0.098],
71
+ hindFetlock: [0.092, zH - (p.wool ? 0.045 : 0.035)],
72
+ hindHoof: [0, zH + (p.wool ? 0.0 : 0.012)],
73
+ neck: [0.71, zF + 0.1],
84
74
  poll: [0.93 + p.carry[0], zF + 0.46 + p.carry[1]],
85
- dock: [0.97, zH - 0.17],
75
+ dock: [0.945, zH - 0.19],
76
+ rump: {
77
+ y: (top + bottom) / 2,
78
+ h: (top - bottom) / 2,
79
+ w: 0.19 * p.girth * narrowAt(p, zH + 0.02),
80
+ n: p.wool ? WOOL_ROUND : RUMP_SQUARE,
81
+ },
86
82
  };
87
83
  }
84
+ /** The squareness of a cow's rump (the rings from the pins to the loin): flat-sided down to the flank so the thighs merge
85
+ * cleanly without looking slab-sided. A fleece stays round. */
86
+ const RUMP_SQUARE = 3.2;
87
+ // A humped beast's shoulders: how much the back rises at z (a bison's hump, forward of the ribs).
88
+ const humpAt = (p, z) => (p.hump || 0) * Math.exp(-(((z - zF + 0.1) / 0.24) ** 2));
89
+ // How much a build's rump is narrower than its barrel (1: not), easing into the barrel behind the flank.
90
+ const narrowAt = (p, z) => lerp(p.rump || 1, 1, sstep(zH - 0.1, 0.25, z));
88
91
 
89
92
  // The bones' joints and the hooves, in metres (as a horse's, animal-horse-body.js).
90
93
  function jointsAt(A, p, K, headAt) {
@@ -114,125 +117,147 @@ function jointsAt(A, p, K, headAt) {
114
117
  joints[h + 3] = at(s * A.hx, A.hindFetlock);
115
118
  });
116
119
  joints[BONE.tail] = at(0, A.dock);
117
- joints[BONE.tail + 1] = at(0, [A.dock[0] - 0.25, A.dock[1] - 0.02]);
118
- joints[BONE.tail + 2] = at(0, [A.dock[0] - 0.5, A.dock[1] - 0.03]);
120
+ joints[BONE.tail + 1] = at(0, [A.dock[0] - 0.24, A.dock[1] - 0.025]);
121
+ joints[BONE.tail + 2] = at(0, [A.dock[0] - 0.48, A.dock[1] - 0.03]);
119
122
  joints[BONE.crest] = at(0, [1, zF]);
120
123
  return { joints, feet: [at(-A.sx, A.hoof), at(A.sx, A.hoof), at(-A.hx, A.hindHoof), at(A.hx, A.hindHoof)] };
121
124
  }
122
125
 
123
- // The trunk's stations, from the pin bones over the rump, the loin and the barrel to the withers, then along the neck to the poll.
126
+ // The trunk's stations, from the pin bones over the rump, the loin and the firm barrel to the withers, then along the neck to the poll.
124
127
  function trunkStations(A, p) {
125
128
  const g = p.girth,
126
129
  n = p.neck,
127
- lift = p.carry[0], // the neck rising to a raised poll
128
- sag = p.belly, // and the barrel hanging lower
129
- round = p.wool ? WOOL_ROUND : Infinity, // a fleece rounds the body's square sections
130
+ lift = p.carry[0],
131
+ sag = p.belly,
132
+ round = p.wool ? WOOL_ROUND : Infinity,
130
133
  wool = p.wool ? 1 : 0,
131
- neckGirth = p.wool ? 1 / Math.sqrt(g) : 1, // and a fleeced neck is not as much wider than a cow's as the barrel, or it stands out from the shoulders
132
- hump = z => (p.hump || 0) * Math.exp(-(((z - zF + 0.1) / 0.24) ** 2)), // a hump over the withers
133
- narrow = z => lerp(p.rump || 1, 1, sstep(zH - 0.1, 0.25, z)), // and narrower hindquarters
134
+ neckGirth = p.wool ? 1 / Math.sqrt(g) : 1,
135
+ narrow = z => narrowAt(p, z),
134
136
  ring = (z, top, bottom, w, bone, sq = 2.4) => {
135
- const t = top + hump(z);
137
+ const t = top + humpAt(p, z);
136
138
  return [(t + bottom) / 2, z, w * g * narrow(z), (t - bottom) / 2, (t - bottom) / 2, bone, Math.min(sq, round)];
137
139
  };
138
140
  return [
139
- [0.84, zH - 0.235, 0, 0, 0, 0],
140
- ring(zH - 0.2, 0.95, 0.74, 0.075, 0, 2.6),
141
- ring(zH - 0.13, 0.985, 0.68, 0.14, 0, 2.8),
142
- ring(zH + 0.02, 1.0, 0.6 - sag * 0.5, 0.19, 0, 3),
143
- ring(zH + 0.16, 0.995, 0.52 - sag, 0.215, 0.4, 2.8),
144
- ring(zH + 0.34, 0.985, 0.44 - sag, 0.245, 0.8, 2.5),
145
- ring(0.02, 0.985, 0.42 - sag, 0.255, 1),
146
- ring(0.2, 0.99, 0.44 - sag, 0.235, 1),
147
- ring(zF - 0.04, 1.0, 0.46 - sag, 0.2, 1),
148
- ring(zF + 0.09, 0.985 + lift * 0.2, 0.45 - sag * 0.5, 0.165, p.wool ? 1.08 : 1.3, 2.3), // a fleece's withers stay with the chest when the neck bends
149
- ring(zF + 0.2, 0.975 + 0.1 * (n - 1) + lift * (p.wool ? 0.2 : 0.5), 0.5 - 0.15 * (n - 1), 0.135 * n * neckGirth, 2, 2.2),
150
- ring(zF + 0.32 + lift * 0.4, 0.96 + 0.05 * (n - 1) + lift * 0.8, 0.62 - 0.2 * (n - 1) + lift * 0.7, 0.112 * n * neckGirth, 3, 2.1),
141
+ [0.8, zH - 0.248, 0, 0, 0, 0],
142
+ ring(zH - 0.195, 0.93, 0.68, 0.084, 0, 3.4),
143
+ ring(zH - 0.115, 0.98, p.wool ? 0.64 : 0.61, 0.148, 0, 4.0),
144
+ [A.rump.y, zH + 0.02, A.rump.w, A.rump.h, A.rump.h, 0, A.rump.n], // the rump's section the thigh hangs inside
145
+ ring(zH + 0.16, 0.99, 0.515 - sag, 0.212, 0.4, 3.0),
146
+ ring(zH + 0.34, 0.985, 0.46 - sag, 0.24, 0.8, 2.45),
147
+ ring(0.02, 0.985, 0.445 - sag, 0.248, 1),
148
+ ring(0.2, 0.99, 0.46 - sag, 0.23, 1),
149
+ ring(zF - 0.04, 1.0, 0.48 - sag, 0.196, 1),
150
+ ring(zF + 0.08, 0.982 + lift * 0.2, 0.5 - sag * 0.5, 0.16, p.wool ? 1.08 : 1.3, 2.25),
151
+ ring(zF + 0.19, 0.97 + 0.08 * (n - 1) + lift * (p.wool ? 0.22 : 0.45), 0.555 - 0.12 * (n - 1), 0.13 * n * neckGirth, 2, 2.2),
152
+ ring(zF + 0.31 + lift * 0.35, 0.955 + 0.04 * (n - 1) + lift * 0.78, 0.65 - 0.14 * (n - 1) + lift * 0.65, 0.108 * n * neckGirth, 3, 2.1),
151
153
  ring(
152
154
  A.poll[1] - 0.06,
153
- 0.95 + lift - 0.04 * wool,
154
- 0.72 - 0.1 * (n - 1) + lift + 0.06 * wool,
155
- 0.095 * n ** (p.wool ? 0.4 : 1) * neckGirth,
155
+ 0.948 + lift - 0.035 * wool,
156
+ 0.73 - 0.08 * (n - 1) + lift + 0.05 * wool,
157
+ 0.092 * n ** (p.wool ? 0.45 : 1) * neckGirth,
156
158
  3.7,
157
159
  2.1,
158
- ), // the fleece thins and narrows to the poll, into the bare face
159
- [A.poll[0] - 0.04, A.poll[1] - 0.01, 0.075, 0.06, 0.08, 4],
160
+ ),
161
+ [A.poll[0] - 0.04, A.poll[1] - 0.01, 0.072, 0.058, 0.076, 4],
160
162
  [A.poll[0] - 0.04, A.poll[1] + 0.03, 0, 0, 0, 4],
161
163
  ];
162
164
  }
163
165
 
164
- // The muscle and bone under the hide: the hip bones and pin bones standing out at the rump, the hollow of the flank before
165
- // the hip, the spine's ridge, the dewlap hanging as a fold under the neck and brisket, and a cow's udder between her thighs.
166
+ // Anatomical relief under the hide: hip hooks, pin bones, hollow flank, spine ridge, modest midline dewlap fold, and tucked udder.
166
167
  function bodyWarp(p, vnoise) {
167
168
  return (Q, q, a, v) => {
168
169
  const x = Q[q],
169
- under = sstep(-0.6, -0.95, Math.sin(a)), // the underside of the ring
170
+ under = sstep(-0.65, -0.96, Math.sin(a)),
170
171
  y = Q[q + 1],
171
172
  z = Q[q + 2],
172
173
  ax = Math.abs(x),
173
- hook = sstep(0.08, 0.0, Math.hypot(ax - 0.19 * p.girth, y - 0.95, (z - zH - 0.1) * 0.8)),
174
- pin = sstep(0.06, 0.0, Math.hypot(ax - 0.07, y - 0.9, z - zH + 0.17)),
175
- flank = sstep(0.12, 0.02, Math.hypot(y - 0.78, (z - zH - 0.32) * 0.7)) * sstep(0.1, 0.2, ax),
174
+ hook = sstep(0.08, 0.0, Math.hypot(ax - 0.185 * p.girth, y - 0.945, (z - zH - 0.1) * 0.8)),
175
+ pin = sstep(0.06, 0.0, Math.hypot(ax - 0.07, y - 0.895, z - zH + 0.165)),
176
+ flank = sstep(0.11, 0.02, Math.hypot(y - 0.78, (z - zH - 0.32) * 0.7)) * sstep(0.1, 0.19, ax),
176
177
  spine = sstep(0.04, 0, ax) * sstep(0.9, 0.97, y) * sstep(zH - 0.1, zH + 0.1, z) * sstep(zF + 0.1, zF - 0.05, z),
177
- fold = under * sstep(zF - 0.04, zF + 0.12, z) * sstep(zF + 0.5, zF + 0.36, z) * (0.6 + 0.4 * sstep(zF + 0.1, zF + 0.24, z)),
178
- udder = p.udder * under * sstep(0.13, 0.02, Math.hypot(x * 0.7, z - zH - 0.16));
179
- Q[q] += Math.sign(x) * (0.03 * hook + 0.015 * pin - 0.018 * flank) * p.girth - x * 0.6 * fold;
180
- Q[q + 1] += 0.025 * hook + 0.012 * pin + 0.008 * spine - 0.08 * p.dewlap * fold - 0.08 * udder;
178
+ // Modest vertical skin fold under the throat and brisket (never a bloated prow bulging ahead of the forelegs).
179
+ fold = under * sstep(0.11, 0.03, ax) * sstep(zF - 0.02, zF + 0.12, z) * sstep(zF + 0.46, zF + 0.34, z),
180
+ // Firm cow udder tucked cleanly between the hind thighs (never hanging loose ahead of the stifle).
181
+ udder = p.udder * under * sstep(0.1, 0.015, Math.hypot(x * 0.85, z - zH - 0.1));
182
+ Q[q] += Math.sign(x) * (0.026 * hook + 0.014 * pin - 0.016 * flank) * p.girth - x * 0.48 * fold;
183
+ Q[q + 1] += 0.022 * hook + 0.01 * pin + 0.008 * spine - 0.04 * p.dewlap * fold - 0.042 * udder;
181
184
  if (p.wool) {
182
- // the fleece in staples and lumps, standing out from the body: broad swells, and smaller clumps over them (each finer than
183
- // the rings that carry it, so that no ring shows as a band)
184
185
  const lump =
185
186
  p.wool *
186
- sstep(0.97, 0.86, v) *
187
- (0.053 * (vnoise(z * 6 + 3, x * 7 + y * 4, 371) - 0.4) + 0.034 * (vnoise(z * 17 + x * 8, y * 14, 373) - 0.5));
187
+ sstep(0.97, 0.84, v) *
188
+ (0.046 * (vnoise(z * 6 + 3, x * 7 + y * 4, 371) - 0.4) + 0.028 * (vnoise(z * 17 + x * 8, y * 14, 373) - 0.5));
188
189
  Q[q] += Math.cos(a) * lump;
189
190
  Q[q + 1] += Math.sin(a) * lump;
190
191
  }
191
192
  };
192
193
  }
193
194
 
194
- // A leg from the shoulder blade or the thigh down to the fetlock, then the pastern, the dewclaws and the cloven hoof.
195
+ // A hind leg's thigh as rounded slices (geometry/animal-haunch.js): height, front edge, back edge, half-width, lean, squareness,
196
+ // level. Real proportions of a cow, in withers heights: hip 0.83, stifle 0.56 forward at the flank fold, hock 0.35 clearly back
197
+ // behind the fetlock. The full rounded bovine thigh emerges tangentially from the rump's side (never a flat clamped plank),
198
+ // curves smoothly forward to the stifle, and sweeps back through a muscular gaskin and Achilles hollow to the point of hock.
199
+ function thighOf(A, p) {
200
+ const w = p.girth * (p.rump ?? 1),
201
+ s = A.stifle,
202
+ k = A.hock,
203
+ h = A.hip[1];
204
+ const cow = [
205
+ [0.95, h + 0.07, h - 0.12, 0, -0.062, 2], // closed inside the upper rump
206
+ [0.84, h + 0.11, h - 0.15, 0.064, -0.042, 2], // upper haunch under the pins
207
+ [0.7, h + 0.148, h - 0.155, 0.072, -0.026, 2], // rounded bovine round flush-tangent with the rump wall
208
+ [s[0], s[1] + 0.038, lerp(h - 0.142, s[1] - 0.09, 0.42), 0.058, -0.01, 2], // smooth rounded stifle at the flank fold
209
+ [lerp(s[0], k[0], 0.42), lerp(s[1], k[1], 0.44) + 0.035, lerp(s[1] - 0.11, k[1] - 0.045, 0.6), 0.042, 0, 2], // muscular gaskin
210
+ [lerp(s[0], k[0], 0.76), lerp(s[1], k[1], 0.8) + 0.028, k[1] - 0.042, 0.03, 0, 2], // Achilles hollow above the hock
211
+ ];
212
+ // a fleece wraps a thigh without showing it: a sheep's slices stay within its fleece, narrower and leaning inboard, until
213
+ // the leg emerges cleanly below the wool line
214
+ return p.wool
215
+ ? cow.map(([y, front, back, wide, lean, sq]) => [
216
+ y,
217
+ lerp(front, back, 0.1),
218
+ lerp(back, front, 0.1),
219
+ wide * w * 0.76,
220
+ (lean - 0.02) * w,
221
+ sq,
222
+ ])
223
+ : cow.map(([y, front, back, wide, lean, sq]) => [y, front, back, wide * w, lean * w, sq]);
224
+ }
225
+
226
+ // A leg from the shoulder or thigh to the fetlock, then seamless pastern, dark tucked dewclaws, and angled cloven hoof.
195
227
  function leg(b, A, p, q, s, hind) {
196
228
  const t = p.bone,
197
229
  i = (hind ? 2 : 0) + (s > 0 ? 1 : 0),
198
230
  f = LEGS[i],
199
231
  mix = (P, Q, k, dz = 0) => [P[0] + (Q[0] - P[0]) * k, P[1] + (Q[1] - P[1]) * k + dz],
200
- fleece = y => (p.wool ? 1 + 0.7 * p.wool * sstep(p.woolLine - 0.04, p.woolLine + 0.04, y) : 1),
201
- // wool rounds a leg out: it thickens the leg across fully and fore and aft by less, or the upper leg stands out of the
202
- // fleece behind the elbow and stifle as a thin deep fin
203
- at = (P, w, front, back, bone, lean = 0) => {
204
- const f = fleece(P[0]),
205
- deep = t * (1 + (f - 1) * WOOL_DEPTH);
206
- return [P[0], P[1], w * t * f, front * deep, back * deep, bone, 2.2, lean];
232
+ fleece = y => (p.wool ? 1 + 0.48 * p.wool * sstep(p.woolLine - 0.04, p.woolLine + 0.05, y) : 1),
233
+ at = (P, w, front, back, bone, lean = 0, level = 0) => {
234
+ const fl = fleece(P[0]),
235
+ deep = t * (1 + (fl - 1) * WOOL_DEPTH);
236
+ return [P[0], P[1], w * t * fl, front * deep, back * deep, bone, 2.2, lean, level];
207
237
  };
208
238
  const S = hind
209
239
  ? [
210
- [p.wool ? 0.88 : 0.95, A.hip[1] + 0.02, 0, 0, 0, 0],
211
- [p.wool ? 0.84 : 0.9, A.hip[1] + 0.01, 0.05, 0.12, 0.16, 0.2, 2, -0.08 * p.girth],
212
- at(mix(A.hip, A.stifle, 0.2, -0.01), 0.072, 0.13, 0.2, 1, -0.05),
213
- at(mix(A.hip, A.stifle, 0.6, -0.02), 0.07, 0.11, 0.18, 1, -0.03),
214
- at(A.stifle, p.wool ? 0.074 : 0.058, 0.07, 0.15, 1.5, -0.01),
215
- at(mix(A.stifle, A.hock, 0.45), 0.048, 0.055, 0.09, 2),
216
- at(mix(A.stifle, A.hock, 0.82), 0.032, 0.032, 0.04, 2),
217
- at(A.hock, 0.034, 0.036, 0.048, 2.5),
218
- at(mix(A.hock, A.hindFetlock, 0.25), 0.026, 0.028, 0.03, 3),
219
- at(mix(A.hock, A.hindFetlock, 0.8), 0.023, 0.025, 0.03, 3),
220
- at(A.hindFetlock, 0.032, 0.032, 0.04, 3),
221
- [A.hindFetlock[0] - 0.03, A.hindFetlock[1] + 0.01, 0, 0, 0, 3],
240
+ // the rounded thigh & backward-sloping gaskin (above), then the crisp backward-pointing hock and near-vertical cannon
241
+ ...haunchStations(thighOf(A, p), { x: A.hx, hip: A.hip[0], stifle: A.stifle[0], hock: A.hock[0] }, A.rump, q === 0),
242
+ at(A.hock, 0.028, 0.028, 0.048, 2.5, 0, 1),
243
+ at(mix(A.hock, A.hindFetlock, 0.3), 0.02, 0.022, 0.027, 3, 0, 0.4),
244
+ at(mix(A.hock, A.hindFetlock, 0.8), 0.019, 0.021, 0.026, 3),
245
+ at(A.hindFetlock, 0.025, 0.025, 0.03, 3),
246
+ [A.hindFetlock[0] - 0.022, A.hindFetlock[1] + 0.01, 0, 0, 0, 3],
222
247
  ]
223
248
  : [
224
- [0.95, zF - 0.04, 0, 0, 0, 0],
225
- [0.88, zF - 0.02, 0.03, 0.08, 0.08, 0, 2, -0.08 * p.girth],
226
- at(mix(A.shoulder, A.elbow, -0.1), 0.05, 0.07, 0.1, 0.5, -0.05),
227
- at(mix(A.shoulder, A.elbow, 0.55), 0.06, 0.075, 0.1, 1, -0.04),
228
- at(A.elbow, 0.055, 0.07, 0.085, 1.5, -0.015),
229
- at(mix(A.elbow, A.knee, 0.3), 0.052, 0.064, 0.06, 2),
230
- at(mix(A.elbow, A.knee, 0.8), 0.032, 0.034, 0.034, 2),
231
- at(A.knee, 0.036, 0.04, 0.036, 2.5),
232
- at(mix(A.knee, A.fetlock, 0.25), 0.026, 0.028, 0.028, 3),
233
- at(mix(A.knee, A.fetlock, 0.8), 0.024, 0.026, 0.028, 3),
234
- at(A.fetlock, 0.032, 0.032, 0.04, 3),
235
- [A.fetlock[0] - 0.03, A.fetlock[1] + 0.01, 0, 0, 0, 3],
249
+ [0.92, zF - 0.04, 0, 0, 0, 0, 2, -0.085 * p.girth],
250
+ [0.86, zF - 0.025, 0.036, 0.072, 0.076, 0.15, 2.1, -0.062 * p.girth],
251
+ at(mix(A.shoulder, A.elbow, -0.05), 0.046, 0.066, 0.082, 0.55, -0.038 * p.girth),
252
+ at(mix(A.shoulder, A.elbow, 0.55), 0.05, 0.064, 0.078, 1.0, -0.022 * p.girth),
253
+ at(A.elbow, 0.045, 0.054, 0.064, 1.5, -0.008),
254
+ at(mix(A.elbow, A.knee, 0.32), 0.04, 0.046, 0.048, 2),
255
+ at(mix(A.elbow, A.knee, 0.8), 0.026, 0.028, 0.029, 2),
256
+ at(A.knee, 0.031, 0.034, 0.031, 2.5),
257
+ at(mix(A.knee, A.fetlock, 0.26), 0.02, 0.022, 0.026, 3),
258
+ at(mix(A.knee, A.fetlock, 0.8), 0.019, 0.021, 0.025, 3),
259
+ at(A.fetlock, 0.026, 0.026, 0.032, 3),
260
+ [A.fetlock[0] - 0.022, A.fetlock[1] + 0.01, 0, 0, 0, 3],
236
261
  ];
237
262
  const x = s * (hind ? A.hx : A.sx),
238
263
  F = hind ? A.hindFetlock : A.fetlock,
@@ -247,23 +272,24 @@ function leg(b, A, p, q, s, hind) {
247
272
  fur: q > 0 && !hind && p.furs?.chaps?.(p, A.knee[0]),
248
273
  droop: 0.6,
249
274
  });
250
- // the short pastern, and the two claws of the hoof with the cleft between them; the dewclaws behind the fetlock
275
+ // Seamless sloping pastern and cloven hoof: angled dorsal wall (~52 deg), flat sole on y = 0, dark horn from the coronet down,
276
+ // and a crisp central cleft parting the two toes.
251
277
  const foot = (col, px, py, pz, nx, ny) => {
252
278
  p.hide(col, px, py, pz, nx, ny);
253
- const hard = sstep(0.052, 0.044, py);
279
+ const hard = sstep(0.058, 0.046, py);
254
280
  for (let k = 0; k < 3; k++) col[k] += (HOOF[k] - col[k]) * hard;
255
281
  col[3] = lerp(SHORT, HARD, hard);
256
282
  };
257
283
  tube(
258
284
  b,
259
285
  [
260
- [F[0] + 0.02, F[1] - 0.006, 0, 0, 0, 0],
261
- [F[0], F[1], 0.03 * t, 0.032 * t, 0.034 * t, 0.4],
262
- [0.06, lerp(F[1], H[1], 0.45), 0.027 * t, 0.028 * t, 0.028 * t, 1],
263
- [0.042, lerp(F[1], H[1], 0.8), 0.036 * t, 0.038 * t, 0.034 * t, 1, 2.4],
264
- [0.016, H[1] - 0.004, 0.042 * t, 0.05 * t, 0.034 * t, 1, 2.8],
265
- [0.002, H[1] + 0.004, 0.044 * t, 0.055 * t, 0.036 * t, 1, 2.8],
266
- [0, H[1], 0, 0, 0, 1],
286
+ [F[0] + 0.016, F[1] - 0.005, 0, 0, 0, 0],
287
+ [F[0], F[1], 0.025 * t, 0.026 * t, 0.03 * t, 0.35],
288
+ [0.064, lerp(F[1], H[1], 0.42), 0.022 * t, 0.023 * t, 0.024 * t, 0.95],
289
+ [0.048, lerp(F[1], H[1], 0.72), 0.028 * t, 0.03 * t, 0.026 * t, 1, 2.3],
290
+ [0.024, H[1] - 0.004, 0.034 * t, 0.038 * t, 0.028 * t, 1, 2.5],
291
+ [0.003, H[1] + 0.003, 0.037 * t, 0.042 * t, 0.03 * t, 1, 2.6],
292
+ [0, H[1] + 0.002, 0, 0, 0, 1],
267
293
  ],
268
294
  {
269
295
  x,
@@ -272,53 +298,61 @@ function leg(b, A, p, q, s, hind) {
272
298
  around: [6, 8, 12][q],
273
299
  sub: [1, 1, 2][q],
274
300
  coat: foot,
275
- // the cleft: the front of the hoof drawn in along its middle, from the coronet to the ground
276
301
  warp: (Q, k) => {
277
- const cleft = sstep(0.012 * t, 0, Math.abs(Q[k] - x)) * sstep(H[1] - 0.01, H[1] + 0.03, Q[k + 2]) * sstep(0.06, 0.03, Q[k + 1]);
278
- Q[k + 2] -= 0.03 * t * cleft;
302
+ const cleft = sstep(0.011 * t, 0, Math.abs(Q[k] - x)) * sstep(H[1] - 0.008, H[1] + 0.026, Q[k + 2]) * sstep(0.056, 0.026, Q[k + 1]);
303
+ Q[k + 2] -= 0.026 * t * cleft;
304
+ if (Q[k + 1] < 0) Q[k + 1] = 0;
279
305
  },
280
306
  },
281
307
  );
282
- if (q > 0)
308
+ // Small dark-horned dewclaws tucked cleanly downward behind the fetlock (never white horizontal spurs).
309
+ if (q > 0) {
310
+ const hornCoat = col => {
311
+ col[0] = HOOF[0] * 1.1;
312
+ col[1] = HOOF[1] * 1.1;
313
+ col[2] = HOOF[2] * 1.1;
314
+ col[3] = HARD;
315
+ };
283
316
  for (const side of [-1, 1])
284
317
  tube(
285
318
  b,
286
319
  [
287
- [F[0] - 0.004, F[1] - 0.022, 0, 0, 0, 0],
288
- [F[0] - 0.012, F[1] - 0.032, 0.008 * t, 0.01 * t, 0.01 * t, 0],
289
- [F[0] - 0.03, F[1] - 0.04, 0.006 * t, 0.007 * t, 0.007 * t, 0],
290
- [F[0] - 0.036, F[1] - 0.042, 0, 0, 0, 0],
320
+ [F[0] - 0.006, F[1] - 0.018, 0, 0, 0, 0],
321
+ [F[0] - 0.014, F[1] - 0.024, 0.006 * t, 0.007 * t, 0.007 * t, 0],
322
+ [F[0] - 0.027, F[1] - 0.027, 0.005 * t, 0.005 * t, 0.005 * t, 0],
323
+ [F[0] - 0.032, F[1] - 0.027, 0, 0, 0, 0],
291
324
  ],
292
- { x: x + side * 0.016 * t, side: s, chain: [f + 3], around: 5, sub: 1, coat: foot },
325
+ { x: x + side * 0.013 * t, side: s, chain: [f + 3], around: 5, sub: 1, coat: hornCoat },
293
326
  );
327
+ }
294
328
  }
295
329
 
296
- // The tail: hung from its high head over the pin bones down to the hocks, ending in a switch of long hair.
330
+ // Tail rooted smoothly into the high tailhead over the pin bones, tapering cleanly to a soft dark switch at hock level.
297
331
  function tail(b, A, p, q) {
298
332
  const D = A.dock,
299
333
  L = p.tail,
300
- switchCol = COAT.map(v => v * 0.55),
301
- w = 1 + 0.8 * (p.wool || 0), // a sheep's short tail is thick with wool
302
- t = p.wool ? w * 0.6 : 1, // and has no switch
334
+ switchCol = COAT.map(v => v * 0.48),
335
+ w = 1 + 0.65 * (p.wool || 0),
336
+ t = p.wool ? w * 0.65 : 1,
303
337
  hair = (col, x, y) => {
304
338
  p.hide(col, x, y, 0, 0, 0);
305
339
  if (p.wool) return;
306
- const tuft = sstep(0.5, 0.42, y);
340
+ const tuft = sstep(0.5, 0.4, y);
307
341
  for (let i = 0; i < 3; i++) col[i] = lerp(col[i], switchCol[i], tuft);
308
342
  col[3] = lerp(SHORT, 0.3, tuft);
309
343
  };
310
344
  tube(
311
345
  b,
312
346
  [
313
- [D[0] - 0.05, D[1] + 0.07, 0, 0, 0, 0],
314
- [D[0] - 0.015, D[1] + 0.01, 0.03, 0.03, 0.03, 0.5],
315
- [D[0] - 0.07 * L, D[1] - 0.045, 0.026 * w, 0.026 * w, 0.026 * w, 1],
316
- [D[0] - 0.16 * L, D[1] - 0.06, 0.022 * w, 0.022 * w, 0.022 * w, 1.2],
317
- [D[0] - 0.3 * L, D[1] - 0.055, 0.018 * w, 0.018 * w, 0.018 * w, 1.8],
318
- [D[0] - 0.5 * L, D[1] - 0.06, 0.014 * w, 0.014 * w, 0.014 * w, 2.5],
319
- [D[0] - 0.58 * L, D[1] - 0.06, 0.03 * t, 0.03 * t, 0.03 * t, 3],
320
- [D[0] - 0.7 * L, D[1] - 0.055, 0.016 * t, 0.016 * t, 0.016 * t, 3],
321
- [D[0] - 0.74 * L, D[1] - 0.05, 0, 0, 0, 3],
347
+ [D[0] - 0.04, D[1] + 0.06, 0, 0, 0, 0],
348
+ [D[0] - 0.01, D[1] + 0.01, 0.028, 0.028, 0.028, 0.5],
349
+ [D[0] - 0.07 * L, D[1] - 0.04, 0.022 * w, 0.022 * w, 0.022 * w, 1],
350
+ [D[0] - 0.16 * L, D[1] - 0.052, 0.017 * w, 0.017 * w, 0.017 * w, 1.3],
351
+ [D[0] - 0.3 * L, D[1] - 0.052, 0.014 * w, 0.014 * w, 0.014 * w, 1.9],
352
+ [D[0] - 0.48 * L, D[1] - 0.054, 0.012 * w, 0.012 * w, 0.012 * w, 2.5],
353
+ [D[0] - 0.57 * L, D[1] - 0.054, 0.026 * t, 0.026 * t, 0.026 * t, 3],
354
+ [D[0] - 0.68 * L, D[1] - 0.05, 0.014 * t, 0.014 * t, 0.014 * t, 3],
355
+ [D[0] - 0.72 * L, D[1] - 0.046, 0, 0, 0, 3],
322
356
  ],
323
357
  {
324
358
  chain: [BONE.hips, BONE.tail, BONE.tail + 1, BONE.tail + 2],
@@ -329,12 +363,12 @@ function tail(b, A, p, q) {
329
363
  fur:
330
364
  q > 0 &&
331
365
  ((o, x, y) => {
332
- if (p.wool || y > D[0] - 0.46) return false;
333
- o[0] = 0.09;
334
- o[1] = 0.05;
335
- o[2] = 0.02;
366
+ if (p.wool || y > D[0] - 0.45) return false;
367
+ o[0] = 0.075;
368
+ o[1] = 0.06;
369
+ o[2] = 0.018;
336
370
  o[3] = q > 1 ? 3 : 2;
337
- o[4] = 0.8;
371
+ o[4] = 0.82;
338
372
  return true;
339
373
  }),
340
374
  },
@@ -88,9 +88,12 @@ function cattleHead(b, p, q) {
88
88
  if (p.horn) horn(b, p, q, s);
89
89
  const col = [0, 0, 0, 0],
90
90
  base = [s * 0.085 * w, -0.005 * k, 0.04 * k],
91
- out = [s * 0.92, -0.25, -0.3],
92
- front = [s * 0.1, 0.35, 0.93];
91
+ out = p.wool ? [s * 0.88, -0.32, -0.22] : [s * 0.9, -0.18, -0.22],
92
+ front = [s * 0.14, 0.3, 0.94];
93
93
  p.bareHide(col, base[0], base[1], base[2], 0, 1);
94
+ const earInner = p.wool
95
+ ? [col[0] * 0.7 + 0.12, col[1] * 0.65 + 0.09, col[2] * 0.65 + 0.08]
96
+ : [lerp(col[0], EAR_IN[0], 0.55), lerp(col[1], EAR_IN[1], 0.55), lerp(col[2], EAR_IN[2], 0.55)];
94
97
  b.tv = SHORT;
95
98
  leaf(
96
99
  b,
@@ -98,12 +101,12 @@ function cattleHead(b, p, q) {
98
101
  out,
99
102
  [out[1] * front[2] - out[2] * front[1], out[2] * front[0] - out[0] * front[2], out[0] * front[1] - out[1] * front[0]],
100
103
  front,
101
- 0.17 * k * p.ear,
102
- 0.1 * k * p.ear,
103
- 0.7,
104
+ 0.155 * k * p.ear,
105
+ 0.088 * k * p.ear,
106
+ 0.75,
104
107
  1,
105
108
  col,
106
- EAR_IN,
109
+ earInner,
107
110
  s < 0 ? BONE.earL : BONE.earR,
108
111
  0,
109
112
  true, // on both faces: every herd draws it on the figure material, which shows one side of a triangle