Found cool js lib: Decomposition of 2D polygons into convex pieces in JavaScript
This could speed up the B2DTerrain class ;o)