SpriteMaterial.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { Material } from './Material.js';
  2. import { Color } from '../math/Color.js';
  3. /**
  4. * parameters = {
  5. * color: <hex>,
  6. * map: new THREE.Texture( <Image> ),
  7. * alphaMap: new THREE.Texture( <Image> ),
  8. * rotation: <float>,
  9. * sizeAttenuation: <bool>
  10. * }
  11. */
  12. function SpriteMaterial( parameters ) {
  13. Material.call( this );
  14. this.type = 'SpriteMaterial';
  15. this.color = new Color( 0xffffff );
  16. this.map = null;
  17. this.alphaMap = null;
  18. this.rotation = 0;
  19. this.sizeAttenuation = true;
  20. this.transparent = true;
  21. this.setValues( parameters );
  22. }
  23. SpriteMaterial.prototype = Object.create( Material.prototype );
  24. SpriteMaterial.prototype.constructor = SpriteMaterial;
  25. SpriteMaterial.prototype.isSpriteMaterial = true;
  26. SpriteMaterial.prototype.copy = function ( source ) {
  27. Material.prototype.copy.call( this, source );
  28. this.color.copy( source.color );
  29. this.map = source.map;
  30. this.alphaMap = source.alphaMap;
  31. this.rotation = source.rotation;
  32. this.sizeAttenuation = source.sizeAttenuation;
  33. return this;
  34. };
  35. export { SpriteMaterial };
粤ICP备19079148号