u-space 0.0.7 → 0.0.9

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 (40) hide show
  1. package/dist/index.cjs +16 -1
  2. package/dist/index.js +1578 -534
  3. package/dist/src/effects/MaterialEffects.d.ts +23 -0
  4. package/dist/src/index.d.ts +1 -0
  5. package/dist/src/interactions/InteractionManager.d.ts +31 -0
  6. package/dist/src/interactions/Selection.d.ts +77 -0
  7. package/dist/src/interactions/index.d.ts +1 -0
  8. package/dist/src/managers/LightManager.d.ts +101 -0
  9. package/dist/src/managers/ObjectManager.d.ts +33 -1
  10. package/dist/src/managers/SceneManager.d.ts +57 -0
  11. package/dist/src/managers/index.d.ts +2 -0
  12. package/dist/src/objects/Model.d.ts +13 -1
  13. package/dist/src/tools/AnnotationManager.d.ts +104 -0
  14. package/dist/src/tools/ClippingTool.d.ts +96 -0
  15. package/dist/src/tools/MeasureTool.d.ts +80 -0
  16. package/dist/src/tools/index.d.ts +3 -0
  17. package/dist/src/viewers/CameraControls.d.ts +23 -0
  18. package/dist/src/viewers/Viewer.d.ts +52 -1
  19. package/docs/api-camera-controls.md +146 -0
  20. package/docs/api-effects.md +47 -5
  21. package/docs/api-interactions.md +107 -7
  22. package/docs/api-managers.md +181 -0
  23. package/docs/api-objects.md +46 -13
  24. package/docs/api-plugin-atmosphere.md +10 -0
  25. package/docs/api-plugin-curve-movement.md +38 -0
  26. package/docs/api-plugin-keyboard-controls.md +40 -0
  27. package/docs/api-plugin-minimap.md +36 -0
  28. package/docs/api-plugin-object-controls.md +67 -0
  29. package/docs/api-plugin-tiles.md +26 -0
  30. package/docs/api-plugin-topology-drawer.md +74 -0
  31. package/docs/api-plugin-tracking-controls.md +23 -0
  32. package/docs/api-plugin-u-manager.md +123 -0
  33. package/docs/api-tools.md +254 -0
  34. package/docs/api-viewer.md +85 -19
  35. package/docs/changelog.md +105 -0
  36. package/docs/examples-guide.md +104 -0
  37. package/docs/getting-started.md +1 -1
  38. package/docs/index.md +14 -12
  39. package/package.json +1 -1
  40. package/docs/api-plugins.md +0 -449
