mrdoob/three.js — pull request #2868 by bhouston (2012-12-31 14:37:08+00:00)
Title: LatheGeometry fix + optimization (dependent on PR#2867 'Geometry.mergeVertices fix')

I noticed that LatheGeometry has a bug/contradiction and is slower than necessary:

* It wraps its vertex indices as if it always assumes that the geometry it is generating is closed but it also supports the specification of an angle that will, if it is less than PI*2 generate an unclosed geometry. Thus all lathe geometry generated with angle < PI*2 is incorrect. See: https://github.com/mrdoob/three.js/blob/master/src/extras/geometries/LatheGeometry.js#L11 and https://github.com/mrdoob/three.js/blob/master/src/extras/geometries/LatheGeometry.js#L41

* LatheGeometry does top to bottom wrapping of vertex indices but then truncates the point index before that happens, see here: https://github.com/mrdoob/three.js/blob/master/src/extras/geometries/LatheGeometry.js#L43 Thus top-to-bottom wrapping isn't used.

* It uses a matrix to rotate the points around the lathe axis. https://github.com/mrdoob/three.js/blob/master/src/extras/geometries/LatheGeometry.js#L14

This PR removes addresses the above via:

* I removed the assumption that the lathe geometry is always closed -- I no longer wrap the vertices. To make a closed geometry, called Geometry.mergeVertices after generation and it will close the main seam as well as the top and bottom correctly if they can be merged. Thus this is a general solution.

* I optimized rotation around the axis via Math.cos and Math.sin.

I updated webgl_geometry_normals.html (here: https://github.com/bhouston/three.js/commit/f454d0955b422dedd86111799a4d71938489b4b3 ) so that you can see the LatheGeometry examples with partial lathes and unclosed lathes and see that they all work correctly (and with correct normals after running Geometry.mergeVertices.)