Reference Frames

Hi,

Looking for a little bit of help with reference frames. I have a set of data that I have been displaying inside of CESIUM with polylines in the Fixed frame. In the current version I noticed that I now define a reference frame with certain features. Is it possible to use the reference frame feature with polylines and if so can you provide an example? Essentially what I am trying to do is use and display ECI data in the ECI Frame inside of CESIUM.

Thanks
Tim

Are you using CZML, or are you creating primitives directly?

For CZML, check out simple.czml in the Apps/CesiumViewer/Gallery directory. It’s as easy as adding the referenceFrame property to the position data:

“position”:{

“interpolationAlgorithm”:“LAGRANGE”,

“interpolationDegree”:5,

“referenceFrame”:“INERTIAL”,

“epoch”:“2012-03-15T10:00:00Z”,

“cartesian”:[

0.0,4650397.56551457,-3390535.52275848,-4087729.48877329,

…]

For custom primitives, you simple use ECI coordinates when calling SetPositions but then also need to set the modelMatrix each frame. To do that you would have code like the following (this is taken directly from DynamicPathVisualizer.js in DynamicScene)

PolylineUpdater.prototype.update = function(time) {

if (this._referenceFrame === ReferenceFrame.INERTIAL) {

var toFixed = Transforms.computeIcrfToFixedMatrix(time, toFixedScratch);

if (typeof toFixed === ‘undefined’) {

toFixed = Transforms.computeTemeToPseudoFixedMatrix(time, toFixedScratch);

}

Matrix4.fromRotationTranslation(toFixed, Cartesian3.ZERO, this._polylineCollection.modelMatrix);

}

};

Matt,

Thanks for the quick reply. I am trying not to use CZML if I do not have to. However the more and more I investigate things I think I am going to be forced to go down that road.

I have looked at and tried converting using the RotationTranslation but I ended up converting my points from ECI to ECF. I did not try applying the modelMatrix so I will look into that.

If I am eventually going to apply quaternion data to all of this is it better to give up now and go down the CZML route?

Thanks
Tim

Ultimately, there are 3 ways to use Cesium.

  1. Load CZML data, either via web-services, a static file, or a stream (such as WebSockets or EventSource).

  2. Read data from any source you want and create/update/manage primitives yourself.

  3. Implement a DataSource object which builds DynamicObject instances from custom data sources.

If you control the web-services generating your data, or can write a web-service facade on top of your data sources; then #1 is probably the easiest way to go. CZML was designed for exactly these types of problems.

If you want to be complete control over everything, #2 gives you that, but in many cases you’re essentially solving problems we already solved (or are in the process of solving for you). This is particularly true for time-dynamic data. For example, you would have to worry about interpolating your data properly in order to get smooth updates in between data points.

If you don’t control the web-services and have a bunch of external data you need to load, then #3 is probably your best bet. This is the same system we use to parse CZML but you would parse the data yourself and simply create the DynamicObject instances. I just finished implementing GeoJSON this way. This option is still a little rough around the edges, but I’m working on making it easier right now. In the future, this will be the easiest/preferred way of getting non-CZML data into Cesium.

Hope that helps. If you still have questions, just ask away. On a related note, if you’re currently using any other AGI products in your project, we have some libraries in the pipeline for writing CZML out of STK and Components. Shoot me an email if you want to know more about those.

Matt,

Once we get things flushed out, this advice would make a good blog post: “what level of Cesium should I use?”

Patrick