Skip to content

Commit 9287c3c

Browse files
author
Hannah
authored
Merge pull request #6944 from AnalyticalGraphicsInc/root-public
Make root tile public
2 parents 4c68791 + 68c35b5 commit 9287c3c

22 files changed

+225
-171
lines changed

CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Change Log
1313
* Added `Matrix4.setScale` for setting the scale on an affine transformation matrix [#6888](https://github.com/AnalyticalGraphicsInc/cesium/pull/6888)
1414
* Added `GeocoderViewModel.destinationFound` for specifying a function that is called upon a successful geocode. The default behavior is to fly to the destination found by the geocoder. [#6915](https://github.com/AnalyticalGraphicsInc/cesium/pull/6915)
1515
* Added optional `width` and `height` to `Scene.drillPick` for specifying a search area.
16+
* Added `Cesium3DTileset.root` for getting the root tile of a tileset. [#6944](https://github.com/AnalyticalGraphicsInc/cesium/pull/6944)
1617
* Added `heightReference` to `BoxGraphics`, `CylinderGraphics` and `EllipsoidGraphics`, which can be used to clamp these entity types to terrain [#6932](https://github.com/AnalyticalGraphicsInc/cesium/pull/6932)
1718

1819
##### Fixes :wrench:

Source/Scene/Cesium3DTile.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,21 @@ define([
383383
}
384384
},
385385

386+
/**
387+
* Get the tile's bounding volume.
388+
*
389+
* @memberof Cesium3DTile.prototype
390+
*
391+
* @type {TileBoundingVolume}
392+
* @readonly
393+
* @private
394+
*/
395+
boundingVolume : {
396+
get : function() {
397+
return this._boundingVolume;
398+
}
399+
},
400+
386401
/**
387402
* Get the bounding volume of the tile's contents. This defaults to the
388403
* tile's bounding volume when the content's bounding volume is
@@ -793,7 +808,7 @@ define([
793808
var tileset = this._tileset;
794809
var clippingPlanes = tileset.clippingPlanes;
795810
if (defined(clippingPlanes) && clippingPlanes.enabled) {
796-
var tileTransform = tileset._root.computedTransform;
811+
var tileTransform = tileset.root.computedTransform;
797812
var intersection = clippingPlanes.computeIntersectionWithBoundingVolume(boundingVolume, tileTransform);
798813
this._isClipped = intersection !== Intersect.INSIDE;
799814
if (intersection === Intersect.OUTSIDE) {
@@ -828,7 +843,7 @@ define([
828843
var tileset = this._tileset;
829844
var clippingPlanes = tileset.clippingPlanes;
830845
if (defined(clippingPlanes) && clippingPlanes.enabled) {
831-
var tileTransform = tileset._root.computedTransform;
846+
var tileTransform = tileset.root.computedTransform;
832847
var intersection = clippingPlanes.computeIntersectionWithBoundingVolume(boundingVolume, tileTransform);
833848
this._isClipped = intersection !== Intersect.INSIDE;
834849
if (intersection === Intersect.OUTSIDE) {

Source/Scene/Cesium3DTileBatchTable.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ define([
11811181
};
11821182

11831183
function getColorBlend(batchTable) {
1184-
var tileset = batchTable._content._tileset;
1184+
var tileset = batchTable._content.tileset;
11851185
var colorBlendMode = tileset.colorBlendMode;
11861186
var colorBlendAmount = tileset.colorBlendAmount;
11871187
if (colorBlendMode === Cesium3DTileColorBlendMode.HIGHLIGHT) {
@@ -1246,7 +1246,7 @@ define([
12461246
var commandEnd = commandList.length;
12471247
var tile = this._content._tile;
12481248
var finalResolution = tile._finalResolution;
1249-
var tileset = tile._tileset;
1249+
var tileset = tile.tileset;
12501250
var bivariateVisibilityTest = tileset._skipLevelOfDetail && tileset._hasMixedContent && frameState.context.stencilBuffer;
12511251
var styleCommandsNeeded = getStyleCommandsNeeded(this);
12521252

@@ -1483,7 +1483,7 @@ define([
14831483
}
14841484

14851485
batchTable._pickTexture = createTexture(batchTable, context, bytes);
1486-
content._tileset._statistics.batchTableByteLength += batchTable._pickTexture.sizeInBytes;
1486+
content.tileset._statistics.batchTableByteLength += batchTable._pickTexture.sizeInBytes;
14871487
}
14881488
}
14891489

Source/Scene/Cesium3DTileOptimizations.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ define([
4444
var length = children.length;
4545

4646
// Check if the parent has an oriented bounding box.
47-
var boundingVolume = tile._boundingVolume;
47+
var boundingVolume = tile.boundingVolume;
4848
if (boundingVolume instanceof TileOrientedBoundingBox || boundingVolume instanceof TileBoundingRegion) {
4949
var orientedBoundingBox = boundingVolume._orientedBoundingBox;
5050
tile._optimChildrenWithinParent = Cesium3DTileOptimizationHint.USE_OPTIMIZATION;
5151
for (var i = 0; i < length; ++i) {
5252
var child = children[i];
5353

5454
// Check if the child has an oriented bounding box.
55-
var childBoundingVolume = child._boundingVolume;
55+
var childBoundingVolume = child.boundingVolume;
5656
if (!(childBoundingVolume instanceof TileOrientedBoundingBox || childBoundingVolume instanceof TileBoundingRegion)) {
5757
// Do not support if the parent and child both do not have oriented bounding boxes.
5858
tile._optimChildrenWithinParent = Cesium3DTileOptimizationHint.SKIP_OPTIMIZATION;

Source/Scene/Cesium3DTileset.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,28 @@ define([
10591059
}
10601060
},
10611061

1062+
/**
1063+
* The root tile.
1064+
*
1065+
* @memberOf Cesium3DTileset.prototype
1066+
*
1067+
* @type {Cesium3DTile}
1068+
* @readonly
1069+
*
1070+
* @exception {DeveloperError} The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true.
1071+
*/
1072+
root : {
1073+
get : function() {
1074+
//>>includeStart('debug', pragmas.debug);
1075+
if (!this.ready) {
1076+
throw new DeveloperError('The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true.');
1077+
}
1078+
//>>includeEnd('debug');
1079+
1080+
return this._root;
1081+
}
1082+
},
1083+
10621084
/**
10631085
* The tileset's bounding sphere.
10641086
*
@@ -1522,7 +1544,7 @@ define([
15221544
}
15231545

15241546
function computeTileLabelPosition(tile) {
1525-
var boundingVolume = tile._boundingVolume.boundingVolume;
1547+
var boundingVolume = tile.boundingVolume.boundingVolume;
15261548
var halfAxes = boundingVolume.halfAxes;
15271549
var radius = boundingVolume.radius;
15281550

Source/Scene/Cesium3DTilesetTraversal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ define([
6868
tileset._emptyTiles.length = 0;
6969
tileset._hasMixedContent = false;
7070

71-
var root = tileset._root;
71+
var root = tileset.root;
7272
updateTile(tileset, root, frameState);
7373

7474
// The root tile is not visible
@@ -216,7 +216,7 @@ define([
216216
var parent = tile.parent;
217217
var useParentScreenSpaceError = defined(parent) && (!skipLevelOfDetail(tileset) || (tile._screenSpaceError === 0.0));
218218
var screenSpaceError = useParentScreenSpaceError ? parent._screenSpaceError : tile._screenSpaceError;
219-
var rootScreenSpaceError = tileset._root._screenSpaceError;
219+
var rootScreenSpaceError = tileset.root._screenSpaceError;
220220
return rootScreenSpaceError - screenSpaceError; // Map higher SSE to lower values (e.g. root tile is highest priority)
221221
}
222222

Source/Scene/Geometry3DTileContent.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ define([
317317
return;
318318
}
319319

320-
var modelMatrix = content._tile.computedTransform;
320+
var modelMatrix = content.tile.computedTransform;
321321

322322
var center;
323323
if (defined(featureTableJson.RTC_CENTER)) {
@@ -365,7 +365,7 @@ define([
365365
center : center,
366366
modelMatrix : modelMatrix,
367367
batchTable : batchTable,
368-
boundingVolume : content._tile._boundingVolume.boundingVolume
368+
boundingVolume : content.tile.boundingVolume.boundingVolume
369369
});
370370
}
371371
}

Source/Scene/Vector3DTileContent.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ define([
396396
polygonMaximumHeights : polygonMaximumHeights,
397397
center : center,
398398
rectangle : rectangle,
399-
boundingVolume : content._tile._boundingVolume.boundingVolume,
399+
boundingVolume : content.tile.boundingVolume.boundingVolume,
400400
batchTable : batchTable,
401401
batchIds : batchIds.polygons,
402402
modelMatrix : modelMatrix
@@ -430,7 +430,7 @@ define([
430430
maximumHeight : maxHeight,
431431
center : center,
432432
rectangle : rectangle,
433-
boundingVolume : content._tile._boundingVolume.boundingVolume,
433+
boundingVolume : content.tile.boundingVolume.boundingVolume,
434434
batchTable : batchTable
435435
});
436436
}

Specs/Cesium3DTilesTester.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ define([
163163

164164
Cesium3DTilesTester.resolvesReadyPromise = function(scene, url) {
165165
return Cesium3DTilesTester.loadTileset(scene, url).then(function(tileset) {
166-
var content = tileset._root.content;
166+
var content = tileset.root.content;
167167
return content.readyPromise.then(function(content) {
168168
expect(content).toBeDefined();
169169
});
@@ -172,7 +172,7 @@ define([
172172

173173
Cesium3DTilesTester.tileDestroys = function(scene, url) {
174174
return Cesium3DTilesTester.loadTileset(scene, url).then(function(tileset) {
175-
var content = tileset._root.content;
175+
var content = tileset.root.content;
176176
expect(content.isDestroyed()).toEqual(false);
177177
scene.primitives.remove(tileset);
178178
expect(content.isDestroyed()).toEqual(true);

Specs/Scene/Batched3DModel3DTileContentSpec.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ defineSuite([
8080
.then(function(tileset) {
8181
expect(Batched3DModel3DTileContent._deprecationWarning).toHaveBeenCalled();
8282
Cesium3DTilesTester.expectRenderTileset(scene, tileset);
83-
var batchTable = tileset._root._content.batchTable;
83+
var batchTable = tileset.root.content.batchTable;
8484
expect(batchTable._properties).toBeDefined();
8585
});
8686
});
@@ -90,7 +90,7 @@ defineSuite([
9090
.then(function(tileset) {
9191
expect(Batched3DModel3DTileContent._deprecationWarning).toHaveBeenCalled();
9292
Cesium3DTilesTester.expectRenderTileset(scene, tileset);
93-
var batchTable = tileset._root._content.batchTable;
93+
var batchTable = tileset.root.content.batchTable;
9494
expect(batchTable._properties).toBeDefined();
9595
});
9696
});
@@ -160,7 +160,7 @@ defineSuite([
160160
var newTransform = Transforms.headingPitchRollToFixedFrame(newCenter, newHPR);
161161

162162
// Update tile transform
163-
tileset._root.transform = newTransform;
163+
tileset.root.transform = newTransform;
164164
scene.renderForSpecs();
165165

166166
// Move the camera to the new location
@@ -183,7 +183,7 @@ defineSuite([
183183

184184
it('picks with batch table', function() {
185185
return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(function(tileset) {
186-
var content = tileset._root.content;
186+
var content = tileset.root.content;
187187
tileset.show = false;
188188
expect(scene).toPickPrimitive(undefined);
189189
tileset.show = true;
@@ -197,7 +197,7 @@ defineSuite([
197197

198198
it('picks without batch table', function() {
199199
return Cesium3DTilesTester.loadTileset(scene, withoutBatchTableUrl).then(function(tileset) {
200-
var content = tileset._root.content;
200+
var content = tileset.root.content;
201201
tileset.show = false;
202202
expect(scene).toPickPrimitive(undefined);
203203
tileset.show = true;
@@ -211,7 +211,7 @@ defineSuite([
211211

212212
it('can get features and properties', function() {
213213
return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(function(tileset) {
214-
var content = tileset._root.content;
214+
var content = tileset.root.content;
215215
expect(content.featuresLength).toBe(10);
216216
expect(content.innerContents).toBeUndefined();
217217
expect(content.hasProperty(0, 'id')).toBe(true);
@@ -221,7 +221,7 @@ defineSuite([
221221

222222
it('throws when calling getFeature with invalid index', function() {
223223
return Cesium3DTilesTester.loadTileset(scene, withoutBatchTableUrl).then(function(tileset) {
224-
var content = tileset._root.content;
224+
var content = tileset.root.content;
225225
expect(function(){
226226
content.getFeature(-1);
227227
}).toThrowDeveloperError();
@@ -236,7 +236,7 @@ defineSuite([
236236

237237
it('gets memory usage', function() {
238238
return Cesium3DTilesTester.loadTileset(scene, texturedUrl).then(function(tileset) {
239-
var content = tileset._root.content;
239+
var content = tileset.root.content;
240240

241241
// 10 buildings, 36 ushort indices and 24 vertices per building, 8 float components (position, normal, uv) and 1 uint component (batchId) per vertex.
242242
// 10 * ((24 * (8 * 4 + 1 * 4)) + (36 * 2)) = 9360
@@ -271,7 +271,7 @@ defineSuite([
271271

272272
it('Links model to tileset clipping planes based on bounding volume clipping', function() {
273273
return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(function(tileset) {
274-
var tile = tileset._root;
274+
var tile = tileset.root;
275275
var content = tile.content;
276276
var model = content._model;
277277

@@ -298,7 +298,7 @@ defineSuite([
298298

299299
it('Links model to tileset clipping planes if tileset clipping planes are reassigned', function() {
300300
return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(function(tileset) {
301-
var tile = tileset._root;
301+
var tile = tileset.root;
302302
var model = tile.content._model;
303303

304304
expect(model.clippingPlanes).toBeUndefined();
@@ -333,7 +333,7 @@ defineSuite([
333333
spyOn(Model, '_getClippingFunction').and.callThrough();
334334

335335
return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(function(tileset) {
336-
var tile = tileset._root;
336+
var tile = tileset.root;
337337

338338
var clippingPlaneCollection = new ClippingPlaneCollection({
339339
planes : [
@@ -352,25 +352,25 @@ defineSuite([
352352
return Cesium3DTilesTester.loadTileset(scene, withRtcCenterUrl).then(function(tileset) {
353353
Cesium3DTilesTester.expectRenderTileset(scene, tileset);
354354

355-
var rtcTransform = tileset._root._content._rtcCenterTransform;
355+
var rtcTransform = tileset.root.content._rtcCenterTransform;
356356
expect(rtcTransform).toEqual(Matrix4.fromTranslation(new Cartesian3(0.1, 0.2, 0.3)));
357357

358-
var expectedModelTransform = Matrix4.multiply(tileset._root.transform, rtcTransform, new Matrix4());
359-
expect(tileset._root._content._contentModelMatrix).toEqual(expectedModelTransform);
360-
expect(tileset._root._content._model._modelMatrix).toEqual(expectedModelTransform);
358+
var expectedModelTransform = Matrix4.multiply(tileset.root.transform, rtcTransform, new Matrix4());
359+
expect(tileset.root.content._contentModelMatrix).toEqual(expectedModelTransform);
360+
expect(tileset.root.content._model._modelMatrix).toEqual(expectedModelTransform);
361361

362362
// Update tile transform
363363
var newLongitude = -1.31962;
364364
var newLatitude = 0.698874;
365365
var newCenter = Cartesian3.fromRadians(newLongitude, newLatitude, 0.0);
366366
var newHPR = new HeadingPitchRoll();
367367
var newTransform = Transforms.headingPitchRollToFixedFrame(newCenter, newHPR);
368-
tileset._root.transform = newTransform;
368+
tileset.root.transform = newTransform;
369369
scene.camera.lookAt(newCenter, new HeadingPitchRange(0.0, 0.0, 15.0));
370370
scene.renderForSpecs();
371371

372-
expectedModelTransform = Matrix4.multiply(tileset._root.computedTransform, rtcTransform, expectedModelTransform);
373-
expect(tileset._root._content._model._modelMatrix).toEqual(expectedModelTransform);
372+
expectedModelTransform = Matrix4.multiply(tileset.root.computedTransform, rtcTransform, expectedModelTransform);
373+
expect(tileset.root.content._model._modelMatrix).toEqual(expectedModelTransform);
374374
});
375375
});
376376

Specs/Scene/Cesium3DTileBatchTableSpec.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ defineSuite([
550550

551551
it('renders tileset with batch table', function() {
552552
return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(function(tileset) {
553-
var content = tileset._root.content;
553+
var content = tileset.root.content;
554554

555555
// Each feature in the b3dm file has an id property from 0 to 9,
556556
// check that the 2nd resource has an id of 2
@@ -568,7 +568,7 @@ defineSuite([
568568

569569
it('renders tileset without batch table', function() {
570570
return Cesium3DTilesTester.loadTileset(scene, withoutBatchTableUrl).then(function(tileset) {
571-
var content = tileset._root.content;
571+
var content = tileset.root.content;
572572

573573
expect(content.getFeature(2).getProperty('id')).toBeUndefined();
574574

@@ -595,7 +595,7 @@ defineSuite([
595595
ContextLimits._maximumTextureSize = 4;
596596

597597
return Cesium3DTilesTester.loadTileset(scene, withoutBatchTableUrl).then(function(tileset) {
598-
var content = tileset._root.content;
598+
var content = tileset.root.content;
599599
expect(content.featuresLength).toBeGreaterThan(ContextLimits._maximumTextureSize);
600600
Cesium3DTilesTester.expectRenderTileset(scene, tileset);
601601

@@ -616,7 +616,7 @@ defineSuite([
616616
});
617617

618618
function expectRenderTranslucent(tileset) {
619-
var batchTable = tileset._root.content.batchTable;
619+
var batchTable = tileset.root.content.batchTable;
620620

621621
// Get initial color
622622
var opaqueColor;
@@ -799,7 +799,7 @@ defineSuite([
799799

800800
function checkHierarchyProperties(tileset, multipleParents) {
801801
// Check isExactClass, isClass, and getExactClassName in Cesium3DTileFeature
802-
var content = tileset._root.content;
802+
var content = tileset.root.content;
803803
var batchTable = content.batchTable;
804804
var hierarchy = batchTable._batchTableHierarchy;
805805

@@ -861,7 +861,7 @@ defineSuite([
861861

862862
function checkHierarchyPropertiesNoParents(tileset) {
863863
// Check isExactClass, isClass, and getExactClassName in Cesium3DTileFeature
864-
var content = tileset._root.content;
864+
var content = tileset.root.content;
865865
var doorFeature = content.getFeature(4);
866866
expect(doorFeature.isExactClass('door')).toBe(true);
867867
expect(doorFeature.isExactClass('doorknob')).toBe(false);
@@ -1111,7 +1111,7 @@ defineSuite([
11111111

11121112
it('destroys', function() {
11131113
return Cesium3DTilesTester.loadTileset(scene, withoutBatchTableUrl).then(function(tileset) {
1114-
var content = tileset._root.content;
1114+
var content = tileset.root.content;
11151115
var batchTable = content.batchTable;
11161116
expect(batchTable.isDestroyed()).toEqual(false);
11171117
scene.primitives.remove(tileset);

0 commit comments

Comments
 (0)