Dynamic Line of Sight between objects

1. A concise explanation of the problem you’re experiencing.

I have four Drones in my scene, and wish to toggle a line of sight ( simply connecting two drones with a line object together) between any pair I like. I already created a webSocket infrastructure with Python which delivers the data to cesium and everything is working great. aside of the issue that I can’t change the objects set for the line of sight. I make the line of sight adding an object to my scene , with a callback which takes the position properties from the two drones I need and thus constatnly updates as the objects move… the problem is , that it’s hard-coded. once it’s there , I can’t touch it . I would like to toggle the lines between the drones as I choose to. I tried doing it with classes etc, but it’s not like C++ , which can have an offset for a callback from this-> , or like a C callback which can accept an arbitrary amount of parameters as input , allowing me to manupulate data .

Thank you .

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

function getPositions(time,result)


 var pos1 = entArray[0].position._value;//This keeps updating the line automatically to draw between drones 0 and 1

 var pos2 = entArray[1].position._value; //I can't change it once its there to , say drones 0 and 2....

 return [pos1,pos2];


entArray[4] = viewer.entities.add({ //4 will be the entity of the line which draws between the drones (0…3) are the drone entities

polyline: {

 followSurface: false,

width: 1,

arcType : Cesium.ArcType.NONE,

 positions: new Cesium.CallbackProperty(getPositions,false),

 material: new Cesium.ColorMaterialProperty(Cesium.Color.RED)



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

dynamic toggling for line of sight simulation

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


That code you have should work. How are you changing the positions? Are you changing what’s in entArray, or are you changing the positions of the entArray[1] entity?

Instead of using the private ._value, consider using position.getValue(time) which will return the given property’s value at the given time (allowing you to do time dynamic properties). If this still doesn’t work, if you can put together a Sandcastle example showing the issue I’d be happy to take a look.

What kind of application is this for? Will this be a publicly available application? It sounds pretty cool!

Hello again , I am changing the positions using this small routine I wrote:
function setEntityPos6D(entID,longDeg,latDeg,altMeters,headingDeg,pitchDeg,rollDeg,disregardHPR=false)


                var tmpPosition = Cesium.Cartesian3.fromDegrees(longDeg, latDeg, altMeters);

                entArray[entID].position = tmpPosition;

                if (disregardHPR == false)


                    var tmpHeading = Cesium.Math.toRadians(headingDeg - 90);

                    var tmpPitch = Cesium.Math.toRadians(pitchDeg);

                    var tmpRoll = Cesium.Math.toRadians(rollDeg);

                    var tmpHPR = new Cesium.HeadingPitchRoll(tmpHeading, tmpPitch, tmpRoll);

                    var tmpOrientation = Cesium.Transforms.headingPitchRollQuaternion(tmpPosition, tmpHPR);

                    entArray[entID].orientation = tmpOrientation;



The rest of my work, unfortunately can’t be shared as I am working on it at my work and thus I think it is the proprietary of the company I am employed at/ I can tell you that I took things to a new level: I believe in the potential of Cesium as an Engine, and have added code to it so that it behaves like a network client to a master websocket server. I have created a protocol between them , so that the moment cesium connects to the server, the server immediately sends all commands to Cesium , such as Create entities, set entity positions, set special effects, like explosions, dynamic line of sight and more. All could be done from any remote computer and any remote language I’d like.

For instance: I just finalized a huge demonstration of Behavior Trees over … Python , which acts as a websocket server, fully demonstrating the capabilities over network. the server, of course, can hook as many Cesium clients as those who connects to it. As I believe in the wonderful potential of cesium , I am using it to display some neat SW technologies required at the industry I work at . Cesium has some more steps to go , yet they are minor ( like working with 3D tiles locally , developing tutorials about how to add my own GIS info to the Engine , making all position calculus in double precision [for camera precision in space[ and some more minor stuff.) . in short , Cesium rocks, and applause to all of those who are doing great work on it. if you are one of them , then applause for you as well! , I never believed I’d say it , but I am actually thinking of moving away from C++ engines (for the sake of demonstrations of technologies ) to cesiumjs web based engine…

I would try using a CallbackProperty instead of changing the positions directly, since properties in CesiumJS are assumed to be static by default. There’s a few examples of CallbackProperty used in Sandcastle, like this one:


And thank you so much for the kind words! I have contributed a bit to the Cesium engine and it’s really great to hear that you’re not only able to do what you need with it, but that it rivals a desktop experience. I definitely personally believe in the web and its ability to create experiences that are accessible across all devices.

If your company is ever interested in showcasing their work with Cesium, we do regularly feature user showcases on the blog: https://cesium.com/blog/categories/userstories/

You can always reach out to me (omar@cesium.com) and/or hello@cesium.com for that.