@margoengine/ragdoll 0.0.0-stage → 1.0.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 +430 -2
- package/dist/balance.d.ts +252 -0
- package/dist/balance.js +588 -0
- package/dist/character.d.ts +200 -0
- package/dist/character.js +325 -0
- package/dist/errors-CDwcEs-j.js +5 -0
- package/dist/errors.d.ts +3 -0
- package/dist/getup.d.ts +86 -0
- package/dist/getup.js +136 -0
- package/dist/hulls.d.ts +71 -0
- package/dist/hulls.js +176 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +998 -0
- package/dist/limits-CCe6Pdej.js +55 -0
- package/dist/limits.d.ts +12 -0
- package/dist/powered.d.ts +145 -0
- package/dist/powered.js +246 -0
- package/dist/profile.d.ts +62 -0
- package/dist/profile.js +268 -0
- package/dist/ragdoll.d.ts +292 -0
- package/package.json +84 -4
package/dist/getup.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { t as e } from "./errors-CDwcEs-j.js";
|
|
2
|
+
import { MargoError as t } from "@margoengine/math/errors";
|
|
3
|
+
import { conjugateQuaternion as n, multiplyQuaternions as r, normalizeQuaternion as i, rotateByQuaternion as a, rotationToQuaternion as o } from "@margoengine/math/quat";
|
|
4
|
+
//#region src/getup.ts
|
|
5
|
+
var s = (e) => {
|
|
6
|
+
let t = Math.hypot(e[0], e[1], e[2]), n = Math.hypot(e[4], e[5], e[6]), r = Math.hypot(e[8], e[9], e[10]);
|
|
7
|
+
return i(o(e, [
|
|
8
|
+
0,
|
|
9
|
+
0,
|
|
10
|
+
0,
|
|
11
|
+
1
|
|
12
|
+
], t, n, r));
|
|
13
|
+
}, c = (e) => 2 * Math.atan2(Math.hypot(e[0], e[1], e[2]), Math.abs(e[3]));
|
|
14
|
+
function l(e, t) {
|
|
15
|
+
let n = e[0] * t[0] + e[1] * t[1] + e[2] * t[2], r = Math.hypot(n, e[3]);
|
|
16
|
+
return r < 1e-9 ? [
|
|
17
|
+
0,
|
|
18
|
+
0,
|
|
19
|
+
0,
|
|
20
|
+
1
|
|
21
|
+
] : [
|
|
22
|
+
t[0] * n / r,
|
|
23
|
+
t[1] * n / r,
|
|
24
|
+
t[2] * n / r,
|
|
25
|
+
e[3] / r
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
var u = class {
|
|
29
|
+
constructor(t, n, r) {
|
|
30
|
+
this.ragdoll = t, this.animator = n, this.disposed = !1, this.states = {
|
|
31
|
+
faceUp: r.faceUp,
|
|
32
|
+
faceDown: r.faceDown
|
|
33
|
+
};
|
|
34
|
+
for (let t of [
|
|
35
|
+
r.faceUp,
|
|
36
|
+
r.faceDown,
|
|
37
|
+
r.then ?? n.state
|
|
38
|
+
]) if (!Object.hasOwn(n.options.states, t)) throw e(`Unknown animator state "${t}"; pass a state name from the Animator's options.`);
|
|
39
|
+
if (this.root = r.root ?? n.animation.model.root, this.then = r.then ?? n.state, this.blend = r.blend ?? .4, this.fade = r.fade ?? .2, !(this.blend >= 0) || this.blend === Infinity || !(this.fade >= 0) || this.fade === Infinity) throw e("Get-up blend and fade must be finite numbers of seconds, 0 or more.");
|
|
40
|
+
let i = r.up ?? [
|
|
41
|
+
0,
|
|
42
|
+
1,
|
|
43
|
+
0
|
|
44
|
+
], a = Math.hypot(i[0], i[1], i[2]);
|
|
45
|
+
if (!(a > 0) || a === Infinity) throw e("Get-up up must be a nonzero finite [x, y, z]; pass the world up, e.g. [0, 1, 0].");
|
|
46
|
+
this.up = [
|
|
47
|
+
i[0] / a,
|
|
48
|
+
i[1] / a,
|
|
49
|
+
i[2] / a
|
|
50
|
+
], this.first = {
|
|
51
|
+
faceUp: this.sample("faceUp"),
|
|
52
|
+
faceDown: this.sample("faceDown")
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
sample(e) {
|
|
56
|
+
let { animator: t } = this, i = t.state, o = t.time, c = t.entryTime, l = this.ragdoll.bones[0].node, u = l.engine.store;
|
|
57
|
+
t.cancelFade(), t.transition(this.states[e], 0), t.onPreUpdate(0), u.tick(!1);
|
|
58
|
+
let d = this.root.matrix, f = l.matrix, p = n(s(d)), m = {
|
|
59
|
+
rotation: r(p, s(f)),
|
|
60
|
+
position: a([
|
|
61
|
+
f[12] - d[12],
|
|
62
|
+
f[13] - d[13],
|
|
63
|
+
f[14] - d[14]
|
|
64
|
+
], p)
|
|
65
|
+
};
|
|
66
|
+
return t.transition(i, 0), t.enterAt(c), t.time = o, t.onPreUpdate(0), u.tick(!1), m;
|
|
67
|
+
}
|
|
68
|
+
fit(e) {
|
|
69
|
+
let t = this.ragdoll.bones[0].body.rotation, i = r(s(this.root.matrix), this.first[e].rotation), a = l(r(t, n(i)), this.up);
|
|
70
|
+
return {
|
|
71
|
+
turn: a,
|
|
72
|
+
mismatch: c(r(n(t), r(a, i)))
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
mismatch(e) {
|
|
76
|
+
return this.live(), this.fit(e).mismatch;
|
|
77
|
+
}
|
|
78
|
+
pick() {
|
|
79
|
+
return this.live(), this.fit("faceUp").mismatch <= this.fit("faceDown").mismatch ? "faceUp" : "faceDown";
|
|
80
|
+
}
|
|
81
|
+
start(e = {}) {
|
|
82
|
+
if (this.live(), !this.ragdoll.active) throw new t("state", "The ragdoll is not limp, so there is nothing to get up from; call activate first.");
|
|
83
|
+
if (this.watching) throw new t("state", "A get-up is already running; wait for its promise.");
|
|
84
|
+
e.signal?.throwIfAborted();
|
|
85
|
+
let n = e.side ?? this.pick(), { turn: i, mismatch: o } = this.fit(n), { animator: c, ragdoll: l, root: u } = this, d = l.bones[0], f = u.engine.store, p = d.body.position, m = u.matrix, h = [
|
|
86
|
+
m[12],
|
|
87
|
+
m[13],
|
|
88
|
+
m[14]
|
|
89
|
+
], g = this.first[n].position, _ = r(i, s(m)), v = a(g, _), y = this.up.map((e) => -e), b = l.physics.raycast(p, y, {
|
|
90
|
+
maxDistance: 100,
|
|
91
|
+
excludeDynamic: !0,
|
|
92
|
+
excludeKinematic: !0
|
|
93
|
+
}), x = (e) => e[0] * this.up[0] + e[1] * this.up[1] + e[2] * this.up[2], S = x(b ? b.point : h), C = [
|
|
94
|
+
0,
|
|
95
|
+
1,
|
|
96
|
+
2
|
|
97
|
+
].map((e) => p[e] - v[e]), w = S - x(C);
|
|
98
|
+
return u.setQuaternion(_), u.setPosition([
|
|
99
|
+
C[0] + this.up[0] * w,
|
|
100
|
+
C[1] + this.up[1] * w,
|
|
101
|
+
C[2] + this.up[2] * w
|
|
102
|
+
]), f.tick(!1), c.cancelFade(), c.transition(this.states[n], 0), l.deactivate(this.blend), new Promise((t, r) => {
|
|
103
|
+
let i = () => {
|
|
104
|
+
this.watching?.(), this.watching = void 0, e.signal?.removeEventListener("abort", a);
|
|
105
|
+
}, a = () => {
|
|
106
|
+
i(), r(e.signal.reason);
|
|
107
|
+
};
|
|
108
|
+
e.signal?.addEventListener("abort", a, { once: !0 });
|
|
109
|
+
let s = c.addLateStep(() => {
|
|
110
|
+
c.state === this.states[n] ? c.normalizedTime >= 1 && (c.transition(this.then, this.fade), i(), t({
|
|
111
|
+
side: n,
|
|
112
|
+
mismatch: o
|
|
113
|
+
})) : (i(), t({
|
|
114
|
+
side: n,
|
|
115
|
+
mismatch: o
|
|
116
|
+
}));
|
|
117
|
+
});
|
|
118
|
+
this.watching = s;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
live() {
|
|
122
|
+
if (this.disposed) throw new t("disposed", "This get-up is disposed; call addGetUp again.");
|
|
123
|
+
}
|
|
124
|
+
dispose() {
|
|
125
|
+
this.disposed = !0, this.watching?.(), this.watching = void 0;
|
|
126
|
+
}
|
|
127
|
+
[Symbol.dispose ?? Symbol()]() {
|
|
128
|
+
this.dispose();
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
function d(t, n, r) {
|
|
132
|
+
if (!t?.bones || typeof n?.transition != "function" || !r) throw e("addGetUp needs a Ragdoll, an Animator and options: addGetUp(ragdoll, animator, {faceUp, faceDown}).");
|
|
133
|
+
return new u(t, n, r);
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
export { u as GetUp, d as addGetUp };
|
package/dist/hulls.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Mesh } from '@margoengine/core/extension';
|
|
2
|
+
import type { Ragdoll, RagdollPart, RagdollShape } from './ragdoll.js';
|
|
3
|
+
/** A skinned mesh in its bind pose, for {@link fitRagdollShapes}. */
|
|
4
|
+
export interface RagdollSkin {
|
|
5
|
+
/** Bind-pose vertex positions, xyz per vertex. */
|
|
6
|
+
positions: ArrayLike<number>;
|
|
7
|
+
/** Skin joint indices, `influences` per vertex: indices into `nodes`. */
|
|
8
|
+
joints: Uint16Array;
|
|
9
|
+
/** Skin weights, one per entry of `joints`. */
|
|
10
|
+
weights: Float32Array;
|
|
11
|
+
/** Slots per vertex. Default 4. */
|
|
12
|
+
influences?: number;
|
|
13
|
+
/** The skin's joint nodes, in skin order. */
|
|
14
|
+
nodes: readonly Mesh[];
|
|
15
|
+
/** Inverse bind matrices, 16 numbers per entry of `nodes`, column-major. */
|
|
16
|
+
inverseBindMatrices: ArrayLike<number>;
|
|
17
|
+
}
|
|
18
|
+
/** What {@link fitRagdollShapes} reads of a glTF model (a `PBRModel`). */
|
|
19
|
+
export interface SkinnedModel {
|
|
20
|
+
readonly nodes: readonly Mesh[];
|
|
21
|
+
readonly primitives: readonly {
|
|
22
|
+
readonly nodeIndex: number;
|
|
23
|
+
readonly definition: {
|
|
24
|
+
readonly attributes?: Record<string, unknown>;
|
|
25
|
+
};
|
|
26
|
+
}[];
|
|
27
|
+
readonly asset: {
|
|
28
|
+
readonly doc: {
|
|
29
|
+
readonly nodes?: readonly {
|
|
30
|
+
readonly skin?: number;
|
|
31
|
+
}[];
|
|
32
|
+
readonly skins?: readonly {
|
|
33
|
+
readonly joints: readonly number[];
|
|
34
|
+
readonly inverseBindMatrices?: unknown;
|
|
35
|
+
}[];
|
|
36
|
+
};
|
|
37
|
+
accessor(id: unknown, type?: string): Float32Array;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Options of {@link fitRagdollShapes}. */
|
|
41
|
+
export interface RagdollFitOptions {
|
|
42
|
+
/** `'hull'`, a convex hull of the bone's vertices, or `'box'`, the smallest box around them that lies along the bone. Default `'hull'`. */
|
|
43
|
+
shape?: 'hull' | 'box';
|
|
44
|
+
/** A vertex counts toward a bone when the bone carries at least this share of it. Default 0.5. */
|
|
45
|
+
minWeight?: number;
|
|
46
|
+
/** Most corners a hull keeps, 8 to 1,024. Default 64. */
|
|
47
|
+
maxPoints?: number;
|
|
48
|
+
}
|
|
49
|
+
/** One bone that got a new shape. */
|
|
50
|
+
export interface RagdollFit {
|
|
51
|
+
/** The bone. */
|
|
52
|
+
part: RagdollPart;
|
|
53
|
+
/** Its shape now, in its own frame. */
|
|
54
|
+
shape: RagdollShape;
|
|
55
|
+
/** Vertices that counted toward it. */
|
|
56
|
+
vertexCount: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Fits each bone's collider to the mesh it carries: a vertex belongs to the bone that dominates its skin weights, skin
|
|
60
|
+
* joints with no body counting toward the bone above them, and the bone's capsule gives way to the hull or the box of its
|
|
61
|
+
* vertices. A bone's mass, friction, groups and joint stay as they are; a bone with no vertices that span a volume keeps
|
|
62
|
+
* its capsule. Call it on a new ragdoll, before `addRagdollMotors`.
|
|
63
|
+
* @example
|
|
64
|
+
* const ragdoll = Ragdoll.attach(physics, { root: hips });
|
|
65
|
+
* const fitted = fitRagdollShapes(ragdoll, model); // or { shape: 'box' }
|
|
66
|
+
* console.log(`${fitted.length} of ${ragdoll.bones.length} bones fit the mesh`);
|
|
67
|
+
* @param source The glTF model the skeleton belongs to, or a skinned mesh in its bind pose.
|
|
68
|
+
* @returns The bones that got a shape.
|
|
69
|
+
* @throws TypeError without a ragdoll or a source, RangeError for a model with no skin on these bones or a bad option.
|
|
70
|
+
*/
|
|
71
|
+
export declare function fitRagdollShapes(ragdoll: Ragdoll, source: SkinnedModel | RagdollSkin, options?: RagdollFitOptions): RagdollFit[];
|
package/dist/hulls.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { t as e } from "./errors-CDwcEs-j.js";
|
|
2
|
+
import { normalizeQuaternion as t, rotateByQuaternion as n } from "@margoengine/math/quat";
|
|
3
|
+
import { jointHulls as r } from "@margoengine/rigging/hulls";
|
|
4
|
+
//#region src/hulls.ts
|
|
5
|
+
var i = [
|
|
6
|
+
1,
|
|
7
|
+
0,
|
|
8
|
+
0,
|
|
9
|
+
0,
|
|
10
|
+
0,
|
|
11
|
+
1,
|
|
12
|
+
0,
|
|
13
|
+
0,
|
|
14
|
+
0,
|
|
15
|
+
0,
|
|
16
|
+
1,
|
|
17
|
+
0,
|
|
18
|
+
0,
|
|
19
|
+
0,
|
|
20
|
+
0,
|
|
21
|
+
1
|
|
22
|
+
], a = 18;
|
|
23
|
+
function o(t, n) {
|
|
24
|
+
let { doc: r } = t.asset, a = (r.skins ?? []).findIndex((e) => e.joints.some((e) => t.nodes[e] === n));
|
|
25
|
+
if (a < 0) throw e("No skin of this model holds the ragdoll's root bone; pass the model the skeleton belongs to.");
|
|
26
|
+
let o = t.primitives.filter((e) => r.nodes?.[e.nodeIndex]?.skin === a);
|
|
27
|
+
if (!o.length) throw e("No mesh of this model uses the skin; there is nothing to fit shapes to.");
|
|
28
|
+
let { joints: s, inverseBindMatrices: c } = r.skins[a], l = o.some((e) => e.definition.attributes?.JOINTS_1 !== void 0) ? 2 : 1, u = l * 4, d = o.map((e) => t.asset.accessor(e.definition.attributes.POSITION, "VEC3")), f = d.reduce((e, t) => e + t.length / 3, 0), p = new Uint16Array(f * u), m = new Float32Array(f * u), h = new Float32Array(f * 3), g = 0;
|
|
29
|
+
o.forEach((e, n) => {
|
|
30
|
+
let r = d[n].length / 3;
|
|
31
|
+
h.set(d[n], g * 3);
|
|
32
|
+
for (let n = 0; n < l; n++) {
|
|
33
|
+
let i = e.definition.attributes, a = i["JOINTS_" + n], o = i["WEIGHTS_" + n];
|
|
34
|
+
if (a === void 0 || o === void 0) continue;
|
|
35
|
+
let s = t.asset.accessor(a, "VEC4"), c = t.asset.accessor(o, "VEC4");
|
|
36
|
+
for (let e = 0; e < r; e++) for (let t = 0; t < 4; t++) p[(g + e) * u + n * 4 + t] = s[e * 4 + t], m[(g + e) * u + n * 4 + t] = c[e * 4 + t];
|
|
37
|
+
}
|
|
38
|
+
g += r;
|
|
39
|
+
});
|
|
40
|
+
for (let e = 0; e < f; e++) {
|
|
41
|
+
let t = 0;
|
|
42
|
+
for (let n = 0; n < u; n++) t += m[e * u + n];
|
|
43
|
+
if (t > 0) for (let n = 0; n < u; n++) m[e * u + n] /= t;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
positions: h,
|
|
47
|
+
joints: p,
|
|
48
|
+
weights: m,
|
|
49
|
+
influences: u,
|
|
50
|
+
nodes: s.map((e) => t.nodes[e]),
|
|
51
|
+
inverseBindMatrices: c === void 0 ? Float32Array.from(s.flatMap(() => i)) : t.asset.accessor(c, "MAT4")
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function s(e, t) {
|
|
55
|
+
let { parents: n } = e.engine.store;
|
|
56
|
+
for (let r = e.id; r !== -1; r = n[r]) {
|
|
57
|
+
let e = t.get(r);
|
|
58
|
+
if (e !== void 0) return e;
|
|
59
|
+
}
|
|
60
|
+
return -1;
|
|
61
|
+
}
|
|
62
|
+
function c(e) {
|
|
63
|
+
return e[1] < -.999999 ? [
|
|
64
|
+
1,
|
|
65
|
+
0,
|
|
66
|
+
0,
|
|
67
|
+
0
|
|
68
|
+
] : t([
|
|
69
|
+
e[2],
|
|
70
|
+
0,
|
|
71
|
+
-e[0],
|
|
72
|
+
1 + e[1]
|
|
73
|
+
]);
|
|
74
|
+
}
|
|
75
|
+
var l = (e, t) => [
|
|
76
|
+
e[3] * t[0] + e[0] * t[3] + e[1] * t[2] - e[2] * t[1],
|
|
77
|
+
e[3] * t[1] - e[0] * t[2] + e[1] * t[3] + e[2] * t[0],
|
|
78
|
+
e[3] * t[2] + e[0] * t[1] - e[1] * t[0] + e[2] * t[3],
|
|
79
|
+
e[3] * t[3] - e[0] * t[0] - e[1] * t[1] - e[2] * t[2]
|
|
80
|
+
];
|
|
81
|
+
function u(e, t) {
|
|
82
|
+
let r = c(t), i, o = Infinity;
|
|
83
|
+
for (let t = 0; t < a; t++) {
|
|
84
|
+
let s = t / a * Math.PI / 4, c = l(r, [
|
|
85
|
+
0,
|
|
86
|
+
Math.sin(s),
|
|
87
|
+
0,
|
|
88
|
+
Math.cos(s)
|
|
89
|
+
]), u = [
|
|
90
|
+
-c[0],
|
|
91
|
+
-c[1],
|
|
92
|
+
-c[2],
|
|
93
|
+
c[3]
|
|
94
|
+
], d = [
|
|
95
|
+
Infinity,
|
|
96
|
+
Infinity,
|
|
97
|
+
Infinity
|
|
98
|
+
], f = [
|
|
99
|
+
-Infinity,
|
|
100
|
+
-Infinity,
|
|
101
|
+
-Infinity
|
|
102
|
+
];
|
|
103
|
+
for (let t = 0; t < e.length; t += 3) {
|
|
104
|
+
let r = n([
|
|
105
|
+
e[t],
|
|
106
|
+
e[t + 1],
|
|
107
|
+
e[t + 2]
|
|
108
|
+
], u);
|
|
109
|
+
for (let e = 0; e < 3; e++) d[e] = Math.min(d[e], r[e]), f[e] = Math.max(f[e], r[e]);
|
|
110
|
+
}
|
|
111
|
+
let p = (f[0] - d[0]) * (f[1] - d[1]) * (f[2] - d[2]);
|
|
112
|
+
p >= o || (o = p, i = {
|
|
113
|
+
type: "box",
|
|
114
|
+
center: n([
|
|
115
|
+
0,
|
|
116
|
+
1,
|
|
117
|
+
2
|
|
118
|
+
].map((e) => (d[e] + f[e]) / 2), c),
|
|
119
|
+
halfExtents: [
|
|
120
|
+
(f[0] - d[0]) / 2,
|
|
121
|
+
(f[1] - d[1]) / 2,
|
|
122
|
+
(f[2] - d[2]) / 2
|
|
123
|
+
],
|
|
124
|
+
rotation: c
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return i;
|
|
128
|
+
}
|
|
129
|
+
function d(t, n, a = {}) {
|
|
130
|
+
if (!t?.bones || !n) throw e("fitRagdollShapes needs a Ragdoll and a model: fitRagdollShapes(ragdoll, model).");
|
|
131
|
+
let { shape: c = "hull", minWeight: l, maxPoints: d } = a;
|
|
132
|
+
if (c !== "hull" && c !== "box") throw e("fitRagdollShapes shape must be 'hull' or 'box'.");
|
|
133
|
+
if (l !== void 0 && !(l > 0 && l <= 1)) throw e("fitRagdollShapes minWeight must be above 0 and at most 1; pass a share, e.g. 0.5.");
|
|
134
|
+
if (d !== void 0 && !(Number.isInteger(d) && d >= 8 && d <= 1024)) throw e("fitRagdollShapes maxPoints must be an integer from 8 to 1024, e.g. 64.");
|
|
135
|
+
let f = "primitives" in n ? o(n, t.bones[0].node) : n, { nodes: p, inverseBindMatrices: m } = f, h = new Map(t.bones.map((e, t) => [e.node.id, t])), g = new Map(p.flatMap((e) => h.has(e.id) ? [[e.id, h.get(e.id)]] : [])), _ = new Float32Array(t.bones.length * 16);
|
|
136
|
+
if (!g.size) throw e("The skin holds none of the ragdoll bones; pass the model the skeleton belongs to.");
|
|
137
|
+
for (let e = 0; e < t.bones.length; e++) _.set(i, e * 16);
|
|
138
|
+
p.forEach((e, t) => {
|
|
139
|
+
let n = g.get(e.id);
|
|
140
|
+
if (n !== void 0) for (let e = 0; e < 16; e++) _[n * 16 + e] = m[t * 16 + e];
|
|
141
|
+
});
|
|
142
|
+
let v = p.map((e) => s(e, g)), y = new Uint16Array(f.joints.length), b = Float32Array.from(f.weights);
|
|
143
|
+
for (let t = 0; t < y.length; t++) {
|
|
144
|
+
let n = v[f.joints[t]];
|
|
145
|
+
if (n === void 0) throw e(`Skin joint ${f.joints[t]} has no node; pass one node per joint.`);
|
|
146
|
+
n < 0 ? b[t] = 0 : y[t] = n;
|
|
147
|
+
}
|
|
148
|
+
return r({
|
|
149
|
+
positions: f.positions,
|
|
150
|
+
skin: {
|
|
151
|
+
joints: y,
|
|
152
|
+
weights: b,
|
|
153
|
+
influences: f.influences ?? 4
|
|
154
|
+
}
|
|
155
|
+
}, {
|
|
156
|
+
minWeight: l,
|
|
157
|
+
maxPoints: d,
|
|
158
|
+
inverseBindMatrices: _
|
|
159
|
+
}).map((e) => {
|
|
160
|
+
let n = t.bones[e.joint], r = n.node.matrix, i = [
|
|
161
|
+
Math.hypot(r[0], r[1], r[2]),
|
|
162
|
+
Math.hypot(r[4], r[5], r[6]),
|
|
163
|
+
Math.hypot(r[8], r[9], r[10])
|
|
164
|
+
], a = e.points.map((e, t) => e * i[t % 3]), o = c === "box" ? u(a, n.axis) : {
|
|
165
|
+
type: "hull",
|
|
166
|
+
points: a
|
|
167
|
+
};
|
|
168
|
+
return t.setShape(n, o), {
|
|
169
|
+
part: n,
|
|
170
|
+
shape: o,
|
|
171
|
+
vertexCount: e.vertexCount
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
export { d as fitRagdollShapes };
|
package/dist/index.d.ts
ADDED