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.
@@ -1,34 +1,32 @@
1
1
  import * as THREE from 'three';
2
2
  import { lerp, sstep } from '../math/scalar.js';
3
3
  import { GB } from './builder.js';
4
- import { TRS } from './primitives.js';
5
- import { SHAPES } from './animal-shapes.js';
6
4
  import { tube } from './animal-skin.js';
5
+ import { haunchStations } from './animal-haunch.js';
7
6
  import { CALLUS, HIDE_TAG, PAD, PAD_TAG, camelHead } from './animal-camel-head.js';
7
+ import { camelPack } from './animal-camel-pack.js';
8
8
  import { BONE, LEGS } from '../motion/quadruped.js';
9
9
 
10
10
  // ════════════════════════════════════════════════════════════════════════
11
- // A camel, a dromedary, built on the four-legged skeleton (motion/quadruped.js) as cattle are (animal-cattle-body.js): nose to
12
- // +z, feet at y 0, laid out in withers heights. A short deep body carried high on long thin legs, one hump of fat on the middle
13
- // of the back, the rump falling away to a thin tufted tail; a long neck that leaves the chest low, runs forward and dips, then
14
- // rises steeply to a long head carried level (animal-camel-head.js); hind legs whose thighs hang free of the body; calloused pads
15
- // where it kneels (the brisket, elbows, knees, stifles); broad soft two-toed feet. Its coat is near white, so that an instance's
16
- // colour gives it its sand, tawny or dark brown; the hair is longer on the hump, the shoulders and under the neck.
11
+ // A dromedary camel built on the four-legged skeleton (motion/quadruped.js): nose to +z, feet at y = 0, laid out in withers
12
+ // heights (1.85 m). Deep chest and tucked flank over narrow sloping hips, one fat hump over the ribcage, convex sloping croup
13
+ // with a thin tufted tail to the hock, low U-curved neck rising to a level head (animal-camel-head.js), long thighs joined high
14
+ // under a flank fold, paired stifle-hock hind legs, calloused kneeling pads (brisket, elbows, knees, stifles), and broad flat
15
+ // soft two-toed foot pads with small front nails. Near-white base coat so an instance colour tints sand, cream or brown.
17
16
  // ════════════════════════════════════════════════════════════════════════
18
- const WITHERS = 1.85, // metres at the shoulder; the hump stands about 30 cm higher
17
+ const WITHERS = 1.85, // metres at the shoulder; the hump crown stands ~33 cm higher
19
18
  COAT = [0.88, 0.84, 0.77], // near white: the herd's tint gives the colour
20
19
  zF = 0.33, // where the fore feet stand along the body,
21
20
  zH = -0.4, // and the hind ones
22
- GRAZE_BEND = [0.85, 0.75, -0.95], // the neck lowered from its base, its upper half and the head bent to the scrub (motion/animal-bearing.js)
23
- GIRTH = 1, // the body's width against the camel modelled
24
- BONE_W = 1; // and the legs'
21
+ GRAZE_BEND = [0.85, 0.75, -0.95], // neck lowered from base, upper half and head bent to scrub (motion/animal-bearing.js)
22
+ GIRTH = 1,
23
+ BONE_W = 1;
25
24
 
