JSONLoader.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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:Object3D parse]( [page:Object json], [page:String texturePath] )</h3>
  32. <div>
  33. [page:String json] — JSON object to parse.<br />
  34. [page:String texturePath] — Base path for textures.
  35. </div>
  36. <div>
  37. Parse a <em>JSON</em> structure and return an [page:Object] containing the parsed .[page:Geometry] and .[page:Array materials].
  38. </div>
  39. <h2>Example</h2>
  40. <code>
  41. // instantiate a loader
  42. var loader = new THREE.JSONLoader();
  43. // load a resource
  44. loader.load(
  45. // resource URL
  46. 'models/animated/monster/monster.js',
  47. // Function when resource is loaded
  48. function ( geometry, materials ) {
  49. var material = new THREE.MeshFaceMaterial( materials );
  50. var object = new THREE.Mesh( geometry, material );
  51. scene.add( object );
  52. }
  53. );
  54. </code>
  55. [example:webgl_loader_json_blender]
  56. <h2>Source</h2>
  57. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  58. </body>
  59. </html>