批注插件
批注插件
批注是指,我们在场景中对模型的某些特征,使用矩形或圆形来进行框选或者直接批注,也可以单独或者叠加使用文本来进行注解。
在批注过程中,我们可以动态调整批注数据的颜色、大小并进行移动或清除。最后完成场景的批注后,可对其进行下载导出。
1. 功能说明
批注插件功能:批注、移动、清除、导出。
1.1 批注
批注有图形批注和文本批注两种类型。图形批注可以选择圆形或矩形进行操作。
我们可以选择喜欢的颜色或者大小来创建批注。
1.2 移动
可选中对创建好的批注进行移动。
1.3 清除
选中不需要的批注进行清除操作。
1.4 导出
直接对当前场景视图进行下载导出。
2. 构造
const notePlugin = new ubm.NotePlugin()
3. 属性
| 属性 | 类型 | 可选 | 说明 |
|---|---|---|---|
| noteGroups | INoteGroup[] | --- | 批注组数据 |
| graphics | INoteGraphic[] | --- | 批注数据 |
- 批注数据是由多个不同的批注组分类组成,每个批注组又由多个不同的图形合成。
- 目前我们的批注数据都在一个组别中,后期会扩展成多个组,此处仅仅只定义了组的概念。
3.1 批注组数据
批注组INoteGroup的数据结果如下:
interface INoteGroup {
// 批注组ID,默认为1
id: string | number
// 批注组名称
name: string
// 批注组时间
time: string
// 批注数据集合,默认为[]
graphics?: INoteGraphic[]
}
当前只有一个批注组,属性都是默认值,批注的动态更新都在属性graphics中体现。
获取批注组数据集合,代码示例如下:
const noteGroupsData = notePlugin.noteGroups
3.2 批注数据
批注数据INoteGraphic的数据结构如下:
interface INoteGraphic {
// ID
id: string | number
// 位置
location: Location
// 类型 文本'text' | 圆形'circle' | 矩形'rectangle'
type: 'text' | 'circle' | 'rectangle',
// 大小
size?: number
// 颜色
color?: string
// 值
value?: string
// 宽度
width?: number
// 高度
height?: number
}
使用时需要注意以下两点
- 属性
value是跟随type为text的。 - 属性
width和height是跟随type为circle或者rectangle的。
4. 方法
| 方法 | 说明 |
|---|---|
| handleCreateNote() | 创建指定类别的批注 |
| create() | 创建指定的批注 |
| delGroup() | 删除批注分组 |
| clear() | 清空所有批注 |
| delNote() | 删除批注 |
| changeDomGraphic() | 改变批注状态 |
| saveToImg() | 将当前批注进行截图并下载 |
4.1 创建指定类别的批注
handleCreateNote(type: string): void
参数type是批注类型,有text、circle和rectangle。
创建指定类别的批注数据,代码示例如下:
notePlugin.model.handleCreateNote('text')
4.2 创建指定的批注
create(noteGroups: INoteGroup[]): void
参数noteGroups是批注数据,可参考属性noteGroups。
已知批注数据noteGroups,直接在场景中创建批注,代码示例如下:
notePlugin.create(noteGroupsData)
4.3 删除批注分组
delGroup(id: number): void
参数id是批注分组id,目前只有一个id为1的分组。
执行删除批注分组,则批注数据合集noteGroups会为空,代码示例如下:
notePlugin.model.delGroup(1)
4.4 清空所有批注
clear(): void
清除当前场景中的全部批注,不区分组别,代码示例如下:
notePlugin.model.clear()
4.5 删除批注
delNote(id: number): void
参数id是批注id
删除指定批注,并更新属性graphics中的数据,代码示例如下:
notePlugin.model.delNote(1724399653446)
4.6 改变批注状态
changeDomGraphic(type: string): void
参数type的值有:move和pointer
修改批注为可以移动状态,代码示例如下:
notePlugin.model.changeDomGraphic('move')
4.7 导出
saveToImg(): void
把当前场景的批注转化成图片并下载,代码示例如下:
notePlugin.model.saveToImg()

BIMFlux AI
