@nebula-spatial/viewer 0.5.1 → 0.5.2
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 +22 -0
- package/README.md +51 -4
- package/dist/assets/types.d.ts +9 -0
- package/dist/{index-CXdFFc74.js → index-Bp6O65bP.js} +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{mjcf-visual-BnZWMjcp.js → mjcf-visual-te_DOjK9.js} +2 -2
- package/dist/session-2sDMfyTY.js +822 -0
- package/dist/{session-BvgzEStG.js → session-CVL_PXO4.js} +2 -2
- package/dist/{stage-DBmU5D0V.js → stage-BrKWuPMa.js} +1 -1
- package/dist/{urdf-session-BtARifnH.js → urdf-session-iGr3RegL.js} +3 -3
- package/dist/usd-session-DX1DHQKU.js +2363 -0
- package/dist/version.d.ts +1 -1
- package/dist/{xacro-B8n3d29Q.js → xacro-Cl87kJRU.js} +1 -1
- package/openusd/openusd_probe.js +1 -1
- package/openusd/openusd_probe.wasm +0 -0
- package/package.json +1 -1
- package/dist/session-BhTeAhTq.js +0 -809
- package/dist/usd-session-DmO4QMLH.js +0 -2240
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this package are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.5.2
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- 新增 `OpenAssetOptions.usdExternalReferenceMode`(`'package' | 'complete'`,公开类型 `UsdExternalReferenceMode`):控制 USD 入口包之外引用的处理策略,缺省为 `'package'`。切换模式需重新调用 `openAsset()`,不在已组合的 stage 上只隐藏或显示环境。
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- USD 外部引用默认改为资产包模式(`package`):URL 入口以同 origin 的入口目录及其子目录为包边界;本地输入以实际选中的文件集合为边界,同目录或已选中的 `../` 依赖仍属包内。未选中的本地依赖、跨 origin 以及远端目录之外的资源不再请求,报告 `USD_EXTERNAL_REFERENCE_SKIPPED` 后继续显示包内内容;远端包内缺失资源、resolver 拒绝与解析失败仍按加载失败处理,不做 catch-all 降级。需要组合外部环境等场景依赖时显式传入 `usdExternalReferenceMode: 'complete'`。
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- 修复 USD 的 references、payloads 与 subLayers 的 URL 到 MEMFS 路径映射:远端或本地依赖取得后经 `usd_probe_stage_open_mapped` 映射到内存 Sdf Layer 再做 composition,以窗口路径隔离不同来源与带查询参数的同名资源,支持 USDA/USDC 的引用、payload 与子层,并保留目标 Prim、layer offset 等原始语义;每次加载使用独立目录,关闭或失败时清理临时资源。
|
|
18
|
+
- 修复恢复 2D 相机快照时的画布宽高比失配:快照只保存正交视锥(`left/right/top/bottom`)、中心与缩放,不保存视口尺寸,而 `OrthographicCamera` 没有 `aspect` 字段可供校正;当快照拍摄时的画布宽高比与本次打开不同(跨页面/跨会话,或图层、属性面板与窗口尺寸变化)时,图纸会被拉伸,直到有其他操作触发一次 `resize()`。现在快照应用后统一按当前视口重适配视锥(保留竖直跨度、水平中心与 `zoom`),规则与 `resize()` / `fitView()` 一致,`camera.setState()` 与 `camera.reset()` 一并覆盖。
|
|
19
|
+
|
|
20
|
+
### Behavior notes
|
|
21
|
+
|
|
22
|
+
- 完整模式(`complete`)在没有 `resourceResolver` 时直接尝试浏览器可访问的 HTTP(S) 引用,仍受 CORS、鉴权、网络、依赖数量与深度限制;提供了 resolver 时它拥有最终决定权,包外资源必须经其解析,拒绝、401/403 或请求失败不会回退为直连。相对引用传给 resolver 时以入口目录为基准并保留必要的 `../`,绝对 URL 引用保留完整域名与 query。
|
|
23
|
+
- 资产包模式跳过包外依赖不代表资产自包含,也不表示原始场景已完整加载;完整预览应切换到完整模式并提供合法可解析的依赖或完整文件包。已依赖自动加载外部引用的宿主需显式传入 `usdExternalReferenceMode: 'complete'`。
|
|
24
|
+
- `openusd_probe.js` 与 `openusd_probe.wasm` 必须与 JS bundle 同步部署;旧运行时缺少映射接口时报 `E_USD_RUNTIME_VERSION`,不会静默展示丢失引用的场景。MDL 模块(如 `OmniPBR.mdl`)不按同目录 HTTP 文件预取,现有材质映射与降级不变。
|
|
25
|
+
- 本次发布只更新 Viewer;`@nebula-spatial/cad-loader` 和私有 `scene-runtime` 版本不变。
|
|
26
|
+
|
|
5
27
|
## 0.5.1
|
|
6
28
|
|
|
7
29
|
### Changed
|
package/README.md
CHANGED
|
@@ -320,7 +320,27 @@ const preview = viewer.openAsset('https://cdn.example.com/robot/scene.xml', {
|
|
|
320
320
|
await preview.ready;
|
|
321
321
|
```
|
|
322
322
|
|
|
323
|
-
|
|
323
|
+
USD 默认使用 `usdExternalReferenceMode: 'package'`(资产包模式):URL 入口以同 origin 的入口目录
|
|
324
|
+
及其子目录为包边界;本地输入以实际选中的文件集合为边界,已选中的 `../shared.usda` 也属于包内。
|
|
325
|
+
未选中的本地依赖、跨 origin 和远端目录之外的资源不请求,报告 `USD_EXTERNAL_REFERENCE_SKIPPED`,
|
|
326
|
+
其它包内内容继续显示。远端包内缺失资源、resolver 拒绝和解析失败仍按加载失败处理,不做 catch-all 降级。
|
|
327
|
+
|
|
328
|
+
需要组合外部环境等场景依赖时,显式开启完整模式:
|
|
329
|
+
|
|
330
|
+
```ts
|
|
331
|
+
const preview = viewer.openAsset('https://cdn.example.com/robot/scene.usd', {
|
|
332
|
+
format: 'usd',
|
|
333
|
+
usdExternalReferenceMode: 'complete',
|
|
334
|
+
});
|
|
335
|
+
await preview.ready;
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
完整模式**没有** `resourceResolver` 时直接尝试浏览器可访问的 HTTP(S) 引用,不要求额外的宿主授权
|
|
339
|
+
开关;仍受 CORS、鉴权、网络、依赖数量和深度限制。**提供了** resolver 时,它拥有最终决定权,
|
|
340
|
+
所有不在本地包内的资源必须经它解析;拒绝、401/403 或请求失败不会回退为直连。
|
|
341
|
+
切换模式需要重新调用 `openAsset()`;不会在已组合的 stage 上只隐藏或显示环境。
|
|
342
|
+
|
|
343
|
+
Viewer 不枚举 CDN 目录。远端目录型资产应传实际入口文件 URL,保持服务器上的相对目录结构;
|
|
324
344
|
需要签名 URL、私有鉴权或路径重写时,通过 `resourceResolver` 映射入口文件引用的子资源:
|
|
325
345
|
|
|
326
346
|
```ts
|
|
@@ -344,9 +364,36 @@ USDZ 是自包含 ZIP 包。包内 layer、mesh 和纹理由 Viewer 从包内读
|
|
|
344
364
|
原样拼接到其他路径。`resourceResolver.resolve(path)` 必须为每个 `path` 返回独立有效的签名 URL
|
|
345
365
|
或已经取得的 `Blob`;入口 URL 自身也必须仍在有效期内。USD loader 会先提取分层 USD 的外部
|
|
346
366
|
引用,再通过该 resolver 递归取得 layer、mesh、material 和 texture 资源;任一依赖返回 401/403
|
|
347
|
-
都会作为鉴权加载失败报告,不会进入视觉降级流程。
|
|
348
|
-
|
|
349
|
-
|
|
367
|
+
都会作为鉴权加载失败报告,不会进入视觉降级流程。
|
|
368
|
+
|
|
369
|
+
USD 的相对引用传给 resolver 时以入口目录为基准,保留必要的 `../`,嵌套 layer 的引用也会
|
|
370
|
+
换算到同一基准。绝对 URL 引用保留完整 URL(包括域名与 query),不会裁剪成包内路径;
|
|
371
|
+
resolver 拒绝包外引用时不会改用直连请求绕过授权。文件包缓存也不会用同名本地文件替代外部 URL。
|
|
372
|
+
依赖发现对 File 和 URL 使用相同的模式策略,而不是按是否传入 resolver 决定是否开启。
|
|
373
|
+
资产包模式跳过包外依赖不代表资产自包含,也不表示所有原始场景内容已经加载;完整预览应选择
|
|
374
|
+
完整模式并提供合法可解析的依赖或完整文件包。
|
|
375
|
+
|
|
376
|
+
URL 依赖由浏览器直连或宿主 resolver 取得后,Viewer 使用 `usd_probe_stage_open_mapped` 在内存中的
|
|
377
|
+
Sdf Layer 上映射至 MEMFS 路径,再进行 composition;支持 USDA/USDC 的 references、payloads
|
|
378
|
+
和 subLayers,保留目标 Prim、layer offset 等原始语义。原文件不会被覆盖,每次加载独立目录,
|
|
379
|
+
关闭或失败时清理;查询参数和不同来源的同名资源不共用缓存。材质资源恢复为宿主标识供现有
|
|
380
|
+
视觉适配层消费,`OmniPBR.mdl` 等 MDL 模块不按同目录 HTTP 文件预取,现有材质映射与降级不变。
|
|
381
|
+
JS bundle、`openusd_probe.js` 和 `.wasm` 必须同步部署;旧运行时缺少映射接口时报
|
|
382
|
+
`E_USD_RUNTIME_VERSION`,不会静默展示丢失引用的场景。资源拒绝、401/403、读取失败或无效 layer
|
|
383
|
+
仍是加载失败,不通过空 Blob 或 catch-all 忽略。提供 resolver 的业务必须允许完整模式需要的合法
|
|
384
|
+
包外引用,Viewer 不绕过白名单。本次模式策略复用现有映射接口,不需要再次构建 OpenUSD WASM。
|
|
385
|
+
|
|
386
|
+
`playground/usd-url-resolver` 提供真实 HL_Robot_1 的 URL + resolver 验证;默认单测不访问外网。
|
|
387
|
+
页面分别选择加载模式和宿主策略,可对照资产包、完整直连、完整白名单及完整拒绝四种行为。
|
|
388
|
+
启动 `npm run dev:usd-url-resolver` 后,可在 PowerShell 单独启用真实模型集成测试:
|
|
389
|
+
|
|
390
|
+
```powershell
|
|
391
|
+
$env:USD_URL_INTEGRATION_ENTRY = 'http://127.0.0.1:8310/models/HL_Robot_1.usd'
|
|
392
|
+
npm test --workspace @nebula-spatial/viewer -- src/simulation/__tests__/usd-single-thread.test.ts
|
|
393
|
+
Remove-Item Env:USD_URL_INTEGRATION_ENTRY
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
`{ kind: 'files', files, entry }` 只表示浏览器已经持有的本地 `File | Blob` 文件包,不能把远端
|
|
350
397
|
URL 字符串放进 `files[].file`。业务层负责入口选择、必要的格式判断、鉴权和依赖映射;不能只依赖
|
|
351
398
|
Viewer 自动识别所有资产形态,也不能把本地样本验证等同于任意远端资产都兼容。普通 glTF 的外部资源仍由 GLTFLoader 按 URL 请求;FBX 外置纹理经过资源解析器,支持本地文件包与异步 resourceResolver。
|
|
352
399
|
|
package/dist/assets/types.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export interface AssetResourceResolver {
|
|
|
26
26
|
readonly signal?: AbortSignal;
|
|
27
27
|
}): string | URL | Blob | Promise<string | URL | Blob>;
|
|
28
28
|
}
|
|
29
|
+
/** Controls how USD references outside the entry package are handled. */
|
|
30
|
+
export type UsdExternalReferenceMode = 'package' | 'complete';
|
|
29
31
|
export interface ViewerAssetOptions {
|
|
30
32
|
readonly dracoDecoderPath?: string;
|
|
31
33
|
readonly openUsdBaseUrl?: string;
|
|
@@ -47,6 +49,13 @@ export interface OpenAssetOptions {
|
|
|
47
49
|
readonly baseUrl?: string;
|
|
48
50
|
/** Resolves package-external resources; local package entries take precedence. */
|
|
49
51
|
readonly resourceResolver?: AssetResourceResolver;
|
|
52
|
+
/**
|
|
53
|
+
* USD-only external reference policy. Defaults to `package`: compose the
|
|
54
|
+
* entry package and skip package-external references. `complete` attempts all
|
|
55
|
+
* browser-resolvable references; a supplied resourceResolver remains the
|
|
56
|
+
* authority and is never bypassed.
|
|
57
|
+
*/
|
|
58
|
+
readonly usdExternalReferenceMode?: UsdExternalReferenceMode;
|
|
50
59
|
/** @deprecated Auto detection never falls back to CAD; pass an explicit format instead. */
|
|
51
60
|
readonly unknownFormatPolicy?: 'cad' | 'error';
|
|
52
61
|
readonly dracoDecoderPath?: string;
|
|
@@ -8,7 +8,7 @@ import { OrbitControls as li } from "three/addons/controls/OrbitControls.js";
|
|
|
8
8
|
import { HDRLoader as di } from "three/addons/loaders/HDRLoader.js";
|
|
9
9
|
import { createCadDocumentSession as ci, getCadDocumentRenderResource as ui, formatCadInsertId as Ne } from "@nebula-spatial/cad-loader";
|
|
10
10
|
import { CSS2DObject as hi, CSS2DRenderer as pi } from "three/addons/renderers/CSS2DRenderer.js";
|
|
11
|
-
const fi = "0.5.
|
|
11
|
+
const fi = "0.5.2", mi = "@nebula-spatial/viewer", Fe = "__NEBULA_SPATIAL_VIEWER_BANNER_PRINTED__";
|
|
12
12
|
function Ve() {
|
|
13
13
|
const s = `%c ${mi} %c v${fi} `;
|
|
14
14
|
console.log(s, "background:#111827;color:#ffffff;padding:4px 10px;border-radius:4px 0 0 4px;font-weight:700;", "background:#10B981;color:#ffffff;padding:4px 10px;border-radius:0 4px 4px 0;font-weight:700;");
|
|
@@ -7021,7 +7021,7 @@ const gn = {
|
|
|
7021
7021
|
clearColor: q.dark
|
|
7022
7022
|
},
|
|
7023
7023
|
async createSession(e, t) {
|
|
7024
|
-
const { createModelSession: i } = await import("./session-
|
|
7024
|
+
const { createModelSession: i } = await import("./session-CVL_PXO4.js");
|
|
7025
7025
|
return i(e, t);
|
|
7026
7026
|
}
|
|
7027
7027
|
});
|
|
@@ -7105,7 +7105,7 @@ const Cn = {
|
|
|
7105
7105
|
clearColor: q.dark
|
|
7106
7106
|
},
|
|
7107
7107
|
async createSession(e, t) {
|
|
7108
|
-
const { createSimulationSession: i } = await import("./session-
|
|
7108
|
+
const { createSimulationSession: i } = await import("./session-2sDMfyTY.js").then((r) => r.f);
|
|
7109
7109
|
return i(e, t);
|
|
7110
7110
|
}
|
|
7111
7111
|
});
|
|
@@ -7847,7 +7847,7 @@ class Mn {
|
|
|
7847
7847
|
applyCameraSnapshot(e, t) {
|
|
7848
7848
|
if (!Ie(e)) return !1;
|
|
7849
7849
|
const i = this.runtime.viewMode;
|
|
7850
|
-
return this.runtime.applyCameraSnapshot(e) ? (this.runtime.viewMode !== i && this.emit("view-mode-change", { viewMode: this.runtime.viewMode }), this.pendingCameraReason = t, this.cadCapability.onCameraChanged(t), this.refreshCadPointerHover(), !0) : !1;
|
|
7850
|
+
return this.runtime.applyCameraSnapshot(e) ? (this.runtime.resize(), this.runtime.viewMode !== i && this.emit("view-mode-change", { viewMode: this.runtime.viewMode }), this.pendingCameraReason = t, this.cadCapability.onCameraChanged(t), this.refreshCadPointerHover(), !0) : !1;
|
|
7851
7851
|
}
|
|
7852
7852
|
detectCameraChange(e = !1) {
|
|
7853
7853
|
const t = xe(this.runtime.captureCameraSnapshot());
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import './version';
|
|
|
2
2
|
export { viewerVersion } from './version';
|
|
3
3
|
export type { ViewerSceneUiOptions, ViewerSceneUiParts } from './ui/types';
|
|
4
4
|
export { createViewer } from './viewer';
|
|
5
|
-
export type { AssetChangeEvent, AssetControlState, AssetControlChangeEvent, AssetDetectionResult, AssetErrorEvent, AssetErrorSnapshot, AssetFileEntry, AssetFormat, AssetLoaderContext, AssetLoaderContribution, AssetPhysicsState, AssetPresentationProfile, AssetPreview, AssetPreviewCapabilities, AssetPreviewKind, AssetPreviewPhase, AssetPreviewSnapshot, AssetResourceResolver, AssetSession, AssetSingleSource, AssetSource, AssetUpAxis, NormalizedAssetSource, OpenAssetOptions, ViewerAssetOptions, } from './assets/types';
|
|
5
|
+
export type { AssetChangeEvent, AssetControlState, AssetControlChangeEvent, AssetDetectionResult, AssetErrorEvent, AssetErrorSnapshot, AssetFileEntry, AssetFormat, AssetLoaderContext, AssetLoaderContribution, AssetPhysicsState, AssetPresentationProfile, AssetPreview, AssetPreviewCapabilities, AssetPreviewKind, AssetPreviewPhase, AssetPreviewSnapshot, AssetResourceResolver, AssetSession, AssetSingleSource, AssetSource, AssetUpAxis, NormalizedAssetSource, OpenAssetOptions, UsdExternalReferenceMode, ViewerAssetOptions, } from './assets/types';
|
|
6
6
|
export type { Disposable, ToolbarItem, ViewerState, ViewerInteractionHooks, ViewerContributionPoint, ViewerPlugin, ViewerPluginContext, ViewerPluginRegistry, } from './plugins';
|
|
7
7
|
export { configureViewerText } from './cad/text';
|
|
8
8
|
export type { ViewerTextBuilderOptions } from './cad/text';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { e as v, s as E } from "./session-
|
|
1
|
+
import { e as v, s as E } from "./session-2sDMfyTY.js";
|
|
2
2
|
import { Group as q, Euler as z, BoxGeometry as G, SphereGeometry as N, CylinderGeometry as P, CapsuleGeometry as $, PlaneGeometry as I, Mesh as X } from "three";
|
|
3
|
-
import { b as j } from "./stage-
|
|
3
|
+
import { b as j } from "./stage-BrKWuPMa.js";
|
|
4
4
|
function U(f) {
|
|
5
5
|
const y = f.extension.documents, l = new q();
|
|
6
6
|
l.name = f.name;
|