JSONLoader.html 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. <p class="desc">
  13. A loader for loading objects in JSON format.
  14. This uses the [page:FileLoader] internally for loading files.
  15. </p>
  16. <h2>Example</h2>
  17. <p>
  18. [example:webgl_loader_json_blender WebGL / loader / json]<br />
  19. [example:webgl_loader_json_objconverter WebGL / loader / json / objconverter]
  20. </p>
  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. // onLoad callback
  29. function ( geometry, materials ) {
  30. var material = materials[ 0 ];
  31. var object = new THREE.Mesh( geometry, material );
  32. scene.add( object );
  33. },
  34. // onProgress callback
  35. function ( xhr ) {
  36. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  37. },
  38. // onError callback
  39. function( err ) {
  40. console.log( 'An error happened' );
  41. }
  42. );
  43. </code>
  44. <h2>Constructor</h2>
  45. <h3>[name]( [param:LoadingManager manager] )</h3>
  46. <p>
  47. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  48. </p>
  49. <p>
  50. Creates a new [name].
  51. </p>
  52. <h2>Properties</h2>
  53. <h3>[property:LoadingManager manager]</h3>
  54. <p>
  55. The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
  56. </p>
  57. <h3>[property:String withCredentials]</h3>
  58. <p>
  59. Whether the XMLHttpRequest uses credentials.
  60. Default is *false*.
  61. </p>
  62. <h2>Methods</h2>
  63. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  64. <p>
  65. [page:String url] — the path or URL to the file. This can also be a
  66. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI]..<br />
  67. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded text response.<br />
  68. [page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, which contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
  69. [page:Function onError] — Will be called when load errors.<br />
  70. </p>
  71. <p>
  72. Begin loading from url and pass the <em>JSON</em> to onLoad.
  73. </p>
  74. <h3>[method:null setTexturePath]( [param:String texturePath] )</h3>
  75. <p>
  76. Set the base path or URL from which to load files. This can be useful if
  77. you are loading many files from the same directory.
  78. </p>
  79. <h3>[method:Object3D parse]( [param:Object json], [param:String texturePath] )</h3>
  80. <p>
  81. [page:String json] — JSON object to parse.<br />
  82. [page:String texturePath] — Base path for textures.<br /><br />
  83. Parse a <em>JSON</em> structure and return an [page:object] containing the parsed [page:Geometry geometry] and [page:Array materials].
  84. </p>
  85. <h2>Source</h2>
  86. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  87. </body>
  88. </html>