GLTFLoader.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 <em>.gltf</em> resource in <em>JSON</em> 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>Constructor</h2>
  19. <h3>[name]( [page:LoadingManager manager] )</h3>
  20. <div>
  21. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  22. </div>
  23. <div>
  24. Creates a new [name].
  25. </div>
  26. <h2>Properties</h2>
  27. <h2>Methods</h2>
  28. <h3>[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )</h3>
  29. <div>
  30. [page:String url] — required<br />
  31. [page:Function onLoad] — Will be called when load completes. The argument will be the loaded JSON response returned from [page:Function parse].<br />
  32. [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 />
  33. [page:Function onError] — Will be called when load errors.<br />
  34. </div>
  35. <div>
  36. Begin loading from url and call the callback function with the parsed response content.
  37. </div>
  38. <h3>[method:null setPath]( [page:String path] )</h3>
  39. <div>
  40. [page:String path] — Base path for loading additional resources e.g. textures, GLSL shaders, .bin data.
  41. </div>
  42. <div>
  43. Set the base path for additional resources.
  44. </div>
  45. <h3>[method:null setCrossOrigin]( [page:String value] )</h3>
  46. <div>
  47. [page:String value] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS.
  48. </div>
  49. <h3>[method:null parse]( [page:Object json], [page:Function callBack], [page:String path] )</h3>
  50. <div>
  51. [page:Object json] — <em>JSON</em> object to parse.<br />
  52. [page:Function callBack] — Will be called when parse completes.<br />
  53. [page:String path] — The base path from which to find subsequent glTF resources such as textures, GLSL shaders and .bin data files.<br />
  54. </div>
  55. <div>
  56. 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]
  57. </div>
  58. <h2>Notes</h2>
  59. <div>
  60. 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.
  61. </div>
  62. <div>
  63. This class is often used with [page:THREE.GLTFLoader.Animations THREE.GLTFLoader.Animations] to animate parsed animations. See [example:webgl_loader_gltf] demo source code for example usage.
  64. </div>
  65. <h2>Example</h2>
  66. <code>
  67. // instantiate a loader
  68. var loader = new THREE.GLTFLoader();
  69. // load a glTF resource
  70. loader.load(
  71. // resource URL
  72. 'models/gltf/duck/duck.json',
  73. // Function when resource is loaded
  74. function ( object ) {
  75. scene.add( object.scene );
  76. }
  77. );
  78. </code>
  79. [example:webgl_loader_gltf]
  80. <h2>Source</h2>
  81. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/GLTFLoader.js examples/js/loaders/GLTFLoader.js]
  82. </body>
  83. </html>