dsh-3d-viewer 0.1.0 → 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.
package/README.md CHANGED
@@ -1,20 +1,25 @@
1
- # 3D Viewer
1
+ <div align="center">
2
+ <img src="https://raw.githubusercontent.com/ybniaobu/dsh-3d-viewer/main/assets/icon-180.png" alt="3D Viewer icon" width="96" height="96">
3
+ <h1 align="center">3D Viewer</h1>
4
+ </div>
2
5
 
3
- English | [中文](README.zh.md)
6
+ English | [中文](https://github.com/ybniaobu/dsh-3d-viewer/blob/main/README.zh.md)
7
+
8
+ [![GitHub](https://img.shields.io/badge/GitHub-ybniaobu-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/ybniaobu/dsh-3d-viewer) [![npm](https://img.shields.io/badge/npm-dsh--3d--viewer-CB3837?logo=npm&logoColor=white&style=flat-square)](https://www.npmjs.com/package/dsh-3d-viewer?activeTab=readme)
4
9
 
5
10
  Preview FBX, OBJ, glTF, GLB, and STL models from the current session's workspace in DSH's right sidebar. No uploads or network: open a model, orbit, zoom, switch materials and environments, and play embedded animations.
6
11
 
7
- ![3D Viewer preview](assets/preview.png)
12
+ ![3D Viewer preview](https://raw.githubusercontent.com/ybniaobu/dsh-3d-viewer/main/assets/preview.png)
8
13
 
9
14
  ## Installation and enabling
10
15
 
11
- Distributed as the npm package `dsh-3d-viewer`. The prebuilt `client.js` already bundles Three.js, the loaders, and four HDRIs; no Node.js or npm download is needed at runtime, and React comes from DSH.
16
+ Distributed as the npm package `dsh-3d-viewer`. The prebuilt `client.js` bundles Three.js and the loaders; the four HDRI files ship in the package and are served by a small read-only host route on the local DSH server, so no network access is needed at runtime. React comes from DSH.
12
17
 
13
18
  ### Install from npm (recommended)
14
19
 
15
20
  1. Open DSH Desktop and choose **Plugins** in the sidebar.
16
21
  2. Click **Add plugin** → **Install a third-party plugin**.
17
- 3. Enter `dsh-3d-viewer` (or `dsh-3d-viewer@0.1.0` to pin a version).
22
+ 3. Enter `dsh-3d-viewer` (or `dsh-3d-viewer@0.1.1` to pin a version).
18
23
  4. Set **Registry** to the official npm registry (npmmirror also works in mainland China).
19
24
  5. Click **Install**, then confirm **3D Viewer** is **On** under **Installed plugins**.
20
25
  6. Open a model from any session. If no preview appears, refresh the page; if it still does not, restart DSH.
@@ -25,7 +30,7 @@ Distributed as the npm package `dsh-3d-viewer`. The prebuilt `client.js` already
25
30
 
26
31
  Use this for offline or intranet distribution.
27
32
 
28
- 1. Unpack the plugin directory anywhere; it must contain `package.json`, `client.js`, `index.js`, and `cordis.patch.yml`.
33
+ 1. Unpack the plugin directory anywhere; it must contain `package.json`, `client.js`, `index.js`, `cordis.patch.yml`, and the `assets/hdri/` directory.
29
34
  2. Open DSH Desktop and choose **Plugins** in the sidebar.
30
35
  3. Click **Add plugin** → **Install a third-party plugin**.
31
36
  4. Enter the directory's absolute path (for example `F:\plugins\dsh-3d-viewer`) and click **Install**.
@@ -38,7 +43,7 @@ Use this for offline or intranet distribution.
38
43
 
39
44
  ### Requirements
40
45
 
41
- - DSH Desktop.
46
+ - DSH Desktop 0.2.2-rc.1 or newer (built and tested on 0.2.2-rc.1).
42
47
  - WebGL 2 support; otherwise the preview reports an error.
43
48
  - Model files in the session workspace, reachable through **Files** in the right sidebar.
44
49
 
@@ -60,6 +65,8 @@ Use this for offline or intranet distribution.
60
65
 
61
66
  External resources (FBX/glTF textures, glTF `.bin`, OBJ MTL and textures) are read from the session workspace.
62
67
 
68
+ The four environments are the exception: the HDRIs ship inside the plugin package, and the Host half serves them from the local DSH server on `/dsh-3d-viewer/hdri/`, so switching environments never touches the network.
69
+
63
70
  Notes:
64
71
 
65
72
  - **All formats**: lights, cameras, and audio embedded in the file are removed; the preview uses its own lighting and camera.
@@ -78,6 +85,7 @@ Notes:
78
85
 
79
86
  | Path | Responsibility |
80
87
  | --- | --- |
88
+ | `index.js` | Host half: registers the read-only `/dsh-3d-viewer/hdri/` route that serves the packaged HDRIs |
81
89
  | `src/client.js` | Plugin entry; registers document previews and Sidebar slots per format |
82
90
  | `src/formats.js` | Format registry: ids, extensions, title/badge keys, and format normalization |
83
91
  | `src/bytes.js` | Shared byte, text, path, MIME, and base64 helpers plus the cancellation error |
@@ -87,7 +95,7 @@ Notes:
87
95
  | `src/ui/chrome.js`, `icons.js`, `primitives.js` | Toolbar, data-driven material/environment popovers, stats panel, icons, and formatting |
88
96
  | `src/ui/styles.js`, `dictionaries.js`, `options.js` | Styles, English/Chinese copy, and UI options |
89
97
  | `src/scene/createSceneView.js` | Scene orchestration: renderer, camera, controls, lifecycle |
90
- | `src/scene/environment.js` | HDRI decoding, PMREM construction, and environment map caching |
98
+ | `src/scene/environment.js` | HDRI fetch from the host route, decode, PMREM construction, and per-id caching |
91
99
  | `src/scene/materials.js` | Phong/Lambert → PBR conversion, material presets, and wireframe material |
92
100
  | `src/scene/ground.js` | Infinite grid shader and shadow receiver; grid pixels are generated once per page |
93
101
  | `src/scene/animation.js` | AnimationMixer, clip timeline, and progress notifications |
@@ -97,11 +105,10 @@ Notes:
97
105
  | `src/loaders/gltf.js` | glTF/GLB external buffer/texture prefetch (deduplicated by resource), animation wiring, and cleanup |
98
106
  | `src/model.js` | Synchronous FBX / OBJ / STL parsing, stats, and resource disposal |
99
107
  | `src/vendor/FBXLoaderPbr.js` | Vendored Three.js FBXLoader with metalness/roughness custom-attribute support |
100
- | `src/generated/hdri-data.js` | Generated embedded HDRI data; do not edit by hand |
101
108
  | `tests/run.mjs` | Test entry; each `tests/*.mjs` runs in its own process |
102
109
  | `icon.svg` | Plugin icon; DSH metadata requires it at the package root |
103
- | `assets/hdri/` | HDRI source files |
110
+ | `assets/hdri/` | Packaged HDRI files served by the host route (Poly Haven CC0) |
104
111
 
105
112
  ## License
106
113
 
107
- MIT; see [LICENSE](LICENSE). Third-party notices are in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md), including Three.js (MIT) and Poly Haven HDRIs (CC0; see [assets/hdri/LICENSE.md](assets/hdri/LICENSE.md)). React is provided by DSH and is not distributed with this package.
114
+ MIT; see [LICENSE](https://github.com/ybniaobu/dsh-3d-viewer/blob/main/LICENSE). Third-party notices are in [THIRD_PARTY_NOTICES.md](https://github.com/ybniaobu/dsh-3d-viewer/blob/main/THIRD_PARTY_NOTICES.md), including Three.js (MIT) and Poly Haven HDRIs (CC0; see [assets/hdri/LICENSE.md](https://github.com/ybniaobu/dsh-3d-viewer/blob/main/assets/hdri/LICENSE.md)). React is provided by DSH and is not distributed with this package.
package/README.zh.md CHANGED
@@ -1,20 +1,25 @@
1
- # 3D Viewer
1
+ <div align="center">
2
+ <img src="https://raw.githubusercontent.com/ybniaobu/dsh-3d-viewer/main/assets/icon-180.png" alt="3D Viewer 图标" width="96" height="96">
3
+ <h1 align="center">3D Viewer</h1>
4
+ </div>
2
5
 
3
- [English](README.md) | 中文
6
+ [English](https://github.com/ybniaobu/dsh-3d-viewer/blob/main/README.md) | 中文
7
+
8
+ [![GitHub](https://img.shields.io/badge/GitHub-ybniaobu-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/ybniaobu/dsh-3d-viewer) [![npm](https://img.shields.io/badge/npm-dsh--3d--viewer-CB3837?logo=npm&logoColor=white&style=flat-square)](https://www.npmjs.com/package/dsh-3d-viewer?activeTab=readme)
4
9
 
5
10
  在 DSH 右侧边栏预览当前会话工作区里的 FBX、OBJ、glTF、GLB、STL 模型。无需上传或联网:打开模型即可旋转、缩放、切换材质与环境,并播放内置动画。
6
11
 
7
- ![3D Viewer 预览](assets/preview.png)
12
+ ![3D Viewer 预览](https://raw.githubusercontent.com/ybniaobu/dsh-3d-viewer/main/assets/preview.png)
8
13
 
9
14
  ## 安装与启用
10
15
 
11
- 插件通过 npm 包 `dsh-3d-viewer` 分发。包内 `client.js` 已打包 Three.js、各类 Loader 和四张 HDRI;运行时不需 Node.js 或 npm,React 由 DSH 提供。
16
+ 插件通过 npm 包 `dsh-3d-viewer` 分发。包内 `client.js` 已打包 Three.js 与各类 Loader;四张 HDRI 以文件形式随包分发,由一段只读的宿主路由从本机 DSH 服务器提供,运行时不需联网,也不需 Node.js 或 npm。React 由 DSH 提供。
12
17
 
13
18
  ### 从 npm 安装(推荐)
14
19
 
15
20
  1. 打开 DSH Desktop,点击侧边栏的 **Plugins(插件)**。
16
21
  2. 点击 **Add plugin(添加插件)** → **Install a third-party plugin(安装第三方插件)**。
17
- 3. 输入 `dsh-3d-viewer`;需要固定版本时写 `dsh-3d-viewer@0.1.0`。
22
+ 3. 输入 `dsh-3d-viewer`;需要固定版本时写 `dsh-3d-viewer@0.1.1`。
18
23
  4. **Registry** 选择 npm 官方源(国内也可用 npmmirror)。
19
24
  5. 点击 **Install**,在 **Installed plugins(已安装插件)** 中确认 **3D Viewer** 为 **On**。
20
25
  6. 回到会话打开模型。若没有出现预览,先刷新页面;仍未出现时重启 DSH。
@@ -25,7 +30,7 @@
25
30
 
26
31
  适合离线或内网分发。
27
32
 
28
- 1. 把插件目录解压到任意位置,目录需包含 `package.json`、`client.js`、`index.js`、`cordis.patch.yml`。
33
+ 1. 把插件目录解压到任意位置,目录需包含 `package.json`、`client.js`、`index.js`、`cordis.patch.yml` 和 `assets/hdri/` 目录。
29
34
  2. 打开 DSH Desktop,点击侧边栏的 **Plugins(插件)**。
30
35
  3. 点击 **Add plugin(添加插件)** → **Install a third-party plugin(安装第三方插件)**。
31
36
  4. 填入插件目录的绝对路径(例如 `F:\plugins\dsh-3d-viewer`),点击 **Install**。
@@ -38,7 +43,7 @@
38
43
 
39
44
  ### 运行要求
40
45
 
41
- - DSH Desktop。
46
+ - DSH Desktop 0.2.2-rc.1 或更高版本(在 0.2.2-rc.1 上构建和测试)。
42
47
  - 支持 WebGL 2,否则预览会报错。
43
48
  - 模型文件位于会话工作区内,可通过右侧边栏的 **Files** 打开。
44
49
 
@@ -60,6 +65,8 @@
60
65
 
61
66
  外部资源(FBX/glTF 贴图、glTF `.bin`、OBJ MTL 与贴图)均从会话工作区读取。
62
67
 
68
+ 四个环境是例外:HDRI 随插件包分发,由宿主端从本机 DSH 服务器的 `/dsh-3d-viewer/hdri/` 只读路由提供,切换环境不会联网。
69
+
63
70
  补充说明:
64
71
 
65
72
  - **所有格式**:文件自带的灯光、相机和音频节点会被移除,预览统一使用自己的灯光和相机。
@@ -78,6 +85,7 @@
78
85
 
79
86
  | 路径 | 职责 |
80
87
  | --- | --- |
88
+ | `index.js` | 宿主端:注册只读的 `/dsh-3d-viewer/hdri/` 路由,提供包内 HDRI 文件 |
81
89
  | `src/client.js` | 插件入口;按格式注册 document preview 与 Sidebar slot |
82
90
  | `src/formats.js` | 格式注册表:id、扩展名、标题/徽标文案和格式归一化 |
83
91
  | `src/bytes.js` | 共用的字节、文本、路径、MIME、base64 辅助函数与取消错误 |
@@ -87,7 +95,7 @@
87
95
  | `src/ui/chrome.js`、`icons.js`、`primitives.js` | 工具条、数据驱动的材质/环境弹层、统计面板、图标与格式化 |
88
96
  | `src/ui/styles.js`、`dictionaries.js`、`options.js` | 样式、中英文案和 UI 选项 |
89
97
  | `src/scene/createSceneView.js` | 场景编排:renderer、camera、controls、生命周期 |
90
- | `src/scene/environment.js` | HDRI 解码、PMREM 构建、环境贴图缓存 |
98
+ | `src/scene/environment.js` | 从宿主路由获取 HDRI、解码、构建 PMREM 并按 id 缓存 |
91
99
  | `src/scene/materials.js` | Phong/Lambert → PBR 转换、材质预设、线框材质 |
92
100
  | `src/scene/ground.js` | 无限网格 shader 与阴影接收面;网格像素图全页只生成一次 |
93
101
  | `src/scene/animation.js` | AnimationMixer、片段时间轴和进度通知 |
@@ -97,11 +105,10 @@
97
105
  | `src/loaders/gltf.js` | glTF/GLB 外部 buffer/贴图预取(按资源去重)、动画挂载和资源清理 |
98
106
  | `src/model.js` | FBX / OBJ / STL 同步解析、统计、资源释放 |
99
107
  | `src/vendor/FBXLoaderPbr.js` | vendored Three.js FBXLoader,额外读取金属度/粗糙度自定义属性 |
100
- | `src/generated/hdri-data.js` | 构建生成的内置 HDRI 数据,不要手改 |
101
108
  | `tests/run.mjs` | 测试入口:每个 `tests/*.mjs` 都在独立进程中运行 |
102
109
  | `icon.svg` | 插件图标;DSH 元信息要求它位于包根目录 |
103
- | `assets/hdri/` | HDRI 源文件 |
110
+ | `assets/hdri/` | 由宿主路由提供的 HDRI 文件(Poly Haven CC0) |
104
111
 
105
112
  ## 许可证
106
113
 
107
- MIT,见 [LICENSE](LICENSE)。第三方声明见 [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md),包括 Three.js(MIT)与 Poly Haven HDRI(CC0,见 [assets/hdri/LICENSE.md](assets/hdri/LICENSE.md))。React 由 DSH 提供,不随包分发。
114
+ MIT,见 [LICENSE](https://github.com/ybniaobu/dsh-3d-viewer/blob/main/LICENSE)。第三方声明见 [THIRD_PARTY_NOTICES.md](https://github.com/ybniaobu/dsh-3d-viewer/blob/main/THIRD_PARTY_NOTICES.md),包括 Three.js(MIT)与 Poly Haven HDRI(CC0,见 [assets/hdri/LICENSE.md](https://github.com/ybniaobu/dsh-3d-viewer/blob/main/assets/hdri/LICENSE.md))。React 由 DSH 提供,不随包分发。
@@ -43,7 +43,9 @@ THE SOFTWARE.
43
43
  [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/). CC0 requires no
44
44
  attribution; the source links and license note are kept in
45
45
  [assets/hdri/LICENSE.md](assets/hdri/LICENSE.md) for provenance.
46
- The HDRIs are embedded into `client.js` as base64 data URLs at build time.
46
+ The HDRIs ship as files in the package and are served at runtime by the
47
+ plugin's Host route (`/dsh-3d-viewer/hdri/`); they are not embedded in
48
+ `client.js`.
47
49
 
48
50
  ## React
49
51
 
@@ -12,5 +12,6 @@ provenance.
12
12
  | `indoor.hdr` | [Lythwood Room](https://polyhaven.com/a/lythwood_room) | `https://dl.polyhaven.org/file/ph-assets/HDRIs/hdr/1k/lythwood_room_1k.hdr` |
13
13
  | `studio.hdr` | [Studio Small 09](https://polyhaven.com/a/studio_small_09) | `https://dl.polyhaven.org/file/ph-assets/HDRIs/hdr/1k/studio_small_09_1k.hdr` |
14
14
 
15
- The files are embedded into `src/generated/hdri-data.js` at build time so the
16
- client bundle does not depend on a separate asset URL or network request.
15
+ The files ship inside the plugin package and are served at runtime by the
16
+ plugin's Host route (`/dsh-3d-viewer/hdri/`), so the client bundle does not
17
+ embed them and no network request is made.