MeshToonMaterial.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. *
  9. * map: new THREE.Texture( <Image> ),
  10. * gradientMap: new THREE.Texture( <Image> ),
  11. *
  12. * lightMap: new THREE.Texture( <Image> ),
  13. * lightMapIntensity: <float>
  14. *
  15. * aoMap: new THREE.Texture( <Image> ),
  16. * aoMapIntensity: <float>
  17. *
  18. * emissive: <hex>,
  19. * emissiveIntensity: <float>
  20. * emissiveMap: new THREE.Texture( <Image> ),
  21. *
  22. * bumpMap: new THREE.Texture( <Image> ),
  23. * bumpScale: <float>,
  24. *
  25. * normalMap: new THREE.Texture( <Image> ),
  26. * normalMapType: THREE.TangentSpaceNormalMap,
  27. * normalScale: <Vector2>,
  28. *
  29. * displacementMap: new THREE.Texture( <Image> ),
  30. * displacementScale: <float>,
  31. * displacementBias: <float>,
  32. *
  33. * alphaMap: new THREE.Texture( <Image> ),
  34. *
  35. * wireframe: <boolean>,
  36. * wireframeLinewidth: <float>,
  37. *
  38. * }
  39. */
  40. class MeshToonMaterial extends Material {
  41. constructor( parameters ) {
  42. super();
  43. this.defines = { 'TOON': '' };
  44. this.type = 'MeshToonMaterial';
  45. this.color = new Color( 0xffffff );
  46. this.map = null;
  47. this.gradientMap = null;
  48. this.lightMap = null;
  49. this.lightMapIntensity = 1.0;
  50. this.aoMap = null;
  51. this.aoMapIntensity = 1.0;
  52. this.emissive = new Color( 0x000000 );
  53. this.emissiveIntensity = 1.0;
  54. this.emissiveMap = null;
  55. this.bumpMap = null;
  56. this.bumpScale = 1;
  57. this.normalMap = null;
  58. this.normalMapType = TangentSpaceNormalMap;
  59. this.normalScale = new Vector2( 1, 1 );
  60. this.displacementMap = null;
  61. this.displacementScale = 1;
  62. this.displacementBias = 0;
  63. this.alphaMap = null;
  64. this.wireframe = false;
  65. this.wireframeLinewidth = 1;
  66. this.wireframeLinecap = 'round';
  67. this.wireframeLinejoin = 'round';
  68. this.setValues( parameters );
  69. }
  70. copy( source ) {
  71. super.copy( source );
  72. this.color.copy( source.color );
  73. this.map = source.map;
  74. this.gradientMap = source.gradientMap;
  75. this.lightMap = source.lightMap;
  76. this.lightMapIntensity = source.lightMapIntensity;
  77. this.aoMap = source.aoMap;
  78. this.aoMapIntensity = source.aoMapIntensity;
  79. this.emissive.copy( source.emissive );
  80. this.emissiveMap = source.emissiveMap;
  81. this.emissiveIntensity = source.emissiveIntensity;
  82. this.bumpMap = source.bumpMap;
  83. this.bumpScale = source.bumpScale;
  84. this.normalMap = source.normalMap;
  85. this.normalMapType = source.normalMapType;
  86. this.normalScale.copy( source.normalScale );
  87. this.displacementMap = source.displacementMap;
  88. this.displacementScale = source.displacementScale;
  89. this.displacementBias = source.displacementBias;
  90. this.alphaMap = source.alphaMap;
  91. this.wireframe = source.wireframe;
  92. this.wireframeLinewidth = source.wireframeLinewidth;
  93. this.wireframeLinecap = source.wireframeLinecap;
  94. this.wireframeLinejoin = source.wireframeLinejoin;
  95. return this;
  96. }
  97. }
  98. MeshToonMaterial.prototype.isMeshToonMaterial = true;
  99. export { MeshToonMaterial };
粤ICP备19079148号