Loading Scripts Into Babylon Native From the Web

Yo @bghgary … I got a question about loading scripts in babylon native (I may have asked you this before)

I see you are loading the core scripts from the app:///babylonscripts folder on the device…

Can i load script from the web. For example in experience.js where we load gltf files from the web using http protocol, can i do the same thing to get some script info the app. with BABYLON.Tools.LoadScriptAsync or something ?

Yes, it should work.

1 Like

Thanks :slight_smile:

Yo @bghgary. … what about adding core script… I wanna add my Babylon.manager.js as core script

What are the steps I need to do add my core script ?

Also… when running the Xcode project I don’t see console logs… where do console messages display from calling console.log ?

I can see this as an important development feature that would be good if it were tested, and documented on readme.

Getting everything “perfect” on a desktop browser, then just building the app once is not very realistic, not to mention dangerous to wait that long to test your deployment.

Having just a little seed code in the app to pull stuff off your dev web server and start it, means you could just do a development build that could last for several iterations. When You changed things in the scene, you could see them on a browser. You could also just launch your app.

This would be even more value when the app was a remote device like a headset. Quest & Hololens have browsers, but catching an issue which only shows up in Native early, but without doing any extra stuff over and over, is definitely important.

Even more important if there feature which is going through different code in native than the devices browser. Thinking about hand tracking or other OpenXR stuff.

Right now, ScriptLoader from the native side is how you do it. If you want to do it on the JavaScript side, load the script with XMLHttpRequest, then eval the result. We are still planning on updating the contract for this. My current thinking is that we will remove the ScriptLoader plugin completely and replace it with a JavaScript async function to load scripts. All core scripts should be loaded through that contract.

With JSC, console is provided by the VM and you can see the logging by using Safari to attach to the JSC context.

Thank you for info :blush: