engine icon indicating copy to clipboard operation
engine copied to clipboard

Should texture parsers be public API?

Open willeastcott opened this issue 9 months ago • 2 comments

Currently, we have the following classes exposed in the API reference:

  • TextureParser
  • BasisParser
  • DdsParser
  • HdrParser
  • ImgParser
  • KtxParser
  • Ktx2Parser

Instances of these classes are created in the TextureHandler constructor and saved to TextureHandler#parsers:

https://github.com/playcanvas/engine/blob/62c1c7fab8df8ab03ab6a42a54ce04fdde77fda4/src/framework/handlers/texture.js#L141-L147

But this object is not public API. So the question is:

  • Should we expose TextureHandler#parsers as public API?
  • Or should we hide the various parsers from the public API?

willeastcott avatar Apr 14 '25 14:04 willeastcott

There is some benefit of exposing it, and allowing this to be configured. As number of parsers are likely to only grow. It will allow some code stripping.

Maksims avatar Apr 14 '25 15:04 Maksims

At the moment, AppBase initialization allows you to register the component systems and resource handlers you use to facilitate treeshaking. Allowing treeshaking that is essentially one extra level down seems like a real microoptimization, IMHO. Personally, I'd prefer a leaner, meaner public API.

willeastcott avatar Apr 14 '25 15:04 willeastcott