LoadingManager.js 849 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. THREE.LoadingManager = function ( onLoad, onProgress, onError ) {
  5. var scope = this;
  6. var isLoading = false, itemsLoaded = 0, itemsTotal = 0;
  7. this.onLoad = onLoad;
  8. this.onProgress = onProgress;
  9. this.onError = onError;
  10. this.itemStart = function ( url ) {
  11. itemsTotal ++;
  12. if ( isLoading === false ) {
  13. if ( scope.onStart !== undefined ) {
  14. scope.onStart( url, itemsLoaded, itemsTotal );
  15. }
  16. }
  17. isLoading = true;
  18. };
  19. this.itemEnd = function ( url ) {
  20. itemsLoaded ++;
  21. if ( scope.onProgress !== undefined ) {
  22. scope.onProgress( url, itemsLoaded, itemsTotal );
  23. }
  24. if ( itemsLoaded === itemsTotal ) {
  25. isLoading = false;
  26. if ( scope.onLoad !== undefined ) {
  27. scope.onLoad();
  28. }
  29. }
  30. };
  31. };
  32. THREE.DefaultLoadingManager = new THREE.LoadingManager();
粤ICP备19079148号