Skip to content
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

Merged
merged 425 commits into from
Jan 8, 2018
Merged

Vector Tiles #4665

merged 425 commits into from
Jan 8, 2018

Conversation

bagnell
Copy link
Contributor

@bagnell bagnell commented Nov 18, 2016

  • Adds vector tile (polygons, polylines, and points), and geometry tile (boxes, cylinders, ellipsoids and spheres) for classifying 3D Tiles and terrain.
  • Adds classificationType to Cesium3DTileset so a b3dm tileset can classify other 3D Tiles and/or terrain.

Future work:

  • Geometry instancing
  • Polygon z-order

@pjcozzi
Copy link
Contributor

pjcozzi commented Nov 22, 2016

@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/',
Copy link
Contributor

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.

@@ -41,12 +45,21 @@ define([
* }
* }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
*/
function Cesium3DTileFeature(tileset, content, batchId) {
function Cesium3DTileFeature(tileset, content, batchId, billboardCollection, labelCollection) {
Copy link
Contributor

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?

return this._batchTable.getShow(this._batchId);
},
set : function(value) {
this._batchTable.setShow(this._batchId, value);
if (defined(this._labelCollection)) {
Copy link
Contributor

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.

@@ -92,17 +116,301 @@ define([
*/
color : {
get : function() {
if (defined(this._labelCollection)) {
var label = this._labelCollection.get(this._batchId);
Copy link
Contributor

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?

/**
* 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>.
Copy link
Contributor

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?"

},
set :function(value) {
this._pointSize = value;
if (defined(this._billboardCollection)) {
Copy link
Contributor

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.


if (defined(value) && value !== '') {
var billboard = this._billboardCollection.get(this._batchId);
billboard.horizontalOrigin = HorizontalOrigin.RIGHT;
Copy link
Contributor

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?

b.setImage(textureId, createCallback(centerAlpha, cssColor, cssOutlineColor, newOutlineWidth, newPointSize));
}

function createCallback(centerAlpha, cssColor, cssOutlineColor, cssOutlineWidth, newPixelSize) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'use strict';

var DEFAULT_JSON_COLOR_EXPRESSION = 'color("#ffffff")';
var DEFAULT_JSON_OUTLINE_COLOR_EXPRESSION = 'color("#000000")';
Copy link
Contributor

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.

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"';
Copy link
Contributor

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?

*
* @type {StyleExpression}
*
* @exception {DeveloperError} The style is not loaded. Use Cesium3DTileStyle.readyPromise or wait for Cesium3DTileStyle.ready to be true.
Copy link
Contributor

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.

*
* @example
* var style = new Cesium3DTileStyle({
* image : '(${Temperature} > 90) ? "/url/to/image1" : "/url/to/image2"'
Copy link
Contributor

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to use it?

*
* @see {@link https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/Styling|3D Tiles Styling language}
*/
outlineColor : {
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor

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%

shaderProgram : primitive._sp,
uniformMap : uniformMap,
boundingVolume : primitive._boundingVolume,
//pass : Pass.GROUND
Copy link
Contributor

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?

var batchedIndices = this._batchedIndices;
var length = batchedIndices.length;

var i;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

var features = new Array(featuresLength);
for (var i = 0; i < featuresLength; ++i) {
if (defined(content._billboardCollection) && i < content._billboardCollection.length) {
var billboardCollection = content._billboardCollection;
Copy link
Contributor

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.

}
}

var batchId;
Copy link
Contributor

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?

Cartesian3.add(position, center, position);

var b = this._billboardCollection.add();
b.position = position;
Copy link
Contributor

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.

this._polylines.applyDebugSettings(enabled, color);
}

//TODO: debug settings for points/billboards/labels
Copy link
Contributor

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.

@pjcozzi
Copy link
Contributor

pjcozzi commented Nov 22, 2016

I think I mentioned this in another PR, but it would be useful to have tests for the new @private batch primitives.

@pjcozzi
Copy link
Contributor

pjcozzi commented Nov 22, 2016

Just those comments.

@pjcozzi
Copy link
Contributor

pjcozzi commented Nov 23, 2016

Also, update CHANGES.md with any new classes: https://github.com/AnalyticalGraphicsInc/cesium/blob/3d-tiles/CHANGES.md

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 4, 2017

Added

to the tasklist.

// Highlight the feature
highlighted.feature = pickedFeature;
Cesium.Color.clone(pickedFeature.color, highlighted.originalColor);
pickedFeature.color = Cesium.Color.WHITE.withAlpha(0.5);
Copy link
Contributor

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>
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.
Copy link
Contributor

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);
Copy link
Contributor

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.
Copy link
Contributor

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?

var rotation = Quaternion.unpack(gltfNode.rotation);
var scale = Cartesian3.fromArray(gltfNode.scale);
model._nodeMatrix = Matrix4.fromTranslationQuaternionRotationScale(translation, rotation, scale, model._nodeMatrix);
}
Copy link
Contributor

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);
Copy link
Contributor

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.
cv

Copy link
Contributor Author

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';
Copy link
Contributor

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.

return;
}

when(verticesPromise, function(result) {
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 7.

@lilleyse
Copy link
Contributor

Throughout any code related to pointColor needs to be just color, as reflected in the spec.

@lilleyse
Copy link
Contributor

A couple new files have slightly low coverage:

coverage

@bagnell
Copy link
Contributor Author

bagnell commented Jan 2, 2018

@lilleyse This is ready for another look. I'm not sure why the tests are failing. They pass (both regular and the stub) locally.

@bagnell
Copy link
Contributor Author

bagnell commented Jan 4, 2018

This is now in sync with the spec.

Copy link
Contributor

@lilleyse lilleyse left a 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 : {
Copy link
Contributor

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.

@lilleyse
Copy link
Contributor

lilleyse commented Jan 6, 2018

Does anyone else want to review? I think this is in good shape to merge on Monday otherwise.

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 6, 2018

No need for me to look at this again.

@bagnell
Copy link
Contributor Author

bagnell commented Jan 8, 2018

@lilleyse Updated.

@lilleyse
Copy link
Contributor

lilleyse commented Jan 8, 2018

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)

@lilleyse lilleyse merged commit 4361ec7 into 3d-tiles-vector Jan 8, 2018
@cesium-concierge
Copy link

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:

The issue at #4665 has just been closed and may resolve your issue. Look for the change in the next stable release of Cesium or get it now in the master branch on GitHub https://github.com/AnalyticalGraphicsInc/cesium.


I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome.

🌍 🌎 🌏

@lilleyse lilleyse deleted the vector-tiles branch January 8, 2018 21:14
@bagnell bagnell mentioned this pull request Jan 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants