Skip to content

Commit

Permalink
Merge pull request #3811 from AnalyticalGraphicsInc/fix-tests
Browse files Browse the repository at this point in the history
Fix failing non-WebGL tests
  • Loading branch information
pjcozzi committed Apr 6, 2016
2 parents fa46306 + dcaa35a commit 2a4cecc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 33 deletions.
12 changes: 6 additions & 6 deletions Specs/Scene/MaterialSpec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*global defineSuite*/
defineSuite([
'Scene/Material',
'Scene/MaterialAppearance',
'Core/Cartesian3',
'Core/Color',
'Core/ColorGeometryInstanceAttribute',
Expand All @@ -15,13 +14,13 @@ defineSuite([
'Core/RectangleGeometry',
'Renderer/ClearCommand',
'Scene/EllipsoidSurfaceAppearance',
'Scene/MaterialAppearance',
'Scene/PolylineCollection',
'Scene/Primitive',
'Specs/pollToPromise',
'Specs/createScene'
'Specs/createScene',
'Specs/pollToPromise'
], function(
Material,
MaterialAppearance,
Cartesian3,
Color,
ColorGeometryInstanceAttribute,
Expand All @@ -35,10 +34,11 @@ defineSuite([
RectangleGeometry,
ClearCommand,
EllipsoidSurfaceAppearance,
MaterialAppearance,
PolylineCollection,
Primitive,
pollToPromise,
createScene) {
createScene,
pollToPromise) {
'use strict';

var scene;
Expand Down
52 changes: 25 additions & 27 deletions Specs/Scene/TileBoundingBoxSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defineSuite([
'Core/Math',
'Core/Rectangle',
'Scene/SceneMode',
'Specs/createScene'
'Specs/createFrameState'
], function(
TileBoundingBox,
Cartesian2,
Expand All @@ -18,17 +18,15 @@ defineSuite([
CesiumMath,
Rectangle,
SceneMode,
createScene) {
createFrameState) {
'use strict';

var scene;
var frameState;
var camera;

beforeAll(function() {
scene = createScene();
});

afterAll(function() {
scene.destroyForSpecs();
beforeEach(function() {
frameState = createFrameState();
camera = frameState.camera;
});

it('throws when options.rectangle is undefined', function() {
Expand All @@ -51,28 +49,28 @@ defineSuite([
});

// Inside rectangle, above height
scene.camera.position = Cartesian3.fromRadians(0.0, 0.0, 20.0);
expect(tile.distanceToCamera(scene.frameState)).toEqualEpsilon(10.0, CesiumMath.EPSILON3);
camera.position = Cartesian3.fromRadians(0.0, 0.0, 20.0);
expect(tile.distanceToCamera(frameState)).toEqualEpsilon(10.0, CesiumMath.EPSILON3);

// Inside rectangle, below height
scene.camera.position = Cartesian3.fromRadians(0.0, 0.0, 5.0);
expect(tile.distanceToCamera(scene.frameState)).toEqual(0.0);
camera.position = Cartesian3.fromRadians(0.0, 0.0, 5.0);
expect(tile.distanceToCamera(frameState)).toEqual(0.0);

// From southwest
scene.camera.position = Cartesian3.fromRadians(west - offset, south - offset, 0.0);
camera.position = Cartesian3.fromRadians(west - offset, south - offset, 0.0);
var southwestPosition = Cartesian3.fromRadians(west, south);
var expectedDistance = Cartesian3.distance(scene.camera.position, southwestPosition);
expect(tile.distanceToCamera(scene.frameState)).toEqualEpsilon(expectedDistance, CesiumMath.EPSILON1);
var expectedDistance = Cartesian3.distance(camera.position, southwestPosition);
expect(tile.distanceToCamera(frameState)).toEqualEpsilon(expectedDistance, CesiumMath.EPSILON1);

// From northeast
scene.camera.position = Cartesian3.fromRadians(east + offset, north + offset, 0.0);
camera.position = Cartesian3.fromRadians(east + offset, north + offset, 0.0);
var northeastPosition = Cartesian3.fromRadians(east, north);
expectedDistance = Cartesian3.distance(scene.camera.position, northeastPosition);
expect(tile.distanceToCamera(scene.frameState)).toEqualEpsilon(expectedDistance, CesiumMath.EPSILON1);
expectedDistance = Cartesian3.distance(camera.position, northeastPosition);
expect(tile.distanceToCamera(frameState)).toEqualEpsilon(expectedDistance, CesiumMath.EPSILON1);
});

it('distanceToCamera in 2D', function() {
scene.mode = SceneMode.SCENE2D;
frameState.mode = SceneMode.SCENE2D;

var offset = 0.0001;
var west = -0.001;
Expand All @@ -87,19 +85,19 @@ defineSuite([
});

// Inside rectangle
scene.camera.position = Cartesian3.fromRadians(0.0, 0.0, 0.0);
expect(tile.distanceToCamera(scene.frameState)).toEqualEpsilon(Ellipsoid.WGS84.radii.x, 10.0);
camera.position = Cartesian3.fromRadians(0.0, 0.0, 0.0);
expect(tile.distanceToCamera(frameState)).toEqual(Ellipsoid.WGS84.radii.x);

// From southwest
var southwest3D = new Cartographic(west, south, 0.0);
var southwest2D = scene.frameState.mapProjection.project(southwest3D);
var southwest2D = frameState.mapProjection.project(southwest3D);
var position3D = new Cartographic(west - offset, south - offset, 0.0);
var position2D = scene.frameState.mapProjection.project(position3D);
var position2D = frameState.mapProjection.project(position3D);
var distance2D = Cartesian2.distance(southwest2D, position2D);
var height = Ellipsoid.WGS84.radii.x;
var expectedDistance = Math.sqrt(distance2D * distance2D + height * height);

scene.camera.position = Cartesian3.fromRadians(position3D.longitude, position3D.latitude);
expect(tile.distanceToCamera(scene.frameState)).toEqualEpsilon(expectedDistance, 10.0);
camera.position = Cartesian3.fromRadians(position3D.longitude, position3D.latitude);
expect(tile.distanceToCamera(frameState)).toEqualEpsilon(expectedDistance, 10.0);
});
});
});

0 comments on commit 2a4cecc

Please sign in to comment.