Control Viewer SDK

Get Current Camera Information

You can call getCameraInformation to get hotspotId, position, and viewer angle.

{
  "floor": 1,
  "position": {
    "x": -20,
    "y": 16.858482123032793,
    "z": -28.727493286132812
  },
  "hotspotId": "yMCFSVOz0cRZj4akWKW6",
  "azimuthAngle": 1.551951338449223,
  "polarAngle": 2.035850986576229
}

Then you can use above information to control viewer to go some hotspots and look direction.

Go to hotspot

You can call goToHotspotLocation with following code to go certain hotspot location with view angle:

await viewer.controls.goHotspotLocation({
  hotspotId: 'rT1sHJsgVgjeapHYASOk',
  azimuthAngle: 0.14441241801160945,
  polarAngle: 1.542009356916441
})

Go to and face to tag

You can call goToHotspotLocation with following code to go certain hotspot location with view angle:

await viewer.controls.goTagLocation('Tag id')

Switch floor number

You can call goFloorLocation to switch floor with number

viewer.controls.goFloorLocation(floor) // floor is number

And call getAllFloorNumbers to get current scene how many floors can go

Get tag id when user click tag

When user click tags on 3d, it triggers and send cmd opentag to message listener, you can handle customized tag dialog and fetch data from your db in this scenario

 case ViewerSdkCmd.opentag:
   console.log('sdk receives tagId: ' + data.tagId)
   break

More SDK controls

There are more controls function, such as dollhouse, and hotspot visible please check:

pageSDK Reference

Last updated