Babylon scene loader. Newb question

I’d like to plug in my own personal model in this line of code

// Load the model
BABYLON.SceneLoader.Append("https://www.babylonjs.com/Assets/FlightHelmet/glTF/", "FlightHelmet_Materials.gltf", scene, function (meshes) {

My question is do I need to have my file hosted on a website? I have a squarespace site and ive had problems doing it. Linking it to google drive or dropbox hasnt worked for me. Any suggestions?

Thanks

you do not need to have it hosted on a website but it all depends on your specific stack. For a traditional webpage, you can just store the scene in your assets folder and load it the same way you would images/videos. The issue you may come across is when you try to preview on local host, if I remember correctly babylonjs wont load models in local environment. Alternatively, you can host your glb/gltf files on cdn’s such as cloudflare, but google drive and drobox will not work.

Here is comprehensive instructions about Using External Assets In the Playground | Babylon.js Documentation
(you’ll find also there the hint how to know your Dropbox file real URL).
For you specific environment it may be even simpler; just check that your URL is URL to the file, not the cloud service download page.

Babylon and any js scripts will not load files from local file system because of security restrictions. Meanwhile there is no problem to setup localhost and load any files in local HTTP environment.

3 Likes