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

Rework external tiles.json #3328

Merged
merged 9 commits into from
Dec 18, 2015
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
46 changes: 40 additions & 6 deletions Source/Scene/Cesium3DTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ define([
'./Empty3DTileContentProvider',
'./PerInstanceColorAppearance',
'./Primitive',
'./TileBoundingBox',
'./Tileset3DTileContentProvider'
'./TileBoundingBox'
], function(
BoxOutlineGeometry,
Cartesian3,
Expand All @@ -49,8 +48,7 @@ define([
Empty3DTileContentProvider,
PerInstanceColorAppearance,
Primitive,
TileBoundingBox,
Tileset3DTileContentProvider) {
TileBoundingBox) {
"use strict";

/**
Expand Down Expand Up @@ -123,13 +121,22 @@ define([
*/
this.numberOfChildrenWithoutContent = defined(header.children) ? header.children.length : 0;

this._numberOfUnrefinableChildren = this.numberOfChildrenWithoutContent;

/**
* DOC_TBA
*
* @readonly
*/
this.hasTilesetContent = false;

/**
* DOC_TBA
*
* @readonly
*/
this.hasContent = true;

/**
* DOC_TBA
*
Expand All @@ -147,17 +154,35 @@ define([

if (type === 'json') {
this.hasTilesetContent = true;
content = new Tileset3DTileContentProvider();
} else if (defined(contentFactory)) {
this.hasContent = false;
this._numberOfUnrefinableChildren = 1;
}

if (defined(contentFactory)) {
content = contentFactory(tileset, this, url);
} else {
throw new DeveloperError('Unknown tile content type, ' + type + ', for ' + url);
}
} else {
content = new Empty3DTileContentProvider();
this.hasContent = false;
}
this._content = content;

function setRefinable(tile) {
var parent = tile.parent;
if (defined(parent) && (tile.hasContent || tile.isRefinable())) {
// When a tile with content is loaded, its parent can safely refine to it without any gaps in rendering
// Since an empty tile doesn't have content of its own, its descendants with content need to be loaded
// before the parent is able to refine to it.
--parent._numberOfUnrefinableChildren;
// If the parent is empty, traverse up the tree to update ancestor tiles.
if (!parent.hasContent) {
setRefinable(parent);
}
}
}

var that = this;

// Content enters the READY state
Expand All @@ -166,6 +191,8 @@ define([
--that.parent.numberOfChildrenWithoutContent;
}

setRefinable(that);

that.readyPromise.resolve(that);
}).otherwise(function(error) {
that.readyPromise.reject(error);
Expand Down Expand Up @@ -237,6 +264,13 @@ define([
return this._content.state === Cesium3DTileContentState.READY;
};

/**
* DOC_TBA
*/
Cesium3DTile.prototype.isRefinable = function() {
return this._numberOfUnrefinableChildren === 0;
};

/**
* DOC_TBA
*/
Expand Down
9 changes: 7 additions & 2 deletions Source/Scene/Cesium3DTileContentProviderFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ define([
'./Composite3DTileContentProvider',
'./Empty3DTileContentProvider',
'./Instanced3DModel3DTileContentProvider',
'./Points3DTileContentProvider'
'./Points3DTileContentProvider',
'./Tileset3DTileContentProvider'
], function(
Batched3DModel3DTileContentProvider,
Composite3DTileContentProvider,
Empty3DTileContentProvider,
Instanced3DModel3DTileContentProvider,
Points3DTileContentProvider) {
Points3DTileContentProvider,
Tileset3DTileContentProvider) {
"use strict";

/**
Expand All @@ -29,6 +31,9 @@ define([
cmpt : function(tileset, tile, url) {
// Send in the factory in order to avoid a cyclical dependency
return new Composite3DTileContentProvider(tileset, tile, url, Cesium3DTileContentProviderFactory);
},
json : function(tileset, tile, url) {
return new Tileset3DTileContentProvider(tileset, tile, url);
}
};

Expand Down
Loading