Maintainers and Contributors to three.js: What changes would you like to see if three.js were to be rewritten?
As a user and contributor for three.js for a few years now, I’d like to share some things that would be good reasons to consider a “three.js lite” version:
- Eliminate the need for a separate
@types/threedependency by making three.js fully compatibile with TypeScript checking via JSDoc. There are inconsistencies between three.js and the third-party@types/threeproject, ESPECIALLY with TSL, which makes using three.js in TypeScript-enabled project difficult (e.g. missing properties, type mismatches, etc.). Aside from the inconsistencies, there is also the lag time between new releases of three.js and the corresponding@types/threerelease. In the spirit of three.js being a JavaScript-first library, JSDoc could be used to make three.js a fully TypeScript-compatible library, even in vanilla JavaScript. This would completely eliminate the need for a separate@types/threedependency. Because JSDoc has been greatly improved over the last several years, making heavy use of the@abstractand@templateJSDoc tags would give you all the features you need for a professional library. I suspect this would greatly help with development of three.js as well because of TypeScript’s early-warning nature, but not actually require you to use TypeScript since JSDoc does not need to be compiled by TypeScript. - Use the new ECMAScript 2022
#character for private class members. Vanilla JavaScript now supports truly private properties and methods with the hash#character. three.js is still filled with underscore_properties serving as private or protected properties, and could benefit from true encapsulation of these properties using#. - Resolve the lingering issues with
updateMatrix()andupdateMatrixWorld()/updateWorldMatrix(). Right now there are problems with theupdateMatrix()andupdateMatrixWorld()/updateWorldMatrix()methods: Calling a world matrix update method cannot recomputematrixWorldwhilematrixWorldAutoUpdate = false. You cannot request only world-matrix calculation while leavingmatrixAutoUpdate = true. World calculation is coupled to local updates and descendant traversal, making custom calculation difficult to override. - A three.js build is quite large, even after being minified. If you ask ChatGPT Astra to generate a standalone
.htmlfile representing a small 3D FPS game using nothing but raw calls to WebGPU, with no library at all, the final file size is around 50kb. When asked to generate the same game with three.js, the final file size is around 600kb. I’m wondering if there are things in three.js that can be simplified or removed?