3DMLoader.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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">
  14. A loader for Rhinoceros 3d files and objects. <br /><br />
  15. Rhinoceros is a 3D modeler used to create, edit, analyze, document, render, animate, and translate NURBS curves, surfaces, solids, point clouds, as well as polygon meshes and SubD objects.
  16. [link:https://github.com/mcneel/rhino3dm rhino3dm.js] is compiled to WebAssembly from the open source geometry library [link:https://github.com/mcneel/opennurbs openNURBS].
  17. </p>
  18. <h2>Supported Conversions</h2>
  19. <p>
  20. [name] loads the following objects to a respective three.js type:
  21. </p>
  22. <table>
  23. <tr>
  24. <th>3dm type</th>
  25. <th>three.js type</th>
  26. </tr>
  27. <tr>
  28. <td>Point</td>
  29. <td>[page:Points Points]</td>
  30. </tr>
  31. <tr>
  32. <td>PointSet</td>
  33. <td>[page:Points Points]</td>
  34. </tr>
  35. <tr>
  36. <td>TextDot</td>
  37. <td>[page:Sprite Sprite]</td>
  38. </tr>
  39. <tr>
  40. <td>Curve</td>
  41. <td>[page:Line Line]</td>
  42. </tr>
  43. <tr>
  44. <td>Mesh</td>
  45. <td>[page:Mesh Mesh]</td>
  46. </tr>
  47. <tr>
  48. <td>Extrusion</td>
  49. <td>[page:Mesh Mesh]</td>
  50. </tr>
  51. <tr>
  52. <td>BREP</td>
  53. <td>[page:Object3D Object3D]</td>
  54. </tr>
  55. <tr>
  56. <td>InstanceReferences</td>
  57. <td>[page:Object3D Object3D]</td>
  58. </tr>
  59. <tr>
  60. <td>DirectionalLight</td>
  61. <td>[page:DirectionalLight DirectionalLight]</td>
  62. </tr>
  63. <tr>
  64. <td>PointLight</td>
  65. <td>[page:PointLight PointLight]</td>
  66. </tr>
  67. <tr>
  68. <td>RectangularLight</td>
  69. <td>[page:RectAreaLight RectAreaLight]</td>
  70. </tr>
  71. <tr>
  72. <td>SpotLight</td>
  73. <td>[page:SpotLight SpotLight]</td>
  74. </tr>
  75. </table>
  76. <h2>Code Example</h2>
  77. <code>
  78. // Instantiate a loader
  79. var loader = new Rhino3dmLoader();
  80. // Specify path to a folder containing WASM/JS libraries.
  81. loader.setLibraryPath( '/examples/jsm/libs/rhino3dm/' );
  82. // Load a 3DM file
  83. loader.load(
  84. // resource URL
  85. 'model.3dm',
  86. // called when the resource is loaded
  87. function ( object ) {
  88. scene.add( object );
  89. },
  90. // called as loading progresses
  91. function ( xhr ) {
  92. console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
  93. },
  94. // called when loading has errors
  95. function ( error ) {
  96. console.log( 'An error happened' );
  97. }
  98. );
  99. </code>
  100. <h2>Examples</h2>
  101. <p>
  102. [example:webgl_loader_3dm]
  103. </p>
  104. <hr>
  105. <h2>Constructor</h2>
  106. <h3>Rhino3dmLoader( [param:LoadingManager manager] )</h3>
  107. <p>
  108. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  109. </p>
  110. <p>
  111. Creates a new Rhino3dmLoader.
  112. </p>
  113. <h2>Properties</h2>
  114. <p>See the base [page:Loader] class for common properties.</p>
  115. <h2>Methods</h2>
  116. <p>See the base [page:Loader] class for common methods.</p>
  117. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  118. <p>
  119. [page:String url] — A string containing the path/URL of the <em>.3dm</em> file.<br />
  120. [page:Function onLoad] — A function to be called after the loading is successfully completed.<br />
  121. [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br />
  122. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
  123. </p>
  124. <p>
  125. Begin loading from url and call the <em>onLoad</em> function with the geometry.
  126. </p>
  127. <h3>[method:this setLibraryPath]( [param:String value] )</h3>
  128. <p>
  129. [page:String value] — Path to folder containing the JS and WASM libraries.
  130. </p>
  131. <h3>[method:this setWorkerLimit]( [param:Number workerLimit] )</h3>
  132. <p>
  133. [page:Number workerLimit] - Maximum number of workers to be allocated. Default is 4.<br />
  134. </p>
  135. <p>
  136. Sets the maximum number of [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers Web Workers]
  137. to be used during decoding. A lower limit may be preferable if workers are also for other tasks
  138. in the application.
  139. </p>
  140. <h3>[method:this dispose]()</h3>
  141. <p>
  142. Disposes of the loader resources and deallocates memory.
  143. </p>
  144. <h2>Source</h2>
  145. <p>
  146. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/3DMLoader.js examples/jsm/loaders/3DMLoader.js]
  147. </p>
  148. </body>
  149. </html>