Skip to content

Commit

Permalink
Merge pull request #3976 from AnalyticalGraphicsInc/billboard-screen-…
Browse files Browse the repository at this point in the history
…space-position

Fix Billboard.computeScreenSpacePosition
  • Loading branch information
pjcozzi committed May 30, 2016
2 parents bd3ddef + 49642d3 commit 269d14e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Change Log
* Fixed infinite horizontal 2D scrolling in IE/Edge. [#3893](https://github.com/AnalyticalGraphicsInc/cesium/issues/3893)
* Fixed a bug that would cause a crash is the camera was on the IDL in 2D. [#3951](https://github.com/AnalyticalGraphicsInc/cesium/issues/3951)
* Fixed issue where a repeating model animation doesn't play when the clock is set to a time before the model was created. [#3932](https://github.com/AnalyticalGraphicsInc/cesium/issues/3932)
* Fixed `Billboard.computeScreenSpacePosition` returning the wrong y coordinate. [#3920](https://github.com/AnalyticalGraphicsInc/cesium/issues/3920)
* Fixed issue where labels were disappearing. [#3730](https://github.com/AnalyticalGraphicsInc/cesium/issues/3730)
* Fixed issue where billboards on terrain didn't always update when the terrain provider was changed. [#3921](https://github.com/AnalyticalGraphicsInc/cesium/issues/3921)
* Fixed issue where `Matrix4.fromCamera` was taking eye/target instead of position/direction. [#3927](https://github.com/AnalyticalGraphicsInc/cesium/issues/3927)
Expand Down
2 changes: 0 additions & 2 deletions Source/Scene/Billboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,6 @@ define([

// Apply pixel offset
pixelOffset = Cartesian2.clone(pixelOffset, scratchComputePixelOffset);
pixelOffset.y = -pixelOffset.y;
var po = Cartesian2.multiplyByScalar(pixelOffset, scene.context.uniformState.resolutionScale, scratchCartesian2);
positionWC.x += po.x;
positionWC.y += po.y;
Expand Down Expand Up @@ -1150,7 +1149,6 @@ define([

var windowCoordinates = Billboard._computeScreenSpacePosition(modelMatrix, actualPosition,
this._eyeOffset, scratchPixelOffset, scene, result);
windowCoordinates.y = scene.canvas.clientHeight - windowCoordinates.y;
return windowCoordinates;
};

Expand Down
3 changes: 1 addition & 2 deletions Source/Scene/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,10 @@ define([

var labelCollection = this._labelCollection;
var modelMatrix = labelCollection.modelMatrix;
var actualPosition = Billboard._computeActualPosition(this, this._position, scene.frameState, modelMatrix);
var actualPosition = defined(this._actualClampedPosition) ? this._actualClampedPosition : this._position;

var windowCoordinates = Billboard._computeScreenSpacePosition(modelMatrix, actualPosition,
this._eyeOffset, this._pixelOffset, scene, result);
windowCoordinates.y = scene.canvas.clientHeight - windowCoordinates.y;
return windowCoordinates;
};

Expand Down
4 changes: 2 additions & 2 deletions Specs/Scene/BillboardCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1020,10 +1020,10 @@ defineSuite([
it('computes screen space position with pixelOffset', function() {
var b = billboards.add({
position : Cartesian3.ZERO,
pixelOffset : new Cartesian2(1.0, 2.0)
pixelOffset : new Cartesian2(0.5, 0.5)
});
scene.renderForSpecs();
expect(b.computeScreenSpacePosition(scene)).toEqualEpsilon(new Cartesian2(1.5, 2.5), CesiumMath.EPSILON1);
expect(b.computeScreenSpacePosition(scene)).toEqualEpsilon(new Cartesian2(1, 1.0), CesiumMath.EPSILON1);
});

it('computes screen space position with eyeOffset', function() {
Expand Down
4 changes: 2 additions & 2 deletions Specs/Scene/LabelCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,10 +801,10 @@ defineSuite([
var label = labels.add({
text : 'abc',
position : Cartesian3.ZERO,
pixelOffset : new Cartesian2(1.0, 2.0)
pixelOffset : new Cartesian2(0.5, 0.5)
});
scene.renderForSpecs();
expect(label.computeScreenSpacePosition(scene)).toEqualEpsilon(new Cartesian2(1.5, 2.5), CesiumMath.EPSILON1);
expect(label.computeScreenSpacePosition(scene)).toEqualEpsilon(new Cartesian2(1.0, 1.0), CesiumMath.EPSILON1);
});

it('can compute screen space position with eyeOffset', function() {
Expand Down

0 comments on commit 269d14e

Please sign in to comment.