Class: RealTimePath

Glodon.CIMCube.Simulation. RealTimePath

实时路径仿真类,用于模拟实时路径规划和导航

new RealTimePath(map, options)

实时路径仿真类构造函数
Parameters:
Name Type Description
map Glodon.CIMCube CIMCube实例
options Object 实时路径仿真配置参数
Properties
Name Type Description
deviceModelList Array 模型列表参数
Properties
Name Type Description
modelId string 模型id
url string 模型url
scale number 模型大小,默认1
animation object 模型启动的骨骼动画,默认为所有动画启动
Properties
Name Type Description
enable bool 模型启动的骨骼动画,默认为所有动画启动
name string 模型启动指定动画
speedup number 关键帧动画速度,默认2
rotation Array 模型自转,不影响其视角,默认[0,0,0] [roll,pitch,heading]
phongLighting bool 是否使用一般的光照模型(冯氏光照),默认为false
alpha number 透明度,默认1
color number 颜色,默认白色
luminanceAtZenith number 亮度,默认0.2
hue number 颜色的色相 (H)SB,默认0.0;值范围:-PI~PI
saturation number 颜色的饱和度 H(S)B,默认1.0;值范围:0~2
brightness number 颜色的明度 HS(B),默认1.0;值范围:0~2
gamma number 伽马值,默认为:1;值范围:0~2
contrast number 对比度,默认为:1
metallicRoughnessFactor Array 金属度|粗糙度调整;建议用在白膜上,会替换材质中原本金属度|粗糙度; 例:[0.5,0.5]; 取值范围:0~1
doubleSided Boolean 图层是否使用双面材质, 会覆盖数据属性, 默认为false
shadowMode ShadowMode 阴影模式,默认为 ShadowMode.DISABLED
silhouetteColor Color 描边颜色,默认为rgba(255,255,255,1.0)
silhouetteSize number 描边宽度,默认0
initialCapacity number [性能优化用]预分配实例数量, 避免频繁扩容, 默认50, 建议根据场景大小调整
batchUpdateEnabled bool [性能优化用]是否启用分帧批量处理,默认true; 当实体数量较大时,每帧只处理一部分,避免单帧卡顿
batchSize number [性能优化用]每帧处理的实体数量,默认1000; 仅在batchUpdateEnabled为true时生效
emptyCollectionDestroyIntervalMs number [性能优化用]间隔多少毫秒尝试销毁已无实例的 ModelInstanceCollection,默认5000; 设为0禁用
canSelected bool 是否可选中,默认false
modelIdCallBack function 模型id回调函数,用于根据模型id获取模型,未指定模型id时不渲染该设备
animationNameCallBack function 动画名称回调函数,用于根据动画名称获取动画
debugShowPathByPolyline bool 是否显示实时漫游线 (debugger用),默认false
Example
modelIdCallBack: function(indices, attribute) {
         // 设备属性值转换为模型ID,理论值通过服务请求获取对应列表
         const index = indices.indexOf("aoc_class_name");
         if(index == -1) return undefined;
         const attributeValue = attribute[index];
         if(attributeValue == "Excavator") {
             return "excavator";
         } else if(attributeValue == "dumper") {
             return "dumper";
         }
         return "modelId";
     },
     animationNameCallBack: function(indices, attribute) {
         // 设备属性值转换为动画名称,理论值通过服务请求获取对应列表
         const index = indices.indexOf("state");
         if(index == -1) return undefined;
         const attributeValue = attribute[index];
         if(attributeValue == "RETURN") {
             return "RETURN";
         } else if(attributeValue == "GO") {
             return "GO";
         }
         return "animationName";
     }

     模型开始渲染时触发
     realTimePath.on("featureRendered", function(param) {
         const featureID = param.featureID; 
         const properties = realTimePath.getFeaturesProperties(featureID);
         console.log(featureID, properties);
     });
     featuresModel.off("featureRendered");

     模型销毁时触发
     realTimePath.on("featureDisposed", function(param) {
         const featureID = param.featureID; 
         const model = param.model;
         console.log(featureID, model);
     });
     realTimePath.off("featureDisposed");

     模型移动时触发
     const featuresModel = realTimePath.getFeatureModel(featureID);
     featuresModel.on("featureMoved", function(param) {
         const featureID = param.featureID; 
         const cartographicDegrees = param.cartographicDegrees;
         const properties = param.properties;
         console.log(featureID, cartographicDegrees, properties);
     });
     featuresModel.off("featureMoved");

     模型属性改变时触发
     const featuresModel = realTimePath.getFeatureModel(featureID);
     featuresModel.on("propertiesChanged", function(param) {
         const featureID = param.featureID;  
         const properties = param.properties;
         console.log(featureID, properties);
     });
     featuresModel.off("propertiesChanged");

