Skip to content

Commit 29e9146

Browse files
authored
Merge pull request #7437 from AnalyticalGraphicsInc/polylines-on-3d-tiles
Polylines on 3D Tiles
2 parents c1000bf + 3729e70 commit 29e9146

20 files changed

+497
-482
lines changed

Apps/SampleData/ClampToGround.czml

+28
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,33 @@
3737
0.7686388857813198
3838
]
3939
}
40+
},
41+
{
42+
"id": "Polyline",
43+
"polyline": {
44+
"positions": {
45+
"cartesian": [
46+
1216348.1632364073,
47+
-4736348.958775471,
48+
4081284.5528982095,
49+
1216369.1229444197,
50+
-4736377.467107148,
51+
4081240.888485707
52+
]
53+
},
54+
"material": {
55+
"polylineOutline": {
56+
"color": {
57+
"rgba": [255, 255, 0, 255]
58+
},
59+
"outlineColor": {
60+
"rgba": [0, 0, 0, 255]
61+
},
62+
"outlineWidth": 2
63+
}
64+
},
65+
"width": 10,
66+
"clampToGround": true
67+
}
4068
}
4169
]
798 Bytes
Loading

Apps/Sandcastle/gallery/Classification Types.html

+34-6
Original file line numberDiff line numberDiff line change
@@ -40,40 +40,68 @@
4040
viewer.camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
4141
});
4242

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

51+
var polyline = viewer.entities.add({
52+
polyline : {
53+
positions : Cesium.Cartesian3.fromDegreesArray([
54+
-75.60217330403601, 40.04102882709425,
55+
-75.59968252414251, 40.04093615560871,
56+
-75.59802015382800, 40.04079437042357,
57+
-75.59674934074435, 40.040816173283304,
58+
-75.59630042791713, 40.03986900370842,
59+
-75.59563636849978, 40.03930996506271,
60+
-75.59492397899098, 40.03873932846581,
61+
-75.59457991226778, 40.038392701955786,
62+
-75.59424838652453, 40.03775403572295,
63+
-75.59387104290336, 40.03677022167725,
64+
-75.59355000490342, 40.03588760913535
65+
]),
66+
width : 8,
67+
material : new Cesium.PolylineOutlineMaterialProperty({
68+
color : Cesium.Color.YELLOW,
69+
outlineWidth : 2,
70+
outlineColor : Cesium.Color.BLACK
71+
}),
72+
clampToGround : true
73+
}
74+
});
75+
5176
var classificationOptions = [{
5277
text : 'Classify Both',
5378
onselect : function() {
54-
entity.polygon.classificationType = Cesium.ClassificationType.BOTH;
79+
polygon.polygon.classificationType = Cesium.ClassificationType.BOTH;
80+
polyline.polyline.classificationType = Cesium.ClassificationType.BOTH;
5581
}
5682
}, {
5783
text : 'Classify Terrain',
5884
onselect : function() {
59-
entity.polygon.classificationType = Cesium.ClassificationType.TERRAIN;
85+
polygon.polygon.classificationType = Cesium.ClassificationType.TERRAIN;
86+
polyline.polyline.classificationType = Cesium.ClassificationType.TERRAIN;
6087
}
6188
}, {
6289
text : 'Classify 3D Tiles',
6390
onselect : function() {
64-
entity.polygon.classificationType = Cesium.ClassificationType.CESIUM_3D_TILE;
91+
polygon.polygon.classificationType = Cesium.ClassificationType.CESIUM_3D_TILE;
92+
polyline.polyline.classificationType = Cesium.ClassificationType.CESIUM_3D_TILE;
6593
}
6694
}];
6795

6896
var materialOptions = [{
6997
text : 'Red Material',
7098
onselect : function() {
71-
entity.polygon.material = Cesium.Color.RED.withAlpha(0.5);
99+
polygon.polygon.material = Cesium.Color.RED.withAlpha(0.5);
72100
}
73101
}, {
74102
text : 'Textured Material',
75103
onselect : function() {
76-
entity.polygon.material = '../images/Cesium_Logo_Color.jpg';
104+
polygon.polygon.material = '../images/Cesium_Logo_Color.jpg';
77105
}
78106
}];
79107

CHANGES.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Change Log
1010
##### Additions :tada:
1111

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

1416
##### Fixes :wrench:
1517
* Fixed an issue where classification primitives with the `CESIUM_3D_TILE` classification type would render on terrain.

