RomaControl
大约 2 分钟
RomaControl
漫游控件,支持线路、巡检、第一人称模式。
构造
new VT.RomaControl(viewer, {
// 相机X轴偏移
offsetX: 0,
// 相机Y轴偏移
offsetY: 1.7,
// 相机Z轴偏移
offsetZ: 0,
// 线路漫游配置参数
// 速度,公里/第小时
speed: 40,
// 是否显示路径
showPath: false,
// 线路点位
points: [],
// 模型
model: null,
// 第一人称漫游参数
// 移动单位 0.25米
moveStep: 0.25,
// 巡检漫游配置参数,线路漫游配置需生效
inspectionMode: false,
// 相等距离条件判断,在离目标点位相隔此距离时暂停
equalDistance: 1.0,
// 暂停时间
inspectionPauseTime: 2000, // 巡检停止时间,毫秒
// 线路漫游模式下的音频播放
audio: "",
// 是否自动播放音频
playAudio: true,
})
属性成员
speed
- 类型:
{Number}
速度
moveStep
- 类型:
{Number}
平移速度
audio
- 类型:
{THREE.Audio}
声音播放器
status
- 类型:
{Integer}
当前状态,0, stop , 1 play, 2 pause
points
- 类型:
{Array}
线路坐标数组,[[x, y, z], [x, y, z]...]
path
- 类型:
{THREE.CatmullRomCurve3}
线路
方法
isPlaying
是否漫游中
- isPlaying()
- 类型:
Function
- 参数:无
- 返回:
{Boolean}
isPaused
是否漫游暂停中
- isPaused()
- 类型:
Function
- 参数:无
- 返回:
{Boolean}
isStopped
是否漫游处于停止状态
- isStopped()
- 类型:
Function
- 参数:无
- 返回:
{Boolean}
pickStartPoint
开始拾取第一人称漫游的起始位置
- pickStartPoint()
- 类型:
Function
- 参数:无
- 返回:无
setPoints
设置漫游线路
- setPoints(points)
- 类型:
Function
- 参数:
- points
{Array}
[[x, y, z], [x, y, z]...]
- points
- 返回:无
setAudio
设置音频声音
- setAudio(audio, callback)
- 类型:
Function
- 参数:
- audio
{String}
音频地址,格式: mp3、wav - callback
{Function}
回调方法
- audio
- 返回:无
playAudio
播放音频,需要先设置音频
- playAudio()
- 类型:
Function
- 参数:无
- 返回:无
play
开始漫游
- play()
- 类型:
Function
- 参数:无
- 返回:无
pause
暂停漫游
- pause()
- 类型:
Function
- 参数:无
- 返回:无
stop
停止漫游
- stop()
- 类型:
Function
- 参数:无
- 返回:无
clear
清除漫游
- clear()
- 类型:
Function
- 参数:无
- 返回:无
destory
退出并清除、销毁漫游
- destory()
- 类型:
Function
- 参数:无
- 返回:无
事件
事件名称 | 回调参数 | 事件说明 |
---|---|---|
playing | - | 漫游中 |
play | - | 开始 |
pause | - | 暂停 |
stop | - | 停止 |
inspection.pause | {index, point} | 巡检暂停 |
使用示例:
// 漫游中触发
romaControl.addEventListener("playing", () => {
// 执行代码
});
// 巡检暂停触发
romaControl.addEventListener("inspection.pause", () => {
// 执行代码
});