MeshNormalMaterial.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { TangentSpaceNormalMap } from '../constants.js';
  2. import { Material } from './Material.js';
  3. import { Vector2 } from '../math/Vector2.js';
  4. /**
  5. * @author mrdoob / http://mrdoob.com/
  6. * @author WestLangley / http://github.com/WestLangley
  7. *
  8. * parameters = {
  9. * opacity: <float>,
  10. *
  11. * bumpMap: new THREE.Texture( <Image> ),
  12. * bumpScale: <float>,
  13. *
  14. * normalMap: new THREE.Texture( <Image> ),
  15. * normalMapType: THREE.TangentSpaceNormalMap,
  16. * normalScale: <Vector2>,
  17. *
  18. * displacementMap: new THREE.Texture( <Image> ),
  19. * displacementScale: <float>,
  20. * displacementBias: <float>,
  21. *
  22. * wireframe: <boolean>,
  23. * wireframeLinewidth: <float>
  24. *
  25. * skinning: <bool>,
  26. * morphTargets: <bool>,
  27. * morphNormals: <bool>
  28. * }
  29. */
  30. function MeshNormalMaterial( parameters ) {
  31. Material.call( this );
  32. this.type = 'MeshNormalMaterial';
  33. this.bumpMap = null;
  34. this.bumpScale = 1;
  35. this.normalMap = null;
  36. this.normalMapType = TangentSpaceNormalMap;
  37. this.normalScale = new Vector2( 1, 1 );
  38. this.displacementMap = null;
  39. this.displacementScale = 1;
  40. this.displacementBias = 0;
  41. this.wireframe = false;
  42. this.wireframeLinewidth = 1;
  43. this.fog = false;
  44. this.skinning = false;
  45. this.morphTargets = false;
  46. this.morphNormals = false;
  47. this.setValues( parameters );
  48. }
  49. MeshNormalMaterial.prototype = Object.create( Material.prototype );
  50. MeshNormalMaterial.prototype.constructor = MeshNormalMaterial;
  51. MeshNormalMaterial.prototype.isMeshNormalMaterial = true;
  52. MeshNormalMaterial.prototype.copy = function ( source ) {
  53. Material.prototype.copy.call( this, source );
  54. this.bumpMap = source.bumpMap;
  55. this.bumpScale = source.bumpScale;
  56. this.normalMap = source.normalMap;
  57. this.normalMapType = source.normalMapType;
  58. this.normalScale.copy( source.normalScale );
  59. this.displacementMap = source.displacementMap;
  60. this.displacementScale = source.displacementScale;
  61. this.displacementBias = source.displacementBias;
  62. this.wireframe = source.wireframe;
  63. this.wireframeLinewidth = source.wireframeLinewidth;
  64. this.skinning = source.skinning;
  65. this.morphTargets = source.morphTargets;
  66. this.morphNormals = source.morphNormals;
  67. return this;
  68. };
  69. export { MeshNormalMaterial };