26
- // How a camel's legs go, and its gaits (motion/quadruped.js): it walks with the two legs of one side nearly together, and at speed paces,
27
- // each side's pair swinging as one. [speed against leg length, stance travel, duty, footfalls (fore left, fore right, hind left,
28
- // hind right), rise, lift, flex].
25
+ // How a camel's legs go, and its gaits (motion/quadruped.js): walks and paces with the two legs of one side swinging near together.
26
+ // Hind legs use paired stifle/hock linkage so the hock stays cleanly behind the stifle and never buckles or splays.
29
27
  const HABITS = {
30
- fore: { follow: 0.9, heel3: 0.08, fold3: 1.2, heel4: 0.6, fold4: 0.7, sink: 0.08, glide: 0.12 },
31
- hind: { follow: 0.65, heel3: 0.2, fold3: 0.35, heel4: 0.6, fold4: 0.55, sink: 0.08, glide: 0 },
28
+ fore: { follow: 0.9, heel3: 0.08, fold3: 1.15, heel4: 0.55, fold4: 0.65, sink: 0.06, glide: 0.12 },
29
+ hind: { follow: 0.65, heel3: 0.18, fold3: 0.25, heel4: 0.55, fold4: 0.5, sink: 0.06, glide: 0, paired: true, thigh: 0.45 },
32
30
  crouch: 0.015,
33
31
  gaits: [
34
32
  [0.1, 0.6, 0.72, [0.12, 0.62, 0, 0.5], 0.008, 0.06, 0.015],
@@ -38,33 +36,40 @@ const HABITS = {
38
36
  ],
39
37
  };
40
38
 
41
- // Where the joints are, in withers heights: [y, z] in the body's upright plane.
39
+ /** The squareness of the rump's sections: gently full so the narrow camel quarters round smoothly into the lean thighs. */
40
+ const RUMP_SQUARE = 2.6;
41
+
42
+ // Where the joints are, in withers heights: [y, z] in the body's upright plane. Real proportions of a dromedary: the hip joint
43
+ // 0.87, the stifle 0.54 (free of the body, below the flank's floor, 0.13 ahead of the hip), the hock 0.37 (0.06 behind the hip),
44
+ // the elbow 0.59 and the knee 0.35; the hind legs set close together (0.075 to each side of the midline, the fore ones 0.115).
42
45
  const A = {
43
- sx: 0.11 * GIRTH,
44
- hx: 0.1 * GIRTH,
45
- shoulder: [0.92, zF - 0.02],
46
- elbow: [0.62, zF - 0.06],
47
- knee: [0.34, zF - 0.01],
48
- fetlock: [0.085, zF],
49
- hoof: [0, zF + 0.04],
50
- hip: [0.86, zH + 0.06],
51
- stifle: [0.6, zH + 0.2],
52
- hock: [0.38, zH - 0.06],
53
- hindFetlock: [0.085, zH - 0.01],
54
- hindHoof: [0, zH + 0.03],
55
- neck: [0.84, zF + 0.12], // the neck's root, on the front of the chest
56
- bow: [0.8, zF + 0.33], // the low point of its dip
46
+ sx: 0.115 * GIRTH,
47
+ hx: 0.075 * GIRTH,
48
+ shoulder: [0.89, zF - 0.01],
49
+ elbow: [0.59, zF - 0.05],
50
+ knee: [0.35, zF - 0.005],
51
+ fetlock: [0.095, zF + 0.005],
52
+ hoof: [0, zF + 0.055],
53
+ hip: [0.87, zH + 0.02],
54
+ stifle: [0.55, zH + 0.115],
55
+ hock: [0.37, zH - 0.068],
56
+ hindFetlock: [0.095, zH - 0.015],
57
+ hindHoof: [0, zH + 0.035],
58
+ neck: [0.78, zF + 0.14], // neck root low on the chest front
59
+ bow: [0.76, zF + 0.32], // low point of the U-curve
57
60
  poll: [1.14, zF + 0.56],
58
- dock: [0.88, zH - 0.12],
61
+ dock: [0.795, zH - 0.115], // tail root set cleanly in the sloping convex croup
62
+ // the rump's section at the hips (the ring over them in trunkStations), for the thigh to hang inside (geometry/animal-haunch.js)
63
+ rump: { y: 0.775, h: 0.145, w: 0.115 * GIRTH, n: RUMP_SQUARE },
59
64
  };
60
65
 
61
66
  // The bones' joints and the feet, in metres (as cattle's, animal-cattle-body.js).
62
67
  function jointsAt(K, headAt) {
63
68
  const at = (x, q) => [x * K, q[0] * K, q[1] * K],
64
69
  joints = [];
65
- joints[BONE.root] = at(0, [0.9, -0.04]);
66
- joints[BONE.hips] = at(0, [0.92, -0.2]);
67
- joints[BONE.chest] = at(0, [0.95, 0.12]);
70
+ joints[BONE.root] = at(0, [0.88, -0.04]);
71
+ joints[BONE.hips] = at(0, [0.89, -0.2]);
72
+ joints[BONE.chest] = at(0, [0.94, 0.12]);
68
73
  joints[BONE.neck] = at(0, A.neck);
69
74
  joints[BONE.neck2] = at(0, A.bow);
70
75
  joints[BONE.head] = at(0, A.poll);
@@ -85,141 +90,153 @@ function jointsAt(K, headAt) {
85
90
  joints[h + 3] = at(s * A.hx, A.hindFetlock);
86
91
  });
87
92
  joints[BONE.tail] = at(0, A.dock);
88
- joints[BONE.tail + 1] = at(0, [A.dock[0] - 0.2, A.dock[1] - 0.02]);
89
- joints[BONE.tail + 2] = at(0, [A.dock[0] - 0.38, A.dock[1] - 0.025]);
93
+ joints[BONE.tail + 1] = at(0, [A.dock[0] - 0.18, A.dock[1] - 0.025]);
94
+ joints[BONE.tail + 2] = at(0, [A.dock[0] - 0.35, A.dock[1] - 0.03]);
90
95
  joints[BONE.crest] = at(0, [1.15, 0.02]);
91
96
  return { joints, feet: [at(-A.sx, A.hoof), at(A.sx, A.hoof), at(-A.hx, A.hindHoof), at(A.hx, A.hindHoof)] };
92
97
  }
93
98
 
94
- // The coat at a point of the body: paler under the belly and inside the legs, dusty low down, darker and rough where it kneels;
95
- // mottled with the world's value noise.
99
+ // Coat shading: paler belly and inner legs, subtle dust low down, calloused brisket and elbows, value-noise mottling.
96
100
  const hideWith = vnoise => (col, x, y, z, nx, ny) => {
97
101
  const under = 0.07 * sstep(-0.3, -0.9, ny),
98
- dust = 0.1 * sstep(0.3, 0.06, y),
99
- mottle = 0.06 * (vnoise(x * 19 + z * 7, y * 23, 391) - 0.5),
100
- // the pads it kneels on: the brisket under the chest, and where an elbow lies against it
101
- brisket = sstep(0.07, 0.02, Math.hypot(x * 0.8, y - 0.55, (z - 0.24) * 0.6)),
102
- elbow = sstep(0.04, 0.012, Math.hypot(Math.abs(x) - A.sx - 0.03, y - A.elbow[0], z - A.elbow[1] + 0.03)),
102
+ dust = 0.09 * sstep(0.28, 0.05, y),
103
+ mottle = 0.055 * (vnoise(x * 19 + z * 7, y * 23, 391) - 0.5),
104
+ brisket = sstep(0.085, 0.03, Math.hypot(x * 0.75, y - 0.505, (z - 0.21) * 0.65)),
105
+ elbow = sstep(0.042, 0.014, Math.hypot(Math.abs(x) - A.sx - 0.025, y - A.elbow[0], z - A.elbow[1] + 0.025)),
103
106
  pad = Math.max(brisket, elbow);
104
107
  for (let i = 0; i < 3; i++) col[i] = lerp(COAT[i] * (1 + under - dust + mottle), CALLUS[i], pad);
105
108
  col[3] = lerp(HIDE_TAG, PAD_TAG, pad);
106
109
  };
