-
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
Picking tiles without batch tables #5253
Picking tiles without batch tables #5253
Conversation
@@ -362,7 +362,8 @@ define([ | |||
pickVertexShaderLoaded : getPickVertexShaderCallback(content), | |||
pickFragmentShaderLoaded : batchTable.getPickFragmentShaderCallback(), | |||
pickUniformMapLoaded : batchTable.getPickUniformMapCallback(), | |||
addBatchIdToGeneratedShaders : (batchLength > 0) // If the batch table has values in it, generated shaders will need a batchId attribute | |||
addBatchIdToGeneratedShaders : (batchLength > 0), // If the batch table has values in it, generated shaders will need a batchId attribute | |||
pickInfo : {tile : 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.
Remove all occurrences of pickPrimitive
now that there's pickInfo
. Also pickObject
may be a better name now.
Also include primitive
(= tileset) and content
into the pick object. Create the pick object as a variable above so this area is cleaner.
Source/Scene/Cesium3DTileFeature.js
Outdated
@@ -46,7 +46,7 @@ define([ | |||
this._batchTable = content.batchTable; | |||
this._batchId = batchId; | |||
this._color = undefined; // for calling getColor | |||
|
|||
this._tile = 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.
_tile
and _content
will need to lose the underscores to be consistent with the pick object sent to Model
and the pick object in PointCloud3DTileContent
. Add doc above them like for this.primitive
.
Source/Scene/Model.js
Outdated
@@ -3468,6 +3469,10 @@ define([ | |||
mesh : runtimeMeshesByName[mesh.name] | |||
}; | |||
|
|||
if (defined(model._pickInfo)) { | |||
owner = combine(owner, model._pickInfo); | |||
} |
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'm starting to rethink this. If the custom pick object exists then it should be used directly, not combined with owner
. I doubt anyone picking a tile needs to know what gltf node/mesh are picked.
You can look at For For more visual testing, you can add some picking code to the 3D Tiles sandcastle and print the results, checking that they look right for a bunch of different tileset urls. |
1a13884
to
5d0cd81
Compare
Comments addressed and added tests, @lilleyse |
5d0cd81
to
ec24907
Compare
Source/Scene/Cesium3DTileFeature.js
Outdated
@@ -55,6 +53,24 @@ define([ | |||
* @private | |||
*/ | |||
this.primitive = tileset; | |||
|
|||
/** | |||
* All objects returned by {@link Scene#pick} have a <code>tile</code> property. |
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.
Replace this comment and the one below with something else, since this is not true for non 3d-tiles things. The comment above primitive
is still correct though.
Source/Scene/Cesium3DTileFeature.js
Outdated
/** | ||
* All objects returned by {@link Scene#pick} have a <code>tile</code> property. | ||
* | ||
* @type {Cesium3DTileset} |
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.
Change the type.
Source/Scene/Cesium3DTileFeature.js
Outdated
/** | ||
* All objects returned by {@link Scene#pick} have a <code>content</code> property. | ||
* | ||
* @type {Cesium3DTileset} |
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.
Change the type.
Source/Scene/Model.js
Outdated
@@ -3462,12 +3461,16 @@ define([ | |||
// GLTF_SPEC: Offical means to determine translucency. https://github.com/KhronosGroup/glTF/issues/105 | |||
var isTranslucent = rs.blending.enabled; | |||
var owner = { | |||
primitive : defaultValue(model.pickPrimitive, model), | |||
primitive : defaultValue(model._pickObject, model), |
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 set primitive
to model
.
Source/Scene/Model.js
Outdated
id : model.id, | ||
node : runtimeNode.publicNode, | ||
mesh : runtimeMeshesByName[mesh.name] | ||
}; | ||
|
||
if (defined(model._pickObject)) { | ||
owner = model._pickObject; | ||
} |
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 logic here can be reversed to avoid the owner
allocation. Something like
var owner = model._pickObject;
if (!defined(owner)) {
owner = ...
}
expect(result.tile).toBe(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.
These tests look good!
Comments addressed! Ready for another look, @lilleyse |
Looks good! |
* | ||
* @private | ||
*/ | ||
this.tile = 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.
Should this be a readonly getter property?
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.
Also, are we sure we need this property? There will be a lot of these objects since they are per-feature and we want to keep them as small as possible.
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.
Technically we don't, this was mainly for convenience.
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 don't think it is worth it since this can be accessed through content
and I think was only used in the tests.
* | ||
* @private | ||
*/ | ||
this.content = 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.
Why isn't this readonly anymore? Is there something outside of this PR?
Fixes #2181. How should I test this, @lilleyse ?