Make camera controls respond only to 3D tileset pick and not to globe pick.

213 views
Skip to first unread message

Jonathan Chemla

unread,
Mar 26, 2020, 12:48:55 PM3/26/20
to cesium-dev
1. A concise explanation of the problem you're experiencing.
I would like to have the camera controls respond only when mouse is clicking on a given 3D tileset I added to the scene, and not when mouse is clicking on the globe (default ellipsoid, no terrain provider). See context for why, I basically would like to use the cesium viewer for an asset which is not linked to a geographical context - therefore an asset which is like hanging in the air on a black background, a bit like sketchfab viewer.

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
Not a bug, but here is what I tried so far. I've tried playing with viewer.scene.globe.depthTestAgainstTerrain = false with no luck. I've also seen mentions of depthFailMaterial, but used for polylines and polygons and not the globe directly. Could it be used in my case? 

After digging through code and github, here is probably the best bet. I am using default camera controls (through scene.screenSpaceCameraController), which probably perform a test based on z-buffer at mouse coordinate when clicking. The controller is probably calling viewer.scene.pickPosition which in turn calls viewer.scene.globe.pick. What I would like to do is basically prevent globe.pick to return anything so camera controls would only work when mouse is clicking on the 3Dtiles asset, and not on the globe.

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I am using the cesium viewer to display a 3D tiles mesh (100M polys tiled with ion) which should not be linked to any geospatial context. So I disabled imagery providers, set terrain to ellipsoid, set sky, atmosphere, world to black, etc. When I use middle mouse button to rotate around the 3D tileset, it works correctly, but I would like to disable it when clicking outside the tileset (on the terrain), which sometimes induce a really large camera motion since the pick point is far from camera center.

4. The Cesium version you're using, your operating system and browser.
Latset build available, 1.67 (on firefox and chrome, on windows)

Sorry for being not so concise. Best,
Jonathan

Omar Shehata

unread,
Mar 27, 2020, 10:15:54 AM3/27/20
to cesium-dev
I think a simpler thing you can do is just lock the camera to that 3D Tileset's origin (like its boundingSphere.center) as described here:


That way the user can freely rotate and zoom out but will never lose track of it. You could also turn off the globe (by passing globe:false to the Viewer constructor).

Is this like a BIM/CAD application where you're visualizing a design that doesn't have a defined world-location?

Jonathan Chemla

unread,
Mar 27, 2020, 1:04:54 PM3/27/20
to cesium-dev
Hi Omar, and thanks for the quick reply.

I cannot use your first trick to lock the camera origin, as I want to be able to move (pan, rotate, zoom). If I try to use what is described in your other post, then I can only look around and zoom, but I cannot pan anymore.
And if I delete the globe (I already tried using globe.destroy(), but the same happens when doing so at viewer creation), then the camera motion are hugely amplified (maybe it has to do with false height reference ?).

The model is that of a mosaicked standing wall. By the way, I am working with a 1M polygon mesh I tiled with my Cesium Ion free account. I'm trying to tile a 100M version of the same model, but the gltf versions had errors during tiling, and the obj version has been blocked at 9% processing for a day. Do you have an idea where this can come from ? Asset it is 85811 (and I deleted the gltf versions to not count against my 5Gb quota).

Thanks again,

Jonathan

Jonathan Chemla

unread,
Apr 1, 2020, 5:52:24 AM4/1/20
to cesium-dev
HI Omar,

Do you have another hint regarding the restriction of the controls to the tileset and not the globe?
And most important, do you have an idea about why the tiling fails on Cesium Ion? If you can share your email with me, I can send you multiple versions of the 3D files so you can try them out and understand why it fails.

Best and talk to you soon,

Jonathan

Omar Shehata

unread,
Apr 2, 2020, 2:35:03 PM4/2/20
to cesium-dev
Hey Jonathan,

Can you tell me how these models are created? If this is photogrammetry, you should select "3D Capture" when uploading to Cesium ion. If you need to share any files outside the public forum feel free to email sup...@cesium.com and we can take a look.

Have you tried disabling the globe like in this Sandcastle example? Does the camera behave as expected there? Note that the location of the model in this example is on the surface of the Earth, even if the globe is turned off, placing it at a location on the surface should give you a more stable camera.

Jonathan Chemla

unread,
Apr 3, 2020, 6:02:29 AM4/3/20
to cesium-dev
Hey Omar, 

Thanks for the answer! Yes the models are photogrammetry, ans I always selected Tile mesh to 3D tiles when uploading to Ion. 

Here is where I get so far - sorry it is not a minimal example, but the important things are below : Cesium Sandcastle 100M demo

We can forget trying to get the controls to avoid responding when clicking on the globe for now. I'd like instead to focus on the quality of the 3D tileset I can produce from the high resolution mesh I want to share. 
On the sandbox link, you have 2 tilesets
 - below is the tileset produced from Cesium Ion given the decimated 1M polygons mesh (obj) and 4x16k textures. 
 - and on top of it is a tileset of the 100M polygons obj mesh (3x16k textures). The photogrammetry was processed in RealityCapture, and I've used Metashape for importing and tiling the mesh, in order to export cesium 3D tiles. 
The workaround of using Metashape for producing the 3D tiles is because I had many attemps at tiling the 100M mesh on Cesium Ion with no luck (I tried obj, gltf, fbx, with and without draco compression, and without webp images). 

So far, the cesium viewer seems to better manage tile streaming of the cesium ion tileset, while it take a while to load tiles of the metashape tileset (probably due to bad configuration of the photoscan meshing, which produced tiles with a too high number of polygons). As you can see, the model is that of a vertical wall, so I tried playing with properties like the one listed below to increase mesh and texture quality, with no luck.

{
 maximumScreenSpaceError : 2.0, // default: 16
maximumMemoryUsage: 2048.0, // default: 512
//---
 skipLevels : 1, // default: 1
skipScreenSpaceErrorFactor : 8,// default: 16.0
dynamicScreenSpaceError : true, // default; false
}

So my first question is: Do you think we can tweak the tileset properties to make the streaming of higher quality, or is it the result of bad tiling parameters? 
Hence the second question: I will send you a dropbox link to the original meshes in the different formats I've tried. Could you try to tile them on Ion (maybe have a look at the logs of my account first to see what might have gone wrong in the tiling trials)? If you manage to enable draco compression and webp images, that would also be a bonus, as shown in the article : https://cesium.com/blog/2019/05/07/faster-3d-tiles/

Thanks again a lot for your help, and do not hesitate if you need anything more. 

Best, 

Jonathan




Le jeudi 2 avril 2020 20:35:03 UTC+2, Omar Shehata a écrit :
Hey Jonathan,

Can you tell me how these models are created? If this is photogrammetry, you should select "3D Capture" when uploading to Cesium ion. If you need to share any files outside the public forum feel free to email sup...@cesium.com and we can take a look.

Have you tried disabling the globe like in this Sandcastle example? Does the camera behave as expected there? Note that the location of the model in this example is on the surface of the Earth, even if the globe is turned off, placing it at a location on the surface should give you a more stable camera.
Reply all
Reply to author
Forward
0 new messages