107
110
 
108
- // The hump: a mound of fat narrower than the back it sits on, highest a little behind the middle of the body; how far it lifts a
109
- // point of the trunk's upper half at (x, y, z), in withers heights. pad: how far out from the hide (the blanket over it).
110
- const HUMP = { rise: 0.2, z: -0.03, long: 0.19, half: 0.165 };
111
+ // The hump: a single mass of fat seated over the middle ribcage, narrower than the barrel, its crown about a fifth of the withers
112
+ // height above the back line.
113
+ const HUMP = { rise: 0.23, z: -0.04, long: 0.205, half: 0.15 };
111
114
  function humpLift(x, y, z, pad = 0) {
112
115
  const across = Math.max(0, 1 - (Math.abs(x) / (HUMP.half + pad)) ** 2),
113
116
  along = (z - HUMP.z) / HUMP.long;
114
- return HUMP.rise * Math.exp(-(along * along) * (0.6 + along * along)) * across ** 0.7 * sstep(0.78, 0.92, y);
117
+ return HUMP.rise * Math.exp(-(along * along) * (0.65 + along * along)) * across ** 0.72 * sstep(0.76, 0.92, y);
115
118
  }
116
119
 
117
- // The trunk's stations, from the buttocks over the rump, the back and the deep chest, then along the neck's dip and rise to the poll:
118
- // [y, z, half width, rise, fall, bone, squareness]. The hump is raised on the back by the warp.
120
+ // Trunk stations from a narrow rump, a short slope behind the hump, tucked flank, deep chest and low-U neck to poll. Real
121
+ // proportions, in withers heights: the back line 0.98 under the hump, falling over a short rump to the tail root at 0.80; the
122
+ // floor rising from the belly (0.50) to the flank (0.60) and the rump's floor (0.68), so the stifle (0.54) hangs free; the hips
123
+ // (0.11 to each side) the widest point of the hindquarters, the buttocks flat (fuller sections), the ribs the widest of all (0.17).
124
+ // Station 0's y (0.745) sits monotonically below station 1's center (0.748) and station 2's (0.763) so the rear spline closes
125
+ // into a smooth convex sloping croup with no pit or dimple under the tail root.
119
126
  function trunkStations() {
120
- const ring = (z, top, bottom, w, bone, sq = 2.4) => [(top + bottom) / 2, z, w * GIRTH, (top - bottom) / 2, (top - bottom) / 2, bone, sq],
121
- neck = (y, z, w, h, bone, low = h) => [y, z, w, h, low, bone, 2.1];
127
+ const ring = (z, top, bottom, w, bone, sq = 2.3) => [(top + bottom) / 2, z, w * GIRTH, (top - bottom) / 2, (top - bottom) / 2, bone, sq],
128
+ neck = (y, z, w, up, bone, low = up) => [y, z, w, up, low, bone, 2.1];
122
129
  return [
123
- [0.8, zH - 0.135, 0, 0, 0, 0],
124
- ring(zH - 0.12, 0.87, 0.68, 0.06, 0, 2.4),
125
- ring(zH - 0.08, 0.92, 0.62, 0.11, 0, 2.6),
126
- ring(zH + 0.02, 0.965, 0.6, 0.145, 0.1, 2.7),
127
- ring(zH + 0.16, 0.985, 0.585, 0.165, 0.35, 2.6),
128
- ring(-0.12, 0.995, 0.57, 0.178, 0.55, 2.5),
129
- ring(0.0, 1.0, 0.56, 0.188, 0.75, 2.4),
130
- ring(0.1, 1.0, 0.55, 0.19, 0.92, 2.4),
131
- ring(0.2, 1.0, 0.53, 0.182, 1, 2.4),
132
- ring(0.29, 0.99, 0.54, 0.165, 1, 2.4),
133
- ring(zF + 0.05, 0.96, 0.6, 0.14, 1.3, 2.3),
134
- neck(0.83, zF + 0.12, 0.1, 0.13, 2, 0.15),
135
- neck(0.81, zF + 0.21, 0.078, 0.1, 2.3),
136
- neck(0.795, zF + 0.3, 0.066, 0.08, 2.8),
137
- neck(0.82, zF + 0.39, 0.06, 0.07, 3.2),
138
- neck(0.9, zF + 0.47, 0.056, 0.064, 3.5),
139
- neck(1.01, zF + 0.525, 0.052, 0.06, 3.8),
140
- neck(1.1, zF + 0.55, 0.052, 0.06, 4),
141
- [A.poll[0] + 0.025, A.poll[1], 0.04, 0.035, 0.045, 4],
142
- [A.poll[0] + 0.05, A.poll[1] + 0.005, 0, 0, 0, 4],
130
+ [0.745, zH - 0.142, 0, 0, 0, 0],
131
+ ring(zH - 0.11, 0.805, 0.69, 0.058, 0, 2.25),
132
+ ring(zH - 0.045, 0.865, 0.66, 0.092, 0, 2.45),
133
+ [A.rump.y, zH + 0.05, A.rump.w, A.rump.h, A.rump.h, 0.12, A.rump.n], // the rump's section the thigh hangs inside
134
+ ring(zH + 0.18, 0.955, 0.6, 0.14, 0.38, 2.8),
135
+ ring(-0.08, 0.98, 0.545, 0.16, 0.6, 2.6),
136
+ ring(0.06, 0.985, 0.51, 0.17, 0.85, 2.5),
137
+ ring(0.19, 0.98, 0.5, 0.165, 1.0, 2.5),
138
+ ring(0.29, 0.96, 0.53, 0.15, 1.0, 2.3),
139
+ ring(zF + 0.06, 0.925, 0.6, 0.122, 1.35, 2.1),
140
+ neck(0.77, zF + 0.14, 0.092, 0.112, 1.9, 0.125),
141
+ neck(0.755, zF + 0.23, 0.075, 0.088, 2.35, 0.095),
142
+ neck(0.765, zF + 0.32, 0.064, 0.074, 2.8, 0.08),
143
+ neck(0.825, zF + 0.405, 0.057, 0.066, 3.2, 0.07),
144
+ neck(0.925, zF + 0.475, 0.052, 0.06, 3.55, 0.062),
145
+ neck(1.035, zF + 0.525, 0.049, 0.056, 3.85, 0.056),
146
+ neck(1.115, zF + 0.552, 0.047, 0.052, 4.0, 0.052),
147
+ [A.poll[0] + 0.02, A.poll[1] + 0.005, 0.036, 0.034, 0.04, 4],
148
+ [A.poll[0] + 0.04, A.poll[1] + 0.015, 0, 0, 0, 4],
143
149
  ];
144
150
  }
