I'm writing a WebGL app in Kotlin JS, and as such I need to fetch resource such as .obj files and shaders. I want to do this through HTTP requests, but I've run into issues.
I'm currently trying to do this via JS's fetch() API. The problem is that this is obviously asynchronous, and fetching the resources needs to be done before the render loop can start (i.e. fetching the resources is initialisation).
I'm really struggling to get this to work synchronously. That is, my program should not continue onto loading buffers and the main draw loop before it has fetched the shaders and .obj files. How can I get this to work in Kotlin JS? Is fetch() not the right way to do this?