3DMLoader.html 5.2 KB

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