From ed01008e2ca50f6a952909bbefea419273d6d634 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Wed, 19 Oct 2016 16:13:35 -0400 Subject: [PATCH 1/3] Don't clamp KML billboards and labels if `clampToGround` is false. Closes #4415 --- Source/DataSources/KmlDataSource.js | 2 +- Specs/DataSources/KmlDataSourceSpec.js | 28 ++++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) 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'); From eb1f1579fd7a58133416cefd43c3639ba6af9c8c Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Wed, 19 Oct 2016 16:21:21 -0400 Subject: [PATCH 2/3] Update CHANGES --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 2ac781d9c5e8..0bf334fe7348 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` was 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) From 12274ea99fae6edbd6b043b60994e8eced9f06c9 Mon Sep 17 00:00:00 2001 From: Matthew Amato Date: Wed, 19 Oct 2016 17:45:42 -0400 Subject: [PATCH 3/3] Don't clamp GeoJsonDataSource billboards to ground unless clampToGround is true. --- CHANGES.md | 2 +- Source/DataSources/GeoJsonDataSource.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0bf334fe7348..8fe9d95ab16f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,7 +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` was not honoring the `clampToGround` option for billboards and labels and was instead always clamping, reducing performance in cases when it was unneeded. +* `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 b85115743868..0bba2fe30735 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; }