@@ -0,0 +1,254 @@
1
+ # Tools API
2
+
3
+ `u-space` 提供了一组实用工具类,包括测量、剖切和标注功能。
4
+
5
+ ## MeasureTool
6
+
7
+ 用于 3D 场景中的距离测量、面积测量和角度测量,测量结果会以可视化线条渲染到场景中。
8
+
9
+ ```typescript
10
+ import { MeasureTool } from 'u-space';
11
+
12
+ const measureTool = new MeasureTool(viewer.scene);
13
+ ```
14
+
15
+ ### `measureDistance(pointA, pointB, options?)`
16
+
17
+ 测量两点之间的距离,并在场景中绘制连线。
18
+
19
+ ```typescript
20
+ const result = measureTool.measureDistance(
21
+ { x: 0, y: 0, z: 0 },
22
+ { x: 5, y: 0, z: 5 },
23
+ { lineColor: 0xffff00 },
24
+ );
25
+ console.log(result.value, result.unit); // 7.071 m
26
+ ```
27
+
28
+ ### `measureArea(points, options?)`
29
+
30
+ 测量由 3 个或更多共面点围成的多边形面积。
31
+
32
+ ```typescript
33
+ const result = measureTool.measureArea([
34
+ { x: 0, y: 0, z: 0 },
35
+ { x: 5, y: 0, z: 0 },
36
+ { x: 5, y: 0, z: 5 },
37
+ { x: 0, y: 0, z: 5 },
38
+ ], { lineColor: 0x00ff00 });
39
+ console.log(result.value, result.unit); // 25 m²
40
+ ```
41
+
42
+ ### `measureAngle(pointA, vertex, pointC, options?)`
43
+
44
+ 测量以中间点为顶点的夹角(单位:度)。
45
+
46
+ ```typescript
47
+ const result = measureTool.measureAngle(
48
+ { x: 3, y: 0, z: 0 },
49
+ { x: 0, y: 0, z: 0 },
50
+ { x: 0, y: 0, z: 3 },
51
+ );
52
+ console.log(result.value, result.unit); // 90 °
53
+ ```
54
+
55
+ ### `MeasureResult`
56
+
57
+ 所有测量方法返回 `MeasureResult` 对象:
58
+
59
+ | 属性 | 类型 | 说明 |
60
+ | :------- | :---------- | :--------------------------------- |
61
+ | `id` | `string` | 测量的唯一标识。 |
62
+ | `type` | `string` | `'distance'` / `'area'` / `'angle'`。|
63
+ | `value` | `number` | 测量值。 |
64
+ | `unit` | `string` | 单位(`m`、`m²`、`°`)。 |
65
+ | `points` | `Vector3[]` | 测量点坐标。 |
66
+ | `object` | `Group` | 场景中的可视化对象。 |
67
+
68
+ ### `MeasureStyleOptions`
69
+
70
+ | 属性 | 类型 | 默认值 | 说明 |
71
+ | :---------- | :-------------------- | :--------- | :----------- |
72
+ | `lineColor` | `ColorRepresentation` | 因方法而异 | 线条颜色。 |
73
+
74
+ ### 管理方法
75
+
76
+ ```typescript
77
+ measureTool.get('measure_dist_0'); // 获取指定测量
78
+ measureTool.remove('measure_dist_0'); // 移除指定测量
79
+ measureTool.removeAll(); // 清除全部
80
+ measureTool.getAll(); // 获取所有测量结果
81
+ measureTool.dispose(); // 释放资源
82
+ ```
83
+
84
+ ---
85
+
86
+ ## ClippingTool
87
+
88
+ 提供剖切面和剖切盒功能,基于 WebGPU 的 `ClippingGroup` 实现。需要被剖切的对象必须是 `ClippingGroup` 的子节点。
89
+
90
+ ```typescript
91
+ import { ClippingTool } from 'u-space';
92
+
93
+ const clippingTool = new ClippingTool(viewer.scene);
94
+
95
+ // 将场景中已有的物体移入 ClippingGroup,使其受剖切影响
96
+ clippingTool.attach();
97
+ ```
98
+
99
+ ### `attach()` / `detach()`
100
+
101
+ `attach()` 将场景根节点的所有子对象移入内部的 `ClippingGroup`,使其受剖切面影响。`detach()` 反向操作,将对象移回场景根节点。
102
+
103
+ 也可以手动将对象添加到 `clippingTool.group` 中:
104
+
105
+ ```typescript
106
+ clippingTool.group.add(myModel); // 仅 myModel 受剖切
107
+ ```
108
+
109
+ ### `addPlane(id, options?)`
110
+
111
+ 添加一个剖切面。
112
+
113
+ ```typescript
114
+ clippingTool.addPlane('cutY', {
115
+ normal: { x: 0, y: -1, z: 0 }, // 法线方向
116
+ constant: 1.5, // 距离原点的偏移
117
+ showHelper: true, // 显示 Helper
118
+ helperSize: 5,
119
+ helperColor: 0xff0000,
120
+ });
121
+ ```
122
+
123
+ #### `ClippingPlaneOptions`
124
+
125
+ | 属性 | 类型 | 默认值 | 说明 |
126
+ | :------------ | :-------------------- | :----------------- | :----------------------- |
127
+ | `normal` | `{x, y, z}` | `{x:0, y:-1, z:0}` | 法线方向。 |
128
+ | `constant` | `number` | `0` | 距原点偏移。 |
129
+ | `showHelper` | `boolean` | `false` | 是否显示 PlaneHelper。 |
130
+ | `helperSize` | `number` | `5` | Helper 尺寸。 |
131
+ | `helperColor` | `ColorRepresentation` | `0xff0000` | Helper 颜色。 |
132
+
133
+ ### `addBox(id, box, options?)` / `addBoxFromObject(id, object, padding?, options?)`
134
+
135
+ 添加由 6 个面组成的剖切盒。
136
+
137
+ ```typescript
138
+ import { Box3 } from 'three/webgpu';
139
+
140
+ // 从 Box3 创建
141
+ const box = new Box3().setFromObject(myModel);
142
+ clippingTool.addBox('clipBox', box);
143
+
144
+ // 从对象创建(带边距)
145
+ clippingTool.addBoxFromObject('clipBox', myModel, 0.5);
146
+ ```
147
+
148
+ ### 动态调整
149
+
150
+ ```typescript
151
+ clippingTool.setPlaneConstant('cutY', 2.0); // 修改剖切位置
152
+ viewer.render();
153
+ ```
154
+
155
+ ### Helper 控制
156
+
157
+ ```typescript
158
+ clippingTool.showHelper('cutY', 5, 0xff0000);
159
+ clippingTool.hideHelper('cutY');
160
+ ```
161
+
162
+ ### 管理方法
163
+
164
+ ```typescript
165
+ clippingTool.get('cutY'); // 获取 Plane 对象
166
+ clippingTool.removePlane('cutY'); // 移除单个
167
+ clippingTool.removeBox('clipBox'); // 移除剖切盒(6 个面)
168
+ clippingTool.removeAll(); // 移除全部
169
+ clippingTool.enable(); // 启用剖切
170
+ clippingTool.disable(); // 禁用剖切
171
+ clippingTool.dispose(); // 释放资源(对象移回场景根节点)
172
+ ```
173
+
174
+ ---
175
+
176
+ ## AnnotationManager
177
+
178
+ 管理 3D 标注,支持引线标注和 HTML 标签。配合 `CSSRenderer` 使用可实现 HTML 浮动标签。
179
+
180
+ ```typescript
181
+ import { AnnotationManager } from 'u-space';
182
+
183
+ const annotationManager = new AnnotationManager(viewer.scene);
184
+ ```
185
+
186
+ ### `setCSSObjectFactory(factory)`
187
+
188
+ 设置 CSS 对象工厂函数(来自 `CSSRenderer`),使标注可渲染为 CSS 叠加元素。
189
+
190
+ ```typescript
191
+ annotationManager.setCSSObjectFactory(
192
+ (el) => viewer.cssRenderer.createCSS2DObject(el),
193
+ );
194
+ ```
195
+
196
+ ### `add(id, options)`
197
+
198
+ 添加一个标注。
199
+
200
+ ```typescript
201
+ annotationManager.add('label-01', {
202
+ position: { x: 0, y: 3, z: 0 },
203
+ content: '<b>设备 A</b><br>温度: 25°C',
204
+ labelOffset: { x: 0, y: 2, z: 0 },
205
+ showLeaderLine: true,
206
+ lineColor: 0xffffff,
207
+ labelStyle: {
208
+ background: 'rgba(0, 0, 0, 0.8)',
209
+ padding: '8px 12px',
210
+ borderRadius: '6px',
211
+ },
212
+ });
213
+ ```
214
+
215
+ #### `AnnotationOptions`
216
+
217
+ | 属性 | 类型 | 默认值 | 说明 |
218
+ | :--------------- | :------------------------ | :---------- | :--------------------- |
219
+ | `position` | `{x, y, z}` | — | 标注锚点位置。 |
220
+ | `content` | `string` | — | HTML 内容。 |
221
+ | `labelOffset` | `{x, y, z}` | `{0, 2, 0}` | 标签相对锚点的偏移。 |
222
+ | `showLeaderLine` | `boolean` | `true` | 是否显示引线。 |
223
+ | `lineColor` | `ColorRepresentation` | `0xffffff` | 引线颜色。 |
224
+ | `labelStyle` | `Partial<CSSStyleDeclaration>` | — | 自定义 CSS 样式。 |
225
+
226
+ ### `addText(text, position, options?)`
227
+
228
+ 快捷添加纯文本标注。
229
+
230
+ ```typescript
231
+ annotationManager.addText('入口', { x: 5, y: 0, z: 0 });
232
+ ```
233
+
234
+ ### 更新与控制
235
+
236
+ ```typescript
237
+ annotationManager.updateContent('label-01', '温度: 30°C');
238
+ annotationManager.updatePosition('label-01', { x: 1, y: 3, z: 0 });
239
+ annotationManager.show('label-01');
240
+ annotationManager.hide('label-01');
241
+ annotationManager.showAll();
242
+ annotationManager.hideAll();
243
+ ```
244
+
245
+ ### 管理方法
246
+
247
+ ```typescript
248
+ annotationManager.get('label-01'); // 获取标注对象
249
+ annotationManager.remove('label-01'); // 移除标注
250
+ annotationManager.removeAll(); // 移除全部
251
+ annotationManager.keys(); // 获取所有 ID
252
+ annotationManager.size; // 标注数量
253
+ annotationManager.dispose(); // 释放资源
254
+ ```
@@ -101,35 +101,101 @@ const camera = viewer.createOrthographicCamera();
101
101
  viewer.setCamera(camera);
