Can I user GLTFLoader to load file from the local file system of the browser

Hi everyone,

I am new here. I have used GLTFLoader to load files from server and I like this file format very much because it is well supported by threejs. However, recently I needed to load many files to the scenery at the beginning of the game and it would be a bit unfriendly to a player to wait for loading such files and he don’t know what happened. And the cache would be sometimes cleaned by the browser. Thus, I would like to provide .gltf files and read files from the local file system of the browser. Is it impossible?

I just read the gltfloader.js from github and found that it would call a file loader, which would use xmlhttprequest to get the resource file from the server. Can I use an address located in local file system? Or can I change parts of this file to implement this function? Have anyone tried this yet?

The web page itself does not have access to the local filesystem, unless the user gives it that access. For example, you could use an HTML file input to select a ZIP file on the hard drive, and then the web page can access it.

The only way around that is to disable the security settings in your browser, which you shouldn’t ask other users to do anyway.

The browser gives you a lot of control over what it caches, and when that cache expires. It’s probably best and easiest just to use those caching mechanisms. For more information, look for tutorials on the Service Worker Cache API, LocalStorage, IndexedDB, and so on.

1 Like

I have begun to use cache control, which is more reasonable. Thank you for your reply!