1. A concise explanation of the problem you’re experiencing.
I want to determine if a screen point is on the sphere by
var position = viewer.scene.camera.pickEllipsoid(screenPoint, viewer.scene.globe.ellipsoid),
the result is correct when the position not equal undefined,but I get the error result when I change the window.devicePixelRatio in chrome browser.
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
var viewer = new Cesium.Viewer(‘cesiumContainer’);
var canvas = document.createElement(‘canvas’);
canvas.width = viewer.scene.canvas.width;
canvas.height = viewer.scene.canvas.height;
canvas.style.position = ‘absolute’;
canvas.style.top = ‘0px’;
canvas.style.left = ‘0px’;
canvas.style[‘pointer-events’] = ‘none’;
viewer.scene.canvas.parentNode.appendChild(canvas);
var sceneContext = canvas.getContext(‘2d’);
sceneContext.fillStyle = 'rgba(255, 0, 0, ’ + 0.7 + ‘)’;
render();
console.log(window.devicePixelRatio);
function render(){
var i=0;
var j=0;
var screenPoint,position;
for(;i<canvas.height;i++){
for(j=0;j<canvas.width;j++){
screenPoint = new Cesium.Cartesian2(j, i);
position = viewer.scene.camera.pickEllipsoid(screenPoint, viewer.scene.globe.ellipsoid);
if(position){
sceneContext.fillRect(j,i,1,1);
}
}
}
}
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
4. The Cesium version you’re using, your operating system and browser.
Cesium 1.64
chrome browser
window.devicePixelRatio=1.25