API help, what is the best way to find the lat long range of each end of a box

I am new to Cesium and am familiarizing myself with the Apis.

I would like to draw little boxes inside of a box that I have already created. However I can't seem to find more information on how I can do this. It seems each box entity would need a different position. Is there a better way to do this than to +/- various values to the center lat long through trial and error?

Hi there, welcome!

If you’re willing to dive a little lower level, you can create Primitives with BoxGeometries from minimum and maximum positions which may be a little more straightforward in this case. However if you need to boxes to be dynamic and update, I would recommend sticking with Entities, in which case you’ll need to use the position.



Hi Gabby,
thanks for the reply. With Boxgeometries, would I be able to create identical boxes, next to each other (on the same axis) with no overlap?

I have been playing around with the positions of these entities, and for some reason, the Cartesian coordinates seem to give me strange behaviors. changing one of the properties, (x,y or z) makes my box shift on two axis. Is there a utility function or something that i can use to reliably predict how my box will move?

Hi Jacob,

Are you using Cartesian coordinates or Cartographic coordinates? Cartesian Coordinate define points in world space relative to the origin (the center of the globe), where Cartographic uses the latitude/longitude system. Cesium uses Cartesian coordinates for most functions, which you can convert to with Cartesian3.fromDegrees.

Other than that, I’m not sure what the problem is exactly. Could you put together a Sandcastle example to show what you mean?



in this demo I am trying to line up the boxes to be next to each other

How’s this work? https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/?src=Hello%20World.html&label=Showcases&gist=aa68916211f84df439eb414192c4a6ce

You may have some issues with gaps because of the curvature of the earth, depending on your scale.