Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Billboard.computeScreenSpacePosition #3976

Merged
merged 3 commits into from
May 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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