three-usd-robot 0.12.0 → 0.13.1
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-7GGSIA6M.js → chunk-5C3VTA56.js} +4 -4
- package/dist/{chunk-7GGSIA6M.js.map → chunk-5C3VTA56.js.map} +1 -1
- package/dist/{chunk-6W4LQVEQ.js → chunk-J6ZQWQ2C.js} +96 -5
- package/dist/chunk-J6ZQWQ2C.js.map +1 -0
- package/dist/{chunk-KYBHWDX5.js → chunk-JN2QPDB3.js} +100 -13
- package/dist/chunk-JN2QPDB3.js.map +1 -0
- package/dist/{chunk-CK5MTMYR.js → chunk-ZHUNBTUV.js} +78 -5
- package/dist/chunk-ZHUNBTUV.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
|
@@ -99,6 +99,8 @@ var COLLISION_API = "PhysicsCollisionAPI";
|
|
|
99
99
|
var MASS_API = "PhysicsMassAPI";
|
|
100
100
|
var MESH_COLLISION_API = "PhysicsMeshCollisionAPI";
|
|
101
101
|
var PHYSICS_MATERIAL_API = "PhysicsMaterialAPI";
|
|
102
|
+
var NEWTON_MIMIC_API = "NewtonMimicAPI";
|
|
103
|
+
var PHYSX_MIMIC_API = "PhysxMimicJointAPI";
|
|
102
104
|
function getJointType(prim) {
|
|
103
105
|
return JOINT_TYPE_BY_SCHEMA[prim.GetTypeName()] ?? null;
|
|
104
106
|
}
|
|
@@ -154,6 +156,45 @@ function getJointDrive(prim, kind) {
|
|
|
154
156
|
function getJointStatePosition(prim, kind) {
|
|
155
157
|
return readNumber(prim, `state:${kind}:physics:position`);
|
|
156
158
|
}
|
|
159
|
+
function physxMimicDof(type, axis) {
|
|
160
|
+
if (type === "fixed") return void 0;
|
|
161
|
+
return `${type === "prismatic" ? "trans" : "rot"}${axis}`;
|
|
162
|
+
}
|
|
163
|
+
function getJointMimic(prim, dof) {
|
|
164
|
+
if (prim.HasAPI(NEWTON_MIMIC_API)) {
|
|
165
|
+
if (prim.GetAttribute("newton:mimicEnabled").Get() === false) return void 0;
|
|
166
|
+
const referencePath2 = prim.GetRelationship("newton:mimicJoint").GetTargets()[0];
|
|
167
|
+
if (referencePath2 === void 0) return void 0;
|
|
168
|
+
return {
|
|
169
|
+
referencePath: referencePath2,
|
|
170
|
+
multiplier: readNumber(prim, "newton:mimicCoef1") ?? 1,
|
|
171
|
+
offset: readNumber(prim, "newton:mimicCoef0") ?? 0
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (dof === void 0) return void 0;
|
|
175
|
+
const referencePath = prim.GetRelationship(`physxMimicJoint:${dof}:referenceJoint`).GetTargets()[0];
|
|
176
|
+
if (referencePath === void 0) return void 0;
|
|
177
|
+
const gearing = readNumber(prim, `physxMimicJoint:${dof}:gearing`) ?? 1;
|
|
178
|
+
const offset = readNumber(prim, `physxMimicJoint:${dof}:offset`) ?? 0;
|
|
179
|
+
const referenceDof = prim.GetAttribute(`physxMimicJoint:${dof}:referenceJointAxis`).Get();
|
|
180
|
+
return {
|
|
181
|
+
referencePath,
|
|
182
|
+
multiplier: -gearing,
|
|
183
|
+
offset: -offset,
|
|
184
|
+
...typeof referenceDof === "string" ? { referenceDof } : {}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function getPhysxMimicDofs(prim) {
|
|
188
|
+
const out = /* @__PURE__ */ new Set();
|
|
189
|
+
for (const schema of prim.GetAppliedSchemas()) {
|
|
190
|
+
if (schema.startsWith(`${PHYSX_MIMIC_API}:`)) out.add(schema.slice(PHYSX_MIMIC_API.length + 1));
|
|
191
|
+
}
|
|
192
|
+
for (const relationship of prim.GetRelationships()) {
|
|
193
|
+
const match = /^physxMimicJoint:([^:]+):referenceJoint$/.exec(relationship.GetName());
|
|
194
|
+
if (match) out.add(match[1]);
|
|
195
|
+
}
|
|
196
|
+
return [...out];
|
|
197
|
+
}
|
|
157
198
|
function getMassProperties(prim) {
|
|
158
199
|
const out = {};
|
|
159
200
|
const mass = readNumber(prim, "physics:mass");
|
|
@@ -441,9 +482,10 @@ function extractRobotDescription(stage, options = {}) {
|
|
|
441
482
|
const joints = {};
|
|
442
483
|
const jointKeyByPath = buildKeyMap(jointPrims.map((p) => p.GetPath()));
|
|
443
484
|
for (const jp of jointPrims) {
|
|
444
|
-
const joint = buildJoint(jp, linkKeyByPath, warn);
|
|
485
|
+
const joint = buildJoint(jp, linkKeyByPath, jointKeyByPath, warn);
|
|
445
486
|
if (joint) joints[jointKeyByPath.get(jp.GetPath())] = joint;
|
|
446
487
|
}
|
|
488
|
+
dropInvalidMimics(joints, warn);
|
|
447
489
|
const name = options.robotName ?? stage.GetDefaultPrim()?.GetName() ?? stage.GetPseudoRoot().GetChildren()[0]?.GetName() ?? "robot";
|
|
448
490
|
const robot = {
|
|
449
491
|
name,
|
|
@@ -494,7 +536,7 @@ function isIdentityMat4(m) {
|
|
|
494
536
|
}
|
|
495
537
|
return true;
|
|
496
538
|
}
|
|
497
|
-
function buildJoint(prim, linkKeyByPath, warn) {
|
|
539
|
+
function buildJoint(prim, linkKeyByPath, jointKeyByPath, warn) {
|
|
498
540
|
const base = getJointType(prim);
|
|
499
541
|
if (!base) return null;
|
|
500
542
|
const path = prim.GetPath();
|
|
@@ -544,8 +586,57 @@ function buildJoint(prim, linkKeyByPath, warn) {
|
|
|
544
586
|
});
|
|
545
587
|
joint.valueSamples = { times, values };
|
|
546
588
|
}
|
|
589
|
+
const dof = physxMimicDof(type, joint.axis);
|
|
590
|
+
const mimic = getJointMimic(prim, dof);
|
|
591
|
+
if (mimic) {
|
|
592
|
+
const leaderDof = jointDof(prim, mimic.referencePath);
|
|
593
|
+
if (mimic.referenceDof !== void 0 && leaderDof !== void 0 && mimic.referenceDof !== leaderDof) {
|
|
594
|
+
warn(
|
|
595
|
+
`${path}: mimic reads "${mimic.referencePath}" on \`${mimic.referenceDof}\`, which is not the dof it moves about (\`${leaderDof}\`); ignoring`
|
|
596
|
+
);
|
|
597
|
+
} else {
|
|
598
|
+
joint.mimic = {
|
|
599
|
+
joint: jointKeyByPath.get(mimic.referencePath) ?? mimic.referencePath,
|
|
600
|
+
multiplier: mimic.multiplier,
|
|
601
|
+
offset: jointValueToSI(angular, mimic.offset)
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
} else if (dof !== void 0) {
|
|
605
|
+
const authored = getPhysxMimicDofs(prim).filter((d) => d !== dof);
|
|
606
|
+
if (authored.length > 0) {
|
|
607
|
+
warn(
|
|
608
|
+
`${path}: mimic authored on \`${authored.join("`, `")}\` but the joint moves about \`${dof}\`; ignoring`
|
|
609
|
+
);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
547
612
|
return joint;
|
|
548
613
|
}
|
|
614
|
+
function jointDof(from, path) {
|
|
615
|
+
const prim = from.GetStage().GetPrimAtPath(path);
|
|
616
|
+
if (!prim) return void 0;
|
|
617
|
+
const type = getJointType(prim);
|
|
618
|
+
return type ? physxMimicDof(type, getJointAxis(prim)) : void 0;
|
|
619
|
+
}
|
|
620
|
+
function dropInvalidMimics(joints, warn) {
|
|
621
|
+
for (const [key, joint] of Object.entries(joints)) {
|
|
622
|
+
const mimic = joint.mimic;
|
|
623
|
+
if (!mimic) continue;
|
|
624
|
+
const leader = joints[mimic.joint];
|
|
625
|
+
let reason = null;
|
|
626
|
+
if (!leader) reason = `references unknown joint "${mimic.joint}"`;
|
|
627
|
+
else if (mimic.joint === key) reason = "references itself";
|
|
628
|
+
else if (joint.type === "fixed" || leader.type === "fixed") {
|
|
629
|
+
reason = "connects a fixed joint (inert)";
|
|
630
|
+
} else if (driveKindFor(joint.type) !== driveKindFor(leader.type)) {
|
|
631
|
+
reason = `couples a ${joint.type} joint to a ${leader.type} leader`;
|
|
632
|
+
}
|
|
633
|
+
if (reason) {
|
|
634
|
+
warn(`${joint.primPath}: mimic ${reason}; ignoring`);
|
|
635
|
+
const { mimic: _dropped, ...rest } = joint;
|
|
636
|
+
joints[key] = rest;
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
}
|
|
549
640
|
function buildKeyMap(paths) {
|
|
550
641
|
const leafCounts = /* @__PURE__ */ new Map();
|
|
551
642
|
for (const p of paths) {
|
|
@@ -3346,6 +3437,6 @@ function openUsdz(bytes) {
|
|
|
3346
3437
|
return { rootEntry, resolver };
|
|
3347
3438
|
}
|
|
3348
3439
|
|
|
3349
|
-
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, getMaterialSubsets, hasArticulationRootAPI, hasCollisionAPI, hasRigidBodyAPI, isBasisCurves, isMesh, isNonVisualPurpose, isPoints, isRenderableGprim, isScope, isSolidGprim, isUnsupportedGprim, isXform, isZip, iterDescendants, jointValueFromSI, jointValueToSI, loadMdlModules, normalizeJointLimits, openUsdz, parseOpType, parseUsda, refineJointType, serializeUsda, toBytes, tokenize };
|
|
3350
|
-
//# sourceMappingURL=chunk-
|
|
3351
|
-
//# sourceMappingURL=chunk-
|
|
3440
|
+
export { ARTICULATION_ROOT_API, Attribute, COLLISION_API, CrateReader, DEFAULT_METERS_PER_UNIT, Layer, MASS_API, MESH_COLLISION_API, NEWTON_MIMIC_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, getMaterialSubsets, hasArticulationRootAPI, hasCollisionAPI, hasRigidBodyAPI, isBasisCurves, isMesh, isNonVisualPurpose, isPoints, isRenderableGprim, isScope, isSolidGprim, isUnsupportedGprim, isXform, isZip, iterDescendants, jointValueFromSI, jointValueToSI, loadMdlModules, normalizeJointLimits, openUsdz, parseOpType, parseUsda, refineJointType, serializeUsda, toBytes, tokenize };
|
|
3441
|
+
//# sourceMappingURL=chunk-J6ZQWQ2C.js.map
|
|
3442
|
+
//# sourceMappingURL=chunk-J6ZQWQ2C.js.map
|