Skip to content

Commit

Permalink
Update CHANGES.md and added a test
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Oct 4, 2018
1 parent be877b3 commit b30ed2e
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change Log
==========

### 1.51 - 2018-11-01

##### Fixes :wrench:
* Fixed an issue where `pickPosition` would return incorrect results when called after `sampleHeight` or `clampToHeight`. [#7113](https://github.com/AnalyticalGraphicsInc/cesium/pull/7113)

### 1.50 - 2018-10-01

##### Breaking Changes :mega:
Expand Down
71 changes: 70 additions & 1 deletion Specs/Scene/PickSpec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
defineSuite([
'Core/Cartesian2',
'Core/Cartesian3',
'Core/Cartographic',
'Core/Color',
'Core/Ellipsoid',
'Core/FeatureDetection',
'Core/GeometryInstance',
Expand All @@ -25,8 +27,10 @@ defineSuite([
'Specs/createScene',
'Specs/pollToPromise'
], 'Scene/Pick', function(
Cartesian2,
Cartesian3,
Cartographic,
Color,
Ellipsoid,
FeatureDetection,
GeometryInstance,
Expand Down Expand Up @@ -57,7 +61,7 @@ defineSuite([
var camera;
var largeRectangle = Rectangle.fromDegrees(-1.0, -1.0, 1.0, 1.0);
var smallRectangle = Rectangle.fromDegrees(-0.0001, -0.0001, 0.0001, 0.0001);
var offscreenRectangle = Rectangle.fromDegrees(-45.0, -1.0, -43.0, 1.0);
var offscreenRectangle = Rectangle.fromDegrees(-45.0002, -1.0002, -45.0001, -1.0001);
var primitiveRay;
var offscreenRay;

Expand Down Expand Up @@ -1078,4 +1082,69 @@ defineSuite([
scene.context._depthTexture = depthTexture;
});
});

it('calls multiple picking functions within the same frame', function() {
if (!scene.clampToHeightSupported || !scene.pickPositionSupported) {
return;
}

createSmallRectangle(0.0);
var offscreenRectanglePrimitive = createRectangle(0.0, offscreenRectangle);
offscreenRectanglePrimitive.appearance.material.uniforms.color = new Color(1.0, 0.0, 0.0, 1.0);

scene.camera.setView({ destination : offscreenRectangle });

// Call render. Lays down depth for the pickPosition call
scene.renderForSpecs();

// Call clampToHeight
var cartesian = Cartesian3.fromRadians(0.0, 0.0, 100000.0);
expect(scene).toClampToHeightAndCall(function(cartesian) {
var expectedCartesian = Cartesian3.fromRadians(0.0, 0.0);
expect(cartesian).toEqualEpsilon(expectedCartesian, CesiumMath.EPSILON5);
}, cartesian);

// Call pickPosition
expect(scene).toPickPositionAndCall(function(cartesian) {
var expectedCartesian = Cartographic.toCartesian(Rectangle.center(offscreenRectangle));
expect(cartesian).toEqualEpsilon(expectedCartesian, CesiumMath.EPSILON5);
});

// Call clampToHeight again
expect(scene).toClampToHeightAndCall(function(cartesian) {
var expectedCartesian = Cartesian3.fromRadians(0.0, 0.0);
expect(cartesian).toEqualEpsilon(expectedCartesian, CesiumMath.EPSILON5);
}, cartesian);

// Call pick
expect(scene).toPickPrimitive(offscreenRectanglePrimitive);

// Call clampToHeight again
expect(scene).toClampToHeightAndCall(function(cartesian) {
var expectedCartesian = Cartesian3.fromRadians(0.0, 0.0);
expect(cartesian).toEqualEpsilon(expectedCartesian, CesiumMath.EPSILON5);
}, cartesian);

// Call pickPosition on translucent primitive and returns undefined
offscreenRectanglePrimitive.appearance.material.uniforms.color = new Color(1.0, 0.0, 0.0, 0.5);
scene.renderForSpecs();
expect(scene).toPickPositionAndCall(function(cartesian) {
expect(cartesian).toBeUndefined();
});

// Call clampToHeight again
expect(scene).toClampToHeightAndCall(function(cartesian) {
var expectedCartesian = Cartesian3.fromRadians(0.0, 0.0);
expect(cartesian).toEqualEpsilon(expectedCartesian, CesiumMath.EPSILON5);
}, cartesian);

// Call pickPosition on translucent primitive with pickTranslucentDepth
scene.pickTranslucentDepth = true;
scene.renderForSpecs();
expect(scene).toPickPositionAndCall(function(cartesian) {
var expectedCartesian = Cartographic.toCartesian(Rectangle.center(offscreenRectangle));
expect(cartesian).toEqualEpsilon(expectedCartesian, CesiumMath.EPSILON5);
});
});

}, 'WebGL');
24 changes: 24 additions & 0 deletions Specs/addDefaultMatchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,30 @@ define([
};
},

toPickPositionAndCall : function(util, customEqualityTesters) {
return {
compare : function(actual, expected, x, y) {
var scene = actual;
var canvas = scene.canvas;
x = defaultValue(x, canvas.clientWidth / 2);
y = defaultValue(y, canvas.clientHeight / 2);
var result = scene.pickPosition(new Cartesian2(x, y));

var webglStub = !!window.webglStub;
if (!webglStub) {
// The callback may have expectations that fail, which still makes the
// spec fail, as we desired, even though this matcher sets pass to true.
var callback = expected;
callback(result);
}

return {
pass : true
};
}
};
},

toReadPixels : function(util, customEqualityTesters) {
return {
compare : function(actual, expected) {
Expand Down

0 comments on commit b30ed2e

Please sign in to comment.