MeshMatcapMaterial.js 2.2 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. * 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. * morphTargets: <bool>,
  28. * morphNormals: <bool>
  29. *
  30. * flatShading: <bool>
  31. * }
  32. */
  33. class MeshMatcapMaterial extends Material {
  34. constructor( parameters ) {
  35. super();
  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.morphTargets = false;
  51. this.morphNormals = false;
  52. this.flatShading = false;
  53. this.setValues( parameters );
  54. }
  55. copy( source ) {
  56. super.copy( source );
  57. this.defines = { 'MATCAP': '' };
  58. this.color.copy( source.color );
  59. this.matcap = source.matcap;
  60. this.map = source.map;
  61. this.bumpMap = source.bumpMap;
  62. this.bumpScale = source.bumpScale;
  63. this.normalMap = source.normalMap;
  64. this.normalMapType = source.normalMapType;
  65. this.normalScale.copy( source.normalScale );
  66. this.displacementMap = source.displacementMap;
  67. this.displacementScale = source.displacementScale;
  68. this.displacementBias = source.displacementBias;
  69. this.alphaMap = source.alphaMap;
  70. this.morphTargets = source.morphTargets;
  71. this.morphNormals = source.morphNormals;
  72. this.flatShading = source.flatShading;
  73. return this;
  74. }
  75. }
  76. MeshMatcapMaterial.prototype.isMeshMatcapMaterial = true;
  77. export { MeshMatcapMaterial };
粤ICP备19079148号