MeshPhongMaterial.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. * specularMap: new THREE.Texture( <Image> ),
  29. *
  30. * alphaMap: new THREE.Texture( <Image> ),
  31. *
  32. * envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
  33. * combine: THREE.Multiply,
  34. * reflectivity: <float>,
  35. * refractionRatio: <float>,
  36. *
  37. * shading: THREE.SmoothShading,
  38. * blending: THREE.NormalBlending,
  39. * depthTest: <bool>,
  40. * depthWrite: <bool>,
  41. *
  42. * wireframe: <boolean>,
  43. * wireframeLinewidth: <float>,
  44. *
  45. * vertexColors: THREE.NoColors / THREE.VertexColors / THREE.FaceColors,
  46. *
  47. * skinning: <bool>,
  48. * morphTargets: <bool>,
  49. * morphNormals: <bool>,
  50. *
  51. * fog: <bool>
  52. * }
  53. */
  54. THREE.MeshPhongMaterial = function ( parameters ) {
  55. THREE.Material.call( this );
  56. this.type = 'MeshPhongMaterial';
  57. this.color = new THREE.Color( 0xffffff ); // diffuse
  58. this.emissive = new THREE.Color( 0x000000 );
  59. this.specular = new THREE.Color( 0x111111 );
  60. this.shininess = 30;
  61. this.metal = false;
  62. this.map = null;
  63. this.lightMap = null;
  64. this.lightMapIntensity = 1.0;
  65. this.aoMap = null;
  66. this.aoMapIntensity = 1.0;
  67. this.emissiveMap = null;
  68. this.bumpMap = null;
  69. this.bumpScale = 1;
  70. this.normalMap = null;
  71. this.normalScale = new THREE.Vector2( 1, 1 );
  72. this.specularMap = null;
  73. this.alphaMap = null;
  74. this.envMap = null;
  75. this.combine = THREE.MultiplyOperation;
  76. this.reflectivity = 1;
  77. this.refractionRatio = 0.98;
  78. this.fog = true;
  79. this.shading = THREE.SmoothShading;
  80. this.wireframe = false;
  81. this.wireframeLinewidth = 1;
  82. this.wireframeLinecap = 'round';
  83. this.wireframeLinejoin = 'round';
  84. this.vertexColors = THREE.NoColors;
  85. this.skinning = false;
  86. this.morphTargets = false;
  87. this.morphNormals = false;
  88. this.setValues( parameters );
  89. };
  90. THREE.MeshPhongMaterial.prototype = Object.create( THREE.Material.prototype );
  91. THREE.MeshPhongMaterial.prototype.constructor = THREE.MeshPhongMaterial;
  92. THREE.MeshPhongMaterial.prototype.copy = function ( source ) {
  93. THREE.Material.prototype.copy.call( this, source );
  94. this.color.copy( source.color );
  95. this.emissive.copy( source.emissive );
  96. this.specular.copy( source.specular );
  97. this.shininess = source.shininess;
  98. this.metal = source.metal;
  99. this.map = source.map;
  100. this.lightMap = source.lightMap;
  101. this.lightMapIntensity = source.lightMapIntensity;
  102. this.aoMap = source.aoMap;
  103. this.aoMapIntensity = source.aoMapIntensity;
  104. this.emissiveMap = source.emissiveMap;
  105. this.bumpMap = source.bumpMap;
  106. this.bumpScale = source.bumpScale;
  107. this.normalMap = source.normalMap;
  108. this.normalScale.copy( source.normalScale );
  109. this.specularMap = source.specularMap;
  110. this.alphaMap = source.alphaMap;
  111. this.envMap = source.envMap;
  112. this.combine = source.combine;
  113. this.reflectivity = source.reflectivity;
  114. this.refractionRatio = source.refractionRatio;
  115. this.fog = source.fog;
  116. this.shading = source.shading;
  117. this.wireframe = source.wireframe;
  118. this.wireframeLinewidth = source.wireframeLinewidth;
  119. this.wireframeLinecap = source.wireframeLinecap;
  120. this.wireframeLinejoin = source.wireframeLinejoin;
  121. this.vertexColors = source.vertexColors;
  122. this.skinning = source.skinning;
  123. this.morphTargets = source.morphTargets;
  124. this.morphNormals = source.morphNormals;
  125. return this;
  126. };
粤ICP备19079148号