MeshPhongMaterial.js 3.5 KB

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