102
102
  ```
103
103
 
104
- ### `controls.setCameraViewpoint(viewpoint, enableTransition?)`
104
+ ### `resize(width?, height?)`
105
105
 
106
- 将相机平滑过渡到指定的位置、目标和缩放。
106
+ 手动触发容器尺寸更新。可选传入指定宽高。
107
107
 
108
108
  ```typescript
109
- await viewer.controls.setCameraViewpoint({
110
- position: { x: 10, y: 5, z: 10 },
111
- target: { x: 0, y: 0, z: 0 },
112
- zoom: 1.0,
109
+ // 手动触发 resize(如容器尺寸变化后)
110
+ viewer.resize();
111
+
112
+ // 指定新尺寸
113
+ viewer.resize(800, 600);
114
+ ```
115
+
116
+ ### `screenshot(options?)`
117
+
118
+ 捕获当前渲染画面并返回 Data URL。
119
+
120
+ ```typescript
121
+ const dataUrl = await viewer.screenshot();
122
+
123
+ // 指定格式和分辨率
124
+ const dataUrl = await viewer.screenshot({
125
+ width: 1920,
126
+ height: 1080,
127
+ type: 'image/png',
128
+ quality: 1.0,
113
129
  });
130
+ ```
131
+
132
+ #### `ScreenshotOptions`
133
+
134
+ | 属性 | 类型 | 默认值 | 说明 |
135
+ | :-------- | :---------------------------------------------- | :------------ | :--------------------- |
136
+ | `width` | `number` | 容器宽度 | 截图宽度。 |
137
+ | `height` | `number` | 容器高度 | 截图高度。 |
138
+ | `type` | `'image/png'` \| `'image/jpeg'` \| `'image/webp'` | `'image/png'` | 图片格式。 |
139
+ | `quality` | `number` | `1.0` | 图片质量(0-1)。 |
140
+
141
+ ### `setBackground(background)`
142
+
143
+ 设置场景背景颜色、纹理或清除背景。
144
+
145
+ ```typescript
146
+ viewer.setBackground(0x333333); // 颜色
147
+ viewer.setBackground('#87ceeb'); // CSS 颜色字符串
148
+ viewer.setBackground(hdrTexture); // 纹理
149
+ viewer.setBackground(null); // 清除背景
150
+ ```
151
+
152
+ ### `setEnvironment(envMap)`
153
+
154
+ 设置场景环境贴图(用于反射/IBL)。
155
+
156
+ ```typescript
157
+ viewer.setEnvironment(hdrTexture);
158
+ viewer.setEnvironment(null); // 清除
159
+ ```
160
+
161
+ ### `enableShadow()` / `disableShadow()`
162
+
163
+ 开启或关闭阴影渲染。
164
+
165
+ ```typescript
166
+ viewer.enableShadow();
167
+ viewer.disableShadow();
168
+ ```
169
+
170
+ ### `enableFog(options?)` / `enableFogExp2(options?)` / `disableFog()`
171
+
172
+ 开启线性雾、指数雾或关闭雾效。
173
+
174
+ ```typescript
175
+ // 线性雾
176
+ viewer.enableFog({ color: 0xcccccc, near: 10, far: 100 });
177
+
178
+ // 指数雾
179
+ viewer.enableFogExp2({ color: 0xcccccc, density: 0.01 });
114
180
 
115
- // 禁用过渡动画,立即跳转
116
- await viewer.controls.setCameraViewpoint(viewpoint, false);
181
+ // 关闭雾效
182
+ viewer.disableFog();
117
183
  ```
118
184
 
119
- **参数:**
185
+ #### `FogOptions`
120
186
 
121
- | 参数 | 类型 | 默认值 | 说明 |
122
- | :----------------- | :--------------------- | :------ | :---------------------------------- |
123
- | `viewpoint` | `CameraViewpointData` | | 包含 `position`、`target`、`zoom`。 |
124
- | `enableTransition` | `boolean` | `true` | 是否启用平滑过渡动画。 |
187
+ | 属性 | 类型 | 默认值 | 说明 |
188
+ | :------ | :-------------------- | :---------- | :------------- |
189
+ | `color` | `ColorRepresentation` | `0xcccccc` | 雾的颜色。 |
190
+ | `near` | `number` | `10` | 雾的起始距离。 |
191
+ | `far` | `number` | `100` | 雾的结束距离。 |
125
192
 
126
- #### `CameraViewpointData`
193
+ #### `FogExp2Options`
127
194
 
128
- | 属性 | 类型 | 说明 |
129
- | :--------- | :--------- | :------------------- |
130
- | `position` | `IVector3` | 相机位置。 |
131
- | `target` | `IVector3` | 相机注视目标位置。 |
132
- | `zoom` | `number` | 相机缩放值。 |
195
+ | 属性 | 类型 | 默认值 | 说明 |
196
+ | :-------- | :-------------------- | :---------- | :------------- |
197
+ | `color` | `ColorRepresentation` | `0xcccccc` | 雾的颜色。 |
198
+ | `density` | `number` | `0.01` | 雾的密度。 |
133
199
 
134
200
  ## 调试工具
135
201
 
@@ -0,0 +1,105 @@
1
+ # 更新日志
2
+
3
+ ## 0.0.8 (开发中)
4
+
5
+ ### 新增
6
+
7
+ - **Viewer** — `resize()`、`screenshot()`、`setBackground()`、`setEnvironment()`、`enableShadow()`/`disableShadow()`、`enableFog()`/`enableFogExp2()`/`disableFog()`
8
+ - **CameraControls** — `flyTo()`、`getCameraViewpoint()`、`lock()`/`unlock()`、`setViewMode('2d' | '3d')`
9
+ - **ObjectManager** — `show()`/`hide()`、`isolate()`、`showAll()`、`setOpacity()`、`getBoundingBox()`、`forEach()`、`filter()`
10
+ - **InteractionManager** — `enable()`/`disable()`、`setInteractable()`、`addIgnore()`/`removeIgnore()`
11
+ - **Selection** — 新增框选(rubber-band)和单选/多选/切换模块,支持 `select`/`deselect`/`change` 事件
12
+ - **MaterialEffects** — `wireframe()`/`removeWireframe()`、`transparent()`/`removeTransparent()`、`xray()`/`removeXray()`、`fadeIn()`/`fadeOut()`
13
+ - **Model** — `getBoundingBox()`、`getCenter()`、`setMaterial()`
14
+ - **SceneManager** — 新模块,多场景创建、注册、切换与序列化
15
+ - **LightManager** — 新模块,灯光便捷创建、4 种预设(indoor/outdoor/studio/warehouse)、Helper 可视化
16
+ - **MeasureTool** — 新工具,距离/面积/角度测量,结果可视化渲染到场景
17
+ - **ClippingTool** — 新工具,基于 WebGPU `ClippingGroup` 的剖切面与剖切盒
18
+ - **AnnotationManager** — 新工具,3D 引线标注 + HTML 浮动标签
19
+ - **示例** — 新增 8 个交互式示例页面
20
+
21
+ ### 修复
22
+
23
+ - **Selection** — 框选覆盖层改为挂载到容器元素(而非 canvas),修复框选矩形不可见的问题
24
+ - **ClippingTool** — 从 `renderer.clippingPlanes`(WebGL API)重写为 `ClippingGroup`(WebGPU API),修复剖切无效的问题
25
+ - **MaterialEffects** — fade 动画在对象移除场景后自动停止,避免内存泄漏
26
+ - **InteractionManager** — `dispose()` 中清除 `clickTimer`,避免定时器泄漏
27
+ - **LightManager** — 修复 `removeAll()`/`hideAllHelpers()` 中遍历 Map 同时删除的问题
28
+ - **ObjectManager** — `setOpacity()` 先检查 `isMesh` 再类型转换
29
+ - **ClippingTool** — `PlaneHelper` 颜色使用 `new Color(color).getHex()` 替代直接 `as number`
30
+ - **MeasureTool** — 移除 WebGPU 不支持的 `linewidth` 属性
31
+
32
+ ---
33
+
34
+ ## 0.0.7
35
+
36
+ ### 变更
37
+
38
+ - 文档拆分:将插件文档拆分为独立文件
39
+ - 新增 CameraControls 独立文档页
40
+ - 修复 getting-started 中的死链
41
+ - 修复 sbmx loader 示例使用新的 MaterialEffects API
42
+
43
+ ---
44
+
45
+ ## 0.0.6
46
+
47
+ ### 新增
48
+
49
+ - **MaterialEffects** — 可组合的材质特效系统,支持安全共享材质和 remove API
50
+ - **RenderPipeline** — 内置 Bloom、SSGI、TRAA 后处理及 OutputComposer API
51
+ - **CSSRenderer** — CSS2D / CSS2.5D / CSS3D 叠加渲染 HTML 元素
52
+ - 从 `package.json` 导出 `version`,统一示例 importmap
53
+
54
+ ---
55
+
56
+ ## 0.0.5
57
+
58
+ ### 变更
59
+
60
+ - 版本发布(无重大功能变更)
61
+
62
+ ---
63
+
64
+ ## 0.0.4
65
+
66
+ ### 新增
67
+
68
+ - **Model** — 动画播放支持(`playAnimation`、`stopAnimation`、`updateAnimation`)
69
+ - **ViewerEventMap** — 事件回调新增 `delta` 时间参数
70
+
71
+ ---
72
+
73
+ ## 0.0.3
74
+
75
+ ### 新增
76
+
77
+ - **ObjectControls** 插件 — 交互式移动、旋转、缩放 3D 对象
78
+ - **TopologyDrawer** 插件 — 在场景任意表面交互式绘制拓扑路径图
79
+ - **Topology** — `exportData()` / `importData()` 数据序列化
80
+
81
+ ### 变更
82
+
83
+ - **Interactions** — `contextmenu` 事件替换为 `rightclick`
84
+ - **Poi** — 优化渲染性能,新增 `scaleFactor` 参数
85
+ - 文档全面完善:本地搜索、侧边栏优化、各插件文档页
86
+
87
+ ---
88
+
89
+ ## 0.0.0
90
+
91
+ ### 新增
92
+
93
+ - 项目初始化:Viewer 核心、WebGPU 渲染器、场景/相机/控制器
94
+ - 模型加载系统:双层缓存(内存 + 持久化)、Draco/KTX2/Meshopt 支持
95
+ - 交互系统:射线检测、事件冒泡、自定义 3D 对象事件
96
+ - 对象系统:Model、Poi、Topology、基础网格(Sphere/Plane/Circle/Tube/Extrude/Shape)
97
+ - ObjectManager 集中式对象注册
98
+ - 补间动画系统
99
+ - u-manager 插件:场景加载、动画、属性、视点管理
100
+ - tiles 插件:ArcGIS 3D 瓦片 / GIS 地球渲染
101
+ - minimap 插件:2D 小地图
102
+ - keyboard-controls 插件:WASD 键盘控制
103
+ - tracking-controls 插件:相机跟随
104
+ - atmosphere 插件:天空/大气渲染
105
+ - curve-movement 插件:曲线路径动画
@@ -86,3 +86,107 @@
86
86
  - 使用 `viewer.renderPipeline.enableTRAA()` / `disableTRAA()` 切换时间抗锯齿。
87
87
  - 使用 `viewer.renderPipeline.setOutputComposer()` 自定义后处理链(示例中实现了灰度滤镜)。
88
88
  - 使用 `setOutputComposer(null)` 恢复默认渲染管线。
89
+
90
+ ## 8. `test_viewer_utils.html`:Viewer 工具方法
91
+
92
+ 该示例演示了 `Viewer` 新增的便捷方法:截图导出、背景切换、雾效控制和阴影开关。
93
+
94
+ ### 核心要点:
95
+
96
+ - 使用 `viewer.screenshot()` 导出当前渲染画面为 PNG 文件。
97
+ - 使用 `viewer.setBackground(color)` 快速切换场景背景颜色。
98
+ - 使用 `viewer.enableFog()` / `viewer.disableFog()` 控制雾效。
99
+ - 使用 `viewer.enableShadow()` / `viewer.disableShadow()` 控制阴影渲染。
100
+ - 使用 `viewer.resize(width, height)` 手动触发尺寸更新。
101
+
102
+ ## 9. `test_camera_controls.html`:CameraControls 增强方法
103
+
104
+ 该示例演示了 `CameraControls` 的飞行定位、视角存取、锁定和二三维切换功能。
105
+
106
+ ### 核心要点:
107
+
108
+ - 使用 `viewer.controls.flyTo(position, target)` 将相机飞行到指定坐标。
109
+ - 使用 `viewer.controls.getCameraViewpoint()` 获取当前视角数据。
110
+ - 使用 `viewer.controls.setCameraViewpoint(data)` 恢复保存的视角。
111
+ - 使用 `viewer.controls.lock()` / `unlock()` 锁定或解锁相机控制。
112
+ - 使用 `viewer.controls.setViewMode('2d')` / `setViewMode('3d')` 在二三维视图间切换。
113
+
114
+ ## 10. `test_object_manager.html`:ObjectManager 增强方法
115
+
116
+ 该示例演示了 `ObjectManager` 的显隐控制、孤立显示、透明度设置、包围盒查询和过滤功能。
117
+
118
+ ### 核心要点:
119
+
120
+ - 使用 `viewer.objectManager.show(id)` / `hide(id)` 控制对象可见性。
121
+ - 使用 `viewer.objectManager.isolate(ids)` 孤立显示指定对象。
122
+ - 使用 `viewer.objectManager.setOpacity(id, value)` 设置材质透明度。
123
+ - 使用 `viewer.objectManager.getBoundingBox()` 查询所有对象的包围盒。
124
+ - 使用 `viewer.objectManager.filter(predicate)` 按条件过滤对象。
125
+
126
+ ## 11. `test_material_effects.html`:MaterialEffects 增强效果
127
+
128
+ 该示例演示了材质效果系统的线框、半透明、X 光和淡入淡出功能。
129
+
130
+ ### 核心要点:
131
+
132
+ - 使用 `MaterialEffects.wireframe(object)` 开启线框渲染模式。
133
+ - 使用 `MaterialEffects.highlightColor(object, { opacity })` 设置半透明效果。
134
+ - 使用 `MaterialEffects.highlightColor(object, { color, opacity, overwrite: true, depthWrite: false })` 实现 X 光透视效果。
135
+ - 使用 `MaterialEffects.fadeOut(object)` / `fadeIn(object)` 执行淡入淡出动画。
136
+ - 使用 `MaterialEffects.removeHighlightColor(object)` 恢复原始材质状态。
137
+
138
+ ## 12. `test_selection.html`:Selection 选择系统
139
+
140
+ 该示例演示了对象选择系统的单选和框选功能。
141
+
142
+ ### 核心要点:
143
+
144
+ - 创建 `Selection` 实例并监听 `select`、`deselect`、`change` 事件。
145
+ - 使用 `selection.select()` / `deselect()` / `toggle()` / `clear()` 进行程序化选择操作。
146
+ - 使用 `selection.enableBoxSelection()` 开启鼠标框选模式。
147
+ - 框选模式下可配合 `viewer.controls.lock()` 避免框选与相机旋转冲突。
148
+
149
+ ## 13. `test_measure.html`:MeasureTool 测量工具
150
+
151
+ 该示例演示了 3D 场景中的距离、面积和角度测量。
152
+
153
+ ### 核心要点:
154
+
155
+ - 使用 `measureTool.measureDistance(pointA, pointB)` 测量两点距离。
156
+ - 使用 `measureTool.measureArea(points)` 测量多边形面积。
157
+ - 使用 `measureTool.measureAngle(pointA, vertex, pointC)` 测量夹角。
158
+ - 测量结果以可视化线条渲染到场景中,返回的 `MeasureResult` 包含数值和单位。
159
+
160
+ ## 14. `test_annotation.html`:AnnotationManager 标注管理
161
+
162
+ 该示例演示了 3D 标注的创建、更新和管理,配合 `CSSRenderer` 实现 HTML 浮动标签。
163
+
164
+ ### 核心要点:
165
+
166
+ - 创建 `AnnotationManager` 实例并通过 `setCSSObjectFactory()` 绑定 `CSSRenderer`。
167
+ - 使用 `annotationManager.add(id, options)` 添加带引线和自定义样式的标注。
168
+ - 使用 `annotationManager.addText(text, position)` 快捷添加纯文本标注。
169
+ - 使用 `updateContent()` 动态更新标注内容,`updatePosition()` 移动标注位置。
170
+ - 使用 `hideAll()` / `showAll()` 批量控制标注显隐。
171
+
172
+ ## 15. `test_clipping.html`:ClippingTool 剖切工具
173
+
174
+ 该示例演示了剖切面的创建和实时调整。
175
+
176
+ ### 核心要点:
177
+
178
+ - 创建 `ClippingTool` 实例并调用 `attach()` 将场景物体移入 ClippingGroup。
179
+ - 使用 `clippingTool.addPlane(id, options)` 添加剖切面。
180
+ - 使用滑块通过 `clippingTool.setPlaneConstant()` 实时调整剖切位置。
181
+ - 使用 `showHelper()` / `hideHelper()` 切换剖切面可视化辅助。
182
+
183
+ ## 16. `test_lights.html`:LightManager 灯光管理
184
+
185
+ 该示例演示了灯光管理器的灯光预设和 Helper 可视化功能。
186
+
187
+ ### 核心要点:
188
+
189
+ - 创建 `LightManager` 实例并使用 `applyPreset()` 一键应用灯光预设。
190
+ - 支持 4 种预设:`indoor`(室内)、`outdoor`(室外)、`studio`(摄影棚)、`warehouse`(仓库)。
191
+ - 使用 `showAllHelpers()` / `hideAllHelpers()` 显示或隐藏灯光辅助可视化。
192
+ - 每种预设会自动清除旧灯光并创建新的灯光组合。
@@ -137,7 +137,7 @@ console.log(window.__USPACE__.version);
137
137
  - 探索如何 [加载模型与使用对象](./api-objects.md)
138
138
  - 理解 [交互系统](./api-interactions.md)
139
139
  - 使用 [Managers API](./api-managers.md) 注册和检索对象
140
- - 通过 [Plugins API](./api-plugins.md) 添加瓦片地图、小地图、键盘控制等功能
140
+ - 通过插件添加 [瓦片地图](./api-plugin-tiles.md)、[小地图](./api-plugin-minimap.md)、[键盘控制](./api-plugin-keyboard-controls.md) 等功能
141
141
  - 使用 [Animations API](./api-animations.md) 为属性添加动画
142
142
  - 使用 [Effects API](./api-effects.md) 应用视觉特效
143
143
  - 浏览 [示例指南](./examples-guide.md)
package/docs/index.md CHANGED
@@ -33,13 +33,15 @@ features:
33
33
  | 文档 | 说明 |
34
34
  | :--- | :--- |
35
35
  | [Viewer](./api-viewer) | 核心类:渲染器、场景、相机、控制器、事件 |
36
+ | [CameraControls](./api-camera-controls) | 相机控制:飞行、视角切换、视点过渡 |
36
37
  | [CSSRenderer](./api-css-renderer) | CSS 渲染器:CSS2D / CSS2.5D / CSS3D 叠加 HTML 元素 |
37
38
  | [RenderPipeline](./api-render-pipeline) | 后处理管线:Bloom、SSGI、TRAA、自定义后处理 |
38
39
  | [Objects](./api-objects) | 3D 对象:模型加载、基础网格、Poi、Topology |
39
- | [Interactions](./api-interactions) | 交互管理:射线检测、鼠标/触摸事件 |
40
- | [Managers](./api-managers) | 对象管理:按 ID / 名称 / 类型检索 |
40
+ | [Interactions](./api-interactions) | 交互管理:射线检测、鼠标/触摸事件、框选 |
41
+ | [Managers](./api-managers) | 对象管理、场景管理、灯光管理 |
41
42
  | [Animations](./api-animations) | 补间动画:`tweenAnimation`、`Tween`、缓动模式 |
42
- | [Effects](./api-effects) | 视觉特效:高亮、流动、呼吸、流体(TSL) |
43
+ | [Effects](./api-effects) | 视觉特效:高亮、呼吸、线框、淡入淡出、流动、流体(TSL) |
44
+ | [Tools](./api-tools) | 工具:测量(距离/面积/角度)、剖切(面/盒)、标注管理 |
43
45
 
44
46
  ### 插件
45
47
 
@@ -47,12 +49,12 @@ features:
47
49
 
48
50
  | 插件 | 说明 |
49
51
  | :--- | :--- |
50
- | [keyboard-controls](./api-plugins#keyboard-controls) | WASD / 方向键控制相机移动与旋转 |
51
- | [minimap](./api-plugins#minimap) | 2D 小地图叠加层 |
52
- | [tiles](./api-plugins#tiles) | ArcGIS 3D 瓦片 / GIS 地球渲染 |
53
- | [u-manager](./api-plugins#u-manager) | 场景加载、拓扑、动画、属性、视点管理 |
54
- | [curve-movement](./api-plugins#curve-movement) | 沿样条曲线移动相机或对象 |
55
- | [tracking-controls](./api-plugins#tracking-controls) | 相机跟随移动目标 |
56
- | [atmosphere](./api-plugins#atmosphere) | 天空/大气渲染(开发中) |
57
- | [object-controls](./api-plugins#object-controls) | 交互式移动、旋转、缩放 3D 对象 |
58
- | [topology-drawer](./api-plugins#topology-drawer) | 在场景任意表面交互式绘制拓扑路径图 |
52
+ | [keyboard-controls](./api-plugin-keyboard-controls) | WASD / 方向键控制相机移动与旋转 |
53
+ | [minimap](./api-plugin-minimap) | 2D 小地图叠加层 |
54
+ | [tiles](./api-plugin-tiles) | ArcGIS 3D 瓦片 / GIS 地球渲染 |
55
+ | [u-manager](./api-plugin-u-manager) | 场景加载、拓扑、动画、属性、视点管理 |
56
+ | [curve-movement](./api-plugin-curve-movement) | 沿样条曲线移动相机或对象 |
57
+ | [tracking-controls](./api-plugin-tracking-controls) | 相机跟随移动目标 |
58
+ | [atmosphere](./api-plugin-atmosphere) | 天空/大气渲染(开发中) |
59
+ | [object-controls](./api-plugin-object-controls) | 交互式移动、旋转、缩放 3D 对象 |
60
+ | [topology-drawer](./api-plugin-topology-drawer) | 在场景任意表面交互式绘制拓扑路径图 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "u-space",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "type": "module",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "module": "dist/index.js",