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

Enable terrain by default in CesiumViewer #6198

Merged
merged 3 commits into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Apps/CesiumViewer/CesiumViewer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
define([
'Cesium/Core/Cartesian3',
'Cesium/Core/CesiumTerrainProvider',
'Cesium/Core/defined',
'Cesium/Core/formatError',
'Cesium/Core/Math',
Expand All @@ -15,6 +16,7 @@ define([
'domReady!'
], function(
Cartesian3,
CesiumTerrainProvider,
defined,
formatError,
CesiumMath,
Expand Down Expand Up @@ -58,6 +60,12 @@ define([
scene3DOnly : endUserOptions.scene3DOnly,
requestRenderMode : true
});

viewer.terrainProvider = new CesiumTerrainProvider({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes the BaseLayerPicker to still think Ellipsoid is selected. To fix that, you need to tell it to use terrain as configured by the picker. Because there's a chance we might not have the baseLayer picker (because of the imagery provider options), we need to handle both cases. Basically this code becomes:

    var baseLayerPicker = viewer.baseLayerPicker;
    if (defined(baseLayerPicker)) {
        var viewModel = baseLayerPicker.viewModel;
        viewModel.selectedTerrain = viewModel.terrainProviderViewModels[1];
    } else {
        viewer.terrainProvider = new CesiumTerrainProvider({
            url: 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles',
            requestWaterMask: true,
            requestVertexNormals: true
        });
    }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an aside, we can probably get rid of the imagery provider option, but for this PR I wouldn't worry about it.

url : 'https://assets.agi.com/stk-terrain/v1/tilesets/world/tiles',
requestWaterMask : true,
requestVertexNormals : true
});
} catch (exception) {
loadingIndicator.style.display = 'none';
var message = formatError(exception);
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Change Log
##### Fixes :wrench:
* Fixed bug where AxisAlignedBoundingBox did not copy over center value when cloning an undefined result. [#6183](https://github.com/AnalyticalGraphicsInc/cesium/pull/6183)

##### Additions :tada:
* Enable terrain in the `CesiumViewer` demo application [#6198](https://github.com/AnalyticalGraphicsInc/cesium/pull/6198)

### 1.42.1 - 2018-02-01
_This is an npm-only release to fix an issue with using Cesium in Node.js.__
* Fixed a bug where Cesium would fail to load under Node.js. [#6177](https://github.com/AnalyticalGraphicsInc/cesium/pull/6177)
Expand Down
3 changes: 2 additions & 1 deletion Source/Widgets/Viewer/viewerDragDropMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ define([
sourceUri : fileName,
proxy : proxy,
camera : scene.camera,
canvas : scene.canvas
canvas : scene.canvas,
clampToGround: clampToGround
});
} else {
viewer.dropError.raiseEvent(viewer, fileName, 'Unrecognized file: ' + fileName);
Expand Down