Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Three.js math with something more compact #2

Open
jcarpenter opened this issue Jul 23, 2015 · 6 comments
Open

Replace Three.js math with something more compact #2

jcarpenter opened this issue Jul 23, 2015 · 6 comments

Comments

@jcarpenter
Copy link

Unminified Three.js makes our cssvr.js file size over 2MB. @caseyyee suggests https://www.npmjs.com/search?q=gl-matrix as an potential alternative.

@jcarpenter
Copy link
Author

Kip adds:

Ideally we’d use a library that is built on SIMD.js:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/float32x4
Not sure if one exists already, but shouldn’t be hard to whip a few matrix functions up...
Essentially, instead of having 16 separate variables to define a matrix, you would have 4 SIMD.Float32x4’s
A vector would be a native datatype, using a single SIMD.Float32x4

And for the vectors, you don’t need a library at all… It’s built-in now
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SIMD
There’s a polyfill for other browsers; however, other browsers will be supporting SIMD.js as well
Polyfill: https://github.com/tc39/ecmascript_simd

@jcarpenter
Copy link
Author

Nick Desaulniers has some ideas on this also.

@dmarcos
Copy link
Contributor

dmarcos commented Aug 3, 2015

This is optimization so I'll give it lower priority than the functionality bugs. I'll deal with this on a clean up pass soon.

@dmarcos
Copy link
Contributor

dmarcos commented Aug 3, 2015

I made a build of threejs with only the Math API. cssvr.js is now 404kb (non minified). I will do further optimizations to keep reducing the size. I would like to keep the threejs Math API for consistency sake. It's what we will likely use for WebGL content.

@dmarcos
Copy link
Contributor

dmarcos commented Aug 4, 2015

Trimmed even more. Just to make things clear:

cssvr.js is the debug build of the library. Source maps, no minification, no uglification. It's 248Kb now

cssvr-min.js is the version to be used in production. It's 48Kb now

@dmarcos
Copy link
Contributor

dmarcos commented Aug 4, 2015

I trimmed threejs a bit more and cssvr-min.js is now 34kb minified (9.65KB gzipped)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants