@nebula-spatial/studio 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/README.md +206 -3
  2. package/dist/ai/contract.d.ts +73 -0
  3. package/dist/ai/host.d.ts +28 -0
  4. package/dist/asset/dependency-scan.d.ts +78 -0
  5. package/dist/asset/intake.d.ts +84 -0
  6. package/dist/asset/layout-detect.d.ts +40 -0
  7. package/dist/asset/media-type.d.ts +10 -0
  8. package/dist/asset/model-inspection.d.ts +127 -0
  9. package/dist/asset/record.d.ts +35 -0
  10. package/dist/asset/remote-asset-resolver.d.ts +36 -0
  11. package/dist/asset/repairs.d.ts +53 -0
  12. package/dist/asset/resource-locator.d.ts +15 -0
  13. package/dist/asset/revision-diff.d.ts +33 -0
  14. package/dist/asset/source-contracts.d.ts +21 -0
  15. package/dist/asset/source-paths.d.ts +15 -0
  16. package/dist/asset/usd-inspection.d.ts +39 -0
  17. package/dist/asset/usd-source-metadata.d.ts +142 -0
  18. package/dist/asset/visual-intake.d.ts +27 -0
  19. package/dist/asset/visual-record.d.ts +22 -0
  20. package/dist/asset/web-intake.d.ts +46 -0
  21. package/dist/asset-source-BExlEcRt.js +444 -0
  22. package/dist/assets/openusd_three_loader-DLiqJWUM.js +13769 -0
  23. package/dist/assets/usd-export-worker-BRxTLqer.js +182 -0
  24. package/dist/assets/usd-worker-DekqMsQv.js +1392 -0
  25. package/dist/builders-BAXRR5o5.js +1854 -0
  26. package/dist/core/asset-task.d.ts +105 -0
  27. package/dist/core/context.d.ts +23 -0
  28. package/dist/core/host.d.ts +432 -0
  29. package/dist/core/persistence-controller.d.ts +58 -0
  30. package/dist/core/plugins.d.ts +139 -0
  31. package/dist/core/scene-tree.d.ts +62 -0
  32. package/dist/core/versions.d.ts +2 -0
  33. package/dist/core/when.d.ts +13 -0
  34. package/dist/core/write-policy.d.ts +29 -0
  35. package/dist/delivery/build-plan.d.ts +2 -0
  36. package/dist/delivery/contracts.d.ts +362 -0
  37. package/dist/delivery/digest.d.ts +3 -0
  38. package/dist/delivery/evidence.d.ts +10 -0
  39. package/dist/delivery/export-evidence.d.ts +3 -0
  40. package/dist/delivery/index.d.ts +9 -0
  41. package/dist/delivery/prim-name.d.ts +17 -0
  42. package/dist/delivery/profile.d.ts +4 -0
  43. package/dist/doc/builders.d.ts +99 -0
  44. package/dist/doc/command.d.ts +195 -0
  45. package/dist/doc/domain-extensions.d.ts +34 -0
  46. package/dist/doc/node-facts.d.ts +87 -0
  47. package/dist/doc/physics-facts.d.ts +74 -0
  48. package/dist/doc/placement-policy.d.ts +71 -0
  49. package/dist/doc/random-placement.d.ts +30 -0
  50. package/dist/doc/scene-graph.d.ts +80 -0
  51. package/dist/doc/scene-regions.d.ts +29 -0
  52. package/dist/doc/schema.d.ts +452 -0
  53. package/dist/doc/task.d.ts +71 -0
  54. package/dist/doc/validate.d.ts +68 -0
  55. package/dist/editor/asset-source.d.ts +15 -0
  56. package/dist/editor/editor.d.ts +246 -0
  57. package/dist/editor/index.d.ts +22 -0
  58. package/dist/editor/shortcuts.d.ts +2 -0
  59. package/dist/editor/types.d.ts +143 -0
  60. package/dist/editor/ui-plugins.d.ts +64 -0
  61. package/dist/editor.js +1755 -0
  62. package/dist/editorial-BkAFWfbg.js +83 -0
  63. package/dist/export-evidence-DMNRhgL9.js +2705 -0
  64. package/dist/generalization/domain.d.ts +10 -0
  65. package/dist/generalization/generalization.d.ts +371 -0
  66. package/dist/generalization/index.d.ts +11 -0
  67. package/dist/generalization.js +1659 -0
  68. package/dist/history/undo-stack.d.ts +74 -0
  69. package/dist/index.d.ts +91 -0
  70. package/dist/index.js +2840 -0
  71. package/dist/mjcf-visual-Bt4bUxd1.js +72 -0
  72. package/dist/mujoco-runtime-BYZnrvbR.js +467 -0
  73. package/dist/persist/content-addressed.d.ts +11 -0
  74. package/dist/persist/create-scene-package-from-host.d.ts +7 -0
  75. package/dist/persist/indexeddb-store.d.ts +69 -0
  76. package/dist/persist/scene-file.d.ts +52 -0
  77. package/dist/persist/scene-package.d.ts +8 -0
  78. package/dist/persist/snapshot.d.ts +5 -0
  79. package/dist/physics-facts-tfQYyNTD.js +337 -0
  80. package/dist/placement-policy-DY_FNRDu.js +405 -0
  81. package/dist/ports/asset-ingestor.d.ts +41 -0
  82. package/dist/ports/asset-source.d.ts +57 -0
  83. package/dist/ports/delivery.d.ts +13 -0
  84. package/dist/ports/persistence.d.ts +29 -0
  85. package/dist/project/asset-catalog.d.ts +21 -0
  86. package/dist/project/contracts.d.ts +272 -0
  87. package/dist/project/editorial.d.ts +16 -0
  88. package/dist/project/identity.d.ts +20 -0
  89. package/dist/project/index.d.ts +9 -0
  90. package/dist/project/scene-document.d.ts +5 -0
  91. package/dist/project/source-dependencies.d.ts +7 -0
  92. package/dist/remote-asset-resolver-Cb8cfNmw.js +136 -0
  93. package/dist/scene/index.d.ts +12 -0
  94. package/dist/scene-graph-DBLKAhxa.js +681 -0
  95. package/dist/scene-session-Cy6vDJ1l.js +21981 -0
  96. package/dist/scene.js +244 -0
  97. package/dist/session-BRBrCLdd.js +963 -0
  98. package/dist/session-DI5tPJxn.js +825 -0
  99. package/dist/session-q3uuG7OP.js +296 -0
  100. package/dist/studio/delivery-catalog.d.ts +28 -0
  101. package/dist/studio/in-memory-asset-source.d.ts +15 -0
  102. package/dist/studio/index.d.ts +31 -0
  103. package/dist/studio/indexeddb-asset-source.d.ts +32 -0
  104. package/dist/studio/indexeddb-persistence.d.ts +13 -0
  105. package/dist/studio/remote-asset-importer.d.ts +56 -0
  106. package/dist/studio/source-package.d.ts +9 -0
  107. package/dist/studio/usd-export-client.d.ts +13 -0
  108. package/dist/studio/usd-export-protocol.d.ts +98 -0
  109. package/dist/studio/usd-export-worker.d.ts +1 -0
  110. package/dist/studio/usd-zip-reader.d.ts +14 -0
  111. package/dist/studio/web-asset-ingestor.d.ts +10 -0
  112. package/dist/studio/web-host.d.ts +8 -0
  113. package/dist/studio.js +5545 -0
  114. package/dist/urdf-session-CQir2nb2.js +1230 -0
  115. package/dist/usd-session-DZJnEEOs.js +7385 -0
  116. package/dist/util/asset-facts.d.ts +3 -0
  117. package/dist/util/data.d.ts +17 -0
  118. package/dist/util/diagnostics.d.ts +38 -0
  119. package/dist/util/geometry.d.ts +11 -0
  120. package/dist/util/hash.d.ts +9 -0
  121. package/dist/util/ids.d.ts +20 -0
  122. package/dist/util/math.d.ts +47 -0
  123. package/dist/util/ply-metadata.d.ts +19 -0
  124. package/dist/util/studio-source.d.ts +23 -0
  125. package/dist/version.d.ts +5 -0
  126. package/dist/view/appearance.d.ts +13 -0
  127. package/dist/view/authoring-appearance.d.ts +25 -0
  128. package/dist/view/bounds-preview.d.ts +34 -0
  129. package/dist/view/bounds.d.ts +11 -0
  130. package/dist/view/camera-zoom.d.ts +3 -0
  131. package/dist/view/geometry-anchors.d.ts +20 -0
  132. package/dist/view/gizmo-appearance.d.ts +5 -0
  133. package/dist/view/gizmo.d.ts +81 -0
  134. package/dist/view/group-selection.d.ts +13 -0
  135. package/dist/view/node-features.d.ts +39 -0
  136. package/dist/view/picking.d.ts +49 -0
  137. package/dist/view/placement.d.ts +48 -0
  138. package/dist/view/region-editing.d.ts +25 -0
  139. package/dist/view/rotation-guide.d.ts +36 -0
  140. package/dist/view/runtime-capabilities.d.ts +22 -0
  141. package/dist/view/scene-session.d.ts +258 -0
  142. package/dist/view/screen-bounds.d.ts +17 -0
  143. package/dist/view/selection-transform.d.ts +20 -0
  144. package/dist/wasm-module-DZn2AM1W.js +13 -0
  145. package/dist/xacro-DLRXyk60.js +76 -0
  146. package/node_modules/@nebula-spatial/cad-loader/CHANGELOG.md +48 -0
  147. package/node_modules/@nebula-spatial/cad-loader/README.md +108 -0
  148. package/node_modules/@nebula-spatial/cad-loader/dist/core/cad-types.d.ts +26 -0
  149. package/node_modules/@nebula-spatial/cad-loader/dist/core/errors.d.ts +5 -0
  150. package/node_modules/@nebula-spatial/cad-loader/dist/core/index.d.ts +24 -0
  151. package/node_modules/@nebula-spatial/cad-loader/dist/core/index.js +2354 -0
  152. package/node_modules/@nebula-spatial/cad-loader/dist/core/parser/bin-group-reader.d.ts +9 -0
  153. package/node_modules/@nebula-spatial/cad-loader/dist/core/parser/bin-parser.d.ts +78 -0
  154. package/node_modules/@nebula-spatial/cad-loader/dist/core/parser/dxbs-sidecar.d.ts +24 -0
  155. package/node_modules/@nebula-spatial/cad-loader/dist/core/parser/geometry-segments.d.ts +20 -0
  156. package/node_modules/@nebula-spatial/cad-loader/dist/core/parser/text-roundtrip.d.ts +4 -0
  157. package/node_modules/@nebula-spatial/cad-loader/dist/core/parser/types.d.ts +81 -0
  158. package/node_modules/@nebula-spatial/cad-loader/dist/core/runtime-text-decoder.d.ts +8 -0
  159. package/node_modules/@nebula-spatial/cad-loader/dist/core/types.d.ts +153 -0
  160. package/node_modules/@nebula-spatial/cad-loader/dist/core/utils/insert-bbox.d.ts +10 -0
  161. package/node_modules/@nebula-spatial/cad-loader/dist/core/utils/viewport-rect.d.ts +21 -0
  162. package/node_modules/@nebula-spatial/cad-loader/dist/index.d.ts +36 -0
  163. package/node_modules/@nebula-spatial/cad-loader/dist/index.js +5829 -0
  164. package/node_modules/@nebula-spatial/cad-loader/dist/loader/geo-loader.d.ts +59 -0
  165. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/automatic-external-resources.d.ts +26 -0
  166. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/external-variant-sidecar-fetch.d.ts +13 -0
  167. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/flow-control.d.ts +29 -0
  168. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/frame-budget-scheduler.d.ts +21 -0
  169. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-compact-executor.d.ts +19 -0
  170. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-loader-local-adapter.d.ts +2 -0
  171. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-loader-pipeline.d.ts +92 -0
  172. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-loader-worker-adapter.d.ts +13 -0
  173. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-node-builder.d.ts +34 -0
  174. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-node-load-sink.d.ts +28 -0
  175. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-node.d.ts +304 -0
  176. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-prepare-worker-types.d.ts +94 -0
  177. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-prepare.d.ts +38 -0
  178. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/geo-prepare.worker.d.ts +1 -0
  179. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/insert-model-builder.d.ts +10 -0
  180. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/insert-runtime-geometry.d.ts +15 -0
  181. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/line-canonical.d.ts +37 -0
  182. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/line-quality.d.ts +9 -0
  183. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/prepare-credit-gate.d.ts +20 -0
  184. package/node_modules/@nebula-spatial/cad-loader/dist/loader/internal/transport.d.ts +2 -0
  185. package/node_modules/@nebula-spatial/cad-loader/dist/render-resource/cad-render-node.d.ts +80 -0
  186. package/node_modules/@nebula-spatial/cad-loader/dist/render-resource/geo-node-cad-render-node.d.ts +12 -0
  187. package/node_modules/@nebula-spatial/cad-loader/dist/scene/geo-cad-line-geometry.d.ts +28 -0
  188. package/node_modules/@nebula-spatial/cad-loader/dist/scene/geo-cad-line-material.d.ts +18 -0
  189. package/node_modules/@nebula-spatial/cad-loader/dist/scene/instancing/block-geometry-registry.d.ts +35 -0
  190. package/node_modules/@nebula-spatial/cad-loader/dist/scene/instancing/insert-instance-table.d.ts +23 -0
  191. package/node_modules/@nebula-spatial/cad-loader/dist/scene/instancing/viewport-instance-presenter.d.ts +66 -0
  192. package/node_modules/@nebula-spatial/cad-loader/dist/selection/cad-insert-selection.d.ts +35 -0
  193. package/node_modules/@nebula-spatial/cad-loader/dist/selection/cad-text-selection.d.ts +31 -0
  194. package/node_modules/@nebula-spatial/cad-loader/dist/session/annotation-idle-gate.d.ts +14 -0
  195. package/node_modules/@nebula-spatial/cad-loader/dist/session/cad-document-session.d.ts +187 -0
  196. package/node_modules/@nebula-spatial/cad-loader/dist/session/cad-font-runtime.d.ts +11 -0
  197. package/node_modules/@nebula-spatial/cad-loader/dist/session/cad-insert-id.d.ts +6 -0
  198. package/node_modules/@nebula-spatial/cad-loader/dist/session/cad-text-warmup.d.ts +38 -0
  199. package/node_modules/@nebula-spatial/cad-loader/dist/session/create-cad-document-session.d.ts +5 -0
  200. package/node_modules/@nebula-spatial/cad-loader/dist/session/load-session.d.ts +90 -0
  201. package/node_modules/@nebula-spatial/cad-loader/dist/session/viewport-coverage.d.ts +32 -0
  202. package/node_modules/@nebula-spatial/cad-loader/dist/shared/abort.d.ts +3 -0
  203. package/node_modules/@nebula-spatial/cad-loader/dist/shared/cad-display-color.d.ts +55 -0
  204. package/node_modules/@nebula-spatial/cad-loader/dist/shared/cad-load-source.d.ts +8 -0
  205. package/node_modules/@nebula-spatial/cad-loader/dist/shared/color-buffer.d.ts +6 -0
  206. package/node_modules/@nebula-spatial/cad-loader/dist/shared/constants.d.ts +11 -0
  207. package/node_modules/@nebula-spatial/cad-loader/dist/shared/display-color-buffer.d.ts +27 -0
  208. package/node_modules/@nebula-spatial/cad-loader/dist/shared/errors.d.ts +2 -0
  209. package/node_modules/@nebula-spatial/cad-loader/dist/shared/text-builder.d.ts +25 -0
  210. package/node_modules/@nebula-spatial/cad-loader/dist/shared/text-font.d.ts +12 -0
  211. package/node_modules/@nebula-spatial/cad-loader/dist/shared/types.d.ts +57 -0
  212. package/node_modules/@nebula-spatial/cad-loader/dist/shared/utils/insert-bbox.d.ts +1 -0
  213. package/node_modules/@nebula-spatial/cad-loader/dist/shared/utils/timing.d.ts +2 -0
  214. package/node_modules/@nebula-spatial/cad-loader/dist/shared/utils/viewport-rect.d.ts +1 -0
  215. package/node_modules/@nebula-spatial/cad-loader/dist/shared/viewer-theme.d.ts +2 -0
  216. package/node_modules/@nebula-spatial/cad-loader/dist/workers/geo-prepare.worker.js +2264 -0
  217. package/node_modules/@nebula-spatial/cad-loader/package.json +62 -0
  218. package/node_modules/@nebula-spatial/viewer/CHANGELOG.md +426 -0
  219. package/node_modules/@nebula-spatial/viewer/FBX-MATERIAL-CONVERSION.md +97 -0
  220. package/node_modules/@nebula-spatial/viewer/README.md +1056 -0
  221. package/node_modules/@nebula-spatial/viewer/USD-VISUAL-MATERIAL-SUPPORT.md +89 -0
  222. package/node_modules/@nebula-spatial/viewer/basis/basis_transcoder.js +19 -0
  223. package/node_modules/@nebula-spatial/viewer/basis/basis_transcoder.wasm +0 -0
  224. package/node_modules/@nebula-spatial/viewer/dist/asset-ir-DEOK9SqE.js +382 -0
  225. package/node_modules/@nebula-spatial/viewer/dist/assets/ground-grid.d.ts +6 -0
  226. package/node_modules/@nebula-spatial/viewer/dist/assets/source-types.d.ts +19 -0
  227. package/node_modules/@nebula-spatial/viewer/dist/assets/types.d.ts +393 -0
  228. package/node_modules/@nebula-spatial/viewer/dist/assets/usd-worker-Bom5cjz3.js +1392 -0
  229. package/node_modules/@nebula-spatial/viewer/dist/cad/text.d.ts +2 -0
  230. package/node_modules/@nebula-spatial/viewer/dist/cad/types.d.ts +368 -0
  231. package/node_modules/@nebula-spatial/viewer/dist/index-ByBlfVc0.js +12132 -0
  232. package/node_modules/@nebula-spatial/viewer/dist/index.d.ts +32 -0
  233. package/node_modules/@nebula-spatial/viewer/dist/index.js +26 -0
  234. package/node_modules/@nebula-spatial/viewer/dist/inspection/types.d.ts +112 -0
  235. package/node_modules/@nebula-spatial/viewer/dist/mjcf-visual-DVRa0w90.js +72 -0
  236. package/node_modules/@nebula-spatial/viewer/dist/mujoco-runtime-Dhx6Ua2u.js +463 -0
  237. package/node_modules/@nebula-spatial/viewer/dist/plugins.d.ts +179 -0
  238. package/node_modules/@nebula-spatial/viewer/dist/scene/instances.d.ts +36 -0
  239. package/node_modules/@nebula-spatial/viewer/dist/scene/types.d.ts +258 -0
  240. package/node_modules/@nebula-spatial/viewer/dist/session-B-j6KdA-.js +389 -0
  241. package/node_modules/@nebula-spatial/viewer/dist/session-B4AICTeJ.js +963 -0
  242. package/node_modules/@nebula-spatial/viewer/dist/session-BAG5cDYe.js +9153 -0
  243. package/node_modules/@nebula-spatial/viewer/dist/simulation/mujoco-runtime.d.ts +118 -0
  244. package/node_modules/@nebula-spatial/viewer/dist/simulation/mujoco-wasm-module.d.ts +11 -0
  245. package/node_modules/@nebula-spatial/viewer/dist/simulation/openusd-wasm-module.d.ts +10 -0
  246. package/node_modules/@nebula-spatial/viewer/dist/simulation/physics-runtime-state.d.ts +75 -0
  247. package/node_modules/@nebula-spatial/viewer/dist/simulation/types.d.ts +129 -0
  248. package/node_modules/@nebula-spatial/viewer/dist/simulation/usd-inspection.d.ts +66 -0
  249. package/node_modules/@nebula-spatial/viewer/dist/simulation/usd-query.d.ts +50 -0
  250. package/node_modules/@nebula-spatial/viewer/dist/simulation/usd-resource-policy.d.ts +28 -0
  251. package/node_modules/@nebula-spatial/viewer/dist/types.d.ts +278 -0
  252. package/node_modules/@nebula-spatial/viewer/dist/ui/types.d.ts +48 -0
  253. package/node_modules/@nebula-spatial/viewer/dist/urdf-session-kemAnBn8.js +3231 -0
  254. package/node_modules/@nebula-spatial/viewer/dist/usd-session-QtwGKI7v.js +6771 -0
  255. package/node_modules/@nebula-spatial/viewer/dist/version.d.ts +5 -0
  256. package/node_modules/@nebula-spatial/viewer/dist/viewer.d.ts +2 -0
  257. package/node_modules/@nebula-spatial/viewer/dist/xacro-CYTPS7mh.js +1537 -0
  258. package/node_modules/@nebula-spatial/viewer/openusd/openusd-runtime-manifest.json +15 -0
  259. package/node_modules/@nebula-spatial/viewer/openusd/openusd_probe.js +14 -0
  260. package/node_modules/@nebula-spatial/viewer/openusd/openusd_probe.wasm +0 -0
  261. package/node_modules/@nebula-spatial/viewer/package.json +66 -0
  262. package/package.json +87 -6
