Skip to content

Commit

Permalink
Merge pull request #9580 from CesiumGS/Console-Warnings-When-a-Tilese…
Browse files Browse the repository at this point in the history
…t-Contains-Unsupported-Extensions-9952

Runtime Errors when a tileset contains unsupported extensions
  • Loading branch information
srothst1 authored Jun 1, 2021
2 parents 80ceefe + 3b7facf commit ce84719
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

### 1.83 - 2021-07-01

##### Additions :tada:

- Added checks for supported 3D tiles extensions.[#9552](https://github.com/CesiumGS/cesium/issues/9552)

### 1.82 - 2021-06-01

##### Additions :tada:
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Dzung Nguyen](https://github.com/dzungpng)
- [Nithin Pranesh](https://github.com/nithinp7)
- [Alexander Gallegos](https://github.com/argallegos)
- [Sam Rothstein](https://github.com/srothst1)
- [Northrop Grumman](http://www.northropgrumman.com)
- [Joseph Stein](https://github.com/nahgrin)
- [EOX IT Services GmbH](https://eox.at)
Expand Down
22 changes: 22 additions & 0 deletions Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,8 @@ Cesium3DTileset.prototype.loadTileset = function (
throw new RuntimeError("The tileset must be 3D Tiles version 0.0 or 1.0.");
}

Cesium3DTileset.checkSupportedExtensions(this._extensions);

var statistics = this._statistics;

var tilesetVersion = asset.tilesetVersion;
Expand Down Expand Up @@ -2804,6 +2806,26 @@ Cesium3DTileset.prototype.destroy = function () {
return destroyObject(this);
};

Cesium3DTileset.supportedExtensions = {
CESIUM_3DTILES_metadata: true,
CESIUM_3DTILES_implicit_tiling: true,
CESIUM_3DTILES_content_gltf: true,
CESIUM_3DTILES_multiple_contents: true,
CESIUM_3DTILES_bounding_volume_S2: true,
CESIUM_3DTILES_batch_table_hierarchy: true,
CESIUM_3DTILES_draco_point_compression: true,
};

Cesium3DTileset.checkSupportedExtensions = function (extensionsRequired) {
for (var extension in extensionsRequired) {
if (extensionsRequired.hasOwnProperty(extension)) {
if (!Cesium3DTileset.supportedExtensions[extension]) {
throw new RuntimeError("Unsupported 3D Tiles Extension: " + extension);
}
}
}
};

/**
* Optimization option. Used as a callback when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control how much to raise the screen space error for tiles outside the foveated cone,
* interpolating between {@link Cesium3DTileset#foveatedMinimumScreenSpaceErrorRelaxation} and {@link Cesium3DTileset#maximumScreenSpaceError}.
Expand Down
22 changes: 22 additions & 0 deletions Specs/Scene/Cesium3DTilesetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,28 @@ describe(
});
});

it("rejects readyPromise with unsupported extension", function () {
var tilesetJson = {
asset: {
version: 1.0,
},
extensionsUsed: ["unsupported_extension"],
extensionsRequired: ["unsupported_extension"],
};

var uri = "data:text/plain;base64," + btoa(JSON.stringify(tilesetJson));

options.url = uri;
var tileset = scene.primitives.add(new Cesium3DTileset(options));
return tileset.readyPromise
.then(function () {
fail("should not resolve");
})
.otherwise(function (error) {
expect(tileset.ready).toEqual(false);
});
});

it("url and tilesetUrl set up correctly given tileset JSON filepath", function () {
var path = "Data/Cesium3DTiles/Tilesets/TilesetOfTilesets/tileset.json";
var tileset = new Cesium3DTileset({
Expand Down

0 comments on commit ce84719

Please sign in to comment.