@nebula-spatial/viewer 0.5.17 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +63 -22
  2. package/USD-VISUAL-MATERIAL-SUPPORT.md +5 -1
  3. package/dist/asset-ir-BEDGD9CL.js +637 -0
  4. package/dist/assets/source-types.d.ts +10 -0
  5. package/dist/assets/types.d.ts +59 -6
  6. package/dist/index-DoxM1Msk.js +17223 -0
  7. package/dist/index.d.ts +20 -1
  8. package/dist/index.js +29 -18
  9. package/dist/{mjcf-visual-C0PWP0vB.js → mjcf-visual-CQEeWkL_.js} +12 -13
  10. package/dist/mujoco-runtime-BmuEJ_ST.js +791 -0
  11. package/dist/physics-guide-size-CplAlsve.js +12 -0
  12. package/dist/scene/instances.d.ts +36 -0
  13. package/dist/scene/joints.d.ts +129 -0
  14. package/dist/scene/session.d.ts +26 -0
  15. package/dist/scene/types.d.ts +284 -0
  16. package/dist/session-BnNntPUE.js +9169 -0
  17. package/dist/{session-D44z2smp.js → session-Cz4tFSlO.js} +6 -8
  18. package/dist/session-sBOJEWpK.js +559 -0
  19. package/dist/simulation/physics-runtime-state.d.ts +73 -0
  20. package/dist/simulation/types.d.ts +151 -0
  21. package/dist/simulation/usd-dependency-probe.d.ts +42 -0
  22. package/dist/simulation/usd-inspection.d.ts +66 -0
  23. package/dist/types.d.ts +46 -1
  24. package/dist/ui/camera-axis-gizmo.d.ts +5 -0
  25. package/dist/urdf-session-HKelZnMM.js +1230 -0
  26. package/dist/usd-session-Cn6whyh4.js +10875 -0
  27. package/dist/version.d.ts +1 -1
  28. package/dist/visual/classification.d.ts +20 -0
  29. package/dist/{xacro-CjMp9HT5.js → xacro-Cl7vUCSC.js} +1 -1
  30. package/package.json +2 -1
  31. package/runtime-assets.d.mts +9 -9
  32. package/runtime-assets.mjs +11 -11
  33. package/vite.d.mts +7 -7
  34. package/vite.mjs +115 -115
  35. package/dist/collision-debug-CHPrPNT3.js +0 -2947
  36. package/dist/index-cM9KArXm.js +0 -11499
  37. package/dist/mujoco-runtime-BV2xR38M.js +0 -739
  38. package/dist/resources-CHhCm2f7.js +0 -27
  39. package/dist/session-CKva1mAh.js +0 -801
  40. package/dist/stage-pxmOnL0U.js +0 -592
  41. package/dist/urdf-session-ChpRmt69.js +0 -1264
  42. package/dist/usd-session-auH_xmOc.js +0 -10526
package/dist/version.d.ts CHANGED
@@ -2,4 +2,4 @@
2
2
  * Viewer 版本号。必须与 package.json 的 version 保持一致,
3
3
  * check-boundary 脚本会在构建前校验两者是否漂移。
4
4
  */
