Skip to content

Commit

Permalink
Merge pull request #5461 from AnalyticalGraphicsInc/3d-tiles-cleanup
Browse files Browse the repository at this point in the history
3D Tiles Cleanup
  • Loading branch information
pjcozzi committed Jun 13, 2017
2 parents 172c05e + b45579b commit 4923555
Show file tree
Hide file tree
Showing 46 changed files with 1,535 additions and 1,425 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
["${suffix} === 'knob'", "color('yellow')"],
["${suffix} === ''", "color('lime')"],
["${suffix} === null", "color('gray')"],
["true", "color('blue'"]
["true", "color('blue')"]
]
}
});
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Heap.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ define([
},

/**
* Gets and sets the maximum size of the heap.
* Gets or sets the maximum size of the heap.
*
* @memberof Heap.prototype
*
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/ManagedArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ define([
* @type Array
* @readonly
*/
internalArray : {
values : {
get : function() {
return this._array;
}
Expand Down
74 changes: 74 additions & 0 deletions Source/Scene/AttributeType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*global define*/
define([
'../Core/freezeObject'
], function(
freezeObject) {
'use strict';

/**
* An enum describing the attribute type for glTF and 3D Tiles.
*
* @exports AttributeType
*
* @private
*/
var AttributeType = {
/**
* The attribute is a single component.
*
* @type {String}
* @constant
*/
SCALAR : 'SCALAR',

/**
* The attribute is a two-component vector.
*
* @type {String}
* @constant
*/
VEC2 : 'VEC2',

/**
* The attribute is a three-component vector.
*
* @type {String}
* @constant
*/
VEC3 : 'VEC3',

/**
* The attribute is a four-component vector.
*
* @type {String}
* @constant
*/
VEC4 : 'VEC4',

/**
* The attribute is a 2x2 matrix.
*
* @type {String}
* @constant
*/
MAT2 : 'MAT2',

/**
* The attribute is a 3x3 matrix.
*
* @type {String}
* @constant
*/
MAT3 : 'MAT3',

/**
* The attribute is a 4x4 matrix.
*
* @type {String}
* @constant
*/
MAT4 : 'MAT4'
};

return freezeObject(AttributeType);
});
65 changes: 38 additions & 27 deletions Source/Scene/Batched3DModel3DTileContent.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,59 @@
/*global define*/
define([
'../Core/Check',
'../Core/Color',
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/deprecationWarning',
'../Core/destroyObject',
'../Core/DeveloperError',
'../Core/FeatureDetection',
'../Core/getAbsoluteUri',
'../Core/getBaseUri',
'../Core/getStringFromTypedArray',
'../Core/RequestType',
'../Core/RuntimeError',
'./Cesium3DTileBatchTable',
'./Cesium3DTileFeature',
'./Cesium3DTileFeatureTable',
'./getAttributeOrUniformBySemantic',
'./Model'
], function(
Check,
Color,
defaultValue,
defined,
defineProperties,
deprecationWarning,
destroyObject,
DeveloperError,
FeatureDetection,
getAbsoluteUri,
getBaseUri,
getStringFromTypedArray,
RequestType,
RuntimeError,
Cesium3DTileBatchTable,
Cesium3DTileFeature,
Cesium3DTileFeatureTable,
getAttributeOrUniformBySemantic,
Model) {
'use strict';

// Bail out if the browser doesn't support typed arrays, to prevent the setup function
// from failing, since we won't be able to create a WebGL context anyway.
if (!FeatureDetection.supportsTypedArrays()) {
return {};
}

/**
* Represents the contents of a
* {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/TileFormats/Batched3DModel/README.md|Batched 3D Model}
* tile in a {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/README.md|3D Tiles} tileset.
* <p>
* Implements the {@link Cesium3DTileContent} interface.
* </p>
*
* @alias Batched3DModel3DTileContent
* @constructor
Expand All @@ -54,7 +69,7 @@ define([
this._features = undefined;

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#featurePropertiesDirty
*/
this.featurePropertiesDirty = false;

Expand All @@ -66,7 +81,7 @@ define([

defineProperties(Batched3DModel3DTileContent.prototype, {
/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#featuresLength
*/
featuresLength : {
get : function() {
Expand All @@ -75,7 +90,7 @@ define([
},

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#pointsLength
*/
pointsLength : {
get : function() {
Expand All @@ -84,7 +99,7 @@ define([
},

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#trianglesLength
*/
trianglesLength : {
get : function() {
Expand All @@ -93,7 +108,7 @@ define([
},

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#geometryByteLength
*/
geometryByteLength : {
get : function() {
Expand All @@ -102,7 +117,7 @@ define([
},

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#texturesByteLength
*/
texturesByteLength : {
get : function() {
Expand All @@ -111,7 +126,7 @@ define([
},

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#batchTableByteLength
*/
batchTableByteLength : {
get : function() {
Expand All @@ -120,7 +135,7 @@ define([
},

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#innerContents
*/
innerContents : {
get : function() {
Expand All @@ -129,7 +144,7 @@ define([
},

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#readyPromise
*/
readyPromise : {
get : function() {
Expand All @@ -138,7 +153,7 @@ define([
},

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#tileset
*/
tileset : {
get : function() {
Expand All @@ -147,7 +162,7 @@ define([
},

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#tile
*/
tile : {
get : function() {
Expand All @@ -156,7 +171,7 @@ define([
},

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#url
*/
url: {
get: function() {
Expand All @@ -165,7 +180,7 @@ define([
},

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#batchTable
*/
batchTable : {
get : function() {
Expand Down Expand Up @@ -229,12 +244,10 @@ define([
var view = new DataView(arrayBuffer);
byteOffset += sizeOfUint32; // Skip magic

//>>includeStart('debug', pragmas.debug);
var version = view.getUint32(byteOffset, true);
if (version !== 1) {
throw new DeveloperError('Only Batched 3D Model version 1 is supported. Version ' + version + ' is not.');
throw new RuntimeError('Only Batched 3D Model version 1 is supported. Version ' + version + ' is not.');
}
//>>includeEnd('debug');
byteOffset += sizeOfUint32;

var byteLength = view.getUint32(byteOffset, true);
Expand Down Expand Up @@ -324,11 +337,9 @@ define([
content._batchTable = batchTable;

var gltfByteLength = byteStart + byteLength - byteOffset;
//>>includeStart('debug', pragmas.debug);
if (gltfByteLength === 0) {
throw new DeveloperError('glTF byte length is zero, i3dm must have a glTF to instance.');
throw new RuntimeError('glTF byte length must be greater than 0.');
}
//>>includeEnd('debug');
var gltfView = new Uint8Array(arrayBuffer, byteOffset, gltfByteLength);

var pickObject = {
Expand Down Expand Up @@ -373,18 +384,18 @@ define([
}

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#hasProperty
*/
Batched3DModel3DTileContent.prototype.hasProperty = function(batchId, name) {
return this._batchTable.hasProperty(batchId, name);
};

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#getFeature
*/
Batched3DModel3DTileContent.prototype.getFeature = function(batchId) {
var featuresLength = this.featuresLength;
//>>includeStart('debug', pragmas.debug);
var featuresLength = this.featuresLength;
if (!defined(batchId) || (batchId < 0) || (batchId >= featuresLength)) {
throw new DeveloperError('batchId is required and between zero and featuresLength - 1 (' + (featuresLength - 1) + ').');
}
Expand All @@ -395,7 +406,7 @@ define([
};

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#applyDebugSettings
*/
Batched3DModel3DTileContent.prototype.applyDebugSettings = function(enabled, color) {
color = enabled ? color : Color.WHITE;
Expand All @@ -407,14 +418,14 @@ define([
};

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#applyStyle
*/
Batched3DModel3DTileContent.prototype.applyStyle = function(frameState, style) {
this._batchTable.applyStyle(frameState, style);
};

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#update
*/
Batched3DModel3DTileContent.prototype.update = function(tileset, frameState) {
var commandStart = frameState.commandList.length;
Expand All @@ -436,14 +447,14 @@ define([
};

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#isDestroyed
*/
Batched3DModel3DTileContent.prototype.isDestroyed = function() {
return false;
};

/**
* Part of the {@link Cesium3DTileContent} interface.
* @inheritdoc Cesium3DTileContent#destroy
*/
Batched3DModel3DTileContent.prototype.destroy = function() {
this._model = this._model && this._model.destroy();
Expand Down

0 comments on commit 4923555

Please sign in to comment.