MeshPhongMaterial.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /**
  2. * @author mr.doob / 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. * envMap: new THREE.TextureCube( [posx, negx, posy, negy, posz, negz] ),
  21. * combine: THREE.Multiply,
  22. * reflectivity: <float>,
  23. * refractionRatio: <float>,
  24. *
  25. * shading: THREE.SmoothShading,
  26. * blending: THREE.NormalBlending,
  27. * depthTest: <bool>,
  28. *
  29. * wireframe: <boolean>,
  30. * wireframeLinewidth: <float>,
  31. *
  32. * vertexColors: THREE.NoColors / THREE.VertexColors / THREE.FaceColors,
  33. *
  34. * skinning: <bool>,
  35. * morphTargets: <bool>,
  36. * morphNormals: <bool>,
  37. *
  38. * fog: <bool>
  39. * }
  40. */
  41. THREE.MeshPhongMaterial = function ( parameters ) {
  42. THREE.Material.call( this );
  43. this.color = new THREE.Color( 0xffffff ); // diffuse
  44. this.ambient = new THREE.Color( 0xffffff );
  45. this.emissive = new THREE.Color( 0x000000 );
  46. this.specular = new THREE.Color( 0x111111 );
  47. this.shininess = 30;
  48. this.metal = false;
  49. this.perPixel = false;
  50. this.wrapAround = false;
  51. this.wrapRGB = new THREE.Vector3( 1, 1, 1 );
  52. this.map = null;
  53. this.lightMap = null;
  54. this.bumpMap = null;
  55. this.bumpScale = 1;
  56. this.envMap = null;
  57. this.combine = THREE.MultiplyOperation;
  58. this.reflectivity = 1;
  59. this.refractionRatio = 0.98;
  60. this.fog = true;
  61. this.shading = THREE.SmoothShading;
  62. this.wireframe = false;
  63. this.wireframeLinewidth = 1;
  64. this.wireframeLinecap = 'round';
  65. this.wireframeLinejoin = 'round';
  66. this.vertexColors = THREE.NoColors;
  67. this.skinning = false;
  68. this.morphTargets = false;
  69. this.morphNormals = false;
  70. this.setValues( parameters );
  71. };
  72. THREE.MeshPhongMaterial.prototype = Object.create( THREE.Material.prototype );
  73. THREE.MeshPhongMaterial.prototype.clone = function () {
  74. var material = new THREE.MeshPhongMaterial();
  75. THREE.Material.prototype.clone.call( this, material );
  76. material.color.copy( this.color );
  77. material.ambient.copy( this.ambient );
  78. material.emissive.copy( this.emissive );
  79. material.specular.copy( this.specular );
  80. material.shininess = this.shininess;
  81. material.metal = this.metal;
  82. material.perPixel = this.perPixel;
  83. material.wrapAround = this.wrapAround;
  84. material.wrapRGB.copy( this.wrapRGB );
  85. material.map = this.map;
  86. material.lightMap = this.lightMap;
  87. material.bumpMap = this.bumpMap;
  88. material.bumpScale= this.bumpScale;
  89. material.envMap = this.envMap;
  90. material.combine = this.combine;
  91. material.reflectivity = this.reflectivity;
  92. material.refractionRatio = this.refractionRatio;
  93. material.fog = this.fog;
  94. material.shading = this.shading;
  95. material.wireframe = this.wireframe;
  96. material.wireframeLinewidth = this.wireframeLinewidth;
  97. material.wireframeLinecap = this.wireframeLinecap;
  98. material.wireframeLinejoin = this.wireframeLinejoin;
  99. material.vertexColors = this.vertexColors;
  100. material.skinning = this.skinning;
  101. material.morphTargets = this.morphTargets;
  102. material.morphNormals = this.morphNormals;
  103. return material;
  104. };
粤ICP备19079148号