MaterialLoader.html 2.2 KB

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