Adding points in 3D is wacky
See original GitHub issueđ Bug
In #3508, the mode guard in 3D was removed in order to be able to select points, but the ability to add points was inadvertently added, and itâs completely broken.
To Reproduce
from skimage import data
from scipy import ndimage as ndi
import napari
blobs = data.binary_blobs(
length=128, volume_fraction=0.1, n_dim=3
)[::2].astype(float)
labeled = ndi.label(blobs)[0]
viewer = napari.Viewer(ndisplay=3)
viewer.add_image(blobs, name='blobs', scale=(2, 1, 1))
viewer.add_labels(labeled, name='blob ID', scale=(2, 1, 1))
pts = viewer.add_points()
viewer.camera.angles = (0, -65, 85)
pts.mode = 'add'
napari.run()
Now click on a point and you should see behaviour like the below:
https://user-images.githubusercontent.com/492549/154223487-99da4922-107b-4682-8a75-f8b64870f1fe.mov
Expected behavior
Adding a point in 3D without context is undefined, so one of two things should happen imho:
- you would need two clicks with parallax to define a point, or
- use another layer such as an image or labels layer to define a point in 3D, as done in zarpaint (though that appears to be a bit broken at the moment, still investigating)
Environment
napari: 0.4.13rc1.dev59+g79ef36175
Platform: macOS-11.4-x86_64-i386-64bit
System: MacOS 11.4
Python: 3.9.7 | packaged by conda-forge | (default, Sep 2 2021, 17:58:46) [Clang 11.1.0 ]
Qt: 5.15.2
PyQt5: 5.15.6
NumPy: 1.20.3
SciPy: 1.7.1
Dask: 2021.09.0
VisPy: 0.9.6
OpenGL:
- GL version: 2.1 ATI-4.5.14
- MAX_TEXTURE_SIZE: 16384
Screens:
- screen 1: resolution 2304x1296, scale 2.0
- screen 2: resolution 1792x1120, scale 2.0
Plugins:
- animation: 0.0.2
- console: 0.0.4
- explode-view: 0.0.1
- napari-midi: 0.1.dev5+g16c91f6.d20210914
- napari-skeleton-curator: 0.1.dev17+gd073290.d20211212
- nd2-reader: 0.0.6
- platelet-unet-watershed: 0.0.3
- scikit-image: 0.4.13rc1.dev59+g79ef36175
- svg: 0.1.5
- tracks: 0.0.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Adding points to 3d plot in r - Stack Overflow
How to add points to the plot (on the surface, e.g to draw in other color point (1,1,2))?. r ¡ graphics ¡ 3d...
Read more >How to make a 3d solid out of points or 3d poly - AutoCAD
Is it possible to add the additional face by using the edges of ... as points or poly lines which is connected together...
Read more >Creating 3D Points - Onshape Forums
Creating 3D Points ... I've scanned this forum for code that does these, I haven't found any solutions. ... case #1: someone picks...
Read more >How to add a point and drag it into position in a 3D plot?
For adding points, I used a right-click event so as not to interfere with the built-in pan/zoom/rotate for Graphics3D (I'm sure there's an ......
Read more >8 Tips for Clean Topology in Blender (Updated for 2021)
The process you use to put together your 3D model determines a lot - how ... You select an edge to add a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @jni . Sorry for the late reply. Things have been busy here.
I was looking into the issue and I think the problem is when the points layer has an ndim of 2. We currently donât have a well defined behavior for changing the dimensionality of layers. For example, if you try to add a 3D point to a points layer with
ndim == 2
, you will get an error. Adding 3D points to a 2D layer through the GUI doesnât raise an error because it is taking the âdisplayed dimsâ of the coordinate (i.e., 0 and 1 axis). I am not sure what the correct behavior should be, but we can disable this for now.If you try
examples/nD_points.py
the point addition âworksâ in 3D for when the points ndim > 2. However, it is adding the points to the invisible camera plane, which I can see how that is not ideal. We could add a flag to disable the âaddâ button on the layer controls when rendering in 3D.I like this idea. I would be up to try to make this in 0.4.16
I merged #4184, which fixes the main issue here. Thus, I will close this issue and open a new one for improving the 3D points adding UI.