@@ -0,0 +1,825 @@
1
+ var Me = Object.defineProperty;
2
+ var Le = (t, e, s) => e in t ? Me(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var k = (t, e, s) => Le(t, typeof e != "symbol" ? e + "" : e, s);
4
+ import { D as ke, S as re, b as Fe, e as be, f as _e } from "./scene-session-Cy6vDJ1l.js";
5
+ const ie = "E_ASSET_RESOURCE_NOT_FOUND", Ue = "E_ASSET_RESOURCE_INVALID", Ie = "E_ASSET_FETCH", $e = "E_ASSET_EXTERNAL_DENIED", Re = "E_ASSET_AUTH", Ge = /* @__PURE__ */ new Set([
6
+ "png",
7
+ "jpg",
8
+ "jpeg",
9
+ "webp",
10
+ "avif",
11
+ "gif",
12
+ "bmp",
13
+ "tga",
14
+ "dds",
15
+ "hdr",
16
+ "exr",
17
+ "ktx2"
18
+ ]), Ve = /* @__PURE__ */ new Set(["usd", "usda", "usdc", "usdz"]);
19
+ function ze(t) {
20
+ var s;
21
+ return ((s = (t.split(/[?#]/, 1)[0] ?? t).split(".").pop()) == null ? void 0 : s.toLowerCase()) ?? "";
22
+ }
23
+ function yt(t) {
24
+ const e = ze(t);
25
+ return Ge.has(e) && !Ve.has(e);
26
+ }
27
+ function Et(t, e) {
28
+ return Object.assign(new Error(t), { code: e });
29
+ }
30
+ function De(t) {
31
+ var n;
32
+ if (t instanceof Error && t.name === "AbortError") return "aborted";
33
+ const e = t == null ? void 0 : t.code;
34
+ if (e === ie) return "missing";
35
+ if (e === Ue) return "invalid";
36
+ if (e === Ie) return "unavailable";
37
+ if (e === Re || e === $e) return "denied";
38
+ const s = (n = /\((\d{3})\)/.exec(t instanceof Error ? t.message : "")) == null ? void 0 : n[1];
39
+ return s === "404" || s === "410" ? "missing" : s === "401" || s === "403" ? "denied" : s != null && s.startsWith("5") ? "unavailable" : "unknown";
40
+ }
41
+ function St(t) {
42
+ const e = De(t);
43
+ return e === "missing" || e === "invalid" || e === "unavailable";
44
+ }
45
+ function Ce(t, e) {
46
+ return t && /\bhtml\b/i.test(t) ? `返回 HTML 页面(${t})` : t && !/^text\//i.test(t) ? null : /^\uFEFF?\s*(?:<!doctype\s+html|<html|<\?xml[^>]*\bhtml)/i.test(e) ? "返回 HTML 兜底页" : null;
47
+ }
48
+ function bt(t, e) {
49
+ return e.byteLength ? Ce(t, new TextDecoder().decode(e.subarray(0, 512))) : "响应内容为空";
50
+ }
51
+ async function qe(t) {
52
+ return t.size ? Ce(t.type, await t.slice(0, 512).text()) : "响应内容为空";
53
+ }
54
+ const We = /* @__PURE__ */ new Set([
55
+ "E_MJCF_INCLUDE_CYCLE",
56
+ "E_MJCF_PARSE",
57
+ "E_URDF_COMPILE",
58
+ "E_URDF_INERTIA",
59
+ "E_USD_INVALID_COLLISION_GEOMETRY",
60
+ "E_USD_INVALID_COLLISION_GROUP",
61
+ "E_USD_INVALID_EQUALITY_CONNECT",
62
+ "E_USD_INVALID_JOINT_REFERENCE",
63
+ "E_USD_INVALID_MASS",
64
+ "E_USD_INVALID_MIMIC",
65
+ "E_USD_INVALID_UNITS",
66
+ "E_USD_MISSING_COLLISION_GEOMETRY",
67
+ "E_USD_MULTIPLE_PHYSICS_SCENES",
68
+ "E_USD_PARTIAL_INERTIA",
69
+ "E_USD_UNREACHABLE_BODIES"
70
+ ]), Be = /* @__PURE__ */ new Set(["step", "reset", "grab", "up-axis"]), Je = Object.freeze({
71
+ kind: "visual-adaptation",
72
+ title: "视觉适配信息",
73
+ summary: "部分材质细节采用近似表示,不影响资产结构与模型查看。",
74
+ tone: "info"
75
+ }), He = Object.freeze({
76
+ kind: "unsupported-by-viewer",
77
+ title: "视觉预览模式",
78
+ summary: "当前仿真链路未能建立物理模型,资产视觉内容仍可正常查看。",
79
+ tone: "info"
80
+ });
81
+ function oe(t, e) {
82
+ return t === "E_URDF_INERTIA" ? {
83
+ kind: "invalid-asset",
84
+ title: "物理定义无效",
85
+ summary: "该 URDF 未声明动力学仿真所需的有效惯性数据,动力学模型无法建立。",
86
+ tone: "warning"
87
+ } : {
88
+ kind: "invalid-asset",
89
+ title: "物理定义无效",
90
+ summary: e === "usd-physics" ? "该 USD 资产的物理参数或关节定义无效,物理模型无法建立。" : "该资产的物理参数缺失或无效,物理模型无法建立。",
91
+ tone: "warning"
92
+ };
93
+ }
94
+ function Ye(t) {
95
+ return t === "visual-material" ? {
96
+ kind: "visual-adaptation",
97
+ title: "视觉材质近似",
98
+ summary: "部分材质信息未完整转换,当前显示使用近似材质。",
99
+ tone: "info"
100
+ } : Je;
101
+ }
102
+ function Oe(t, e) {
103
+ const s = e.split(":").at(-1);
104
+ if (s && Be.has(s))
105
+ return {
106
+ kind: "runtime-failure",
107
+ title: "仿真运行异常",
108
+ summary: "仿真初始化或运行过程中发生异常,物理仿真已停止;资产视觉内容仍可正常查看。",
109
+ tone: "warning"
110
+ };
111
+ if (t === "E_MUJOCO_INITIALIZE") {
112
+ if (e === "mjcf-physics")
113
+ return {
114
+ kind: "runtime-failure",
115
+ title: "物理模型初始化失败",
116
+ summary: "MuJoCo 物理模型初始化失败,资产仍可进行视觉预览。",
117
+ tone: "warning"
118
+ };
119
+ if (e === "urdf-physics")
120
+ return {
121
+ kind: "runtime-failure",
122
+ title: "动力学初始化失败",
123
+ summary: "URDF 动力学初始化失败,当前保留运动学预览。",
124
+ tone: "warning"
125
+ };
126
+ if (e === "usd-physics")
127
+ return {
128
+ kind: "runtime-failure",
129
+ title: "物理模型初始化失败",
130
+ summary: "当前 USD 物理模型未能完成 MuJoCo 初始化,资产视觉内容仍可正常查看。",
131
+ tone: "warning"
132
+ };
133
+ }
134
+ return We.has(t) ? oe(t, e) : e === "usd-physics" || t.startsWith("E_USD_") ? {
135
+ kind: "unsupported-by-viewer",
136
+ title: "视觉预览模式",
137
+ summary: "当前 Viewer 未覆盖该 USD 资产使用的部分物理语义,视觉与结构信息可正常查看,物理仿真未启动。",
138
+ tone: "info"
139
+ } : t.startsWith("E_MJCF_") || t.startsWith("E_URDF_") ? oe(t, e) : He;
140
+ }
141
+ function Xe(t, e) {
142
+ const s = t.notice ?? (e === "physics-validation" ? oe(t.code, t.source) : e === "visual-adaptation" || e === "visual-material" ? Ye(e) : Oe(t.code, t.source ?? e));
143
+ return { ...t, stage: e, notice: s };
144
+ }
145
+ function ne(t, e, s) {
146
+ if (e.throwIfAborted(), t instanceof Error && (t.name === "AbortError" || ["E_ABORTED", "E_SUPERSEDED"].includes(String(t.code)))) throw t;
147
+ const n = t && typeof t == "object" && "code" in t && typeof t.code == "string" ? t.code : "E_PHYSICS_INITIALIZE", r = t instanceof Error ? t.message : String(t);
148
+ return { code: n, source: s, message: r, notice: Oe(n, s) };
149
+ }
150
+ const Ke = /<UDIM>/i;
151
+ function Ze(t, e) {
152
+ const s = we(t).replaceAll("\\", "/");
153
+ if (!Ke.test(s)) return null;
154
+ const n = Ae(s), r = n.split("/").at(-1);
155
+ if (!r) return { paths: [], tiles: [] };
156
+ const a = xe(r);
157
+ if (!a) return { paths: [], tiles: [] };
158
+ const l = [];
159
+ for (const u of new Set(e)) {
160
+ const y = we(u).replaceAll("\\", "/"), m = Ae(y), U = m.split("/").at(-1);
161
+ if (!U) continue;
162
+ const A = a.exec(U);
163
+ if (!A) continue;
164
+ const C = Number(A[1]);
165
+ !Number.isInteger(C) || C < 1001 || C > 9999 || l.push({
166
+ path: u,
167
+ tile: C,
168
+ score: et(n, m)
169
+ });
170
+ }
171
+ if (!l.length) return { paths: [], tiles: [] };
172
+ const h = Math.max(...l.map((u) => u.score)), d = l.filter((u) => u.score === h).sort((u, y) => u.tile - y.tile || u.path.localeCompare(y.path));
173
+ return {
174
+ paths: d.map((u) => u.path),
175
+ tiles: d.map((u) => u.tile)
176
+ };
177
+ }
178
+ function _t(t) {
179
+ if (!t.tiles.length) return null;
180
+ const e = t.tiles.map(Qe), s = Math.min(...e.map(({ column: l }) => l)), n = Math.max(...e.map(({ column: l }) => l)), r = Math.min(...e.map(({ row: l }) => l)), a = Math.max(...e.map(({ row: l }) => l));
181
+ return {
182
+ minColumn: s,
183
+ maxColumn: n,
184
+ minRow: r,
185
+ maxRow: a,
186
+ columns: n - s + 1,
187
+ rows: a - r + 1
188
+ };
189
+ }
190
+ function Qe(t) {
191
+ const e = t - 1001;
192
+ return {
193
+ column: (e % 10 + 10) % 10,
194
+ row: Math.floor(e / 10)
195
+ };
196
+ }
197
+ function xe(t) {
198
+ const e = t.split(/<UDIM>/i);
199
+ return e.length !== 2 ? null : new RegExp(`^${ge(e[0])}(\\d{4})${ge(e[1])}$`, "i");
200
+ }
201
+ function et(t, e) {
202
+ const s = t.split("/").slice(0, -1).filter(Boolean), n = e.split("/").slice(0, -1).filter(Boolean);
203
+ let r = 0;
204
+ for (; r < s.length && r < n.length; ) {
205
+ const a = s.at(-1 - r), l = n.at(-1 - r);
206
+ if ((a == null ? void 0 : a.toLowerCase()) !== (l == null ? void 0 : l.toLowerCase())) break;
207
+ r += 1;
208
+ }
209
+ return r;
210
+ }
211
+ function we(t) {
212
+ const e = t.replace(/%3CUDIM%3E/gi, "<UDIM>");
213
+ try {
214
+ return decodeURIComponent(e);
215
+ } catch {
216
+ return e;
217
+ }
218
+ }
219
+ function Ae(t) {
220
+ const e = t.search(/[?#]/);
221
+ return e < 0 ? t : t.slice(0, e);
222
+ }
223
+ function ge(t) {
224
+ return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
225
+ }
226
+ class tt {
227
+ constructor(e) {
228
+ k(this, "entries", /* @__PURE__ */ new Map());
229
+ k(this, "objectUrls", /* @__PURE__ */ new Map());
230
+ k(this, "objectUrlPaths", /* @__PURE__ */ new Map());
231
+ /**
232
+ * Reads that already failed, so a missing resource is not requested again by
233
+ * the visual adapter after the reference prefetch has recorded it.
234
+ */
235
+ k(this, "failures", /* @__PURE__ */ new Map());
236
+ k(this, "localPackage");
237
+ this.source = e;
238
+ const s = e.original;
239
+ if (this.localPackage = ve(s) || typeof Blob < "u" && s instanceof Blob || s instanceof ArrayBuffer || typeof s == "object" && s !== null && "kind" in s && s.kind === "buffer", ve(s))
240
+ for (const n of s.files) this.entries.set(R(n.path), n.file);
241
+ else e.entryBlob && typeof s == "object" && s !== null && "kind" in s && s.kind === "remote-entry" ? this.entries.set(e.entryPath ?? s.entryPath, e.entryBlob) : typeof Blob < "u" && s instanceof Blob ? this.entries.set(e.entryPath ?? e.filename ?? "asset", s) : s instanceof ArrayBuffer ? this.entries.set(e.entryPath ?? e.filename ?? "asset", new Blob([s])) : typeof s == "object" && s !== null && "kind" in s && s.kind === "buffer" && this.entries.set(e.entryPath ?? e.filename ?? "asset", new Blob([s.buffer]));
242
+ }
243
+ paths() {
244
+ return [...this.entries.keys()];
245
+ }
246
+ hasLocalFiles() {
247
+ return this.localPackage;
248
+ }
249
+ put(e, s) {
250
+ this.entries.set(R(e), s);
251
+ }
252
+ relativePaths(e = "", s = !1) {
253
+ return [...this.relativeEntries(e, s)].map(([n]) => n);
254
+ }
255
+ asSourceRecord(e = "", s = !1) {
256
+ return Object.fromEntries(this.relativeEntries(e, s));
257
+ }
258
+ *relativeEntries(e = "", s = !1) {
259
+ const n = R(e), r = n ? `${n}/` : "";
260
+ for (const [a, l] of this.entries)
261
+ if (!r || a.startsWith(r)) yield [r ? a.slice(r.length) : a, l];
262
+ else if (s) {
263
+ const h = n.split("/"), d = a.split("/");
264
+ let u = 0;
265
+ for (; u < h.length && h[u] === d[u]; ) u++;
266
+ yield [[...h.slice(u).map(() => ".."), ...d.slice(u)].join("/"), l];
267
+ }
268
+ }
269
+ resolve(e, s = "") {
270
+ const n = this.find(e, s);
271
+ if (n) return n;
272
+ const r = R(s).split("/").slice(0, -1).join("/");
273
+ if (this.source.url) return R(`${r}/${e.replace(/^package:\/\//, "")}`);
274
+ throw T(`Simulation resource not found: ${e}`, "E_ASSET_RESOURCE_NOT_FOUND");
275
+ }
276
+ find(e, s = "") {
277
+ const n = R(e.replace(/^package:\/\//, ""));
278
+ if (x(n)) return this.entries.has(n) ? n : null;
279
+ const r = R(s).split("/").slice(0, -1).join("/");
280
+ for (const l of [R(`${r}/${e.replace(/^package:\/\//, "")}`), n])
281
+ if (this.entries.has(l)) return l;
282
+ const a = this.paths().filter(
283
+ (l) => !x(l) && (l === n || l.endsWith(`/${n}`) || n.endsWith(`/${l}`))
284
+ );
285
+ return a.length === 1 ? a[0] : null;
286
+ }
287
+ async text(e) {
288
+ await this.ensure(e);
289
+ const s = this.entries.get(this.resolve(e));
290
+ if (!s) throw T(`Simulation resource not found: ${e}`, "E_ASSET_RESOURCE_NOT_FOUND");
291
+ return s.text();
292
+ }
293
+ async bytes(e) {
294
+ await this.ensure(e);
295
+ const s = this.entries.get(this.resolve(e));
296
+ if (!s) throw T(`Simulation resource not found: ${e}`, "E_ASSET_RESOURCE_NOT_FOUND");
297
+ return new Uint8Array(await s.arrayBuffer());
298
+ }
299
+ getBlob(e) {
300
+ const s = this.resolve(e), n = this.entries.get(s);
301
+ if (!n) throw T(`Simulation resource not found: ${e}`, "E_ASSET_RESOURCE_NOT_FOUND");
302
+ return n;
303
+ }
304
+ async ensure(e, s) {
305
+ const n = R(e);
306
+ if (this.entries.has(n)) return;
307
+ const r = this.failures.get(n);
308
+ if (r) throw r;
309
+ try {
310
+ const a = await this.source.resolve(n, s);
311
+ if (!/^https?:\/\//i.test(a) && !/^blob:/i.test(a))
312
+ throw T(`Simulation resource not found: ${e}. Upload the complete asset folder or provide a resourceResolver/baseUrl.`, ie);
313
+ const l = await fetch(a, { signal: this.source.signal });
314
+ if (!l.ok) {
315
+ const u = l.status === 401 || l.status === 403 ? Re : l.status === 404 || l.status === 410 ? ie : Ie;
316
+ throw T(`Simulation resource request failed (${l.status}): ${a}`, u);
317
+ }
318
+ const h = await l.blob();
319
+ this.source.signal.throwIfAborted();
320
+ const d = await qe(h);
321
+ if (d) throw T(`Simulation resource is not usable (${d}): ${a}`, Ue);
322
+ this.entries.set(n, h);
323
+ } catch (a) {
324
+ throw De(a) === "aborted" || this.failures.set(n, a instanceof Error ? a : new Error(String(a))), a;
325
+ }
326
+ }
327
+ /** The recorded failure for a resource, if a previous read already failed. */
328
+ failureOf(e) {
329
+ return this.failures.get(R(e));
330
+ }
331
+ objectUrl(e) {
332
+ const s = this.resolve(e);
333
+ let n = this.objectUrls.get(s);
334
+ return n || (n = URL.createObjectURL(this.getBlob(s)), this.objectUrls.set(s, n), this.objectUrlPaths.set(n, s)), n;
335
+ }
336
+ pathForObjectUrl(e) {
337
+ return this.objectUrlPaths.get(e) ?? null;
338
+ }
339
+ /**
340
+ * Resolve a texture relative to the directory containing the entry layer.
341
+ * Pass the entry directory, not the entry file path.
342
+ */
343
+ findTexture(e, s = "") {
344
+ const n = this.findPresent(e, s);
345
+ if (n) return n;
346
+ const r = this.udimTextureSet(e);
347
+ return (r == null ? void 0 : r.paths.length) === 1 ? r.paths[0] : null;
348
+ }
349
+ udimTextureSet(e) {
350
+ return Ze(e, this.paths());
351
+ }
352
+ objectUrlIfPresent(e, s = "") {
353
+ const n = this.findTexture(e, s);
354
+ return n ? this.objectUrl(n) : null;
355
+ }
356
+ findPresent(e, s = "") {
357
+ if (x(e)) return this.entries.has(e) ? e : null;
358
+ const n = R(s), r = n ? `${n}/` : "", a = R(e), l = r ? this.paths().filter((h) => {
359
+ if (!h.startsWith(r)) return !1;
360
+ const d = h.slice(r.length);
361
+ return d === a || a.endsWith(`/${d}`);
362
+ }) : [];
363
+ return l.length === 1 ? l[0] : this.find(e);
364
+ }
365
+ dispose() {
366
+ for (const e of this.objectUrls.values()) URL.revokeObjectURL(e);
367
+ this.objectUrls.clear(), this.objectUrlPaths.clear(), this.entries.clear(), this.failures.clear();
368
+ }
369
+ }
370
+ async function st(t, e) {
371
+ if (e.hasLocalFiles()) return e.text(t.entryPath ?? t.filename ?? e.paths()[0]);
372
+ const s = await fetch(t.url ?? await t.resolve(t.entryPath ?? ""), { signal: t.signal });
373
+ if (!s.ok) throw T(`Simulation asset request failed: ${s.status}`, "E_ASSET_FETCH");
374
+ return s.text();
375
+ }
376
+ function wt(t) {
377
+ return R(t);
378
+ }
379
+ function R(t) {
380
+ if (x(t)) return t;
381
+ const e = [];
382
+ for (const s of t.replaceAll("\\", "/").split("/"))
383
+ !s || s === "." || (s === ".." && e.length && e.at(-1) !== ".." ? e.pop() : e.push(s));
384
+ return e.join("/");
385
+ }
386
+ function x(t) {
387
+ return /^[a-z][a-z\d+.-]*:/i.test(t) && !/^package:\/\//i.test(t);
388
+ }
389
+ function ve(t) {
390
+ return typeof t == "object" && t !== null && "kind" in t && t.kind === "files";
391
+ }
392
+ function T(t, e) {
393
+ return Object.assign(new Error(t), { code: e });
394
+ }
395
+ function rt() {
396
+ return { errors: [], warnings: [], approximations: [], droppedFeatures: [] };
397
+ }
398
+ function nt(t, e = {}) {
399
+ const s = Object.freeze({ schemaVersion: 1, ...t });
400
+ return it(s, e), s;
401
+ }
402
+ function it(t, e = {}) {
403
+ if (!t.id.trim() || !t.name.trim()) throw Z("Asset IR id and name are required.", "E_ASSET_IR_INVALID");
404
+ if (t.source.format !== "usd" && t.links.length === 0) throw Z("Asset IR requires at least one link.", "E_ASSET_IR_INVALID");
405
+ const s = /* @__PURE__ */ new Set();
406
+ for (const r of t.links) {
407
+ if (!r.id || s.has(r.id)) throw Z(`Invalid or duplicate link: ${r.id}`, "E_ASSET_IR_INVALID");
408
+ s.add(r.id);
409
+ }
410
+ const n = /* @__PURE__ */ new Set();
411
+ for (const r of t.joints) {
412
+ if (!r.id || n.has(r.id) || !e.allowInvalidGraph && (!s.has(r.parent) || !s.has(r.child)))
413
+ throw Z(`Invalid joint: ${r.id}`, "E_ASSET_IR_INVALID");
414
+ n.add(r.id);
415
+ }
416
+ }
417
+ function Z(t, e) {
418
+ return Object.assign(new Error(t), { code: e });
419
+ }
420
+ async function ot(t, e, s) {
421
+ var d;
422
+ const n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), l = async (u, y) => {
423
+ if (a.has(u)) throw ae(`MJCF include cycle: ${u}`, "E_MJCF_INCLUDE_CYCLE");
424
+ a.add(u);
425
+ const m = ft(y, u);
426
+ n.set(u, m);
427
+ for (const U of m.querySelectorAll("worldbody body[name]")) r.add(U.getAttribute("name"));
428
+ for (const U of m.querySelectorAll("include[file]")) {
429
+ const A = s.resolve(U.getAttribute("file"), u);
430
+ await l(A, await s.text(A));
431
+ }
432
+ a.delete(u);
433
+ };
434
+ await l(e, t);
435
+ const h = (d = n.get(e)) == null ? void 0 : d.querySelector("mujoco");
436
+ if (!h || r.size === 0) throw ae("MJCF requires a mujoco root and at least one named body.", "E_MJCF_PARSE");
437
+ return nt({
438
+ id: h.getAttribute("model") || e,
439
+ name: h.getAttribute("model") || e,
440
+ source: { format: "mjcf", uri: e },
441
+ links: [...r].map((u) => ({ id: u, name: u, visuals: [], collisions: [] })),
442
+ joints: [],
443
+ diagnostics: rt(),
444
+ extension: { files: s, xml: t, documents: n }
445
+ });
446
+ }
447
+ async function at(t) {
448
+ const e = t.extension.files, s = t.source.uri, n = s.split("/").slice(0, -1).join("/"), r = /* @__PURE__ */ new Map(), a = t.extension.documents;
449
+ for (const [d, u] of a) {
450
+ const y = u.querySelector("compiler");
451
+ for (const m of u.querySelectorAll("asset [file]")) {
452
+ const U = (y == null ? void 0 : y.getAttribute(m.tagName === "texture" ? "texturedir" : "meshdir")) ?? (y == null ? void 0 : y.getAttribute("assetdir")) ?? "", A = e.resolve(`${U}/${m.getAttribute("file")}`, d);
453
+ await e.bytes(A);
454
+ }
455
+ }
456
+ for (const d of ct(e.paths(), a)) {
457
+ if (d === s) continue;
458
+ const u = n && d.startsWith(`${n}/`) ? d.slice(n.length + 1) : d;
459
+ r.set(u, await e.bytes(d));
460
+ }
461
+ const l = t.extension.xml;
462
+ return { format: "mjcf", xml: lt(a) ? ut(l) : l, files: r };
463
+ }
464
+ function lt(t) {
465
+ return t.size === 0 || ![...t.values()].some((s) => s.querySelector("freejoint, actuator") ? !0 : [...s.querySelectorAll("joint")].some(
466
+ (n) => (n.getAttribute("type") ?? "hinge").toLowerCase() !== "fixed"
467
+ )) ? !1 : ![...t.values()].some(
468
+ (s) => [...s.querySelectorAll("worldbody geom")].some((n) => {
469
+ var r;
470
+ return ((r = n.getAttribute("type")) == null ? void 0 : r.toLowerCase()) === "plane";
471
+ })
472
+ );
473
+ }
474
+ function ut(t) {
475
+ const e = '<geom name="__viewer_default_ground__" type="plane" size="5 5 0.1" contype="1" conaffinity="1" friction="0.8 0.01 0.0002"/>';
476
+ return /<worldbody\b[^>]*>/i.test(t) ? t.replace(/(<worldbody\b[^>]*>)/i, `$1${e}`) : t.replace(/<\/mujoco\s*>/i, `<worldbody>${e}</worldbody></mujoco>`);
477
+ }
478
+ function ct(t, e) {
479
+ const s = (h) => h.replaceAll("\\", "/").split("/").pop() ?? "", n = /* @__PURE__ */ new Map();
480
+ for (const h of t) {
481
+ const d = s(h), u = n.get(d) ?? [];
482
+ u.push(h), n.set(d, u);
483
+ }
484
+ const r = new Set(e.keys()), a = /* @__PURE__ */ new Set(["include", "mesh", "texture", "hfield", "skin"]), l = /* @__PURE__ */ new Set(["fileleft", "fileright", "fileup", "filedown", "filefront", "fileback"]);
485
+ for (const h of e.values()) {
486
+ if (h.querySelector("plugin, extension, model, attach")) return t;
487
+ for (const d of h.querySelectorAll("*"))
488
+ for (const u of d.attributes) {
489
+ if (!u.name.startsWith("file")) continue;
490
+ if (u.name === "file") {
491
+ if (!a.has(d.tagName)) return t;
492
+ } else if (!(d.tagName === "texture" && l.has(u.name)))
493
+ return t;
494
+ if (!u.value) continue;
495
+ const y = n.get(s(u.value));
496
+ if (!y) return t;
497
+ for (const m of y) r.add(m);
498
+ }
499
+ }
500
+ return t.filter((h) => r.has(h));
501
+ }
502
+ function ft(t, e) {
503
+ const s = new DOMParser().parseFromString(t, "application/xml"), n = s.querySelector("parsererror");
504
+ if (n) throw ae(`MJCF XML parse failed (${e}): ${n.textContent ?? ""}`, "E_MJCF_PARSE");
505
+ return s;
506
+ }
507
+ function ae(t, e) {
508
+ return Object.assign(new Error(t), { code: e });
509
+ }
510
+ function dt(t, e) {
511
+ const s = new tt(t), n = e.format === "usd" || e.format === "usda" || e.format === "usdc" || e.format === "usdz";
512
+ let r = null, a = null, l = null, h = null, d = null, u = null, y = null, m = null, U = null, A = null, C = null, E = !1, v = !1, _ = !1, I = !1, g = null, N = null, ue, w = null, F = null, i = null, c = null, L = null, b = null, B = null, $ = !1, G = null, J = "z", ee = !1;
513
+ const V = () => {
514
+ i && (J = e.options.upAxis ?? "z", ee = !0, i.setUpAxis(J) && (a == null || a.sync(), c == null || c.sync()));
515
+ }, z = (o, f) => {
516
+ var O;
517
+ const S = ne(o, e.signal, `${e.format}:${f}`);
518
+ v = !1, _ = !1, N = { ...S, stage: f };
519
+ try {
520
+ i == null || i.endGrab();
521
+ } catch {
522
+ }
523
+ (O = e.reportSessionState) == null || O.call(e), e.reportError(o, { fatal: !1, stage: f, code: S.code });
524
+ }, je = (o) => {
525
+ var f;
526
+ if (E) {
527
+ o.dispose();
528
+ return;
529
+ }
530
+ b = null, $ = !1, w = o.asset, l = o.dispose, I = o.hasAnimation === !0, h = o.hasPhysics || I ? o.step : null, d = o.reset, v = !o.hasPhysics && o.hasAnimation === !0, _ = o.hasPhysics, g = o.fallback ? { ...o.fallback, stage: "physics-fallback" } : o.visualWarning ? { ...o.visualWarning, stage: "visual-adaptation" } : null, a = o.binding, r = o.runtime ?? null, F = o.physics ?? null, G = o.inspect ?? null, c = o.collision ?? null, L = o.createCollision ?? null, i == null || i.setRuntime(o.runtime), i == null || i.replaceModel(o.binding.root), c && (c.root.visible = !1, i == null || i.attachAuxiliary(c.root), c.sync()), V(), (f = e.reportSessionState) == null || f.call(e), e.requestRender();
531
+ }, Ne = (o) => {
532
+ var S;
533
+ if (E) return;
534
+ const f = ne(o, e.signal, "usd-physics");
535
+ $ = !1, N = { ...f, stage: "usd-physics" }, _ = !1, I = (b == null ? void 0 : b.visual.hasAnimation) ?? I, h = b != null && b.visual.hasAnimation ? b.visual.step : null, d = b != null && b.visual.hasAnimation ? b.visual.reset : null, v = !!(b != null && b.visual.hasAnimation), (S = e.reportSessionState) == null || S.call(e), e.reportError(o, { fatal: !1, stage: "usd-physics", code: f.code });
536
+ }, ce = () => {
537
+ E = !0, v = !1;
538
+ }, fe = () => {
539
+ if (c) return !0;
540
+ const o = L;
541
+ return L = null, !o || !i || (c = o() ?? null, !c) ? !1 : (c.root.visible = !1, i.attachAuxiliary(c.root), c.sync(), !0);
542
+ };
543
+ let de = () => {
544
+ }, he = () => {
545
+ }, pe = !1;
546
+ const te = new Promise((o, f) => {
547
+ de = o, he = f;
548
+ }), H = () => {
549
+ pe || (pe = !0, de());
550
+ };
551
+ return (async () => {
552
+ var o, f, S, O, Y, D, q, W, me, ye;
553
+ try {
554
+ const P = e.format;
555
+ if (P === "usd" || P === "usda" || P === "usdc" || P === "usdz") {
556
+ (o = e.reportProgress) == null || o.call(e, "usd-visual", "正在解析 USD 视觉场景...");
557
+ const p = await (await import("./usd-session-DZJnEEOs.js")).loadUsdSimulation(t, e, s);
558
+ if (E || e.signal.aborted)
559
+ throw p.dispose(), le();
560
+ b = p, a = { root: p.visual.root, sync() {
561
+ }, dispose() {
562
+ } }, l = p.dispose, I = p.visual.hasAnimation, h = I ? p.visual.step : null, d = p.visual.reset, v = !1, $ = !0, g = p.visual.warning ? { ...p.visual.warning, stage: "visual-adaptation" } : null, (f = e.reportProgress) == null || f.call(e, "stage", "正在构建三维场景与环境光影..."), i = new re(
563
+ p.visual.root,
564
+ e.options.simulationTheme,
565
+ void 0,
566
+ "simulation",
567
+ "visual"
568
+ ), V(), H(), (S = e.reportProgress) == null || S.call(e, "usd-physics", "视觉场景已就绪,正在准备物理..."), B = p.completePhysics().then(je).catch(Ne);
569
+ return;
570
+ }
571
+ if (P === "urdf" || P === "xacro") {
572
+ (O = e.reportProgress) == null || O.call(e, "urdf", "正在解析 URDF 场景与运动学结构...");
573
+ const p = await (await import("./urdf-session-CQir2nb2.js")).loadUrdfSimulation(t, e, s);
574
+ if (E || e.signal.aborted)
575
+ throw p.dispose(), le();
576
+ w = p.asset, i = p.stage, U = p.inspection, l = p.dispose, h = p.step, d = p.reset, u = p.play, y = p.pause, m = p.isPlaying, A = () => p.capabilities, C = () => p.physics, v = !1, _ = !1, g = p.warning ?? null, V(), H();
577
+ return;
578
+ }
579
+ let X = t.entryPath ?? t.filename;
580
+ if (!X && P === "mjcf") {
581
+ const j = s.paths().filter((p) => p.toLowerCase().endsWith(".xml"));
582
+ for (const p of ["scene.xml", "model.xml", "main.xml"]) {
583
+ const K = j.find((M) => M.toLowerCase().endsWith(`/${p}`) || M.toLowerCase() === p);
584
+ if (K) {
585
+ X = K;
586
+ break;
587
+ }
588
+ }
589
+ }
590
+ X ?? (X = "asset.xml"), (Y = e.reportProgress) == null || Y.call(e, "fetch", "正在读取模型描述与依赖资源...");
591
+ const Pe = await st(t, s);
592
+ Q(E, e.signal), (D = e.reportProgress) == null || D.call(e, "parse", "正在解析 MJCF 场景与连杆..."), w = await ot(Pe, X, s);
593
+ try {
594
+ (q = e.reportProgress) == null || q.call(e, "compile", "正在编译物理模型与参数...");
595
+ const j = await at(w);
596
+ F = j, Q(E, e.signal), (W = e.reportProgress) == null || W.call(e, "runtime", "正在初始化物理内核...");
597
+ const { MujocoRuntime: p } = await import("./mujoco-runtime-BYZnrvbR.js");
598
+ r = new p(), await r.initialize(j, {
599
+ baseUrl: e.options.mujocoBaseUrl,
600
+ wasmModule: e.options.mujocoWasmModule
601
+ });
602
+ } catch (j) {
603
+ const p = ne(j, e.signal, "mjcf-physics");
604
+ r == null || r.dispose(), r = null;
605
+ const { compileMjcfPreview: K } = await import("./mjcf-visual-Bt4bUxd1.js");
606
+ let M;
607
+ try {
608
+ M = K(w);
609
+ } catch (se) {
610
+ throw new Error(`${p.message};独立视觉预览也不可用:${se instanceof Error ? se.message : String(se)}`);
611
+ }
612
+ a = { root: M, sync() {
613
+ }, dispose() {
614
+ Fe(M);
615
+ } }, g = { ...p, stage: "physics-fallback" }, i = new re(M, e.options.simulationTheme, void 0, "simulation", "visual"), v = !1, V(), H();
616
+ return;
617
+ }
618
+ _ = !0, Q(E, e.signal), (me = e.reportProgress) == null || me.call(e, "visual", "正在构建视觉渲染网格...");
619
+ const Te = be(r, !1, w.diagnostics), Ee = w.diagnostics.droppedFeatures.find((j) => j.code.startsWith("MJCF_"));
620
+ Ee && (g = { ...Ee, stage: "visual-material" }), Q(E, e.signal), (ye = e.reportProgress) == null || ye.call(e, "stage", "正在构建三维场景与环境光影..."), a = new _e(r, Te), i = new re(a.root, e.options.simulationTheme, r);
621
+ const Se = be(r, !0, w.diagnostics);
622
+ Se.root.children.length > 0 ? (c = new _e(r, Se), c.root.visible = !1) : c = null, c && i.attachAuxiliary(c.root), V(), H();
623
+ } catch (P) {
624
+ throw i == null || i.dispose(), i = null, l ? (l(), l = null) : (c == null || c.dispose(), a == null || a.dispose(), r == null || r.dispose()), c = null, a = null, r = null, s.dispose(), F = null, b = null, P;
625
+ }
626
+ })().catch(he), te.catch(() => {
627
+ }), {
628
+ id: `simulation-${Math.random().toString(36).slice(2)}`,
629
+ get autoPlay() {
630
+ return !$ && !_ && I;
631
+ },
632
+ get inspection() {
633
+ return U;
634
+ },
635
+ isPlaying() {
636
+ return (m == null ? void 0 : m()) ?? v;
637
+ },
638
+ opened: te,
639
+ get root() {
640
+ return (i == null ? void 0 : i.root) ?? null;
641
+ },
642
+ getFitBounds() {
643
+ return (i == null ? void 0 : i.getModelBounds()) ?? null;
644
+ },
645
+ beforeRender(o, f, S) {
646
+ return i == null ? void 0 : i.beforeRender(o, f, S);
647
+ },
648
+ get capabilities() {
649
+ const o = c !== null || L !== null;
650
+ return N ? { canPlay: !1, canPause: !1, canReset: !1, hasPhysics: !1, hasAnimation: !1, canToggleGround: !0, canToggleCollision: o, canReorientUpAxis: !0 } : (A == null ? void 0 : A()) ?? { canPlay: _ || I, canPause: _ || I, canReset: _ || I, hasPhysics: _, hasAnimation: I, canToggleGround: !0, canToggleCollision: o, canReorientUpAxis: !0 };
651
+ },
652
+ get warning() {
653
+ return g && !g.notice ? Xe(g, g.stage) : g;
654
+ },
655
+ get physics() {
656
+ return N ? { status: "unavailable", issue: N } : C ? C() : $ ? { status: "initializing" } : _ ? { status: "ready" } : (g == null ? void 0 : g.stage) === "physics-fallback" ? { status: "unavailable", issue: g } : { status: "not-authored" };
657
+ },
658
+ setTheme(o) {
659
+ i == null || i.setTheme(o);
660
+ },
661
+ setGroundVisible(o) {
662
+ i == null || i.setGroundVisible(o);
663
+ },
664
+ getGroundVisible() {
665
+ return (i == null ? void 0 : i.getGroundVisible()) ?? !0;
666
+ },
667
+ getGroundGridScale() {
668
+ return (i == null ? void 0 : i.getGroundGridScale()) ?? ke;
669
+ },
670
+ getUpAxis() {
671
+ return i && ee ? J : null;
672
+ },
673
+ setUpAxis(o) {
674
+ if (!(E || !i))
675
+ try {
676
+ if (!i.setUpAxis(o)) return;
677
+ J = o, a == null || a.sync(), c == null || c.sync(), e.requestRender();
678
+ } catch (f) {
679
+ z(f, "up-axis");
680
+ }
681
+ },
682
+ presentation: { preferredViewMode: "3d", interactionMode: "simulation", uiProfile: "simulation", fitPolicy: "fit-on-ready" },
683
+ beginDispose: ce,
684
+ setCollisionVisible(o) {
685
+ if (!E) {
686
+ if (A) {
687
+ const f = U;
688
+ f == null || f.setOverlay("collision", o);
689
+ return;
690
+ }
691
+ if (o && !fe()) throw new Error("This asset has no collision display.");
692
+ c && (c.root.visible = o), e.requestRender();
693
+ }
694
+ },
695
+ getCollisionRoot() {
696
+ return E || A || !fe() ? null : (c == null || c.sync(), (c == null ? void 0 : c.root) ?? null);
697
+ },
698
+ getVisualDiagnostics() {
699
+ return E || !w || w.source.format !== "usd" ? null : structuredClone({
700
+ report: w.extension.visualAdaptation,
701
+ diagnostics: w.diagnostics,
702
+ usd: (G == null ? void 0 : G()) ?? null
703
+ });
704
+ },
705
+ getPhysicsProperties() {
706
+ const o = r;
707
+ if (E || !_ || !(o != null && o.model) || !o.mujoco) return null;
708
+ const f = o.model, S = o.mujoco;
709
+ return structuredClone({
710
+ units: { length: "m", mass: "kg", time: "s" },
711
+ timestep: f.opt.timestep,
712
+ gravity: Array.from(f.opt.gravity),
713
+ bodyCount: f.nbody - 1,
714
+ jointCount: f.njnt,
715
+ geomCount: f.ngeom,
716
+ bodies: Array.from({ length: f.nbody - 1 }, (O, Y) => {
717
+ var q, W;
718
+ const D = Y + 1;
719
+ return {
720
+ id: D,
721
+ name: S.mj_id2name(f, S.mjtObj.mjOBJ_BODY.value, D),
722
+ mass: f.body_mass[D],
723
+ inertia: Array.from(f.body_inertia.slice(D * 3, D * 3 + 3)),
724
+ position: Array.from(((q = o.data) == null ? void 0 : q.xpos.slice(D * 3, D * 3 + 3)) ?? []),
725
+ quaternion: Array.from(((W = o.data) == null ? void 0 : W.xquat.slice(D * 4, D * 4 + 4)) ?? [])
726
+ };
727
+ }),
728
+ diagnostics: w == null ? void 0 : w.diagnostics
729
+ });
730
+ },
731
+ get update() {
732
+ return r != null && r.model || h || n ? (o) => {
733
+ if (N || E || !((m == null ? void 0 : m()) ?? v) || !a && !h || !h && !(r != null && r.model)) return !1;
734
+ try {
735
+ if (h) {
736
+ const S = h(o);
737
+ return S && (c == null || c.sync()), S;
738
+ }
739
+ const f = r.step(o);
740
+ return f && (a.sync(), c == null || c.sync(), i == null || i.updateForceLine()), f;
741
+ } catch (f) {
742
+ return z(f, "step"), !1;
743
+ }
744
+ } : void 0;
745
+ },
746
+ play() {
747
+ E || N || (u ? (u(), v = (m == null ? void 0 : m()) ?? !1) : (_ || I) && (v = !0));
748
+ },
749
+ pause() {
750
+ N || (y && y(), v = !1);
751
+ },
752
+ reset() {
753
+ if (!(N || E || !a && !d))
754
+ try {
755
+ i == null || i.endGrab(), d ? d() : (r == null || r.reset(), a.sync()), c == null || c.sync(), i == null || i.resetGround(), i == null || i.updateForceLine();
756
+ } catch (o) {
757
+ z(o, "reset");
758
+ }
759
+ },
760
+ beginGrab(o, f, S) {
761
+ if (E || !((m == null ? void 0 : m()) ?? v) || !_ && !C) return !1;
762
+ try {
763
+ return (i == null ? void 0 : i.beginGrab(o, f, S)) ?? !1;
764
+ } catch (O) {
765
+ return z(O, "grab"), !1;
766
+ }
767
+ },
768
+ moveGrab(o, f, S) {
769
+ if (!(E || !((m == null ? void 0 : m()) ?? v) || !_ && !C))
770
+ try {
771
+ i == null || i.moveGrab(o, f, S);
772
+ } catch (O) {
773
+ z(O, "grab");
774
+ }
775
+ },
776
+ endGrab() {
777
+ i == null || i.endGrab();
778
+ },
779
+ getScenePhysics() {
780
+ if (E || !_ || !F || !a) return null;
781
+ const o = /* @__PURE__ */ new Map();
782
+ return a.root.traverse((f) => {
783
+ typeof f.userData.bodyId == "number" && f.name && o.set(f.name, f);
784
+ }), {
785
+ ...F,
786
+ visualBindings: o
787
+ };
788
+ },
789
+ dispose() {
790
+ return ce(), ue ?? (ue = te.catch(() => {
791
+ }).then(async () => {
792
+ i == null || i.dispose(), i = null, l ? (l(), l = null, i = null, a = null, c = null, L = null) : (c == null || c.root.removeFromParent(), c == null || c.dispose(), c = null, L = null, a == null || a.dispose(), a = null, r == null || r.dispose()), await (B == null ? void 0 : B.catch(() => {
793
+ })), b = null, s.dispose(), w = null, U = null, G = null, h = null, d = null, u = null, y = null, m = null, A = null, C = null, _ = !1, I = !1, g = null, ee = !1;
794
+ })), ue;
795
+ }
796
+ };
797
+ }
798
+ function Q(t, e) {
799
+ if (t || e.aborted) throw le();
800
+ }
801
+ function le() {
802
+ return Object.assign(new Error("Simulation load aborted."), { name: "AbortError", code: "E_ABORTED" });
803
+ }
804
+ const At = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
805
+ __proto__: null,
806
+ createSimulationSession: dt
807
+ }, Symbol.toStringTag, { value: "Module" }));
808
+ export {
809
+ Ue as U,
810
+ yt as a,
811
+ St as b,
812
+ Et as c,
813
+ nt as d,
814
+ De as e,
815
+ rt as f,
816
+ st as g,
817
+ oe as h,
818
+ bt as i,
819
+ wt as n,
820
+ ne as p,
821
+ Ze as r,
822
+ At as s,
823
+ _t as u,
824
+ Xe as w
825
+ };