allen-cell-animated / volume-viewer

https://allen-cell-animated.github.io/volume-viewer/
Other
92 stars 7 forks source link

Feature/option to append viewer to document manually #97

Closed frasercl closed 1 year ago

frasercl commented 1 year ago

Problem

View3d's constructor must currently be supplied with a parent element to which to append the viewer element on creation. This leads to a pattern in website-3d-cell-viewer where the viewer is only created after its containing component has mounted and rendered a container, leading in turn to TypeScript requiring null checks any time view3d is used because it is not definitely assigned in the constructor. Three.js exposes a domElement property on renderers and allows users to add it where they want in the document; if View3d used a similar pattern, it would allow website-3d-cell-viewer to initialize the viewer on component creation and avoid null checks.

Solution

This is a BREAKING CHANGE to View3d's constructor signature. Some trivial, but ugly, changes could be made to make the constructor backwards-compatible if necessary.

Also, replace a bunch of image null checks with TypeScript's more concise ?. syntax.