deep-engine-demo/packages/docs/api/mesh/Icon.md
2026-04-19 18:46:28 +08:00

91 lines
1.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
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` 的公开方法调用。