Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D Non-Orthogonal Clipping Planes #418

Merged
merged 22 commits into from
Apr 15, 2021

Conversation

ilan-gold
Copy link
Collaborator

@ilan-gold ilan-gold commented Apr 12, 2021

Fixes one of the "nice to haves" from the roadmap:https://docs.google.com/document/d/1swidpzUFDjSZOjK98XW-r-QTVW9D8klgZ-3DYWUGA6c/edit#

My engineering estimates are often way off and this was one of those times - I had chalked this up to be a ton of work, but I had a bit of an epiphany while doing something unrelated, and then it only took about 15 minutes :)

Background

This PR allows for non-orthogonal (i.e not one of the axis-aligned xSlice, ySlice, or zSlice) clipping planes by allowing people to specify a list of normal vectors and offsets from the origin, the two of which together define the equation for a plane. We can then use this to decide how to clip the volume on the shader

Change List

- Adds numPlanes, normalClippingPlanes, and offsetClippingPlanes props to our Layers and Viewers - edit the shaders accordingly.

  • Add numPlanes and clippingPlanes props for clipping planes. Edit shaders accoringly.

Checklist

  • Update JSdoc types if there is any API change.
  • Make sure Avivator works as expected with your change.

@ilan-gold ilan-gold requested a review from manzt April 12, 2021 14:36
@ilan-gold
Copy link
Collaborator Author

Just discovered https://math.gl/modules/culling/docs/api-reference/plane so going to try switching to that. Sorry for the change.

Copy link
Member

@manzt manzt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Do you have a working demo?

How does the exposed API clippingPlanes + numPlanes interact/conflict with <x,y,z>Slice? Can numPlanes be inferred from clippingPlanes?

@ilan-gold
Copy link
Collaborator Author

ilan-gold commented Apr 15, 2021

Cool! Do you have a working demo?

For now I was just using the xSlice, ySlice and zSlice props to test it, but this functionality will be part of Avivator so a demo will exist.

How does the exposed API clippingPlanes + numPlanes interact/conflict with <x,y,z>Slice? Can numPlanes be inferred from clippingPlanes?

