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

Camera can't be put low #2415

Closed
alexander-entin opened this issue Jan 21, 2015 · 3 comments
Closed

Camera can't be put low #2415

alexander-entin opened this issue Jan 21, 2015 · 3 comments

Comments

@alexander-entin
Copy link

Load the code into Sandcastle and try looking at the model from below.
Camera can't be put lower than 12.6 meters.

var point = 
     { lon: -2.434, lat: -0.248 } // Case 1
//    { lon: -2.137, lat: 0.66 } // Case 2
;

var viewer = new Cesium.Viewer('cesiumContainer', {
    baseLayerPicker: false
  , terrainProvider: new Cesium.CesiumTerrainProvider({
        url : '//cesiumjs.org/tilesets/terrain/smallterrain'
    })
});
viewer.scene.globe.depthTestAgainstTerrain = true

viewer.camera.flyTo({
    destination : Cesium.Cartesian3.fromRadians(point.lon, point.lat, 100)
  , duration: 0
});

// put the model at terrain height
Cesium.sampleTerrain(viewer.terrainProvider, 11, [viewer.camera.positionCartographic.clone()])
.then(function(cartographic) {
    var alt = cartographic[0].height || 0
    console.log(alt)

    var czml = new Cesium.CzmlDataSource()
    czml.load([{ id: "document", version: "1.0" }, {
        position: {
            cartographicRadians: [point.lon, point.lat, alt]
        }
      , model: { 
          gltf: '../../SampleData/models/CesiumAir/Cesium_Air.gltf' 
      }
    }])
    viewer.dataSources.add(czml)
})

// to monitor camera height
setInterval(function() {
   console.log(viewer.camera.positionCartographic.height)
}, 3000)    

In "Case 2" (un-comment line 3) terrain height is -32.4 but camera can't be put lower than -12.6 m (again! now negative).

"Case 2" also illustrates #2271 - when camera height becomes negative terrain and sky disappear.

Also got an exception several times while manipulating the camera with middle mouse button pressed:

An error occurred while rendering. Rendering has stopped.
RangeError: Invalid array length
RangeError: Invalid array length
    at updateFrustums (http://cesiumjs.org/Cesium/Source/Scene/Scene.js:821:36)
    at createPotentiallyVisibleSet (http://cesiumjs.org/Cesium/Source/Scene/Scene.js:971:13)
    at render (http://cesiumjs.org/Cesium/Source/Scene/Scene.js:1373:9)
    at Scene.render (http://cesiumjs.org/Cesium/Source/Scene/Scene.js:1413:13)
    at CesiumWidget.render (http://cesiumjs.org/Cesium/Source/Widgets/CesiumWidget/CesiumWidget.js:641:25)
    at render (http://cesiumjs.org/Cesium/Source/Widgets/CesiumWidget/CesiumWidget.js:68:32)
@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 21, 2015

Thanks for the report. @bagnell can probably suggest a workaround.

@mramato
Copy link
Contributor

mramato commented Feb 4, 2015

There are a couple of things at work here.

  1. When in the camera's default mode, the closest you can get to the terrain is specified by the viewer.scene.screenSpaceCameraController.minimumZoomDistance property. I believe it defaults to 20 (mainly because of the sky disappearing issue I think).
  2. If you are in a different camera reference frame (i.e. you aren't looking at the center of the earth), you can get as close to whatever you are looking at via the above property as well. The 3D Models example is a good illustration of that (use the combo box and select skinned model). You are only about 1 meter off the ground in that example.
  3. The limitation of 2, is that in this mode we currently don't keep the camera above terrain. (which is on the todo list).

@pjcozzi
Copy link
Contributor

pjcozzi commented Sep 16, 2015

@alexander-entin thanks for the report. This is fixed in master, and will be in Cesium 1.14 on October 1.

@pjcozzi pjcozzi closed this as completed Sep 16, 2015
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

3 participants