Recommendation for a BabylonJS-PWA with full offline support?

I have created a web application where 8 different gltf-models can be loaded by selection. Now I want to create a PWA with offline functionality from it. Each gltf-scene has

  • a corresponding manifest file
  • Database.IDBStorageEnabled = true

so each scene is successfully stored in the IndexedDB, when loading the file manually in my application!

Questions:

  • Is there a way to use BabylonJS to preload scenes into the IndexedDB in advance using a command? Something like ‚BABYLON.Database.pushFile(„./assets/myfile.gltf“)‘?
  • Is the IndexedDB the rigth place to store files persistant?
  • Should I better implement the whole thing myself, e.g. with a “ServiceWorker” or the Background Fetch API?
  • Is there a documentation how scenes have to be stored in the IndexedDB so that they can be loaded from there by BabylonJS?

(In the past I’ve build several offline- / desktop-applications based on Bayblon and Electron / NW.js.)

Thanks for your advices / suggestions how to (roughly) achieve a PWA with full offline support!

As you are mentioning PWA, the best way to preload everything is to use service workers

(look at pwabuilder.com for a lot of samples and guidance)

Service workers are meant to be used in your usecase. Not IDB.

4 Likes

Thanks for your response!

OK, seems I have mixed up a few things. ServiceWorker works fine. As you mentioned, there is no reason to store assets in IndexedDB, Service Worker will handle all requests.

Unfortunately, when it comes to the “persistence” of the data, it is not quite clear: With Chrome and Chrome-based browsers, it obviously depends on the browser’s heuristics whether the store is persistent or not. In my local development environment, the storage was initially marked as non-persistent, after installing the PWA has the store is persistent.
(How to check persitancy)

Can anyone confirm this behavior?