pygfx icon indicating copy to clipboard operation
pygfx copied to clipboard

More consistent io / load

Open almarklein opened this issue 1 year ago • 2 comments

In Pygfx there's a few places where we support data to be loaded with external libraries. In particular:

  • in geometries/_compat.py for converting external geometry to pygfx geometry.
  • In materials/_compat.py for converting external materials to pygfx materials.
  • In utils/load.py for 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 load or io subpackage 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 gfx namespace (deprecate first).

almarklein avatar Nov 18 '24 08:11 almarklein

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.

almarklein avatar Nov 18 '24 08:11 almarklein

There is meshio: https://github.com/nschloe/meshio

Korijn avatar Nov 18 '24 11:11 Korijn