I am trying to get 3D Tile feature that selected. I used viewer.scene.pick function before and got results but I dont know why it dont be returned again . Every time when I want to get feature picked, cesium returns object that has content,detail,id and tileset. I am using react typescript and cesium 1.111 version.
Here is my code and image of feature object
const viewer = new Viewer('cesiumContainer', {
terrain: Terrain.fromWorldTerrain(),
timeline: false,
animation: false,
homeButton: false,
geocoder: false,
baseLayerPicker: false,
sceneModePicker: false,
navigationHelpButton: false,
sceneMode: Cesium.SceneMode.SCENE3D,
mapProjection: new Cesium.WebMercatorProjection(),
});
viewer.screenSpaceEventHandler.setInputAction(function (movement: any) {
var feature = viewer.scene.pick(movement.position);
if (feature instanceof Cesium.Cesium3DTileFeature) {
feature = feature as Cesium.Cesium3DTileFeature;
var propertyNames = feature.getPropertyNames();
var length = propertyNames.length;
for (var i = 0; i < length; ++i) {
var propertyName = propertyNames[i];
console.log(
propertyName +
': ' +
feature.getProperty(propertyName)
);
}
}
}, Cesium.ScreenSpaceEventType.RIGHT_CLICK);
A quick guess, based on the title and a very quick look at the code: I think it should be getPropertyIds (instead of getPropertyNames). If this does not help, it may be necessary to take a closer look…
Thank you for your response Marco 13. But looking at the image of the feature object we can also see that cesium returns an invalid object even though the tile has objects.
I used fromUrl funtion with featureLabelId property to add 3D tile , When I remove {featureIdLabel:layer.Id} the problem was resolved. The code worked incorrectly is like below
It is not entirely clear for me whether the issue is reolved now.
If not: You mention the featureIdLabel, which raises some questions about the exact input data structures: Are you using glTF tile content with the EXT_mesh_features extension?
(This thread will likely be moved to the ‘CesiumJS’ category soon, maybe someone can provide more detailed guidance there…)
According to the documentation for featureIdLabel, this is expected behavior:
Label of the feature ID set to use for picking and styling. For EXT_mesh_features, this is the feature ID’s label property, or “featureId_N” (where N is the index in the featureIds array) when not specified. EXT_feature_metadata did not have a label field, so such feature ID sets are always labeled “featureId_N” where N is the index in the list of all feature Ids, where feature ID attributes are listed before feature ID textures. If featureIdLabel is an integer N, it is converted to the string “featureId_N” automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.
I believe this option was added when support for 3D Tiles 1.1 was added. Under the hood, this uses glTF and the EXT_mesh_features extension as @Marco13 mentions.