Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

three.js vs libgdx for 3D web development

Libgdx is focused mainly on Android and is written in java but apparently it can run apps on the browser(webGL?). Three.js is a very impressive javascript 3D library which uses WebGL(or 2d canvas) as well for rendering. So far I haven't seen any comparisons between this two since they have different focuses, but I would like to know the differences, what can one library do that the other one can not.

like image 517
olanod Avatar asked May 30 '12 17:05

olanod


1 Answers

I don't think I'm too qualified to talk about Three.js, but I have used libGDX for many projects of mine and know its disadvantages when it comes to WebGL (the browser export).

  1. The first factors to consider is what language you are used to, Three.js uses JavaScript and libGDX uses Java. And although libGDX exports to WebGL, it's only because it uses GWT, you still do the coding in Java.

  2. LibGDX is specialized (as you said) in mobile and (to an extent) desktop applications. If you're goal is to create something that works on the web as well as mobile and desktop then libGDX should be considered. However, if you only wish to program things for the web, then I would really consider just doing Three.js for reasons I will explain later.

  3. LibGDX is made mainly for game development, so if the application you're making is a game, you could consider libGDX, as it makes game programming in 3D nice and easy (and you'll be able to port it to multiple platforms, not only web, but mobile and desktop). But if you're making something else, Three.js may be a better option.

  4. If your platform for distribution is going to be your web version I would suggest sticking with Three.js, because libGDX isn't that good for its WebGL export. One of the biggest issues (which is solvable, but a pain to deal with) is that libGDX does not prevent default browser keys from being used. However, if you do choose to use libGDX, make sure you take a look at this to fix that problem (more or less).

  5. For the most part, if you're main platform is going to be web you'll want to program in a language that is meant for web development. If you program in JavaScript using the Three.js framework the code will be cleaner and faster to run. Meanwhile, if you use libGDX it essentially transforms Java code into JavaScript coding making it inefficient and bulky and will contain many lines of JavaScript code that are either useless or can be simplified. It's not an issue with libGDX (or rather GWT) itself, but rather just something that cannot be avoided when automating programming language translation. To give you an example, using the programming language Haxe, if you compile a HelloWorld Haxe to C++ it contains a bunch of unnecessary variables and methods (in the C++ source code) that you could just get rid of. Same in this case.

So in the end it depends on what you're aiming for. If you plan on sticking with just the web version use Three.js, otherwise libGDX should be considered.

like image 102
Deathsbreed Avatar answered Oct 07 '22 14:10

Deathsbreed