MaterialLoader.html 2.4 KB

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