-
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
Vector Tiles #4665
Vector Tiles #4665
Conversation
@bagnell please update CesiumGS/3d-tiles#124 to keep the implementation and spec in sync. |
viewer.scene.globe.depthTestAgainstTerrain = true; | ||
|
||
var tileset = scene.primitives.add(new Cesium.Cesium3DTileset({ | ||
url : 'http://localhost:8002/tilesets/VectorTile-Test/', |
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.
Add changing this to the tasklist if it isn't already.
Source/Scene/Cesium3DTileFeature.js
Outdated
@@ -41,12 +45,21 @@ define([ | |||
* } | |||
* }, Cesium.ScreenSpaceEventType.MOUSE_MOVE); | |||
*/ | |||
function Cesium3DTileFeature(tileset, content, batchId) { | |||
function Cesium3DTileFeature(tileset, content, batchId, billboardCollection, labelCollection) { |
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.
These changes make Cesium3DTileFeature
really heavy especially for all the non-vector features that do not need most of these properties. Is it possible to cleanly add a Cesium3DTileVectorFeature
so we only pay this cost when needed? Is it also possible to amortize some properties over multiple features, e.g., do all features with the same batch table also have the same billboard and label collection?
Source/Scene/Cesium3DTileFeature.js
Outdated
return this._batchTable.getShow(this._batchId); | ||
}, | ||
set : function(value) { | ||
this._batchTable.setShow(this._batchId, value); | ||
if (defined(this._labelCollection)) { |
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.
Style-wise throughout when members like this._labelCollection
and this._batchId
are used more than once in a function assign them to a local.
Source/Scene/Cesium3DTileFeature.js
Outdated
@@ -92,17 +116,301 @@ define([ | |||
*/ | |||
color : { | |||
get : function() { | |||
if (defined(this._labelCollection)) { | |||
var label = this._labelCollection.get(this._batchId); |
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.
What is this get
function needed? Why can't we always keep reference to the label?
Source/Scene/Cesium3DTileFeature.js
Outdated
/** | ||
* Gets and sets the point size of this feature. | ||
* <p> | ||
* Only applied when the feature is a point feature and <code>image</code> is <code>undefined</code>. |
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.
Does this mean "a point feature in a vector tile?"
Source/Scene/Cesium3DTileFeature.js
Outdated
}, | ||
set :function(value) { | ||
this._pointSize = value; | ||
if (defined(this._billboardCollection)) { |
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.
Is it worth optimizing for special cases when a PointPrimitiveCollection
could be used? Seems like it would be hard to manage when setting some properties at runtime could cause it to split into a billboard collection. Add a PERFORMANCE_IDEA
/ roadmap item if you think this would be reasonable and useful for some cases.
Source/Scene/Cesium3DTileFeature.js
Outdated
|
||
if (defined(value) && value !== '') { | ||
var billboard = this._billboardCollection.get(this._batchId); | ||
billboard.horizontalOrigin = HorizontalOrigin.RIGHT; |
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.
This doesn't put the label on top of the billboard?
Source/Scene/Cesium3DTileFeature.js
Outdated
b.setImage(textureId, createCallback(centerAlpha, cssColor, cssOutlineColor, newOutlineWidth, newPointSize)); | ||
} | ||
|
||
function createCallback(centerAlpha, cssColor, cssOutlineColor, cssOutlineWidth, newPixelSize) { |
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.
This is from https://github.com/AnalyticalGraphicsInc/cesium/blob/4c6b691b4327a16a6065f5432d33471cddb7978a/Source/DataSources/PointVisualizer.js#L306, right? Can we share it as a @private
function?
Source/Scene/Cesium3DTileStyle.js
Outdated
'use strict'; | ||
|
||
var DEFAULT_JSON_COLOR_EXPRESSION = 'color("#ffffff")'; | ||
var DEFAULT_JSON_OUTLINE_COLOR_EXPRESSION = 'color("#000000")'; |
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.
Please update the styling spec when you update the 3D Tiles spec.
Source/Scene/Cesium3DTileStyle.js
Outdated
var DEFAULT_JSON_BOOLEAN_EXPRESSION = true; | ||
var DEFAULT_JSON_NUMBER_EXPRESSION = 1.0; | ||
var DEFAULT_LABEL_STYLE_EXPRESSION = LabelStyle.FILL; | ||
var DEFAULT_FONT_EXPRESSION = '"30px sans-serif"'; |
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.
Are you sure about this default here and below?
Source/Scene/Cesium3DTileStyle.js
Outdated
* | ||
* @type {StyleExpression} | ||
* | ||
* @exception {DeveloperError} The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true. |
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.
Probably use {@link }
here and throughout for the references.
Source/Scene/Cesium3DTileStyle.js
Outdated
* | ||
* @example | ||
* var style = new Cesium3DTileStyle({ | ||
* image : '(${Temperature} > 90) ? "/url/to/image1" : "/url/to/image2"' |
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.
When you document the styling spec, this should state the validate image formats - it should be the same as those supported by the browser (probably including svg).
Also, please add a tasklist item to the spec PR to consider if this should be able to point to a texture atlas / glTF-style buffer/bufferView.
Probably something to consider for v2, but let's discuss in the context of the styling PR.
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.
How to use it?
Source/Scene/Cesium3DTileStyle.js
Outdated
* | ||
* @see {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/Styling|3D Tiles Styling language} | ||
*/ | ||
outlineColor : { |
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.
Can you run coverage for these get/set functions? Most of them are not covered.
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.
Same comment for new properties in Cesium3DTileFeature.js
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.
Coverage is also pretty low for Vector3DTileContent.js at 85%
Source/Scene/GroundPolylineBatch.js
Outdated
shaderProgram : primitive._sp, | ||
uniformMap : uniformMap, | ||
boundingVolume : primitive._boundingVolume, | ||
//pass : Pass.GROUND |
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.
Does this need a TODO
so we add the GROUND_TRANSLUCENT
pass before merging 3d-tiles
into master?
Source/Scene/GroundPrimitiveBatch.js
Outdated
var batchedIndices = this._batchedIndices; | ||
var length = batchedIndices.length; | ||
|
||
var i; |
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.
Declare below inside the loop, it isn't used elsewhere, right?
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.
Its used outside the loop as the found index.
Source/Scene/Vector3DTileContent.js
Outdated
var features = new Array(featuresLength); | ||
for (var i = 0; i < featuresLength; ++i) { | ||
if (defined(content._billboardCollection) && i < content._billboardCollection.length) { | ||
var billboardCollection = content._billboardCollection; |
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.
Could move this above and use the local in the if
statement.
Source/Scene/Vector3DTileContent.js
Outdated
} | ||
} | ||
|
||
var batchId; |
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.
Is this local really needed?
Source/Scene/Vector3DTileContent.js
Outdated
Cartesian3.add(position, center, position); | ||
|
||
var b = this._billboardCollection.add(); | ||
b.position = position; |
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.
Here and below, why not pass these to add
? To avoid the object literal? I dunno, maybe that optimization is too soon given everything else this function does.
Source/Scene/Vector3DTileContent.js
Outdated
this._polylines.applyDebugSettings(enabled, color); | ||
} | ||
|
||
//TODO: debug settings for points/billboards/labels |
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.
Is this trivial to do now? If no, let's wait until the merge to 3d-tiles
.
I think I mentioned this in another PR, but it would be useful to have tests for the new |
Just those comments. |
Also, update CHANGES.md with any new classes: https://github.com/AnalyticalGraphicsInc/cesium/blob/3d-tiles/CHANGES.md |
Added
to the tasklist. |
Use b3dm tilesets for classification
// Highlight the feature | ||
highlighted.feature = pickedFeature; | ||
Cesium.Color.clone(pickedFeature.color, highlighted.originalColor); | ||
pickedFeature.color = Cesium.Color.WHITE.withAlpha(0.5); |
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.
Should the color be yellow instead?
@@ -0,0 +1,85 @@ | |||
<!DOCTYPE html> |
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.
Will there be any Sandcastle examples using vector tiles in the more traditional sense - labels, billboards, polylines, etc? Also it's not completely clear which of the new demos are using b3dm vs. geom vs. vctr for classification. Each should have a comment about what tile format they are using.
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.
I added a comment to each example.
The 3D Tiles Terrain Classification
example is traditional vector tiles (polygons draped on terrain). There are no polylines or points/billboards/labels. This is the best I can do until I find better open data and better tiling.
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.
I opened an issue to keep track of this: #6095
} | ||
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE); | ||
|
||
// Color a feature on selection and show metadata in the InfoBox. |
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.
Remove note about the InfoBox.
|
||
// Highlight newly selected feature | ||
pickedFeature.color = Cesium.Color.LIME; | ||
}, Cesium.ScreenSpaceEventType.LEFT_CLICK); |
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.
There should be a comment explaining why the selected feature doesn't stay selected when you zoom in and out, and link to CesiumGS/3d-tiles#265.
CHANGES.md
Outdated
* `Cesium3DTileStyle` has expanded for styling point features. See the [styling specification](https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/vector-tiles/Styling#vector-data) for details. | ||
* `Cesium3DTileFeature` can modify `color` and `show` properties for polygon, polyline, and geometry features. | ||
* `Cesium3DTilePointFeature` can modify the styling options for a point feature. | ||
* Added `Cesium3DTileset.classificationType` to specify if a tileset classifies terrain, another 3D Tiles tileset, or both. This only applies to vector, geometry and batched 3D model tilesets. See [#6033](https://github.com/AnalyticalGraphicsInc/cesium/pull/6033) for limitations on the glTF contained in the b3dm tile. |
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.
Should the b3dm restrictions be mentioned here in CHANGES.md
instead of linking to a PR?
Source/Scene/ClassificationModel.js
Outdated
var rotation = Quaternion.unpack(gltfNode.rotation); | ||
var scale = Cartesian3.fromArray(gltfNode.scale); | ||
model._nodeMatrix = Matrix4.fromTranslationQuaternionRotationScale(translation, rotation, scale, model._nodeMatrix); | ||
} |
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.
Can this section use ModelUtility.getTransform
?
model._rtcCenter = model._rtcCenter3D; | ||
} else { | ||
var center = model.boundingSphere.center; | ||
var to2D = Transforms.wgs84To2DModelMatrix(projection, center, scratchComputedMatrixIn2D); |
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.
I tested 3D Tiles Photogrammetry Classification
in 2D and CV and was happy to see that it works in both. Though switching modes causes the classification to be unaligned - probably related to #5955.
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.
Yeah, I think it's the same problem.
when, | ||
Cesium3DTileBatchTable, | ||
Vector3DTileGeometry) { | ||
'use strict'; |
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.
Fix indentation on these includes.
Source/Scene/Vector3DTilePoints.js
Outdated
return; | ||
} | ||
|
||
when(verticesPromise, function(result) { |
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.
Could this just be verticesPromise.then
?
* | ||
* @see czm_pass | ||
*/ | ||
const float czm_passClassification = 8.0; |
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.
This should be 7.
Throughout any code related to |
@lilleyse This is ready for another look. I'm not sure why the tests are failing. They pass (both regular and the stub) locally. |
This is now in sync with the spec. |
…es or when used for classification.
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.
Just one comment.
* @type {Ellipsoid} | ||
* @readonly | ||
*/ | ||
ellipsoid : { |
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.
This should be documented in CHANGES.md
.
Does anyone else want to review? I think this is in good shape to merge on Monday otherwise. |
No need for me to look at this again. |
@lilleyse Updated. |
Awesome! This was a big undertaking and I'm glad it's finally ready. The two failing tests in the latest build are unrelated (VideoSynchronizer related) |
Congratulations on closing the issue! I found these Cesium forum links in the comments above: https://groups.google.com/forum/#!topic/cesium-dev/eXH90obYoSs If this issue affects any of these threads, please post a comment like the following:
I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome. 🌍 🌎 🌏 |
classificationType
toCesium3DTileset
so ab3dm
tileset can classify other 3D Tiles and/or terrain.Future work: