Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #23 from oterral/c2c_c2c_patches
Browse files Browse the repository at this point in the history
Fix initial set of tiles to load
  • Loading branch information
gberaudo authored Nov 21, 2016
2 parents f4c5349 + 105b532 commit afe04e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Source/Scene/QuadtreePrimitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ define([
if (terrainProvider && terrainProvider._availableLevels && terrainProvider._rectangle) {
var level = terrainProvider._availableLevels[0];
primitive._levelZeroTiles = QuadtreeTile.createMinimumLevelTiles(tilingScheme,
level, terrainProvider._rectangle);
level, terrainProvider);
} else {
primitive._levelZeroTiles = QuadtreeTile.createLevelZeroTiles(tilingScheme);
}
Expand Down
29 changes: 19 additions & 10 deletions Source/Scene/QuadtreeTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,36 +144,45 @@ define([
*
* @param {TilingScheme} tilingScheme The tiling scheme for which the tiles are to be created.
* @param {Number} level The minimum level to display.
* @param {Recatngle} rectangle The area to display.
* @param {CesiumTerrainProvider} terrainProvider The area to display.
* @returns {QuadtreeTile[]} An array containing the tiles at minimum level of detail, starting with the
* tile in the northwest corner and followed by the tile (if any) to its east of the area.
*/
QuadtreeTile.createMinimumLevelTiles = function(tilingScheme, level, rectangle) {
QuadtreeTile.createMinimumLevelTiles = function(tilingScheme, level, terrainProvider) {
//>>includeStart('debug', pragmas.debug);
if (!defined(tilingScheme)) {
throw new DeveloperError('tilingScheme is required.');
}
if (!defined(level)) {
throw new DeveloperError('level is required.');
}
if (!defined(rectangle)) {
throw new DeveloperError('rectangle is required.');
if (!defined(terrainProvider)) {
throw new DeveloperError('terrainProvider is required.');
}
//>>includeEnd('debug');
var rectangle = terrainProvider._rectangle;
var westSouth = Cartographic.fromRadians(rectangle.west, rectangle.south);
var eastNorth = Cartographic.fromRadians(rectangle.east, rectangle.north);
var bottomLeft = tilingScheme.positionToTileXY(westSouth, level);
var topRight = tilingScheme.positionToTileXY(eastNorth, level);
var result = new Array();
var ranges = terrainProvider._availableTiles[level];
var numberOfTilesY = tilingScheme.getNumberOfYTilesAtLevel(level);

for (var y = topRight.y; y <= bottomLeft.y; y++) {
for (var x = bottomLeft.x; x <= topRight.x; x++) {
result.push(new QuadtreeTile({
tilingScheme : tilingScheme,
x : x,
y : y,
level : level
}));
for (var i = 0, len = ranges.length; i < len; ++i) {
var range = ranges[i];
var terrainY = numberOfTilesY - y - 1;
if (x >= range.startX && x <= range.endX && terrainY >= range.startY && terrainY <= range.endY) {
result.push(new QuadtreeTile({
tilingScheme : tilingScheme,
x : x,
y : y,
level : level
}));
}
}
}
}

Expand Down

0 comments on commit afe04e3

Please sign in to comment.