Interplenatary visualization settings problems

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

I’m attempting to switch the central body of the view to something other than the earth. I’m running into two problems but I can’t figure out how to overcome them. The first problem is that planetoids that are smaller than the earth are blacked out unless you get close enough to them. At that point they light up. I thought that disabling lighting and shadow mapping would stop that but I can’t seem to get that to happen. A second problem I’m having is that I can’t seem to set the far distance so when looking at the sun, for example, it quickly blinks out even when it occupies a large part of the screen. I’d like to get a view that is the entire solar system with planetary orbit paths at the end of this.

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

This is the state fo my trial and error code for trying to achieve this:

var ellipsoid = new Cesium.Ellipsoid(planetoid.x, planetoid.y, planetoid.z);
var globe = new Cesium.Globe(ellipsoid);
var newGeographicProjection = new Cesium.GeographicProjection(ellipsoid);

viewer.scene.globe = globe;
viewer.scene.camera.projection = newGeographicProjection;
viewer.scene.globe.baseColor = planetoid.baseColor;
viewer.scene.fog.enabled = false;
viewer.scene.moon.show = false;
viewer.scene.sun.show = false;
viewer.scene.shadowMap.enabled = false;
viewer.scene.logarithmicDepthBuffer = true;
viewer.scene.enableLighting = false;
viewer.scene.showGroundAtmosphere = false;
viewer.camera.far = 1e12;

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

I’m trying to create a solar system viewer where ultimately I’d like to be able to jump from one planet/moon/minor planet to another.

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

Whatever the current version in webpack is which I think is 1.64.0

Some more information. There is an occluding transparent-ish earth that’s being used somewhere and I honestly can’t find it. I believe it’s the earth ellipsoid because the clipping of the CZML is identical. Stepping through the occluder code after the CB size is changed isn’t showing any ellipsoid size other than the one that I’ve inserted. I’ve attached some screenshots with some CZML. The first is with the Earth and the CZML. The second is with Mercury and the same CZML. The third is the same view but with it zoomed in so you can start to see the image on Mercury. The last is the frustrum cone view of the first Mercury view. I’m pretty much blocked on figuring this out at this point. Maybe putting it down and coming back to it will give me some fresh eyes but anything people could suggest for what’s going on and how to overcome it would be awesome.

PS I’m aware that there are going to be problems with the pole geometry which have to be overcome since the pole is now wrapped around an earth oriented body, and some other not so small details, but right now I’m stuck trying to figure out where this other masking/occluding/whatever body is being left over from or set from and then applied to the scene map.

Since I had a hard time finding this in the stack to see if there was a reply I figured I’d just ping the group to see if someone had a chance to look at this and point me in the right direction for solving this. Thanks!

Hey Hank,

Smaller ellipsoids being blacked out is definitely a bug. Can you share the x/y/z of your planetoid there so we can reproduce it? Or ideally just a Sandcastle link (you can click “share” and paste the link you get here).

There is a known issue where the ground atmosphere causes this: https://github.com/AnalyticalGraphicsInc/cesium/issues/7124

I see you’re setting that to false on the scene, but it’s a property on the globe. Let me know if changing it to viewer.scene.globe.showGroundAtmosphere = false fixes it.

Thanks the lighting suggestion being set on the correct object fixed the shadowing problem. It unfortunately didn’t fix the masking problem of the CZML lines though. Any insight on that and how to set near/far distances so I can do a solar-system wide view would be awesome. Thanks! PS I posted the code here:

I’ve partially fixed the problem with the obscuration problem. I can’t nail down why but the viewer.scene.globe isn’t being used for calculating obscurations. Instead it is the viewer level mapProjection that is doing that. If I create my viewer with the following code I get a mostly right obscuration:

var viewer = new Cesium.Viewer('cesiumContainer',{
    skyAtmosphere: false,
    mapProjection: new Cesium.GeographicProjection(new Cesium.Ellipsoid(2497000,2497000,2497000))
});

I say mostly right because the obscuring volume that is generated is not a sphere but instead a box. You can see it clearly when the frustrums are turned on. Essentially as the
mapProjection ellipsoid gets smaller than the WGS84 default ellipsoid it starts being clipped. The moon looks like a truncated sphere. There is a second problem, the
mapProjection can only be set when the viewer is created. So swapping central bodies during the execution then becomes impossible.

First question, is this it expected that the mapProjection ellipsoids is what should be used for the obscuration calculations. Second question, should there be a way to change
it dynamically if that is so? Third question, how can I get the obscuring volumes to retain their spherical shapes. I've tried tuning near/far ratios and other parameters but with
no success.

Related to the maximum viewable distance, nothing I do with the viewer.scene.logarithmicDepthFarToNearRatio or farToNearRatio (depending on which mode I’m using) seems to change the absolute maximum viewing distance. This is my current code (at the same repo link) in my last iteration. I know it’s only using one of the values at a time but I’m toggling back and forth trying to get some change in behavior…

viewer.scene.logarithmicDepthBuffer = true;
viewer.scene.logarithmicDepthFarToNearRatio = 1e24;
viewer.scene.farToNearRatio = 1e24;

Hey Hank,

Can you tell me how to reproduce the occlusion issue you’re having? I’m running your solar system example locally and looking at the moon ellipsoid but I don’t see any CZML lines.

Also, if you haven’t already seen it, replacing the default ellipsoid might be a better way to do it, rather than passing a custom ellipsoid, as discussed here:

