Face3.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { Color } from '../math/Color';
  2. import { Vector3 } from '../math/Vector3';
  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. Face3.prototype = {
  18. constructor: Face3,
  19. clone: function () {
  20. return new this.constructor().copy( this );
  21. },
  22. copy: function ( source ) {
  23. this.a = source.a;
  24. this.b = source.b;
  25. this.c = source.c;
  26. this.normal.copy( source.normal );
  27. this.color.copy( source.color );
  28. this.materialIndex = source.materialIndex;
  29. for ( var i = 0, il = source.vertexNormals.length; i < il; i ++ ) {
  30. this.vertexNormals[ i ] = source.vertexNormals[ i ].clone();
  31. }
  32. for ( var i = 0, il = source.vertexColors.length; i < il; i ++ ) {
  33. this.vertexColors[ i ] = source.vertexColors[ i ].clone();
  34. }
  35. return this;
  36. }
  37. };
  38. export { Face3 };
粤ICP备19079148号