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

Z-ordering for ground geometry entities #6362

Merged
merged 17 commits into from
May 22, 2018
93 changes: 93 additions & 0 deletions Apps/Sandcastle/gallery/Ordering Geometry.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<!DOCTYPE html>
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rename this to Z-Indexing Geometry, to both be consistent with our internal terminology and because Z-Indexing is the standard term.

<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="description" content="Draw a rectangle or extruded rectangle that conforms to the surface of the globe.">
<meta name="cesium-sandcastle-labels" content="Geometries">
<title>Cesium Demo</title>
<script type="text/javascript" src="../Sandcastle-header.js"></script>
<script type="text/javascript" src="../../../ThirdParty/requirejs-2.1.20/require.js"></script>
<script type="text/javascript">
if(typeof require === "function") {
require.config({
baseUrl : '../../../Source',
waitSeconds : 120
});
}
</script>
</head>
<body class="sandcastle-loading" data-sandcastle-bucket="bucket-requirejs.html">
<style>
@import url(../templates/bucket.css);
</style>
<div id="cesiumContainer" class="fullSize"></div>
<div id="loadingOverlay"><h1>Loading...</h1></div>
<div id="toolbar"></div>
<script id="cesium_sandcastle_script">
function startup(Cesium) {
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer');

viewer.entities.add({
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(-110.0, 20.0, -100.5, 30.0),
material : Cesium.Color.RED,
zIndex: 1
}
});

viewer.entities.add({
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(-112.0, 25.0, -102.5, 35.0),
material : Cesium.Color.GREEN,
zIndex: 2
}
});

viewer.entities.add({
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(-110.0, 31.0, -100.5, 41.0),
material : Cesium.Color.BLUE,
zIndex: 3
}
});

viewer.entities.add({
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(-99.5, 20.0, -90.0, 30.0),
material : Cesium.Color.RED,
zIndex: 3
}
});

viewer.entities.add({
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(-97.5, 25.0, -88.0, 35.0),
material : Cesium.Color.GREEN,
zIndex: 2
}
});

viewer.entities.add({
rectangle : {
coordinates : Cesium.Rectangle.fromDegrees(-99.5, 31.0, -90.0, 41.0),
material : Cesium.Color.BLUE,
zIndex: 1
}
});

viewer.zoomTo(viewer.entities);
//Sandcastle_End
Sandcastle.finishedLoading();
}
if (typeof Cesium !== "undefined") {
startup(Cesium);
} else if (typeof require === "function") {
require(["Cesium"], startup);
}
</script>
</body>
</html>
2 changes: 2 additions & 0 deletions Source/Core/oneTimeWarning.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ define([

oneTimeWarning.geometryOutlines = 'Entity geometry outlines are unsupported on terrain. Outlines will be disabled. To enable outlines, disable geometry terrain clamping by explicitly setting height to 0.';

oneTimeWarning.geometryZIndex = 'Entity geometry with zIndex are unsupported when the entity is dynamic, or height or extrudedHeight are defined. zIndex will be ignored';
Copy link
Contributor

Choose a reason for hiding this comment

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

Are dynamic entities still not supported? This message appears to only be used in one place and doesn't check anything about dynamic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah no, I fixed that. I'll update the message


return oneTimeWarning;
});
2 changes: 2 additions & 0 deletions Source/DataSources/BoxGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ define([
geometryPropertyName : 'box',
observedPropertyNames : ['availability', 'position', 'orientation', 'box']
});

this._onEntityPropertyChanged(entity, 'box', entity.box, undefined);
}

