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

Only show picked tile debug labels #5325

Merged
merged 6 commits into from
May 24, 2017

Conversation

rahwang
Copy link
Contributor

@rahwang rahwang commented May 15, 2017

An addition to #5188 , adds option for only displaying debug labels for picked tile in the inspector.

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.

Looks good so far, a few things:

  • It is sometimes hard to see the info box when picking a tile that is close up. Something like the Picking sandcastle where the box follows the cursor would be better.
  • Picking doesn't work for tiles without a batch table, like ../../../Specs/Data/Cesium3DTiles/Batched/BatchedNoBatchIds
  • Add a test to Cesium3DTileset

@@ -196,6 +196,7 @@ define([
errorBox.setAttribute('data-bind', 'text: editorError');
stylePanelContents.appendChild(errorBox);

tileDebugLabelsPanelContents.appendChild(makeCheckbox('showOnlyPickedTileDebugLabel', 'Show Only Picked Tile Label'));
Copy link
Contributor

Choose a reason for hiding this comment

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

The text could be simplified to Show Picked Only

@@ -327,9 +327,11 @@ define([
var picked = scene.pick(e.endPosition);
if (picked instanceof Cesium3DTileFeature) {
that.feature = picked;
that._tileset._pickedTile = picked.content._tile;
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to _debugPickedTile

showOnlyPickedTileDebugLabel(value);
if (that._tileset) {
that._tileset._onlyPickedTileDebugLabel = value;
that.picking = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

This option shouldn't turn picking on.

@rahwang
Copy link
Contributor Author

rahwang commented May 17, 2017

Thanks for the review, @lilleyse ! This is ready for another look.

As we were discussing, the labels still stick when scene.pickTranslucentDepth = false.

that._pickStatsText = getStats(that._tileset, true);

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove empty line.

if (scene.pickPositionSupported && (pos = scene.pickPosition(e.endPosition))) {
that._tileset._debugPickPosition = pos;
}
that._tileset._debugPickedTile = picked.content._tile;
Copy link
Contributor

Choose a reason for hiding this comment

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

You can now do picked.content.tile (recently added).

that.feature = picked;
var pos;
e.endPosition.x += 10;
e.endPosition.y -= 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of offsetting the pick position, you could add a pixelOffset to the label. This may fix some of the other issues, but we'll see.

var pos;
e.endPosition.x += 10;
e.endPosition.y -= 10;
if (scene.pickPositionSupported && (pos = scene.pickPosition(e.endPosition))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The second statement belongs inside the if block.

that.feature = picked;
var pos;
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid abbreviations. position is fine.

if (defined(tileset._debugPickedTile)) {
addTileDebugLabel(tileset._debugPickedTile, tileset);
if (defined(tileset._debugPickPosition)) {
tileset._tileDebugLabels._labels[0].position = tileset._debugPickPosition;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use tileDebugLabels.get.

@rahwang
Copy link
Contributor Author

rahwang commented May 22, 2017

Thanks for the review, @lilleyse ! The pixelOffset did the trick -- looks like the flickering was from interference from the label.

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.

Getting close. The actual behavior is perfect now.

@@ -1451,6 +1451,32 @@ defineSuite([
});
});

it('show only picked tile debug label with all stats', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test should be setting _onlyPickedTileDebugLabel to true.

You can use expect(scene).toPickAndCall(function(result) { to set _debugPickedTile, and then something else for _debugPickPosition. The scene.pickForSpecs call isn't required.

As part of the same test, set _debugPickedTile to undefined and check that no label is present.

@@ -325,11 +325,18 @@ define([
if (value) {
that._eventHandler.setInputAction(function(e) {
var picked = scene.pick(e.endPosition);
if (picked instanceof Cesium3DTileFeature) {
if (picked && defined(picked.content)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use defined(picked) instead of just picked.

position = scene.pickPosition(e.endPosition);
that._tileset._debugPickPosition = position;
}
that._tileset._debugPickedTile = picked.content.tile;
Copy link
Contributor

Choose a reason for hiding this comment

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

This area could be organized a little differently so that it only does these steps if showOnlyPickedTileDebugLabel is true. Also setting that.feature = picked may have side effects when picked is not a feature.

var halfAxes = boundingVolume.halfAxes;
var radius = boundingVolume.radius;

var position = Cartesian3.clone(boundingVolume.center, scratchCartesian);
Copy link
Contributor

Choose a reason for hiding this comment

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

I should have left this comment earlier, but since there are two different ways of positioning labels now, maybe they can be broken out into separate functions.

var position;
if (scene.pickPositionSupported) {
position = scene.pickPosition(e.endPosition);
that._tileset._debugPickPosition = position;
Copy link
Contributor

Choose a reason for hiding this comment

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

Cesium3DTilesInspectorViewModel shouldn't be setting all of these private attributes of Cesium3DTileset. If they can be set without consequences, should they be public instead?

Copy link
Contributor

@lilleyse lilleyse May 22, 2017

Choose a reason for hiding this comment

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

Yeah I wasn't sure about this either or how strict we get for tightly-coupled areas like this. Maybe they should be public but still marked as private for exclusion from doc?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it need to be private? We have all kinds of public debug properties in Scene

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I made them public for now, but I see Sean's point about excluding from docs.

@rahwang
Copy link
Contributor Author

rahwang commented May 23, 2017

Thanks for the review, @hpinkos and @lilleyse -- comments addressed!

@@ -400,6 +402,11 @@ define([
*/
this.debugShowGeometricError = defaultValue(options.debugShowGeometricError, false);

this._tileDebugLabels = undefined;
this._onlyPickedTileDebugLabel = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency this should lose the underscore as well.

if (defined(tileset.debugPickedTile)) {
var position = (defined(tileset.debugPickPosition)) ? tileset.debugPickPosition : computeTileLabelPosition(tileset.debugPickedTile);
addTileDebugLabel(tileset.debugPickedTile, tileset, position);
tileset._tileDebugLabels.get(0).pixelOffset = new Cartesian2(15, -15); // Offset to avoid picking the label.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a bit cleaner if addTileDebugLabel returns the label, then set the pixelOffset on that rather than getting from the collection.

that._tileset.debugPickPosition = position;
} else {
position = undefined;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for this else block.

@lilleyse
Copy link
Contributor

When zoomed out I sometimes see situations where a tile is picked but the pick position returns undefined. This causes the tile to move to the corner of the tile sometimes. Probably the best solution is to not set the debugPickPosition if it would be undefined.

labels

@rahwang
Copy link
Contributor Author

rahwang commented May 23, 2017

What causes pickPosition to return undefined? Are there any scenarios where that would happen outside of !scene.pickPositionSupported?

@rahwang
Copy link
Contributor Author

rahwang commented May 23, 2017

Fixed, @lilleyse

@lilleyse
Copy link
Contributor

What causes pickPosition to return undefined? Are there any scenarios where that would happen outside of !scene.pickPositionSupported?

It can happen if scene.globe.depthTestAgainstTerrain is false (the default) where the terrain doesn't write depth.

@lilleyse
Copy link
Contributor

Thanks @rahwang, looks good!

@lilleyse lilleyse merged commit 5489bcb into CesiumGS:3d-tiles May 24, 2017
@rahwang rahwang deleted the pick-tile-debug-label branch June 26, 2017 13:01
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.

3 participants