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 Points updates - quantization and oct-encoding #4183

Merged
merged 34 commits into from Sep 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1937747
Doc fixes
lilleyse Jul 16, 2016
db2d3ec
Remove workaround2657
lilleyse Jul 17, 2016
f368971
Simplify TileOrientedBoundingBox constructor
lilleyse Jul 17, 2016
b159f72
Update the bounding volumes
lilleyse Jul 17, 2016
e69e0a4
Updates
lilleyse Jul 18, 2016
f3d1054
Added tileset.modelMatrix
lilleyse Jul 18, 2016
1e63cd0
Merge branch '3d-tiles' into 3d-tiles-transform
lilleyse Aug 8, 2016
654e053
Merge branch '3d-tiles' into 3d-tiles-transform
lilleyse Aug 9, 2016
18212bb
Fix broken tests
lilleyse Aug 10, 2016
44a3fe0
Merge branch '3d-tiles' into 3d-tiles-transform
lilleyse Aug 11, 2016
4569101
Merge branch '3d-tiles' into 3d-tiles-transform
lilleyse Aug 18, 2016
4a18731
Merge branch '3d-tiles' into 3d-tiles-transform
lilleyse Aug 23, 2016
b05417e
Fix bad merge
lilleyse Aug 23, 2016
f21b076
Points with quantization and oct encoded normals
lilleyse Aug 11, 2016
c677114
Added tests
lilleyse Aug 11, 2016
27f8456
Added picking support
lilleyse Aug 11, 2016
075bbfa
Added picking test
lilleyse Aug 15, 2016
b0d9a85
Added getPropertyArray to Cesium3DTileFeatureTableResources to suppor…
lilleyse Aug 18, 2016
7a6f245
Update offsets for quantized points
lilleyse Aug 22, 2016
1699954
Batch table binary
lilleyse Aug 23, 2016
232234f
Refactoring and updates
lilleyse Aug 24, 2016
b048042
More updates
lilleyse Aug 26, 2016
62a6fbd
Change point backface culling to false
pjcozzi Aug 26, 2016
af6c677
Merge pull request #4228 from AnalyticalGraphicsInc/batch-table-binary
pjcozzi Aug 26, 2016
736cc26
Tests for getPropertyArray
lilleyse Aug 26, 2016
6b6bf06
Renamed Points3DTileContent to PointCloud3DTileContent
lilleyse Aug 26, 2016
0cbef73
Renamed folder from Points to PointCloud
lilleyse Aug 29, 2016
4099695
More renaming
lilleyse Aug 29, 2016
2a3eef3
Streamline ModelInstanceCollection and fix shadow bugs
lilleyse Aug 27, 2016
ecef596
Tile transform tests and EAST_NORTH_UP property for i3dm
lilleyse Aug 30, 2016
1e192e4
Removed CesiumMath
lilleyse Aug 31, 2016
0f14709
EAST_NORTH_UP added to all i3dm and cmpt tilesets
lilleyse Sep 1, 2016
a162752
Merge pull request #4256 from AnalyticalGraphicsInc/transform-tests
pjcozzi Sep 1, 2016
4344f74
Check if batchTableBinary is defined before copying buffer
lilleyse Sep 2, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion Apps/Sandcastle/gallery/3D Tiles.html
Expand Up @@ -53,7 +53,13 @@
}, {
name : 'Composite', url : '../../../Specs/Data/Cesium3DTiles/Composite/Composite/'
}, {
name : 'Points', url : '../../../Specs/Data/Cesium3DTiles/Points/PointsRGB/'
name : 'PointCloud', url : '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudRGB/'
}, {
name : 'PointCloudConstantColor', url : '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudConstantColor/'
}, {
name : 'PointCloudNormals', url : '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudQuantizedOctEncoded/'
}, {
name : 'PointCloudBatched', url : '../../../Specs/Data/Cesium3DTiles/PointCloud/PointCloudBatched/'
}];

var tileset;
Expand Down
31 changes: 31 additions & 0 deletions Source/Core/ComponentDatatype.js
Expand Up @@ -297,5 +297,36 @@ define([
}
};

