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

Require full tileset JSON path #6678

Merged
merged 4 commits into from
Jun 12, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -5,6 +5,7 @@ Change Log

##### Breaking Changes :mega:
* glTF 2.0 models corrected to face +Z forwards per specification. Internally Cesium uses +X as forward, so a new +Z to +X rotation was added for 2.0 models only. [#6632](https://github.com/AnalyticalGraphicsInc/cesium/pull/6632)
* Dropped support for directory URLs when loading tilesets to match the updated [3D Tiles spec](https://github.com/AnalyticalGraphicsInc/3d-tiles/issues/272). [#6502](https://github.com/AnalyticalGraphicsInc/cesium/issues/6502)

##### Additions :tada:
* `PostProcessStage` has a `selectedFeatures` property which is an array of primitives used for selectively applying a post-process stage. In the fragment shader, use the function `bool czm_selected(vec2 textureCoordinates` to determine whether or not the stage should be applied at that fragment.
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
* [Hannah Bollar](https://github.com/hanbollar)
* [Luke San Antonio Bialecki](https://github.com/lukesanantonio)
* [Josh Lawrence](https://github.com/loshjawrence)
* [Omar Shehata](https://github.com/OmarShehata)
* [NICTA](http://www.nicta.com.au/)
* [Chris Cooper](https://github.com/chris-cooper)
* [Kevin Ring](https://github.com/kring)
Expand Down
24 changes: 9 additions & 15 deletions Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ define([
* @constructor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a bunch of examples in the documentation that need to be fixed. Search for url : 'http://localhost:8002/tilesets/Seattle' - I couldn't find other cases.

*
* @param {Object} options Object with the following properties:
* @param {Resource|String|Promise<Resource>|Promise<String>} options.url The url to a tileset.json file or to a directory containing a tileset.json file.
* @param {Resource|String|Promise<Resource>|Promise<String>} options.url The url to a tileset JSON file.
Copy link
Contributor

@lilleyse lilleyse Jun 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also make similar adjustments to the wording (tileset.json -> tileset JSON) in other 3D Tiles related files - Cesium3DTile, Cesium3DTilesetStatistics, and Cesium3DTilesInspectorViewModel

* @param {Boolean} [options.show=true] Determines if the tileset will be shown.
* @param {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] A 4x4 transformation matrix that transforms the tileset's root tile.
* @param {ShadowMode} [options.shadows=ShadowMode.ENABLED] Determines whether the tileset casts or receives shadows from each light source.
Expand Down Expand Up @@ -668,7 +668,7 @@ define([
*/
this.debugShowUrl = defaultValue(options.debugShowUrl, false);

// A bunch of tilesets were generated that have a leading / in front of all URLs in the tileset.json. If the tiles aren't
// A bunch of tilesets were generated that have a leading / in front of all URLs in the tileset JSON file. If the tiles aren't
// at the root of the domain they will not load anymore. If we find a b3dm file with a leading slash, we test load a tile.
// If it succeeds we continue on. If it fails, we set this to true so we know to strip the slash when loading tiles.
this._brokenUrlWorkaround = false;
Expand All @@ -691,27 +691,21 @@ define([
basePath = resource.getBaseUri(true);
} else if (resource.isDataUri) {
basePath = '';
} else {
resource.appendForwardSlash();
tilesetResource = resource.getDerivedResource({
url: 'tileset.json'
});
basePath = resource.url;
}

that._url = resource.url;
that._tilesetUrl = tilesetResource.url;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just remove _tilesetUrl altogether now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And similarly, remove tilesetResource.

that._basePath = basePath;

// We don't know the distance of the tileset until tileset.json is loaded, so use the default distance for now
// We don't know the distance of the tileset until tileset JSON file is loaded, so use the default distance for now
return Cesium3DTileset.loadJson(tilesetResource);
})
.then(function(tilesetJson) {
return detectBrokenUrlWorkaround(that, tilesetResource, tilesetJson);
})
.then(function(tilesetJson) {
if (that._brokenUrlWorkaround) {
deprecationWarning('Cesium3DTileset.leadingSlash', 'Having a leading slash in a tile URL that is actually relative to the tileset.json is deprecated.');
deprecationWarning('Cesium3DTileset.leadingSlash', 'Having a leading slash in a tile URL that is actually relative to the tileset JSON file is deprecated.');
}

that._root = that.loadTileset(tilesetResource, tilesetJson);
Expand Down Expand Up @@ -920,7 +914,7 @@ define([
},

/**
* The url to a tileset.json file or to a directory containing a tileset.json file.
* The url to a tileset JSON file.
*
* @memberof Cesium3DTileset.prototype
*
Expand All @@ -934,7 +928,7 @@ define([
},

/**
* The base path that non-absolute paths in tileset.json are relative to.
* The base path that non-absolute paths in tileset JSON file are relative to.
*
* @memberof Cesium3DTileset.prototype
*
Expand All @@ -944,7 +938,7 @@ define([
*/
basePath : {
get : function() {
deprecationWarning('Cesium3DTileset.basePath', 'Cesium3DTileset.basePath has been deprecated. All tiles are relative to the url of the tileset.json that contains them. Use the url property instead.');
deprecationWarning('Cesium3DTileset.basePath', 'Cesium3DTileset.basePath has been deprecated. All tiles are relative to the url of the tileset JSON file that contains them. Use the url property instead.');
return this._basePath;
}
},
Expand Down Expand Up @@ -1252,7 +1246,7 @@ define([
};

/**
* Loads the main tileset.json or a tileset.json referenced from a tile.
* Loads the main tileset JSON file or a tileset JSON file referenced from a tile.
*
* @private
*/
Expand All @@ -1276,7 +1270,7 @@ define([
tilesetResource.setQueryParameters(versionQuery);
}

// A tileset.json referenced from a tile may exist in a different directory than the root tileset.
// A tileset JSON file referenced from a tile may exist in a different directory than the root tileset.
// Get the basePath relative to the external tileset.
var rootTile = new Cesium3DTile(this, tilesetResource, tilesetJson.root, parentTile);

Expand Down
6 changes: 3 additions & 3 deletions Specs/Scene/Batched3DModel3DTileContentClassificationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ defineSuite([
var centerLongitude = -1.31968;
var centerLatitude = 0.698874;

var withBatchTableUrl = './Data/Cesium3DTiles/Batched/BatchedWithBatchTable/';
var withBatchTableBinaryUrl = './Data/Cesium3DTiles/Batched/BatchedWithBatchTableBinary/';
var withQuantizationUrl = './Data/Cesium3DTiles/Batched/BatchedWithQuantization/';
var withBatchTableUrl = './Data/Cesium3DTiles/Batched/BatchedWithBatchTable/tileset.json';
var withBatchTableBinaryUrl = './Data/Cesium3DTiles/Batched/BatchedWithBatchTableBinary/tileset.json';
var withQuantizationUrl = './Data/Cesium3DTiles/Batched/BatchedWithQuantization/tileset.json';

function setCamera(longitude, latitude) {
// One feature is located at the center, point the camera there
Expand Down
28 changes: 14 additions & 14 deletions Specs/Scene/Batched3DModel3DTileContentSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ defineSuite([
var centerLongitude = -1.31968;
var centerLatitude = 0.698874;

var withBatchTableUrl = './Data/Cesium3DTiles/Batched/BatchedWithBatchTable/';
var withBatchTableBinaryUrl = './Data/Cesium3DTiles/Batched/BatchedWithBatchTableBinary/';
var withoutBatchTableUrl = './Data/Cesium3DTiles/Batched/BatchedWithoutBatchTable/';
var translucentUrl = './Data/Cesium3DTiles/Batched/BatchedTranslucent/';
var translucentOpaqueMixUrl = './Data/Cesium3DTiles/Batched/BatchedTranslucentOpaqueMix/';
var withKHRMaterialsCommonUrl = './Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/';
var withTransformBoxUrl = './Data/Cesium3DTiles/Batched/BatchedWithTransformBox/';
var withTransformSphereUrl = './Data/Cesium3DTiles/Batched/BatchedWithTransformSphere/';
var withTransformRegionUrl = './Data/Cesium3DTiles/Batched/BatchedWithTransformRegion/';
var texturedUrl = './Data/Cesium3DTiles/Batched/BatchedTextured/';
var compressedTexturesUrl = './Data/Cesium3DTiles/Batched/BatchedCompressedTextures/';
var deprecated1Url = './Data/Cesium3DTiles/Batched/BatchedDeprecated1/';
var deprecated2Url = './Data/Cesium3DTiles/Batched/BatchedDeprecated2/';
var gltfZUpUrl = './Data/Cesium3DTiles/Batched/BatchedGltfZUp';
var withBatchTableUrl = './Data/Cesium3DTiles/Batched/BatchedWithBatchTable/tileset.json';
var withBatchTableBinaryUrl = './Data/Cesium3DTiles/Batched/BatchedWithBatchTableBinary/tileset.json';
var withoutBatchTableUrl = './Data/Cesium3DTiles/Batched/BatchedWithoutBatchTable/tileset.json';
var translucentUrl = './Data/Cesium3DTiles/Batched/BatchedTranslucent/tileset.json';
var translucentOpaqueMixUrl = './Data/Cesium3DTiles/Batched/BatchedTranslucentOpaqueMix/tileset.json';
var withKHRMaterialsCommonUrl = './Data/Cesium3DTiles/Batched/BatchedWithKHRMaterialsCommon/tileset.json';
var withTransformBoxUrl = './Data/Cesium3DTiles/Batched/BatchedWithTransformBox/tileset.json';
var withTransformSphereUrl = './Data/Cesium3DTiles/Batched/BatchedWithTransformSphere/tileset.json';
var withTransformRegionUrl = './Data/Cesium3DTiles/Batched/BatchedWithTransformRegion/tileset.json';
var texturedUrl = './Data/Cesium3DTiles/Batched/BatchedTextured/tileset.json';
var compressedTexturesUrl = './Data/Cesium3DTiles/Batched/BatchedCompressedTextures/tileset.json';
var deprecated1Url = './Data/Cesium3DTiles/Batched/BatchedDeprecated1/tileset.json';
var deprecated2Url = './Data/Cesium3DTiles/Batched/BatchedDeprecated2/tileset.json';
var gltfZUpUrl = './Data/Cesium3DTiles/Batched/BatchedGltfZUp/tileset.json';

function setCamera(longitude, latitude) {
// One feature is located at the center, point the camera there
Expand Down
14 changes: 7 additions & 7 deletions Specs/Scene/Cesium3DTileBatchTableSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ defineSuite([
var centerLongitude = -1.31968;
var centerLatitude = 0.698874;

var withBatchTableUrl = './Data/Cesium3DTiles/Batched/BatchedWithBatchTable/';
var withoutBatchTableUrl = './Data/Cesium3DTiles/Batched/BatchedWithoutBatchTable/';
var noBatchIdsUrl = './Data/Cesium3DTiles/Batched/BatchedNoBatchIds/';
var batchTableHierarchyUrl = './Data/Cesium3DTiles/Hierarchy/BatchTableHierarchy/';
var batchTableHierarchyBinaryUrl = './Data/Cesium3DTiles/Hierarchy/BatchTableHierarchyBinary/';
var batchTableHierarchyMultipleParentsUrl = './Data/Cesium3DTiles/Hierarchy/BatchTableHierarchyMultipleParents/';
var batchTableHierarchyNoParentsUrl = './Data/Cesium3DTiles/Hierarchy/BatchTableHierarchyNoParents/';
var withBatchTableUrl = './Data/Cesium3DTiles/Batched/BatchedWithBatchTable/tileset.json';
var withoutBatchTableUrl = './Data/Cesium3DTiles/Batched/BatchedWithoutBatchTable/tileset.json';
var noBatchIdsUrl = './Data/Cesium3DTiles/Batched/BatchedNoBatchIds/tileset.json';
var batchTableHierarchyUrl = './Data/Cesium3DTiles/Hierarchy/BatchTableHierarchy/tileset.json';
var batchTableHierarchyBinaryUrl = './Data/Cesium3DTiles/Hierarchy/BatchTableHierarchyBinary/tileset.json';
var batchTableHierarchyMultipleParentsUrl = './Data/Cesium3DTiles/Hierarchy/BatchTableHierarchyMultipleParents/tileset.json';
var batchTableHierarchyNoParentsUrl = './Data/Cesium3DTiles/Hierarchy/BatchTableHierarchyNoParents/tileset.json';

var result = new Color();

Expand Down
Loading