GCodeLoader.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>GCodeLoader - 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">GCodeLoader</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A loader for the GCode format.</p>
  17. <p>GCode files are usually used for 3D printing or CNC applications.</p></div>
  18. <h2>Code Example</h2>
  19. <div translate="no"><pre><code class="language-js">const loader = new GCodeLoader();
  20. const object = await loader.loadAsync( 'models/gcode/benchy.gcode' );
  21. scene.add( object );
  22. </code></pre></div>
  23. </header>
  24. <article>
  25. <h2 class="subsection-title">Import</h2>
  26. <p><span translate="no">GCodeLoader</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
  27. <pre><code class="language-js">import { GCodeLoader } from 'three/addons/loaders/GCodeLoader.js';</code></pre>
  28. <div class="container-overview">
  29. <h2>Constructor</h2>
  30. <h3 class="name name-method" id="GCodeLoader" translate="no">new <a href="#GCodeLoader">GCodeLoader</a><span class="signature">( manager : <span class="param-type">LoadingManager</span> )</span> </h3>
  31. <div class="method">
  32. <div class="description">
  33. <p>Constructs a new GCode loader.</p>
  34. </div>
  35. <table class="params">
  36. <tbody>
  37. <tr>
  38. <td class="name"><code>manager</code></td>
  39. <td class="description last"><p>The loading manager.</p></td>
  40. </tr>
  41. </tbody>
  42. </table>
  43. </div>
  44. </div>
  45. <h2 class="subsection-title">Properties</h2>
  46. <div class="member">
  47. <h3 class="name" id="splitLayer" translate="no">.<a href="#splitLayer">splitLayer</a><span class="type-signature"> : boolean</span> </h3>
  48. <div class="description">
  49. <p>Whether to split layers or not.<br/>Default is <code>false</code>.</p>
  50. </div>
  51. </div>
  52. <h2 class="subsection-title">Methods</h2>
  53. <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">onProgressCallback</span>, onError : <span class="param-type">onErrorCallback</span> )</span> </h3>
  54. <div class="method">
  55. <div class="description">
  56. <p>Starts loading from the given URL and passes the loaded GCode asset
  57. to the <code>onLoad()</code> callback.</p>
  58. </div>
  59. <table class="params">
  60. <tbody>
  61. <tr>
  62. <td class="name"><code>url</code></td>
  63. <td class="description last"><p>The path/URL of the file to be loaded. This can also be a data URI.</p></td>
  64. </tr>
  65. <tr>
  66. <td class="name"><code>onLoad</code></td>
  67. <td class="description last"><p>Executed when the loading process has been finished.</p></td>
  68. </tr>
  69. <tr>
  70. <td class="name"><code>onProgress</code></td>
  71. <td class="description last"><p>Executed while the loading is in progress.</p></td>
  72. </tr>
  73. <tr>
  74. <td class="name"><code>onError</code></td>
  75. <td class="description last"><p>Executed when errors occur.</p></td>
  76. </tr>
  77. </tbody>
  78. </table>
  79. <dl class="details">
  80. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
  81. </dl>
  82. </div>
  83. <h3 class="name name-method" id="parse" translate="no">.<a href="#parse">parse</a><span class="signature">( data : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="Group.html">Group</a></span> </h3>
  84. <div class="method">
  85. <div class="description">
  86. <p>Parses the given GCode data and returns a group with lines.</p>
  87. </div>
  88. <table class="params">
  89. <tbody>
  90. <tr>
  91. <td class="name"><code>data</code></td>
  92. <td class="description last"><p>The raw Gcode data as a string.</p></td>
  93. </tr>
  94. </tbody>
  95. </table>
  96. <dl class="details">
  97. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#parse">Loader#parse</a></dt>
  98. </dl>
  99. <dl class="details">
  100. <dt class="tag-returns"><strong>Returns:</strong> The parsed GCode asset.</dt>
  101. </dl>
  102. </div>
  103. <h2 class="subsection-title">Source</h2>
  104. <p>
  105. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/GCodeLoader.js" target="_blank" rel="noopener" translate="no">examples/jsm/loaders/GCodeLoader.js</a>
  106. </p>
  107. </article>
  108. </section>
  109. <script src="../scripts/linenumber.js"></script>
  110. <script src="../scripts/page.js"></script>
  111. </body>
  112. </html>
粤ICP备19079148号