PRWMLoader.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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>.prwm</em> resource.<br />
  14. Packed Raw WebGL Model is an open-source binary file format for nD geometries specifically designed for
  15. JavaScript and WebGL with a strong focus on fast parsing (from 1ms to 0.1ms in Chrome 59
  16. on a MBP Late 2013). The parsing of PRWM file is especially fast when the endianness of the file is
  17. the same as the endianness of the client platform. More information
  18. on this <a href="https://github.com/kchapelier/PRWM">here</a>.
  19. </p>
  20. <h2>Example</h2>
  21. <code>
  22. // instantiate a loader
  23. var loader = new THREE.PRWMLoader();
  24. // load a resource
  25. loader.load(
  26. // resource URL
  27. 'models/nefertiti.le.prwm',
  28. // called when resource is loaded
  29. function ( bufferGeometry ) {
  30. var object = new THREE.Mesh( bufferGeometry, new THREE.MeshNormalMaterial() );
  31. scene.add( object );
  32. },
  33. // called when loading is in progresses
  34. function ( xhr ) {
  35. console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
  36. },
  37. // called when loading has errors
  38. function ( error ) {
  39. console.log( 'An error happened' );
  40. }
  41. );
  42. </code>
  43. [example:webgl_loader_prwm]
  44. <h2>Constructor</h2>
  45. <h3>[name]( [param:LoadingManager manager] )</h3>
  46. <p>
  47. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  48. </p>
  49. <p>
  50. Creates a new [name].
  51. </p>
  52. <h2>Properties</h2>
  53. <p>See the base [page:Loader] class for common properties.</p>
  54. <h2>Methods</h2>
  55. <p>See the base [page:Loader] class for common methods.</p>
  56. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  57. <p>
  58. [page:String url] — A string containing the path/URL of the <em>.prwm</em> file. Any <em>*</em> character in the URL will be automatically replaced by <em>le</em> or <em>be</em> depending on the platform endianness.<br />
  59. [page:Function onLoad] — (optional) A function to be called after the loading is successfully completed. The function receives the loaded [page:BufferGeometry] as an argument.<br />
  60. [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The function receives a XMLHttpRequest instance, which contains [page:Integer total] and [page:Integer loaded] bytes.<br />
  61. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
  62. </p>
  63. <p>
  64. Begin loading from url and call onLoad with the parsed response content.
  65. </p>
  66. <h3>[method:BufferGeometry parse]( [param:ArrayBuffer arrayBuffer] )</h3>
  67. <p>
  68. [page:ArrayBuffer arrayBuffer] — ArrayBuffer containing the <em>prwm</em> data.
  69. </p>
  70. <p>
  71. Parse a <em>prwm</em> file passed as an ArrayBuffer and directly return an instance of [page:BufferGeometry].
  72. </p>
  73. <h3>PRWMLoader.isBigEndianPlatform( )</h3>
  74. <p>
  75. Return true if the endianness of the platform is Big Endian, false otherwise.
  76. </p>
  77. <h2>Source</h2>
  78. <p>
  79. [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/PRWMLoader.js examples/js/loaders/PRWMLoader.js]
  80. </p>
  81. </body>
  82. </html>