145
151
 
146
- // Under the hide: the hump, the ridge of the spine before and behind it, the shoulder blades, the hollow of the flank, the hip
147
- // bones at the corners of the rump.
152
+ // Sculpted anatomy under the hide: hump, brisket pedestal pad, shoulder blades, hip hooks, hollow flank, spine ridge.
148
153
  function bodyWarp(Q, q) {
149
154
  const x = Q[q],
150
155
  y = Q[q + 1],
151
156
  z = Q[q + 2],
152
157
  ax = Math.abs(x),
153
- blade = sstep(0.09, 0.0, Math.hypot(ax - 0.14, y - 0.88, (z - zF + 0.02) * 0.6)),
154
- hook = sstep(0.06, 0.0, Math.hypot(ax - 0.14, y - 0.93, z - zH - 0.02)),
155
- flank = sstep(0.12, 0.02, Math.hypot(y - 0.75, (z - zH - 0.22) * 0.7)) * sstep(0.1, 0.18, ax),
158
+ blade = sstep(0.09, 0.0, Math.hypot(ax - 0.13, y - 0.87, (z - zF + 0.01) * 0.6)),
159
+ hook = sstep(0.065, 0.0, Math.hypot(ax - 0.085, y - 0.88, z - zH - 0.04)),
160
+ flank = sstep(0.12, 0.02, Math.hypot(y - 0.76, (z - zH - 0.22) * 0.7)) * sstep(0.07, 0.14, ax),
161
+ brisketPad = sstep(0.09, 0.02, Math.hypot(ax * 0.9, y - 0.505, (z - 0.2) * 0.75)) * sstep(0.55, 0.505, y),
156
162
  spine =
157
163
  sstep(0.03, 0, ax) *
158
- sstep(0.95, 1.0, y) *
164
+ sstep(0.92, 0.98, y) *
159
165
  (sstep(-0.42, -0.3, z) * sstep(-0.18, -0.26, z) + sstep(0.18, 0.24, z) * sstep(0.36, 0.3, z));
160
- Q[q] += Math.sign(x) * (0.018 * blade + 0.02 * hook - 0.02 * flank);
161
- Q[q + 1] += 0.01 * blade + 0.015 * hook + 0.01 * spine + (z < 0.4 ? humpLift(x, y, z) : 0);
166
+ Q[q] += Math.sign(x) * (0.014 * blade + 0.014 * hook - 0.016 * flank);
167
+ Q[q + 1] += 0.008 * blade + 0.01 * hook + 0.008 * spine - 0.018 * brisketPad + (z < 0.4 ? humpLift(x, y, z) : 0);
162
168
  }
163
169
 
164
- // The longer hair of a dromedary's coat, as a tube's fur (animal-skin.js): on the hump's crown, over the shoulders and down the
165
- // front and underside of the neck; out: [length, lift, width, locks at the point, the tips' shade].
170
+ // Subtle woollier coat on the hump crown and upper shoulders (fine locks that blend without jagged dark triangles on the throat).
166
171
  const shagWith = vnoise => (out, x, y, z, nx, ny) => {
167
- const hump = sstep(1.05, 1.15, y) * sstep(-0.2, -0.08, z) * sstep(0.18, 0.08, z),
168
- throat = sstep(-0.3, -0.8, ny) * sstep(zF + 0.14, zF + 0.24, z) * sstep(zF + 0.45, zF + 0.36, z),
169
- shoulder = sstep(0.93, 1.0, y) * sstep(0.18, 0.28, z) * sstep(0.38, 0.32, z),
170
- grow = Math.max(hump, throat, shoulder * 0.6);
171
- if (grow < 0.2) return false;
172
- out[0] = grow * (0.025 + 0.015 * throat) * (0.8 + 0.4 * vnoise(x * 50, z * 50, 393));
173
- out[1] = 0.25 + 0.2 * hump;
174
- out[2] = 0.025;
175
- out[3] = 2;
176
- out[4] = 0.8;
172
+ const hump = sstep(1.07, 1.16, y) * sstep(-0.18, -0.07, z) * sstep(0.16, 0.07, z),
173
+ throat = sstep(-0.5, -0.9, ny) * sstep(zF + 0.2, zF + 0.28, z) * sstep(zF + 0.42, zF + 0.35, z),
174
+ grow = Math.max(hump * 0.75, throat * 0.42);
175
+ if (grow < 0.24) return false;
176
+ out[0] = grow * 0.013 * (0.85 + 0.3 * vnoise(x * 50, z * 50, 393));
177
+ out[1] = 0.1 + 0.1 * hump;
178
+ out[2] = 0.02;
179
+ out[3] = 1;
180
+ out[4] = 1.02;
177
181
  return true;
178
182
  };
