MeshPhysicalMaterial.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 = { 'PHYSICAL': '' };
  21. this.type = 'MeshPhysicalMaterial';
  22. this.reflectivity = 0.5; // maps to F0 = 0.04
  23. this.clearCoat = 0.0;
  24. this.clearCoatRoughness = 0.0;
  25. this.sheenColor = null; // null will disable sheen bsdf
  26. this.clearCoatNormalScale = new Vector2( 1, 1 );
  27. this.clearCoatNormalMap = null;
  28. this.setValues( parameters );
  29. }
  30. MeshPhysicalMaterial.prototype = Object.create( MeshStandardMaterial.prototype );
  31. MeshPhysicalMaterial.prototype.constructor = MeshPhysicalMaterial;
  32. MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true;
  33. MeshPhysicalMaterial.prototype.copy = function ( source ) {
  34. MeshStandardMaterial.prototype.copy.call( this, source );
  35. this.defines = { 'PHYSICAL': '' };
  36. this.reflectivity = source.reflectivity;
  37. this.clearCoat = source.clearCoat;
  38. this.clearCoatRoughness = source.clearCoatRoughness;
  39. if ( source.sheenColor ) this.sheenColor = ( this.sheenColor || new Color() ).copy( source.sheenColor );
  40. else this.sheenColor = null;
  41. this.clearCoatNormalMap = source.clearCoatNormalMap;
  42. this.clearCoatNormalScale.copy( source.clearCoatNormalScale );
  43. return this;
  44. };
  45. export { MeshPhysicalMaterial };
粤ICP备19079148号