Best solution for running three.js in a desktop app?

I’m working on a large, complex FRPG game engine built using three.js and Rapier physics. One of the things I haven’t made up my mind about is whether to deploy it as a website or as a desktop app.

While making a website is easier for me technically, and is easier for players (nothing to install) there are some significant downsides. One is hosting costs: although there are many sites that offer free hosting for hobbyists, there are limits, and since the game assets are many gigabytes in size and are dynamically loaded and unloaded during play, those limits would quickly be exceeded if the game is at all popular. Also, storing saved games in browser local storage is risky, the player could easily lose all of their progress via “clear browsing data”.

Sites like itch.io which offer free hosting for games are really hosting downloadable installers, not actual websites.

The alternative approach is to use something like Electron, Tauri, or one of the many similar frameworks out there and make the game installable on the desktop. I’ve used both Electron and Tauri with three.js before, although apparently there are some issues with Tauri not supporting WebGL2 on some platforms. Although one of the things I really like about Tauri is that generating installer executables as part of a CI pipeline works right out of the box, you can set up github actions to build your binaries very easily.

What I’m looking for is the best user experience in terms of ease of installation; and the best developer experience. I’m curious to know what solutions folks have used for running three.js on the desktop, and how they compare to each other.

One of my fav games CrossCode is written in javascript and outputs to HTML Canvas. Their engine is forked from impact.js. According to this post on hacker news they use a library called Kha to make it into an executable, which is how they published to steam, consoles, etc. with the same binary. GitHub - Kode/Kha: Ultra-portable, high performance, open source multimedia framework.

Realise this is an old post but leaving it here in case it’s useful to you or others

2 Likes

this will yield a native opengles app using expo-gl. in other words you use nearly the same code, it’s a real app that is installed like any other, there is no webview or browser embed, no touch lag, nothing is being routed through the dom.

the downside is that a lot of what’s in three was written for the web, loaders use dom fetch requests, etc. with fiber it won’t sting that bad and most things will work, especially loaders, it channels all this dom stuff into native constructs.

here’s an example, this app runs on the web, interaction and all, and now on mobile with pointer events and everything else running https://twitter.com/0xca0a/status/1462861615494307856

I quite liked my experience with NW.js

You just catenate the zip of your site onto its executable and you wont have to modify your code unless you want to do non-browser things. It’s pretty straightforward iirc.

1 Like

Can i also turn an existing Project into a standalone app with this? Or does it have to be setup before developing?

you can re-use most of the code.