- Home /
How can I load 3d models(.obj, .fbx) dynamically in to unity scene after building it to WebGL ?
Hi, My goal is to import 3D models(.obj) files dynamically from external folders after building it to WebGL. All my 3D model files are present in External folder on my desktop. I want to load all the files in to unity WebGL scene. How can I do that ?
i also want to know if I could download/stream a fbx on demand.
Answer by Bunny83 · Nov 07, 2021 at 02:02 PM
Well you have several issues here. First of all Unity does not support any model loading at runtime natively besides assetbundles / addressable assets. That's because the engine itself does not contain any code for loading those various file formats, only the Unity editor does.
So if you want to load any of those formats you have to have your own loading routines or libraries.
The second issue specific for webgl is that a website can not access any folder on the clients PC. The website is trapped inside the browser. When it's hosted on a server, you could load files and assets from your server, that's possible. Another way how you could provide local files on the client machine to the WebGL build is through javascript functions like file drag and drop or file upload. Both has to be initiated by the user. The website can not load them itself.
Both of those issues do not have a simple solution and require some work outside of Unity. You should look up the javascript file drag and drop API as well as the javascript File API