Skip to content

Commit

Permalink
Merge pull request #7437 from AnalyticalGraphicsInc/polylines-on-3d-t…
Browse files Browse the repository at this point in the history
…iles

Polylines on 3D Tiles
  • Loading branch information
bagnell committed Jan 2, 2019
2 parents c1000bf + 3729e70 commit 29e9146
Show file tree
Hide file tree
Showing 20 changed files with 497 additions and 482 deletions.
28 changes: 28 additions & 0 deletions Apps/SampleData/ClampToGround.czml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,33 @@
0.7686388857813198
]
}
},
{
"id": "Polyline",
"polyline": {
"positions": {
"cartesian": [
1216348.1632364073,
-4736348.958775471,
4081284.5528982095,
1216369.1229444197,
-4736377.467107148,
4081240.888485707
]
},
"material": {
"polylineOutline": {
"color": {
"rgba": [255, 255, 0, 255]
},
"outlineColor": {
"rgba": [0, 0, 0, 255]
},
"outlineWidth": 2
}
},
"width": 10,
"clampToGround": true
}
}
]
Binary file modified Apps/Sandcastle/gallery/Clamp to 3D Tiles.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 34 additions & 6 deletions Apps/Sandcastle/gallery/Classification Types.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,40 +40,68 @@
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
});

