Avoid camera collision to ground when using api


How can I implement collision detection (avoid camera collision to ground) ?
I know this can be done with viewer.scene.screenSpaceCameraController.enableCollisionDetection = true; but I think it is used with touch navigation…
but how can I do it when I use api like Camera.move/rotate/lookAt ?

Thank U

This might help:
Funny moment underground
Can do something like edist<1 to keep a meter above ground.

1 Like

Thank you Hyper Sonic,

I solved it by computing camera height (relative to terrain height) with Cesium.sampleTerrain (with camera cartographic position).
I do this on camera.moveEnd event and make a camera.moveUp() if it is less than a fixed limit.
But this is not perfect as the camera first go under limit, then go upper a little time after.

I suppose if the camera isn’t rolled or pitched the camera.moveUp method would work just fine, that’s good you got it working.

1 Like