three-usd-robot 0.11.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 +32 -280
- package/dist/MeshBinding-B_8RhuQE.d.ts +288 -0
- package/dist/{ThreeUsdRobot-BxnCluuK.d.ts → ThreeUsdRobot-X1zbpRZo.d.ts} +38 -8
- package/dist/{ThreeUsdRobotLoader-C-E9uwEe.d.ts → ThreeUsdRobotLoader-u3d1yoLM.d.ts} +11 -3
- package/dist/{buildKinematicTree-BCySuZZn.d.ts → buildKinematicTree-Q9JOjAjM.d.ts} +17 -3
- package/dist/bytes-CxGRGry_.d.ts +14 -0
- package/dist/{chunk-BCRRXGNB.js → chunk-5ZPHZ5ZH.js} +81 -6
- package/dist/chunk-5ZPHZ5ZH.js.map +1 -0
- package/dist/{chunk-AXPMXEQC.js → chunk-FUVHAORT.js} +77 -717
- package/dist/chunk-FUVHAORT.js.map +1 -0
- package/dist/{chunk-5SVRTKS4.js → chunk-GRJGPHLW.js} +18 -11
- package/dist/chunk-GRJGPHLW.js.map +1 -0
- package/dist/chunk-JGIVJXBU.js +54 -0
- package/dist/chunk-JGIVJXBU.js.map +1 -0
- package/dist/{chunk-ENWFOYHU.js → chunk-JN2QPDB3.js} +101 -14
- package/dist/chunk-JN2QPDB3.js.map +1 -0
- package/dist/chunk-PPPRB6KE.js +963 -0
- package/dist/chunk-PPPRB6KE.js.map +1 -0
- package/dist/{chunk-LDO5FKQS.js → chunk-YGJ23CG3.js} +4 -53
- package/dist/chunk-YGJ23CG3.js.map +1 -0
- package/dist/core.d.ts +8 -65
- package/dist/core.js +5 -3
- package/dist/extras.d.ts +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/helpers.js +3 -2
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +22 -263
- package/dist/index.js +35 -9
- package/dist/index.js.map +1 -1
- package/dist/nodes.d.ts +49 -0
- package/dist/nodes.js +439 -0
- package/dist/nodes.js.map +1 -0
- package/dist/parseMdl-vfzBGoMr.d.ts +87 -0
- package/dist/react.d.ts +6 -4
- package/dist/react.js +6 -4
- package/dist/react.js.map +1 -1
- package/package.json +6 -2
- package/dist/bytes-MOJ2oN-u.d.ts +0 -42
- package/dist/chunk-5SVRTKS4.js.map +0 -1
- package/dist/chunk-AXPMXEQC.js.map +0 -1
- package/dist/chunk-BCRRXGNB.js.map +0 -1
- package/dist/chunk-ENWFOYHU.js.map +0 -1
- package/dist/chunk-LDO5FKQS.js.map +0 -1
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helpers/appearance.ts","../src/helpers/JointAxisHelper.ts","../src/helpers/JointLimitHelper.ts","../src/helpers/LinkFrameHelper.ts","../src/helpers/attach.ts"],"names":["THREE","THREE2","lo","hi","THREE4"],"mappings":";;;;AAiBA,IAAM,cAAA,uBAAqB,OAAA,EAAuD;AAGlF,IAAM,cAAA,GAAiB,0BAAA;AAOhB,SAAS,aAAA,CACd,KAAA,EACA,IAAA,EACA,IAAA,GAAqB,KAAA,EACP;AACd,EAAA,MAAM,GAAA,GAAM,KAAA,CAAM,aAAA,CAAc,IAAI,CAAA;AACpC,EAAA,IAAI,CAAC,GAAA,EAAK,OAAO,EAAC;AAClB,EAAA,MAAM,MAAoB,EAAC;AAC3B,EAAA,KAAA,MAAW,KAAA,IAAS,IAAI,QAAA,EAAU;AAChC,IAAA,MAAM,IAAA,GAAO,KAAA;AACb,IAAA,IAAI,CAAC,KAAK,MAAA,EAAQ;AAClB,IAAA,MAAM,CAAA,GAAK,KAAK,QAAA,CAA+B,IAAA;AAC/C,IAAA,IAAI,CAAA,KAAM,QAAA,IAAY,CAAA,KAAM,WAAA,EAAa;AACzC,IAAA,IAAI,IAAA,KAAS,KAAA,IAAS,CAAA,KAAM,IAAA,EAAM;AAClC,IAAA,GAAA,CAAI,KAAK,IAAI,CAAA;AAAA,EACf;AACA,EAAA,OAAO,GAAA;AACT;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GAAA,CAAI,KAAK,MAAM,CAAA;AAAA,EACjB;AACA,EAAA,OAAO,GAAA;AACT;AAGO,SAAS,mBAAA,CAAoB,OAAsB,IAAA,EAAkC;AAC1F,EAAA,MAAM,MAAyB,EAAC;AAChC,EAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,CAAM,YAAA,EAAa,EAAG;AACvC,IAAA,MAAM,IAAA,GAAO,KAAA,CAAM,aAAA,CAAc,IAAI,CAAA;AACrC,IAAA,IAAI,CAAC,IAAA,EAAM;AACX,IAAA,MAAM,MAAA,GAAS,IAAI,eAAA,CAAgB,IAAI,CAAA;AACvC,IAAA,IAAA,CAAK,IAAI,MAAM,CAAA;AACf,IAAA,GAAA,CAAI,KAAK,MAAM,CAAA;AAAA,EACjB;AACA,EAAA,OAAO,GAAA;AACT","file":"helpers.js","sourcesContent":["/**\n * Per-link appearance helpers: highlight (tint), material replacement, and\n * translucent \"ghost\" clones for pose previews.\n *\n * Material overrides are reversible — the original materials are kept aside on\n * first override and put back exactly by {@link restoreLinkMaterials} /\n * {@link restoreAllLinkMaterials}. Links are addressed like everywhere else:\n * by key or by full prim path.\n */\n\nimport * as THREE from \"three\";\nimport { ThreeUsdRobot } from \"../three/ThreeUsdRobot.js\";\n\n/** Which meshes of a link an operation affects. */\nexport type LinkMeshKind = \"visual\" | \"collision\" | \"all\";\n\n/** Originals saved on first override (per mesh; first save wins until restore). */\nconst savedMaterials = new WeakMap<THREE.Mesh, THREE.Material | THREE.Material[]>();\n\n/** Marks materials created by {@link highlightLink}, so restore can dispose them. */\nconst HIGHLIGHT_FLAG = \"__threeUsdRobotHighlight\";\n\n/**\n * The meshes belonging to exactly this link — not those of child links, which\n * live under their own `LinkObject` deeper in the kinematic chain. Helpers and\n * joint-frame groups are excluded.\n */\nexport function getLinkMeshes(\n robot: ThreeUsdRobot,\n link: string,\n kind: LinkMeshKind = \"all\",\n): THREE.Mesh[] {\n const obj = robot.getLinkObject(link);\n if (!obj) return [];\n const out: THREE.Mesh[] = [];\n for (const child of obj.children) {\n const mesh = child as THREE.Mesh;\n if (!mesh.isMesh) continue;\n const k = (mesh.userData as { kind?: string }).kind;\n if (k !== \"visual\" && k !== \"collision\") continue;\n if (kind !== \"all\" && k !== kind) continue;\n out.push(mesh);\n }\n return out;\n}\n\nexport type HighlightLinkOptions = {\n /** Highlight color (default red `0xff4444`). */\n color?: THREE.ColorRepresentation;\n /** Emissive strength of the tint (default `0.8`). */\n emissiveIntensity?: number;\n /** Force translucency while highlighted (e.g. `0.5`); default keeps the material's own. */\n opacity?: number;\n /** Which meshes of the link to affect (default `\"visual\"`). */\n kind?: LinkMeshKind;\n};\n\n/**\n * Tint a link's meshes (emissive red by default) while keeping their maps and\n * base colors — e.g. to flag a colliding link. Repeated calls re-tint from the\n * *original* materials, so highlights don't stack; restore with\n * {@link restoreLinkMaterials}. Returns `false` when the link has no matching\n * meshes.\n */\nexport function highlightLink(\n robot: ThreeUsdRobot,\n link: string,\n options: HighlightLinkOptions = {},\n): boolean {\n const meshes = getLinkMeshes(robot, link, options.kind ?? \"visual\");\n if (meshes.length === 0) return false;\n\n const color = new THREE.Color(options.color ?? 0xff4444);\n for (const mesh of meshes) {\n if (!savedMaterials.has(mesh)) savedMaterials.set(mesh, mesh.material);\n const base = savedMaterials.get(mesh)!;\n disposeHighlightClones(mesh.material);\n mesh.material = Array.isArray(base)\n ? base.map((m) => tintClone(m, color, options))\n : tintClone(base, color, options);\n }\n return true;\n}\n\nfunction tintClone(\n base: THREE.Material,\n color: THREE.Color,\n options: HighlightLinkOptions,\n): THREE.Material {\n const m = base.clone();\n m.userData[HIGHLIGHT_FLAG] = true;\n const std = m as THREE.MeshStandardMaterial;\n if (std.isMeshStandardMaterial) {\n std.emissive.copy(color);\n std.emissiveIntensity = options.emissiveIntensity ?? 0.8;\n } else if (\"color\" in m) {\n (m as THREE.MeshBasicMaterial).color.copy(color);\n }\n if (options.opacity !== undefined) {\n m.transparent = options.opacity < 1;\n m.opacity = options.opacity;\n }\n return m;\n}\n\n/**\n * Replace a link's mesh materials with `material` (one shared instance). The\n * caller keeps ownership — it is never disposed here. Restore the originals\n * with {@link restoreLinkMaterials}. Returns `false` when the link has no\n * matching meshes.\n */\nexport function setLinkMaterial(\n robot: ThreeUsdRobot,\n link: string,\n material: THREE.Material,\n kind: LinkMeshKind = \"visual\",\n): boolean {\n const meshes = getLinkMeshes(robot, link, kind);\n if (meshes.length === 0) return false;\n for (const mesh of meshes) {\n if (!savedMaterials.has(mesh)) savedMaterials.set(mesh, mesh.material);\n disposeHighlightClones(mesh.material);\n mesh.material = material;\n }\n return true;\n}\n\n/** Put back a link's original materials (no-op for untouched meshes). */\nexport function restoreLinkMaterials(robot: ThreeUsdRobot, link: string): void {\n for (const mesh of getLinkMeshes(robot, link, \"all\")) {\n const original = savedMaterials.get(mesh);\n if (original === undefined) continue;\n disposeHighlightClones(mesh.material);\n mesh.material = original;\n savedMaterials.delete(mesh);\n }\n}\n\n/** Put back the original materials of every link of the robot. */\nexport function restoreAllLinkMaterials(robot: ThreeUsdRobot): void {\n for (const name of robot.getLinkNames()) restoreLinkMaterials(robot, name);\n}\n\n/** Dispose materials created by {@link highlightLink} (never user-supplied ones). */\nfunction disposeHighlightClones(current: THREE.Material | THREE.Material[]): void {\n for (const m of Array.isArray(current) ? current : [current]) {\n if (m.userData[HIGHLIGHT_FLAG]) m.dispose();\n }\n}\n\nexport type GhostRobotOptions = {\n /** Ghost tint (default `0x66aaff`). */\n color?: THREE.ColorRepresentation;\n /** Ghost opacity (default `0.35`). */\n opacity?: number;\n /** Complete material override; `color` / `opacity` are ignored when given. */\n material?: THREE.Material;\n /** Which meshes to clone (default `\"visual\"`). */\n kind?: \"visual\" | \"collision\";\n /** Joint overrides applied on top of the source robot's current pose. */\n jointValues?: Record<string, number>;\n};\n\n/**\n * Build a translucent clone of the robot for pose previews (target pose,\n * onion-skinning). Geometry is shared with the source; every mesh uses one\n * ghost material and is tagged `userData.kind = \"ghost\"`, so the source's\n * `showVisual` / `showCollision` toggles never affect it. The clone is a full\n * {@link ThreeUsdRobot} — drive it with `setJointValues` — starting from the\n * source's current joint values (plus `jointValues` overrides) and mirroring\n * its root transform. Add it to the same parent/scene as the source.\n */\nexport function createGhostRobot(\n robot: ThreeUsdRobot,\n options: GhostRobotOptions = {},\n): ThreeUsdRobot {\n const ghost = new ThreeUsdRobot(robot.robot, robot.tree, {\n clampJointLimits: robot.clampJointLimits,\n applyInitialPose: false,\n upAxisConversion: \"none\",\n });\n ghost.name = `${robot.name}_ghost`;\n // Mirror the source root exactly (stage normalization + any user transform).\n ghost.position.copy(robot.position);\n ghost.quaternion.copy(robot.quaternion);\n ghost.scale.copy(robot.scale);\n\n const material =\n options.material ??\n new THREE.MeshStandardMaterial({\n color: options.color ?? 0x66aaff,\n transparent: true,\n opacity: options.opacity ?? 0.35,\n depthWrite: false,\n metalness: 0,\n roughness: 1,\n });\n\n const kind = options.kind ?? \"visual\";\n for (const key of robot.getLinkNames()) {\n const target = ghost.getLinkObject(key);\n if (!target) continue;\n for (const src of getLinkMeshes(robot, key, kind)) {\n const mesh = new THREE.Mesh(src.geometry, material);\n mesh.name = `${src.name}_ghost`;\n mesh.userData.kind = \"ghost\";\n mesh.userData.primPath = (src.userData as { primPath?: string }).primPath;\n mesh.matrixAutoUpdate = false;\n mesh.matrix.copy(src.matrix);\n mesh.matrixWorldNeedsUpdate = true;\n target.add(mesh);\n }\n }\n\n for (const name of robot.getJointNames()) {\n const value = robot.getJointValue(name);\n if (value !== undefined) ghost.setJointValue(name, value);\n }\n if (options.jointValues) ghost.setJointValues(options.jointValues);\n return ghost;\n}\n","import * as THREE from \"three\";\nimport type { JointObject } from \"../three/JointObject.js\";\n\n/**\n * An arrow drawn along a joint's motion axis (the rotation axis for\n * revolute/continuous joints, the slide direction for prismatic). Add it to the\n * joint's motion node so it tracks the joint.\n */\nexport class JointAxisHelper extends THREE.ArrowHelper {\n readonly isJointAxisHelper = true;\n\n constructor(joint: JointObject, length = 0.2, color: THREE.ColorRepresentation = 0xffd000) {\n super(joint.axis.clone().normalize(), new THREE.Vector3(0, 0, 0), length, color);\n this.name = `${joint.jointName}:axis`;\n }\n}\n","import * as THREE from \"three\";\nimport type { JointObject } from \"../three/JointObject.js\";\n\n/**\n * Visualizes a joint's range of motion: an arc swept between the lower and\n * upper limits (revolute/continuous) or a line segment between them\n * (prismatic). A limitless revolute joint draws a full circle. Add it to the\n * joint's motion node's parent frame (or the joint node) to anchor it.\n */\nexport class JointLimitHelper extends THREE.Line {\n readonly isJointLimitHelper = true;\n\n constructor(joint: JointObject, radius = 0.15, color: THREE.ColorRepresentation = 0x00aaff) {\n super(buildLimitGeometry(joint, radius), new THREE.LineBasicMaterial({ color }));\n this.name = `${joint.jointName}:limit`;\n }\n}\n\nfunction buildLimitGeometry(joint: JointObject, radius: number): THREE.BufferGeometry {\n const axis = joint.axis.clone().normalize();\n\n if (joint.jointType === \"prismatic\") {\n const lo = joint.lower ?? -radius;\n const hi = joint.upper ?? radius;\n return new THREE.BufferGeometry().setFromPoints([\n axis.clone().multiplyScalar(lo),\n axis.clone().multiplyScalar(hi),\n ]);\n }\n\n // Revolute / continuous: sweep an arc in the plane perpendicular to the axis.\n const lo = joint.lower ?? 0;\n const hi = joint.upper ?? Math.PI * 2;\n const { u, v } = perpendicularBasis(axis);\n const segments = 48;\n const points: THREE.Vector3[] = [];\n for (let i = 0; i <= segments; i++) {\n const t = lo + ((hi - lo) * i) / segments;\n points.push(\n u\n .clone()\n .multiplyScalar(Math.cos(t) * radius)\n .addScaledVector(v, Math.sin(t) * radius),\n );\n }\n return new THREE.BufferGeometry().setFromPoints(points);\n}\n\nfunction perpendicularBasis(axis: THREE.Vector3): { u: THREE.Vector3; v: THREE.Vector3 } {\n const ref = Math.abs(axis.x) < 0.9 ? new THREE.Vector3(1, 0, 0) : new THREE.Vector3(0, 1, 0);\n const u = new THREE.Vector3().crossVectors(axis, ref).normalize();\n const v = new THREE.Vector3().crossVectors(axis, u).normalize();\n return { u, v };\n}\n","import * as THREE from \"three\";\n\n/** A small RGB axes gizmo for a link's local frame. Add it to a `LinkObject`. */\nexport class LinkFrameHelper extends THREE.AxesHelper {\n readonly isLinkFrameHelper = true;\n\n constructor(size = 0.2) {\n super(size);\n this.name = \"linkFrame\";\n }\n}\n","import type * as THREE from \"three\";\nimport type { ThreeUsdRobot } from \"../three/ThreeUsdRobot.js\";\nimport { JointAxisHelper } from \"./JointAxisHelper.js\";\nimport { JointLimitHelper } from \"./JointLimitHelper.js\";\nimport { LinkFrameHelper } from \"./LinkFrameHelper.js\";\n\n/** Attach a {@link JointAxisHelper} to every articulated joint. Returns the helpers. */\nexport function addJointAxisHelpers(\n robot: ThreeUsdRobot,\n length?: number,\n color?: THREE.ColorRepresentation,\n): JointAxisHelper[] {\n const out: JointAxisHelper[] = [];\n for (const name of robot.getJointNames()) {\n const joint = robot.getJointObject(name);\n if (!joint?.articulated) continue;\n const helper = new JointAxisHelper(joint, length, color);\n joint.add(helper);\n out.push(helper);\n }\n return out;\n}\n\n/** Attach a {@link JointLimitHelper} to every articulated joint. Returns the helpers. */\nexport function addJointLimitHelpers(\n robot: ThreeUsdRobot,\n radius?: number,\n color?: THREE.ColorRepresentation,\n): JointLimitHelper[] {\n const out: JointLimitHelper[] = [];\n for (const name of robot.getJointNames()) {\n const joint = robot.getJointObject(name);\n if (!joint?.articulated) continue;\n const helper = new JointLimitHelper(joint, radius, color);\n joint.add(helper);\n out.push(helper);\n }\n return out;\n}\n\n/** Attach a {@link LinkFrameHelper} to every link. Returns the helpers. */\nexport function addLinkFrameHelpers(robot: ThreeUsdRobot, size?: number): LinkFrameHelper[] {\n const out: LinkFrameHelper[] = [];\n for (const name of robot.getLinkNames()) {\n const link = robot.getLinkObject(name);\n if (!link) continue;\n const helper = new LinkFrameHelper(size);\n link.add(helper);\n out.push(helper);\n }\n return out;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/helpers/appearance.ts","../src/helpers/JointAxisHelper.ts","../src/helpers/JointLimit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,MAAM,CAAA;AAAA,EACjB;AACA,EAAA,OAAO,GAAA;AACT","file":"helpers.js","sourcesContent":["/**\n * Per-link appearance helpers: highlight (tint), material replacement, and\n * translucent \"ghost\" clones for pose previews.\n *\n * Material overrides are reversible — the original materials are kept aside on\n * first override and put back exactly by {@link restoreLinkMaterials} /\n * {@link restoreAllLinkMaterials}. Links are addressed like everywhere else:\n * by key or by full prim path.\n */\n\nimport * as THREE from \"three\";\nimport { ThreeUsdRobot } from \"../three/ThreeUsdRobot.js\";\n\n/** Which meshes of a link an operation affects. */\nexport type LinkMeshKind = \"visual\" | \"collision\" | \"all\";\n\n/** Originals saved on first override (per mesh; first save wins until restore). */\nconst savedMaterials = new WeakMap<THREE.Mesh, THREE.Material | THREE.Material[]>();\n\n/** Marks materials created by {@link highlightLink}, so restore can dispose them. */\nconst HIGHLIGHT_FLAG = \"__threeUsdRobotHighlight\";\n\n/**\n * The meshes belonging to exactly this link — not those of child links, which\n * live under their own `LinkObject` deeper in the kinematic chain. Helpers and\n * joint-frame groups are excluded.\n */\nexport function getLinkMeshes(\n robot: ThreeUsdRobot,\n link: string,\n kind: LinkMeshKind = \"all\",\n): THREE.Mesh[] {\n const obj = robot.getLinkObject(link);\n if (!obj) return [];\n const out: THREE.Mesh[] = [];\n for (const child of obj.children) {\n const mesh = child as THREE.Mesh;\n if (!mesh.isMesh) continue;\n const k = (mesh.userData as { kind?: string }).kind;\n if (k !== \"visual\" && k !== \"collision\") continue;\n if (kind !== \"all\" && k !== kind) continue;\n out.push(mesh);\n }\n return out;\n}\n\nexport type HighlightLinkOptions = {\n /** Highlight color (default red `0xff4444`). */\n color?: THREE.ColorRepresentation;\n /** Emissive strength of the tint (default `0.8`). */\n emissiveIntensity?: number;\n /** Force translucency while highlighted (e.g. `0.5`); default keeps the material's own. */\n opacity?: number;\n /** Which meshes of the link to affect (default `\"visual\"`). */\n kind?: LinkMeshKind;\n};\n\n/**\n * Tint a link's meshes (emissive red by default) while keeping their maps and\n * base colors — e.g. to flag a colliding link. Repeated calls re-tint from the\n * *original* materials, so highlights don't stack; restore with\n * {@link restoreLinkMaterials}. Returns `false` when the link has no matching\n * meshes.\n */\nexport function highlightLink(\n robot: ThreeUsdRobot,\n link: string,\n options: HighlightLinkOptions = {},\n): boolean {\n const meshes = getLinkMeshes(robot, link, options.kind ?? \"visual\");\n if (meshes.length === 0) return false;\n\n const color = new THREE.Color(options.color ?? 0xff4444);\n for (const mesh of meshes) {\n if (!savedMaterials.has(mesh)) savedMaterials.set(mesh, mesh.material);\n const base = savedMaterials.get(mesh)!;\n disposeHighlightClones(mesh.material);\n mesh.material = Array.isArray(base)\n ? base.map((m) => tintClone(m, color, options))\n : tintClone(base, color, options);\n }\n return true;\n}\n\nfunction tintClone(\n base: THREE.Material,\n color: THREE.Color,\n options: HighlightLinkOptions,\n): THREE.Material {\n const m = base.clone();\n m.userData[HIGHLIGHT_FLAG] = true;\n const std = m as THREE.MeshStandardMaterial;\n if (std.isMeshStandardMaterial) {\n std.emissive.copy(color);\n std.emissiveIntensity = options.emissiveIntensity ?? 0.8;\n } else if (\"color\" in m) {\n (m as THREE.MeshBasicMaterial).color.copy(color);\n }\n if (options.opacity !== undefined) {\n m.transparent = options.opacity < 1;\n m.opacity = options.opacity;\n }\n return m;\n}\n\n/**\n * Replace a link's mesh materials with `material` (one shared instance). The\n * caller keeps ownership — it is never disposed here. Restore the originals\n * with {@link restoreLinkMaterials}. Returns `false` when the link has no\n * matching meshes.\n */\nexport function setLinkMaterial(\n robot: ThreeUsdRobot,\n link: string,\n material: THREE.Material,\n kind: LinkMeshKind = \"visual\",\n): boolean {\n const meshes = getLinkMeshes(robot, link, kind);\n if (meshes.length === 0) return false;\n for (const mesh of meshes) {\n if (!savedMaterials.has(mesh)) savedMaterials.set(mesh, mesh.material);\n disposeHighlightClones(mesh.material);\n mesh.material = material;\n }\n return true;\n}\n\n/** Put back a link's original materials (no-op for untouched meshes). */\nexport function restoreLinkMaterials(robot: ThreeUsdRobot, link: string): void {\n for (const mesh of getLinkMeshes(robot, link, \"all\")) {\n const original = savedMaterials.get(mesh);\n if (original === undefined) continue;\n disposeHighlightClones(mesh.material);\n mesh.material = original;\n savedMaterials.delete(mesh);\n }\n}\n\n/** Put back the original materials of every link of the robot. */\nexport function restoreAllLinkMaterials(robot: ThreeUsdRobot): void {\n for (const name of robot.getLinkNames()) restoreLinkMaterials(robot, name);\n}\n\n/** Dispose materials created by {@link highlightLink} (never user-supplied ones). */\nfunction disposeHighlightClones(current: THREE.Material | THREE.Material[]): void {\n for (const m of Array.isArray(current) ? current : [current]) {\n if (m.userData[HIGHLIGHT_FLAG]) m.dispose();\n }\n}\n\nexport type GhostRobotOptions = {\n /** Ghost tint (default `0x66aaff`). */\n color?: THREE.ColorRepresentation;\n /** Ghost opacity (default `0.35`). */\n opacity?: number;\n /** Complete material override; `color` / `opacity` are ignored when given. */\n material?: THREE.Material;\n /** Which meshes to clone (default `\"visual\"`). */\n kind?: \"visual\" | \"collision\";\n /** Joint overrides applied on top of the source robot's current pose. */\n jointValues?: Record<string, number>;\n};\n\n/**\n * Build a translucent clone of the robot for pose previews (target pose,\n * onion-skinning). Geometry is shared with the source; every mesh uses one\n * ghost material and is tagged `userData.kind = \"ghost\"`, so the source's\n * `showVisual` / `showCollision` toggles never affect it. The clone is a full\n * {@link ThreeUsdRobot} — drive it with `setJointValues` — starting from the\n * source's current joint values (plus `jointValues` overrides) and mirroring\n * its root transform. Add it to the same parent/scene as the source.\n */\nexport function createGhostRobot(\n robot: ThreeUsdRobot,\n options: GhostRobotOptions = {},\n): ThreeUsdRobot {\n const ghost = new ThreeUsdRobot(robot.robot, robot.tree, {\n clampJointLimits: robot.clampJointLimits,\n applyInitialPose: false,\n upAxisConversion: \"none\",\n });\n ghost.name = `${robot.name}_ghost`;\n // Mirror the source root exactly (stage normalization + any user transform).\n ghost.position.copy(robot.position);\n ghost.quaternion.copy(robot.quaternion);\n ghost.scale.copy(robot.scale);\n\n const material =\n options.material ??\n new THREE.MeshStandardMaterial({\n color: options.color ?? 0x66aaff,\n transparent: true,\n opacity: options.opacity ?? 0.35,\n depthWrite: false,\n metalness: 0,\n roughness: 1,\n });\n\n const kind = options.kind ?? \"visual\";\n for (const key of robot.getLinkNames()) {\n const target = ghost.getLinkObject(key);\n if (!target) continue;\n for (const src of getLinkMeshes(robot, key, kind)) {\n const mesh = new THREE.Mesh(src.geometry, material);\n mesh.name = `${src.name}_ghost`;\n mesh.userData.kind = \"ghost\";\n mesh.userData.primPath = (src.userData as { primPath?: string }).primPath;\n mesh.matrixAutoUpdate = false;\n mesh.matrix.copy(src.matrix);\n mesh.matrixWorldNeedsUpdate = true;\n target.add(mesh);\n }\n }\n\n for (const name of robot.getJointNames()) {\n const value = robot.getJointValue(name);\n if (value !== undefined) ghost.setJointValue(name, value);\n }\n if (options.jointValues) ghost.setJointValues(options.jointValues);\n return ghost;\n}\n","import * as THREE from \"three\";\nimport type { JointObject } from \"../three/JointObject.js\";\n\n/**\n * An arrow drawn along a joint's motion axis (the rotation axis for\n * revolute/continuous joints, the slide direction for prismatic). Add it to the\n * joint's motion node so it tracks the joint.\n */\nexport class JointAxisHelper extends THREE.ArrowHelper {\n readonly isJointAxisHelper = true;\n\n constructor(joint: JointObject, length = 0.2, color: THREE.ColorRepresentation = 0xffd000) {\n super(joint.axis.clone().normalize(), new THREE.Vector3(0, 0, 0), length, color);\n this.name = `${joint.jointName}:axis`;\n }\n}\n","import * as THREE from \"three\";\nimport type { JointObject } from \"../three/JointObject.js\";\n\n/**\n * Visualizes a joint's range of motion: an arc swept between the lower and\n * upper limits (revolute/continuous) or a line segment between them\n * (prismatic). A limitless revolute joint draws a full circle. Add it to the\n * joint's motion node's parent frame (or the joint node) to anchor it.\n */\nexport class JointLimitHelper extends THREE.Line {\n readonly isJointLimitHelper = true;\n\n constructor(joint: JointObject, radius = 0.15, color: THREE.ColorRepresentation = 0x00aaff) {\n super(buildLimitGeometry(joint, radius), new THREE.LineBasicMaterial({ color }));\n this.name = `${joint.jointName}:limit`;\n }\n}\n\nfunction buildLimitGeometry(joint: JointObject, radius: number): THREE.BufferGeometry {\n const axis = joint.axis.clone().normalize();\n\n if (joint.jointType === \"prismatic\") {\n const lo = joint.lower ?? -radius;\n const hi = joint.upper ?? radius;\n return new THREE.BufferGeometry().setFromPoints([\n axis.clone().multiplyScalar(lo),\n axis.clone().multiplyScalar(hi),\n ]);\n }\n\n // Revolute / continuous: sweep an arc in the plane perpendicular to the axis.\n const lo = joint.lower ?? 0;\n const hi = joint.upper ?? Math.PI * 2;\n const { u, v } = perpendicularBasis(axis);\n const segments = 48;\n const points: THREE.Vector3[] = [];\n for (let i = 0; i <= segments; i++) {\n const t = lo + ((hi - lo) * i) / segments;\n points.push(\n u\n .clone()\n .multiplyScalar(Math.cos(t) * radius)\n .addScaledVector(v, Math.sin(t) * radius),\n );\n }\n return new THREE.BufferGeometry().setFromPoints(points);\n}\n\nfunction perpendicularBasis(axis: THREE.Vector3): { u: THREE.Vector3; v: THREE.Vector3 } {\n const ref = Math.abs(axis.x) < 0.9 ? new THREE.Vector3(1, 0, 0) : new THREE.Vector3(0, 1, 0);\n const u = new THREE.Vector3().crossVectors(axis, ref).normalize();\n const v = new THREE.Vector3().crossVectors(axis, u).normalize();\n return { u, v };\n}\n","import * as THREE from \"three\";\n\n/** A small RGB axes gizmo for a link's local frame. Add it to a `LinkObject`. */\nexport class LinkFrameHelper extends THREE.AxesHelper {\n readonly isLinkFrameHelper = true;\n\n constructor(size = 0.2) {\n super(size);\n this.name = \"linkFrame\";\n }\n}\n","import type * as THREE from \"three\";\nimport type { ThreeUsdRobot } from \"../three/ThreeUsdRobot.js\";\nimport { JointAxisHelper } from \"./JointAxisHelper.js\";\nimport { JointLimitHelper } from \"./JointLimitHelper.js\";\nimport { LinkFrameHelper } from \"./LinkFrameHelper.js\";\n\n/** Attach a {@link JointAxisHelper} to every articulated joint. Returns the helpers. */\nexport function addJointAxisHelpers(\n robot: ThreeUsdRobot,\n length?: number,\n color?: THREE.ColorRepresentation,\n): JointAxisHelper[] {\n const out: JointAxisHelper[] = [];\n for (const name of robot.getJointNames()) {\n const joint = robot.getJointObject(name);\n if (!joint?.articulated) continue;\n const helper = new JointAxisHelper(joint, length, color);\n joint.add(helper);\n out.push(helper);\n }\n return out;\n}\n\n/** Attach a {@link JointLimitHelper} to every articulated joint. Returns the helpers. */\nexport function addJointLimitHelpers(\n robot: ThreeUsdRobot,\n radius?: number,\n color?: THREE.ColorRepresentation,\n): JointLimitHelper[] {\n const out: JointLimitHelper[] = [];\n for (const name of robot.getJointNames()) {\n const joint = robot.getJointObject(name);\n if (!joint?.articulated) continue;\n const helper = new JointLimitHelper(joint, radius, color);\n joint.add(helper);\n out.push(helper);\n }\n return out;\n}\n\n/** Attach a {@link LinkFrameHelper} to every link. Returns the helpers. */\nexport function addLinkFrameHelpers(robot: ThreeUsdRobot, size?: number): LinkFrameHelper[] {\n const out: LinkFrameHelper[] = [];\n for (const name of robot.getLinkNames()) {\n const link = robot.getLinkObject(name);\n if (!link) continue;\n const helper = new LinkFrameHelper(size);\n link.add(helper);\n out.push(helper);\n }\n return out;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,269 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { ARTICULATION_ROOT_API, COLLISION_API, ComposeOptions, CrateReader, ExtractOptions, JointDofInput, JointRelativeDecomposition, MASS_API, MESH_COLLISION_API,
|
|
1
|
+
import { CollisionApproximation, ExportPhysicsMaterial, RobotGeometryProvider, ExportRobotOptions, ExportMaterial, ExportMesh } from './core.js';
|
|
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,
|
|
5
|
-
export {
|
|
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
|
-
|
|
9
|
-
export {
|
|
10
|
-
export { a as
|
|
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
|
+
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
|
+
export { B as BinarySource, U as UsdSource, t as toBytes } from './bytes-CxGRGry_.js';
|
|
11
12
|
|
|
12
13
|
/** Unit vector for a USD joint axis token. Returns a fresh vector each call. */
|
|
13
14
|
declare function axisVector(axis: Axis): THREE.Vector3;
|
|
14
15
|
|
|
15
|
-
/**
|
|
16
|
-
* Resolves `UsdShade` material bindings to flat PBR parameters.
|
|
17
|
-
*
|
|
18
|
-
* Follows a prim's (or an ancestor's) `material:binding` to a `Material`, finds
|
|
19
|
-
* its surface `Shader`, and reads constant color/metalness/roughness/opacity/
|
|
20
|
-
* emissive inputs plus the **texture** asset paths for the diffuse, normal,
|
|
21
|
-
* roughness, metallic, occlusion and emissive channels. Handles both
|
|
22
|
-
* `UsdPreviewSurface` (constant inputs or a connected `UsdUVTexture` network)
|
|
23
|
-
* and the Omniverse MDL material families (M20): `OmniPBR` (and derivatives
|
|
24
|
-
* such as `OmniPBR_Opacity`), `OmniPBR_ClearCoat`, `OmniGlass`, and an
|
|
25
|
-
* `OmniSurface(Lite)` constants subset. MDL shaders are identified by
|
|
26
|
-
* `info:mdl:sourceAsset` / `:subIdentifier`; when the referenced `.mdl` module
|
|
27
|
-
* text is available (see `loadMdlModules`), parameter values fall back from
|
|
28
|
-
* authored USD inputs to the module's wrapper arguments and declaration
|
|
29
|
-
* defaults. Executing MDL remains out of scope.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/** `UsdUVTexture` wrap mode for one axis (`black` ≈ clamp; three has no border). */
|
|
33
|
-
type TextureWrap = "repeat" | "clamp" | "mirror" | "black";
|
|
34
|
-
/** `UsdTransform2d` applied to the `st` coords feeding a texture. */
|
|
35
|
-
type TextureTransform = {
|
|
36
|
-
/** `inputs:translation` (UV offset). */
|
|
37
|
-
translation?: Vec2;
|
|
38
|
-
/** `inputs:rotation` in degrees (CCW about the origin). */
|
|
39
|
-
rotation?: number;
|
|
40
|
-
/** `inputs:scale` (UV tiling). */
|
|
41
|
-
scale?: Vec2;
|
|
42
|
-
};
|
|
43
|
-
/** A resolved texture reference plus its `UsdUVTexture` sampler/transform state. */
|
|
44
|
-
type ResolvedTexture = {
|
|
45
|
-
/** Authored asset path of the image. */
|
|
46
|
-
path: string;
|
|
47
|
-
wrapS?: TextureWrap;
|
|
48
|
-
wrapT?: TextureWrap;
|
|
49
|
-
/** `UsdTransform2d` on the `st` input, if any. */
|
|
50
|
-
transform?: TextureTransform;
|
|
51
|
-
/** `inputs:scale` — multiplies the sampled value (folded into material factors). */
|
|
52
|
-
scale?: [number, number, number, number];
|
|
53
|
-
/** `inputs:bias` — added to the sampled value. */
|
|
54
|
-
bias?: [number, number, number, number];
|
|
55
|
-
/**
|
|
56
|
-
* UV-set (primvar) name the texture reads, resolved through the `inputs:st`
|
|
57
|
-
* connection to a `UsdPrimvarReader_float2.inputs:varname`. Absent ⇒ `"st"`.
|
|
58
|
-
*/
|
|
59
|
-
uvSet?: string;
|
|
60
|
-
/** `inputs:sourceColorSpace` — overrides the per-channel colorspace default. */
|
|
61
|
-
sourceColorSpace?: "raw" | "sRGB" | "auto";
|
|
62
|
-
/**
|
|
63
|
-
* Which output the consuming input connects to (`outputs:r` → `"r"`, …).
|
|
64
|
-
* three.js samples fixed channels (roughness = G, metalness = B, ao = R);
|
|
65
|
-
* a mismatch is surfaced as a load warning.
|
|
66
|
-
*/
|
|
67
|
-
outputChannel?: "r" | "g" | "b" | "a" | "rgb";
|
|
68
|
-
};
|
|
69
|
-
type ResolvedMaterial = {
|
|
70
|
-
/** Name of the bound `Material` prim, for round-tripping and debugging. */
|
|
71
|
-
name?: string;
|
|
72
|
-
color?: Vec3;
|
|
73
|
-
opacity?: number;
|
|
74
|
-
metalness?: number;
|
|
75
|
-
roughness?: number;
|
|
76
|
-
emissiveColor?: Vec3;
|
|
77
|
-
/**
|
|
78
|
-
* `inputs:opacityThreshold`. When `> 0`, opacity is a binary mask (alpha
|
|
79
|
-
* clip / cutout); when `0`/absent, sub-unit opacity blends translucently.
|
|
80
|
-
*/
|
|
81
|
-
opacityThreshold?: number;
|
|
82
|
-
/** `inputs:ior` — promotes the three material to `MeshPhysicalMaterial`. */
|
|
83
|
-
ior?: number;
|
|
84
|
-
/** `inputs:clearcoat` (physical promotion). */
|
|
85
|
-
clearcoat?: number;
|
|
86
|
-
/** `inputs:clearcoatRoughness` (physical promotion). */
|
|
87
|
-
clearcoatRoughness?: number;
|
|
88
|
-
/** `inputs:specularColor`, only when `inputs:useSpecularWorkflow = 1`. */
|
|
89
|
-
specularColor?: Vec3;
|
|
90
|
-
/** OmniPBR `inputs:emissive_intensity` — multiplies the emissive color. */
|
|
91
|
-
emissiveIntensity?: number;
|
|
92
|
-
/** OmniGlass — `1` marks a transmissive dielectric (physical promotion, M20). */
|
|
93
|
-
transmission?: number;
|
|
94
|
-
/** OmniGlass `inputs:depth` — refraction volume thickness (scene units, M20). */
|
|
95
|
-
thickness?: number;
|
|
96
|
-
/** Diffuse/albedo texture, if any. */
|
|
97
|
-
colorTexture?: ResolvedTexture;
|
|
98
|
-
/** Opacity / alpha texture (may be the same image as `colorTexture`). */
|
|
99
|
-
opacityTexture?: ResolvedTexture;
|
|
100
|
-
/** Tangent-space normal map, if any. */
|
|
101
|
-
normalTexture?: ResolvedTexture;
|
|
102
|
-
/** Roughness map, if any. */
|
|
103
|
-
roughnessTexture?: ResolvedTexture;
|
|
104
|
-
/** Metallic map, if any. */
|
|
105
|
-
metalnessTexture?: ResolvedTexture;
|
|
106
|
-
/** Ambient-occlusion map, if any. */
|
|
107
|
-
occlusionTexture?: ResolvedTexture;
|
|
108
|
-
/** Emissive map, if any. */
|
|
109
|
-
emissiveTexture?: ResolvedTexture;
|
|
110
|
-
/** OmniPBR_ClearCoat `clearcoat_normalmap_texture` (physical promotion, M20). */
|
|
111
|
-
clearcoatNormalTexture?: ResolvedTexture;
|
|
112
|
-
};
|
|
113
|
-
type ResolveMaterialOptions = {
|
|
114
|
-
/** Parsed `.mdl` modules for MDL family detection and value fallback (M20). */
|
|
115
|
-
mdl?: MdlModuleProvider;
|
|
116
|
-
/** Receives diagnostics (unknown MDL material families). */
|
|
117
|
-
onWarn?: (message: string) => void;
|
|
118
|
-
};
|
|
119
|
-
/** Resolve the bound material's flat parameters for `prim`, or `undefined`. */
|
|
120
|
-
declare function resolveBoundMaterial(stage: Stage, prim: Prim, options?: ResolveMaterialOptions): ResolvedMaterial | undefined;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Loads texture image assets referenced by `UsdShade` materials.
|
|
124
|
-
*
|
|
125
|
-
* A {@link TextureProvider} maps an authored asset path (plus sampler/transform
|
|
126
|
-
* options) to a `THREE.Texture`. The default provider fetches the image **bytes**
|
|
127
|
-
* through the {@link AssetResolver} and decodes them via a blob URL — so it works
|
|
128
|
-
* uniformly for textures served over HTTP and for images embedded inside a
|
|
129
|
-
* `.usdz` package (whose resolver serves zip entries, not real URLs). Decoded
|
|
130
|
-
* images are cached per resolved URL and shared across every texture that uses
|
|
131
|
-
* them; each `THREE.Texture` carries its own color space / wrap / transform.
|
|
132
|
-
*/
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Color space to interpret a texture in. Color/albedo and emissive maps are
|
|
136
|
-
* `"srgb"`; data maps (normal, roughness, metalness, occlusion) are `"linear"`.
|
|
137
|
-
*/
|
|
138
|
-
type TextureColorSpace = "srgb" | "linear";
|
|
139
|
-
/** Per-use sampler state applied to the returned `THREE.Texture`. */
|
|
140
|
-
type TextureOptions = {
|
|
141
|
-
/** Defaults to `"srgb"`. */
|
|
142
|
-
colorSpace?: TextureColorSpace;
|
|
143
|
-
wrapS?: TextureWrap;
|
|
144
|
-
wrapT?: TextureWrap;
|
|
145
|
-
transform?: TextureTransform;
|
|
146
|
-
/** UV channel index (0 = `uv`, 1 = `uv1`, …) for multi-UV-set meshes. */
|
|
147
|
-
channel?: number;
|
|
148
|
-
};
|
|
149
|
-
/** Resolve an authored texture asset path to a `THREE.Texture` (or `null`). */
|
|
150
|
-
type TextureProvider = (assetPath: string, options?: TextureOptions) => THREE.Texture | null;
|
|
151
|
-
/**
|
|
152
|
-
* A {@link TextureProvider} backed by the {@link AssetResolver}, resolving paths
|
|
153
|
-
* against `baseUrl`. Image bytes are fetched once per URL (works for HTTP and
|
|
154
|
-
* `.usdz` entries alike) and the decoded image is shared; each call returns a
|
|
155
|
-
* distinct `THREE.Texture` carrying the requested color space / wrap / transform.
|
|
156
|
-
*/
|
|
157
|
-
declare function createTextureProvider(resolver: AssetResolver, baseUrl: string): TextureProvider;
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Binds renderable gprims — `UsdGeom.Mesh` plus the parametric solids (`Cube` /
|
|
161
|
-
* `Sphere` / `Cylinder` / `Capsule` / `Cone`) — to Three.js geometry and
|
|
162
|
-
* attaches them under the robot's link objects.
|
|
163
|
-
*
|
|
164
|
-
* Meshes are triangulated with a simple fan. Primvars (`st` UV sets, `normals`,
|
|
165
|
-
* `displayColor`) resolve with USD interpolation semantics — `:indices`
|
|
166
|
-
* de-referencing, vertex vs faceVarying (de-indexed) layouts, multiple UV
|
|
167
|
-
* channels. Solids tessellate from their schema attributes. Geometry is left
|
|
168
|
-
* in stage units; the global `metersPerUnit` scale is applied at the root in M9.
|
|
169
|
-
*/
|
|
170
|
-
|
|
171
|
-
type MeshKind = "visual" | "collision";
|
|
172
|
-
type BindMeshesOptions = {
|
|
173
|
-
loadVisuals?: boolean;
|
|
174
|
-
loadCollisions?: boolean;
|
|
175
|
-
/** Resolves diffuse texture asset paths to `THREE.Texture` (M-tex). */
|
|
176
|
-
textureProvider?: TextureProvider;
|
|
177
|
-
/** Render `BasisCurves` with authored `widths` as tube meshes (M18). */
|
|
178
|
-
curveTubes?: boolean;
|
|
179
|
-
/** Receives fidelity diagnostics (channel-packing mismatches, M19). */
|
|
180
|
-
onWarn?: (message: string) => void;
|
|
181
|
-
/** Parsed `.mdl` modules for MDL material family/value resolution (M20). */
|
|
182
|
-
mdl?: MdlModuleProvider;
|
|
183
|
-
};
|
|
184
|
-
/**
|
|
185
|
-
* Build a `BufferGeometry` from a Mesh prim, or `null` if it has no points.
|
|
186
|
-
*
|
|
187
|
-
* Primvars resolve with full interpolation semantics (M19): `:indices` arrays
|
|
188
|
-
* are de-referenced, vertex-interpolated `st` sets / `normals` /
|
|
189
|
-
* `displayColor` bind onto the shared vertices, and any faceVarying primvar
|
|
190
|
-
* (or per-face color) switches the mesh to a de-indexed layout where every
|
|
191
|
-
* face corner owns its vertex. Extra UV sets become `uv1`, `uv2`, … in
|
|
192
|
-
* {@link meshUvSetNames} order.
|
|
193
|
-
*
|
|
194
|
-
* When the mesh carries `materialBind` face subsets, the triangles are ordered
|
|
195
|
-
* subset by subset and a geometry group is added for each — so the mesh can be
|
|
196
|
-
* drawn with one material per subset (see {@link buildMeshMaterials}). Group
|
|
197
|
-
* order matches {@link getMaterialSubsets}, with any unassigned faces last.
|
|
198
|
-
*/
|
|
199
|
-
declare function buildMeshGeometry(meshPrim: Prim): THREE.BufferGeometry | null;
|
|
200
|
-
/**
|
|
201
|
-
* Build geometry for any renderable gprim: `Mesh` via {@link buildMeshGeometry},
|
|
202
|
-
* parametric solids from their schema attributes. Solids follow UsdGeom
|
|
203
|
-
* semantics — sizes in stage units, centered at the origin, `axis` (default
|
|
204
|
-
* `"Z"`) along the spine, and a capsule's `height` spans only its cylindrical
|
|
205
|
-
* section. Returns `null` for unsupported prim types.
|
|
206
|
-
*/
|
|
207
|
-
declare function buildGprimGeometry(prim: Prim): THREE.BufferGeometry | null;
|
|
208
|
-
type BuildGprimOptions = {
|
|
209
|
-
/** Resolves texture asset paths for mesh materials. */
|
|
210
|
-
textureProvider?: TextureProvider;
|
|
211
|
-
/**
|
|
212
|
-
* Render `BasisCurves` that author `widths` as tube meshes instead of
|
|
213
|
-
* 1-px lines (default `false`).
|
|
214
|
-
*/
|
|
215
|
-
curveTubes?: boolean;
|
|
216
|
-
/** Receives fidelity diagnostics (channel-packing mismatches, M19). */
|
|
217
|
-
onWarn?: (message: string) => void;
|
|
218
|
-
/** Parsed `.mdl` modules for MDL material family/value resolution (M20). */
|
|
219
|
-
mdl?: MdlModuleProvider;
|
|
220
|
-
};
|
|
221
|
-
/**
|
|
222
|
-
* Build a renderable `THREE.Object3D` for any supported gprim (M18):
|
|
223
|
-
* `Mesh` and the parametric solids become a `THREE.Mesh` (via
|
|
224
|
-
* {@link buildGprimGeometry} + {@link buildMeshMaterials}), `Points` a
|
|
225
|
-
* `THREE.Points`, and `BasisCurves` a `THREE.Group` holding one line — or,
|
|
226
|
-
* with {@link BuildGprimOptions.curveTubes}, one tube mesh — per curve.
|
|
227
|
-
* Returns `null` for unsupported prim types and degenerate geometry.
|
|
228
|
-
*/
|
|
229
|
-
declare function buildGprimObject(prim: Prim, stage?: Stage, options?: BuildGprimOptions): THREE.Object3D | null;
|
|
230
|
-
/**
|
|
231
|
-
* Build a material for a gprim. Color priority: bound `UsdShade` material
|
|
232
|
-
* (when `stage` is given) → `primvars:displayColor` → default gray. Textures
|
|
233
|
-
* (via `textures`) become the matching `MeshStandardMaterial` maps — diffuse →
|
|
234
|
-
* `map` (sRGB), plus `normalMap` / `roughnessMap` / `metalnessMap` / `aoMap`
|
|
235
|
-
* (linear data) and emissive `emissiveMap`. Metalness / roughness / opacity /
|
|
236
|
-
* emissive constants come from the bound material when present.
|
|
237
|
-
*/
|
|
238
|
-
declare function buildMeshMaterial(meshPrim: Prim, stage?: Stage, textures?: TextureProvider,
|
|
239
|
-
/** Resolve the material binding from here instead (a `GeomSubset`). */
|
|
240
|
-
bindingPrim?: Prim,
|
|
241
|
-
/** Receives fidelity diagnostics (channel-packing mismatches, M19). */
|
|
242
|
-
onWarn?: (message: string) => void,
|
|
243
|
-
/** Parsed `.mdl` modules for MDL material family/value resolution (M20). */
|
|
244
|
-
mdl?: MdlModuleProvider): THREE.Material;
|
|
245
|
-
/**
|
|
246
|
-
* Attach visual (and optionally collision) meshes to every link of a built
|
|
247
|
-
* {@link ThreeUsdRobot}. Each mesh is positioned by its transform relative to
|
|
248
|
-
* the owning link prim.
|
|
249
|
-
*/
|
|
250
|
-
declare function bindRobotMeshes(stage: Stage, robot3d: ThreeUsdRobot, desc: RobotDescription, options?: BindMeshesOptions): void;
|
|
251
|
-
/**
|
|
252
|
-
* Attach the gprims that belong to no link — the static scenery of a cell that
|
|
253
|
-
* also contains robots. The authored prim hierarchy is mirrored with
|
|
254
|
-
* `THREE.Group` nodes (each carrying `userData.primPath` and its prim's local
|
|
255
|
-
* transform), so grouped scenery — a pallet and its cartons, a fence and its
|
|
256
|
-
* wires — stays one movable subtree. World placements are unchanged, and the
|
|
257
|
-
* loader's up-axis and unit normalization still applies at the robot root.
|
|
258
|
-
* Collision-only and guide/proxy prims are skipped.
|
|
259
|
-
*/
|
|
260
|
-
declare function bindSceneMeshes(stage: Stage, robot3d: ThreeUsdRobot, desc: RobotDescription, options?: {
|
|
261
|
-
textureProvider?: TextureProvider;
|
|
262
|
-
curveTubes?: boolean;
|
|
263
|
-
onWarn?: (message: string) => void;
|
|
264
|
-
mdl?: MdlModuleProvider;
|
|
265
|
-
}): number;
|
|
266
|
-
|
|
267
16
|
/**
|
|
268
17
|
* Authoring API (M14): assemble a robot from Three.js objects and export it.
|
|
269
18
|
*
|
|
@@ -317,6 +66,16 @@ type AddJointOptions = {
|
|
|
317
66
|
/** Initial joint value in SI, exported as `PhysicsJointStateAPI`. */
|
|
318
67
|
initialValue?: number;
|
|
319
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
|
+
};
|
|
320
79
|
};
|
|
321
80
|
declare class RobotBuilder {
|
|
322
81
|
private readonly robotName;
|
|
@@ -330,7 +89,7 @@ declare class RobotBuilder {
|
|
|
330
89
|
private materialAutoId;
|
|
331
90
|
constructor(options: RobotBuilderOptions);
|
|
332
91
|
addLink(options: AddLinkOptions): this;
|
|
333
|
-
addFixedJoint(options: Omit<AddJointOptions, "axis" | "lower" | "upper">): this;
|
|
92
|
+
addFixedJoint(options: Omit<AddJointOptions, "axis" | "lower" | "upper" | "mimic">): this;
|
|
334
93
|
addRevoluteJoint(options: AddJointOptions): this;
|
|
335
94
|
addPrismaticJoint(options: AddJointOptions): this;
|
|
336
95
|
private addJoint;
|
|
@@ -397,4 +156,4 @@ type ExportThreeUsdRobotOptions = Omit<ExportRobotOptions, "geometry"> & {
|
|
|
397
156
|
/** Export a loaded robot back to a USDA AST (pass the result to `serializeUsda`). */
|
|
398
157
|
declare function exportThreeUsdRobot(robot: ThreeUsdRobot, options?: ExportThreeUsdRobotOptions): UsdaFile;
|
|
399
158
|
|
|
400
|
-
export { type AddJointOptions, type AddLinkOptions,
|
|
159
|
+
export { type AddJointOptions, type AddLinkOptions, Axis, CollisionApproximation, ExportMaterial, ExportMesh, ExportPhysicsMaterial, ExportRobotOptions, type ExportThreeUsdRobotOptions, type GeometryToExportMeshOptions, JointDriveDescription, KinematicTree, LinkInertialDescription, Mat4, RobotBuilder, type RobotBuilderOptions, RobotDescription, RobotGeometryProvider, Stage, ThreeUsdRobot, UsdaFile, type WorldFrame, axisVector, exportThreeUsdRobot, geometryToExportMesh, materialToExportMaterial, threeGeometryProvider };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
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,
|
|
6
|
-
export { JointObject, LinkObject, ThreeUsdRobot, axisVector } from './chunk-
|
|
7
|
-
import { identity4, multiply, invert } from './chunk-
|
|
8
|
-
export {
|
|
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
|
+
import { identity4, multiply, invert } from './chunk-YGJ23CG3.js';
|
|
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
|
+
export { DefaultAssetResolver, createMemoryResolver, findBoundSurfaceShader, isMdlTexture, joinPosix, parseMdl, parseMdlLiteral, resolveBoundMaterial } from './chunk-PPPRB6KE.js';
|
|
10
|
+
export { AssetPath, Quat, UsdMatrix } from './chunk-JGIVJXBU.js';
|
|
9
11
|
import * as THREE from 'three';
|
|
10
12
|
|
|
11
13
|
function geometryToExportMesh(geometry, options) {
|
|
@@ -233,6 +235,23 @@ var RobotBuilder = class {
|
|
|
233
235
|
const jointWorld = pending.world ?? childLink.world;
|
|
234
236
|
const parentWorld = parent === "" ? identity4() : this.links.get(parent).world;
|
|
235
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
|
+
}
|
|
236
255
|
joints[name] = {
|
|
237
256
|
name,
|
|
238
257
|
primPath: `/${this.robotName}/${name}`,
|
|
@@ -245,7 +264,14 @@ var RobotBuilder = class {
|
|
|
245
264
|
...options.lower !== void 0 ? { lower: options.lower } : {},
|
|
246
265
|
...options.upper !== void 0 ? { upper: options.upper } : {},
|
|
247
266
|
...options.initialValue !== void 0 ? { initialValue: options.initialValue } : {},
|
|
248
|
-
...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
|
+
} : {}
|
|
249
275
|
};
|
|
250
276
|
}
|
|
251
277
|
if (this.articulationRoot !== void 0 && !this.links.has(this.articulationRoot)) {
|