var entity = viewer.entities.add({
var polygon = viewer.entities.add({
polygon : {
hierarchy : new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromRadiansArray([-1.3194369277314022, 0.6988062530900625, -1.3193955980204217, 0.6988091578771254, -1.3193931220959367, 0.698743632490865, -1.3194358224045408, 0.6987471965556998])),
material : Cesium.Color.RED.withAlpha(0.5),
classificationType : Cesium.ClassificationType.BOTH
}
});

var polyline = viewer.entities.add({
polyline : {
positions : Cesium.Cartesian3.fromDegreesArray([
-75.60217330403601, 40.04102882709425,
-75.59968252414251, 40.04093615560871,
-75.59802015382800, 40.04079437042357,
-75.59674934074435, 40.040816173283304,
-75.59630042791713, 40.03986900370842,
-75.59563636849978, 40.03930996506271,
-75.59492397899098, 40.03873932846581,
-75.59457991226778, 40.038392701955786,
-75.59424838652453, 40.03775403572295,
-75.59387104290336, 40.03677022167725,
-75.59355000490342, 40.03588760913535
]),
width : 8,
material : new Cesium.PolylineOutlineMaterialProperty({
color : Cesium.Color.YELLOW,
outlineWidth : 2,
outlineColor : Cesium.Color.BLACK
}),
clampToGround : true
}
});

var classificationOptions = [{
text : 'Classify Both',
onselect : function() {
entity.polygon.classificationType = Cesium.ClassificationType.BOTH;
polygon.polygon.classificationType = Cesium.ClassificationType.BOTH;
polyline.polyline.classificationType = Cesium.ClassificationType.BOTH;
}
}, {
text : 'Classify Terrain',
onselect : function() {
entity.polygon.classificationType = Cesium.ClassificationType.TERRAIN;
polygon.polygon.classificationType = Cesium.ClassificationType.TERRAIN;
polyline.polyline.classificationType = Cesium.ClassificationType.TERRAIN;
}
}, {
text : 'Classify 3D Tiles',
onselect : function() {
entity.polygon.classificationType = Cesium.ClassificationType.CESIUM_3D_TILE;
polygon.polygon.classificationType = Cesium.ClassificationType.CESIUM_3D_TILE;
polyline.polyline.classificationType = Cesium.ClassificationType.CESIUM_3D_TILE;
}
}];

var materialOptions = [{
text : 'Red Material',
onselect : function() {
entity.polygon.material = Cesium.Color.RED.withAlpha(0.5);
polygon.polygon.material = Cesium.Color.RED.withAlpha(0.5);
}
}, {
text : 'Textured Material',
onselect : function() {
entity.polygon.material = '../images/Cesium_Logo_Color.jpg';
polygon.polygon.material = '../images/Cesium_Logo_Color.jpg';
}
}];

Expand Down
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Change Log
##### Additions :tada:

* Added support for textured ground entities (entities with unspecified `height`) and `GroundPrimitives` on 3D Tiles.
* Added support for polylines on 3D Tiles.
* Added `classificationType` property to `PolylineGraphics` and `GroundPolylinePrimitive` which specifies whether a polyline clamped to ground should be clamped to terrain, 3D Tiles, or both.

##### Fixes :wrench:
* Fixed an issue where classification primitives with the `CESIUM_3D_TILE` classification type would render on terrain.
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/GroundPolylineGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ define([
var WALL_INITIAL_MAX_HEIGHT = 1000.0;

/**
* A description of a polyline on terrain. Only to be used with {@link GroundPolylinePrimitive}.
* A description of a polyline on terrain or 3D Tiles. Only to be used with {@link GroundPolylinePrimitive}.
*
* @alias GroundPolylineGeometry
* @constructor
Expand Down Expand Up @@ -159,7 +159,7 @@ define([
* Set the GroundPolylineGeometry's projection and ellipsoid.
* Used by GroundPolylinePrimitive to signal scene information to the geometry for generating 2D attributes.
*
* @param {GroundPolylineGeometry} groundPolylineGeometry GroundPolylinGeometry describing a polyline on terrain.
* @param {GroundPolylineGeometry} groundPolylineGeometry GroundPolylinGeometry describing a polyline on terrain or 3D Tiles.
* @param {Projection} mapProjection A MapProjection used for projecting cartographic coordinates to 2D.
* @private
*/
Expand Down Expand Up @@ -386,7 +386,7 @@ define([
var intersectionScratch = new Cartesian3();
/**
* Computes shadow volumes for the ground polyline, consisting of its vertices, indices, and a bounding sphere.
* Vertices are "fat," packing all the data needed in each volume to describe a line on terrain.
* Vertices are "fat," packing all the data needed in each volume to describe a line on terrain or 3D Tiles.
* Should not be called independent of {@link GroundPolylinePrimitive}.
*
* @param {GroundPolylineGeometry} groundPolylineGeometry
Expand Down
3 changes: 2 additions & 1 deletion Source/DataSources/CorridorGraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,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 {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this corridor will classify terrain, 3D Tiles, or both when on the ground.
* @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
Expand Down Expand Up @@ -232,7 +233,7 @@ define([
* Gets or sets the {@link ClassificationType} Property specifying whether this corridor will classify terrain, 3D Tiles, or both when on the ground.
* @memberof CorridorGraphics.prototype
* @type {Property}
* @default ClassificationType.TERRAIN
* @default ClassificationType.BOTH
*/
classificationType : createPropertyDescriptor('classificationType'),

Expand Down
3 changes: 2 additions & 1 deletion Source/DataSources/EllipseGraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,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 {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this ellipse will classify terrain, 3D Tiles, or both when on the ground.
* @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 @@ -254,7 +255,7 @@ define([
* Gets or sets the {@link ClassificationType} Property specifying whether this ellipse will classify terrain, 3D Tiles, or both when on the ground.
* @memberof EllipseGraphics.prototype
* @type {Property}
* @default ClassificationType.TERRAIN
* @default ClassificationType.BOTH
*/
classificationType : createPropertyDescriptor('classificationType'),

Expand Down
4 changes: 2 additions & 2 deletions Source/DataSources/Entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,12 +676,12 @@ define([
};

/**
* Checks if the given Scene supports polylines clamped to the ground..
* Checks if the given Scene supports polylines clamped to terrain or 3D Tiles.
* If this feature is not supported, Entities with PolylineGraphics will be rendered with vertices at
* the provided heights and using the `followSurface` parameter instead of clamped to the ground.
*
* @param {Scene} scene The current scene.
* @returns {Boolean} Whether or not the current scene supports Polylines on Terrain.
* @returns {Boolean} Whether or not the current scene supports polylines on terrain or 3D TIles.
*/
Entity.supportsPolylinesOnTerrain = function(scene) {
return GroundPolylinePrimitive.isSupported(scene);
Expand Down
3 changes: 2 additions & 1 deletion Source/DataSources/PolygonGraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ define([
* @param {Boolean} [options.closeBottom=true] When false, leaves off the bottom of an extruded polygon open.
* @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the polygon casts or receives shadows from each light source.
* @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this polygon will be displayed.
* @param {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this polygon will classify terrain, 3D Tiles, or both when on the ground.
* @param {ConstantProperty} [options.zIndex=0] A property specifying the zIndex used for ordering ground geometry. Only has an effect if the polygon is constant and neither height or extrudedHeight are specified.
*
* @see Entity
Expand Down Expand Up @@ -255,7 +256,7 @@ define([
* Gets or sets the {@link ClassificationType} Property specifying whether this polygon will classify terrain, 3D Tiles, or both when on the ground.
* @memberof PolygonGraphics.prototype
* @type {Property}
* @default ClassificationType.TERRAIN
* @default ClassificationType.BOTH
*/
classificationType : createPropertyDescriptor('classificationType'),

Expand Down
20 changes: 19 additions & 1 deletion Source/DataSources/PolylineGeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ define([
'../Core/PolylinePipeline',
'../Core/ShowGeometryInstanceAttribute',
'../DataSources/Entity',
'../Scene/ClassificationType',
'../Scene/GroundPolylinePrimitive',
'../Scene/PolylineCollection',
'../Scene/PolylineColorAppearance',
Expand Down Expand Up @@ -48,6 +49,7 @@ define([
PolylinePipeline,
ShowGeometryInstanceAttribute,
Entity,
ClassificationType,
GroundPolylinePrimitive,
PolylineCollection,
PolylineColorAppearance,
Expand All @@ -70,6 +72,7 @@ define([
var defaultShow = new ConstantProperty(true);
var defaultShadows = new ConstantProperty(ShadowMode.DISABLED);
var defaultDistanceDisplayCondition = new ConstantProperty(new DistanceDisplayCondition());
var defaultClassificationType = new ConstantProperty(ClassificationType.BOTH);

function GeometryOptions() {
this.vertexFormat = undefined;
Expand Down Expand Up @@ -113,6 +116,7 @@ define([
this._materialProperty = undefined;
this._shadowsProperty = undefined;
this._distanceDisplayConditionProperty = undefined;
this._classificationTypeProperty = undefined;
this._depthFailMaterialProperty = undefined;
this._geometryOptions = new GeometryOptions();
this._groundGeometryOptions = new GroundGeometryOptions();
Expand Down Expand Up @@ -252,6 +256,18 @@ define([
return this._distanceDisplayConditionProperty;
}
},
/**
* Gets or sets the {@link ClassificationType} Property specifying if this geometry will classify terrain, 3D Tiles, or both when on the ground.
* @memberof PolylineGeometryUpdater.prototype
*
* @type {Property}
* @readonly
*/
classificationTypeProperty : {
get : function() {
return this._classificationTypeProperty;
}
},
/**
* Gets a value indicating if the geometry is time-varying.
* If true, all visualization is delegated to the {@link DynamicGeometryUpdater}
Expand Down Expand Up @@ -473,6 +489,7 @@ define([
this._showProperty = defaultValue(show, defaultShow);
this._shadowsProperty = defaultValue(polyline.shadows, defaultShadows);
this._distanceDisplayConditionProperty = defaultValue(polyline.distanceDisplayCondition, defaultDistanceDisplayCondition);
this._classificationTypeProperty = defaultValue(polyline.classificationType, defaultClassificationType);
this._fillEnabled = true;
this._zIndex = defaultValue(zIndex, defaultZIndex);

Expand All @@ -493,7 +510,7 @@ define([
var positions = positionsProperty.getValue(Iso8601.MINIMUM_VALUE, geometryOptions.positions);

//Because of the way we currently handle reference properties,
//we can't automatically assume the positions are always valid.
//we can't automatically assume the positions are always valid.
if (!defined(positions) || positions.length < 2) {
if (this._fillEnabled) {
this._fillEnabled = false;
Expand Down Expand Up @@ -635,6 +652,7 @@ define([
this._groundPolylinePrimitive = groundPrimitives.add(new GroundPolylinePrimitive({
geometryInstances : geometryUpdater.createFillGeometryInstance(time),
appearance : appearance,
classificationType : geometryUpdater.classificationTypeProperty.getValue(time),
asynchronous : false
}), Property.getValueOrUndefined(geometryUpdater.zIndex, time));

Expand Down
15 changes: 14 additions & 1 deletion Source/DataSources/PolylineGraphics.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ define([
* @param {Property} [options.width=1.0] A numeric Property specifying the width in pixels.
* @param {Property} [options.show=true] A boolean Property specifying the visibility of the polyline.
* @param {MaterialProperty} [options.material=Color.WHITE] A Property specifying the material used to draw the polyline.
* @param {MaterialProperty} [options.depthFailMaterial] A property specifiying the material used to draw the polyline when it is below the terrain.
* @param {MaterialProperty} [options.depthFailMaterial] A property specifying the material used to draw the polyline when it is below the terrain.
* @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the angular distance between each latitude and longitude if followSurface is true.
* @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the polyline casts or receives shadows from each light source.
* @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this polyline will be displayed.
* @param {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this polyline will classify terrain, 3D Tiles, or both when on the ground.
* @param {Property} [options.zIndex=0] A Property specifying the zIndex used for ordering ground geometry. Only has an effect if `clampToGround` is true and polylines on terrain is supported.
*
* @see Entity
Expand Down Expand Up @@ -62,6 +63,8 @@ define([
this._shadowsSubscription = undefined;
this._distanceDisplayCondition = undefined;
this._distanceDisplayConditionSubscription = undefined;
this._classificationType = undefined;
this._classificationTypeSubscription = undefined;
this._zIndex = undefined;
this._zIndexSubscription = undefined;

Expand Down Expand Up @@ -170,6 +173,14 @@ define([
*/
distanceDisplayCondition : createPropertyDescriptor('distanceDisplayCondition'),

/**
* Gets or sets the {@link ClassificationType} Property specifying whether this polyline will classify terrain, 3D Tiles, or both when on the ground.
* @memberof PolylineGraphics.prototype
* @type {Property}
* @default ClassificationType.BOTH
*/
classificationType : createPropertyDescriptor('classificationType'),

/**
* Gets or sets the zIndex Property specifying the ordering of the polyline. Only has an effect if `clampToGround` is true and polylines on terrain is supported.
* @memberof RectangleGraphics.prototype
Expand Down Expand Up @@ -199,6 +210,7 @@ define([
result.granularity = this.granularity;
result.shadows = this.shadows;
result.distanceDisplayCondition = this.distanceDisplayCondition;
result.classificationType = this.classificationType;
result.zIndex = this.zIndex;

return result;
Expand Down Expand Up @@ -227,6 +239,7 @@ define([
this.granularity = defaultValue(this.granularity, source.granularity);
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);
};

Expand Down
Loading

0 comments on commit 29e9146

Please sign in to comment.