Source/Core/GroundPolylineGeometry.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ define([
7070
var WALL_INITIAL_MAX_HEIGHT = 1000.0;
7171

7272
/**
73-
* A description of a polyline on terrain. Only to be used with {@link GroundPolylinePrimitive}.
73+
* A description of a polyline on terrain or 3D Tiles. Only to be used with {@link GroundPolylinePrimitive}.
7474
*
7575
* @alias GroundPolylineGeometry
7676
* @constructor
@@ -159,7 +159,7 @@ define([
159159
* Set the GroundPolylineGeometry's projection and ellipsoid.
160160
* Used by GroundPolylinePrimitive to signal scene information to the geometry for generating 2D attributes.
161161
*
162-
* @param {GroundPolylineGeometry} groundPolylineGeometry GroundPolylinGeometry describing a polyline on terrain.
162+
* @param {GroundPolylineGeometry} groundPolylineGeometry GroundPolylinGeometry describing a polyline on terrain or 3D Tiles.
163163
* @param {Projection} mapProjection A MapProjection used for projecting cartographic coordinates to 2D.
164164
* @private
165165
*/
@@ -386,7 +386,7 @@ define([
386386
var intersectionScratch = new Cartesian3();
387387
/**
388388
* Computes shadow volumes for the ground polyline, consisting of its vertices, indices, and a bounding sphere.
389-
* Vertices are "fat," packing all the data needed in each volume to describe a line on terrain.
389+
* Vertices are "fat," packing all the data needed in each volume to describe a line on terrain or 3D Tiles.
390390
* Should not be called independent of {@link GroundPolylinePrimitive}.
391391
*
392392
* @param {GroundPolylineGeometry} groundPolylineGeometry

Source/DataSources/CorridorGraphics.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ define([
4141
* @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the distance between each latitude and longitude.
4242
* @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the corridor casts or receives shadows from each light source.
4343
* @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this corridor will be displayed.
44+
* @param {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this corridor will classify terrain, 3D Tiles, or both when on the ground.
4445
* @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.
4546
*
4647
* @see Entity
@@ -232,7 +233,7 @@ define([
232233
* Gets or sets the {@link ClassificationType} Property specifying whether this corridor will classify terrain, 3D Tiles, or both when on the ground.
233234
* @memberof CorridorGraphics.prototype
234235
* @type {Property}
235-
* @default ClassificationType.TERRAIN
236+
* @default ClassificationType.BOTH
236237
*/
237238
classificationType : createPropertyDescriptor('classificationType'),
238239

Source/DataSources/EllipseGraphics.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ define([
4444
* @param {Property} [options.granularity=Cesium.Math.RADIANS_PER_DEGREE] A numeric Property specifying the angular distance between points on the ellipse.
4545
* @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the ellipse casts or receives shadows from each light source.
4646
* @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this ellipse will be displayed.
47+
* @param {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this ellipse will classify terrain, 3D Tiles, or both when on the ground.
4748
* @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.
4849
*
4950
* @demo {@link https://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Circles and Ellipses.html|Cesium Sandcastle Circles and Ellipses Demo}
@@ -254,7 +255,7 @@ define([
254255
* Gets or sets the {@link ClassificationType} Property specifying whether this ellipse will classify terrain, 3D Tiles, or both when on the ground.
255256
* @memberof EllipseGraphics.prototype
256257
* @type {Property}
257-
* @default ClassificationType.TERRAIN
258+
* @default ClassificationType.BOTH
258259
*/
259260
classificationType : createPropertyDescriptor('classificationType'),
260261

Source/DataSources/Entity.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -676,12 +676,12 @@ define([
676676
};
677677

678678
/**
679-
* Checks if the given Scene supports polylines clamped to the ground..
679+
* Checks if the given Scene supports polylines clamped to terrain or 3D Tiles.
680680
* If this feature is not supported, Entities with PolylineGraphics will be rendered with vertices at
681681
* the provided heights and using the `followSurface` parameter instead of clamped to the ground.
682682
*
683683
* @param {Scene} scene The current scene.
684-
* @returns {Boolean} Whether or not the current scene supports Polylines on Terrain.
684+
* @returns {Boolean} Whether or not the current scene supports polylines on terrain or 3D TIles.
685685
*/
686686
Entity.supportsPolylinesOnTerrain = function(scene) {
687687
return GroundPolylinePrimitive.isSupported(scene);

Source/DataSources/PolygonGraphics.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ define([
4343
* @param {Boolean} [options.closeBottom=true] When false, leaves off the bottom of an extruded polygon open.
4444
* @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the polygon casts or receives shadows from each light source.
4545
* @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this polygon will be displayed.
46+
* @param {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this polygon will classify terrain, 3D Tiles, or both when on the ground.
4647
* @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.
4748
*
4849
* @see Entity
@@ -255,7 +256,7 @@ define([
255256
* Gets or sets the {@link ClassificationType} Property specifying whether this polygon will classify terrain, 3D Tiles, or both when on the ground.
256257
* @memberof PolygonGraphics.prototype
257258
* @type {Property}
258-
* @default ClassificationType.TERRAIN
259+
* @default ClassificationType.BOTH
259260
*/
260261
classificationType : createPropertyDescriptor('classificationType'),
261262

Source/DataSources/PolylineGeometryUpdater.js

+19-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ define([
1818
'../Core/PolylinePipeline',
1919
'../Core/ShowGeometryInstanceAttribute',
2020
'../DataSources/Entity',
21+
'../Scene/ClassificationType',
2122
'../Scene/GroundPolylinePrimitive',
2223
'../Scene/PolylineCollection',
2324
'../Scene/PolylineColorAppearance',
@@ -48,6 +49,7 @@ define([
4849
PolylinePipeline,
4950
ShowGeometryInstanceAttribute,
5051
Entity,
52+
ClassificationType,
5153
GroundPolylinePrimitive,
5254
PolylineCollection,
5355
PolylineColorAppearance,
@@ -70,6 +72,7 @@ define([
7072
var defaultShow = new ConstantProperty(true);
7173
var defaultShadows = new ConstantProperty(ShadowMode.DISABLED);
7274
var defaultDistanceDisplayCondition = new ConstantProperty(new DistanceDisplayCondition());
75+
var defaultClassificationType = new ConstantProperty(ClassificationType.BOTH);
7376

7477
function GeometryOptions() {
7578
this.vertexFormat = undefined;
@@ -113,6 +116,7 @@ define([
113116
this._materialProperty = undefined;
114117
this._shadowsProperty = undefined;
115118
this._distanceDisplayConditionProperty = undefined;
119+
this._classificationTypeProperty = undefined;
116120
this._depthFailMaterialProperty = undefined;
117121
this._geometryOptions = new GeometryOptions();
118122
this._groundGeometryOptions = new GroundGeometryOptions();
@@ -252,6 +256,18 @@ define([
252256
return this._distanceDisplayConditionProperty;
253257
}
254258
},
259+
/**
260+
* Gets or sets the {@link ClassificationType} Property specifying if this geometry will classify terrain, 3D Tiles, or both when on the ground.
261+
* @memberof PolylineGeometryUpdater.prototype
262+
*
263+
* @type {Property}
264+
* @readonly
265+
*/
266+
classificationTypeProperty : {
267+
get : function() {
268+
return this._classificationTypeProperty;
269+
}
270+
},
255271
/**
256272
* Gets a value indicating if the geometry is time-varying.
257273
* If true, all visualization is delegated to the {@link DynamicGeometryUpdater}
@@ -473,6 +489,7 @@ define([
473489
this._showProperty = defaultValue(show, defaultShow);
474490
this._shadowsProperty = defaultValue(polyline.shadows, defaultShadows);
475491
this._distanceDisplayConditionProperty = defaultValue(polyline.distanceDisplayCondition, defaultDistanceDisplayCondition);
492+
this._classificationTypeProperty = defaultValue(polyline.classificationType, defaultClassificationType);
476493
this._fillEnabled = true;
477494
this._zIndex = defaultValue(zIndex, defaultZIndex);
478495

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

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

Source/DataSources/PolylineGraphics.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ define([
3131
* @param {Property} [options.width=1.0] A numeric Property specifying the width in pixels.
3232
* @param {Property} [options.show=true] A boolean Property specifying the visibility of the polyline.
3333
* @param {MaterialProperty} [options.material=Color.WHITE] A Property specifying the material used to draw the polyline.
34-
* @param {MaterialProperty} [options.depthFailMaterial] A property specifiying the material used to draw the polyline when it is below the terrain.
34+
* @param {MaterialProperty} [options.depthFailMaterial] A property specifying the material used to draw the polyline when it is below the terrain.
3535
* @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.
3636
* @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the polyline casts or receives shadows from each light source.
3737
* @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this polyline will be displayed.
38+
* @param {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this polyline will classify terrain, 3D Tiles, or both when on the ground.
3839
* @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.
3940
*
4041
* @see Entity
@@ -62,6 +63,8 @@ define([
6263
this._shadowsSubscription = undefined;
6364
this._distanceDisplayCondition = undefined;
6465
this._distanceDisplayConditionSubscription = undefined;
66+
this._classificationType = undefined;
67+
this._classificationTypeSubscription = undefined;
6568
this._zIndex = undefined;
6669
this._zIndexSubscription = undefined;
6770

@@ -170,6 +173,14 @@ define([
170173
*/
171174
distanceDisplayCondition : createPropertyDescriptor('distanceDisplayCondition'),
172175

176+
/**
177+
* Gets or sets the {@link ClassificationType} Property specifying whether this polyline will classify terrain, 3D Tiles, or both when on the ground.
178+
* @memberof PolylineGraphics.prototype
179+
* @type {Property}
180+
* @default ClassificationType.BOTH
181+
*/
182+
classificationType : createPropertyDescriptor('classificationType'),
183+
173184
/**
174185
* 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.
175186
* @memberof RectangleGraphics.prototype
@@ -199,6 +210,7 @@ define([
199210
result.granularity = this.granularity;
200211
result.shadows = this.shadows;
201212
result.distanceDisplayCondition = this.distanceDisplayCondition;
213+
result.classificationType = this.classificationType;
202214
result.zIndex = this.zIndex;
203215

204216
return result;
@@ -227,6 +239,7 @@ define([
227239
this.granularity = defaultValue(this.granularity, source.granularity);
228240
this.shadows = defaultValue(this.shadows, source.shadows);
229241
this.distanceDisplayCondition = defaultValue(this.distanceDisplayCondition, source.distanceDisplayCondition);
242+
this.classificationType = defaultValue(this.classificationType, source.classificationType);
230243
this.zIndex = defaultValue(this.zIndex, source.zIndex);
231244
};
232245

0 commit comments

Comments
 (0)