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 1 commit
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 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
15 changes: 15 additions & 0 deletions Specs/Scene/SceneTransformsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,19 @@ 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();
});
}, 'WebGL');