Skip to content

Commit

Permalink
and contentLoader option, change fetchOptions to loadOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Avnerus committed Jun 9, 2021
1 parent 74005c3 commit cfb6974
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
9 changes: 7 additions & 2 deletions modules/tiles/src/tileset/tile-3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,19 @@ export default class TileHeader {
// The content can be a binary tile ot a JSON tileset
const loader = this.tileset.loader;
const options = {
fetch: this.tileset.fetchOptions,
[loader.id]: {
isTileset: this.type === 'json',
...this._getLoaderSpecificOptions(loader.id)
}
},
...this.tileset.loadOptions
};

this.content = await load(contentUrl, loader, options);

if (this.tileset.options.contentLoader) {
await this.tileset.options.contentLoader(this);
}

if (this._isTileset()) {
// Add tile headers for the nested tilset's subtree
// Async update of the tree should be fine since there would never be edits to the same node
Expand Down
15 changes: 12 additions & 3 deletions modules/tiles/src/tileset/tileset-3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ const DEFAULT_OPTIONS = {
onTileUnload: () => {},
onTileError: (tile, message, url) => {},

// Optional async tile content loader
contentLoader: null,

// TODO CESIUM
// The maximum screen space error used to drive level of detail refinement.
maximumScreenSpaceError: 8
Expand Down Expand Up @@ -134,12 +137,18 @@ export default class Tileset3D {
this.refine = json.root.refine;

// TODO add to loader context?
this.fetchOptions = this.options.fetchOptions || {};
this.loadOptions = this.options.loadOptions || {};
if (this.options.headers) {
this.fetchOptions.headers = this.options.headers;
this.loadOptions.fetch = {
...this.loadOptions.fetch,
headers: this.options.headers
};
}
if (this.options.token) {
this.fetchOptions.token = this.options.token;
this.loadOptions.fetch = {
...this.loadOptions.fetch,
token: this.options.token
};
}

this.root = null;
Expand Down

0 comments on commit cfb6974

Please sign in to comment.