Tracking entity from CZML file

47 views
Skip to first unread message

adn...@gmail.com

unread,
Aug 28, 2019, 12:15:12 PM8/28/19
to cesium-dev
1. A concise explanation of the problem you're experiencing.
Hi all, sorry in advance for the newbie question (I'm just learning Cesium). I've loaded in a CZML file and am trying to use trackedEntity to make the camera follow it, but I'm running into a problem. Instead of actually following it, all my code does is zoom in on its initial position and then stay there. What am I doing wrong?

As a test, I pulled the CZML data from the CZML Path demo in Sandcastle (https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=CZML%20Path.html&label=CZML), saved it as its own file, and pointed the czml variable in the code below at it; it worked perfectly. So it seems like its an issue with the CZML file I'm using, but I can't figure out what?


2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.

//my code in Cesium

    var viewer = new Cesium.Viewer('cesiumContainer', {
    terrainProvider : Cesium.createWorldTerrain(),
    baseLayerPicker : false,
    shouldAnimate : true
});

viewer.dataSources.add(Cesium.CzmlDataSource.load(czml)).then(function(ds) {
  viewer.trackedEntity = ds.entities.getById('path');
});

//A sample of my CZML file -- I've cut out most of the coordinates, save for a sample, because it's so long:

[{"id": "document", "name": "AT Demo", "version": "1.0",
"author": "Adam Roy", "clock": {"interval":
"2019-08-28T01:14:42+00:00/2019-09-02T14:50:51+00:00", "currentTime":
"2019-08-28T01:14:42+00:00", "multiplier": 1000}}, {"id": "path",
"availability":
"2019-08-28T01:14:42+00:00/2019-09-02T14:50:51+00:00", "position":
{"epoch": "2019-08-28T01:14:42+00:00", "cartographicDegrees": [0,
-71.021238, 44.485148, 914.9, 7.0, -71.021165, 44.485176, 915.8,
21.0, -71.021009, 44.485184, 917.7, 26.0, -71.02096, 44.485213,
918.6, 44.0, -71.020767, 44.485203, 921.1, 50.0, -71.020703,
44.485225, 922.2, 70.0, -71.020525, 44.48512, 923.0, /* coordinates removed here */]}, "point": {"color": {"rgba": [255, 255,
255, 255]}, "outlineColor": {"rgba": [0, 173, 253, 255]},
"outlineWidth": 6, "pixelSize": 8, "heightReference":
"RELATIVE_TO_GROUND"}}]



3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I'm trying to make the camera follow a path plotted out by the CZML file

4. The Cesium version you're using, your operating system and browser.

1.60, MacOS High Sierra, Chrome

adn...@gmail.com

unread,
Aug 29, 2019, 1:58:36 PM8/29/19
to cesium-dev
Solved. I was using the wrong variable. *headdesk*

Omar Shehata

unread,
Aug 29, 2019, 3:42:37 PM8/29/19
to cesium-dev
Glad to hear you resolved it - and welcome to the Cesium community!
Reply all
Reply to author
Forward
0 new messages