question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Camera.computeViewRectangle doesn't work in 2D or CV

See original GitHub issue

Reported on the forum: https://groups.google.com/forum/?hl=en#!topic/cesium-dev/Ildibeod608

var viewer = new Cesium.Viewer('cesiumContainer', {
    sceneMode: Cesium.SceneMode.SCENE2D
});

viewer.scene.camera.flyTo({
    destination: Cesium.Cartesian3.fromDegrees(-90, 43, 50000),
    duration: 0,
});

viewer.camera.moveEnd.addEventListener(logViewRectangle);

function logViewRectangle() {
    console.log('camera.computeViewRectangle() is ' + JSON.stringify(viewer.scene.camera.computeViewRectangle()));
}

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:2
  • Comments:23 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
mlui00commented, Oct 5, 2018

I’ve used this. (Cesium.Rectangle)

var rect = viewer.camera.computeViewRectangle(viewer.scene.globe.ellipsoid, scratchRectangle);
        
if(rect == undefined)
{
	var cl2 = new Cesium.Cartesian2(0, 0);
	var leftTop = viewer.scene.camera.pickEllipsoid(cl2, ellipsoid);
		
	var cr2 = new Cesium.Cartesian2(viewer.scene.canvas.width, viewer.scene.canvas.height);
	var rightDown = viewer.scene.camera.pickEllipsoid(cr2, ellipsoid);
	
	leftTop = ellipsoid.cartesianToCartographic(leftTop);
	rightDown = ellipsoid.cartesianToCartographic(rightDown);
	rect = new Cesium.Rectangle(leftTop.longitude, rightDown.latitude, rightDown.longitude, leftTop.latitude);
}
1reaction
electricsamcommented, Dec 23, 2019

I just ran into this issue as well. Are there any updates on a fix?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Camera.computeViewRectangle doesn't work in 2D or CV
I implemented a solution as described here to capture the view before a morph and reset it on morph complete, and it works...
Read more >
Cesium - Camera.computeViewRectangle to get current view ...
On the first line, Rectangle.fromDegrees needs 4 input parameters, not 2. Next, computeViewRectangle is not a static function, you have to call ...
Read more >
camera.computeViewRectangle not working with terrain ...
Hello. My company has been using Cesium for about a year now to develop a viewer for Wide Area Motion Imagery (WAMI).
Read more >
Camera.computeViewRectangle() does not cover all the ...
When I move camera toward South Pole, the view rectangle returned by Camera.computeViewRectangle() does not contain all the visible area.
Read more >
Bountysource
Camera.computeViewRectangle doesn't work in 2D or CV.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found