I am trying to make an application which would vizualize a trajectory of a low Earth spacecraft. This is easily achievable by loading a czml. However, I would like to provide cesium the position at any time myself. For example, I would like to write a javascript function taking time as input and providing a cartesian position for a perfectly circular orbit as output. Is there a way to pass this function to cesium so it can vizualize it, for example with a trail and attached model ?
To give a bit of context, the idea behind my app is to allow vizualization of trajectories stored on server side in a binary format. I have a c library to read/interpolate these files. I wrote a node js addon to call the library from a node js script. Now, I could write a js function on the client/browser side which would take time as input, call the server (I was thinking of socket.io) and receive the position which would then be passed to Cesium.
I am quite new to cesium/js. In fact I ‘dived’ into js only because of cesium… So my question may be naive or the answer obvious.
Sounds like a great project you are working on. Here are some resources for time dynamic data where you can control the position that can help you get started:
Moving vehicle with interpolated positions
Building a flight tracker with custom JSON latitude, longitude, and height data
Please follow up with additional questions as necessary.
the vehicle example is really nice ! The Cesium.CallbackProperty is what I was looking for. Its a user defined function of time used in the example to set the text and the wheel orientation. I tried if its possible to set an entity’s position with the CallbackProperty as well and it works:
function updatePosition(time, result) {
var tt = Cesium.JulianDate.secondsDifference(time, start);
var currentPosition = new Cesium.Cartesian3();
currentPosition.x = startPosition.x + tt * (endPosition.x - startPosition.x);
currentPosition.y = startPosition.y + tt * (endPosition.y - startPosition.y);
currentPosition.z = startPosition.z + tt * (endPosition.z - startPosition.z);
return currentPosition;
}
var vehicleEntity = viewer.entities.add({
position: new Cesium.CallbackProperty(updatePosition, false),
(...)
The car changes linearly its position as specified in the updatePosition function.