GLTFLoader.html 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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">
  14. A loader for loading a *gltf* resource in JSON format.
  15. <br /><br />
  16. The <a href="https://www.khronos.org/gltf">glTF file format</a> is a JSON file format to enable rapid delivery and loading of 3D content.
  17. </div>
  18. <h2>Notes</h2>
  19. <div>
  20. When using custom shaders provided within a glTF file [page:THREE.GLTFLoader.Shaders] should be updated on each render loop. See [example:webgl_loader_gltf] demo source code for example usage.
  21. </div>
  22. <h2>Example</h2>
  23. <code>
  24. // instantiate a loader
  25. var loader = new THREE.GLTFLoader();
  26. // load a glTF resource
  27. loader.load(
  28. // resource URL
  29. 'models/gltf/duck/duck.json',
  30. // Function when resource is loaded
  31. function ( object ) {
  32. scene.add( object.scene );
  33. }
  34. );
  35. </code>
  36. [example:webgl_loader_gltf]
  37. <h2>Constructor</h2>
  38. <h3>[name]( [page:LoadingManager manager] )</h3>
  39. <div>
  40. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  41. </div>
  42. <div>
  43. Creates a new [name].
  44. </div>
  45. <h2>Properties</h2>
  46. <h2>Methods</h2>
  47. <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  48. <div>
  49. [page:String url] — required<br />
  50. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded JSON response returned from [page:Function parse].<br />
  51. [page:Function onProgress] — Will be called while load progresses. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
  52. [page:Function onError] — Will be called when load errors.<br />
  53. </div>
  54. <div>
  55. Begin loading from url and call the callback function with the parsed response content.
  56. </div>
  57. <h3>[method:null setPath]( [page:String path] )</h3>
  58. <div>
  59. [page:String path] — Base path for loading additional resources e.g. textures, GLSL shaders, .bin data.
  60. </div>
  61. <div>
  62. Set the base path for additional resources.
  63. </div>
  64. <h3>[method:null setCrossOrigin]( [page:String value] )</h3>
  65. <div>
  66. [page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
  67. </div>
  68. <h3>[method:null parse]( [page:Object json], [page:Function callBack], [page:String path] )</h3>
  69. <div>
  70. [page:Object json] — <em>JSON</em> object to parse.<br />
  71. [page:Function callBack] — Will be called when parse completes.<br />
  72. [page:String path] — The base path from which to find subsequent glTF resources such as textures, GLSL shaders and .bin data files.<br />
  73. </div>
  74. <div>
  75. Parse a glTF-based <em>JSON</em> structure and fire [page:Function callback] when complete. The argument to [page:Function callback] will be an [page:object] that contains loaded parts: .[page:Scene scene], .[page:Array cameras], .[page:Array animations] and .[page:Array shaders]
  76. </div>
  77. <h2>Source</h2>
  78. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/GLTFLoader.js examples/js/loaders/GLTFLoader.js]
  79. </body>
  80. </html>