Rhino3dmLoader.html 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Rhino3dmLoader - Three.js Docs</title>
  6. <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
  7. <script src="../scripts/highlight.min.js"></script>
  8. <link type="text/css" rel="stylesheet" href="../styles/highlight-three.css">
  9. <link type="text/css" rel="stylesheet" href="../styles/page.css">
  10. </head>
  11. <body>
  12. <p class="inheritance" translate="no"><a href="Loader.html">Loader</a> → </p>
  13. <h1 translate="no">Rhino3dmLoader</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A loader for Rhinoceros 3D files and objects.</p>
  17. <p>Rhinoceros is a 3D modeler used to create, edit, analyze, document, render,
  18. animate, and translate NURBS curves, surfaces, breps, extrusions, point clouds,
  19. as well as polygon meshes and SubD objects. <code>rhino3dm.js</code> is compiled to WebAssembly
  20. from the open source geometry library <code>openNURBS</code>. The loader currently uses
  21. <code>rhino3dm.js 8.4.0</code>.</p></div>
  22. <h2>Code Example</h2>
  23. <div translate="no"><pre><code class="language-js">const loader = new Rhino3dmLoader();
  24. loader.setLibraryPath( 'https://cdn.jsdelivr.net/npm/rhino3dm@8.0.1' );
  25. const object = await loader.loadAsync( 'models/3dm/Rhino_Logo.3dm' );
  26. scene.add( object );
  27. </code></pre></div>
  28. </header>
  29. <article>
  30. <h2 class="subsection-title">Import</h2>
  31. <p><span translate="no">Rhino3dmLoader</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank" rel="noopener">Installation#Addons</a>.</p>
  32. <pre><code class="language-js">import { Rhino3dmLoader } from 'three/addons/loaders/3DMLoader.js';</code></pre>
  33. <div class="container-overview">
  34. <h2>Constructor</h2>
  35. <h3 class="name name-method" id="Rhino3dmLoader" translate="no">new <a href="#Rhino3dmLoader">Rhino3dmLoader</a><span class="signature">( manager : <span class="param-type"><a href="LoadingManager.html">LoadingManager</a></span> )</span> </h3>
  36. <div class="method">
  37. <div class="description">
  38. <p>Constructs a new Rhino 3DM loader.</p>
  39. </div>
  40. <table class="params">
  41. <tbody>
  42. <tr>
  43. <td class="name">
  44. <strong>manager</strong>
  45. </td>
  46. <td class="description last">
  47. <p>The loading manager.</p>
  48. </td>
  49. </tr>
  50. </tbody>
  51. </table>
  52. </div>
  53. </div>
  54. <h2 class="subsection-title">Methods</h2>
  55. <h3 class="name name-method" id="debug" translate="no">.<a href="#debug">debug</a><span class="signature">()</span> </h3>
  56. <div class="method">
  57. <div class="description">
  58. <p>Prints debug messages to the browser console.</p>
  59. </div>
  60. </div>
  61. <h3 class="name name-method" id="decodeObjects" translate="no">.<a href="#decodeObjects">decodeObjects</a><span class="signature">( buffer : <span class="param-type">ArrayBuffer</span>, url : <span class="param-type">string</span> )</span><span class="type-signature"> : Promise.&lt;<a href="Object3D.html">Object3D</a>></span> </h3>
  62. <div class="method">
  63. <div class="description">
  64. <p>Decodes the 3DM asset data with a Web Worker.</p>
  65. </div>
  66. <table class="params">
  67. <tbody>
  68. <tr>
  69. <td class="name">
  70. <strong>buffer</strong>
  71. </td>
  72. <td class="description last">
  73. <p>The raw 3DM asset data as an array buffer.</p>
  74. </td>
  75. </tr>
  76. <tr>
  77. <td class="name">
  78. <strong>url</strong>
  79. </td>
  80. <td class="description last">
  81. <p>The asset URL.</p>
  82. </td>
  83. </tr>
  84. </tbody>
  85. </table>
  86. <dl class="details">
  87. <dt class="tag-returns"><strong>Returns:</strong> A Promise that resolved with the decoded 3D object.</dt>
  88. </dl>
  89. </div>
  90. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  91. <div class="method">
  92. <div class="description">
  93. <p>Frees internal resources. This method should be called
  94. when the loader is no longer required.</p>
  95. </div>
  96. </div>
  97. <h3 class="name name-method" id="load" translate="no">.<a href="#load">load</a><span class="signature">( url : <span class="param-type">string</span>, onLoad : <span class="param-type">function</span>, onProgress : <span class="param-type"><a href="global.html#onProgressCallback">onProgressCallback</a></span>, onError : <span class="param-type"><a href="global.html#onErrorCallback">onErrorCallback</a></span> )</span> </h3>
  98. <div class="method">
  99. <div class="description">
  100. <p>Starts loading from the given URL and passes the loaded 3DM asset
  101. to the <code>onLoad()</code> callback.</p>
  102. </div>
  103. <table class="params">
  104. <tbody>
  105. <tr>
  106. <td class="name">
  107. <strong>url</strong>
  108. </td>
  109. <td class="description last">
  110. <p>The path/URL of the file to be loaded. This can also be a data URI.</p>
  111. </td>
  112. </tr>
  113. <tr>
  114. <td class="name">
  115. <strong>onLoad</strong>
  116. </td>
  117. <td class="description last">
  118. <p>Executed when the loading process has been finished.</p>
  119. </td>
  120. </tr>
  121. <tr>
  122. <td class="name">
  123. <strong>onProgress</strong>
  124. </td>
  125. <td class="description last">
  126. <p>Executed while the loading is in progress.</p>
  127. </td>
  128. </tr>
  129. <tr>
  130. <td class="name">
  131. <strong>onError</strong>
  132. </td>
  133. <td class="description last">
  134. <p>Executed when errors occur.</p>
  135. </td>
  136. </tr>
  137. </tbody>
  138. </table>
  139. <dl class="details">
  140. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
  141. </dl>
  142. </div>
  143. <h3 class="name name-method" id="parse" translate="no">.<a href="#parse">parse</a><span class="signature">( data : <span class="param-type">ArrayBuffer</span>, onLoad : <span class="param-type">function</span>, onError : <span class="param-type"><a href="global.html#onErrorCallback">onErrorCallback</a></span> )</span> </h3>
  144. <div class="method">
  145. <div class="description">
  146. <p>Parses the given 3DM data and passes the loaded 3DM asset
  147. to the <code>onLoad()</code> callback.</p>
  148. </div>
  149. <table class="params">
  150. <tbody>
  151. <tr>
  152. <td class="name">
  153. <strong>data</strong>
  154. </td>
  155. <td class="description last">
  156. <p>The raw 3DM asset data as an array buffer.</p>
  157. </td>
  158. </tr>
  159. <tr>
  160. <td class="name">
  161. <strong>onLoad</strong>
  162. </td>
  163. <td class="description last">
  164. <p>Executed when the loading process has been finished.</p>
  165. </td>
  166. </tr>
  167. <tr>
  168. <td class="name">
  169. <strong>onError</strong>
  170. </td>
  171. <td class="description last">
  172. <p>Executed when errors occur.</p>
  173. </td>
  174. </tr>
  175. </tbody>
  176. </table>
  177. <dl class="details">
  178. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#parse">Loader#parse</a></dt>
  179. </dl>
  180. </div>
  181. <h3 class="name name-method" id="setLibraryPath" translate="no">.<a href="#setLibraryPath">setLibraryPath</a><span class="signature">( path : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="Rhino3dmLoader.html">Rhino3dmLoader</a></span> </h3>
  182. <div class="method">
  183. <div class="description">
  184. <p>Path to a folder containing the JS and WASM libraries.</p>
  185. </div>
  186. <table class="params">
  187. <tbody>
  188. <tr>
  189. <td class="name">
  190. <strong>path</strong>
  191. </td>
  192. <td class="description last">
  193. <p>The library path to set.</p>
  194. </td>
  195. </tr>
  196. </tbody>
  197. </table>
  198. <dl class="details">
  199. <dt class="tag-returns"><strong>Returns:</strong> A reference to this loader.</dt>
  200. </dl>
  201. </div>
  202. <h3 class="name name-method" id="setWorkerLimit" translate="no">.<a href="#setWorkerLimit">setWorkerLimit</a><span class="signature">( workerLimit : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="Rhino3dmLoader.html">Rhino3dmLoader</a></span> </h3>
  203. <div class="method">
  204. <div class="description">
  205. <p>Sets the maximum number of Web Workers to be used during decoding.
  206. A lower limit may be preferable if workers are also for other
  207. tasks in the application.</p>
  208. </div>
  209. <table class="params">
  210. <tbody>
  211. <tr>
  212. <td class="name">
  213. <strong>workerLimit</strong>
  214. </td>
  215. <td class="description last">
  216. <p>The worker limit.</p>
  217. </td>
  218. </tr>
  219. </tbody>
  220. </table>
  221. <dl class="details">
  222. <dt class="tag-returns"><strong>Returns:</strong> A reference to this loader.</dt>
  223. </dl>
  224. </div>
  225. <h2 class="subsection-title">Source</h2>
  226. <p>
  227. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/3DMLoader.js" translate="no" target="_blank" rel="noopener">examples/jsm/loaders/3DMLoader.js</a>
  228. </p>
  229. </article>
  230. </section>
  231. <script src="../scripts/linenumber.js"></script>
  232. <script src="../scripts/page.js"></script>
  233. </body>
  234. </html>
粤ICP备19079148号