@nebula-spatial/viewer 0.4.5 → 0.5.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/CHANGELOG.md +62 -5
- package/README.md +98 -51
- package/dist/assets/types.d.ts +40 -11
- package/dist/cad/types.d.ts +4 -8
- package/dist/{index-CxbZ--5C.js → index-D2vtjYht.js} +2648 -2287
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -2
- package/dist/{mjcf-visual-6_RqDf4z.js → mjcf-visual-NkIASi_6.js} +2 -2
- package/dist/mujoco-runtime-7xiBQNJm.js +324 -0
- package/dist/session-DHPMjyl3.js +809 -0
- package/dist/{session-CnlODeFp.js → session-di9BueA_.js} +152 -163
- package/dist/{stage-BPiGudYP.js → stage-D-BewE6x.js} +198 -150
- package/dist/types.d.ts +11 -0
- package/dist/{urdf-session-CuIZOiCF.js → urdf-session-DsE5uC-u.js} +433 -424
- package/dist/usd-session-yEFMGOIp.js +2240 -0
- package/dist/version.d.ts +5 -0
- package/dist/{xacro-DrBtv-gK.js → xacro-D8OfZ2xw.js} +1 -1
- package/openusd/openusd_probe.js +14 -0
- package/openusd/openusd_probe.wasm +0 -0
- package/package.json +5 -4
- package/dist/mujoco-runtime-C29PXDOl.js +0 -258
- package/dist/session-DNyPmQOW.js +0 -795
- package/dist/usd-session-JDfuDgWv.js +0 -1907
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this package are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.5.0
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- USD 改用单线程 OpenUSD WASM 运行时(无 pthread、无 `SharedArrayBuffer`):浏览器不再需要 `Cross-Origin-Opener-Policy` / `Cross-Origin-Embedder-Policy` 跨源隔离响应头,也不再需要同源的 Blob 模块 Worker 入口;跨域 CDN 只需放行 CORS。
|
|
10
|
+
- USD 场景改用参考包纯 JS 的构建器,`USDSceneData` 抽取、引用发现与 Stage 生命周期由包内适配层负责。宿主提供的 `resourceResolver` 继续按引用逐项解析,语义与原先的引用预取一致。
|
|
11
|
+
- `@openusd-wasm/pxr` 不再是本包的直接依赖:Viewer 不再实例化 threaded PXR runtime,绕过 `USDSceneData` 的动态 Prim/Attribute 读取改由内置探针提供。
|
|
12
|
+
- 统一资产 source 类型:新增 `AssetSingleSource`,明确单源与 `{ kind: 'files' }` 文件包的区别;`Blob` 现已在公开类型中显式声明,CAD 的 `CadLoadSource` 与 `packFile` 兼容形态保留。
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- 新增 `openusd/` 运行时目录并随包发布:`openusd_probe.js` 与 `openusd_probe.wasm`,通过 `exports` 的 `./openusd/*` 暴露。`assets.openUsdBaseUrl` 缺省值改为 `/openusd/`(站点根绝对路径,不随页面所在子目录变化)。
|
|
17
|
+
- 新增单线程 USD 回归覆盖:真实关节资产(24 刚体 / 23 关节)走通 `compileUsdPhysics` → MuJoCo 的编译、步进与重置;GeomSubset 的 UV 重排与逐面子集材质分组与参考栈结果一致;引用解析的标识符归一、去重与 403 授权失败不再回退。
|
|
18
|
+
- 自动格式识别文档明确为“扩展名优先,loader `match()` 兜底”;无法从两者确定格式时,错误信息会提示提供入口文件名或显式 `format`。
|
|
19
|
+
|
|
20
|
+
### Removed
|
|
21
|
+
|
|
22
|
+
- 移除 `resolveUsdResourcePackage`:它只服务 threaded PXR 运行时的引用预取,职责已并入包内适配层的引用解析。
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- 修复发布产物中丢失的 `viewerVersion`:包入口此前只做副作用导入、没有重新导出该常量,模块级版本 banner 会被打包器整块摇掉,消费方既看不到 banner 也无法 `import { viewerVersion }`。现在入口显式导出该常量,`sideEffects` 如实标记为含副作用,构建产物与独立消费方产物都会校验 banner 与导出仍在。
|
|
27
|
+
- 修复 USDZ 包内纹理在 URL + `resourceResolver` 场景下被错误当作包外依赖请求的问题;包内条目优先由 USDZ 包解析器提供,resolver 仅处理真正的包外资源。
|
|
28
|
+
|
|
29
|
+
### Behavior notes
|
|
30
|
+
|
|
31
|
+
- 接入方需让 `openusd_probe.js` 与 `openusd_probe.wasm` 以同名同目录出现在站点可访问的路径下(拷入站点静态目录、由打包器的静态拷贝插件搬运,或上传到自有 CDN 后覆盖 `assets.openUsdBaseUrl`)。`assets.openUsdBaseUrl` 缺省为站点根下的 `/openusd/`,部署在子路径或 CDN 时需显式覆盖。
|
|
32
|
+
- 跨源隔离响应头不再是 USD 预览的必需项;playground / embed-viewer 的开发与预览服务器也不再发送它们,仓库内已无依赖 `SharedArrayBuffer` 的浏览器侧运行时代码。
|
|
33
|
+
- 本次发布只更新 Viewer;`@nebula-spatial/cad-loader` 和私有 `scene-runtime` 版本不变。
|
|
34
|
+
|
|
35
|
+
## 0.4.6
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- URDF 内置工作台新增结构图弹窗:以只读 SVG 渲染 Link/Joint 拓扑,支持缩放、重置视图、最大化、拖动窗口与四角拖拽改尺寸,节点与场景选择、结构树双向联动。
|
|
40
|
+
- 新增预览拖拽预设 `ViewerOptions.previewDragPreset` 与 `viewer.setPreviewDragPreset()`:在 `left-rotate`(默认,左键旋转/右键平移)和 `left-pan`(左键平移/右键旋转)之间切换模型与仿真预览的指针映射。
|
|
41
|
+
- 仿真资产(URDF/XACRO/MJCF/USD)新增 `capabilities.canReorientUpAxis` 与 `preview.setUpAxis()` 重定向:运行时已就绪时旋转编译后的物理模型,顶层刚体的参考位姿、当前位姿与速度一并跟随。
|
|
42
|
+
- 新增 `viewerVersion` 导出:包入口在模块加载时打印一次版本 banner,`check-boundary` 校验它与 `package.json` 版本是否漂移。
|
|
43
|
+
|
|
44
|
+
### Improved
|
|
45
|
+
|
|
46
|
+
- 内置 URDF UI 拆分为结构面板、属性面板、工具栏、状态栏与结构图组件,各自持有各自的 UI 状态;工具栏统一为覆盖层、名称、角度单位、地面、适应视图、主题、仿真与重置。
|
|
47
|
+
- 结构树在选中与关节控制刷新时保留滚动位置和焦点;mimic 联动关节按控制根分组展示,跟随关系与偏移量在同一分组内说明。
|
|
48
|
+
- 仿真上轴切换后按翻转后的包围盒重铺地面与反射,重力保持 -Z、物理地面保持水平;URDF 在运动学与动力学之间切换时上轴旋转不会叠加。
|
|
49
|
+
- GLB/glTF 按 glTF 规范默认使用 Y-up;FBX 仍优先读取文件内的正向 `UpAxis`/`UpAxisSign` 声明,USD/URDF/MJCF 保持默认 Z-up。
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
- 结构图弹窗背景改为半透明,避免遮挡底层模型;四角拖拽限制最小 420×320,并防止窗口被拖出画布范围。
|
|
54
|
+
|
|
55
|
+
### Behavior notes
|
|
56
|
+
|
|
57
|
+
- 结构图是只读拓扑视图,不编辑资产;不支持的语义仍以严格检查的错误列表为准。
|
|
58
|
+
- 仿真资产的上轴重定向移动的是编译后的物理模型:重力方向与查看器地面保持不变,固定基座机器人只会整体倾斜;无运行时(运动学预览、物理降级预览)退回纯场景图旋转。
|
|
59
|
+
- `left-pan` 仅为兼容 sim-studio 的既有映射,默认的 `left-rotate` 与 OrbitControls 约定一致。
|
|
60
|
+
- 本次发布只更新 Viewer;`@nebula-spatial/cad-loader` 和私有 `scene-runtime` 版本不变。
|
|
61
|
+
|
|
5
62
|
## 0.4.5
|
|
6
63
|
|
|
7
64
|
### Added
|
|
@@ -9,8 +66,8 @@ All notable changes to this package are documented in this file.
|
|
|
9
66
|
- 新增 USD 视觉材质适配支持矩阵,明确 `UsdPreviewSurface`、MaterialX Standard Surface、OmniPBR 和 OmniGlass 的已转换、有界近似及未适配范围。
|
|
10
67
|
- 支持常量介质透明、`presence`、`opacityThreshold`、受限透明纹理、MaterialX 薄壁透射,以及 OmniGlass 的覆盖率、反射颜色、粗糙度和受限法线适配。
|
|
11
68
|
- 支持 USD 实例材质代理中的可确定常量 `UsdPreviewSurface` 输入恢复;保留循环、歧义、程序节点和体积光学语义的诊断。
|
|
12
|
-
- 本地 Viewer 文件包入口支持 `root.usd`、`root.usda`、`root.usdc` 和 `root.usdz`,不受上传顺序影响。
|
|
13
|
-
- 支持浏览器 Xacro 子集展开,包含宏、属性、参数、条件、块参数、嵌套 include 与 ROS package 映射;不支持的 Python/ROS 语义会显式失败。
|
|
69
|
+
- 本地 Viewer 文件包入口支持 `root.usd`、`root.usda`、`root.usdc` 和 `root.usdz`,不受上传顺序影响。
|
|
70
|
+
- 支持浏览器 Xacro 子集展开,包含宏、属性、参数、条件、块参数、嵌套 include 与 ROS package 映射;不支持的 Python/ROS 语义会显式失败。
|
|
14
71
|
- 支持 URDF mimic 联动、可行控制范围、浏览器 COLLADA 网格、内嵌材质,以及本地文件包目录浏览和入口切换。
|
|
15
72
|
|
|
16
73
|
### Improved
|
|
@@ -18,20 +75,20 @@ All notable changes to this package are documented in this file.
|
|
|
18
75
|
- 统一 URDF/MJCF 视觉材质的线性颜色、粗糙度、金属度、法线、透明度、发光和纹理通道转换,并补充纹理资源释放与诊断。
|
|
19
76
|
- URDF 审查工作台补充惯性姿态、惯量信息展开、连续关节控制范围、关节扫描和侧栏交互保持。
|
|
20
77
|
- USD 视觉过滤按 `purpose` 隔离辅助几何;修正世界侧关节参考系、单位/up-axis 转换和显式惯性处理。
|
|
21
|
-
- 物理模型取景忽略环境平面,避免地面或辅助几何主导模型缩放;补充跨格式材质审计页面及 Chromium 验证脚本。
|
|
78
|
+
- 物理模型取景忽略环境平面,避免地面或辅助几何主导模型缩放;补充跨格式材质审计页面及 Chromium 验证脚本。
|
|
22
79
|
- 恢复分离 USD 视觉树到刚体的引用归属,支持显式引用 Prim 路径与 defaultPrim 引用,并对歧义、缺失和格式错误保留诊断。
|
|
23
80
|
|
|
24
81
|
### Fixed
|
|
25
82
|
|
|
26
83
|
- 玻璃透射材质按 USD `doubleSided` 声明应用单面/双面策略,避免共享材质被错误修改;纯金属材质不被误判为玻璃。
|
|
27
84
|
- 修复 USD 透明度、覆盖率阈值、透明纹理、OmniGlass 法线与反射参数的边界转换;无法可靠表达的体积吸收、实体光程和复杂光学效果继续报告诊断,不生成猜测值。
|
|
28
|
-
- 允许具有完整显式质量、质心、惯量和主轴数据的 USD 刚体缺少碰撞几何;仅有不完整惯性时仍明确失败,不虚构碰撞形状。
|
|
85
|
+
- 允许具有完整显式质量、质心、惯量和主轴数据的 USD 刚体缺少碰撞几何;仅有不完整惯性时仍明确失败,不虚构碰撞形状。
|
|
29
86
|
- 修复 URDF 固定轴 RPY、惯性坐标旋转、mimic 初始姿态与 MuJoCo equality 约束;修复 USD 聚合视觉网格不随对应刚体更新的问题。
|
|
30
87
|
|
|
31
88
|
### Behavior notes
|
|
32
89
|
|
|
33
90
|
- 本版本继续使用有边界的 Three.js 材质映射,不执行 MDL 或完整 MaterialX 节点网络,也不承诺与 Blender、Omniverse 或路径追踪渲染逐像素一致。
|
|
34
|
-
- `USD-VISUAL-MATERIAL-SUPPORT.md` 随 npm 包发布,记录具体支持矩阵;材质适配报告和诊断仍是判断单个资产结果的依据。
|
|
91
|
+
- `USD-VISUAL-MATERIAL-SUPPORT.md` 随 npm 包发布,记录具体支持矩阵;材质适配报告和诊断仍是判断单个资产结果的依据。
|
|
35
92
|
- Xacro 是受限浏览器预处理子集,不执行外部 ROS 命令或环境访问;复杂 Python/YAML 语义应先使用官方工具展开。
|
|
36
93
|
- 本次发布只更新 Viewer;`@nebula-spatial/cad-loader` 和私有 `scene-runtime` 版本不变。
|
|
37
94
|
|
package/README.md
CHANGED
|
@@ -197,6 +197,10 @@ resolve;增量几何和 sidecar 仍通过 `load-progress`、`document-change`
|
|
|
197
197
|
替换中的 open 会以 `E_SUPERSEDED` 结束,外部 `AbortSignal` 取消会以 `E_ABORTED` 结束。
|
|
198
198
|
旧的 `viewer.cad.open()` 仅作为兼容入口保留,已标记为 deprecated。
|
|
199
199
|
|
|
200
|
+
省略 `format` 与传入 `format: 'auto'` 等价。Viewer 先使用入口 URL、文件名或文件包 `entry` 的
|
|
201
|
+
扩展名选择 loader;扩展名缺失、未知或没有匹配 loader 时,再按注册顺序调用 loader 的
|
|
202
|
+
`match()` 做内容识别。只有两条路径都无法确定格式时,才需要调用方显式传入 `format`。
|
|
203
|
+
|
|
200
204
|
`viewer.cad.getSnapshot()` 返回深冻结快照(包括独立的 `CadInspectorSnapshot` / `CadHudSnapshot` 数据形状),适合状态管理;图层可用
|
|
201
205
|
`layers.setVisible(index, visible)` / `setVisibleBatch()` 做确定性更新。无参
|
|
202
206
|
`viewer.fitView()` 与 `viewer.fitAll()` 适配全部内容,`viewer.cad.fitSelection()` 只适配当前
|
|
@@ -223,15 +227,30 @@ stop();
|
|
|
223
227
|
旧句柄的 `close()` 只等待自己的资源清理,不会关闭后来打开的资产。`closeAsset()` 关闭调用瞬间
|
|
224
228
|
的活动资产。普通模型以 borrowed 方式挂入唯一 scene runtime,GPU 资源只由模型 session 释放。
|
|
225
229
|
|
|
226
|
-
|
|
230
|
+
模型的 authored up 轴在 Viewer 中由 `upAxis` 声明。预览世界固定 Z-up;FBX 会先读取
|
|
231
|
+
`GlobalSettings` 中正向的 Y/Z `UpAxis` 与 `UpAxisSign` 声明,声明缺失、损坏或当前不支持时才
|
|
232
|
+
回退到 Y-up;GLB/glTF 没有任何文件内声明可读,按 glTF 规范默认使用 Y-up,
|
|
233
|
+
只能由调用方声明。显式传入的 `upAxis` 始终优先。
|
|
227
234
|
对轴向错误的模型传 `upAxis: 'y'` 打开(仅旋转资产根节点,不移动相机与世界),或运行期用
|
|
228
235
|
`preview.setUpAxis('y' | 'z')` / `preview.getUpAxis()` 切换(切换后自动重铺地面并重新适配
|
|
229
|
-
相机,不平移贴地)。能力标志为 `capabilities.canReorientUpAxis
|
|
230
|
-
|
|
236
|
+
相机,不平移贴地)。能力标志为 `capabilities.canReorientUpAxis`。
|
|
237
|
+
|
|
238
|
+
仿真资产(URDF/XACRO/MJCF/USD)同样暴露 `canReorientUpAxis`,切换语义是**旋转编译后的物理模型**:
|
|
239
|
+
把所有顶层刚体绕世界原点按该轴向旋转(free joint 的参考位姿与当前位姿、速度一并跟随),重力仍为
|
|
240
|
+
-Z、物理地面仍是原有的水平面,因此杯子这类资产切换后会真的倾倒并沉降到地面,碰撞代理、力线、
|
|
241
|
+
抓取换算都和渲染保持一致。地面会随翻转自适应:物理平面重新落到翻转后资产的最低点,地面盘的
|
|
242
|
+
中心与范围按新包围盒重铺;相机**不**重新适配。URDF 固定基座机器人只会整体倾斜(基座焊接在世界上,
|
|
243
|
+
不会倒);无运行时(运动学预览、物理降级预览)时退回纯场景图旋转。
|
|
244
|
+
URDF/XACRO/MJCF 规范即 Z-up,USD 在加载时已按 stage 声明的 up 轴烘焙到 Z-up 世界朝向,所以三者的
|
|
245
|
+
初始值都是 `'z'`;`OpenAssetOptions.upAxis` 可覆盖初始值。
|
|
231
246
|
|
|
232
247
|
地面(网格线 + 反射 + 接影地板)可通过 `preview.setGroundVisible(false)` 整体隐藏、`preview.getGroundVisible()`
|
|
233
248
|
查询,对应 `capabilities.canToggleGround`;模型与仿真预览均支持。隐藏时跳过反射 pass,接影地板与地面阴影一并隐藏。
|
|
234
249
|
|
|
250
|
+
模型与仿真预览的鼠标拖拽映射由 `previewDragPreset` 决定,默认 `left-rotate`(左键旋转、右键平移、
|
|
251
|
+
中键缩放),`left-pan` 保留 sim-studio 的左键平移、右键旋转映射。运行期可用
|
|
252
|
+
`viewer.setPreviewDragPreset('left-rotate' | 'left-pan')` 切换。
|
|
253
|
+
|
|
235
254
|
GLB/glTF 的 Draco decoder 路径由宿主显式配置,不使用站点根路径默认值:
|
|
236
255
|
|
|
237
256
|
```ts
|
|
@@ -315,6 +334,9 @@ const preview = viewer.openAsset('https://cdn.example.com/robot/scene.xml', {
|
|
|
315
334
|
await preview.ready;
|
|
316
335
|
```
|
|
317
336
|
|
|
337
|
+
USDZ 是自包含 ZIP 包。包内 layer、mesh 和纹理由 Viewer 从包内读取,即使同时传入
|
|
338
|
+
`resourceResolver` 也不会把包内条目当作 CDN 兄弟资源请求;resolver 只处理包外引用。
|
|
339
|
+
|
|
318
340
|
对于私有 OSS/S3/CDN,常见的预签名 URL 只授权一个具体 Object Key。`root.usd` 的签名通常不能
|
|
319
341
|
复用于 `asset.usdc`、`physics/physics.usda`、纹理等兄弟资源,也不能把入口 URL 的 query
|
|
320
342
|
原样拼接到其他路径。`resourceResolver.resolve(path)` 必须为每个 `path` 返回独立有效的签名 URL
|
|
@@ -348,7 +370,7 @@ USD 仿真继续以 OpenUSD Stage 和 USD Physics 为语义权威;视觉适配
|
|
|
348
370
|
PBR 参数转换之后查漏补缺。它不会重建 loader 已正确生成的材质,也不会修改刚体、关节、碰撞体
|
|
349
371
|
或 MuJoCo 绑定。
|
|
350
372
|
|
|
351
|
-
USD 视觉引用归属:当视觉几何位于独立聚合树、刚体树中的 `Visual` Prim 通过 USD reference 指向该聚合树时,Viewer 会按引用的目标 Prim 路径将网格绑定到对应刚体,使其跟随 MuJoCo 运行时位姿。支持显式引用 Prim 路径及 defaultPrim 引用;多个刚体映射到同一视觉尾路径、引用元数据缺失或格式无法解析时不会猜测归属,而是保留视觉诊断。
|
|
373
|
+
USD 视觉引用归属:当视觉几何位于独立聚合树、刚体树中的 `Visual` Prim 通过 USD reference 指向该聚合树时,Viewer 会按引用的目标 Prim 路径将网格绑定到对应刚体,使其跟随 MuJoCo 运行时位姿。支持显式引用 Prim 路径及 defaultPrim 引用;多个刚体映射到同一视觉尾路径、引用元数据缺失或格式无法解析时不会猜测归属,而是保留视觉诊断。
|
|
352
374
|
实例化材质:当 Loader 遗漏实例代理中的 Shader 时,适配层沿 `outputs:surface` 读取
|
|
353
375
|
标准 `UsdPreviewSurface`,解析其输入到材质实例常量的连接,再复用 Loader 的材质转换。
|
|
354
376
|
当前只补齐可确定解析的常量网络;缺失、循环、歧义连接或纹理/程序节点网络保留原诊断。
|
|
@@ -404,19 +426,35 @@ USD 视觉引用归属:当视觉几何位于独立聚合树、刚体树中的
|
|
|
404
426
|
`getPhysicsProperties().diagnostics` 读取诊断列表。首个视觉降级也会作为 asset warning 发布,`stage` 为 `visual-adaptation`。如果同时发生物理降级,
|
|
405
427
|
物理 warning 优先显示,完整视觉诊断仍保留在 diagnostics 中。
|
|
406
428
|
|
|
407
|
-
OpenUSD
|
|
429
|
+
OpenUSD 现在使用单线程 WASM 构建(无 pthread、无 `SharedArrayBuffer`),因此**不再需要**跨源隔离
|
|
430
|
+
响应头:`Cross-Origin-Opener-Policy` 与 `Cross-Origin-Embedder-Policy` 已从 playground /
|
|
431
|
+
embed-viewer 的开发与预览服务器移除。
|
|
408
432
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
Cross-Origin-Embedder-Policy: require-corp
|
|
412
|
-
```
|
|
433
|
+
仓库里已没有依赖 `SharedArrayBuffer` 的运行时:playground 的 material-audit 也从参考包的 threaded
|
|
434
|
+
`USDLoader` 换成了本包的单线程 `createSingleThreadUsd`。
|
|
413
435
|
|
|
414
436
|
`@mujoco/mujoco` 和 `@openusd-wasm/three-loader` 保持动态加载。Vite 浏览器构建需要将 MuJoCo
|
|
415
437
|
包中的 Node-only 裸模块 `module` 精确 alias 到一个导出 `createRequire()` 的浏览器拒绝模块;
|
|
416
438
|
仓库的 `vite.config.ts` 和独立消费者验证脚本包含该配置。可通过 `assets.mujocoBaseUrl` 与
|
|
417
439
|
`assets.openUsdBaseUrl` 指向自行托管的 runtime 文件目录。
|
|
418
|
-
|
|
419
|
-
|
|
440
|
+
|
|
441
|
+
`assets.openUsdBaseUrl` 指向存放 `openusd_probe.js` 与 `openusd_probe.wasm` 的目录,默认 `/openusd/`,
|
|
442
|
+
即站点根绝对路径(不随页面所在子目录变化)。单线程构建是普通 ES 模块 + wasm,跨域 CDN 只需允许 CORS,不需要 Blob 模块 Worker
|
|
443
|
+
入口,也不需要上述跨源隔离响应头。
|
|
444
|
+
|
|
445
|
+
两个 runtime 文件随包发布,位于 `@nebula-spatial/viewer/openusd/`(`exports` 已暴露
|
|
446
|
+
`./openusd/*`)。它们必须保持同名同目录地被站点提供,再按需覆盖 `assets.openUsdBaseUrl`:
|
|
447
|
+
|
|
448
|
+
```ts
|
|
449
|
+
// 1. 拷到站点静态目录(public/openusd/):默认的 `/openusd/` 直接生效。
|
|
450
|
+
// 2. 用打包器的静态拷贝插件从 node_modules 搬运同一目录。
|
|
451
|
+
// 3. 上传到自有 CDN,再把 `assets.openUsdBaseUrl` 指向该目录 URL。
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
本仓库自身由 `web/public/openusd/` 提供静态文件,那是构建期副本、不入版本控制;真源是
|
|
455
|
+
`packages/viewer/openusd/`,用 `npm run sync:openusd` 刷新。`npm run dev`、
|
|
456
|
+
`npm run dev:playground`、`npm run build`、`npm run build:url-viewer` 与
|
|
457
|
+
`npm run build:local-viewer` 已自动前置该同步。
|
|
420
458
|
|
|
421
459
|
|
|
422
460
|
## CAD 快速开始
|
|
@@ -489,7 +527,10 @@ Troika 全局、模块级、一次性配置语义。字体资源和 `resolveText
|
|
|
489
527
|
需要自行托管 Worker 或满足特定 CSP 时,可通过 `CadOpenOptions.workerUrl` 或
|
|
490
528
|
`workerFactory` 覆盖 Worker 创建方式。
|
|
491
529
|
|
|
492
|
-
`
|
|
530
|
+
通用 `AssetSingleSource` 支持 URL、`ArrayBuffer`、`Blob`、`File` 及对应的 `{ kind: ... }` 形式。
|
|
531
|
+
`AssetSource` 还支持 `{ kind: 'files', files, entry }` 文件包;包内文件优先使用,传入的
|
|
532
|
+
`resourceResolver` 只用于包外依赖。CAD 的 `CadLoadSource` 在此基础上保留专用的
|
|
533
|
+
`{ kind: 'packFile' }` 兼容形态。`openAsset()`
|
|
493
534
|
会替换当前活动资产;调用 `viewer.closeAsset()` 关闭活动资产。旧的 `viewer.cad.open()` /
|
|
494
535
|
`viewer.cad.close()` 会保留兼容行为,但已标记为 deprecated;新代码不应再使用它们管理生命周期。
|
|
495
536
|
|
|
@@ -587,7 +628,7 @@ open/close 生命周期被提升到 Viewer。`viewer.cad.open()` / `viewer.cad.c
|
|
|
587
628
|
- URDF/MJCF 需要 MuJoCo runtime,USD 需要 OpenUSD runtime;可用 `assets.mujocoBaseUrl` 与
|
|
588
629
|
`assets.openUsdBaseUrl` 指向自托管目录。
|
|
589
630
|
- 远端目录型资产传入口文件 URL,并保持相对依赖目录;`{ kind:'files' }` 只用于本地 `File | Blob`
|
|
590
|
-
文件包。跨域部署还要配置 CORS、MIME 与鉴权;USD 页面必须满足 HTTPS
|
|
631
|
+
文件包。跨域部署还要配置 CORS、MIME 与鉴权;USD 页面必须满足 HTTPS,但不再需要 COOP/COEP。
|
|
591
632
|
- `format:'auto'` 只识别明确扩展名/loader match。通用 `.xml`、无扩展名和目录 URL 应显式传 format,
|
|
592
633
|
不再通过 `unknownFormatPolicy:'cad'` 猜测。
|
|
593
634
|
|
|
@@ -629,14 +670,15 @@ CAD 类型改为 `ViewerCadUiOptions`、`ViewerCadUiParts`、`ViewerCadUiKeyboar
|
|
|
629
670
|
- [ ] CAD 业务状态仍从 `viewer.cad` 读取,没有把 CAD 专属能力混入通用 asset API。
|
|
630
671
|
- [ ] 旧 `ui.parts`、`ui.preview`、顶层 CAD persistence/keyboard 配置已完成分组迁移。
|
|
631
672
|
- [ ] Embed 中重复 UI、GLTF 加载、clearColor 分支、抓取监听和 resize/inset 状态机已移除。
|
|
632
|
-
- [ ] Draco、MuJoCo
|
|
633
|
-
|
|
673
|
+
- [ ] Draco、MuJoCo runtime URL 由宿主明确配置;OpenUSD 探针随包发布(默认 `/openusd/`,可用
|
|
674
|
+
`assets.openUsdBaseUrl` 覆盖),并已在真实部署路径验证。
|
|
675
|
+
- [ ] 远端资产的 CORS、MIME、鉴权、相对资源路径已端到端验证(USD 单线程构建不再需要跨源隔离)。
|
|
634
676
|
|
|
635
677
|
## URDF Viewer 审查工作台(0.4.4)
|
|
636
678
|
|
|
637
679
|
URDF 默认打开为静止的**运动学预览**:关节控制由确定性 FK 驱动,不会自动加载或启动 MuJoCo。只有用户调用 `preview.play()`、`ctx.commands.play()` 或点击内置“动力学仿真”播放按钮后,Viewer 才按需初始化现有物理运行时。
|
|
638
680
|
|
|
639
|
-
内置工作台包括可折叠结构树、搜索/过滤、关节滑块与范围扫描、Collision
|
|
681
|
+
内置工作台包括可折叠结构树、搜索/过滤、关节滑块与范围扫描、Collision/关节轴与正方向/质心/惯量覆盖层、结构图弹窗、属性面板、XML 只读定位,以及只报告确定错误的严格检查。可通过 `ui.urdf: false` 关闭内置界面,或通过 `ui.preset: 'none'` 完全 Headless 使用。
|
|
640
682
|
|
|
641
683
|
### 交互与仿真状态
|
|
642
684
|
|
|
@@ -645,6 +687,7 @@ URDF 默认打开为静止的**运动学预览**:关节控制由确定性 FK
|
|
|
645
687
|
- 仿真运行时关节控制与部件选择只读,但保留物理拖拽;关节轴、质心、惯量可以开关并跟随实时姿态。
|
|
646
688
|
- 暂停后恢复点选与关节调整,再次播放使用当前姿态;重置恢复初始运动学状态。选中关节时,其 child link 的质心和惯量使用区别色。
|
|
647
689
|
- 场景工具栏提供播放/暂停、重置、地面显隐、适应视图及主题切换;侧栏支持调宽和折叠,结构树选择保留滚动位置。
|
|
690
|
+
- 结构图弹窗以只读 SVG 渲染 Link/Joint 拓扑,支持缩放、重置视图、最大化、拖动窗口和四角拖拽改尺寸;节点选中与结构树、场景选择双向同步。
|
|
648
691
|
|
|
649
692
|
### 默认地面的防穿透与重置
|
|
650
693
|
|
|
@@ -721,6 +764,10 @@ Viewer 自行拥有 SceneRuntime、Renderer、Camera、Controls、事件监听
|
|
|
721
764
|
`dispose()` 会统一释放这些资源。运行时依赖为 `three` peer dependency,要求 Node.js 18
|
|
722
765
|
或更高版本。
|
|
723
766
|
|
|
767
|
+
包入口导出 `viewerVersion`,与 `package.json` 的版本保持一致,并在模块首次加载时打印一次
|
|
768
|
+
版本 banner;`npm run check:boundary --workspace @nebula-spatial/viewer` 会在构建前校验两者
|
|
769
|
+
是否漂移。
|
|
770
|
+
|
|
724
771
|
## 开发
|
|
725
772
|
|
|
726
773
|
```bash
|
|
@@ -765,39 +812,39 @@ ready 等待纹理解码及转换完成;中断和关闭清理源纹理、转
|
|
|
765
812
|
|
|
766
813
|
材质参数对齐不等于截图逐像素对齐:还需相同 HDR、环境旋转、曝光、视角与色彩管理。
|
|
767
814
|
Viewer 不会为了匹配单个 Blender 截图而覆盖全局曝光或灯光。
|
|
768
|
-
|
|
769
|
-
## Xacro preview
|
|
770
|
-
|
|
771
|
-
`.xacro` and `.urdf.xacro` use `xacro-parser@0.3.11` as an optional, lazily loaded
|
|
772
|
-
preprocessing stage before the existing URDF kinematic review. They do not autoplay.
|
|
773
|
-
Upload the entire description directory, not only its entry XML, or provide a
|
|
774
|
-
`baseUrl` / `resourceResolver` for includes and meshes.
|
|
775
|
-
|
|
776
|
-
```ts
|
|
777
|
-
const preview = viewer.openAsset({ kind: 'files', entry: 'robot/urdf/main.urdf.xacro', files }, {
|
|
778
|
-
xacro: {
|
|
779
|
-
arguments: { prefix: 'arm_', size: 0.2 },
|
|
780
|
-
packages: { robot_description: 'robot' },
|
|
781
|
-
},
|
|
782
|
-
});
|
|
783
|
-
await preview.ready;
|
|
784
|
-
```
|
|
785
|
-
|
|
786
|
-
`xacro.packages` maps ROS package names to directories relative to the uploaded
|
|
787
|
-
file package or `baseUrl`. Local `package.xml` files supply mappings automatically;
|
|
788
|
-
explicit mappings override discovery. Ambiguous package names fail. External ROS
|
|
789
|
-
commands and environment access are not executed. Mesh/texture `package://` paths
|
|
790
|
-
use the same mapping. Resource requests retain the existing resolver and abort signal.
|
|
791
|
-
|
|
792
|
-
Supported subset: macros, properties, arguments/defaults, numeric expressions,
|
|
793
|
-
if/unless, block parameters and nested includes. Python expressions are **not**
|
|
794
|
-
fully compatible: `xacro.load_yaml`, include namespaces, dynamic `xacro:call`, and
|
|
795
|
-
`param:=^|default` are unsupported. Expansion errors are fatal `E_XACRO_EXPAND`
|
|
796
|
-
errors; there is no fallback that renders incomplete raw Xacro as URDF. Inputs are
|
|
797
|
-
limited to 4 MiB each and 128 include reads, but this is not a sandbox or a complete
|
|
798
|
-
CPU/memory limit for untrusted macro expansion.
|
|
799
|
-
|
|
800
|
-
Review source ranges are labeled `(expanded URDF)`; they do not map back to the
|
|
801
|
-
original macro definition. The current Universal Robots ROS2 description uses
|
|
802
|
-
Python/YAML expressions and is not covered by this browser subset. For full ROS
|
|
815
|
+
|
|
816
|
+
## Xacro preview
|
|
817
|
+
|
|
818
|
+
`.xacro` and `.urdf.xacro` use `xacro-parser@0.3.11` as an optional, lazily loaded
|
|
819
|
+
preprocessing stage before the existing URDF kinematic review. They do not autoplay.
|
|
820
|
+
Upload the entire description directory, not only its entry XML, or provide a
|
|
821
|
+
`baseUrl` / `resourceResolver` for includes and meshes.
|
|
822
|
+
|
|
823
|
+
```ts
|
|
824
|
+
const preview = viewer.openAsset({ kind: 'files', entry: 'robot/urdf/main.urdf.xacro', files }, {
|
|
825
|
+
xacro: {
|
|
826
|
+
arguments: { prefix: 'arm_', size: 0.2 },
|
|
827
|
+
packages: { robot_description: 'robot' },
|
|
828
|
+
},
|
|
829
|
+
});
|
|
830
|
+
await preview.ready;
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
`xacro.packages` maps ROS package names to directories relative to the uploaded
|
|
834
|
+
file package or `baseUrl`. Local `package.xml` files supply mappings automatically;
|
|
835
|
+
explicit mappings override discovery. Ambiguous package names fail. External ROS
|
|
836
|
+
commands and environment access are not executed. Mesh/texture `package://` paths
|
|
837
|
+
use the same mapping. Resource requests retain the existing resolver and abort signal.
|
|
838
|
+
|
|
839
|
+
Supported subset: macros, properties, arguments/defaults, numeric expressions,
|
|
840
|
+
if/unless, block parameters and nested includes. Python expressions are **not**
|
|
841
|
+
fully compatible: `xacro.load_yaml`, include namespaces, dynamic `xacro:call`, and
|
|
842
|
+
`param:=^|default` are unsupported. Expansion errors are fatal `E_XACRO_EXPAND`
|
|
843
|
+
errors; there is no fallback that renders incomplete raw Xacro as URDF. Inputs are
|
|
844
|
+
limited to 4 MiB each and 128 include reads, but this is not a sandbox or a complete
|
|
845
|
+
CPU/memory limit for untrusted macro expansion.
|
|
846
|
+
|
|
847
|
+
Review source ranges are labeled `(expanded URDF)`; they do not map back to the
|
|
848
|
+
original macro definition. The current Universal Robots ROS2 description uses
|
|
849
|
+
Python/YAML expressions and is not covered by this browser subset. For full ROS
|
|
803
850
|
compatibility, expand with the official Xacro tool first and open the resulting URDF.
|
package/dist/assets/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AssetInspection } from '../inspection/types';
|
|
2
2
|
import type { Object3D, WebGLRenderer, Scene, Camera, Box3, ColorRepresentation } from 'three';
|
|
3
3
|
import type { CadLoadSource, CadOpenOptions } from '../cad/types';
|
|
4
|
+
import type { AssetSingleSource } from './source-types';
|
|
4
5
|
import type { ViewerViewMode } from '../types';
|
|
5
6
|
export type AssetPreviewKind = 'cad' | 'model' | 'simulation';
|
|
6
7
|
export type BuiltinAssetFormat = 'cad' | 'glb' | 'gltf' | 'fbx' | 'urdf' | 'xacro' | 'mjcf' | 'usd' | 'usda' | 'usdc' | 'usdz';
|
|
@@ -9,10 +10,15 @@ export interface AssetFileEntry {
|
|
|
9
10
|
readonly path: string;
|
|
10
11
|
readonly file: File | Blob;
|
|
11
12
|
}
|
|
12
|
-
export type
|
|
13
|
+
export type { AssetSingleSource } from './source-types';
|
|
14
|
+
/** A single source or a browser-held multi-file package. */
|
|
15
|
+
export type AssetSource = AssetSingleSource | Extract<CadLoadSource, {
|
|
16
|
+
readonly kind: 'packFile';
|
|
17
|
+
}> | {
|
|
13
18
|
readonly kind: 'files';
|
|
14
19
|
readonly files: readonly AssetFileEntry[];
|
|
15
20
|
readonly entry?: string;
|
|
21
|
+
/** Aborts this package operation; combined with OpenAssetOptions.signal. */
|
|
16
22
|
readonly signal?: AbortSignal;
|
|
17
23
|
};
|
|
18
24
|
export interface AssetResourceResolver {
|
|
@@ -33,10 +39,13 @@ export interface OpenAssetOptions {
|
|
|
33
39
|
readonly packages?: Readonly<Record<string, string>>;
|
|
34
40
|
};
|
|
35
41
|
readonly simulationTheme?: 'dark' | 'light';
|
|
42
|
+
/** Defaults to automatic detection: extension first, then registered loader matchers. */
|
|
36
43
|
readonly format?: AssetFormat | 'auto';
|
|
37
44
|
readonly filename?: string;
|
|
38
45
|
readonly signal?: AbortSignal;
|
|
46
|
+
/** Base URL for package-external relative resources. */
|
|
39
47
|
readonly baseUrl?: string;
|
|
48
|
+
/** Resolves package-external resources; local package entries take precedence. */
|
|
40
49
|
readonly resourceResolver?: AssetResourceResolver;
|
|
41
50
|
/** @deprecated Auto detection never falls back to CAD; pass an explicit format instead. */
|
|
42
51
|
readonly unknownFormatPolicy?: 'cad' | 'error';
|
|
@@ -44,12 +53,17 @@ export interface OpenAssetOptions {
|
|
|
44
53
|
readonly mujocoBaseUrl?: string;
|
|
45
54
|
readonly openUsdBaseUrl?: string;
|
|
46
55
|
/**
|
|
47
|
-
* Which authored axis is "up"
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
56
|
+
* Which authored axis is "up". FBX first uses a supported positive Y/Z
|
|
57
|
+
* declaration from GlobalSettings, then falls back to 'y' when it is missing
|
|
58
|
+
* or cannot be read. GLB/glTF default to 'y' per the glTF coordinate
|
|
59
|
+
* convention. An explicit value always wins. 'y' rotates the model root into
|
|
60
|
+
* world +Z.
|
|
61
|
+
*
|
|
62
|
+
* Also seeds the initial up axis of simulation assets. URDF/XACRO/MJCF are
|
|
63
|
+
* Z-up by specification; USD defaults to 'z' because the loader has already
|
|
64
|
+
* applied the stage's declared axis. For simulation the rotation is applied
|
|
65
|
+
* to the compiled model itself, so collisions, contacts and gravity stay
|
|
66
|
+
* consistent with what is rendered.
|
|
53
67
|
*/
|
|
54
68
|
readonly upAxis?: AssetUpAxis;
|
|
55
69
|
/** CAD-specific compatibility options. `filename` and `signal` above take precedence. */
|
|
@@ -63,9 +77,12 @@ export interface AssetPreviewCapabilities {
|
|
|
63
77
|
readonly canReset: boolean;
|
|
64
78
|
readonly hasPhysics: boolean;
|
|
65
79
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
80
|
+
* The asset's authored up axis can be re-oriented at runtime. Declared by
|
|
81
|
+
* model and simulation sessions. For simulation assets the compiled physics
|
|
82
|
+
* is rotated with it (gravity and the viewer ground stay put), so a toggled
|
|
83
|
+
* asset keeps rendering and simulating the same pose. Optional (absent means
|
|
84
|
+
* false) so pre-existing third-party asset sessions that build this literal
|
|
85
|
+
* keep compiling.
|
|
69
86
|
*/
|
|
70
87
|
readonly canReorientUpAxis?: boolean;
|
|
71
88
|
/**
|
|
@@ -79,6 +96,13 @@ export interface AssetPreviewCapabilities {
|
|
|
79
96
|
* bodies, so this must not be inferred from `hasPhysics`.
|
|
80
97
|
*/
|
|
81
98
|
readonly canToggleCollision?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* The session drives authored clips (skeletal/xform animation) without a
|
|
101
|
+
* physics runtime. Playing them is not "running a simulation", so hosts can
|
|
102
|
+
* relabel the playback controls. Optional, same rationale as
|
|
103
|
+
* `canReorientUpAxis`; only sessions that actually reference clips set it.
|
|
104
|
+
*/
|
|
105
|
+
readonly hasAnimation?: boolean;
|
|
82
106
|
}
|
|
83
107
|
export type AssetPreviewPhase = 'detecting' | 'loading' | 'ready' | 'failed' | 'closing' | 'closed';
|
|
84
108
|
export interface AssetErrorSnapshot {
|
|
@@ -137,7 +161,12 @@ export interface AssetPreview {
|
|
|
137
161
|
/** USD visual report and diagnostics, including static assets. */
|
|
138
162
|
getVisualDiagnostics?(): Readonly<Record<string, unknown>> | null;
|
|
139
163
|
setCollisionVisible(visible: boolean): void;
|
|
140
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* Re-orients the asset's authored up axis without moving the camera. Model
|
|
166
|
+
* previews re-seat the ground and refit the camera; simulation assets rotate
|
|
167
|
+
* the physics itself, re-seat the ground under the new pose and leave the
|
|
168
|
+
* camera alone.
|
|
169
|
+
*/
|
|
141
170
|
setUpAxis(axis: AssetUpAxis): void;
|
|
142
171
|
getUpAxis(): AssetUpAxis | null;
|
|
143
172
|
/** Shows or hides the staged ground (grid + reflection). */
|
package/dist/cad/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RenderDebugBreakdownEntry, SplitBlockLayerDetail } from '@nebula-spatial/cad-loader';
|
|
2
2
|
import type { CadSessionLoadTiming } from '@nebula-spatial/cad-loader';
|
|
3
3
|
import type { ViewerViewMode } from '../types';
|
|
4
|
+
import type { AssetSingleSource } from '../assets/source-types';
|
|
4
5
|
export type { ViewerUiOptions, ViewerSceneUiOptions, ViewerSceneUiParts, ViewerUiPreset, ViewerUiTheme, ViewerUiTokens } from '../ui/types';
|
|
5
6
|
export type { CadSessionLoadTiming } from '@nebula-spatial/cad-loader';
|
|
6
7
|
export type { RenderDebugBreakdownEntry, SplitBlockLayerDetail } from '@nebula-spatial/cad-loader';
|
|
@@ -14,14 +15,9 @@ export interface CadWorldBounds {
|
|
|
14
15
|
readonly maxZ: number;
|
|
15
16
|
readonly planar: boolean;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} | {
|
|
21
|
-
readonly kind: 'url';
|
|
22
|
-
readonly url: string;
|
|
23
|
-
readonly signal?: AbortSignal;
|
|
24
|
-
} | {
|
|
18
|
+
/** CAD accepts the common single-source forms plus its legacy packFile form. */
|
|
19
|
+
export type CadLoadSource = AssetSingleSource | {
|
|
20
|
+
/** CAD-specific package source; do not use AssetSource's { kind: 'files' }. */
|
|
25
21
|
readonly kind: 'packFile';
|
|
26
22
|
readonly file: Pick<File, 'arrayBuffer'>;
|
|
27
23
|
};
|