MeshToonMaterial.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. * skinning: <bool>,
  39. * morphTargets: <bool>,
  40. * morphNormals: <bool>
  41. * }
  42. */
  43. class MeshToonMaterial extends Material {
  44. constructor( parameters ) {
  45. super();
  46. this.defines = { 'TOON': '' };
  47. this.type = 'MeshToonMaterial';
  48. this.color = new Color( 0xffffff );
  49. this.map = null;
  50. this.gradientMap = null;
  51. this.lightMap = null;
  52. this.lightMapIntensity = 1.0;
  53. this.aoMap = null;
  54. this.aoMapIntensity = 1.0;
  55. this.emissive = new Color( 0x000000 );
  56. this.emissiveIntensity = 1.0;
  57. this.emissiveMap = null;
  58. this.bumpMap = null;
  59. this.bumpScale = 1;
  60. this.normalMap = null;
  61. this.normalMapType = TangentSpaceNormalMap;
  62. this.normalScale = new Vector2( 1, 1 );
  63. this.displacementMap = null;
  64. this.displacementScale = 1;
  65. this.displacementBias = 0;
  66. this.alphaMap = null;
  67. this.wireframe = false;
  68. this.wireframeLinewidth = 1;
  69. this.wireframeLinecap = 'round';
  70. this.wireframeLinejoin = 'round';
  71. this.skinning = false;
  72. this.morphTargets = false;
  73. this.morphNormals = false;
  74. this.setValues( parameters );
  75. }
  76. copy( source ) {
  77. super.copy( source );
  78. this.color.copy( source.color );
  79. this.map = source.map;
  80. this.gradientMap = source.gradientMap;
  81. this.lightMap = source.lightMap;
  82. this.lightMapIntensity = source.lightMapIntensity;
  83. this.aoMap = source.aoMap;
  84. this.aoMapIntensity = source.aoMapIntensity;
  85. this.emissive.copy( source.emissive );
  86. this.emissiveMap = source.emissiveMap;
  87. this.emissiveIntensity = source.emissiveIntensity;
  88. this.bumpMap = source.bumpMap;
  89. this.bumpScale = source.bumpScale;
  90. this.normalMap = source.normalMap;
  91. this.normalMapType = source.normalMapType;
  92. this.normalScale.copy( source.normalScale );
  93. this.displacementMap = source.displacementMap;
  94. this.displacementScale = source.displacementScale;
  95. this.displacementBias = source.displacementBias;
  96. this.alphaMap = source.alphaMap;
  97. this.wireframe = source.wireframe;
  98. this.wireframeLinewidth = source.wireframeLinewidth;
  99. this.wireframeLinecap = source.wireframeLinecap;
  100. this.wireframeLinejoin = source.wireframeLinejoin;
  101. this.skinning = source.skinning;
  102. this.morphTargets = source.morphTargets;
  103. this.morphNormals = source.morphNormals;
  104. return this;
  105. }
  106. }
  107. MeshToonMaterial.prototype.isMeshToonMaterial = true;
  108. export { MeshToonMaterial };