Skip to content

Commit 6575cec

Browse files
authored
Merge pull request #6374 from AnalyticalGraphicsInc/occlusion-fix
Prevent globe from occluding commands when show is false
2 parents 41c7d6b + 8f7f5fb commit 6575cec

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

CHANGES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ Change Log
4242
* Fixed default value of `alphaCutoff` in glTF models. [#6346](https://github.com/AnalyticalGraphicsInc/cesium/pull/6346)
4343
* Fixed rendering vector tiles when using `invertClassification`. [#6349](https://github.com/AnalyticalGraphicsInc/cesium/pull/6349)
4444
* Fixed animation for glTF models with missing animation targets. [#6351](https://github.com/AnalyticalGraphicsInc/cesium/pull/6351)
45+
* Fixed occlusion when `globe.show` is `false`. [#6374](https://github.com/AnalyticalGraphicsInc/cesium/pull/6374)
4546
* Fixed double-sided flag for glTF materials with `BLEND` enabled. [#6371](https://github.com/AnalyticalGraphicsInc/cesium/pull/6371)
4647

47-
4848
### 1.43 - 2018-03-01
4949

5050
##### Major Announcements :loudspeaker:

Source/Scene/Scene.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ define([
14491449
// TODO: The occluder is the top-level globe. When we add
14501450
// support for multiple central bodies, this should be the closest one.
14511451
var globe = scene.globe;
1452-
if (scene._mode === SceneMode.SCENE3D && defined(globe)) {
1452+
if (scene._mode === SceneMode.SCENE3D && defined(globe) && globe.show) {
14531453
var ellipsoid = globe.ellipsoid;
14541454
scratchOccluderBoundingSphere.radius = ellipsoid.minimumRadius;
14551455
scratchOccluder = Occluder.fromBoundingSphere(scratchOccluderBoundingSphere, scene._camera.positionWC, scratchOccluder);

Specs/Scene/SceneSpec.js

+47-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ defineSuite([
99
'Core/Ellipsoid',
1010
'Core/GeographicProjection',
1111
'Core/GeometryInstance',
12+
'Core/HeadingPitchRoll',
1213
'Core/JulianDate',
1314
'Core/Math',
1415
'Core/PerspectiveFrustum',
@@ -53,6 +54,7 @@ defineSuite([
5354
Ellipsoid,
5455
GeographicProjection,
5556
GeometryInstance,
57+
HeadingPitchRoll,
5658
JulianDate,
5759
CesiumMath,
5860
PerspectiveFrustum,
@@ -487,7 +489,7 @@ defineSuite([
487489
scene.globe = globe;
488490
expect(globe.isDestroyed()).toEqual(false);
489491

490-
scene.globe = null;
492+
scene.globe = undefined;
491493
expect(globe.isDestroyed()).toEqual(true);
492494

493495
scene.destroyForSpecs();
@@ -1643,4 +1645,48 @@ defineSuite([
16431645

16441646
scene.destroyForSpecs();
16451647
});
1648+
1649+
function getFrustumCommandsLength(scene) {
1650+
var commandsLength = 0;
1651+
var frustumCommandsList = scene._frustumCommandsList;
1652+
var frustumsLength = frustumCommandsList.length;
1653+
for (var i = 0; i < frustumsLength; ++i) {
1654+
var frustumCommands = frustumCommandsList[i];
1655+
for (var j = 0; j < Pass.NUMBER_OF_PASSES; ++j) {
1656+
commandsLength += frustumCommands.indices[j];
1657+
}
1658+
}
1659+
return commandsLength;
1660+
}
1661+
1662+
it('occludes primitive', function() {
1663+
var scene = createScene();
1664+
scene.globe = new Globe(Ellipsoid.WGS84);
1665+
1666+
var rectangle = Rectangle.fromDegrees(-100.0, 30.0, -90.0, 40.0);
1667+
var rectanglePrimitive = createRectangle(rectangle, 10);
1668+
scene.primitives.add(rectanglePrimitive);
1669+
1670+
scene.camera.setView({
1671+
destination: new Cartesian3(-588536.1057451078, -10512475.371849751, 6737159.100747835),
1672+
orientation: new HeadingPitchRoll(6.283185307179586, -1.5688261558859757, 0.0)
1673+
});
1674+
scene.renderForSpecs();
1675+
expect(getFrustumCommandsLength(scene)).toBe(1);
1676+
1677+
scene.camera.setView({
1678+
destination: new Cartesian3(-5754647.167415793, 14907694.100240812, -483807.2406259497),
1679+
orientation: new HeadingPitchRoll(6.283185307179586, -1.5698869547885104, 0.0)
1680+
});
1681+
scene.renderForSpecs();
1682+
expect(getFrustumCommandsLength(scene)).toBe(0);
1683+
1684+
// Still on opposite side of globe but now show is false, the command should not be occluded anymore
1685+
scene.globe.show = false;
1686+
scene.renderForSpecs();
1687+
expect(getFrustumCommandsLength(scene)).toBe(1);
1688+
1689+
scene.destroyForSpecs();
1690+
});
1691+
16461692
}, 'WebGL');

0 commit comments

Comments
 (0)