Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With depthTestAgainstTerrain eq. true but Entity or Primitive are not covered by globe #11393

Closed
wewindy opened this issue Jul 5, 2023 · 4 comments · Fixed by #11412
Closed

Comments

@wewindy
Copy link
Contributor

wewindy commented Jul 5, 2023

There is an eg.

sandcastle 1.107

box.webm

Code:

const viewer = new Cesium.Viewer("cesiumContainer");
viewer.scene.globe.depthTestAgainstTerrain = true;

const redBox = viewer.entities.add({
  name: "Red box with black outline",
  position: Cesium.Cartesian3.fromDegrees(-107.0, 40.0, -200000.0),
  box: {
    dimensions: new Cesium.Cartesian3(400000.0, 300000.0, 500000.0),
    material: Cesium.Color.RED.withAlpha(0.5),
    outline: true,
    outlineColor: Cesium.Color.BLACK,
  },
});

viewer.zoomTo(viewer.entities);

I have tried to use Primitive API, but still:

Platform Info.

Platform 1

Windows 11 22H2
Intel i5 13600K with Intel UHD 770 GraphicCard Inside
Browser:Mircosoft Edge 114.0.1823.58 & Chrome 114.0.5735.199

WebGL Report

image

image

Platform 2

Windows 11 22H2
AMD R7-7735HS with AMD Radeon RX 680M GraphicCard Inside
Browser:Mircosoft Edge 114.0.1823.58 & Chrome 114.0.5735.199

WebGL Report

image

image

@wewindy
Copy link
Contributor Author

wewindy commented Jul 5, 2023

There is a Primitive's example:

sandcastle 1.107

checkboard.webm

@wewindy
Copy link
Contributor Author

wewindy commented Jul 6, 2023

CesiumJS 1.103 and below do not have this problem.
PTAL @ggetz

@ggetz
Copy link
Contributor

ggetz commented Jul 6, 2023

Thanks for the report @onsummer! I believe this has to do with async behavior and #6991.

To test, log the value of depthTestAgainstTerrain after a promise has resolved, and you'll see that the value is false.

await viewer.zoomTo(viewer.entities);
console.log(viewer.scene.globe.depthTestAgainstTerrain);

@wewindy
Copy link
Contributor Author

wewindy commented Jul 7, 2023

Thanks to reply, I try to set globe.depthTestAgainstTerrain = true; in a resolved promise or directly setTimeout after adding entity or primitive:

scene.primitives.add(/* ... */);

setTimeout(() => { 
  scene.globe.depthTestAgainstTerrain = true; 
}, 0)
// or
Promise.resolve(0).then(() => { 
  scene.globe.depthTestAgainstTerrain = true; 
})

that will work, but is there a better solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants