2
0

JSONLoader.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. [page:Loader] &rarr;
  12. <h1>[name]</h1>
  13. <div class="desc">A loader for loading objects in JSON format.</div>
  14. <h2>Constructor</h2>
  15. <h3>[name]()</h3>
  16. <div>
  17. Creates a new [name].
  18. </div>
  19. <h2>Properties</h2>
  20. <h3>[property:boolean withCredentials]</h3>
  21. <div>
  22. If true, the ajax request will use cookies.
  23. </div>
  24. <h2>Methods</h2>
  25. <h3>[method:null load]( [page:String url], [page:Function callback], [page:String texturePath] )</h3>
  26. <div>
  27. [page:String url] — required<br />
  28. [page:Function callback] — required. Will be called when load completes. The arguments will be the loaded [page:Object3D] and the loaded [page:Array materials].<br />
  29. [page:String texturePath] — optional. If not specified, textures will be assumed to be in the same folder as the Javascript model file.
  30. </div>
  31. <h3>[method:null loadAjaxJSON]([page:JSONLoader context], [page:String url], [page:Function callback], [page:String texturePath], [page:Function callbackProgress])</h3>
  32. <div>
  33. [page:JSONLoader context] — The [page:JSONLoader] instance<br />
  34. [page:String url] — required<br />
  35. [page:Function callback] — required. This function will be called with the loaded model as an instance of [page:Geometry geometry] when the load is completed.<br />
  36. [page:String texturePath] — Base path for textures.<br />
  37. [page:Function callbackProgress] — Will be called while load progresses. The argument will be an [page:Object] containing two attributes: .[page:Integer total] and .[page:Integer loaded] bytes.
  38. </div>
  39. <div>
  40. Begin loading from url and call <em>callback</em> with the parsed response content.
  41. </div>
  42. <h3>[method:Object3D parse]( [page:Object json], [page:String texturePath] )</h3>
  43. <div>
  44. [page:String json] — JSON object to parse.<br />
  45. [page:String texturePath] — Base path for textures.
  46. </div>
  47. <div>
  48. Parse a <em>JSON</em> structure and return an [page:Object] containing the parsed .[page:Geometry] and .[page:Array materials].
  49. </div>
  50. <h2>Example</h2>
  51. <code>
  52. // instantiate a loader
  53. var loader = new THREE.JSONLoader();
  54. // load a resource
  55. loader.load(
  56. // resource URL
  57. 'models/animated/monster/monster.js',
  58. // Function when resource is loaded
  59. function ( geometry, materials ) {
  60. var material = new THREE.MeshFaceMaterial( materials );
  61. var object = new THREE.Mesh( geometry, material );
  62. scene.add( object );
  63. }
  64. );
  65. </code>
  66. [example:webgl_loader_json_blender]
  67. <h2>Source</h2>
  68. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  69. </body>
  70. </html>