MeshPhysicalMaterial.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. * clearcoat: <float>,
  9. * clearcoatMap: new THREE.Texture( <Image> ),
  10. * clearcoatRoughness: <float>,
  11. * clearcoatRoughnessMap: new THREE.Texture( <Image> ),
  12. * clearcoatNormalScale: <Vector2>,
  13. * clearcoatNormalMap: new THREE.Texture( <Image> ),
  14. *
  15. * reflectivity: <float>,
  16. *
  17. * sheen: <Color>,
  18. *
  19. * transparency: <float>
  20. * }
  21. */
  22. function MeshPhysicalMaterial( parameters ) {
  23. MeshStandardMaterial.call( this );
  24. this.defines = {
  25. 'STANDARD': '',
  26. 'PHYSICAL': ''
  27. };
  28. this.type = 'MeshPhysicalMaterial';
  29. this.clearcoat = 0.0;
  30. this.clearcoatMap = null;
  31. this.clearcoatRoughness = 0.0;
  32. this.clearcoatRoughnessMap = null;
  33. this.clearcoatNormalScale = new Vector2( 1, 1 );
  34. this.clearcoatNormalMap = null;
  35. this.reflectivity = 0.5; // maps to F0 = 0.04
  36. this.sheen = null; // null will disable sheen bsdf
  37. this.transparency = 0.0;
  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.transparency = source.transparency;
  62. return this;
  63. };
  64. export { MeshPhysicalMaterial };
粤ICP备19079148号