MeshPhongMaterial.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. * @author alteredq / http://alteredqualia.com/
  4. *
  5. * parameters = {
  6. * color: <hex>,
  7. * emissive: <hex>,
  8. * specular: <hex>,
  9. * shininess: <float>,
  10. * opacity: <float>,
  11. *
  12. * map: new THREE.Texture( <Image> ),
  13. *
  14. * lightMap: new THREE.Texture( <Image> ),
  15. * lightMapIntensity: <float>
  16. *
  17. * aoMap: new THREE.Texture( <Image> ),
  18. * aoMapIntensity: <float>
  19. *
  20. * emissiveMap: new THREE.Texture( <Image> ),
  21. *
  22. * bumpMap: new THREE.Texture( <Image> ),
  23. * bumpScale: <float>,
  24. *
  25. * normalMap: new THREE.Texture( <Image> ),
  26. * normalScale: <Vector2>,
  27. *
  28. * displacementMap: new THREE.Texture( <Image> ),
  29. * displacementScale: <float>,
  30. * displacementBias: <float>,
  31. *
  32. * specularMap: new THREE.Texture( <Image> ),
  33. *
  34. * alphaMap: new THREE.Texture( <Image> ),
  35. *
  36. * envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
  37. * combine: THREE.Multiply,
  38. * reflectivity: <float>,
  39. * refractionRatio: <float>,
  40. *
  41. * shading: THREE.SmoothShading,
  42. * blending: THREE.NormalBlending,
  43. * depthTest: <bool>,
  44. * depthWrite: <bool>,
  45. *
  46. * wireframe: <boolean>,
  47. * wireframeLinewidth: <float>,
  48. *
  49. * vertexColors: THREE.NoColors / THREE.VertexColors / THREE.FaceColors,
  50. *
  51. * skinning: <bool>,
  52. * morphTargets: <bool>,
  53. * morphNormals: <bool>,
  54. *
  55. * fog: <bool>
  56. * }
  57. */
  58. THREE.MeshPhongMaterial = function ( parameters ) {
  59. THREE.Material.call( this );
  60. this.type = 'MeshPhongMaterial';
  61. this.color = new THREE.Color( 0xffffff ); // diffuse
  62. this.emissive = new THREE.Color( 0x000000 );
  63. this.specular = new THREE.Color( 0x111111 );
  64. this.shininess = 30;
  65. this.map = null;
  66. this.lightMap = null;
  67. this.lightMapIntensity = 1.0;
  68. this.aoMap = null;
  69. this.aoMapIntensity = 1.0;
  70. this.emissiveMap = null;
  71. this.bumpMap = null;
  72. this.bumpScale = 1;
  73. this.normalMap = null;
  74. this.normalScale = new THREE.Vector2( 1, 1 );
  75. this.displacementMap = null;
  76. this.displacementScale = 1;
  77. this.displacementBias = 0;
  78. this.specularMap = null;
  79. this.alphaMap = null;
  80. this.envMap = null;
  81. this.combine = THREE.MultiplyOperation;
  82. this.reflectivity = 1;
  83. this.refractionRatio = 0.98;
  84. this.fog = true;
  85. this.shading = THREE.SmoothShading;
  86. this.wireframe = false;
  87. this.wireframeLinewidth = 1;
  88. this.wireframeLinecap = 'round';
  89. this.wireframeLinejoin = 'round';
  90. this.vertexColors = THREE.NoColors;
  91. this.skinning = false;
  92. this.morphTargets = false;
  93. this.morphNormals = false;
  94. this.setValues( parameters );
  95. };
  96. THREE.MeshPhongMaterial.prototype = Object.create( THREE.Material.prototype );
  97. THREE.MeshPhongMaterial.prototype.constructor = THREE.MeshPhongMaterial;
  98. THREE.MeshPhongMaterial.prototype.copy = function ( source ) {
  99. THREE.Material.prototype.copy.call( this, source );
  100. this.color.copy( source.color );
  101. this.emissive.copy( source.emissive );
  102. this.specular.copy( source.specular );
  103. this.shininess = source.shininess;
  104. this.map = source.map;
  105. this.lightMap = source.lightMap;
  106. this.lightMapIntensity = source.lightMapIntensity;
  107. this.aoMap = source.aoMap;
  108. this.aoMapIntensity = source.aoMapIntensity;
  109. this.emissiveMap = source.emissiveMap;
  110. this.bumpMap = source.bumpMap;
  111. this.bumpScale = source.bumpScale;
  112. this.normalMap = source.normalMap;
  113. this.normalScale.copy( source.normalScale );
  114. this.displacementMap = source.displacementMap;
  115. this.displacementScale = source.displacementScale;
  116. this.displacementBias = source.displacementBias;
  117. this.specularMap = source.specularMap;
  118. this.alphaMap = source.alphaMap;
  119. this.envMap = source.envMap;
  120. this.combine = source.combine;
  121. this.reflectivity = source.reflectivity;
  122. this.refractionRatio = source.refractionRatio;
  123. this.fog = source.fog;
  124. this.shading = source.shading;
  125. this.wireframe = source.wireframe;
  126. this.wireframeLinewidth = source.wireframeLinewidth;
  127. this.wireframeLinecap = source.wireframeLinecap;
  128. this.wireframeLinejoin = source.wireframeLinejoin;
  129. this.vertexColors = source.vertexColors;
  130. this.skinning = source.skinning;
  131. this.morphTargets = source.morphTargets;
  132. this.morphNormals = source.morphNormals;
  133. return this;
  134. };
粤ICP备19079148号