@automovie/human 0.1.0 → 0.2.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/README.md +18 -3
- package/lib/generation/AutoMovieHumanDigitJoints.d.ts +8 -26
- package/lib/generation/AutoMovieHumanDigitJoints.js +9 -37
- package/lib/generation/AutoMovieHumanDigitJoints.js.map +1 -1
- package/lib/generation/conic/AutoMovieHumanConicLoft.d.ts +154 -0
- package/lib/generation/conic/AutoMovieHumanConicLoft.js +430 -0
- package/lib/generation/conic/AutoMovieHumanConicLoft.js.map +1 -0
- package/lib/generation/conic/AutoMovieHumanConicPose.d.ts +92 -0
- package/lib/generation/conic/AutoMovieHumanConicPose.js +202 -0
- package/lib/generation/conic/AutoMovieHumanConicPose.js.map +1 -0
- package/lib/generation/conic/AutoMovieHumanConicRelief.d.ts +52 -0
- package/lib/generation/conic/AutoMovieHumanConicRelief.js +88 -0
- package/lib/generation/conic/AutoMovieHumanConicRelief.js.map +1 -0
- package/lib/generation/conic/AutoMovieHumanConicSection.d.ts +252 -0
- package/lib/generation/conic/AutoMovieHumanConicSection.js +567 -0
- package/lib/generation/conic/AutoMovieHumanConicSection.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1.d.ts +265 -0
- package/lib/generation/f1/AutoMovieHumanF1.js +1254 -0
- package/lib/generation/f1/AutoMovieHumanF1.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Antihelix.d.ts +23 -0
- package/lib/generation/f1/AutoMovieHumanF1Antihelix.js +65 -0
- package/lib/generation/f1/AutoMovieHumanF1Antihelix.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Arm.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1Arm.js +82 -0
- package/lib/generation/f1/AutoMovieHumanF1Arm.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Axilla.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1Axilla.js +91 -0
- package/lib/generation/f1/AutoMovieHumanF1Axilla.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Breast.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1Breast.js +75 -0
- package/lib/generation/f1/AutoMovieHumanF1Breast.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Concha.d.ts +40 -0
- package/lib/generation/f1/AutoMovieHumanF1Concha.js +81 -0
- package/lib/generation/f1/AutoMovieHumanF1Concha.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerIndex.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerIndex.js +59 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerIndex.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerMiddle.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerMiddle.js +59 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerMiddle.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerPinky.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerPinky.js +75 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerPinky.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerRing.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerRing.js +75 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerRing.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerThumb.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerThumb.js +59 -0
- package/lib/generation/f1/AutoMovieHumanF1FingerThumb.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Frames.d.ts +97 -0
- package/lib/generation/f1/AutoMovieHumanF1Frames.js +160 -0
- package/lib/generation/f1/AutoMovieHumanF1Frames.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Hand.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1Hand.js +81 -0
- package/lib/generation/f1/AutoMovieHumanF1Hand.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Helix.d.ts +20 -0
- package/lib/generation/f1/AutoMovieHumanF1Helix.js +64 -0
- package/lib/generation/f1/AutoMovieHumanF1Helix.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Joints.d.ts +231 -0
- package/lib/generation/f1/AutoMovieHumanF1Joints.js +249 -0
- package/lib/generation/f1/AutoMovieHumanF1Joints.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Landmarks.d.ts +86 -0
- package/lib/generation/f1/AutoMovieHumanF1Landmarks.js +89 -0
- package/lib/generation/f1/AutoMovieHumanF1Landmarks.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Leg.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1Leg.js +82 -0
- package/lib/generation/f1/AutoMovieHumanF1Leg.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Nose.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1Nose.js +82 -0
- package/lib/generation/f1/AutoMovieHumanF1Nose.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Nostril.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1Nostril.js +59 -0
- package/lib/generation/f1/AutoMovieHumanF1Nostril.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Placement.d.ts +75 -0
- package/lib/generation/f1/AutoMovieHumanF1Placement.js +151 -0
- package/lib/generation/f1/AutoMovieHumanF1Placement.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Placing.d.ts +45 -0
- package/lib/generation/f1/AutoMovieHumanF1Placing.js +301 -0
- package/lib/generation/f1/AutoMovieHumanF1Placing.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Plate.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1Plate.js +59 -0
- package/lib/generation/f1/AutoMovieHumanF1Plate.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeBig.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeBig.js +59 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeBig.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeIndex.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeIndex.js +59 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeIndex.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeLittle.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeLittle.js +75 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeLittle.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeMiddle.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeMiddle.js +75 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeMiddle.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeRing.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeRing.js +75 -0
- package/lib/generation/f1/AutoMovieHumanF1ToeRing.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Trunk.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1Trunk.js +79 -0
- package/lib/generation/f1/AutoMovieHumanF1Trunk.js.map +1 -0
- package/lib/generation/f1/AutoMovieHumanF1Vault.d.ts +18 -0
- package/lib/generation/f1/AutoMovieHumanF1Vault.js +75 -0
- package/lib/generation/f1/AutoMovieHumanF1Vault.js.map +1 -0
- package/lib/generation/frame/AutoMovieHumanSegmentFrame.d.ts +149 -0
- package/lib/generation/frame/AutoMovieHumanSegmentFrame.js +290 -0
- package/lib/generation/frame/AutoMovieHumanSegmentFrame.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -1
- package/lib/skeleton/AutoMovieHumanCanonicalBody.d.ts +7 -3
- package/lib/skeleton/AutoMovieHumanCanonicalBody.js +31 -3
- package/lib/skeleton/AutoMovieHumanCanonicalBody.js.map +1 -1
- package/lib/skeleton/AutoMovieHumanCanonicalProfile.d.ts +22 -31
- package/lib/skeleton/AutoMovieHumanCanonicalProfile.js +112 -172
- package/lib/skeleton/AutoMovieHumanCanonicalProfile.js.map +1 -1
- package/lib/skeleton/AutoMovieHumanCanonicalSolids.d.ts +65 -0
- package/lib/skeleton/AutoMovieHumanCanonicalSolids.js +105 -0
- package/lib/skeleton/AutoMovieHumanCanonicalSolids.js.map +1 -0
- package/lib/skeleton/index.d.ts +1 -0
- package/lib/skeleton/index.js +1 -0
- package/lib/skeleton/index.js.map +1 -1
- package/package.json +21 -13
- package/src/generation/AutoMovieHumanDigitJoints.ts +12 -47
- package/src/generation/conic/AutoMovieHumanConicLoft.ts +566 -0
- package/src/generation/conic/AutoMovieHumanConicPose.ts +213 -0
- package/src/generation/conic/AutoMovieHumanConicRelief.ts +94 -0
- package/src/generation/conic/AutoMovieHumanConicSection.ts +609 -0
- package/src/generation/f1/AutoMovieHumanF1.ts +1448 -0
- package/src/generation/f1/AutoMovieHumanF1Antihelix.ts +64 -0
- package/src/generation/f1/AutoMovieHumanF1Arm.ts +82 -0
- package/src/generation/f1/AutoMovieHumanF1Axilla.ts +90 -0
- package/src/generation/f1/AutoMovieHumanF1Breast.ts +74 -0
- package/src/generation/f1/AutoMovieHumanF1Concha.ts +80 -0
- package/src/generation/f1/AutoMovieHumanF1FingerIndex.ts +58 -0
- package/src/generation/f1/AutoMovieHumanF1FingerMiddle.ts +58 -0
- package/src/generation/f1/AutoMovieHumanF1FingerPinky.ts +74 -0
- package/src/generation/f1/AutoMovieHumanF1FingerRing.ts +74 -0
- package/src/generation/f1/AutoMovieHumanF1FingerThumb.ts +58 -0
- package/src/generation/f1/AutoMovieHumanF1Frames.ts +191 -0
- package/src/generation/f1/AutoMovieHumanF1Hand.ts +81 -0
- package/src/generation/f1/AutoMovieHumanF1Helix.ts +63 -0
- package/src/generation/f1/AutoMovieHumanF1Joints.ts +319 -0
- package/src/generation/f1/AutoMovieHumanF1Landmarks.ts +101 -0
- package/src/generation/f1/AutoMovieHumanF1Leg.ts +82 -0
- package/src/generation/f1/AutoMovieHumanF1Nose.ts +82 -0
- package/src/generation/f1/AutoMovieHumanF1Nostril.ts +58 -0
- package/src/generation/f1/AutoMovieHumanF1Placement.ts +148 -0
- package/src/generation/f1/AutoMovieHumanF1Placing.ts +313 -0
- package/src/generation/f1/AutoMovieHumanF1Plate.ts +59 -0
- package/src/generation/f1/AutoMovieHumanF1ToeBig.ts +58 -0
- package/src/generation/f1/AutoMovieHumanF1ToeIndex.ts +58 -0
- package/src/generation/f1/AutoMovieHumanF1ToeLittle.ts +74 -0
- package/src/generation/f1/AutoMovieHumanF1ToeMiddle.ts +74 -0
- package/src/generation/f1/AutoMovieHumanF1ToeRing.ts +74 -0
- package/src/generation/f1/AutoMovieHumanF1Trunk.ts +79 -0
- package/src/generation/f1/AutoMovieHumanF1Vault.ts +74 -0
- package/src/generation/frame/AutoMovieHumanSegmentFrame.ts +309 -0
- package/src/index.ts +11 -0
- package/src/skeleton/AutoMovieHumanCanonicalBody.ts +53 -3
- package/src/skeleton/AutoMovieHumanCanonicalProfile.ts +153 -358
- package/src/skeleton/AutoMovieHumanCanonicalSolids.ts +175 -0
- package/src/skeleton/index.ts +1 -0
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
HUMANOID_REST_FRAME,
|
|
6
6
|
Quaternion,
|
|
7
7
|
Vector3,
|
|
8
|
+
combinePhysicalMassProperties,
|
|
8
9
|
rotationBetween,
|
|
9
10
|
toRigAngle,
|
|
10
11
|
} from "@automovie/engine";
|
|
@@ -16,25 +17,24 @@ import type {
|
|
|
16
17
|
IAutoMoviePhysicalProfile as P,
|
|
17
18
|
} from "@automovie/interface";
|
|
18
19
|
|
|
20
|
+
import { AutoMovieHumanCanonicalSolids as Solids } from "./AutoMovieHumanCanonicalSolids";
|
|
21
|
+
|
|
19
22
|
/**
|
|
20
23
|
* The contact and mass profile of a polygon man, built from the same joints
|
|
21
24
|
* and girth radii its drawing is built from, at the canonical T-pose rest.
|
|
22
25
|
*
|
|
23
|
-
* Colliders
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* roots' (the ball), standing on the floor, and the toes the box of the toe
|
|
36
|
-
* joints' spheres to their tips, riding the toes bone so they bend at the
|
|
37
|
-
* ball as the drawn toes do.
|
|
26
|
+
* Colliders are the drawn solids. The trunk, the neck, the head, each limb
|
|
27
|
+
* segment, the palm, the rear foot and every toe phalanx collide as the
|
|
28
|
+
* convex hulls of the very ring points the drawing lofts its mesh through
|
|
29
|
+
* (`AutoMovieHumanCanonicalSolids`), so the collision surface is the drawn
|
|
30
|
+
* surface: no corner stands outside what is seen and no drawn surface lies
|
|
31
|
+
* outside its collider. A rig bone carries the hulls of every drawn module
|
|
32
|
+
* that rides it: the foot its two modules through the subtalar and midfoot
|
|
33
|
+
* joints, the toes bone every toe phalanx, so the toes bend at the ball as
|
|
34
|
+
* drawn. Each phalanx of the hand is a capsule of its girth radius from its
|
|
35
|
+
* joint to its child joint, a distal one ending with its cap on the
|
|
36
|
+
* fingertip, because a curl solves its contact in closed form on capsules
|
|
37
|
+
* and the drawn phalanx is that round.
|
|
38
38
|
*
|
|
39
39
|
* Masses are Dempster's shares of body mass as tabulated by Winter
|
|
40
40
|
* (Biomechanics and Motor Control of Human Movement, 4th ed., table 4.1):
|
|
@@ -42,33 +42,24 @@ import type {
|
|
|
42
42
|
* 0.0145, thorax 0.216, abdomen 0.139, pelvis 0.142 and head with neck 0.081,
|
|
43
43
|
* the head taking de Leva's (1996) 0.0694 and the neck the rest; the hand's
|
|
44
44
|
* share is split over the palm and the phalanges by collider volume, a
|
|
45
|
-
* uniform density within the hand, and the foot's over the rear foot and
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
45
|
+
* uniform density within the hand, and the foot's over the rear foot and the
|
|
46
|
+
* toes the same way. Each segment's centre of mass and inertia are those of
|
|
47
|
+
* its colliders as uniform solids, combined by the parallel-axis theorem,
|
|
48
|
+
* the way physics engines derive inertia from shapes. Joints sit at each
|
|
49
|
+
* child joint with identity frames; every clinical axis of
|
|
50
|
+
* `DEFAULT_HUMANOID_ROM` becomes a physical axis along its
|
|
51
51
|
* `HUMANOID_JOINT_AXES` direction with limits read through
|
|
52
52
|
* `HUMANOID_REST_FRAME`, so the physical zero is the T-pose. Drive gains are
|
|
53
53
|
* placeholders kinematic motion never reads: 50 N m per downstream kilogram.
|
|
54
54
|
*/
|
|
55
55
|
export namespace AutoMovieHumanCanonicalProfile {
|
|
56
56
|
/** One drawn joint: its canonical rest position, its girth radius and its carrier. */
|
|
57
|
-
export
|
|
58
|
-
/** Rest joint centre, canonical metres. */
|
|
59
|
-
position: IAutoMovieVector3;
|
|
60
|
-
|
|
61
|
-
/** Rest tip of a leaf segment, canonical metres. */
|
|
62
|
-
tip: IAutoMovieVector3 | null;
|
|
63
|
-
|
|
64
|
-
/** Girth radius, metres. */
|
|
65
|
-
radius: number;
|
|
66
|
-
}
|
|
57
|
+
export type IJoint = Solids.IJoint;
|
|
67
58
|
|
|
68
59
|
/**
|
|
69
60
|
* Build the profile.
|
|
70
61
|
*
|
|
71
|
-
* @param joints Every drawn Human joint by id.
|
|
62
|
+
* @param joints Every drawn Human joint by id, parent before child.
|
|
72
63
|
* @param mass Body mass, kilograms.
|
|
73
64
|
* @param id Profile id.
|
|
74
65
|
* @returns The profile on the rig's bones.
|
|
@@ -84,69 +75,39 @@ export namespace AutoMovieHumanCanonicalProfile {
|
|
|
84
75
|
throw new Error(`The polygon profile needs the joint ${name}`);
|
|
85
76
|
return found;
|
|
86
77
|
};
|
|
87
|
-
const k: number = Math.sqrt(Math.PI / 4);
|
|
88
78
|
const identity: IAutoMovieQuaternion = Quaternion.identity();
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
): void => {
|
|
97
|
-
const m: number = share * mass;
|
|
98
|
-
segments.push({
|
|
99
|
-
bone,
|
|
100
|
-
neutral: { position: origin, rotation: identity },
|
|
101
|
-
mass: m,
|
|
102
|
-
centerOfMass: shape.transform.position,
|
|
103
|
-
inertia: Vector3.scale(inertia, m),
|
|
104
|
-
inertiaRotation: shape.transform.rotation,
|
|
105
|
-
shapes: [shape],
|
|
106
|
-
});
|
|
79
|
+
const at = (name: string): IAutoMovieVector3 => j(name).position;
|
|
80
|
+
// A rig bone's origin is its joint; the toes bone sits at the hallux's root.
|
|
81
|
+
const origin = (bone: AutoMovieHumanoidBone): IAutoMovieVector3 =>
|
|
82
|
+
at(bone.replace(/Toes$/u, "HalluxProximal"));
|
|
83
|
+
const parts: Map<AutoMovieHumanoidBone, IPart[]> = new Map();
|
|
84
|
+
const put = (bone: AutoMovieHumanoidBone, part: IPart): void => {
|
|
85
|
+
parts.set(bone, [...(parts.get(bone) ?? []), part]);
|
|
107
86
|
};
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
max: IAutoMovieVector3,
|
|
113
|
-
origin: IAutoMovieVector3 = j(bone).position,
|
|
114
|
-
): void => {
|
|
115
|
-
const half: IAutoMovieVector3 = Vector3.scale(
|
|
116
|
-
Vector3.subtract(max, min),
|
|
117
|
-
0.5,
|
|
118
|
-
);
|
|
119
|
-
const centre: IAutoMovieVector3 = Vector3.subtract(
|
|
120
|
-
Vector3.scale(Vector3.add(min, max), 0.5),
|
|
121
|
-
origin,
|
|
122
|
-
);
|
|
123
|
-
add(
|
|
124
|
-
bone,
|
|
125
|
-
share,
|
|
126
|
-
{
|
|
127
|
-
id: "body",
|
|
87
|
+
for (const solid of Solids.build(joints))
|
|
88
|
+
put(solid.carrier, {
|
|
89
|
+
shape: {
|
|
90
|
+
id: solid.id,
|
|
128
91
|
material: "skin",
|
|
129
|
-
transform: {
|
|
130
|
-
|
|
131
|
-
|
|
92
|
+
transform: {
|
|
93
|
+
position: Vector3.subtract(solid.centre, origin(solid.carrier)),
|
|
94
|
+
rotation: identity,
|
|
95
|
+
},
|
|
96
|
+
kind: "hull",
|
|
97
|
+
points: solid.points,
|
|
132
98
|
},
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
);
|
|
140
|
-
};
|
|
141
|
-
// A capsule between two joints ends in the joints' balls; one to a surface
|
|
142
|
-
// tip (the crown, a fingertip) ends with its cap on the tip.
|
|
99
|
+
volume: solid.volume,
|
|
100
|
+
inertia: solid.inertia,
|
|
101
|
+
inertiaRotation: solid.inertiaRotation,
|
|
102
|
+
});
|
|
103
|
+
// A phalanx between two joints ends in the joints' balls; a distal one
|
|
104
|
+
// ends with its cap on the fingertip.
|
|
143
105
|
const capsule = (
|
|
144
106
|
bone: AutoMovieHumanoidBone,
|
|
145
|
-
share: number,
|
|
146
107
|
from: IAutoMovieVector3,
|
|
147
108
|
end: IAutoMovieVector3,
|
|
148
109
|
radius: number,
|
|
149
|
-
tip: boolean
|
|
110
|
+
tip: boolean,
|
|
150
111
|
): void => {
|
|
151
112
|
const span: number = Vector3.length(Vector3.subtract(end, from));
|
|
152
113
|
const inward: number = tip ? Math.min(radius, span) : 0;
|
|
@@ -161,267 +122,29 @@ export namespace AutoMovieHumanCanonicalProfile {
|
|
|
161
122
|
const length: number = Vector3.length(axis);
|
|
162
123
|
const rotation: IAutoMovieQuaternion =
|
|
163
124
|
length > 1e-9 ? rotationBetween({ x: 0, y: 1, z: 0 }, axis) : identity;
|
|
164
|
-
const
|
|
165
|
-
Vector3.scale(Vector3.add(from, to), 0.5),
|
|
166
|
-
j(bone).position,
|
|
167
|
-
);
|
|
168
|
-
const half: number = length / 2;
|
|
169
|
-
const full: number = 2 * half + 2 * radius;
|
|
170
|
-
const axial: number = (radius * radius) / 2;
|
|
125
|
+
const full: number = length + 2 * radius;
|
|
171
126
|
const transverse: number = (3 * radius * radius + full * full) / 12;
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
share,
|
|
175
|
-
{
|
|
127
|
+
put(bone, {
|
|
128
|
+
shape: {
|
|
176
129
|
id: "body",
|
|
177
130
|
material: "skin",
|
|
178
|
-
transform: {
|
|
131
|
+
transform: {
|
|
132
|
+
position: Vector3.subtract(
|
|
133
|
+
Vector3.scale(Vector3.add(from, to), 0.5),
|
|
134
|
+
origin(bone),
|
|
135
|
+
),
|
|
136
|
+
rotation,
|
|
137
|
+
},
|
|
179
138
|
kind: "capsule",
|
|
180
139
|
radius,
|
|
181
|
-
halfLength:
|
|
140
|
+
halfLength: length / 2,
|
|
182
141
|
},
|
|
183
|
-
|
|
184
|
-
|
|
142
|
+
volume:
|
|
143
|
+
Math.PI * radius * radius * length + (4 / 3) * Math.PI * radius ** 3,
|
|
144
|
+
inertia: { x: transverse, y: (radius * radius) / 2, z: transverse },
|
|
145
|
+
inertiaRotation: rotation,
|
|
146
|
+
});
|
|
185
147
|
};
|
|
186
|
-
const at = (name: string): IAutoMovieVector3 => j(name).position;
|
|
187
|
-
const span = (a: string, b: string): number =>
|
|
188
|
-
Math.abs(at(a).x - at(b).x) / 2;
|
|
189
|
-
|
|
190
|
-
// Trunk boxes from the drawing's sections (half breadth, half depth = girth radius).
|
|
191
|
-
const hips: IJoint = j("hips");
|
|
192
|
-
const spine: IJoint = j("spine");
|
|
193
|
-
const chest: IJoint = j("chest");
|
|
194
|
-
const legRadius: number = Math.max(
|
|
195
|
-
j("leftUpperLeg").radius,
|
|
196
|
-
j("rightUpperLeg").radius,
|
|
197
|
-
);
|
|
198
|
-
const armRadius: number = Math.max(
|
|
199
|
-
j("leftUpperArm").radius,
|
|
200
|
-
j("rightUpperArm").radius,
|
|
201
|
-
);
|
|
202
|
-
const hipBreadth: number = Math.max(
|
|
203
|
-
hips.radius,
|
|
204
|
-
span("leftUpperLeg", "rightUpperLeg") + legRadius,
|
|
205
|
-
);
|
|
206
|
-
const shoulderBreadth: number = Math.max(
|
|
207
|
-
chest.radius,
|
|
208
|
-
span("leftUpperArm", "rightUpperArm") + armRadius,
|
|
209
|
-
);
|
|
210
|
-
const lumbar: number = Math.max(spine.radius, 0.75 * shoulderBreadth);
|
|
211
|
-
const thorax: number = Math.max(chest.radius, 0.85 * shoulderBreadth);
|
|
212
|
-
const trunk = (
|
|
213
|
-
bone: AutoMovieHumanoidBone,
|
|
214
|
-
share: number,
|
|
215
|
-
bottom: number,
|
|
216
|
-
top: number,
|
|
217
|
-
breadth: number,
|
|
218
|
-
depth: number,
|
|
219
|
-
z: number,
|
|
220
|
-
): void =>
|
|
221
|
-
box(
|
|
222
|
-
bone,
|
|
223
|
-
share,
|
|
224
|
-
{ x: -k * breadth, y: bottom, z: z - k * depth },
|
|
225
|
-
{ x: k * breadth, y: top, z: z + k * depth },
|
|
226
|
-
);
|
|
227
|
-
trunk(
|
|
228
|
-
"hips",
|
|
229
|
-
0.142,
|
|
230
|
-
hips.position.y -
|
|
231
|
-
Math.min(j("leftUpperLeg").radius, j("rightUpperLeg").radius),
|
|
232
|
-
spine.position.y,
|
|
233
|
-
hipBreadth,
|
|
234
|
-
hips.radius,
|
|
235
|
-
hips.position.z,
|
|
236
|
-
);
|
|
237
|
-
trunk(
|
|
238
|
-
"spine",
|
|
239
|
-
0.139,
|
|
240
|
-
spine.position.y,
|
|
241
|
-
chest.position.y,
|
|
242
|
-
(lumbar + thorax) / 2,
|
|
243
|
-
(spine.radius + chest.radius) / 2,
|
|
244
|
-
spine.position.z,
|
|
245
|
-
);
|
|
246
|
-
trunk(
|
|
247
|
-
"chest",
|
|
248
|
-
0.216,
|
|
249
|
-
chest.position.y,
|
|
250
|
-
at("neck").y,
|
|
251
|
-
(thorax + shoulderBreadth) / 2,
|
|
252
|
-
chest.radius,
|
|
253
|
-
chest.position.z,
|
|
254
|
-
);
|
|
255
|
-
capsule("neck", 0.081 - 0.0694, at("neck"), at("head"), j("neck").radius);
|
|
256
|
-
const crown: IAutoMovieVector3 =
|
|
257
|
-
j("head").tip ??
|
|
258
|
-
Vector3.add(at("head"), { x: 0, y: 2 * j("head").radius, z: 0 });
|
|
259
|
-
capsule(
|
|
260
|
-
"head",
|
|
261
|
-
0.0694,
|
|
262
|
-
at("head"),
|
|
263
|
-
crown,
|
|
264
|
-
j("head").radius,
|
|
265
|
-
j("head").tip !== null,
|
|
266
|
-
);
|
|
267
|
-
|
|
268
|
-
for (const side of ["left", "right"] as const) {
|
|
269
|
-
const b = (name: string): AutoMovieHumanoidBone =>
|
|
270
|
-
`${side}${name}` as AutoMovieHumanoidBone;
|
|
271
|
-
capsule(
|
|
272
|
-
b("UpperArm"),
|
|
273
|
-
0.028,
|
|
274
|
-
at(b("UpperArm")),
|
|
275
|
-
at(b("LowerArm")),
|
|
276
|
-
j(b("UpperArm")).radius,
|
|
277
|
-
);
|
|
278
|
-
capsule(
|
|
279
|
-
b("LowerArm"),
|
|
280
|
-
0.016,
|
|
281
|
-
at(b("LowerArm")),
|
|
282
|
-
at(b("Hand")),
|
|
283
|
-
j(b("LowerArm")).radius,
|
|
284
|
-
);
|
|
285
|
-
const knuckles: IJoint[] = FINGERS.map(
|
|
286
|
-
(d: string): IJoint => j(b(`${d}Proximal`)),
|
|
287
|
-
);
|
|
288
|
-
const across: number =
|
|
289
|
-
Math.abs(at(b("IndexProximal")).z - at(b("LittleProximal")).z) / 2 +
|
|
290
|
-
j(b("IndexProximal")).radius;
|
|
291
|
-
const thick: number = k * j(b("Hand")).radius;
|
|
292
|
-
const wrist: IAutoMovieVector3 = at(b("Hand"));
|
|
293
|
-
const xs: number[] = [
|
|
294
|
-
wrist.x,
|
|
295
|
-
...knuckles.flatMap((n: IJoint): number[] => [
|
|
296
|
-
n.position.x - n.radius,
|
|
297
|
-
n.position.x + n.radius,
|
|
298
|
-
]),
|
|
299
|
-
];
|
|
300
|
-
const digits: {
|
|
301
|
-
bone: AutoMovieHumanoidBone;
|
|
302
|
-
from: IAutoMovieVector3;
|
|
303
|
-
to: IAutoMovieVector3;
|
|
304
|
-
radius: number;
|
|
305
|
-
tip: boolean;
|
|
306
|
-
}[] = DIGITS.flatMap((chain: readonly string[]) =>
|
|
307
|
-
chain.map((name: string, i: number) => {
|
|
308
|
-
const joint: IJoint = j(b(name));
|
|
309
|
-
const next: string | undefined = chain[i + 1];
|
|
310
|
-
return {
|
|
311
|
-
bone: b(name),
|
|
312
|
-
from: joint.position,
|
|
313
|
-
to:
|
|
314
|
-
next === undefined ? (joint.tip ?? joint.position) : at(b(next)),
|
|
315
|
-
tip: next === undefined && joint.tip !== null,
|
|
316
|
-
radius: joint.radius,
|
|
317
|
-
};
|
|
318
|
-
}),
|
|
319
|
-
);
|
|
320
|
-
// The hand's Dempster share split over its palm and phalanges by volume (uniform density).
|
|
321
|
-
const palmHalf: IAutoMovieVector3 = {
|
|
322
|
-
x: (Math.max(...xs) - Math.min(...xs)) / 2,
|
|
323
|
-
y: thick,
|
|
324
|
-
z: across,
|
|
325
|
-
};
|
|
326
|
-
const capsuleVolume = (r: number, length: number): number =>
|
|
327
|
-
Math.PI * r * r * length + (4 / 3) * Math.PI * r ** 3;
|
|
328
|
-
const volumes: number[] = digits.map((d): number =>
|
|
329
|
-
capsuleVolume(d.radius, Vector3.length(Vector3.subtract(d.to, d.from))),
|
|
330
|
-
);
|
|
331
|
-
const palmVolume: number = 8 * palmHalf.x * palmHalf.y * palmHalf.z;
|
|
332
|
-
const handVolume: number =
|
|
333
|
-
palmVolume + volumes.reduce((s: number, v: number): number => s + v, 0);
|
|
334
|
-
box(
|
|
335
|
-
b("Hand"),
|
|
336
|
-
(0.006 * palmVolume) / handVolume,
|
|
337
|
-
{ x: Math.min(...xs), y: wrist.y - thick, z: wrist.z - across },
|
|
338
|
-
{ x: Math.max(...xs), y: wrist.y + thick, z: wrist.z + across },
|
|
339
|
-
);
|
|
340
|
-
digits.forEach((d, i: number): void =>
|
|
341
|
-
capsule(
|
|
342
|
-
d.bone,
|
|
343
|
-
(0.006 * volumes[i]!) / handVolume,
|
|
344
|
-
d.from,
|
|
345
|
-
d.to,
|
|
346
|
-
d.radius,
|
|
347
|
-
d.tip,
|
|
348
|
-
),
|
|
349
|
-
);
|
|
350
|
-
capsule(
|
|
351
|
-
b("UpperLeg"),
|
|
352
|
-
0.1,
|
|
353
|
-
at(b("UpperLeg")),
|
|
354
|
-
at(b("LowerLeg")),
|
|
355
|
-
j(b("UpperLeg")).radius,
|
|
356
|
-
);
|
|
357
|
-
capsule(
|
|
358
|
-
b("LowerLeg"),
|
|
359
|
-
0.0465,
|
|
360
|
-
at(b("LowerLeg")),
|
|
361
|
-
at(b("Foot")),
|
|
362
|
-
j(b("LowerLeg")).radius,
|
|
363
|
-
);
|
|
364
|
-
// The rear foot to the balls of the toes' roots, and the toes from their roots to their tips.
|
|
365
|
-
const named = (pattern: RegExp): IJoint[] =>
|
|
366
|
-
[...joints.entries()]
|
|
367
|
-
.filter(
|
|
368
|
-
([name]): boolean => name.startsWith(side) && pattern.test(name),
|
|
369
|
-
)
|
|
370
|
-
.map(([, joint]): IJoint => joint);
|
|
371
|
-
const roots: IJoint[] = named(/(HalluxProximal|Toe\dProximal)$/);
|
|
372
|
-
const extent = (
|
|
373
|
-
parts: IJoint[],
|
|
374
|
-
floor: number,
|
|
375
|
-
top: number,
|
|
376
|
-
tips: boolean,
|
|
377
|
-
): { min: IAutoMovieVector3; max: IAutoMovieVector3 } => {
|
|
378
|
-
const min: IAutoMovieVector3 = { x: Infinity, y: floor, z: Infinity };
|
|
379
|
-
const max: IAutoMovieVector3 = { x: -Infinity, y: top, z: -Infinity };
|
|
380
|
-
for (const joint of parts)
|
|
381
|
-
for (const p of [
|
|
382
|
-
joint.position,
|
|
383
|
-
...(tips && joint.tip !== null ? [joint.tip] : []),
|
|
384
|
-
]) {
|
|
385
|
-
min.x = Math.min(min.x, p.x - joint.radius);
|
|
386
|
-
min.z = Math.min(min.z, p.z - joint.radius);
|
|
387
|
-
max.x = Math.max(max.x, p.x + joint.radius);
|
|
388
|
-
max.z = Math.max(max.z, p.z + joint.radius);
|
|
389
|
-
}
|
|
390
|
-
return { min, max };
|
|
391
|
-
};
|
|
392
|
-
const toes: IJoint[] = named(/(Hallux|Toe\d)/);
|
|
393
|
-
const rear = extent(
|
|
394
|
-
[...named(/(Foot|Subtalar|Midfoot)$/), ...roots],
|
|
395
|
-
0,
|
|
396
|
-
at(b("Foot")).y,
|
|
397
|
-
false,
|
|
398
|
-
);
|
|
399
|
-
const front = extent(
|
|
400
|
-
toes,
|
|
401
|
-
Math.min(
|
|
402
|
-
...toes.map(
|
|
403
|
-
(t: IJoint): number =>
|
|
404
|
-
Math.min(t.position.y, t.tip?.y ?? Infinity) - t.radius,
|
|
405
|
-
),
|
|
406
|
-
),
|
|
407
|
-
Math.max(...toes.map((t: IJoint): number => t.position.y + t.radius)),
|
|
408
|
-
true,
|
|
409
|
-
);
|
|
410
|
-
const volume = (e: {
|
|
411
|
-
min: IAutoMovieVector3;
|
|
412
|
-
max: IAutoMovieVector3;
|
|
413
|
-
}): number =>
|
|
414
|
-
(e.max.x - e.min.x) * (e.max.y - e.min.y) * (e.max.z - e.min.z);
|
|
415
|
-
const share: number = volume(front) / (volume(front) + volume(rear));
|
|
416
|
-
box(b("Foot"), 0.0145 * (1 - share), rear.min, rear.max);
|
|
417
|
-
box(
|
|
418
|
-
b("Toes"),
|
|
419
|
-
0.0145 * share,
|
|
420
|
-
front.min,
|
|
421
|
-
front.max,
|
|
422
|
-
at(b("HalluxProximal")),
|
|
423
|
-
);
|
|
424
|
-
}
|
|
425
148
|
|
|
426
149
|
const parentOf: Partial<
|
|
427
150
|
Record<AutoMovieHumanoidBone, AutoMovieHumanoidBone>
|
|
@@ -430,21 +153,15 @@ export namespace AutoMovieHumanCanonicalProfile {
|
|
|
430
153
|
chest: "spine",
|
|
431
154
|
neck: "chest",
|
|
432
155
|
head: "neck",
|
|
433
|
-
leftUpperArm: "chest",
|
|
434
|
-
rightUpperArm: "chest",
|
|
435
|
-
leftLowerArm: "leftUpperArm",
|
|
436
|
-
rightLowerArm: "rightUpperArm",
|
|
437
|
-
leftHand: "leftLowerArm",
|
|
438
|
-
rightHand: "rightLowerArm",
|
|
439
|
-
leftUpperLeg: "hips",
|
|
440
|
-
rightUpperLeg: "hips",
|
|
441
|
-
leftLowerLeg: "leftUpperLeg",
|
|
442
|
-
rightLowerLeg: "rightUpperLeg",
|
|
443
|
-
leftFoot: "leftLowerLeg",
|
|
444
|
-
rightFoot: "rightLowerLeg",
|
|
445
|
-
leftToes: "leftFoot",
|
|
446
|
-
rightToes: "rightFoot",
|
|
447
156
|
};
|
|
157
|
+
// Each group of rig bones shares one Dempster share by collider volume.
|
|
158
|
+
const groups: { share: number; bones: AutoMovieHumanoidBone[] }[] = [
|
|
159
|
+
{ share: 0.142, bones: ["hips"] },
|
|
160
|
+
{ share: 0.139, bones: ["spine"] },
|
|
161
|
+
{ share: 0.216, bones: ["chest"] },
|
|
162
|
+
{ share: 0.081 - 0.0694, bones: ["neck"] },
|
|
163
|
+
{ share: 0.0694, bones: ["head"] },
|
|
164
|
+
];
|
|
448
165
|
const hands: AutoMovieHumanoidBone[][] = [];
|
|
449
166
|
for (const side of ["left", "right"] as const) {
|
|
450
167
|
const b = (name: string): AutoMovieHumanoidBone =>
|
|
@@ -452,11 +169,77 @@ export namespace AutoMovieHumanCanonicalProfile {
|
|
|
452
169
|
const hand: AutoMovieHumanoidBone[] = [b("Hand")];
|
|
453
170
|
for (const chain of DIGITS)
|
|
454
171
|
chain.forEach((name: string, i: number): void => {
|
|
172
|
+
const joint: IJoint = j(b(name));
|
|
173
|
+
const next: string | undefined = chain[i + 1];
|
|
174
|
+
capsule(
|
|
175
|
+
b(name),
|
|
176
|
+
joint.position,
|
|
177
|
+
next === undefined ? (joint.tip ?? joint.position) : at(b(next)),
|
|
178
|
+
joint.radius,
|
|
179
|
+
next === undefined && joint.tip !== null,
|
|
180
|
+
);
|
|
455
181
|
parentOf[b(name)] = i === 0 ? b("Hand") : b(chain[i - 1]!);
|
|
456
182
|
hand.push(b(name));
|
|
457
183
|
});
|
|
458
184
|
hands.push(hand);
|
|
185
|
+
parentOf[b("UpperArm")] = "chest";
|
|
186
|
+
parentOf[b("LowerArm")] = b("UpperArm");
|
|
187
|
+
parentOf[b("Hand")] = b("LowerArm");
|
|
188
|
+
parentOf[b("UpperLeg")] = "hips";
|
|
189
|
+
parentOf[b("LowerLeg")] = b("UpperLeg");
|
|
190
|
+
parentOf[b("Foot")] = b("LowerLeg");
|
|
191
|
+
parentOf[b("Toes")] = b("Foot");
|
|
192
|
+
groups.push(
|
|
193
|
+
{ share: 0.028, bones: [b("UpperArm")] },
|
|
194
|
+
{ share: 0.016, bones: [b("LowerArm")] },
|
|
195
|
+
{ share: 0.006, bones: hand },
|
|
196
|
+
{ share: 0.1, bones: [b("UpperLeg")] },
|
|
197
|
+
{ share: 0.0465, bones: [b("LowerLeg")] },
|
|
198
|
+
{ share: 0.0145, bones: [b("Foot"), b("Toes")] },
|
|
199
|
+
);
|
|
459
200
|
}
|
|
201
|
+
|
|
202
|
+
const segments: P.ISegment[] = [];
|
|
203
|
+
for (const group of groups) {
|
|
204
|
+
const members: IPart[][] = group.bones.map(
|
|
205
|
+
(bone: AutoMovieHumanoidBone): IPart[] => {
|
|
206
|
+
const found: IPart[] | undefined = parts.get(bone);
|
|
207
|
+
if (found === undefined)
|
|
208
|
+
throw new Error(`The polygon profile has no collider on ${bone}`);
|
|
209
|
+
return found;
|
|
210
|
+
},
|
|
211
|
+
);
|
|
212
|
+
const density: number =
|
|
213
|
+
(group.share * mass) /
|
|
214
|
+
members
|
|
215
|
+
.flat()
|
|
216
|
+
.reduce((sum: number, part: IPart): number => sum + part.volume, 0);
|
|
217
|
+
group.bones.forEach(
|
|
218
|
+
(bone: AutoMovieHumanoidBone, index: number): void => {
|
|
219
|
+
const whole: combinePhysicalMassProperties.IPart =
|
|
220
|
+
combinePhysicalMassProperties(
|
|
221
|
+
members[index]!.map(
|
|
222
|
+
(part: IPart): combinePhysicalMassProperties.IPart => ({
|
|
223
|
+
mass: density * part.volume,
|
|
224
|
+
centerOfMass: part.shape.transform.position,
|
|
225
|
+
inertia: Vector3.scale(part.inertia, density * part.volume),
|
|
226
|
+
inertiaRotation: part.inertiaRotation,
|
|
227
|
+
}),
|
|
228
|
+
),
|
|
229
|
+
);
|
|
230
|
+
segments.push({
|
|
231
|
+
bone,
|
|
232
|
+
neutral: { position: origin(bone), rotation: identity },
|
|
233
|
+
mass: whole.mass,
|
|
234
|
+
centerOfMass: whole.centerOfMass,
|
|
235
|
+
inertia: whole.inertia,
|
|
236
|
+
inertiaRotation: whole.inertiaRotation,
|
|
237
|
+
shapes: members[index]!.map((part: IPart): P.IShape => part.shape),
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
460
243
|
const children = (bone: AutoMovieHumanoidBone): AutoMovieHumanoidBone[] =>
|
|
461
244
|
(Object.keys(parentOf) as AutoMovieHumanoidBone[]).filter(
|
|
462
245
|
(c: AutoMovieHumanoidBone): boolean => parentOf[c] === bone,
|
|
@@ -467,9 +250,6 @@ export namespace AutoMovieHumanCanonicalProfile {
|
|
|
467
250
|
(sum: number, c: AutoMovieHumanoidBone): number => sum + downstream(c),
|
|
468
251
|
0,
|
|
469
252
|
);
|
|
470
|
-
const origin = (bone: AutoMovieHumanoidBone): IAutoMovieVector3 =>
|
|
471
|
-
segments.find((s: P.ISegment): boolean => s.bone === bone)!.neutral
|
|
472
|
-
.position;
|
|
473
253
|
const links: P.IJoint[] = (
|
|
474
254
|
Object.keys(parentOf) as AutoMovieHumanoidBone[]
|
|
475
255
|
).map((child: AutoMovieHumanoidBone): P.IJoint => {
|
|
@@ -545,11 +325,26 @@ export namespace AutoMovieHumanCanonicalProfile {
|
|
|
545
325
|
},
|
|
546
326
|
],
|
|
547
327
|
provenance:
|
|
548
|
-
"Polygon-man contact profile: drawn
|
|
328
|
+
"Polygon-man contact profile: convex hulls of the drawn ring points with capsule phalanges, Dempster segment masses (Winter table 4.1), uniform-solid collider inertia.",
|
|
549
329
|
};
|
|
550
330
|
}
|
|
551
331
|
}
|
|
552
332
|
|
|
333
|
+
/** One collider of a segment with the uniform solid's properties about its own centre. */
|
|
334
|
+
interface IPart {
|
|
335
|
+
/** The collider, its transform in the segment's frame. */
|
|
336
|
+
shape: P.IShape;
|
|
337
|
+
|
|
338
|
+
/** Volume, cubic metres. */
|
|
339
|
+
volume: number;
|
|
340
|
+
|
|
341
|
+
/** Principal moments per unit mass, square metres. */
|
|
342
|
+
inertia: IAutoMovieVector3;
|
|
343
|
+
|
|
344
|
+
/** Rotation from the principal frame to the segment's frame. */
|
|
345
|
+
inertiaRotation: IAutoMovieQuaternion;
|
|
346
|
+
}
|
|
347
|
+
|
|
553
348
|
/** The four fingers, by rig name. */
|
|
554
349
|
const FINGERS: readonly string[] = ["Index", "Middle", "Ring", "Little"];
|
|
555
350
|
|