Face3.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { Color } from '../math/Color.js';
  2. import { Vector3 } from '../math/Vector3.js';
  3. /**
  4. * @author mrdoob / http://mrdoob.com/
  5. * @author alteredq / http://alteredqualia.com/
  6. */
  7. function Face3( a, b, c, normal, color, materialIndex ) {
  8. this.a = a;
  9. this.b = b;
  10. this.c = c;
  11. this.normal = ( normal && normal.isVector3 ) ? normal : new Vector3();
  12. this.vertexNormals = Array.isArray( normal ) ? normal : [];
  13. this.color = ( color && color.isColor ) ? color : new Color();
  14. this.vertexColors = Array.isArray( color ) ? color : [];
  15. this.materialIndex = materialIndex !== undefined ? materialIndex : 0;
  16. }
  17. Object.assign( Face3.prototype, {
  18. clone: function () {
  19. return new this.constructor().copy( this );
  20. },
  21. copy: function ( source ) {
  22. this.a = source.a;
  23. this.b = source.b;
  24. this.c = source.c;
  25. this.normal.copy( source.normal );
  26. this.color.copy( source.color );
  27. this.materialIndex = source.materialIndex;
  28. for ( var i = 0, il = source.vertexNormals.length; i < il; i ++ ) {
  29. this.vertexNormals[ i ] = source.vertexNormals[ i ].clone();
  30. }
  31. for ( var i = 0, il = source.vertexColors.length; i < il; i ++ ) {
  32. this.vertexColors[ i ] = source.vertexColors[ i ].clone();
  33. }
  34. return this;
  35. }
  36. } );
  37. export { Face3 };