diff --git a/CHANGES.md b/CHANGES.md index 8acf88d28bfc..80d08c4616e9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ Change Log * Fixed a bug affected models with multiple meshes without indices. [#4237](https://github.com/AnalyticalGraphicsInc/cesium/issues/4237) * Fixed a glTF transparency bug where `blendFuncSeparate` parameters were loaded in the wrong order. [#4435](https://github.com/AnalyticalGraphicsInc/cesium/pull/4435) * Fixed a bug where creating a custom geometry with attributes and indices that have values that are not a typed array would cause a crash. [#4419](https://github.com/AnalyticalGraphicsInc/cesium/pull/4419) +* `KmlDataSource` and `GeoJsonDataSource` were not honoring the `clampToGround` option for billboards and labels and was instead always clamping, reducing performance in cases when it was unneeded. * Fixed a bug with rotated, textured rectangles. [#4430](https://github.com/AnalyticalGraphicsInc/cesium/pull/4430) * Fixed a bug when morphing from 2D to 3D. [#4388](https://github.com/AnalyticalGraphicsInc/cesium/pull/4388) * Fixed a bug where when KML features had duplicate IDs, only one was drawn. [#3941](https://github.com/AnalyticalGraphicsInc/cesium/issues/3941) diff --git a/Source/DataSources/GeoJsonDataSource.js b/Source/DataSources/GeoJsonDataSource.js index bdae9dfa8315..637cdf7d50a7 100644 --- a/Source/DataSources/GeoJsonDataSource.js +++ b/Source/DataSources/GeoJsonDataSource.js @@ -285,7 +285,7 @@ define([ billboard.verticalOrigin = new ConstantProperty(VerticalOrigin.BOTTOM); // Clamp to ground if there isn't a height specified - if (coordinates.length === 2) { + if (coordinates.length === 2 && options.clampToGround) { billboard.heightReference = HeightReference.CLAMP_TO_GROUND; } diff --git a/Source/DataSources/KmlDataSource.js b/Source/DataSources/KmlDataSource.js index eed05c7ff8d8..8ad8ff9e4cb1 100644 --- a/Source/DataSources/KmlDataSource.js +++ b/Source/DataSources/KmlDataSource.js @@ -1089,7 +1089,7 @@ define([ } } - if (defined(heightReference)) { + if (defined(heightReference) && dataSource._clampToGround) { billboard.heightReference = heightReference; label.heightReference = heightReference; } diff --git a/Specs/DataSources/KmlDataSourceSpec.js b/Specs/DataSources/KmlDataSourceSpec.js index 24ac384f943b..c5a467b1eb86 100644 --- a/Specs/DataSources/KmlDataSourceSpec.js +++ b/Specs/DataSources/KmlDataSourceSpec.js @@ -2192,7 +2192,7 @@ defineSuite([ }); }); - it('Geometry Point: sets heightReference to clampToGround (the default)', function() { + it('Geometry Point: sets heightReference to clampToGround', function() { var kml = '\ \ \ @@ -2200,7 +2200,11 @@ defineSuite([ \ '; - return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), options).then(function(dataSource) { + return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), { + camera : options.camera, + canvas : options.canvas, + clampToGround : true + }).then(function(dataSource) { var entities = dataSource.entities.values; expect(entities.length).toEqual(1); expect(entities[0].billboard.heightReference.getValue(Iso8601.MINIMUM_VALUE)).toEqual(HeightReference.CLAMP_TO_GROUND); @@ -2705,7 +2709,7 @@ defineSuite([ }); }); - it('Geometry gx:Track: sets position and availability (clampToGround default)', function() { + it('Geometry gx:Track: sets position and availability', function() { var kml = '\ \ @@ -2719,7 +2723,11 @@ defineSuite([ \ '; - return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), options).then(function(dataSource) { + return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), { + camera : options.camera, + canvas : options.canvas, + clampToGround : true + }).then(function(dataSource) { var time1 = JulianDate.fromIso8601('2000-01-01T00:00:00Z'); var time2 = JulianDate.fromIso8601('2000-01-01T00:00:01Z'); var time3 = JulianDate.fromIso8601('2000-01-01T00:00:02Z'); @@ -2754,7 +2762,11 @@ defineSuite([ \ '; - return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), options).then(function(dataSource) { + return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), { + camera : options.camera, + canvas : options.canvas, + clampToGround : true + }).then(function(dataSource) { var time1 = JulianDate.fromIso8601('2000-01-01T00:00:00Z'); var time2 = JulianDate.fromIso8601('2000-01-01T00:00:01Z'); var time3 = JulianDate.fromIso8601('2000-01-01T00:00:02Z'); @@ -2847,7 +2859,11 @@ defineSuite([ \ '; - return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), options).then(function(dataSource) { + return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), { + camera : options.camera, + canvas : options.canvas, + clampToGround : true + }).then(function(dataSource) { var time1 = JulianDate.fromIso8601('2000-01-01T00:00:00Z'); var time2 = JulianDate.fromIso8601('2000-01-01T00:00:01Z'); var time3 = JulianDate.fromIso8601('2000-01-01T00:00:02Z');