MeshToonMaterial.js 3.7 KB

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