/**
* Get the ComponentDatatype from its name.
*
* @param {String} name The name of the ComponentDatatype.
* @returns {ComponentDatatype} The ComponentDatatype.
*
* @exception {DeveloperError} name is not a valid value.
*/
ComponentDatatype.fromName = function(name) {
switch (name) {
case 'BYTE':
return ComponentDatatype.BYTE;
case 'UNSIGNED_BYTE':
return ComponentDatatype.UNSIGNED_BYTE;
case 'SHORT':
return ComponentDatatype.SHORT;
case 'UNSIGNED_SHORT':
return ComponentDatatype.UNSIGNED_SHORT;
case 'INT':
return ComponentDatatype.INT;
case 'UNSIGNED_INT':
return ComponentDatatype.UNSIGNED_INT;
case 'FLOAT':
return ComponentDatatype.FLOAT;
case 'DOUBLE':
return ComponentDatatype.DOUBLE;
default:
throw new DeveloperError('name is not a valid value.');
}
};

return freezeObject(ComponentDatatype);
});
21 changes: 9 additions & 12 deletions Source/Core/PointGeometry.js
Expand Up @@ -50,6 +50,9 @@ define([
if (!defined(options.positionsTypedArray)) {
throw new DeveloperError('options.positionsTypedArray is required.');
}
if (!defined(options.colorsTypedArray)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please cherry-pick this for master.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what's in master, I had removed it when I was still using the PointGeometry to render Points3DTileContent, but since that isn't the case anymore I reverted all the changes.

throw new DeveloperError('options.colorsTypedArray is required');
}
//>>includeEnd('debug');

this._positionsTypedArray = options.positionsTypedArray;
Expand Down Expand Up @@ -77,18 +80,12 @@ define([
values : positions
});

var colors = pointGeometry._colorsTypedArray;
if (defined(colors)) {
// Check if the colors are provided as rgb or rgba
var colorComponentsPerAttribute = (colors.length === positions.length) ? 3 : 4;

attributes.color = new GeometryAttribute({
componentDatatype : ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : colorComponentsPerAttribute,
values : colors,
normalize : true
});
}
attributes.color = new GeometryAttribute({
componentDatatype : ComponentDatatype.UNSIGNED_BYTE,
componentsPerAttribute : 3,
values : pointGeometry._colorsTypedArray,
normalize : true
});

// User provided bounding sphere to save computation time.
var boundingSphere = pointGeometry._boundingSphere;
Expand Down
77 changes: 53 additions & 24 deletions Source/Scene/Batched3DModel3DTileContent.js
Expand Up @@ -14,7 +14,7 @@ define([
'../Core/RequestType',
'../ThirdParty/when',
'./Cesium3DTileFeature',
'./Cesium3DTileBatchTableResources',
'./Cesium3DTileBatchTable',
'./Cesium3DTileContentState',
'./Model'
], function(
Expand All @@ -32,7 +32,7 @@ define([
RequestType,
when,
Cesium3DTileFeature,
Cesium3DTileBatchTableResources,
Cesium3DTileBatchTable,
Cesium3DTileContentState,
Model) {
'use strict';
Expand All @@ -57,7 +57,7 @@ define([
* The following properties are part of the {@link Cesium3DTileContent} interface.
*/
this.state = Cesium3DTileContentState.UNLOADED;
this.batchTableResources = undefined;
this.batchTable = undefined;
this.featurePropertiesDirty = false;

this._contentReadyToProcessPromise = when.defer();
Expand Down Expand Up @@ -120,7 +120,7 @@ define([
* Part of the {@link Cesium3DTileContent} interface.
*/
Batched3DModel3DTileContent.prototype.hasProperty = function(name) {
return this.batchTableResources.hasProperty(name);
return this.batchTable.hasProperty(name);
};

/**
Expand Down Expand Up @@ -199,27 +199,54 @@ define([
var byteLength = view.getUint32(byteOffset, true);
byteOffset += sizeOfUint32;

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

var batchTableResources = new Cesium3DTileBatchTableResources(this, batchLength);
this.batchTableResources = batchTableResources;
var batchTableBinaryByteLength = view.getUint32(byteOffset, true);
byteOffset += sizeOfUint32;

var batchTableByteLength = view.getUint32(byteOffset, true);
var batchLength = view.getUint32(byteOffset, true);
byteOffset += sizeOfUint32;
if (batchTableByteLength > 0) {
var batchTableString = getStringFromTypedArray(uint8Array, byteOffset, batchTableByteLength);
byteOffset += batchTableByteLength;

// TODO : remove this legacy check before merging into master
// Legacy header: [batchLength] [batchTableByteLength]
// Current header: [batchTableJsonByteLength] [batchTableBinaryByteLength] [batchLength]
// If the header is in the legacy format 'batchLength' will be the start of the JSON string (a quotation mark) or the glTF magic.
// Accordingly the first byte of uint32 will be either 0x22 or 0x67 and so the uint32 will exceed any reasonable 'batchLength'.
if (batchLength > 10000000) {
byteOffset -= sizeOfUint32;
batchLength = batchTableJsonByteLength;
batchTableJsonByteLength = batchTableBinaryByteLength;
batchTableBinaryByteLength = 0;
console.log('Warning: b3dm header is using the legacy format [batchLength] [batchTableByteLength]. The new format is [batchTableJsonByteLength] [batchTableBinaryByteLength] [batchLength] from https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/TileFormats/Batched3DModel/README.md.');
}

this._featuresLength = batchLength;

var batchTableJson;
var batchTableBinary;
if (batchTableJsonByteLength > 0) {
// PERFORMANCE_IDEA: is it possible to allocate this on-demand? Perhaps keep the
// arraybuffer/string compressed in memory and then decompress it when it is first accessed.
//
// We could also make another request for it, but that would make the property set/get
// API async, and would double the number of numbers in some cases.
batchTableResources.batchTable = JSON.parse(batchTableString);
var batchTableString = getStringFromTypedArray(uint8Array, byteOffset, batchTableJsonByteLength);
batchTableJson = JSON.parse(batchTableString);
byteOffset += batchTableJsonByteLength;

if (batchTableBinaryByteLength > 0) {
// Has a batch table binary
batchTableBinary = new Uint8Array(arrayBuffer, byteOffset, batchTableBinaryByteLength);
// Copy the batchTableBinary section and let the underlying ArrayBuffer be freed
batchTableBinary = new Uint8Array(batchTableBinary);
byteOffset += batchTableBinaryByteLength;
}
}

var batchTable = new Cesium3DTileBatchTable(this, batchLength, batchTableJson, batchTableBinary);
this.batchTable = batchTable;

var gltfByteLength = byteStart + byteLength - byteOffset;
var gltfView = new Uint8Array(arrayBuffer, byteOffset, gltfByteLength);

Expand All @@ -229,13 +256,14 @@ define([
gltf : gltfView,
cull : false, // The model is already culled by the 3D tiles
releaseGltfJson : true, // Models are unique and will not benefit from caching so save memory
vertexShaderLoaded : batchTableResources.getVertexShaderCallback(),
fragmentShaderLoaded : batchTableResources.getFragmentShaderCallback(),
uniformMapLoaded : batchTableResources.getUniformMapCallback(),
pickVertexShaderLoaded : batchTableResources.getPickVertexShaderCallback(),
pickFragmentShaderLoaded : batchTableResources.getPickFragmentShaderCallback(),
pickUniformMapLoaded : batchTableResources.getPickUniformMapCallback(),
basePath : this._url
basePath : this._url,
modelMatrix : this._tile.computedTransform,
vertexShaderLoaded : batchTable.getVertexShaderCallback(),
fragmentShaderLoaded : batchTable.getFragmentShaderCallback(),
uniformMapLoaded : batchTable.getUniformMapCallback(),
pickVertexShaderLoaded : batchTable.getPickVertexShaderCallback(),
pickFragmentShaderLoaded : batchTable.getPickFragmentShaderCallback(),
pickUniformMapLoaded : batchTable.getPickUniformMapCallback()
});

this._model = model;
Expand All @@ -258,7 +286,7 @@ define([
*/
Batched3DModel3DTileContent.prototype.applyDebugSettings = function(enabled, color) {
color = enabled ? color : Color.WHITE;
this.batchTableResources.setAllColor(color);
this.batchTable.setAllColor(color);
};

/**
Expand All @@ -267,13 +295,14 @@ define([
Batched3DModel3DTileContent.prototype.update = function(tileset, frameState) {
var oldAddCommand = frameState.addCommand;
if (frameState.passes.render) {
frameState.addCommand = this.batchTableResources.getAddCommand();
frameState.addCommand = this.batchTable.getAddCommand();
}

// In the PROCESSING state we may be calling update() to move forward
// the content's resource loading. In the READY state, it will
// actually generate commands.
this.batchTableResources.update(tileset, frameState);
this.batchTable.update(tileset, frameState);
this._model.modelMatrix = this._tile.computedTransform;
this._model.update(frameState);

frameState.addCommand = oldAddCommand;
Expand All @@ -291,7 +320,7 @@ define([
*/
Batched3DModel3DTileContent.prototype.destroy = function() {
this._model = this._model && this._model.destroy();
this.batchTableResources = this.batchTableResources && this.batchTableResources.destroy();
this.batchTable = this.batchTable && this.batchTable.destroy();

return destroyObject(this);
};
Expand Down