BufferGeometryLoader.html 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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>Examples</h2>
  41. <p>[example:webgl_performance WebGL / performance]</p>
  42. <h2>Constructor</h2>
  43. <h3>[name]( [param:LoadingManager manager] )</h3>
  44. <p>
  45. [page:LoadingManager manager] — The [page:LoadingManager loadingManager]
  46. for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  47. </p>
  48. <p>Creates a new [name].</p>
  49. <h2>Properties</h2>
  50. <p>See the base [page:Loader] class for common properties.</p>
  51. <h2>Methods</h2>
  52. <p>See the base [page:Loader] class for common methods.</p>
  53. <h3>
  54. [method:undefined load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )
  55. </h3>
  56. <p>
  57. [page:String url] — the path or URL to the file. This can also be a
  58. [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].d<br />
  59. [page:Function onLoad] — Will be called when load completes. The argument
  60. will be the loaded [page:BufferGeometry].<br />
  61. [page:Function onProgress] (optional) — Will be called while load
  62. progresses. The argument will be the ProgressEvent instance, which
  63. contains .[page:Boolean lengthComputable], .[page:Integer total] and
  64. .[page:Integer loaded]. If the server does not set the Content-Length
  65. header; .[page:Integer total] will be 0.<br />
  66. [page:Function onError] (optional) — Will be called when load errors.<br />
  67. </p>
  68. <p>
  69. Begin loading from url and call onLoad with the parsed response content.
  70. </p>
  71. <h3>[method:BufferGeometry parse]( [param:Object json] )</h3>
  72. <p>
  73. [page:Object json] — The `JSON` structure to parse.<br /><br />
  74. Parse a `JSON` structure and return a [page:BufferGeometry].
  75. </p>
  76. <h2>Source</h2>
  77. <p>
  78. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  79. </p>
  80. </body>
  81. </html>