PLYLoader.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>PLYLoader - 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">PLYLoader</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A loader for PLY the PLY format (known as the Polygon
  17. File Format or the Stanford Triangle Format).</p>
  18. <p>Limitations:</p>
  19. <ul>
  20. <li>ASCII decoding assumes file is UTF-8.</li>
  21. </ul></div>
  22. <h2>Code Example</h2>
  23. <div translate="no"><pre><code class="language-js">const loader = new PLYLoader();
  24. const geometry = await loader.loadAsync( './models/ply/ascii/dolphins.ply' );
  25. scene.add( new THREE.Mesh( geometry ) );
  26. </code></pre></div>
  27. </header>
  28. <article>
  29. <h2 class="subsection-title">Import</h2>
  30. <p><span translate="no">PLYLoader</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>
  31. <pre><code class="language-js">import { PLYLoader } from 'three/addons/loaders/PLYLoader.js';</code></pre>
  32. <div class="container-overview">
  33. <h2>Constructor</h2>
  34. <h3 class="name name-method" id="PLYLoader" translate="no">new <a href="#PLYLoader">PLYLoader</a><span class="signature">( manager : <span class="param-type"><a href="LoadingManager.html">LoadingManager</a></span> )</span> </h3>
  35. <div class="method">
  36. <div class="description">
  37. <p>Constructs a new PLY loader.</p>
  38. </div>
  39. <table class="params">
  40. <tbody>
  41. <tr>
  42. <td class="name">
  43. <strong>manager</strong>
  44. </td>
  45. <td class="description last">
  46. <p>The loading manager.</p>
  47. </td>
  48. </tr>
  49. </tbody>
  50. </table>
  51. </div>
  52. </div>
  53. <h2 class="subsection-title">Methods</h2>
  54. <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>
  55. <div class="method">
  56. <div class="description">
  57. <p>Starts loading from the given URL and passes the loaded PLY asset
  58. to the <code>onLoad()</code> callback.</p>
  59. </div>
  60. <table class="params">
  61. <tbody>
  62. <tr>
  63. <td class="name">
  64. <strong>url</strong>
  65. </td>
  66. <td class="description last">
  67. <p>The path/URL of the file to be loaded. This can also be a data URI.</p>
  68. </td>
  69. </tr>
  70. <tr>
  71. <td class="name">
  72. <strong>onLoad</strong>
  73. </td>
  74. <td class="description last">
  75. <p>Executed when the loading process has been finished.</p>
  76. </td>
  77. </tr>
  78. <tr>
  79. <td class="name">
  80. <strong>onProgress</strong>
  81. </td>
  82. <td class="description last">
  83. <p>Executed while the loading is in progress.</p>
  84. </td>
  85. </tr>
  86. <tr>
  87. <td class="name">
  88. <strong>onError</strong>
  89. </td>
  90. <td class="description last">
  91. <p>Executed when errors occur.</p>
  92. </td>
  93. </tr>
  94. </tbody>
  95. </table>
  96. <dl class="details">
  97. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#load">Loader#load</a></dt>
  98. </dl>
  99. </div>
  100. <h3 class="name name-method" id="parse" translate="no">.<a href="#parse">parse</a><span class="signature">( data : <span class="param-type">ArrayBuffer</span> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  101. <div class="method">
  102. <div class="description">
  103. <p>Parses the given PLY data and returns the resulting geometry.</p>
  104. </div>
  105. <table class="params">
  106. <tbody>
  107. <tr>
  108. <td class="name">
  109. <strong>data</strong>
  110. </td>
  111. <td class="description last">
  112. <p>The raw PLY data as an array buffer.</p>
  113. </td>
  114. </tr>
  115. </tbody>
  116. </table>
  117. <dl class="details">
  118. <dt class="tag-overrides"><strong>Overrides:</strong> <a href="Loader.html#parse">Loader#parse</a></dt>
  119. </dl>
  120. <dl class="details">
  121. <dt class="tag-returns"><strong>Returns:</strong> The parsed geometry.</dt>
  122. </dl>
  123. </div>
  124. <h3 class="name name-method" id="setCustomPropertyNameMapping" translate="no">.<a href="#setCustomPropertyNameMapping">setCustomPropertyNameMapping</a><span class="signature">( mapping : <span class="param-type">Object</span> )</span> </h3>
  125. <div class="method">
  126. <div class="description">
  127. <p>Custom properties outside of the defaults for position, uv, normal
  128. and color attributes can be added using the setCustomPropertyNameMapping method.
  129. For example, the following maps the element properties “custom_property_a”
  130. and “custom_property_b” to an attribute “customAttribute” with an item size of 2.
  131. Attribute item sizes are set from the number of element properties in the property array.</p>
  132. <pre><code class="language-js">loader.setCustomPropertyNameMapping( {
  133. customAttribute: ['custom_property_a', 'custom_property_b'],
  134. } );
  135. </code></pre>
  136. </div>
  137. <table class="params">
  138. <tbody>
  139. <tr>
  140. <td class="name">
  141. <strong>mapping</strong>
  142. </td>
  143. <td class="description last">
  144. <p>The mapping dictionary.</p>
  145. </td>
  146. </tr>
  147. </tbody>
  148. </table>
  149. </div>
  150. <h3 class="name name-method" id="setPropertyNameMapping" translate="no">.<a href="#setPropertyNameMapping">setPropertyNameMapping</a><span class="signature">( mapping : <span class="param-type">Object</span> )</span> </h3>
  151. <div class="method">
  152. <div class="description">
  153. <p>Sets a property name mapping that maps default property names
  154. to custom ones. For example, the following maps the properties
  155. “diffuse_(red|green|blue)” in the file to standard color names.</p>
  156. <pre><code class="language-js">loader.setPropertyNameMapping( {
  157. diffuse_red: 'red',
  158. diffuse_green: 'green',
  159. diffuse_blue: 'blue'
  160. } );
  161. </code></pre>
  162. </div>
  163. <table class="params">
  164. <tbody>
  165. <tr>
  166. <td class="name">
  167. <strong>mapping</strong>
  168. </td>
  169. <td class="description last">
  170. <p>The mapping dictionary.</p>
  171. </td>
  172. </tr>
  173. </tbody>
  174. </table>
  175. </div>
  176. <h2 class="subsection-title">Source</h2>
  177. <p>
  178. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/PLYLoader.js" translate="no" target="_blank" rel="noopener">examples/jsm/loaders/PLYLoader.js</a>
  179. </p>
  180. </article>
  181. </section>
  182. <script src="../scripts/linenumber.js"></script>
  183. <script src="../scripts/page.js"></script>
  184. </body>
  185. </html>
粤ICP备19079148号