2
0

JSONLoader.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 WebGL / loader / json]
  19. </p>
  20. <code>
  21. // instantiate a loader
  22. var loader = new THREE.JSONLoader();
  23. // load a resource
  24. loader.load(
  25. // resource URL
  26. 'models/animated/monster/monster.js',
  27. // onLoad callback
  28. function ( geometry, materials ) {
  29. var material = materials[ 0 ];
  30. var object = new THREE.Mesh( geometry, material );
  31. scene.add( object );
  32. },
  33. // onProgress callback
  34. function ( xhr ) {
  35. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  36. },
  37. // onError callback
  38. function( err ) {
  39. console.log( 'An error happened' );
  40. }
  41. );
  42. </code>
  43. <h2>Constructor</h2>
  44. <h3>[name]( [param:LoadingManager manager] )</h3>
  45. <p>
  46. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  47. </p>
  48. <p>
  49. Creates a new [name].
  50. </p>
  51. <h2>Properties</h2>
  52. <h3>[property:String crossOrigin]</h3>
  53. <p>
  54. If set, assigns the [link:https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes crossOrigin]
  55. attribute of the image to the value of *crossOrigin*, prior to starting the load. Default is *"anonymous"*.
  56. </p>
  57. <h3>[property:LoadingManager manager]</h3>
  58. <p>
  59. The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].
  60. </p>
  61. <h3>[property:String withCredentials]</h3>
  62. <p>
  63. Whether the XMLHttpRequest uses credentials.
  64. Default is *false*.
  65. </p>
  66. <h2>Methods</h2>
  67. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  68. <p>
  69. [page:String url] — the path or URL to the file. This can also be a
  70. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI]..<br />
  71. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded text response.<br />
  72. [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 />
  73. [page:Function onError] — Will be called when load errors.<br />
  74. </p>
  75. <p>
  76. Begin loading from url and pass the <em>JSON</em> to onLoad.
  77. </p>
  78. <h3>[method:Object3D parse]( [param:Object json], [param:String path] )</h3>
  79. <p>
  80. [page:String json] — JSON object to parse.<br />
  81. [page:String path] — Base path for resources if no resource path is defined.<br /><br />
  82. Parse a <em>JSON</em> structure and return an [page:object] containing the parsed [page:Geometry geometry] and [page:Array materials].
  83. </p>
  84. <h3>[method:JSONLoader setCrossOrigin]( [param:String value] )</h3>
  85. <p>
  86. Set the [page:.crossOrigin] attribute.
  87. </p>
  88. <h3>[method:JSONLoader setPath]( [param:String value] )</h3>
  89. <p>
  90. Set the base path for the original file.
  91. </p>
  92. <h3>[method:JSONLoader setResourcePath]( [param:String value] )</h3>
  93. <p>
  94. Set the base path for dependent resources like textures.
  95. </p>
  96. <h2>Source</h2>
  97. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  98. </body>
  99. </html>