https://github.com/CesiumGS/cesium/issues/4245#issuecomment-243300221

If you’re able to reproduce some of these issues in a Sandcastle (https://sandcastle.cesium.com/index.html?) then we can open an issue with that to get more feedback from other maintainers (or contributing a PR to fix it would if you know where the issue is would be awesome!)

This code pasted into Sandcastle is showing the clipping behavior for smaller ellipsoids (this is set to the radius of Mercury). Rotate the view around to see the problem more exacerbated than in the initial orientation:

var radius = 2497000;
var viewer = new Cesium.Viewer(‘cesiumContainer’, {
shouldAnimate : false,
skyAtmosphere: false,
mapProjection: new Cesium.GeographicProjection(new Cesium.Ellipsoid(radius,radius,radius))
});

Sandcastle.reset = function() {
viewer.dataSources.add(Cesium.CzmlDataSource.load(’…/SampleData/simple.czml’));
var ellipsoid = new Cesium.Ellipsoid(radius, radius, radius);
var globe = new Cesium.Globe(ellipsoid);

globe.enableLighting = false;
globe.showGroundAtmosphere = false;
var newGeographicProjection = new Cesium.GeographicProjection(ellipsoid);

viewer.scene.globe = globe;
viewer.scene.globe.baseColor = Cesium.Color.AQUA;
viewer.scene.fog.enabled = false;
viewer.scene.moon.show = false;
viewer.scene.sun.show = false;
viewer.scene.shadowMap.enabled = false;

};

This code pasted into Sandcastle is showing how the clipping behavior isn’t really happening at Sun-sized ellipsoid size but the bigger problem is I can’t seem to figure out the maximum view distance. I’m thinking it’s not near/far ratio but instead a setting on the object of maximum viewer distance from but I can’t determine what it should be.

var radius = 696342000;
var altitude = radius * 3;
var viewer = new Cesium.Viewer(‘cesiumContainer’, {
shouldAnimate : false,
skyAtmosphere: false,
mapProjection: new Cesium.GeographicProjection(new Cesium.Ellipsoid(radius,radius,radius))
});

var czml = [{
“id” : “document”,
“name” : “CZML Geometries: Polyline”,
“version” : “1.0”
}, {
“id” : “Planetoid Orbit Line”,
“name” : “Red line clamped to terain”,
“polyline” : {
“positions” : {
“cartographicDegrees” : [
0, 0, altitude,
45, 0, altitude,
90, 0, altitude,
135, 0, altitude,
180, 0, altitude,
225, 0, altitude,
270, 0, altitude,
315, 0, altitude,
360, 0, altitude
]
},
“material” : {
“solidColor” : {
“color” : {
“rgba” : [255, 255, 255, 255]
}
}
},
“width” : 5,
}
}];

Sandcastle.reset = function() {
var ellipsoid = new Cesium.Ellipsoid(radius, radius, radius);
var globe = new Cesium.Globe(ellipsoid);

globe.enableLighting = false;
globe.showGroundAtmosphere = false;
var newGeographicProjection = new Cesium.GeographicProjection(ellipsoid);

viewer.scene.globe = globe;
viewer.scene.globe.baseColor = Cesium.Color.ORANGE;
viewer.scene.fog.enabled = false;
viewer.scene.moon.show = false;
viewer.scene.sun.show = false;
viewer.scene.shadowMap.enabled = false;

//Two ways tried setting near/far ratio to zoom out to solar system size
//NormalDepth Buffer
//viewer.scene.farToNearRatio = 1e50;

//Logarithmic depth buffer
viewer.scene.logarithmicDepthBuffer = true;
viewer.scene.logarithmicDepthFarToNearRatio = 1e50;

var dataSourcePromise = Cesium.CzmlDataSource.load(czml);
viewer.dataSources.add(dataSourcePromise);

};

Hey Hank,

The occluding issue seems to be because the Earth-sized ellipsoid is hardcoded in a few locations, see this GitHub issue: https://github.com/CesiumGS/cesium/issues/8683

Can you elaborate on what you mean by maximum viewer distance? There is no limit to how far the camera can go. If you mean the sun disappears when you go back to a certain distance, that’s because of the screen space error, which you can lower with:

viewer.scene.globe.maximumScreenSpaceError = 0.1;

``

But at that point, it seems there are precision issues.

Yeah I mean the sun and all objects blanking out at a certain distance. I thought it may be the near/far ratios because in VO all objects have a maxmimum viewing distance which I was picturing that ratio being coding off of. I couldn’t find any other distance thresholds in the Cesium back end so didn’t know where else to look. I could try the maximum screenspacerror. Ideally I’d like to be able to draw the whole solar system with a view out beyond Pluto. I’ll try the field you listed below.

I tried manipulating that value from everywhere from 1e-3 to 100 and the disappearing orbit line and sun happen at essentially the same distance away.

My bad, looks like you need to move the far plane, but there’s still going to be depth issues. I documented the issue here:

https://github.com/CesiumGS/cesium/issues/8686

How is it going with your solar system project? I am studying the same thing…

Did you try this for visibility of remote bodies?

viewer.scene.camera.frustum.far = 1e12; //Move the far wall of the viewing frustum.

Starting from the example in this thread I am arrived to this draft… still far from being a real solar system…:

  • globes lack night/day
  • globes orientation must be dynamically calculated
  • center globe to be replaced by sun
    -…

This is another experiment, to wrap planets surfaces on original center/earth globe.