MeshStandardMaterial.js 3.9 KB

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