BufferGeometryLoader.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. [page:Loader] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. A loader for loading a [page:BufferGeometry]. This uses the
  14. [page:FileLoader] internally for loading files.
  15. </p>
  16. <h2>Code Example</h2>
  17. <code>
  18. // instantiate a loader
  19. const loader = new THREE.BufferGeometryLoader();
  20. // load a resource
  21. loader.load(
  22. // resource URL
  23. 'models/json/pressure.json',
  24. // onLoad callback
  25. function ( geometry ) {
  26. const material = new THREE.MeshLambertMaterial( { color: 0xF5F5F5 } );
  27. const object = new THREE.Mesh( geometry, material );
  28. scene.add( object );
  29. },
  30. // onProgress callback
  31. function ( xhr ) {
  32. console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
  33. },
  34. // onError callback
  35. function ( err ) {
  36. console.log( 'An error happened' );
  37. }
  38. );
  39. </code>
  40. <h2>Constructor</h2>
  41. <h3>[name]( [param:LoadingManager manager] )</h3>
  42. <p>
  43. [page:LoadingManager manager] — The [page:LoadingManager loadingManager]
  44. for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  45. </p>
  46. <p>Creates a new [name].</p>
  47. <h2>Properties</h2>
  48. <p>See the base [page:Loader] class for common properties.</p>
  49. <h2>Methods</h2>
  50. <p>See the base [page:Loader] class for common methods.</p>
  51. <h3>
  52. [method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )
  53. </h3>
  54. <p>
  55. [page:String url] — the path or URL to the file. This can also be a
  56. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].d<br />
  57. [page:Function onLoad] — Will be called when load completes. The argument
  58. will be the loaded [page:BufferGeometry].<br />
  59. [page:Function onProgress] (optional) — Will be called while load
  60. progresses. The argument will be the ProgressEvent instance, which
  61. contains .[page:Boolean lengthComputable], .[page:Integer total] and
  62. .[page:Integer loaded]. If the server does not set the Content-Length
  63. header; .[page:Integer total] will be 0.<br />
  64. [page:Function onError] (optional) — Will be called when load errors.<br />
  65. </p>
  66. <p>
  67. Begin loading from url and call onLoad with the parsed response content.
  68. </p>
  69. <h3>[method:BufferGeometry parse]( [param:Object json] )</h3>
  70. <p>
  71. [page:Object json] — The `JSON` structure to parse.<br /><br />
  72. Parse a `JSON` structure and return a [page:BufferGeometry].
  73. </p>
  74. <h2>Source</h2>
  75. <p>
  76. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  77. </p>
  78. </body>
  79. </html>