mattdesl / svg-mesh-3d

:rocket: converts a SVG path to a 3D mesh
http://mattdesl.github.io/svg-mesh-3d/
MIT License
1.2k stars 93 forks source link

bundle size #1

Open mattdesl opened 8 years ago

mattdesl commented 8 years ago

The bundle size is fairly large (101kb).

Biggest dependencies:

Taking a look in disc, some heavy hitters are box-intersect, bn.js, and of course buffer.

/cc @mikolalysenko - what do you think?

mikolalysenko commented 8 years ago

box-intersect is hard to kill. Buffer is probably an accident and shouldn't be there. The tough one is bn.js, which might be removable with some work. What we really need is a modular bignumber. Perhaps this could be part of rat-nest?

mattdesl commented 8 years ago

The size isn't a huge deal, but might turn some people off using it for frontend purposes.

Buffer is from typedarray-pool I think. Maybe also some other modules are using it?

mattdesl commented 8 years ago

p.s. How do you usually go about unit testing triangulation modules?

mikolalysenko commented 8 years ago

Well, cdt2d and the other pslg type modules are a bit rough right now. I wrote that whole suite of modules in one shot during an 18 hour plane ride to Dublin, and I haven't revisited them in more detail yet.

The most important thing with geometry programming is to get the basics 100% first before jumping into more complicated stuff. For anything like triangulation, you should not be using raw inexact floating point arithmetic, unless you are ready to bear the pain later on. Using correct and robust predicates means that you can be very certain that you've caught all the logic bugs in a higher level routine using more basic unit testing practices like code coverage and fuzzing.

For writing test cases, I try to look for degeneracies and test those first. These are usually things like denormal numbers, overflows, rounding bugs, or input which is not in general position. So things which are usually good test for triangulation specifically are:

It is also important to test the performance of a module too. It is very easy in JavaScript to write code that works, but might not have good asymptotic performance due to stupid things like array splicing or string copying. So you usually need to run some experiments with inputs over a parameter sweep and then test that.