diff --git a/CHANGES.md b/CHANGES.md index 20e2c16554f3..4ea7b3772340 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/Source/Scene/Billboard.js b/Source/Scene/Billboard.js index d43ea94be474..0c3669135de9 100644 --- a/Source/Scene/Billboard.js +++ b/Source/Scene/Billboard.js @@ -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; @@ -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; }; diff --git a/Source/Scene/Label.js b/Source/Scene/Label.js index 8856f347c68e..19adaf37bb00 100644 --- a/Source/Scene/Label.js +++ b/Source/Scene/Label.js @@ -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; }; diff --git a/Specs/Scene/BillboardCollectionSpec.js b/Specs/Scene/BillboardCollectionSpec.js index 7bd99ab5b89f..ec1826699959 100644 --- a/Specs/Scene/BillboardCollectionSpec.js +++ b/Specs/Scene/BillboardCollectionSpec.js @@ -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() { diff --git a/Specs/Scene/LabelCollectionSpec.js b/Specs/Scene/LabelCollectionSpec.js index 070a3de363f5..71ce3639851f 100644 --- a/Specs/Scene/LabelCollectionSpec.js +++ b/Specs/Scene/LabelCollectionSpec.js @@ -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() {