To import babylon meshes from an external path but now Im working with a cordova project that uses the plugins: cordova-plugin-file and cordova-plugin-file-transfer to download one specific .babylon file. I can see that the file is downloaded successfully but when I try to import it to my existing scene it never shows up.
Its quite strange cause when I create the apk with the same file (instead downloading it) in the same folder its importation goes fine and shows up in my scene.
Is there some kind of change I must do in my code to be able to import the downloaded file in my existing scene? or other kind of solution?
Thank you all.
Ps: I tried to download in cordova.file.externalDataDirectory and cordova.file.dataDirectory but I need to download it in cordova.file.dataDirectory
The changes I was considering were more extendable than what was done there and to support local (disk/app) and remote assets transparently based on uri ie:( file:// (android/ios), content:// (android), asset:// (android),no scheme (android bundled resource), ph:// (ios), assets-library:// (ios)). Do you have a repo that we can look at? It’s not clear to me if you are loading external as in over http or from files shared from another app.
You should check the network request whitelist docs as well, but it sounds like you are downloading content. Whitelist - Apache Cordova
Sorry for the delay, thanks Delta and brianzinn. I found the solution, the thing is that cordova file system is kinda hard to use, studying cordova’s docs I saw that I needed to use window.resolveLocalFileSystemURL (strange cause for other kind of files I dont need it) so the code to use local babylon files after downloading them is:
window.resolveLocalFileSystemURL(cordova.file.dataDirectory + "mycontentfolder/", function (fs){
fs.getFile(mycontent + ".babylon", { create: false }, function (fe){
BABYLON.SceneLoader.ImportMesh("", "", fe.nativeURL, scene, function (newMeshes, particleSystems, skeletons) {
//My code here
});
}, function(){
alert("Error visualizar_contenido local");
});
}, function(){});
I hope this helps other people with the same issue.