1
0

MaterialLoader.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. This uses the
  14. [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]
  42. 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>
  49. Object holding any textures used by the material. See [page:.setTextures].
  50. </p>
  51. <h2>Methods</h2>
  52. <p>See the base [page:Loader] class for common methods.</p>
  53. <h3>
  54. [method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )
  55. </h3>
  56. <p>
  57. [page:String url] — the path or URL to the file. This can also be a
  58. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].<br />
  59. [page:Function onLoad] — Will be called when load completes. The argument
  60. will be the loaded [page:Material].<br />
  61. [page:Function onProgress] (optional) — Will be called while load
  62. progresses. The argument will be the ProgressEvent instance, which
  63. contains .[page:Boolean lengthComputable], .[page:Integer total] and
  64. .[page:Integer loaded]. If the server does not set the Content-Length
  65. header; .[page:Integer total] will be 0.<br />
  66. [page:Function onError] (optional) — Will be called when load errors.<br /><br />
  67. Begin loading from url.
  68. </p>
  69. <h3>[method:Material parse]( [param:Object json] )</h3>
  70. <p>
  71. [page:Object json] — The json object containing the parameters of the
  72. Material.<br /><br />
  73. Parse a `JSON` structure and create a new [page:Material] of the type
  74. [page:String json.type] with parameters defined in the json object.
  75. </p>
  76. <h3>[method:this setTextures]( [param:Object textures] )</h3>
  77. <p>
  78. [page:Object textures] — object containing any textures used by the
  79. material.
  80. </p>
  81. <h2>Source</h2>
  82. <p>
  83. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  84. </p>
  85. </body>
  86. </html>