3DMLoader.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 Rhinoceros 3d files and objects. <br /><br />
  14. 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.
  15. [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].
  16. Currently uses rhino3dm.js 0.13.0
  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] <sup>1</sup></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] <sup> 2</sup></td>
  50. </tr>
  51. <tr>
  52. <td>BREP</td>
  53. <td>[page:Object3D Object3D] <sup>2, 3</sup></td>
  54. </tr>
  55. <tr>
  56. <td>SubD</td>
  57. <td>[page:Mesh Mesh] <sup>4</sup></td>
  58. </tr>
  59. <tr>
  60. <td>InstanceReferences</td>
  61. <td>[page:Object3D Object3D]</td>
  62. </tr>
  63. <tr>
  64. <td>DirectionalLight</td>
  65. <td>[page:DirectionalLight DirectionalLight]</td>
  66. </tr>
  67. <tr>
  68. <td>PointLight</td>
  69. <td>[page:PointLight PointLight]</td>
  70. </tr>
  71. <tr>
  72. <td>RectangularLight</td>
  73. <td>[page:RectAreaLight RectAreaLight]</td>
  74. </tr>
  75. <tr>
  76. <td>SpotLight</td>
  77. <td>[page:SpotLight SpotLight]</td>
  78. </tr>
  79. </table>
  80. <p><i>
  81. <sup>1</sup> NURBS curves are discretized to a hardcoded resolution.
  82. </i></p>
  83. <p><i>
  84. <sup>2</sup> Types which are based on BREPs and NURBS surfaces are represented with their "Render Mesh".
  85. </i></p>
  86. <p><i>
  87. <sup>3</sup> BREPS are converted to an Object3D with it's children array populated with BREP Faces
  88. </i></p>
  89. <p><i>
  90. <sup>4</sup> SubD objects are represented by subdividing their control net.
  91. </i></p>
  92. <h2>Code Example</h2>
  93. <code>
  94. // Instantiate a loader
  95. const loader = new Rhino3dmLoader();
  96. // Specify path to a folder containing WASM/JS libraries.
  97. loader.setLibraryPath( '/examples/jsm/libs/rhino3dm/' );
  98. // Load a 3DM file
  99. loader.load(
  100. // resource URL
  101. 'model.3dm',
  102. // called when the resource is loaded
  103. function ( object ) {
  104. scene.add( object );
  105. },
  106. // called as loading progresses
  107. function ( xhr ) {
  108. console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
  109. },
  110. // called when loading has errors
  111. function ( error ) {
  112. console.log( 'An error happened' );
  113. }
  114. );
  115. </code>
  116. <h2>Examples</h2>
  117. <p>
  118. [example:webgl_loader_3dm]
  119. </p>
  120. <hr>
  121. <h2>Constructor</h2>
  122. <h3>Rhino3dmLoader( [param:LoadingManager manager] )</h3>
  123. <p>
  124. [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager].
  125. </p>
  126. <p>
  127. Creates a new Rhino3dmLoader.
  128. </p>
  129. <h2>Properties</h2>
  130. <p>See the base [page:Loader] class for common properties.</p>
  131. <h2>Methods</h2>
  132. <p>See the base [page:Loader] class for common methods.</p>
  133. <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3>
  134. <p>
  135. [page:String url] — A string containing the path/URL of the <em>.3dm</em> file.<br />
  136. [page:Function onLoad] — A function to be called after the loading is successfully completed.<br />
  137. [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 />
  138. [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br />
  139. </p>
  140. <p>
  141. Begin loading from url and call the <em>onLoad</em> function with the geometry.
  142. </p>
  143. <h3>[method:this setLibraryPath]( [param:String value] )</h3>
  144. <p>
  145. [page:String value] — Path to folder containing the JS and WASM libraries.
  146. </p>
  147. <h3>[method:this setWorkerLimit]( [param:Number workerLimit] )</h3>
  148. <p>
  149. [page:Number workerLimit] - Maximum number of workers to be allocated. Default is 4.<br />
  150. </p>
  151. <p>
  152. Sets the maximum number of [link:https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers Web Workers]
  153. to be used during decoding. A lower limit may be preferable if workers are also for other tasks
  154. in the application.
  155. </p>
  156. <h3>[method:this dispose]()</h3>
  157. <p>
  158. Disposes of the loader resources and deallocates memory.
  159. </p>
  160. <h2>Source</h2>
  161. <p>
  162. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/3DMLoader.js examples/jsm/loaders/3DMLoader.js]
  163. </p>
  164. </body>
  165. </html>