RayHitTestParameters.Direction Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets a Vector3D that indicates the direction (from its origin) of the ray along which to hit test.

Namespace:   System.Windows.Media.Media3D
Assembly:  PresentationCore (in PresentationCore.dll)

public Vector3D Direction { get; }

Property Value

Type: System.Windows.Media.Media3D.Vector3D

Vector3D that indicates the direction of the ray along which to hit test.

Note that the visual layer supports hit testing against all objects under a point or geometry, not just the topmost object. A 2D hit test will also return 3D results directly under the specified point or geometry.

public void HitTest(object sender, System.Windows.Input.MouseButtonEventArgs args)
    Point mouseposition = args.GetPosition(myViewport);
    Point3D testpoint3D = new Point3D(mouseposition.X, mouseposition.Y, 0);
    Vector3D testdirection = new Vector3D(mouseposition.X, mouseposition.Y, 10);
    PointHitTestParameters pointparams = new PointHitTestParameters(mouseposition);
    RayHitTestParameters rayparams = new RayHitTestParameters(testpoint3D, testdirection);

    //test for a result in the Viewport3D
    VisualTreeHelper.HitTest(myViewport, null, HTResult, pointparams);

.NET Framework
Available since 3.0
Return to top