Face3.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 = Array.isArray( normal ) ? normal : [];
  11. this.color = color instanceof THREE.Color ? color : new THREE.Color();
  12. this.vertexColors = Array.isArray( color ) ? color : [];
  13. this.materialIndex = materialIndex !== undefined ? materialIndex : 0;
  14. };
  15. THREE.Face3.prototype = {
  16. constructor: THREE.Face3,
  17. clone: function () {
  18. return new this.constructor().copy( this );
  19. },
  20. copy: function ( source ) {
  21. this.a = source.a;
  22. this.b = source.b;
  23. this.c = source.c;
  24. this.normal.copy( source.normal );
  25. this.color.copy( source.color );
  26. this.materialIndex = source.materialIndex;
  27. for ( var i = 0, il = source.vertexNormals.length; i < il; i ++ ) {
  28. this.vertexNormals[ i ] = source.vertexNormals[ i ].clone();
  29. }
  30. for ( var i = 0, il = source.vertexColors.length; i < il; i ++ ) {
  31. this.vertexColors[ i ] = source.vertexColors[ i ].clone();
  32. }
  33. return this;
  34. }
  35. };