Could GLTFLoader() _loadIndicesAccessorAsync() be exposed as public method?

I was writing a custom IGLTFLoaderExtension that loads alternative index buffer for ngon wireframes from custom added gltf metadata.

However I had to call _loadIndicesAccessorAsync with a hacky any conversion: (this.loader as any)._loadIndicesAccessorAsync(...) to access the private method in order to load the index buffer accessor without duplicating half of GLTFLoader itself. But by doing so I lost type checking in case the internal method arguments are changed in future update.

Most other “internal” methods like that have already been exposed as public as needed by other extensions (eg. _loadFloatAccessorAsync, _createTextureAsync, _loadMeshPrimitiveAsync, _loadAnimationChannelAsync etc. are public), but seems like there are still some left private because no internal gltf extension has yet needed those.

Therefore would be great if this method was also changed to public to make it easier to write custom extensions even if they want to load additional index buffers. Maybe even change _loadVertexBufferViewAsync and _loadVertexAccessorAsync to public as well, in case someone needs those at some point in the future. :slight_smile:

do you mind creating a PR @MiikaH ?

Any suggestions of the scope of such change? Just _loadIndicesAccessorAsync() or also other similar higher level methods that are still private?

I was thinking a person familiar with the code would be able to quickly go through the GLTFLoader methods and change the remaining sensible ones public as well because many of them would definitely be useful for people writing more complex custom extensions. Underscore + @internal flag should be enough to make it clear that they aren’t guaranteed to remain unchanged between releases, so allowing people who understand that utilize them would make sense to me.

But if you think that only changing _loadIndicesAccessorAsync() makes most sense I can go ahead an make a PR for it?

If you do one, you could rather do all the vertex buffers ones, sounds like a good plan :slight_smile:

@bghgary any concerns ?

I’m okay with this. Start with public underscore + @internal. We can upgrade to fully public later once it has been used by a few extensions.

Ok, I now created a pull request here: Make GLTFLoader index and vertex buffer load methods public by MiikaH · Pull Request #13687 · BabylonJS/Babylon.js · GitHub

I guess that should have “skip changelog” label, but I’ll leave that to you guys as I’m not sure if I even could add it myself. :thinking: