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.
- package/geometry/animal-camel-body.js +201 -214
- package/geometry/animal-camel-pack.js +192 -0
- package/geometry/animal-canine-body.js +125 -73
- package/geometry/animal-canine-breeds.js +46 -43
- package/geometry/animal-canine-head.js +26 -25
- package/geometry/animal-cat-body.js +374 -0
- package/geometry/animal-cat-head.js +301 -0
- package/geometry/animal-cattle-body.js +185 -151
- package/geometry/animal-cattle-head.js +9 -6
- package/geometry/animal-ear.js +137 -0
- package/geometry/animal-eye.js +154 -0
- package/geometry/animal-haunch.js +87 -0
- package/geometry/animal-hen-head.js +149 -0
- package/geometry/animal-hen.js +282 -115
- package/geometry/animal-horse-body.js +60 -41
- package/geometry/animal-horse-hair.js +8 -8
- package/geometry/animal-nose.js +79 -0
- package/geometry/animal-skin.js +11 -7
- package/index.js +2 -0
- package/motion/animal-bearing.js +4 -4
- package/motion/animal-canine-bearing.js +4 -2
- package/motion/animal-cat-bearing.js +157 -0
- package/package.json +1 -1
- package/tools/ios-sim.sh +14 -4
package/geometry/animal-hen.js
CHANGED
|
@@ -1,164 +1,328 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build animated poses of a domestic farm hen (standing, walking, pecking and settled) as static triangle geometries for instanced herds.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
import * as THREE from 'three';
|
|
2
|
-
import { C, TRS
|
|
7
|
+
import { C, TRS } from './primitives.js';
|
|
3
8
|
import { GB, geometryOf } from './builder.js';
|
|
4
|
-
import {
|
|
9
|
+
import { leaf, scatter, tube } from './animal-skin.js';
|
|
10
|
+
import { henHead, shadeHen as shade } from './animal-hen-head.js';
|
|
5
11
|
|
|
6
12
|
// ════════════════════════════════════════════════════════════════════════
|
|
7
|
-
// A hen of a yard, in metres, facing +z and standing on y 0: a deep,
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
// with it), and settling down on its belly. Arithmetic only, so the pool's workers cast it.
|
|
13
|
+
// A hen of a yard, in metres, facing +z and standing on y 0: a deep, boat-shaped feathered body carried breast-high,
|
|
14
|
+
// an S-curved neck of layered hackles rising smoothly into a compact head with a two-part horn beak, a continuous red
|
|
15
|
+
// serrated comb and pendant wattles; smooth folded wings with dark primary tips, an upright fanned tail, feathered
|
|
16
|
+
// drumsticks, and slender tapered yellow shanks to four clawed toes that grip the ground. Cast in still poses for
|
|
17
|
+
// instanced crowds (motion/animal-herd-cast.js): arithmetic only, so workers can cast it.
|
|
13
18
|
// ════════════════════════════════════════════════════════════════════════
|
|
14
19
|
const COATS = {
|
|
15
|
-
// body, hackles, tail, wing tips:
|
|
16
|
-
brown: [
|
|
17
|
-
white: [
|
|
18
|
-
black: [
|
|
19
|
-
grey: [
|
|
20
|
+
// body, hackles, tail, wing tips: red-brown with golden hackles, white, black with a green sheen, grey
|
|
21
|
+
brown: [0x8e4c26, 0xbc823a, 0x3b2d22, 0x5c341c],
|
|
22
|
+
white: [0xe4dfd2, 0xede8da, 0xd8d3c6, 0xcac5b6],
|
|
23
|
+
black: [0x3d3e44, 0x454c4a, 0x343b3e, 0x36363c],
|
|
24
|
+
grey: [0x848076, 0xa29a8a, 0x45413b, 0x625e56],
|
|
20
25
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
SHIN = 0.085, // hock to foot
|
|
32
|
-
FOOT_X = 0.045, // a foot's way out to the side
|
|
26
|
+
CLAW = 0x564632, // dark horn toe tips
|
|
27
|
+
SHANK = 0xcda438, // the bare scaly legs and toes
|
|
28
|
+
BODY_Y = 0.228, // the body's middle over the ground standing, metres
|
|
29
|
+
PITCH = -0.16, // the body carried breast up, radians (about x, front down positive)
|
|
30
|
+
NECK_ROOT = [0, 0.042, 0.074], // where the neck emerges smoothly from the upper breast, in the body's frame
|
|
31
|
+
HEAD = [0.352, 0.148], // the head's height and how far forward of the feet it is carried
|
|
32
|
+
HIP = [0.042, -0.036, 0.004], // a hip in the body's frame (x to the side)
|
|
33
|
+
THIGH = 0.102, // hip to hock, metres
|
|
34
|
+
SHIN = 0.086, // hock to ankle
|
|
35
|
+
FOOT_X = 0.044, // a foot's way out to the side
|
|
33
36
|
STEP_LENGTH = 0.11, // how far a foot passes back under the body while it stands
|
|
34
37
|
DUTY = 0.62, // the share of a stride a foot is on the ground
|
|
35
38
|
LIFT = 0.035, // how high a foot is carried
|
|
36
39
|
BOB = 0.7, // the share of a step the head is held still in the air before it is thrust on
|
|
37
|
-
// pecking: the body's pitch and how far it is lowered, and the head's height, reach and bow
|
|
38
|
-
// between strikes, and at the strike, beak to the ground
|
|
40
|
+
// pecking: the body's pitch and how far it is lowered, and the head's height, reach and bow
|
|
39
41
|
STAND = { pitch: PITCH, drop: 0, head: [HEAD[0], HEAD[1], 0] },
|
|
40
|
-
WATCH = { pitch: 0.04, drop: 0.004, head: [0.
|
|
41
|
-
STRIKE = { pitch: 0.
|
|
42
|
-
PECK_STEPS = 8, // poses after standing in the peck's series
|
|
43
|
-
SETTLE = { y: 0.
|
|
42
|
+
WATCH = { pitch: 0.04, drop: 0.004, head: [0.205, 0.19, 0.6] },
|
|
43
|
+
STRIKE = { pitch: 0.36, drop: 0.012, head: [0.038, 0.215, 1.25] },
|
|
44
|
+
PECK_STEPS = 8, // poses after standing in the peck's series
|
|
45
|
+
SETTLE = { y: 0.118, head: [0.292, 0.12] }, // settled: body height and head drawn in
|
|
44
46
|
REST_STEPS = 4, // poses after standing in each rest's series
|
|
47
|
+
CHAIN = [0],
|
|
45
48
|
_a = new THREE.Vector3(),
|
|
46
49
|
_b = new THREE.Vector3(),
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
NECK_TUBE = new THREE.CylinderGeometry(0.27, 0.5, 1, 8, 2).translate(0, 0.5, 0); // a neck narrowing to the head
|
|
50
|
+
_h = new THREE.Vector3(),
|
|
51
|
+
_bodyM = new THREE.Matrix4(),
|
|
52
|
+
_m = new THREE.Matrix4();
|
|
51
53
|
|
|
52
54
|
// The body's frame for a pose: up to its height, pitched and rolled.
|
|
53
|
-
const bodyFrame = pose =>
|
|
54
|
-
const inBody = (B, x, y, z) =>
|
|
55
|
+
const bodyFrame = pose => _bodyM.copy(TRS(0, pose.y, 0, 1, 1, 1, 0, pose.pitch, pose.roll));
|
|
56
|
+
const inBody = (B, x, y, z, out) => out.set(x, y, z).applyMatrix4(B);
|
|
55
57
|
|
|
56
|
-
//
|
|
57
|
-
function body(b,
|
|
58
|
-
const [main, hackle,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
// Continuous feathered torso, close-folded wings with dark primary tips, and an upright fanned tail, all in the body's frame.
|
|
59
|
+
function body(b, cols) {
|
|
60
|
+
const [main, hackle, tailCol, tip] = cols;
|
|
61
|
+
// Boat-shaped torso from fluffy rump under the tail through the concave back saddle to the full rounded breast
|
|
62
|
+
tube(
|
|
63
|
+
b,
|
|
64
|
+
[
|
|
65
|
+
[0.008, -0.158, 0, 0, 0, 0],
|
|
66
|
+
[-0.006, -0.132, 0.062, 0.054, 0.062, 0, 2.05],
|
|
67
|
+
[-0.01, -0.072, 0.08, 0.062, 0.08, 0, 2.1],
|
|
68
|
+
[-0.004, 0.006, 0.082, 0.062, 0.084, 0, 2.1],
|
|
69
|
+
[0.004, 0.076, 0.072, 0.058, 0.072, 0, 2.05],
|
|
70
|
+
[0.008, 0.118, 0.046, 0.044, 0.044, 0, 2],
|
|
71
|
+
[0.008, 0.142, 0, 0, 0, 0],
|
|
72
|
+
],
|
|
73
|
+
{
|
|
74
|
+
chain: CHAIN,
|
|
75
|
+
sub: 2,
|
|
76
|
+
around: 14,
|
|
77
|
+
coat: (col, x, y, z, nx, ny, nz, a, v) => {
|
|
78
|
+
// Golden/lighter hackle tint spills down the upper breast and shoulders; underbelly and rump fluff sit darker
|
|
79
|
+
const cape = Math.max(0, (v - 0.56) * 2.2) * (0.45 + 0.55 * Math.max(0, ny * 0.5 + 0.5));
|
|
80
|
+
const grain = 0.94 + 0.1 * scatter(Math.floor(v * 26) * 19 + Math.floor(a * 5));
|
|
81
|
+
const bell = ny < -0.25 ? 0.84 : 1;
|
|
82
|
+
shade(col, main, hackle, cape, grain * bell, 0);
|
|
83
|
+
},
|
|
84
|
+
},
|
|
64
85
|
);
|
|
65
|
-
|
|
86
|
+
// Folded wings: almond-shaped feathered shields curving neatly along each flank, plus tucked primary tips
|
|
66
87
|
for (const s of [-1, 1]) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
88
|
+
tube(
|
|
89
|
+
b,
|
|
90
|
+
[
|
|
91
|
+
[0.006, -0.118, 0, 0, 0, 0, 2, -0.012],
|
|
92
|
+
[0.01, -0.095, 0.014, 0.028, 0.026, 0, 2.1, -0.002],
|
|
93
|
+
[0.014, -0.028, 0.024, 0.048, 0.052, 0, 2.15, 0.008],
|
|
94
|
+
[0.016, 0.042, 0.023, 0.044, 0.048, 0, 2.1, 0.004],
|
|
95
|
+
[0.018, 0.086, 0, 0, 0, 0, 2, -0.016],
|
|
96
|
+
],
|
|
97
|
+
{
|
|
98
|
+
x: s * 0.068,
|
|
99
|
+
side: s,
|
|
100
|
+
chain: CHAIN,
|
|
101
|
+
sub: 2,
|
|
102
|
+
around: 10,
|
|
103
|
+
coat: (col, x, y, z, nx, ny, nz, a, v) => {
|
|
104
|
+
const tipMix = Math.max(0, (0.34 - v) * 2.4);
|
|
105
|
+
const bar = 0.93 + 0.1 * Math.sin(v * 28 + a * 2);
|
|
106
|
+
shade(col, main, tip, tipMix, 0.92 * bar, 0);
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
);
|
|
110
|
+
// Primary flight-feather tips emerging cleanly from under the rear edge of the folded wing
|
|
111
|
+
tube(
|
|
112
|
+
b,
|
|
113
|
+
[
|
|
114
|
+
[0.008, -0.148, 0, 0, 0, 0, 2, -0.01],
|
|
115
|
+
[0.006, -0.122, 0.011, 0.02, 0.018, 0, 2.2, -0.002],
|
|
116
|
+
[0.006, -0.086, 0.014, 0.022, 0.022, 0, 2.1, 0.002],
|
|
117
|
+
[0.006, -0.068, 0, 0, 0, 0, 2, -0.008],
|
|
118
|
+
],
|
|
119
|
+
{
|
|
120
|
+
x: s * 0.062,
|
|
121
|
+
side: s,
|
|
122
|
+
chain: CHAIN,
|
|
123
|
+
sub: 1,
|
|
124
|
+
around: 8,
|
|
125
|
+
coat: col => shade(col, tip, tailCol, 0.35, 0.96, 0),
|
|
126
|
+
},
|
|
71
127
|
);
|
|
72
|
-
b.add(SHAPES.sph, tip, TRS(s * 0.06, -0.004, -0.12, 0.026, 0.05, 0.1, 0, 0.1, s * 0.1)); // the primaries, tucked under
|
|
73
128
|
}
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
129
|
+
// Upright fanned tail: seven overlapping double-sided feathers arranged in a hen's inverted-V tent (broad in profile, V-fan from behind)
|
|
130
|
+
const innerTail = tailCol.map(v => v * 0.86);
|
|
131
|
+
for (let i = -3; i <= 3; i++) {
|
|
132
|
+
const f = i / 3,
|
|
133
|
+
af = Math.abs(f),
|
|
134
|
+
len = 0.135 - af * 0.02,
|
|
135
|
+
wide = 0.042 - af * 0.004,
|
|
136
|
+
pitch = 0.96 - af * 0.24,
|
|
137
|
+
splay = f * 0.34,
|
|
138
|
+
// Feather spine rises up and back; its width runs across the side profile so the tail reads broad from the side and tapered from behind
|
|
139
|
+
up = [Math.sin(splay) * 0.36, Math.sin(pitch), -Math.cos(pitch)],
|
|
140
|
+
ul = Math.hypot(up[0], up[1], up[2]),
|
|
141
|
+
ux = up[0] / ul,
|
|
142
|
+
uy = up[1] / ul,
|
|
143
|
+
uz = up[2] / ul,
|
|
144
|
+
// Sideways normal tilts outward from the centreline in an inverted V
|
|
145
|
+
fx = f === 0 ? 0.96 : Math.sign(f) * 0.88,
|
|
146
|
+
fy = 0.28,
|
|
147
|
+
fz = 0.24 + af * 0.18,
|
|
148
|
+
across = [uy * fz - uz * fy, uz * fx - ux * fz, ux * fy - uy * fx],
|
|
149
|
+
al = Math.hypot(across[0], across[1], across[2]) || 1,
|
|
150
|
+
ax = across[0] / al,
|
|
151
|
+
ay = across[1] / al,
|
|
152
|
+
az = across[2] / al,
|
|
153
|
+
front = [ay * uz - az * uy, az * ux - ax * uz, ax * uy - ay * ux],
|
|
154
|
+
fl = Math.hypot(front[0], front[1], front[2]) || 1;
|
|
155
|
+
leaf(
|
|
156
|
+
b,
|
|
157
|
+
[i * 0.0045, 0.022 - af * 0.01, -0.126 + af * 0.01],
|
|
158
|
+
[ux, uy, uz],
|
|
159
|
+
[ax, ay, az],
|
|
160
|
+
[front[0] / fl, front[1] / fl, front[2] / fl],
|
|
161
|
+
len,
|
|
162
|
+
wide,
|
|
163
|
+
0.06,
|
|
164
|
+
0.88,
|
|
165
|
+
af > 0.7 ? tip : tailCol,
|
|
166
|
+
innerTail,
|
|
167
|
+
0,
|
|
168
|
+
0.12,
|
|
169
|
+
true,
|
|
170
|
+
);
|
|
91
171
|
}
|
|
92
|
-
b.tv = 0;
|
|
93
172
|
}
|
|
94
173
|
|
|
95
|
-
//
|
|
96
|
-
function neck(b,
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
174
|
+
// Smooth S-curved neck of layered hackles bridging the upper breast seamlessly to the back of the head.
|
|
175
|
+
function neck(b, cols, from, to) {
|
|
176
|
+
const [main, hackle] = cols,
|
|
177
|
+
dy = to.y - from.y,
|
|
178
|
+
dz = to.z - from.z,
|
|
179
|
+
// Stand upright -> graceful S-curve (belly of neck bows slightly back then forward to skull); pecking -> extends cleanly
|
|
180
|
+
sCurve = Math.max(0, Math.min(1, dy / 0.14)),
|
|
181
|
+
p0y = from.y - 0.024,
|
|
182
|
+
p0z = from.z - 0.018,
|
|
183
|
+
p4y = to.y - 0.006,
|
|
184
|
+
p4z = to.z - 0.014,
|
|
185
|
+
p1y = p0y + dy * 0.26,
|
|
186
|
+
p1z = p0z + dz * 0.24 - 0.004 * sCurve,
|
|
187
|
+
p2y = p0y + dy * 0.6,
|
|
188
|
+
p2z = p0z + dz * 0.54 - 0.014 * sCurve,
|
|
189
|
+
p3y = p0y + dy * 0.86,
|
|
190
|
+
p3z = p0z + dz * 0.82 - 0.006 * sCurve;
|
|
191
|
+
tube(
|
|
192
|
+
b,
|
|
193
|
+
[
|
|
194
|
+
[p0y - 0.018, p0z - 0.012, 0, 0, 0, 0],
|
|
195
|
+
[p0y, p0z, 0.056, 0.056, 0.058, 0, 2.05], // broad hackle cape merging seamlessly into shoulders and breast
|
|
196
|
+
[p1y, p1z, 0.044, 0.044, 0.046, 0, 2.05],
|
|
197
|
+
[p2y, p2z, 0.03, 0.031, 0.031, 0, 2],
|
|
198
|
+
[p3y, p3z, 0.022, 0.023, 0.022, 0, 2],
|
|
199
|
+
[p4y, p4z, 0.018, 0.019, 0.018, 0, 2],
|
|
200
|
+
],
|
|
201
|
+
{
|
|
202
|
+
chain: CHAIN,
|
|
203
|
+
sub: 2,
|
|
204
|
+
around: 10,
|
|
205
|
+
coat: (col, x, y, z, nx, ny, nz, a, v) => {
|
|
206
|
+
// Blend smoothly from torso main plumage at the root into golden hackles up the neck
|
|
207
|
+
const hackleMix = Math.min(1, 0.3 + v * 0.9);
|
|
208
|
+
const grain = 0.94 + 0.1 * scatter(Math.floor(v * 20) * 13 + Math.floor(a * 4));
|
|
209
|
+
shade(col, main, hackle, hackleMix, grain, 0);
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
);
|
|
101
213
|
}
|
|
102
214
|
|
|
103
|
-
// A leg from its hip (in
|
|
104
|
-
//
|
|
105
|
-
function leg(b,
|
|
106
|
-
const
|
|
215
|
+
// A leg from its hip (in world space) to its foot at (x, lift, z): a smooth feathered drumstick blending from the belly
|
|
216
|
+
// down to the backward-bent hock, a slender tapered yellow shank, and four clawed toes gripping y = 0.
|
|
217
|
+
function leg(b, cols, hip, x, lift, z) {
|
|
218
|
+
const s = x < 0 ? -1 : 1,
|
|
219
|
+
foot = _b.set(x, lift + 0.01, z),
|
|
107
220
|
dy = foot.y - hip.y,
|
|
108
221
|
dz = foot.z - hip.z,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
222
|
+
dist = Math.hypot(dy, dz) || 1e-4,
|
|
223
|
+
d = Math.min(THIGH + SHIN - 0.002, Math.max(Math.abs(THIGH - SHIN) + 0.01, dist)),
|
|
224
|
+
uy = dy / dist,
|
|
225
|
+
uz = dz / dist,
|
|
112
226
|
along = (THIGH * THIGH - SHIN * SHIN + d * d) / (2 * d),
|
|
113
227
|
out = Math.sqrt(Math.max(0, THIGH * THIGH - along * along)),
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
228
|
+
hockY = hip.y + uy * along - uz * out,
|
|
229
|
+
hockZ = hip.z + uz * along + uy * out, // bent back: a bird's hock is its ankle
|
|
230
|
+
ankleY = hip.y + uy * d,
|
|
231
|
+
ankleZ = hip.z + uz * d,
|
|
232
|
+
curl = lift > 0.004 ? 0.65 : 0.08,
|
|
233
|
+
main = cols[0],
|
|
234
|
+
tip = cols[3],
|
|
235
|
+
yellow = C(SHANK),
|
|
236
|
+
yellowDark = yellow.map(v => v * 0.84),
|
|
237
|
+
clawCol = C(CLAW);
|
|
238
|
+
// Feathered drumstick tapering cleanly from deep inside the lower flank down to the hock joint
|
|
239
|
+
const topY = hip.y + 0.036,
|
|
240
|
+
topZ = hip.z + 0.004,
|
|
241
|
+
leanIn = (hip.x - x) * s;
|
|
242
|
+
tube(
|
|
119
243
|
b,
|
|
120
|
-
[
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
244
|
+
[
|
|
245
|
+
[topY + 0.01, topZ, 0.022, 0.024, 0.024, 0, 2, leanIn - 0.006],
|
|
246
|
+
[topY - 0.006, topZ, 0.036, 0.038, 0.04, 0, 2.05, leanIn],
|
|
247
|
+
[(topY + hockY) * 0.5, (topZ + hockZ) * 0.5 + 0.004, 0.028, 0.03, 0.032, 0, 2, leanIn * 0.5],
|
|
248
|
+
[hockY + 0.018, hockZ + 0.004, 0.016, 0.017, 0.017, 0, 2, 0],
|
|
249
|
+
[hockY - 0.004, hockZ, 0.009, 0.009, 0.009, 0, 2, 0],
|
|
250
|
+
],
|
|
251
|
+
{
|
|
252
|
+
x,
|
|
253
|
+
side: s,
|
|
254
|
+
chain: CHAIN,
|
|
255
|
+
sub: 1,
|
|
256
|
+
around: 10,
|
|
257
|
+
coat: (col, px, py, pz, nx, ny, nz, a, v) => shade(col, main, tip, v * 0.4, 0.9, 0),
|
|
258
|
+
},
|
|
125
259
|
);
|
|
126
|
-
|
|
127
|
-
|
|
260
|
+
// Bare scaly yellow shank from hock down to ankle
|
|
261
|
+
tube(
|
|
262
|
+
b,
|
|
263
|
+
[
|
|
264
|
+
[hockY + 0.004, hockZ, 0.0082, 0.0085, 0.0085, 0, 2],
|
|
265
|
+
[(hockY + ankleY) * 0.5, (hockZ + ankleZ) * 0.5, 0.0058, 0.0062, 0.0062, 0, 2],
|
|
266
|
+
[ankleY + 0.008, ankleZ, 0.0065, 0.0068, 0.0068, 0, 2],
|
|
267
|
+
[ankleY - 0.004, ankleZ, 0.008, 0.008, 0.008, 0, 2],
|
|
268
|
+
],
|
|
269
|
+
{
|
|
270
|
+
x,
|
|
271
|
+
side: s,
|
|
272
|
+
chain: CHAIN,
|
|
273
|
+
sub: 1,
|
|
274
|
+
around: 8,
|
|
275
|
+
coat: (col, px, py, pz, nx, ny, nz, a, v) => shade(col, yellowDark, yellow, 0.5 + 0.5 * v, 1, 1),
|
|
276
|
+
},
|
|
277
|
+
);
|
|
278
|
+
// Four tapered toes with dark horn claws: three splayed ahead and one hallux behind
|
|
128
279
|
for (const [turn, len] of [
|
|
129
|
-
[-0.
|
|
130
|
-
[0, 0.
|
|
131
|
-
[0.
|
|
132
|
-
[Math.PI, 0.
|
|
133
|
-
])
|
|
134
|
-
|
|
280
|
+
[-0.44, 0.048],
|
|
281
|
+
[0, 0.056],
|
|
282
|
+
[0.44, 0.048],
|
|
283
|
+
[Math.PI, 0.026],
|
|
284
|
+
]) {
|
|
285
|
+
const drop = Math.min(ankleY - 0.0025, len * Math.sin(curl)),
|
|
286
|
+
reach = len * Math.cos(curl);
|
|
287
|
+
b.M = _m.copy(TRS(x, ankleY, ankleZ, 1, 1, 1, turn));
|
|
288
|
+
tube(
|
|
135
289
|
b,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
290
|
+
[
|
|
291
|
+
[0, 0, 0.0048, 0.0048, 0.0046, 0, 2],
|
|
292
|
+
[-drop * 0.65, reach * 0.55, 0.0036, 0.0036, 0.0034, 0, 2],
|
|
293
|
+
[-drop, reach * 0.88, 0.0024, 0.0024, 0.0022, 0, 2],
|
|
294
|
+
[-drop - 0.001, reach + 0.004, 0, 0, 0, 0],
|
|
295
|
+
],
|
|
296
|
+
{
|
|
297
|
+
chain: CHAIN,
|
|
298
|
+
sub: 1,
|
|
299
|
+
around: 6,
|
|
300
|
+
coat: (col, px, py, pz, nx, ny, nz, a, v) => shade(col, yellow, clawCol, v > 0.78 ? (v - 0.78) * 4.5 : 0, 1, 1),
|
|
301
|
+
},
|
|
140
302
|
);
|
|
141
|
-
|
|
303
|
+
}
|
|
304
|
+
b.M = null;
|
|
142
305
|
}
|
|
143
306
|
|
|
144
|
-
// A hen of coat c in pose p
|
|
307
|
+
// A hen of coat c in pose p as a plain geometry: its position, normal, colour and tag arrays.
|
|
145
308
|
function henGeometry(c, p) {
|
|
146
309
|
const b = new GB(),
|
|
147
|
-
B = bodyFrame(p)
|
|
310
|
+
B = bodyFrame(p),
|
|
311
|
+
cols = c.map(h => C(h));
|
|
148
312
|
b.tg = [];
|
|
149
313
|
b.tv = 0;
|
|
150
314
|
b.M = B;
|
|
151
|
-
body(b,
|
|
315
|
+
body(b, cols);
|
|
152
316
|
b.M = null;
|
|
153
|
-
const from = inBody(B,
|
|
317
|
+
const from = inBody(B, NECK_ROOT[0], NECK_ROOT[1], NECK_ROOT[2], _h),
|
|
154
318
|
to = _a.set(0, p.head[0], p.head[1]);
|
|
155
|
-
neck(b,
|
|
319
|
+
neck(b, cols, from, to);
|
|
156
320
|
b.M = _m.copy(TRS(0, p.head[0], p.head[1], 1, 1, 1, 0, p.head[2]));
|
|
157
|
-
|
|
321
|
+
henHead(b, cols);
|
|
158
322
|
b.M = null;
|
|
159
323
|
for (let k = 0; k < 2; k++) {
|
|
160
324
|
const s = k ? 1 : -1;
|
|
161
|
-
leg(b,
|
|
325
|
+
leg(b, cols, inBody(B, s * HIP[0], HIP[1], HIP[2], _h), s * FOOT_X, p.feet[k][1], p.feet[k][0]);
|
|
162
326
|
}
|
|
163
327
|
const geo = geometryOf(b.parts(true));
|
|
164
328
|
b.release();
|
|
@@ -198,8 +362,7 @@ function walking(phase) {
|
|
|
198
362
|
return p;
|
|
199
363
|
}
|
|
200
364
|
|
|
201
|
-
// A rest at f (0 standing, 1 its full): pecking at the ground, or settled on its belly.
|
|
202
|
-
// way from standing to watching to the strike, so that its timing (a crowd's peck) alone gives it its ease.
|
|
365
|
+
// A rest at f (0 standing, 1 its full): pecking at the ground, or settled on its belly.
|
|
203
366
|
function resting(rest, f) {
|
|
204
367
|
const p = standing(),
|
|
205
368
|
e = f * f * (3 - 2 * f);
|
|
@@ -220,7 +383,11 @@ function resting(rest, f) {
|
|
|
220
383
|
return p;
|
|
221
384
|
}
|
|
222
385
|
|
|
223
|
-
|
|
386
|
+
/**
|
|
387
|
+
* Create a hen pose caster for an instanced herd (`motion/animal-herd-cast.js`).
|
|
388
|
+
* @param {{ coat?: 'brown' | 'white' | 'black' | 'grey', moments: number, rests: string[] }} options
|
|
389
|
+
* @returns {{ skins: THREE.BufferGeometry[], skin: () => THREE.BufferGeometry, frames: (cast: () => unknown) => { rests: unknown[][], walk: { frames: unknown[], stride: number } } }}
|
|
390
|
+
*/
|
|
224
391
|
function henHerd({ coat, moments, rests }) {
|
|
225
392
|
const c = COATS[coat] ?? COATS.brown;
|
|
226
393
|
let pose = standing();
|
|
@@ -5,6 +5,7 @@ import { GB, geometryOf } from './builder.js';
|
|
|
5
5
|
import { indexParts } from './index-parts.js';
|
|
6
6
|
import { NO_ANIMAL_OPTIONS, animalNoise, presetOf } from './animal-options.js';
|
|
7
7
|
import { tube } from './animal-skin.js';
|
|
8
|
+
import { haunchStations } from './animal-haunch.js';
|
|
8
9
|
import { ear, eyeWithLids } from './animal-horse-face.js';
|
|
9
10
|
import { MEALY, SLEEK, coatOf, codedCoat, skinOf } from './animal-horse-coat.js';
|
|
10
11
|
import { forelock, hair } from './animal-horse-hair.js';
|
|
@@ -66,7 +67,8 @@ const HABITS = {
|
|
|
66
67
|
],
|
|
67
68
|
};
|
|
68
69
|
|
|
69
|
-
// Where the joints are, in withers heights: [y, z] in the body's upright plane
|
|
70
|
+
// Where the joints are, in withers heights: [y, z] in the body's upright plane; how much narrower than the barrel the breast is;
|
|
71
|
+
// and the rump's section at the hips (the ring over them in trunkStations), for the thigh to hang inside (geometry/animal-haunch.js).
|
|
70
72
|
function anatomy(p) {
|
|
71
73
|
const carriage = lerp(0.35, 1.05, p.neck[2]),
|
|
72
74
|
reach = 0.5 * p.neck[0],
|
|
@@ -82,16 +84,21 @@ function anatomy(p) {
|
|
|
82
84
|
// the stifle high against the flank, a little ahead of the hoof; the gaskin sloping back from it to a hock under the
|
|
83
85
|
// buttock at about the front knee's height; the cannon near upright and the pastern sloping forward to the hoof
|
|
84
86
|
hip: [0.8, zH + 0.02],
|
|
85
|
-
stifle: [0.
|
|
86
|
-
hock: [0.37, zH - 0.
|
|
87
|
+
stifle: [0.62, zH + 0.14],
|
|
88
|
+
hock: [0.37, zH - 0.115],
|
|
87
89
|
hindFetlock: [0.105, zH - 0.065],
|
|
88
90
|
hindHoof: [0, zH - 0.02],
|
|
89
91
|
neck,
|
|
90
92
|
poll: [neck[0] + reach * Math.sin(carriage), neck[1] + reach * Math.cos(carriage)],
|
|
91
93
|
dock: [0.95, zH - 0.19],
|
|
92
94
|
hands: [1.09, zF - 0.05], // where a rider's hands hold the reins, over the withers
|
|
95
|
+
breast: z => lerp(1, p.chest ?? 1, sstep(zF - 0.3, zF, z)), // a mule narrow at the breast
|
|
96
|
+
rump: { y: 0.785, h: 0.207, w: 0.172 * p.girth, n: RUMP_SQUARE }, // the mule's narrow breast is forward of the hips
|
|
93
97
|
};
|
|
94
98
|
}
|
|
99
|
+
/** The squareness of the rump's sections (the rings from the croup to the loin): gently fuller than the barrel's so the rump's
|
|
100
|
+
* side flows smoothly into the thigh without flattening the rounded equine croup. */
|
|
101
|
+
const RUMP_SQUARE = 2.65;
|
|
95
102
|
|
|
96
103
|
// The bones' joints and the hooves, in metres.
|
|
97
104
|
function jointsAt(A, p, K, headAt) {
|
|
@@ -131,7 +138,7 @@ function jointsAt(A, p, K, headAt) {
|
|
|
131
138
|
function trunkStations(A, p) {
|
|
132
139
|
const g = p.girth,
|
|
133
140
|
nt = p.neck[1],
|
|
134
|
-
breast =
|
|
141
|
+
breast = A.breast, // a mule narrow at the breast
|
|
135
142
|
ring = (z, top, bottom, w, bone, sq = 2.25) => [
|
|
136
143
|
(top + bottom) / 2,
|
|
137
144
|
z,
|
|
@@ -143,11 +150,12 @@ function trunkStations(A, p) {
|
|
|
143
150
|
],
|
|
144
151
|
mid = [(A.neck[0] + A.poll[0]) / 2 + 0.01, (A.neck[1] + A.poll[1]) / 2 - 0.01];
|
|
145
152
|
return [
|
|
146
|
-
[0.
|
|
147
|
-
|
|
148
|
-
ring(zH - 0.
|
|
149
|
-
ring(zH
|
|
150
|
-
|
|
153
|
+
[0.828, zH - 0.228, 0, 0, 0, 0],
|
|
154
|
+
// the rump's sections stay smoothly rounded while carrying enough depth at the flank for the thigh to emerge cleanly
|
|
155
|
+
ring(zH - 0.185, 0.955, 0.7, 0.092, 0, 2.4),
|
|
156
|
+
ring(zH - 0.08, 0.988, 0.615, 0.158, 0, 2.6),
|
|
157
|
+
[A.rump.y, zH + 0.06, A.rump.w, A.rump.h, A.rump.h, 0, A.rump.n], // the rump's section the thigh hangs inside
|
|
158
|
+
ring(zH + 0.22, 0.958, 0.582, 0.164, 0.5, 2.5),
|
|
151
159
|
ring(zH + 0.4, 0.938, 0.548, 0.174, 0.9),
|
|
152
160
|
ring(zF - 0.2, 0.945, 0.54, 0.17, 1),
|
|
153
161
|
ring(zF - 0.09, 0.985, 0.548, 0.158, 1),
|
|
@@ -161,6 +169,23 @@ function trunkStations(A, p) {
|
|
|
161
169
|
];
|
|
162
170
|
}
|
|
163
171
|
|
|
172
|
+
// A hind leg's thigh, from the croup down to just above the hock, as level slices (geometry/animal-haunch.js): height, front edge,
|
|
173
|
+
// back edge, half-width, lean. Real proportions, in withers heights: the hip joint 0.80, the stifle 0.63 (at the flank fold,
|
|
174
|
+
// 0.11 ahead of the hip), the hock 0.37 (a third of the leg, 0.12 behind the hip); the buttock 0.19 behind the hip; the gaskin
|
|
175
|
+
// sweeps cleanly back along the tibia from the stifle to the point of the hock so the thigh never overhangs below the belly.
|
|
176
|
+
function thighOf(p) {
|
|
177
|
+
const g = p.girth ** 0.75,
|
|
178
|
+
t = p.bone ** 0.6;
|
|
179
|
+
return [
|
|
180
|
+
[0.94, zH + 0.06, zH - 0.13, 0, -0.06 * g, 2], // closed inside the upper croup
|
|
181
|
+
[0.85, zH + 0.1, zH - 0.17, 0.062 * g, -0.04 * g, 2], // upper quarter tucked smoothly inside croup
|
|
182
|
+
[0.74, zH + 0.142, zH - 0.185, 0.074 * g, -0.016 * g, 2], // rounded equine quarter flush-tangent with croup
|
|
183
|
+
[0.62, zH + 0.172, zH - 0.12, 0.063 * g, -0.006 * g, 2], // rounded stifle forward at the flank fold
|
|
184
|
+
[0.52, zH + 0.085, zH - 0.12, 0.044 * g, 0, 2], // muscular upper gaskin sloping back along the tibia
|
|
185
|
+
[0.44, zH - 0.025, zH - 0.14, 0.033 * t, 0, 2], // tapered lower gaskin / Achilles tendon above the hock
|
|
186
|
+
];
|
|
187
|
+
}
|
|
188
|
+
|
|
164
189
|
// A leg from the shoulder blade or the quarter down to the fetlock, then the pastern and the hoof.
|
|
165
190
|
function leg(b, A, p, coat, q, s, hind) {
|
|
166
191
|
const t = p.bone,
|
|
@@ -168,36 +193,30 @@ function leg(b, A, p, coat, q, s, hind) {
|
|
|
168
193
|
f = LEGS[i],
|
|
169
194
|
skin = skinOf(coat, i),
|
|
170
195
|
mix = (P, Q, k, dz = 0) => [P[0] + (Q[0] - P[0]) * k, P[1] + (Q[1] - P[1]) * k + dz],
|
|
171
|
-
at = (P, w, front, back, bone, lean = 0) => [P[0], P[1], w * t, front * t, back * t, bone, 2.2, lean];
|
|
196
|
+
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];
|
|
172
197
|
const S = hind
|
|
173
198
|
? [
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
at(mix(A.
|
|
178
|
-
at(mix(A.
|
|
179
|
-
at(A.
|
|
180
|
-
|
|
181
|
-
at(mix(A.stifle, A.hock, 0.8), 0.03, 0.032, 0.05, 2),
|
|
182
|
-
at(A.hock, 0.03, 0.036, 0.05, 2.5),
|
|
183
|
-
at(mix(A.hock, A.hindFetlock, 0.25), 0.023, 0.025, 0.03, 3),
|
|
184
|
-
at(mix(A.hock, A.hindFetlock, 0.8), 0.02, 0.022, 0.029, 3),
|
|
185
|
-
at(A.hindFetlock, 0.027, 0.03, 0.036, 3),
|
|
186
|
-
[A.hindFetlock[0] - 0.03, A.hindFetlock[1] + 0.01, 0, 0, 0, 3],
|
|
199
|
+
// the rounded quarter & gaskin (above), then the crisp backward-pointing hock and near-vertical cannon to the fetlock
|
|
200
|
+
...haunchStations(thighOf(p), { x: A.hx, hip: A.hip[0], stifle: A.stifle[0], hock: A.hock[0] }, A.rump, q === 0),
|
|
201
|
+
at(A.hock, 0.03, 0.034, 0.052, 2.5, 0, 1),
|
|
202
|
+
at(mix(A.hock, A.hindFetlock, 0.3), 0.022, 0.024, 0.029, 3, 0, 0.4),
|
|
203
|
+
at(mix(A.hock, A.hindFetlock, 0.8), 0.019, 0.021, 0.028, 3),
|
|
204
|
+
at(A.hindFetlock, 0.026, 0.028, 0.034, 3),
|
|
205
|
+
[A.hindFetlock[0] + 0.01, A.hindFetlock[1] - 0.025, 0, 0, 0, 3],
|
|
187
206
|
]
|
|
188
207
|
: [
|
|
189
|
-
[0.
|
|
190
|
-
[0.
|
|
191
|
-
at(
|
|
192
|
-
at(
|
|
193
|
-
at(A.elbow, 0.
|
|
194
|
-
at(mix(A.elbow, A.knee, 0.28), 0.
|
|
195
|
-
at(mix(A.elbow, A.knee, 0.78), 0.
|
|
196
|
-
at(A.knee, 0.
|
|
197
|
-
at(mix(A.knee, A.fetlock, 0.25), 0.
|
|
198
|
-
at(mix(A.knee, A.fetlock, 0.8), 0.
|
|
199
|
-
at(A.fetlock, 0.
|
|
200
|
-
[A.fetlock[0] - 0.
|
|
208
|
+
[0.95, zF - 0.02, 0, 0, 0, 0, 2, -0.074 * p.girth],
|
|
209
|
+
[0.85, zF + 0.02, 0.046, 0.076, 0.084, 0.15, 2.05, -0.048 * p.girth],
|
|
210
|
+
at([0.72, zF + 0.052], 0.054, 0.06, 0.088, 0.55, -0.024 * p.girth),
|
|
211
|
+
at([0.625, zF + 0.024], 0.052, 0.056, 0.082, 1, -0.012 * p.girth),
|
|
212
|
+
at(A.elbow, 0.044, 0.052, 0.068, 1.5, -0.004),
|
|
213
|
+
at(mix(A.elbow, A.knee, 0.28), 0.04, 0.05, 0.052, 2),
|
|
214
|
+
at(mix(A.elbow, A.knee, 0.78), 0.027, 0.029, 0.031, 2),
|
|
215
|
+
at(A.knee, 0.031, 0.035, 0.033, 2.5),
|
|
216
|
+
at(mix(A.knee, A.fetlock, 0.25), 0.021, 0.023, 0.027, 3),
|
|
217
|
+
at(mix(A.knee, A.fetlock, 0.8), 0.019, 0.021, 0.027, 3),
|
|
218
|
+
at(A.fetlock, 0.026, 0.028, 0.034, 3),
|
|
219
|
+
[A.fetlock[0] - 0.025, A.fetlock[1] + 0.01, 0, 0, 0, 3],
|
|
201
220
|
];
|
|
202
221
|
const x = s * (hind ? A.hx : A.sx),
|
|
203
222
|
F = hind ? A.hindFetlock : A.fetlock,
|
|
@@ -223,12 +242,12 @@ function leg(b, A, p, coat, q, s, hind) {
|
|
|
223
242
|
tube(
|
|
224
243
|
b,
|
|
225
244
|
[
|
|
226
|
-
[F[0] + 0.
|
|
227
|
-
[F[0], F[1], 0.025 * t, 0.
|
|
228
|
-
[0.
|
|
229
|
-
[0.054, lerp(F[1], H[1], 0.
|
|
230
|
-
[0.028, H[1] - 0.004, 0.
|
|
231
|
-
[0.003, H[1], 0.
|
|
245
|
+
[F[0] + 0.018, F[1] - 0.005, 0, 0, 0, 0],
|
|
246
|
+
[F[0], F[1], 0.025 * t, 0.027 * t, 0.031 * t, 0.35],
|
|
247
|
+
[0.076, lerp(F[1], H[1], 0.44), 0.023 * t, 0.024 * t, 0.025 * t, 0.95],
|
|
248
|
+
[0.054, lerp(F[1], H[1], 0.78), 0.031 * t, 0.033 * t, 0.03 * t, 1, 2.25],
|
|
249
|
+
[0.028, H[1] - 0.004, 0.037 * t, 0.044 * t, 0.035 * t, 1, 2.45],
|
|
250
|
+
[0.003, H[1] + 0.002, 0.042 * t, 0.05 * t, 0.039 * t, 1, 2.5],
|
|
232
251
|
[0, H[1], 0, 0, 0, 1],
|
|
233
252
|
],
|
|
234
253
|
{
|