179
183
 
180
- // A leg from the shoulder blade or the thigh to the fetlock, then the pastern lying low and the broad soft foot: two toes with a
181
- // nail each, on one spreading pad. Calloused at the knee (fore) and the stifle (hind), where the camel kneels.
184
+ // A hind leg's thigh as rounded slices (geometry/animal-haunch.js): height, front edge, back edge, half-width, lean, squareness,
185
+ // level. A dromedary's thigh is lean, rounded and high-set: it emerges tangentially from the narrow sloping rump, carries the
186
+ // stifle clear below the tucked flank, and tapers cleanly back along the tibia to a crisp backward-pointing hock.
187
+ const THIGH = [
188
+ [0.87, A.hip[1] + 0.05, A.hip[1] - 0.06, 0, -0.032, 2], // closed inside the upper rump
189
+ [0.79, A.hip[1] + 0.08, A.hip[1] - 0.09, 0.042, -0.022, 2], // rounded upper thigh
190
+ [0.68, A.hip[1] + 0.105, A.hip[1] - 0.095, 0.044, -0.012, 2], // lean muscular mid-thigh flush-tangent with narrow rump
191
+ [A.stifle[0], A.stifle[1] + 0.03, lerp(A.hip[1] - 0.09, A.stifle[1] - 0.08, 0.42), 0.035, -0.004, 2], // free rounded stifle
192
+ [
193
+ lerp(A.stifle[0], A.hock[0], 0.42),
194
+ lerp(A.stifle[1], A.hock[1], 0.45) + 0.026,
195
+ lerp(A.stifle[1] - 0.085, A.hock[1] - 0.042, 0.56),
196
+ 0.026,
197
+ 0,
198
+ 2,
199
+ ], // slender backward-sloping camel gaskin
200
+ [lerp(A.stifle[0], A.hock[0], 0.76), lerp(A.stifle[1], A.hock[1], 0.8) + 0.022, A.hock[1] - 0.038, 0.023, 0, 2], // Achilles
201
+ ];
202
+
203
+ // A leg from shoulder or high muscular thigh to fetlock, then sloping pastern and broad flat soft two-toed foot pad.
182
204
  function leg(b, q, s, hind, hide) {
183
205
  const t = BONE_W,
184
206
  i = (hind ? 2 : 0) + (s > 0 ? 1 : 0),
185
207
  f = LEGS[i],
186
208
  mix = (P, R, k, dz = 0) => [P[0] + (R[0] - P[0]) * k, P[1] + (R[1] - P[1]) * k + dz],
187
- at = (P, w, front, back, bone, lean = 0) => [P[0], P[1], w * t, front * t, back * t, bone, 2.2, lean],
209
+ at = (P, w, front, back, bone, lean = 0, level = 0) => [P[0], P[1], w * t, front * t, back * t, bone, 2.2, lean, level],
188
210
  pad = hind ? A.stifle : A.knee,
189
211
  coat = (col, x, y, z, nx, ny) => {
190
212
  hide(col, x, y, z, nx, ny);
191
- const callus = sstep(0.05, 0.02, Math.hypot(y - pad[0], z - pad[1] - (hind ? 0.02 : 0.03)));
213
+ const callus = sstep(0.048, 0.018, Math.hypot(y - pad[0], z - pad[1] - (hind ? 0.018 : 0.024)));
192
214
  for (let k = 0; k < 3; k++) col[k] = lerp(col[k], CALLUS[k], callus);
193
215
  col[3] = lerp(col[3], PAD_TAG, callus);
194
216
  };
195
217
  const S = hind
196
218
  ? [
197
- [0.9, A.hip[1] + 0.03, 0, 0, 0, 0],
198
- [0.86, A.hip[1] + 0.01, 0.05, 0.12, 0.14, 0.2, 2, -0.08],
199
- at(mix(A.hip, A.stifle, 0.25, -0.01), 0.07, 0.13, 0.15, 1, -0.06),
200
- at(mix(A.hip, A.stifle, 0.65, -0.01), 0.058, 0.1, 0.12, 1, -0.03),
201
- at(A.stifle, 0.046, 0.06, 0.1, 1.5),
202
- at(mix(A.stifle, A.hock, 0.4), 0.036, 0.04, 0.06, 2),
203
- at(mix(A.stifle, A.hock, 0.85), 0.024, 0.024, 0.032, 2),
204
- at(A.hock, 0.026, 0.026, 0.04, 2.5),
205
- at(mix(A.hock, A.hindFetlock, 0.3), 0.018, 0.02, 0.022, 3),
206
- at(mix(A.hock, A.hindFetlock, 0.85), 0.017, 0.019, 0.022, 3),
207
- at(A.hindFetlock, 0.023, 0.024, 0.028, 3),
208
- [A.hindFetlock[0] - 0.02, A.hindFetlock[1] + 0.012, 0, 0, 0, 3],
219
+ // the rounded lean thigh & gaskin (above), then the crisp backward camel hock and slender cannon to the fetlock
220
+ ...haunchStations(THIGH, { x: A.hx, hip: A.hip[0], stifle: A.stifle[0], hock: A.hock[0] }, A.rump, q === 0),
221
+ at(A.hock, 0.024, 0.025, 0.044, 2.5, 0, 1),
222
+ at(mix(A.hock, A.hindFetlock, 0.3), 0.018, 0.019, 0.023, 3, 0, 0.4),
223
+ at(mix(A.hock, A.hindFetlock, 0.82), 0.017, 0.018, 0.021, 3),
224
+ at(A.hindFetlock, 0.022, 0.023, 0.026, 3),
225
+ [A.hindFetlock[0] - 0.018, A.hindFetlock[1] + 0.01, 0, 0, 0, 3],
209
226
  ]
210
227
  : [
211
- [0.84, zF - 0.04, 0, 0, 0, 0],
212
- [0.8, zF - 0.03, 0.03, 0.07, 0.08, 0, 2, -0.1],
213
- at(mix(A.shoulder, A.elbow, 0.25), 0.05, 0.075, 0.09, 0.5, -0.05),
214
- at(mix(A.shoulder, A.elbow, 0.6), 0.046, 0.065, 0.08, 1, -0.02),
215
- at(A.elbow, 0.04, 0.05, 0.07, 1.5, 0.01),
216
- at(mix(A.elbow, A.knee, 0.3), 0.034, 0.042, 0.042, 2),
217
- at(mix(A.elbow, A.knee, 0.82), 0.022, 0.024, 0.024, 2),
218
- at(A.knee, 0.027, 0.032, 0.026, 2.5),
219
- at(mix(A.knee, A.fetlock, 0.3), 0.018, 0.019, 0.019, 3),
220
- at(mix(A.knee, A.fetlock, 0.85), 0.017, 0.018, 0.02, 3),
221
- at(A.fetlock, 0.023, 0.024, 0.028, 3),
222
- [A.fetlock[0] - 0.02, A.fetlock[1] + 0.012, 0, 0, 0, 3],
228
+ [0.9, zF - 0.03, 0, 0, 0, 0, 2, -0.06],
229
+ [0.855, zF - 0.025, 0.04, 0.064, 0.074, 0.2, 2.1, -0.048],
230
+ at(mix(A.shoulder, A.elbow, 0.3), 0.045, 0.064, 0.076, 0.65, -0.026),
231
+ at(mix(A.shoulder, A.elbow, 0.68), 0.041, 0.054, 0.065, 1.05, -0.01),
232
+ at(A.elbow, 0.037, 0.044, 0.054, 1.5, 0.002),
233
+ at(mix(A.elbow, A.knee, 0.3), 0.031, 0.036, 0.038, 2),
234
+ at(mix(A.elbow, A.knee, 0.82), 0.022, 0.024, 0.025, 2),
235
+ at(A.knee, 0.026, 0.032, 0.026, 2.5),
236
+ at(mix(A.knee, A.fetlock, 0.25), 0.018, 0.019, 0.022, 3),
237
+ at(mix(A.knee, A.fetlock, 0.82), 0.017, 0.018, 0.021, 3),
238
+ at(A.fetlock, 0.022, 0.023, 0.026, 3),
239
+ [A.fetlock[0] - 0.018, A.fetlock[1] + 0.01, 0, 0, 0, 3],
223
240
  ];
224
241
  const x = s * (hind ? A.hx : A.sx),
225
242
  F = hind ? A.hindFetlock : A.fetlock,
@@ -233,131 +250,101 @@ function leg(b, q, s, hind, hide) {
233
250
  coat,
234
251
  droop: 0.6,
235
252
  });
