mrdoob/three.js — pull request #4216 by martinwicke (2013-12-16 05:40:00+00:00)
Title: Fix crash in computeVertexNormals 

There is a crash in computeVertexNormals when it is called on a THREE.Geometry twice, when the .faces or .vertices fields were modified in between the two calls.

The first time computeVertexNormals is called, .__tmpVertices is initialized, as well as f.vertexNormals in each face f. The next time computeVertexNormals is called, no initialization takes place if .__tmpVertices is not undefined, even if faces and/or vertices have changed since, rendering .__tmpVertices and f.vertexNormals invalid.

This commit makes sure that .__tmpVertices is updated whenever the .vertices array has changed in length, and that the f.vertexNormals are initialized whenever they are not present or of the right size (ie whenever faces have changed).