MeshNormalMaterial.js 1.7 KB

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