236
- // the pastern runs forward low to the foot; the foot is a flat oval pad wider than the leg, cleft in front into two toes
253
+ // Sloping pastern joining the fetlock cleanly down into the top of the foot pad.
254
+ tube(
255
+ b,
256
+ [
257
+ [F[0] + 0.012, F[1] - 0.005, 0, 0, 0, 0],
258
+ [F[0], F[1], 0.022 * t, 0.023 * t, 0.025 * t, 0.3],
259
+ [0.056, lerp(F[1], H[1], 0.45), 0.022 * t, 0.023 * t, 0.024 * t, 0.9],
260
+ [0.028, lerp(F[1], H[1], 0.82), 0.028 * t, 0.028 * t, 0.026 * t, 1],
261
+ [0.014, H[1] - 0.002, 0, 0, 0, 1],
262
+ ],
263
+ {
264
+ x,
265
+ side: s,
266
+ chain: [f + 2, f + 3],
267
+ around: [6, 8, 10][q],
268
+ sub: [1, 1, 2][q],
269
+ coat: hide,
270
+ },
271
+ );
272
+ // Broad soft two-toed camel foot pad: lofted horizontally along +z with a flat sole on y = 0, a gentle front toe cleft, and
273
+ // two small dark nails sitting on the front edge of the two toes (never an upturned hoof cup).
237
274
  const foot = (col, px, py, pz, nx, ny) => {
238
275
  hide(col, px, py, pz, nx, ny);
239
- const sole = sstep(0.03, 0.012, py),
240
- nail = sstep(H[1] + 0.035, H[1] + 0.055, pz) * sstep(0.012, 0.03, py) * sstep(0.05, 0.035, py);
241
- for (let k = 0; k < 3; k++) col[k] = lerp(lerp(col[k], PAD[k], sole), PAD[k] * 0.5, nail);
276
+ const sole = sstep(0.016, 0.005, py),
277
+ dx = Math.abs(px - x),
278
+ nail = sstep(H[1] + 0.038, H[1] + 0.056, pz) * sstep(0.005, 0.024, dx) * sstep(0.036, 0.026, dx) * sstep(0.03, 0.01, py);
279
+ for (let k = 0; k < 3; k++) col[k] = lerp(lerp(col[k], PAD[k], sole * 0.85), PAD[k] * 0.42, nail);
242
280
  col[3] = lerp(col[3], PAD_TAG, Math.max(sole, nail));
243
281
  };
