-
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
Only show picked tile debug labels #5325
Conversation
26a1581
to
7457f0a
Compare
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.
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')); |
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.
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; |
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.
Rename to _debugPickedTile
showOnlyPickedTileDebugLabel(value); | ||
if (that._tileset) { | ||
that._tileset._onlyPickedTileDebugLabel = value; | ||
that.picking = 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.
This option shouldn't turn picking on.
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); | ||
|
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 empty line.
if (scene.pickPositionSupported && (pos = scene.pickPosition(e.endPosition))) { | ||
that._tileset._debugPickPosition = pos; | ||
} | ||
that._tileset._debugPickedTile = picked.content._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.
You can now do picked.content.tile
(recently added).
that.feature = picked; | ||
var pos; | ||
e.endPosition.x += 10; | ||
e.endPosition.y -= 10; |
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.
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))) { |
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.
The second statement belongs inside the if block.
that.feature = picked; | ||
var pos; |
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.
Avoid abbreviations. position
is fine.
Source/Scene/Cesium3DTileset.js
Outdated
if (defined(tileset._debugPickedTile)) { | ||
addTileDebugLabel(tileset._debugPickedTile, tileset); | ||
if (defined(tileset._debugPickPosition)) { | ||
tileset._tileDebugLabels._labels[0].position = tileset._debugPickPosition; |
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.
Use tileDebugLabels.get
.
Thanks for the review, @lilleyse ! The pixelOffset did the trick -- looks like the flickering was from interference from the label. |
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.
Getting close. The actual behavior is perfect now.
@@ -1451,6 +1451,32 @@ defineSuite([ | |||
}); | |||
}); | |||
|
|||
it('show only picked tile debug label with all stats', function() { |
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 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)) { |
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.
Use defined(picked)
instead of just picked
.
position = scene.pickPosition(e.endPosition); | ||
that._tileset._debugPickPosition = position; | ||
} | ||
that._tileset._debugPickedTile = picked.content.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.
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); |
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 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; |
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.
Cesium3DTilesInspectorViewModel
shouldn't be setting all of these private attributes of Cesium3DTileset
. If they can be set without consequences, should they be public instead?
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 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?
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 it need to be private? We have all kinds of public debug properties in Scene
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.
Hmm, I made them public for now, but I see Sean's point about excluding from docs.
059e5d0
to
670e865
Compare
670e865
to
1a04748
Compare
Source/Scene/Cesium3DTileset.js
Outdated
@@ -400,6 +402,11 @@ define([ | |||
*/ | |||
this.debugShowGeometricError = defaultValue(options.debugShowGeometricError, false); | |||
|
|||
this._tileDebugLabels = undefined; | |||
this._onlyPickedTileDebugLabel = false; |
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.
For consistency this should lose the underscore as well.
Source/Scene/Cesium3DTileset.js
Outdated
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. |
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.
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; | ||
} |
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.
No need for this else
block.
What causes pickPosition to return undefined? Are there any scenarios where that would happen outside of !scene.pickPositionSupported? |
Fixed, @lilleyse |
It can happen if |
Thanks @rahwang, looks good! |
An addition to #5188 , adds option for only displaying debug labels for picked tile in the inspector.