three-usd-robot 0.4.0 → 0.6.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 +136 -35
- package/dist/AssetResolver-CpIJNgWZ.d.ts +29 -0
- package/dist/{ThreeUsdRobot-Deoh7zam.d.ts → ThreeUsdRobot-CajXJqYU.d.ts} +1 -1
- package/dist/ThreeUsdRobotLoader-DrMMLzo-.d.ts +67 -0
- package/dist/{buildKinematicTree-CZjBMA1I.d.ts → buildKinematicTree-wtZPzy0B.d.ts} +53 -16
- package/dist/{chunk-FYVZ7YPW.js → chunk-4MEZM763.js} +3153 -2618
- package/dist/chunk-4MEZM763.js.map +1 -0
- package/dist/chunk-JZMCABQO.js +864 -0
- package/dist/chunk-JZMCABQO.js.map +1 -0
- package/dist/chunk-YVWSO27W.js +709 -0
- package/dist/chunk-YVWSO27W.js.map +1 -0
- package/dist/core.d.ts +297 -134
- package/dist/core.js +2 -1
- package/dist/extras.d.ts +2 -2
- package/dist/helpers.d.ts +2 -2
- package/dist/index.d.ts +229 -83
- package/dist/index.js +271 -631
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +72 -0
- package/dist/react.js +92 -0
- package/dist/react.js.map +1 -0
- package/package.json +22 -1
- package/dist/chunk-FYVZ7YPW.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
# three-usd-robot
|
|
2
2
|
|
|
3
|
-
> **Kinematic OpenUSD robot loader for Three.js.**
|
|
4
|
-
> Load Isaac Sim / OpenUSD robot assets,
|
|
5
|
-
>
|
|
3
|
+
> **Kinematic OpenUSD robot loader — and exporter — for Three.js.**
|
|
4
|
+
> Load Isaac Sim / OpenUSD robot assets, control their joints in the browser,
|
|
5
|
+
> and write scenes back out as USD. No physics engine, no OpenUSD/WASM
|
|
6
|
+
> dependency.
|
|
6
7
|
|
|
7
8
|
Think of it as a **USD version of [`urdf-loader`](https://www.npmjs.com/package/urdf-loader)**:
|
|
8
|
-
it reads the link / joint / xform / mesh structure out of `UsdPhysics`
|
|
9
|
+
it reads the link / joint / xform / mesh structure out of `UsdPhysics` assets
|
|
9
10
|
and drives forward kinematics on a Three.js `Object3D` hierarchy.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
> (crate)**, and **`.usdz`** robots — including **multi-file assets** via
|
|
13
|
-
> references / payloads / sublayers (resolved across `.usda` *and* binary layers,
|
|
14
|
-
> with relationship-path remapping), **variant selections**, and **instanceable**
|
|
15
|
-
> prims — drives forward kinematics with meshes, applies flat **`UsdShade`
|
|
16
|
-
> material colors** (UsdPreviewSurface / OmniPBR constants) and **diffuse
|
|
17
|
-
> textures** (`UsdUVTexture`), normalizes up-axis & units, seeds the initial
|
|
18
|
-
> pose, and **plays back time-sampled joint trajectories**. The crate reader is a
|
|
19
|
-
> from-scratch TypeScript implementation (no OpenUSD/WASM dependency). Not yet:
|
|
20
|
-
> time samples and variant *selection* stored inside binary crate.
|
|
12
|
+

|
|
21
13
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- **Formats** — ASCII `.usda`, binary `.usdc` / `.usd`, and `.usdz`, auto-detected.
|
|
17
|
+
Multi-file assets (references / payloads / sublayers), variant selections and
|
|
18
|
+
instanceable prims are composed for you.
|
|
19
|
+
- **Robots** — links, joints (fixed / revolute / continuous / prismatic), limits,
|
|
20
|
+
drives and the initial pose become a `setJointValue`-able hierarchy.
|
|
21
|
+
- **Rendering** — meshes with `UsdShade` materials (UsdPreviewSurface / OmniPBR)
|
|
22
|
+
and textures; up-axis and units normalized automatically.
|
|
23
|
+
- **Animation** — plays back time-sampled joint trajectories.
|
|
24
|
+
- **Export** — write robots and whole cells back to `.usda` / `.usdz`,
|
|
25
|
+
simulation-ready for Isaac Sim.
|
|
26
|
+
- **React** — declarative `<UsdRobot>` for React Three Fiber.
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
Not yet supported: time samples and variant *selections* stored inside binary
|
|
29
|
+
crate files, and full material/shader fidelity.
|
|
30
30
|
|
|
31
31
|
## Install
|
|
32
32
|
|
|
@@ -36,11 +36,12 @@ npm install three-usd-robot three
|
|
|
36
36
|
|
|
37
37
|
`three` is a **peer dependency** (`>=0.160.0`).
|
|
38
38
|
|
|
39
|
-
##
|
|
39
|
+
## Quick start
|
|
40
40
|
|
|
41
41
|
```ts
|
|
42
42
|
import { ThreeUsdRobotLoader } from "three-usd-robot";
|
|
43
43
|
|
|
44
|
+
// .usda / .usdc / binary .usd / .usdz are all auto-detected.
|
|
44
45
|
const robot = await new ThreeUsdRobotLoader().loadAsync("/assets/arm.usda");
|
|
45
46
|
scene.add(robot);
|
|
46
47
|
|
|
@@ -52,9 +53,12 @@ const handMatrix = robot.getLinkWorldMatrix("tool0"); // THREE.Matrix4
|
|
|
52
53
|
const handPos = robot.getLinkWorldPosition("tool0"); // THREE.Vector3
|
|
53
54
|
|
|
54
55
|
robot.getJointNames(); // controllable joints
|
|
55
|
-
robot.getKinematicTree(); // root, ordering,
|
|
56
|
+
robot.getKinematicTree(); // root, ordering, loop joints, ...
|
|
56
57
|
```
|
|
57
58
|
|
|
59
|
+
Already have the bytes? Use `parse(usdaText)`, `parseCrate(usdcBytes)` or
|
|
60
|
+
`parseUsdz(bytes)` instead of `loadAsync`.
|
|
61
|
+
|
|
58
62
|
### Viewer toggles & helpers
|
|
59
63
|
|
|
60
64
|
```ts
|
|
@@ -67,6 +71,10 @@ import { addJointLimitHelpers } from "three-usd-robot/helpers";
|
|
|
67
71
|
addJointLimitHelpers(robot); // arc (revolute) / segment (prismatic) per joint
|
|
68
72
|
```
|
|
69
73
|
|
|
74
|
+
Loading a whole cell rather than a bare robot? Pass
|
|
75
|
+
`{ loadSceneGeometry: true }` to the loader to draw the static environment
|
|
76
|
+
(floor, guarding, racking, …) around the machines.
|
|
77
|
+
|
|
70
78
|
### Joint slider panel (lil-gui)
|
|
71
79
|
|
|
72
80
|
```ts
|
|
@@ -76,24 +84,107 @@ import { createJointSliderPanel } from "three-usd-robot/extras";
|
|
|
76
84
|
createJointSliderPanel(robot, new GUI()); // one slider per articulated joint
|
|
77
85
|
```
|
|
78
86
|
|
|
79
|
-
The
|
|
80
|
-
`lil-gui`.
|
|
87
|
+
The panel takes the GUI instance from you, so the library never bundles
|
|
88
|
+
`lil-gui`.
|
|
81
89
|
|
|
82
90
|
### Animation playback
|
|
83
91
|
|
|
84
|
-
If the asset has time-sampled joint trajectories
|
|
85
|
-
time samples), the robot plays them back:
|
|
92
|
+
If the asset has time-sampled joint trajectories, the robot plays them back:
|
|
86
93
|
|
|
87
94
|
```ts
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// in your render loop, advance a time code and sample:
|
|
95
|
+
const range = robot.getTimeRange();
|
|
96
|
+
if (range) {
|
|
97
|
+
// in your render loop, advance a time code between range.start and range.end:
|
|
92
98
|
robot.setTime(t); // interpolates every animated joint and updates FK
|
|
93
99
|
}
|
|
94
100
|
```
|
|
95
101
|
|
|
96
|
-
###
|
|
102
|
+
### React Three Fiber
|
|
103
|
+
|
|
104
|
+
`three-usd-robot/react` provides a declarative `<UsdRobot>` (`react` and
|
|
105
|
+
`@react-three/fiber` are **optional** peer deps):
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
import { Canvas } from "@react-three/fiber";
|
|
109
|
+
import { Suspense } from "react";
|
|
110
|
+
import { UsdRobot } from "three-usd-robot/react";
|
|
111
|
+
|
|
112
|
+
<Canvas camera={{ position: [2, 2, 2] }}>
|
|
113
|
+
<Suspense fallback={null}>
|
|
114
|
+
<UsdRobot
|
|
115
|
+
url="/robot.usda"
|
|
116
|
+
jointValues={{ joint1: 0.4 }} // controlled
|
|
117
|
+
showJointAxes
|
|
118
|
+
animate // play time-sampled trajectories
|
|
119
|
+
onLoad={(robot) => console.log(robot.getJointNames())}
|
|
120
|
+
/>
|
|
121
|
+
</Suspense>
|
|
122
|
+
<ambientLight />
|
|
123
|
+
</Canvas>;
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Also exported: `useUsdRobot(url)` (Suspense loader), `useRobotAnimation(robot)`,
|
|
127
|
+
`preloadUsdRobot`, `clearUsdRobotCache`. Pass a `ref` to `<UsdRobot>` for the
|
|
128
|
+
imperative API.
|
|
129
|
+
|
|
130
|
+
## Export USD
|
|
131
|
+
|
|
132
|
+
The loader's inverse: re-export something you loaded, or author a robot from
|
|
133
|
+
Three.js objects and open the result in Isaac Sim.
|
|
134
|
+
|
|
135
|
+

