Skip to content

Commit

Permalink
Merge pull request #6944 from AnalyticalGraphicsInc/root-public
Browse files Browse the repository at this point in the history
Make root tile public
  • Loading branch information
Hannah authored Aug 23, 2018
2 parents 4c68791 + 68c35b5 commit 9287c3c
Show file tree
Hide file tree
Showing 22 changed files with 225 additions and 171 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Change Log
* Added `Matrix4.setScale` for setting the scale on an affine transformation matrix [#6888](https://github.com/AnalyticalGraphicsInc/cesium/pull/6888)
* 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)
* Added optional `width` and `height` to `Scene.drillPick` for specifying a search area.
* Added `Cesium3DTileset.root` for getting the root tile of a tileset. [#6944](https://github.com/AnalyticalGraphicsInc/cesium/pull/6944)
* 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)

##### Fixes :wrench:
Expand Down
19 changes: 17 additions & 2 deletions Source/Scene/Cesium3DTile.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,21 @@ define([
}
},

/**
* Get the tile's bounding volume.
*
* @memberof Cesium3DTile.prototype
*
* @type {TileBoundingVolume}
* @readonly
* @private
*/
boundingVolume : {
get : function() {
return this._boundingVolume;
}
},

/**
* Get the bounding volume of the tile's contents. This defaults to the
* tile's bounding volume when the content's bounding volume is
Expand Down Expand Up @@ -793,7 +808,7 @@ define([
var tileset = this._tileset;
var clippingPlanes = tileset.clippingPlanes;
if (defined(clippingPlanes) && clippingPlanes.enabled) {
var tileTransform = tileset._root.computedTransform;
var tileTransform = tileset.root.computedTransform;
var intersection = clippingPlanes.computeIntersectionWithBoundingVolume(boundingVolume, tileTransform);
this._isClipped = intersection !== Intersect.INSIDE;
if (intersection === Intersect.OUTSIDE) {
Expand Down Expand Up @@ -828,7 +843,7 @@ define([
var tileset = this._tileset;
var clippingPlanes = tileset.clippingPlanes;
if (defined(clippingPlanes) && clippingPlanes.enabled) {
var tileTransform = tileset._root.computedTransform;
var tileTransform = tileset.root.computedTransform;
var intersection = clippingPlanes.computeIntersectionWithBoundingVolume(boundingVolume, tileTransform);
this._isClipped = intersection !== Intersect.INSIDE;
if (intersection === Intersect.OUTSIDE) {
Expand Down
6 changes: 3 additions & 3 deletions Source/Scene/Cesium3DTileBatchTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ define([
};

function getColorBlend(batchTable) {
var tileset = batchTable._content._tileset;
var tileset = batchTable._content.tileset;
var colorBlendMode = tileset.colorBlendMode;
var colorBlendAmount = tileset.colorBlendAmount;
if (colorBlendMode === Cesium3DTileColorBlendMode.HIGHLIGHT) {
Expand Down Expand Up @@ -1246,7 +1246,7 @@ define([
var commandEnd = commandList.length;
var tile = this._content._tile;
var finalResolution = tile._finalResolution;
var tileset = tile._tileset;
var tileset = tile.tileset;
var bivariateVisibilityTest = tileset._skipLevelOfDetail && tileset._hasMixedContent && frameState.context.stencilBuffer;
var styleCommandsNeeded = getStyleCommandsNeeded(this);

Expand Down Expand Up @@ -1483,7 +1483,7 @@ define([
}

batchTable._pickTexture = createTexture(batchTable, context, bytes);
content._tileset._statistics.batchTableByteLength += batchTable._pickTexture.sizeInBytes;
content.tileset._statistics.batchTableByteLength += batchTable._pickTexture.sizeInBytes;
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/Cesium3DTileOptimizations.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ define([
var length = children.length;

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

// Check if the child has an oriented bounding box.
var childBoundingVolume = child._boundingVolume;
var childBoundingVolume = child.boundingVolume;
if (!(childBoundingVolume instanceof TileOrientedBoundingBox || childBoundingVolume instanceof TileBoundingRegion)) {
// Do not support if the parent and child both do not have oriented bounding boxes.
tile._optimChildrenWithinParent = Cesium3DTileOptimizationHint.SKIP_OPTIMIZATION;
Expand Down
24 changes: 23 additions & 1 deletion Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,28 @@ define([
}
},

/**
* The root tile.
*
* @memberOf Cesium3DTileset.prototype
*
* @type {Cesium3DTile}
* @readonly
*
* @exception {DeveloperError} The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true.
*/
root : {
get : function() {
//>>includeStart('debug', pragmas.debug);
if (!this.ready) {
throw new DeveloperError('The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true.');
}
//>>includeEnd('debug');

return this._root;
}
},

