feat(all): init commit

This commit is contained in:
plum
2026-04-19 18:46:28 +08:00
commit 5d7f479765
479 changed files with 178500 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
---
outline: [2, 3]
---
# ClippingHelper
- 源文件:`packages/sdk/src/mesh/ClippingHelper.ts`
- 文档位置:`packages/docs/api/mesh/ClippingHelper.md`
## 类:`ClippingHelper`
- 作用:剖切平面辅助对象,用于可视化 {@link THREE.Plane} 实例。 ```js const plane = new THREE.Plane( new THREE.Vector3( 1, 1, 0.2 ), 3 ); const helper = new ClippingHelper( plane, 1, 1, 0xffff00 ); scene.add( helper ); ```
- 继承/实现:`extends THREE.Line`
### 构造函数
#### `new ClippingHelper(plane: THREE.Plane, width: number = 1, height: number = 1, hex: number | THREE.Color | string = 0xffff00)`
- 作用:构造一个新的剖切平面辅助对象。
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `plane` | `THREE.Plane` | 是 | - 要可视化的平面。 |
| `width` | `number` | 否 | - 辅助对象的宽度。 |
| `height` | `number` | 否 | - 辅助对象的高度。 |
| `hex` | `number \| THREE.Color \| string` | 否 | - 辅助对象的颜色。 |
- 出参:`ClippingHelper`
- 返回说明:返回当前类实例。
### 属性
| 属性名 | 可见性 | 类型 | 作用 |
| --- | --- | --- | --- |
| `plane` | `public` | `THREE.Plane` | 要可视化的平面。 |
| `width` | `public` | `number` | 辅助对象的宽度。 |
| `height` | `public` | `number` | 辅助对象的高度。 |
| `topRotateHandle` | `public` | `THREE.Sprite \| null` | 上方旋转手柄 Sprite(绕局部 X 轴旋转) |
| `rightRotateHandle` | `public` | `THREE.Sprite \| null` | 右方旋转手柄 Sprite(绕局部 Y 轴旋转) |
| `textureBasePath` | `public` | `string` | 纹理基础路径(由外部注入,通常为 Vite 的 base 路径) |
### 方法
#### `showRotateHandles(show: boolean): void`
- 作用:显示或隐藏旋转控制手柄。 首次调用 show=true 时会懒加载纹理并创建 Sprite。
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `show` | `boolean` | 是 | 是否显示 |
- 出参:`void`
- 返回说明:无返回值。
#### `dispose(): void`
- 作用:释放辅助对象占用的资源。
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
## 构造示例
- 当前 Demo 中没有直接展示 `ClippingHelper` 的构造调用。
## 函数示例
- 当前 Demo 中没有直接展示 `ClippingHelper` 的公开方法调用。
+411
View File
@@ -0,0 +1,411 @@
---
outline: [2, 3]
---
# CubePanel
- 源文件:`packages/sdk/src/mesh/CubePanel.ts`
- 文档位置:`packages/docs/api/mesh/CubePanel.md`
## 枚举:`LabelPosition`
- 作用:标签位置枚举
| 枚举项 | 值 | 说明 |
| --- | --- | --- |
| `TOP` | `'top'` | 枚举值 `TOP`。 |
| `BOTTOM` | `'bottom'` | 枚举值 `BOTTOM`。 |
| `LEFT` | `'left'` | 枚举值 `LEFT`。 |
| `RIGHT` | `'right'` | 枚举值 `RIGHT`。 |
## 接口:`ISmallTextConfig`
- 作用:小字配置接口
### 字段
| 字段名 | 类型 | 必填 | 作用 |
| --- | --- | --- | --- |
| `text` | `string` | 是 | 文字内容 |
| `cubeIndex` | `number` | 是 | 目标正方体索引(0-4),-1 表示全部 |
| `rotation` | `number` | 否 | 旋转角度(度) |
| `fontSize` | `number` | 否 | 字体大小(像素) |
| `color` | `string` | 否 | 字体颜色 |
| `fontWeight` | `string` | 否 | 字体权重 |
| `offset` | `number` | 否 | 与面板边缘的距离(3D单位) |
## 接口:`ICubeData`
- 作用:小正方体数据接口
### 字段
| 字段名 | 类型 | 必填 | 作用 |
| --- | --- | --- | --- |
| `color` | `THREE.Color` | 是 | 颜色 |
| `text` | `string` | 是 | 文字 |
## 接口:`ISinglePanelOptions`
- 作用:单个面板配置选项
### 字段
| 字段名 | 类型 | 必填 | 作用 |
| --- | --- | --- | --- |
| `name` | `string` | 是 | 面板名称 |
| `size` | `number` | 否 | 面板大小,three 的单位 |
| `cubeSize` | `number` | 否 | 小正方体大小 |
| `cubeGap` | `number` | 否 | 小正方体间距 |
| `position` | `THREE.Vector3` | 否 | 面板位置 |
| `rotation` | `THREE.Euler` | 否 | 面板旋转 |
| `initialData` | `ICubeData[][]` | 否 | 初始数据 |
| `titleConfig` | `{ text: string; position: LabelPosition; rotation?: number; fontSize?: number; color?: string; offset?: number; }` | 否 | 标题配置 |
| `smallTextConfig` | `{ position: LabelPosition; smallText1?: ISmallTextConfig[]; smallText2?: ISmallTextConfig[]; rotation?: number; }` | 否 | 小字乐配置 |
| `visibleColumns` | `number[]` | 否 | 可见列索引数组,只有这些列会显示,其他列显示为白色 |
## 类:`CubePanel`
- 作用:单个面板类 表示一个由5*5个小正方体构成的面板
### 构造函数
#### `new CubePanel(options: ISinglePanelOptions)`
- 作用:创建单个面板
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `options` | `ISinglePanelOptions` | 是 | - 配置选项 |
- 出参:`CubePanel`
- 返回说明:返回当前类实例。
### 属性
| 属性名 | 可见性 | 类型 | 作用 |
| --- | --- | --- | --- |
| `name` | `public` | `string` | 面板名称 |
| `group` | `public` | `THREE.Group` | 面板组对象 |
| `cubeData` | `public` | `Map<string, ICubeData>` | 小正方体数据映射 |
| `panelMesh` | `public` | `THREE.Mesh \| null` | 面板网格 |
| `options` | `public` | `Required<ISinglePanelOptions>` | 配置选项 |
| `titleObject` | `public` | `THREE.Mesh \| null` | 标题对象 |
| `titleConfig` | `public` | `{ text: string; position: LabelPosition; rotation: number; fontSize: number; color: string; offset?: number } \| null` | 标题配置 |
| `fontLoader` | `public` | `FontLoader` | 字体加载器 |
| `font` | `public` | `any` | 加载的字体 |
| `smallTextObjects` | `public` | `THREE.Mesh[]` | 小字对象数组 |
| `smallTextPlanes` | `public` | `THREE.Mesh[]` | 小字平面几何体数组 |
| `smallTextCanvas` | `public` | `HTMLCanvasElement \| null` | 小字生成的 canvas |
| `visibleColumns` | `public` | `Set<number>` | 可见列索引集合 |
### 方法
#### `getModelSize(targetModel: THREE.Object3D): THREE.Vector3 | null`
- 作用:静态方法:获取场景中指定名称的模型并计算其包围盒大小
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `targetModel` | `THREE.Object3D` | 是 | 参数 `targetModel`,类型为 `THREE.Object3D`。 |
- 出参:`THREE.Vector3 \| null`
- 返回说明:模型的包围盒大小,如果未找到模型则返回 null
#### `getModelFaceCenters(targetModel: THREE.Object3D): { [key: string]: THREE.Vector3; } | null`
- 作用:静态方法:获取场景中指定名称的模型并计算其包围盒六个面的中心点位置
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `targetModel` | `THREE.Object3D` | 是 | 参数 `targetModel`,类型为 `THREE.Object3D`。 |
- 出参:`{ [key: string]: THREE.Vector3; } \| null`
- 返回说明:模型的包围盒六个面的中心点位置,如果未找到模型则返回 null
#### `createPanel(): void`
- 作用:创建面板
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `initDefaultData(): void`
- 作用:初始化默认数据
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `generatePanelHTML(): string`
- 作用:生成面板的 HTML
- 入参:无
- 出参:`string`
- 返回说明:HTML 字符串
#### `updatePanelTexture(): Promise<void>`
- 作用:将 HTML 转换为纹理并更新面板
- 入参:无
- 出参:`Promise<void>`
- 返回说明:返回 Promise,解析结果类型为 `void`
#### `setCubeData(row: number, col: number, data: ICubeData): void`
- 作用:设置小正方体数据
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `row` | `number` | 是 | - 行索引 |
| `col` | `number` | 是 | - 列索引 |
| `data` | `ICubeData` | 是 | - 小正方体数据 |
- 出参:`void`
- 返回说明:无返回值。
#### `getCubeData(row: number, col: number): ICubeData | undefined`
- 作用:获取小正方体数据
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `row` | `number` | 是 | - 行索引 |
| `col` | `number` | 是 | - 列索引 |
- 出参:`ICubeData \| undefined`
- 返回说明:小正方体数据
#### `setPanelData(data: ICubeData[][]): void`
- 作用:批量设置面板数据
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `data` | `ICubeData[][]` | 是 | - 面板数据 |
- 出参:`void`
- 返回说明:无返回值。
#### `setTitle(titleConfig: ISinglePanelOptions['titleConfig']): void`
- 作用:设置面板标题
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `titleConfig` | `ISinglePanelOptions['titleConfig']` | 是 | - 标题配置 |
- 出参:`void`
- 返回说明:无返回值。
#### `loadFontAndCreateTitle(): void`
- 作用:加载字体并创建标题
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `createTitleObject(): void`
- 作用:创建标题对象
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `setSmallText(smallTextConfig: ISinglePanelOptions['smallTextConfig']): Promise<void>`
- 作用:设置小字
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `smallTextConfig` | `ISinglePanelOptions['smallTextConfig']` | 是 | - 小字配置 |
- 出参:`Promise<void>`
- 返回说明:返回 Promise,解析结果类型为 `void`
#### `createSmallTextHTML(smallTextConfig: ISinglePanelOptions['smallTextConfig']): Promise<void>`
- 作用:使用 HTML 实现小字,在一个大的 div 中创建所有小字,然后转为 canvas 到一个新的平面几何体
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `smallTextConfig` | `ISinglePanelOptions['smallTextConfig']` | 是 | - 小字配置 |
- 出参:`Promise<void>`
- 返回说明:返回 Promise,解析结果类型为 `void`
#### `clearSmallText(): void`
- 作用:清理小字
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `clearTitle(): void`
- 作用:清理标题对象
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `addDebugSpheres(): void`
- 作用:添加调试小球,在小字和mountGroup的原点添加不同颜色的小球
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `clearDebugSpheres(): void`
- 作用:清理调试小球
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `dispose(): void`
- 作用:销毁面板
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `setVisibleColumns(columns: number[]): void`
- 作用:设置可见列
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `columns` | `number[]` | 是 | - 可见列索引数组 |
- 出参:`void`
- 返回说明:无返回值。
#### `toggleColumnVisibility(column: number): void`
- 作用:切换列的可见性
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `column` | `number` | 是 | - 列索引 |
- 出参:`void`
- 返回说明:无返回值。
## 构造示例
- 来源:`packages/demo/src/panels/TunnelScene/LoadSurface.vue`
```ts
text: config.title,
position: LabelPosition.TOP,
rotation: 0,
fontSize: 1,
color: '#000000',
offset: 1
},
smallTextConfig: config.smallTextConfig,
// ZD 面只显示第2列(索引为2)
visibleColumns: key === 'ZD' ? [2] : undefined
};
const panel = new CubePanel(panelOptions);
panel.group.visible = false; // 初始隐藏
viewer.scene.add(panel.group);
panels.set(key, panel);
});
```
## 函数示例
### `CubePanel.getModelFaceCenters`
- 来源:`packages/demo/src/panels/TunnelScene/LoadSurface.vue`
```ts
if (!viewer) return;
// 使用 CubePanel 的静态方法获取模型包围盒六个面的中心点位置
// const faceCenters = CubePanel.getModelFaceCenters(bus.getRockSample());
const faceCenters = {
"YF": {
"x": 0,
"y": 0,
"z": 2.5
},
"BEI": {
"x": 0,
"y": 0,
"z": -2.5
},
"ZUO": {
"x": -2.5,
"y": 0,
"z": 0
},
"YOU": {
"x": 2.5,
```
## Demo 参考
### `LabelPosition`
以下示例文件中可以看到该 API 的实际调用方式:
- `packages/demo/src/panels/TunnelScene/LoadSurface.vue`
### `ISinglePanelOptions`
以下示例文件中可以看到该 API 的实际调用方式:
- `packages/demo/src/panels/TunnelScene/LoadSurface.vue`
### `CubePanel`
以下示例文件中可以看到该 API 的实际调用方式:
- `packages/demo/src/panels/TunnelScene/LoadSurface.vue`
+262
View File
@@ -0,0 +1,262 @@
---
outline: [2, 3]
---
# FlowLine
- 源文件:`packages/sdk/src/mesh/FlowLine.ts`
- 文档位置:`packages/docs/api/mesh/FlowLine.md`
## 类:`FlowLine`
- 作用:FlowLine 类。
### 构造函数
#### `new FlowLine(options: { points?: THREE.Vector3[]; textureUrl?: string | null; radius?: number; radialSegments?: number; cornerRadius?: number; cornerSplit?: number; scrollSpeed?: number; flowDirection?: number; [key: string]: any; } = {})`
- 作用:创建 FlowLine 实例。
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `options` | `{ points?: THREE.Vector3[]; textureUrl?: string \| null; radius?: number; radialSegments?: number; cornerRadius?: number; cornerSplit?: number; scrollSpeed?: number; flowDirection?: number; [key: string]: any; }` | 否 | 当前功能对应的配置项。 |
- 出参:`FlowLine`
- 返回说明:返回当前类实例。
### 属性
| 属性名 | 可见性 | 类型 | 作用 |
| --- | --- | --- | --- |
| `points` | `public` | `THREE.Vector3[]` | 用于保存 `points` 的集合数据。 |
| `textureUrl` | `public` | `string \| null` | 用于保存 `textureUrl` 对应的数据。 |
| `options` | `public` | `{ radius: number; radialSegments: number; cornerRadius: number; cornerSplit: number; scrollSpeed: number; flowDirection: number; }` | 用于保存 `options` 对应的数据。 |
| `pathPointList` | `public` | `PathPointList \| null` | 用于保存 `pathPointList` 对应的数据。 |
| `geometry` | `public` | `PathTubeGeometry \| null` | 用于保存 `geometry` 对应的数据。 |
| `material` | `public` | `THREE.MeshPhongMaterial \| null` | 材质参数。 |
| `mesh` | `public` | `THREE.Mesh \| null` | 用于保存 `mesh` 对应的数据。 |
| `texture` | `public` | `THREE.Texture \| null` | 用于保存 `texture` 对应的数据。 |
| `playing` | `public` | `boolean` | 用于标记 `playing` 的启用状态。 |
| `progress` | `public` | `number` | 用于保存 `progress` 对应的数据。 |
| `playSpeed` | `public` | `number` | 用于保存 `playSpeed` 对应的数据。 |
| `textureAnimating` | `public` | `boolean` | 用于标记 `textureAnimating` 的启用状态。 |
| `textureAnimationSpeed` | `public` | `number` | 用于保存 `textureAnimationSpeed` 对应的数据。 |
### 方法
#### `init(): void`
- 作用:执行 init 初始化逻辑。
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `loadTexture(url: string): void`
- 作用:加载 Texture。
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `url` | `string` | 是 | 资源地址。 |
- 出参:`void`
- 返回说明:无返回值。
#### `addToScene(scene: THREE.Scene): void`
- 作用:添加 To Scene。
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `scene` | `THREE.Scene` | 是 | 目标场景实例。 |
- 出参:`void`
- 返回说明:无返回值。
#### `removeFromScene(scene: THREE.Scene): void`
- 作用:移除 From Scene。
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `scene` | `THREE.Scene` | 是 | 目标场景实例。 |
- 出参:`void`
- 返回说明:无返回值。
#### `startAnimation(): void`
- 作用:执行 start Animation 相关逻辑。
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `stopAnimation(): void`
- 作用:执行 stop Animation 相关逻辑。
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `startTextureAnimation(): void`
- 作用:开始纹理动画
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `stopTextureAnimation(): void`
- 作用:停止纹理动画
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `update(): void`
- 作用:更新 update。
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `updateTextureAnimation(): void`
- 作用:更新纹理动画
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `setTextureAnimationSpeed(speed: number): void`
- 作用:设置纹理动画速度
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `speed` | `number` | 是 | 速度系数,1.0 为默认速度 |
- 出参:`void`
- 返回说明:无返回值。
#### `getTextureAnimationSpeed(): number`
- 作用:获取纹理动画速度
- 入参:无
- 出参:`number`
- 返回说明:纹理动画速度
#### `toggleTextureAnimation(): boolean`
- 作用:切换纹理动画状态
- 入参:无
- 出参:`boolean`
- 返回说明:切换后的状态
#### `setFlowDirection(direction: number): void`
- 作用:设置 Flow Direction。
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `direction` | `number` | 是 | 参数 `direction`,类型为 `number`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `setScrollSpeed(speed: number): void`
- 作用:设置 Scroll Speed。
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `speed` | `number` | 是 | 参数 `speed`,类型为 `number`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `setPlaySpeed(speed: number): void`
- 作用:设置 Play Speed。
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `speed` | `number` | 是 | 参数 `speed`,类型为 `number`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `updatePoints(points: THREE.Vector3[]): void`
- 作用:更新 Points。
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `points` | `THREE.Vector3[]` | 是 | 参数 `points`,类型为 `THREE.Vector3[]`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `updateRadius(radius: number): void`
- 作用:更新 Radius。
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `radius` | `number` | 是 | 半径参数。 |
- 出参:`void`
- 返回说明:无返回值。
#### `getMesh(): THREE.Mesh<THREE.BufferGeometry<THREE.NormalBufferAttributes, THREE.BufferGeometryEventMap>, THREE.Material<THREE.MaterialEventMap> | THREE.Material<THREE.MaterialEventMap>[], THREE.Object3DEventMap> | null`
- 作用:获取 Mesh。
- 入参:无
- 出参:`THREE.Mesh<THREE.BufferGeometry<THREE.NormalBufferAttributes, THREE.BufferGeometryEventMap>, THREE.Material<THREE.MaterialEventMap> \| THREE.Material<THREE.MaterialEventMap>[], THREE.Object3DEventMap> \| null`
- 返回说明:返回 `THREE.Mesh<THREE.BufferGeometry<THREE.NormalBufferAttributes, THREE.BufferGeometryEventMap>, THREE.Material<THREE.MaterialEventMap> | THREE.Material<THREE.MaterialEventMap>[], THREE.Object3DEventMap> | null`
## 构造示例
- 当前 Demo 中没有直接展示 `FlowLine` 的构造调用。
## 函数示例
- 当前 Demo 中没有直接展示 `FlowLine` 的公开方法调用。
+269
View File
@@ -0,0 +1,269 @@
---
outline: [2, 3]
---
# HtmlPanel
- 源文件:`packages/sdk/src/mesh/HtmlPanel.ts`
- 文档位置:`packages/docs/api/mesh/HtmlPanel.md`
## 枚举:`CssType`
- 作用:CSS渲染类型枚举
| 枚举项 | 值 | 说明 |
| --- | --- | --- |
| `CSS2D` | `'css2d'` | 枚举值 `CSS2D`。 |
| `CSS3D` | `'css3d'` | 枚举值 `CSS3D`。 |
| `CSS3DSprite` | `'css3dsprite'` | 枚举值 `CSS3DSprite`。 |
## 类:`HtmlPanel`
- 作用:HTML面板基础类
### 构造函数
#### `new HtmlPanel(public type: CssType = CssType.CSS3D)`
- 作用:构造函数
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `type` | `CssType` | 否 | CSS渲染类型 |
- 出参:`HtmlPanel`
- 返回说明:返回当前类实例。
### 属性
| 属性名 | 可见性 | 类型 | 作用 |
| --- | --- | --- | --- |
| `container` | `public` | `HTMLDivElement` | 用于保存 `container` 对应的数据。 |
| `cssObject` | `public` | `THREE.Object3D` | 用于保存 `cssObject` 对应的数据。 |
| `isVisible` | `public` | `boolean` | 用于标记 `isVisible` 的启用状态。 |
| `position` | `public` | `THREE.Vector3` | 位置数据。 |
### 方法
#### `getCssObject(): THREE.Object3D<THREE.Object3DEventMap>`
- 作用:获取CSS对象
- 入参:无
- 出参:`THREE.Object3D<THREE.Object3DEventMap>`
- 返回说明:返回 `THREE.Object3D<THREE.Object3DEventMap>`
#### `getUniqueId(): string`
- 作用:获取唯一ID
- 入参:无
- 出参:`string`
- 返回说明:CSS对象的UUID
#### `show(): void`
- 作用:显示面板
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `hide(): void`
- 作用:隐藏面板
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `toggle(): void`
- 作用:切换面板可见性
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `updatePosition(position: THREE.Vector3): void`
- 作用:更新面板位置
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `position` | `THREE.Vector3` | 是 | 新位置 |
- 出参:`void`
- 返回说明:无返回值。
#### `updateContent(content: string): void`
- 作用:更新面板内容
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `content` | `string` | 是 | 新内容 |
- 出参:`void`
- 返回说明:无返回值。
#### `getVisible(): boolean`
- 作用:获取弹窗可见性
- 入参:无
- 出参:`boolean`
- 返回说明:返回布尔结果。
#### `changeCssType(type: CssType): THREE.Object3D<THREE.Object3DEventMap>`
- 作用:动态修改CSS类型
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `type` | `CssType` | 是 | 新的CSS渲染类型 |
- 出参:`THREE.Object3D<THREE.Object3DEventMap>`
- 返回说明:新的CSS对象
#### `getCssType(): CssType`
- 作用:获取当前CSS类型
- 入参:无
- 出参:`CssType`
- 返回说明:返回 `CssType`
#### `dispose(): void`
- 作用:销毁面板,清理所有资源
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `createCssObject(): void`
- 作用:创建CSS对象
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
## 构造示例
- 来源:`packages/demo/src/components/htmlPanel/DrillingModal.ts`
```ts
/**
* 钻进信息面板类
*/
export class DrillingModal extends HtmlPanel {
private drillingData: IDrillingData = {
pipeName: '',
drillingSpeed: 0,
currentDepth: 0,
targetDepth: 0,
progress: 0,
pipeRadius: 0,
status: 'stopped'
};
```
## 函数示例
### `HtmlPanel.getCssObject`
- 来源:`packages/demo/src/panels/GoldMineScene/VentilationFillingPanel.vue`
```ts
if (fillingHtmlPanel) {
viewer?.scene.remove(fillingHtmlPanel.getCssObject());
fillingHtmlPanel = null;
}
```
### `HtmlPanel.getUniqueId`
- 来源:`packages/demo/src/htmlPanel/GoldMineScene/AirSupplyHtmlPanel.ts`
```ts
/**
* 构造函数
* @param type CSS渲染类型
*/
constructor(type: CssType = CssType.CSS2D) {
super(type);
this.uuid = this.getUniqueId();
this.initContent();
this.attachDeleteEvent();
}
```
### `HtmlPanel.show`
- 来源:`packages/demo/src/panels/GoldMineScene/VentilationFillingPanel.vue`
```ts
// 初始化数据
fillingHtmlPanel.updateData({
progress: fillingStatus.value.progress,
currentTime: (Date.now() - fillingStatus.value.startTime) / 1000,
endTime: fillingParams.value.endTime,
material: fillingParams.value.material,
fillingRate: fillingParams.value.fillingRate,
pressure: fillingParams.value.pressure,
status: fillingStatus.value.isRunning ? 'running' : 'stopped'
});
fillingHtmlPanel.updatePosition(new THREE.Vector3(position.x, position.y + 1, position.z));
fillingHtmlPanel.show();
viewer?.scene.add(fillingHtmlPanel.getCssObject());
};
```
## Demo 参考
### `CssType`
以下示例文件中可以看到该 API 的实际调用方式:
- `packages/demo/src/components/htmlPanel/DrillingModal.ts`
- `packages/demo/src/components/htmlPanel/PrintModelModal.ts`
- `packages/demo/src/components/htmlPanel/RuptureEventModal.ts`
- `packages/demo/src/components/htmlPanel/SensorModal.ts`
- `packages/demo/src/components/htmlPanel/SingleSensorModal.ts`
- `packages/demo/src/components/htmlPanel/TunnelModal.ts`
- `packages/demo/src/disasterFormationPanel/TunnelScene/RockBurstPanel.vue`
- `packages/demo/src/disasterFormationPanel/TunnelScene/RuptureEventPanel.vue`
### `HtmlPanel`
以下示例文件中可以看到该 API 的实际调用方式:
- `packages/demo/src/components/htmlPanel/DrillingModal.ts`
- `packages/demo/src/components/htmlPanel/PrintModelModal.ts`
- `packages/demo/src/components/htmlPanel/RuptureEventModal.ts`
- `packages/demo/src/components/htmlPanel/SensorModal.ts`
- `packages/demo/src/components/htmlPanel/SingleSensorModal.ts`
- `packages/demo/src/components/htmlPanel/TunnelModal.ts`
- `packages/demo/src/htmlPanel/GoldMineScene/AirSupplyHtmlPanel.ts`
- `packages/demo/src/htmlPanel/GoldMineScene/DrillingHtmlPanel.ts`
+90
View File
@@ -0,0 +1,90 @@
---
outline: [2, 3]
---
# Icon
- 源文件:`packages/sdk/src/mesh/Icon.ts`
- 文档位置:`packages/docs/api/mesh/Icon.md`
## 类:`Icon`
- 作用:图标类 - 表示单个精灵图图标
- 继承/实现:`extends THREE.Sprite`
### 构造函数
#### `new Icon(id: string, textureUrl: string, size: number = 1)`
- 作用:构造函数
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `id` | `string` | 是 | 图标唯一标识 |
| `textureUrl` | `string` | 是 | 精灵图纹理URL |
| `size` | `number` | 否 | 图标大小 |
- 出参:`Icon`
- 返回说明:返回当前类实例。
### 属性
| 属性名 | 可见性 | 类型 | 作用 |
| --- | --- | --- | --- |
| `id` | `public` | `string` | 用于保存 `id` 对应的数据。 |
### 方法
#### `getId(): string`
- 作用:获取图标ID
- 入参:无
- 出参:`string`
- 返回说明:图标唯一标识
#### `setPosition(position: THREE.Vector3): this`
- 作用:设置图标位置
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `position` | `THREE.Vector3` | 是 | 新位置 |
- 出参:`this`
- 返回说明:当前图标实例
#### `setSize(size: number): this`
- 作用:设置图标大小
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `size` | `number` | 是 | 新大小 |
- 出参:`this`
- 返回说明:当前图标实例
#### `dispose(): void`
- 作用:销毁图标,清理资源
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
## 构造示例
- 当前 Demo 中没有直接展示 `Icon` 的构造调用。
## 函数示例
- 当前 Demo 中没有直接展示 `Icon` 的公开方法调用。
+115
View File
@@ -0,0 +1,115 @@
---
outline: [2, 3]
---
# SpritePanel
- 源文件:`packages/sdk/src/mesh/SpritePanel.ts`
- 文档位置:`packages/docs/api/mesh/SpritePanel.md`
## 接口:`SpritePanelOptions`
- 作用:SpritePanelOptions 的结构定义。
### 字段
| 字段名 | 类型 | 必填 | 作用 |
| --- | --- | --- | --- |
| `text` | `string` | 是 | 用于保存 `text` 对应的数据。 |
| `textColor` | `string` | 否 | 用于保存 `textColor` 对应的数据。 |
| `backgroundColor` | `string` | 否 | 用于保存 `backgroundColor` 对应的数据。 |
| `borderColor` | `string` | 否 | 用于保存 `borderColor` 对应的数据。 |
| `borderWidth` | `number` | 否 | 用于保存 `borderWidth` 对应的数据。 |
| `fontSize` | `number` | 否 | 用于保存 `fontSize` 对应的数据。 |
| `padding` | `number` | 否 | 用于保存 `padding` 对应的数据。 |
| `sizeAttenuation` | `boolean` | 否 | 用于标记 `sizeAttenuation` 的启用状态。 |
## 类:`SpritePanel`
- 作用:精灵面板类 - 显示带背景和边框的文字面板
- 继承/实现:`extends THREE.Sprite`
### 构造函数
#### `new SpritePanel(options: SpritePanelOptions)`
- 作用:创建 SpritePanel 实例。
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `options` | `SpritePanelOptions` | 是 | 当前功能对应的配置项。 |
- 出参:`SpritePanel`
- 返回说明:返回当前类实例。
### 属性
| 属性名 | 可见性 | 类型 | 作用 |
| --- | --- | --- | --- |
| `canvas` | `public` | `HTMLCanvasElement` | 用于保存 `canvas` 对应的数据。 |
| `context` | `public` | `CanvasRenderingContext2D` | 用于保存 `context` 对应的数据。 |
| `options` | `public` | `Required<SpritePanelOptions>` | 用于保存 `options` 对应的数据。 |
### 方法
#### `setText(text: string): void`
- 作用:设置 Text。
- 入参:
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | --- |
| `text` | `string` | 是 | 参数 `text`,类型为 `string`。 |
- 出参:`void`
- 返回说明:无返回值。
#### `dispose(): void`
- 作用:释放资源并销毁当前实例。
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
#### `updateTexture(): void`
- 作用:更新 Texture。
- 入参:无
- 出参:`void`
- 返回说明:无返回值。
## 构造示例
- 来源:`packages/demo/src/disasterFormationPanel/GoldMineScene/HeatDisasterLabelPanel.vue`
```ts
const viewer = bus.getViewer();
label = new SpritePanel({
text: '热害',
textColor: '#ffffff',
backgroundColor: '#ff4444',
borderColor: '#cc0000',
borderWidth: 4
});
```
## 函数示例
- 当前 Demo 中没有直接展示 `SpritePanel` 的公开方法调用。
## Demo 参考
### `SpritePanel`
以下示例文件中可以看到该 API 的实际调用方式:
- `packages/demo/src/disasterFormationPanel/GoldMineScene/HeatDisasterLabelPanel.vue`