BabylonLoader.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. <p class="desc">A loader for loading a <em>.babylon</em> resource. <br />
  14. The <a href="https://doc.babylonjs.com/generals/file_format_map_(.babylon)"> .babylon </a> file format used by
  15. <a href="https://www.babylonjs.com/">Babylon.js</a>.
  16. </p>
  17. <h2>Example</h2>
  18. <code>
  19. // instantiate a loader
  20. var loader = new THREE.BabylonLoader();
  21. // load a Babylon resource
  22. loader.load(
  23. // resource URL
  24. 'models/babylon/skull.babylon',
  25. // called when resource is loaded
  26. function ( object ) {
  27. scene.add( object );
  28. },
  29. // called when loading is in progress
  30. function ( xhr ) {
  31. console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
  32. },
  33. // called when loading has errors
  34. function ( xhr ) {
  35. console.log( 'An error happened' );
  36. }
  37. );
  38. </code>
  39. [example:webgl_loader_babylon]
  40. <h2>Constructor</h2>
  41. <h3>[name]( [param:LoadingManager manager] )</h3>
  42. <p>
  43. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  44. </p>
  45. <p>
  46. Creates a new [name].
  47. </p>
  48. <h2>Properties</h2>
  49. <p>See the base [page:Loader] class for common properties.</p>
  50. <h2>Methods</h2>
  51. <p>See the base [page:Loader] class for common methods.</p>
  52. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  53. <p>
  54. [page:String url] — A string containing the path/URL of the <em>.babylon</em> file.<br />
  55. [page:function onLoad] — (optional) A function to be called after loading is successfully completed. The function receives the loaded [page:Object3D] as an argument.<br />
  56. [page:function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, which contains [page:Integer total] and [page:Integer loaded] bytes.<br />
  57. [page:function onError] — (optional) A function to be called if an error occurs during loading. The function receives the error as an argument.<br />
  58. </p>
  59. <p>
  60. Begin loading from url and call onLoad with the parsed response content.
  61. </p>
  62. <h3>[method:Object3D parse]( [param:Object json] )</h3>
  63. <p>
  64. [page:Object json] — The <em>JSON</em> structure to parse.
  65. </p>
  66. <p>
  67. Parse a <em>JSON</em> structure and return an [page:Object3D object] or a [page:Scene scene].<br />
  68. Found objects are converted to [page:Mesh] with a [page:BufferGeometry] and a default [page:MeshPhongMaterial].<br />
  69. Lights are parsed accordingly.
  70. </p>
  71. <h2>Source</h2>
  72. <p>
  73. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/BabylonLoader.js examples/js/loaders/BabylonLoader.js]
  74. </p>
  75. </body>
  76. </html>