MeshToonMaterial.js 3.4 KB

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