Material.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**
  2. * @author mr.doob / http://mrdoob.com/
  3. * @author alteredq / http://alteredqualia.com/
  4. */
  5. THREE.Material = function () {
  6. this.id = THREE.MaterialCount ++;
  7. this.name = '';
  8. this.side = THREE.FrontSide;
  9. this.opacity = 1;
  10. this.transparent = false;
  11. this.blending = THREE.NormalBlending;
  12. this.blendSrc = THREE.SrcAlphaFactor;
  13. this.blendDst = THREE.OneMinusSrcAlphaFactor;
  14. this.blendEquation = THREE.AddEquation;
  15. this.depthTest = true;
  16. this.depthWrite = true;
  17. this.polygonOffset = false;
  18. this.polygonOffsetFactor = 0;
  19. this.polygonOffsetUnits = 0;
  20. this.alphaTest = 0;
  21. this.overdraw = false; // Boolean for fixing antialiasing gaps in CanvasRenderer
  22. this.visible = true;
  23. this.needsUpdate = true;
  24. };
  25. THREE.Material.prototype.setValues = function ( values ) {
  26. if ( values === undefined ) return;
  27. for ( var key in values ) {
  28. if ( this[ key ] !== undefined ) {
  29. this[ key ] = values[ key ];
  30. }
  31. }
  32. };
  33. THREE.Material.prototype.clone = function ( material ) {
  34. if ( material === undefined ) material = new THREE.material()
  35. material.name = this.name;
  36. material.side = this.side;
  37. material.opacity = this.opacity;
  38. material.transparent = this.transparent;
  39. material.blending = this.blending;
  40. material.blendSrc = this.blendSrc;
  41. material.blendDst = this.blendDst;
  42. material.blendEquation = this.blendEquation;
  43. material.depthTest = this.depthTest;
  44. material.depthWrite = this.depthWrite;
  45. material.polygonOffset = this.polygonOffset;
  46. material.polygonOffsetFactor = this.polygonOffsetFactor;
  47. material.polygonOffsetUnits = this.polygonOffsetUnits;
  48. material.alphaTest = this.alphaTest;
  49. material.overdraw = this.overdraw;
  50. material.visible = this.visible;
  51. return material;
  52. };
  53. THREE.MaterialCount = 0;