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 can't read x of undefined when getting window coordinates #4022

Merged
merged 2 commits into from
Jun 15, 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
3 changes: 2 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Change Log
* `Clock` now keeps its configuration settings self-consistent. Previously, this was done by `AnimationViewModel` and could become inconsistent in certain cases. [#4007](https://github.com/AnalyticalGraphicsInc/cesium/pull/4007)
* Updated Cardboard Sandcastle example.
* Added the hot air balloon sample model.
* Fix "Cannot read property 'x' of undefined" error when calling SceneTransforms.wgs84ToWindowCoordinates in certain cases. [#4022](https://github.com/AnalyticalGraphicsInc/cesium/pull/4022)

### 1.22.2 - 2016-06-14
* This is an npm only release to fix the improperly published 1.22.1. There were no code changes.
Expand Down Expand Up @@ -42,7 +43,7 @@ Change Log
* Fixed exaggerated terrain tiles disappearing. [#3676](https://github.com/AnalyticalGraphicsInc/cesium/issues/3676)
* Fixed a bug that could cause incorrect normals to be computed for exaggerated terrain, especially for low-detail tiles. [#3904](https://github.com/AnalyticalGraphicsInc/cesium/pull/3904)
* Fixed a bug that was causing errors to be thrown when picking and terrain was enabled. [#3779](https://github.com/AnalyticalGraphicsInc/cesium/issues/3779)
* 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 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)
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [Mike Macaulay](https://github.com/mmacaula)
* [Nathan Schulte](https://github.com/nmschulte)
* [Jed Fong](https://github.com/jedfong)
* [Brandon McAllister](https://github.com/bmcallis)
* [Inovaworks](http://www.inovaworks.com/)
* [Sergio Flores](https://github.com/relfos)
* [CubeWerx Inc.](http://www.cubewerx.com/)
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/SceneTransforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ define([
Cartesian3.clone(cameraPosition, camera.position);
camera.frustum = frustum.clone();

Cartesian2.clone(scratchWindowCoord0, result);
result = Cartesian2.clone(scratchWindowCoord0, result);
if (result.x < 0.0 || result.x > canvas.clientWidth) {
result.x = scratchWindowCoord1.x;
}
Expand Down
16 changes: 16 additions & 0 deletions Specs/Scene/SceneTransformsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,20 @@ defineSuite([
expect(drawingBufferCoordinates.x).toBeLessThan(1.0);
expect(drawingBufferCoordinates.y).toBeLessThan(1.0);
});

it('should not error when zoomed out and in 2D', function(done) {
var scene = createScene();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to create a new scene instead of using the one that was created in the beforeAll block because changes I made to it were impacting other tests. I can update this spec be a little less fragile by creating the scene in the beforeEach instead of just once if that's preferred.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a Scene for this test is fine, but you need to call destroyForSpecs afterwards to release all WebGL resources.

scene.camera.setView({
destination : Cartesian3.fromDegrees(75, 15, 30000000.0)
});

// Update scene state
scene.morphTo2D(0);
scene.renderForSpecs();

var position = Cartesian3.fromDegrees(-80, 25);
var windowCoordinates = SceneTransforms.wgs84ToWindowCoordinates(scene, position);
expect(windowCoordinates).toBeDefined();
scene.destroyForSpecs();
});
}, 'WebGL');