ImageLoader.js 554 B

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. THREE.ImageLoader = function () {
  5. THREE.EventTarget.call( this );
  6. var _this = this;
  7. this.crossOrigin = 'anonymous';
  8. this.load = function ( url ) {
  9. var image = new Image();
  10. image.addEventListener( 'load', function () {
  11. _this.dispatchEvent( { type: 'complete', image: image } );
  12. }, false );
  13. image.addEventListener( 'error', function () {
  14. _this.dispatchEvent( { type: 'error', image: image } );
  15. }, false );
  16. image.crossOrigin = this.crossOrigin;
  17. image.src = url;
  18. };
  19. };