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

Infinite scroll 2D is really slow with polygons #5026

Open
hpinkos opened this issue Feb 22, 2017 · 9 comments
Open

Infinite scroll 2D is really slow with polygons #5026

hpinkos opened this issue Feb 22, 2017 · 9 comments

Comments

@hpinkos
Copy link
Contributor

hpinkos commented Feb 22, 2017

  • Open the viewer
  • Drag drop the attached GeoJSON file
  • Switch to 2D mode

The map is lags pretty badly in 2D infinite scroll mode. The performance is fine in 3D and is much better if you use the rotatable 2D map instead

vienna.geojson.txt

@hpinkos
Copy link
Contributor Author

hpinkos commented Mar 2, 2017

@bagnell a number of users on the forum have been complaining about slow polygons when upgrading from 1.2x to 1.30+. Do you know of anything that changed that might have caused that?

@pjcozzi
Copy link
Contributor

pjcozzi commented Mar 6, 2017

@hpinkos do you have links to the forum issues?

@bagnell sounds like something is being computed per-vertex/triangle per-frame. Perhaps it is missing a coarse-grained check?

@hpinkos
Copy link
Contributor Author

hpinkos commented Mar 6, 2017

Forum posts:

https://groups.google.com/d/msg/cesium-dev/hXC8gxdi3uE/ZBWHUL6jAgAJ
https://groups.google.com/d/msg/cesium-dev/wT2jkCrvvGQ/WdrP3QgmAwAJ

@hpinkos
Copy link
Contributor Author

hpinkos commented Apr 1, 2019

Also reported by @forest21000 in #7694

@ggetz
Copy link
Contributor

ggetz commented Apr 19, 2022

Reported again by @zhangchn in #10304.

@zhangchn
Copy link

Reported again by @zhangchn in #10304.

The performance issue in SCENE2D could NOT be alleviated by using MapMode2D.ROTATE.

@0dividedby0-b
Copy link

0dividedby0-b commented Sep 12, 2024

I am also seeing this same issue, even with MapMode2D.ROTATE enabled. Lower frame rate and higher CPU usage when 2D is compared to 3D.

@andrewda
Copy link

andrewda commented Dec 20, 2024

Hey folks. Running into a similar issue here. I'll preface this by saying I believe this only affects issues with MapMode2D.INFINITE_SCROLL -- issues that affect both INFINITE_SCROLL and ROTATE might be a separate, unrelated issue.

I did a little debugging, and the following diff to execute2DViewportCommands seems to fix it my performance issues...

diff --git a/packages/engine/Source/Scene/Scene.js b/packages/engine/Source/Scene/Scene.js
index e438fdf87e..e52b0d2723 100644
--- a/packages/engine/Source/Scene/Scene.js
+++ b/packages/engine/Source/Scene/Scene.js
@@ -3310,8 +3310,10 @@ function execute2DViewportCommands(scene, passState) {
   }
 
   camera._setTransform(transform);
-  Cartesian3.clone(position, camera.position);
+  camera.position.x = position.x;
+  camera.position.y = position.y;
+  // camera.position.z = position.z;
   camera.frustum = frustum.clone();
   passState.viewport = originalViewport;
 }

Setting camera.position.z seems to make the issue come back. Digging a little deeper, it looks like the camera's z is getting set in executeCommands to avoid z-fighting.

if (scene.mode === SceneMode.SCENE2D) {
// To avoid z-fighting in 2D, move the camera to just before the frustum
// and scale the frustum depth to be in [1.0, nearToFarDistance2D].
camera.position.z = height2D - frustumCommands.near + 1.0;

So this change performed in executeCommands was getting reverted when resetting the camera's position in execute2DViewportCommands. If this seems like a reasonable change, I'm happy to open a PR 😄

cc @ggetz

@andrewda
Copy link

This change also appears to fix #8302 (polyline zIndex issues in INFINITE_SCROLL mode)!

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

No branches or pull requests

6 participants