You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello all,
I'd like to share my experience with adopting three.js for processing it with the closure compiler. I won't begin from the very basics hoping that most of us are somewhat familiar with these 2 beasts.
As some of you might know, Closure compiler can produce highly-optimized and efficient code in advanced compilation mode, but it requires following several rules and annotating some parts of the code to help closure recognize types of var for better optimization. One day I thought to try to make it work with three.js.
I started my POC from a simple cube example and did very naive refactoring of a few classes to make them processable by closure. My base version was 126.1, so i ported all non-es6 js to es6 classes. It's so nice that 128 version has more es6 classes now!
In the end, i got a working js with size of ~299kb and 94.2% typed rate.
If you'd like to compile it by yourself, you'll need to set a proper path to closure by yourself in run.sh.
So i am curios whether the three.js community is interested in closure ? I understand that closure annotations will never be merged in the base project, but maybe I (with some support) could maintain a fork?
Part 2: The Java part
Actually i also write a wrapper that allows Java programmers to use three.js for developing web applications on Java. Initially it was based on GWT but GWT time has come to an end. So we're creating a new modern stack of tools based on j2cl (java to js) and closure.
So if you'd like to take a look how it can be done please check this repo:
So i am curios whether the three.js community is interested in closure ?
We have once used the Closure compiler but it was replaced with Terser, here #20354.
I understand that closure annotations will never be merged in the base project, but maybe I (with some support) could maintain a fork?
It think it's better if such annotations are maintained in a fork. In general, we want to keep the code simple and clean. We already manage /*@__PURE__*/ annotations to improve tree-shaking and I don't think we want to clutter the code base even more.
I'll be happy to have any feedback!
Thanks for sharing your project in this community! However, GitHub is no the intended place for such topics. So please move it to the forum. Probably into the category Resources 👍 .
Hello all,
I'd like to share my experience with adopting three.js for processing it with the closure compiler. I won't begin from the very basics hoping that most of us are somewhat familiar with these 2 beasts.
As some of you might know, Closure compiler can produce highly-optimized and efficient code in advanced compilation mode, but it requires following several rules and annotating some parts of the code to help closure recognize types of var for better optimization. One day I thought to try to make it work with three.js.
I started my POC from a simple cube example and did very naive refactoring of a few classes to make them processable by closure. My base version was 126.1, so i ported all non-es6 js to es6 classes. It's so nice that 128 version has more es6 classes now!
In the end, i got a working js with size of ~299kb and 94.2% typed rate.
You can take a look here: https://github.com/treblereel/three.js/tree/closure_compiler/src
If you'd like to compile it by yourself, you'll need to set a proper path to closure by yourself in run.sh.
So i am curios whether the three.js community is interested in closure ? I understand that closure annotations will never be merged in the base project, but maybe I (with some support) could maintain a fork?
Part 2: The Java part
Actually i also write a wrapper that allows Java programmers to use three.js for developing web applications on Java. Initially it was based on GWT but GWT time has come to an end. So we're creating a new modern stack of tools based on j2cl (java to js) and closure.
So if you'd like to take a look how it can be done please check this repo:
It's the same cube demo but written in java, it's compiled into a 298kb file with the same typed rate.
I'll be happy to have any feedback!
The text was updated successfully, but these errors were encountered: