关于 `@realsee/dnalogel` 中工具函数和类的文档。

### 导入
```ts twoslash
import { Util } from '@realsee/dnalogel'
```

### `Util.blink`
闪烁一个 dom / THREE.Object3D
```ts twoslash

// ---cut---
const target = document.getElementById('my-dom-element')!

Util.blink(target)
Util.reblink(target) // 反向闪烁
```

### `Util.FiveDomEvents`
five空间中的物体的交互系统
```ts twoslash

// ---cut---
const domEvents = new Util.FiveDomEvents(five)

domEvents.addEventListener(object, 'click', () => {
  console.log('Clicked!')
})

domEvents.addEventListener(object, 'hover', () => {
  console.log('Hovered!')
})

domEvents.addEventListener(object, 'unHover', () => {
  console.log('Unhovered!')
})
```

### `Util.FivePuppet`
使用独立 canvas 绘制物体，摄像机位置及视角与 five 保持一致
```ts twoslash

// ---cut---
const fivePuppet = new Util.FivePuppet(five)
fivePuppet.scene.add(object)
```

### `Util.lookObject`
以最佳视角观察一个物体
```ts twoslash

// ---cut---
Util.lookObject(five, object)
```

### `Util.lookPoint`
以最佳视角看向一个坐标点
```ts twoslash

const vector3 = new THREE.Vector3(0, 1, 2)
// ---cut---
Util.lookPoint(five, vector3)
```

### `Util.PointSelector`
选点器，支持触摸屏长按选点
```ts twoslash

// ---cut---
const selector = new Util.PointSelector(five)

// 连续选点
selector.on('select', (intersection) => {
  console.log('Selected point:', intersection?.point)
})

// 选点后自动结束
selector.on('select', (intersection) => {
  console.log('Selected point:', intersection?.point)
  selector.disable()
})

selector.enable()
```

### `Util.sculpt`
封装了一些常用的 mesh。完整数据结构：[data](https://open.realsee.cn/docs/dnalogel/Sculpt#data)
```ts twoslash

// ---cut---
const {
  LineMesh,
  BoxMesh,
  CircleMesh,
  CircleWithEdgeMesh,
  CylinderMesh,
  PointMesh,
  PolygonMesh,
  PrismMesh
} = Util.sculpt

// 在空间中添加 (0,1,2) 点
five.scene.add(new PointMesh({ point: [0, 1, 2] }))

// 添加线
five.scene.add(new LineMesh({ points: [[0, 1, 2], [3, 4, 5]] }))

// 添加多边形
five.scene.add(new PolygonMesh({ points: [[0, 1, 2], [3, 4, 5], [6, 7, 8]] }))

// 添加半径为3的圆，圆心为 (0,1,2) 点
five.scene.add(new CircleMesh({ center: [0, 1, 2], radius: 3 }))

// 添加带边的圆
five.scene.add(new CircleWithEdgeMesh({ center: [0, 1, 2], radius: 3 }))

// 添加柱体
five.scene.add(new CylinderMesh({ bottomCenter: [0, 1, 0], topCenter: [0, 2, 0], radius: 3 }))

// 添加 box，底面矩形为 [[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1]]，高点为 [0, 2, 0]
five.scene.add(new BoxMesh({ 
  points: [
    [0, 0, 0],
    [1, 0, 0],
    [1, 0, 1],
    [0, 0, 1]
  ],
  heightPoint: [0, 2, 0], 
}))

// 添加棱柱
five.scene.add(new PrismMesh({
  points: [
    [0, 0, 0],
    [1, 0, 0],
    [1, 0, 2],
    [1, 0, 1],
    [0, 0, 1]
  ],
  heightPoint: [0, 2, 0], 
}))
```


其他用法请参阅 [Sculpt](https://open.realsee.cn/docs/dnalogel/Sculpt#创建物体)，例如绘制一个 boxMesh 并启用 box 编辑功能。
```ts twoslash

// ---cut---
const { PointSelector } = Util
const { BoxMesh, BoxMeshEditor, createBox } = Util.sculpt

// 创建 boxMesh
const boxMesh = new BoxMesh({ lineColor: 0xff0000 })
five.scene.add(boxMesh)

// 按需初始化编辑器
const editor = new BoxMeshEditor(boxMesh)

// 创建选择器
const pointSelector = new PointSelector(five)

createBox(boxMesh, pointSelector).then(() => {
  console.log('绘制完成')

  // 按需启用编辑功能
  editor.enable()
})
```

### `Util.tag`
轻量化的标签
```ts twoslash

// ---cut---
const tag1 = Util.tag(five, [0, 1, 2])
tag1.container.innerHTML = '<div>tag1</div>'

const tag2 = Util.tag(five, [0, 1, 2])
tag2.container.innerHTML = '<div>tag2</div>'
```
或：先初始化，后设置位置
```ts twoslash

// ---cut---
const tag = Util.tag(five)
tag.container.innerHTML = '<div>tag</div>'

tag.setPosition(new THREE.Vector3(0, 1, 2))
```

网页版本：https://open.realsee.cn/docs/dnalogel/Util
文档索引：https://open.realsee.cn/docs.md
