Hi Mazen,
Haven't forgot about this question. So there was actually a bug where we were returning the FeatureIndex not the FeatureID in this result. The next release will contain this fix. IF you need it now I can recommend updating the function to be this
public Physics.ArcGISRaycastHit GetArcGISRaycastHit(RaycastHit raycastHit)
{
Physics.ArcGISRaycastHit output;
output.featureId = -1;
output.featureIndex = -1;
output.layer = null;
var arcGISRendererComponent = rendererGO.GetComponent<ArcGISRendererComponent>();
if (raycastHit.collider != null && arcGISRendererComponent != null)
{
var sceneComponent = arcGISRendererComponent.GetSceneComponentByGameObject(raycastHit.collider.gameObject);
if (sceneComponent != null)
{
output.featureIndex = Physics.RaycastHelpers.GetFeatureIndexByTriangleIndex(raycastHit.collider.gameObject, raycastHit.triangleIndex);
output.layer = View.Map?.FindLayerById(sceneComponent.LayerId);
if (sceneComponent.Material.NativeMaterial.HasTexture("_FeatureIds"))
{
// gets the feature ID
var featureIds = (Texture2D)sceneComponent.Material.NativeMaterial.GetTexture("_FeatureIds");
var width = featureIds.width;
int y = (int)Mathf.Floor(output.featureIndex / width);
int x = output.featureIndex - y * width;
var color = featureIds.GetPixel(x, y);
var scaledColor = new Vector4(255f * color.r, 255f * color.g, 255f * color.b, 255f * color.a);
var shift = new Vector4(1, 0x100, 0x10000, 0x1000000);
scaledColor.Scale(shift);
output.featureId = (int)(scaledColor.x + scaledColor.y + scaledColor.z + scaledColor.w);
}
}
}
return output;
}
You will still have one more issue though, with that being the difference between some SceneServers. Some have an associated FeatureLayer resource which you can just use the query operation on. However if your SceneServer contains cached attributes it is significantly more complicated.
If you share the service you are using I can help identify what it is.
IF it ends up being a cached service I can try to explain how you can use the AttributeProcessor to store all the attributes you need in a map for your later use. But we will be creating a better solution for this as well so I'll hold off on explaining this unless we end up confirming you are working with a cached SceneServer