CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.79k stars 3.46k forks source link

Weird interaction between CzmlDataSource.process and tracked entity #4647

Open hpinkos opened 7 years ago

hpinkos commented 7 years ago

Reported on the forum: https://groups.google.com/forum/?hl=en#!topic/cesium-dev/fILh9nJyI1w

The model in this example looks like its flickering. To me it looks like it might be that the camera isn't tracking it correctly for a split second after the model moves. This only happens when czmlDataSource.process is called.

var viewer = new Cesium.Viewer('cesiumContainer');

var czmlDataSource = new Cesium.CzmlDataSource();
viewer.dataSources.add(czmlDataSource);

var czmlString = '[\
{\
  "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\
          ]\
        }\
      }\
    }\
  }\
}]';

var czml = JSON.parse(czmlString);
czmlDataSource.process(czml);

var position = Cesium.Cartesian3.fromDegrees(-118.2437,34.0522,20000);
var heading = Cesium.Math.toRadians(135);
var pitch = 0;
var roll = 0;
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);
var url = '../../SampleData/models/CesiumAir/Cesium_Air.glb';
var entity = viewer.entities.add({
        name : url,
        position : new Cesium.CallbackProperty(function() {return position;}, false),
        orientation : orientation,
        model : {
            uri : url,
            minimumPixelSize : 128,
            maximumScale : 20000
        }
    });

var i = 0;
viewer.trackedEntity = entity;

setInterval (function () {    
    position = Cesium.Cartesian3.fromDegrees(-118.2437+i,34.0522,20000);
    i += 0.001;       
}, 2000);    

setInterval(function () {
    czmlDataSource.process(czml);
}, 1000);
AshitakaLax commented 3 years ago

I also was able to get the same issue to repeat. It appears like it is a camera tracking issue. I have tried both running multiple czml documents and a single czml document here is a single czml document. error-process.czml.txt

Here is the Timeline

Here is the image of what it looks like normally at May 27 2021 23:44:54 UTC. image Without touching anything but letting the time pass for 1 second May 27 2021 23:44:55 UTC. image One second later at May 27 2021 23:44:56 UTC it goes back to the expected camera position. image

I also reviewed the specific samples associated with the switch and they look good.

srcejon commented 2 years ago

Same problem here. Did you find a workaround @AshitakaLax?

AshitakaLax commented 2 years ago

No, I haven't found any solution to this issue, but I also haven't worked on the specific project for months either.