Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-throw runtime errors when failing to parse 3D Tiles content. #6088

Merged
merged 6 commits into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Change Log
* Improved CZML Custom Properties sandcastle example [#6086](https://github.com/AnalyticalGraphicsInc/cesium/pull/6086)
* Added `Plane.projectPointOntoPlane` for projecting a `Cartesian3` position onto a `Plane` [#6092](https://github.com/AnalyticalGraphicsInc/cesium/pull/6092)
* Added `Cartesian3.projectVector` for projecting one vector to another [#6093](https://github.com/AnalyticalGraphicsInc/cesium/pull/6093)
* Added `Cesium3DTileset.tileFailed` event that will be raised when a tile fails to load. The object passed to the event listener will have a url and message property. If there are no event listeners, error messages will be logged to the console. [#6088](https://github.com/AnalyticalGraphicsInc/cesium/pull/6088)

### 1.41 - 2018-01-02

Expand Down
32 changes: 31 additions & 1 deletion Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,23 @@ define([
*/
this.tileUnload = new Event();

/**
* The event fired to indicate that a tile's content failed to load.
* <p>
* If there are no event listeners, error messages will be logged to the console.
* </p>
*
* @type {Event}
* @default new Event()
*
* @example
* tileset.tileFailed.addEventListener(function(error) {
* console.log('An error occurred loading tile: ' + error.url);
* console.log('Error: ' + error.message);
* });
*/
this.tileFailed = new Event();

/**
* This event fires once for each visible tile in a frame. This can be used to manually
* style a tileset.
Expand Down Expand Up @@ -1261,7 +1278,20 @@ define([
tile.contentReadyPromise.then(function() {
removeFunction();
tileset.tileLoad.raiseEvent(tile);
}).otherwise(removeFunction);
}).otherwise(function(error) {
removeFunction();
var url = tile._contentUrl;
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 Down
52 changes: 52 additions & 0 deletions Specs/Data/Cesium3DTiles/Tilesets/TilesetInvalid/tileset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"asset": {
"version": "1.0",
"tilesetVersion": "1.2.3"
},
"properties": {
"id": {
"minimum": 0,
"maximum": 9
},
"Longitude": {
"minimum": -1.3197192952275933,
"maximum": -1.319644104024109
},
"Latitude": {
"minimum": 0.698848878034009,
"maximum": 0.6989046192460953
},
"Height": {
"minimum": 6.161747192963958,
"maximum": 84.83180232718587
}
},
"geometricError": 240,
"root": {
"boundingVolume": {
"region": [
-1.3197209591796106,
0.6988424218,
-1.3196390408203893,
0.6989055782,
0,
88
]
},
"geometricError": 70,
"refine": "ADD",
"content": {
"url": "does_not_exist.b3dm",
"boundingVolume": {
"region": [
-1.3197004795898053,
0.6988582109,
-1.3196595204101946,
0.6988897891,
0,
88
]
}
}
}
}
20 changes: 20 additions & 0 deletions Specs/Scene/Cesium3DTilesetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ defineSuite([
var pointCloudUrl = './Data/Cesium3DTiles/PointCloud/PointCloudRGB';
var pointCloudBatchedUrl = './Data/Cesium3DTiles/PointCloud/PointCloudBatched';

var invalidTileset = './Data/Cesium3DTiles/Tilesets/TilesetInvalid/';

beforeAll(function() {
scene = createScene();
});
Expand Down Expand Up @@ -1684,6 +1686,24 @@ defineSuite([
});
});

it('tile failed event is raised', function() {
viewNothing();
return Cesium3DTilesTester.loadTileset(scene, invalidTileset).then(function(tileset) {
var spyUpdate = jasmine.createSpy('listener');
tileset.tileFailed.addEventListener(spyUpdate);
tileset.maximumMemoryUsage = 0;
viewRootOnly();
return Cesium3DTilesTester.waitForTilesLoaded(scene, tileset).then(function() {
expect(spyUpdate.calls.count()).toEqual(1);

var arg = spyUpdate.calls.argsFor(0)[0];
expect(arg).toBeDefined();
expect(arg.url).toContain('does_not_exist.b3dm');
expect(arg.message).toBeDefined();
});
});
});

it('destroys', function() {
return Cesium3DTilesTester.loadTileset(scene, tilesetUrl).then(function(tileset) {
var root = tileset._root;
Expand Down