MeshStandardMaterial.js 4.0 KB

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