@margoengine/horses 0.0.0-stage → 0.1.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.
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +348 -3
- package/dist/anatomy.d.ts +75 -0
- package/dist/anatomy.js +89 -0
- package/dist/clip-plan.d.ts +10 -0
- package/dist/crowd.d.ts +76 -0
- package/dist/crowd.js +172 -0
- package/dist/drive.d.ts +39 -0
- package/dist/gaits.d.ts +93 -0
- package/dist/gaits.js +165 -0
- package/dist/grounding.d.ts +14 -0
- package/dist/index.d.ts +176 -0
- package/dist/index.js +1 -0
- package/dist/model-D2H9-6oj.js +1503 -0
- package/dist/model.d.ts +159 -0
- package/dist/model.js +1 -0
- package/dist/scene-scope-BIsfeY-W.js +42 -0
- package/dist/seat.d.ts +93 -0
- package/dist/seat.js +164 -0
- package/dist/settings.d.ts +29 -0
- package/dist/settings.js +126 -0
- package/dist/shared/settings.d.ts +89 -0
- package/dist/src-CAiGrBte.js +531 -0
- package/dist/strands.d.ts +30 -0
- package/dist/strands.js +135 -0
- package/package.json +86 -6
package/dist/strands.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { l as e } from "./model-D2H9-6oj.js";
|
|
2
|
+
import { n as t } from "./src-CAiGrBte.js";
|
|
3
|
+
import { cos as n, sin as r } from "@margoengine/math/pinned";
|
|
4
|
+
import { conjugateQuaternion as i, multiplyQuaternions as a, normalizeQuaternion as o, rotateByQuaternion as s } from "@margoengine/math/quat";
|
|
5
|
+
//#region src/strands.ts
|
|
6
|
+
var c = (e, t) => [
|
|
7
|
+
e[0] + t[0],
|
|
8
|
+
e[1] + t[1],
|
|
9
|
+
e[2] + t[2]
|
|
10
|
+
], l = (e, t) => [
|
|
11
|
+
e[0] - t[0],
|
|
12
|
+
e[1] - t[1],
|
|
13
|
+
e[2] - t[2]
|
|
14
|
+
];
|
|
15
|
+
function u(e) {
|
|
16
|
+
return {
|
|
17
|
+
position: e.position,
|
|
18
|
+
rotation: [
|
|
19
|
+
0,
|
|
20
|
+
r(e.heading / 2),
|
|
21
|
+
0,
|
|
22
|
+
n(e.heading / 2)
|
|
23
|
+
]
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function d(t, n, r) {
|
|
27
|
+
let i = [];
|
|
28
|
+
for (let [l, u] of t.joints.entries()) {
|
|
29
|
+
let d = i[u.parent] ?? r;
|
|
30
|
+
i.push({
|
|
31
|
+
position: c(d.position, s(e(t, n, l), d.rotation)),
|
|
32
|
+
rotation: o(a(d.rotation, n.rotations[l]))
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return i;
|
|
36
|
+
}
|
|
37
|
+
function f(e, t) {
|
|
38
|
+
return c(e.position, s(t, e.rotation));
|
|
39
|
+
}
|
|
40
|
+
async function p(e, n = {}) {
|
|
41
|
+
let { strands: r, signal: c, ...p } = n;
|
|
42
|
+
c?.throwIfAborted();
|
|
43
|
+
let [{ StrandSolver: m }, { PhysicsWorld: h }] = await Promise.all([import("@margoengine/physics/strands"), import("@margoengine/physics/world")]), g = await m.load({ signal: c }), _ = await t(e, {
|
|
44
|
+
...p,
|
|
45
|
+
strandRig: !0
|
|
46
|
+
});
|
|
47
|
+
try {
|
|
48
|
+
c?.throwIfAborted();
|
|
49
|
+
let e = _.skeleton, t = e.strandChains;
|
|
50
|
+
if (!t?.length) throw RangeError("Supply an authored skin with a tail, mane and forelock strand rig, or use the procedural horse.");
|
|
51
|
+
let n = new h({
|
|
52
|
+
rate: {
|
|
53
|
+
num: 240,
|
|
54
|
+
den: 1
|
|
55
|
+
},
|
|
56
|
+
cellSize: r?.cellSize
|
|
57
|
+
}), p = _.body, m = e.index("body"), v = e.index("neck1"), y = e.index("head"), { tail: b, mane: x, ...S } = r ?? {}, C = d(e, _.pose, u(_.frame())), w = C, T = t.map((e, t) => {
|
|
58
|
+
let n = e[0], r = i(C[n].rotation);
|
|
59
|
+
return {
|
|
60
|
+
...t === 0 ? {
|
|
61
|
+
radius: .018,
|
|
62
|
+
density: 1150,
|
|
63
|
+
young: 32e6,
|
|
64
|
+
dragWidth: .083,
|
|
65
|
+
...b
|
|
66
|
+
} : {
|
|
67
|
+
radius: .0045,
|
|
68
|
+
density: 1100,
|
|
69
|
+
young: 6e7,
|
|
70
|
+
dragWidth: .027,
|
|
71
|
+
...x
|
|
72
|
+
},
|
|
73
|
+
points: e.map((e) => C[e].position),
|
|
74
|
+
anchor: () => ({
|
|
75
|
+
position: w[n].position,
|
|
76
|
+
rotation: o(a(w[n].rotation, r))
|
|
77
|
+
})
|
|
78
|
+
};
|
|
79
|
+
}), E = () => {
|
|
80
|
+
let e = w[m];
|
|
81
|
+
return {
|
|
82
|
+
start: f(e, [
|
|
83
|
+
0,
|
|
84
|
+
0,
|
|
85
|
+
-.3 * p.bodyLength
|
|
86
|
+
]),
|
|
87
|
+
end: f(e, [
|
|
88
|
+
0,
|
|
89
|
+
0,
|
|
90
|
+
.31 * p.bodyLength
|
|
91
|
+
]),
|
|
92
|
+
radius: .44 * p.chestDepth
|
|
93
|
+
};
|
|
94
|
+
}, D = () => ({
|
|
95
|
+
start: w[v].position,
|
|
96
|
+
end: w[y].position,
|
|
97
|
+
radius: .073 * p.withers
|
|
98
|
+
});
|
|
99
|
+
n.add(g, {
|
|
100
|
+
...S,
|
|
101
|
+
strands: T,
|
|
102
|
+
rate: 2,
|
|
103
|
+
damping: S.damping ?? 5,
|
|
104
|
+
rodSolve: S.rodSolve ?? "local",
|
|
105
|
+
colliders: [E, D]
|
|
106
|
+
});
|
|
107
|
+
let O = n.takeSnapshot(), k = t.map((e, t) => e.map((e, n) => a(i(g.sample(t, n).rotation), C[e].rotation)));
|
|
108
|
+
return _.onStep((t, r) => {
|
|
109
|
+
w = d(e, r.pose, u(r.frame())), n.advance(Math.round(r.time * 240));
|
|
110
|
+
}, () => {
|
|
111
|
+
w = C, n.restoreSnapshot(O.bytes);
|
|
112
|
+
}), _.onPose((n, r) => {
|
|
113
|
+
let c = u(r.frame()), f = d(e, n, c), p = [...n.rotations], m = new Map(n.jointTranslations);
|
|
114
|
+
for (let [n, r] of t.entries()) for (let [t, u] of r.entries()) {
|
|
115
|
+
let r = g.sample(n, t), d = f[e.joints[u].parent] ?? c, h = o(a(r.rotation, k[n][t])), _ = i(d.rotation);
|
|
116
|
+
p[u] = o(a(_, h)), m.set(u, s(l(r.position, d.position), _)), f[u] = {
|
|
117
|
+
position: r.position,
|
|
118
|
+
rotation: h
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
...n,
|
|
123
|
+
rotations: p,
|
|
124
|
+
jointTranslations: m
|
|
125
|
+
};
|
|
126
|
+
}), _.advanceTime(0), Object.assign(_, {
|
|
127
|
+
strandSolver: g,
|
|
128
|
+
strandWorld: n
|
|
129
|
+
});
|
|
130
|
+
} catch (e) {
|
|
131
|
+
throw _.dispose(), e;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
export { p as addStrandHorse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,86 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@margoengine/horses",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@margoengine/horses",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Horses built in code from published equine measurements: draft, cavalry and riding builds, coats and markings, a mane and tail in strand hair, a 37-joint rig, walk, trot, canter and gallop from equine biomechanics, a rider seat, and crowds of hundreds in one draw.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"margoengine",
|
|
7
|
+
"webgpu",
|
|
8
|
+
"3d",
|
|
9
|
+
"horses",
|
|
10
|
+
"gaits",
|
|
11
|
+
"cavalry",
|
|
12
|
+
"animals"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://margoengine.com",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/scottcampbelldata/margoengine/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/scottcampbelldata/margoengine.git",
|
|
21
|
+
"directory": "packages/horses"
|
|
22
|
+
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"author": "Scott Campbell",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "node ../../scripts/build-optional.js horses",
|
|
31
|
+
"test": "npm run build && node --test test/*.test.js",
|
|
32
|
+
"prepack": "npm --prefix ../.. run build:packages",
|
|
33
|
+
"test:gpu:strands": "cd ../.. && node packages/horses/test/strand-horse.browser.mjs",
|
|
34
|
+
"test:gpu": "cd ../.. && node packages/horses/test/horses-check.mjs"
|
|
35
|
+
},
|
|
36
|
+
"sideEffects": false,
|
|
37
|
+
"exports": {
|
|
38
|
+
".": {
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"import": "./dist/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./anatomy": {
|
|
43
|
+
"types": "./dist/anatomy.d.ts",
|
|
44
|
+
"import": "./dist/anatomy.js"
|
|
45
|
+
},
|
|
46
|
+
"./gaits": {
|
|
47
|
+
"types": "./dist/gaits.d.ts",
|
|
48
|
+
"import": "./dist/gaits.js"
|
|
49
|
+
},
|
|
50
|
+
"./model": {
|
|
51
|
+
"types": "./dist/model.d.ts",
|
|
52
|
+
"import": "./dist/model.js"
|
|
53
|
+
},
|
|
54
|
+
"./seat": {
|
|
55
|
+
"types": "./dist/seat.d.ts",
|
|
56
|
+
"import": "./dist/seat.js"
|
|
57
|
+
},
|
|
58
|
+
"./crowd": {
|
|
59
|
+
"types": "./dist/crowd.d.ts",
|
|
60
|
+
"import": "./dist/crowd.js"
|
|
61
|
+
},
|
|
62
|
+
"./settings": {
|
|
63
|
+
"types": "./dist/settings.d.ts",
|
|
64
|
+
"import": "./dist/settings.js"
|
|
65
|
+
},
|
|
66
|
+
"./strands": {
|
|
67
|
+
"types": "./dist/strands.d.ts",
|
|
68
|
+
"import": "./dist/strands.js"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"files": [
|
|
72
|
+
"dist",
|
|
73
|
+
"LICENSE",
|
|
74
|
+
"NOTICE"
|
|
75
|
+
],
|
|
76
|
+
"peerDependencies": {
|
|
77
|
+
"@margoengine/core": "^0.1.0",
|
|
78
|
+
"@margoengine/gltf": "^0.1.0"
|
|
79
|
+
},
|
|
80
|
+
"dependencies": {
|
|
81
|
+
"@margoengine/animation": "^0.1.0",
|
|
82
|
+
"@margoengine/math": "^0.1.0",
|
|
83
|
+
"@margoengine/materials": "^0.1.0",
|
|
84
|
+
"@margoengine/physics": "^0.1.0"
|
|
85
|
+
}
|
|
86
|
+
}
|