/**
* The tileset's bounding sphere.
*
Expand Down Expand Up @@ -1522,7 +1544,7 @@ define([
}

function computeTileLabelPosition(tile) {
var boundingVolume = tile._boundingVolume.boundingVolume;
var boundingVolume = tile.boundingVolume.boundingVolume;
var halfAxes = boundingVolume.halfAxes;
var radius = boundingVolume.radius;

Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/Cesium3DTilesetTraversal.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ define([
tileset._emptyTiles.length = 0;
tileset._hasMixedContent = false;

var root = tileset._root;
var root = tileset.root;
updateTile(tileset, root, frameState);

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

Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/Geometry3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ define([
return;
}

var modelMatrix = content._tile.computedTransform;
var modelMatrix = content.tile.computedTransform;

var center;
if (defined(featureTableJson.RTC_CENTER)) {
Expand Down Expand Up @@ -365,7 +365,7 @@ define([
center : center,
modelMatrix : modelMatrix,
batchTable : batchTable,
boundingVolume : content._tile._boundingVolume.boundingVolume
boundingVolume : content.tile.boundingVolume.boundingVolume
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/Vector3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ define([
polygonMaximumHeights : polygonMaximumHeights,
center : center,
rectangle : rectangle,
boundingVolume : content._tile._boundingVolume.boundingVolume,
boundingVolume : content.tile.boundingVolume.boundingVolume,
batchTable : batchTable,
batchIds : batchIds.polygons,
modelMatrix : modelMatrix
Expand Down Expand Up @@ -430,7 +430,7 @@ define([
maximumHeight : maxHeight,
center : center,
rectangle : rectangle,
boundingVolume : content._tile._boundingVolume.boundingVolume,
boundingVolume : content.tile.boundingVolume.boundingVolume,
batchTable : batchTable
});
}
Expand Down
4 changes: 2 additions & 2 deletions Specs/Cesium3DTilesTester.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ define([

Cesium3DTilesTester.resolvesReadyPromise = function(scene, url) {
return Cesium3DTilesTester.loadTileset(scene, url).then(function(tileset) {
var content = tileset._root.content;
var content = tileset.root.content;
return content.readyPromise.then(function(content) {
expect(content).toBeDefined();
});
Expand All @@ -172,7 +172,7 @@ define([

Cesium3DTilesTester.tileDestroys = function(scene, url) {
return Cesium3DTilesTester.loadTileset(scene, url).then(function(tileset) {
var content = tileset._root.content;
var content = tileset.root.content;
expect(content.isDestroyed()).toEqual(false);
scene.primitives.remove(tileset);
expect(content.isDestroyed()).toEqual(true);
Expand Down
36 changes: 18 additions & 18 deletions Specs/Scene/Batched3DModel3DTileContentSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ defineSuite([
.then(function(tileset) {
expect(Batched3DModel3DTileContent._deprecationWarning).toHaveBeenCalled();
Cesium3DTilesTester.expectRenderTileset(scene, tileset);
var batchTable = tileset._root._content.batchTable;
var batchTable = tileset.root.content.batchTable;
expect(batchTable._properties).toBeDefined();
});
});
Expand All @@ -90,7 +90,7 @@ defineSuite([
.then(function(tileset) {
expect(Batched3DModel3DTileContent._deprecationWarning).toHaveBeenCalled();
Cesium3DTilesTester.expectRenderTileset(scene, tileset);
var batchTable = tileset._root._content.batchTable;
var batchTable = tileset.root.content.batchTable;
expect(batchTable._properties).toBeDefined();
});
});
Expand Down Expand Up @@ -160,7 +160,7 @@ defineSuite([
var newTransform = Transforms.headingPitchRollToFixedFrame(newCenter, newHPR);

// Update tile transform
tileset._root.transform = newTransform;
tileset.root.transform = newTransform;
scene.renderForSpecs();

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

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

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

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

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

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

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

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

Expand All @@ -298,7 +298,7 @@ defineSuite([

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

expect(model.clippingPlanes).toBeUndefined();
Expand Down Expand Up @@ -333,7 +333,7 @@ defineSuite([
spyOn(Model, '_getClippingFunction').and.callThrough();

return Cesium3DTilesTester.loadTileset(scene, withBatchTableUrl).then(function(tileset) {
var tile = tileset._root;
var tile = tileset.root;

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

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

var expectedModelTransform = Matrix4.multiply(tileset._root.transform, rtcTransform, new Matrix4());
expect(tileset._root._content._contentModelMatrix).toEqual(expectedModelTransform);
expect(tileset._root._content._model._modelMatrix).toEqual(expectedModelTransform);
var expectedModelTransform = Matrix4.multiply(tileset.root.transform, rtcTransform, new Matrix4());
expect(tileset.root.content._contentModelMatrix).toEqual(expectedModelTransform);
expect(tileset.root.content._model._modelMatrix).toEqual(expectedModelTransform);

// Update tile transform
var newLongitude = -1.31962;
var newLatitude = 0.698874;
var newCenter = Cartesian3.fromRadians(newLongitude, newLatitude, 0.0);
var newHPR = new HeadingPitchRoll();
var newTransform = Transforms.headingPitchRollToFixedFrame(newCenter, newHPR);
tileset._root.transform = newTransform;
tileset.root.transform = newTransform;
scene.camera.lookAt(newCenter, new HeadingPitchRange(0.0, 0.0, 15.0));
scene.renderForSpecs();

expectedModelTransform = Matrix4.multiply(tileset._root.computedTransform, rtcTransform, expectedModelTransform);
expect(tileset._root._content._model._modelMatrix).toEqual(expectedModelTransform);
expectedModelTransform = Matrix4.multiply(tileset.root.computedTransform, rtcTransform, expectedModelTransform);
expect(tileset.root.content._model._modelMatrix).toEqual(expectedModelTransform);
});
});

Expand Down
14 changes: 7 additions & 7 deletions Specs/Scene/Cesium3DTileBatchTableSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ defineSuite([

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

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

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

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

Expand All @@ -595,7 +595,7 @@ defineSuite([
ContextLimits._maximumTextureSize = 4;

return Cesium3DTilesTester.loadTileset(scene, withoutBatchTableUrl).then(function(tileset) {
var content = tileset._root.content;
var content = tileset.root.content;
expect(content.featuresLength).toBeGreaterThan(ContextLimits._maximumTextureSize);
Cesium3DTilesTester.expectRenderTileset(scene, tileset);

Expand All @@ -616,7 +616,7 @@ defineSuite([
});

function expectRenderTranslucent(tileset) {
var batchTable = tileset._root.content.batchTable;
var batchTable = tileset.root.content.batchTable;

// Get initial color
var opaqueColor;
Expand Down Expand Up @@ -799,7 +799,7 @@ defineSuite([

function checkHierarchyProperties(tileset, multipleParents) {
// Check isExactClass, isClass, and getExactClassName in Cesium3DTileFeature
var content = tileset._root.content;
var content = tileset.root.content;
var batchTable = content.batchTable;
var hierarchy = batchTable._batchTableHierarchy;

Expand Down Expand Up @@ -861,7 +861,7 @@ defineSuite([

function checkHierarchyPropertiesNoParents(tileset) {
// Check isExactClass, isClass, and getExactClassName in Cesium3DTileFeature
var content = tileset._root.content;
var content = tileset.root.content;
var doorFeature = content.getFeature(4);
expect(doorFeature.isExactClass('door')).toBe(true);
expect(doorFeature.isExactClass('doorknob')).toBe(false);
Expand Down Expand Up @@ -1111,7 +1111,7 @@ defineSuite([

it('destroys', function() {
return Cesium3DTilesTester.loadTileset(scene, withoutBatchTableUrl).then(function(tileset) {
var content = tileset._root.content;
var content = tileset.root.content;
var batchTable = content.batchTable;
expect(batchTable.isDestroyed()).toEqual(false);
scene.primitives.remove(tileset);
Expand Down
Loading

0 comments on commit 9287c3c

Please sign in to comment.