Face3.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. * @author alteredq / http://alteredqualia.com/
  4. */
  5. THREE.Face3 = function ( a, b, c, normal, color, materialIndex ) {
  6. this.a = a;
  7. this.b = b;
  8. this.c = c;
  9. this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
  10. this.vertexNormals = normal instanceof Array ? normal : [ ];
  11. this.color = color instanceof THREE.Color ? color : new THREE.Color();
  12. this.vertexColors = color instanceof Array ? color : [];
  13. this.vertexTangents = [];
  14. this.materialIndex = materialIndex !== undefined ? materialIndex : 0;
  15. this.centroid = new THREE.Vector3();
  16. };
  17. THREE.Face3.prototype = {
  18. constructor: THREE.Face3,
  19. clone: function () {
  20. var face = new THREE.Face3( this.a, this.b, this.c );
  21. face.normal.copy( this.normal );
  22. face.color.copy( this.color );
  23. face.centroid.copy( this.centroid );
  24. face.materialIndex = this.materialIndex;
  25. var i, il;
  26. for ( i = 0, il = this.vertexNormals.length; i < il; i ++ ) face.vertexNormals[ i ] = this.vertexNormals[ i ].clone();
  27. for ( i = 0, il = this.vertexColors.length; i < il; i ++ ) face.vertexColors[ i ] = this.vertexColors[ i ].clone();
  28. for ( i = 0, il = this.vertexTangents.length; i < il; i ++ ) face.vertexTangents[ i ] = this.vertexTangents[ i ].clone();
  29. return face;
  30. }
  31. };
粤ICP备19079148号