MeshPhysicalMaterial.js 2.1 KB

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