TeapotGeometry.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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/">SPD software</a>
  22. Created for the Udacity course <a href="http://bit.ly/ericity">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">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"><code>size</code></td>
  45. <td class="description last"><p>Relative scale of the teapot.<br/>Default is <code>50</code>.</p></td>
  46. </tr>
  47. <tr>
  48. <td class="name"><code>segments</code></td>
  49. <td class="description last"><p>Number of line segments to subdivide each patch edge.<br/>Default is <code>10</code>.</p></td>
  50. </tr>
  51. <tr>
  52. <td class="name"><code>bottom</code></td>
  53. <td class="description last"><p>Whether the bottom of the teapot is generated or not.<br/>Default is <code>true</code>.</p></td>
  54. </tr>
  55. <tr>
  56. <td class="name"><code>lid</code></td>
  57. <td class="description last"><p>Whether the lid is generated or not.<br/>Default is <code>true</code>.</p></td>
  58. </tr>
  59. <tr>
  60. <td class="name"><code>body</code></td>
  61. <td class="description last"><p>Whether the body is generated or not.<br/>Default is <code>true</code>.</p></td>
  62. </tr>
  63. <tr>
  64. <td class="name"><code>fitLid</code></td>
  65. <td class="description last"><p>Whether the lid is slightly stretched to prevent gaps between the body and lid or not.<br/>Default is <code>true</code>.</p></td>
  66. </tr>
  67. <tr>
  68. <td class="name"><code>blinn</code></td>
  69. <td class="description last"><p>Whether the teapot is scaled vertically for better aesthetics or not.<br/>Default is <code>true</code>.</p></td>
  70. </tr>
  71. </tbody>
  72. </table>
  73. </div>
  74. </div>
  75. <h2 class="subsection-title">Source</h2>
  76. <p>
  77. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/TeapotGeometry.js" target="_blank" rel="noopener" translate="no">examples/jsm/geometries/TeapotGeometry.js</a>
  78. </p>
  79. </article>
  80. </section>
  81. <script src="../scripts/linenumber.js"></script>
  82. <script src="../scripts/page.js"></script>
  83. </body>
  84. </html>
粤ICP备19079148号