Open greggman opened 5 years ago
idk, since we will have all libraries from one maintainer without code duplication.
maybe I can separate them into separate repos but still have twgl-full include the math and the primitives.
The math stuff doesn't require anything so there would be no code duplication to separate out the math.
The primitives do use both the math and twgl so it's unclear how to separate them.
Maybe pass in twgl and math something like
import * as twgl from 'path/to/twgl.min.js';
import {m4, v3} from 'path/to/mathstuff.min.js';
import * as primitives from 'path/to/primitives.min.js';
primitives.setup({twgl, m4, v3});
You could pull them into the main repo as git sub modules perhaps - then your twgl releases can be built and tested against a specific maths or primitives commit ref example: https://github.com/uNetworking/uWebSockets -> uSockets @ 2b34391 or https://github.com/stackgl/headless-gl -> angle @ 9216e68
Separate math and primitives is a really good idea. Along with your point on separating math to use it in not-twgl projects - it would be great to be able to use some external math library (like http://glmatrix.net) without pulling extra logic from twgl.
My suggestion is to use monorepo approach (with lerna
for example) - it's really handy for maintain separated libraries (especially if they depend on each other)
Thanks for the suggestion.
Just fyi, first off there's twgl.js vs twgl-full.js in the dist folder. twgl.js doesn't include the math and primitives.
In npm there's 2 different libraries, twgl.js, and twgl-base.js which doesn't include the math or the primitives.
And finally the module version is tree-shaking friendly so if you don't use something it won't get included.
That's the biggest reason I haven't bothered is that there are already solutions.
Looks like twgl.js in npm with ES6 modules still have full version. Of cause I am tree-shaked it, but looks little bit weird.
import * as twgl from 'twgl.js';
P.S. The thing that you moved math and primitives to another library it's really good. I understand this only now.
I've been wondering if I should move the math stuff to a separate library for v5 and just remove it entirely from twgl. Same for the
primitives
namespace.They are both in there now just because it was easy but looking at for example three.js, 50% of it or more is external the the main library and no one complains. Either they include 2 to 50 scripts OR they run a build step and pull in what they need.
I've also run into places where i wanted to use the math library separately from twgl. I could make it separate and still have twgl compiled it into itself but at the moment I'm leaning toward separating them.
thoughts?