I overridden the _loadUriAsync (in an extend class from IGLTFLoaderExtension), it works fine in Babylon,js, but embedded in a BabyonNative app, it failed on the texture loading (loadTexture not seems to be mapped ? ).
It gives me the following stacktrace:
I guess the parameters for loadTexture are not the right types.
Can you repro with a playground? I can test and debug with BabylonNative then. Hard to do without a repro PG
I generated a test.js file (from typescript code) that you could test in BabylonNative project.
I am not sure it is whttps://github.com/EricBeetsOfficial-Opuscope/WebXR/blob/master/test.jshat you need/want to test and debug…
Let me know if you need more information.
Inpsired by the function glTFLoader.loadUriAsync and based on a custom BABYLON.IGLTFLoaderExtension plugin, I can make it work without the loadTexture call issue (using scene._loadFile instead of Tools.LoadFileAsync).
I don’t know exactly if it’s the correct fix…but it seems to works as expected.
What do you think of this solution ?
I’m glad to hear it’s working for you. Loadtexture was failing because of the image data parameter type was not what was expected. I think you fix that so it’s working now.
@Eric_Beets Are you aware of the glTFFileLoader.preprocessUrlAsync property? I’m not sure exactly what your scenario is, but maybe this will be easy to deal with than creating a glTF loader extension overriding an undocumented function.
I am not sure to understand the benefit of using public preprocessUrlAsync = (url: string) => Promise.resolve(url);.
It seems, as @Cedric said, the data parameter type was wrong: use new Uint8Array(buff as ArrayBuffer) instead of new DataView(buff) in Tools.LoadFileAsync fixes the loadTexture native call.
It’s likely I don’t understand what you are doing exactly, but I think you are trying to redirect urls from one to another. This function allow you to control that. If you do something like the following, it should allow you to update the url without using a loader extension.
loader.preprocessUrlAsync = function (url) {
if (url === "from.bin") {
url = "to.bin";
}
// ...
return Promise.resolve(url);
}
Maybe this is not what you want to. If so, then ignore me.