MeshMatcapMaterial.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import { TangentSpaceNormalMap } from '../constants.js';
  2. import { Material } from './Material.js';
  3. import { Vector2 } from '../math/Vector2.js';
  4. import { Color } from '../math/Color.js';
  5. /**
  6. * parameters = {
  7. * color: <hex>,
  8. * opacity: <float>,
  9. *
  10. * matcap: new THREE.Texture( <Image> ),
  11. *
  12. * map: new THREE.Texture( <Image> ),
  13. *
  14. * bumpMap: new THREE.Texture( <Image> ),
  15. * bumpScale: <float>,
  16. *
  17. * normalMap: new THREE.Texture( <Image> ),
  18. * normalMapType: THREE.TangentSpaceNormalMap,
  19. * normalScale: <Vector2>,
  20. *
  21. * displacementMap: new THREE.Texture( <Image> ),
  22. * displacementScale: <float>,
  23. * displacementBias: <float>,
  24. *
  25. * alphaMap: new THREE.Texture( <Image> ),
  26. *
  27. * flatShading: <bool>
  28. * }
  29. */
  30. class MeshMatcapMaterial extends Material {
  31. constructor( parameters ) {
  32. super();
  33. this.defines = { 'MATCAP': '' };
  34. this.type = 'MeshMatcapMaterial';
  35. this.color = new Color( 0xffffff ); // diffuse
  36. this.matcap = null;
  37. this.map = null;
  38. this.bumpMap = null;
  39. this.bumpScale = 1;
  40. this.normalMap = null;
  41. this.normalMapType = TangentSpaceNormalMap;
  42. this.normalScale = new Vector2( 1, 1 );
  43. this.displacementMap = null;
  44. this.displacementScale = 1;
  45. this.displacementBias = 0;
  46. this.alphaMap = null;
  47. this.flatShading = false;
  48. this.setValues( parameters );
  49. }
  50. copy( source ) {
  51. super.copy( source );
  52. this.defines = { 'MATCAP': '' };
  53. this.color.copy( source.color );
  54. this.matcap = source.matcap;
  55. this.map = source.map;
  56. this.bumpMap = source.bumpMap;
  57. this.bumpScale = source.bumpScale;
  58. this.normalMap = source.normalMap;
  59. this.normalMapType = source.normalMapType;
  60. this.normalScale.copy( source.normalScale );
  61. this.displacementMap = source.displacementMap;
  62. this.displacementScale = source.displacementScale;
  63. this.displacementBias = source.displacementBias;
  64. this.alphaMap = source.alphaMap;
  65. this.flatShading = source.flatShading;
  66. return this;
  67. }
  68. }
  69. MeshMatcapMaterial.prototype.isMeshMatcapMaterial = true;
  70. export { MeshMatcapMaterial };