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

Polylines on 3D Tiles #7437

Merged
merged 13 commits into from
Jan 2, 2019
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.
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
19 changes: 14 additions & 5 deletions Source/DataSources/PolylineVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ define([
'../Core/defaultValue',
'../Core/defined',
'../Core/destroyObject',
'../Scene/ClassificationType',
'../Scene/PolylineColorAppearance',
'../Scene/PolylineMaterialAppearance',
'../Scene/ShadowMode',
Expand All @@ -22,6 +23,7 @@ define([
defaultValue,
defined,
destroyObject,
ClassificationType,
PolylineColorAppearance,
PolylineMaterialAppearance,
ShadowMode,
Expand Down Expand Up @@ -52,7 +54,8 @@ define([
}

if (updater.clampToGround && updater.fillEnabled) { // Also checks for support
that._groundBatch.add(time, updater);
var classificationType = updater.classificationTypeProperty.getValue(time);
that._groundBatches[classificationType].add(time, updater);
return;
}

Expand Down Expand Up @@ -106,11 +109,12 @@ define([
this._removedObjects = new AssociativeArray();
this._changedObjects = new AssociativeArray();

var i;
var numberOfShadowModes = ShadowMode.NUMBER_OF_SHADOW_MODES;
this._colorBatches = new Array(numberOfShadowModes * 3);
this._materialBatches = new Array(numberOfShadowModes * 3);

for (var i = 0; i < numberOfShadowModes; ++i) {
for (i = 0; i < numberOfShadowModes; ++i) {
this._colorBatches[i] = new StaticGeometryColorBatch(primitives, PolylineColorAppearance, undefined, false, i); // no depth fail appearance
this._materialBatches[i] = new StaticGeometryPerMaterialBatch(primitives, PolylineMaterialAppearance, undefined, false, i);

Expand All @@ -122,10 +126,15 @@ define([
}

this._dynamicBatch = new DynamicGeometryBatch(primitives, groundPrimitives);
// Only available for terrain classification
this._groundBatch = new StaticGroundPolylinePerMaterialBatch(groundPrimitives);

this._batches = this._colorBatches.concat(this._materialBatches, this._dynamicBatch, this._groundBatch);
var numberOfClassificationTypes = ClassificationType.NUMBER_OF_CLASSIFICATION_TYPES;
this._groundBatches = new Array(numberOfClassificationTypes);

for (i = 0; i < numberOfClassificationTypes; ++i) {
this._groundBatches[i] = new StaticGroundPolylinePerMaterialBatch(groundPrimitives, i);
}

this._batches = this._colorBatches.concat(this._materialBatches, this._dynamicBatch, this._groundBatches);

this._subscriptions = new AssociativeArray();
this._updaters = new AssociativeArray();
Expand Down
3 changes: 2 additions & 1 deletion Source/DataSources/RectangleGraphics.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 angular distance between points on the rectangle.
* @param {Property} [options.shadows=ShadowMode.DISABLED] An enum Property specifying whether the rectangle casts or receives shadows from each light source.
* @param {Property} [options.distanceDisplayCondition] A Property specifying at what distance from the camera that this rectangle will be displayed.
* @param {Property} [options.classificationType=ClassificationType.BOTH] An enum Property specifying whether this rectangle 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 the rectangle is constant and neither height or extrudedHeight are specified.
*
* @see Entity
Expand Down Expand Up @@ -234,7 +235,7 @@ define([
* Gets or sets the {@link ClassificationType} Property specifying whether this rectangle will classify terrain, 3D Tiles, or both when on the ground.
* @memberof RectangleGraphics.prototype
* @type {Property}
* @default ClassificationType.TERRAIN
* @default ClassificationType.BOTH
*/
classificationType : createPropertyDescriptor('classificationType'),

Expand Down
Loading