BufferGeometry.html 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>BufferGeometry - 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> → </p>
  13. <h1 translate="no">BufferGeometry</h1>
  14. <section>
  15. <header>
  16. <div class="class-description"><p>A representation of mesh, line, or point geometry. Includes vertex
  17. positions, face indices, normals, colors, UVs, and custom attributes
  18. within buffers, reducing the cost of passing all this data to the GPU.</p></div>
  19. <h2>Code Example</h2>
  20. <div translate="no"><pre><code class="language-js">const geometry = new THREE.BufferGeometry();
  21. // create a simple square shape. We duplicate the top left and bottom right
  22. // vertices because each vertex needs to appear once per triangle.
  23. const vertices = new Float32Array( [
  24. -1.0, -1.0, 1.0, // v0
  25. 1.0, -1.0, 1.0, // v1
  26. 1.0, 1.0, 1.0, // v2
  27. 1.0, 1.0, 1.0, // v3
  28. -1.0, 1.0, 1.0, // v4
  29. -1.0, -1.0, 1.0 // v5
  30. ] );
  31. // itemSize = 3 because there are 3 values (components) per vertex
  32. geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
  33. const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
  34. const mesh = new THREE.Mesh( geometry, material );
  35. </code></pre></div>
  36. </header>
  37. <article>
  38. <div class="container-overview">
  39. <h2>Constructor</h2>
  40. <h3 class="name name-method" id="BufferGeometry" translate="no">new <a href="#BufferGeometry">BufferGeometry</a><span class="signature">()</span> </h3>
  41. <div class="method">
  42. <div class="description">
  43. <p>Constructs a new geometry.</p>
  44. </div>
  45. </div>
  46. </div>
  47. <h2 class="subsection-title">Properties</h2>
  48. <div class="member">
  49. <h3 class="name" id="attributes" translate="no">.<a href="#attributes">attributes</a><span class="type-signature"> : Object.&lt;string, (<a href="BufferAttribute.html">BufferAttribute</a>|<a href="InterleavedBufferAttribute.html">InterleavedBufferAttribute</a>)></span> </h3>
  50. <div class="description">
  51. <p>This dictionary has as id the name of the attribute to be set and as value
  52. the buffer attribute to set it to. Rather than accessing this property directly,
  53. use <code>setAttribute()</code> and <code>getAttribute()</code> to access attributes of this geometry.</p>
  54. </div>
  55. </div>
  56. <div class="member">
  57. <h3 class="name" id="boundingBox" translate="no">.<a href="#boundingBox">boundingBox</a><span class="type-signature"> : <a href="Box3.html">Box3</a></span> </h3>
  58. <div class="description">
  59. <p>Bounding box for the geometry which can be calculated with <code>computeBoundingBox()</code>.</p>
  60. <p>Default is <code>null</code>.</p>
  61. </div>
  62. </div>
  63. <div class="member">
  64. <h3 class="name" id="boundingSphere" translate="no">.<a href="#boundingSphere">boundingSphere</a><span class="type-signature"> : <a href="Sphere.html">Sphere</a></span> </h3>
  65. <div class="description">
  66. <p>Bounding sphere for the geometry which can be calculated with <code>computeBoundingSphere()</code>.</p>
  67. <p>Default is <code>null</code>.</p>
  68. </div>
  69. </div>
  70. <div class="member">
  71. <h3 class="name" id="drawRange" translate="no">.<a href="#drawRange">drawRange</a><span class="type-signature"> : Object</span> </h3>
  72. <div class="description">
  73. <p>Determines the part of the geometry to render. This should not be set directly,
  74. instead use <code>setDrawRange()</code>.</p>
  75. </div>
  76. </div>
  77. <div class="member">
  78. <h3 class="name" id="groups" translate="no">.<a href="#groups">groups</a><span class="type-signature"> : Array.&lt;Object></span> </h3>
  79. <div class="description">
  80. <p>Split the geometry into groups, each of which will be rendered in a
  81. separate draw call. This allows an array of materials to be used with the geometry.</p>
  82. <p>Use <code>addGroup()</code> and <code>clearGroups()</code> to edit groups, rather than modifying this array directly.</p>
  83. <p>Every vertex and index must belong to exactly one group — groups must not share vertices or
  84. indices, and must not leave vertices or indices unused.</p>
  85. </div>
  86. </div>
  87. <div class="member">
  88. <h3 class="name" id="id" translate="no">.<a href="#id">id</a><span class="type-signature"> : number</span> <span class="type-signature">(readonly) </span></h3>
  89. <div class="description">
  90. <p>The ID of the geometry.</p>
  91. </div>
  92. </div>
  93. <div class="member">
  94. <h3 class="name" id="index" translate="no">.<a href="#index">index</a><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  95. <div class="description">
  96. <p>Allows for vertices to be re-used across multiple triangles; this is
  97. called using &quot;indexed triangles&quot;. Each triangle is associated with the
  98. indices of three vertices. This attribute therefore stores the index of
  99. each vertex for each triangular face. If this attribute is not set, the
  100. renderer assumes that each three contiguous positions represent a single triangle.</p>
  101. <p>Default is <code>null</code>.</p>
  102. </div>
  103. </div>
  104. <div class="member">
  105. <h3 class="name" id="indirect" translate="no">.<a href="#indirect">indirect</a><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  106. <div class="description">
  107. <p>A (storage) buffer attribute which was generated with a compute shader and
  108. now defines indirect draw calls.</p>
  109. <p>Can only be used with <a href="WebGPURenderer.html">WebGPURenderer</a> and a WebGPU backend.</p>
  110. <p>Default is <code>null</code>.</p>
  111. </div>
  112. </div>
  113. <div class="member">
  114. <h3 class="name" id="indirectOffset" translate="no">.<a href="#indirectOffset">indirectOffset</a><span class="type-signature"> : number | Array.&lt;number></span> </h3>
  115. <div class="description">
  116. <p>The offset, in bytes, into the indirect drawing buffer where the value data begins. If an array is provided, multiple indirect draw calls will be made for each offset.</p>
  117. <p>Can only be used with <a href="WebGPURenderer.html">WebGPURenderer</a> and a WebGPU backend.</p>
  118. <p>Default is <code>0</code>.</p>
  119. </div>
  120. </div>
  121. <div class="member">
  122. <h3 class="name" id="isBufferGeometry" translate="no">.<a href="#isBufferGeometry">isBufferGeometry</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  123. <div class="description">
  124. <p>This flag can be used for type testing.</p>
  125. <p>Default is <code>true</code>.</p>
  126. </div>
  127. </div>
  128. <div class="member">
  129. <h3 class="name" id="morphAttributes" translate="no">.<a href="#morphAttributes">morphAttributes</a><span class="type-signature"> : Object</span> </h3>
  130. <div class="description">
  131. <p>This dictionary holds the morph targets of the geometry.</p>
  132. <p>Note: Once the geometry has been rendered, the morph attribute data cannot
  133. be changed. You will have to call <code>dispose()</code>, and create a new geometry instance.</p>
  134. </div>
  135. </div>
  136. <div class="member">
  137. <h3 class="name" id="morphTargetsRelative" translate="no">.<a href="#morphTargetsRelative">morphTargetsRelative</a><span class="type-signature"> : boolean</span> </h3>
  138. <div class="description">
  139. <p>Used to control the morph target behavior; when set to <code>true</code>, the morph
  140. target data is treated as relative offsets, rather than as absolute
  141. positions/normals.</p>
  142. <p>Default is <code>false</code>.</p>
  143. </div>
  144. </div>
  145. <div class="member">
  146. <h3 class="name" id="name" translate="no">.<a href="#name">name</a><span class="type-signature"> : string</span> </h3>
  147. <div class="description">
  148. <p>The name of the geometry.</p>
  149. </div>
  150. </div>
  151. <div class="member">
  152. <h3 class="name" id="userData" translate="no">.<a href="#userData">userData</a><span class="type-signature"> : Object</span> </h3>
  153. <div class="description">
  154. <p>An object that can be used to store custom data about the geometry.
  155. It should not hold references to functions as these will not be cloned.</p>
  156. </div>
  157. </div>
  158. <div class="member">
  159. <h3 class="name" id="uuid" translate="no">.<a href="#uuid">uuid</a><span class="type-signature"> : string</span> <span class="type-signature">(readonly) </span></h3>
  160. <div class="description">
  161. <p>The UUID of the geometry.</p>
  162. </div>
  163. </div>
  164. <h2 class="subsection-title">Methods</h2>
  165. <h3 class="name name-method" id="addGroup" translate="no">.<a href="#addGroup">addGroup</a><span class="signature">( start : <span class="param-type">number</span>, count : <span class="param-type">number</span>, materialIndex : <span class="param-type">number</span> )</span> </h3>
  166. <div class="method">
  167. <div class="description">
  168. <p>Adds a group to this geometry.</p>
  169. </div>
  170. <table class="params">
  171. <tbody>
  172. <tr>
  173. <td class="name">
  174. <strong>start</strong>
  175. </td>
  176. <td class="description last">
  177. <p>The first element in this draw call. That is the first
  178. vertex for non-indexed geometry, otherwise the first triangle index.</p>
  179. </td>
  180. </tr>
  181. <tr>
  182. <td class="name">
  183. <strong>count</strong>
  184. </td>
  185. <td class="description last">
  186. <p>Specifies how many vertices (or indices) are part of this group.</p>
  187. </td>
  188. </tr>
  189. <tr>
  190. <td class="name">
  191. <strong>materialIndex</strong>
  192. </td>
  193. <td class="description last">
  194. <p>The material array index to use.</p>
  195. <p>Default is <code>0</code>.</p>
  196. </td>
  197. </tr>
  198. </tbody>
  199. </table>
  200. </div>
  201. <h3 class="name name-method" id="applyMatrix4" translate="no">.<a href="#applyMatrix4">applyMatrix4</a><span class="signature">( matrix : <span class="param-type"><a href="Matrix4.html">Matrix4</a></span> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  202. <div class="method">
  203. <div class="description">
  204. <p>Applies the given 4x4 transformation matrix to the geometry.</p>
  205. </div>
  206. <table class="params">
  207. <tbody>
  208. <tr>
  209. <td class="name">
  210. <strong>matrix</strong>
  211. </td>
  212. <td class="description last">
  213. <p>The matrix to apply.</p>
  214. </td>
  215. </tr>
  216. </tbody>
  217. </table>
  218. <dl class="details">
  219. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  220. </dl>
  221. </div>
  222. <h3 class="name name-method" id="applyQuaternion" translate="no">.<a href="#applyQuaternion">applyQuaternion</a><span class="signature">( q : <span class="param-type"><a href="Quaternion.html">Quaternion</a></span> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  223. <div class="method">
  224. <div class="description">
  225. <p>Applies the rotation represented by the Quaternion to the geometry.</p>
  226. </div>
  227. <table class="params">
  228. <tbody>
  229. <tr>
  230. <td class="name">
  231. <strong>q</strong>
  232. </td>
  233. <td class="description last">
  234. <p>The Quaternion to apply.</p>
  235. </td>
  236. </tr>
  237. </tbody>
  238. </table>
  239. <dl class="details">
  240. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  241. </dl>
  242. </div>
  243. <h3 class="name name-method" id="center" translate="no">.<a href="#center">center</a><span class="signature">()</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  244. <div class="method">
  245. <div class="description">
  246. <p>Center the geometry based on its bounding box.</p>
  247. </div>
  248. <dl class="details">
  249. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  250. </dl>
  251. </div>
  252. <h3 class="name name-method" id="clearGroups" translate="no">.<a href="#clearGroups">clearGroups</a><span class="signature">()</span> </h3>
  253. <div class="method">
  254. <div class="description">
  255. <p>Clears all groups.</p>
  256. </div>
  257. </div>
  258. <h3 class="name name-method" id="clone" translate="no">.<a href="#clone">clone</a><span class="signature">()</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  259. <div class="method">
  260. <div class="description">
  261. <p>Returns a new geometry with copied values from this instance.</p>
  262. </div>
  263. <dl class="details">
  264. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  265. </dl>
  266. </div>
  267. <h3 class="name name-method" id="computeBoundingBox" translate="no">.<a href="#computeBoundingBox">computeBoundingBox</a><span class="signature">()</span> </h3>
  268. <div class="method">
  269. <div class="description">
  270. <p>Computes the bounding box of the geometry, and updates the <code>boundingBox</code> member.
  271. The bounding box is not computed by the engine; it must be computed by your app.
  272. You may need to recompute the bounding box if the geometry vertices are modified.</p>
  273. </div>
  274. </div>
  275. <h3 class="name name-method" id="computeBoundingSphere" translate="no">.<a href="#computeBoundingSphere">computeBoundingSphere</a><span class="signature">()</span> </h3>
  276. <div class="method">
  277. <div class="description">
  278. <p>Computes the bounding sphere of the geometry, and updates the <code>boundingSphere</code> member.
  279. The engine automatically computes the bounding sphere when it is needed, e.g., for ray casting or view frustum culling.
  280. You may need to recompute the bounding sphere if the geometry vertices are modified.</p>
  281. </div>
  282. </div>
  283. <h3 class="name name-method" id="computeTangents" translate="no">.<a href="#computeTangents">computeTangents</a><span class="signature">()</span> </h3>
  284. <div class="method">
  285. <div class="description">
  286. <p>Calculates and adds a tangent attribute to this geometry.</p>
  287. <p>The computation is only supported for indexed geometries and if position, normal, and uv attributes
  288. are defined. When using a tangent space normal map, prefer the MikkTSpace algorithm provided by
  289. BufferGeometryUtils#computeMikkTSpaceTangents instead.</p>
  290. </div>
  291. </div>
  292. <h3 class="name name-method" id="computeVertexNormals" translate="no">.<a href="#computeVertexNormals">computeVertexNormals</a><span class="signature">()</span> </h3>
  293. <div class="method">
  294. <div class="description">
  295. <p>Computes vertex normals for the given vertex data. For indexed geometries, the method sets
  296. each vertex normal to be the average of the face normals of the faces that share that vertex.
  297. For non-indexed geometries, vertices are not shared, and the method sets each vertex normal
  298. to be the same as the face normal.</p>
  299. </div>
  300. </div>
  301. <h3 class="name name-method" id="copy" translate="no">.<a href="#copy">copy</a><span class="signature">( source : <span class="param-type"><a href="BufferGeometry.html">BufferGeometry</a></span> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  302. <div class="method">
  303. <div class="description">
  304. <p>Copies the values of the given geometry to this instance.</p>
  305. </div>
  306. <table class="params">
  307. <tbody>
  308. <tr>
  309. <td class="name">
  310. <strong>source</strong>
  311. </td>
  312. <td class="description last">
  313. <p>The geometry to copy.</p>
  314. </td>
  315. </tr>
  316. </tbody>
  317. </table>
  318. <dl class="details">
  319. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  320. </dl>
  321. </div>
  322. <h3 class="name name-method" id="deleteAttribute" translate="no">.<a href="#deleteAttribute">deleteAttribute</a><span class="signature">( name : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  323. <div class="method">
  324. <div class="description">
  325. <p>Deletes the attribute for the given name.</p>
  326. </div>
  327. <table class="params">
  328. <tbody>
  329. <tr>
  330. <td class="name">
  331. <strong>name</strong>
  332. </td>
  333. <td class="description last">
  334. <p>The attribute name to delete.</p>
  335. </td>
  336. </tr>
  337. </tbody>
  338. </table>
  339. <dl class="details">
  340. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  341. </dl>
  342. </div>
  343. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  344. <div class="method">
  345. <div class="description">
  346. <p>Frees the GPU-related resources allocated by this instance. Call this
  347. method whenever this instance is no longer used in your app.</p>
  348. </div>
  349. <h5>Fires:</h5>
  350. <ul>
  351. <li>BufferGeometry#event:dispose</li>
  352. </ul>
  353. </div>
  354. <h3 class="name name-method" id="getAttribute" translate="no">.<a href="#getAttribute">getAttribute</a><span class="signature">( name : <span class="param-type">string</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a> | <a href="InterleavedBufferAttribute.html">InterleavedBufferAttribute</a> | undefined</span> </h3>
  355. <div class="method">
  356. <div class="description">
  357. <p>Returns the buffer attribute for the given name.</p>
  358. </div>
  359. <table class="params">
  360. <tbody>
  361. <tr>
  362. <td class="name">
  363. <strong>name</strong>
  364. </td>
  365. <td class="description last">
  366. <p>The attribute name.</p>
  367. </td>
  368. </tr>
  369. </tbody>
  370. </table>
  371. <dl class="details">
  372. <dt class="tag-returns"><strong>Returns:</strong> The buffer attribute.
  373. Returns <code>undefined</code> if not attribute has been found.</dt>
  374. </dl>
  375. </div>
  376. <h3 class="name name-method" id="getIndex" translate="no">.<a href="#getIndex">getIndex</a><span class="signature">()</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  377. <div class="method">
  378. <div class="description">
  379. <p>Returns the index of this geometry.</p>
  380. </div>
  381. <dl class="details">
  382. <dt class="tag-returns"><strong>Returns:</strong> The index. Returns <code>null</code> if no index is defined.</dt>
  383. </dl>
  384. </div>
  385. <h3 class="name name-method" id="getIndirect" translate="no">.<a href="#getIndirect">getIndirect</a><span class="signature">()</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  386. <div class="method">
  387. <div class="description">
  388. <p>Returns the indirect attribute of this geometry.</p>
  389. </div>
  390. <dl class="details">
  391. <dt class="tag-returns"><strong>Returns:</strong> The indirect attribute. Returns <code>null</code> if no indirect attribute is defined.</dt>
  392. </dl>
  393. </div>
  394. <h3 class="name name-method" id="hasAttribute" translate="no">.<a href="#hasAttribute">hasAttribute</a><span class="signature">( name : <span class="param-type">string</span> )</span><span class="type-signature"> : boolean</span> </h3>
  395. <div class="method">
  396. <div class="description">
  397. <p>Returns <code>true</code> if this geometry has an attribute for the given name.</p>
  398. </div>
  399. <table class="params">
  400. <tbody>
  401. <tr>
  402. <td class="name">
  403. <strong>name</strong>
  404. </td>
  405. <td class="description last">
  406. <p>The attribute name.</p>
  407. </td>
  408. </tr>
  409. </tbody>
  410. </table>
  411. <dl class="details">
  412. <dt class="tag-returns"><strong>Returns:</strong> Whether this geometry has an attribute for the given name or not.</dt>
  413. </dl>
  414. </div>
  415. <h3 class="name name-method" id="lookAt" translate="no">.<a href="#lookAt">lookAt</a><span class="signature">( vector : <span class="param-type"><a href="Vector3.html">Vector3</a></span> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  416. <div class="method">
  417. <div class="description">
  418. <p>Rotates the geometry to face a point in 3D space. This is typically done as a one time
  419. operation, and not during a loop. Use <a href="Object3D.html#lookAt">Object3D#lookAt</a> for typical
  420. real-time mesh rotation.</p>
  421. </div>
  422. <table class="params">
  423. <tbody>
  424. <tr>
  425. <td class="name">
  426. <strong>vector</strong>
  427. </td>
  428. <td class="description last">
  429. <p>The target point.</p>
  430. </td>
  431. </tr>
  432. </tbody>
  433. </table>
  434. <dl class="details">
  435. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  436. </dl>
  437. </div>
  438. <h3 class="name name-method" id="normalizeNormals" translate="no">.<a href="#normalizeNormals">normalizeNormals</a><span class="signature">()</span> </h3>
  439. <div class="method">
  440. <div class="description">
  441. <p>Ensures every normal vector in a geometry will have a magnitude of <code>1</code>. This will
  442. correct lighting on the geometry surfaces.</p>
  443. </div>
  444. </div>
  445. <h3 class="name name-method" id="rotateX" translate="no">.<a href="#rotateX">rotateX</a><span class="signature">( angle : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  446. <div class="method">
  447. <div class="description">
  448. <p>Rotates the geometry about the X axis. This is typically done as a one time
  449. operation, and not during a loop. Use <a href="Object3D.html#rotation">Object3D#rotation</a> for typical
  450. real-time mesh rotation.</p>
  451. </div>
  452. <table class="params">
  453. <tbody>
  454. <tr>
  455. <td class="name">
  456. <strong>angle</strong>
  457. </td>
  458. <td class="description last">
  459. <p>The angle in radians.</p>
  460. </td>
  461. </tr>
  462. </tbody>
  463. </table>
  464. <dl class="details">
  465. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  466. </dl>
  467. </div>
  468. <h3 class="name name-method" id="rotateY" translate="no">.<a href="#rotateY">rotateY</a><span class="signature">( angle : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  469. <div class="method">
  470. <div class="description">
  471. <p>Rotates the geometry about the Y axis. This is typically done as a one time
  472. operation, and not during a loop. Use <a href="Object3D.html#rotation">Object3D#rotation</a> for typical
  473. real-time mesh rotation.</p>
  474. </div>
  475. <table class="params">
  476. <tbody>
  477. <tr>
  478. <td class="name">
  479. <strong>angle</strong>
  480. </td>
  481. <td class="description last">
  482. <p>The angle in radians.</p>
  483. </td>
  484. </tr>
  485. </tbody>
  486. </table>
  487. <dl class="details">
  488. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  489. </dl>
  490. </div>
  491. <h3 class="name name-method" id="rotateZ" translate="no">.<a href="#rotateZ">rotateZ</a><span class="signature">( angle : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  492. <div class="method">
  493. <div class="description">
  494. <p>Rotates the geometry about the Z axis. This is typically done as a one time
  495. operation, and not during a loop. Use <a href="Object3D.html#rotation">Object3D#rotation</a> for typical
  496. real-time mesh rotation.</p>
  497. </div>
  498. <table class="params">
  499. <tbody>
  500. <tr>
  501. <td class="name">
  502. <strong>angle</strong>
  503. </td>
  504. <td class="description last">
  505. <p>The angle in radians.</p>
  506. </td>
  507. </tr>
  508. </tbody>
  509. </table>
  510. <dl class="details">
  511. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  512. </dl>
  513. </div>
  514. <h3 class="name name-method" id="scale" translate="no">.<a href="#scale">scale</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"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  515. <div class="method">
  516. <div class="description">
  517. <p>Scales the geometry. This is typically done as a one time
  518. operation, and not during a loop. Use <a href="Object3D.html#scale">Object3D#scale</a> for typical
  519. real-time mesh rotation.</p>
  520. </div>
  521. <table class="params">
  522. <tbody>
  523. <tr>
  524. <td class="name">
  525. <strong>x</strong>
  526. </td>
  527. <td class="description last">
  528. <p>The x scale.</p>
  529. </td>
  530. </tr>
  531. <tr>
  532. <td class="name">
  533. <strong>y</strong>
  534. </td>
  535. <td class="description last">
  536. <p>The y scale.</p>
  537. </td>
  538. </tr>
  539. <tr>
  540. <td class="name">
  541. <strong>z</strong>
  542. </td>
  543. <td class="description last">
  544. <p>The z scale.</p>
  545. </td>
  546. </tr>
  547. </tbody>
  548. </table>
  549. <dl class="details">
  550. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  551. </dl>
  552. </div>
  553. <h3 class="name name-method" id="setAttribute" translate="no">.<a href="#setAttribute">setAttribute</a><span class="signature">( name : <span class="param-type">string</span>, attribute : <span class="param-type"><a href="BufferAttribute.html">BufferAttribute</a> | <a href="InterleavedBufferAttribute.html">InterleavedBufferAttribute</a></span> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  554. <div class="method">
  555. <div class="description">
  556. <p>Sets the given attribute for the given name.</p>
  557. </div>
  558. <table class="params">
  559. <tbody>
  560. <tr>
  561. <td class="name">
  562. <strong>name</strong>
  563. </td>
  564. <td class="description last">
  565. <p>The attribute name.</p>
  566. </td>
  567. </tr>
  568. <tr>
  569. <td class="name">
  570. <strong>attribute</strong>
  571. </td>
  572. <td class="description last">
  573. <p>The attribute to set.</p>
  574. </td>
  575. </tr>
  576. </tbody>
  577. </table>
  578. <dl class="details">
  579. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  580. </dl>
  581. </div>
  582. <h3 class="name name-method" id="setDrawRange" translate="no">.<a href="#setDrawRange">setDrawRange</a><span class="signature">( start : <span class="param-type">number</span>, count : <span class="param-type">number</span> )</span> </h3>
  583. <div class="method">
  584. <div class="description">
  585. <p>Sets the draw range for this geometry.</p>
  586. </div>
  587. <table class="params">
  588. <tbody>
  589. <tr>
  590. <td class="name">
  591. <strong>start</strong>
  592. </td>
  593. <td class="description last">
  594. <p>The first vertex for non-indexed geometry, otherwise the first triangle index.</p>
  595. </td>
  596. </tr>
  597. <tr>
  598. <td class="name">
  599. <strong>count</strong>
  600. </td>
  601. <td class="description last">
  602. <p>For non-indexed BufferGeometry, <code>count</code> is the number of vertices to render.
  603. For indexed BufferGeometry, <code>count</code> is the number of indices to render.</p>
  604. </td>
  605. </tr>
  606. </tbody>
  607. </table>
  608. </div>
  609. <h3 class="name name-method" id="setFromPoints" translate="no">.<a href="#setFromPoints">setFromPoints</a><span class="signature">( points : <span class="param-type">Array.&lt;<a href="Vector2.html">Vector2</a>> | Array.&lt;<a href="Vector3.html">Vector3</a>></span> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  610. <div class="method">
  611. <div class="description">
  612. <p>Defines a geometry by creating a <code>position</code> attribute based on the given array of points. The array
  613. can hold 2D or 3D vectors. When using two-dimensional data, the <code>z</code> coordinate for all vertices is
  614. set to <code>0</code>.</p>
  615. <p>If the method is used with an existing <code>position</code> attribute, the vertex data are overwritten with the
  616. data from the array. The length of the array must match the vertex count.</p>
  617. </div>
  618. <table class="params">
  619. <tbody>
  620. <tr>
  621. <td class="name">
  622. <strong>points</strong>
  623. </td>
  624. <td class="description last">
  625. <p>The points.</p>
  626. </td>
  627. </tr>
  628. </tbody>
  629. </table>
  630. <dl class="details">
  631. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  632. </dl>
  633. </div>
  634. <h3 class="name name-method" id="setIndex" translate="no">.<a href="#setIndex">setIndex</a><span class="signature">( index : <span class="param-type">Array.&lt;number> | <a href="BufferAttribute.html">BufferAttribute</a></span> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  635. <div class="method">
  636. <div class="description">
  637. <p>Sets the given index to this geometry.</p>
  638. </div>
  639. <table class="params">
  640. <tbody>
  641. <tr>
  642. <td class="name">
  643. <strong>index</strong>
  644. </td>
  645. <td class="description last">
  646. <p>The index to set.</p>
  647. </td>
  648. </tr>
  649. </tbody>
  650. </table>
  651. <dl class="details">
  652. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  653. </dl>
  654. </div>
  655. <h3 class="name name-method" id="setIndirect" translate="no">.<a href="#setIndirect">setIndirect</a><span class="signature">( indirect : <span class="param-type"><a href="BufferAttribute.html">BufferAttribute</a></span>, indirectOffset : <span class="param-type">number | Array.&lt;number></span> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  656. <div class="method">
  657. <div class="description">
  658. <p>Sets the given indirect attribute to this geometry.</p>
  659. </div>
  660. <table class="params">
  661. <tbody>
  662. <tr>
  663. <td class="name">
  664. <strong>indirect</strong>
  665. </td>
  666. <td class="description last">
  667. <p>The attribute holding indirect draw calls.</p>
  668. </td>
  669. </tr>
  670. <tr>
  671. <td class="name">
  672. <strong>indirectOffset</strong>
  673. </td>
  674. <td class="description last">
  675. <p>The offset, in bytes, into the indirect drawing buffer where the value data begins. If an array is provided, multiple indirect draw calls will be made for each offset.</p>
  676. <p>Default is <code>0</code>.</p>
  677. </td>
  678. </tr>
  679. </tbody>
  680. </table>
  681. <dl class="details">
  682. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  683. </dl>
  684. </div>
  685. <h3 class="name name-method" id="toJSON" translate="no">.<a href="#toJSON">toJSON</a><span class="signature">()</span><span class="type-signature"> : Object</span> </h3>
  686. <div class="method">
  687. <div class="description">
  688. <p>Serializes the geometry into JSON.</p>
  689. </div>
  690. <dl class="details">
  691. <dt class="tag-returns"><strong>Returns:</strong> A JSON object representing the serialized geometry.</dt>
  692. </dl>
  693. </div>
  694. <h3 class="name name-method" id="toNonIndexed" translate="no">.<a href="#toNonIndexed">toNonIndexed</a><span class="signature">()</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  695. <div class="method">
  696. <div class="description">
  697. <p>Return a new non-index version of this indexed geometry. If the geometry
  698. is already non-indexed, the method is a NOOP.</p>
  699. </div>
  700. <dl class="details">
  701. <dt class="tag-returns"><strong>Returns:</strong> The non-indexed version of this indexed geometry.</dt>
  702. </dl>
  703. </div>
  704. <h3 class="name name-method" id="translate" translate="no">.<a href="#translate">translate</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"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  705. <div class="method">
  706. <div class="description">
  707. <p>Translates the geometry. This is typically done as a one time
  708. operation, and not during a loop. Use <a href="Object3D.html#position">Object3D#position</a> for typical
  709. real-time mesh rotation.</p>
  710. </div>
  711. <table class="params">
  712. <tbody>
  713. <tr>
  714. <td class="name">
  715. <strong>x</strong>
  716. </td>
  717. <td class="description last">
  718. <p>The x offset.</p>
  719. </td>
  720. </tr>
  721. <tr>
  722. <td class="name">
  723. <strong>y</strong>
  724. </td>
  725. <td class="description last">
  726. <p>The y offset.</p>
  727. </td>
  728. </tr>
  729. <tr>
  730. <td class="name">
  731. <strong>z</strong>
  732. </td>
  733. <td class="description last">
  734. <p>The z offset.</p>
  735. </td>
  736. </tr>
  737. </tbody>
  738. </table>
  739. <dl class="details">
  740. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  741. </dl>
  742. </div>
  743. <h2 class="subsection-title">Source</h2>
  744. <p>
  745. <a href="https://github.com/mrdoob/three.js/blob/master/src/core/BufferGeometry.js" translate="no" target="_blank" rel="noopener">src/core/BufferGeometry.js</a>
  746. </p>
  747. </article>
  748. </section>
  749. <script src="../scripts/linenumber.js"></script>
  750. <script src="../scripts/page.js"></script>
  751. </body>
  752. </html>
粤ICP备19079148号