Good point, numPlanes probably could be. As for the <x,y,z>Slice props, they work in tandem no problem (i.e there shouldn't be any issue about coordinate systems mismatches or the like). On some level I guess <x,y,z>Slice is redundant now, although it is does provide a more performant way of doing the orthogonal slicing. I think we could have implemented the planes API in the intersectBox function but I there have been discussions about hooking up slicing to a lens in some way, so I do want to be a bit more flexible about how these more custom slicers could render (i.e not just on or off).

Base automatically changed from ilan-gold/3d_avivator to feature/3d April 15, 2021 15:59
@ilan-gold ilan-gold merged commit 02d254c into feature/3d Apr 15, 2021
@ilan-gold ilan-gold deleted the ilan-gold/non_ortho_clipping_planes branch April 15, 2021 16:33
ilan-gold added a commit that referenced this pull request May 27, 2021
* 3D Viv Core (#409)

* Initial commit

* CHANGELOG.

* Address comments.

* Prettier.

* 3D Docs (#411)

* First pass at docs.

* Clean up.

* Add to docs.

* Spelling & brief docs.

* Change docs target

* Update docs/3D_RENDERING_BRIEF.md

Co-authored-by: Trevor Manz <trevor.j.manz@gmail.com>

Co-authored-by: Trevor Manz <trevor.j.manz@gmail.com>

* Fix 3D types/docs

* Remove header.

* Basic 3D Avivator (#412)

* Initial commit

* CHANGELOG.

* Address comments.

* Prettier.

* [WIP] Avivator first pass.

* Fix webpack config.

* Fix restricted syntax.

* 3D Non-Orthogonal Clipping Planes (#418)

* Initial commit

* CHANGELOG.

* Address comments.

* Prettier.

* [WIP] Avivator first pass.

* Add non-orthogonal clipping planes.

* Use `flat`

* Fix typo

* Fix numPlanes padding

* Fix plane equation.

* Use sign function instead of ceil

* Remove cast.

* Use Plane API

* Remove `numPlanes` argument.

* (For 3D) Avivator Refactor (#420)

* Initial commit

* CHANGELOG.

* Address comments.

* Prettier.

* [WIP] Avivator first pass.

* [WIP] State management, some updates to Avivator.

* [WIP] Adding more use of the global state.

* [WIP] More state replacement.

* Change color palette selector.

* Use imgae settings.

* Use viewer store.

* Clean up unnecessary Avivator props.

* Create self-contained buttons.

* Refactor main `useEffect` to use hooks.

* Fix snackbars.

* Refactor Viewer.

* Change names of buttons.

* Refactor Snackbars

* Remove unused vars.

* Refactor menu.

* Reset with new image.

* Fix linting error.

* Refactor props -> global state for dropzone components.

* Remove more unnecessary props.

* Colorpalette use global state.

* Refactor selections.

* Fix async selection bug.

* Fix viewState/initialViewState issue.

* Fix toggle.  Remove dead code.

* Small ids fix.

* Refactor channel stats.

* Use > instead of epsilon.

* Revert loader change.

* Fix import paths.

* Tweaks.

* Prettier.

* Fix state bug and lens display.

* Handle undefined loader in state.  Small entries suggestion.

* Reform state management.

* Small code compleixty change.

* Fix artifacts for additive.

* Small Features/Fixes for Viv Src (#422)

* Fixes for viv src

* Update src/layers/ImageLayer.js

Co-authored-by: Trevor Manz <trevor.j.manz@gmail.com>

* Prettier,

Co-authored-by: Trevor Manz <trevor.j.manz@gmail.com>

* New Avivator (#421)

* Initial commit

* CHANGELOG.

* Address comments.

* Prettier.

* [WIP] Avivator first pass.

* [WIP] State management, some updates to Avivator.

* [WIP] Adding more use of the global state.

* [WIP] More state replacement.

* Change color palette selector.

* Use imgae settings.

* Use viewer store.

* Clean up unnecessary Avivator props.

* Create self-contained buttons.

* Refactor main `useEffect` to use hooks.

* Fix snackbars.

* Refactor Viewer.

* Change names of buttons.

* Refactor Snackbars

* Remove unused vars.

* Refactor menu.

* Reset with new image.

* Fix linting error.

* Refactor props -> global state for dropzone components.

* Remove more unnecessary props.

* Colorpalette use global state.

* Refactor selections.

* Fix async selection bug.

* Fix viewState/initialViewState issue.

* Fix toggle.  Remove dead code.

* Small ids fix.

* Refactor channel stats.

* Use > instead of epsilon.

* Revert loader change.

* Fix import paths.

* Tweaks.

* Prettier.

* Styling.

* Slicers using polar coordinates.

* Merge branch 'ilan-gold/avivator_refactor' into ilan-gold/new_avivator

* Use epsilon value.

* Use better range of theta.

* onViewportLoad callbacks.

* Remove plane flip

* Move onViewportLoad to image settings.

* Set up isLoading callbacks.

* Fix AddChannel call backs.

* Allow options to be disabled as well.

* Simplify global selections

* AbortController for volume layer

* Only do keydown change selection

* Add delay to onViewportload prop for volumes

* Add slicer presets. Move slicer location.

* Fix Camera Axis.

* Debounce view state change.

* Fix coordinate system for volume.

* Change scaling of normal planes.

* Linting.

* Fix old merge issues

* Change coordinates of slicing

* Add isLoading for channel.

* Add isChannelLoading removal.

* Chane when channel is set to loading.

* Fix jsdocs. Small fix for volume button.

* Don't always use physical size scaling.

* Fix loader physical size inference.

* Make typescript happy.

* Small fix.

* Fix properties state bug.

* Fix rotation recentering.

* Use copy of clipping planes.

* Fixes for viv src

* Address comments.

* Slicing Reversion + New Demo Datasets (#430)

* Revert to orthogonal slicing.

* Add idr datasets

* Fix slicer styling.

* Small doc fixes.

* Add interpolation to 3D

* Add check for interpolation.

* prettier.

* Final Changes for Avivator (#434)

* Use tabs for controller.

* WRong disabled cpondition for volume button

* Change non-3d rendering mode display.

* Small style tweaks.

* Fix checkbox.  Small styling issues.

* Rename

* Add disabled styling.

* Add spacing.

* Fix slicer styling.

* Set bounding cube intiially.

* Add warning about WebGL2

* Remind to refresh page.

* Fix for 3D Blending. (#440)

* Minimal Fix for 3D Blending.

* Remove culling on layer

* Add comment.

* Prettier.

* Add progress indicator option + onUpdate callback. (#446)

Co-authored-by: Trevor Manz <trevor.j.manz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants