LoadingManager.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>[name]</h1>
  12. <div class="desc">
  13. Handles and keeps track of loaded and pending data. A default global instance of this class
  14. is created and used by loaders if not supplied manually - see [page:DefaultLoadingManager].<br /><br />
  15. In general that should be sufficient, however there are times when it can be useful to have seperate loaders -
  16. for example if you want to show seperate loading bars for objects and textures.
  17. </div>
  18. <h2>Example</h2>
  19. <div>
  20. [example:webgl_loader_babylon WebGL / loader / babylon]<br />
  21. [example:webgl_loader_fbx WebGL / loader / fbx]<br />
  22. [example:webgl_loader_obj WebGL / loader / obj]<br />
  23. [example:webgl_materials_reflectivity WebGL / materials / reflectivity]<br />
  24. [example:webgl_postprocessing_outline WebGL / postprocesing / outline]<br />
  25. [example:webgl_terrain_dynamic WebGL / terrain / dynamic]
  26. </div>
  27. <code>
  28. var manager = new THREE.LoadingManager();
  29. manager.onStart = function ( url, itemsLoaded, itemsTotal ) {
  30. console.log( 'Started loading file: ' + url + '.\nLoaded ' + itemsLoaded + ' of ' + itemsTotal + ' files.' );
  31. };
  32. manager.onLoad = function ( ) {
  33. console.log( 'Loading complete!');
  34. };
  35. manager.onProgress = function ( url, itemsLoaded, itemsTotal ) {
  36. console.log( 'Loading file: ' + url + '.\nLoaded ' + itemsLoaded + ' of ' + itemsTotal + ' files.' );
  37. };
  38. manager.onError = function ( url ) {
  39. console.log( 'There was an error loading ' + url );
  40. };
  41. var loader = new THREE.OBJLoader( manager );
  42. loader.load( 'file.obj', function ( object ) {
  43. //
  44. } );
  45. </code>
  46. <h2>Constructor</h2>
  47. <h3>[name]( [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  48. <div>
  49. [page:Function onLoad] — (optional) this function will be called when all loaders are done.<br />
  50. [page:Function onProgress] — (optional) this function will be called when an item is complete.<br />
  51. [page:Function onError] — (optional) this function will be called a loader encounters errors. <br />
  52. Creates a new [name].
  53. </div>
  54. <h2>Properties</h2>
  55. <h3>[property:Function onStart]</h3>
  56. <div>
  57. This function will be called when loading starts.
  58. The arguments are:<br />
  59. [page:String url] — The url of the item just loaded.<br />
  60. [page:Integer itemsLoaded] — the number of items already loaded so far.<br />
  61. [page:Iteger itemsTotal] — the total amount of items to be loaded.<br /><br />
  62. By default this is undefined.
  63. </div>
  64. <h3>[property:Function onLoad]</h3>
  65. <div>
  66. This function will be called when all loading is completed. By default this is undefined,
  67. unless passed in the constructor.
  68. </div>
  69. <h3>[property:Function onProgress]</h3>
  70. <div>
  71. This function will be called when an item is complete.
  72. The arguments are:<br />
  73. [page:String url] — The url of the item just loaded.<br />
  74. [page:Integer itemsLoaded] — the number of items already loaded so far.<br />
  75. [page:Iteger itemsTotal] — the total amount of items to be loaded.<br /><br />
  76. By default this is undefined, unless passed in the constructor.
  77. </div>
  78. <h3>[property:Function onError]</h3>
  79. <div>
  80. This function will be called when any item errors, with the argument:<br />
  81. [page:String url] — The url of the item that errored.<br /><br />
  82. By default this is undefined, unless passed in the constructor.
  83. </div>
  84. <h2>Methods</h2>
  85. <div>
  86. <em>Note: The following methods are designed to be called internally by loaders. You shouldn't call
  87. them directly.</em>
  88. </div>
  89. <h3>[method:null itemStart]( [page:String url] )</h3>
  90. <div>
  91. [page:String url] — the url to load<br /><br />
  92. This should be called by any loader used by the manager when the loader starts loading an url.
  93. </div>
  94. <h3>[method:null itemEnd]( [page:String url] )</h3>
  95. <div>
  96. [page:String url] — the loaded url<br /><br />
  97. This should be called by any loader used by the manager when the loader ended loading an url.
  98. </div>
  99. <h3>[method:null itemError]( [page:String url] )</h3>
  100. <div>
  101. [page:String url] — the loaded url<br /><br />
  102. This should be called by any loader used by the manager when the loader errors loading an url.
  103. </div>
  104. <h2>Source</h2>
  105. [link:https://github.com/mrdoob/three.js/blob/master/src/loaders/LoadingManager.js src/loaders/LoadingManager.js]
  106. </body>
  107. </html>