MaterialLoader.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. [page:Loader] &rarr;
  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>Code Example</h2>
  17. <code>
  18. // instantiate a loader
  19. const 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. <p>See the base [page:Loader] class for common properties.</p>
  46. <h3>[property:Object textures]</h3>
  47. <p>Object holding any textures used by the material. See [page:.setTextures].</p>
  48. <h2>Methods</h2>
  49. <p>See the base [page:Loader] class for common methods.</p>
  50. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  51. <p>
  52. [page:String url] — the path or URL to the file. This can also be a
  53. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
  54. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Material].<br />
  55. [page:Function onProgress] — Will be called while load progresses. The argument will be the progress event.<br />
  56. [page:Function onError] — Will be called when load errors.<br /><br />
  57. Begin loading from url.
  58. </p>
  59. <h3>[method:Material parse]( [param:Object json] )</h3>
  60. <p>
  61. [page:Object json] — The json object containing the parameters of the Material.<br /><br />
  62. 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.
  63. </p>
  64. <h3>[method:MaterialLoader setTextures]( [param:Object textures] )</h3>
  65. <p>
  66. [page:Object textures] — object containing any textures used by the material.
  67. </p>
  68. <h2>Source</h2>
  69. <p>
  70. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  71. </p>
  72. </body>
  73. </html>