Class: PanoViewer

PanoViewer

全景SDK。支持全景图的展示和编辑;只支持单个场景加载,分级分块加载,小行星入场动画,3d/2d热点,陀螺仪等功能;素材格式支持单张图片图,六面体散图,六面体雪碧图,分级分块散图等。

new Hydreigon.PanoViewer (parent, ak, sk, options)

Name Type Description
parent HTMLElement 播放器容器element.
ak string | undefined ak字符码
sk string | undefined sk字符码
options IOption SDK配置

Methods

addEffect (effect)void

添加特效
Name Type Description
effect object 特性对象
Returns:
Type Description
void

addHotspot (hotspot)boolean

编辑接口,增加热点
Name Type Description
hotspot Object 新增热点的配置文件
Returns:
Type Description
boolean true表示成功, false表示失败

degToRad (deg)float

角度转弧度
Name Type Description
deg float 角度值
Returns:
Type Description
float 弧度值

destroy ()void

全景图类资源销毁函数
Returns:
Type Description
void

enablePointEvent (enable)void

指针事件开关
Name Type Description
enable boolean true表示开启, false关闭
Returns:
Type Description
void

forceShowPiece ()void

显示场景图,hydreigon入场动画结束或者没有入场动画,则需要调用此函数。
Returns:
Type Description
void

forceUpdateRotation ()void

强制更新旋转四元数
Returns:
Type Description
void

getCameraQuaternion ()Object

获取当前渲染场景中此刻相机的四元数
Returns:
Type Description
Object {x, y, z, w}对象

getCameraRotation ()Object

获取当前渲染场景中此刻相机的Rotation,用于设置初始视角
Returns:
Type Description
Object rotation为欧拉角,为{x, y, z}对象

getCoord (x, y)object

通过屏幕坐标获取空间坐标
Name Type Description
x number 屏幕坐标x值
y number 屏幕坐标y值
Returns:
Type Description
object {x: number, y: number, z: number} 空间坐标

getFov ()number

获取当前渲染场景的fov值
Returns:
Type Description
number fov值

getHsManager (sceneId)HotspotManager

获取场景的热点管理类,sceneId代表为当前场景
Name Type Description
sceneId string 场景Id
Returns:
Type Description
HotspotManager hotspotManager

getMaxFov ()number

获取当前渲染场景的fov范围最小值
Returns:
Type Description
number max fov值

getMaxPitch ()number

获取当前渲染场景中垂直方向的max Pitch
Returns:
Type Description
number 垂直方向中大角度值

getMinFov ()number

获取当前渲染场景的fov范围最小值
Returns:
Type Description
number min fov值

getMinPitch ()number

获取当前渲染场景中垂直方向的min Pitch
Returns:
Type Description
number 垂直方向中小角度值

getPitchRange ()Array

获取当前渲染场景中垂直方向的Pitch范围,即南北两级的范围
Returns:
Type Description
Array pitchRange,形如[min, max] min和max为角度

getSupplyId ()string

获取全景图中渠道ID
Returns:
Type Description
string 渠道ID

getVersion ()string

获取SDK版本号
Returns:
Type Description
string version

hideHotspotContainer ()void

隐藏热点容器
Returns:
Type Description
void

init (config)Promise

初始化全景图
Name Type Description
config PanoConfiguration 初始化所需的配置
Returns:
Type Description
Promise , resolve鉴权成功回调函数,reject失败回调函数;

isDebug ()boolean

查询是否为调试模式
Returns:
Type Description
boolean debug true为调试模式,false为正常模式

isGyroOpen ()boolean

获取移动端上陀螺仪是否处于开启状态
Returns:
Type Description
boolean true表示成功, false表示失败

isPinchEnabled ()boolean

查询pinch操作开关是否开启
Returns:
Type Description
boolean true 已经开启, false 关闭

onWindowResize ()void

响应窗口Size变化函数
Returns:
Type Description
void

panoToScreenCoord (obj, camera)HTMLElement

空间坐标转换成屏幕坐标
Name Type Description
obj object 为{x: number, y: number, z: number}对象
camera Camera 当前渲染场景的相机对象
Returns:
Type Description
HTMLElement container 场景显示的容器

pauseAnimation (key)PanoViewer

暂停动画
Name Type Description
key Symbol 动画队列ID
Returns:
Type Description
PanoViewer this;

performAnimation (animationName)Symbol

执行动画 * 当第一个参数为数组,表示n个动画一个接着一个播放,那么第二个参数也是数组,分别是n的动画对应的参数 play会创建一个播放队列。外部如果要终止某一动画需要使用queueKey去中断。play都是队列级别操作
Name Type Description
animationName string 场景名称
Returns:
Type Description
Symbol 动画队列ID

pinchEnable (是否开启,)

pinch操作开关
Name Type Description
是否开启, boolean true为开启, false为关闭, 默认开启

pitchEnabled ()boolean

查询pitch操作开关是否开启
Returns:
Type Description
boolean true 已经开启, false 关闭

radToDeg (rad)float

弧度转角度
Name Type Description
rad float 弧度值
Returns:
Type Description
float 角度值

removeAllHotspot ()boolean

编辑接口,删除当前场景所有热点
Returns:
Type Description
boolean true 表示成功, false表示失败

removeEffect (effect, sceneId)boolean

移除当前场景特效(暂时只能移除当前场景的effect)
Name Type Description
effect string 特性对象
sceneId string 场景id
Returns:
Type Description
boolean true表示成功, false表示失败

removeHotspot (id, sceneId)boolean

编辑接口,删除热点
Name Type Description
id string 热点的id
sceneId string 场景id,缺省时
Returns:
Type Description
boolean true表示成功, false表示失败

requestSnapShot (renderer)string

获取当前渲染区域的快照
Name Type Description
renderer WebGLRenderer
Returns:
Type Description
string 图片base64格式

resumeAnimation (key)PanoViewer

恢复动画
Name Type Description
key Symbol 动画队列ID
Returns:
Type Description
PanoViewer this;

reversalEvent (b)void

反转事件
Name Type Description
b boolean true 反转, false 正常
Returns:
Type Description
void

screenToPanoCoord (x, y)object

屏幕坐标转换成空间坐标
Name Type Description
x number 屏幕坐标x值
y number 屏幕坐标y值
Returns:
Type Description
object {x: number, y: number, z: number} 空间坐标

selectHotspot (id, sceneId)boolean

编辑接口,选中指定场景中的一个热点
Name Type Description
id string 热点的id
sceneId string 场景id,缺省时代表当前渲染场景
Returns:
Type Description
boolean true表示成功, false表示失败

setCameraQuaternion (quaternion)boolean

设置当前渲染场景中此刻相机的四元数,使渲染区域朝向指定的视角
Name Type Description
quaternion Object 为欧拉角,为{x, y, z, w}对象
Returns:
Type Description
boolean true表示成功, false表示失败

setCameraRotation (rotation)boolean

设置当前渲染场景中此刻相机的Rotation,使渲染区域朝向指定的视角
Name Type Description
rotation Object 为欧拉角,为{x, y, z}对象
Returns:
Type Description
boolean true表示成功, false表示失败

setDebug (debug)void

设置为调试模式
Name Type Description
debug boolean true为调试模式,false为正常模式
Returns:
Type Description
void

setDefaultRotation (rotation)boolean

编辑接口,修改当前渲染场景的默认初始视角
Name Type Description
rotation Object 为欧拉角,为{x, y, z}对象
Returns:
Type Description
boolean true表示成功, false表示失败

setFov (fov)boolean

获取当前渲染场景的fov值
Name Type Description
fov number 设置的fov值
Returns:
Type Description
boolean

setFovRange (min, max)boolean

获取当前渲染场景的fov范围
Name Type Description
min number min为小值
max number max为大值
Returns:
Type Description
boolean

