MarchingCubes.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>MarchingCubes - 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. <h1 translate="no">MarchingCubes</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>A marching cubes implementation.</p>
  16. <p>Port of: <a href="http://webglsamples.org/blob/blob.html">http://webglsamples.org/blob/blob.html</a></p></div>
  17. </header>
  18. <article>
  19. <h2 class="subsection-title">Import</h2>
  20. <p><span translate="no">MarchingCubes</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
  21. <pre><code class="language-js">import { MarchingCubes } from 'three/addons/objects/MarchingCubes.js';</code></pre>
  22. <div class="container-overview">
  23. <h2>Constructor</h2>
  24. <h3 class="name name-method" id="MarchingCubes" translate="no">new <a href="#MarchingCubes">MarchingCubes</a><span class="signature">( resolution : <span class="param-type">number</span>, material : <span class="param-type">Material</span>, enableUvs : <span class="param-type">boolean</span>, enableColors : <span class="param-type">boolean</span>, maxPolyCount : <span class="param-type">number</span> )</span> </h3>
  25. <div class="method">
  26. <div class="description">
  27. <p>Constructs a new marching cubes instance.</p>
  28. </div>
  29. <table class="params">
  30. <tbody>
  31. <tr>
  32. <td class="name"><code>resolution</code></td>
  33. <td class="description last"><p>The effect's resolution.</p></td>
  34. </tr>
  35. <tr>
  36. <td class="name"><code>material</code></td>
  37. <td class="description last"><p>The cube's material.</p></td>
  38. </tr>
  39. <tr>
  40. <td class="name"><code>enableUvs</code></td>
  41. <td class="description last"><p>Whether texture coordinates should be animated or not.<br/>Default is <code>false</code>.</p></td>
  42. </tr>
  43. <tr>
  44. <td class="name"><code>enableColors</code></td>
  45. <td class="description last"><p>Whether colors should be animated or not.<br/>Default is <code>false</code>.</p></td>
  46. </tr>
  47. <tr>
  48. <td class="name"><code>maxPolyCount</code></td>
  49. <td class="description last"><p>The maximum size of the geometry buffers.<br/>Default is <code>10000</code>.</p></td>
  50. </tr>
  51. </tbody>
  52. </table>
  53. </div>
  54. </div>
  55. <h2 class="subsection-title">Properties</h2>
  56. <div class="member">
  57. <h3 class="name" id="enableColors" translate="no">.<a href="#enableColors">enableColors</a><span class="type-signature"> : boolean</span> </h3>
  58. <div class="description">
  59. <p>Whether colors should be animated or not.<br/>Default is <code>false</code>.</p>
  60. </div>
  61. </div>
  62. <div class="member">
  63. <h3 class="name" id="enableUvs" translate="no">.<a href="#enableUvs">enableUvs</a><span class="type-signature"> : boolean</span> </h3>
  64. <div class="description">
  65. <p>Whether texture coordinates should be animated or not.<br/>Default is <code>false</code>.</p>
  66. </div>
  67. </div>
  68. <div class="member">
  69. <h3 class="name" id="isMarchingCubes" translate="no">.<a href="#isMarchingCubes">isMarchingCubes</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  70. <div class="description">
  71. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  72. </div>
  73. </div>
  74. <h2 class="subsection-title">Methods</h2>
  75. <h3 class="name name-method" id="addBall" translate="no">.<a href="#addBall">addBall</a><span class="signature">( ballx : <span class="param-type">number</span>, bally : <span class="param-type">number</span>, ballz : <span class="param-type">number</span>, strength : <span class="param-type">number</span>, subtract : <span class="param-type">number</span>, colors : <span class="param-type">Color</span> )</span> </h3>
  76. <div class="method">
  77. <div class="description">
  78. <p>Adds a reciprocal ball (nice and blobby) that, to be fast, fades to zero after
  79. a fixed distance, determined by strength and subtract.</p>
  80. </div>
  81. <table class="params">
  82. <tbody>
  83. <tr>
  84. <td class="name"><code>ballx</code></td>
  85. <td class="description last"><p>The x-coordinate of the ball.</p></td>
  86. </tr>
  87. <tr>
  88. <td class="name"><code>bally</code></td>
  89. <td class="description last"><p>The y-coordinate of the ball.</p></td>
  90. </tr>
  91. <tr>
  92. <td class="name"><code>ballz</code></td>
  93. <td class="description last"><p>The z-coordinate of the ball.</p></td>
  94. </tr>
  95. <tr>
  96. <td class="name"><code>strength</code></td>
  97. <td class="description last"><p>The strength factor.</p></td>
  98. </tr>
  99. <tr>
  100. <td class="name"><code>subtract</code></td>
  101. <td class="description last"><p>The subtract factor.</p></td>
  102. </tr>
  103. <tr>
  104. <td class="name"><code>colors</code></td>
  105. <td class="description last"><p>The color.</p></td>
  106. </tr>
  107. </tbody>
  108. </table>
  109. </div>
  110. <h3 class="name name-method" id="addPlaneX" translate="no">.<a href="#addPlaneX">addPlaneX</a><span class="signature">( strength : <span class="param-type">number</span>, subtract : <span class="param-type">number</span> )</span> </h3>
  111. <div class="method">
  112. <div class="description">
  113. <p>Adds a plane along the x-axis.</p>
  114. </div>
  115. <table class="params">
  116. <tbody>
  117. <tr>
  118. <td class="name"><code>strength</code></td>
  119. <td class="description last"><p>The strength factor.</p></td>
  120. </tr>
  121. <tr>
  122. <td class="name"><code>subtract</code></td>
  123. <td class="description last"><p>The subtract factor.</p></td>
  124. </tr>
  125. </tbody>
  126. </table>
  127. </div>
  128. <h3 class="name name-method" id="addPlaneY" translate="no">.<a href="#addPlaneY">addPlaneY</a><span class="signature">( strength : <span class="param-type">number</span>, subtract : <span class="param-type">number</span> )</span> </h3>
  129. <div class="method">
  130. <div class="description">
  131. <p>Adds a plane along the y-axis.</p>
  132. </div>
  133. <table class="params">
  134. <tbody>
  135. <tr>
  136. <td class="name"><code>strength</code></td>
  137. <td class="description last"><p>The strength factor.</p></td>
  138. </tr>
  139. <tr>
  140. <td class="name"><code>subtract</code></td>
  141. <td class="description last"><p>The subtract factor.</p></td>
  142. </tr>
  143. </tbody>
  144. </table>
  145. </div>
  146. <h3 class="name name-method" id="addPlaneZ" translate="no">.<a href="#addPlaneZ">addPlaneZ</a><span class="signature">( strength : <span class="param-type">number</span>, subtract : <span class="param-type">number</span> )</span> </h3>
  147. <div class="method">
  148. <div class="description">
  149. <p>Adds a plane along the z-axis.</p>
  150. </div>
  151. <table class="params">
  152. <tbody>
  153. <tr>
  154. <td class="name"><code>strength</code></td>
  155. <td class="description last"><p>The strength factor.</p></td>
  156. </tr>
  157. <tr>
  158. <td class="name"><code>subtract</code></td>
  159. <td class="description last"><p>The subtract factor.</p></td>
  160. </tr>
  161. </tbody>
  162. </table>
  163. </div>
  164. <h3 class="name name-method" id="blur" translate="no">.<a href="#blur">blur</a><span class="signature">( intensity : <span class="param-type">number</span> )</span> </h3>
  165. <div class="method">
  166. <div class="description">
  167. <p>Applies a blur with the given intensity.</p>
  168. </div>
  169. <table class="params">
  170. <tbody>
  171. <tr>
  172. <td class="name"><code>intensity</code></td>
  173. <td class="description last"><p>The intensity of the blur.<br/>Default is <code>1</code>.</p></td>
  174. </tr>
  175. </tbody>
  176. </table>
  177. </div>
  178. <h3 class="name name-method" id="getCell" translate="no">.<a href="#getCell">getCell</a><span class="signature">( x : <span class="param-type">number</span>, y : <span class="param-type">number</span>, z : <span class="param-type">number</span> )</span><span class="type-signature"> : number</span> </h3>
  179. <div class="method">
  180. <div class="description">
  181. <p>Returns the cell value for the given coordinates.</p>
  182. </div>
  183. <table class="params">
  184. <tbody>
  185. <tr>
  186. <td class="name"><code>x</code></td>
  187. <td class="description last"><p>The x value.</p></td>
  188. </tr>
  189. <tr>
  190. <td class="name"><code>y</code></td>
  191. <td class="description last"><p>The y value.</p></td>
  192. </tr>
  193. <tr>
  194. <td class="name"><code>z</code></td>
  195. <td class="description last"><p>The z value.</p></td>
  196. </tr>
  197. </tbody>
  198. </table>
  199. <dl class="details">
  200. <dt class="tag-returns"><strong>Returns:</strong> The value.</dt>
  201. </dl>
  202. </div>
  203. <h3 class="name name-method" id="reset" translate="no">.<a href="#reset">reset</a><span class="signature">()</span> </h3>
  204. <div class="method">
  205. <div class="description">
  206. <p>Resets the effect.</p>
  207. </div>
  208. </div>
  209. <h3 class="name name-method" id="setCell" translate="no">.<a href="#setCell">setCell</a><span class="signature">( x : <span class="param-type">number</span>, y : <span class="param-type">number</span>, z : <span class="param-type">number</span>, value : <span class="param-type">number</span> )</span> </h3>
  210. <div class="method">
  211. <div class="description">
  212. <p>Sets the cell value for the given coordinates.</p>
  213. </div>
  214. <table class="params">
  215. <tbody>
  216. <tr>
  217. <td class="name"><code>x</code></td>
  218. <td class="description last"><p>The x value.</p></td>
  219. </tr>
  220. <tr>
  221. <td class="name"><code>y</code></td>
  222. <td class="description last"><p>The y value.</p></td>
  223. </tr>
  224. <tr>
  225. <td class="name"><code>z</code></td>
  226. <td class="description last"><p>The z value.</p></td>
  227. </tr>
  228. <tr>
  229. <td class="name"><code>value</code></td>
  230. <td class="description last"><p>The value to set.</p></td>
  231. </tr>
  232. </tbody>
  233. </table>
  234. </div>
  235. <h3 class="name name-method" id="update" translate="no">.<a href="#update">update</a><span class="signature">()</span> </h3>
  236. <div class="method">
  237. <div class="description">
  238. <p>Updates the effect.</p>
  239. </div>
  240. </div>
  241. <h2 class="subsection-title">Source</h2>
  242. <p>
  243. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/MarchingCubes.js" target="_blank" rel="noopener" translate="no">examples/jsm/objects/MarchingCubes.js</a>
  244. </p>
  245. </article>
  246. </section>
  247. <script src="../scripts/linenumber.js"></script>
  248. <script src="../scripts/page.js"></script>
  249. </body>
  250. </html>
粤ICP备19079148号