three-usd-robot 0.12.0 → 0.13.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 +31 -320
- package/dist/{MeshBinding-DQKXuYNr.d.ts → MeshBinding-B_8RhuQE.d.ts} +2 -2
- package/dist/{ThreeUsdRobot-C3N6-XBJ.d.ts → ThreeUsdRobot-X1zbpRZo.d.ts} +38 -8
- package/dist/{ThreeUsdRobotLoader-D2fEo9_p.d.ts → ThreeUsdRobotLoader-u3d1yoLM.d.ts} +3 -3
- package/dist/{buildKinematicTree-iFqaw0Jl.d.ts → buildKinematicTree-Q9JOjAjM.d.ts} +17 -3
- package/dist/{chunk-CK5MTMYR.js → chunk-5ZPHZ5ZH.js} +78 -5
- package/dist/chunk-5ZPHZ5ZH.js.map +1 -0
- package/dist/{chunk-6W4LQVEQ.js → chunk-FUVHAORT.js} +67 -5
- package/dist/chunk-FUVHAORT.js.map +1 -0
- package/dist/{chunk-7GGSIA6M.js → chunk-GRJGPHLW.js} +4 -4
- package/dist/{chunk-7GGSIA6M.js.map → chunk-GRJGPHLW.js.map} +1 -1
- package/dist/{chunk-KYBHWDX5.js → chunk-JN2QPDB3.js} +100 -13
- package/dist/chunk-JN2QPDB3.js.map +1 -0
- package/dist/core.d.ts +4 -4
- package/dist/core.js +2 -2
- package/dist/extras.d.ts +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/helpers.js +1 -1
- package/dist/index.d.ts +17 -7
- package/dist/index.js +31 -7
- package/dist/index.js.map +1 -1
- package/dist/nodes.d.ts +3 -3
- package/dist/react.d.ts +4 -4
- package/dist/react.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-6W4LQVEQ.js.map +0 -1
- package/dist/chunk-CK5MTMYR.js.map +0 -1
- package/dist/chunk-KYBHWDX5.js.map +0 -1
|
@@ -21,6 +21,8 @@ var JointObject = class extends THREE4.Object3D {
|
|
|
21
21
|
axis;
|
|
22
22
|
lower;
|
|
23
23
|
upper;
|
|
24
|
+
/** Mimic constraint this joint follows, if any (see {@link JointMimicDescription}). */
|
|
25
|
+
mimic;
|
|
24
26
|
_value = 0;
|
|
25
27
|
constructor(joint) {
|
|
26
28
|
super();
|
|
@@ -32,6 +34,7 @@ var JointObject = class extends THREE4.Object3D {
|
|
|
32
34
|
this.axis = axisVector(joint.axis);
|
|
33
35
|
this.lower = joint.lower;
|
|
34
36
|
this.upper = joint.upper;
|
|
37
|
+
this.mimic = joint.mimic;
|
|
35
38
|
}
|
|
36
39
|
get value() {
|
|
37
40
|
return this._value;
|
|
@@ -88,6 +91,10 @@ var ThreeUsdRobot = class extends THREE4.Object3D {
|
|
|
88
91
|
jointObjects = /* @__PURE__ */ new Map();
|
|
89
92
|
linkKeyByPath = /* @__PURE__ */ new Map();
|
|
90
93
|
jointKeyByPath = /* @__PURE__ */ new Map();
|
|
94
|
+
/** Mimic edges among realized joints: leader key → followers. */
|
|
95
|
+
mimicFollowers = /* @__PURE__ */ new Map();
|
|
96
|
+
mimicLeaderByFollower = /* @__PURE__ */ new Map();
|
|
97
|
+
warnedMimicDrive = false;
|
|
91
98
|
dirty = true;
|
|
92
99
|
/** Constructed (fk rest) local matrix of every link, for baked→fk restore. */
|
|
93
100
|
restLocal = /* @__PURE__ */ new Map();
|
|
@@ -124,8 +131,10 @@ var ThreeUsdRobot = class extends THREE4.Object3D {
|
|
|
124
131
|
this.attachRoot();
|
|
125
132
|
this.attachTreeEdges();
|
|
126
133
|
this.attachIsolatedLinks();
|
|
134
|
+
this.registerMimicFollowers();
|
|
127
135
|
this.applyStageNormalization(robot, options);
|
|
128
136
|
if (options.applyInitialPose ?? true) this.applyInitialPose(robot);
|
|
137
|
+
this.propagateAllMimic();
|
|
129
138
|
for (const [key, obj] of this.linkObjects) this.restLocal.set(key, obj.matrix.toArray());
|
|
130
139
|
const debug = options.debugBakedTransforms;
|
|
131
140
|
this.debugBaked = debug ? {
|
|
@@ -154,6 +163,57 @@ var ThreeUsdRobot = class extends THREE4.Object3D {
|
|
|
154
163
|
}
|
|
155
164
|
this.dirty = true;
|
|
156
165
|
}
|
|
166
|
+
// -- Mimic joints ---------------------------------------------------------
|
|
167
|
+
/** Index the mimic edges realized in the tree (leader and follower both driven). */
|
|
168
|
+
registerMimicFollowers() {
|
|
169
|
+
for (const [key, joint] of Object.entries(this.robot.joints)) {
|
|
170
|
+
const mimic = joint.mimic;
|
|
171
|
+
if (!mimic || !this.jointObjects.has(key)) continue;
|
|
172
|
+
const leaderKey = this.jointKey(mimic.joint);
|
|
173
|
+
if (!this.jointObjects.has(leaderKey)) continue;
|
|
174
|
+
this.mimicLeaderByFollower.set(key, leaderKey);
|
|
175
|
+
const list = this.mimicFollowers.get(leaderKey) ?? [];
|
|
176
|
+
list.push({ key, multiplier: mimic.multiplier, offset: mimic.offset });
|
|
177
|
+
this.mimicFollowers.set(leaderKey, list);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/** Drive the followers of `leaderKey` from its current value (recursive, cycle-safe). */
|
|
181
|
+
propagateMimic(leaderKey, visited) {
|
|
182
|
+
const followers = this.mimicFollowers.get(leaderKey);
|
|
183
|
+
if (!followers) return;
|
|
184
|
+
const leaderValue = this.jointObjects.get(leaderKey)?.value;
|
|
185
|
+
if (leaderValue === void 0) return;
|
|
186
|
+
const seen = visited ?? /* @__PURE__ */ new Set([leaderKey]);
|
|
187
|
+
for (const { key, multiplier, offset } of followers) {
|
|
188
|
+
if (seen.has(key)) continue;
|
|
189
|
+
seen.add(key);
|
|
190
|
+
this.jointObjects.get(key)?.setValue(multiplier * leaderValue + offset, this.clampJointLimits);
|
|
191
|
+
this.propagateMimic(key, seen);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/** Re-derive every follower from its chain's top-most leader. */
|
|
195
|
+
propagateAllMimic() {
|
|
196
|
+
for (const leaderKey of this.mimicFollowers.keys()) {
|
|
197
|
+
if (!this.mimicLeaderByFollower.has(leaderKey)) this.propagateMimic(leaderKey);
|
|
198
|
+
}
|
|
199
|
+
if (this.mimicFollowers.size > 0) this.dirty = true;
|
|
200
|
+
}
|
|
201
|
+
/** Whether the joint (key or prim path) is a mimic follower, driven by its leader. */
|
|
202
|
+
isMimicFollower(name) {
|
|
203
|
+
return this.mimicLeaderByFollower.has(this.jointKey(name));
|
|
204
|
+
}
|
|
205
|
+
/** Keys of the mimic-follower joints (excluded from {@link getJointNames}). */
|
|
206
|
+
getMimicJointNames() {
|
|
207
|
+
return [...this.mimicLeaderByFollower.keys()];
|
|
208
|
+
}
|
|
209
|
+
warnMimicDriveOnce(key) {
|
|
210
|
+
if (this.warnedMimicDrive) return;
|
|
211
|
+
this.warnedMimicDrive = true;
|
|
212
|
+
const leader = this.mimicLeaderByFollower.get(key);
|
|
213
|
+
console.warn(
|
|
214
|
+
`three-usd-robot: "${key}" is a mimic follower of "${leader}" \u2014 its value derives from the leader; direct sets are ignored (warned once)`
|
|
215
|
+
);
|
|
216
|
+
}
|
|
157
217
|
attachRoot() {
|
|
158
218
|
const rootObj = this.linkObjects.get(this.tree.root);
|
|
159
219
|
if (!rootObj) return;
|
|
@@ -216,19 +276,28 @@ var ThreeUsdRobot = class extends THREE4.Object3D {
|
|
|
216
276
|
// -- Joint control -------------------------------------------------------
|
|
217
277
|
/**
|
|
218
278
|
* Set one joint value, addressed by key or full prim path. Unknown joints
|
|
219
|
-
* are ignored
|
|
279
|
+
* are ignored, and so are mimic followers (their value derives from the
|
|
280
|
+
* leader; a warning is logged once). Driving a leader also updates its
|
|
281
|
+
* followers. Returns whether it applied. Always restores `"fk"` display
|
|
220
282
|
* mode first (see {@link setLinkTransforms}).
|
|
221
283
|
*/
|
|
222
284
|
setJointValue(name, value) {
|
|
223
285
|
this.exitBakedMode();
|
|
224
|
-
const
|
|
286
|
+
const key = this.jointKey(name);
|
|
287
|
+
if (this.mimicLeaderByFollower.has(key)) {
|
|
288
|
+
this.warnMimicDriveOnce(key);
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
const joint = this.jointObjects.get(key);
|
|
225
292
|
if (!joint) return false;
|
|
226
293
|
joint.setValue(value, this.clampJointLimits);
|
|
294
|
+
this.propagateMimic(key);
|
|
227
295
|
this.dirty = true;
|
|
228
296
|
return true;
|
|
229
297
|
}
|
|
230
298
|
/**
|
|
231
|
-
* Set several joint values at once (matrix update is coalesced).
|
|
299
|
+
* Set several joint values at once (matrix update is coalesced). Mimic
|
|
300
|
+
* followers in the batch are skipped like in {@link setJointValue}. Always
|
|
232
301
|
* restores `"fk"` display mode first, recomputing every link purely from
|
|
233
302
|
* joint values — even an empty batch returns from baked playback (see
|
|
234
303
|
* {@link setLinkTransforms}).
|
|
@@ -236,9 +305,15 @@ var ThreeUsdRobot = class extends THREE4.Object3D {
|
|
|
236
305
|
setJointValues(values) {
|
|
237
306
|
this.exitBakedMode();
|
|
238
307
|
for (const [name, value] of Object.entries(values)) {
|
|
239
|
-
const
|
|
308
|
+
const key = this.jointKey(name);
|
|
309
|
+
if (this.mimicLeaderByFollower.has(key)) {
|
|
310
|
+
this.warnMimicDriveOnce(key);
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
const joint = this.jointObjects.get(key);
|
|
240
314
|
if (joint) {
|
|
241
315
|
joint.setValue(value, this.clampJointLimits);
|
|
316
|
+
this.propagateMimic(key);
|
|
242
317
|
this.dirty = true;
|
|
243
318
|
}
|
|
244
319
|
}
|
|
@@ -341,9 +416,11 @@ var ThreeUsdRobot = class extends THREE4.Object3D {
|
|
|
341
416
|
/**
|
|
342
417
|
* Project a link-pose batch onto the joint manifold: the closed-form 1-DOF
|
|
343
418
|
* joint values that best reproduce it, plus the same residuals as
|
|
344
|
-
* {@link validateLinkTransforms}. `values` covers the
|
|
345
|
-
*
|
|
346
|
-
*
|
|
419
|
+
* {@link validateLinkTransforms}. `values` covers the commandable
|
|
420
|
+
* articulated tree joints (mimic followers excluded — their leaders
|
|
421
|
+
* re-derive them), keyed by joint prim path, and feeds
|
|
422
|
+
* {@link setJointValues} directly — the constraint-respecting playback of
|
|
423
|
+
* the same track:
|
|
347
424
|
*
|
|
348
425
|
* ```ts
|
|
349
426
|
* robot.setJointValues(robot.jointValuesFromLinkTransforms(poses, { previous }).values);
|
|
@@ -363,6 +440,7 @@ var ThreeUsdRobot = class extends THREE4.Object3D {
|
|
|
363
440
|
}
|
|
364
441
|
residuals[joint.primPath] = this.buildResidual(joint, q, rel);
|
|
365
442
|
if (!this.jointObjects.get(key)?.articulated) continue;
|
|
443
|
+
if (this.mimicLeaderByFollower.has(key)) continue;
|
|
366
444
|
if (opts.clampLimits) {
|
|
367
445
|
if (joint.lower !== void 0 && q < joint.lower) q = joint.lower;
|
|
368
446
|
if (joint.upper !== void 0 && q > joint.upper) q = joint.upper;
|
|
@@ -582,9 +660,13 @@ var ThreeUsdRobot = class extends THREE4.Object3D {
|
|
|
582
660
|
getLinks() {
|
|
583
661
|
return Object.values(this.robot.links);
|
|
584
662
|
}
|
|
585
|
-
/**
|
|
663
|
+
/**
|
|
664
|
+
* Names of the commandable joints — articulated tree joints minus mimic
|
|
665
|
+
* followers, whose values derive from their leader
|
|
666
|
+
* (see {@link getMimicJointNames}).
|
|
667
|
+
*/
|
|
586
668
|
getJointNames() {
|
|
587
|
-
return [...this.jointObjects.keys()];
|
|
669
|
+
return [...this.jointObjects.keys()].filter((key) => !this.mimicLeaderByFollower.has(key));
|
|
588
670
|
}
|
|
589
671
|
getLinkNames() {
|
|
590
672
|
return [...this.linkObjects.keys()];
|
|
@@ -629,11 +711,16 @@ var ThreeUsdRobot = class extends THREE4.Object3D {
|
|
|
629
711
|
}
|
|
630
712
|
return null;
|
|
631
713
|
}
|
|
632
|
-
/**
|
|
714
|
+
/**
|
|
715
|
+
* Sample every animated joint at time code `t` and apply the values (an fk
|
|
716
|
+
* drive — leaves baked mode). Samples on mimic followers are ignored; the
|
|
717
|
+
* constraint re-derives them from their leader.
|
|
718
|
+
*/
|
|
633
719
|
setTime(t) {
|
|
634
720
|
this.exitBakedMode();
|
|
635
721
|
for (const [key, joint] of Object.entries(this.robot.joints)) {
|
|
636
|
-
if (joint.valueSamples
|
|
722
|
+
if (!joint.valueSamples || this.mimicLeaderByFollower.has(key)) continue;
|
|
723
|
+
this.setJointValue(key, interpolate(joint.valueSamples, t));
|
|
637
724
|
}
|
|
638
725
|
}
|
|
639
726
|
// -- Display toggles -----------------------------------------------------
|
|
@@ -697,5 +784,5 @@ function setMatrix(obj, m) {
|
|
|
697
784
|
}
|
|
698
785
|
|
|
699
786
|
export { JointObject, LinkObject, ThreeUsdRobot, axisVector };
|
|
700
|
-
//# sourceMappingURL=chunk-
|
|
701
|
-
//# sourceMappingURL=chunk-
|
|
787
|
+
//# sourceMappingURL=chunk-JN2QPDB3.js.map
|
|
788
|
+
//# sourceMappingURL=chunk-JN2QPDB3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/three/axis.ts","../src/three/JointObject.ts","../src/three/LinkObject.ts","../src/three/ThreeUsdRobot.ts"],"names":["THREE","THREE2","THREE3"],"mappings":";;;AAIO,SAAS,WAAW,IAAA,EAA2B;AACpD,EAAA,QAAQ,IAAA;AAAM,IACZ,KAAK,GAAA;AACH,MAAA,OAAO,IAAUA,MAAA,CAAA,OAAA,CAAQ,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA;AAAA,IAClC,KAAK,GAAA;AACH,MAAA,OAAO,IAAUA,MAAA,CAAA,OAAA,CAAQ,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA;AAAA,IAClC,KAAK,GAAA;AACH,MAAA,OAAO,IAAUA,MAAA,CAAA,OAAA,CAAQ,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA;AAAA;AAEtC;ACEO,IAAM,WAAA,GAAN,cAAgCC,MAAA,CAAA,QAAA,CAAS;AAAA,EACrC,aAAA,GAAgB,IAAA;AAAA,EAChB,SAAA;AAAA;AAAA,EAEA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,I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AA,GAAA,CAAI,MAAA,CAAO,UAAU,CAAC,CAAA;AACtB,EAAA,GAAA,CAAI,sBAAA,GAAyB,IAAA;AAC/B","file":"chunk-JN2QPDB3.js","sourcesContent":["import * as THREE from \"three\";\nimport type { Axis } from \"../robot/RobotDescription.js\";\n\n/** Unit vector for a USD joint axis token. Returns a fresh vector each call. */\nexport function axisVector(axis: Axis): THREE.Vector3 {\n switch (axis) {\n case \"X\":\n return new THREE.Vector3(1, 0, 0);\n case \"Y\":\n return new THREE.Vector3(0, 1, 0);\n case \"Z\":\n return new THREE.Vector3(0, 0, 1);\n }\n}\n","import * as THREE from \"three\";\nimport type {\n Axis,\n JointDescription,\n JointMimicDescription,\n JointType,\n} from \"../robot/RobotDescription.js\";\nimport { axisVector } from \"./axis.js\";\n\n/**\n * The articulated \"motion\" node of a joint, inserted between the joint's two\n * fixed frames (`jointFrame0` and `inverse(jointFrame1)`). {@link setValue}\n * rotates it about the axis (revolute/continuous) or slides it along the axis\n * (prismatic); fixed joints are inert.\n */\nexport class JointObject extends THREE.Object3D {\n readonly isJointObject = true;\n readonly jointName: string;\n /** Full USD prim path of the joint — the collision-proof address. */\n readonly primPath: string;\n readonly jointType: JointType;\n readonly axisToken: Axis;\n readonly axis: THREE.Vector3;\n readonly lower: number | undefined;\n readonly upper: number | undefined;\n /** Mimic constraint this joint follows, if any (see {@link JointMimicDescription}). */\n readonly mimic: JointMimicDescription | undefined;\n\n private _value = 0;\n\n constructor(joint: JointDescription) {\n super();\n this.name = joint.name;\n this.jointName = joint.name;\n this.primPath = joint.primPath;\n this.jointType = joint.type;\n this.axisToken = joint.axis;\n this.axis = axisVector(joint.axis);\n this.lower = joint.lower;\n this.upper = joint.upper;\n this.mimic = joint.mimic;\n }\n\n get value(): number {\n return this._value;\n }\n\n get articulated(): boolean {\n return this.jointType !== \"fixed\";\n }\n\n /**\n * Set the joint value (radians for revolute/continuous, length for prismatic).\n * Optionally clamps to authored limits. Returns the value actually applied.\n */\n setValue(value: number, clampToLimits = true): number {\n if (!this.articulated) return this._value; // fixed joint: inert\n\n let v = value;\n if (clampToLimits) {\n if (this.lower !== undefined && v < this.lower) v = this.lower;\n if (this.upper !== undefined && v > this.upper) v = this.upper;\n }\n this._value = v;\n\n if (this.jointType === \"prismatic\") {\n this.position.copy(this.axis).multiplyScalar(v);\n this.quaternion.identity();\n } else {\n this.quaternion.setFromAxisAngle(this.axis, v);\n this.position.set(0, 0, 0);\n }\n return v;\n }\n}\n","import * as THREE from \"three\";\nimport type { LinkDescription } from \"../robot/RobotDescription.js\";\n\n/**\n * Three.js node for a robot link. Its frame is the USD link prim's frame;\n * visual/collision meshes (M6) attach as children relative to it. Placement\n * relative to the parent is supplied by the joint chain, so a link's own local\n * matrix is identity (except the root, which carries the world-fixed placement).\n */\nexport class LinkObject extends THREE.Object3D {\n readonly isLinkObject = true;\n readonly linkName: string;\n readonly primPath: string;\n\n constructor(link: LinkDescription) {\n super();\n this.name = link.name;\n this.linkName = link.name;\n this.primPath = link.primPath;\n // Placement comes from the parent joint chain; keep the local matrix fixed.\n this.matrixAutoUpdate = false;\n }\n}\n","import * as THREE from \"three\";\nimport {\n type JointRelativeDecomposition,\n decomposeJointRelative,\n nearestAngleBranch,\n} from \"../kinematics/jointResiduals.js\";\nimport { interpolate } from \"../kinematics/sampling.js\";\nimport { type Mat4, identity4, invert, multiply, multiplyAll } from \"../kinematics/transforms.js\";\nimport type {\n JointDescription,\n LinkDescription,\n RobotDescription,\n} from \"../robot/RobotDescription.js\";\nimport type { KinematicTree } from \"../robot/buildKinematicTree.js\";\nimport type { Stage } from \"../usd/Stage.js\";\nimport { JointObject } from \"./JointObject.js\";\nimport { LinkObject } from \"./LinkObject.js\";\n\n/** Target world up-axis: normalize to Y-up / Z-up, or keep the authored orientation. */\nexport type WorldUpAxis = \"Y\" | \"Z\" | \"keep\";\n\nexport type ThreeUsdRobotOptions = {\n /** Clamp `setJointValue` to authored limits (default `true`). */\n clampJointLimits?: boolean;\n /** Size of the built-in joint-axis / link-frame helpers (stage units, default `0.15`). */\n helperSize?: number;\n /**\n * Target world up-axis. The root is rotated so the stage's authored `upAxis`\n * lands in that convention: `\"Y\"` for a standard three.js scene, `\"Z\"` for a\n * robotics-style Z-up world, `\"keep\"` for no correction. Takes precedence\n * over the deprecated {@link ThreeUsdRobotOptions.upAxisConversion}.\n */\n worldUp?: WorldUpAxis;\n /**\n * Legacy up-axis correction: `\"auto\"` ≡ `worldUp: \"Y\"`, `\"Y\"` / `\"none\"` ≡\n * `worldUp: \"keep\"`, and `\"Z\"` forces the Z-up→Y-up rotation regardless of\n * stage metadata. Default `\"none\"` (the loader defaults to `\"auto\"`).\n * @deprecated Use {@link ThreeUsdRobotOptions.worldUp}.\n */\n upAxisConversion?: \"auto\" | \"Y\" | \"Z\" | \"none\";\n /** Extra uniform scale multiplied with the stage `metersPerUnit` (default `1`). */\n unitScale?: number;\n /** Seed joints from their authored initial value (drive target / joint state). Default `true`. */\n applyInitialPose?: boolean;\n /**\n * Diagnose {@link ThreeUsdRobot.setLinkTransforms} poses against the joint\n * constraints and `console.warn` once per baked session when one deviates\n * beyond tolerance (default 1 mm anchor / 0.01 rad axis). `true` uses the\n * defaults; pass an object to tune them.\n */\n debugBakedTransforms?: boolean | { anchorTolerance?: number; axisTolerance?: number };\n};\n\n/**\n * A rigid world pose for {@link ThreeUsdRobot.setLinkTransforms} —\n * `quaternion` in Three.js `[x, y, z, w]` order (USD authors quatf as\n * `(w, x, y, z)`; reorder when reading recorded USD by hand).\n */\nexport type LinkPose = {\n position: [number, number, number];\n quaternion: [number, number, number, number];\n};\n\n/**\n * Coordinate space of {@link LinkPose} batches. `\"world\"` (default) is the\n * Three.js scene world *after* `worldUp` / unit normalization — with\n * `worldUp: \"Z\"` you hand in Z-up poses — including any transform on the\n * robot object itself (which must stay a similarity: uniform scale, no\n * shear). `\"stage\"` is the authored USD stage space (before up-axis rotation\n * and `metersPerUnit` scaling), as prim world transforms are written in the\n * file.\n */\nexport type LinkPoseSpace = \"world\" | \"stage\";\n\nexport type LinkPosesOptions = {\n /** Interpretation of the poses (default `\"world\"`). */\n space?: LinkPoseSpace;\n};\n\nexport type JointValuesFromLinkTransformsOptions = LinkPosesOptions & {\n /**\n * Previous joint values (keyed like the returned `values`): each\n * revolute/continuous joint picks the 2πk branch of its projection nearest\n * this, for frame-to-frame continuity past ±π.\n */\n previous?: Record<string, number>;\n /** Clamp `values` to authored limits (default `false` — deviations are reported, not hidden). */\n clampLimits?: boolean;\n};\n\n/**\n * Per-joint constraint residual of a link-pose batch, keyed by joint prim\n * path. The ideal parent→child transform of a joint is a pure motion along\n * its DOF; whatever the poses leave over splits into `anchorError` /\n * `axisError` (see {@link ThreeUsdRobot.validateLinkTransforms}).\n */\nexport type JointResidual = {\n /** Translation residual at the joint anchor, in meters (`metersPerUnit` applied). */\n anchorError: number;\n /** Rotation residual off the joint DOF, in radians. */\n axisError: number;\n /** Projected joint value (SI: radians / stage length units; `0` for fixed joints). */\n q: number;\n /** Whether `q` lies outside the authored limits. */\n limitExceeded: boolean;\n};\n\n/**\n * A Three.js `Object3D` that realizes a {@link RobotDescription} as a kinematic\n * hierarchy and drives forward kinematics via {@link setJointValue}.\n *\n * Per joint the hierarchy is\n * `parentLink → jointFrame0 → jointMotion → jointFrame1⁻¹ → childLink`,\n * where only `jointMotion` (a {@link JointObject}) changes with the joint value;\n * world poses then fall out of Three.js's `updateMatrixWorld`.\n *\n * **Naming contract** — a link/joint's key is its prim's leaf name when that\n * is unique across the robot, else its full prim path (deterministic; see the\n * extractor). Every accessor taking a name equally accepts the full prim path,\n * which is stable regardless of collisions; {@link getLinkObjectsByPath} /\n * {@link getJointObjectsByPath} enumerate the path-keyed tables.\n */\nexport class ThreeUsdRobot extends THREE.Object3D {\n readonly isThreeUsdRobot = true;\n readonly robot: RobotDescription;\n readonly tree: KinematicTree;\n readonly clampJointLimits: boolean;\n /**\n * The composed USD stage this robot was built from — the full prim tree, for\n * inspection tooling (structure panels, attribute browsers). Attached by\n * {@link ThreeUsdRobotLoader}; `undefined` for programmatically-built robots.\n */\n stage?: Stage;\n\n private readonly linkObjects = new Map<string, LinkObject>();\n private readonly jointObjects = new Map<string, JointObject>();\n private readonly linkKeyByPath = new Map<string, string>();\n private readonly jointKeyByPath = new Map<string, string>();\n /** Mimic edges among realized joints: leader key → followers. */\n private readonly mimicFollowers = new Map<\n string,\n { key: string; multiplier: number; offset: number }[]\n >();\n private readonly mimicLeaderByFollower = new Map<string, string>();\n private warnedMimicDrive = false;\n private dirty = true;\n\n /** Constructed (fk rest) local matrix of every link, for baked→fk restore. */\n private readonly restLocal = new Map<string, Mat4>();\n private _displayMode: \"fk\" | \"baked\" = \"fk\";\n /** Stage-space link worlds while baked (`null` in fk mode). */\n private bakedStageWorld: Map<string, Mat4> | null = null;\n /** Frozen `frame0 · motion · frame1⁻¹` per tree joint while baked. */\n private bakedChainRel: Map<string, Mat4> | null = null;\n private readonly debugBaked: { anchorTolerance: number; axisTolerance: number } | null;\n private bakedDebugWarned = false;\n private readonly warnedPoseKeys = new Set<string>();\n private warnedNonUniformScale = false;\n\n private readonly helperSize: number;\n private _showVisual = true;\n private _showCollision = false;\n private _showJointAxes = false;\n private _showLinkFrames = false;\n private jointAxesHelpers: THREE.AxesHelper[] = [];\n private linkFrameHelpers: THREE.AxesHelper[] = [];\n\n constructor(robot: RobotDescription, tree: KinematicTree, options: ThreeUsdRobotOptions = {}) {\n super();\n this.name = robot.name;\n this.robot = robot;\n this.tree = tree;\n this.clampJointLimits = options.clampJointLimits ?? true;\n this.helperSize = options.helperSize ?? 0.15;\n\n // Create a node for every link up front; index links and joints by path.\n for (const [key, link] of Object.entries(robot.links)) {\n this.linkObjects.set(key, new LinkObject(link));\n this.linkKeyByPath.set(link.primPath, key);\n }\n for (const [key, joint] of Object.entries(robot.joints)) {\n this.jointKeyByPath.set(joint.primPath, key);\n }\n\n this.attachRoot();\n this.attachTreeEdges();\n this.attachIsolatedLinks();\n this.registerMimicFollowers();\n this.applyStageNormalization(robot, options);\n if (options.applyInitialPose ?? true) this.applyInitialPose(robot);\n this.propagateAllMimic();\n\n for (const [key, obj] of this.linkObjects) this.restLocal.set(key, obj.matrix.toArray());\n const debug = options.debugBakedTransforms;\n this.debugBaked = debug\n ? {\n anchorTolerance: (typeof debug === \"object\" ? debug.anchorTolerance : undefined) ?? 1e-3,\n axisTolerance: (typeof debug === \"object\" ? debug.axisTolerance : undefined) ?? 0.01,\n }\n : null;\n }\n\n /** Orient (authored upAxis → target world up) and scale (metersPerUnit × unitScale) the root. */\n private applyStageNormalization(robot: RobotDescription, options: ThreeUsdRobotOptions): void {\n const scale = (robot.metersPerUnit || 1) * (options.unitScale ?? 1);\n if (scale !== 1) this.scale.setScalar(scale);\n\n const rotateX = (angle: number) =>\n this.quaternion.setFromAxisAngle(new THREE.Vector3(1, 0, 0), angle);\n\n if (options.worldUp) {\n if (options.worldUp === \"Y\" && robot.upAxis === \"Z\") rotateX(-Math.PI / 2);\n else if (options.worldUp === \"Z\" && robot.upAxis === \"Y\") rotateX(Math.PI / 2);\n return; // matching axis or \"keep\": leave as authored\n }\n const conv = options.upAxisConversion ?? \"none\";\n if (conv === \"Z\" || (conv === \"auto\" && robot.upAxis === \"Z\")) rotateX(-Math.PI / 2);\n }\n\n /** Apply each joint's authored initial value, if any. */\n private applyInitialPose(robot: RobotDescription): void {\n for (const [key, joint] of Object.entries(robot.joints)) {\n if (joint.initialValue === undefined) continue;\n this.jointObjects.get(key)?.setValue(joint.initialValue, this.clampJointLimits);\n }\n this.dirty = true;\n }\n\n // -- Mimic joints ---------------------------------------------------------\n\n /** Index the mimic edges realized in the tree (leader and follower both driven). */\n private registerMimicFollowers(): void {\n for (const [key, joint] of Object.entries(this.robot.joints)) {\n const mimic = joint.mimic;\n if (!mimic || !this.jointObjects.has(key)) continue;\n const leaderKey = this.jointKey(mimic.joint);\n // A leader outside the fk tree (loop joint) cannot drive; leave the\n // follower independently commandable.\n if (!this.jointObjects.has(leaderKey)) continue;\n this.mimicLeaderByFollower.set(key, leaderKey);\n const list = this.mimicFollowers.get(leaderKey) ?? [];\n list.push({ key, multiplier: mimic.multiplier, offset: mimic.offset });\n this.mimicFollowers.set(leaderKey, list);\n }\n }\n\n /** Drive the followers of `leaderKey` from its current value (recursive, cycle-safe). */\n private propagateMimic(leaderKey: string, visited?: Set<string>): void {\n const followers = this.mimicFollowers.get(leaderKey);\n if (!followers) return;\n const leaderValue = this.jointObjects.get(leaderKey)?.value;\n if (leaderValue === undefined) return;\n const seen = visited ?? new Set([leaderKey]);\n for (const { key, multiplier, offset } of followers) {\n if (seen.has(key)) continue; // cycle — reported by the validator\n seen.add(key);\n this.jointObjects\n .get(key)\n ?.setValue(multiplier * leaderValue + offset, this.clampJointLimits);\n this.propagateMimic(key, seen);\n }\n }\n\n /** Re-derive every follower from its chain's top-most leader. */\n private propagateAllMimic(): void {\n for (const leaderKey of this.mimicFollowers.keys()) {\n if (!this.mimicLeaderByFollower.has(leaderKey)) this.propagateMimic(leaderKey);\n }\n if (this.mimicFollowers.size > 0) this.dirty = true;\n }\n\n /** Whether the joint (key or prim path) is a mimic follower, driven by its leader. */\n isMimicFollower(name: string): boolean {\n return this.mimicLeaderByFollower.has(this.jointKey(name));\n }\n\n /** Keys of the mimic-follower joints (excluded from {@link getJointNames}). */\n getMimicJointNames(): string[] {\n return [...this.mimicLeaderByFollower.keys()];\n }\n\n private warnMimicDriveOnce(key: string): void {\n if (this.warnedMimicDrive) return;\n this.warnedMimicDrive = true;\n const leader = this.mimicLeaderByFollower.get(key);\n console.warn(\n `three-usd-robot: \"${key}\" is a mimic follower of \"${leader}\" — its value derives from the leader; direct sets are ignored (warned once)`,\n );\n }\n\n private attachRoot(): void {\n const rootObj = this.linkObjects.get(this.tree.root);\n if (!rootObj) return; // empty robot\n const rootJointKey = this.tree.rootJoint;\n const rootLink = this.robot.links[this.tree.root];\n if (rootJointKey) {\n const j = this.robot.joints[rootJointKey];\n // World-fixed placement: jointFrame0 (in world) · inverse(jointFrame1).\n if (j) setMatrix(rootObj, multiply(j.jointFrame0, invert(j.jointFrame1)));\n } else if (rootLink?.worldTransform) {\n // Floating base: keep the authored stage placement.\n setMatrix(rootObj, rootLink.worldTransform);\n }\n this.add(rootObj);\n }\n\n private attachTreeEdges(): void {\n for (const linkKey of this.tree.order) {\n const node = this.tree.nodes[linkKey];\n if (!node || node.parent === null || node.jointToParent === null) continue;\n\n const parentObj = this.linkObjects.get(node.parent);\n const childObj = this.linkObjects.get(linkKey);\n const joint = this.robot.joints[node.jointToParent];\n if (!parentObj || !childObj || !joint) continue;\n\n this.attachJointChain(parentObj, childObj, node.jointToParent, joint);\n }\n }\n\n /** Build `parent → frame0 → motion → frame1⁻¹ → child` for one joint. */\n private attachJointChain(\n parent: LinkObject,\n child: LinkObject,\n jointKey: string,\n joint: JointDescription,\n ): void {\n const frame0 = new THREE.Group();\n frame0.name = `${joint.name}:frame0`;\n setMatrix(frame0, joint.jointFrame0);\n\n const motion = new JointObject(joint);\n\n const frame1Inv = new THREE.Group();\n frame1Inv.name = `${joint.name}:frame1Inv`;\n setMatrix(frame1Inv, invert(joint.jointFrame1));\n\n parent.add(frame0);\n frame0.add(motion);\n motion.add(frame1Inv);\n frame1Inv.add(child);\n\n this.jointObjects.set(jointKey, motion);\n }\n\n private attachIsolatedLinks(): void {\n for (const key of this.tree.isolatedLinks) {\n const obj = this.linkObjects.get(key);\n if (!obj || obj.parent) continue;\n // Not placeable by any joint chain — keep the authored stage placement\n // (other machines / free bodies on a multi-articulation stage).\n const worldTransform = this.robot.links[key]?.worldTransform;\n if (worldTransform) setMatrix(obj, worldTransform);\n this.add(obj);\n }\n }\n\n // -- Naming --------------------------------------------------------------\n\n /** Resolve a link reference — key or full prim path — to the extractor key. */\n private linkKey(ref: string): string {\n if (this.linkObjects.has(ref)) return ref;\n return this.linkKeyByPath.get(ref) ?? ref;\n }\n\n /** Resolve a joint reference — key or full prim path — to the extractor key. */\n private jointKey(ref: string): string {\n if (this.jointObjects.has(ref)) return ref;\n return this.jointKeyByPath.get(ref) ?? ref;\n }\n\n // -- Joint control -------------------------------------------------------\n\n /**\n * Set one joint value, addressed by key or full prim path. Unknown joints\n * are ignored, and so are mimic followers (their value derives from the\n * leader; a warning is logged once). Driving a leader also updates its\n * followers. Returns whether it applied. Always restores `\"fk\"` display\n * mode first (see {@link setLinkTransforms}).\n */\n setJointValue(name: string, value: number): boolean {\n this.exitBakedMode();\n const key = this.jointKey(name);\n if (this.mimicLeaderByFollower.has(key)) {\n this.warnMimicDriveOnce(key);\n return false;\n }\n const joint = this.jointObjects.get(key);\n if (!joint) return false;\n joint.setValue(value, this.clampJointLimits);\n this.propagateMimic(key);\n this.dirty = true;\n return true;\n }\n\n /**\n * Set several joint values at once (matrix update is coalesced). Mimic\n * followers in the batch are skipped like in {@link setJointValue}. Always\n * restores `\"fk\"` display mode first, recomputing every link purely from\n * joint values — even an empty batch returns from baked playback (see\n * {@link setLinkTransforms}).\n */\n setJointValues(values: Record<string, number>): void {\n this.exitBakedMode();\n for (const [name, value] of Object.entries(values)) {\n const key = this.jointKey(name);\n if (this.mimicLeaderByFollower.has(key)) {\n this.warnMimicDriveOnce(key);\n continue;\n }\n const joint = this.jointObjects.get(key);\n if (joint) {\n joint.setValue(value, this.clampJointLimits);\n this.propagateMimic(key);\n this.dirty = true;\n }\n }\n }\n\n getJointValue(name: string): number | undefined {\n return this.jointObjects.get(this.jointKey(name))?.value;\n }\n\n /** Recompute world matrices. Called lazily by the getters; safe to call directly. */\n updateKinematics(): void {\n this.updateMatrixWorld(true);\n this.dirty = false;\n }\n\n private ensureUpdated(): void {\n if (this.dirty) this.updateKinematics();\n }\n\n // -- Baked link transforms (M23) -----------------------------------------\n\n /**\n * `\"fk\"` (default): link placements derive from joint values. `\"baked\"`:\n * {@link setLinkTransforms} wrote link poses directly and the joints no\n * longer constrain the display; any `setJointValue`-family call restores fk.\n */\n get displayMode(): \"fk\" | \"baked\" {\n return this._displayMode;\n }\n\n /**\n * Drive link world poses directly — the display path for baked recordings\n * (Isaac Sim body-transform time samples, maximal-coordinate playback).\n * usdview-like semantics: constraint deviations are shown, never corrected —\n * {@link validateLinkTransforms} measures them,\n * {@link jointValuesFromLinkTransforms} projects onto the joints instead.\n *\n * Enters `\"baked\"` display mode; joint values stay untouched. Return to fk\n * with {@link setJointValues} (any batch, even `{}`), which recomputes\n * every link purely from joint values.\n *\n * Keys are link keys or full prim paths; unknown keys warn once and are\n * skipped. Unspecified links KEEP their current world pose — a track that\n * omits a link means \"it did not move\". Poses are rigid, `quaternion` in\n * `[x, y, z, w]` order, interpreted per `opts.space` (default `\"world\"`:\n * the Three.js scene world after `worldUp` normalization — pair a Z-up\n * meter track with `worldUp: \"Z\"`). Matrix updates are coalesced into the\n * next render / world query. Returns the number of poses applied.\n */\n setLinkTransforms(poses: Record<string, LinkPose>, opts: LinkPosesOptions = {}): number {\n const targets = this.resolvePoseTargets(poses, opts.space ?? \"world\");\n if (this._displayMode !== \"baked\") this.enterBakedMode();\n const current = this.bakedStageWorld ?? new Map<string, Mat4>();\n const rels = this.bakedChainRel ?? new Map<string, Mat4>();\n\n // Rewrite every link's local matrix parents-first: written links land on\n // their target, held links keep their world pose while ancestors move.\n // The chain nodes in between stay frozen at their fk values; each link's\n // local absorbs the difference, so world matrices come out exact.\n const next = new Map<string, Mat4>();\n for (const key of this.tree.order) {\n const node = this.tree.nodes[key];\n const obj = this.linkObjects.get(key);\n if (!node || !obj) continue;\n const world = targets.get(key) ?? current.get(key);\n if (!world) continue;\n if (node.parent === null || node.jointToParent === null) {\n next.set(key, world); // the root's Object3D parent is the robot itself\n setMatrix(obj, world);\n continue;\n }\n const parentWorld = next.get(node.parent);\n const chainRel = rels.get(node.jointToParent);\n if (!parentWorld || !chainRel) continue;\n next.set(key, world);\n setMatrix(obj, multiply(invert(multiply(parentWorld, chainRel)), world));\n }\n for (const key of this.tree.isolatedLinks) {\n const obj = this.linkObjects.get(key);\n const world = targets.get(key) ?? current.get(key);\n if (!obj || !world) continue;\n next.set(key, world);\n setMatrix(obj, world);\n }\n\n this.bakedStageWorld = next;\n this.dirty = true;\n this.warnBakedDeviationOnce(next);\n return targets.size;\n }\n\n /**\n * Measure how far a link-pose batch deviates from the joint constraints,\n * without touching the display. Unspecified links resolve to their current\n * displayed pose, so the report predicts exactly what\n * {@link setLinkTransforms} with the same batch would show.\n *\n * Keyed by joint prim path; covers every joint — fixed joints (`q` = 0\n * check), loop joints dropped from the fk tree (closure error) and the\n * world-fixed root attachment (a moved base against a fixed-base model).\n * Typical signatures: a constant `anchorError` offset on every joint —\n * recording/model mismatch (wrong version or scale); growth over time —\n * maximal-coordinate solver drift; large uniform `axisError` — a\n * coordinate-convention bug (Y/Z-up or quaternion order).\n */\n validateLinkTransforms(\n poses: Record<string, LinkPose>,\n opts: LinkPosesOptions = {},\n ): Record<string, JointResidual> {\n const out: Record<string, JointResidual> = {};\n for (const { joint, rel } of this.decomposeJoints(poses, opts.space ?? \"world\")) {\n out[joint.primPath] = this.buildResidual(joint, rel.q, rel);\n }\n return out;\n }\n\n /**\n * Project a link-pose batch onto the joint manifold: the closed-form 1-DOF\n * joint values that best reproduce it, plus the same residuals as\n * {@link validateLinkTransforms}. `values` covers the commandable\n * articulated tree joints (mimic followers excluded — their leaders\n * re-derive them), keyed by joint prim path, and feeds\n * {@link setJointValues} directly — the constraint-respecting playback of\n * the same track:\n *\n * ```ts\n * robot.setJointValues(robot.jointValuesFromLinkTransforms(poses, { previous }).values);\n * ```\n *\n * Residual `q` / `limitExceeded` always report the unclamped projection,\n * also when `clampLimits` clamps `values`.\n */\n jointValuesFromLinkTransforms(\n poses: Record<string, LinkPose>,\n opts: JointValuesFromLinkTransformsOptions = {},\n ): { values: Record<string, number>; residuals: Record<string, JointResidual> } {\n const values: Record<string, number> = {};\n const residuals: Record<string, JointResidual> = {};\n for (const { key, joint, rel } of this.decomposeJoints(poses, opts.space ?? \"world\")) {\n let q = rel.q;\n if (joint.type === \"revolute\" || joint.type === \"continuous\") {\n const previous = opts.previous?.[joint.primPath] ?? opts.previous?.[key];\n if (previous !== undefined) q = nearestAngleBranch(q, previous);\n }\n residuals[joint.primPath] = this.buildResidual(joint, q, rel);\n if (!this.jointObjects.get(key)?.articulated) continue;\n // Followers are not commandable — the constraint re-derives them when\n // the returned values are fed to setJointValues.\n if (this.mimicLeaderByFollower.has(key)) continue;\n if (opts.clampLimits) {\n if (joint.lower !== undefined && q < joint.lower) q = joint.lower;\n if (joint.upper !== undefined && q > joint.upper) q = joint.upper;\n }\n values[joint.primPath] = q;\n }\n return { values, residuals };\n }\n\n /** Restore the constructed fk link placements (no-op when already `\"fk\"`). */\n private exitBakedMode(): void {\n if (this._displayMode === \"fk\") return;\n for (const [key, local] of this.restLocal) {\n const obj = this.linkObjects.get(key);\n if (obj) setMatrix(obj, local);\n }\n this.bakedStageWorld = null;\n this.bakedChainRel = null;\n this.bakedDebugWarned = false;\n this._displayMode = \"fk\";\n this.dirty = true;\n }\n\n /** Freeze the fk state a baked session builds on (joints cannot move while baked). */\n private enterBakedMode(): void {\n const rels = this.computeChainRels();\n this.bakedChainRel = rels;\n this.bakedStageWorld = this.computeStageWorlds(rels);\n this._displayMode = \"baked\";\n }\n\n /** `frame0 · motion(q) · frame1⁻¹` of every tree joint, from live joint values. */\n private computeChainRels(): Map<string, Mat4> {\n const rels = new Map<string, Mat4>();\n for (const [key, motion] of this.jointObjects) {\n const joint = this.robot.joints[key];\n if (!joint) continue;\n motion.updateMatrix();\n rels.set(\n key,\n multiplyAll([joint.jointFrame0, motion.matrix.toArray(), invert(joint.jointFrame1)]),\n );\n }\n return rels;\n }\n\n /** Stage-space world transform of every link under the current display state. */\n private computeStageWorlds(rels: Map<string, Mat4>): Map<string, Mat4> {\n const worlds = new Map<string, Mat4>();\n for (const key of this.tree.order) {\n const node = this.tree.nodes[key];\n const obj = this.linkObjects.get(key);\n if (!node || !obj) continue;\n const local = obj.matrix.toArray();\n if (node.parent === null || node.jointToParent === null) {\n worlds.set(key, local);\n continue;\n }\n const parentWorld = worlds.get(node.parent);\n const chainRel = rels.get(node.jointToParent);\n if (!parentWorld || !chainRel) continue;\n worlds.set(key, multiplyAll([parentWorld, chainRel, local]));\n }\n for (const key of this.tree.isolatedLinks) {\n const obj = this.linkObjects.get(key);\n if (obj) worlds.set(key, obj.matrix.toArray());\n }\n return worlds;\n }\n\n private currentStageWorlds(): Map<string, Mat4> {\n return this.bakedStageWorld ?? this.computeStageWorlds(this.computeChainRels());\n }\n\n /** Resolve pose keys to link keys and convert each pose to a rigid stage-space matrix. */\n private resolvePoseTargets(\n poses: Record<string, LinkPose>,\n space: LinkPoseSpace,\n ): Map<string, Mat4> {\n const targets = new Map<string, Mat4>();\n const entries = Object.entries(poses);\n if (entries.length === 0) return targets;\n\n const toStage = space === \"world\" ? this.sceneToStageConverter() : null;\n const position = new THREE.Vector3();\n const quaternion = new THREE.Quaternion();\n const matrix = new THREE.Matrix4();\n for (const [ref, pose] of entries) {\n const key = this.linkKey(ref);\n if (!this.linkObjects.has(key)) {\n this.warnUnknownPoseKey(ref);\n continue;\n }\n position.fromArray(pose.position);\n quaternion.fromArray(pose.quaternion).normalize();\n toStage?.(position, quaternion);\n targets.set(key, matrix.compose(position, quaternion, UNIT_SCALE).toArray());\n }\n return targets;\n }\n\n /**\n * Scene world → stage space, undoing the robot's own world transform\n * (up-axis rotation, unit scale, any user placement) as a similarity — so\n * link locals stay rigid and the root keeps carrying the scale.\n */\n private sceneToStageConverter(): (position: THREE.Vector3, quaternion: THREE.Quaternion) => void {\n this.updateWorldMatrix(true, false);\n const rootPosition = new THREE.Vector3();\n const rootQuaternion = new THREE.Quaternion();\n const rootScale = new THREE.Vector3();\n this.matrixWorld.decompose(rootPosition, rootQuaternion, rootScale);\n const s = rootScale.x;\n if (\n !this.warnedNonUniformScale &&\n (Math.abs(rootScale.y - s) > 1e-6 * Math.abs(s) ||\n Math.abs(rootScale.z - s) > 1e-6 * Math.abs(s))\n ) {\n this.warnedNonUniformScale = true;\n console.warn(\n `three-usd-robot: non-uniform world scale on \"${this.name}\"; space:\"world\" poses are off`,\n );\n }\n const invQuaternion = rootQuaternion.clone().invert();\n const invScale = s !== 0 ? 1 / s : 1;\n return (position, quaternion) => {\n position.sub(rootPosition).applyQuaternion(invQuaternion).multiplyScalar(invScale);\n quaternion.premultiply(invQuaternion);\n };\n }\n\n /**\n * Decompose every joint's parent→child transform under a pose batch\n * (unspecified links resolve to their current displayed pose, mirroring\n * {@link setLinkTransforms}). Pure — the display is untouched.\n */\n private decomposeJoints(\n poses: Record<string, LinkPose>,\n space: LinkPoseSpace,\n ): { key: string; joint: JointDescription; rel: JointRelativeDecomposition }[] {\n const worlds = new Map(this.currentStageWorlds());\n for (const [key, world] of this.resolvePoseTargets(poses, space)) worlds.set(key, world);\n\n const out: { key: string; joint: JointDescription; rel: JointRelativeDecomposition }[] = [];\n for (const [key, joint] of Object.entries(this.robot.joints)) {\n const childWorld = worlds.get(joint.child);\n const parentWorld = joint.parent === \"\" ? IDENTITY4 : worlds.get(joint.parent);\n if (!childWorld || !parentWorld) continue;\n out.push({ key, joint, rel: decomposeJointRelative(joint, parentWorld, childWorld) });\n }\n return out;\n }\n\n private buildResidual(\n joint: JointDescription,\n q: number,\n rel: JointRelativeDecomposition,\n ): JointResidual {\n return {\n anchorError: rel.anchorError * this.robot.metersPerUnit,\n axisError: rel.axisError,\n q,\n limitExceeded:\n (joint.lower !== undefined && q < joint.lower - LIMIT_EPS) ||\n (joint.upper !== undefined && q > joint.upper + LIMIT_EPS),\n };\n }\n\n private warnUnknownPoseKey(ref: string): void {\n if (this.warnedPoseKeys.has(ref)) return;\n this.warnedPoseKeys.add(ref);\n console.warn(`three-usd-robot: unknown link \"${ref}\" in a pose batch; ignoring`);\n }\n\n /** `debugBakedTransforms`: warn once per baked session when poses break the constraints. */\n private warnBakedDeviationOnce(worlds: Map<string, Mat4>): void {\n if (!this.debugBaked || this.bakedDebugWarned) return;\n const { anchorTolerance, axisTolerance } = this.debugBaked;\n let count = 0;\n let worst: { path: string; anchor: number; axis: number; score: number } | null = null;\n for (const joint of Object.values(this.robot.joints)) {\n const childWorld = worlds.get(joint.child);\n const parentWorld = joint.parent === \"\" ? IDENTITY4 : worlds.get(joint.parent);\n if (!childWorld || !parentWorld) continue;\n const rel = decomposeJointRelative(joint, parentWorld, childWorld);\n const anchor = rel.anchorError * this.robot.metersPerUnit;\n if (anchor <= anchorTolerance && rel.axisError <= axisTolerance) continue;\n count++;\n const score = anchor / anchorTolerance + rel.axisError / axisTolerance;\n if (!worst || score > worst.score) {\n worst = { path: joint.primPath, anchor, axis: rel.axisError, score };\n }\n }\n if (!worst) return;\n this.bakedDebugWarned = true;\n console.warn(\n `three-usd-robot: baked poses deviate from ${count} joint constraint(s) — worst ` +\n `${worst.path}: anchor ${(worst.anchor * 1e3).toFixed(3)} mm, axis ` +\n `${worst.axis.toFixed(4)} rad (recording/model mismatch? warned once per baked session)`,\n );\n }\n\n // -- Queries -------------------------------------------------------------\n\n /** World matrix of a link, addressed by key or full prim path. */\n getLinkWorldMatrix(name: string): THREE.Matrix4 {\n const obj = this.linkObjects.get(this.linkKey(name));\n if (!obj) throw new Error(`unknown link \"${name}\"`);\n this.ensureUpdated();\n return obj.matrixWorld.clone();\n }\n\n getLinkWorldPosition(name: string): THREE.Vector3 {\n return new THREE.Vector3().setFromMatrixPosition(this.getLinkWorldMatrix(name));\n }\n\n /** Link object by key or full prim path. */\n getLinkObject(name: string): LinkObject | undefined {\n return this.linkObjects.get(this.linkKey(name));\n }\n\n /** Joint object by key or full prim path. */\n getJointObject(name: string): JointObject | undefined {\n return this.jointObjects.get(this.jointKey(name));\n }\n\n /**\n * Table of link prim path → {@link LinkObject}. Prim paths are the\n * collision-proof way to pin a link (e.g. to attach tools or gizmos).\n */\n getLinkObjectsByPath(): Map<string, LinkObject> {\n const out = new Map<string, LinkObject>();\n for (const [path, key] of this.linkKeyByPath) {\n const obj = this.linkObjects.get(key);\n if (obj) out.set(path, obj);\n }\n return out;\n }\n\n /**\n * Table of joint prim path → {@link JointObject}, covering the joints\n * realized in the kinematic tree (loop joints have no motion node).\n */\n getJointObjectsByPath(): Map<string, JointObject> {\n const out = new Map<string, JointObject>();\n for (const [path, key] of this.jointKeyByPath) {\n const obj = this.jointObjects.get(key);\n if (obj) out.set(path, obj);\n }\n return out;\n }\n\n getJoints(): JointDescription[] {\n return Object.values(this.robot.joints);\n }\n\n getLinks(): LinkDescription[] {\n return Object.values(this.robot.links);\n }\n\n /**\n * Names of the commandable joints — articulated tree joints minus mimic\n * followers, whose values derive from their leader\n * (see {@link getMimicJointNames}).\n */\n getJointNames(): string[] {\n return [...this.jointObjects.keys()].filter((key) => !this.mimicLeaderByFollower.has(key));\n }\n\n getLinkNames(): string[] {\n return [...this.linkObjects.keys()];\n }\n\n getKinematicTree(): KinematicTree {\n return this.tree;\n }\n\n /** Authored stage up-axis (`\"Y\"` or `\"Z\"`) — unaffected by `worldUp` normalization. */\n get upAxis(): \"Y\" | \"Z\" {\n return this.robot.upAxis;\n }\n\n /** Authored stage scale in meters per unit (already applied to the root). */\n get metersPerUnit(): number {\n return this.robot.metersPerUnit;\n }\n\n // -- Animation playback --------------------------------------------------\n\n /** Playback rate in time codes per second (from the stage; default 24). */\n getTimeCodesPerSecond(): number {\n return this.robot.timeCodesPerSecond ?? 24;\n }\n\n /** Whether any joint has a time-sampled trajectory. */\n hasAnimation(): boolean {\n return Object.values(this.robot.joints).some((j) => j.valueSamples !== undefined);\n }\n\n /**\n * Animation range in time codes: the union of authored joint sample ranges,\n * falling back to the stage `startTimeCode`/`endTimeCode`. `null` if neither.\n */\n getTimeRange(): { start: number; end: number } | null {\n let start = Number.POSITIVE_INFINITY;\n let end = Number.NEGATIVE_INFINITY;\n for (const joint of Object.values(this.robot.joints)) {\n const times = joint.valueSamples?.times;\n if (!times || times.length === 0) continue;\n start = Math.min(start, times[0]!);\n end = Math.max(end, times[times.length - 1]!);\n }\n if (start <= end) return { start, end };\n\n const { startTimeCode, endTimeCode } = this.robot;\n if (startTimeCode !== undefined && endTimeCode !== undefined) {\n return { start: startTimeCode, end: endTimeCode };\n }\n return null;\n }\n\n /**\n * Sample every animated joint at time code `t` and apply the values (an fk\n * drive — leaves baked mode). Samples on mimic followers are ignored; the\n * constraint re-derives them from their leader.\n */\n setTime(t: number): void {\n this.exitBakedMode();\n for (const [key, joint] of Object.entries(this.robot.joints)) {\n if (!joint.valueSamples || this.mimicLeaderByFollower.has(key)) continue;\n this.setJointValue(key, interpolate(joint.valueSamples, t));\n }\n }\n\n // -- Display toggles -----------------------------------------------------\n\n get showVisual(): boolean {\n return this._showVisual;\n }\n set showVisual(v: boolean) {\n this._showVisual = v;\n this.setKindVisibility(\"visual\", v);\n }\n\n get showCollision(): boolean {\n return this._showCollision;\n }\n set showCollision(v: boolean) {\n this._showCollision = v;\n this.setKindVisibility(\"collision\", v);\n }\n\n get showJointAxes(): boolean {\n return this._showJointAxes;\n }\n set showJointAxes(v: boolean) {\n this._showJointAxes = v;\n if (v && this.jointAxesHelpers.length === 0) {\n for (const joint of this.jointObjects.values()) {\n const h = new THREE.AxesHelper(this.helperSize);\n h.name = `${joint.jointName}:axes`;\n joint.add(h);\n this.jointAxesHelpers.push(h);\n }\n }\n for (const h of this.jointAxesHelpers) h.visible = v;\n }\n\n get showLinkFrames(): boolean {\n return this._showLinkFrames;\n }\n set showLinkFrames(v: boolean) {\n this._showLinkFrames = v;\n if (v && this.linkFrameHelpers.length === 0) {\n for (const link of this.linkObjects.values()) {\n const h = new THREE.AxesHelper(this.helperSize);\n h.name = `${link.linkName}:frame`;\n link.add(h);\n this.linkFrameHelpers.push(h);\n }\n }\n for (const h of this.linkFrameHelpers) h.visible = v;\n }\n\n private setKindVisibility(kind: string, visible: boolean): void {\n this.traverse((o) => {\n if ((o.userData as { kind?: string }).kind === kind) o.visible = visible;\n });\n }\n}\n\nconst UNIT_SCALE = new THREE.Vector3(1, 1, 1);\nconst IDENTITY4: Mat4 = identity4();\n/** Slack for `limitExceeded` so poses exactly at a limit round-trip clean. */\nconst LIMIT_EPS = 1e-9;\n\n/** Assign a fixed local matrix to an object (disables Three.js auto-update). */\nfunction setMatrix(obj: THREE.Object3D, m: Mat4): void {\n obj.matrixAutoUpdate = false;\n obj.matrix.fromArray(m);\n obj.matrixWorldNeedsUpdate = true;\n}\n"]}
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { U as UsdaFile,
|
|
2
|
-
export { a as AssetPath, b as Attribute, c as AttributeSpec, B as BuildTreeOptions, C as CompositionArc, D as DEFAULT_METERS_PER_UNIT, d as DEG2RAD, e as JointDescription, J as JointDriveDescription,
|
|
1
|
+
import { U as UsdaFile, z as Vec3, y as Vec2, M as Mat4, j as LinkDescription, S as Stage, R as RobotDescription, P as Prim, x as UsdValue, g as JointType, A as Axis, s as SdfPath, L as LinkInertialDescription } from './buildKinematicTree-Q9JOjAjM.js';
|
|
2
|
+
export { a as AssetPath, b as Attribute, c as AttributeSpec, B as BuildTreeOptions, C as CompositionArc, D as DEFAULT_METERS_PER_UNIT, d as DEG2RAD, e as JointDescription, J as JointDriveDescription, f as JointMimicDescription, h as KinematicNode, K as KinematicTree, i as Layer, k as ListOp, l as MetadataMap, m as PrimSpec, n as PropertySpec, Q as Quat, o as RAD2DEG, p as Relationship, q as RelationshipSpec, r as SampleChannel, t as Specifier, T as TreeEdge, u as UpAxis, v as UsdDictionary, w as UsdMatrix, V as Variability, E as Vec4, F as buildKinematicTree, G as channelFromSamples, H as decomposeRigid, I as fromUsdMatrix, N as getTranslation, O as identity4, W as interpolate, X as invert, Y as makeEuler, Z as makeRotationFromQuat, _ as makeRotationX, $ as makeRotationY, a0 as makeRotationZ, a1 as makeScale, a2 as makeTranslation, a3 as multiply, a4 as multiplyAll, a5 as toUsdMatrix } from './buildKinematicTree-Q9JOjAjM.js';
|
|
3
3
|
import { A as AssetResolver, b as MdlModuleProvider } from './parseMdl-vfzBGoMr.js';
|
|
4
4
|
export { D as DefaultAssetResolver, M as MdlMaterialDecl, a as MdlModule, c as MdlTextureValue, d as MdlValue, e as createMemoryResolver, i as isMdlTexture, j as joinPosix, p as parseMdl, f as parseMdlLiteral } from './parseMdl-vfzBGoMr.js';
|
|
5
5
|
export { B as BinarySource, U as UsdSource, t as toBytes } from './bytes-CxGRGry_.js';
|
|
@@ -146,8 +146,8 @@ declare function stageGeometryProvider(stage: Stage): RobotGeometryProvider;
|
|
|
146
146
|
*
|
|
147
147
|
* Builds a self-contained UsdPhysics robot layer from a {@link RobotDescription}:
|
|
148
148
|
* one `Xform` prim per link placed at its **zero-pose** world transform
|
|
149
|
-
* (folding joint frames root-down, `T_child = T_parent · frame0 · frame1⁻¹`
|
|
150
|
-
*
|
|
149
|
+
* (folding joint frames root-down, `T_child = T_parent · frame0 · frame1⁻¹`),
|
|
150
|
+
* one `Physics*Joint` prim per joint, and the
|
|
151
151
|
* link meshes supplied by a {@link RobotGeometryProvider}. Initial joint values
|
|
152
152
|
* author as `PhysicsJointStateAPI` opinions rather than being baked into link
|
|
153
153
|
* transforms, so a re-import applies them exactly once. Values convert back
|
package/dist/core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { PACKAGE_NAME, VERSION, exportRobotUsda, stageGeometryProvider, validateRobotDescription, writeUsdz } from './chunk-
|
|
2
|
-
export { ARTICULATION_ROOT_API, Attribute, COLLISION_API, CrateReader, DEFAULT_METERS_PER_UNIT, Layer, MASS_API, MESH_COLLISION_API, PHYSICS_MATERIAL_API, ParseError, Prim, RIGID_BODY_API, Relationship, Stage, TokenizeError, buildKinematicTree, collectMdlAssetPaths, composeFile, composeLayer, computeLocalTransform, computeWorldTransform, crateToUsdaFile, driveKindFor, extractRobotDescription, gatherGprimDescendants, gatherMeshDescendants, getJointAxis, getJointBodies, getJointDrive, getJointLimits, getJointLocalFrame, getJointStatePosition, getJointType, getMassProperties, hasArticulationRootAPI, hasCollisionAPI, hasRigidBodyAPI, isBasisCurves, isMesh, isPoints, isRenderableGprim, isScope, isSolidGprim, isUnsupportedGprim, isXform, isZip, iterDescendants, jointValueFromSI, jointValueToSI, loadMdlModules, normalizeJointLimits, openUsdz, parseOpType, parseUsda, refineJointType, serializeUsda, toBytes, tokenize } from './chunk-
|
|
1
|
+
export { PACKAGE_NAME, VERSION, exportRobotUsda, stageGeometryProvider, validateRobotDescription, writeUsdz } from './chunk-5ZPHZ5ZH.js';
|
|
2
|
+
export { ARTICULATION_ROOT_API, Attribute, COLLISION_API, CrateReader, DEFAULT_METERS_PER_UNIT, Layer, MASS_API, MESH_COLLISION_API, PHYSICS_MATERIAL_API, ParseError, Prim, RIGID_BODY_API, Relationship, Stage, TokenizeError, buildKinematicTree, collectMdlAssetPaths, composeFile, composeLayer, computeLocalTransform, computeWorldTransform, crateToUsdaFile, driveKindFor, extractRobotDescription, gatherGprimDescendants, gatherMeshDescendants, getJointAxis, getJointBodies, getJointDrive, getJointLimits, getJointLocalFrame, getJointStatePosition, getJointType, getMassProperties, hasArticulationRootAPI, hasCollisionAPI, hasRigidBodyAPI, isBasisCurves, isMesh, isPoints, isRenderableGprim, isScope, isSolidGprim, isUnsupportedGprim, isXform, isZip, iterDescendants, jointValueFromSI, jointValueToSI, loadMdlModules, normalizeJointLimits, openUsdz, parseOpType, parseUsda, refineJointType, serializeUsda, toBytes, tokenize } from './chunk-FUVHAORT.js';
|
|
3
3
|
export { DEG2RAD, RAD2DEG, channelFromSamples, decomposeJointRelative, decomposeRigid, fromUsdMatrix, getTranslation, identity4, interpolate, invert, makeEuler, makeRotationFromQuat, makeRotationX, makeRotationY, makeRotationZ, makeScale, makeTranslation, multiply, multiplyAll, nearestAngleBranch, toUsdMatrix } from './chunk-YGJ23CG3.js';
|
|
4
4
|
export { DefaultAssetResolver, createMemoryResolver, isMdlTexture, joinPosix, parseMdl, parseMdlLiteral } from './chunk-PPPRB6KE.js';
|
|
5
5
|
export { AssetPath, Quat, UsdMatrix } from './chunk-JGIVJXBU.js';
|
package/dist/extras.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as ThreeUsdRobot } from './ThreeUsdRobot-
|
|
1
|
+
import { T as ThreeUsdRobot } from './ThreeUsdRobot-X1zbpRZo.js';
|
|
2
2
|
import 'three';
|
|
3
|
-
import './buildKinematicTree-
|
|
3
|
+
import './buildKinematicTree-Q9JOjAjM.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* `three-usd-robot/extras`
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { T as ThreeUsdRobot, J as JointObject } from './ThreeUsdRobot-
|
|
3
|
-
import './buildKinematicTree-
|
|
2
|
+
import { T as ThreeUsdRobot, J as JointObject } from './ThreeUsdRobot-X1zbpRZo.js';
|
|
3
|
+
import './buildKinematicTree-Q9JOjAjM.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Per-link appearance helpers: highlight (tint), material replacement, and
|
package/dist/helpers.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CollisionApproximation, ExportPhysicsMaterial, RobotGeometryProvider, ExportRobotOptions, ExportMaterial, ExportMesh } from './core.js';
|
|
2
2
|
export { ARTICULATION_ROOT_API, COLLISION_API, ComposeOptions, CrateReader, ExtractOptions, JointDofInput, JointRelativeDecomposition, MASS_API, MESH_COLLISION_API, PACKAGE_NAME, PHYSICS_MATERIAL_API, ParseError, RIGID_BODY_API, ResolvedXform, TextureChannel, TokenizeError, UsdzPackage, VERSION, ValidateRobotOptions, ValidationIssue, ValidationSeverity, collectMdlAssetPaths, composeFile, composeLayer, computeLocalTransform, computeWorldTransform, crateToUsdaFile, decomposeJointRelative, driveKindFor, exportRobotUsda, extractRobotDescription, gatherGprimDescendants, gatherMeshDescendants, getJointAxis, getJointBodies, getJointDrive, getJointLimits, getJointLocalFrame, getJointStatePosition, getJointType, getMassProperties, hasArticulationRootAPI, hasCollisionAPI, hasRigidBodyAPI, isBasisCurves, isMesh, isPoints, isRenderableGprim, isScope, isSolidGprim, isUnsupportedGprim, isXform, isZip, iterDescendants, jointValueFromSI, jointValueToSI, loadMdlModules, nearestAngleBranch, normalizeJointLimits, openUsdz, parseOpType, parseUsda, refineJointType, serializeUsda, stageGeometryProvider, tokenize, validateRobotDescription, writeUsdz } from './core.js';
|
|
3
3
|
import * as THREE from 'three';
|
|
4
|
-
import { A as Axis, J as JointDriveDescription, L as LinkInertialDescription, R as RobotDescription, K as KinematicTree, U as UsdaFile, S as Stage, M as Mat4 } from './buildKinematicTree-
|
|
5
|
-
export { a as AssetPath, b as Attribute, c as AttributeSpec, B as BuildTreeOptions, C as CompositionArc, D as DEFAULT_METERS_PER_UNIT, d as DEG2RAD, e as JointDescription, f as
|
|
6
|
-
import { T as ThreeUsdRobot } from './ThreeUsdRobot-
|
|
7
|
-
export { J as JointObject, b as JointResidual, c as JointValuesFromLinkTransformsOptions, L as LinkObject, d as LinkPose, e as LinkPoseSpace, f as LinkPosesOptions, a as ThreeUsdRobotOptions, W as WorldUpAxis } from './ThreeUsdRobot-
|
|
8
|
-
export { B as BindMeshesOptions, a as BuildGprimOptions, M as MaterialFactory, b as MeshKind, R as ResolveMaterialOptions, c as ResolvedMaterial, d as ResolvedTexture, e as TextureColorSpace, f as TextureOptions, T as TextureProvider, g as TextureTransform, h as TextureWrap, i as bindRobotMeshes, j as bindSceneMeshes, k as buildGprimGeometry, l as buildGprimObject, m as buildMeshGeometry, n as buildMeshMaterial, o as createTextureProvider, p as findBoundSurfaceShader, r as resolveBoundMaterial } from './MeshBinding-
|
|
9
|
-
export { a as ThreeUsdRobotLoader, T as ThreeUsdRobotLoaderOptions } from './ThreeUsdRobotLoader-
|
|
4
|
+
import { A as Axis, J as JointDriveDescription, L as LinkInertialDescription, R as RobotDescription, K as KinematicTree, U as UsdaFile, S as Stage, M as Mat4 } from './buildKinematicTree-Q9JOjAjM.js';
|
|
5
|
+
export { a as AssetPath, b as Attribute, c as AttributeSpec, B as BuildTreeOptions, C as CompositionArc, D as DEFAULT_METERS_PER_UNIT, d as DEG2RAD, e as JointDescription, f as JointMimicDescription, g as JointType, h as KinematicNode, i as Layer, j as LinkDescription, k as ListOp, l as MetadataMap, P as Prim, m as PrimSpec, n as PropertySpec, Q as Quat, o as RAD2DEG, p as Relationship, q as RelationshipSpec, r as SampleChannel, s as SdfPath, t as Specifier, T as TreeEdge, u as UpAxis, v as UsdDictionary, w as UsdMatrix, x as UsdValue, V as Variability, y as Vec2, z as Vec3, E as Vec4, F as buildKinematicTree, G as channelFromSamples, H as decomposeRigid, I as fromUsdMatrix, N as getTranslation, O as identity4, W as interpolate, X as invert, Y as makeEuler, Z as makeRotationFromQuat, _ as makeRotationX, $ as makeRotationY, a0 as makeRotationZ, a1 as makeScale, a2 as makeTranslation, a3 as multiply, a4 as multiplyAll, a5 as toUsdMatrix } from './buildKinematicTree-Q9JOjAjM.js';
|
|
6
|
+
import { T as ThreeUsdRobot } from './ThreeUsdRobot-X1zbpRZo.js';
|
|
7
|
+
export { J as JointObject, b as JointResidual, c as JointValuesFromLinkTransformsOptions, L as LinkObject, d as LinkPose, e as LinkPoseSpace, f as LinkPosesOptions, a as ThreeUsdRobotOptions, W as WorldUpAxis } from './ThreeUsdRobot-X1zbpRZo.js';
|
|
8
|
+
export { B as BindMeshesOptions, a as BuildGprimOptions, M as MaterialFactory, b as MeshKind, R as ResolveMaterialOptions, c as ResolvedMaterial, d as ResolvedTexture, e as TextureColorSpace, f as TextureOptions, T as TextureProvider, g as TextureTransform, h as TextureWrap, i as bindRobotMeshes, j as bindSceneMeshes, k as buildGprimGeometry, l as buildGprimObject, m as buildMeshGeometry, n as buildMeshMaterial, o as createTextureProvider, p as findBoundSurfaceShader, r as resolveBoundMaterial } from './MeshBinding-B_8RhuQE.js';
|
|
9
|
+
export { a as ThreeUsdRobotLoader, T as ThreeUsdRobotLoaderOptions } from './ThreeUsdRobotLoader-u3d1yoLM.js';
|
|
10
10
|
export { A as AssetResolver, D as DefaultAssetResolver, M as MdlMaterialDecl, a as MdlModule, b as MdlModuleProvider, c as MdlTextureValue, d as MdlValue, e as createMemoryResolver, i as isMdlTexture, j as joinPosix, p as parseMdl, f as parseMdlLiteral } from './parseMdl-vfzBGoMr.js';
|
|
11
11
|
export { B as BinarySource, U as UsdSource, t as toBytes } from './bytes-CxGRGry_.js';
|
|
12
12
|
|
|
@@ -66,6 +66,16 @@ type AddJointOptions = {
|
|
|
66
66
|
/** Initial joint value in SI, exported as `PhysicsJointStateAPI`. */
|
|
67
67
|
initialValue?: number;
|
|
68
68
|
drive?: JointDriveDescription;
|
|
69
|
+
/**
|
|
70
|
+
* Follow another joint: `value = multiplier · leader + offset` (SI), exported
|
|
71
|
+
* as `NewtonMimicAPI`. The leader must be declared (in any order) and share
|
|
72
|
+
* the motion kind. `multiplier` defaults to `1`, `offset` to `0`.
|
|
73
|
+
*/
|
|
74
|
+
mimic?: {
|
|
75
|
+
joint: string;
|
|
76
|
+
multiplier?: number;
|
|
77
|
+
offset?: number;
|
|
78
|
+
};
|
|
69
79
|
};
|
|
70
80
|
declare class RobotBuilder {
|
|
71
81
|
private readonly robotName;
|
|
@@ -79,7 +89,7 @@ declare class RobotBuilder {
|
|
|
79
89
|
private materialAutoId;
|
|
80
90
|
constructor(options: RobotBuilderOptions);
|
|
81
91
|
addLink(options: AddLinkOptions): this;
|
|
82
|
-
addFixedJoint(options: Omit<AddJointOptions, "axis" | "lower" | "upper">): this;
|
|
92
|
+
addFixedJoint(options: Omit<AddJointOptions, "axis" | "lower" | "upper" | "mimic">): this;
|
|
83
93
|
addRevoluteJoint(options: AddJointOptions): this;
|
|
84
94
|
addPrismaticJoint(options: AddJointOptions): this;
|
|
85
95
|
private addJoint;
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { stageGeometryProvider, exportRobotUsda } from './chunk-
|
|
2
|
-
export { PACKAGE_NAME, VERSION, exportRobotUsda, stageGeometryProvider, validateRobotDescription, writeUsdz } from './chunk-
|
|
3
|
-
export { ThreeUsdRobotLoader, bindRobotMeshes, bindSceneMeshes, buildGprimGeometry, buildGprimObject, buildMeshGeometry, buildMeshMaterial, createTextureProvider } from './chunk-
|
|
4
|
-
import { refineJointType, buildKinematicTree } from './chunk-
|
|
5
|
-
export { ARTICULATION_ROOT_API, Attribute, COLLISION_API, CrateReader, DEFAULT_METERS_PER_UNIT, Layer, MASS_API, MESH_COLLISION_API, PHYSICS_MATERIAL_API, ParseError, Prim, RIGID_BODY_API, Relationship, Stage, TokenizeError, buildKinematicTree, collectMdlAssetPaths, composeFile, composeLayer, computeLocalTransform, computeWorldTransform, crateToUsdaFile, driveKindFor, extractRobotDescription, gatherGprimDescendants, gatherMeshDescendants, getJointAxis, getJointBodies, getJointDrive, getJointLimits, getJointLocalFrame, getJointStatePosition, getJointType, getMassProperties, hasArticulationRootAPI, hasCollisionAPI, hasRigidBodyAPI, isBasisCurves, isMesh, isPoints, isRenderableGprim, isScope, isSolidGprim, isUnsupportedGprim, isXform, isZip, iterDescendants, jointValueFromSI, jointValueToSI, loadMdlModules, normalizeJointLimits, openUsdz, parseOpType, parseUsda, refineJointType, serializeUsda, toBytes, tokenize } from './chunk-
|
|
6
|
-
export { JointObject, LinkObject, ThreeUsdRobot, axisVector } from './chunk-
|
|
1
|
+
import { stageGeometryProvider, exportRobotUsda } from './chunk-5ZPHZ5ZH.js';
|
|
2
|
+
export { PACKAGE_NAME, VERSION, exportRobotUsda, stageGeometryProvider, validateRobotDescription, writeUsdz } from './chunk-5ZPHZ5ZH.js';
|
|
3
|
+
export { ThreeUsdRobotLoader, bindRobotMeshes, bindSceneMeshes, buildGprimGeometry, buildGprimObject, buildMeshGeometry, buildMeshMaterial, createTextureProvider } from './chunk-GRJGPHLW.js';
|
|
4
|
+
import { refineJointType, buildKinematicTree } from './chunk-FUVHAORT.js';
|
|
5
|
+
export { ARTICULATION_ROOT_API, Attribute, COLLISION_API, CrateReader, DEFAULT_METERS_PER_UNIT, Layer, MASS_API, MESH_COLLISION_API, PHYSICS_MATERIAL_API, ParseError, Prim, RIGID_BODY_API, Relationship, Stage, TokenizeError, buildKinematicTree, collectMdlAssetPaths, composeFile, composeLayer, computeLocalTransform, computeWorldTransform, crateToUsdaFile, driveKindFor, extractRobotDescription, gatherGprimDescendants, gatherMeshDescendants, getJointAxis, getJointBodies, getJointDrive, getJointLimits, getJointLocalFrame, getJointStatePosition, getJointType, getMassProperties, hasArticulationRootAPI, hasCollisionAPI, hasRigidBodyAPI, isBasisCurves, isMesh, isPoints, isRenderableGprim, isScope, isSolidGprim, isUnsupportedGprim, isXform, isZip, iterDescendants, jointValueFromSI, jointValueToSI, loadMdlModules, normalizeJointLimits, openUsdz, parseOpType, parseUsda, refineJointType, serializeUsda, toBytes, tokenize } from './chunk-FUVHAORT.js';
|
|
6
|
+
export { JointObject, LinkObject, ThreeUsdRobot, axisVector } from './chunk-JN2QPDB3.js';
|
|
7
7
|
import { identity4, multiply, invert } from './chunk-YGJ23CG3.js';
|
|
8
8
|
export { DEG2RAD, RAD2DEG, channelFromSamples, decomposeJointRelative, decomposeRigid, fromUsdMatrix, getTranslation, identity4, interpolate, invert, makeEuler, makeRotationFromQuat, makeRotationX, makeRotationY, makeRotationZ, makeScale, makeTranslation, multiply, multiplyAll, nearestAngleBranch, toUsdMatrix } from './chunk-YGJ23CG3.js';
|
|
9
9
|
export { DefaultAssetResolver, createMemoryResolver, findBoundSurfaceShader, isMdlTexture, joinPosix, parseMdl, parseMdlLiteral, resolveBoundMaterial } from './chunk-PPPRB6KE.js';
|
|
@@ -235,6 +235,23 @@ var RobotBuilder = class {
|
|
|
235
235
|
const jointWorld = pending.world ?? childLink.world;
|
|
236
236
|
const parentWorld = parent === "" ? identity4() : this.links.get(parent).world;
|
|
237
237
|
const type = refineJointType(pending.type, options.lower, options.upper);
|
|
238
|
+
if (options.mimic) {
|
|
239
|
+
const leader = this.joints.get(options.mimic.joint);
|
|
240
|
+
if (!leader) {
|
|
241
|
+
throw new Error(
|
|
242
|
+
`RobotBuilder: joint "${name}" mimics unknown joint "${options.mimic.joint}"`
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
if (options.mimic.joint === name) {
|
|
246
|
+
throw new Error(`RobotBuilder: joint "${name}" cannot mimic itself`);
|
|
247
|
+
}
|
|
248
|
+
const linear = (t) => t === "prismatic";
|
|
249
|
+
if (leader.type === "fixed" || linear(leader.type) !== linear(pending.type)) {
|
|
250
|
+
throw new Error(
|
|
251
|
+
`RobotBuilder: joint "${name}" (${pending.type}) cannot mimic "${options.mimic.joint}" (${leader.type})`
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
238
255
|
joints[name] = {
|
|
239
256
|
name,
|
|
240
257
|
primPath: `/${this.robotName}/${name}`,
|
|
@@ -247,7 +264,14 @@ var RobotBuilder = class {
|
|
|
247
264
|
...options.lower !== void 0 ? { lower: options.lower } : {},
|
|
248
265
|
...options.upper !== void 0 ? { upper: options.upper } : {},
|
|
249
266
|
...options.initialValue !== void 0 ? { initialValue: options.initialValue } : {},
|
|
250
|
-
...options.drive ? { drive: options.drive } : {}
|
|
267
|
+
...options.drive ? { drive: options.drive } : {},
|
|
268
|
+
...options.mimic ? {
|
|
269
|
+
mimic: {
|
|
270
|
+
joint: options.mimic.joint,
|
|
271
|
+
multiplier: options.mimic.multiplier ?? 1,
|
|
272
|
+
offset: options.mimic.offset ?? 0
|
|
273
|
+
}
|
|
274
|
+
} : {}
|
|
251
275
|
};
|
|
252
276
|
}
|
|
253
277
|
if (this.articulationRoot !== void 0 && !this.links.has(this.articulationRoot)) {
|