From 49557739600841a1c6c7265fb55eb17c24d38826 Mon Sep 17 00:00:00 2001 From: Ian Lilley Date: Fri, 27 Aug 2021 13:47:22 -0400 Subject: [PATCH 1/5] remove deprecated terrain exaggeration --- CHANGES.md | 4 +++ Source/Scene/Scene.js | 36 --------------------- Source/Widgets/CesiumWidget/CesiumWidget.js | 8 ----- Source/Widgets/Viewer/Viewer.js | 1 - 4 files changed, 4 insertions(+), 45 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 02100fb62bdd..c24e13c29fac 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,10 @@ ### 1.85 - 2021-09-01 +##### Breaking Changes :mega: + +- Removed `Scene.terrainExaggeration` and `options.terrainExaggeration` for `CesiumWidget`, `Viewer`, and `Scene`, which were deprecated in CesiumJS 1.82. Use `Globe.terrainExaggeration` instead. + ##### Additions :tada: - `BingMapsGeocoderService` now takes an optional [Culture Code](https://docs.microsoft.com/en-us/bingmaps/rest-services/common-parameters-and-types/supported-culture-codes) for localizing results. diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 4af275c2b174..17f8a2179e9d 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -613,14 +613,6 @@ function Scene(options) { this._brdfLutGenerator = new BrdfLutGenerator(); - if (defined(options.terrainExaggeration)) { - deprecationWarning( - "terrainExaggeration-removed", - "terrainExaggeration is now a property of Globe" - ); - } - this._terrainExaggeration = defaultValue(options.terrainExaggeration, 1.0); - this._performanceDisplay = undefined; this._debugVolume = undefined; @@ -1437,34 +1429,6 @@ Object.defineProperties(Scene.prototype, { }, }, - /** - * Gets or sets the scalar used to exaggerate the terrain. - * @memberof Scene.prototype - * @type {Number} - */ - terrainExaggeration: { - get: function () { - deprecationWarning( - "terrainExaggeration-removed", - "terrainExaggeration is now a property of Globe" - ); - if (defined(this.globe)) { - return this.globe.terrainExaggeration; - } - return this._terrainExaggeration; - }, - set: function (value) { - deprecationWarning( - "terrainExaggeration-removed", - "terrainExaggeration is now a property of Globe" - ); - if (defined(this.globe)) { - this.globe.terrainExaggeration = value; - } - this._terrainExaggeration = value; - }, - }, - /** * When true, splits the scene into two viewports with steroscopic views for the left and right eyes. * Used for cardboard and WebVR. diff --git a/Source/Widgets/CesiumWidget/CesiumWidget.js b/Source/Widgets/CesiumWidget/CesiumWidget.js index 3aca92c9c9f5..40854f54204c 100644 --- a/Source/Widgets/CesiumWidget/CesiumWidget.js +++ b/Source/Widgets/CesiumWidget/CesiumWidget.js @@ -271,7 +271,6 @@ function CesiumWidget(container, options) { mapProjection: options.mapProjection, orderIndependentTranslucency: options.orderIndependentTranslucency, scene3DOnly: defaultValue(options.scene3DOnly, false), - terrainExaggeration: options.terrainExaggeration, shadows: options.shadows, mapMode2D: options.mapMode2D, requestRenderMode: options.requestRenderMode, @@ -293,13 +292,6 @@ function CesiumWidget(container, options) { if (!defined(globe)) { globe = new Globe(ellipsoid); } - if (defined(options.terrainExaggeration)) { - deprecationWarning( - "terrainExaggeration-removed", - "terrainExaggeration is now a property of Globe" - ); - globe.terrainExaggeration = options.terrainExaggeration; - } if (globe !== false) { scene.globe = globe; scene.globe.shadows = defaultValue( diff --git a/Source/Widgets/Viewer/Viewer.js b/Source/Widgets/Viewer/Viewer.js index 5def0611aceb..90f9d8c00d6c 100644 --- a/Source/Widgets/Viewer/Viewer.js +++ b/Source/Widgets/Viewer/Viewer.js @@ -499,7 +499,6 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to : bottomContainer, creditViewport: options.creditViewport, scene3DOnly: scene3DOnly, - terrainExaggeration: options.terrainExaggeration, shadows: options.shadows, terrainShadows: options.terrainShadows, mapMode2D: options.mapMode2D, From bc8a8a6d19f1ac250ca911927562417675681046 Mon Sep 17 00:00:00 2001 From: Ian Lilley Date: Sun, 29 Aug 2021 12:52:27 -0400 Subject: [PATCH 2/5] removed deprecation warning include --- Source/Scene/Scene.js | 1 - Source/Widgets/CesiumWidget/CesiumWidget.js | 1 - 2 files changed, 2 deletions(-) diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 17f8a2179e9d..63ec70e992be 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -10,7 +10,6 @@ import createGuid from "../Core/createGuid.js"; import CullingVolume from "../Core/CullingVolume.js"; import defaultValue from "../Core/defaultValue.js"; import defined from "../Core/defined.js"; -import deprecationWarning from "../Core/deprecationWarning.js"; import destroyObject from "../Core/destroyObject.js"; import DeveloperError from "../Core/DeveloperError.js"; import EllipsoidGeometry from "../Core/EllipsoidGeometry.js"; diff --git a/Source/Widgets/CesiumWidget/CesiumWidget.js b/Source/Widgets/CesiumWidget/CesiumWidget.js index 40854f54204c..0dad2aaa0642 100644 --- a/Source/Widgets/CesiumWidget/CesiumWidget.js +++ b/Source/Widgets/CesiumWidget/CesiumWidget.js @@ -3,7 +3,6 @@ import Cartesian3 from "../../Core/Cartesian3.js"; import Clock from "../../Core/Clock.js"; import defaultValue from "../../Core/defaultValue.js"; import defined from "../../Core/defined.js"; -import deprecationWarning from "../../Core/deprecationWarning.js"; import destroyObject from "../../Core/destroyObject.js"; import DeveloperError from "../../Core/DeveloperError.js"; import Ellipsoid from "../../Core/Ellipsoid.js"; From 6583b890ea4c0968f5dc2b2fd95557c112564f27 Mon Sep 17 00:00:00 2001 From: Ian Lilley Date: Sun, 29 Aug 2021 13:29:04 -0400 Subject: [PATCH 3/5] don't check exaggeration after more than one frame --- Source/Scene/GlobeSurfaceTile.js | 48 +++++++++++++++++++++ Source/Scene/GlobeSurfaceTileProvider.js | 54 ++---------------------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/Source/Scene/GlobeSurfaceTile.js b/Source/Scene/GlobeSurfaceTile.js index 1e2a2f34ccde..4f40eb4168ce 100644 --- a/Source/Scene/GlobeSurfaceTile.js +++ b/Source/Scene/GlobeSurfaceTile.js @@ -450,6 +450,54 @@ GlobeSurfaceTile.prototype.removeGeodeticSurfaceNormals = function ( toggleGeodeticSurfaceNormals(this, false, undefined, frameState); }; +GlobeSurfaceTile.prototype.updateExaggeration = function ( + tile, + frameState, + quadtree +) { + var surfaceTile = this; + var mesh = surfaceTile.renderedMesh; + if (mesh === undefined) { + return; + } + + // Check the tile's terrain encoding to see if it has been exaggerated yet + var exaggeration = frameState.terrainExaggeration; + var exaggerationRelativeHeight = frameState.terrainExaggerationRelativeHeight; + var hasExaggerationScale = exaggeration !== 1.0; + + var encoding = mesh.encoding; + var encodingExaggerationScaleChanged = encoding.exaggeration !== exaggeration; + var encodingRelativeHeightChanged = + encoding.exaggerationRelativeHeight !== exaggerationRelativeHeight; + + if (encodingExaggerationScaleChanged || encodingRelativeHeightChanged) { + // Turning exaggeration scale on/off requires adding or removing geodetic surface normals + // Relative height only translates, so it has no effect on normals + if (encodingExaggerationScaleChanged) { + if (hasExaggerationScale && !encoding.hasGeodeticSurfaceNormals) { + var ellipsoid = tile.tilingScheme.ellipsoid; + surfaceTile.addGeodeticSurfaceNormals(ellipsoid, frameState); + } else if (!hasExaggerationScale && encoding.hasGeodeticSurfaceNormals) { + surfaceTile.removeGeodeticSurfaceNormals(frameState); + } + } + + encoding.exaggeration = exaggeration; + encoding.exaggerationRelativeHeight = exaggerationRelativeHeight; + + // Notify the quadtree that this tile's height has changed + quadtree._tileToUpdateHeights.push(tile); + var customData = tile.customData; + var customDataLength = customData.length; + for (var i = 0; i < customDataLength; i++) { + // Restart the level so that a height update is triggered + var data = customData[i]; + data.level = -1; + } + } +}; + function prepareNewTile(tile, terrainProvider, imageryLayerCollection) { var available = terrainProvider.getTileDataAvailable( tile.x, diff --git a/Source/Scene/GlobeSurfaceTileProvider.js b/Source/Scene/GlobeSurfaceTileProvider.js index 37c6834ce889..926e75b663e6 100644 --- a/Source/Scene/GlobeSurfaceTileProvider.js +++ b/Source/Scene/GlobeSurfaceTileProvider.js @@ -178,7 +178,6 @@ function GlobeSurfaceTileProvider(options) { this._oldTerrainExaggeration = undefined; this._oldTerrainExaggerationRelativeHeight = undefined; - this._processingTerrainExaggerationChange = false; } Object.defineProperties(GlobeSurfaceTileProvider.prototype, { @@ -480,7 +479,6 @@ GlobeSurfaceTileProvider.prototype.endUpdate = function (frameState) { var quadtree = this.quadtree; var exaggeration = frameState.terrainExaggeration; var exaggerationRelativeHeight = frameState.terrainExaggerationRelativeHeight; - var hasExaggerationScale = exaggeration !== 1.0; var exaggerationChanged = this._oldTerrainExaggeration !== exaggeration || this._oldTerrainExaggerationRelativeHeight !== exaggerationRelativeHeight; @@ -489,59 +487,13 @@ GlobeSurfaceTileProvider.prototype.endUpdate = function (frameState) { this._oldTerrainExaggeration = exaggeration; this._oldTerrainExaggerationRelativeHeight = exaggerationRelativeHeight; - var processingChange = - exaggerationChanged || this._processingTerrainExaggerationChange; - var continueProcessing = false; - - if (processingChange) { - quadtree.forEachRenderedTile(function (tile) { + if (exaggerationChanged) { + quadtree.forEachLoadedTile(function (tile) { var surfaceTile = tile.data; - var mesh = surfaceTile.renderedMesh; - if (mesh !== undefined) { - // Check the tile's terrain encoding to see if it has been exaggerated yet - var encoding = mesh.encoding; - var encodingExaggerationScaleChanged = - encoding.exaggeration !== exaggeration; - var encodingRelativeHeightChanged = - encoding.exaggerationRelativeHeight !== exaggerationRelativeHeight; - - if (encodingExaggerationScaleChanged || encodingRelativeHeightChanged) { - // Turning exaggeration scale on/off requires adding or removing geodetic surface normals - // Relative height only translates, so it has no effect on normals - if (encodingExaggerationScaleChanged) { - if (hasExaggerationScale && !encoding.hasGeodeticSurfaceNormals) { - var ellipsoid = tile.tilingScheme.ellipsoid; - surfaceTile.addGeodeticSurfaceNormals(ellipsoid, frameState); - } else if ( - !hasExaggerationScale && - encoding.hasGeodeticSurfaceNormals - ) { - surfaceTile.removeGeodeticSurfaceNormals(frameState); - } - } - - encoding.exaggeration = exaggeration; - encoding.exaggerationRelativeHeight = exaggerationRelativeHeight; - - // Notify the quadtree that this tile's height has changed - quadtree._tileToUpdateHeights.push(tile); - var customData = tile.customData; - var customDataLength = customData.length; - for (var i = 0; i < customDataLength; i++) { - // Restart the level so that a height update is triggered - var data = customData[i]; - data.level = -1; - } - } - } else { - // this tile may come into view at a later time so keep the loop active - continueProcessing = true; - } + surfaceTile.updateExaggeration(tile, frameState, quadtree); }); } - this._processingTerrainExaggerationChange = continueProcessing; - // Add the tile render commands to the command list, sorted by texture count. var tilesToRenderByTextureCount = this._tilesToRenderByTextureCount; for ( From 1d729ad87866ed2327b132a1dc169b4324019d27 Mon Sep 17 00:00:00 2001 From: Ian Lilley Date: Sun, 29 Aug 2021 15:43:19 -0400 Subject: [PATCH 4/5] fixed recently loaded tiles with wrong exaggeration --- Source/Scene/GlobeSurfaceTile.js | 23 ++++++++++++++++------- Source/Scene/GlobeSurfaceTileProvider.js | 2 ++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Source/Scene/GlobeSurfaceTile.js b/Source/Scene/GlobeSurfaceTile.js index 4f40eb4168ce..f72b4747f7bf 100644 --- a/Source/Scene/GlobeSurfaceTile.js +++ b/Source/Scene/GlobeSurfaceTile.js @@ -251,6 +251,7 @@ GlobeSurfaceTile.processStateMachine = function ( frameState, terrainProvider, imageryLayerCollection, + quadtree, vertexArraysToDestroy, terrainOnly ) { @@ -264,6 +265,7 @@ GlobeSurfaceTile.processStateMachine = function ( frameState, terrainProvider, imageryLayerCollection, + quadtree, vertexArraysToDestroy ); } @@ -487,13 +489,15 @@ GlobeSurfaceTile.prototype.updateExaggeration = function ( encoding.exaggerationRelativeHeight = exaggerationRelativeHeight; // Notify the quadtree that this tile's height has changed - quadtree._tileToUpdateHeights.push(tile); - var customData = tile.customData; - var customDataLength = customData.length; - for (var i = 0; i < customDataLength; i++) { - // Restart the level so that a height update is triggered - var data = customData[i]; - data.level = -1; + if (quadtree !== undefined) { + quadtree._tileToUpdateHeights.push(tile); + var customData = tile.customData; + var customDataLength = customData.length; + for (var i = 0; i < customDataLength; i++) { + // Restart the level so that a height update is triggered + var data = customData[i]; + data.level = -1; + } } } }; @@ -538,6 +542,7 @@ function processTerrainStateMachine( frameState, terrainProvider, imageryLayerCollection, + quadtree, vertexArraysToDestroy ) { var surfaceTile = tile.data; @@ -559,6 +564,7 @@ function processTerrainStateMachine( frameState, terrainProvider, imageryLayerCollection, + quadtree, vertexArraysToDestroy, true ); @@ -608,6 +614,9 @@ function processTerrainStateMachine( tile.level, vertexArraysToDestroy ); + + // Update the tile's exaggeration in case the globe's exaggeration changed while the tile was being processed + surfaceTile.updateExaggeration(tile, frameState, quadtree); } if ( diff --git a/Source/Scene/GlobeSurfaceTileProvider.js b/Source/Scene/GlobeSurfaceTileProvider.js index 926e75b663e6..9cdca9e137ce 100644 --- a/Source/Scene/GlobeSurfaceTileProvider.js +++ b/Source/Scene/GlobeSurfaceTileProvider.js @@ -602,6 +602,7 @@ GlobeSurfaceTileProvider.prototype.loadTile = function (frameState, tile) { frameState, this.terrainProvider, this._imageryLayers, + this.quadtree, this._vertexArraysToDestroy, terrainOnly ); @@ -623,6 +624,7 @@ GlobeSurfaceTileProvider.prototype.loadTile = function (frameState, tile) { frameState, this.terrainProvider, this._imageryLayers, + this.quadtree, this._vertexArraysToDestroy, terrainOnly ); From f3e39b24afb721ee0d6b0ad5672f404800c68c7e Mon Sep 17 00:00:00 2001 From: Ian Lilley Date: Mon, 30 Aug 2021 10:42:53 -0400 Subject: [PATCH 5/5] fixed version of deprecation in CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index c24e13c29fac..6d7056514e75 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,7 @@ ##### Breaking Changes :mega: -- Removed `Scene.terrainExaggeration` and `options.terrainExaggeration` for `CesiumWidget`, `Viewer`, and `Scene`, which were deprecated in CesiumJS 1.82. Use `Globe.terrainExaggeration` instead. +- Removed `Scene.terrainExaggeration` and `options.terrainExaggeration` for `CesiumWidget`, `Viewer`, and `Scene`, which were deprecated in CesiumJS 1.83. Use `Globe.terrainExaggeration` instead. ##### Additions :tada: