Three.js for Java devs: J2CL, Closure, Bazel, etc ...

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • Onboard AI - Learn any GitHub repo in 59 seconds
  • InfluxDB - Collect and Analyze Billions of Data Points in Real Time
  • SaaSHub - Software Alternatives and Reviews
  • j2clmavenplugin

    Maven plugin to launch new J2CL compilation

    Google loves Bazel (yeah, a monorepo, reproducible and stable builds and so on), we usually use Maven or Gradle for our projects. Luckily, we can try j2cl-maven-plugin that is developed by Colin Alworth from Vertispan, but for now let’s try the Bazel way.

  • gwt3-processors

    Set of goodies for J2CL apps

    First steps with Bazel are pain. What’s good, we can reuse 2 samples provided by the J2CL project, these 2 demos are more than enough to get us started. In short, the most important Bazel rules for us are j2cl_library and j2cl_application that can be used to set groups of files and transpile them into an executable JavaScript file. But for it to work one more step is required: we need to define an entry point for our application. It can be done in 2 ways: we can define it with a handwritten JavaScript script like it works in J2CL demos, or we can generate it with an annotation processor I wrote for this purpose, feel free to take a look at the demo too.

  • Onboard AI

    Learn any GitHub repo in 59 seconds. Onboard AI learns any GitHub repo in minutes and lets you chat with it to locate functionality, understand different parts, and generate new code. Use it for free at www.getonboard.dev.

  • bazel-vscode-java

    Bazel Java development extension for VS Code

    OK, so far so good. My favorite IDE is IntelliJ IDEA that has an official Bazel plugin by Google, but if you prefer VS Code you could try a plugin developed by salesforge.

  • elemental2

    Type checked access to browser APIs for Java code.

    To work with browser APIs from Java we would use Elemental2, which is abstractions for JavaScript APIs, the set of Java wrappers based on the Closure Compiler externs.

  • jsinterop-generator

    Generates Java annotated with JsInterop from JavaScript extern sources

    Externs are type definitions of, for instance, Browser APIs like HTML elements or WebGL classes, pretty much the same as d.ts, that helps Closure Compiler to recognize the types. By the way, Elemental2 libraries were generated from the built-in Closure Compiler externs using the JsInterop generator. Elemental2 does not cover the whole set of Web APIs, but it’s not too difficult to write missing parts like I did in my research project.

  • elemental2-experimental

    Externs are type definitions of, for instance, Browser APIs like HTML elements or WebGL classes, pretty much the same as d.ts, that helps Closure Compiler to recognize the types. By the way, Elemental2 libraries were generated from the built-in Closure Compiler externs using the JsInterop generator. Elemental2 does not cover the whole set of Web APIs, but it’s not too difficult to write missing parts like I did in my research project.

  • akasha

    Typed Browser APIs

    TIP: Peter Donald is working on an impressive project Akasha that aims at creating a unified set of APIs generated from the latest WebIDL specs. It’s kept mostly up-to-date but is incompatible with Elemental2 (as a matter of fact, it’s incompatible with the built-in Closure externs).

  • InfluxDB

    Collect and Analyze Billions of Data Points in Real Time. Manage all types of time series data in a single, purpose-built database. Run at any scale in any environment in the cloud, on-premises, or at the edge.

  • j2cl

    Java to Closure JavaScript transpiler

    So it looks like we have pretty much everything except for the most important part: three.js that we can use from Java. And it’s a little bit of a complex part. To interop with JavaScript we should use J2CL JsInterop API, but there is a little problem: Closure Compiler must be able to recognize types of (most of the) three.js objects. Here we have two options:

  • tsickle

    Tsickle — TypeScript to Closure Translator

    Well, sounds nice, writing externs from scratch for such a huge project like three.js is an overwhelming task for one person. But there was a little problem: how to convert d.ts to externs? The good news: we can use Tsickle, the project aimed at generating externs from d.ts.

  • bazel_three_demo

    bazel j2cl app

    The source code is published here: https://github.com/treblereel/bazel_three_demo

  • quake2-j2cl-port

    Automatically exported from code.google.com/p/quake2-gwt-port

    TIP: Some time ago I ported Quake2 by id Software to J2CL using j2cl-maven-plugin with Quarkus backend, so you can take a look, it rocks!

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts