TeapotGeometry.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>TeapotGeometry - 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="EventDispatcher.html">EventDispatcher</a> → <a href="BufferGeometry.html">BufferGeometry</a> → </p>
  13. <h1 translate="no">TeapotGeometry</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>Tessellates the famous Utah teapot database by Martin Newell into triangles.</p>
  17. <p>The teapot should normally be rendered as a double sided object, since for some
  18. patches both sides can be seen, e.g., the gap around the lid and inside the spout.</p>
  19. <p>Segments 'n' determines the number of triangles output. Total triangles = 32<em>2</em>n<em>n - 8</em>n
  20. (degenerates at the top and bottom cusps are deleted).</p>
  21. <p>Code based on <a href="http://tog.acm.org/resources/SPD/" target="_blank" rel="noopener">SPD software</a>
  22. Created for the Udacity course <a href="http://bit.ly/ericity" target="_blank" rel="noopener">Interactive Rendering</a></p></div>
  23. <h2>Code Example</h2>
  24. <div translate="no"><pre><code class="language-js">const geometry = new TeapotGeometry( 50, 18 );
  25. const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
  26. const teapot = new THREE.Mesh( geometry, material );
  27. scene.add( teapot );
  28. </code></pre></div>
  29. </header>
  30. <article>
  31. <h2 class="subsection-title">Import</h2>
  32. <p><span translate="no">TeapotGeometry</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>
  33. <pre><code class="language-js">import { TeapotGeometry } from 'three/addons/geometries/TeapotGeometry.js';</code></pre>
  34. <div class="container-overview">
  35. <h2>Constructor</h2>
  36. <h3 class="name name-method" id="TeapotGeometry" translate="no">new <a href="#TeapotGeometry">TeapotGeometry</a><span class="signature">( size : <span class="param-type">number</span>, segments : <span class="param-type">number</span>, bottom : <span class="param-type">boolean</span>, lid : <span class="param-type">boolean</span>, body : <span class="param-type">boolean</span>, fitLid : <span class="param-type">boolean</span>, blinn : <span class="param-type">boolean</span> )</span> </h3>
  37. <div class="method">
  38. <div class="description">
  39. <p>Constructs a new teapot geometry.</p>
  40. </div>
  41. <table class="params">
  42. <tbody>
  43. <tr>
  44. <td class="name">
  45. <strong>size</strong>
  46. </td>
  47. <td class="description last">
  48. <p>Relative scale of the teapot.</p>
  49. <p>Default is <code>50</code>.</p>
  50. </td>
  51. </tr>
  52. <tr>
  53. <td class="name">
  54. <strong>segments</strong>
  55. </td>
  56. <td class="description last">
  57. <p>Number of line segments to subdivide each patch edge.</p>
  58. <p>Default is <code>10</code>.</p>
  59. </td>
  60. </tr>
  61. <tr>
  62. <td class="name">
  63. <strong>bottom</strong>
  64. </td>
  65. <td class="description last">
  66. <p>Whether the bottom of the teapot is generated or not.</p>
  67. <p>Default is <code>true</code>.</p>
  68. </td>
  69. </tr>
  70. <tr>
  71. <td class="name">
  72. <strong>lid</strong>
  73. </td>
  74. <td class="description last">
  75. <p>Whether the lid is generated or not.</p>
  76. <p>Default is <code>true</code>.</p>
  77. </td>
  78. </tr>
  79. <tr>
  80. <td class="name">
  81. <strong>body</strong>
  82. </td>
  83. <td class="description last">
  84. <p>Whether the body is generated or not.</p>
  85. <p>Default is <code>true</code>.</p>
  86. </td>
  87. </tr>
  88. <tr>
  89. <td class="name">
  90. <strong>fitLid</strong>
  91. </td>
  92. <td class="description last">
  93. <p>Whether the lid is slightly stretched to prevent gaps between the body and lid or not.</p>
  94. <p>Default is <code>true</code>.</p>
  95. </td>
  96. </tr>
  97. <tr>
  98. <td class="name">
  99. <strong>blinn</strong>
  100. </td>
  101. <td class="description last">
  102. <p>Whether the teapot is scaled vertically for better aesthetics or not.</p>
  103. <p>Default is <code>true</code>.</p>
  104. </td>
  105. </tr>
  106. </tbody>
  107. </table>
  108. </div>
  109. </div>
  110. <h2 class="subsection-title">Source</h2>
  111. <p>
  112. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/TeapotGeometry.js" translate="no" target="_blank" rel="noopener">examples/jsm/geometries/TeapotGeometry.js</a>
  113. </p>
  114. </article>
  115. </section>
  116. <script src="../scripts/linenumber.js"></script>
  117. <script src="../scripts/page.js"></script>
  118. </body>
  119. </html>
粤ICP备19079148号