Many newbie questions, about file access, portable code, etc

Hi there,

I’ve been a Unity user for over a decade and programmed using C++ in the past, used Game Maker and a few other engines before that when I was younger…

I’m very interested in developing for Babylon, as I really really like the ease of use and fast iteration of using an interpreted language like javascript, and being able to test on different devices and have a compact portable code base seems like a dream…

I have a few newbie questions before starting…they are…

  1. I’m wondering about File IO. Does this happen through a single Node.js API function I can use? Would I need to modify my code if I ported to desktops using Electron or another library, and then modify my code for my functions again if I were to be building to iOS and/or Android?
  2. Probably kind of a dumb question, and that is potentially on porting to consoles. I have a game on Xbox, and am wondering if in theory creating a headless browser using a console’s built in browser functionality…in theory might be possible? (I know that NDA keeps people from being able to talk about it). I’m guessing I would just have to keep my game logic abstracted from the Babylon engine so that it could be converted to C++ if there was a need to port it, but have to ask.
  3. And third kind of falls in line with the other two questions, and that’s just concerning headless browsers or using something like CEF or Electron with Babylon.js. Just wondering what solutions people have found for this. I’m confident in creating a desktop application and iOS, and Android applications and that’s exciting, it just seems like having that limitation far into the future of not being able to port to consoles is the only thing really keeping me from going full blast into Babylon.

Hi! Welcome!

Typically you run your BabylonJS application in a web browser so you are limitied by the browser when it comes to File IO. The most common approach is to use fetch to get any data to your web app.

Everything is possible is theory but it would be a monstruous task I believe.

If you are into game making for consoles unfortunatelly BabylonJS is not the right choice. Browsers doesn’t support real multithreading so you are bound to one CPU core. This is the main bottleneck but there are many. To mention one or two more: BabylonJS apps runs in a browser which requires resources comapring to native code running on a console and you don’t have full access to the console’s HW… etc…



1: You mean for like savegames and config files? If you can live with writing you data to the browser’s localStorage, you do not need any backend file IO. Otherwise, I do not think you can get around writing platform specific code. One code-saving option could be to write your app for the browser. For file IO for instance, you have your regular fetch calls. But then in Electron you intercept these calls and use fs.readFile instead, or so. Not sure how something like that could work on mobile or consoles.

3: E.g. Electron, if you run it in “Kiosk” mode, it looks like a normal fullscreen game. IDK about consoles. Can you make a quick prototype* for the web and run this on a console browser? If it works fine or if not… Or wait, are your concnerns more about how to actually port the JS game to a console?

*Like copy&pasting some assets from Sketchfab, setup Recast (navigation) and Havok and add some post-processes (code is all ready in the Babylon docs) - in order to have a rough scene model.

1 Like