Detect if Entities are in view

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

Unable to detect if a bounding box is occluded by the earth. I’ve tried creating an occluder using the bounding sphere from the earth & one from the frustum but both methods do not seem to be working!

The occluder always returns “NONE” and the fustrum always returns “FULL”

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

My current thinking (working on the sandbox)

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

// To geographically place an HTML element on top of the Cesium canvas, we use

// scene.cartesianToCanvasCoordinates to map a world position to canvas x and y values.

// This example places and img element, but any element will work.

// Scractch memory allocation, happens only once.

var scratchRectangle = new Cesium.Rectangle();

var worldSphere;

worldSphere = Cesium.BoundingSphere.fromEllipsoid(Cesium.Ellipsoid.WGS84);

var htmlOverlay = document.getElementById(‘htmlOverlay’);

var scratch = new Cesium.Cartesian2();

viewer.scene.preRender.addEventListener(function() {

var position = Cesium.Cartesian3.fromDegrees(-75.59777, 40.03883);

var viewRect =,


var east = Cesium.Math.toDegrees(viewRect.east);

var west = Cesium.Math.toDegrees(viewRect.west);

// This does not work when zoomed out - reaches ±180 degrees.

//console.log("east: " + east + ", west: " + west);

var sphere2 = new Cesium.BoundingSphere(position, 0.5);

console.log("Earth Position: " +;

console.log("Earth Radius: " + worldSphere.radius);

console.log("Position Center: " +;

console.log("Position Radius: " + sphere2.radius);

console.log("Camera : " +;

var occluder = new Cesium.Occluder(worldSphere,;

var visible = occluder.computeVisibility(sphere2);

// var cullingVolume =,,;

// var intersect = cullingVolume.computeVisibility(sphere2);

if(visible != Cesium.Visibility.NONE) {

console.log(visible); //returns Visibility.NONE


var canvasPosition = viewer.scene.cartesianToCanvasCoordinates(position, scratch);

if (Cesium.defined(canvasPosition)) { = canvasPosition.y + ‘px’; = canvasPosition.x + ‘px’;



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

I would like to render dynamic content (canvas elements) on top of the Cesium viewer. Billboards and BillboardGroups run out of graphics eventually (I believe this is due to Atlas not freeing up texture space for removed billboards) so I’d like to do this if possible via the cartesianToCanvasCoordinates method.

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

1.67 Chrome 80

No luck trying to get it working using an EllipsoidalOccluder either. I'm starting to think something is wrong with my understanding of the camera, or the way I'm handling the position of the image.. or both!

     var cameraPosition =;
     var occluderEllipsoid = Cesium.Ellipsoid.WGS84;
     var occluder2 = new Cesium.EllipsoidalOccluder(occluderEllipsoid, cameraPosition);
     var isPointVisible = occluder.isPointVisible(position);

Change worldSphere into
worldSphere = new Cesium.BoundingSphere(new Cesium.Cartesian3(0, 0, 0), 6350000);
should work, but I don’t know why.