5
- export declare const viewerVersion = "0.5.17";
5
+ export declare const viewerVersion = "0.6.0";
@@ -0,0 +1,20 @@
1
+ export type PlyContentKind = 'ply-mesh' | 'ply-point-cloud' | 'gaussian-ply' | 'unsupported';
2
+ export type VisualContentKind = PlyContentKind | 'glb' | 'gltf' | 'gaussian-spz' | 'gaussian-splat' | 'gaussian-ksplat' | 'gaussian-sog' | 'gaussian-rad' | 'unsupported';
3
+ export interface PlyHeader {
4
+ readonly format: string | null;
5
+ readonly vertexCount: number;
6
+ readonly faceCount: number;
7
+ readonly properties: readonly string[];
8
+ readonly elements: readonly string[];
9
+ }
10
+ export interface VisualContentDetection {
11
+ readonly kind: VisualContentKind;
12
+ readonly reason: string;
13
+ readonly ply?: PlyHeader;
14
+ }
15
+ /**
16
+ * Content-first PLY dispatch. A face element always wins, while Gaussian
17
+ * property names are checked before ordinary point-cloud fields.
18
+ */
19
+ export declare function detectPlyContent(input: Uint8Array | ArrayBuffer): VisualContentDetection;
20
+ export declare function detectVisualContent(bytes: Uint8Array, filename: string | null, formatHint?: string | null): VisualContentDetection;
@@ -1,4 +1,4 @@
1
- import { n as bt } from "./collision-debug-CHPrPNT3.js";
1
+ import { n as bt } from "./asset-ir-BEDGD9CL.js";
2
2
  function _t(t) {
3
3
  const e = t.split(/[\\/]/g);
4
4
  return e.pop(), e.length === 0 ? "./" : e.join("/") + "/";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nebula-spatial/viewer",
3
- "version": "0.5.17",
3
+ "version": "0.6.0",
4
4
  "description": "Read-only Three.js viewer facade",
5
5
  "license": "ISC",
6
6
  "engines": {
@@ -66,6 +66,7 @@
66
66
  "@mujoco/mujoco": "^3.12.0",
67
67
  "@nebula-spatial/cad-loader": "^0.3.1",
68
68
  "@openusd-wasm/three-loader": "^0.0.13",
69
+ "@sparkjsdev/spark": "^2.4.0",
69
70
  "three-mesh-bvh": "^0.9.5",
70
71
  "xacro-parser": "0.3.11"
71
72
  },
@@ -1,9 +1,9 @@
1
- export declare const viewerRuntimeAssetDirectories: Readonly<{
2
- basis: string;
3
- draco: string;
4
- }>;
5
-
6
- export declare const viewerRuntimeAssetUrls: Readonly<{
7
- openUsdModuleUrl: string;
8
- openUsdWasmUrl: string;
9
- }>;
1
+ export declare const viewerRuntimeAssetDirectories: Readonly<{
2
+ basis: string;
3
+ draco: string;
4
+ }>;
5
+
6
+ export declare const viewerRuntimeAssetUrls: Readonly<{
7
+ openUsdModuleUrl: string;
8
+ openUsdWasmUrl: string;
9
+ }>;
@@ -1,11 +1,11 @@
1
- /** Fallback directories used when the host does not install the Viewer Vite plugin. */
2
- export const viewerRuntimeAssetDirectories = Object.freeze({
3
- basis: 'basis/',
4
- draco: 'draco/',
5
- });
6
-
7
- /** Fallback OpenUSD URLs used outside Vite or without the Viewer Vite plugin. */
8
- export const viewerRuntimeAssetUrls = Object.freeze({
9
- openUsdModuleUrl: '/openusd/openusd_probe.js',
10
- openUsdWasmUrl: '/openusd/openusd_probe.wasm',
11
- });
1
+ /** Fallback directories used when the host does not install the Viewer Vite plugin. */
2
+ export const viewerRuntimeAssetDirectories = Object.freeze({
3
+ basis: 'basis/',
4
+ draco: 'draco/',
5
+ });
6
+
7
+ /** Fallback OpenUSD URLs used outside Vite or without the Viewer Vite plugin. */
8
+ export const viewerRuntimeAssetUrls = Object.freeze({
9
+ openUsdModuleUrl: '/openusd/openusd_probe.js',
10
+ openUsdWasmUrl: '/openusd/openusd_probe.wasm',
11
+ });
package/vite.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import type { Plugin } from 'vite';
2
-
3
- /**
4
- * Serves the Viewer's Basis and Draco runtime files with stable filenames in
5
- * development and copies them into each production build.
6
- */
7
- export declare function viewerRuntimeAssets(): Plugin;
1
+ import type { Plugin } from 'vite';
2
+
3
+ /**
4
+ * Serves the Viewer's Basis and Draco runtime files with stable filenames in
5
+ * development and copies them into each production build.
6
+ */
7
+ export declare function viewerRuntimeAssets(): Plugin;
package/vite.mjs CHANGED
@@ -1,115 +1,115 @@
1
- import { readFileSync } from 'node:fs';
2
- import { extname, join } from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
-
5
- const runtimeDirectories = Object.freeze([
6
- {
7
- name: 'basis',
8
- root: fileURLToPath(new URL('./basis/', import.meta.url)),
9
- files: ['basis_transcoder.js', 'basis_transcoder.wasm'],
10
- },
11
- {
12
- name: 'draco',
13
- root: fileURLToPath(new URL('./draco/', import.meta.url)),
14
- files: ['draco_wasm_wrapper.js', 'draco_decoder.wasm'],
15
- },
16
- ]);
17
-
18
- const contentTypes = new Map([
19
- ['.js', 'text/javascript; charset=utf-8'],
20
- ['.wasm', 'application/wasm'],
21
- ]);
22
- const runtimeAssetSpecifier = '@nebula-spatial/viewer/runtime-assets';
23
- const runtimeAssetVirtualId = '\0nebula-spatial-viewer-runtime-assets';
24
-
25
- function normalizeBase(base) {
26
- if (!base || base === './' || base === '.') return '/';
27
- const pathname = /^[a-z]+:\/\//i.test(base) ? new URL(base).pathname : base;
28
- const rooted = pathname.startsWith('/') ? pathname : `/${pathname}`;
29
- return rooted.endsWith('/') ? rooted : `${rooted}/`;
30
- }
31
-
32
- function runtimeAssets() {
33
- return runtimeDirectories.flatMap((directory) => directory.files.map((file) => ({
34
- directory: directory.name,
35
- file,
36
- path: join(directory.root, file),
37
- })));
38
- }
39
-
40
- /**
41
- * Serves the Viewer's Basis and Draco runtime files with stable filenames in
42
- * development and copies them into each production build.
43
- */
44
- export function viewerRuntimeAssets() {
45
- let base = '/';
46
-
47
- return {
48
- name: 'nebula-spatial-viewer-runtime-assets',
49
- enforce: 'pre',
50
- configResolved(config) {
51
- base = normalizeBase(config.base);
52
- },
53
- resolveId(id) {
54
- return id === runtimeAssetSpecifier ? runtimeAssetVirtualId : null;
55
- },
56
- load(id) {
57
- if (id !== runtimeAssetVirtualId) return null;
58
- return [
59
- "import openUsdModuleUrl from '@nebula-spatial/viewer/openusd/openusd_probe.js?url';",
60
- "import openUsdWasmUrl from '@nebula-spatial/viewer/openusd/openusd_probe.wasm?url';",
61
- `export const viewerRuntimeAssetDirectories = Object.freeze(${JSON.stringify({
62
- basis: `${base}basis/`,
63
- draco: `${base}draco/`,
64
- })});`,
65
- 'export const viewerRuntimeAssetUrls = Object.freeze({ openUsdModuleUrl, openUsdWasmUrl });',
66
- '',
67
- ].join('\n');
68
- },
69
- buildStart() {
70
- for (const asset of runtimeAssets()) {
71
- // Read eagerly so a broken package fails at build start, not midway.
72
- readFileSync(asset.path);
73
- }
74
- },
75
- configureServer(server) {
76
- server.middlewares.use((request, response, next) => {
77
- if (request.method !== 'GET' && request.method !== 'HEAD') {
78
- next();
79
- return;
80
- }
81
- let pathname;
82
- try {
83
- pathname = decodeURIComponent(new URL(request.url ?? '/', 'http://viewer.invalid').pathname);
84
- } catch {
85
- next();
86
- return;
87
- }
88
- const asset = runtimeAssets().find(({ directory, file }) => (
89
- pathname === `${base}${directory}/${file}`
90
- || pathname.endsWith(`/${directory}/${file}`)
91
- ));
92
- if (!asset) {
93
- next();
94
- return;
95
- }
96
- const bytes = readFileSync(asset.path);
97
- response.statusCode = 200;
98
- response.setHeader('Content-Type', contentTypes.get(extname(asset.file)) ?? 'application/octet-stream');
99
- response.setHeader('Cache-Control', 'no-cache');
100
- response.setHeader('Content-Length', bytes.byteLength);
101
- if (request.method === 'HEAD') response.end();
102
- else response.end(bytes);
103
- });
104
- },
105
- generateBundle() {
106
- for (const asset of runtimeAssets()) {
107
- this.emitFile({
108
- type: 'asset',
109
- fileName: `${asset.directory}/${asset.file}`,
110
- source: readFileSync(asset.path),
111
- });
112
- }
113
- },
114
- };
115
- }
1
+ import { readFileSync } from 'node:fs';
2
+ import { extname, join } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const runtimeDirectories = Object.freeze([
6
+ {
7
+ name: 'basis',
8
+ root: fileURLToPath(new URL('./basis/', import.meta.url)),
9
+ files: ['basis_transcoder.js', 'basis_transcoder.wasm'],
10
+ },
11
+ {
12
+ name: 'draco',
13
+ root: fileURLToPath(new URL('./draco/', import.meta.url)),
14
+ files: ['draco_wasm_wrapper.js', 'draco_decoder.wasm'],
15
+ },
16
+ ]);
17
+
18
+ const contentTypes = new Map([
19
+ ['.js', 'text/javascript; charset=utf-8'],
20
+ ['.wasm', 'application/wasm'],
21
+ ]);
22
+ const runtimeAssetSpecifier = '@nebula-spatial/viewer/runtime-assets';
23
+ const runtimeAssetVirtualId = '\0nebula-spatial-viewer-runtime-assets';
24
+
25
+ function normalizeBase(base) {
26
+ if (!base || base === './' || base === '.') return '/';
27
+ const pathname = /^[a-z]+:\/\//i.test(base) ? new URL(base).pathname : base;
28
+ const rooted = pathname.startsWith('/') ? pathname : `/${pathname}`;
29
+ return rooted.endsWith('/') ? rooted : `${rooted}/`;
30
+ }
31
+
32
+ function runtimeAssets() {
33
+ return runtimeDirectories.flatMap((directory) => directory.files.map((file) => ({
34
+ directory: directory.name,
35
+ file,
36
+ path: join(directory.root, file),
37
+ })));
38
+ }
39
+
40
+ /**
41
+ * Serves the Viewer's Basis and Draco runtime files with stable filenames in
42
+ * development and copies them into each production build.
43
+ */
44
+ export function viewerRuntimeAssets() {
45
+ let base = '/';
46
+
47
+ return {
48
+ name: 'nebula-spatial-viewer-runtime-assets',
49
+ enforce: 'pre',
50
+ configResolved(config) {
51
+ base = normalizeBase(config.base);
52
+ },
53
+ resolveId(id) {
54
+ return id === runtimeAssetSpecifier ? runtimeAssetVirtualId : null;
55
+ },
56
+ load(id) {
57
+ if (id !== runtimeAssetVirtualId) return null;
58
+ return [
59
+ "import openUsdModuleUrl from '@nebula-spatial/viewer/openusd/openusd_probe.js?url';",
60
+ "import openUsdWasmUrl from '@nebula-spatial/viewer/openusd/openusd_probe.wasm?url';",
61
+ `export const viewerRuntimeAssetDirectories = Object.freeze(${JSON.stringify({
62
+ basis: `${base}basis/`,
63
+ draco: `${base}draco/`,
64
+ })});`,
65
+ 'export const viewerRuntimeAssetUrls = Object.freeze({ openUsdModuleUrl, openUsdWasmUrl });',
66
+ '',
67
+ ].join('\n');
68
+ },
69
+ buildStart() {
70
+ for (const asset of runtimeAssets()) {
71
+ // Read eagerly so a broken package fails at build start, not midway.
72
+ readFileSync(asset.path);
73
+ }
74
+ },
75
+ configureServer(server) {
76
+ server.middlewares.use((request, response, next) => {
77
+ if (request.method !== 'GET' && request.method !== 'HEAD') {
78
+ next();
79
+ return;
80
+ }
81
+ let pathname;
82
+ try {
83
+ pathname = decodeURIComponent(new URL(request.url ?? '/', 'http://viewer.invalid').pathname);
84
+ } catch {
85
+ next();
86
+ return;
87
+ }
88
+ const asset = runtimeAssets().find(({ directory, file }) => (
89
+ pathname === `${base}${directory}/${file}`
90
+ || pathname.endsWith(`/${directory}/${file}`)
91
+ ));
92
+ if (!asset) {
93
+ next();
94
+ return;
95
+ }
96
+ const bytes = readFileSync(asset.path);
97
+ response.statusCode = 200;
98
+ response.setHeader('Content-Type', contentTypes.get(extname(asset.file)) ?? 'application/octet-stream');
99
+ response.setHeader('Cache-Control', 'no-cache');
100
+ response.setHeader('Content-Length', bytes.byteLength);
101
+ if (request.method === 'HEAD') response.end();
102
+ else response.end(bytes);
103
+ });
104
+ },
105
+ generateBundle() {
106
+ for (const asset of runtimeAssets()) {
107
+ this.emitFile({
108
+ type: 'asset',
109
+ fileName: `${asset.directory}/${asset.file}`,
110
+ source: readFileSync(asset.path),
111
+ });
112
+ }
113
+ },
114
+ };
115
+ }