GLTFLoader.html 3.6 KB

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