Extends

Members


canSelected

是否可选中

Methods


addEventListener(type, listener [, thisArg])

在此事件派发器上添加事件监听.
Parameters:
Name Type Argument Description
type string 事件类型.
listener function 事件监听器.
thisArg Object <optional>
事件监听器的this指针(可选).
Inherited From:
Overrides:
Returns:
调用时将删除此事件侦听器的函数.
Type
function

clearFeaturesModel(deleteFeatureID)

清除实时路径模型与数据
Parameters:
Name Type Description
deleteFeatureID string featureID,空的场合清除所有实时路径模型与数据

conversionFramePathData(data)

转换的实时路径数据
Parameters:
Name Type Description
data JSON 实时路径数据
Returns:
转换后的实时路径数据
Type
JSON

dispatchEvent(event)

在此事件派发器上派发事件.
Parameters:
Name Type Description
event Object 待派发的事件.
Inherited From:
Overrides:

dispose()

释放资源

fire(event)

语法糖. fire == dispatchEvent
Parameters:
Name Type Description
event Object 待派发的事件.
Inherited From:
Overrides:

getAllFeaturesModel()

获取所有实时路径模型
Returns:
所有实时路径模型
Type
Object

getFeatureModel(featureID)

获取实时路径模型
Parameters:
Name Type Description
featureID string featureID
Returns:
实时路径模型
Type
RealTimePathEntity

getFeaturesProperties(featureID)

获取模型实时属性
Parameters:
Name Type Description
featureID string featureID
Returns:
模型实时属性
Type
Object

hasEventListener(type [, listener])

检查此事件派发器上是否存在事件监听,如果不传递事件监听器,则判断是否存在指定事件类型的事件监听.
Parameters:
Name Type Argument Description
type string 事件类型
listener function <optional>
事件监听器(可选).
Inherited From:
Overrides:
Returns:
是否存在指定类型及指定事件监听器的事件监听.
Type
boolean

off(type [, listener])

语法糖. off == removeEventListeners|removeEventListener
Parameters:
Name Type Argument Description
type string 事件类型.
listener function <optional>
事件监听器(可选).
Inherited From:
Overrides:

on(type, listener [, thisArg])

语法糖. on == addEventListener
Parameters:
Name Type Argument Description
type string 事件类型.
listener function 事件监听器.
thisArg Object <optional>
事件监听器的this指针(可选).
Inherited From:
Overrides:
Returns:
调用时将删除此事件侦听器的函数.
Type
function

removeEventListener(type, listener)

从此事件派发器上删除指定事件监听.
Parameters:
Name Type Description
type string 事件类型.
listener function 事件监听器.
Inherited From:
Overrides:

removeEventListeners(type)

从此事件派发器上删除事件监听,如果不提供事件类型,则删除全部事件监听.
Parameters:
Name Type Description
type string 事件类型.
Inherited From:
Overrides:

showPathByPolylines(featureID, opt)

显示实时漫游线 (debugger用)
Parameters:
Name Type Description
featureID string 实时路径featureID
opt Object 漫游线参数
Properties
Name Type Description
lineType number 漫游线类型,默认3;连线效果类型 0:实线|1:发光线|2:虚线|3:动态线
duration number 漫游线持续时间,默认5
lineWidth number 漫游线宽度,默认20
lineColor string 漫游线颜色,默认#00C6FF
image string 漫游线图片
maskLength number 漫游线图片长度,默认25

updatePaths(options)

更新实时路径漫游数据
Parameters:
Name Type Description
options Object 实时路径数据参数
Properties
Name Type Argument Default Description
featuresPath Object feature实时路径数据
Properties
Name Type Description
featureID string featureID
{featureID}.modelId string modelId
{featureID}.position PositionFragment 智能体位置数据
{featureID}.animationName AnimationFragment 智能体动画数据
{featureID}.properties Object 智能体属性列表;
fps number <optional>
10 模拟帧率,默认10
startRealTime number <optional>
0 模拟开始时间,默认0
replace number <optional>
false 数据是否全替换,默认false
autoComplete number <optional>
true replace为false场合,前次模拟数据自动执行完成;默认true