From c2d0e53de6225e401d8f6bb4467dc7805952a4e9 Mon Sep 17 00:00:00 2001 From: Daniel Leone Date: Tue, 15 Dec 2020 11:24:23 +0800 Subject: [PATCH 01/12] * added the intellj shelf to the git ignore list * fixed the doc for `TerrainData.createMesh` (missing param) * exposed `_tileAvailability` on ArcGISTiledElevationTerrainProvider as the `availability`; this fixes sampleTerrainMostDetailed which requires that property. * made `sampleTerrain` call `createMesh` on every tile requested; this fixes ArcGIS terrain which currently requires the mesh to be built before interpolating height (because the request buffer is still encoded in LERC and the decoding happens during mesh building) --- .gitignore | 1 + .../ArcGISTiledElevationTerrainProvider.js | 10 +++++- Source/Core/TerrainData.js | 1 + Source/Core/sampleTerrain.js | 32 +++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 240b38f501bf..004aac89e86e 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ yarn.lock # WebStorm user-specific .idea/workspace.xml .idea/tasks.xml +.idea/shelf diff --git a/Source/Core/ArcGISTiledElevationTerrainProvider.js b/Source/Core/ArcGISTiledElevationTerrainProvider.js index 1a95dbeb81ed..84123c2729d0 100644 --- a/Source/Core/ArcGISTiledElevationTerrainProvider.js +++ b/Source/Core/ArcGISTiledElevationTerrainProvider.js @@ -304,7 +304,14 @@ Object.defineProperties(ArcGISTiledElevationTerrainProvider.prototype, { */ availability: { get: function () { - return undefined; + //>>includeStart('debug', pragmas.debug) + if (!this._ready) { + throw new DeveloperError( + "availability must not be called before the terrain provider is ready." + ); + } + //>>includeEnd('debug'); + return this._tilesAvailable; }, }, }); @@ -650,6 +657,7 @@ function requestAvailability(that, level, x, y) { // Mark whole area as having availability loaded that._tilesAvailablityLoaded.addAvailableTileRange( + level, xOffset, yOffset, xOffset + dim, diff --git a/Source/Core/TerrainData.js b/Source/Core/TerrainData.js index a76e95e998f4..39ff627558dc 100644 --- a/Source/Core/TerrainData.js +++ b/Source/Core/TerrainData.js @@ -75,6 +75,7 @@ TerrainData.prototype.isChildAvailable = DeveloperError.throwInstantiationError; * @param {Number} x The X coordinate of the tile for which to create the terrain data. * @param {Number} y The Y coordinate of the tile for which to create the terrain data. * @param {Number} level The level of the tile for which to create the terrain data. + * @param {Number} [exaggeration=1.0] The scale used to exaggerate the terrain. * @returns {Promise.|undefined} A promise for the terrain mesh, or undefined if too many * asynchronous mesh creations are already in progress and the operation should * be retried later. diff --git a/Source/Core/sampleTerrain.js b/Source/Core/sampleTerrain.js index 93f2f6f3407c..ac07b7eb1f87 100644 --- a/Source/Core/sampleTerrain.js +++ b/Source/Core/sampleTerrain.js @@ -89,6 +89,10 @@ function doSampling(terrainProvider, level, positions) { tileRequest.level ); var tilePromise = requestPromise + // Make sure to generate our mesh for each tile first + // because some tiles actually require the mesh to interpolate heights + // (eg: ArcGISTiledElevationTerrainProvider) + .then(createMeshCreatorFunction(tileRequest)) .then(createInterpolateFunction(tileRequest)) .otherwise(createMarkFailedFunction(tileRequest)); tilePromises.push(tilePromise); @@ -99,6 +103,34 @@ function doSampling(terrainProvider, level, positions) { }); } +/** + * + * @param {Object} tileRequest + * @returns {function(TerrainData):Promise} + */ +function createMeshCreatorFunction(tileRequest) { + /** + * @param {TerrainData} terrainData + * @return {Promise} + */ + function createMesh(terrainData) { + return terrainData + .createMesh( + tileRequest.tilingScheme, + tileRequest.x, + tileRequest.y, + tileRequest.level, + // I'm guessing we always want no terrain exaggeration when calling sample terrain directly + 1 + ) + .then(function () { + // make sure we pass back the same terrain data object; not the generated mesh. + return terrainData; + }); + } + return createMesh; +} + function createInterpolateFunction(tileRequest) { var tilePositions = tileRequest.positions; var rectangle = tileRequest.tilingScheme.tileXYToRectangle( From 93605adba2e74076f2dc12d2deb80cb34223fb3f Mon Sep 17 00:00:00 2001 From: Daniel Leone Date: Tue, 15 Dec 2020 16:14:41 +0800 Subject: [PATCH 02/12] * hijacked the Terrain.html Sandcastle for testing * increased the active task limit for now as it was getting in the way --- Apps/Sandcastle/gallery/Terrain.html | 120 +++++++++++++++++++++++---- Source/Core/HeightmapTerrainData.js | 2 +- 2 files changed, 107 insertions(+), 15 deletions(-) diff --git a/Apps/Sandcastle/gallery/Terrain.html b/Apps/Sandcastle/gallery/Terrain.html index e927a609aedd..400526f160db 100644 --- a/Apps/Sandcastle/gallery/Terrain.html +++ b/Apps/Sandcastle/gallery/Terrain.html @@ -33,6 +33,7 @@
+