Model

人工模型。

new CooWasm.Model(props, callback, wayPointCallback, positionCallback)

Name Type Default Description
props Object

包含如下属性的Object:

Name Type Default Description
url String

模型路径。

translation Vec3Obj new Vec3Obj(0.0, 0.0, 0.0) optional

x、y、z轴偏移值。

scale Vec3Obj new Vec3Obj(1.0, 1.0, 1.0) optional

x、y、z轴比例值。

rotation Vec3Obj new Vec3Obj(0.0, 0.0, 0.0) optional

x、y、z轴旋转值。

location Vec3Obj null optional

地理位置坐标值,默认为当前视点目标点位置。

bVisible Boolean true optional

显隐状态。

playStatus EnumPathPlayStatus EnumPathPlayStatus.STOP optional

运动状态。

playMode EnumPathPlayMode EnumPathPlayMode.ONCE optional

运动模式。

path Path null optional

绑定的路径对象。

moveSpeed Number 5.0 optional

移动速度,单位:m/s。

rotateSpeed Number 40.0 optional

转弯速度,单位:角度/s。

interval Number 10 optional

间隔帧数,用于控制positionCallback触发间隔。

minAltitude Number 0.0 optional

最小可见高度。

maxAltitude Number 10000.0 optional

最大可见高度。

callback CallbackBoolean null optional

加载成功后触发的函数回调。

wayPointCallback CallbackString null optional

沿着路径运动时,经过关键路径点时,返回索引。

positionCallback CallbackString null optional

沿着路径运动时,按照一定时间间隔返回经纬度地理坐标。

Example:
var model = new CooWasm.Model({},(state)=>{console.log("load status:" + state)})
Demo:

Members

readonlyavatarUuid : String

人工模型对象uuid。

bIndexCallback : CallbackString

索引回调。

bPositionCallback : CallbackString

位置回调。

bVisible : Boolean

人工模型显隐状态。

Default Value: true

readonlycomponentUuid : String

人工模型组件uuid。

interval : Number

间隔帧数,用于控制positionCallback触发间隔。

location : Vec3Obj

人工模型地理位置坐标值,默认为当前视点目标点位置。

maxAltitude : Number

最大可见高度。

minAltitude : Number

最小可见高度。

moveSpeed : Number

移动速度,单位:m/s。

path : Path

path对象。

readonlypathAvatarUuid : String

path对象的avatar uuid。

readonlypathComponentUuid : String

path对象的component uuid。

playMode : EnumPathPlayMode

物体运动模式。

playStatus : EnumPlayStatus

物体运动状态。

rotateSpeed : Number

转弯速度,单位:角度/s。

rotation : Vec3Obj

人工模型x、y、z轴旋转值。

scale : Vec3Obj

人工模型x、y、z轴比例值。

readonlyspatialReference : String

人工模型地理位置坐标参考系。

translation : Vec3Obj

人工模型x、y、z轴偏移值。

readonlytreeInfo : String

行为树内容。

url : String

人工模型路径。

Methods

bindPath(path, bPlay, callback, wayPointCallback, positionCallback)

与路径绑定,将按照路径线运动。

Name Type Default Description
path Path

Path对象。

bPlay Boolean

是否播放。

callback CallbackBoolean null optional

更新成功后触发的函数回调。

wayPointCallback CallbackString null optional

沿着路径运动时,经过关键路径点时,返回索引。

positionCallback CallbackString null optional

沿着路径运动时,按照一定时间间隔返回经纬度地理坐标。

Example:
var path = new CooWasm.Path({
     points:[
         new CooWasm.Vec3Obj(120.14809914543076, 30.162721658047321, 12.651933761499823),
         new CooWasm.Vec3Obj(120.15027113314304, 30.163552581628441, 32.567664995975790),
         new CooWasm.Vec3Obj(120.15215840759309, 30.159521920633519, 10.357548876851798),
         new CooWasm.Vec3Obj(120.15043531969498, 30.158788468192203, 9.7634695854038007)
     ]
})
geoCuboid.bindPath(path,true)

destroy(callback)

从场景中销毁自身。

Name Type Default Description
callback CallbackBoolean null optional

销毁对象后触发的函数回调。

Returns:

null 空值。

Example:
model = model.destroy((state)=>{console.log("destroy status:" + state)})

extractCDATAContent(xmlString)String

从XML中提取CDATA内容

Name Type Description
xmlString String

包含CDATA部分的XML字符串

Returns:

CDATA内容,如果没有找到则返回空字符串

generateUuid()String

生成符合RFC4122标准的UUID (版本4)

Returns:

返回格式为'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'的UUID

getProperties()Boolean

获取对象包含的属性。

Returns:

是否获取成功。获取成功时,会自动赋值给属性。

Example:
model.getProperties()

locate(callback)

从场景中定位自身(自动根据数据包围盒定位,不可修改定位参数)。

Name Type Default Description
callback CallbackBoolean null optional

飞行结束后触发的函数回调。

Example:
model.locate((state)=>{console.log("locate status:" + state)})

update(props, callback, wayPointCallback, positionCallback)

更新单个或者多个对象属性,使之立即生效。

Name Type Default Description
props Object optional

包含如下属性的Object。

Name Type Description
translation Vec3Obj optional

x、y、z轴偏移值。

scale Vec3Obj optional

x、y、z轴比例值。

rotation Vec3Obj optional

x、y、z轴旋转值。

location Vec3Obj optional

地理位置坐标值,默认为当前视点目标点位置。

bVisible Boolean optional

显隐状态。

playStatus EnumPathPlayStatus optional

运动状态。

mode EnumPathPlayMode optional

运动模式。

path Path optional

绑定的路径对象。

moveSpeed Number optional

移动速度,单位:m/s。

rotateSpeed Number optional

转弯速度,单位:角度/s。

interval Number optional

间隔帧数,用于控制positionCallback触发间隔。

callback CallbackBoolean null optional

更新成功后触发的函数回调。

wayPointCallback CallbackString null optional

沿着路径运动时,经过关键路径点时,返回索引。

positionCallback CallbackString null optional

沿着路径运动时,按照一定时间间隔返回经纬度地理坐标。

Example:
model.update({
   bVisible:false
},(state)=>{console.log("update status:" + state)})