MaterialLoader.html 2.7 KB

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