Skip to content

Commit

Permalink
Merge pull request #7456 from AnalyticalGraphicsInc/classification-fixes
Browse files Browse the repository at this point in the history
Polylines and textured ground primitives on 3D Tiles
  • Loading branch information
bagnell authored Jan 3, 2019
2 parents c7b1fe6 + 290b531 commit 2241ff0
Show file tree
Hide file tree
Showing 54 changed files with 2,413 additions and 1,562 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.
55 changes: 48 additions & 7 deletions Apps/Sandcastle/gallery/Classification Types.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
var viewer = new Cesium.Viewer('cesiumContainer', {
terrainProvider: Cesium.createWorldTerrain()
});
viewer.scene.globe.depthTestAgainstTerrain = false;

var tileset = new Cesium.Cesium3DTileset({ url: Cesium.IonResource.fromAssetId(6074) });
viewer.scene.primitives.add(tileset);
Expand All @@ -41,31 +40,73 @@
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 options = [{
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;
}
}];
Sandcastle.addToolbarMenu(options);

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

Sandcastle.addToolbarMenu(classificationOptions);
Sandcastle.addToolbarMenu(materialOptions);
//Sandcastle_End
Sandcastle.finishedLoading();
}
Expand Down
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ Change Log

### 1.54 - 2019-02-01

