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

3D Tiles feature renames #3473

Merged
merged 8 commits into from
Jan 26, 2016
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion Apps/Sandcastle/gallery/Cities.html
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@
if (batchTableResources.hasProperty(currentPropertyName)) {
var length = content.batchSize;
for (var i = 0; i < length; ++i) {
var building = content.getModel(i);
var building = content.getFeature(i);
var value = building.getProperty(currentPropertyName);

// TODO: we could also fix these server side
Expand Down
4 changes: 2 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Change Log
* Added support for [3D Tiles](https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/README.md) for streaming massive heterogeneous 3D geospatial datasets. The new Cesium types are:
* `Cesium3DTileset`
* `Cesium3DTile`
* `Cesium3DTileFeature`
* `Cesium3DTileBatchTableResources`
* `Batched3DModel3DTileContentProvider`
* `Instanced3DModel3DTileContentProvider`
* `Points3DTileContentProvider`
* `Composite3DTileContentProvider`
* `Tileset3DTileContentProvider`
* `Empty3DTileContentProvider`
* `BatchedModel`
* `Cesium3DTileBatchTableResources`

TODO: these are still private:
* Added `vertexShaderLoaded`, `fragmentShaderLoaded`, `uniformMapLoaded`, `pickVertexShaderLoaded`, `pickFragmentShaderLoaded`, and `pickUniformMapLoaded` callbacks to the `Model` constructor and `Model.fromGltf`.
Expand Down
42 changes: 21 additions & 21 deletions Source/Scene/Batched3DModel3DTileContentProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ define([
'../Core/RequestScheduler',
'../Core/RequestType',
'../ThirdParty/when',
'./BatchedModel',
'./Cesium3DTileFeature',
'./Cesium3DTileBatchTableResources',
'./Cesium3DTileContentState',
'./Model'
Expand All @@ -29,7 +29,7 @@ define([
RequestScheduler,
RequestType,
when,
BatchedModel,
Cesium3DTileFeature,
Cesium3DTileBatchTableResources,
Cesium3DTileContentState,
Model) {
Expand Down Expand Up @@ -76,23 +76,23 @@ define([
*/
this.readyPromise = when.defer();

this._batchLength = 0;
this._featuresLength = 0;
this._batchTableResources = undefined;
this._models = undefined;
this._features = undefined;
}

defineProperties(Batched3DModel3DTileContentProvider.prototype, {
/**
* DOC_TBA
* Gets the number of features in the tile, i.e., the number of 3D models in the batch.
*
* @memberof Batched3DModel3DTileContentProvider.prototype
*
* @type {Number}
* @readonly
*/
batchLength : {
featuresLength : {
get : function() {
return this._batchLength;
return this._featuresLength;
}
},

Expand All @@ -106,31 +106,31 @@ define([
}
});

function createModels(content) {
function createFeatures(content) {
var tileset = content._tileset;
var batchLength = content._batchLength;
if (!defined(content._models) && (batchLength > 0)) {
var models = new Array(batchLength);
for (var i = 0; i < batchLength; ++i) {
models[i] = new BatchedModel(tileset, content._batchTableResources, i);
var featuresLength = content._featuresLength;
if (!defined(content._features) && (featuresLength > 0)) {
var features = new Array(featuresLength);
for (var i = 0; i < featuresLength; ++i) {
features[i] = new Cesium3DTileFeature(tileset, content._batchTableResources, i);
}
content._models = models;
content._features = features;
}
}

/**
* DOC_TBA
*/
Batched3DModel3DTileContentProvider.prototype.getModel = function(batchId) {
var batchLength = this._batchLength;
Batched3DModel3DTileContentProvider.prototype.getFeature = function(batchId) {
var featuresLength = this._featuresLength;
//>>includeStart('debug', pragmas.debug);
if (!defined(batchId) || (batchId < 0) || (batchId >= batchLength)) {
throw new DeveloperError('batchId is required and between zero and batchLength - 1 (' + (batchLength - 1) + ').');
if (!defined(batchId) || (batchId < 0) || (batchId >= featuresLength)) {
throw new DeveloperError('batchId is required and between zero and featuresLength - 1 (' + (featuresLength - 1) + ').');
}
//>>includeEnd('debug');

createModels(this);
return this._models[batchId];
createFeatures(this);
return this._features[batchId];
};

var sizeOfUint32 = Uint32Array.BYTES_PER_ELEMENT;
Expand Down Expand Up @@ -195,7 +195,7 @@ define([
byteOffset += sizeOfUint32;

var batchLength = view.getUint32(byteOffset, true);
this._batchLength = batchLength;
this._featuresLength = batchLength;
byteOffset += sizeOfUint32;

var batchTableResources = new Cesium3DTileBatchTableResources(this, batchLength);
Expand Down
80 changes: 40 additions & 40 deletions Source/Scene/Cesium3DTileBatchTableResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ define([
/**
* DOC_TBA
*/
function Cesium3DTileBatchTableResources(contentProvider, size) {
this._batchLength = defaultValue(size, 0);
function Cesium3DTileBatchTableResources(contentProvider, featuresLength) {
featuresLength = defaultValue(featuresLength, 0);
this._featuresLength = featuresLength;
this._batchValues = undefined; // Per-model show/color
this._batchValuesDirty = false;
this._batchTexture = undefined;
Expand All @@ -59,12 +60,11 @@ define([
var textureDimensions;
var textureStep;

var batchLength = this._batchLength;
if (batchLength > 0) {
if (featuresLength > 0) {
// PERFORMANCE_IDEA: this can waste memory in the last row in the uncommon case
// when more than one row is needed (e.g., > 16K models in one tile)
var width = Math.min(batchLength, ContextLimits.maximumTextureSize);
var height = Math.ceil(batchLength / ContextLimits.maximumTextureSize);
var width = Math.min(featuresLength, ContextLimits.maximumTextureSize);
var height = Math.ceil(featuresLength / ContextLimits.maximumTextureSize);
var stepX = 1.0 / width;
var centerX = stepX * 0.5;
var stepY = 1.0 / height;
Expand All @@ -90,9 +90,9 @@ define([
* @type {Number}
* @readonly
*/
batchLength : {
featuresLength : {
get : function() {
return this._batchLength;
return this._featuresLength;
}
},

Expand Down Expand Up @@ -137,10 +137,10 @@ define([
* DOC_TBA
*/
Cesium3DTileBatchTableResources.prototype.setShow = function(batchId, value) {
var batchLength = this._batchLength;
var featuresLength = this._featuresLength;
//>>includeStart('debug', pragmas.debug);
if (!defined(batchId) || (batchId < 0) || (batchId > batchLength)) {
throw new DeveloperError('batchId is required and between zero and batchLength - 1 (' + batchLength - + ').');
if (!defined(batchId) || (batchId < 0) || (batchId > featuresLength)) {
throw new DeveloperError('batchId is required and between zero and featuresLength - 1 (' + featuresLength - + ').');
}

if (!defined(value)) {
Expand All @@ -167,10 +167,10 @@ define([
* DOC_TBA
*/
Cesium3DTileBatchTableResources.prototype.getShow = function(batchId) {
var batchLength = this._batchLength;
var featuresLength = this._featuresLength;
//>>includeStart('debug', pragmas.debug);
if (!defined(batchId) || (batchId < 0) || (batchId > batchLength)) {
throw new DeveloperError('batchId is required and between zero and batchLength - 1 (' + batchLength - + ').');
if (!defined(batchId) || (batchId < 0) || (batchId > featuresLength)) {
throw new DeveloperError('batchId is required and between zero and featuresLength - 1 (' + featuresLength - + ').');
}
//>>includeEnd('debug');

Expand All @@ -189,10 +189,10 @@ define([
* DOC_TBA
*/
Cesium3DTileBatchTableResources.prototype.setColor = function(batchId, value) {
var batchLength = this._batchLength;
var featuresLength = this._featuresLength;
//>>includeStart('debug', pragmas.debug);
if (!defined(batchId) || (batchId < 0) || (batchId > batchLength)) {
throw new DeveloperError('batchId is required and between zero and batchLength - 1 (' + batchLength - + ').');
if (!defined(batchId) || (batchId < 0) || (batchId > featuresLength)) {
throw new DeveloperError('batchId is required and between zero and featuresLength - 1 (' + featuresLength - + ').');
}

if (!defined(value)) {
Expand Down Expand Up @@ -229,8 +229,8 @@ define([
}
//>>includeEnd('debug');

var batchLength = this._batchLength;
for (var i = 0; i < batchLength; ++i) {
var featuresLength = this._featuresLength;
for (var i = 0; i < featuresLength; ++i) {
// PERFORMANCE_IDEA: duplicate part of setColor here to factor things out of the loop
this.setColor(i, value);
}
Expand All @@ -240,10 +240,10 @@ define([
* DOC_TBA
*/
Cesium3DTileBatchTableResources.prototype.getColor = function(batchId, result) {
var batchLength = this._batchLength;
var featuresLength = this._featuresLength;
//>>includeStart('debug', pragmas.debug);
if (!defined(batchId) || (batchId < 0) || (batchId > batchLength)) {
throw new DeveloperError('batchId is required and between zero and batchLength - 1 (' + batchLength - + ').');
if (!defined(batchId) || (batchId < 0) || (batchId > featuresLength)) {
throw new DeveloperError('batchId is required and between zero and featuresLength - 1 (' + featuresLength - + ').');
}

if (!defined(result)) {
Expand Down Expand Up @@ -299,10 +299,10 @@ define([
* DOC_TBA
*/
Cesium3DTileBatchTableResources.prototype.getProperty = function(batchId, name) {
var batchLength = this._batchLength;
var featuresLength = this._featuresLength;
//>>includeStart('debug', pragmas.debug);
if (!defined(batchId) || (batchId < 0) || (batchId > batchLength)) {
throw new DeveloperError('batchId is required and between zero and batchLength - 1 (' + batchLength - + ').');
if (!defined(batchId) || (batchId < 0) || (batchId > featuresLength)) {
throw new DeveloperError('batchId is required and between zero and featuresLength - 1 (' + featuresLength - + ').');
}

if (!defined(name)) {
Expand All @@ -327,10 +327,10 @@ define([
* DOC_TBA
*/
Cesium3DTileBatchTableResources.prototype.setProperty = function(batchId, name, value) {
var batchLength = this._batchLength;
var featuresLength = this._featuresLength;
//>>includeStart('debug', pragmas.debug);
if (!defined(batchId) || (batchId < 0) || (batchId > batchLength)) {
throw new DeveloperError('batchId is required and between zero and batchLength - 1 (' + batchLength - + ').');
if (!defined(batchId) || (batchId < 0) || (batchId > featuresLength)) {
throw new DeveloperError('batchId is required and between zero and featuresLength - 1 (' + featuresLength - + ').');
}

if (!defined(name)) {
Expand All @@ -347,15 +347,15 @@ define([

if (!defined(propertyValues)) {
// Property does not exist. Create it.
this._batchTable[name] = new Array(batchLength);
this._batchTable[name] = new Array(featuresLength);
propertyValues = this._batchTable[name];
}

propertyValues[batchId] = clone(value, true);
};

function getGlslComputeSt(batchTableResources) {
// GLSL batchId is zero-based: [0, batchLength - 1]
// GLSL batchId is zero-based: [0, featuresLength - 1]
if (batchTableResources._textureDimensions.y === 1) {
return 'uniform vec4 tiles3d_textureStep; \n' +
'vec2 computeSt(float batchId) \n' +
Expand Down Expand Up @@ -384,7 +384,7 @@ define([
* @private
*/
Cesium3DTileBatchTableResources.prototype.getVertexShaderCallback = function() {
if (this._batchLength === 0) {
if (this._featuresLength === 0) {
// Do not change vertex shader source; the model was not batched
return undefined;
}
Expand Down Expand Up @@ -426,7 +426,7 @@ define([
* @private
*/
Cesium3DTileBatchTableResources.prototype.getFragmentShaderCallback = function() {
if (this._batchLength === 0) {
if (this._featuresLength === 0) {
// Do not change fragment shader source; the model was not batched
return undefined;
}
Expand Down Expand Up @@ -494,7 +494,7 @@ define([
* @private
*/
Cesium3DTileBatchTableResources.prototype.getUniformMapCallback = function() {
if (this._batchLength === 0) {
if (this._featuresLength === 0) {
// Do not change the uniform map; the model was not batched
return undefined;
}
Expand Down Expand Up @@ -522,7 +522,7 @@ define([
* @private
*/
Cesium3DTileBatchTableResources.prototype.getPickVertexShaderCallback = function() {
if (this._batchLength === 0) {
if (this._featuresLength === 0) {
// Do not change vertex shader source; the model was not batched
return undefined;
}
Expand Down Expand Up @@ -564,7 +564,7 @@ define([
* @private
*/
Cesium3DTileBatchTableResources.prototype.getPickFragmentShaderCallback = function() {
if (this._batchLength === 0) {
if (this._featuresLength === 0) {
// Do not change fragment shader source; the model was not batched
return undefined;
}
Expand Down Expand Up @@ -614,7 +614,7 @@ define([
* @private
*/
Cesium3DTileBatchTableResources.prototype.getPickUniformMapCallback = function() {
if (this._batchLength === 0) {
if (this._featuresLength === 0) {
// Do not change the uniform map; the model was not batched
return undefined;
}
Expand Down Expand Up @@ -661,8 +661,8 @@ define([
}

function createPickTexture(batchTableResources, context) {
var batchLength = batchTableResources._batchLength;
if (!defined(batchTableResources._pickTexture) && (batchLength > 0)) {
var featuresLength = batchTableResources._featuresLength;
if (!defined(batchTableResources._pickTexture) && (featuresLength > 0)) {
var pickIds = batchTableResources._pickIds;
var byteLength = getByteLength(batchTableResources);
var bytes = new Uint8Array(byteLength);
Expand All @@ -672,8 +672,8 @@ define([
// a continuous range of pickIds and then converting the base pickId + batchId
// to RGBA in the shader. The only consider is precision issues, which might
// not be an issue in WebGL 2.
for (var i = 0; i < batchLength; ++i) {
var pickId = context.createPickId(contentProvider.getModel(i));
for (var i = 0; i < featuresLength; ++i) {
var pickId = context.createPickId(contentProvider.getFeature(i));
pickIds.push(pickId);

var pickColor = pickId.color;
Expand Down
27 changes: 27 additions & 0 deletions Source/Scene/Cesium3DTileContentProvider.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/*global define*/
define([
'../Core/defineProperties',
'../Core/DeveloperError'
], function(
defineProperties,
DeveloperError) {
"use strict";

Expand Down Expand Up @@ -41,6 +43,31 @@ define([
this.readyPromise = undefined;
}

defineProperties(Cesium3DTileContentProvider.prototype, {
/**
* Gets the number of features in the tile.
*
* @memberof Cesium3DTileContentProvider.prototype
*
* @type {Number}
* @readonly
*/
featuresLength : {
get : function() {
DeveloperError.throwInstantiationError();
}
},

/**
* DOC_TBA
*/
batchTableResources : {
get : function() {
DeveloperError.throwInstantiationError();
}
}
});

/**
* Requests the tile's content.
* <p>
Expand Down
Loading