MeshPhysicalMaterial.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { Vector2 } from '../math/Vector2.js';
  2. import { MeshStandardMaterial } from './MeshStandardMaterial.js';
  3. import { Color } from '../math/Color.js';
  4. /**
  5. * @author WestLangley / http://github.com/WestLangley
  6. *
  7. * parameters = {
  8. * reflectivity: <float>
  9. * clearcoat: <float>
  10. * clearcoatRoughness: <float>
  11. *
  12. * sheen: <Color>
  13. *
  14. * clearcoatNormalScale: <Vector2>,
  15. * clearcoatNormalMap: new THREE.Texture( <Image> ),
  16. * }
  17. */
  18. function MeshPhysicalMaterial( parameters ) {
  19. MeshStandardMaterial.call( this );
  20. this.defines = {
  21. 'PHYSICAL': '',
  22. 'ADVANCED_PHYSICAL': ''
  23. };
  24. this.type = 'MeshPhysicalMaterial';
  25. this.reflectivity = 0.5; // maps to F0 = 0.04
  26. this.clearcoat = 0.0;
  27. this.clearcoatRoughness = 0.0;
  28. this.sheen = null; // null will disable sheen bsdf
  29. this.clearcoatNormalScale = new Vector2( 1, 1 );
  30. this.clearcoatNormalMap = null;
  31. this.setValues( parameters );
  32. }
  33. MeshPhysicalMaterial.prototype = Object.create( MeshStandardMaterial.prototype );
  34. MeshPhysicalMaterial.prototype.constructor = MeshPhysicalMaterial;
  35. MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true;
  36. MeshPhysicalMaterial.prototype.copy = function ( source ) {
  37. MeshStandardMaterial.prototype.copy.call( this, source );
  38. this.defines = {
  39. 'PHYSICAL': '',
  40. 'ADVANCED_PHYSICAL': ''
  41. };
  42. this.reflectivity = source.reflectivity;
  43. this.clearcoat = source.clearcoat;
  44. this.clearcoatRoughness = source.clearcoatRoughness;
  45. if ( source.sheen ) this.sheen = ( this.sheen || new Color() ).copy( source.sheen );
  46. else this.sheen = null;
  47. this.clearcoatNormalMap = source.clearcoatNormalMap;
  48. this.clearcoatNormalScale.copy( source.clearcoatNormalScale );
  49. return this;
  50. };
  51. export { MeshPhysicalMaterial };