niivue / ipyniivue

A WebGL-powered Jupyter Widget for Niivue based on anywidget
BSD 2-Clause "Simplified" License
25 stars 8 forks source link

feat: Implement initial mesh support #69

Closed manzt closed 1 month ago

manzt commented 2 months ago

Implements initial support for meshes. See ./examples/mesh_layers.ipynb for an example. It is based on the corresponding JavaScript demo.

manzt commented 2 months ago

TODO: I don't see any visual changes adjusting mesh[0].opacity = <new value> or mesh[0].visibile = False.

christian-oreilly commented 1 month ago

Great to see that this feature is moving forward! I fetched the branch and tried the mesh_layer.ipynb notebooks and it runs without issues but do not display any output

image

This behavior is on VS Code in MacOS.

kolibril13 commented 1 month ago

hi @christian-oreilly , I just ran this script as well on MacOS in VS Code, and it runs correctly:

image

Did you run npm run dev before executing the notebook?

christian-oreilly commented 1 month ago

I had not. I had run npm run build. I did not know that npm run dev was necessary since I was not modifying the JS myself. In any case, I did now and it did not change anything. I also check with the normal Jupyter Notebook and JupyterLab and it also does not work there. I got a screenshot of the JS console when I run that cell:

image

Not sure if that can be useful to you. I'll be traveling for the next 3 weeks or so, so I may not be able to follow up on this before I return, but I wanted to share this before leaving.

manzt commented 1 month ago

I had not. I had run npm run build. I did not know that npm run dev was necessary since I was not modifying the JS myself.

To clarify, the front-end source code is in TypeScript and requires transformation to load in the browser. The final assets are not checked into source control, so trying out new changes requires running a npm run build step.

When publishing to PyPI, we build the files for others much like distributing wheels so others do not need to "compile" themselves.

manzt commented 1 month ago

I'm going to merge to continue iteration. This PR also introduces better typesafety and code quality to the code base so I don't want to be blocked with that. @christian-oreilly when you are back ping me and we can find a time for you to try out the changes.