on_mouse_pick give me random wrong position
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 316
- Avg merge
- 7h 44m
- Merged PRs (30d)
- 5
Description
I am trying to use Mayavi with trait to build an application. However the on_mouse_pick function always give me wrong position and it cannot obtain the object I clicked on at all.
I draw many 3d points with mlab.points3d method. For example, I click on the point A with position (30, 50, 1), but when I use on_mouse_pick to click on that point, the pick value is random position like (124, 289, 19). There is no any relation between my click point with the picker position.
(Just like shown in figures below, I click on red star, but on_mouse_pick gives the position at the white ball)

Only if I zoom extremely close and click, the position may be close.

And I also found that, when the more I zoom out, the picker position farther to the click position. I think they're maybe some relations between zoom and on_mouse_pick but I cannot figure it out.
Also the famous red ball example cannot work at all. [http://docs.enthought.com/mayavi/mayavi/auto/example_select_red_balls.html](url)
Also I tried on_mouse_pick(self.picker_callback, type='cell') and type='world', they are not work at all.
BTW I am with python 3.7, Mayavi 4.7.1, traits 6.0.0, VTK 8.1.2.
Here is part of my code related with on_mouse_pick
```
class Visualization(HasTraits):
time = Range(100, 149,1)
scene = Instance(MlabSceneModel, ())
def __init__(self):
# Do not forget to call the parent's __init__
HasTraits.__init__(self)
self.data = get_my_data(100)
self.plot_th = self.scene.mlab.points3d(self.data[0], self.data[1], self.data[2], self self.data th_data[3], colormap="hot", scale_factor=1.5, reset_zoom=False)
@on_trait_change('scene.activated')
def set_click(self):
self.figure = mlab.gcf(engine=self.scene.engine)
picker = self.figure.on_mouse_pick(self.picker_callback)
picker.tolerance = 1
def picker_callback(self,picker):
print('pick --> ',picker)
view = View(Item('scene', editor=SceneEditor(scene_class=MayaviScene),
height=800, width=800, show_label=False),
HGroup(
'_', 'time',
),
)
visualization = Visualization()
visualization.configure_traits()
```
How should I fix this one? I appreciate anyone's help.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.