Skip to content

Commit

Permalink
Merge pull request #4273 from AnalyticalGraphicsInc/spec-fixes-2
Browse files Browse the repository at this point in the history
Fix clamp to ground specs for IE
  • Loading branch information
pjcozzi committed Sep 1, 2016
2 parents 2e4ddef + b3e341d commit 94fd66f
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 45 deletions.
45 changes: 34 additions & 11 deletions Specs/DataSources/CorridorGeometryUpdaterSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ defineSuite([
'DataSources/SampledPositionProperty',
'DataSources/SampledProperty',
'DataSources/TimeIntervalCollectionProperty',
'Scene/GroundPrimitive',
'Scene/PrimitiveCollection',
'Scene/ShadowMode',
'Specs/createDynamicGeometryBoundingSphereSpecs',
Expand All @@ -44,6 +45,7 @@ defineSuite([
SampledPositionProperty,
SampledProperty,
TimeIntervalCollectionProperty,
GroundPrimitive,
PrimitiveCollection,
ShadowMode,
createDynamicGeometryBoundingSphereSpecs,
Expand All @@ -53,10 +55,12 @@ defineSuite([

var scene;
var time;
var groundPrimitiveSupported;

beforeAll(function() {
scene = createScene();
time = JulianDate.now();
groundPrimitiveSupported = GroundPrimitive.isSupported(scene);
});

afterAll(function() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
35 changes: 29 additions & 6 deletions Specs/DataSources/EllipseGeometryUpdaterSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ defineSuite([
'DataSources/SampledPositionProperty',
'DataSources/SampledProperty',
'DataSources/TimeIntervalCollectionProperty',
'Scene/GroundPrimitive',
'Scene/PrimitiveCollection',
'Scene/ShadowMode',
'Specs/createDynamicGeometryBoundingSphereSpecs',
Expand All @@ -42,6 +43,7 @@ defineSuite([
SampledPositionProperty,
SampledProperty,
TimeIntervalCollectionProperty,
GroundPrimitive,
PrimitiveCollection,
ShadowMode,
createDynamicGeometryBoundingSphereSpecs,
Expand All @@ -51,10 +53,12 @@ defineSuite([

var scene;
var time;
var groundPrimitiveSupported;

beforeAll(function() {
scene = createScene();
time = JulianDate.now();
groundPrimitiveSupported = GroundPrimitive.isSupported(scene);
});

afterAll(function() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 4 additions & 0 deletions Specs/DataSources/GeometryVisualizerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion Specs/DataSources/KmlDataSourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defineSuite([
'Core/ClockRange',
'Core/ClockStep',
'Core/Color',
'Core/combine',
'Core/DefaultProxy',
'Core/Event',
'Core/Iso8601',
Expand Down Expand Up @@ -37,6 +38,7 @@ defineSuite([
ClockRange,
ClockStep,
Color,
combine,
DefaultProxy,
Event,
Iso8601,
Expand Down Expand Up @@ -3848,7 +3850,7 @@ defineSuite([
</coordinates>\
</LineString>\
</Placemark>';
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();
Expand Down
61 changes: 44 additions & 17 deletions Specs/DataSources/PolygonGeometryUpdaterSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ defineSuite([
'DataSources/SampledPositionProperty',
'DataSources/SampledProperty',
'DataSources/TimeIntervalCollectionProperty',
'Scene/GroundPrimitive',
'Scene/PrimitiveCollection',
'Scene/ShadowMode',
'Specs/createDynamicGeometryBoundingSphereSpecs',
Expand All @@ -44,6 +45,7 @@ defineSuite([
SampledPositionProperty,
SampledProperty,
TimeIntervalCollectionProperty,
GroundPrimitive,
PrimitiveCollection,
ShadowMode,
createDynamicGeometryBoundingSphereSpecs,
Expand All @@ -53,10 +55,12 @@ defineSuite([

var scene;
var time;
var groundPrimitiveSupported;

beforeAll(function() {
scene = createScene();
time = JulianDate.now();
groundPrimitiveSupported = GroundPrimitive.isSupported(scene);
});

afterAll(function() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 94fd66f

Please sign in to comment.