three-usd-robot 0.7.0 → 0.8.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 +68 -7
- package/dist/{ThreeUsdRobot-Ljh4PDVD.d.ts → ThreeUsdRobot-CsjraHqP.d.ts} +32 -2
- package/dist/{ThreeUsdRobotLoader-BSIVFA48.d.ts → ThreeUsdRobotLoader-CxOGRLXH.d.ts} +31 -16
- package/dist/{buildKinematicTree-Ccd2DIKH.d.ts → buildKinematicTree-D4R0hEtN.d.ts} +2 -2
- package/dist/{AssetResolver-CpIJNgWZ.d.ts → bytes-MOJ2oN-u.d.ts} +14 -1
- package/dist/chunk-3CANZKP3.js +374 -0
- package/dist/chunk-3CANZKP3.js.map +1 -0
- package/dist/chunk-IYKPVUZ2.js +406 -0
- package/dist/chunk-IYKPVUZ2.js.map +1 -0
- package/dist/{chunk-O7XP5FQ4.js → chunk-P6CHTMGW.js} +4 -3
- package/dist/chunk-P6CHTMGW.js.map +1 -0
- package/dist/{chunk-4GPCBXUS.js → chunk-PHHMWMCA.js} +45 -410
- package/dist/chunk-PHHMWMCA.js.map +1 -0
- package/dist/{chunk-FL554IS5.js → chunk-YX5GIEMT.js} +114 -366
- package/dist/chunk-YX5GIEMT.js.map +1 -0
- package/dist/core.d.ts +17 -5
- package/dist/core.js +3 -2
- package/dist/extras.d.ts +2 -2
- package/dist/helpers.d.ts +73 -3
- package/dist/helpers.js +125 -13
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +28 -18
- package/dist/index.js +8 -5
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +4 -4
- package/dist/react.js +4 -2
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4GPCBXUS.js.map +0 -1
- package/dist/chunk-FL554IS5.js.map +0 -1
- package/dist/chunk-O7XP5FQ4.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/three/MeshBinding.ts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EAAO,GAAI;AAAC,KAC7E;AAAA,EACF;AACF","file":"chunk-YX5GIEMT.js","sourcesContent":["/**\n * Binds renderable gprims — `UsdGeom.Mesh` plus the parametric solids (`Cube` /\n * `Sphere` / `Cylinder` / `Capsule` / `Cone`) — to Three.js geometry and\n * attaches them under the robot's link objects.\n *\n * Meshes are triangulated with a simple fan, use authored per-vertex normals\n * when present (else computed smooth normals), and read `primvars:st` UVs and\n * `primvars:displayColor`. Solids tessellate from their schema attributes.\n * Geometry is left in stage units; the global `metersPerUnit` scale is applied\n * at the root in M9.\n */\n\nimport * as THREE from \"three\";\nimport { type Mat4, identity4, multiply } from \"../kinematics/transforms.js\";\nimport type { Vec2, Vec3 } from \"../parser/ast.js\";\nimport type { RobotDescription } from \"../robot/RobotDescription.js\";\nimport {\n type MaterialSubset,\n getMaterialSubsets,\n isNonVisualPurpose,\n isRenderableGprim,\n} from \"../schemas/usdGeom.js\";\nimport { COLLISION_API } from \"../schemas/usdPhysics.js\";\nimport type { Prim } from \"../usd/Prim.js\";\nimport type { Stage } from \"../usd/Stage.js\";\nimport { computeLocalTransform, computeWorldTransform } from \"../usd/xformOps.js\";\nimport { type ResolvedTexture, resolveBoundMaterial } from \"./MaterialBinding.js\";\nimport type { TextureProvider } from \"./TextureBinding.js\";\nimport type { ThreeUsdRobot } from \"./ThreeUsdRobot.js\";\n\nexport type MeshKind = \"visual\" | \"collision\";\n\nconst DEFAULT_COLOR = 0x9a9a9a;\n\nexport type BindMeshesOptions = {\n loadVisuals?: boolean;\n loadCollisions?: boolean;\n /** Resolves diffuse texture asset paths to `THREE.Texture` (M-tex). */\n textureProvider?: TextureProvider;\n};\n\n/**\n * Build a `BufferGeometry` from a Mesh prim, or `null` if it has no points.\n *\n * When the mesh carries `materialBind` face subsets, the triangles are ordered\n * subset by subset and a geometry group is added for each — so the mesh can be\n * drawn with one material per subset (see {@link buildMeshMaterials}). Group\n * order matches {@link getMaterialSubsets}, with any unassigned faces last.\n */\nexport function buildMeshGeometry(meshPrim: Prim): THREE.BufferGeometry | null {\n const points = meshPrim.GetAttribute(\"points\").Get();\n if (!isVec3Array(points) || points.length === 0) return null;\n\n const geometry = new THREE.BufferGeometry();\n geometry.setAttribute(\"position\", new THREE.Float32BufferAttribute(flat3(points), 3));\n\n const counts = meshPrim.GetAttribute(\"faceVertexCounts\").Get();\n const indices = meshPrim.GetAttribute(\"faceVertexIndices\").Get();\n if (isNumberArray(counts) && isNumberArray(indices)) {\n const subsets = getMaterialSubsets(meshPrim);\n if (subsets.length > 0) {\n geometry.setIndex(triangulateBySubset(geometry, counts, indices, subsets));\n } else {\n geometry.setIndex(triangulate(counts, indices));\n }\n } else if (isNumberArray(indices)) {\n geometry.setIndex(indices.slice());\n }\n\n const normals = meshPrim.GetAttribute(\"normals\").Get();\n if (isVec3Array(normals) && normals.length === points.length) {\n geometry.setAttribute(\"normal\", new THREE.Float32BufferAttribute(flat3(normals), 3));\n } else {\n geometry.computeVertexNormals();\n }\n\n const st = meshPrim.GetAttribute(\"primvars:st\").Get();\n if (isVec2Array(st) && st.length === points.length) {\n geometry.setAttribute(\"uv\", new THREE.Float32BufferAttribute(flat2(st), 2));\n }\n\n return geometry;\n}\n\n/**\n * Build geometry for any renderable gprim: `Mesh` via {@link buildMeshGeometry},\n * parametric solids from their schema attributes. Solids follow UsdGeom\n * semantics — sizes in stage units, centered at the origin, `axis` (default\n * `\"Z\"`) along the spine, and a capsule's `height` spans only its cylindrical\n * section. Returns `null` for unsupported prim types.\n */\nexport function buildGprimGeometry(prim: Prim): THREE.BufferGeometry | null {\n switch (prim.GetTypeName()) {\n case \"Mesh\":\n return buildMeshGeometry(prim);\n case \"Cube\": {\n const size = getNumber(prim, \"size\") ?? 2;\n return new THREE.BoxGeometry(size, size, size);\n }\n case \"Sphere\":\n return new THREE.SphereGeometry(getNumber(prim, \"radius\") ?? 1, 32, 16);\n case \"Cylinder\": {\n const radius = getNumber(prim, \"radius\") ?? 1;\n const height = getNumber(prim, \"height\") ?? 2;\n return orientSpine(new THREE.CylinderGeometry(radius, radius, height, 32), prim);\n }\n case \"Capsule\": {\n const radius = getNumber(prim, \"radius\") ?? 0.5;\n const height = getNumber(prim, \"height\") ?? 1;\n return orientSpine(new THREE.CapsuleGeometry(radius, height, 8, 32), prim);\n }\n case \"Cone\": {\n const radius = getNumber(prim, \"radius\") ?? 1;\n const height = getNumber(prim, \"height\") ?? 2;\n return orientSpine(new THREE.ConeGeometry(radius, height, 32), prim);\n }\n default:\n return null;\n }\n}\n\nfunction getNumber(prim: Prim, name: string): number | undefined {\n const v = prim.GetAttribute(name).Get();\n return typeof v === \"number\" ? v : undefined;\n}\n\n/** Rotate a Y-spined three.js primitive onto the prim's `axis` (USD default `Z`). */\nfunction orientSpine(geometry: THREE.BufferGeometry, prim: Prim): THREE.BufferGeometry {\n const axis = prim.GetAttribute(\"axis\").Get();\n if (axis === \"Y\") return geometry;\n if (axis === \"X\") return geometry.rotateZ(-Math.PI / 2);\n return geometry.rotateX(Math.PI / 2);\n}\n\n/**\n * Build a material for a gprim. Color priority: bound `UsdShade` material\n * (when `stage` is given) → `primvars:displayColor` → default gray. Textures\n * (via `textures`) become the matching `MeshStandardMaterial` maps — diffuse →\n * `map` (sRGB), plus `normalMap` / `roughnessMap` / `metalnessMap` / `aoMap`\n * (linear data) and emissive `emissiveMap`. Metalness / roughness / opacity /\n * emissive constants come from the bound material when present.\n */\nexport function buildMeshMaterial(\n meshPrim: Prim,\n stage?: Stage,\n textures?: TextureProvider,\n /** Resolve the material binding from here instead (a `GeomSubset`). */\n bindingPrim?: Prim,\n): THREE.Material {\n const color = new THREE.Color(DEFAULT_COLOR);\n let opacity = 1;\n\n const bound = stage ? resolveBoundMaterial(stage, bindingPrim ?? meshPrim) : undefined;\n if (bound?.color) {\n color.setRGB(bound.color[0], bound.color[1], bound.color[2]);\n } else {\n const displayColor = meshPrim.GetAttribute(\"primvars:displayColor\").Get();\n if (isVec3Array(displayColor) && displayColor[0]) {\n const [r, g, b] = displayColor[0];\n color.setRGB(r, g, b);\n }\n }\n if (bound?.opacity !== undefined) opacity = bound.opacity;\n\n // Resolve a channel's `THREE.Texture`, forwarding its wrap modes and\n // `UsdTransform2d` (the `UsdUVTexture.inputs:scale`/`bias` are folded into the\n // material factors below, not the sampler).\n const tex = (rt: ResolvedTexture | undefined, cs: \"srgb\" | \"linear\") =>\n rt && textures\n ? textures(rt.path, {\n colorSpace: cs,\n ...(rt.wrapS ? { wrapS: rt.wrapS } : {}),\n ...(rt.wrapT ? { wrapT: rt.wrapT } : {}),\n ...(rt.transform ? { transform: rt.transform } : {}),\n })\n : null;\n\n const map = tex(bound?.colorTexture, \"srgb\");\n // `inputs:scale` on the diffuse texture tints the map; otherwise pass through.\n if (map) {\n const s = bound?.colorTexture?.scale;\n if (s) color.setRGB(s[0], s[1], s[2]);\n else color.setRGB(1, 1, 1);\n }\n const normalMap = tex(bound?.normalTexture, \"linear\");\n const roughnessMap = tex(bound?.roughnessTexture, \"linear\");\n const metalnessMap = tex(bound?.metalnessTexture, \"linear\");\n const aoMap = tex(bound?.occlusionTexture, \"linear\");\n const emissiveMap = tex(bound?.emissiveTexture, \"srgb\");\n\n // A scalar map's `inputs:scale[0]` (or an authored constant) becomes three's\n // factor; three multiplies factor × map, so default to 1 to pass it through.\n const metalness =\n bound?.metalness ?? bound?.metalnessTexture?.scale?.[0] ?? (metalnessMap ? 1 : 0.1);\n const roughness =\n bound?.roughness ?? bound?.roughnessTexture?.scale?.[0] ?? (roughnessMap ? 1 : 0.8);\n\n const emissive = new THREE.Color(0x000000);\n if (bound?.emissiveColor) {\n emissive.setRGB(bound.emissiveColor[0], bound.emissiveColor[1], bound.emissiveColor[2]);\n } else if (emissiveMap) {\n emissive.setRGB(1, 1, 1); // let the map drive emission\n }\n\n // Opacity sourcing: a dedicated opacity texture → `alphaMap`; an opacity input\n // wired to the *same* image as the diffuse map → that map's own alpha channel\n // (no separate map needed). `opacityThreshold > 0` means alpha clip (a binary\n // cutout rendered in the opaque pass); otherwise sub-unit alpha blends.\n const opacityTex = bound?.opacityTexture;\n const sharesColorMap = !!(opacityTex && opacityTex.path === bound?.colorTexture?.path);\n const alphaMap = sharesColorMap ? null : tex(opacityTex, \"linear\");\n const hasAlphaSource = opacity < 1 || sharesColorMap || !!alphaMap;\n const threshold = bound?.opacityThreshold;\n const alphaTest = threshold !== undefined && threshold > 0 ? threshold : 0;\n // Alpha-clip masks render opaque (depth-written, discarded below the cutoff);\n // only true translucency uses the transparent/blended pass.\n const transparent = alphaTest === 0 && hasAlphaSource;\n\n const doubleSided = meshPrim.GetAttribute(\"doubleSided\").Get() === true;\n const material = new THREE.MeshStandardMaterial({\n color,\n metalness,\n roughness,\n emissive,\n transparent,\n opacity,\n ...(alphaTest > 0 ? { alphaTest } : {}),\n side: doubleSided ? THREE.DoubleSide : THREE.FrontSide,\n ...(map ? { map } : {}),\n ...(alphaMap ? { alphaMap } : {}),\n ...(normalMap ? { normalMap } : {}),\n ...(roughnessMap ? { roughnessMap } : {}),\n ...(metalnessMap ? { metalnessMap } : {}),\n ...(aoMap ? { aoMap } : {}),\n ...(emissiveMap ? { emissiveMap } : {}),\n });\n // Carry the USD material name so re-exports keep it (and dedupe by it).\n if (bound?.name) material.name = bound.name;\n return material;\n}\n\n/**\n * Attach visual (and optionally collision) meshes to every link of a built\n * {@link ThreeUsdRobot}. Each mesh is positioned by its transform relative to\n * the owning link prim.\n */\nexport function bindRobotMeshes(\n stage: Stage,\n robot3d: ThreeUsdRobot,\n desc: RobotDescription,\n options: BindMeshesOptions = {},\n): void {\n const loadVisuals = options.loadVisuals ?? true;\n const loadCollisions = options.loadCollisions ?? false;\n const textures = options.textureProvider;\n\n for (const [key, link] of Object.entries(desc.links)) {\n const linkObj = robot3d.getLinkObject(key);\n const linkPrim = stage.GetPrimAtPath(link.primPath);\n if (!linkObj || !linkPrim) continue;\n\n // A mesh may be both visual and collision; attach it once, as visual.\n const visualSet = new Set(link.visualPrims);\n\n if (loadVisuals) {\n for (const meshPath of link.visualPrims) {\n attachMesh(stage, linkPrim, meshPath, linkObj, \"visual\", textures);\n }\n }\n if (loadCollisions) {\n for (const meshPath of link.collisionPrims ?? []) {\n if (loadVisuals && visualSet.has(meshPath)) continue;\n attachMesh(stage, linkPrim, meshPath, linkObj, \"collision\", textures);\n }\n }\n }\n}\n\n/**\n * Attach the gprims that belong to no link — the static scenery of a cell that\n * also contains robots. They are placed by their authored stage transform\n * under the robot root, so the loader's up-axis and unit normalization applies\n * to them too. Collision-only and guide/proxy prims are skipped.\n */\nexport function bindSceneMeshes(\n stage: Stage,\n robot3d: ThreeUsdRobot,\n desc: RobotDescription,\n options: { textureProvider?: TextureProvider } = {},\n): number {\n const owned = new Set<string>();\n for (const link of Object.values(desc.links)) {\n for (const path of link.visualPrims) owned.add(path);\n for (const path of link.collisionPrims ?? []) owned.add(path);\n owned.add(link.primPath);\n }\n\n let attached = 0;\n for (const prim of stage.Traverse()) {\n if (!isRenderableGprim(prim) || owned.has(prim.GetPath())) continue;\n if (prim.HasAPI(COLLISION_API) || isNonVisualPurpose(prim)) continue;\n // Skip gprims under a link (already bound relative to their link).\n if ([...owned].some((path) => prim.GetPath().startsWith(`${path}/`))) continue;\n\n const geometry = buildGprimGeometry(prim);\n if (!geometry) continue;\n const mesh = new THREE.Mesh(geometry, buildMeshMaterial(prim, stage, options.textureProvider));\n mesh.name = prim.GetName();\n mesh.userData.kind = \"scene\";\n mesh.userData.primPath = prim.GetPath();\n mesh.matrixAutoUpdate = false;\n mesh.matrix.fromArray(computeWorldTransform(prim));\n mesh.matrixWorldNeedsUpdate = true;\n robot3d.add(mesh);\n attached++;\n }\n return attached;\n}\n\n/**\n * Materials for a mesh: one per `materialBind` face subset (matching the\n * geometry groups {@link buildMeshGeometry} adds) plus a trailing fallback for\n * faces no subset claims. A mesh without subsets gets a single material.\n */\nexport function buildMeshMaterials(\n meshPrim: Prim,\n stage?: Stage,\n textures?: TextureProvider,\n): THREE.Material | THREE.Material[] {\n const subsets = stage ? getMaterialSubsets(meshPrim) : [];\n if (subsets.length === 0) return buildMeshMaterial(meshPrim, stage, textures);\n return [\n ...subsets.map((s) => buildMeshMaterial(meshPrim, stage, textures, s.prim)),\n buildMeshMaterial(meshPrim, stage, textures),\n ];\n}\n\nfunction attachMesh(\n stage: Stage,\n linkPrim: Prim,\n meshPath: string,\n parent: THREE.Object3D,\n kind: MeshKind,\n textures: TextureProvider | undefined,\n): void {\n const meshPrim = stage.GetPrimAtPath(meshPath);\n if (!meshPrim) return;\n const geometry = buildGprimGeometry(meshPrim);\n if (!geometry) return;\n\n const mesh = new THREE.Mesh(geometry, buildMeshMaterials(meshPrim, stage, textures));\n mesh.name = meshPrim.GetName();\n mesh.userData.kind = kind;\n mesh.userData.primPath = meshPath;\n // Collision meshes are loaded hidden; reveal via `robot.showCollision = true`.\n if (kind === \"collision\") mesh.visible = false;\n mesh.matrixAutoUpdate = false;\n mesh.matrix.fromArray(relativeTransform(linkPrim, meshPrim));\n mesh.matrixWorldNeedsUpdate = true;\n parent.add(mesh);\n}\n\n/** Accumulated local transform from `linkPrim` (exclusive) down to `meshPrim` (inclusive). */\nfunction relativeTransform(linkPrim: Prim, meshPrim: Prim): Mat4 {\n const chain: Prim[] = [];\n let p: Prim | null = meshPrim;\n const stop = linkPrim.GetPath();\n while (p && p.GetPath() !== stop) {\n chain.push(p);\n p = p.GetParent();\n }\n chain.reverse(); // top-most (just under link) → mesh\n\n let m = identity4();\n for (const prim of chain) {\n m = multiply(m, computeLocalTransform(prim).matrix);\n }\n return m;\n}\n\n// --- triangulation & typed-array helpers -----------------------------------\n\n/** Fan-triangulate USD polygon faces into a flat triangle index list. */\nfunction triangulate(faceVertexCounts: number[], faceVertexIndices: number[]): number[] {\n const tris: number[] = [];\n let offset = 0;\n for (const count of faceVertexCounts) {\n for (let k = 2; k < count; k++) {\n tris.push(\n faceVertexIndices[offset]!,\n faceVertexIndices[offset + k - 1]!,\n faceVertexIndices[offset + k]!,\n );\n }\n offset += count;\n }\n return tris;\n}\n\n/**\n * Triangulate subset by subset so each subset owns a contiguous run of the\n * index buffer, and register that run as a geometry group.\n */\nfunction triangulateBySubset(\n geometry: THREE.BufferGeometry,\n faceVertexCounts: number[],\n faceVertexIndices: number[],\n subsets: MaterialSubset[],\n): number[] {\n const faceStart: number[] = [];\n let offset = 0;\n for (const count of faceVertexCounts) {\n faceStart.push(offset);\n offset += count;\n }\n\n const tris: number[] = [];\n const emit = (face: number) => {\n const start = faceStart[face]!;\n const count = faceVertexCounts[face]!;\n for (let k = 2; k < count; k++) {\n tris.push(\n faceVertexIndices[start]!,\n faceVertexIndices[start + k - 1]!,\n faceVertexIndices[start + k]!,\n );\n }\n };\n\n const claimed = new Uint8Array(faceVertexCounts.length);\n subsets.forEach((subset, index) => {\n const begin = tris.length;\n for (const face of subset.faces) {\n if (face < 0 || face >= faceVertexCounts.length || claimed[face]) continue;\n claimed[face] = 1;\n emit(face);\n }\n if (tris.length > begin) geometry.addGroup(begin, tris.length - begin, index);\n });\n\n const begin = tris.length;\n for (let face = 0; face < faceVertexCounts.length; face++) {\n if (!claimed[face]) emit(face);\n }\n if (tris.length > begin) geometry.addGroup(begin, tris.length - begin, subsets.length);\n\n return tris;\n}\n\nfunction flat3(v: Vec3[]): number[] {\n const out = new Array<number>(v.length * 3);\n for (let i = 0; i < v.length; i++) {\n out[i * 3] = v[i]![0];\n out[i * 3 + 1] = v[i]![1];\n out[i * 3 + 2] = v[i]![2];\n }\n return out;\n}\n\nfunction flat2(v: Vec2[]): number[] {\n const out = new Array<number>(v.length * 2);\n for (let i = 0; i < v.length; i++) {\n out[i * 2] = v[i]![0];\n out[i * 2 + 1] = v[i]![1];\n }\n return out;\n}\n\nfunction isNumberArray(v: unknown): v is number[] {\n return Array.isArray(v) && v.every((n) => typeof n === \"number\");\n}\n\nfunction isVec3Array(v: unknown): v is Vec3[] {\n return Array.isArray(v) && v.every((e) => Array.isArray(e) && e.length === 3);\n}\n\nfunction isVec2Array(v: unknown): v is Vec2[] {\n return Array.isArray(v) && v.every((e) => Array.isArray(e) && e.length === 2);\n}\n","/**\n * Loads texture image assets referenced by `UsdShade` materials.\n *\n * A {@link TextureProvider} maps an authored asset path (plus sampler/transform\n * options) to a `THREE.Texture`. The default provider fetches the image **bytes**\n * through the {@link AssetResolver} and decodes them via a blob URL — so it works\n * uniformly for textures served over HTTP and for images embedded inside a\n * `.usdz` package (whose resolver serves zip entries, not real URLs). Decoded\n * images are cached per resolved URL and shared across every texture that uses\n * them; each `THREE.Texture` carries its own color space / wrap / transform.\n */\n\nimport * as THREE from \"three\";\nimport type { AssetResolver } from \"../usd/AssetResolver.js\";\nimport type { TextureTransform, TextureWrap } from \"./MaterialBinding.js\";\n\n/**\n * Color space to interpret a texture in. Color/albedo and emissive maps are\n * `\"srgb\"`; data maps (normal, roughness, metalness, occlusion) are `\"linear\"`.\n */\nexport type TextureColorSpace = \"srgb\" | \"linear\";\n\n/** Per-use sampler state applied to the returned `THREE.Texture`. */\nexport type TextureOptions = {\n /** Defaults to `\"srgb\"`. */\n colorSpace?: TextureColorSpace;\n wrapS?: TextureWrap;\n wrapT?: TextureWrap;\n transform?: TextureTransform;\n};\n\n/** Resolve an authored texture asset path to a `THREE.Texture` (or `null`). */\nexport type TextureProvider = (assetPath: string, options?: TextureOptions) => THREE.Texture | null;\n\nconst DEG2RAD = Math.PI / 180;\n\n/**\n * A {@link TextureProvider} backed by the {@link AssetResolver}, resolving paths\n * against `baseUrl`. Image bytes are fetched once per URL (works for HTTP and\n * `.usdz` entries alike) and the decoded image is shared; each call returns a\n * distinct `THREE.Texture` carrying the requested color space / wrap / transform.\n */\nexport function createTextureProvider(resolver: AssetResolver, baseUrl: string): TextureProvider {\n const images = new Map<string, Promise<TexImageSource>>();\n\n const imageFor = (url: string): Promise<TexImageSource> => {\n let p = images.get(url);\n if (!p) {\n p = loadImage(resolver, url);\n images.set(url, p);\n }\n return p;\n };\n\n return (assetPath: string, options: TextureOptions = {}) => {\n let url: string;\n try {\n url = resolver.resolve(assetPath, baseUrl);\n } catch {\n return null;\n }\n\n const texture = new THREE.Texture();\n texture.colorSpace =\n options.colorSpace === \"linear\" ? THREE.NoColorSpace : THREE.SRGBColorSpace;\n texture.wrapS = toThreeWrap(options.wrapS);\n texture.wrapT = toThreeWrap(options.wrapT);\n applyTransform(texture, options.transform);\n\n imageFor(url)\n .then((image) => {\n texture.image = image;\n texture.needsUpdate = true;\n })\n .catch(() => {\n /* leave the texture blank if the image can't be decoded */\n });\n return texture;\n };\n}\n\n/**\n * Fetch image bytes through the resolver and decode them via a blob URL into an\n * `HTMLImageElement` (so three's default `flipY = true` orients USD's bottom-left\n * `st` origin correctly, matching the prior `TextureLoader` HTTP path).\n */\nasync function loadImage(resolver: AssetResolver, url: string): Promise<TexImageSource> {\n const bytes = resolver.fetchBytes\n ? await resolver.fetchBytes(url)\n : new TextEncoder().encode(await resolver.fetchText(url));\n const blob = new Blob([bytes as BlobPart], { type: mimeOf(url) });\n const objectUrl = URL.createObjectURL(blob);\n try {\n return await new Promise<HTMLImageElement>((resolve, reject) => {\n const img = new Image();\n img.onload = () => resolve(img);\n img.onerror = () => reject(new Error(`failed to decode texture: ${url}`));\n img.src = objectUrl;\n });\n } finally {\n // The decoded image keeps its pixels; the blob URL can be released.\n URL.revokeObjectURL(objectUrl);\n }\n}\n\nfunction toThreeWrap(wrap: TextureWrap | undefined): THREE.Wrapping {\n switch (wrap) {\n case \"clamp\":\n case \"black\": // three has no border color; clamp is the closest mode\n return THREE.ClampToEdgeWrapping;\n case \"mirror\":\n return THREE.MirroredRepeatWrapping;\n default:\n return THREE.RepeatWrapping;\n }\n}\n\n/** Map a `UsdTransform2d` onto a texture's offset / repeat / rotation. */\nfunction applyTransform(texture: THREE.Texture, t: TextureTransform | undefined): void {\n if (!t) return;\n if (t.scale) texture.repeat.set(t.scale[0], t.scale[1]);\n if (t.translation) texture.offset.set(t.translation[0], t.translation[1]);\n if (t.rotation !== undefined) {\n texture.rotation = t.rotation * DEG2RAD;\n texture.center.set(0, 0); // UsdTransform2d rotates about the origin\n }\n}\n\nfunction mimeOf(url: string): string {\n if (/\\.jpe?g$/i.test(url)) return \"image/jpeg\";\n if (/\\.webp$/i.test(url)) return \"image/webp\";\n return \"image/png\";\n}\n","import type { RobotDescription } from \"../robot/RobotDescription.js\";\nimport { extractRobotDescription } from \"../robot/RobotExtractor.js\";\nimport { buildKinematicTree } from \"../robot/buildKinematicTree.js\";\nimport { type AssetResolver, DefaultAssetResolver } from \"../usd/AssetResolver.js\";\nimport { Stage } from \"../usd/Stage.js\";\nimport { type BinarySource, type UsdSource, toBytes } from \"../usd/bytes.js\";\nimport { composeFile, composeLayer } from \"../usd/composition.js\";\nimport { CrateReader } from \"../usd/crate/CrateReader.js\";\nimport { crateToUsdaFile } from \"../usd/crate/toUsdaFile.js\";\nimport { isZip, openUsdz } from \"../usd/usdz.js\";\nimport { bindRobotMeshes, bindSceneMeshes } from \"./MeshBinding.js\";\nimport { createTextureProvider } from \"./TextureBinding.js\";\nimport { ThreeUsdRobot, type ThreeUsdRobotOptions } from \"./ThreeUsdRobot.js\";\n\nexport type ThreeUsdRobotLoaderOptions = {\n /** Resolver for references / payloads / sublayers (default {@link DefaultAssetResolver}). */\n assetResolver?: AssetResolver;\n /** Render visual meshes (M6). */\n loadVisuals?: boolean;\n /** Render collision meshes (M6). */\n loadCollisions?: boolean;\n /**\n * Also render gprims that belong to no link — the static scenery of a cell\n * that contains robots (floor, guarding, racking, …). Placed by their\n * authored stage transform. Default `false`; a stage with no articulation at\n * all (a pure static scene) defaults to `true` so it renders out of the box.\n */\n loadSceneGeometry?: boolean;\n /** Load diffuse textures referenced by materials (default `true`). */\n loadTextures?: boolean;\n /** Up-axis correction strategy (M9). */\n upAxisConversion?: \"auto\" | \"Y\" | \"Z\" | \"none\";\n /** Extra uniform scale multiplied with `metersPerUnit` (M9). */\n unitScale?: number;\n /** Clamp `setJointValue` to authored limits (default `true`). */\n clampJointLimits?: boolean;\n /** Seed joints from drive targets / joint state (M9). */\n applyDriveTargetsAsInitialPose?: boolean;\n /** Override the robot name. */\n robotName?: string;\n /** Receives non-fatal load diagnostics. */\n onWarn?: (message: string) => void;\n};\n\n/** A composed stage plus the context needed to bind its meshes and textures. */\ntype OpenedStage = { stage: Stage; baseUrl: string; resolver: AssetResolver };\n\n/**\n * Loads Isaac Sim / OpenUSD robot assets into a controllable {@link ThreeUsdRobot}.\n *\n * Assets load by URL ({@link loadAsync}) or from in-memory content\n * ({@link parse} — USDA text, `ArrayBuffer`, typed array, or `Blob`/`File`).\n * Composition (references / payloads / sublayers, M8) is resolved through an\n * {@link AssetResolver}. Mesh rendering is M6; unit / up-axis / initial-pose\n * handling is M9; USDC and variants are M10.\n */\nexport class ThreeUsdRobotLoader {\n readonly options: ThreeUsdRobotLoaderOptions;\n\n constructor(options: ThreeUsdRobotLoaderOptions = {}) {\n this.options = options;\n }\n\n private get resolver(): AssetResolver {\n return this.options.assetResolver ?? new DefaultAssetResolver();\n }\n\n /**\n * Fetch an asset by URL and build the robot. `.usdz` packages are unzipped and\n * composed from their entries; everything else is sniffed for the zip / crate\n * magic and parsed as USDZ, binary USDC, or USDA text.\n */\n async loadAsync(url: string): Promise<ThreeUsdRobot> {\n const bytes = await this.fetchRootBytes(url);\n // Extension first: sniffing only sees offset 0, the extension also covers\n // zip archives with a prefix (fflate reads the central directory anyway).\n if (/\\.usdz$/i.test(url)) return this.parseUsdz(bytes);\n return this.parse(bytes, url);\n }\n\n private async fetchRootBytes(url: string): Promise<Uint8Array> {\n const resolver = this.resolver;\n if (resolver.fetchBytes) return resolver.fetchBytes(url);\n return new TextEncoder().encode(await resolver.fetchText(url));\n }\n\n /**\n * Build a robot from in-memory content — no fetch involved. Accepts USDA\n * source text, or an `ArrayBuffer` / typed array / `Blob` (e.g. a dropped\n * `File`) holding USDA text, a binary crate, or a `.usdz` package; binary\n * input is sniffed for the zip / crate magic. `baseUrl` anchors relative\n * references, payloads, and texture paths of non-package input.\n */\n async parse(data: UsdSource, baseUrl = \"\"): Promise<ThreeUsdRobot> {\n return this.buildFromStage(await this.openSource(data, baseUrl));\n }\n\n /** Build a robot from a `.usdz` package (bytes, `ArrayBuffer`, or `Blob`). */\n async parseUsdz(data: BinarySource): Promise<ThreeUsdRobot> {\n return this.buildFromStage(await this.openUsdzStage(await toBytes(data)));\n }\n\n /** Build a robot from a binary crate (`.usdc` / binary `.usd`). */\n async parseCrate(data: BinarySource, baseUrl = \"\"): Promise<ThreeUsdRobot> {\n const stage = await this.composeStageFromBytes(await toBytes(data), baseUrl, this.resolver);\n return this.buildFromStage({ stage, baseUrl, resolver: this.resolver });\n }\n\n /**\n * Parse + compose in-memory content (same formats as {@link parse}) into the\n * Three.js-independent robot IR.\n */\n async parseRobotDescription(data: UsdSource, baseUrl = \"\"): Promise<RobotDescription> {\n const { stage } = await this.openSource(data, baseUrl);\n return extractRobotDescription(stage, this.extractOptions());\n }\n\n /** Sniff in-memory content (text / zip / crate) and compose it into a stage. */\n private async openSource(data: UsdSource, baseUrl: string): Promise<OpenedStage> {\n const resolver = this.resolver;\n if (typeof data === \"string\") {\n return { stage: await this.composeStage(data, baseUrl, resolver), baseUrl, resolver };\n }\n const bytes = await toBytes(data);\n if (isZip(bytes)) return this.openUsdzStage(bytes);\n const stage = CrateReader.isCrate(bytes)\n ? await this.composeStageFromBytes(bytes, baseUrl, resolver)\n : await this.composeStage(new TextDecoder().decode(bytes), baseUrl, resolver);\n return { stage, baseUrl, resolver };\n }\n\n private async openUsdzStage(bytes: Uint8Array): Promise<OpenedStage> {\n const pkg = openUsdz(bytes);\n // The root layer of a usdz is typically binary USDC — sniff, don't assume text.\n const rootBytes = await pkg.resolver.fetchBytes(pkg.rootEntry);\n const stage = await this.composeStageFromBytes(rootBytes, pkg.rootEntry, pkg.resolver);\n return { stage, baseUrl: pkg.rootEntry, resolver: pkg.resolver };\n }\n\n private buildFromStage({ stage, baseUrl, resolver }: OpenedStage): ThreeUsdRobot {\n const robot = extractRobotDescription(stage, this.extractOptions());\n const tree = buildKinematicTree(robot);\n const robot3d = new ThreeUsdRobot(robot, tree, this.robotOptions());\n\n const loadVisuals = this.options.loadVisuals ?? true;\n const loadCollisions = this.options.loadCollisions ?? false;\n // A stage with no articulation at all is a pure static scene; default to\n // drawing its geometry — otherwise the load would be silently empty.\n const isStaticScene =\n Object.keys(robot.links).length === 0 && Object.keys(robot.joints).length === 0;\n if (isStaticScene && this.options.loadSceneGeometry === undefined) {\n this.options.onWarn?.(\n \"no articulation found (0 links / 0 joints); rendering the stage as static scene geometry\",\n );\n }\n const loadScene = this.options.loadSceneGeometry ?? isStaticScene;\n if (loadVisuals || loadCollisions || loadScene) {\n const textureProvider =\n (this.options.loadTextures ?? true) ? createTextureProvider(resolver, baseUrl) : undefined;\n if (loadVisuals || loadCollisions) {\n bindRobotMeshes(stage, robot3d, robot, {\n loadVisuals,\n loadCollisions,\n ...(textureProvider ? { textureProvider } : {}),\n });\n }\n if (loadScene) {\n bindSceneMeshes(stage, robot3d, robot, {\n ...(textureProvider ? { textureProvider } : {}),\n });\n }\n }\n return robot3d;\n }\n\n private async composeStage(\n text: string,\n baseUrl: string,\n resolver: AssetResolver,\n ): Promise<Stage> {\n const composeOptions = this.options.onWarn ? { onWarn: this.options.onWarn } : {};\n return Stage.OpenFromFile(await composeLayer(text, baseUrl, resolver, composeOptions));\n }\n\n /** Compose a layer from raw bytes, sniffing binary crate vs USDA text. */\n private async composeStageFromBytes(\n bytes: Uint8Array,\n baseUrl: string,\n resolver: AssetResolver,\n ): Promise<Stage> {\n const composeOptions = this.options.onWarn ? { onWarn: this.options.onWarn } : {};\n const composed = CrateReader.isCrate(bytes)\n ? await composeFile(\n crateToUsdaFile(new CrateReader(bytes)),\n baseUrl,\n resolver,\n composeOptions,\n )\n : await composeLayer(new TextDecoder().decode(bytes), baseUrl, resolver, composeOptions);\n return Stage.OpenFromFile(composed);\n }\n\n private robotOptions(): ThreeUsdRobotOptions {\n return {\n upAxisConversion: this.options.upAxisConversion ?? \"auto\",\n ...(this.options.clampJointLimits !== undefined\n ? { clampJointLimits: this.options.clampJointLimits }\n : {}),\n ...(this.options.unitScale !== undefined ? { unitScale: this.options.unitScale } : {}),\n ...(this.options.applyDriveTargetsAsInitialPose !== undefined\n ? { applyInitialPose: this.options.applyDriveTargetsAsInitialPose }\n : {}),\n };\n }\n\n private extractOptions(): { robotName?: string; onWarn?: (message: string) => void } {\n return {\n ...(this.options.robotName !== undefined ? { robotName: this.options.robotName } : {}),\n ...(this.options.onWarn !== undefined ? { onWarn: this.options.onWarn } : {}),\n };\n }\n}\n"]}
|
package/dist/core.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { U as UsdaFile, i as MetadataMap, q as UsdValue, P as PrimSpec, l as RelationshipSpec, m as SdfPath, f as AttributeSpec, r as Variability, n as Specifier, b as Vec3, V as Vec2, M as Mat4, L as LinkDescription, R as RobotDescription, J as JointType, A as Axis, d as LinkInertialDescription } from './buildKinematicTree-
|
|
2
|
-
export { e as AssetPath, B as BuildTreeOptions, C as CompositionArc, D as DEG2RAD, a as JointDescription, c as JointDriveDescription, g as KinematicNode, K as KinematicTree, h as ListOp, j as PropertySpec, Q as Quat, k as RAD2DEG, S as SampleChannel, T as TreeEdge, o as UsdDictionary, p as UsdMatrix, s as Vec4, t as buildKinematicTree, u as channelFromSamples, v as decomposeRigid, w as fromUsdMatrix, x as getTranslation, y as identity4, z as interpolate, E as invert, F as makeEuler, G as makeRotationFromQuat, H as makeRotationX, I as makeRotationY, N as makeRotationZ, O as makeScale, W as makeTranslation, X as multiply, Y as multiplyAll, Z as toUsdMatrix } from './buildKinematicTree-
|
|
3
|
-
import { A as AssetResolver } from './
|
|
4
|
-
export { D as DefaultAssetResolver, c as createMemoryResolver, j as joinPosix } from './
|
|
1
|
+
import { U as UsdaFile, i as MetadataMap, q as UsdValue, P as PrimSpec, l as RelationshipSpec, m as SdfPath, f as AttributeSpec, r as Variability, n as Specifier, b as Vec3, V as Vec2, M as Mat4, L as LinkDescription, R as RobotDescription, J as JointType, A as Axis, d as LinkInertialDescription } from './buildKinematicTree-D4R0hEtN.js';
|
|
2
|
+
export { e as AssetPath, B as BuildTreeOptions, C as CompositionArc, D as DEG2RAD, a as JointDescription, c as JointDriveDescription, g as KinematicNode, K as KinematicTree, h as ListOp, j as PropertySpec, Q as Quat, k as RAD2DEG, S as SampleChannel, T as TreeEdge, o as UsdDictionary, p as UsdMatrix, s as Vec4, t as buildKinematicTree, u as channelFromSamples, v as decomposeRigid, w as fromUsdMatrix, x as getTranslation, y as identity4, z as interpolate, E as invert, F as makeEuler, G as makeRotationFromQuat, H as makeRotationX, I as makeRotationY, N as makeRotationZ, O as makeScale, W as makeTranslation, X as multiply, Y as multiplyAll, Z as toUsdMatrix } from './buildKinematicTree-D4R0hEtN.js';
|
|
3
|
+
import { A as AssetResolver } from './bytes-MOJ2oN-u.js';
|
|
4
|
+
export { B as BinarySource, D as DefaultAssetResolver, U as UsdSource, c as createMemoryResolver, j as joinPosix, t as toBytes } from './bytes-MOJ2oN-u.js';
|
|
5
5
|
|
|
6
6
|
/** Package identity. Kept in one place so every entry point can re-export it. */
|
|
7
7
|
declare const PACKAGE_NAME = "three-usd-robot";
|
|
@@ -446,6 +446,12 @@ declare function parseOpType(opName: string): string;
|
|
|
446
446
|
* binary crate (`.usdc`), which composition sniffs and decodes (M10).
|
|
447
447
|
*/
|
|
448
448
|
|
|
449
|
+
/**
|
|
450
|
+
* True when the bytes start with a zip magic (`PK\x03\x04`, or the empty /
|
|
451
|
+
* spanned archive markers). A `.usdz` always begins with a local file header,
|
|
452
|
+
* so this is the sniff counterpart of {@link CrateReader.isCrate}.
|
|
453
|
+
*/
|
|
454
|
+
declare function isZip(bytes: Uint8Array): boolean;
|
|
449
455
|
type UsdzPackage = {
|
|
450
456
|
/** Archive path of the root layer to open. */
|
|
451
457
|
rootEntry: string;
|
|
@@ -597,10 +603,16 @@ declare function refineJointType(base: JointType, lower: number | undefined, upp
|
|
|
597
603
|
declare function isXform(prim: Prim): boolean;
|
|
598
604
|
declare function isScope(prim: Prim): boolean;
|
|
599
605
|
declare function isMesh(prim: Prim): boolean;
|
|
606
|
+
/** True for a `Cube` / `Sphere` / `Cylinder` / `Capsule` / `Cone` prim. */
|
|
607
|
+
declare function isSolidGprim(prim: Prim): boolean;
|
|
608
|
+
/** True for any gprim the runtime can render: a `Mesh` or a parametric solid. */
|
|
609
|
+
declare function isRenderableGprim(prim: Prim): boolean;
|
|
600
610
|
/** Depth-first iterator over all descendant prims (excluding `prim` itself). */
|
|
601
611
|
declare function iterDescendants(prim: Prim): Generator<Prim>;
|
|
602
612
|
/** Collect the prim paths of all Mesh descendants of a link prim. */
|
|
603
613
|
declare function gatherMeshDescendants(prim: Prim): string[];
|
|
614
|
+
/** Collect the prim paths of all renderable gprim descendants (meshes + solids). */
|
|
615
|
+
declare function gatherGprimDescendants(prim: Prim): string[];
|
|
604
616
|
|
|
605
617
|
/**
|
|
606
618
|
* UsdPhysics schema helpers for robot extraction.
|
|
@@ -652,4 +664,4 @@ declare function getJointStatePosition(prim: Prim, kind: "angular" | "linear"):
|
|
|
652
664
|
/** Read `UsdPhysicsMassAPI` properties, or `undefined` when none are authored (M16). */
|
|
653
665
|
declare function getMassProperties(prim: Prim): LinkInertialDescription | undefined;
|
|
654
666
|
|
|
655
|
-
export { ARTICULATION_ROOT_API, AssetResolver, Attribute, AttributeSpec, Axis, COLLISION_API, type CollisionApproximation, type ComposeOptions, CrateReader, DEFAULT_METERS_PER_UNIT, type ExportMaterial, type ExportMesh, type ExportPhysicsMaterial, type ExportRobotOptions, type ExtractOptions, JointType, Layer, LinkDescription, LinkInertialDescription, MASS_API, MESH_COLLISION_API, Mat4, MetadataMap, PACKAGE_NAME, PHYSICS_MATERIAL_API, ParseError, Prim, PrimSpec, RIGID_BODY_API, Relationship, RelationshipSpec, type ResolvedXform, RobotDescription, type RobotGeometryProvider, SdfPath, Specifier, Stage, type TextureChannel, TokenizeError, type UpAxis, UsdValue, UsdaFile, type UsdzPackage, VERSION, type ValidateRobotOptions, type ValidationIssue, type ValidationSeverity, Variability, Vec2, Vec3, composeFile, composeLayer, computeLocalTransform, computeWorldTransform, crateToUsdaFile, driveKindFor, exportRobotUsda, extractRobotDescription, gatherMeshDescendants, getJointAxis, getJointBodies, getJointDrive, getJointLimits, getJointLocalFrame, getJointStatePosition, getJointType, getMassProperties, hasArticulationRootAPI, hasCollisionAPI, hasRigidBodyAPI, isMesh, isScope, isXform, iterDescendants, jointValueFromSI, jointValueToSI, normalizeJointLimits, openUsdz, parseOpType, parseUsda, refineJointType, serializeUsda, stageGeometryProvider, tokenize, validateRobotDescription, writeUsdz };
|
|
667
|
+
export { ARTICULATION_ROOT_API, AssetResolver, Attribute, AttributeSpec, Axis, COLLISION_API, type CollisionApproximation, type ComposeOptions, CrateReader, DEFAULT_METERS_PER_UNIT, type ExportMaterial, type ExportMesh, type ExportPhysicsMaterial, type ExportRobotOptions, type ExtractOptions, JointType, Layer, LinkDescription, LinkInertialDescription, MASS_API, MESH_COLLISION_API, Mat4, MetadataMap, PACKAGE_NAME, PHYSICS_MATERIAL_API, ParseError, Prim, PrimSpec, RIGID_BODY_API, Relationship, RelationshipSpec, type ResolvedXform, RobotDescription, type RobotGeometryProvider, SdfPath, Specifier, Stage, type TextureChannel, TokenizeError, type UpAxis, UsdValue, UsdaFile, type UsdzPackage, VERSION, type ValidateRobotOptions, type ValidationIssue, type ValidationSeverity, Variability, Vec2, Vec3, composeFile, composeLayer, computeLocalTransform, computeWorldTransform, crateToUsdaFile, driveKindFor, exportRobotUsda, extractRobotDescription, gatherGprimDescendants, gatherMeshDescendants, getJointAxis, getJointBodies, getJointDrive, getJointLimits, getJointLocalFrame, getJointStatePosition, getJointType, getMassProperties, hasArticulationRootAPI, hasCollisionAPI, hasRigidBodyAPI, isMesh, isRenderableGprim, isScope, isSolidGprim, isXform, isZip, iterDescendants, jointValueFromSI, jointValueToSI, normalizeJointLimits, openUsdz, parseOpType, parseUsda, refineJointType, serializeUsda, stageGeometryProvider, tokenize, validateRobotDescription, writeUsdz };
|
package/dist/core.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { PACKAGE_NAME, VERSION, exportRobotUsda, stageGeometryProvider, validateRobotDescription, writeUsdz } from './chunk-
|
|
2
|
-
export { ARTICULATION_ROOT_API,
|
|
1
|
+
export { PACKAGE_NAME, VERSION, exportRobotUsda, stageGeometryProvider, validateRobotDescription, writeUsdz } from './chunk-P6CHTMGW.js';
|
|
2
|
+
export { ARTICULATION_ROOT_API, Attribute, COLLISION_API, CrateReader, DEFAULT_METERS_PER_UNIT, DefaultAssetResolver, Layer, MASS_API, MESH_COLLISION_API, PHYSICS_MATERIAL_API, ParseError, Prim, RIGID_BODY_API, Relationship, Stage, TokenizeError, buildKinematicTree, composeFile, composeLayer, computeLocalTransform, computeWorldTransform, crateToUsdaFile, createMemoryResolver, driveKindFor, extractRobotDescription, gatherGprimDescendants, gatherMeshDescendants, getJointAxis, getJointBodies, getJointDrive, getJointLimits, getJointLocalFrame, getJointStatePosition, getJointType, getMassProperties, hasArticulationRootAPI, hasCollisionAPI, hasRigidBodyAPI, isMesh, isRenderableGprim, isScope, isSolidGprim, isXform, isZip, iterDescendants, joinPosix, jointValueFromSI, jointValueToSI, normalizeJointLimits, openUsdz, parseOpType, parseUsda, refineJointType, serializeUsda, toBytes, tokenize } from './chunk-PHHMWMCA.js';
|
|
3
|
+
export { AssetPath, DEG2RAD, Quat, RAD2DEG, UsdMatrix, channelFromSamples, decomposeRigid, fromUsdMatrix, getTranslation, identity4, interpolate, invert, makeEuler, makeRotationFromQuat, makeRotationX, makeRotationY, makeRotationZ, makeScale, makeTranslation, multiply, multiplyAll, toUsdMatrix } from './chunk-IYKPVUZ2.js';
|
|
3
4
|
//# sourceMappingURL=core.js.map
|
|
4
5
|
//# sourceMappingURL=core.js.map
|
package/dist/extras.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as ThreeUsdRobot } from './ThreeUsdRobot-
|
|
1
|
+
import { T as ThreeUsdRobot } from './ThreeUsdRobot-CsjraHqP.js';
|
|
2
2
|
import 'three';
|
|
3
|
-
import './buildKinematicTree-
|
|
3
|
+
import './buildKinematicTree-D4R0hEtN.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* `three-usd-robot/extras`
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,6 +1,76 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import {
|
|
3
|
-
import './buildKinematicTree-
|
|
2
|
+
import { T as ThreeUsdRobot, J as JointObject } from './ThreeUsdRobot-CsjraHqP.js';
|
|
3
|
+
import './buildKinematicTree-D4R0hEtN.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Per-link appearance helpers: highlight (tint), material replacement, and
|
|
7
|
+
* translucent "ghost" clones for pose previews.
|
|
8
|
+
*
|
|
9
|
+
* Material overrides are reversible — the original materials are kept aside on
|
|
10
|
+
* first override and put back exactly by {@link restoreLinkMaterials} /
|
|
11
|
+
* {@link restoreAllLinkMaterials}. Links are addressed like everywhere else:
|
|
12
|
+
* by key or by full prim path.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Which meshes of a link an operation affects. */
|
|
16
|
+
type LinkMeshKind = "visual" | "collision" | "all";
|
|
17
|
+
/**
|
|
18
|
+
* The meshes belonging to exactly this link — not those of child links, which
|
|
19
|
+
* live under their own `LinkObject` deeper in the kinematic chain. Helpers and
|
|
20
|
+
* joint-frame groups are excluded.
|
|
21
|
+
*/
|
|
22
|
+
declare function getLinkMeshes(robot: ThreeUsdRobot, link: string, kind?: LinkMeshKind): THREE.Mesh[];
|
|
23
|
+
type HighlightLinkOptions = {
|
|
24
|
+
/** Highlight color (default red `0xff4444`). */
|
|
25
|
+
color?: THREE.ColorRepresentation;
|
|
26
|
+
/** Emissive strength of the tint (default `0.8`). */
|
|
27
|
+
emissiveIntensity?: number;
|
|
28
|
+
/** Force translucency while highlighted (e.g. `0.5`); default keeps the material's own. */
|
|
29
|
+
opacity?: number;
|
|
30
|
+
/** Which meshes of the link to affect (default `"visual"`). */
|
|
31
|
+
kind?: LinkMeshKind;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Tint a link's meshes (emissive red by default) while keeping their maps and
|
|
35
|
+
* base colors — e.g. to flag a colliding link. Repeated calls re-tint from the
|
|
36
|
+
* *original* materials, so highlights don't stack; restore with
|
|
37
|
+
* {@link restoreLinkMaterials}. Returns `false` when the link has no matching
|
|
38
|
+
* meshes.
|
|
39
|
+
*/
|
|
40
|
+
declare function highlightLink(robot: ThreeUsdRobot, link: string, options?: HighlightLinkOptions): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Replace a link's mesh materials with `material` (one shared instance). The
|
|
43
|
+
* caller keeps ownership — it is never disposed here. Restore the originals
|
|
44
|
+
* with {@link restoreLinkMaterials}. Returns `false` when the link has no
|
|
45
|
+
* matching meshes.
|
|
46
|
+
*/
|
|
47
|
+
declare function setLinkMaterial(robot: ThreeUsdRobot, link: string, material: THREE.Material, kind?: LinkMeshKind): boolean;
|
|
48
|
+
/** Put back a link's original materials (no-op for untouched meshes). */
|
|
49
|
+
declare function restoreLinkMaterials(robot: ThreeUsdRobot, link: string): void;
|
|
50
|
+
/** Put back the original materials of every link of the robot. */
|
|
51
|
+
declare function restoreAllLinkMaterials(robot: ThreeUsdRobot): void;
|
|
52
|
+
type GhostRobotOptions = {
|
|
53
|
+
/** Ghost tint (default `0x66aaff`). */
|
|
54
|
+
color?: THREE.ColorRepresentation;
|
|
55
|
+
/** Ghost opacity (default `0.35`). */
|
|
56
|
+
opacity?: number;
|
|
57
|
+
/** Complete material override; `color` / `opacity` are ignored when given. */
|
|
58
|
+
material?: THREE.Material;
|
|
59
|
+
/** Which meshes to clone (default `"visual"`). */
|
|
60
|
+
kind?: "visual" | "collision";
|
|
61
|
+
/** Joint overrides applied on top of the source robot's current pose. */
|
|
62
|
+
jointValues?: Record<string, number>;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Build a translucent clone of the robot for pose previews (target pose,
|
|
66
|
+
* onion-skinning). Geometry is shared with the source; every mesh uses one
|
|
67
|
+
* ghost material and is tagged `userData.kind = "ghost"`, so the source's
|
|
68
|
+
* `showVisual` / `showCollision` toggles never affect it. The clone is a full
|
|
69
|
+
* {@link ThreeUsdRobot} — drive it with `setJointValues` — starting from the
|
|
70
|
+
* source's current joint values (plus `jointValues` overrides) and mirroring
|
|
71
|
+
* its root transform. Add it to the same parent/scene as the source.
|
|
72
|
+
*/
|
|
73
|
+
declare function createGhostRobot(robot: ThreeUsdRobot, options?: GhostRobotOptions): ThreeUsdRobot;
|
|
4
74
|
|
|
5
75
|
/**
|
|
6
76
|
* An arrow drawn along a joint's motion axis (the rotation axis for
|
|
@@ -36,4 +106,4 @@ declare function addJointLimitHelpers(robot: ThreeUsdRobot, radius?: number, col
|
|
|
36
106
|
/** Attach a {@link LinkFrameHelper} to every link. Returns the helpers. */
|
|
37
107
|
declare function addLinkFrameHelpers(robot: ThreeUsdRobot, size?: number): LinkFrameHelper[];
|
|
38
108
|
|
|
39
|
-
export { JointAxisHelper, JointLimitHelper, LinkFrameHelper, addJointAxisHelpers, addJointLimitHelpers, addLinkFrameHelpers };
|
|
109
|
+
export { type GhostRobotOptions, type HighlightLinkOptions, JointAxisHelper, JointLimitHelper, LinkFrameHelper, type LinkMeshKind, addJointAxisHelpers, addJointLimitHelpers, addLinkFrameHelpers, createGhostRobot, getLinkMeshes, highlightLink, restoreAllLinkMaterials, restoreLinkMaterials, setLinkMaterial };
|
package/dist/helpers.js
CHANGED
|
@@ -1,17 +1,129 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ThreeUsdRobot } from './chunk-3CANZKP3.js';
|
|
2
|
+
import './chunk-IYKPVUZ2.js';
|
|
3
|
+
import * as THREE3 from 'three';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
+
var savedMaterials = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
var HIGHLIGHT_FLAG = "__threeUsdRobotHighlight";
|
|
7
|
+
function getLinkMeshes(robot, link, kind = "all") {
|
|
8
|
+
const obj = robot.getLinkObject(link);
|
|
9
|
+
if (!obj) return [];
|
|
10
|
+
const out = [];
|
|
11
|
+
for (const child of obj.children) {
|
|
12
|
+
const mesh = child;
|
|
13
|
+
if (!mesh.isMesh) continue;
|
|
14
|
+
const k = mesh.userData.kind;
|
|
15
|
+
if (k !== "visual" && k !== "collision") continue;
|
|
16
|
+
if (kind !== "all" && k !== kind) continue;
|
|
17
|
+
out.push(mesh);
|
|
18
|
+
}
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
function highlightLink(robot, link, options = {}) {
|
|
22
|
+
const meshes = getLinkMeshes(robot, link, options.kind ?? "visual");
|
|
23
|
+
if (meshes.length === 0) return false;
|
|
24
|
+
const color = new THREE3.Color(options.color ?? 16729156);
|
|
25
|
+
for (const mesh of meshes) {
|
|
26
|
+
if (!savedMaterials.has(mesh)) savedMaterials.set(mesh, mesh.material);
|
|
27
|
+
const base = savedMaterials.get(mesh);
|
|
28
|
+
disposeHighlightClones(mesh.material);
|
|
29
|
+
mesh.material = Array.isArray(base) ? base.map((m) => tintClone(m, color, options)) : tintClone(base, color, options);
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
function tintClone(base, color, options) {
|
|
34
|
+
const m = base.clone();
|
|
35
|
+
m.userData[HIGHLIGHT_FLAG] = true;
|
|
36
|
+
const std = m;
|
|
37
|
+
if (std.isMeshStandardMaterial) {
|
|
38
|
+
std.emissive.copy(color);
|
|
39
|
+
std.emissiveIntensity = options.emissiveIntensity ?? 0.8;
|
|
40
|
+
} else if ("color" in m) {
|
|
41
|
+
m.color.copy(color);
|
|
42
|
+
}
|
|
43
|
+
if (options.opacity !== void 0) {
|
|
44
|
+
m.transparent = options.opacity < 1;
|
|
45
|
+
m.opacity = options.opacity;
|
|
46
|
+
}
|
|
47
|
+
return m;
|
|
48
|
+
}
|
|
49
|
+
function setLinkMaterial(robot, link, material, kind = "visual") {
|
|
50
|
+
const meshes = getLinkMeshes(robot, link, kind);
|
|
51
|
+
if (meshes.length === 0) return false;
|
|
52
|
+
for (const mesh of meshes) {
|
|
53
|
+
if (!savedMaterials.has(mesh)) savedMaterials.set(mesh, mesh.material);
|
|
54
|
+
disposeHighlightClones(mesh.material);
|
|
55
|
+
mesh.material = material;
|
|
56
|
+
}
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
function restoreLinkMaterials(robot, link) {
|
|
60
|
+
for (const mesh of getLinkMeshes(robot, link, "all")) {
|
|
61
|
+
const original = savedMaterials.get(mesh);
|
|
62
|
+
if (original === void 0) continue;
|
|
63
|
+
disposeHighlightClones(mesh.material);
|
|
64
|
+
mesh.material = original;
|
|
65
|
+
savedMaterials.delete(mesh);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function restoreAllLinkMaterials(robot) {
|
|
69
|
+
for (const name of robot.getLinkNames()) restoreLinkMaterials(robot, name);
|
|
70
|
+
}
|
|
71
|
+
function disposeHighlightClones(current) {
|
|
72
|
+
for (const m of Array.isArray(current) ? current : [current]) {
|
|
73
|
+
if (m.userData[HIGHLIGHT_FLAG]) m.dispose();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function createGhostRobot(robot, options = {}) {
|
|
77
|
+
const ghost = new ThreeUsdRobot(robot.robot, robot.tree, {
|
|
78
|
+
clampJointLimits: robot.clampJointLimits,
|
|
79
|
+
applyInitialPose: false,
|
|
80
|
+
upAxisConversion: "none"
|
|
81
|
+
});
|
|
82
|
+
ghost.name = `${robot.name}_ghost`;
|
|
83
|
+
ghost.position.copy(robot.position);
|
|
84
|
+
ghost.quaternion.copy(robot.quaternion);
|
|
85
|
+
ghost.scale.copy(robot.scale);
|
|
86
|
+
const material = options.material ?? new THREE3.MeshStandardMaterial({
|
|
87
|
+
color: options.color ?? 6728447,
|
|
88
|
+
transparent: true,
|
|
89
|
+
opacity: options.opacity ?? 0.35,
|
|
90
|
+
depthWrite: false,
|
|
91
|
+
metalness: 0,
|
|
92
|
+
roughness: 1
|
|
93
|
+
});
|
|
94
|
+
const kind = options.kind ?? "visual";
|
|
95
|
+
for (const key of robot.getLinkNames()) {
|
|
96
|
+
const target = ghost.getLinkObject(key);
|
|
97
|
+
if (!target) continue;
|
|
98
|
+
for (const src of getLinkMeshes(robot, key, kind)) {
|
|
99
|
+
const mesh = new THREE3.Mesh(src.geometry, material);
|
|
100
|
+
mesh.name = `${src.name}_ghost`;
|
|
101
|
+
mesh.userData.kind = "ghost";
|
|
102
|
+
mesh.userData.primPath = src.userData.primPath;
|
|
103
|
+
mesh.matrixAutoUpdate = false;
|
|
104
|
+
mesh.matrix.copy(src.matrix);
|
|
105
|
+
mesh.matrixWorldNeedsUpdate = true;
|
|
106
|
+
target.add(mesh);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
for (const name of robot.getJointNames()) {
|
|
110
|
+
const value = robot.getJointValue(name);
|
|
111
|
+
if (value !== void 0) ghost.setJointValue(name, value);
|
|
112
|
+
}
|
|
113
|
+
if (options.jointValues) ghost.setJointValues(options.jointValues);
|
|
114
|
+
return ghost;
|
|
115
|
+
}
|
|
116
|
+
var JointAxisHelper = class extends THREE3.ArrowHelper {
|
|
5
117
|
isJointAxisHelper = true;
|
|
6
118
|
constructor(joint, length = 0.2, color = 16764928) {
|
|
7
|
-
super(joint.axis.clone().normalize(), new
|
|
119
|
+
super(joint.axis.clone().normalize(), new THREE3.Vector3(0, 0, 0), length, color);
|
|
8
120
|
this.name = `${joint.jointName}:axis`;
|
|
9
121
|
}
|
|
10
122
|
};
|
|
11
|
-
var JointLimitHelper = class extends
|
|
123
|
+
var JointLimitHelper = class extends THREE3.Line {
|
|
12
124
|
isJointLimitHelper = true;
|
|
13
125
|
constructor(joint, radius = 0.15, color = 43775) {
|
|
14
|
-
super(buildLimitGeometry(joint, radius), new
|
|
126
|
+
super(buildLimitGeometry(joint, radius), new THREE3.LineBasicMaterial({ color }));
|
|
15
127
|
this.name = `${joint.jointName}:limit`;
|
|
16
128
|
}
|
|
17
129
|
};
|
|
@@ -20,7 +132,7 @@ function buildLimitGeometry(joint, radius) {
|
|
|
20
132
|
if (joint.jointType === "prismatic") {
|
|
21
133
|
const lo2 = joint.lower ?? -radius;
|
|
22
134
|
const hi2 = joint.upper ?? radius;
|
|
23
|
-
return new
|
|
135
|
+
return new THREE3.BufferGeometry().setFromPoints([
|
|
24
136
|
axis.clone().multiplyScalar(lo2),
|
|
25
137
|
axis.clone().multiplyScalar(hi2)
|
|
26
138
|
]);
|
|
@@ -36,15 +148,15 @@ function buildLimitGeometry(joint, radius) {
|
|
|
36
148
|
u.clone().multiplyScalar(Math.cos(t) * radius).addScaledVector(v, Math.sin(t) * radius)
|
|
37
149
|
);
|
|
38
150
|
}
|
|
39
|
-
return new
|
|
151
|
+
return new THREE3.BufferGeometry().setFromPoints(points);
|
|
40
152
|
}
|
|
41
153
|
function perpendicularBasis(axis) {
|
|
42
|
-
const ref = Math.abs(axis.x) < 0.9 ? new
|
|
43
|
-
const u = new
|
|
44
|
-
const v = new
|
|
154
|
+
const ref = Math.abs(axis.x) < 0.9 ? new THREE3.Vector3(1, 0, 0) : new THREE3.Vector3(0, 1, 0);
|
|
155
|
+
const u = new THREE3.Vector3().crossVectors(axis, ref).normalize();
|
|
156
|
+
const v = new THREE3.Vector3().crossVectors(axis, u).normalize();
|
|
45
157
|
return { u, v };
|
|
46
158
|
}
|
|
47
|
-
var LinkFrameHelper = class extends
|
|
159
|
+
var LinkFrameHelper = class extends THREE3.AxesHelper {
|
|
48
160
|
isLinkFrameHelper = true;
|
|
49
161
|
constructor(size = 0.2) {
|
|
50
162
|
super(size);
|
|
@@ -87,6 +199,6 @@ function addLinkFrameHelpers(robot, size) {
|
|
|
87
199
|
return out;
|
|
88
200
|
}
|
|
89
201
|
|
|
90
|
-
export { JointAxisHelper, JointLimitHelper, LinkFrameHelper, addJointAxisHelpers, addJointLimitHelpers, addLinkFrameHelpers };
|
|
202
|
+
export { JointAxisHelper, JointLimitHelper, LinkFrameHelper, addJointAxisHelpers, addJointLimitHelpers, addLinkFrameHelpers, createGhostRobot, getLinkMeshes, highlightLink, restoreAllLinkMaterials, restoreLinkMaterials, setLinkMaterial };
|
|
91
203
|
//# sourceMappingURL=helpers.js.map
|
|
92
204
|
//# sourceMappingURL=helpers.js.map
|
package/dist/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/helpers/JointAxisHelper.ts","../src/helpers/JointLimitHelper.ts","../src/helpers/LinkFrameHelper.ts","../src/helpers/attach.ts"],"names":["THREE","lo","hi","THREE3"],"mappings":";;;AAQO,IAAM,eAAA,GAAN,cAAoCA,MAAA,CAAA,WAAA,CAAY;AAAA,EAC5C,iBAAA,GAAoB,IAAA;AAAA,EAE7B,WAAA,CAAY,KAAA,EAAoB,MAAA,GAAS,GAAA,EAAK,QAAmC,QAAA,EAAU;AACzF,IAAA,KAAA,CAAM,KAAA,CAAM,IAAA,CAAK,KAAA,EAAM,CAAE,SAAA,EAAU,EAAG,IAAUA,MAAA,CAAA,OAAA,CAAQ,CAAA,EAAG,CAAA,EAAG,CAAC,CAAA,EAAG,QAAQ,KAAK,CAAA;AAC/E,IAAA,IAAA,CAAK,IAAA,GAAO,CAAA,EAAG,KAAA,CAAM,SAAS,CAAA,KAAA,CAAA;AAAA,EAChC;AACF;ACNO,IAAM,gBAAA,GAAN,cAAqC,MAAA,CAAA,IAAA,CAAK;AAAA,EACtC,kBAAA,GAAqB,IAAA;AAAA,EAE9B,WAAA,CAAY,KAAA,EAAoB,MAAA,GAAS,IAAA,EAAM,QAAmC,KAAA,EAAU;AAC1F,IAAA,KAAA,CAAM,kBAAA,CAAmB,OAAO,MAAM,CAAA,EAAG,IAAU,MAAA,CAAA,iBAAA,CAAkB,EAAE,KAAA,EAA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gB,KAAA,EAAO,QAAQ,KAAK,CAAA;AACvD,IAAA,KAAA,CAAM,IAAI,MAAM,CAAA;AAChB,IAAA,GAAA,CAAI,KAAK,MAAM,CAAA;AAAA,EACjB;AACA,EAAA,OAAO,GAAA;AACT;AAGO,SAAS,oBAAA,CACd,KAAA,EACA,MAAA,EACA,KAAA,EACoB;AACpB,EAAA,MAAM,MAA0B,EAAC;AACjC,EAAA,KAAA,MAAW,IAAA,IAAQ,KAAA,CAAM,aAAA,EAAc,EAAG;AACxC,IAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,cAAA,CAAe,IAAI,CAAA;AACvC,IAAA,IAAI,CAAC,OAAO,WAAA,EAAa;AACzB,IAAA,MAAM,MAAA,GAAS,IAAI,gBAAA,CAAiB,KAAA,EAAO,QAAQ,KAAK,CAAA;AACxD,IAAA,KAAA,CAAM,IAAI,MAAM,CAAA;AAChB,IAAA,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":["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/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;AAoBO,SAAS,aAAA,CACd,KAAA,EACA,IAAA,EACA,OAAA,GAAgC,EAAC,EACxB;AACT,EAAA,MAAM,SAAS,aAAA,CAAc,KAAA,EAAO,IAAA,EAAM,OAAA,CAAQ,QAAQ,QAAQ,CAAA;AAClE,EAAA,IAAI,MAAA,CAAO,MAAA,KAAW,CAAA,EAAG,OAAO,KAAA;AAEhC,EAAA,MAAM,KAAA,GAAQ,IAAUA,MAAA,CAAA,KAAA,CAAM,OAAA,CAAQ,SAAS,QAAQ,CAAA;AACvD,EAAA,KAAA,MAAW,QAAQ,MAAA,EAA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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"]}
|