Is there anyway to perform boolean logic on geometry?

I'm trying to determine if there is an easy way to perform Boolean logic on geometry, primarily intersection. I'd like to find a way that doesn't involve manually calculating the intersection as I'd like to take advantage of the built in timeline to make the objects and their intersection bigger over time. Hopefully the following picture makes what I'm trying to accomplish a bit clearer.

In this example I have two circles growing over time but I want to only be seeing their intersection growing over time.

I thought there might be some way to do this via polygon holes but I haven't been able to figure it out yet.


Cesium does not do this, but you might be able to integrate another library. Perhaps or


Thanks for the response. I had been looking at csg.js but I hadn't seen turfjs. When looking at csg.js I was having a hard time figuring out where I could inject it into cesium. I'm relatively new at Cesium and not exactly sure where in the code the objects are being interpolated based on the current time and then where they are being rendered. Best case is I could somehow create new geometry that has properties to allow intersection and then apply one of these libraries to making it happen after interpolation. I just don't know enough about cesium yet to know what the best way to do that would be.

I'll keep digging around but if someone has a suggestion about how this could potentially be implemented I would love to hear it.

There is also jsts javascript port of the widely used JTS Topology Suite

the original JTS

It really depends on what exactly you are trying to draw and if the result of your intersection is a shape we already handle. For example, if you wanted to render the intersection of 2 boxes, that is easy because the result is a box and Cesium already knows how to draw boxes. You just need to supply the algorithm that produces the intersection. The same is true if your shapes are in 2D because the result will always be a polygon of some form. It would be trivial to do this kind of visualization using the Entity API.

Where it gets non-trivial is the moment you have shapes that we don’t handle, like the intersection of 2 spheres. At that point you need to create custom geometry. That gets you a static shape, but you would need to handle the tracking/updating of the geometry over time yourself. You could go a step further and implement your custom geometry as an Entity plug-in (which as far as I’m aware no one outside of the core Cesium team has done on their own yet), which then lets it directly interoperate with the rest of the Entity API. It’s entirely possible, just not something there’s a lot of doc on yet. Of course even if you did all of this, the next hurdle would be performance, which will be an issue unless you are only talking about a small amount of objects.

Another even more complex solution would be doing it all in the shader, which would eliminate the performance problem (or at least offload it to the video card), but I’m not sure the amount of worked involved or the complexity makes it realistic.

A completely different approach, would be to use translucent geometry, and allow the overlapping of them to produce more opaque shapes. So if you have a red, green, and blue translucent sphere, the intersection is going to be whiter and more opaque. Of course this doesn’t do exactly what you want, but it’s a compromise that incredibly simplifies the problem

thanks for the turfjs link, the first time I’ve seen it.

a lot of great stuff in turf, what caught my eye in particular: isolines, tin and triangle-grid,

been thinking about implementing a few of these things for a while now

Thanks for this very detailed response. I did have some hopes of doing the intersections of 3D objects but I would get a lot of what I want to get done with 2d intersections. You would recommend I just do something like register for the scene prerender event and then update the entity polygon property with the appropriate polygon according to the event time? Or is there some easier/more efficient way of going about it?

Using entities, you can either implement a custom property or simply use the CallbackProperty. How is your data organized? Do you have shapes associated with an interval of time? Or is the shape moving/changing constantly?

The shapes are moving constantly and their new shape is directly determined by an algorithm using time as an input. Thank you.

CallbackProperty is definitely what you want. Here’s a simple example that you can prototype with. Just fill in the function. This assumes you already have your source data loaded in some way that you can easily look up data for a given time.

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var hierarchy = new Cesium.CallbackProperty(function(time) {

//TODO Compute and return hierarchy/positions at the provided time.

}, false);

var shape = viewer.entities.add({

polygon : {

hierarchy : hierarchy,

material : Cesium.Color.RED.withAlpha(0.5),

outline : true,

outlineColor : Cesium.Color.BLACK




You could also implement a completely custom property (instead of using CallbackProperty) if you wanted to have a re-usable class that takes shapes as input and then returns intersections.