Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
I'd suggest comparing with other implementations. Also, remove the source reverenced in the inline comment. As a start, this one seems to involve fewer computations, but I have not had the time to investigate fully. |
|
Claude says we should adopt it: Operation Count
Why gl-matrix is BetterThe key insight is the choice of which 2×2 minors to pre-compute:
This decomposition is symmetric—every output element can be expressed as exactly 3 products of these minors. The determinant becomes a simple dot product of top minors with bottom minors. The current three.js code computes 3×3 cofactors first (more work), then still has to compute 12 elements from scratch. RecommendationAdopt the gl-matrix approach. It's ~60% fewer multiplications and the code is actually shorter and clearer. |
|
Asked if there are any downsides... Good question. Let me think through potential concerns: Memory/Variables
Negligible difference—all stack-allocated locals that any JIT will optimize. Numerical Stability Code Clarity Licensing Honest assessment: I don't see any real downsides. The gl-matrix approach is simply a better factorization of the same mathematics. The only reason not to adopt it would be:
But both are addressed by having good unit tests, which three.js does. |
Adopts gl-matrix's
invert()algorithm which uses a more efficient factorization.Approach
Pre-computes 12 two-term minors from row pairs:
Each output element is then expressed as exactly 3 products of these minors.
Performance
~60% fewer multiplications.
(Made with Claude Opus 4.5)