Hi guys, I’m one of the new immigrants in the Cesium community due to the availability of Google Earth data. I’m playing around trying to integrate it in my webapp (cubetrek.com).
One basic question I’ve run into: how do I prevent the camera from going under the terrain?
Naively I would just set viewer.scene.screenSpaceCameraController.minimumCollisionTerrainHeight = 100; . But this doesn’t seem to work.
Is this because I’m using Cesium3DTileset and not some other way of providing terrain data?
Awesome, great to hear you’re checking out Cesium!
Yes, the root of this is that there are two different ways of providing “terrain” data into CesiumJS. One of which is 3D Tiles like how the Google data is streamed. In the CesiumJS API, this is accessed through Cesium3DTileset.
The other way is trough imagery and terrain, which is usually 2D textures draped on top of 3D elevation data. It was generally assumed that most apps would load these for a global context, then load additional data into the scene. This assumption is what much of the existing camera controls and systems are built around in CesiumJS.
Recently we are seeing more and more use cases where the entire earth is represented with 3D Tiles, so there is no longer need for base layers terrain and imagery to provide the global context. I’ve gone ahead and opened an issue to track this feature..
In the meantime, you should be able to emulate this behavior by sampling the height of the tileset at the current camera position, and offsetting the camera height so it’s above that value. Scene.postRender may be a convenient event to subscribe to so you can do so each frame.