MeshDistanceMaterial.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { Material } from './Material.js';
  2. import { Vector3 } from '../math/Vector3.js';
  3. /**
  4. * @author WestLangley / http://github.com/WestLangley
  5. *
  6. * parameters = {
  7. *
  8. * referencePosition: <float>,
  9. * nearDistance: <float>,
  10. * farDistance: <float>,
  11. *
  12. * skinning: <bool>,
  13. * morphTargets: <bool>,
  14. *
  15. * map: new THREE.Texture( <Image> ),
  16. *
  17. * alphaMap: new THREE.Texture( <Image> ),
  18. *
  19. * displacementMap: new THREE.Texture( <Image> ),
  20. * displacementScale: <float>,
  21. * displacementBias: <float>
  22. *
  23. * }
  24. */
  25. function MeshDistanceMaterial( parameters ) {
  26. Material.call( this );
  27. this.type = 'MeshDistanceMaterial';
  28. this.referencePosition = new Vector3();
  29. this.nearDistance = 1;
  30. this.farDistance = 1000;
  31. this.skinning = false;
  32. this.morphTargets = false;
  33. this.map = null;
  34. this.alphaMap = null;
  35. this.displacementMap = null;
  36. this.displacementScale = 1;
  37. this.displacementBias = 0;
  38. this.fog = false;
  39. this.lights = false;
  40. this.setValues( parameters );
  41. }
  42. MeshDistanceMaterial.prototype = Object.create( Material.prototype );
  43. MeshDistanceMaterial.prototype.constructor = MeshDistanceMaterial;
  44. MeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;
  45. MeshDistanceMaterial.prototype.copy = function ( source ) {
  46. Material.prototype.copy.call( this, source );
  47. this.referencePosition.copy( source.referencePosition );
  48. this.nearDistance = source.nearDistance;
  49. this.farDistance = source.farDistance;
  50. this.skinning = source.skinning;
  51. this.morphTargets = source.morphTargets;
  52. this.map = source.map;
  53. this.alphaMap = source.alphaMap;
  54. this.displacementMap = source.displacementMap;
  55. this.displacementScale = source.displacementScale;
  56. this.displacementBias = source.displacementBias;
  57. return this;
  58. };
  59. export { MeshDistanceMaterial };