編集

次の方法で共有


RayHitTestParameters.Direction Property

Definition

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

public:
 property System::Windows::Media::Media3D::Vector3D Direction { System::Windows::Media::Media3D::Vector3D get(); };
public System.Windows.Media.Media3D.Vector3D Direction { get; }
member this.Direction : System.Windows.Media.Media3D.Vector3D
Public ReadOnly Property Direction As Vector3D

Property Value

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

Examples

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);
Public Sub HitTest(ByVal sender As Object, ByVal args As MouseButtonEventArgs)
    Dim mouseposition As Point = args.GetPosition(myViewport)
    Dim testpoint3D As New Point3D(mouseposition.X, mouseposition.Y, 0)
    Dim testdirection As New Vector3D(mouseposition.X, mouseposition.Y, 10)
    Dim pointparams As New PointHitTestParameters(mouseposition)
    Dim rayparams As New RayHitTestParameters(testpoint3D, testdirection)

    'test for a result in the Viewport3D
    VisualTreeHelper.HitTest(myViewport, Nothing, AddressOf HTResult, pointparams)

Remarks

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.

Applies to

See also