From b3e341d6c22f5e35cc58b4f6159916b630bebb49 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Thu, 1 Sep 2016 11:24:02 -0400 Subject: [PATCH] Fix clamp to ground specs for IE --- .../CorridorGeometryUpdaterSpec.js | 45 ++++++++++---- .../DataSources/EllipseGeometryUpdaterSpec.js | 35 +++++++++-- Specs/DataSources/GeometryVisualizerSpec.js | 4 ++ Specs/DataSources/KmlDataSourceSpec.js | 4 +- .../DataSources/PolygonGeometryUpdaterSpec.js | 61 +++++++++++++------ .../RectangleGeometryUpdaterSpec.js | 35 +++++++++-- Specs/Scene/GroundPrimitiveSpec.js | 10 +-- 7 files changed, 149 insertions(+), 45 deletions(-) diff --git a/Specs/DataSources/CorridorGeometryUpdaterSpec.js b/Specs/DataSources/CorridorGeometryUpdaterSpec.js index dbe41222d91d..792933e5f7cc 100644 --- a/Specs/DataSources/CorridorGeometryUpdaterSpec.js +++ b/Specs/DataSources/CorridorGeometryUpdaterSpec.js @@ -19,6 +19,7 @@ defineSuite([ 'DataSources/SampledPositionProperty', 'DataSources/SampledProperty', 'DataSources/TimeIntervalCollectionProperty', + 'Scene/GroundPrimitive', 'Scene/PrimitiveCollection', 'Scene/ShadowMode', 'Specs/createDynamicGeometryBoundingSphereSpecs', @@ -44,6 +45,7 @@ defineSuite([ SampledPositionProperty, SampledProperty, TimeIntervalCollectionProperty, + GroundPrimitive, PrimitiveCollection, ShadowMode, createDynamicGeometryBoundingSphereSpecs, @@ -53,10 +55,12 @@ defineSuite([ var scene; var time; + var groundPrimitiveSupported; beforeAll(function() { scene = createScene(); time = JulianDate.now(); + groundPrimitiveSupported = GroundPrimitive.isSupported(scene); }); afterAll(function() { @@ -389,8 +393,13 @@ defineSuite([ var updater = new CorridorGeometryUpdater(entity, scene); - expect(updater.onTerrain).toBe(true); - expect(updater.outlineEnabled).toBe(false); + if (groundPrimitiveSupported) { + expect(updater.onTerrain).toBe(true); + expect(updater.outlineEnabled).toBe(false); + } else { + expect(updater.onTerrain).toBe(false); + expect(updater.outlineEnabled).toBe(true); + } }); it('Checks that an entity with height isn\'t on terrain', function() { @@ -513,11 +522,11 @@ defineSuite([ it('dynamic updater on terrain', function() { var corridor = new CorridorGraphics(); corridor.positions = createDynamicProperty(Cartesian3.fromRadiansArray([ - 0, 0, - 1, 0, - 1, 1, - 0, 1 - ])); + 0, 0, + 1, 0, + 1, 1, + 0, 1 + ])); corridor.show = createDynamicProperty(true); corridor.outline = createDynamicProperty(true); corridor.fill = createDynamicProperty(true); @@ -537,8 +546,14 @@ defineSuite([ expect(groundPrimitives.length).toBe(0); dynamicUpdater.update(time); - expect(primitives.length).toBe(0); - expect(groundPrimitives.length).toBe(1); + + if (groundPrimitiveSupported) { + expect(primitives.length).toBe(0); + expect(groundPrimitives.length).toBe(1); + } else { + expect(primitives.length).toBe(2); + expect(groundPrimitives.length).toBe(0); + } dynamicUpdater.destroy(); updater.destroy(); @@ -650,7 +665,11 @@ defineSuite([ var entity = createBasicCorridorWithoutHeight(); entity.corridor.fill = true; var updater = new CorridorGeometryUpdater(entity, scene); - expect(updater.onTerrain).toBe(true); + if (groundPrimitiveSupported) { + expect(updater.onTerrain).toBe(true); + } else { + expect(updater.onTerrain).toBe(false); + } }); it('fill is false sets onTerrain to false', function() { @@ -681,7 +700,11 @@ defineSuite([ entity.corridor.fill = true; entity.corridor.material = new ColorMaterialProperty(Color.WHITE); var updater = new CorridorGeometryUpdater(entity, scene); - expect(updater.onTerrain).toBe(true); + if (groundPrimitiveSupported) { + expect(updater.onTerrain).toBe(true); + } else { + expect(updater.onTerrain).toBe(false); + } }); it('non-color material sets onTerrain to false', function() { diff --git a/Specs/DataSources/EllipseGeometryUpdaterSpec.js b/Specs/DataSources/EllipseGeometryUpdaterSpec.js index 4d27fa27feb3..4df887e1a075 100644 --- a/Specs/DataSources/EllipseGeometryUpdaterSpec.js +++ b/Specs/DataSources/EllipseGeometryUpdaterSpec.js @@ -18,6 +18,7 @@ defineSuite([ 'DataSources/SampledPositionProperty', 'DataSources/SampledProperty', 'DataSources/TimeIntervalCollectionProperty', + 'Scene/GroundPrimitive', 'Scene/PrimitiveCollection', 'Scene/ShadowMode', 'Specs/createDynamicGeometryBoundingSphereSpecs', @@ -42,6 +43,7 @@ defineSuite([ SampledPositionProperty, SampledProperty, TimeIntervalCollectionProperty, + GroundPrimitive, PrimitiveCollection, ShadowMode, createDynamicGeometryBoundingSphereSpecs, @@ -51,10 +53,12 @@ defineSuite([ var scene; var time; + var groundPrimitiveSupported; beforeAll(function() { scene = createScene(); time = JulianDate.now(); + groundPrimitiveSupported = GroundPrimitive.isSupported(scene); }); afterAll(function() { @@ -436,8 +440,13 @@ defineSuite([ var updater = new EllipseGeometryUpdater(entity, scene); - expect(updater.onTerrain).toBe(true); - expect(updater.outlineEnabled).toBe(false); + if (groundPrimitiveSupported) { + expect(updater.onTerrain).toBe(true); + expect(updater.outlineEnabled).toBe(false); + } else { + expect(updater.onTerrain).toBe(false); + expect(updater.outlineEnabled).toBe(true); + } }); it('Checks that an entity with height isn\'t on terrain', function() { @@ -573,8 +582,14 @@ defineSuite([ expect(groundPrimitives.length).toBe(0); dynamicUpdater.update(time); - expect(primitives.length).toBe(0); - expect(groundPrimitives.length).toBe(1); + + if (groundPrimitiveSupported) { + expect(primitives.length).toBe(0); + expect(groundPrimitives.length).toBe(1); + } else { + expect(primitives.length).toBe(2); + expect(groundPrimitives.length).toBe(0); + } dynamicUpdater.destroy(); updater.destroy(); @@ -688,7 +703,11 @@ defineSuite([ var entity = createBasicEllipseWithoutHeight(); entity.ellipse.fill = true; var updater = new EllipseGeometryUpdater(entity, scene); - expect(updater.onTerrain).toBe(true); + if (groundPrimitiveSupported) { + expect(updater.onTerrain).toBe(true); + } else { + expect(updater.onTerrain).toBe(false); + } }); it('fill is false sets onTerrain to false', function() { @@ -719,7 +738,11 @@ defineSuite([ entity.ellipse.fill = true; entity.ellipse.material = new ColorMaterialProperty(Color.WHITE); var updater = new EllipseGeometryUpdater(entity, scene); - expect(updater.onTerrain).toBe(true); + if (groundPrimitiveSupported) { + expect(updater.onTerrain).toBe(true); + } else { + expect(updater.onTerrain).toBe(false); + } }); it('non-color material sets onTerrain to false', function() { diff --git a/Specs/DataSources/GeometryVisualizerSpec.js b/Specs/DataSources/GeometryVisualizerSpec.js index f72d6156fbe9..285d295be647 100644 --- a/Specs/DataSources/GeometryVisualizerSpec.js +++ b/Specs/DataSources/GeometryVisualizerSpec.js @@ -628,6 +628,10 @@ defineSuite([ }); it('StaticGroundGeometryColorBatch updates color attribute after rebuilding primitive', function() { + if (!GroundPrimitive.isSupported(scene)) { + return; + } + var batch = new StaticGroundGeometryColorBatch(scene.groundPrimitives); function computeKey(color) { diff --git a/Specs/DataSources/KmlDataSourceSpec.js b/Specs/DataSources/KmlDataSourceSpec.js index 9cec648460c5..8b5c304c592a 100644 --- a/Specs/DataSources/KmlDataSourceSpec.js +++ b/Specs/DataSources/KmlDataSourceSpec.js @@ -7,6 +7,7 @@ defineSuite([ 'Core/ClockRange', 'Core/ClockStep', 'Core/Color', + 'Core/combine', 'Core/DefaultProxy', 'Core/Event', 'Core/Iso8601', @@ -37,6 +38,7 @@ defineSuite([ ClockRange, ClockStep, Color, + combine, DefaultProxy, Event, Iso8601, @@ -3848,7 +3850,7 @@ defineSuite([ \ \ '; - var clampToGroundOptions = Object.assign({ clampToGround : true }, options); + var clampToGroundOptions = combine(options, { clampToGround : true }); return KmlDataSource.load(parser.parseFromString(kml, "text/xml"), clampToGroundOptions).then(function(dataSource) { var entity = dataSource.entities.values[0]; expect(entity.corridor).toBeDefined(); diff --git a/Specs/DataSources/PolygonGeometryUpdaterSpec.js b/Specs/DataSources/PolygonGeometryUpdaterSpec.js index 17bf08ac8602..211152007aeb 100644 --- a/Specs/DataSources/PolygonGeometryUpdaterSpec.js +++ b/Specs/DataSources/PolygonGeometryUpdaterSpec.js @@ -19,6 +19,7 @@ defineSuite([ 'DataSources/SampledPositionProperty', 'DataSources/SampledProperty', 'DataSources/TimeIntervalCollectionProperty', + 'Scene/GroundPrimitive', 'Scene/PrimitiveCollection', 'Scene/ShadowMode', 'Specs/createDynamicGeometryBoundingSphereSpecs', @@ -44,6 +45,7 @@ defineSuite([ SampledPositionProperty, SampledProperty, TimeIntervalCollectionProperty, + GroundPrimitive, PrimitiveCollection, ShadowMode, createDynamicGeometryBoundingSphereSpecs, @@ -53,10 +55,12 @@ defineSuite([ var scene; var time; + var groundPrimitiveSupported; beforeAll(function() { scene = createScene(); time = JulianDate.now(); + groundPrimitiveSupported = GroundPrimitive.isSupported(scene); }); afterAll(function() { @@ -408,8 +412,13 @@ defineSuite([ var updater = new PolygonGeometryUpdater(entity, scene); - expect(updater.onTerrain).toBe(true); - expect(updater.outlineEnabled).toBe(false); + if (groundPrimitiveSupported) { + expect(updater.onTerrain).toBe(true); + expect(updater.outlineEnabled).toBe(false); + } else { + expect(updater.onTerrain).toBe(false); + expect(updater.outlineEnabled).toBe(true); + } }); it('Checks that an entity with height isn\'t on terrain', function() { @@ -458,7 +467,11 @@ defineSuite([ var updater = new PolygonGeometryUpdater(entity, scene); - expect(updater.onTerrain).toBe(true); + if (groundPrimitiveSupported) { + expect(updater.onTerrain).toBe(true); + } else { + expect(updater.onTerrain).toBe(false); + } }); it('createFillGeometryInstance obeys Entity.show is false.', function() { @@ -484,11 +497,11 @@ defineSuite([ it('dynamic updater sets properties', function() { var polygon = new PolygonGraphics(); polygon.hierarchy = createDynamicProperty(new PolygonHierarchy(Cartesian3.fromRadiansArray([ - 0, 0, - 1, 0, - 1, 1, - 0, 1 - ]))); + 0, 0, + 1, 0, + 1, 1, + 0, 1 + ]))); polygon.show = createDynamicProperty(true); polygon.height = createDynamicProperty(3); polygon.extrudedHeight = createDynamicProperty(2); @@ -556,11 +569,11 @@ defineSuite([ it('dynamic updater on terrain', function() { var polygon = new PolygonGraphics(); polygon.hierarchy = createDynamicProperty(new PolygonHierarchy(Cartesian3.fromRadiansArray([ - 0, 0, - 1, 0, - 1, 1, - 0, 1 - ]))); + 0, 0, + 1, 0, + 1, 1, + 0, 1 + ]))); polygon.show = createDynamicProperty(true); polygon.outline = createDynamicProperty(true); polygon.fill = createDynamicProperty(true); @@ -579,8 +592,14 @@ defineSuite([ expect(groundPrimitives.length).toBe(0); dynamicUpdater.update(time); - expect(primitives.length).toBe(0); - expect(groundPrimitives.length).toBe(1); + + if (groundPrimitiveSupported) { + expect(primitives.length).toBe(0); + expect(groundPrimitives.length).toBe(1); + } else { + expect(primitives.length).toBe(2); + expect(groundPrimitives.length).toBe(0); + } dynamicUpdater.destroy(); updater.destroy(); @@ -692,7 +711,11 @@ defineSuite([ var entity = createBasicPolygonWithoutHeight(); entity.polygon.fill = true; var updater = new PolygonGeometryUpdater(entity, scene); - expect(updater.onTerrain).toBe(true); + if (groundPrimitiveSupported) { + expect(updater.onTerrain).toBe(true); + } else { + expect(updater.onTerrain).toBe(false); + } }); it('fill is false sets onTerrain to false', function() { @@ -731,7 +754,11 @@ defineSuite([ entity.polygon.fill = true; entity.polygon.material = new ColorMaterialProperty(Color.WHITE); var updater = new PolygonGeometryUpdater(entity, scene); - expect(updater.onTerrain).toBe(true); + if (groundPrimitiveSupported) { + expect(updater.onTerrain).toBe(true); + } else { + expect(updater.onTerrain).toBe(false); + } }); it('non-color material sets onTerrain to false', function() { diff --git a/Specs/DataSources/RectangleGeometryUpdaterSpec.js b/Specs/DataSources/RectangleGeometryUpdaterSpec.js index f8ef6b33cfd7..63ecba106986 100644 --- a/Specs/DataSources/RectangleGeometryUpdaterSpec.js +++ b/Specs/DataSources/RectangleGeometryUpdaterSpec.js @@ -17,6 +17,7 @@ defineSuite([ 'DataSources/RectangleGraphics', 'DataSources/SampledProperty', 'DataSources/TimeIntervalCollectionProperty', + 'Scene/GroundPrimitive', 'Scene/PrimitiveCollection', 'Scene/ShadowMode', 'Specs/createDynamicGeometryBoundingSphereSpecs', @@ -40,6 +41,7 @@ defineSuite([ RectangleGraphics, SampledProperty, TimeIntervalCollectionProperty, + GroundPrimitive, PrimitiveCollection, ShadowMode, createDynamicGeometryBoundingSphereSpecs, @@ -51,12 +53,14 @@ defineSuite([ var time2; var time3; var scene; + var groundPrimitiveSupported; beforeAll(function() { scene = createScene(); time = new JulianDate(0, 0); time2 = new JulianDate(10, 0); time3 = new JulianDate(20, 0); + groundPrimitiveSupported = GroundPrimitive.isSupported(scene); }); afterAll(function() { @@ -389,8 +393,13 @@ defineSuite([ var updater = new RectangleGeometryUpdater(entity, scene); - expect(updater.onTerrain).toBe(true); - expect(updater.outlineEnabled).toBe(false); + if (groundPrimitiveSupported) { + expect(updater.onTerrain).toBe(true); + expect(updater.outlineEnabled).toBe(false); + } else { + expect(updater.onTerrain).toBe(false); + expect(updater.outlineEnabled).toBe(true); + } }); it('Checks that an entity with height isn\'t on terrain', function() { @@ -524,8 +533,14 @@ defineSuite([ expect(groundPrimitives.length).toBe(0); dynamicUpdater.update(time); - expect(primitives.length).toBe(0); - expect(groundPrimitives.length).toBe(1); + + if (groundPrimitiveSupported) { + expect(primitives.length).toBe(0); + expect(groundPrimitives.length).toBe(1); + } else { + expect(primitives.length).toBe(2); + expect(groundPrimitives.length).toBe(0); + } dynamicUpdater.destroy(); updater.destroy(); @@ -634,7 +649,11 @@ defineSuite([ var entity = createBasicRectangleWithoutHeight(); entity.rectangle.fill = true; var updater = new RectangleGeometryUpdater(entity, scene); - expect(updater.onTerrain).toBe(true); + if (groundPrimitiveSupported) { + expect(updater.onTerrain).toBe(true); + } else { + expect(updater.onTerrain).toBe(false); + } }); it('fill is false sets onTerrain to false', function() { @@ -665,7 +684,11 @@ defineSuite([ entity.rectangle.fill = true; entity.rectangle.material = new ColorMaterialProperty(Color.WHITE); var updater = new RectangleGeometryUpdater(entity, scene); - expect(updater.onTerrain).toBe(true); + if (groundPrimitiveSupported) { + expect(updater.onTerrain).toBe(true); + } else { + expect(updater.onTerrain).toBe(false); + } }); it('non-color material sets onTerrain to false', function() { diff --git a/Specs/Scene/GroundPrimitiveSpec.js b/Specs/Scene/GroundPrimitiveSpec.js index 80bac3ec1568..470bbfc27578 100644 --- a/Specs/Scene/GroundPrimitiveSpec.js +++ b/Specs/Scene/GroundPrimitiveSpec.js @@ -854,10 +854,12 @@ defineSuite([ geometryInstances : rectangleInstance, asynchronous : false }); - - expect(function() { - primitive.update(scene.frameState); - }).toThrowDeveloperError(); + + if (GroundPrimitive.isSupported(scene)) { + expect(function() { + primitive.update(scene.frameState); + }).toThrowDeveloperError(); + } // Set back to initialized state GroundPrimitive._initPromise = initPromise;