TextGeometry.html 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>TextGeometry - 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> → <a href="ExtrudeGeometry.html">ExtrudeGeometry</a> → </p>
  13. <h1 translate="no">TextGeometry</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A class for generating text as a single geometry. It is constructed by providing a string of text, and a set of
  17. parameters consisting of a loaded font and extrude settings.</p>
  18. <p>See the <a href="FontLoader.html">FontLoader</a> page for additional details.</p>
  19. <p><code>TextGeometry</code> uses <a href="http://gero3.github.io/facetype.js/">typeface.json</a> generated fonts.
  20. Some existing fonts can be found located in <code>/examples/fonts</code>.</p></div>
  21. <h2>Code Example</h2>
  22. <div translate="no"><pre><code class="language-js">const loader = new FontLoader();
  23. const font = await loader.loadAsync( 'fonts/helvetiker_regular.typeface.json' );
  24. const geometry = new TextGeometry( 'Hello three.js!', {
  25. font: font,
  26. size: 80,
  27. depth: 5,
  28. curveSegments: 12
  29. } );
  30. </code></pre></div>
  31. </header>
  32. <article>
  33. <h2 class="subsection-title">Import</h2>
  34. <p><span translate="no">TextGeometry</span> is an addon, and must be imported explicitly, see <a href="https://threejs.org/manual/#en/installation" target="_blank">Installation#Addons</a>.</p>
  35. <pre><code class="language-js">import { TextGeometry } from 'three/addons/geometries/TextGeometry.js';</code></pre>
  36. <div class="container-overview">
  37. <h2>Constructor</h2>
  38. <h3 class="name name-method" id="TextGeometry" translate="no">new <a href="#TextGeometry">TextGeometry</a><span class="signature">( text : <span class="param-type">string</span>, parameters : <span class="param-type">TextGeometry~Options</span> )</span> </h3>
  39. <div class="method">
  40. <div class="description">
  41. <p>Constructs a new text geometry.</p>
  42. </div>
  43. <table class="params">
  44. <tbody>
  45. <tr>
  46. <td class="name"><code>text</code></td>
  47. <td class="description last"><p>The text that should be transformed into a geometry.</p></td>
  48. </tr>
  49. <tr>
  50. <td class="name"><code>parameters</code></td>
  51. <td class="description last"><p>The text settings.</p></td>
  52. </tr>
  53. </tbody>
  54. </table>
  55. </div>
  56. </div>
  57. <h2 class="subsection-title">Type Definitions</h2>
  58. <div class="member">
  59. <h3 class="name" id="~Options" translate="no">.<a href="#~Options">Options</a> </h3>
  60. <div class="description">
  61. <p>Represents the <code>options</code> type of the geometry's constructor.</p>
  62. </div>
  63. <h5 class="subsection-title">Properties:</h5>
  64. <table class="props">
  65. <thead>
  66. <tr>
  67. <th>Name</th>
  68. <th>Type</th>
  69. <th>Attributes</th>
  70. <th>Default</th>
  71. <th class="last">Description</th>
  72. </tr>
  73. </thead>
  74. <tbody>
  75. <tr>
  76. <td class="name"><code>font</code></td>
  77. <td class="type">
  78. <span class="param-type"><a href="Font.html">Font</a></span>
  79. </td>
  80. <td class="attributes">
  81. &lt;optional><br>
  82. </td>
  83. <td class="default">
  84. </td>
  85. <td class="description last"><p>The font.</p></td>
  86. </tr>
  87. <tr>
  88. <td class="name"><code>size</code></td>
  89. <td class="type">
  90. <span class="param-type">number</span>
  91. </td>
  92. <td class="attributes">
  93. &lt;optional><br>
  94. </td>
  95. <td class="default">
  96. 100
  97. </td>
  98. <td class="description last"><p>The text size.</p></td>
  99. </tr>
  100. <tr>
  101. <td class="name"><code>depth</code></td>
  102. <td class="type">
  103. <span class="param-type">number</span>
  104. </td>
  105. <td class="attributes">
  106. &lt;optional><br>
  107. </td>
  108. <td class="default">
  109. 50
  110. </td>
  111. <td class="description last"><p>Depth to extrude the shape.</p></td>
  112. </tr>
  113. <tr>
  114. <td class="name"><code>curveSegments</code></td>
  115. <td class="type">
  116. <span class="param-type">number</span>
  117. </td>
  118. <td class="attributes">
  119. &lt;optional><br>
  120. </td>
  121. <td class="default">
  122. 12
  123. </td>
  124. <td class="description last"><p>Number of points on the curves.</p></td>
  125. </tr>
  126. <tr>
  127. <td class="name"><code>steps</code></td>
  128. <td class="type">
  129. <span class="param-type">number</span>
  130. </td>
  131. <td class="attributes">
  132. &lt;optional><br>
  133. </td>
  134. <td class="default">
  135. 1
  136. </td>
  137. <td class="description last"><p>Number of points used for subdividing segments along the depth of the extruded spline.</p></td>
  138. </tr>
  139. <tr>
  140. <td class="name"><code>bevelEnabled</code></td>
  141. <td class="type">
  142. <span class="param-type">boolean</span>
  143. </td>
  144. <td class="attributes">
  145. &lt;optional><br>
  146. </td>
  147. <td class="default">
  148. false
  149. </td>
  150. <td class="description last"><p>Whether to beveling to the shape or not.</p></td>
  151. </tr>
  152. <tr>
  153. <td class="name"><code>bevelThickness</code></td>
  154. <td class="type">
  155. <span class="param-type">number</span>
  156. </td>
  157. <td class="attributes">
  158. &lt;optional><br>
  159. </td>
  160. <td class="default">
  161. 10
  162. </td>
  163. <td class="description last"><p>How deep into the original shape the bevel goes.</p></td>
  164. </tr>
  165. <tr>
  166. <td class="name"><code>bevelSize</code></td>
  167. <td class="type">
  168. <span class="param-type">number</span>
  169. </td>
  170. <td class="attributes">
  171. &lt;optional><br>
  172. </td>
  173. <td class="default">
  174. 8
  175. </td>
  176. <td class="description last"><p>Distance from the shape outline that the bevel extends.</p></td>
  177. </tr>
  178. <tr>
  179. <td class="name"><code>bevelOffset</code></td>
  180. <td class="type">
  181. <span class="param-type">number</span>
  182. </td>
  183. <td class="attributes">
  184. &lt;optional><br>
  185. </td>
  186. <td class="default">
  187. 0
  188. </td>
  189. <td class="description last"><p>Distance from the shape outline that the bevel starts.</p></td>
  190. </tr>
  191. <tr>
  192. <td class="name"><code>bevelSegments</code></td>
  193. <td class="type">
  194. <span class="param-type">number</span>
  195. </td>
  196. <td class="attributes">
  197. &lt;optional><br>
  198. </td>
  199. <td class="default">
  200. 3
  201. </td>
  202. <td class="description last"><p>Number of bevel layers.</p></td>
  203. </tr>
  204. <tr>
  205. <td class="name"><code>direction</code></td>
  206. <td class="type">
  207. <span class="param-type">string</span>
  208. </td>
  209. <td class="attributes">
  210. &lt;optional><br>
  211. </td>
  212. <td class="default">
  213. 'ltr'
  214. </td>
  215. <td class="description last"><p>Char direction: ltr(left to right), rtl(right to left) &amp; tb(top bottom).</p></td>
  216. </tr>
  217. <tr>
  218. <td class="name"><code>extrudePath</code></td>
  219. <td class="type">
  220. <span class="param-type"><a href="Curve.html">Curve</a></span>
  221. </td>
  222. <td class="attributes">
  223. &lt;optional><br>
  224. &lt;nullable><br>
  225. </td>
  226. <td class="default">
  227. null
  228. </td>
  229. <td class="description last"><p>A 3D spline path along which the shape should be extruded. Bevels not supported for path extrusion.</p></td>
  230. </tr>
  231. <tr>
  232. <td class="name"><code>UVGenerator</code></td>
  233. <td class="type">
  234. <span class="param-type">Object</span>
  235. </td>
  236. <td class="attributes">
  237. &lt;optional><br>
  238. </td>
  239. <td class="default">
  240. </td>
  241. <td class="description last"><p>An object that provides UV generator functions for custom UV generation.</p></td>
  242. </tr>
  243. </tbody>
  244. </table>
  245. </div>
  246. <h2 class="subsection-title">Source</h2>
  247. <p>
  248. <a href="https://github.com/mrdoob/three.js/blob/master/examples/jsm/geometries/TextGeometry.js" target="_blank" rel="noopener" translate="no">examples/jsm/geometries/TextGeometry.js</a>
  249. </p>
  250. </article>
  251. </section>
  252. <script src="../scripts/linenumber.js"></script>
  253. <script src="../scripts/page.js"></script>
  254. </body>
  255. </html>
粤ICP备19079148号