devicePixelRatio for camera.pickEllipsoid

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.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; = ‘absolute’; = ‘0px’; = ‘0px’;[‘pointer-events’] = ‘none’;


var sceneContext = canvas.getContext(‘2d’);

sceneContext.fillStyle = 'rgba(255, 0, 0, ’ + 0.7 + ‘)’;



function render(){

var i=0;

var j=0;

var screenPoint,position;



screenPoint = new Cesium.Cartesian2(j, i);

position =, viewer.scene.globe.ellipsoid);







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


You could scale up your canvas context before doing the fillRects: sceneContext.scale(window.devicePixelRatio, window.devicePixelRatio);

@Jonathan, I don’t know why my answers was deleted,so I can only replay by this way.
I set the scale for canvas and then change the devicePixelRatio in browser , but it’s still get error when devicePixelRatio less then 1.

在 2019年12月17日星期二 UTC+8下午12:02:07,pollux写道:

What do you mean with ‘change the devicePixelRatio in browser’? I don’t see it in the screenshot… (In CodeSandbox you can just save the code and copy the url of the window)

I usually change devicePixelRatio in browser setting,now I change browser scale equal 50%,and the devicePixelRatio become 0.5.
this is the reuslt image.


在 2019年12月18日星期三 UTC+8下午4:10:09,Jonathan写道: