-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add Extras to 3DTile and 3DTileset #6974
Changes from 15 commits
722701d
9badee4
0c3d711
1e73469
0a0af0f
e434db4
25c8623
8a24922
468a1fb
5de6c3f
4f0d17c
90ee7cf
d4c90e3
e88a6c8
e683221
e4d20f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,7 @@ define([ | |
var contentHeader = header.content; | ||
|
||
/** | ||
* The local transform of this tile | ||
* The local transform of this tile. | ||
* @type {Matrix4} | ||
*/ | ||
this.transform = defined(header.transform) ? Matrix4.unpack(header.transform) : Matrix4.clone(Matrix4.IDENTITY); | ||
|
@@ -100,7 +100,7 @@ define([ | |
this._initialTransform = Matrix4.multiply(parentInitialTransform, this.transform, new Matrix4()); | ||
|
||
/** | ||
* The final computed transform of this tile | ||
* The final computed transform of this tile. | ||
* @type {Matrix4} | ||
* @readonly | ||
*/ | ||
|
@@ -429,6 +429,22 @@ define([ | |
} | ||
}, | ||
|
||
/** | ||
* Returns the <code>extras</code> property in the tileset JSON for this tile, which contains application specific metadata. | ||
* Returns <code>undefined</code> if <code>extras</code> does not exist. | ||
* | ||
* @memberof Cesium3DTile.prototype | ||
* | ||
* @type {*} | ||
* @readonly | ||
* @see {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#specifying-extensions-and-application-specific-extras|Extras in the 3D Tiles specification.} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comments here. |
||
*/ | ||
extras : { | ||
get : function() { | ||
return this._header.extras; | ||
} | ||
}, | ||
|
||
/** | ||
* Gets or sets the tile's highlight color. | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,6 +181,7 @@ define([ | |
this._selectedTilesToStyle = []; | ||
this._loadTimestamp = undefined; | ||
this._timeSinceLoad = 0.0; | ||
this._extras = undefined; | ||
|
||
this._cullWithChildrenBounds = defaultValue(options.cullWithChildrenBounds, true); | ||
this._allTilesAdditive = true; | ||
|
@@ -710,6 +711,7 @@ define([ | |
that._geometricError = tilesetJson.geometricError; | ||
that._extensionsUsed = tilesetJson.extensionsUsed; | ||
that._gltfUpAxis = gltfUpAxis; | ||
that._extras = tilesetJson.extras; | ||
that._readyPromise.resolve(that); | ||
}).otherwise(function(error) { | ||
that._readyPromise.reject(error); | ||
|
@@ -1237,6 +1239,31 @@ define([ | |
get : function() { | ||
return this._ellipsoid; | ||
} | ||
}, | ||
|
||
/** | ||
* Returns the <code>extras</code> property at the top-level of the tileset JSON, which contains application specific metadata. | ||
* Returns <code>undefined</code> if <code>extras</code> does not exist. | ||
* | ||
* @memberof Cesium3DTileset.prototype | ||
* | ||
* @exception {DeveloperError} The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true. | ||
* | ||
* @type {*} | ||
* @readonly | ||
* | ||
* @see {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#specifying-extensions-and-application-specific-extras|Extras in the 3D Tiles specification.} | ||
*/ | ||
extras : { | ||
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'); | ||
OmarShehata marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return this._extras; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be a good idea to check if the tileset is ready before accessing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only needed for the |
||
} | ||
}); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ defineSuite([ | |
'Scene/Cesium3DTileset', | ||
'Core/Cartesian3', | ||
'Core/Color', | ||
'Core/defined', | ||
'Core/CullingVolume', | ||
'Core/getAbsoluteUri', | ||
'Core/getStringFromTypedArray', | ||
|
@@ -32,6 +33,7 @@ defineSuite([ | |
Cesium3DTileset, | ||
Cartesian3, | ||
Color, | ||
defined, | ||
CullingVolume, | ||
getAbsoluteUri, | ||
getStringFromTypedArray, | ||
|
@@ -356,6 +358,24 @@ defineSuite([ | |
}); | ||
}); | ||
|
||
it('loads tileset with extras', function() { | ||
return Cesium3DTilesTester.loadTileset(scene, tilesetUrl).then(function(tileset) { | ||
expect(tileset.extras).toEqual({ 'name': 'Sample Tileset' }); | ||
expect(tileset.root.extras).not.toBeDefined(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, |
||
|
||
var length = tileset.root.children.length; | ||
var taggedChildren = 0; | ||
for (var i = 0; i < length; ++i) { | ||
if (defined(tileset.root.children[i].extras)) { | ||
expect(tileset.root.children[i].extras).toEqual({ 'id': 'Special Tile' }); | ||
++taggedChildren; | ||
} | ||
} | ||
|
||
expect(taggedChildren).toEqual(1); | ||
}); | ||
}); | ||
|
||
it('gets root tile', function() { | ||
var tileset = scene.primitives.add(new Cesium3DTileset({ | ||
url : tilesetUrl | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing these!