Class: RoamingController

RoamingController

控制漫游的开始、暂停、播放、改变速度、设置漫游时间与间隔、 添加路径、删除路径、追踪某一条路径等功能。

testRoaming() {
  this.rc = new RoamingController(this.$viewer);
  this.rc.setTimeDuration(new Date(), 20);
  let path = new RoamingPath("test");
  path.setPositions([
    new Position(118.78652278, 31.9118927, 0),
    new Position(118.78655718, 31.91305226, 0),
    new Position(118.78782395, 31.91411149, 0),
    new Position(118.78789172, 31.91761209, 0),
    new Position(118.79094442, 31.91788549, 0),
    new Position(118.79124342, 31.91780779, 0),
    new Position(118.79121663, 31.91629651, 0),
    new Position(118.78854253, 31.91625039, 0)
  ]);
  path.setModel("/zjgapi/examples/models/qiche.gltf", {
    scale: 0.5
  });
  this.rc.addPath(path);
  // rc.trackedPath(path, RoamingViewMode.TRACKED)
  // rc.trackedPath(path, RoamingViewMode.FP, {
  //   pitch:-20,
  //   range:100
  // })
  this.rc.trackedPath(path, RoamingViewMode.TP, {
    range: 1000
  });
  // this.rc.trackedPath(path, RoamingViewMode.FREE);
  this.rc.play();
}

new RoamingController(viewer)

roaming/RoamingController.js, line 45

当前视图 Viewer

Name Type Description
viewer Viewer

当前视图

Classes

RoamingController

Methods

addPath(path)

roaming/RoamingController.js, line 171

添加漫游路径

Name Type Description
path RoamingPath

漫游路径

changeSpeed(speed)

roaming/RoamingController.js, line 161

改变播放速度

Name Type Description
speed Number

播放速度

clearPath()

roaming/RoamingController.js, line 206

清除所有的漫游路径

getPath(id){RoamingPath}

roaming/RoamingController.js, line 185

根据设置的路径唯一 id 获取漫游路径

Name Type Description
id String

路径唯一 id

Returns:
Type Description
RoamingPath 漫游路径

pause()

roaming/RoamingController.js, line 142

暂停所有漫游路径

play()

roaming/RoamingController.js, line 124

播放所有漫游路径

removePath(path)

roaming/RoamingController.js, line 194

移出漫游路径

Name Type Description
path RoamingPath

漫游路径

restore()

roaming/RoamingController.js, line 151

继续播放所有的漫游路径

setTimeDuration(startTime, duration)

roaming/RoamingController.js, line 111

设置漫游开始时间以及时间间隔

Name Type Description
startTime Date

开始时间

duration Number

时间间隔(秒)

setTimeRange(startTime, endTime)

roaming/RoamingController.js, line 86

设置漫游的时间区间

Name Type Description
startTime Date

开始时间

endTime Date

结束时间

trackedPath(path, viewMode, viewOption)

roaming/RoamingController.js, line 232

相机视角跟踪某一条路径

Name Type Description
path RoamingPath

漫游路径

viewMode String

视角类型,通过 RoamingViewMode 的属性值赋值

  const RoamingViewMode = {
    FP: "1", // 第一人称视角
    TP: "2", // 第三人称视角
    TRACKED: "3", // 跟随视角
    FREE: "5" // 自由视角
  };
viewOption Object

相机视角参数

Name Type Default Description
alt Number 5 optional

viewModeRoamingViewMode.TP 时,相机位置高度设置

pitch Number 0 optional

viewModeRoamingViewMode.TP 时,相机偏移量中的俯仰角设置

range Object

相机视角范围