MeshDistanceMaterial.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { Material } from './Material.js';
  2. import { Vector3 } from '../math/Vector3.js';
  3. /**
  4. * parameters = {
  5. *
  6. * referencePosition: <float>,
  7. * nearDistance: <float>,
  8. * farDistance: <float>,
  9. *
  10. * map: new THREE.Texture( <Image> ),
  11. *
  12. * alphaMap: new THREE.Texture( <Image> ),
  13. *
  14. * displacementMap: new THREE.Texture( <Image> ),
  15. * displacementScale: <float>,
  16. * displacementBias: <float>
  17. *
  18. * }
  19. */
  20. class MeshDistanceMaterial extends Material {
  21. constructor( parameters ) {
  22. super();
  23. this.type = 'MeshDistanceMaterial';
  24. this.referencePosition = new Vector3();
  25. this.nearDistance = 1;
  26. this.farDistance = 1000;
  27. this.map = null;
  28. this.alphaMap = null;
  29. this.displacementMap = null;
  30. this.displacementScale = 1;
  31. this.displacementBias = 0;
  32. this.fog = false;
  33. this.setValues( parameters );
  34. }
  35. copy( source ) {
  36. super.copy( source );
  37. this.referencePosition.copy( source.referencePosition );
  38. this.nearDistance = source.nearDistance;
  39. this.farDistance = source.farDistance;
  40. this.map = source.map;
  41. this.alphaMap = source.alphaMap;
  42. this.displacementMap = source.displacementMap;
  43. this.displacementScale = source.displacementScale;
  44. this.displacementBias = source.displacementBias;
  45. return this;
  46. }
  47. }
  48. MeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;
  49. export { MeshDistanceMaterial };