{
"id": "2129c05288d445708a601d5953be57ac",
"name": "测试 001",
"type": "004",
"properties": {
"status": "use"
},
"position": {
"interpolationAlgorithm": "LAGRANGE",
"interpolationDegree": 1,
"epoch": "2022-09-10T00:00:00Z",
"cartographicDegrees": [
0,
11,
22,
100,
5000,
33,
55,
200
]
},
"model": {
"show": true,
"gltf": "http://localhost:1024/earth/model/missile.glb",
"scale": 10,
"minimumPixelSize": 16
},
"label": {
"fillColor": {
"rgba": [
233,
150,
122,
255
]
},
"outlineWidth": 2,
"verticalOrigin": "CENTER",
"outlineColor": {
"rgba": [
0,
0,
0,
255
]
},
"show": true,
"horizontalOrigin": "LEFT",
"scale": 0.5,
"style": "FILL_AND_OUTLINE",
"text": "测试",
"pixelOffset": {
"cartesian2": [
5,
-60
]
},
"font": "21pt Lucida Console"
}
}
这里创建了一个运动实体测试 001
positions: new Cesium.CallbackProperty(function() {
try {
const userEntityExists = ds.entities.getById(userEntity.id);
const closestSatelliteExists = closestDataSource.entities.getById(closestSatellite.id);
if (userEntityExists && userEntityExists.position && closestSatelliteExists && closestSatelliteExists.position) {
return [userEntityExists.position.getValue(viewer.clock.currentTime), closestSatelliteExists.position.getValue(viewer.clock.currentTime)];
} else {
viewer.entities.removeById(lineID);
return null;
}
} catch (error) {
console.error(`An error occurred while creating the polyline for ${lineID}: `, error);
viewer.entities.removeById(lineID);
return null;
}
}, false),
这里使用了 Cesium.CallbackProperty 来获取 postion 创建实体测试 001 和卫星的连线,现在当测试 001 消失的时候会报错 Uncaught TypeError: Cannot read property ‘x‘ of undefined 这个要怎么处理呢
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.