I am streaming CZML on a websocket and also creating entitys in javascript code at the same time. When I do this and I track an entity with the viewer, there is flickering
or an artifact forming of the entities on the screen. This only happens when the camera is tracking the entity.
Here is the code for loading the streamed CZML:
var czmlDataSource = new Cesium.CzmlDataSource();
viewer.dataSources.add(czmlDataSource);
// Set up websocket for czml streaming
var czws = new WebSocket("ws://" + location.host + "/czmlFeed");
czws.onmessage = czmlPacket => {
try {
var czml = JSON.parse(czmlPacket.data);
czmlDataSource.process(czml);
} catch(err) {
console.log(err);
}
};
``
Here is an example of the CZML packet being streamed in:
[
{
“id”:“document”,
“version”:“1.0”,
“clock”:{
“multiplier”:1,
“range”:“UNBOUNDED”,
“step”:“SYSTEM_CLOCK”,
“interval”:“0001-01-01T00:00:00Z/9999-12-31T23:59:59.999Z”,
“currentTime”:“2016-11-15T00:15:53.63100000000122Z”
}
},
{
“availability”:“0001-01-01T00:00:00Z/9999-12-31T23:59:59.999Z”,
“id”:“LineToTarget”,
“polyline”:{
“width”:3,
“positions”:{
“cartographicDegrees”:[
-118.2437,34.0522,20000,-122.4194,37.7749,100
]
},
“material”:{
“solidColor”:{
“color”:{
“rgba”:[
255,0,0,255
]
}
}
}
}
}]
``
Here is the code snippet for creating an another entity not using CZML and updating it’s position:
var entityCurrentPosition;
var entityCurrentOrientation;
entityStateUpdaters[entityName] = es => {
entityCurrentPosition = new Cesium.Cartesian3(es.positionECEF.x, es.positionECEF.y, es.positionECEF.z);
entityCurrentOrientation = Cesium.Quaternion.fromHeadingPitchRoll(-es.orientationEuler.psi, -es.orientationEuler.theta, es.orientationEuler.phi + Cesium.Math.PI);
};
viewer.entities.add({
id: entityName,
position: new Cesium.CallbackProperty(() => entityCurrentPosition, false),
orientation: new Cesium.CallbackProperty(() => entityCurrentOrientation, false),
model: {
uri: availableModels[ms.options[ms.selectedIndex].value],
scale: 1.0
}
});
// Set up websocket for entity data
var ws = new WebSocket("ws://" + location.host + "/liveEntities");
// called when entity data is received from server
ws.onmessage = entities => {
JSON.parse(entities.data).forEach(e => {
entityStateUpdaters[entityName](e);
});
};
``
Any ideas?
Thanks,
Bobby