##### Breaking Changes :mega:
* Billboards with `HeightReference.CLAMP_TO_GROUND` are now clamped to both terrain and 3D Tiles. [#7434](https://github.com/AnalyticalGraphicsInc/cesium/pull/7434)
* The default `classificationType` for `GroundPrimitive`, `CorridorGraphics`, `EllipseGraphics`, `PolygonGraphics` and `RectangleGraphics` is now `ClassificationType.BOTH`. [#7434](https://github.com/AnalyticalGraphicsInc/cesium/pull/7434)

##### Deprecated :hourglass_flowing_sand:
* `Scene.clampToHeight` now takes an optional `width` argument before the `result` argument. The previous function definition will no longer work in 1.56. [#7287](https://github.com/AnalyticalGraphicsInc/cesium/pull/7287)

##### Additions :tada:
* Added support for textured ground entities (entities with unspecified `height`) and `GroundPrimitives` on 3D Tiles. [#7434](https://github.com/AnalyticalGraphicsInc/cesium/pull/7434)
* Added support for polylines on 3D Tiles. [#7437](https://github.com/AnalyticalGraphicsInc/cesium/pull/7437)
* Added `classificationType` property to `PolylineGraphics` and `GroundPolylinePrimitive` which specifies whether a polyline clamped to ground should be clamped to terrain, 3D Tiles, or both. [#7437](https://github.com/AnalyticalGraphicsInc/cesium/pull/7437)
* Added the ability to specify the width of the intersection volume for `Scene.sampleHeight`, `Scene.clampToHeight`, `Scene.sampleHeightMostDetailed`, and `Scene.clampToHeightMostDetailed`. [#7287](https://github.com/AnalyticalGraphicsInc/cesium/pull/7287)

##### Fixes :wrench:
* Fixed an issue where classification primitives with the `CESIUM_3D_TILE` classification type would render on terrain. [#7422](https://github.com/AnalyticalGraphicsInc/cesium/pull/7422)
* Fixed an issue where 3D Tiles would show through the globe. [#7422](https://github.com/AnalyticalGraphicsInc/cesium/pull/7422)
* Fixed crash when entity geometry show value is an interval that only covered part of the entity availability range [#7458](https://github.com/AnalyticalGraphicsInc/cesium/pull/7458)
* Fixed image size issue when using multiple particle systems [#7412](https://github.com/AnalyticalGraphicsInc/cesium/pull/7412)

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
6 changes: 3 additions & 3 deletions Source/DataSources/Entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ define([
};

/**
* Checks if the given Scene supports materials besides Color on Entities draped on terrain.
* Checks if the given Scene supports materials besides Color on Entities draped on terrain or 3D Tiles.
* If this feature is not supported, Entities with non-color materials but no `height` will
* instead be rendered as if height is 0.
*
Expand All @@ -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
2 changes: 1 addition & 1 deletion Source/DataSources/GeometryUpdater.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ define([
var defaultOutlineColor = new ConstantProperty(Color.BLACK);
var defaultShadows = new ConstantProperty(ShadowMode.DISABLED);
var defaultDistanceDisplayCondition = new ConstantProperty(new DistanceDisplayCondition());
var defaultClassificationType = new ConstantProperty(ClassificationType.TERRAIN);
var defaultClassificationType = new ConstantProperty(ClassificationType.BOTH);

/**
* An abstract class for updating geometry entites.
Expand Down
18 changes: 5 additions & 13 deletions Source/DataSources/GeometryVisualizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,27 +173,22 @@ define([
var groundColorBatches = new Array(numberOfClassificationTypes);
var groundMaterialBatches = [];
if (supportsMaterialsforEntitiesOnTerrain) {
// Culling, phong shading only supported for ClassificationType.TERRAIN at the moment because
// tileset depth information not yet available.
groundColorBatches[ClassificationType.TERRAIN] = new StaticGroundGeometryPerMaterialBatch(groundPrimitives, PerInstanceColorAppearance);
for (i = 0; i < numberOfClassificationTypes; ++i) {
if (i !== ClassificationType.TERRAIN) {
groundColorBatches[i] = new StaticGroundGeometryColorBatch(groundPrimitives, i);
}
groundMaterialBatches.push(new StaticGroundGeometryPerMaterialBatch(groundPrimitives, i, MaterialAppearance));
groundColorBatches[i] = new StaticGroundGeometryPerMaterialBatch(groundPrimitives, i, PerInstanceColorAppearance);
}
groundMaterialBatches[0] = new StaticGroundGeometryPerMaterialBatch(groundPrimitives, MaterialAppearance);
this._groundTerrainMaterialBatch = groundMaterialBatches[0];
} else {
for (i = 0; i < numberOfClassificationTypes; ++i) {
groundColorBatches[i] = new StaticGroundGeometryColorBatch(groundPrimitives, i);
}
}

this._groundColorBatches = groundColorBatches;
this._groundMaterialBatches = groundMaterialBatches;

this._dynamicBatch = new DynamicGeometryBatch(primitives, groundPrimitives);

this._batches = this._outlineBatches.concat(this._closedColorBatches, this._closedMaterialBatches, this._openColorBatches, this._openMaterialBatches, this._groundColorBatches, groundMaterialBatches, this._dynamicBatch);
this._batches = this._outlineBatches.concat(this._closedColorBatches, this._closedMaterialBatches, this._openColorBatches, this._openMaterialBatches, this._groundColorBatches, this._groundMaterialBatches, this._dynamicBatch);

this._subscriptions = new AssociativeArray();
this._updaterSets = new AssociativeArray();
Expand Down Expand Up @@ -414,10 +409,7 @@ define([
this._groundColorBatches[classificationType].add(time, updater);
} else {
// If unsupported, updater will not be on terrain.
// If the updater has a material, ignore input ClassificationType for now and only classify terrain.
// Culling, phong shading only supported for ClassificationType.TERRAIN at the moment because
// tileset depth information not yet available.
this._groundTerrainMaterialBatch.add(time, updater);
this._groundMaterialBatches[classificationType].add(time, updater);
}
} else if (updater.isClosed) {
if (updater.fillMaterialProperty instanceof ColorMaterialProperty) {
Expand Down
70 changes: 35 additions & 35 deletions Source/DataSources/GroundGeometryUpdater.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
define([
'../Core/ApproximateTerrainHeights',
'../Core/Cartesian3',
'../Core/Check',
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/DeveloperError',
'../Core/GeometryOffsetAttribute',
'../Core/Iso8601',
'../Core/oneTimeWarning',
'../Scene/GroundPrimitive',
'../Scene/HeightReference',
'./CallbackProperty',
'./ConstantProperty',
'./GeometryUpdater',
'./Property',
'./TerrainOffsetProperty'
], function(
ApproximateTerrainHeights,
Cartesian3,
Check,
defaultValue,
defined,
defineProperties,
DeveloperError,
GeometryOffsetAttribute,
Iso8601,
oneTimeWarning,
GroundPrimitive,
HeightReference,
CallbackProperty,
ConstantProperty,
GeometryUpdater,
Property,
TerrainOffsetProperty) {
'../Core/ApproximateTerrainHeights',
'../Core/Cartesian3',
'../Core/Check',
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/DeveloperError',
'../Core/GeometryOffsetAttribute',
'../Core/Iso8601',
'../Core/oneTimeWarning',
'../Scene/GroundPrimitive',
'../Scene/HeightReference',
'./CallbackProperty',
'./ConstantProperty',
'./GeometryUpdater',
'./Property',
'./TerrainOffsetProperty'
], function(
ApproximateTerrainHeights,
Cartesian3,
Check,
defaultValue,
defined,
defineProperties,
DeveloperError,
GeometryOffsetAttribute,
Iso8601,
oneTimeWarning,
GroundPrimitive,
HeightReference,
CallbackProperty,
ConstantProperty,
GeometryUpdater,
Property,
TerrainOffsetProperty) {
'use strict';

var defaultZIndex = new ConstantProperty(0);
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
Loading

0 comments on commit 2241ff0

Please sign in to comment.