Skip to content

Commit

Permalink
Merge pull request #8765 from fredj/cameraUnderground_scene
Browse files Browse the repository at this point in the history
Add cameraUnderground property to the Scene
  • Loading branch information
lilleyse committed Apr 17, 2020
2 parents 56f6285 + 6d97829 commit dcd5bfc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

##### Additions :tada:

- Added `Scene.cameraUnderground` for checking whether the camera is underneath the globe. [#8765](https://github.com/CesiumGS/cesium/pull/8765)
- Added `RequestScheduler` to the public API; this allows users to have more control over the requests made by CesiumJS. [#8384](https://github.com/CesiumGS/cesium/issues/8384)

##### Fixes :wrench:
Expand Down
16 changes: 16 additions & 0 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -1435,6 +1435,7 @@ Object.defineProperties(Scene.prototype, {
* Gets the scalar used to exaggerate the terrain.
* @memberof Scene.prototype
* @type {Number}
* @readonly
*/
terrainExaggeration: {
get: function () {
Expand Down Expand Up @@ -1490,6 +1491,7 @@ Object.defineProperties(Scene.prototype, {
* Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction.
* @memberof Scene.prototype
* @type {MapMode2D}
* @readonly
*/
mapMode2D: {
get: function () {
Expand Down Expand Up @@ -1597,6 +1599,7 @@ Object.defineProperties(Scene.prototype, {
* Whether or not high dynamic range rendering is supported.
* @memberof Scene.prototype
* @type {Boolean}
* @readonly
* @default true
*/
highDynamicRangeSupported: {
Expand All @@ -1609,6 +1612,19 @@ Object.defineProperties(Scene.prototype, {
},
},

/**
* Whether or not the camera is underneath the globe.
* @memberof Scene.prototype
* @type {Boolean}
* @readonly
* @default false
*/
cameraUnderground: {
get: function () {
return this._cameraUnderground;
},
},

/**
* Gets or sets the color of the light emitted by the sun.
*
Expand Down
14 changes: 7 additions & 7 deletions Specs/Scene/SceneSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,7 @@ describe(

return updateGlobeUntilDone(scene)
.then(function () {
expect(scene._cameraUnderground).toBe(false);
expect(scene.cameraUnderground).toBe(false);

// Look underground
scene.camera.setView({
Expand All @@ -2053,7 +2053,7 @@ describe(
return updateGlobeUntilDone(scene);
})
.then(function () {
expect(scene._cameraUnderground).toBe(true);
expect(scene.cameraUnderground).toBe(true);
scene.destroyForSpecs();
});
});
Expand All @@ -2069,15 +2069,15 @@ describe(
).and.returnValue(true);

return updateGlobeUntilDone(scene).then(function () {
expect(scene._cameraUnderground).toBe(false);
expect(scene.cameraUnderground).toBe(false);
scene.destroyForSpecs();
});
});

it("detects that camera is above ground if globe is undefined", function () {
var scene = createScene();
scene.renderForSpecs();
expect(scene._cameraUnderground).toBe(false);
expect(scene.cameraUnderground).toBe(false);
scene.destroyForSpecs();
});

Expand All @@ -2086,7 +2086,7 @@ describe(
var globe = new Globe();
scene.globe = globe;
scene.morphTo2D(0.0);
expect(scene._cameraUnderground).toBe(false);
expect(scene.cameraUnderground).toBe(false);
scene.destroyForSpecs();
});

Expand All @@ -2095,7 +2095,7 @@ describe(
var globe = new Globe();
scene.globe = globe;
scene.morphTo2D(1.0);
expect(scene._cameraUnderground).toBe(false);
expect(scene.cameraUnderground).toBe(false);
scene.destroyForSpecs();
});

Expand All @@ -2120,7 +2120,7 @@ describe(
scene.morphToColumbusView(0.0);

return updateGlobeUntilDone(scene).then(function () {
expect(scene._cameraUnderground).toBe(true);
expect(scene.cameraUnderground).toBe(true);
scene.destroyForSpecs();
});
});
Expand Down

0 comments on commit dcd5bfc

Please sign in to comment.