Start a new topic

Accessing files from SD Card then load in ARchitect

Accessing files from SD Card then load in ARchitect


Hi !

I'm developing with this awesome Wikitude tool but I'd encountered a big problem and I cannot find any solution.

I have a lot of 3d models. Too many to be set in the assets folder. My APK did approximatly 40 Mo !

So I decide to store files in the web then download them on the first launch of the app. The goal is to get the augmented reality to work even if I haven't an internet connexion.

My model files are stored in the internal storage, as "/mnt/sdcard/<myappfodler>/models". Notice that the .html file stays in the "Assets" folder on my app.

My Question : How can I tell ARchitect to get the model files from the internal storage ?

 

My Investigations

1.) I tried to get this work with ContentProvider (and content:// uri) but this doesn't work.

2.) I tried by accessing "file:///sdcard" ou "file:///mnt/sdcard" but same problem. (but curiously it works with "file:///android_asset/")

 

PS: Sorry for my bad english :(

Hi Christophe!

Anything written in JS should work cross-platform. If you need your assets in the app, please store them in the asset-folder directly and access them using relative paths in whole project.

E.g. create "world"-folder in asset folder and a "world/models" folder containing all your 3D data. You can then create 3D models etc. using relative paths too.

Hope that helps, 
Kind regards,
Andreas

Hi and thanks for the reply.

Missed to mention that I'm working on Android platform, sorry :)

 

I cannot store all models inside the "assets" folder because the APK resulted file will be too big. So I can reference a HTTP url to the model, but I want also the AR to work event if you are without internet connection.

So I MUST use the internal storage of the device. Is it possible to get models from the internal storage ?

 

For instance :

var model2 = new AR.Model("file:///sdcard/models/deer.wt3", {

scale : {

x : 0.120,

y : 0.120,

z : 0.120

},

enabled : true,

onLoaded: function() { AR.logger.debug("Model onLoaded!"); },

onError: function() { AR.logger.debug("Model onError!"); }

});

 

 

Or, if not, as the path could be relative, is it possible to load a HTML page stored in the internal storage ?

I tried "architectView.load("file:///mnt/sdcard/world_cerf.html");" but it doesn't work :(

Hi there!

Yes, in fact, you need to put them in assets folder and access the assets relative.
Currently there is no way to load files from sd-card. Since there is no way to update asset-folder files you really have to prebundle them within your app or access them via url, showing a progress-bar while loading.

Kind regards,
Andreas

Thanks for the reply. This is a nice feature to implement in my opinion :)

After some discussion with my team we found it's maybe possible to get models loaded from the sdcard by the use of a HTTP Local Server inside the app.

I have the same need: i would like to cache some contents in order to use it offline.

I'm using wikitude via Phonegap so i was thinking about this workflow:

1) Get the file via phonegap

2) Write the file somewhere via phonegap

3) Serve this file from phonegap to wikitude (how? is this possibile? iOS and Android both?)

Let me know.

Hi Roberto!

Meanwhile it is possible to load content from any source.
If you want to cache something it is recommended to update files in a local directory and open the content from there.

Note: Android's directory paths to SD-card etc. may be different, depending on OS-Version and device (some only have an emulated one...)

Kind regards,
Andreas

Thank you Andreas for your quick answer.

Could you be more specific about your suggestion?

I mean, i read on the docs that is not possible from Wikitude to have access to a local file and the only way to achieve it is to put all the files on the apk (but it's not what i want).

So, how could i read a file from local storage?

Maybe something like this

var imageres = new AR.ImageResource("file://storage/sdcard0/resource.png");

could works?

 

Thanks in advance.

I recommend not to use the path to the SD-card inside the World impementation, but instead access all assets relative to the root "index.html" of the loaded World.

1) Launch world from local firectory, file://....

2) load assets via "var imageres = new AR.ImageResource("pictures/resource.png");"

that way the experience still works on iOS and Android and there is no need to diffentiate between os/device specific temp-directories.
Find details inside the PhoenGap WikitudePlugin.js,the Wikitude PhoneGap documentation but also check out FileWriters in PhoneGap for fetching data and accessing them via url.

Kind regards,
Andreas

Great idea! Thanks!

I will implement it and i will give you a feedback :)

could you explain about the solution please?

I used th NanoHTTPd for that but just showing the html css js, but AR content not loaded 

 

Library:

https://github.com/gseguin/NanoHTTPd

Sorry that problem was because of my mistake, NanoHTTPd works like a charm!
Login or Signup to post a comment