244
282
  tube(
245
283
  b,
246
284
  [
247
- [F[0] + 0.015, F[1] - 0.008, 0, 0, 0, 0],
248
- [F[0], F[1], 0.024 * t, 0.025 * t, 0.028 * t, 0.4],
249
- [0.058, lerp(F[1], H[1], 0.35), 0.027 * t, 0.026 * t, 0.026 * t, 1],
250
- [0.04, lerp(F[1], H[1], 0.7), 0.042 * t, 0.034 * t, 0.04 * t, 1, 2.6],
251
- [0.022, H[1] - 0.005, 0.056 * t, 0.06 * t, 0.06 * t, 1, 3.2],
252
- [0.006, H[1] + 0.008, 0.058 * t, 0.066 * t, 0.062 * t, 1, 3.6],
253
- [0, H[1] + 0.01, 0, 0, 0, 1],
285
+ [0.018, H[1] - 0.048, 0, 0, 0, 0],
286
+ [0.018, H[1] - 0.042, 0.032 * t, 0.017 * t, 0.018 * t, 0, 2.1],
287
+ [0.018, H[1] - 0.016, 0.048 * t, 0.022 * t, 0.018 * t, 0, 2.2],
288
+ [0.018, H[1] + 0.018, 0.053 * t, 0.021 * t, 0.018 * t, 0, 2.2],
289
+ [0.015, H[1] + 0.048, 0.046 * t, 0.016 * t, 0.015 * t, 0, 2.1],
290
+ [0.012, H[1] + 0.062, 0.026 * t, 0.01 * t, 0.012 * t, 0, 2.0],
291
+ [0.012, H[1] + 0.068, 0, 0, 0, 0],
254
292
  ],
255
293
  {
256
294
  x,
257
295
  side: s,
258
- chain: [f + 2, f + 3],
296
+ chain: [f + 3],
259
297
  around: [6, 8, 12][q],
260
298
  sub: [1, 1, 2][q],
261
299
  coat: foot,
262
- // the cleft between the toes, from the front of the pad back along its middle
263
300
  warp: (Q, k) => {
264
- const cleft = sstep(0.008, 0, Math.abs(Q[k] - x)) * sstep(H[1] + 0.03, H[1] + 0.06, Q[k + 2]) * sstep(0.04, 0.015, Q[k + 1]);
265
- Q[k + 2] -= 0.012 * cleft;
301
+ const cleft = sstep(0.011, 0, Math.abs(Q[k] - x)) * sstep(H[1] + 0.022, H[1] + 0.062, Q[k + 2]);
302
+ Q[k + 2] -= 0.016 * cleft;
303
+ Q[k + 1] = Math.max(0, Q[k + 1] - 0.005 * cleft);
266
304
  },
267
305
  },
268
306
  );
269
307
  }
270
308
 
