TextureLoader.js 750 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. THREE.TextureLoader = function () {
  5. THREE.EventTarget.call( this );
  6. this.crossOrigin = null;
  7. };
  8. THREE.TextureLoader.prototype = {
  9. constructor: THREE.TextureLoader,
  10. load: function ( url ) {
  11. var scope = this;
  12. var image = new Image();
  13. image.addEventListener( 'load', function () {
  14. var texture = new THREE.Texture( image );
  15. texture.needsUpdate = true;
  16. scope.dispatchEvent( { type: 'load', content: texture } );
  17. }, false );
  18. image.addEventListener( 'error', function () {
  19. scope.dispatchEvent( { type: 'error', message: 'Couldn\'t load URL [' + url + ']' } );
  20. }, false );
  21. if ( scope.crossOrigin ) image.crossOrigin = scope.crossOrigin;
  22. image.src = url;
  23. }
  24. }
粤ICP备19079148号