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

Picking tiles without batch tables #5253

Merged
merged 4 commits into from
May 3, 2017

Conversation

rahwang
Copy link
Contributor

@rahwang rahwang commented Apr 28, 2017

Fixes #2181. How should I test this, @lilleyse ?

@rahwang rahwang changed the title adding tile to tilefeature and pickId objects Picking tiles without batch tables Apr 28, 2017
@@ -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}
Copy link
Contributor

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.

@@ -46,7 +46,7 @@ define([
this._batchTable = content.batchTable;
this._batchId = batchId;
this._color = undefined; // for calling getColor

this._tile = 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.

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

@@ -3468,6 +3469,10 @@ define([
mesh : runtimeMeshesByName[mesh.name]
};

if (defined(model._pickInfo)) {
owner = combine(owner, model._pickInfo);
}
Copy link
Contributor

@lilleyse lilleyse Apr 28, 2017

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.

@lilleyse
Copy link
Contributor

lilleyse commented Apr 28, 2017

How should I test this, @lilleyse ?

You can look at picks in PointCloud3DTileContent as an example. That test needs to be modified to check that result.tile is there.

For Batched3DTileContent make sure the tileset you load is withoutBatchTableUrl.

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.

@rahwang rahwang force-pushed the picking-without-batch-tables branch from 1a13884 to 5d0cd81 Compare May 2, 2017 21:49
@rahwang
Copy link
Contributor Author

rahwang commented May 2, 2017

Comments addressed and added tests, @lilleyse

@rahwang rahwang force-pushed the picking-without-batch-tables branch from 5d0cd81 to ec24907 Compare May 3, 2017 13:23
@@ -55,6 +53,24 @@ define([
* @private
*/
this.primitive = tileset;

/**
* All objects returned by {@link Scene#pick} have a <code>tile</code> property.
Copy link
Contributor

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.

/**
* All objects returned by {@link Scene#pick} have a <code>tile</code> property.
*
* @type {Cesium3DTileset}
Copy link
Contributor

Choose a reason for hiding this comment

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

Change the type.

/**
* All objects returned by {@link Scene#pick} have a <code>content</code> property.
*
* @type {Cesium3DTileset}
Copy link
Contributor

Choose a reason for hiding this comment

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

Change the type.

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

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.

id : model.id,
node : runtimeNode.publicNode,
mesh : runtimeMeshesByName[mesh.name]
};

if (defined(model._pickObject)) {
owner = model._pickObject;
}
Copy link
Contributor

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

Choose a reason for hiding this comment

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

These tests look good!

@rahwang
Copy link
Contributor Author

rahwang commented May 3, 2017

Comments addressed! Ready for another look, @lilleyse

@lilleyse
Copy link
Contributor

lilleyse commented May 3, 2017

Looks good!

@lilleyse lilleyse merged commit 3a3c466 into CesiumGS:3d-tiles May 3, 2017
*
* @private
*/
this.tile = 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.

Should this be a readonly getter property?

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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

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?

@rahwang rahwang deleted the picking-without-batch-tables 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