Use a reference for CZML orientation property?

Hi all,

I’m wondering if there’s a way to avoid explicitly specifying an orientation property for an entity created in CZML. Is there a way to do something like:




But for “orientation” instead of position?

I’m specifically trying to create an agi_* sensor, per, attach it to a satellite, and point it in the sat’s nadir direction. See the attached .czml file (lifted from the same github repo) for an example of one of these sensors implemented. It would be really nice if I don’t have to actually add a nadir quaternion at every timestep for every satellite in my czml file, but rather could reference some property of the satellite itself.

Exploring a satellite entity from the console in a Cesium-rendering webpage (see attached screencap, actually from another sim I’m running, not from the same .czml file), I see that its “orientation” is undefined - which makes sense, considering I didn’t actually define that field for the sat. But I DO inherently have information about the satellite’s nadir direction, because I have its position. Is there a convenient way to extract the nadir quaternion from that, hopefully without adding a ton of overhead?

I’m not terribly familiar with JS, but could I somehow attach a function to the satellite entity that returns an orientation quaternion and is called for anything that has a reference property referring to the sat’s orientation? (ha, I might have answered my own question there. But if anyone has a better idea!..)


-Kit Kennedy

LotsOfSensors.czml (4.31 MB)

CZML orientation, like all properties, can be defined as a reference, using the exact same syntax as you showed for position (of course, replacing position with orientation in the reference string).

If you’re talking about computing orientation entirely on the client, then yes, you can do that by configuring the Entity’s orientation property. A CallbackProperty allows you to install your own calculation function which then must compute and return the value at each given time.

You can mix the two approaches by loading a CZML file, then using custom JS code, retrieve the loaded Entity, and replace just the orientation with a CallbackProperty, and leave the other properties as defined by the CZML file.

Thanks! That makes sense. A follow on: how do I ensure the satellite object has been loaded from CZML so that I can redefine its orientation property? Essentially, after line 1 below, how do I ensure the entity for ‘Satellite/CubeSat2’ exists?


var sat =‘Satellite/CubeSat2’)

sat.orientation = new Cesium.CallbackProperty(function(time, result) {

return ‘blah’;

}, false);


CzmlDataSource.load returns a promise, which you can use like any normal JavaScript promise.

var dataSourcePromise = Cesium.CzmlDataSource.load(‘app_data_files/sats_file.czml’);

dataSourcePromise = dataSourcePromise.then(function(dataSource) {

var entity = dataSource.entities.getById(‘whateverID’);

entity.orientation = new Cesium.CallbackProperty(function(time, result) {



return dataSource;



Alright, thanks much!