setPitchRange (min, max)boolean

编辑接口,设置当前渲染场景中垂直方向的Pitch范围,即南北两级的范围
Name Type Description
min number min为角度值,为小值
max number max为角度值,为大值
Returns:
Type Description
boolean

setSupplyId (supplyId)void

设置全景图渠道ID
Name Type Description
supplyId string 渠道ID
Returns:
Type Description
void

showEffects (effects)void

展示所有特效
Name Type Description
effects Array.<object> 特性对象列表
Returns:
Type Description
void

showHotspotContainer ()void

显示热点容器
Returns:
Type Description
void

stopAllAnimation ()PanoViewer

停止动画
Returns:
Type Description
PanoViewer this;

stopAnimation (key, needEvent)PanoViewer

停止动画
Name Type Description
key Symbol 动画队列ID
needEvent boolean 是否需要发送事件
Returns:
Type Description
PanoViewer this;

switchGyro (enable)Promise

移动端上陀螺仪的开关,异步
Name Type Description
enable boolean
Returns:
Type Description
Promise

switchView (config)Promise

更新全景图
Name Type Description
config PanoConfiguration 初始化所需的配置
Returns:
Type Description
Promise resolve鉴权成功回调函数,reject失败回调函数;

triggerEnter ()void

标记全景已经加载完
Returns:
Type Description
void }

unSelectHotspot (id)boolean

编辑接口,反选场景中的某个热点
Name Type Description
id string 热点的id,可缺省
Returns:
Type Description
boolean true表示成功, false表示失败

update (time)void

全景图更新入口函数,需要加入渲染循环中
Name Type Description
time number
Returns:
Type Description
void

updateHotspot (id, hotspot, sceneId)boolean

编辑接口,更新热点
Name Type Description
id string 热点的id
hotspot Object 热点更新后的配置文件
sceneId string 热点所在的场景Id
Returns:
Type Description
boolean true表示成功, false表示失败

Interface Definitions

IOption

Events

after-render

渲染后钩子

animation-end

动画结束事件

animation-pause

动画暂停事件

animation-resume

动画恢复事件

animation-start

动画开始事件

before-render

渲染前钩子

camera-animation-end

编辑模式下,调用选中热点时,触发相机的转动动画结束

camera-animation-start

编辑模式下,调用选中热点时,触发相机的转动动画

camera-change

相机变化了
Returns:
Name Type Description
cause string 相机变化的原因,包括:anim,touch,gyro,auto,all
rotation Object 相机的rotation,欧拉角
fov float 相机的fov

controller-drag

控制器被拖拽交互

hs-click

3D热点被点击了

hs-select

编辑模式场景中热点被选中了
Name Type Description
热点Id string

hs-unselect

编辑模式场景中热点被取消选中了

hs-update

编辑模式场景中热点更新了,如场景的热点
Returns:
Name Type Description
sceneId string 场景id
hotspotId string 热点Id
hotspot Object 更新后的热点

hyd-startup-end

开场动画结束

hyd-startup-error

开场动画错误

level-loaded

加载完场景最低level中所有的瓦片图

loaded

进场完成。

options-error

配置错误.

pause-auto-rotate

暂停自动旋转事件

scene-click

场景点击事件
Returns:
Type Description
string sceneId:场景id

scene-config-error

场景主资源加载失败

scene-image-error

场景主资源加载失败

scene-loaded

场景切换完成
Returns:
Type Description
string sceneId:场景id

scene-loading

下一个场景的资源开始加载;第一个场景加载是不触发
Returns:
Type Description
string sceneId:场景id

scene-transition

下场景开始加载完成,开始进行两个场景的场景过渡动画;第一个场景加载是不触发

snapshot-ready

编辑模式下,通知外部可以截图了

tile-image-error

场景中瓦片图拉取失败

transition-end

转场结束事件

webgl-not-support

设备不支持webgl.