JSONLoader.html 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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">
  13. A loader for loading objects in JSON format.
  14. This uses the [page:FileLoader] internally for loading files.
  15. </div>
  16. <h2>Example</h2>
  17. <div>
  18. [example:webgl_loader_json_blender WebGL / loader / json / blender]<br />
  19. [example:webgl_loader_json_objconverter WebGL / loader / json / objconverter]
  20. </div>
  21. <code>
  22. // instantiate a loader
  23. var loader = new THREE.JSONLoader();
  24. // load a resource
  25. loader.load(
  26. // resource URL
  27. 'models/animated/monster/monster.js',
  28. // Function when resource is loaded
  29. function ( geometry, materials ) {
  30. var material = new THREE.MultiMaterial( materials );
  31. var object = new THREE.Mesh( geometry, material );
  32. scene.add( object );
  33. }
  34. );
  35. </code>
  36. <h2>Constructor</h2>
  37. <h3>[name]( [page:LoadingManager manager] )</h3>
  38. <div>
  39. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  40. </div>
  41. <div>
  42. Creates a new [name].
  43. </div>
  44. <h2>Properties</h2>
  45. <h3>[property:LoadingManager manager]</h3>
  46. <div>
  47. The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
  48. </div>
  49. <h3>[property:String withCredentials]</h3>
  50. <div>
  51. Whether the XMLHttpRequest uses credentials.
  52. Default is *false*.
  53. </div>
  54. <h2>Methods</h2>
  55. <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  56. <div>
  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 will be the loaded text response.<br />
  60. [page:Function onProgress] — Will be called while load progresses. The argument will be the XmlHttpRequest instance, that contain .[page:Integer total] and .[page:Integer loaded] bytes.<br />
  61. [page:Function onError] — Will be called when load errors.<br />
  62. </div>
  63. <div>
  64. Begin loading from url and pass the <em>JSON</em> to onLoad.
  65. </div>
  66. <h3>[method:null setTexturePath]( [page:String texturePath] )</h3>
  67. <div>
  68. Set the base path or URL from which to load files. This can be useful if
  69. you are loading many files from the same directory.
  70. </div>
  71. <h3>[method:Object3D parse]( [page:Object json], [page:String texturePath] )</h3>
  72. <div>
  73. [page:String json] — JSON object to parse.<br />
  74. [page:String texturePath] — Base path for textures.<br /><br />
  75. Parse a <em>JSON</em> structure and return an [page:object] containing the parsed [page:Geometry geometry] and [page:Array materials].
  76. </div>
  77. <h2>Source</h2>
  78. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  79. </body>
  80. </html>