u-space 0.0.7 → 0.0.11
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/dist/index.cjs +16 -1
- package/dist/index.js +1578 -534
- package/dist/plugins/u-manager/index.cjs +21 -21
- package/dist/plugins/u-manager/index.js +5 -5
- package/dist/src/effects/MaterialEffects.d.ts +23 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/interactions/InteractionManager.d.ts +31 -0
- package/dist/src/interactions/Selection.d.ts +77 -0
- package/dist/src/interactions/index.d.ts +1 -0
- package/dist/src/managers/LightManager.d.ts +101 -0
- package/dist/src/managers/ObjectManager.d.ts +33 -1
- package/dist/src/managers/SceneManager.d.ts +57 -0
- package/dist/src/managers/index.d.ts +2 -0
- package/dist/src/objects/ExtrudeMesh.d.ts +1 -1
- package/dist/src/objects/Model.d.ts +13 -1
- package/dist/src/tools/AnnotationManager.d.ts +104 -0
- package/dist/src/tools/ClippingTool.d.ts +96 -0
- package/dist/src/tools/MeasureTool.d.ts +80 -0
- package/dist/src/tools/index.d.ts +3 -0
- package/dist/src/viewers/CameraControls.d.ts +23 -0
- package/dist/src/viewers/Viewer.d.ts +52 -1
- package/docs/api-camera-controls.md +146 -0
- package/docs/api-effects.md +47 -5
- package/docs/api-interactions.md +107 -7
- package/docs/api-managers.md +181 -0
- package/docs/api-objects.md +46 -13
- package/docs/api-plugin-atmosphere.md +10 -0
- package/docs/api-plugin-curve-movement.md +38 -0
- package/docs/api-plugin-keyboard-controls.md +40 -0
- package/docs/api-plugin-minimap.md +36 -0
- package/docs/api-plugin-object-controls.md +67 -0
- package/docs/api-plugin-tiles.md +26 -0
- package/docs/api-plugin-topology-drawer.md +74 -0
- package/docs/api-plugin-tracking-controls.md +23 -0
- package/docs/api-plugin-u-manager.md +123 -0
- package/docs/api-tools.md +254 -0
- package/docs/api-viewer.md +85 -19
- package/docs/changelog.md +105 -0
- package/docs/examples-guide.md +104 -0
- package/docs/getting-started.md +1 -1
- package/docs/index.md +14 -12
- package/package.json +2 -2
- package/docs/api-plugins.md +0 -449
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# u-manager
|
|
2
|
+
|
|
3
|
+
`u-manager` 是一套全面的加载器和解析器,用于从服务器路径流式传输、解密并显示结构化场景数据。支持场景、拓扑、动画、属性和相机视点。
|
|
4
|
+
|
|
5
|
+
所有加载器均继承自 Three.js 的 `Loader`,并提供 `setPath(path)` 方法,在调用 `loadAsync()` 前配置基础数据目录。
|
|
6
|
+
|
|
7
|
+
## `SceneLoader`
|
|
8
|
+
|
|
9
|
+
从服务端场景包加载完整场景树(模型、组、形状、拉伸区域),并自动将所有已加载对象按 `id` 和 `sid` 注册到 `viewer.objectManager`。
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { SceneLoader } from 'u-space/plugins/u-manager';
|
|
13
|
+
|
|
14
|
+
const sceneLoader = new SceneLoader(viewer);
|
|
15
|
+
sceneLoader.setPath('./scenes/my-scene');
|
|
16
|
+
sceneLoader.setKey('YOUR_LICENSE_KEY'); // 官方授权场景必需
|
|
17
|
+
const group = await sceneLoader.loadAsync();
|
|
18
|
+
viewer.scene.add(group);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**方法:**
|
|
22
|
+
|
|
23
|
+
| 方法 | 说明 |
|
|
24
|
+
| :--------------- | :------------------------------------------------------------ |
|
|
25
|
+
| `setKey(key)` | 设置授权场景的 RSA 解密密钥。 |
|
|
26
|
+
| `loadAsync()` | 加载并解析场景,返回包含完整层级的 `Group`。 |
|
|
27
|
+
| `clearCache()` | 从 `objectManager` 中移除此加载器注册的所有 ID。 |
|
|
28
|
+
| `dispose()` | 清除缓存并释放水印叠加层。 |
|
|
29
|
+
|
|
30
|
+
## `TopologiesLoader` / `TopologyParser`
|
|
31
|
+
|
|
32
|
+
加载拓扑图数据并将其转换为 `Topology` 对象。
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { TopologiesLoader } from 'u-space/plugins/u-manager';
|
|
36
|
+
|
|
37
|
+
const loader = new TopologiesLoader();
|
|
38
|
+
loader.setPath('./scenes/my-scene');
|
|
39
|
+
const topologies = await loader.loadAsync(); // Topology[]
|
|
40
|
+
viewer.scene.add(...topologies);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## `VisionsLoader` / `VisionsParser`
|
|
44
|
+
|
|
45
|
+
加载命名相机视点,并将相机飞行到指定视点。
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { VisionsLoader, VisionsParser } from 'u-space/plugins/u-manager';
|
|
49
|
+
|
|
50
|
+
const visionsLoader = new VisionsLoader();
|
|
51
|
+
visionsLoader.setPath('./scenes/my-scene');
|
|
52
|
+
const visionsData = await visionsLoader.loadAsync();
|
|
53
|
+
// visionsData 是 Record<string, IVisions[]>
|
|
54
|
+
|
|
55
|
+
const visionsParser = new VisionsParser(viewer);
|
|
56
|
+
|
|
57
|
+
// 飞行到指定视点
|
|
58
|
+
await visionsParser.flyTo(visionsData['HOME'][0]);
|
|
59
|
+
|
|
60
|
+
// 飞行到主(默认)视点
|
|
61
|
+
await visionsParser.flyToPrimary(visionsData['HOME']);
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**`IVisions` 字段:**
|
|
65
|
+
|
|
66
|
+
| 字段 | 类型 | 说明 |
|
|
67
|
+
| :--------- | :------------ | :------------------------------ |
|
|
68
|
+
| `camera` | `'P' \| 'O'` | 相机类型:透视或正交。 |
|
|
69
|
+
| `position` | `IVector3` | 相机世界位置。 |
|
|
70
|
+
| `target` | `IVector3` | 相机朝向目标点。 |
|
|
71
|
+
| `zoom` | `number` | 相机缩放级别。 |
|
|
72
|
+
| `primary` | `boolean` | 是否为默认视点。 |
|
|
73
|
+
|
|
74
|
+
## `AnimationsLoader` / `AnimationsParser`
|
|
75
|
+
|
|
76
|
+
加载关键帧动画数据,并通过 `tweenAnimation` 驱动 `Object3D` 的变换。
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { AnimationsLoader, AnimationsParser } from 'u-space/plugins/u-manager';
|
|
80
|
+
|
|
81
|
+
const animLoader = new AnimationsLoader();
|
|
82
|
+
animLoader.setPath('./scenes/my-scene');
|
|
83
|
+
const animationsData = await animLoader.loadAsync(); // IAnimations[]
|
|
84
|
+
|
|
85
|
+
// 查找特定对象的动画
|
|
86
|
+
const data = animationsData.find((a) => a.modelId === myModel.userData.id);
|
|
87
|
+
|
|
88
|
+
const parser = new AnimationsParser(viewer, myModel);
|
|
89
|
+
parser.initTransform(); // 保存初始位置/旋转/缩放
|
|
90
|
+
|
|
91
|
+
await parser.play(data.keyframes); // 播放动画序列
|
|
92
|
+
|
|
93
|
+
// 中途停止
|
|
94
|
+
parser.stop();
|
|
95
|
+
|
|
96
|
+
// 重置到初始变换
|
|
97
|
+
parser.reset();
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## `PropertiesLoader`
|
|
101
|
+
|
|
102
|
+
加载与模型关联的结构化属性元数据(如 BIM 属性)。
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
import { PropertiesLoader } from 'u-space/plugins/u-manager';
|
|
106
|
+
|
|
107
|
+
const propsLoader = new PropertiesLoader();
|
|
108
|
+
propsLoader.setPath('./scenes/my-scene');
|
|
109
|
+
const properties = await propsLoader.loadAsync(); // IProperties[]
|
|
110
|
+
|
|
111
|
+
// 查找模型的属性
|
|
112
|
+
const modelProps = properties.filter(p => p.modelId === myModel.userData.id);
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**`IProperties` 字段:**
|
|
116
|
+
|
|
117
|
+
| 字段 | 类型 | 说明 |
|
|
118
|
+
| :-------- | :--------------- | :----------------------- |
|
|
119
|
+
| `modelId` | `string` | 关联模型的 ID。 |
|
|
120
|
+
| `group` | `string` | 属性分组/类别名称。 |
|
|
121
|
+
| `key` | `string` | 属性键名。 |
|
|
122
|
+
| `value` | `string \| null` | 属性值。 |
|
|
123
|
+
| `label` | `string \| null` | 属性的显示标签。 |
|
|
@@ -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
|
+
```
|
package/docs/api-viewer.md
CHANGED
|
@@ -101,35 +101,101 @@ const camera = viewer.createOrthographicCamera();
|
|
|
101
101
|
viewer.setCamera(camera);
|
|
102
102
|
```
|
|
103
103
|
|
|
104
|
-
### `
|
|
104
|
+
### `resize(width?, height?)`
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
手动触发容器尺寸更新。可选传入指定宽高。
|
|
107
107
|
|
|
108
108
|
```typescript
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
181
|
+
// 关闭雾效
|
|
182
|
+
viewer.disableFog();
|
|
117
183
|
```
|
|
118
184
|
|
|
119
|
-
|
|
185
|
+
#### `FogOptions`
|
|
120
186
|
|
|
121
|
-
|
|
|
122
|
-
|
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
187
|
+
| 属性 | 类型 | 默认值 | 说明 |
|
|
188
|
+
| :------ | :-------------------- | :---------- | :------------- |
|
|
189
|
+
| `color` | `ColorRepresentation` | `0xcccccc` | 雾的颜色。 |
|
|
190
|
+
| `near` | `number` | `10` | 雾的起始距离。 |
|
|
191
|
+
| `far` | `number` | `100` | 雾的结束距离。 |
|
|
125
192
|
|
|
126
|
-
#### `
|
|
193
|
+
#### `FogExp2Options`
|
|
127
194
|
|
|
128
|
-
| 属性
|
|
129
|
-
|
|
|
130
|
-
| `
|
|
131
|
-
| `
|
|
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 插件:曲线路径动画
|