helix-toolkit / helix-toolkit

Helix Toolkit is a collection of 3D components for .NET.

Home Page:http://helix-toolkit.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to determine which GeometryModel3D object is selected by the mouse?

zhw1992 opened this issue · comments

<HelixToolkit:HelixViewport3D MouseMove="HelixView_MouseMove">
HelixToolkit:DefaultLights/

</HelixToolkit:HelixViewport3D>

The code adds geometries in the following structure:
Model
Model3DGroup
└── Model3DGroup(Multiple)
└──GeometryModel3D (Multiple)

The code populates a hierarchy where the root object is a Model that contains a Model3DGroup. This Model3DGroup houses multiple instances of itself (Model3DGroup), each of which, in turn, contains multiple instances of GeometryModel3D.

After obtaining a ModelVisual3D object through VisualTreeHelper.HitTest, I would like to retrieve the associated GeometryModel3D object. How should I proceed?

We have SelectionCommands, see at Selection Example

@MauNguyenVan
If the mouse is hovered over without moving, and it is the GeometryModel3D that I want to select, how should I implement it?

do u want to hover the mouse on the GeometryModel3D, and try to check which object is selected, right?
It's same like show the tooltip when hover the mouse on a button, right?

@MauNguyenVan
Yes, the SelectionCommands currently require a click to display. How can I implement showing something when the mouse hovers over a GeometryModel3D?

I think, you can try with mouse move + timer. If mouse locations is not change, and pass some 100ms, you can activate your command.
I remember wpf behavior lib allows you to bind a command in an event .

If the helix selected command does not support it. You can implement your own selected command base on helix selected command