@margoengine/rigging 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 +1443 -2
- package/dist/anatomy-data-ansur2.d.ts +63 -0
- package/dist/anatomy-data-cdc.d.ts +16 -0
- package/dist/anatomy-data-deleva.d.ts +86 -0
- package/dist/anatomy-human.d.ts +67 -0
- package/dist/anatomy-human.js +2229 -0
- package/dist/anatomy.d.ts +638 -0
- package/dist/anatomy.js +1112 -0
- package/dist/autorig.d.ts +50 -0
- package/dist/autorig.js +663 -0
- package/dist/bar-grip.d.ts +7 -0
- package/dist/body-volumes-DTym0RVY.js +56 -0
- package/dist/body-volumes.d.ts +19 -0
- package/dist/checks.d.ts +50 -0
- package/dist/contact.d.ts +186 -0
- package/dist/contact.js +746 -0
- package/dist/correctives.d.ts +92 -0
- package/dist/correctives.js +162 -0
- package/dist/coupling.d.ts +57 -0
- package/dist/coupling.js +330 -0
- package/dist/errors-D8rc8kzg.js +7 -0
- package/dist/face.d.ts +93 -0
- package/dist/face.js +144 -0
- package/dist/hands.d.ts +209 -0
- package/dist/hands.js +510 -0
- package/dist/heat.d.ts +38 -0
- package/dist/hinged-contact.d.ts +7 -0
- package/dist/hulls.d.ts +54 -0
- package/dist/hulls.js +134 -0
- package/dist/ik.d.ts +162 -0
- package/dist/ik.js +561 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +390 -0
- package/dist/joint-limits.d.ts +44 -0
- package/dist/joint-limits.js +74 -0
- package/dist/limb-collision.d.ts +99 -0
- package/dist/loading-CZaYr1N7.js +67 -0
- package/dist/mesh-CyvLHNp0.js +142 -0
- package/dist/mesh.d.ts +47 -0
- package/dist/mtoon-data.d.ts +118 -0
- package/dist/mtoon-legacy.d.ts +17 -0
- package/dist/mtoon-shader.d.ts +4 -0
- package/dist/mtoon.d.ts +84 -0
- package/dist/mtoon.js +990 -0
- package/dist/paint.d.ts +82 -0
- package/dist/pose-tracking.d.ts +117 -0
- package/dist/pose-tracking.js +488 -0
- package/dist/retarget.d.ts +78 -0
- package/dist/retarget.js +375 -0
- package/dist/rig-BawZ5OLb.js +127 -0
- package/dist/rig.d.ts +65 -0
- package/dist/shared/gltf.d.ts +257 -0
- package/dist/shared/layers.d.ts +16 -0
- package/dist/springs.d.ts +180 -0
- package/dist/springs.js +458 -0
- package/dist/strand-springs.d.ts +46 -0
- package/dist/strand-springs.js +168 -0
- package/dist/swim.d.ts +55 -0
- package/dist/swim.js +167 -0
- package/dist/transfer.d.ts +41 -0
- package/dist/transfer.js +136 -0
- package/dist/validate.d.ts +188 -0
- package/dist/validate.js +440 -0
- package/dist/voxel-weights-48ok-Dax.js +255 -0
- package/dist/voxel-weights.d.ts +42 -0
- package/dist/voxel-weights.js +1 -0
- package/dist/voxels.d.ts +36 -0
- package/dist/vrm-constraints.d.ts +60 -0
- package/dist/vrm-constraints.js +261 -0
- package/dist/vrm-first-person.d.ts +115 -0
- package/dist/vrm-first-person.js +618 -0
- package/dist/vrm-presets-CU4V4yq6.js +47 -0
- package/dist/vrm-presets.d.ts +1 -0
- package/dist/vrm.d.ts +303 -0
- package/dist/vrm.js +574 -0
- package/dist/vrm0.d.ts +134 -0
- package/dist/vrm0.js +377 -0
- package/dist/vrma.d.ts +90 -0
- package/dist/vrma.js +315 -0
- package/dist/weight-map-D8cAONQQ.js +92 -0
- package/dist/weight-map.d.ts +58 -0
- package/package.json +189 -4
package/dist/springs.js
ADDED
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import { MargoError as e } from "@margoengine/math/errors";
|
|
2
|
+
import { multiplyQuaternions as t, normalizeQuaternion as n, rotateByQuaternion as r, rotationToQuaternion as i } from "@margoengine/math/quat";
|
|
3
|
+
//#region src/springs.ts
|
|
4
|
+
var a = (e) => e, o = 60, s = 8, c = 256, l = [
|
|
5
|
+
0,
|
|
6
|
+
0,
|
|
7
|
+
0,
|
|
8
|
+
1
|
|
9
|
+
], u = (e) => [
|
|
10
|
+
-e[0],
|
|
11
|
+
-e[1],
|
|
12
|
+
-e[2],
|
|
13
|
+
e[3]
|
|
14
|
+
], d = (e, t) => [
|
|
15
|
+
e[0] * t[0] + e[4] * t[1] + e[8] * t[2] + e[12],
|
|
16
|
+
e[1] * t[0] + e[5] * t[1] + e[9] * t[2] + e[13],
|
|
17
|
+
e[2] * t[0] + e[6] * t[1] + e[10] * t[2] + e[14]
|
|
18
|
+
];
|
|
19
|
+
function f(e, t) {
|
|
20
|
+
let n = e;
|
|
21
|
+
if (!n || n.length !== 3 || !Number.isFinite(n[0]) || !Number.isFinite(n[1]) || !Number.isFinite(n[2])) throw RangeError(`${t} must be three finite numbers`);
|
|
22
|
+
}
|
|
23
|
+
function p(t) {
|
|
24
|
+
let n = Math.hypot(t[0], t[1], t[2]), r = Math.hypot(t[4], t[5], t[6]), i = Math.hypot(t[8], t[9], t[10]);
|
|
25
|
+
if (!(t[0] * (t[5] * t[10] - t[6] * t[9]) - t[4] * (t[1] * t[10] - t[2] * t[9]) + t[8] * (t[1] * t[6] - t[2] * t[5]) > 0)) throw new e("state", "Spring bones need positive scales; remove zero or mirrored scales");
|
|
26
|
+
return [
|
|
27
|
+
n,
|
|
28
|
+
r,
|
|
29
|
+
i
|
|
30
|
+
];
|
|
31
|
+
}
|
|
32
|
+
function m(e) {
|
|
33
|
+
let [t, n, r] = p(e);
|
|
34
|
+
return (t + n + r) / 3;
|
|
35
|
+
}
|
|
36
|
+
function h(e) {
|
|
37
|
+
let [t, r, a] = p(e);
|
|
38
|
+
return n(i(e, [
|
|
39
|
+
0,
|
|
40
|
+
0,
|
|
41
|
+
0,
|
|
42
|
+
0
|
|
43
|
+
], t, r, a));
|
|
44
|
+
}
|
|
45
|
+
function g(e, t) {
|
|
46
|
+
let r = e[0] * t[0] + e[1] * t[1] + e[2] * t[2];
|
|
47
|
+
if (r < -1 + 1e-10) {
|
|
48
|
+
let t = +(Math.abs(e[0]) < .9), r = 1 - t;
|
|
49
|
+
return n([
|
|
50
|
+
-e[2] * r,
|
|
51
|
+
e[2] * t,
|
|
52
|
+
e[0] * r - e[1] * t,
|
|
53
|
+
0
|
|
54
|
+
]);
|
|
55
|
+
}
|
|
56
|
+
return n([
|
|
57
|
+
e[1] * t[2] - e[2] * t[1],
|
|
58
|
+
e[2] * t[0] - e[0] * t[2],
|
|
59
|
+
e[0] * t[1] - e[1] * t[0],
|
|
60
|
+
1 + r
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
function _(e, t) {
|
|
64
|
+
if (t >= 1) return e;
|
|
65
|
+
let r = e[3] < 0 ? -1 : 1;
|
|
66
|
+
return n([
|
|
67
|
+
e[0] * r * t,
|
|
68
|
+
e[1] * r * t,
|
|
69
|
+
e[2] * r * t,
|
|
70
|
+
1 - t + e[3] * r * t
|
|
71
|
+
]);
|
|
72
|
+
}
|
|
73
|
+
var v = class {
|
|
74
|
+
constructor(e, t) {
|
|
75
|
+
if (this.parents = e, this.options = t, this.world = null, !Array.isArray(e) || e.some((t, n) => !Number.isInteger(t) || t < -1 || t >= e.length || t === n)) throw TypeError("SpringBones needs an array of parent indices, -1 at the top");
|
|
76
|
+
let n = t?.chains ?? [], r = /* @__PURE__ */ new Set(), i = (t, n) => {
|
|
77
|
+
if (!Number.isInteger(t) || t < 0 || t >= e.length) throw RangeError(`${n} ${String(t)} is not a bone of this skeleton; use a bone index`);
|
|
78
|
+
}, a = (t) => {
|
|
79
|
+
let n = 0;
|
|
80
|
+
for (; e[t] !== -1; t = e[t]) if (++n > e.length) throw RangeError("SpringBones parents form a cycle; every bone must reach -1");
|
|
81
|
+
return n;
|
|
82
|
+
}, s = (t, n) => {
|
|
83
|
+
for (let r = e[t]; r !== -1; r = e[r]) if (r === n) return !0;
|
|
84
|
+
return !1;
|
|
85
|
+
};
|
|
86
|
+
e.forEach((e, t) => a(t));
|
|
87
|
+
for (let e of n) {
|
|
88
|
+
let t = e?.joints;
|
|
89
|
+
if (!Array.isArray(t) || t.length < 1 || t.length > c) throw RangeError(`A spring chain needs 1 to ${c} joints`);
|
|
90
|
+
if (t.length === 1 && !e.tail) throw RangeError("A one-joint spring chain needs a tail: the local end point that gives it a direction");
|
|
91
|
+
if (t.forEach((e, n) => {
|
|
92
|
+
if (i(e, "Spring joint"), r.has(e)) throw RangeError(`Bone ${e} is in two spring chains; a joint can have only one`);
|
|
93
|
+
if (r.add(e), n && !s(e, t[n - 1])) throw TypeError(`Spring joint ${e} must descend from the joint before it; list them root to tip`);
|
|
94
|
+
}), e.center !== void 0 && e.center !== null && (i(e.center, "Spring center"), e.center !== t[0] && !s(t[0], e.center))) throw RangeError("Spring center must be the chain's first joint or an ancestor of it");
|
|
95
|
+
}
|
|
96
|
+
let l = [...n].sort((e, t) => a(e.joints[0]) - a(t.joints[0]));
|
|
97
|
+
this.chains = l.map((t, n) => {
|
|
98
|
+
let r = t.tail ? t.joints : t.joints.slice(0, -1), i = new Set(t.joints), a = (t) => {
|
|
99
|
+
for (let n = e[t]; n !== -1; n = e[n]) if (i.has(n)) return !0;
|
|
100
|
+
return !1;
|
|
101
|
+
}, s = r.length + 1;
|
|
102
|
+
return {
|
|
103
|
+
spec: t,
|
|
104
|
+
heads: r,
|
|
105
|
+
flush: l.slice(n + 1).some((e) => a(e.joints[0])),
|
|
106
|
+
points: new Float64Array(s * 3),
|
|
107
|
+
before: new Float64Array(s * 3),
|
|
108
|
+
tails: new Float64Array(r.length * 3),
|
|
109
|
+
last: new Float64Array(r.length * 3),
|
|
110
|
+
links: new Float64Array(r.length * 6),
|
|
111
|
+
step: 1 / o,
|
|
112
|
+
started: !1
|
|
113
|
+
};
|
|
114
|
+
}), this.jiggles = (t?.jiggles ?? []).map((e) => (i(e?.joint, "Jiggle joint"), {
|
|
115
|
+
spec: e,
|
|
116
|
+
position: /* @__PURE__ */ new Float64Array(3),
|
|
117
|
+
speed: /* @__PURE__ */ new Float64Array(3),
|
|
118
|
+
target: /* @__PURE__ */ new Float64Array(3),
|
|
119
|
+
started: !1
|
|
120
|
+
}));
|
|
121
|
+
for (let e of t?.colliders ?? []) e?.node !== void 0 && e?.node !== null && i(e.node, "Spring collider node");
|
|
122
|
+
this.settings();
|
|
123
|
+
}
|
|
124
|
+
bones() {
|
|
125
|
+
return [.../* @__PURE__ */ new Set([...this.chains.flatMap((e) => e.heads), ...this.jiggles.map((e) => e.spec.joint)])];
|
|
126
|
+
}
|
|
127
|
+
reset() {
|
|
128
|
+
for (let e of this.chains) e.started = !1;
|
|
129
|
+
for (let e of this.jiggles) e.started = !1;
|
|
130
|
+
}
|
|
131
|
+
settings() {
|
|
132
|
+
let { weight: e = 1, force: t = null, teleportSpeed: n = 100, colliders: r = [] } = this.options ?? {};
|
|
133
|
+
if (!(e >= 0 && e <= 1)) throw RangeError("Spring weight must be from 0 to 1");
|
|
134
|
+
if (!(n > 0)) throw RangeError("Spring teleportSpeed must be above 0");
|
|
135
|
+
t !== null && f(t, "Spring force");
|
|
136
|
+
for (let e of r) {
|
|
137
|
+
if (!(e?.radius > 0 && e.radius < Infinity)) throw RangeError("A spring collider radius must be finite and above 0");
|
|
138
|
+
e.offset !== void 0 && f(e.offset, "Spring collider offset"), e.tail !== void 0 && e.tail !== null && f(e.tail, "Spring collider tail");
|
|
139
|
+
}
|
|
140
|
+
for (let e of this.chains) {
|
|
141
|
+
let t = e.spec;
|
|
142
|
+
t.tail && f(t.tail, "Spring chain tail");
|
|
143
|
+
for (let e of t.colliders ?? []) if (!Number.isInteger(e) || e < 0 || e >= r.length) throw RangeError(`Spring chain collider ${e} is not in options.colliders; use an index into it`);
|
|
144
|
+
e.heads.forEach((n, r) => {
|
|
145
|
+
let i = t.settings?.[r], a = i?.stiffness ?? t.stiffness ?? 1, o = i?.drag ?? t.drag ?? .5, s = i?.gravity ?? t.gravity ?? 0, c = i?.gravityDirection ?? t.gravityDirection ?? [
|
|
146
|
+
0,
|
|
147
|
+
-1,
|
|
148
|
+
0
|
|
149
|
+
], l = i?.radius ?? t.radius ?? 0;
|
|
150
|
+
if (!(a >= 0 && a < Infinity)) throw RangeError("Spring stiffness must be 0 or more");
|
|
151
|
+
if (!(o >= 0 && o <= 1)) throw RangeError("Spring drag must be from 0 to 1");
|
|
152
|
+
if (!Number.isFinite(s)) throw RangeError("Spring gravity must be finite");
|
|
153
|
+
if (!(l >= 0 && l < Infinity)) throw RangeError("Spring radius must be 0 or more");
|
|
154
|
+
f(c, "Spring gravityDirection");
|
|
155
|
+
let u = Math.hypot(c[0], c[1], c[2]);
|
|
156
|
+
if (!(u > 0) && s !== 0) throw RangeError("Spring gravityDirection must not be zero");
|
|
157
|
+
let d = u > 0 ? s / u : 0;
|
|
158
|
+
e.links.set([
|
|
159
|
+
a,
|
|
160
|
+
1 - o,
|
|
161
|
+
c[0] * d,
|
|
162
|
+
c[1] * d,
|
|
163
|
+
c[2] * d,
|
|
164
|
+
l
|
|
165
|
+
], r * 6);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
for (let { spec: e } of this.jiggles) {
|
|
169
|
+
let { frequency: t = 4, damping: n = .35, limit: r = .05, amount: i = 1 } = e;
|
|
170
|
+
if (!(t > 0 && t <= 15)) throw RangeError("Jiggle frequency must be above 0 and at most 15");
|
|
171
|
+
if (!(n > 0 && n < Infinity)) throw RangeError("Jiggle damping must be above 0");
|
|
172
|
+
if (!(r >= 0 && r < Infinity)) throw RangeError("Jiggle limit must be 0 or more");
|
|
173
|
+
if (!(i >= 0 && i <= 1)) throw RangeError("Jiggle amount must be from 0 to 1");
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
weight: e,
|
|
177
|
+
force: t,
|
|
178
|
+
teleport: n
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
step(e, t) {
|
|
182
|
+
if (!(e >= 0 && e < Infinity)) throw RangeError("Spring delta must be a finite time of 0 or more");
|
|
183
|
+
let n = this.settings(), r = Math.min(s, Math.ceil(e * o - 1e-9)), i = r ? Math.min(e / r, 1 / o) : 0;
|
|
184
|
+
for (let a of this.chains) this.solveChain(a, e, r, i, n, t), a.flush && t.flush();
|
|
185
|
+
if (this.chains.length && t.flush(), this.jiggles.length) {
|
|
186
|
+
for (let a of this.jiggles) this.solveJiggle(a, e, r, i, n, t);
|
|
187
|
+
t.flush();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
solveChain(e, i, a, s, c, f) {
|
|
191
|
+
let { spec: p, heads: v, points: y, before: b, tails: x, last: S, links: C } = e, w = v.length, T = p.center ?? null, E = T === null ? null : f.world(T), D = E ? m(E) : 1, O = E ? h(E) : l, k = u(O), A = (e) => E ? r([
|
|
192
|
+
e[0] - E[12],
|
|
193
|
+
e[1] - E[13],
|
|
194
|
+
e[2] - E[14]
|
|
195
|
+
], k).map((e) => e / D) : e, j = v.map((e) => f.world(e)), M = j.map(h), N = m(j[0]) / D;
|
|
196
|
+
for (let e = 0; e < w; e++) {
|
|
197
|
+
let t = j[e];
|
|
198
|
+
y.set(A([
|
|
199
|
+
t[12],
|
|
200
|
+
t[13],
|
|
201
|
+
t[14]
|
|
202
|
+
]), e * 3);
|
|
203
|
+
}
|
|
204
|
+
let P = f.world(p.joints[p.joints.length - 1]);
|
|
205
|
+
y.set(A(p.tail ? d(P, p.tail) : [
|
|
206
|
+
P[12],
|
|
207
|
+
P[13],
|
|
208
|
+
P[14]
|
|
209
|
+
]), w * 3);
|
|
210
|
+
let F = Math.hypot(y[0] - b[0], y[1] - b[1], y[2] - b[2]);
|
|
211
|
+
if (!e.started || i > 0 && F / i > c.teleport * N) {
|
|
212
|
+
b.set(y);
|
|
213
|
+
for (let e = 0; e < w; e++) for (let t = 0; t < 3; t++) x[e * 3 + t] = S[e * 3 + t] = y[e * 3 + 3 + t];
|
|
214
|
+
e.step = 1 / o, e.started = !0;
|
|
215
|
+
}
|
|
216
|
+
let I = this.options.colliders ?? [], L = (p.colliders ?? I.map((e, t) => t)).map((e) => {
|
|
217
|
+
let t = I[e], n = t.node === void 0 || t.node === null ? null : f.world(t.node), r = t.offset ?? [
|
|
218
|
+
0,
|
|
219
|
+
0,
|
|
220
|
+
0
|
|
221
|
+
];
|
|
222
|
+
return {
|
|
223
|
+
a: A(n ? d(n, r) : r),
|
|
224
|
+
b: t.tail ? A(n ? d(n, t.tail) : t.tail) : null,
|
|
225
|
+
radius: t.radius * (n ? m(n) : 1) / D
|
|
226
|
+
};
|
|
227
|
+
}), R = [
|
|
228
|
+
0,
|
|
229
|
+
0,
|
|
230
|
+
0
|
|
231
|
+
], z = c.force;
|
|
232
|
+
for (let i = 1; i <= a; i++) {
|
|
233
|
+
let c = i / a, u = s / e.step, d = o * s, f = s * s * o * N, p = l;
|
|
234
|
+
for (let e = 0; e < w; e++) {
|
|
235
|
+
let i = e * 3, a = e * 6, o = e ? x[i - 3] : b[0] + (y[0] - b[0]) * c, s = e ? x[i - 2] : b[1] + (y[1] - b[1]) * c, l = e ? x[i - 1] : b[2] + (y[2] - b[2]) * c, m = b[i + 3] - b[i] + (y[i + 3] - y[i] - b[i + 3] + b[i]) * c, h = b[i + 4] - b[i + 1] + (y[i + 4] - y[i + 1] - b[i + 4] + b[i + 1]) * c, _ = b[i + 5] - b[i + 2] + (y[i + 5] - y[i + 2] - b[i + 5] + b[i + 2]) * c, v = Math.hypot(m, h, _), w = Math.hypot(y[i + 3] - y[i], y[i + 4] - y[i + 1], y[i + 5] - y[i + 2]);
|
|
236
|
+
if (!(w > 0) || !(v > 0)) {
|
|
237
|
+
S[i] = x[i] = o, S[i + 1] = x[i + 1] = s, S[i + 2] = x[i + 2] = l;
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
let T = r([
|
|
241
|
+
m / v,
|
|
242
|
+
h / v,
|
|
243
|
+
_ / v
|
|
244
|
+
], p), D = C[a + 1] ** d, O = C[a];
|
|
245
|
+
R[0] = C[a + 2] + (z ? z[0] : 0), R[1] = C[a + 3] + (z ? z[1] : 0), R[2] = C[a + 4] + (z ? z[2] : 0);
|
|
246
|
+
let A = E ? r(R, k) : R, j = x[i] + (x[i] - S[i]) * u * D + f * (T[0] * O + A[0]), M = x[i + 1] + (x[i + 1] - S[i + 1]) * u * D + f * (T[1] * O + A[1]), P = x[i + 2] + (x[i + 2] - S[i + 2]) * u * D + f * (T[2] * O + A[2]), F = () => {
|
|
247
|
+
let e = j - o, t = M - s, n = P - l, r = Math.hypot(e, t, n);
|
|
248
|
+
j = r > 0 ? o + e / r * w : o + T[0] * w, M = r > 0 ? s + t / r * w : s + T[1] * w, P = r > 0 ? l + n / r * w : l + T[2] * w;
|
|
249
|
+
};
|
|
250
|
+
F();
|
|
251
|
+
let I = C[a + 5] * N;
|
|
252
|
+
for (let { a: e, b: t, radius: n } of L) {
|
|
253
|
+
let r = j - e[0], i = M - e[1], a = P - e[2];
|
|
254
|
+
if (t) {
|
|
255
|
+
let n = t[0] - e[0], o = t[1] - e[1], s = t[2] - e[2], c = n * n + o * o + s * s, l = c > 0 ? Math.min(1, Math.max(0, (r * n + i * o + a * s) / c)) : 0;
|
|
256
|
+
r -= n * l, i -= o * l, a -= s * l;
|
|
257
|
+
}
|
|
258
|
+
let o = Math.hypot(r, i, a), s = n + I - o;
|
|
259
|
+
s <= 0 || (j += o > 0 ? r / o * s : T[0] * s, M += o > 0 ? i / o * s : T[1] * s, P += o > 0 ? a / o * s : T[2] * s, F());
|
|
260
|
+
}
|
|
261
|
+
S[i] = x[i], S[i + 1] = x[i + 1], S[i + 2] = x[i + 2], x[i] = j, x[i + 1] = M, x[i + 2] = P;
|
|
262
|
+
let B = j - o, V = M - s, H = P - l, U = Math.hypot(B, V, H);
|
|
263
|
+
U > 0 && (p = n(t(g(T, [
|
|
264
|
+
B / U,
|
|
265
|
+
V / U,
|
|
266
|
+
H / U
|
|
267
|
+
]), p)));
|
|
268
|
+
}
|
|
269
|
+
e.step = s;
|
|
270
|
+
}
|
|
271
|
+
a && b.set(y);
|
|
272
|
+
let B = l, V = l;
|
|
273
|
+
for (let e = 0; e < w; e++) {
|
|
274
|
+
let i = e * 3, a = e ? x[i - 3] : y[0], o = e ? x[i - 2] : y[1], s = e ? x[i - 1] : y[2], d = y[i + 3] - y[i], p = y[i + 4] - y[i + 1], m = y[i + 5] - y[i + 2], b = Math.hypot(d, p, m), S = x[i] - a, C = x[i + 1] - o, w = x[i + 2] - s, T = Math.hypot(S, C, w);
|
|
275
|
+
if (b > 0 && T > 0) {
|
|
276
|
+
let e = r([
|
|
277
|
+
d / b,
|
|
278
|
+
p / b,
|
|
279
|
+
m / b
|
|
280
|
+
], B);
|
|
281
|
+
B = n(t(g(e, [
|
|
282
|
+
S / T,
|
|
283
|
+
C / T,
|
|
284
|
+
w / T
|
|
285
|
+
]), B));
|
|
286
|
+
}
|
|
287
|
+
let D = _(E ? t(t(O, B), k) : B, c.weight), A = f.parentWorld(v[e]), j = A ? h(A) : l, N = t(u(V), D);
|
|
288
|
+
f.rotate(v[e], n(t(u(j), t(N, M[e])))), V = D;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
solveJiggle(e, t, n, i, a, o) {
|
|
292
|
+
let { spec: s, position: c, speed: l, target: d } = e, f = o.world(s.joint), p = m(f), { frequency: g = 4, damping: _ = .35, limit: v = .05, amount: y = 1 } = s, b = 2 * Math.PI * g, S = v * p, C = [
|
|
293
|
+
f[12],
|
|
294
|
+
f[13],
|
|
295
|
+
f[14]
|
|
296
|
+
], w = Math.hypot(C[0] - d[0], C[1] - d[1], C[2] - d[2]);
|
|
297
|
+
(!e.started || t > 0 && w / t > a.teleport * p) && (c.set(C), d.set(C), l.fill(0), e.started = !0);
|
|
298
|
+
for (let e = 1; e <= n; e++) {
|
|
299
|
+
let r = e / n, a = [
|
|
300
|
+
0,
|
|
301
|
+
0,
|
|
302
|
+
0
|
|
303
|
+
], o = [
|
|
304
|
+
0,
|
|
305
|
+
0,
|
|
306
|
+
0
|
|
307
|
+
];
|
|
308
|
+
for (let e = 0; e < 3; e++) {
|
|
309
|
+
let n = d[e] + (C[e] - d[e]) * r;
|
|
310
|
+
o[e] = (C[e] - d[e]) / t;
|
|
311
|
+
let [s, u] = x(c[e] - (n - o[e] * i), l[e] - o[e], b, _, i);
|
|
312
|
+
c[e] = n + s, l[e] = o[e] + u, a[e] = c[e] - n;
|
|
313
|
+
}
|
|
314
|
+
let s = Math.hypot(a[0], a[1], a[2]);
|
|
315
|
+
if (s > S) {
|
|
316
|
+
let e = 0;
|
|
317
|
+
for (let t = 0; t < 3; t++) e += (l[t] - o[t]) * a[t] / s, c[t] += a[t] / s * S - a[t];
|
|
318
|
+
if (e > 0) for (let t = 0; t < 3; t++) l[t] -= e * a[t] / s;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
n && d.set(C);
|
|
322
|
+
let T = y * a.weight, E = o.parentWorld(s.joint), D = [
|
|
323
|
+
(c[0] - C[0]) * T,
|
|
324
|
+
(c[1] - C[1]) * T,
|
|
325
|
+
(c[2] - C[2]) * T
|
|
326
|
+
];
|
|
327
|
+
if (!E) {
|
|
328
|
+
o.move(s.joint, D);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
let O = m(E);
|
|
332
|
+
o.move(s.joint, r(D, u(h(E))).map((e) => e / O));
|
|
333
|
+
}
|
|
334
|
+
stepPose(e, t, r) {
|
|
335
|
+
let { parents: i, local: a } = e ?? {}, o = this.parents.length;
|
|
336
|
+
if (i !== this.parents && (i?.length !== o || i.some((e, t) => e !== this.parents[t]))) throw TypeError("stepPose needs the parents this SpringBones was made with");
|
|
337
|
+
if (a?.length !== o * 10) throw RangeError("stepPose needs 10 numbers per bone in pose.local");
|
|
338
|
+
let s = this.world ??= new Float64Array(o * 16), c = new Uint8Array(o), l = (e) => {
|
|
339
|
+
if (c[e]) return;
|
|
340
|
+
let t = this.parents[e];
|
|
341
|
+
t !== -1 && l(t), c[e] = 1;
|
|
342
|
+
let i = e * 10, [o, u, d, f] = n([
|
|
343
|
+
a[i + 3],
|
|
344
|
+
a[i + 4],
|
|
345
|
+
a[i + 5],
|
|
346
|
+
a[i + 6]
|
|
347
|
+
]), p = a[i + 7], m = a[i + 8], h = a[i + 9], g = [
|
|
348
|
+
[
|
|
349
|
+
(1 - 2 * (u * u + d * d)) * p,
|
|
350
|
+
2 * (o * u + d * f) * p,
|
|
351
|
+
2 * (o * d - u * f) * p
|
|
352
|
+
],
|
|
353
|
+
[
|
|
354
|
+
2 * (o * u - d * f) * m,
|
|
355
|
+
(1 - 2 * (o * o + d * d)) * m,
|
|
356
|
+
2 * (u * d + o * f) * m
|
|
357
|
+
],
|
|
358
|
+
[
|
|
359
|
+
2 * (o * d + u * f) * h,
|
|
360
|
+
2 * (u * d - o * f) * h,
|
|
361
|
+
(1 - 2 * (o * o + u * u)) * h
|
|
362
|
+
],
|
|
363
|
+
[
|
|
364
|
+
a[i],
|
|
365
|
+
a[i + 1],
|
|
366
|
+
a[i + 2]
|
|
367
|
+
]
|
|
368
|
+
], _ = t === -1 ? r : s.subarray(t * 16, t * 16 + 16);
|
|
369
|
+
g.forEach((t, n) => {
|
|
370
|
+
for (let r = 0; r < 3; r++) s[e * 16 + n * 4 + r] = _ ? _[r] * t[0] + _[4 + r] * t[1] + _[8 + r] * t[2] + (n === 3 ? _[12 + r] : 0) : t[r];
|
|
371
|
+
s[e * 16 + n * 4 + 3] = +(n === 3);
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
this.step(t, {
|
|
375
|
+
world: (e) => (l(e), s.subarray(e * 16, e * 16 + 16)),
|
|
376
|
+
parentWorld: (e) => {
|
|
377
|
+
let t = this.parents[e];
|
|
378
|
+
return t === -1 ? r ?? null : (l(t), s.subarray(t * 16, t * 16 + 16));
|
|
379
|
+
},
|
|
380
|
+
rotate: (e, t) => {
|
|
381
|
+
for (let n = 0; n < 4; n++) a[e * 10 + 3 + n] = t[n];
|
|
382
|
+
},
|
|
383
|
+
move: (e, t) => {
|
|
384
|
+
for (let n = 0; n < 3; n++) a[e * 10 + n] += t[n];
|
|
385
|
+
},
|
|
386
|
+
flush: () => c.fill(0)
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
stepSkeleton(e, t, n) {
|
|
390
|
+
if (typeof e?.getPose != "function" || typeof e.setPose != "function") throw TypeError("stepSkeleton needs a Skeleton from @margoengine/animation");
|
|
391
|
+
let r = this.parents.length, i = new Float64Array(r * 10);
|
|
392
|
+
for (let t = 0; t < r; t++) {
|
|
393
|
+
let { translation: n, rotation: r, scale: a } = e.getPose(t);
|
|
394
|
+
i.set(n, t * 10), i.set(r, t * 10 + 3), i.set(a, t * 10 + 7);
|
|
395
|
+
}
|
|
396
|
+
this.stepPose({
|
|
397
|
+
parents: this.parents,
|
|
398
|
+
local: i
|
|
399
|
+
}, t, n);
|
|
400
|
+
for (let t of this.bones()) e.setPose(t, {
|
|
401
|
+
translation: [
|
|
402
|
+
i[t * 10],
|
|
403
|
+
i[t * 10 + 1],
|
|
404
|
+
i[t * 10 + 2]
|
|
405
|
+
],
|
|
406
|
+
rotation: [
|
|
407
|
+
i[t * 10 + 3],
|
|
408
|
+
i[t * 10 + 4],
|
|
409
|
+
i[t * 10 + 5],
|
|
410
|
+
i[t * 10 + 6]
|
|
411
|
+
]
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
function y(e, t) {
|
|
416
|
+
let n = e.nodes.map(a), r = a(e.root).engine, i = r.store, o = i.transforms;
|
|
417
|
+
return {
|
|
418
|
+
world: (e) => n[e].matrix,
|
|
419
|
+
parentWorld: (e) => {
|
|
420
|
+
let t = i.parents[n[e].id];
|
|
421
|
+
return t === -1 ? null : r.meshes.get(t).matrix;
|
|
422
|
+
},
|
|
423
|
+
rotate: t ?? ((e, t) => n[e].setQuaternion(t)),
|
|
424
|
+
move: (e, t) => {
|
|
425
|
+
let r = n[e].id;
|
|
426
|
+
n[e].setPosition([
|
|
427
|
+
o.x[r] + t[0],
|
|
428
|
+
o.y[r] + t[1],
|
|
429
|
+
o.z[r] + t[2]
|
|
430
|
+
]);
|
|
431
|
+
},
|
|
432
|
+
flush: () => i.tick(!1)
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
function b(e, t) {
|
|
436
|
+
let n = e.animation.model, { nodes: r } = n, i = n.root.engine.store.parents, a = new Map(r.map((e, t) => [e.id, t])), o = new v(r.map((e) => a.get(i[e.id]) ?? -1), t), s = y(n, (t, n) => e.writeNodeRotation(r[t], n)), c = e.addSolver((e) => o.step(e, s)), l = () => {
|
|
437
|
+
c?.(), c = null;
|
|
438
|
+
};
|
|
439
|
+
return {
|
|
440
|
+
springs: o,
|
|
441
|
+
reset: () => o.reset(),
|
|
442
|
+
dispose: l,
|
|
443
|
+
[Symbol.dispose]: l
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
function x(e, t, n, r, i) {
|
|
447
|
+
let a = r * n, o = n * n * (1 - r * r), s, c;
|
|
448
|
+
if (o > 0) {
|
|
449
|
+
let e = Math.sqrt(o), t = Math.exp(-a * i), n = e * i;
|
|
450
|
+
s = t * Math.cos(n), c = t * (n > 1e-6 ? Math.sin(n) / e : i);
|
|
451
|
+
} else {
|
|
452
|
+
let e = Math.sqrt(-o), t = Math.exp((e - a) * i), n = Math.exp(-(e + a) * i);
|
|
453
|
+
s = (t + n) / 2, c = e * i > 1e-6 ? (t - n) / (2 * e) : Math.exp(-a * i) * i;
|
|
454
|
+
}
|
|
455
|
+
return [e * s + (t + a * e) * c, t * s - (n * n * e + a * t) * c];
|
|
456
|
+
}
|
|
457
|
+
//#endregion
|
|
458
|
+
export { v as SpringBones, b as addSpringBones, y as springAccess };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// @ts-ignore optional peer: its types apply when it is installed
|
|
2
|
+
import type { Animator } from '@margoengine/animator';
|
|
3
|
+
import type { Vec3 } from '@margoengine/math';
|
|
4
|
+
import type { StrandParams, StrandSolver, StrandSpec } from '@margoengine/physics/strands';
|
|
5
|
+
import type { PhysicsWorld } from '@margoengine/physics/world';
|
|
6
|
+
import { type SpringAccess, type SpringCollider } from './springs.js';
|
|
7
|
+
/** A weighted bone chain driven by an SI fibre guide. */
|
|
8
|
+
export interface StrandSpringChain extends Omit<StrandSpec, 'points'> {
|
|
9
|
+
/** Ordered glTF node indices, each an ancestor of the next. Each node belongs to one chain. */
|
|
10
|
+
readonly joints: readonly number[];
|
|
11
|
+
/** A virtual tip in the last joint's local metres. Supply this for a single-joint accessory. */
|
|
12
|
+
readonly tip?: Vec3;
|
|
13
|
+
}
|
|
14
|
+
/** Physics settings and the skin's guide chains. */
|
|
15
|
+
export interface StrandSpringRigOptions extends Omit<StrandParams, 'strands' | 'rate' | 'colliders'> {
|
|
16
|
+
readonly chains: readonly StrandSpringChain[];
|
|
17
|
+
/** Shared body capsules or spheres. Node-space shapes follow their attachment bone. */
|
|
18
|
+
readonly colliders?: readonly SpringCollider[];
|
|
19
|
+
readonly signal?: AbortSignal;
|
|
20
|
+
}
|
|
21
|
+
/** An active physical spring-bone attachment on an Animator. */
|
|
22
|
+
export interface StrandSpringAttachment {
|
|
23
|
+
readonly rig: StrandSpringRig;
|
|
24
|
+
dispose(): void;
|
|
25
|
+
[Symbol.dispose](): void;
|
|
26
|
+
}
|
|
27
|
+
/** Native physical spring bones on any {@link SpringAccess}, advanced at 240 frames per second. */
|
|
28
|
+
export declare class StrandSpringRig {
|
|
29
|
+
readonly world: PhysicsWorld;
|
|
30
|
+
readonly solver: StrandSolver;
|
|
31
|
+
private readonly access;
|
|
32
|
+
private readonly joints;
|
|
33
|
+
private readonly frameToBone;
|
|
34
|
+
private readonly initial;
|
|
35
|
+
private constructor();
|
|
36
|
+
/** Reads the current weighted rest rig and binds its joints to physical guides. */
|
|
37
|
+
static load(access: SpringAccess, options: StrandSpringRigOptions): Promise<StrandSpringRig>;
|
|
38
|
+
/** Advance to a whole 240 Hz frame and apply the solved pose. Supply animation inputs before advancing. */
|
|
39
|
+
advance(frame: number): this;
|
|
40
|
+
/** Restore the initial state and replay. Time-sampled anchors and wind reproduce the original inputs. */
|
|
41
|
+
seek(frame: number): this;
|
|
42
|
+
/** Apply the current solved pose after restoring a caller-owned world snapshot. */
|
|
43
|
+
apply(): void;
|
|
44
|
+
}
|
|
45
|
+
/** Attach native strand spring bones after an Animator's pose and foot placement. */
|
|
46
|
+
export declare function addStrandSpringRig(animator: Animator, options: StrandSpringRigOptions): Promise<StrandSpringAttachment>;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { springAccess as e } from "./springs.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
|
+
import { hypot as s } from "@margoengine/math/pinned";
|
|
5
|
+
//#region src/strand-springs.ts
|
|
6
|
+
var c = {
|
|
7
|
+
position: [
|
|
8
|
+
0,
|
|
9
|
+
0,
|
|
10
|
+
0
|
|
11
|
+
],
|
|
12
|
+
rotation: [
|
|
13
|
+
0,
|
|
14
|
+
0,
|
|
15
|
+
0,
|
|
16
|
+
1
|
|
17
|
+
],
|
|
18
|
+
scale: 1
|
|
19
|
+
}, l = 240, u = 16 / 8388608, d = (e, t) => [
|
|
20
|
+
e[0] - t[0],
|
|
21
|
+
e[1] - t[1],
|
|
22
|
+
e[2] - t[2]
|
|
23
|
+
], f = (e, t) => [
|
|
24
|
+
e[0] + t[0],
|
|
25
|
+
e[1] + t[1],
|
|
26
|
+
e[2] + t[2]
|
|
27
|
+
], p = (e, t) => [
|
|
28
|
+
e[0] * t,
|
|
29
|
+
e[1] * t,
|
|
30
|
+
e[2] * t
|
|
31
|
+
];
|
|
32
|
+
function m(e) {
|
|
33
|
+
if (!e) return c;
|
|
34
|
+
let n = [
|
|
35
|
+
e[0],
|
|
36
|
+
e[1],
|
|
37
|
+
e[2]
|
|
38
|
+
], r = [
|
|
39
|
+
e[4],
|
|
40
|
+
e[5],
|
|
41
|
+
e[6]
|
|
42
|
+
], a = [
|
|
43
|
+
e[8],
|
|
44
|
+
e[9],
|
|
45
|
+
e[10]
|
|
46
|
+
], l = s(...n), d = s(...r), f = s(...a), p = l * u, m = (e, t) => e[0] * t[0] + e[1] * t[1] + e[2] * t[2], h = m(n, [
|
|
47
|
+
r[1] * a[2] - r[2] * a[1],
|
|
48
|
+
r[2] * a[0] - r[0] * a[2],
|
|
49
|
+
r[0] * a[1] - r[1] * a[0]
|
|
50
|
+
]);
|
|
51
|
+
if (!(h > 0 && Number.isFinite(h) && Math.abs(l - d) <= p && Math.abs(l - f) <= p && Math.abs(m(n, r)) <= p * l && Math.abs(m(n, a)) <= p * l && Math.abs(m(r, a)) <= p * l)) throw new t("state", "Physical strand bones need uniformly scaled rigid transforms. Apply the skin and ancestor scales before binding.");
|
|
52
|
+
return {
|
|
53
|
+
position: [
|
|
54
|
+
e[12],
|
|
55
|
+
e[13],
|
|
56
|
+
e[14]
|
|
57
|
+
],
|
|
58
|
+
rotation: i(o(e, [
|
|
59
|
+
0,
|
|
60
|
+
0,
|
|
61
|
+
0,
|
|
62
|
+
0
|
|
63
|
+
], l, d, f)),
|
|
64
|
+
scale: l
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function h(e, t) {
|
|
68
|
+
return f(e.position, a(p(t, e.scale), e.rotation));
|
|
69
|
+
}
|
|
70
|
+
function g(e, t) {
|
|
71
|
+
return p(a(t, n(e.rotation)), 1 / e.scale);
|
|
72
|
+
}
|
|
73
|
+
var _ = class e {
|
|
74
|
+
constructor(e, t, n, r, i, a) {
|
|
75
|
+
this.world = e, this.solver = t, this.access = n, this.joints = r, this.frameToBone = i, this.initial = a;
|
|
76
|
+
}
|
|
77
|
+
static async load(a, o) {
|
|
78
|
+
let { chains: s, colliders: u = [], signal: f, ...p } = o;
|
|
79
|
+
f?.throwIfAborted();
|
|
80
|
+
let [{ StrandSolver: _ }, { PhysicsWorld: v }] = await Promise.all([import("@margoengine/physics/strands"), import("@margoengine/physics/world")]), y = await _.load({ signal: f }), b = new v({
|
|
81
|
+
rate: {
|
|
82
|
+
num: l,
|
|
83
|
+
den: 1
|
|
84
|
+
},
|
|
85
|
+
cellSize: p.cellSize
|
|
86
|
+
});
|
|
87
|
+
a.flush();
|
|
88
|
+
let x = [], S = /* @__PURE__ */ new Set(), C = s.map((e) => {
|
|
89
|
+
let { joints: o, tip: s, anchor: c, ...l } = e;
|
|
90
|
+
if (o.length < (s ? 1 : 2)) throw new t("state", "Provide two physical strand bone indices, or give a single rooted bone a virtual tip.");
|
|
91
|
+
for (let e of o) {
|
|
92
|
+
if (!Number.isSafeInteger(e) || e < 0 || S.has(e)) throw new t("state", "Pass unique nonnegative bone indices to the physical strand rig.");
|
|
93
|
+
S.add(e);
|
|
94
|
+
}
|
|
95
|
+
let u = o[0], f = o.map((e) => m(a.world(e))), p = m(a.parentWorld(u)), _ = g(p, d(f[0].position, p.position)), v = n(p.rotation), y = f.map((e) => e.position);
|
|
96
|
+
return s && y.push(h(f.at(-1), s)), x.push(f), {
|
|
97
|
+
...l,
|
|
98
|
+
points: y,
|
|
99
|
+
anchor: c ?? (() => {
|
|
100
|
+
let e = m(a.parentWorld(u));
|
|
101
|
+
return {
|
|
102
|
+
position: h(e, _),
|
|
103
|
+
rotation: i(r(e.rotation, v))
|
|
104
|
+
};
|
|
105
|
+
})
|
|
106
|
+
};
|
|
107
|
+
}), w = u.map(({ node: e, offset: t = [
|
|
108
|
+
0,
|
|
109
|
+
0,
|
|
110
|
+
0
|
|
111
|
+
], tail: n = null, radius: r }) => () => {
|
|
112
|
+
let i = e == null ? c : m(a.world(e));
|
|
113
|
+
return {
|
|
114
|
+
start: h(i, t),
|
|
115
|
+
end: h(i, n ?? t),
|
|
116
|
+
radius: r * i.scale
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
b.add(y, {
|
|
120
|
+
...p,
|
|
121
|
+
strands: C,
|
|
122
|
+
colliders: w,
|
|
123
|
+
rate: 2
|
|
124
|
+
});
|
|
125
|
+
let T = x.map((e, t) => e.map((e, a) => i(r(n(y.sample(t, a).rotation), e.rotation))));
|
|
126
|
+
return new e(b, y, a, s.map((e) => [...e.joints]), T, b.takeSnapshot().bytes);
|
|
127
|
+
}
|
|
128
|
+
advance(e) {
|
|
129
|
+
return this.access.flush(), this.world.advance(e), this.apply(), this;
|
|
130
|
+
}
|
|
131
|
+
seek(e) {
|
|
132
|
+
return this.world.restoreSnapshot(this.initial), this.advance(e);
|
|
133
|
+
}
|
|
134
|
+
apply() {
|
|
135
|
+
let { access: e, solver: t } = this;
|
|
136
|
+
e.flush();
|
|
137
|
+
for (let [a, o] of this.joints.entries()) for (let [s, c] of o.entries()) {
|
|
138
|
+
let o = t.sample(a, s), l = m(e.parentWorld(c)), u = m(e.world(c)), f = r(o.rotation, this.frameToBone[a][s]);
|
|
139
|
+
e.move(c, g(l, d(o.position, u.position))), e.rotate(c, i(r(n(l.rotation), f))), e.flush();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
async function v(n, r) {
|
|
144
|
+
let i = n.animation.model, a = i.root.engine.store.parents;
|
|
145
|
+
for (let e of r.chains) for (let [n, r] of e.joints.entries()) {
|
|
146
|
+
let o = i.nodes[r];
|
|
147
|
+
if (!o) throw new t("state", "Pass strand joint indices from the Animator model.");
|
|
148
|
+
if (n === 0) continue;
|
|
149
|
+
let s = i.nodes[e.joints[n - 1]].id, c = a[o.id];
|
|
150
|
+
for (; c !== -1 && c !== s;) c = a[c];
|
|
151
|
+
if (c !== s) throw new t("state", "Pass each physical chain in parent-to-descendant order.");
|
|
152
|
+
}
|
|
153
|
+
for (let e of r.colliders ?? []) if (e.node != null && !i.nodes[e.node]) throw new t("state", "Pass collider node indices from the same Animator model.");
|
|
154
|
+
let o = e(i, (e, t) => n.writeNodeRotation(i.nodes[e], t)), s = await _.load(o, r), c = 0, u = n.addSolver((e) => {
|
|
155
|
+
c += e;
|
|
156
|
+
let t = c * l;
|
|
157
|
+
s.advance(Math.floor(t + 8 * 2 ** -52 * Math.max(1, t)));
|
|
158
|
+
}), d, f = () => {
|
|
159
|
+
u(), d?.(), d = void 0;
|
|
160
|
+
};
|
|
161
|
+
return d = n.onDispose(f), {
|
|
162
|
+
rig: s,
|
|
163
|
+
dispose: f,
|
|
164
|
+
[Symbol.dispose]: f
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//#endregion
|
|
168
|
+
export { _ as StrandSpringRig, v as addStrandSpringRig };
|