Skip to content
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
61 changes: 51 additions & 10 deletions Source/Scene/Batched3DModel3DTileContent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*global define*/
define([
'../Core/Color',
'../Core/ComponentDatatype',
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
Expand All @@ -19,10 +20,12 @@ define([
'./Cesium3DTileBatchTable',
'./Cesium3DTileContentState',
'./Cesium3DTileFeature',
'./Cesium3DTileFeatureTable',
'./getAttributeOrUniformBySemantic',
'./Model'
], function(
Color,
ComponentDatatype,
defaultValue,
defined,
defineProperties,
Expand All @@ -41,6 +44,7 @@ define([
Cesium3DTileBatchTable,
Cesium3DTileContentState,
Cesium3DTileFeature,
Cesium3DTileFeatureTable,
getAttributeOrUniformBySemantic,
Model) {
'use strict';
Expand Down Expand Up @@ -296,28 +300,65 @@ define([
var byteLength = view.getUint32(byteOffset, true);
byteOffset += sizeOfUint32;

var featureTableJsonByteLength = view.getUint32(byteOffset, true);
byteOffset += sizeOfUint32;

var featureTableBinaryByteLength = view.getUint32(byteOffset, true);
byteOffset += sizeOfUint32;

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

var batchTableBinaryByteLength = view.getUint32(byteOffset, true);
byteOffset += sizeOfUint32;

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

// 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) {
// Legacy header #1: [batchLength] [batchTableByteLength]
// Legacy header #2: [batchTableJsonByteLength] [batchTableBinaryByteLength] [batchLength]
// Current header: [featureTableJsonByteLength] [featureTableBinaryByteLength] [batchTableJsonByteLength] [batchTableBinaryByteLength]
// If the header is in the first legacy format 'batchTableJsonByteLength' will be the start of the JSON string (a quotation mark) or the glTF magic.
// Accordingly its first byte will be either 0x22 or 0x67, and so the minimum uint32 expected is 0x22000000 = 570425344 = 570MB. It is unlikely that the feature table JSON will exceed this length.
// The check for the second legacy format is similar, except it checks 'batchTableBinaryByteLength' instead
if (batchTableJsonByteLength >= 570425344) {
// First legacy check
byteOffset -= sizeOfUint32 * 2;
batchLength = featureTableJsonByteLength;
batchTableJsonByteLength = featureTableBinaryByteLength;
batchTableBinaryByteLength = 0;
featureTableJsonByteLength = 0;
featureTableBinaryByteLength = 0;
deprecationWarning('b3dm-legacy-header', 'This b3dm header is using the legacy format [batchLength] [batchTableByteLength]. The new format is [featureTableJsonByteLength] [featureTableBinaryByteLength] [batchTableJsonByteLength] [batchTableBinaryByteLength] from https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/TileFormats/Batched3DModel/README.md.');
} else if (batchTableBinaryByteLength >= 570425344) {
// Second legacy check
byteOffset -= sizeOfUint32;
batchLength = batchTableJsonByteLength;
batchTableJsonByteLength = batchTableBinaryByteLength;
batchTableBinaryByteLength = 0;
deprecationWarning('b3dm-legacy-header', 'This 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.');
batchTableJsonByteLength = featureTableJsonByteLength;
batchTableBinaryByteLength = featureTableBinaryByteLength;
featureTableJsonByteLength = 0;
featureTableBinaryByteLength = 0;
deprecationWarning('b3dm-legacy-header', 'This b3dm header is using the legacy format [batchTableJsonByteLength] [batchTableBinaryByteLength] [batchLength]. The new format is [featureTableJsonByteLength] [featureTableBinaryByteLength] [batchTableJsonByteLength] [batchTableBinaryByteLength] from https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/TileFormats/Batched3DModel/README.md.');
}

var featureTableJson;
if (featureTableJsonByteLength === 0) {
featureTableJson = {
BATCH_LENGTH : defaultValue(batchLength, 0)
};
} else {
var featureTableString = getStringFromTypedArray(uint8Array, byteOffset, featureTableJsonByteLength);
featureTableJson = JSON.parse(featureTableString);
byteOffset += featureTableJsonByteLength;
}

var featureTableBinary = new Uint8Array(arrayBuffer, byteOffset, featureTableBinaryByteLength);
byteOffset += featureTableBinaryByteLength;

var featureTable = new Cesium3DTileFeatureTable(featureTableJson, featureTableBinary);

batchLength = featureTable.getGlobalProperty('BATCH_LENGTH', ComponentDatatype.UNSIGNED_INT);
featureTable.featuresLength = batchLength;
this._featuresLength = batchLength;

var batchTableJson;
Expand Down
22 changes: 15 additions & 7 deletions Specs/Cesium3DTilesTester.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*global define*/
define([
'Core/arrayFill',
'Core/Color',
'Core/defaultValue',
'Core/defined',
Expand All @@ -9,6 +10,7 @@ define([
'Scene/TileBoundingSphere',
'Specs/pollToPromise'
], function(
arrayFill,
Color,
defaultValue,
defined,
Expand Down Expand Up @@ -216,20 +218,26 @@ define([
var magic = defaultValue(options.magic, [98, 51, 100, 109]);
var version = defaultValue(options.version, 1);
var featuresLength = defaultValue(options.featuresLength, 1);
var featureTableJson = {
BATCH_LENGTH : featuresLength
};
var featureTableJsonString = JSON.stringify(featureTableJson);
var featureTableJsonByteLength = featureTableJsonString.length;

var headerByteLength = 24;
var headerByteLength = 28;
var byteLength = headerByteLength;
var buffer = new ArrayBuffer(byteLength);
var view = new DataView(buffer);
view.setUint8(0, magic[0]);
view.setUint8(1, magic[1]);
view.setUint8(2, magic[2]);
view.setUint8(3, magic[3]);
view.setUint32(4, version, true); // version
view.setUint32(8, byteLength, true); // byteLength
view.setUint32(12, 0, true); // batchTableJsonByteLength
view.setUint32(16, 0, true); // batchTableBinaryByteLength
view.setUint32(20, featuresLength, true); // batchLength
view.setUint32(4, version, true); // version
view.setUint32(8, byteLength, true); // byteLength
view.setUint32(12, featureTableJsonByteLength, true); // featureTableJsonByteLength
view.setUint32(16, 0, true); // featureTableBinaryByteLength
view.setUint32(20, 0, true); // batchTableJsonByteLength
view.setUint32(24, 0, true); // batchTableBinaryByteLength

return buffer;
};
Expand All @@ -247,7 +255,7 @@ define([
var featuresLength = defaultValue(options.featuresLength, 1);
var featureTableJson = {
INSTANCES_LENGTH : featuresLength,
POSITION : new Array(featuresLength * 3).fill(0)
POSITION : arrayFill(new Array(featuresLength * 3), 0)
};
var featureTableJsonString = JSON.stringify(featureTableJson);
var featureTableJsonByteLength = featureTableJsonString.length;
Expand Down
Binary file modified Specs/Data/Cesium3DTiles/Batched/BatchedColors/batchedColors.b3dm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"geometricError": 0,
"content": {
"url": "batchedDeprecated.b3dm"
"url": "batchedDeprecated1.b3dm"
}
}
}
Binary file not shown.
41 changes: 41 additions & 0 deletions Specs/Data/Cesium3DTiles/Batched/BatchedDeprecated2/tileset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"asset": {
"version": "0.0"
},
"properties": {
"id": {
"minimum": 0,
"maximum": 9
},
"Longitude": {
"minimum": -1.3196972173766555,
"maximum": -1.3196718547473905
},
"Latitude": {
"minimum": 0.6988624606923348,
"maximum": 0.6988888301460953
},
"Height": {
"minimum": 6.2074098233133554,
"maximum": 12.83180232718587
}
},
"geometricError": 70,
"root": {
"refine": "add",
"boundingVolume": {
"region": [
-1.3197004795898053,
0.6988582109,
-1.3196595204101946,
0.6988897891,
0,
20
]
},
"geometricError": 0,
"content": {
"url": "batchedDeprecated2.b3dm"
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Batched/BatchedWGS84/batchedWGS84.b3dm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Composite/Composite/composite.cmpt
Binary file not shown.
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Hierarchy/BatchTableHierarchy/tile.b3dm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
0,
0,
0,
30
15
]
},
"geometricError": 0,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/Tileset/ll.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/Tileset/lr.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/Tileset/parent.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/Tileset/ul.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/Tileset/ur.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetEmptyRoot/ll.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetEmptyRoot/lr.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetEmptyRoot/ul.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetEmptyRoot/ur.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetInvalid/lr.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetInvalid/ul.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetInvalid/ur.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetOfTilesets/lr.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetOfTilesets/parent.b3dm
Binary file not shown.
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetOfTilesets/ul.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetOfTilesets/ur.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetRefinementMix/ll.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetRefinementMix/lr.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetRefinementMix/parent.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetRefinementMix/ul.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetRefinementMix/ur.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetReplacement1/ll.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetReplacement1/lr.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetReplacement1/parent.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetReplacement1/ul.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetReplacement1/ur.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetReplacement2/ll.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetReplacement2/parent.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetReplacement2/ur.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetReplacement3/ll.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetReplacement3/lr.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetReplacement3/parent.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetReplacement3/ul.b3dm
Binary file not shown.
Binary file modified Specs/Data/Cesium3DTiles/Tilesets/TilesetReplacement3/ur.b3dm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"asset": {
"version": "0.0",
"tilesetVersion": "1.2.3"
"version": "0.0"
},
"properties": {
"id": {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
0,
0,
0,
30
15
]
},
"transform": [
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
21 changes: 17 additions & 4 deletions Specs/Scene/Batched3DModel3DTileContentSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ defineSuite([
var withTransformRegionUrl = './Data/Cesium3DTiles/Batched/BatchedWithTransformRegion/';
var texturedUrl = './Data/Cesium3DTiles/Batched/BatchedTextured/';
var compressedTexturesUrl = './Data/Cesium3DTiles/Batched/BatchedCompressedTextures/';
var deprecatedUrl = './Data/Cesium3DTiles/Batched/BatchedDeprecated/';
var deprecated1Url = './Data/Cesium3DTiles/Batched/BatchedDeprecated1/';
var deprecated2Url = './Data/Cesium3DTiles/Batched/BatchedDeprecated2/';
var gltfZUpUrl = './Data/Cesium3DTiles/Batched/BatchedGltfZUp';

function setCamera(longitude, latitude) {
Expand Down Expand Up @@ -75,9 +76,21 @@ defineSuite([
return Cesium3DTilesTester.loadTileExpectError(scene, arrayBuffer, 'b3dm');
});

it('recognizes the legacy b3dm format', function() {
it('recognizes the legacy 20-byte header', function() {
spyOn(Batched3DModel3DTileContent, '_deprecationWarning');
return Cesium3DTilesTester.loadTileset(scene, deprecatedUrl)
return Cesium3DTilesTester.loadTileset(scene, deprecated1Url)
.then(function(tileset) {
expect(Batched3DModel3DTileContent._deprecationWarning).toHaveBeenCalled();
Cesium3DTilesTester.expectRenderTileset(scene, tileset);
var batchTable = tileset._root._content.batchTable;
expect(batchTable.batchTableJson).toBeDefined();
expect(batchTable.batchTableBinary).toBeUndefined();
});
});

it('recognizes the legacy 24-byte header', function() {
spyOn(Batched3DModel3DTileContent, '_deprecationWarning');
return Cesium3DTilesTester.loadTileset(scene, deprecated2Url)
.then(function(tileset) {
expect(Batched3DModel3DTileContent._deprecationWarning).toHaveBeenCalled();
Cesium3DTilesTester.expectRenderTileset(scene, tileset);
Expand All @@ -89,7 +102,7 @@ defineSuite([

it('logs deprecation warning for use of BATCHID without prefixed underscore', function() {
spyOn(Batched3DModel3DTileContent, '_deprecationWarning');
return Cesium3DTilesTester.loadTileset(scene, deprecatedUrl)
return Cesium3DTilesTester.loadTileset(scene, deprecated1Url)
.then(function(tileset) {
expect(Batched3DModel3DTileContent._deprecationWarning).toHaveBeenCalled();
Cesium3DTilesTester.expectRenderTileset(scene, tileset);
Expand Down
2 changes: 1 addition & 1 deletion Specs/Scene/Cesium3DTilesetSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ defineSuite([
}

function viewAllTiles() {
setZoom(20.0);
setZoom(15.0);
}

function viewRootOnly() {
Expand Down
2 changes: 1 addition & 1 deletion Specs/Scene/Instanced3DModel3DTileContentSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defineSuite([
function setCamera(longitude, latitude) {
// One instance is located at the center, point the camera there
var center = Cartesian3.fromRadians(longitude, latitude);
scene.camera.lookAt(center, new HeadingPitchRange(0.0, -1.57, 30.0));
scene.camera.lookAt(center, new HeadingPitchRange(0.0, -1.57, 27.0));
}

beforeAll(function() {
Expand Down