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

Prevent globe from occluding commands when show is false #6374

Merged
merged 3 commits into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ Change Log
* Fixed default value of `alphaCutoff` in glTF models. [#6346](https://github.com/AnalyticalGraphicsInc/cesium/pull/6346)
* Fixed rendering vector tiles when using `invertClassification`. [#6349](https://github.com/AnalyticalGraphicsInc/cesium/pull/6349)
* Fixed animation for glTF models with missing animation targets. [#6351](https://github.com/AnalyticalGraphicsInc/cesium/pull/6351)
* Fixed occlusion when `globe.show` is `false`. [#6374](https://github.com/AnalyticalGraphicsInc/cesium/pull/6374)
* Fixed double-sided flag for glTF materials with `BLEND` enabled. [#6371](https://github.com/AnalyticalGraphicsInc/cesium/pull/6371)


### 1.43 - 2018-03-01

##### Major Announcements :loudspeaker:
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,7 @@ define([
// TODO: The occluder is the top-level globe. When we add
// support for multiple central bodies, this should be the closest one.
var globe = scene.globe;
if (scene._mode === SceneMode.SCENE3D && defined(globe)) {
if (scene._mode === SceneMode.SCENE3D && defined(globe) && globe.show) {
var ellipsoid = globe.ellipsoid;
scratchOccluderBoundingSphere.radius = ellipsoid.minimumRadius;
scratchOccluder = Occluder.fromBoundingSphere(scratchOccluderBoundingSphere, scene._camera.positionWC, scratchOccluder);
Expand Down
48 changes: 47 additions & 1 deletion Specs/Scene/SceneSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ defineSuite([
'Core/Ellipsoid',
'Core/GeographicProjection',
'Core/GeometryInstance',
'Core/HeadingPitchRoll',
'Core/JulianDate',
'Core/Math',
'Core/PerspectiveFrustum',
Expand Down Expand Up @@ -53,6 +54,7 @@ defineSuite([
Ellipsoid,
GeographicProjection,
GeometryInstance,
HeadingPitchRoll,
JulianDate,
CesiumMath,
PerspectiveFrustum,
Expand Down Expand Up @@ -487,7 +489,7 @@ defineSuite([
scene.globe = globe;
expect(globe.isDestroyed()).toEqual(false);

scene.globe = null;
scene.globe = undefined;
expect(globe.isDestroyed()).toEqual(true);

scene.destroyForSpecs();
Expand Down Expand Up @@ -1643,4 +1645,48 @@ defineSuite([

scene.destroyForSpecs();
});

function getFrustumCommandsLength(scene) {
var commandsLength = 0;
var frustumCommandsList = scene._frustumCommandsList;
var frustumsLength = frustumCommandsList.length;
for (var i = 0; i < frustumsLength; ++i) {
var frustumCommands = frustumCommandsList[i];
for (var j = 0; j < Pass.NUMBER_OF_PASSES; ++j) {
commandsLength += frustumCommands.indices[j];
}
}
return commandsLength;
}

it('occludes primitive', function() {
var scene = createScene();
scene.globe = new Globe(Ellipsoid.WGS84);

var rectangle = Rectangle.fromDegrees(-100.0, 30.0, -90.0, 40.0);
var rectanglePrimitive = createRectangle(rectangle, 10);
scene.primitives.add(rectanglePrimitive);

scene.camera.setView({
destination: new Cartesian3(-588536.1057451078, -10512475.371849751, 6737159.100747835),
orientation: new HeadingPitchRoll(6.283185307179586, -1.5688261558859757, 0.0)
});
scene.renderForSpecs();
expect(getFrustumCommandsLength(scene)).toBe(1);

scene.camera.setView({
destination: new Cartesian3(-5754647.167415793, 14907694.100240812, -483807.2406259497),
orientation: new HeadingPitchRoll(6.283185307179586, -1.5698869547885104, 0.0)
});
scene.renderForSpecs();
expect(getFrustumCommandsLength(scene)).toBe(0);

// Still on opposite side of globe but now show is false, the command should not be occluded anymore
scene.globe.show = false;
scene.renderForSpecs();
expect(getFrustumCommandsLength(scene)).toBe(1);

scene.destroyForSpecs();
});

}, 'WebGL');