diff --git a/CHANGES.md b/CHANGES.md index 449f88a163dc..abb325e9ede4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/Source/Scene/OrthographicOffCenterFrustum.js b/Source/Scene/OrthographicOffCenterFrustum.js index d14053b6ec51..1d84ac5b253f 100644 --- a/Source/Scene/OrthographicOffCenterFrustum.js +++ b/Source/Scene/OrthographicOffCenterFrustum.js @@ -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); diff --git a/Source/Scene/PerspectiveOffCenterFrustum.js b/Source/Scene/PerspectiveOffCenterFrustum.js index fdb5322fe548..fe23401db8cc 100644 --- a/Source/Scene/PerspectiveOffCenterFrustum.js +++ b/Source/Scene/PerspectiveOffCenterFrustum.js @@ -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)) { @@ -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)) { @@ -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)) { @@ -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)) { diff --git a/Source/Scene/SceneTransitioner.js b/Source/Scene/SceneTransitioner.js index e338985fcebf..59866d2ae660 100644 --- a/Source/Scene/SceneTransitioner.js +++ b/Source/Scene/SceneTransitioner.js @@ -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); diff --git a/Specs/Scene/PerspectiveOffCenterFrustumSpec.js b/Specs/Scene/PerspectiveOffCenterFrustumSpec.js index 6cd2b4d653e2..535d919f63e5 100644 --- a/Specs/Scene/PerspectiveOffCenterFrustumSpec.js +++ b/Specs/Scene/PerspectiveOffCenterFrustumSpec.js @@ -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() {