MeshLambertMaterial.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. * @author alteredq / http://alteredqualia.com/
  4. *
  5. * parameters = {
  6. * color: <hex>,
  7. * emissive: <hex>,
  8. * opacity: <float>,
  9. *
  10. * map: new THREE.Texture( <Image> ),
  11. *
  12. * specularMap: new THREE.Texture( <Image> ),
  13. *
  14. * alphaMap: new THREE.Texture( <Image> ),
  15. *
  16. * envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
  17. * combine: THREE.Multiply,
  18. * reflectivity: <float>,
  19. * refractionRatio: <float>,
  20. *
  21. * shading: THREE.SmoothShading,
  22. * blending: THREE.NormalBlending,
  23. * depthTest: <bool>,
  24. * depthWrite: <bool>,
  25. *
  26. * wireframe: <boolean>,
  27. * wireframeLinewidth: <float>,
  28. *
  29. * vertexColors: THREE.NoColors / THREE.VertexColors / THREE.FaceColors,
  30. *
  31. * skinning: <bool>,
  32. * morphTargets: <bool>,
  33. * morphNormals: <bool>,
  34. *
  35. * fog: <bool>
  36. * }
  37. */
  38. THREE.MeshLambertMaterial = function ( parameters ) {
  39. THREE.Material.call( this );
  40. this.type = 'MeshLambertMaterial';
  41. this.color = new THREE.Color( 0xffffff ); // diffuse
  42. this.emissive = new THREE.Color( 0x000000 );
  43. this.map = null;
  44. this.specularMap = null;
  45. this.alphaMap = null;
  46. this.envMap = null;
  47. this.combine = THREE.MultiplyOperation;
  48. this.reflectivity = 1;
  49. this.refractionRatio = 0.98;
  50. this.fog = true;
  51. this.shading = THREE.SmoothShading;
  52. this.wireframe = false;
  53. this.wireframeLinewidth = 1;
  54. this.wireframeLinecap = 'round';
  55. this.wireframeLinejoin = 'round';
  56. this.vertexColors = THREE.NoColors;
  57. this.skinning = false;
  58. this.morphTargets = false;
  59. this.morphNormals = false;
  60. this.setValues( parameters );
  61. };
  62. THREE.MeshLambertMaterial.prototype = Object.create( THREE.Material.prototype );
  63. THREE.MeshLambertMaterial.prototype.constructor = THREE.MeshLambertMaterial;
  64. THREE.MeshLambertMaterial.prototype.clone = function () {
  65. var material = new THREE.MeshLambertMaterial();
  66. THREE.Material.prototype.clone.call( this, material );
  67. material.color.copy( this.color );
  68. material.emissive.copy( this.emissive );
  69. material.map = this.map;
  70. material.specularMap = this.specularMap;
  71. material.alphaMap = this.alphaMap;
  72. material.envMap = this.envMap;
  73. material.combine = this.combine;
  74. material.reflectivity = this.reflectivity;
  75. material.refractionRatio = this.refractionRatio;
  76. material.fog = this.fog;
  77. material.shading = this.shading;
  78. material.wireframe = this.wireframe;
  79. material.wireframeLinewidth = this.wireframeLinewidth;
  80. material.wireframeLinecap = this.wireframeLinecap;
  81. material.wireframeLinejoin = this.wireframeLinejoin;
  82. material.vertexColors = this.vertexColors;
  83. material.skinning = this.skinning;
  84. material.morphTargets = this.morphTargets;
  85. material.morphNormals = this.morphNormals;
  86. return material;
  87. };
  88. THREE.MeshLambertMaterial.prototype.toJSON = function () {
  89. var data = THREE.Material.prototype.toJSON.call( this );
  90. data.color = this.color.getHex();
  91. data.emissive = this.emissive.getHex();
  92. if ( this.vertexColors !== THREE.NoColors ) data.vertexColors = this.vertexColors;
  93. if ( this.shading !== THREE.SmoothShading ) data.shading = this.shading;
  94. if ( this.blending !== THREE.NormalBlending ) data.blending = this.blending;
  95. if ( this.side !== THREE.FrontSide ) data.side = this.side;
  96. return data;
  97. };