Material.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. var value = values[ key ];
  29. if ( this[ key ] !== undefined ) {
  30. this[ key ] = value;
  31. }
  32. }
  33. };
  34. THREE.Material.prototype.clone = function ( 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. };
  52. THREE.MaterialCount = 0;
粤ICP备19079148号