From 38f7e25f5d29e0c9114104bc57f8a42dfb41af9f Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Fri, 27 May 2016 15:13:15 -0400 Subject: [PATCH 1/2] Swap screen space position y coordinate so it increases from top to bottom. Also fix the calculation in 2D for labels. --- Source/Scene/Billboard.js | 2 -- Source/Scene/Label.js | 3 +-- Specs/Scene/BillboardCollectionSpec.js | 4 ++-- Specs/Scene/LabelCollectionSpec.js | 4 ++-- 4 files changed, 5 insertions(+), 8 deletions(-) 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() { From 59f4f1ba942f1cc36f2aafcd3d977d2eafae6b4b Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Sat, 28 May 2016 17:57:57 -0400 Subject: [PATCH 2/2] Update CHANGES.md. --- CHANGES.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 8913bcf7cd08..20a00ae2ee16 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -26,7 +26,8 @@ Change Log * 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) * Added `Scene.nearToFarDistance2D` that determines the size of each frustum of the multifrustum in 2D. * Added support for rendering models in 2D and Columbus view. -* Fixed a bug that was causing the atmosphere to disappear when only atmosphere is visible. [#3347](https://github.com/AnalyticalGraphicsInc/cesium/issues/3347) +* Fixed a bug that was causing the atmosphere to disappear when only atmosphere is visible. [#3347](https://github.com/AnalyticalGraphicsInc/cesium/issues/3347) +* Fixed `Billboard.computeScreenSpacePosition` returning the wrong y coordinate. [#3920](https://github.com/AnalyticalGraphicsInc/cesium/issues/3920) ### 1.21 - 2016-05-02