MaterialLoader.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. <p class="desc">
  13. A loader for loading a [page:Material] in JSON format.
  14. This uses the [page:FileLoader] internally for loading files.
  15. </p>
  16. <h2>Example</h2>
  17. <code>
  18. // instantiate a loader
  19. var loader = new THREE.MaterialLoader();
  20. // load a resource
  21. loader.load(
  22. // resource URL
  23. 'path/to/material.json',
  24. // onLoad callback
  25. function ( material ) {
  26. object.material = material;
  27. },
  28. // onProgress callback
  29. function ( xhr ) {
  30. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  31. },
  32. // onError callback
  33. function ( err ) {
  34. console.log( 'An error happened' );
  35. }
  36. );
  37. </code>
  38. <h2>Constructor</h2>
  39. <h3>[name]( [param:LoadingManager manager] )</h3>
  40. <p>
  41. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].<br /><br />
  42. Creates a new [name].
  43. </p>
  44. <h2>Properties</h2>
  45. <h3>[property:LoadingManager manager]</h3>
  46. <p>
  47. The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
  48. </p>
  49. <h3>[property:Object textures]</h3>
  50. <p>Object holding any textures used by the material. See [page:.setTextures].</p>
  51. <h2>Methods</h2>
  52. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  53. <p>
  54. [page:String url] — the path or URL to the file. This can also be a
  55. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
  56. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Material].<br />
  57. [page:Function onProgress] — Will be called while load progresses. The argument will be the progress event.<br />
  58. [page:Function onError] — Will be called when load errors.<br /><br />
  59. Begin loading from url and return the [page:Material] object that will contain the data.
  60. </p>
  61. <h3>[method:Material parse]( [param:Object json] )</h3>
  62. <p>
  63. [page:Object json] — The json object containing the parameters of the Material.<br /><br />
  64. 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.
  65. </p>
  66. <h3>[method:null setTextures]( [param:Object textures] )</h3>
  67. <p>
  68. [page:Object textures] — object containing any textures used by the material.
  69. </p>
  70. <h2>Source</h2>
  71. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  72. </body>
  73. </html>