pygfx
pygfx copied to clipboard
More consistent io / load
In Pygfx there's a few places where we support data to be loaded with external libraries. In particular:
- in
geometries/_compat.pyfor converting external geometry to pygfx geometry. - In
materials/_compat.pyfor converting external materials to pygfx materials. - In
utils/load.pyfor loading whole meshes, scenes, etc.
As Korijn said, the important parts are:
- Ensure external lib imports are optional
- The compatibility layer between external objects and pygfx objects is what matters most
- Direct loading functions are for convenience
- Consistency between different libraries is a pipe dream
Let's not try to make a single abstraction over multiple external libraries. Instead I propose:
- The compat functionality for geometries and materials is fine.
- Create a
loadoriosubpackage that is basically a collection of functions to load (and store?) stuff using external libraries. - Give this a separate section in the docs (instead of as part of
pygfx.utils). - Remove all io from the main
gfxnamespace (deprecate first).
basically a collection of functions
IO is inherently messy. By constraining it to a specific namespace, it's somewhat scalable without affecting the main pygfx API.
There is meshio: https://github.com/nschloe/meshio