AssetLayer

AssetLayer

new AssetLayer(params, messageNeedsUpdate, childNeedsUpdate)

Description:
  • 动态资产数据加载,用于动态资产请求,游戏引擎内部逻辑请求资产
Source:
  • objects/other/AssetLayer.js, line35
Parameters:
Name Type Description
params object 参数
Properties
Name Type Description
url string 设备点位信息请求地址
body string 设备点位信息请求内容
header string 设备点位信息请求头信息,如果没有特殊设置,可不给值
deviceAutoUpdate Boolean 点位信息是否由SDK自动更新,默认false,由用户通过body自动更新
deviceAutoUpdateInterval number deviceAutoUpdate=true的时候,SDK更新频率,默认2秒
maxUpdateHeight number 设备点位信息最大自动更新请求的高度,默认1000,单位:米
renderNum number 每帧渲染的点位数量,默认15,代表每一帧会渲染15个点位,如果点位太多,会导致渲染性能问题
searchMode string 搜索模式,默认'coord',可选值:'coord', 'mc_grid'。'coord'表示根据坐标搜索,'mc_grid'表示根据网格搜索
tileLevel number 瓦片层级,默认16 当searchMode为'mc_grid'时,tileLevel设置生效
rtEnable Boolean 实时数据是否启用,默认false
rtUrl string 实时数据请求地址, 当启用实时数据时生效
rtTilelLevel number 实时数据查询层级,默认17,当启用实时数据时生效
messageNeedsUpdate Boolean 消息是否变化,只读
childNeedsUpdate Boolean 子模型是否变化,只读

Methods

addChildren(children)

Description:
  • 添加子模型
Source:
  • objects/other/AssetLayer.js, line204
Parameters:
Name Type Description
children Array 子模型数组
child.uuid string 单个子模型的唯一标识符
child.id id 单个子模型的id

removeChild(child)

Description:
  • 移除单个子模型
Source:
  • objects/other/AssetLayer.js, line230
Parameters:
Name Type Description
child object 子模型
Properties
Name Type Description
uuid string 子模型的唯一标识符
id id 子模型的id

removeChildren(children)

Description:
  • 移除多个子模型
Source:
  • objects/other/AssetLayer.js, line246
Parameters:
Name Type Description
children Array 子模型数组
child.uuid string 子模型的唯一标识符
child.id id 子模型的id

updateChild(child)

Description:
  • 更新单个子模型
Source:
  • objects/other/AssetLayer.js, line302
Example
child = {
uuid:****,
point_id:****,
params:{
        "map": "url",
        "color": {"r":,"g":,"b":,"a":},
        "metallic": 0,
        "roughness": 1,
        "brightness": 0,
        "brightnessColor":  {"r":,"g":,"b":},
        "scale": {"x":,"y":,"z":},
        "rotation": {"x":,"y":,"z":},
        "position": {"x":,"y":,"z":},
      }
    }
Parameters:
Name Type Description
child object 子模型
Properties
Name Type Description
uuid string 子模型的唯一标识符
point_id string 子模型的点位id,如果有就赋值,没有可以不给
params object 更新参数
params.color object 更新颜色,{"r":,"g":,"b":,"a":},值0-1
params.brightnessColor object 发光颜色,{"r":,"g":,"b":},值0-1
params.map string 更新贴图,接受url
params.metallic object 更新金属度
params.roughness object 更新粗糙度
params.brightness object 更新发光强度
params.position object 更新位置, {"x":,"y":,"z":},经度纬度高度,单位 度
params.scale object 更新缩放, {"x":,"y":,"z":}
params.rotation object 更新旋转, {"x":,"y":,"z":},单位 角度
params.text string 文字,不为空时文字贴图优先级最高
params.textStyle object 文本样式,具体参照Utils的drawTextToImage方法的第二个参数
params.scroll number 更新纹理是否沿着横轴滚动,1为正方向滚动,-1为反方向滚动,默认值0不滚动
params.speed number 设置纹理滚动速度,scroll不为0设置才生效,建议值0.5,默认值0,静止

updateChildAnimation(child, params)

Description:
  • 更新单个子设备的动画类型
Source:
  • objects/other/AssetLayer.js, line480
Parameters:
Name Type Description
child object 子设备
Properties
Name Type Description
uuid string 子模型的唯一标识符
point_id string 子模型的点位id,如果有就赋值,没有可以不给
params object 更新参数
Properties
Name Type Description
animationIndex number 动画序号,默认0,-1为停止动画,传值参考:0,1,2...
animationLoop boolean 动画是否循环播放 默认true
animationSpeed number 动画播放速率 默认1 正常速率

updateChildren(children)

Description:
  • 更新多个子模型
Source:
  • objects/other/AssetLayer.js, line351
Example
child = {
uuid:****,
point_id:****,
params:{
        "map": "url",
        "color": {"r":,"g":,"b":,"a":},
        "metallic": 0,
        "roughness": 1,
        "brightness": 0,
        "brightnessColor":  {"r":,"g":,"b":},
        "scale": {"x":,"y":,"z":},
        "rotation": {"x":,"y":,"z":},
        "position": {"x":,"y":,"z":},
      }
    }
Parameters:
Name Type Description
children Array 子模型数组
child.uuid string 子模型的唯一标识符
child.point_id string 子模型的点位id,如果有就赋值,没有可以不给
child.params object 更新参数
params.color object 更新颜色,{"r":,"g":,"b":,"a":},值0-1
params.brightnessColor object 发光颜色,{"r":,"g":,"b":},值0-1
params.map string 更新贴图,接受url
params.metallic object 更新金属度
params.roughness object 更新粗糙度
params.brightness object 更新发光强度
params.position object 更新位置, {"x":,"y":,"z":},经度纬度高度,单位 度
params.scale object 更新缩放, {"x":,"y":,"z":}
params.rotation object 更新旋转, {"x":,"y":,"z":},单位 角度
params.text string 文字,不为空时文字贴图优先级最高
params.textStyle object 文本样式,具体参照Utils的drawTextToImage方法的第二个参数
params.scroll number 更新纹理是否沿着横轴滚动,1为正方向滚动,-1为反方向滚动,默认值0不滚动
params.speed number 设置纹理滚动速度,scroll不为0设置才生效,建议值0.5,默认值0,静止

updateChildrenAnimation(children, params)

Description:
  • 更新多个子设备的动画类型
Source:
  • objects/other/AssetLayer.js, line502
Parameters:
Name Type Description
children Array 子设备模型
child.uuid string 子模型的唯一标识符
child.point_id string 子模型的点位id,如果有就赋值,没有可以不给
params object 更新参数
Properties
Name Type Description
animationIndex number 动画序号,默认0,-1为停止动画,传值参考:0,1,2...
animationLoop boolean 动画是否循环播放 默认true
animationSpeed number 动画播放速率 默认1 正常速率