1
This commit is contained in:
40
public/docs/hotspot-events.md
Normal file
40
public/docs/hotspot-events.md
Normal file
@ -0,0 +1,40 @@
|
||||
# 热点与事件
|
||||
|
||||
## 渲染热点
|
||||
```ts
|
||||
const hotspots = [
|
||||
{
|
||||
id: 'engine',
|
||||
position: [0.8, 0.6, -0.2],
|
||||
icon: 'info',
|
||||
label: '发动机舱',
|
||||
event: 'show-engine',
|
||||
payload: { part: 'engine' },
|
||||
},
|
||||
{
|
||||
id: 'door',
|
||||
position: [1.1, 0.9, 0.4],
|
||||
icon: 'action',
|
||||
label: '开启车门',
|
||||
event: 'toggle-door',
|
||||
payload: { side: 'left' },
|
||||
},
|
||||
]
|
||||
|
||||
sdk.hotspot.render(hotspots)
|
||||
```
|
||||
|
||||
## 订阅事件
|
||||
```ts
|
||||
sdk.hotspot.on('click', ({ id, payload }) => {
|
||||
// 根据 id/payload 触发业务逻辑
|
||||
})
|
||||
|
||||
sdk.hotspot.on('hover', ({ id, hovering }) => {
|
||||
// hover 高亮或提示
|
||||
})
|
||||
```
|
||||
|
||||
## 事件命名建议
|
||||
- `hotspot:click`、`hotspot:hover`、`hotspot:focus`
|
||||
- `hotspot:rendered`(所有热点就绪)
|
||||
Reference in New Issue
Block a user