Search code examples
wpfeventstransparencyhelix-3d-toolkithelix

Click Event through transparent surface using Helixtoolkit.SortingVisual3D


I want my clickable blue cube to change a color while I click on it through transparent surface MeshGeometryVisual3D element. When the cube container is a children of the ViewPort class everything works fine but is not visible through the surface (no sorting), but when it is children of Helixtoolkit.SortingVisual3D the click event stops to work but is visible through the surface! This is the code of SortingVisual3D elements what I use:

<helix:SortingVisual3D x:Name="sortingVisual1" Method="BoundingSphereSurface" SortingFrequency="5" >  
   <helix:MeshGeometryVisual3D x:Name="_visual"  MeshGeometry="{Binding objectGeometry}"   Visible="{Binding IsChecked, ElementName=MeshVisible}" >
   </helix:MeshGeometryVisual3D>
</helix:SortingVisual3D>

The code of the cube adding to SortingVisual3D element is this:

 AddCubePoint cpsorting = new AddCubePoint(middle, defaultMaterial);
            sortingVisual1.Children.Add(cpsorting);

enter image description here

I have tried to use two identical cubes (one child of ViewPort, the second of SortingVisual3D) at the same position, but the color changes on clicking behind the surface, only on children of ViewPort (see the picture)!

enter image description here

I am new to helix-3d-toolkit and after 2 days research I couldn't find any workable solution or idea how to solve this problem ! Please, help me !


Solution

  • You need to put the cube before your semi transparent mesh, so the cube is rendered first. Set your transparent mesh hit test visible to false