Skip to content

Commit

Permalink
Merge pull request #43 from AnalyticalGraphicsInc/Issue35Fixes
Browse files Browse the repository at this point in the history
Fixes to sensor tests.
  • Loading branch information
mramato committed Jan 20, 2014
2 parents 14f442a + 82f05bb commit 49788bf
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 21 deletions.
40 changes: 32 additions & 8 deletions Specs/Scene/CustomSensorVolumeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ defineSuite([

beforeAll(function() {
scene = createScene();
var camera = scene.getCamera();
camera.direction = Cartesian3.clone(Cartesian3.UNIT_Z);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Y);
var z = -(Ellipsoid.WGS84.getRadii().z + 10000000.0);
camera.position = new Cartesian3(0.0, 0.0, z);
});

afterAll(function() {
Expand Down Expand Up @@ -81,6 +76,11 @@ defineSuite([
}

beforeEach(function() {
var camera = scene.getCamera();
camera.direction = Cartesian3.clone(Cartesian3.UNIT_Z);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Y);
var z = -(Ellipsoid.WGS84.getRadii().z + 10000000.0);
camera.position = new Cartesian3(0.0, 0.0, z);
scene.initializeFrame();
});

Expand Down Expand Up @@ -159,6 +159,14 @@ defineSuite([
});

it('renders using complete (default) option', function() {
var camera = scene.getCamera();
camera.direction = Cartesian3.clone(Cartesian3.UNIT_Z, camera.direction);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Y, camera.up);
var x = 1000000.0;
var y = 1000000.0;
var z = -(Ellipsoid.WGS84.getRadii().z + 10000000.0);
camera.position = new Cartesian3(x, y, z);

scene.render();
expect(scene.getContext().readPixels()).toEqual([0, 0, 0, 255]);
var sensor = addSensor({
Expand All @@ -167,10 +175,18 @@ defineSuite([
});
sensor.portionToDisplay = SensorVolumePortionToDisplay.COMPLETE;
scene.render();
expect(scene.getContext().readPixels({ x : 1, y :1})).not.toEqual([0, 0, 0, 255]);
expect(scene.getContext().readPixels()).not.toEqual([0, 0, 0, 255]);
});

it('renders using below ellipsoid horizon option', function() {
var camera = scene.getCamera();
camera.direction = Cartesian3.clone(Cartesian3.UNIT_Z, camera.direction);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Y, camera.up);
var x = 1000000.0;
var y = 1000000.0;
var z = -(Ellipsoid.WGS84.getRadii().z + 10000000.0);
camera.position = new Cartesian3(x, y, z);

scene.render();
expect(scene.getContext().readPixels()).toEqual([0, 0, 0, 255]);
var sensor = addSensor({
Expand All @@ -179,10 +195,18 @@ defineSuite([
});
sensor.portionToDisplay = SensorVolumePortionToDisplay.BELOW_ELLIPSOID_HORIZON;
scene.render();
expect(scene.getContext().readPixels({ x : 1, y :1})).not.toEqual([0, 0, 0, 255]);
expect(scene.getContext().readPixels()).not.toEqual([0, 0, 0, 255]);
});

it('renders using above ellipsoid horizon option', function() {
var camera = scene.getCamera();
camera.direction = Cartesian3.clone(Cartesian3.UNIT_Z, camera.direction);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Y, camera.up);
var x = 1000000.0;
var y = 1000000.0;
var z = -(Ellipsoid.WGS84.getRadii().z + 10000000.0);
camera.position = new Cartesian3(x, y, z);

scene.render();
expect(scene.getContext().readPixels()).toEqual([0, 0, 0, 255]);
var sensor = addSensor({
Expand All @@ -191,7 +215,7 @@ defineSuite([
});
sensor.portionToDisplay = SensorVolumePortionToDisplay.ABOVE_ELLIPSOID_HORIZON;
scene.render();
expect(scene.getContext().readPixels({ x : 1, y :1})).not.toEqual([0, 0, 0, 255]);
expect(scene.getContext().readPixels()).not.toEqual([0, 0, 0, 255]);
});

it('renders using outside ellipsoid horizon fragment shader', function() {
Expand Down
50 changes: 37 additions & 13 deletions Specs/Scene/RectangularPyramidSensorVolumeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ defineSuite([

beforeAll(function() {
scene = createScene();
var camera = scene.getCamera();
camera.direction = Cartesian3.UNIT_Z;
camera.up = Cartesian3.UNIT_Y;
var z = -(Ellipsoid.WGS84.getRadii().z + 10000000.0);
camera.position = new Cartesian3(0.0, 0.0, z);
});

afterAll(function() {
Expand Down Expand Up @@ -75,6 +70,11 @@ defineSuite([
}

beforeEach(function() {
var camera = scene.getCamera();
camera.direction = Cartesian3.clone(Cartesian3.UNIT_Z, camera.direction);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Y, camera.up);
var z = -(Ellipsoid.WGS84.getRadii().z + 10000000.0);
camera.position = new Cartesian3(0.0, 0.0, z);
scene.initializeFrame();
});

Expand Down Expand Up @@ -159,39 +159,63 @@ defineSuite([
});

it('renders using complete (default) option', function() {
var camera = scene.getCamera();
camera.direction = Cartesian3.clone(Cartesian3.UNIT_Z, camera.direction);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Y, camera.up);
var x = 1000000.0;
var y = 1000000.0;
var z = -(Ellipsoid.WGS84.getRadii().z + 10000000.0);
camera.position = new Cartesian3(x, y, z);

scene.render();
expect(scene.getContext().readPixels()).toEqual([0, 0, 0, 255]);
var sensor = addSensor({
latitude : -90.0,
altitude : 3000000.0
altitude : 2500000.0
});
sensor.portionToDisplay = SensorVolumePortionToDisplay.COMPLETE;
scene.render();
expect(scene.getContext().readPixels({ x : 1, y :1})).not.toEqual([0, 0, 0, 255]);
expect(scene.getContext().readPixels()).not.toEqual([0, 0, 0, 255]);
});

it('renders using below ellipsoid horizon option', function() {
var camera = scene.getCamera();
camera.direction = Cartesian3.clone(Cartesian3.UNIT_Z, camera.direction);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Y, camera.up);
var x = 1000000.0;
var y = 1000000.0;
var z = -(Ellipsoid.WGS84.getRadii().z + 10000000.0);
camera.position = new Cartesian3(x, y, z);

scene.render();
expect(scene.getContext().readPixels()).toEqual([0, 0, 0, 255]);
var sensor = addSensor({
latitude : -90.0,
altitude : 3000000.0
altitude : 2500000.0
});
sensor.portionToDisplay = SensorVolumePortionToDisplay.BELOW_ELLIPSOID_HORIZON;
scene.render();
expect(scene.getContext().readPixels({ x : 1, y :1})).not.toEqual([0, 0, 0, 255]);
expect(scene.getContext().readPixels()).not.toEqual([0, 0, 0, 255]);
});

it('renders using above ellipsoid horizon option', function() {
var camera = scene.getCamera();
camera.direction = Cartesian3.clone(Cartesian3.UNIT_Z, camera.direction);
camera.up = Cartesian3.clone(Cartesian3.UNIT_Y, camera.up);
var x = 1000000.0;
var y = 1000000.0;
var z = -(Ellipsoid.WGS84.getRadii().z + 10000000.0);
camera.position = new Cartesian3(x, y, z);

scene.render();
expect(scene.getContext().readPixels()).toEqual([0, 0, 0, 255]);
var sensor = addSensor({
latitude : -90.0,
altitude : 3000000.0
altitude : 2500000.0
});
sensor.portionToDisplay = SensorVolumePortionToDisplay.ABOVE_ELLIPSOID_HORIZON;
scene.render();
expect(scene.getContext().readPixels({ x : 1, y :1})).not.toEqual([0, 0, 0, 255]);
expect(scene.getContext().readPixels()).not.toEqual([0, 0, 0, 255]);
});

it('renders', function() {
Expand Down Expand Up @@ -233,7 +257,7 @@ defineSuite([
// The camera is looking along the negative x-axis with z as the up direction and 2km from the surface.
var camera = scene.getCamera();
camera.direction = Cartesian3.negate(Cartesian3.UNIT_X);
camera.up = Cartesian3.UNIT_Z;
camera.up = Cartesian3.clone(Cartesian3.UNIT_Z, camera.up);
var x = (Ellipsoid.WGS84.getRadii().x + 2000.0);
camera.position = new Cartesian3(x, 0.0, 0.0);

Expand Down Expand Up @@ -293,7 +317,7 @@ defineSuite([
// The camera is looking along the negative x-axis with z as the up direction and 2km from the surface.
var camera = scene.getCamera();
camera.direction = Cartesian3.negate(Cartesian3.UNIT_X);
camera.up = Cartesian3.UNIT_Z;
camera.up = Cartesian3.clone(Cartesian3.UNIT_Z, camera.up);
var x = (Ellipsoid.WGS84.getRadii().x + 2000.0);
camera.position = new Cartesian3(x, 0.0, 0.0);

Expand Down

0 comments on commit 49788bf

Please sign in to comment.