MeshMatcapMaterial.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. * @author WestLangley / http://github.com/WestLangley
  7. *
  8. * parameters = {
  9. * color: <hex>,
  10. * opacity: <float>,
  11. *
  12. * matcap: new THREE.Texture( <Image> ),
  13. *
  14. * map: new THREE.Texture( <Image> ),
  15. *
  16. * bumpMap: new THREE.Texture( <Image> ),
  17. * bumpScale: <float>,
  18. *
  19. * normalMap: new THREE.Texture( <Image> ),
  20. * normalMapType: THREE.TangentSpaceNormalMap,
  21. * normalScale: <Vector2>,
  22. *
  23. * displacementMap: new THREE.Texture( <Image> ),
  24. * displacementScale: <float>,
  25. * displacementBias: <float>,
  26. *
  27. * alphaMap: new THREE.Texture( <Image> ),
  28. *
  29. * skinning: <bool>,
  30. * morphTargets: <bool>,
  31. * morphNormals: <bool>
  32. * }
  33. */
  34. function MeshMatcapMaterial( parameters ) {
  35. Material.call( this );
  36. this.defines = { 'MATCAP': '' };
  37. this.type = 'MeshMatcapMaterial';
  38. this.color = new Color( 0xffffff ); // diffuse
  39. this.matcap = null;
  40. this.map = null;
  41. this.bumpMap = null;
  42. this.bumpScale = 1;
  43. this.normalMap = null;
  44. this.normalMapType = TangentSpaceNormalMap;
  45. this.normalScale = new Vector2( 1, 1 );
  46. this.displacementMap = null;
  47. this.displacementScale = 1;
  48. this.displacementBias = 0;
  49. this.alphaMap = null;
  50. this.skinning = false;
  51. this.morphTargets = false;
  52. this.morphNormals = false;
  53. this.lights = false;
  54. this.setValues( parameters );
  55. }
  56. MeshMatcapMaterial.prototype = Object.create( Material.prototype );
  57. MeshMatcapMaterial.prototype.constructor = MeshMatcapMaterial;
  58. MeshMatcapMaterial.prototype.isMeshMatcapMaterial = true;
  59. MeshMatcapMaterial.prototype.copy = function ( source ) {
  60. Material.prototype.copy.call( this, source );
  61. this.defines = { 'MATCAP': '' };
  62. this.color.copy( source.color );
  63. this.matcap = source.matcap;
  64. this.map = source.map;
  65. this.bumpMap = source.bumpMap;
  66. this.bumpScale = source.bumpScale;
  67. this.normalMap = source.normalMap;
  68. this.normalMapType = source.normalMapType;
  69. this.normalScale.copy( source.normalScale );
  70. this.displacementMap = source.displacementMap;
  71. this.displacementScale = source.displacementScale;
  72. this.displacementBias = source.displacementBias;
  73. this.alphaMap = source.alphaMap;
  74. this.skinning = source.skinning;
  75. this.morphTargets = source.morphTargets;
  76. this.morphNormals = source.morphNormals;
  77. return this;
  78. };
  79. export { MeshMatcapMaterial };