From 065849da83ba89358f4d0c333ce27c78105d4646 Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Wed, 4 May 2016 15:17:41 -0400 Subject: [PATCH 1/7] Fix terrain horizon occlusion point when exaggerated. --- Source/Core/QuantizedMeshTerrainData.js | 2 +- Source/Workers/createVerticesFromQuantizedTerrainMesh.js | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Source/Core/QuantizedMeshTerrainData.js b/Source/Core/QuantizedMeshTerrainData.js index 7e6d741d9d16..43c85f7c2a8c 100644 --- a/Source/Core/QuantizedMeshTerrainData.js +++ b/Source/Core/QuantizedMeshTerrainData.js @@ -305,7 +305,7 @@ define([ var maximumHeight = result.maximumHeight; var boundingSphere = defaultValue(result.boundingSphere, that._boundingSphere); var obb = defaultValue(result.orientedBoundingBox, that._orientedBoundingBox); - var occlusionPoint = defaultValue(result.occludeePointInScaledSpace, that._horizonOcclusionPoint); + var occlusionPoint = that._horizonOcclusionPoint; var stride = result.vertexStride; var terrainEncoding = TerrainEncoding.clone(result.encoding); diff --git a/Source/Workers/createVerticesFromQuantizedTerrainMesh.js b/Source/Workers/createVerticesFromQuantizedTerrainMesh.js index 73450be748fd..76a1a3cb02f6 100644 --- a/Source/Workers/createVerticesFromQuantizedTerrainMesh.js +++ b/Source/Workers/createVerticesFromQuantizedTerrainMesh.js @@ -8,7 +8,6 @@ define([ '../Core/Cartographic', '../Core/defined', '../Core/Ellipsoid', - '../Core/EllipsoidalOccluder', '../Core/IndexDatatype', '../Core/Math', '../Core/Matrix3', @@ -26,7 +25,6 @@ define([ Cartographic, defined, Ellipsoid, - EllipsoidalOccluder, IndexDatatype, CesiumMath, Matrix3, @@ -111,7 +109,6 @@ define([ Cartesian3.maximumByComponent(cartesian3Scratch, maximum, maximum); } - var occludeePointInScaledSpace; var orientedBoundingBox; var boundingSphere; @@ -119,9 +116,6 @@ define([ // Bounding volumes and horizon culling point need to be recomputed since the tile payload assumes no exaggeration. boundingSphere = BoundingSphere.fromPoints(positions); orientedBoundingBox = OrientedBoundingBox.fromRectangle(rectangle, minimumHeight, maximumHeight, ellipsoid); - - var occluder = new EllipsoidalOccluder(ellipsoid); - occludeePointInScaledSpace = occluder.computeHorizonCullingPointFromPoints(center, positions); } var hMin = minimumHeight; @@ -189,7 +183,6 @@ define([ maximumHeight : maximumHeight, boundingSphere : boundingSphere, orientedBoundingBox : orientedBoundingBox, - occludeePointInScaledSpace : occludeePointInScaledSpace, encoding : encoding, skirtIndex : parameters.indices.length }; From c0ee4dad8bdf0577430afbe4c9142fbf9ff087b9 Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Thu, 5 May 2016 13:15:21 -0400 Subject: [PATCH 2/7] Fix 2D in IE/Edge by making sure the viewports are not outside the bounds of the framebuffer. WIP. --- Source/Scene/Scene.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 750f812da421..512fea6f2624 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -1768,32 +1768,32 @@ define([ executeCommandsInViewport(true, scene, passState, backgroundColor, picking); viewport.x += windowCoordinates.x; + viewport.width = context.drawingBufferWidth - windowCoordinates.x; camera.position.x = -camera.position.x; - var right = camera.frustum.right; - camera.frustum.right = -camera.frustum.left; - camera.frustum.left = -right; + camera.frustum.left = -camera.frustum.right; + camera.frustum.right = camera.frustum.left + x; frameState.cullingVolume = camera.frustum.computeCullingVolume(camera.positionWC, camera.directionWC, camera.upWC); context.uniformState.update(frameState); executeCommandsInViewport(false, scene, passState, backgroundColor, picking); } else { - viewport.x += windowCoordinates.x; - viewport.width -= windowCoordinates.x; + viewport.x = windowCoordinates.x; + viewport.width = context.drawingBufferWidth - windowCoordinates.x; camera.frustum.left = -maxCoord.x - x; executeCommandsInViewport(true, scene, passState, backgroundColor, picking); - viewport.x = viewport.x - viewport.width; + viewport.x = 0; + viewport.width = windowCoordinates.x; camera.position.x = -camera.position.x; - var left = camera.frustum.left; - camera.frustum.left = -camera.frustum.right; - camera.frustum.right = -left; + camera.frustum.right = -camera.frustum.left; + camera.frustum.left = camera.frustum.right + x; frameState.cullingVolume = camera.frustum.computeCullingVolume(camera.positionWC, camera.directionWC, camera.upWC); context.uniformState.update(frameState); From cfecbe2811000747d49a3e29594a35d364ebd128 Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Thu, 5 May 2016 13:55:28 -0400 Subject: [PATCH 3/7] Fix zooming. --- Source/Scene/Scene.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 512fea6f2624..8796ce7de157 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -1763,6 +1763,7 @@ define([ } else if (windowCoordinates.x > context.drawingBufferWidth * 0.5) { viewport.width = windowCoordinates.x; + var right = camera.frustum.right; camera.frustum.right = maxCoord.x - x; executeCommandsInViewport(true, scene, passState, backgroundColor, picking); @@ -1773,7 +1774,7 @@ define([ camera.position.x = -camera.position.x; camera.frustum.left = -camera.frustum.right; - camera.frustum.right = camera.frustum.left + x; + camera.frustum.right = camera.frustum.left + (right - camera.frustum.right); frameState.cullingVolume = camera.frustum.computeCullingVolume(camera.positionWC, camera.directionWC, camera.upWC); context.uniformState.update(frameState); @@ -1783,6 +1784,7 @@ define([ viewport.x = windowCoordinates.x; viewport.width = context.drawingBufferWidth - windowCoordinates.x; + var left = camera.frustum.left; camera.frustum.left = -maxCoord.x - x; executeCommandsInViewport(true, scene, passState, backgroundColor, picking); @@ -1793,7 +1795,8 @@ define([ camera.position.x = -camera.position.x; camera.frustum.right = -camera.frustum.left; - camera.frustum.left = camera.frustum.right + x; + camera.frustum.left = camera.frustum.right + (left - camera.frustum.left); + frameState.cullingVolume = camera.frustum.computeCullingVolume(camera.positionWC, camera.directionWC, camera.upWC); context.uniformState.update(frameState); From c9e08f6fb9aadf60580013f61d817fe2a746566f Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Thu, 5 May 2016 14:03:35 -0400 Subject: [PATCH 4/7] Update CHANGES.md. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index f4208c98e327..00f013fafa79 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ Change Log * Fixed issue causing the fog to go dark and the atmosphere to flicker when the camera clips the globe. [#3178](https://github.com/AnalyticalGraphicsInc/cesium/issues/3178) * Fixed a bug that caused an exception and rendering to stop when using `ArcGisMapServerImageryProvider` to connect to a MapServer specifying the Web Mercator projection and a fullExtent bigger than the valid extent of the projection. [#3854](https://github.com/AnalyticalGraphicsInc/cesium/pull/3854) * Fixed issue causing an exception when switching scene modes with an active KML network link. [#3865](https://github.com/AnalyticalGraphicsInc/cesium/issues/3865) +* Fixed infinite horizontal 2D scrolling in IE/Edge. [#3893](https://github.com/AnalyticalGraphicsInc/cesium/issues/3893) ### 1.20 - 2016-04-01 From 72c18a189877b2c93edfca35eafc780d4a0218ff Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Mon, 9 May 2016 13:51:57 -0400 Subject: [PATCH 5/7] Remove duplicate code. --- Source/Core/EllipsoidalOccluder.js | 42 --------------------------- Source/Core/HeightmapTessellator.js | 2 +- Specs/Core/EllipsoidalOccluderSpec.js | 35 ---------------------- 3 files changed, 1 insertion(+), 78 deletions(-) diff --git a/Source/Core/EllipsoidalOccluder.js b/Source/Core/EllipsoidalOccluder.js index 1f95bad9631b..ae0d355c4fe1 100644 --- a/Source/Core/EllipsoidalOccluder.js +++ b/Source/Core/EllipsoidalOccluder.js @@ -238,48 +238,6 @@ define([ return magnitudeToPoint(scaledSpaceDirectionToPoint, resultMagnitude, result); }; - /** - * Computes a point that can be used for horizon culling from a list of positions. If the point is below - * the horizon, all of the positions are guaranteed to be below the horizon as well. The returned point - * is expressed in the ellipsoid-scaled space and is suitable for use with - * {@link EllipsoidalOccluder#isScaledSpacePointVisible}. - * - * @param {Cartesian3} directionToPoint The direction that the computed point will lie along. - * A reasonable direction to use is the direction from the center of the ellipsoid to - * the center of the bounding sphere computed from the positions. The direction need not - * be normalized. - * @param {Cartesian3[]} points The vertices from which to compute the horizon culling point. The positions - * must be expressed in a reference frame centered at the ellipsoid and aligned with the - * ellipsoid's axes. - * @param {Cartesian3} [result] The instance on which to store the result instead of allocating a new instance. - * @returns {Cartesian3} The computed horizon culling point, expressed in the ellipsoid-scaled space. - */ - EllipsoidalOccluder.prototype.computeHorizonCullingPointFromPoints = function(directionToPoint, points, result) { - //>>includeStart('debug', pragmas.debug); - if (!defined(directionToPoint)) { - throw new DeveloperError('directionToPoint is required'); - } - if (!defined(points)) { - throw new DeveloperError('points is required'); - } - //>>includeEnd('debug'); - - if (!defined(result)) { - result = new Cartesian3(); - } - - var ellipsoid = this._ellipsoid; - var scaledSpaceDirectionToPoint = computeScaledSpaceDirectionToPoint(ellipsoid, directionToPoint); - var resultMagnitude = 0.0; - - for (var i = 0, len = points.length; i < len; ++i) { - var candidateMagnitude = computeMagnitude(ellipsoid, points[i], scaledSpaceDirectionToPoint); - resultMagnitude = Math.max(resultMagnitude, candidateMagnitude); - } - - return magnitudeToPoint(scaledSpaceDirectionToPoint, resultMagnitude, result); - }; - var subsampleScratch = []; /** diff --git a/Source/Core/HeightmapTessellator.js b/Source/Core/HeightmapTessellator.js index f2a5f62f7450..fbb28c43ebb7 100644 --- a/Source/Core/HeightmapTessellator.js +++ b/Source/Core/HeightmapTessellator.js @@ -365,7 +365,7 @@ define([ var center = options.relativetoCenter; if (defined(center)) { var occluder = new EllipsoidalOccluder(ellipsoid); - occludeePointInScaledSpace = occluder.computeHorizonCullingPointFromPoints(center, positions); + occludeePointInScaledSpace = occluder.computeHorizonCullingPoint(center, positions); } var aaBox = new AxisAlignedBoundingBox(minimum, maximum, relativeToCenter); diff --git a/Specs/Core/EllipsoidalOccluderSpec.js b/Specs/Core/EllipsoidalOccluderSpec.js index 72ee15ffa258..5e803dbd1858 100644 --- a/Specs/Core/EllipsoidalOccluderSpec.js +++ b/Specs/Core/EllipsoidalOccluderSpec.js @@ -255,41 +255,6 @@ defineSuite([ }); }); - describe('computeHorizonCullingPointFromPoints', function() { - it('requires directionToPointand points', function() { - var ellipsoid = new Ellipsoid(12345.0, 12345.0, 12345.0); - var ellipsoidalOccluder = new EllipsoidalOccluder(ellipsoid); - - var positions = [new Cartesian3(-12345.0, 12345.0, 12345.0), new Cartesian3(-12346.0, 12345.0, 12345.0), new Cartesian3(-12446.0, 12445.0, 12445.0)]; - var boundingSphere = BoundingSphere.fromPoints(positions); - - ellipsoidalOccluder.computeHorizonCullingPointFromPoints(boundingSphere.center, positions); - - expect(function() { - ellipsoidalOccluder.computeHorizonCullingPointFromPoints(undefined, positions); - }).toThrowDeveloperError(); - - expect(function() { - ellipsoidalOccluder.computeHorizonCullingPointFromPoints(boundingSphere.center, undefined); - }).toThrowDeveloperError(); - }); - - it('produces same answers as computeHorizonCullingPoint', function() { - var ellipsoid = new Ellipsoid(12345.0, 12345.0, 12345.0); - var ellipsoidalOccluder = new EllipsoidalOccluder(ellipsoid); - - var positions = [new Cartesian3(-12345.0, 12345.0, 12345.0), new Cartesian3(-12346.0, 12345.0, 12345.0), new Cartesian3(-12446.0, 12445.0, 12445.0)]; - var boundingSphere = BoundingSphere.fromPoints(positions); - - var result1 = ellipsoidalOccluder.computeHorizonCullingPoint(boundingSphere.center, positions); - var result2 = ellipsoidalOccluder.computeHorizonCullingPointFromPoints(boundingSphere.center, positions); - - expect(result1.x).toEqualEpsilon(result2.x, CesiumMath.EPSILON14); - expect(result1.y).toEqualEpsilon(result2.y, CesiumMath.EPSILON14); - expect(result1.z).toEqualEpsilon(result2.z, CesiumMath.EPSILON14); - }); - }); - describe('computeHorizonCullingPointFromRectangle', function() { it('returns undefined for global rectangle', function() { var ellipsoid = new Ellipsoid(12345.0, 12345.0, 12345.0); From 7f7d8e004f9ae8cc7aca1386348b5357fe9c4001 Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Mon, 9 May 2016 14:10:58 -0400 Subject: [PATCH 6/7] Update CHANGES.md. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index f4208c98e327..fcede0bc4877 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ Change Log * Fixed issue causing the fog to go dark and the atmosphere to flicker when the camera clips the globe. [#3178](https://github.com/AnalyticalGraphicsInc/cesium/issues/3178) * Fixed a bug that caused an exception and rendering to stop when using `ArcGisMapServerImageryProvider` to connect to a MapServer specifying the Web Mercator projection and a fullExtent bigger than the valid extent of the projection. [#3854](https://github.com/AnalyticalGraphicsInc/cesium/pull/3854) * Fixed issue causing an exception when switching scene modes with an active KML network link. [#3865](https://github.com/AnalyticalGraphicsInc/cesium/issues/3865) +* Fixed exaggerated terrain tiles disappearing. [#3676](https://github.com/AnalyticalGraphicsInc/cesium/issues/3676) ### 1.20 - 2016-04-01 From 3ac3568b26f11b06c470fef3392ee1c321fc1922 Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Mon, 9 May 2016 15:26:42 -0400 Subject: [PATCH 7/7] Fix failing sun tests with WebGL validation on. --- Source/Scene/Sun.js | 2 +- Source/Scene/SunPostProcess.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Scene/Sun.js b/Source/Scene/Sun.js index 6837cc21e2db..628a4c233386 100644 --- a/Source/Scene/Sun.js +++ b/Source/Scene/Sun.js @@ -178,7 +178,7 @@ define([ this._glowFactorDirty = false; var size = Math.max(drawingBufferWidth, drawingBufferHeight); - size = Math.pow(2.0, Math.ceil(Math.log(size) / Math.log(2.0)) - 2.0); + size = Math.max(1.0, Math.pow(2.0, Math.ceil(Math.log(size) / Math.log(2.0)) - 2.0)); this._texture = new Texture({ context : context, diff --git a/Source/Scene/SunPostProcess.js b/Source/Scene/SunPostProcess.js index 1dd0304ef198..67b79a48f9f5 100644 --- a/Source/Scene/SunPostProcess.js +++ b/Source/Scene/SunPostProcess.js @@ -215,7 +215,7 @@ define([ var downSampleWidth = Math.pow(2.0, Math.ceil(Math.log(width) / Math.log(2)) - 2.0); var downSampleHeight = Math.pow(2.0, Math.ceil(Math.log(height) / Math.log(2)) - 2.0); - var downSampleSize = Math.max(downSampleWidth, downSampleHeight); + var downSampleSize = Math.max(1.0, Math.max(downSampleWidth, downSampleHeight)); var downSampleViewport = downSampleViewportBoundingRectangle; downSampleViewport.width = downSampleSize;