|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import {
|
|
139
|
+
exportThreeUsdRobot,
|
|
140
|
+
RobotBuilder,
|
|
141
|
+
serializeUsda,
|
|
142
|
+
writeUsdz,
|
|
143
|
+
} from "three-usd-robot";
|
|
144
|
+
|
|
145
|
+
// Re-export a loaded robot (meshes harvested from the Three.js scene):
|
|
146
|
+
const usda = serializeUsda(exportThreeUsdRobot(robot));
|
|
147
|
+
|
|
148
|
+
// …or build one from Three.js meshes. Z-up and metres by default; each joint
|
|
149
|
+
// takes ONE world-space frame, and the build-time arrangement is the zero pose.
|
|
150
|
+
const builder = new RobotBuilder({ name: "my_robot" });
|
|
151
|
+
builder.addLink({ name: "base", visuals: [baseMesh] });
|
|
152
|
+
builder.addLink({ name: "arm", frame: armFrame, visuals: [armMesh] });
|
|
153
|
+
builder.addFixedJoint({ name: "root_joint", child: "base" });
|
|
154
|
+
builder.addRevoluteJoint({
|
|
155
|
+
name: "j1", parent: "base", child: "arm",
|
|
156
|
+
frame: jointFrame, axis: "Z", lower: -Math.PI, upper: Math.PI,
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const file = builder.toUsda();
|
|
160
|
+
writeFileSync("robot.usda", serializeUsda(file));
|
|
161
|
+
writeFileSync("robot.usdz", writeUsdz({ "robot.usda": serializeUsda(file) }));
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Joints export as `UsdPhysics` prims with their limits, drives and initial pose.
|
|
165
|
+
For a simulation-ready asset, links also take mass properties, and collision
|
|
166
|
+
meshes take physics materials and a collision approximation:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
builder.addLink({
|
|
170
|
+
name: "arm",
|
|
171
|
+
visuals: [armMesh],
|
|
172
|
+
collisions: [armCollisionMesh],
|
|
173
|
+
inertial: { mass: 2.5, centerOfMass: [0, 0, 0.2], diagonalInertia: [0.02, 0.02, 0.004] },
|
|
174
|
+
collisionApproximation: "convexHull",
|
|
175
|
+
physicsMaterial: { name: "steel", staticFriction: 0.6, dynamicFriction: 0.5 },
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Both screenshots above come from `npx tsx scripts/demo-factory.ts`, which
|
|
180
|
+
authors a complete robot cell — a 7-DOF arm with a gripper, a conveyor, a
|
|
181
|
+
turntable and the surrounding scenery — and exports it to
|
|
182
|
+
`out/factory.usda` / `.usdz`.
|
|
183
|
+
|
|
184
|
+
## Use it without Three.js
|
|
185
|
+
|
|
186
|
+
`three-usd-robot/core` is a standalone USD parser, writer and robot IR — handy
|
|
187
|
+
for server-side validation or asset tooling:
|
|
97
188
|
|
|
98
189
|
```ts
|
|
99
190
|
import { parseUsda, Stage, extractRobotDescription } from "three-usd-robot/core";
|
|
@@ -102,14 +193,24 @@ const desc = extractRobotDescription(Stage.OpenFromString(usdaText));
|
|
|
102
193
|
console.log(desc.rootLink, Object.keys(desc.joints));
|
|
103
194
|
```
|
|
104
195
|
|
|
196
|
+
Command line: `npx tsx scripts/usdc-to-usda.ts robot.usd` converts binary crate
|
|
197
|
+
and `.usdz` packages to ASCII USDA.
|
|
198
|
+
|
|
199
|
+
## Examples
|
|
200
|
+
|
|
201
|
+
[`examples/`](./examples) holds runnable Vite demos, including a React Three
|
|
202
|
+
Fiber viewer that loads any asset via `?asset=<url>` and exports it back to
|
|
203
|
+
`.usda` / `.usdz`.
|
|
204
|
+
|
|
105
205
|
## Package entry points
|
|
106
206
|
|
|
107
207
|
| Import | Contents |
|
|
108
208
|
| --- | --- |
|
|
109
|
-
| `three-usd-robot` | Three.js runtime — `ThreeUsdRobotLoader`, `ThreeUsdRobot` |
|
|
110
|
-
| `three-usd-robot/core` | Three.js-independent
|
|
209
|
+
| `three-usd-robot` | Three.js runtime — `ThreeUsdRobotLoader`, `ThreeUsdRobot`, `RobotBuilder`, export helpers |
|
|
210
|
+
| `three-usd-robot/core` | Three.js-independent USD parser & writer, robot IR, forward-kinematics math |
|
|
111
211
|
| `three-usd-robot/helpers` | Viewer helpers (joint axes, link frames, joint limits) |
|
|
112
|
-
| `three-usd-robot/extras` |
|
|
212
|
+
| `three-usd-robot/extras` | Joint slider panel (bring your own `lil-gui`) |
|
|
213
|
+
| `three-usd-robot/react` | React Three Fiber `<UsdRobot>` component + hooks |
|
|
113
214
|
|
|
114
215
|
## Development
|
|
115
216
|
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves USD asset paths (from references / payloads / sublayers) to URLs and
|
|
3
|
+
* fetches their text. Composition (`composition.ts`) is I/O-agnostic and goes
|
|
4
|
+
* through an {@link AssetResolver}, so the same engine works in the browser, in
|
|
5
|
+
* Node, or against an in-memory file map in tests.
|
|
6
|
+
*/
|
|
7
|
+
interface AssetResolver {
|
|
8
|
+
/** Resolve an authored asset path against the layer's base URL to an absolute key. */
|
|
9
|
+
resolve(assetPath: string, baseUrl: string): string;
|
|
10
|
+
/** Fetch the text of a resolved asset; rejects if it cannot be read. */
|
|
11
|
+
fetchText(url: string): Promise<string>;
|
|
12
|
+
/** Fetch the raw bytes of a resolved asset (for binary USDC / USDZ). Optional. */
|
|
13
|
+
fetchBytes?(url: string): Promise<Uint8Array>;
|
|
14
|
+
}
|
|
15
|
+
/** URL-based resolver using the global `fetch` (browser / Node 18+). */
|
|
16
|
+
declare class DefaultAssetResolver implements AssetResolver {
|
|
17
|
+
resolve(assetPath: string, baseUrl: string): string;
|
|
18
|
+
fetchText(url: string): Promise<string>;
|
|
19
|
+
fetchBytes(url: string): Promise<Uint8Array>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolver over an in-memory `{ path: contents }` map (text or bytes), with
|
|
23
|
+
* posix-style joins. Useful for tests and bundled assets.
|
|
24
|
+
*/
|
|
25
|
+
declare function createMemoryResolver(files: Record<string, string | Uint8Array>): AssetResolver;
|
|
26
|
+
/** Resolve `rel` against `baseUrl` using posix semantics, normalizing `.`/`..`. */
|
|
27
|
+
declare function joinPosix(baseUrl: string, rel: string): string;
|
|
28
|
+
|
|
29
|
+
export { type AssetResolver as A, DefaultAssetResolver as D, createMemoryResolver as c, joinPosix as j };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as THREE from 'three';
|
|
2
|
-
import { J as JointType, A as Axis, a as JointDescription, L as LinkDescription, R as RobotDescription, K as KinematicTree } from './buildKinematicTree-
|
|
2
|
+
import { J as JointType, A as Axis, a as JointDescription, L as LinkDescription, R as RobotDescription, K as KinematicTree } from './buildKinematicTree-wtZPzy0B.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The articulated "motion" node of a joint, inserted between the joint's two
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { R as RobotDescription } from './buildKinematicTree-wtZPzy0B.js';
|
|
2
|
+
import { A as AssetResolver } from './AssetResolver-CpIJNgWZ.js';
|
|
3
|
+
import { T as ThreeUsdRobot } from './ThreeUsdRobot-CajXJqYU.js';
|
|
4
|
+
|
|
5
|
+
type ThreeUsdRobotLoaderOptions = {
|
|
6
|
+
/** Resolver for references / payloads / sublayers (default {@link DefaultAssetResolver}). */
|
|
7
|
+
assetResolver?: AssetResolver;
|
|
8
|
+
/** Render visual meshes (M6). */
|
|
9
|
+
loadVisuals?: boolean;
|
|
10
|
+
/** Render collision meshes (M6). */
|
|
11
|
+
loadCollisions?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Also render Mesh prims that belong to no link — the static scenery of a
|
|
14
|
+
* cell that contains robots (floor, guarding, racking, …). Placed by their
|
|
15
|
+
* authored stage transform. Default `false`.
|
|
16
|
+
*/
|
|
17
|
+
loadSceneGeometry?: boolean;
|
|
18
|
+
/** Load diffuse textures referenced by materials (default `true`). */
|
|
19
|
+
loadTextures?: boolean;
|
|
20
|
+
/** Up-axis correction strategy (M9). */
|
|
21
|
+
upAxisConversion?: "auto" | "Y" | "Z" | "none";
|
|
22
|
+
/** Extra uniform scale multiplied with `metersPerUnit` (M9). */
|
|
23
|
+
unitScale?: number;
|
|
24
|
+
/** Clamp `setJointValue` to authored limits (default `true`). */
|
|
25
|
+
clampJointLimits?: boolean;
|
|
26
|
+
/** Seed joints from drive targets / joint state (M9). */
|
|
27
|
+
applyDriveTargetsAsInitialPose?: boolean;
|
|
28
|
+
/** Override the robot name. */
|
|
29
|
+
robotName?: string;
|
|
30
|
+
/** Receives non-fatal load diagnostics. */
|
|
31
|
+
onWarn?: (message: string) => void;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Loads Isaac Sim / OpenUSD robot assets into a controllable {@link ThreeUsdRobot}.
|
|
35
|
+
*
|
|
36
|
+
* Composition (references / payloads / sublayers, M8) is resolved through an
|
|
37
|
+
* {@link AssetResolver}. Mesh rendering is M6; unit / up-axis / initial-pose
|
|
38
|
+
* handling is M9; USDC and variants are M10.
|
|
39
|
+
*/
|
|
40
|
+
declare class ThreeUsdRobotLoader {
|
|
41
|
+
readonly options: ThreeUsdRobotLoaderOptions;
|
|
42
|
+
constructor(options?: ThreeUsdRobotLoaderOptions);
|
|
43
|
+
private get resolver();
|
|
44
|
+
/**
|
|
45
|
+
* Fetch an asset by URL and build the robot. `.usdz` packages are unzipped and
|
|
46
|
+
* composed from their entries; everything else is sniffed for the crate magic
|
|
47
|
+
* and parsed as binary USDC or USDA text.
|
|
48
|
+
*/
|
|
49
|
+
loadAsync(url: string): Promise<ThreeUsdRobot>;
|
|
50
|
+
private fetchRootBytes;
|
|
51
|
+
/** Build a robot (composed, with meshes) from USDA source text. */
|
|
52
|
+
parse(text: string, baseUrl?: string): Promise<ThreeUsdRobot>;
|
|
53
|
+
/** Build a robot from the bytes of a `.usdz` package. */
|
|
54
|
+
parseUsdz(bytes: Uint8Array): Promise<ThreeUsdRobot>;
|
|
55
|
+
/** Build a robot from the bytes of a binary crate (`.usdc` / binary `.usd`). */
|
|
56
|
+
parseCrate(bytes: Uint8Array, baseUrl?: string): Promise<ThreeUsdRobot>;
|
|
57
|
+
/** Parse + compose USDA source into the Three.js-independent robot IR. */
|
|
58
|
+
parseRobotDescription(text: string, baseUrl?: string): Promise<RobotDescription>;
|
|
59
|
+
private buildFromStage;
|
|
60
|
+
private composeStage;
|
|
61
|
+
/** Compose a layer from raw bytes, sniffing binary crate vs USDA text. */
|
|
62
|
+
private composeStageFromBytes;
|
|
63
|
+
private robotOptions;
|
|
64
|
+
private extractOptions;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export { type ThreeUsdRobotLoaderOptions as T, ThreeUsdRobotLoader as a };
|
|
@@ -125,6 +125,25 @@ type RelationshipSpec = {
|
|
|
125
125
|
line: number;
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Time-sample interpolation for animated values (e.g. joint trajectories).
|
|
130
|
+
*
|
|
131
|
+
* USD time samples are keyed by time code. We linearly interpolate between the
|
|
132
|
+
* two bracketing samples and hold the endpoints outside the authored range
|
|
133
|
+
* (matching USD's held extrapolation).
|
|
134
|
+
*/
|
|
135
|
+
/** A sorted time-sampled scalar channel. */
|
|
136
|
+
type SampleChannel = {
|
|
137
|
+
/** Sample times, ascending. */
|
|
138
|
+
times: number[];
|
|
139
|
+
/** Sample values, parallel to {@link times} (SI units). */
|
|
140
|
+
values: number[];
|
|
141
|
+
};
|
|
142
|
+
/** Linearly sample `channel` at time `t` (held outside the range). */
|
|
143
|
+
declare function interpolate(channel: SampleChannel, t: number): number;
|
|
144
|
+
/** Build a sorted {@link SampleChannel} from `(time → value)` pairs via `map`. */
|
|
145
|
+
declare function channelFromSamples(samples: Map<number, number>): SampleChannel;
|
|
146
|
+
|
|
128
147
|
/**
|
|
129
148
|
* Minimal 4×4 matrix math, Three.js-independent.
|
|
130
149
|
*
|
|
@@ -176,25 +195,21 @@ declare function makeEuler(angles: Vec3, order: string): Mat4;
|
|
|
176
195
|
declare function fromUsdMatrix(m: UsdMatrix): Mat4;
|
|
177
196
|
/** Extract the translation component `[x, y, z]` from a {@link Mat4}. */
|
|
178
197
|
declare function getTranslation(m: Mat4): Vec3;
|
|
179
|
-
|
|
198
|
+
/** Copy a {@link Mat4} into a USD `matrix4d` — same flat layout (see module docs). */
|
|
199
|
+
declare function toUsdMatrix(m: Mat4): UsdMatrix;
|
|
180
200
|
/**
|
|
181
|
-
*
|
|
201
|
+
* Decompose a rigid transform into translation + orientation (M13 export).
|
|
182
202
|
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
203
|
+
* The rotation basis is orthonormalized (Gram-Schmidt, right-handed) before
|
|
204
|
+
* quaternion extraction; `rigid` reports whether the input already was rigid
|
|
205
|
+
* within tolerance, so callers can warn that scale/shear/reflection was
|
|
206
|
+
* discarded.
|
|
186
207
|
*/
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
/** Sample values, parallel to {@link times} (SI units). */
|
|
192
|
-
values: number[];
|
|
208
|
+
declare function decomposeRigid(m: Mat4): {
|
|
209
|
+
position: Vec3;
|
|
210
|
+
orientation: Quat;
|
|
211
|
+
rigid: boolean;
|
|
193
212
|
};
|
|
194
|
-
/** Linearly sample `channel` at time `t` (held outside the range). */
|
|
195
|
-
declare function interpolate(channel: SampleChannel, t: number): number;
|
|
196
|
-
/** Build a sorted {@link SampleChannel} from `(time → value)` pairs via `map`. */
|
|
197
|
-
declare function channelFromSamples(samples: Map<number, number>): SampleChannel;
|
|
198
213
|
|
|
199
214
|
/**
|
|
200
215
|
* Robot intermediate representation (IR) — Three.js-independent.
|
|
@@ -240,6 +255,28 @@ type LinkDescription = {
|
|
|
240
255
|
visualPrims: string[];
|
|
241
256
|
/** Mesh prim paths flagged with a collision API. */
|
|
242
257
|
collisionPrims?: string[];
|
|
258
|
+
/** Mass properties (`UsdPhysicsMassAPI`), if authored (M16). */
|
|
259
|
+
inertial?: LinkInertialDescription;
|
|
260
|
+
/**
|
|
261
|
+
* Authored stage (world) transform of the link prim, when not identity.
|
|
262
|
+
* Joint chains place tree links; this places floating roots and links that
|
|
263
|
+
* are isolated from the chosen tree (e.g. other machines / free bodies on a
|
|
264
|
+
* multi-articulation stage).
|
|
265
|
+
*/
|
|
266
|
+
worldTransform?: Mat4;
|
|
267
|
+
};
|
|
268
|
+
/** Mass properties as authored by `UsdPhysicsMassAPI` (stage units). */
|
|
269
|
+
type LinkInertialDescription = {
|
|
270
|
+
/** Mass in kilograms. */
|
|
271
|
+
mass?: number;
|
|
272
|
+
/** Center of mass in the link frame (stage linear units). */
|
|
273
|
+
centerOfMass?: Vec3;
|
|
274
|
+
/** Principal moments of inertia. */
|
|
275
|
+
diagonalInertia?: Vec3;
|
|
276
|
+
/** Orientation of the principal inertia axes in the link frame. */
|
|
277
|
+
principalAxes?: Quat;
|
|
278
|
+
/** Density — the physics engine derives mass from it when `mass` is absent. */
|
|
279
|
+
density?: number;
|
|
243
280
|
};
|
|
244
281
|
type JointDescription = {
|
|
245
282
|
/** Display name (leaf prim name). */
|
|
@@ -319,4 +356,4 @@ type BuildTreeOptions = {
|
|
|
319
356
|
};
|
|
320
357
|
declare function buildKinematicTree(robot: RobotDescription, options?: BuildTreeOptions): KinematicTree;
|
|
321
358
|
|
|
322
|
-
export { type Axis as A, type BuildTreeOptions as B, type CompositionArc as C, DEG2RAD as D,
|
|
359
|
+
export { type Axis as A, type BuildTreeOptions as B, type CompositionArc as C, DEG2RAD as D, invert as E, makeEuler as F, makeRotationFromQuat as G, makeRotationX as H, makeRotationY as I, type JointType as J, type KinematicTree as K, type LinkDescription as L, type Mat4 as M, makeRotationZ as N, makeScale as O, type PrimSpec as P, Quat as Q, type RobotDescription as R, type SampleChannel as S, type TreeEdge as T, type UsdaFile as U, type Vec2 as V, makeTranslation as W, multiply as X, multiplyAll as Y, toUsdMatrix as Z, type JointDescription as a, type Vec3 as b, type JointDriveDescription as c, type LinkInertialDescription as d, AssetPath as e, type AttributeSpec as f, type KinematicNode as g, type ListOp as h, type MetadataMap as i, type PropertySpec as j, RAD2DEG as k, type RelationshipSpec as l, type SdfPath as m, type Specifier as n, type UsdDictionary as o, UsdMatrix as p, type UsdValue as q, type Variability as r, type Vec4 as s, buildKinematicTree as t, channelFromSamples as u, decomposeRigid as v, fromUsdMatrix as w, getTranslation as x, identity4 as y, interpolate as z };
|