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
|
@@ -24,12 +24,12 @@ function hair(b, A, p, coat, q) {
|
|
|
24
24
|
tube(
|
|
25
25
|
b,
|
|
26
26
|
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
29
|
-
[A.neck[0] + 0.135 * nt + 0.
|
|
30
|
-
[mid[0] + 0.1 * nt, mid[1] - 0.088 * nt, 0.
|
|
31
|
-
[A.poll[0] + 0.
|
|
32
|
-
[A.poll[0] + 0.
|
|
27
|
+
[0.94, zF + 0.02, 0, 0, 0, 0],
|
|
28
|
+
[0.96, zF + 0.055, 0.009, 0.012, 0.014, 0],
|
|
29
|
+
[A.neck[0] + 0.135 * nt + 0.008, Math.max(zF + 0.095, A.neck[1] - 0.055 * nt), 0.014, 0.018, 0.026, 1],
|
|
30
|
+
[mid[0] + 0.1 * nt, mid[1] - 0.088 * nt, 0.015, 0.02, 0.028, 2],
|
|
31
|
+
[A.poll[0] + 0.042, A.poll[1] - 0.055, 0.013, 0.016, 0.026, 2.8],
|
|
32
|
+
[A.poll[0] + 0.042, A.poll[1] - 0.01, 0, 0, 0, 3],
|
|
33
33
|
],
|
|
34
34
|
{
|
|
35
35
|
chain: [BONE.chest, BONE.neck, BONE.neck2, BONE.head],
|
|
@@ -113,8 +113,8 @@ function mane(b, A, p, lock, side, q) {
|
|
|
113
113
|
mid = [(A.neck[0] + A.poll[0]) / 2, (A.neck[1] + A.poll[1]) / 2],
|
|
114
114
|
// the crest: [y, z, bone along the chest, neck, neck2, head], with the neck's half-width and its half-depth below the crest there
|
|
115
115
|
crest = [
|
|
116
|
-
[
|
|
117
|
-
[A.neck[0] + 0.135 * nt + 0.012, A.neck[1] - 0.
|
|
116
|
+
[0.985, zF + 0.045, 0, 0.105 * p.girth, 0.19],
|
|
117
|
+
[A.neck[0] + 0.135 * nt + 0.012, Math.max(zF + 0.095, A.neck[1] - 0.055 * nt), 1, 0.1 * nt, 0.17 * nt],
|
|
118
118
|
[mid[0] + 0.1 * nt, mid[1] - 0.088 * nt, 2, 0.074 * nt, 0.13 * nt],
|
|
119
119
|
[A.poll[0] + 0.045, A.poll[1] - 0.055, 2.8, 0.052 * nt, 0.09 * nt],
|
|
120
120
|
],
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
2
|
+
// A nose leather: the bare, wet pad at the tip of a short-muzzled beast's nose (a cat's, a fox's, a bear's), a rounded
|
|
3
|
+
// triangle broadest at its top and pointed down, swelling out of the muzzle it sits on. Laid over the muzzle's surface from
|
|
4
|
+
// vertex colours and one tag, so it needs no socket, and a worker can build it.
|
|
5
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Lays a nose leather on a muzzle.
|
|
9
|
+
* @param {import('./builder.js').GB} gb The builder, which keeps tags.
|
|
10
|
+
* @param {object} o In the lengths of the head it is laid on.
|
|
11
|
+
* @param {number[]} o.at The middle of its foot, on the muzzle's surface.
|
|
12
|
+
* @param {number[]} o.face The unit direction the muzzle's front faces.
|
|
13
|
+
* @param {number[]} o.up A unit direction across it: the head's own up.
|
|
14
|
+
* @param {number} o.wide Its half-width at the top.
|
|
15
|
+
* @param {number} o.high Its half-height (to its point below the middle).
|
|
16
|
+
* @param {number} o.depth How far it swells out of the muzzle.
|
|
17
|
+
* @param {number[]} o.colour Linear [r, g, b].
|
|
18
|
+
* @param {number} o.tag The tag of bare, wet skin.
|
|
19
|
+
* @param {number} o.bone The bone every point follows.
|
|
20
|
+
* @param {number} o.segments The points of its rim.
|
|
21
|
+
*/
|
|
22
|
+
function noseLeather(gb, { at, face, up, wide, high, depth, colour, tag, bone, segments: n }) {
|
|
23
|
+
const rx = up[1] * face[2] - up[2] * face[1],
|
|
24
|
+
ry = up[2] * face[0] - up[0] * face[2],
|
|
25
|
+
rz = up[0] * face[1] - up[1] * face[0],
|
|
26
|
+
rl = Math.hypot(rx, ry, rz) || 1,
|
|
27
|
+
ux = rx / rl,
|
|
28
|
+
uy = ry / rl,
|
|
29
|
+
uz = rz / rl,
|
|
30
|
+
REACH = 1.22; // the outline's furthest points, as a share of a circle's: the three corners of the triangle
|
|
31
|
+
// the outline at the angle phi: a circle swelled towards three corners, one below and two above, so the leather is a rounded
|
|
32
|
+
// triangle pointed down
|
|
33
|
+
const outline = phi => 1 + 0.22 * Math.cos(3 * (phi + Math.PI / 2)),
|
|
34
|
+
point = (phi, f, lift, out) => {
|
|
35
|
+
const r = outline(phi) * f,
|
|
36
|
+
u = wide * r * Math.cos(phi),
|
|
37
|
+
v = high * r * Math.sin(phi),
|
|
38
|
+
d = depth * (1 - (r / REACH) ** 2) + lift;
|
|
39
|
+
out[0] = at[0] + ux * u + up[0] * v + face[0] * d;
|
|
40
|
+
out[1] = at[1] + uy * u + up[1] * v + face[1] * d;
|
|
41
|
+
out[2] = at[2] + uz * u + up[2] * v + face[2] * d;
|
|
42
|
+
const nx = face[0] / depth + (ux * u) / (wide * wide),
|
|
43
|
+
ny = face[1] / depth + (uy * u) / (wide * wide) + (up[1] * v) / (high * high),
|
|
44
|
+
nz = face[2] / depth + (uz * u) / (wide * wide) + (up[2] * v) / (high * high),
|
|
45
|
+
l = Math.hypot(nx, ny, nz) || 1;
|
|
46
|
+
out[3] = nx / l;
|
|
47
|
+
out[4] = ny / l;
|
|
48
|
+
out[5] = nz / l;
|
|
49
|
+
return out;
|
|
50
|
+
},
|
|
51
|
+
P = [0, 0, 0, 0, 0, 0],
|
|
52
|
+
Q = [0, 0, 0, 0, 0, 0],
|
|
53
|
+
R = [0, 0, 0, 0, 0, 0],
|
|
54
|
+
S = [0, 0, 0, 0, 0, 0],
|
|
55
|
+
put = p => gb.raw(p[0], p[1], p[2], p[3], p[4], p[5], colour[0], colour[1], colour[2], bone, bone, 1),
|
|
56
|
+
// the eye's way round (right, up) has its outward normal along `face`, so a ring wound counter-clockwise faces out
|
|
57
|
+
tri = (a, b, c) => {
|
|
58
|
+
put(a);
|
|
59
|
+
put(b);
|
|
60
|
+
put(c);
|
|
61
|
+
};
|
|
62
|
+
gb.tv = tag;
|
|
63
|
+
for (let j = 0; j < n; j++) {
|
|
64
|
+
const a = (j / n) * Math.PI * 2,
|
|
65
|
+
b = ((j + 1) / n) * Math.PI * 2;
|
|
66
|
+
// the rim's strip, from the ring sunk into the muzzle to the outline...
|
|
67
|
+
point(a, 1.1, -depth * 0.25, P);
|
|
68
|
+
point(b, 1.1, -depth * 0.25, Q);
|
|
69
|
+
point(a, 1, 0, R);
|
|
70
|
+
point(b, 1, 0, S);
|
|
71
|
+
tri(P, R, S);
|
|
72
|
+
tri(P, S, Q);
|
|
73
|
+
// ...and the dome, a fan from its centre
|
|
74
|
+
point(0, 0, 0, P);
|
|
75
|
+
tri(P, R, S);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { noseLeather };
|
package/geometry/animal-skin.js
CHANGED
|
@@ -50,11 +50,13 @@ function lock(gb, p, d, n, len, wide, root, end, b1, b2, w, tip = -1) {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
// A skin lofted through stations along a path. A station is [y, z, half-width, rise, fall, bone, squareness, lean]: the
|
|
54
|
-
// stands across the path, `rise` on the side that is up when the path runs forward (the front, when it runs down a leg) and
|
|
53
|
+
// A skin lofted through stations along a path. A station is [y, z, half-width, rise, fall, bone, squareness, lean, level]: the
|
|
54
|
+
// section stands across the path, `rise` on the side that is up when the path runs forward (the front, when it runs down a leg) and
|
|
55
55
|
// `fall` on the other; `bone` is a place along o.chain (1.5: halfway between its second and third bones); squareness 2 is an
|
|
56
|
-
// ellipse, more is boxier; lean moves the station outwards (inwards when negative) from the path's own side.
|
|
57
|
-
//
|
|
56
|
+
// ellipse, more is boxier; lean moves the station outwards (inwards when negative) from the path's own side. A thigh is better
|
|
57
|
+
// described by its edges at each height than by sections across its bone, so a station may lie `level` (0 to 1): level, the
|
|
58
|
+
// section lies across the body's upright plane at the station's height, `rise` towards the nose and `fall` towards the tail
|
|
59
|
+
// (geometry/animal-haunch.js). The stations are joined by a spline, o.sub rings to a span, o.around points to a ring.
|
|
58
60
|
// o.x, o.side the path's place to the side, and -1 to mirror the section for a left limb
|
|
59
61
|
// o.coat(col, x, y, z, nx, ny, nz, a, v) fills col with the colour and the tag (how smooth) at a point
|
|
60
62
|
// o.warp(p, q, a, v) moves the point p[q..q+2] before the normals are found (a socket, a muscle, a toe)
|
|
@@ -78,7 +80,8 @@ function tube(gb, S, o) {
|
|
|
78
80
|
N = _n,
|
|
79
81
|
R = _c,
|
|
80
82
|
X = _x;
|
|
81
|
-
const at = (k, i, t) =>
|
|
83
|
+
const at = (k, i, t) =>
|
|
84
|
+
spline(S[Math.max(0, i - 1)][k] ?? 0, S[i][k] ?? 0, S[Math.min(n - 1, i + 1)][k] ?? 0, S[Math.min(n - 1, i + 2)][k] ?? 0, t);
|
|
82
85
|
for (let r = 0; r < rings; r++) {
|
|
83
86
|
const i = Math.min(n - 2, (r / sub) | 0),
|
|
84
87
|
t = r / sub - i,
|
|
@@ -87,6 +90,7 @@ function tube(gb, S, o) {
|
|
|
87
90
|
w = Math.max(0, at(2, i, t)),
|
|
88
91
|
u = Math.max(0, at(3, i, t)),
|
|
89
92
|
d = Math.max(0, at(4, i, t)),
|
|
93
|
+
level = Math.min(1, Math.max(0, at(8, i, t))), // how far this ring lies level instead of across the path
|
|
90
94
|
e = 2 / ((S[i][6] ?? 2) + ((S[i + 1][6] ?? 2) - (S[i][6] ?? 2)) * t),
|
|
91
95
|
xc = x0 + side * ((S[i][7] ?? 0) + ((S[i + 1][7] ?? 0) - (S[i][7] ?? 0)) * t);
|
|
92
96
|
let ty = at(0, i, t + 0.02) - at(0, i, t - 0.02),
|
|
@@ -108,8 +112,8 @@ function tube(gb, S, o) {
|
|
|
108
112
|
sy = Math.sign(s) * Math.abs(s) ** e * (s > 0 ? u : d),
|
|
109
113
|
q = (r * seg + j) * 3;
|
|
110
114
|
P[q] = xc + side * cx * w;
|
|
111
|
-
P[q + 1] = y + tz * sy;
|
|
112
|
-
P[q + 2] = z - ty *
|
|
115
|
+
P[q + 1] = y + tz * sy * (1 - level);
|
|
116
|
+
P[q + 2] = z + sy * (level - ty * (1 - level));
|
|
113
117
|
if (o.warp) o.warp(P, q, a, r / (rings - 1));
|
|
114
118
|
}
|
|
115
119
|
}
|
package/index.js
CHANGED
|
@@ -140,8 +140,10 @@ export { rigHorse } from './rendering/animal-horse-figure.js';
|
|
|
140
140
|
export { buildCattle } from './rendering/animal-cattle-figure.js';
|
|
141
141
|
export { buildCamel } from './rendering/animal-camel-figure.js';
|
|
142
142
|
export { buildCanine } from './rendering/animal-canine-figure.js';
|
|
143
|
+
export { catBodies, catRig } from './geometry/animal-cat-body.js';
|
|
143
144
|
export { horsePose } from './motion/animal-bearing.js';
|
|
144
145
|
export { caninePose } from './motion/animal-canine-bearing.js';
|
|
146
|
+
export { catPose } from './motion/animal-cat-bearing.js';
|
|
145
147
|
export { herdArrays } from './motion/animal-herd-cast.js';
|
|
146
148
|
export { createFlierShapes, createSwarm, FLY_WINGS } from './rendering/flier-swarm.js';
|
|
147
149
|
export { FLY_LOOK, flyShape } from './geometry/flier-shapes.js';
|
package/motion/animal-bearing.js
CHANGED
|
@@ -94,10 +94,10 @@ function horsePose(H, dt, t, speed, a = null, ground = null) {
|
|
|
94
94
|
leg.w = 0;
|
|
95
95
|
if (k === lazy && S[REST] > 0.01) {
|
|
96
96
|
leg.w = S[REST];
|
|
97
|
-
leg.y = 0.
|
|
98
|
-
leg.z = L.fz + 0.
|
|
99
|
-
leg.a3 = 0.
|
|
100
|
-
leg.a4 = 0.
|
|
97
|
+
leg.y = 0.008 * Q.leg;
|
|
98
|
+
leg.z = L.fz + 0.015 * Q.leg;
|
|
99
|
+
leg.a3 = 0.06;
|
|
100
|
+
leg.a4 = 0.45;
|
|
101
101
|
}
|
|
102
102
|
if (S[DOWN] > 0.01) {
|
|
103
103
|
leg.w = S[DOWN];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { clamp, sstep, TAU } from '../math/scalar.js';
|
|
2
|
+
import { catPose } from './animal-cat-bearing.js';
|
|
2
3
|
import { BONE, LEGS, stepRig } from './quadruped.js';
|
|
3
4
|
|
|
4
5
|
// ════════════════════════════════════════════════════════════════════════
|
|
@@ -59,6 +60,7 @@ function gazeYaw(a, F) {
|
|
|
59
60
|
* @returns {number} How far its group should rise: nothing, since the body rises on its own legs.
|
|
60
61
|
*/
|
|
61
62
|
function caninePose(a, dt, t, blow, ground = null, watch = a.lookAt) {
|
|
63
|
+
if (a.rig?.isCat) return catPose(a, dt, t, blow, ground, watch);
|
|
62
64
|
const Q = a.rig,
|
|
63
65
|
B = Q.bones,
|
|
64
66
|
joints = Q.joints,
|
|
@@ -121,8 +123,8 @@ function caninePose(a, dt, t, blow, ground = null, watch = a.lookAt) {
|
|
|
121
123
|
len = L.len[0] + L.len[1] + L.len[2],
|
|
122
124
|
odd = k % 2 ? 1 : -1;
|
|
123
125
|
leg.w = 0;
|
|
124
|
-
// sitting
|
|
125
|
-
if (hind) hold(leg, Math.max(sit, lie), 0, pz + 0.3 * h + odd * 0.02 * h, -1.
|
|
126
|
+
// sitting, the hocks rest on the ground just behind the hips with the paws tucked ahead of them; lying, paws stretch further forward
|
|
127
|
+
if (hind) hold(leg, Math.max(sit, lie), 0, pz + (0.3 - 0.18 * sit) * h + odd * 0.02 * h, -1.2, 0);
|
|
126
128
|
else hold(leg, lie, 0, pz + 0.52 * h + odd * 0.03 * h, -1.3, 0);
|
|
127
129
|
// a spring: the forelegs thrown forward, the hind legs trailing
|
|
128
130
|
if (hind) hold(leg, reach, py - 0.5 * len, pz - 0.82 * len, 0.5, 0.9);
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { clamp, sstep, TAU } from '../math/scalar.js';
|
|
2
|
+
import { BONE, LEGS, stepRig } from './quadruped.js';
|
|
3
|
+
|
|
4
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
5
|
+
// A house cat's bearing on top of its light feline gait (motion/quadruped.js): a head carried level and turned to what it
|
|
6
|
+
// watches, independent flicking ears, a sleek prowl crouch, a neat sit with the tail round the feet and a curled rest, and a
|
|
7
|
+
// tail as long as the body that is raised with a gentle hook when the cat stands, low in a curve when it walks and twitching
|
|
8
|
+
// at its tip on the prowl. Zero per-frame allocations.
|
|
9
|
+
// ════════════════════════════════════════════════════════════════════════
|
|
10
|
+
const CROUCH = 0,
|
|
11
|
+
SIT = 1,
|
|
12
|
+
LIE = 2,
|
|
13
|
+
LIMP = 3,
|
|
14
|
+
NECK_X = 4,
|
|
15
|
+
NECK_Y = 5,
|
|
16
|
+
EARS = 6,
|
|
17
|
+
CHANNELS = 7,
|
|
18
|
+
SIT_BACK = 0.68,
|
|
19
|
+
_want = new Float32Array(CHANNELS),
|
|
20
|
+
_manner = { dy: 0, dz: 0, pitch: 0, hips: 0, chest: 0, legs: [0, 1, 2, 3].map(() => ({ y: 0, z: 0, a3: 0, a4: 0, w: 0 })) },
|
|
21
|
+
_frame = { x: 0, y: 0, z: 0, yaw: 0, s: 1, ground: null };
|
|
22
|
+
|
|
23
|
+
function hold(leg, w, y, z, a3, a4) {
|
|
24
|
+
if (w <= 0) return;
|
|
25
|
+
const k = w / (leg.w + w);
|
|
26
|
+
leg.y += (y - leg.y) * k;
|
|
27
|
+
leg.z += (z - leg.z) * k;
|
|
28
|
+
leg.a3 += (a3 - leg.a3) * k;
|
|
29
|
+
leg.a4 += (a4 - leg.a4) * k;
|
|
30
|
+
leg.w = Math.min(1, leg.w + w);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function gazeYaw(a, F) {
|
|
34
|
+
if (!F) return null;
|
|
35
|
+
const dx = F.x - a.x,
|
|
36
|
+
dz = F.z - a.z;
|
|
37
|
+
if (dx * dx + dz * dz < 1.5) return null;
|
|
38
|
+
let dy = Math.atan2(dx, dz) - a.yaw;
|
|
39
|
+
dy -= Math.round(dy / TAU) * TAU;
|
|
40
|
+
return Math.abs(dy) < 1.9 ? clamp(dy, -1, 1) : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Poses a house cat for this frame on top of its light feline gait: upright swaying tail, alert head, crouched prowl, neat sit
|
|
45
|
+
* and curled rest.
|
|
46
|
+
* @param {object} a The cat actor (`rig` from `catRig`, `group`, `x`, `y`, `z`, `yaw`, `seed`, `pose`, `fixY`, `lookAt`).
|
|
47
|
+
* @param {number} dt Seconds since the last frame.
|
|
48
|
+
* @param {number} t Seconds of the clock.
|
|
49
|
+
* @param {{ w: number, cr: number } | null} [blow=null] Optional crouch/spring cue.
|
|
50
|
+
* @param {((x: number, z: number) => number) | null} [ground=null] Ground height sampler, or null for flat floor.
|
|
51
|
+
* @param {{ x: number, z: number } | null} [watch=a.lookAt] Optional target the cat watches.
|
|
52
|
+
* @returns {number} Always 0 (the cat rises on its own legs).
|
|
53
|
+
*/
|
|
54
|
+
function catPose(a, dt, t, blow = null, ground = null, watch = a.lookAt) {
|
|
55
|
+
const Q = a.rig,
|
|
56
|
+
B = Q.bones,
|
|
57
|
+
joints = Q.joints,
|
|
58
|
+
h = Q.leg,
|
|
59
|
+
S = a.hs && a.hs.length >= CHANNELS ? a.hs : (a.hs = new Float32Array(CHANNELS)),
|
|
60
|
+
W = _want,
|
|
61
|
+
M = _manner,
|
|
62
|
+
pose = a.pose,
|
|
63
|
+
dead = pose === 'dead',
|
|
64
|
+
prowl = pose === 'prowl' || pose === 'guard' || pose === 'strike',
|
|
65
|
+
fx = blow ? blow.w : 0,
|
|
66
|
+
run = sstep(0.95, 1.8, Q.u || 0),
|
|
67
|
+
brisk = sstep(0.05, 0.55, Q.u || 0);
|
|
68
|
+
W[CROUCH] = Math.max(prowl ? 0.42 : pose === 'cower' ? 0.55 : 0, blow ? (blow.cr || 0) * fx : 0);
|
|
69
|
+
W[SIT] = pose === 'sit' ? 1 : 0;
|
|
70
|
+
W[LIE] = pose === 'kneel' ? 1 : 0;
|
|
71
|
+
W[LIMP] = dead ? 1 : 0;
|
|
72
|
+
const look = dead || brisk > 0.5 ? null : gazeYaw(a, watch),
|
|
73
|
+
idle = Math.sin(t * 0.31 + a.seed * 27) * 0.28 * (1 - brisk);
|
|
74
|
+
W[NECK_Y] = look === null ? idle : idle * 0.25 + look * 0.75;
|
|
75
|
+
W[NECK_X] = dead ? 0.45 : 0.16 * run + 0.3 * W[CROUCH] + (pose === 'cower' ? 0.25 : 0);
|
|
76
|
+
W[EARS] = dead ? 0.35 : pose === 'cower' ? 0.85 : prowl ? 0.35 : 0;
|
|
77
|
+
const quick = Math.min(1, dt * (blow ? 16 : 5));
|
|
78
|
+
for (let i = 0; i < CHANNELS; i++) S[i] += (W[i] - S[i]) * quick;
|
|
79
|
+
|
|
80
|
+
const sit = S[SIT],
|
|
81
|
+
lie = S[LIE],
|
|
82
|
+
limp = S[LIMP],
|
|
83
|
+
tip = -SIT_BACK * sit,
|
|
84
|
+
sy = joints[LEGS[0]][1] - joints[0][1],
|
|
85
|
+
sz = joints[LEGS[0]][2] - joints[0][2],
|
|
86
|
+
floor = joints[LEGS[0] + 1][1] - 0.08 * h;
|
|
87
|
+
M.pitch = tip + 0.08 * S[CROUCH] * (1 - limp);
|
|
88
|
+
M.dy = -0.24 * h * S[CROUCH] - floor * lie - (sy * Math.cos(tip) - sz * Math.sin(tip) - sy) - (a.cur ? a.cur[6] : 0);
|
|
89
|
+
M.dz = -(sy * Math.sin(tip) + sz * Math.cos(tip) - sz);
|
|
90
|
+
M.chest = 0.06 * sit - 0.06 * S[CROUCH];
|
|
91
|
+
M.hips = -0.05 * sit;
|
|
92
|
+
const rootY = joints[0][1] + M.dy,
|
|
93
|
+
rootZ = joints[0][2] + M.dz;
|
|
94
|
+
for (let k = 0; k < 4; k++) {
|
|
95
|
+
const leg = M.legs[k],
|
|
96
|
+
hind = k > 1,
|
|
97
|
+
L = Q.legs[k],
|
|
98
|
+
oy = joints[L.bone][1] - joints[0][1],
|
|
99
|
+
oz = joints[L.bone][2] - joints[0][2],
|
|
100
|
+
py = rootY + oy * Math.cos(M.pitch) - oz * Math.sin(M.pitch),
|
|
101
|
+
pz = rootZ + oy * Math.sin(M.pitch) + oz * Math.cos(M.pitch),
|
|
102
|
+
len = L.len[0] + L.len[1] + L.len[2],
|
|
103
|
+
odd = k % 2 ? 1 : -1;
|
|
104
|
+
leg.w = 0;
|
|
105
|
+
if (hind) hold(leg, Math.max(sit, lie), 0, pz + 0.28 * h + odd * 0.02 * h, -1.2, 0);
|
|
106
|
+
else hold(leg, lie, 0, pz + 0.42 * h + odd * 0.025 * h, -1.25, 0);
|
|
107
|
+
if (hind) hold(leg, limp, py - 0.8 * len, pz - (0.22 + odd * 0.1) * len, 0.25, 0.5);
|
|
108
|
+
else hold(leg, limp, py - 0.78 * len, pz + (0.26 + odd * 0.12) * len, 0.2, 0.55);
|
|
109
|
+
}
|
|
110
|
+
const F = _frame,
|
|
111
|
+
free = a.fixY === null || a.fixY === undefined;
|
|
112
|
+
F.x = a.x;
|
|
113
|
+
F.y = a.y;
|
|
114
|
+
F.z = a.z;
|
|
115
|
+
F.yaw = a.yaw;
|
|
116
|
+
F.s = a.group.scale.y;
|
|
117
|
+
F.ground = free && !dead ? ground : null;
|
|
118
|
+
stepRig(Q, F, dt, M);
|
|
119
|
+
|
|
120
|
+
// Poised feline head: smooth, steady carry with minimal walk bob and a closed mouth at rest.
|
|
121
|
+
const level = -(Q.pitch + B[BONE.chest].rotation.x) * 0.85,
|
|
122
|
+
nx = S[NECK_X],
|
|
123
|
+
ny = S[NECK_Y],
|
|
124
|
+
nod = 0.018 * brisk * (1 - run) * Math.sin(Q.ph * TAU * 2);
|
|
125
|
+
B[BONE.neck].rotation.set(level * 0.55 + nx * 0.55 + nod, ny * 0.35, 0);
|
|
126
|
+
B[BONE.neck2].rotation.set(level * 0.45 + nx * 0.45, ny * 0.35, 0);
|
|
127
|
+
B[BONE.head].rotation.set(-nx * 0.5 - nod * 0.5 + 0.2 * limp, ny * 0.42, ny * 0.08 + (Q.breed?.tilt || 0));
|
|
128
|
+
B[BONE.jaw].rotation.x = 0;
|
|
129
|
+
|
|
130
|
+
// Alert upright ears with occasional subtle flicks.
|
|
131
|
+
const twitch = sstep(0.95, 1, Math.sin(t * 0.85 + a.seed * 37)) * Math.sin(t * 26) * 0.16;
|
|
132
|
+
B[BONE.earL].rotation.set(-0.55 * S[EARS] + twitch, 0, 0.2 * S[EARS]);
|
|
133
|
+
B[BONE.earR].rotation.set(-0.55 * S[EARS], 0, -0.2 * S[EARS]);
|
|
134
|
+
|
|
135
|
+
// The tail, as long as the body, at rest streaming back with a slight droop. Standing still it is raised with a gentle hook at
|
|
136
|
+
// the tip and a slow sway; walking, it is low in a curve with the tip lifted; prowling, low with its tip twitching; at a run it
|
|
137
|
+
// streams behind; sitting, it comes down and curls round the feet; lying, it curls beside the body.
|
|
138
|
+
const beat = t * (1.2 + 1.6 * brisk) + a.seed * 19,
|
|
139
|
+
rest = Math.max(sit, lie),
|
|
140
|
+
limpTail = limp,
|
|
141
|
+
crouch = S[CROUCH],
|
|
142
|
+
lift = Math.max(0, (1 - brisk * 0.75) * (1 - run) * (1 - rest) * (1 - limpTail) * (1 - crouch * 2)),
|
|
143
|
+
curlSide = rest * 0.72,
|
|
144
|
+
sway = (0.1 + 0.08 * brisk) * (1 - limpTail) * (1 - rest * 0.6) * Math.sin(beat),
|
|
145
|
+
tipTwitch = 0.25 * crouch * Math.max(0, Math.sin(beat * 3.1));
|
|
146
|
+
const walk = brisk * (1 - run) * (1 - rest); // walking: the tail hangs back and down, its tip lifted a little
|
|
147
|
+
B[BONE.tail].rotation.set(0.75 * lift - 0.35 * crouch - 0.25 * walk - 1.0 * rest + 0.05 * run, curlSide + sway * 0.5, 0);
|
|
148
|
+
B[BONE.tail + 1].rotation.set(0.6 * lift - 0.1 * crouch - 0.15 * walk - 0.3 * rest - 0.1 * run, curlSide * 0.8 + sway, 0);
|
|
149
|
+
B[BONE.tail + 2].rotation.set(
|
|
150
|
+
-0.7 * lift + 0.35 * (1 - lift) * (1 - rest) + 0.25 * walk + 0.5 * crouch + 0.3 * run + tipTwitch,
|
|
151
|
+
curlSide * 0.6 + sway * 1.3,
|
|
152
|
+
0,
|
|
153
|
+
);
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export { catPose };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "roamwright",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.1",
|
|
4
4
|
"description": "A procedural worldbuilding engine built on top of Three.js. Generate landscapes with rivers and changing weather, animate crowds, and explore on foot or in flight.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"threejs",
|
package/tools/ios-sim.sh
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
# SIM_STORAGE_LOG_KEY localStorage key holding the diagnostic log JSON (default: roamwright:log)
|
|
19
19
|
# SIM_DEFAULT_ADDRESS default route address when $1 is omitted
|
|
20
20
|
# SIM_SERVE_SCRIPT relative path to server script supporting SERVE_ENTRY (default: scripts/serve.py)
|
|
21
|
+
# SIM_WAIT seconds to wait for another headless run on this Mac to finish before giving up (default: 600)
|
|
21
22
|
set -eu
|
|
22
23
|
REPO="${SIM_REPO:?SIM_REPO is required}"
|
|
23
24
|
OUT="${SIM_OUT:?SIM_OUT is required}"
|
|
@@ -48,10 +49,19 @@ entry="r=$address&mute${4:+&q=$4}${5:+&$5}"
|
|
|
48
49
|
echo "sim: no built page in $REPO: run make build there first" >&2
|
|
49
50
|
exit 2
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
# One page at a time on this Mac: a headless run already here is waited for (polled every 10 s, up to SIM_WAIT seconds), as the
|
|
53
|
+
# remote runner waits for a free turn, rather than failing a gate at once because another check was a minute from its end.
|
|
54
|
+
busy_here() { [ -d "${TMPDIR:-/tmp}/$TURN_HERE_NAME" ] || pgrep -x chrome-headless-shell >/dev/null || pgrep -qf 'Google Chrome for Testing'; }
|
|
55
|
+
waited=0
|
|
56
|
+
while busy_here; do
|
|
57
|
+
[ "$waited" -lt "${SIM_WAIT:-600}" ] || {
|
|
58
|
+
echo "sim: a headless run has used this Mac for ${waited} s: one page at a time (raise SIM_WAIT to wait longer)" >&2
|
|
59
|
+
exit 2
|
|
60
|
+
}
|
|
61
|
+
[ "$waited" -gt 0 ] || echo "sim: a headless run is using this Mac; waiting up to ${SIM_WAIT:-600} s for it to finish" >&2
|
|
62
|
+
sleep 10
|
|
63
|
+
waited=$((waited + 10))
|
|
64
|
+
done
|
|
55
65
|
mkdir -p "$OUT" "$(dirname "$QUIET")"
|
|
56
66
|
held=
|
|
57
67
|
[ -e "$QUIET" ] || {
|