# 3D object picker for Makie or other visualization package

**URL:** https://discourse.julialang.org/t/3d-object-picker-for-makie-or-other-visualization-package/43458
**Category:** General Usage
**Created:** [July 22, 2020, 12:24am UTC](https://discourse.julialang.org/t/3d-object-picker-for-makie-or-other-visualization-package/43458 "2020-07-22T00:24:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![pauljurczak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pauljurczak/32/921_2.png) [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)
#### Post date: [July 22, 2020, 12:24am UTC](https://discourse.julialang.org/t/3d-object-picker-for-makie-or-other-visualization-package/43458/1 "2020-07-22T00:24:34Z")

</div>

I noticed that Makie has 2D picking and mouse click screen to world coordinates transform:

```julia
  on(scene.events.mousebuttons) do buttons
    if ispressed(scene, Mouse.left)
      pos = to_world(scene, Point2f0(scene.events.mouseposition[]))

```

When I try it inside a 3D scene, `pos` doesn’t seem to have any correspondence with world coordinates. Is there anything available for picking in 3D visualizations with Makie or another package?

---

<div class="post-metadata">

### Author: ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)
#### Post date: [July 22, 2020, 1:31am UTC](https://discourse.julialang.org/t/3d-object-picker-for-makie-or-other-visualization-package/43458/2 "2020-07-22T01:31:45Z")

</div>

not sure if makie has it built in. Back in the OpenGL days I used to do this by: mouse to world coords( Sometimes that vector rotation is done via quaternerions depending on users ability to do pitch, roll and yaw) then an infinite (or max world length) vector checking for nearest intersections with basic vector stuff. Spheres were easiest but you could also do mesh picking, I bet the #geometry crew would be up for it.

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [July 22, 2020, 4:59am UTC](https://discourse.julialang.org/t/3d-object-picker-for-makie-or-other-visualization-package/43458/3 "2020-07-22T04:59:25Z")

</div>

I wanted this at some point, but the problem is that you only have a 2D view, so how do you specify 3D coordinates?

---

<div class="post-metadata">

### Author: ![pauljurczak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pauljurczak/32/921_2.png) [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)
#### Post date: [July 22, 2020, 5:04am UTC](https://discourse.julialang.org/t/3d-object-picker-for-makie-or-other-visualization-package/43458/4 "2020-07-22T05:04:08Z")

</div>

You project 3D world onto 2D screen, specify a 3D ray intersecting transformed mouse coordinates and calculate, which object is closest to it or some other metric favoring objects closer to the camera.
