MaterialLoader.html 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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">A loader for loading a [page:Material] in JSON format.</div>
  13. <h2>Constructor</h2>
  14. <h3>[name]( [page:LoadingManager manager] )</h3>
  15. <div>
  16. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  17. </div>
  18. <div>
  19. Creates a new [name].
  20. </div>
  21. <h2>Methods</h2>
  22. <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  23. <div>
  24. [page:String url] — required<br />
  25. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Material].<br />
  26. [page:Function onProgress] — Will be called while load progresses. The argument will be the progress event.<br />
  27. [page:Function onError] — Will be called when load errors.<br />
  28. </div>
  29. <div>
  30. Begin loading from url and return the [page:Material] object that will contain the data.
  31. </div>
  32. <h3>[method:Material parse]( [page:Object json] )</h3>
  33. <div>
  34. [page:Object json] — The json object containing the parameters of the Material.
  35. </div>
  36. <div>
  37. Parse a <em>JSON</em> structure and create a new [page:Material] of the type [page:String json.type] with parameters defined in the json object.
  38. </div>
  39. <h2>Example</h2>
  40. <code>
  41. // instantiate a loader
  42. var loader = new THREE.MaterialLoader();
  43. // load a resource
  44. loader.load(
  45. // resource URL
  46. 'path/to/material.json',
  47. // Function when resource is loaded
  48. function ( material ) {
  49. object.material = material;
  50. },
  51. // Function called when download progresses
  52. function ( xhr ) {
  53. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  54. },
  55. // Function called when download errors
  56. function ( xhr ) {
  57. console.log( 'An error happened' );
  58. }
  59. );
  60. </code>
  61. <h2>Source</h2>
  62. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  63. </body>
  64. </html>