Skip to content

Commit

Permalink
Revert changes in #6558
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed May 8, 2018
1 parent 845846c commit a79b93f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 58 deletions.
50 changes: 24 additions & 26 deletions Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -1435,8 +1435,25 @@ define([

++statistics.numberOfPendingRequests;

var removeFunction = removeFromProcessingQueue(tileset, tile);
tile.contentReadyToProcessPromise.then(addToProcessingQueue(tileset, tile));
tile.contentReadyPromise.then(handleTileSuccess(tileset, tile)).otherwise(handleTileFailure(tileset, tile));
tile.contentReadyPromise.then(function() {
removeFunction();
tileset.tileLoad.raiseEvent(tile);
}).otherwise(function(error) {
removeFunction();
var url = tile._contentResource.url;
var message = defined(error.message) ? error.message : error.toString();
if (tileset.tileFailed.numberOfListeners > 0) {
tileset.tileFailed.raiseEvent({
url : url,
message : message
});
} else {
console.log('A 3D tile failed to load: ' + url);
console.log('Error: ' + message);
}
});
}

function requestTiles(tileset, outOfCore) {
Expand All @@ -1459,32 +1476,15 @@ define([
};
}

function handleTileFailure(tileset, tile) {
return function(error) {
if (tileset._processingQueue.indexOf(tile) >= 0) {
// Failed during processing
--tileset._statistics.numberOfTilesProcessing;
} else {
// Failed when making request
function removeFromProcessingQueue(tileset, tile) {
return function() {
if (tile._contentState === Cesium3DTileContentState.FAILED) {
// Not in processing queue
// For example, when a url request fails and the ready promise is rejected
--tileset._statistics.numberOfPendingRequests;
return;
}

var url = tile._contentResource.url;
var message = defined(error.message) ? error.message : error.toString();
if (tileset.tileFailed.numberOfListeners > 0) {
tileset.tileFailed.raiseEvent({
url : url,
message : message
});
} else {
console.log('A 3D tile failed to load: ' + url);
console.log('Error: ' + message);
}
};
}

function handleTileSuccess(tileset, tile) {
return function() {
--tileset._statistics.numberOfTilesProcessing;

if (tile.hasRenderableContent) {
Expand All @@ -1498,8 +1498,6 @@ define([
tile.replacementNode = tileset._replacementList.add(tile);
}
}

tileset.tileLoad.raiseEvent(tile);
};
}

Expand Down
32 changes: 0 additions & 32 deletions Specs/Scene/Cesium3DTilesetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,38 +480,6 @@ defineSuite([
fail('should not resolve');
}).otherwise(function(error) {
expect(root._contentState).toEqual(Cesium3DTileContentState.FAILED);
var statistics = tileset.statistics;
expect(statistics.numberOfAttemptedRequests).toBe(0);
expect(statistics.numberOfPendingRequests).toBe(0);
expect(statistics.numberOfTilesProcessing).toBe(0);
expect(statistics.numberOfTilesWithContentReady).toBe(0);
});
});
});

it('handles failed tile processing', function() {
viewRootOnly();
var tileset = scene.primitives.add(new Cesium3DTileset({
url : tilesetUrl
}));
return tileset.readyPromise.then(function(tileset) {
// Start spying after the tileset json has been loaded
spyOn(Resource._Implementations, 'loadWithXhr').and.callFake(function(url, responseType, method, data, headers, deferred, overrideMimeType) {
deferred.resolve(Cesium3DTilesTester.generateBatchedTileBuffer({
version : 0 // Invalid version
}));
});
scene.renderForSpecs(); // Request root
var root = tileset._root;
return root.contentReadyPromise.then(function() {
fail('should not resolve');
}).otherwise(function(error) {
expect(root._contentState).toEqual(Cesium3DTileContentState.FAILED);
var statistics = tileset.statistics;
expect(statistics.numberOfAttemptedRequests).toBe(0);
expect(statistics.numberOfPendingRequests).toBe(0);
expect(statistics.numberOfTilesProcessing).toBe(0);
expect(statistics.numberOfTilesWithContentReady).toBe(0);
});
});
});
Expand Down

0 comments on commit a79b93f

Please sign in to comment.