MeshNormalMaterial.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. * skinning: <bool>,
  23. * morphTargets: <bool>,
  24. * morphNormals: <bool>,
  25. *
  26. * flatShading: <bool>
  27. * }
  28. */
  29. class MeshNormalMaterial extends Material {
  30. constructor( parameters ) {
  31. super();
  32. Object.defineProperty( this, 'isMeshNormalMaterial', { value: true } );
  33. this.type = 'MeshNormalMaterial';
  34. this.bumpMap = null;
  35. this.bumpScale = 1;
  36. this.normalMap = null;
  37. this.normalMapType = TangentSpaceNormalMap;
  38. this.normalScale = new Vector2( 1, 1 );
  39. this.displacementMap = null;
  40. this.displacementScale = 1;
  41. this.displacementBias = 0;
  42. this.wireframe = false;
  43. this.wireframeLinewidth = 1;
  44. this.fog = false;
  45. this.skinning = false;
  46. this.morphTargets = false;
  47. this.morphNormals = false;
  48. this.flatShading = false;
  49. this.setValues( parameters );
  50. }
  51. copy( source ) {
  52. super.clone( source );
  53. this.bumpMap = source.bumpMap;
  54. this.bumpScale = source.bumpScale;
  55. this.normalMap = source.normalMap;
  56. this.normalMapType = source.normalMapType;
  57. this.normalScale.copy( source.normalScale );
  58. this.displacementMap = source.displacementMap;
  59. this.displacementScale = source.displacementScale;
  60. this.displacementBias = source.displacementBias;
  61. this.wireframe = source.wireframe;
  62. this.wireframeLinewidth = source.wireframeLinewidth;
  63. this.skinning = source.skinning;
  64. this.morphTargets = source.morphTargets;
  65. this.morphNormals = source.morphNormals;
  66. this.flatShading = source.flatShading;
  67. return this;
  68. }
  69. }
  70. export { MeshNormalMaterial };
粤ICP备19079148号