@nebula-spatial/viewer 0.4.0 → 0.4.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 +12 -0
- package/README.md +23 -17
- package/dist/assets/types.d.ts +6 -5
- package/dist/{index-Lsk3kHNe.js → index-C9CW-EyW.js} +3 -3
- package/dist/index.js +1 -1
- package/dist/{session-B_UiRctl.js → session-B-qVl3Yy.js} +162 -163
- package/dist/session-B2SfkK9o.js +266 -0
- package/dist/{stage-BxROW_dP.js → stage-D-Q_zul6.js} +1 -1
- package/dist/{usd-session-Dcd20Z6G.js → usd-session-DCuV_H-Y.js} +191 -175
- package/package.json +57 -57
- package/dist/session-CGaj14lM.js +0 -93
package/package.json
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@nebula-spatial/viewer",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"description": "Read-only Three.js viewer facade",
|
|
5
|
-
"license": "ISC",
|
|
6
|
-
"engines": {
|
|
7
|
-
"node": ">=18"
|
|
8
|
-
},
|
|
9
|
-
"type": "module",
|
|
10
|
-
"files": [
|
|
11
|
-
"dist",
|
|
12
|
-
"README.md",
|
|
13
|
-
"CHANGELOG.md",
|
|
14
|
-
"package.json"
|
|
15
|
-
],
|
|
16
|
-
"main": "./dist/index.js",
|
|
17
|
-
"module": "./dist/index.js",
|
|
18
|
-
"types": "./dist/index.d.ts",
|
|
19
|
-
"exports": {
|
|
20
|
-
".": {
|
|
21
|
-
"types": "./dist/index.d.ts",
|
|
22
|
-
"import": "./dist/index.js",
|
|
23
|
-
"default": "./dist/index.js"
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"sideEffects": false,
|
|
27
|
-
"scripts": {
|
|
28
|
-
"build": "npm run check:boundary && npm run typecheck && npm run build:bundle && npm run build:types && npm run check:dist",
|
|
29
|
-
"build:bundle": "vite build --config vite.config.ts",
|
|
30
|
-
"build:types": "tsc --project tsconfig.build.json && node scripts/prune-dist-types.mjs",
|
|
31
|
-
"check:boundary": "node scripts/check-boundary.mjs",
|
|
32
|
-
"check:dist": "node scripts/check-dist.mjs",
|
|
33
|
-
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
34
|
-
"test": "vitest run --config vitest.config.ts",
|
|
35
|
-
"pack:dry": "npm pack --dry-run",
|
|
36
|
-
"prepack": "npm run build"
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@mujoco/mujoco": "^3.12.0",
|
|
40
|
-
"@nebula-spatial/cad-loader": "^0.3.0",
|
|
41
|
-
"@openusd-wasm/pxr": "0.0.13",
|
|
42
|
-
"@openusd-wasm/three-loader": "^0.0.13"
|
|
43
|
-
},
|
|
44
|
-
"peerDependencies": {
|
|
45
|
-
"three": "0.182.0"
|
|
46
|
-
},
|
|
47
|
-
"devDependencies": {
|
|
48
|
-
"@types/jsdom": "^27.0.0",
|
|
49
|
-
"@types/node": "^25.6.0",
|
|
50
|
-
"@types/three": "0.182.0",
|
|
51
|
-
"jsdom": "^29.0.2",
|
|
52
|
-
"three": "0.182.0",
|
|
53
|
-
"typescript": "^5.6.3",
|
|
54
|
-
"vite": "^5.4.10",
|
|
55
|
-
"vitest": "^2.1.8"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@nebula-spatial/viewer",
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"description": "Read-only Three.js viewer facade",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=18"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md",
|
|
13
|
+
"CHANGELOG.md",
|
|
14
|
+
"package.json"
|
|
15
|
+
],
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"module": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "npm run check:boundary && npm run typecheck && npm run build:bundle && npm run build:types && npm run check:dist",
|
|
29
|
+
"build:bundle": "vite build --config vite.config.ts",
|
|
30
|
+
"build:types": "tsc --project tsconfig.build.json && node scripts/prune-dist-types.mjs",
|
|
31
|
+
"check:boundary": "node scripts/check-boundary.mjs",
|
|
32
|
+
"check:dist": "node scripts/check-dist.mjs",
|
|
33
|
+
"typecheck": "tsc --project tsconfig.json --noEmit",
|
|
34
|
+
"test": "vitest run --config vitest.config.ts",
|
|
35
|
+
"pack:dry": "npm pack --dry-run",
|
|
36
|
+
"prepack": "npm run build"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@mujoco/mujoco": "^3.12.0",
|
|
40
|
+
"@nebula-spatial/cad-loader": "^0.3.0",
|
|
41
|
+
"@openusd-wasm/pxr": "0.0.13",
|
|
42
|
+
"@openusd-wasm/three-loader": "^0.0.13"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"three": "0.182.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/jsdom": "^27.0.0",
|
|
49
|
+
"@types/node": "^25.6.0",
|
|
50
|
+
"@types/three": "0.182.0",
|
|
51
|
+
"jsdom": "^29.0.2",
|
|
52
|
+
"three": "0.182.0",
|
|
53
|
+
"typescript": "^5.6.3",
|
|
54
|
+
"vite": "^5.4.10",
|
|
55
|
+
"vitest": "^2.1.8"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/dist/session-CGaj14lM.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { Quaternion as y, Vector3 as M, Group as P, Box3 as T } from "three";
|
|
2
|
-
import { DRACOLoader as x } from "three/examples/jsm/loaders/DRACOLoader.js";
|
|
3
|
-
import { GLTFLoader as D } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
4
|
-
import { S as E, d as w } from "./stage-BxROW_dP.js";
|
|
5
|
-
const G = new y().setFromAxisAngle(new M(1, 0, 0), Math.PI / 2), R = new y();
|
|
6
|
-
function S(r) {
|
|
7
|
-
return r === "y" ? G : R;
|
|
8
|
-
}
|
|
9
|
-
function b(r, n) {
|
|
10
|
-
const t = S(n);
|
|
11
|
-
return t.equals(r.quaternion) ? !1 : (r.quaternion.copy(t), r.updateMatrixWorld(!0), !0);
|
|
12
|
-
}
|
|
13
|
-
function z(r, n) {
|
|
14
|
-
let t = !1, i = null, e = null, d = "z", f;
|
|
15
|
-
const l = new x(), p = new D(), m = () => {
|
|
16
|
-
t = !0;
|
|
17
|
-
}, a = (async () => {
|
|
18
|
-
d = n.options.upAxis ?? "z", n.options.dracoDecoderPath && l.setDecoderPath(n.options.dracoDecoderPath), p.setDRACOLoader(l);
|
|
19
|
-
let o = null;
|
|
20
|
-
try {
|
|
21
|
-
if (t || n.signal.aborted) throw h();
|
|
22
|
-
const s = await p.loadAsync(r.url ?? await r.resolve(r.entryPath ?? ""));
|
|
23
|
-
o = new P(), o.name = "viewer-model-root";
|
|
24
|
-
const u = s.scenes.filter((c) => c !== s.scene);
|
|
25
|
-
if (o.add(s.scene), t || n.signal.aborted) {
|
|
26
|
-
for (const c of u) o.add(c);
|
|
27
|
-
throw h();
|
|
28
|
-
}
|
|
29
|
-
b(o, d), g(o);
|
|
30
|
-
const A = new E(o, n.options.simulationTheme, void 0, "model");
|
|
31
|
-
i = o, e = A, o = null;
|
|
32
|
-
} finally {
|
|
33
|
-
o && w(o), l.dispose();
|
|
34
|
-
}
|
|
35
|
-
})();
|
|
36
|
-
return a.catch(() => {
|
|
37
|
-
}), {
|
|
38
|
-
id: `model-${Math.random().toString(36).slice(2)}`,
|
|
39
|
-
opened: a,
|
|
40
|
-
get root() {
|
|
41
|
-
return (e == null ? void 0 : e.root) ?? null;
|
|
42
|
-
},
|
|
43
|
-
getFitBounds() {
|
|
44
|
-
return (e == null ? void 0 : e.getModelBounds()) ?? null;
|
|
45
|
-
},
|
|
46
|
-
beforeRender(o, s, u) {
|
|
47
|
-
return e == null ? void 0 : e.beforeRender(o, s, u);
|
|
48
|
-
},
|
|
49
|
-
capabilities: { canPlay: !1, canPause: !1, canReset: !1, hasPhysics: !1, canReorientUpAxis: !0, canToggleGround: !0 },
|
|
50
|
-
// Session presentation overrides are only consulted for `interactionMode`
|
|
51
|
-
// and `fitPolicy`; the UI group comes from the loader descriptor. Keep the
|
|
52
|
-
// two in sync so the override never reads as a contradictory value.
|
|
53
|
-
presentation: { preferredViewMode: "3d", interactionMode: "object", uiProfile: "model", fitPolicy: "fit-on-ready" },
|
|
54
|
-
getUpAxis() {
|
|
55
|
-
return i ? d : null;
|
|
56
|
-
},
|
|
57
|
-
setTheme(o) {
|
|
58
|
-
e == null || e.setTheme(o);
|
|
59
|
-
},
|
|
60
|
-
setGroundVisible(o) {
|
|
61
|
-
e == null || e.setGroundVisible(o);
|
|
62
|
-
},
|
|
63
|
-
getGroundVisible() {
|
|
64
|
-
return (e == null ? void 0 : e.getGroundVisible()) ?? !0;
|
|
65
|
-
},
|
|
66
|
-
setUpAxis(o) {
|
|
67
|
-
if (t || !i || !e || !b(i, o)) return;
|
|
68
|
-
d = o, e.reseatGround();
|
|
69
|
-
const s = e.getModelBounds();
|
|
70
|
-
n.requestRender(), n.fit(s, { padding: 1.15 });
|
|
71
|
-
},
|
|
72
|
-
beginDispose: m,
|
|
73
|
-
dispose() {
|
|
74
|
-
return m(), f ?? (f = a.catch(() => {
|
|
75
|
-
}).then(() => {
|
|
76
|
-
e == null || e.dispose(), e = null, i && w(i), i = null;
|
|
77
|
-
})), f;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function g(r) {
|
|
82
|
-
r.updateMatrixWorld(!0);
|
|
83
|
-
const n = new T().setFromObject(r);
|
|
84
|
-
if (n.isEmpty()) throw new Error("模型不包含可显示的几何内容。");
|
|
85
|
-
const t = n.getSize(new M()), i = Math.max(t.x, t.y, t.z);
|
|
86
|
-
if (!Number.isFinite(i) || i <= 0) throw new Error("模型尺寸无效。");
|
|
87
|
-
}
|
|
88
|
-
function h() {
|
|
89
|
-
return Object.assign(new Error("Model load aborted."), { name: "AbortError", code: "E_ABORTED" });
|
|
90
|
-
}
|
|
91
|
-
export {
|
|
92
|
-
z as createModelSession
|
|
93
|
-
};
|