Material.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * @author mr.doob / http://mrdoob.com/
  3. * @author alteredq / http://alteredqualia.com/
  4. */
  5. THREE.Material = function ( parameters ) {
  6. parameters = parameters || {};
  7. this.id = THREE.MaterialCount ++;
  8. this.name = '';
  9. this.opacity = parameters.opacity !== undefined ? parameters.opacity : 1;
  10. this.transparent = parameters.transparent !== undefined ? parameters.transparent : false;
  11. this.blending = parameters.blending !== undefined ? parameters.blending : THREE.NormalBlending;
  12. this.blendSrc = parameters.blendSrc !== undefined ? parameters.blendSrc : THREE.SrcAlphaFactor;
  13. this.blendDst = parameters.blendDst !== undefined ? parameters.blendDst : THREE.OneMinusSrcAlphaFactor;
  14. this.blendEquation = parameters.blendEquation !== undefined ? parameters.blendEquation : THREE.AddEquation;
  15. this.depthTest = parameters.depthTest !== undefined ? parameters.depthTest : true;
  16. this.depthWrite = parameters.depthWrite !== undefined ? parameters.depthWrite : true;
  17. this.polygonOffset = parameters.polygonOffset !== undefined ? parameters.polygonOffset : false;
  18. this.polygonOffsetFactor = parameters.polygonOffsetFactor !== undefined ? parameters.polygonOffsetFactor : 0;
  19. this.polygonOffsetUnits = parameters.polygonOffsetUnits !== undefined ? parameters.polygonOffsetUnits : 0;
  20. this.alphaTest = parameters.alphaTest !== undefined ? parameters.alphaTest : 0;
  21. this.overdraw = parameters.overdraw !== undefined ? parameters.overdraw : false; // Boolean for fixing antialiasing gaps in CanvasRenderer
  22. this.visible = true;
  23. this.needsUpdate = true;
  24. }
  25. THREE.MaterialCount = 0;
  26. // shading
  27. THREE.NoShading = 0;
  28. THREE.FlatShading = 1;
  29. THREE.SmoothShading = 2;
  30. // colors
  31. THREE.NoColors = 0;
  32. THREE.FaceColors = 1;
  33. THREE.VertexColors = 2;
  34. // blending modes
  35. THREE.NoBlending = 0;
  36. THREE.NormalBlending = 1;
  37. THREE.AdditiveBlending = 2;
  38. THREE.SubtractiveBlending = 3;
  39. THREE.MultiplyBlending = 4;
  40. THREE.CustomBlending = 5;
  41. // custom blending equations
  42. // (numbers start from 100 not to clash with other
  43. // mappings to OpenGL constants defined in Texture.js)
  44. THREE.AddEquation = 100;
  45. THREE.SubtractEquation = 101;
  46. THREE.ReverseSubtractEquation = 102;
  47. // custom blending destination factors
  48. THREE.ZeroFactor = 200;
  49. THREE.OneFactor = 201;
  50. THREE.SrcColorFactor = 202;
  51. THREE.OneMinusSrcColorFactor = 203;
  52. THREE.SrcAlphaFactor = 204;
  53. THREE.OneMinusSrcAlphaFactor = 205;
  54. THREE.DstAlphaFactor = 206;
  55. THREE.OneMinusDstAlphaFactor = 207;
  56. // custom blending source factors
  57. //THREE.ZeroFactor = 200;
  58. //THREE.OneFactor = 201;
  59. //THREE.SrcAlphaFactor = 204;
  60. //THREE.OneMinusSrcAlphaFactor = 205;
  61. //THREE.DstAlphaFactor = 206;
  62. //THREE.OneMinusDstAlphaFactor = 207;
  63. THREE.DstColorFactor = 208;
  64. THREE.OneMinusDstColorFactor = 209;
  65. THREE.SrcAlphaSaturateFactor = 210;
粤ICP备19079148号