271
- // The tail: thin, hung from a dock below the top of the rump to about the hocks, ending in a tuft of dark hair.
309
+ // Thin round tail rooted cleanly into the sloping croup, hanging down to the hock and ending in a soft dark hair tuft.
272
310
  function tail(b, q, hide) {
273
311
  const D = A.dock,
274
312
  hair = (col, x, y, z, nx, ny) => {
275
313
  hide(col, x, y, z, nx, ny);
276
- const tuft = sstep(0.62, 0.55, y);
277
- for (let i = 0; i < 3; i++) col[i] = lerp(col[i], COAT[i] * 0.45, tuft);
278
- col[3] = lerp(col[3], 0.3, tuft);
314
+ const tuft = sstep(0.56, 0.47, y);
315
+ for (let i = 0; i < 3; i++) col[i] = lerp(col[i], COAT[i] * 0.42, tuft);
316
+ col[3] = lerp(HIDE_TAG, 0.3, tuft);
279
317
  };
280
318
  tube(
281
319
  b,
282
320
  [
283
- [D[0] + 0.03, D[1] + 0.03, 0, 0, 0, 0],
284
- [D[0] - 0.005, D[1] + 0.005, 0.018, 0.02, 0.02, 0.5],
285
- [D[0] - 0.08, D[1] - 0.03, 0.014, 0.014, 0.014, 1],
286
- [D[0] - 0.2, D[1] - 0.04, 0.011, 0.011, 0.011, 1.4],
287
- [D[0] - 0.32, D[1] - 0.04, 0.012, 0.016, 0.016, 2.2],
288
- [D[0] - 0.42, D[1] - 0.035, 0.016, 0.02, 0.02, 3],
289
- [D[0] - 0.47, D[1] - 0.03, 0, 0, 0, 3],
290
- ],
291
- { chain: [BONE.hips, BONE.tail, BONE.tail + 1, BONE.tail + 2], around: [4, 6, 8][q], sub: [1, 2, 2][q], coat: hair, lay: 1 },
292
- );
293
- }
294
-
295
- // A pack camel's load, set on the chest's bone: a striped blanket over the hump, a wooden pack saddle of two arches tied over it,
296
- // a pair of stuffed sacks hung on each side under a rolled rug, and the ropes that bind them. The blanket and the rugs are of
297
- // undyed wool unless a world dyes them (`camelPack` of geometry/animal-options.js).
298
- const BLANKET = [0.46, 0.4, 0.32], // undyed wool, its stripes dark and pale
299
- SACK = [0.62, 0.55, 0.44],
300
- RUGS = [
301
- [0.36, 0.3, 0.24],
302
- [0.56, 0.5, 0.41],
303
- ], // a dark fleece's and a pale one's
304
- WOOD = [0.32, 0.22, 0.13],
305
- ROPE = [0.5, 0.42, 0.3];
306
- function pack(b, q, { blanket = BLANKET, rugs = RUGS } = {}) {
307
- // the blanket follows the body's own sections a little out from the hide, over the top and down to the sacks
308
- const drape = (z, top, bottom, w) => [(top + bottom) / 2, z, w + 0.02, (top - bottom) / 2 + 0.02, (top - bottom) / 2 + 0.02, 0, 2.4];
309
- b.tv = 0.8; // cloth
310
- tube(
311
- b,
312
- [
313
- drape(-0.24, 0.99, 0.58, 0.168),
314
- drape(-0.12, 0.995, 0.57, 0.178),
315
- drape(0.0, 1.0, 0.56, 0.188),
316
- drape(0.1, 1.0, 0.55, 0.19),
317
- drape(0.2, 1.0, 0.53, 0.182),
321
+ [D[0] + 0.02, D[1] + 0.035, 0, 0, 0, 0],
322
+ [D[0] - 0.005, D[1] + 0.005, 0.018, 0.018, 0.018, 0.5],
323
+ [D[0] - 0.075, D[1] - 0.026, 0.013, 0.013, 0.013, 1],
324
+ [D[0] - 0.19, D[1] - 0.036, 0.01, 0.01, 0.01, 1.5],
325
+ [D[0] - 0.3, D[1] - 0.036, 0.012, 0.012, 0.012, 2.2],
326
+ [D[0] - 0.39, D[1] - 0.032, 0.018, 0.018, 0.018, 2.9],
327
+ [D[0] - 0.45, D[1] - 0.028, 0, 0, 0, 3],
318
328
  ],
319
329
  {
320
- chain: [BONE.chest],
321
- around: [8, 12, 16][q],
330
+ chain: [BONE.hips, BONE.tail, BONE.tail + 1, BONE.tail + 2],
331
+ around: [5, 6, 8][q],
322
332
  sub: [1, 2, 2][q],
323
- arc: [0.15, Math.PI - 0.15],
324
- warp: (Q, k) => {
325
- Q[k + 1] += humpLift(Q[k], Q[k + 1], Q[k + 2], 0.03) * 1.05;
326
- },
327
- coat: (col, x, y, z) => {
328
- const stripe = Math.sin((z + 0.22) * 70) > 0.75 ? 0.45 : 1,
329
- hem = sstep(0.97, 0.93, y);
330
- for (let i = 0; i < 3; i++) col[i] = lerp(blanket[i] * stripe, 0.7, hem * 0.5);
331
- col[3] = 0.8;
332
- },
333
+ coat: hair,
334
+ lay: 1,
335
+ fur:
336
+ q > 0 &&
337
+ ((out, x, y) => {
338
+ if (y > D[0] - 0.3) return false;
339
+ out[0] = 0.055;
340
+ out[1] = 0.08;
341
+ out[2] = 0.014;
342
+ out[3] = q > 1 ? 2 : 1;
343
+ out[4] = 0.78;
344
+ return true;
345
+ }),
333
346
  },
334
347
  );
335
- b.bone = BONE.chest;
336
- const put = (shape, col, x, y, z, sx, sy, sz, ry = 0, rx = 0, rz = 0) => b.add(shape, col, TRS(x, y, z, sx, sy, sz, ry, rx, rz));
337
- b.tv = 0.3; // wood: each arch two legs crossed over the hump, and the side bars that join the arches
338
- for (const z of [-0.22, 0.17]) for (const s of [-1, 1]) put(SHAPES.cyl6, WOOD, s * 0.15, 0.97, z, 0.025, 0.27, 0.025, 0, 0, s * 0.95);
339
- for (const s of [-1, 1]) put(SHAPES.cyl6, WOOD, s * 0.18, 0.94, -0.25, 0.022, 0.47, 0.022, 0, Math.PI / 2);
340
- b.tv = 0.75;
341
- for (const s of [-1, 1]) {
342
- // two sacks a side, stuffed full and slumped against the flank, a rolled rug on them, and the ropes down their outer faces
343
- put(SHAPES.sph, SACK, s * 0.29, 0.86, 0.0, 0.17, 0.25, 0.36, 0, 0, s * 0.1);
344
- put(
345
- SHAPES.sph,
346
- SACK.map(v => v * 0.92),
347
- s * 0.28,
348
- 0.93,
349
- 0.18,
350
- 0.15,
351
- 0.2,
352
- 0.2,
353
- 0,
354
- 0,
355
- s * 0.12,
356
- );
357
- put(SHAPES.cyl, rugs[s > 0 ? 0 : 1], s * 0.27, 1.0, -0.17, 0.11, 0.42, 0.11, 0, Math.PI / 2);
358
- for (const z of [-0.08, 0.08]) put(SHAPES.cyl6, ROPE, s * 0.37, 0.74, z, 0.012, 0.26, 0.012, 0, 0, s * 0.08);
359
- }
360
- put(SHAPES.cyl6, ROPE, 0.2, 0.545, 0.2, 0.014, 0.4, 0.014, 0, 0, Math.PI / 2); // the girth under the belly, holding it all down
361
348
  }
362
349
 
363
350
  const HEAD_DIP = 0.3; // radians the face slopes down from level
@@ -400,7 +387,7 @@ function camelMesh(q, packed, vnoise, colours) {
400
387
  leg(b, q, s, true, hide);
401
388
  }
402
389
  tail(b, q, hide);
403
- if (packed) pack(b, q, colours);
390
+ if (packed) camelPack(b, q, humpLift, colours);
404
391
  b.M = headMatrix(K);
405
392
  camelHead(b, q, hide);
406
393
  b.M = null;