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 morph crash from Columbus view to 3D #5312

Merged
merged 5 commits into from
May 18, 2017
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 @@ -11,6 +11,7 @@ Change Log
* Fixed bug where polylines would not update when `PolylineCollection` model matrix was updated [#5327](https://github.com/AnalyticalGraphicsInc/cesium/pull/5327)
* Fixed translucency bug for certain material types [#5335](https://github.com/AnalyticalGraphicsInc/cesium/pull/5335)
* Fix picking polylines that use a depth fail appearance. [#5337](https://github.com/AnalyticalGraphicsInc/cesium/pull/5337)
* Fixed a crash when morphing from Columbus view to 3D. [#5311](https://github.com/AnalyticalGraphicsInc/cesium/issues/5311)

### 1.33 - 2017-05-01

Expand Down
1 change: 1 addition & 0 deletions Source/Scene/OrthographicOffCenterFrustum.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ define([
var f = this.far;

var right = Cartesian3.cross(direction, up, getPlanesRight);
Cartesian3.normalize(right, right);
var nearCenter = getPlanesNearCenter;
Cartesian3.multiplyByScalar(direction, n, nearCenter);
Cartesian3.add(position, nearCenter, nearCenter);
Expand Down
7 changes: 4 additions & 3 deletions Source/Scene/PerspectiveOffCenterFrustum.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ define([
Cartesian3.subtract(normal, position, normal);
Cartesian3.normalize(normal, normal);
Cartesian3.cross(normal, up, normal);
Cartesian3.normalize(normal, normal);

var plane = planes[0];
if (!defined(plane)) {
Expand All @@ -234,8 +235,8 @@ define([
Cartesian3.multiplyByScalar(right, r, normal);
Cartesian3.add(nearCenter, normal, normal);
Cartesian3.subtract(normal, position, normal);
Cartesian3.normalize(normal, normal);
Cartesian3.cross(up, normal, normal);
Cartesian3.normalize(normal, normal);

plane = planes[1];
if (!defined(plane)) {
Expand All @@ -250,8 +251,8 @@ define([
Cartesian3.multiplyByScalar(up, b, normal);
Cartesian3.add(nearCenter, normal, normal);
Cartesian3.subtract(normal, position, normal);
Cartesian3.normalize(normal, normal);
Cartesian3.cross(right, normal, normal);
Cartesian3.normalize(normal, normal);

plane = planes[2];
if (!defined(plane)) {
Expand All @@ -266,8 +267,8 @@ define([
Cartesian3.multiplyByScalar(up, t, normal);
Cartesian3.add(nearCenter, normal, normal);
Cartesian3.subtract(normal, position, normal);
Cartesian3.normalize(normal, normal);
Cartesian3.cross(normal, right, normal);
Cartesian3.normalize(normal, normal);

plane = planes[3];
if (!defined(plane)) {
Expand Down
23 changes: 11 additions & 12 deletions Source/Scene/SceneTransitioner.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,19 @@ define([
Cartesian3.clone(Cartesian3.UNIT_Z, camera3D.up);
} else {
camera3D = getColumbusViewTo3DCamera(this, ellipsoid);
}

var frustum;
if (this._morphToOrthographic) {
var camera = scene.camera;
frustum = scratch2DTo3DFrustumOrtho;
frustum.aspectRatio = scene.drawingBufferWidth / scene.drawingBufferHeight;
frustum.width = camera.frustum.right - camera.frustum.left;
} else {
frustum = scratch2DTo3DFrustumPersp;
frustum.aspectRatio = scene.drawingBufferWidth / scene.drawingBufferHeight;
frustum.fov = CesiumMath.toRadians(60.0);
}
camera3D.frustum = frustum;
var frustum;
var camera = scene.camera;
if (camera.frustum instanceof OrthographicFrustum) {
frustum = camera.frustum.clone();
} else {
frustum = scratch2DTo3DFrustumPersp;
frustum.aspectRatio = scene.drawingBufferWidth / scene.drawingBufferHeight;
frustum.fov = CesiumMath.toRadians(60.0);
}
camera3D.frustum = frustum;

var complete = complete3DCallback(camera3D);
createMorphHandler(this, complete);

Expand Down
12 changes: 6 additions & 6 deletions Specs/Scene/PerspectiveOffCenterFrustumSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,40 +64,40 @@ defineSuite([
var leftPlane = planes[0];
var x = 1.0 / Math.sqrt(2.0);
var expectedResult = new Cartesian4(x, 0.0, -x, 0.0);
expect(leftPlane).toEqual(expectedResult);
expect(leftPlane).toEqualEpsilon(expectedResult, CesiumMath.EPSILON15);
});

it('get frustum right plane', function() {
var rightPlane = planes[1];
var x = 1.0 / Math.sqrt(2.0);
var expectedResult = new Cartesian4(-x, 0.0, -x, 0.0);
expect(rightPlane).toEqual(expectedResult);
expect(rightPlane).toEqualEpsilon(expectedResult, CesiumMath.EPSILON15);
});

it('get frustum bottom plane', function() {
var bottomPlane = planes[2];
var x = 1.0 / Math.sqrt(2.0);
var expectedResult = new Cartesian4(0.0, x, -x, 0.0);
expect(bottomPlane).toEqual(expectedResult);
expect(bottomPlane).toEqualEpsilon(expectedResult, CesiumMath.EPSILON15);
});

it('get frustum top plane', function() {
var topPlane = planes[3];
var x = 1.0 / Math.sqrt(2.0);
var expectedResult = new Cartesian4(0.0, -x, -x, 0.0);
expect(topPlane).toEqual(expectedResult);
expect(topPlane).toEqualEpsilon(expectedResult, CesiumMath.EPSILON15);
});

it('get frustum near plane', function() {
var nearPlane = planes[4];
var expectedResult = new Cartesian4(0.0, 0.0, -1.0, -1.0);
expect(nearPlane).toEqual(expectedResult);
expect(nearPlane).toEqualEpsilon(expectedResult, CesiumMath.EPSILON15);
});

it('get frustum far plane', function() {
var farPlane = planes[5];
var expectedResult = new Cartesian4(0.0, 0.0, 1.0, 2.0);
expect(farPlane).toEqual(expectedResult);
expect(farPlane).toEqualEpsilon(expectedResult, CesiumMath.EPSILON15);
});

it('get perspective projection matrix', function() {
Expand Down