if (defined(Object.create)) {
Expand Down
8 changes: 6 additions & 2 deletions Source/DataSources/CorridorGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ define([
'./ColorMaterialProperty',
'./DynamicGeometryUpdater',
'./GeometryUpdater',
'./GroundGeometryUpdater',
'./Property'
], function(
Check,
Expand All @@ -35,6 +36,7 @@ define([
ColorMaterialProperty,
DynamicGeometryUpdater,
GeometryUpdater,
GroundGeometryUpdater,
Property) {
'use strict';

Expand All @@ -61,17 +63,19 @@ define([
* @param {Scene} scene The scene where visualization is taking place.
*/
function CorridorGeometryUpdater(entity, scene) {
GeometryUpdater.call(this, {
GroundGeometryUpdater.call(this, {
entity : entity,
scene : scene,
geometryOptions : new CorridorGeometryOptions(entity),
geometryPropertyName : 'corridor',
observedPropertyNames : ['availability', 'corridor']
});

this._onEntityPropertyChanged(entity, 'corridor', entity.corridor, undefined);
}

if (defined(Object.create)) {
CorridorGeometryUpdater.prototype = Object.create(GeometryUpdater.prototype);
CorridorGeometryUpdater.prototype = Object.create(GroundGeometryUpdater.prototype);
CorridorGeometryUpdater.prototype.constructor = CorridorGeometryUpdater;
}

Expand Down
15 changes: 14 additions & 1 deletion Source/DataSources/CorridorGraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ define([
* @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the distance between each latitude and longitude.
* @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the corridor casts or receives shadows from each light source.
* @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this corridor will be displayed.
* @param {ConstantProperty} [options.zIndex] A Property specifying the zIndex of the corridor, used for ordering. Only has an effect if height and extrudedHeight are undefined, and if the corridor is static.
*
* @see Entity
* @demo {@link https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Corridor.html|Cesium Sandcastle Corridor Demo}
Expand Down Expand Up @@ -74,6 +75,8 @@ define([
this._distanceDisplayConditionSubscription = undefined;
this._classificationType = undefined;
this._classificationTypeSubscription = undefined;
this._zIndex = undefined;
this._zIndexSubscription = undefined;
this._definitionChanged = new Event();

this.merge(defaultValue(options, defaultValue.EMPTY_OBJECT));
Expand Down Expand Up @@ -209,7 +212,15 @@ define([
* @type {Property}
* @default ClassificationType.BOTH
*/
classificationType : createPropertyDescriptor('classificationType')
classificationType : createPropertyDescriptor('classificationType'),

/**
* Gets or sets the zIndex Property specifying the ordering of the corridor. Only has an effect if the coridor is static and neither height or exturdedHeight are specified.
* @memberof CorridorGraphics.prototype
* @type {ConstantProperty}
* @default 0
Copy link
Contributor

Choose a reason for hiding this comment

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

All of the defaults say 0, but there's not actually a default is there? It's just undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

undefined === 0 for zIndex. I defaultValue(zIndex, 0) in the geometry updaters

*/
zIndex: createPropertyDescriptor('zIndex')
});

/**
Expand Down Expand Up @@ -237,6 +248,7 @@ define([
result.shadows = this.shadows;
result.distanceDisplayCondition = this.distanceDisplayCondition;
result.classificationType = this.classificationType;
result.zIndex = this.zIndex;
return result;
};

Expand Down Expand Up @@ -268,6 +280,7 @@ define([
this.shadows = defaultValue(this.shadows, source.shadows);
this.distanceDisplayCondition = defaultValue(this.distanceDisplayCondition, source.distanceDisplayCondition);
this.classificationType = defaultValue(this.classificationType, source.classificationType);
this.zIndex = defaultValue(this.zIndex, source.zIndex);
};

return CorridorGraphics;
Expand Down
2 changes: 2 additions & 0 deletions Source/DataSources/CylinderGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ define([
geometryPropertyName: 'cylinder',
observedPropertyNames: ['availability', 'position', 'orientation', 'cylinder']
});

this._onEntityPropertyChanged(entity, 'cylinder', entity.cylinder, undefined);
}

if (defined(Object.create)) {
Expand Down
8 changes: 6 additions & 2 deletions Source/DataSources/EllipseGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ define([
'./ColorMaterialProperty',
'./DynamicGeometryUpdater',
'./GeometryUpdater',
'./GroundGeometryUpdater',
'./Property'
], function(
Check,
Expand All @@ -35,6 +36,7 @@ define([
ColorMaterialProperty,
DynamicGeometryUpdater,
GeometryUpdater,
GroundGeometryUpdater,
Property) {
'use strict';

Expand Down Expand Up @@ -64,17 +66,19 @@ define([
* @param {Scene} scene The scene where visualization is taking place.
*/
function EllipseGeometryUpdater(entity, scene) {
GeometryUpdater.call(this, {
GroundGeometryUpdater.call(this, {
entity : entity,
scene : scene,
geometryOptions : new EllipseGeometryOptions(entity),
geometryPropertyName : 'ellipse',
observedPropertyNames : ['availability', 'position', 'ellipse']
});

this._onEntityPropertyChanged(entity, 'ellipse', entity.ellipse, undefined);
}

if (defined(Object.create)) {
EllipseGeometryUpdater.prototype = Object.create(GeometryUpdater.prototype);
EllipseGeometryUpdater.prototype = Object.create(GroundGeometryUpdater.prototype);
EllipseGeometryUpdater.prototype.constructor = EllipseGeometryUpdater;
}

Expand Down
15 changes: 14 additions & 1 deletion Source/DataSources/EllipseGraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ define([
* @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the angular distance between points on the ellipse.
* @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the ellipse casts or receives shadows from each light source.
* @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this ellipse will be displayed.
* @param {ConstantProperty} [options.zIndex=0] A property specifying the zIndex of the Ellipse. Used for ordering ground geometry. Only has an effect if the ellipse is constant and neither height or exturdedHeight are specified.
*
* @demo {@link https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Circles and Ellipses.html|Cesium Sandcastle Circles and Ellipses Demo}
*/
Expand Down Expand Up @@ -80,6 +81,8 @@ define([
this._distanceDisplayConditionSubscription = undefined;
this._classificationType = undefined;
this._classificationTypeSubscription = undefined;
this._zIndex = undefined;
this._zIndexSubscription = undefined;
this._definitionChanged = new Event();

this.merge(defaultValue(options, defaultValue.EMPTY_OBJECT));
Expand Down Expand Up @@ -231,7 +234,15 @@ define([
* @type {Property}
* @default ClassificationType.BOTH
*/
classificationType : createPropertyDescriptor('classificationType')
classificationType : createPropertyDescriptor('classificationType'),

/**
* Gets or sets the zIndex Property specifying the ellipse ordering. Only has an effect if the ellipse is constant and neither height or extrudedHeight are specified
* @memberof EllipseGraphics.prototype
* @type {ConstantProperty}
* @default 0
*/
zIndex : createPropertyDescriptor('zIndex')
});

/**
Expand Down Expand Up @@ -261,6 +272,7 @@ define([
result.shadows = this.shadows;
result.distanceDisplayCondition = this.distanceDisplayCondition;
result.classificationType = this.classificationType;
result.zIndex = this.zIndex;
return result;
};

Expand Down Expand Up @@ -294,6 +306,7 @@ define([
this.shadows = defaultValue(this.shadows, source.shadows);
this.distanceDisplayCondition = defaultValue(this.distanceDisplayCondition, source.distanceDisplayCondition);
this.classificationType = defaultValue(this.classificationType, source.classificationType);
this.zIndex = defaultValue(this.zIndex, source.zIndex);
};

return EllipseGraphics;
Expand Down
2 changes: 1 addition & 1 deletion Source/DataSources/EllipsoidGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ define([
observedPropertyNames : ['availability', 'position', 'orientation', 'ellipsoid']
});

this._isClosed = true;
this._onEntityPropertyChanged(entity, 'ellipsoid', entity.ellipsoid, undefined);
}

if (defined(Object.create)) {
Expand Down
5 changes: 1 addition & 4 deletions Source/DataSources/GeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ define([
var defaultClassificationType = new ConstantProperty(ClassificationType.BOTH);

/**
* A {@link GeometryUpdater} for boxes.
* Clients do not normally create this class directly, but instead rely on {@link DataSourceDisplay}.
* An abstract class for updating geometry entites.
* @alias GeometryUpdater
* @constructor
*
Expand Down Expand Up @@ -88,8 +87,6 @@ define([
this._geometryPropertyName = geometryPropertyName;
this._id = geometryPropertyName + '-' + entity.id;
this._observedPropertyNames = options.observedPropertyNames;

this._onEntityPropertyChanged(entity, geometryPropertyName, entity[geometryPropertyName], undefined);
}

defineProperties(GeometryUpdater.prototype, {
Expand Down
Loading