Skip to main content

Actor Viewer

ActorViewer 提供观察 actor 的能力,并提供双指缩放、滚轮缩放、单指旋转功能、使用方式如下:

进入观察页面

const actor = world.spawn(IExtendedActor)

// 进入观察actor页面, bgUrl为背景图, 默认支持任意角度旋转
await world.getActorViewer().enterViewMode({
actor: actor,
bgUrl: 'http://xxxxx',
// 指定是否使用环物相机来观察,默认为true
useRotateCamera: true,
})

限制仅水平旋转

const actor = world.spawn(IExtendedActor)

await world.getActorViewer().enterViewMode({
actor: actor,
bgUrl: 'http://xxxxx',
horizontalRotateOnly: true,
mode: 'horizontalRotateOnly',
})

限制仅垂直方向旋转

const actor = world.spawn(IExtendedActor)

await world.getActorViewer().enterViewMode({
actor: actor,
bgUrl: 'http://xxxxx',
mode: 'verticalRotateOnly',
})

退出观察页面

// 销毁 actor
actor.dispose()
// 退出观察页面
world.getActorViewer().exit()