BufferGeometry.html 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  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="isBufferGeometry" translate="no">.<a href="#isBufferGeometry">isBufferGeometry</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  115. <div class="description">
  116. <p>This flag can be used for type testing.</p>
  117. <p>Default is <code>true</code>.</p>
  118. </div>
  119. </div>
  120. <div class="member">
  121. <h3 class="name" id="morphAttributes" translate="no">.<a href="#morphAttributes">morphAttributes</a><span class="type-signature"> : Object</span> </h3>
  122. <div class="description">
  123. <p>This dictionary holds the morph targets of the geometry.</p>
  124. <p>Note: Once the geometry has been rendered, the morph attribute data cannot
  125. be changed. You will have to call `dispose()?, and create a new geometry instance.</p>
  126. </div>
  127. </div>
  128. <div class="member">
  129. <h3 class="name" id="morphTargetsRelative" translate="no">.<a href="#morphTargetsRelative">morphTargetsRelative</a><span class="type-signature"> : boolean</span> </h3>
  130. <div class="description">
  131. <p>Used to control the morph target behavior; when set to <code>true</code>, the morph
  132. target data is treated as relative offsets, rather than as absolute
  133. positions/normals.</p>
  134. <p>Default is <code>false</code>.</p>
  135. </div>
  136. </div>
  137. <div class="member">
  138. <h3 class="name" id="name" translate="no">.<a href="#name">name</a><span class="type-signature"> : string</span> </h3>
  139. <div class="description">
  140. <p>The name of the geometry.</p>
  141. </div>
  142. </div>
  143. <div class="member">
  144. <h3 class="name" id="userData" translate="no">.<a href="#userData">userData</a><span class="type-signature"> : Object</span> </h3>
  145. <div class="description">
  146. <p>An object that can be used to store custom data about the geometry.
  147. It should not hold references to functions as these will not be cloned.</p>
  148. </div>
  149. </div>
  150. <div class="member">
  151. <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>
  152. <div class="description">
  153. <p>The UUID of the geometry.</p>
  154. </div>
  155. </div>
  156. <h2 class="subsection-title">Methods</h2>
  157. <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>
  158. <div class="method">
  159. <div class="description">
  160. <p>Adds a group to this geometry.</p>
  161. </div>
  162. <table class="params">
  163. <tbody>
  164. <tr>
  165. <td class="name">
  166. <strong>start</strong>
  167. </td>
  168. <td class="description last">
  169. <p>The first element in this draw call. That is the first
  170. vertex for non-indexed geometry, otherwise the first triangle index.</p>
  171. </td>
  172. </tr>
  173. <tr>
  174. <td class="name">
  175. <strong>count</strong>
  176. </td>
  177. <td class="description last">
  178. <p>Specifies how many vertices (or indices) are part of this group.</p>
  179. </td>
  180. </tr>
  181. <tr>
  182. <td class="name">
  183. <strong>materialIndex</strong>
  184. </td>
  185. <td class="description last">
  186. <p>The material array index to use.</p>
  187. <p>Default is <code>0</code>.</p>
  188. </td>
  189. </tr>
  190. </tbody>
  191. </table>
  192. </div>
  193. <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>
  194. <div class="method">
  195. <div class="description">
  196. <p>Applies the given 4x4 transformation matrix to the geometry.</p>
  197. </div>
  198. <table class="params">
  199. <tbody>
  200. <tr>
  201. <td class="name">
  202. <strong>matrix</strong>
  203. </td>
  204. <td class="description last">
  205. <p>The matrix to apply.</p>
  206. </td>
  207. </tr>
  208. </tbody>
  209. </table>
  210. <dl class="details">
  211. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  212. </dl>
  213. </div>
  214. <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>
  215. <div class="method">
  216. <div class="description">
  217. <p>Applies the rotation represented by the Quaternion to the geometry.</p>
  218. </div>
  219. <table class="params">
  220. <tbody>
  221. <tr>
  222. <td class="name">
  223. <strong>q</strong>
  224. </td>
  225. <td class="description last">
  226. <p>The Quaternion to apply.</p>
  227. </td>
  228. </tr>
  229. </tbody>
  230. </table>
  231. <dl class="details">
  232. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  233. </dl>
  234. </div>
  235. <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>
  236. <div class="method">
  237. <div class="description">
  238. <p>Center the geometry based on its bounding box.</p>
  239. </div>
  240. <dl class="details">
  241. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  242. </dl>
  243. </div>
  244. <h3 class="name name-method" id="clearGroups" translate="no">.<a href="#clearGroups">clearGroups</a><span class="signature">()</span> </h3>
  245. <div class="method">
  246. <div class="description">
  247. <p>Clears all groups.</p>
  248. </div>
  249. </div>
  250. <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>
  251. <div class="method">
  252. <div class="description">
  253. <p>Returns a new geometry with copied values from this instance.</p>
  254. </div>
  255. <dl class="details">
  256. <dt class="tag-returns"><strong>Returns:</strong> A clone of this instance.</dt>
  257. </dl>
  258. </div>
  259. <h3 class="name name-method" id="computeBoundingBox" translate="no">.<a href="#computeBoundingBox">computeBoundingBox</a><span class="signature">()</span> </h3>
  260. <div class="method">
  261. <div class="description">
  262. <p>Computes the bounding box of the geometry, and updates the <code>boundingBox</code> member.
  263. The bounding box is not computed by the engine; it must be computed by your app.
  264. You may need to recompute the bounding box if the geometry vertices are modified.</p>
  265. </div>
  266. </div>
  267. <h3 class="name name-method" id="computeBoundingSphere" translate="no">.<a href="#computeBoundingSphere">computeBoundingSphere</a><span class="signature">()</span> </h3>
  268. <div class="method">
  269. <div class="description">
  270. <p>Computes the bounding sphere of the geometry, and updates the <code>boundingSphere</code> member.
  271. The engine automatically computes the bounding sphere when it is needed, e.g., for ray casting or view frustum culling.
  272. You may need to recompute the bounding sphere if the geometry vertices are modified.</p>
  273. </div>
  274. </div>
  275. <h3 class="name name-method" id="computeTangents" translate="no">.<a href="#computeTangents">computeTangents</a><span class="signature">()</span> </h3>
  276. <div class="method">
  277. <div class="description">
  278. <p>Calculates and adds a tangent attribute to this geometry.</p>
  279. <p>The computation is only supported for indexed geometries and if position, normal, and uv attributes
  280. are defined. When using a tangent space normal map, prefer the MikkTSpace algorithm provided by
  281. BufferGeometryUtils#computeMikkTSpaceTangents instead.</p>
  282. </div>
  283. </div>
  284. <h3 class="name name-method" id="computeVertexNormals" translate="no">.<a href="#computeVertexNormals">computeVertexNormals</a><span class="signature">()</span> </h3>
  285. <div class="method">
  286. <div class="description">
  287. <p>Computes vertex normals for the given vertex data. For indexed geometries, the method sets
  288. each vertex normal to be the average of the face normals of the faces that share that vertex.
  289. For non-indexed geometries, vertices are not shared, and the method sets each vertex normal
  290. to be the same as the face normal.</p>
  291. </div>
  292. </div>
  293. <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>
  294. <div class="method">
  295. <div class="description">
  296. <p>Copies the values of the given geometry to this instance.</p>
  297. </div>
  298. <table class="params">
  299. <tbody>
  300. <tr>
  301. <td class="name">
  302. <strong>source</strong>
  303. </td>
  304. <td class="description last">
  305. <p>The geometry to copy.</p>
  306. </td>
  307. </tr>
  308. </tbody>
  309. </table>
  310. <dl class="details">
  311. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  312. </dl>
  313. </div>
  314. <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>
  315. <div class="method">
  316. <div class="description">
  317. <p>Deletes the attribute for the given name.</p>
  318. </div>
  319. <table class="params">
  320. <tbody>
  321. <tr>
  322. <td class="name">
  323. <strong>name</strong>
  324. </td>
  325. <td class="description last">
  326. <p>The attribute name to delete.</p>
  327. </td>
  328. </tr>
  329. </tbody>
  330. </table>
  331. <dl class="details">
  332. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  333. </dl>
  334. </div>
  335. <h3 class="name name-method" id="dispose" translate="no">.<a href="#dispose">dispose</a><span class="signature">()</span> </h3>
  336. <div class="method">
  337. <div class="description">
  338. <p>Frees the GPU-related resources allocated by this instance. Call this
  339. method whenever this instance is no longer used in your app.</p>
  340. </div>
  341. <h5>Fires:</h5>
  342. <ul>
  343. <li>BufferGeometry#event:dispose</li>
  344. </ul>
  345. </div>
  346. <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>
  347. <div class="method">
  348. <div class="description">
  349. <p>Returns the buffer attribute for the given name.</p>
  350. </div>
  351. <table class="params">
  352. <tbody>
  353. <tr>
  354. <td class="name">
  355. <strong>name</strong>
  356. </td>
  357. <td class="description last">
  358. <p>The attribute name.</p>
  359. </td>
  360. </tr>
  361. </tbody>
  362. </table>
  363. <dl class="details">
  364. <dt class="tag-returns"><strong>Returns:</strong> The buffer attribute.
  365. Returns <code>undefined</code> if not attribute has been found.</dt>
  366. </dl>
  367. </div>
  368. <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>
  369. <div class="method">
  370. <div class="description">
  371. <p>Returns the index of this geometry.</p>
  372. </div>
  373. <dl class="details">
  374. <dt class="tag-returns"><strong>Returns:</strong> The index. Returns <code>null</code> if no index is defined.</dt>
  375. </dl>
  376. </div>
  377. <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>
  378. <div class="method">
  379. <div class="description">
  380. <p>Returns the indirect attribute of this geometry.</p>
  381. </div>
  382. <dl class="details">
  383. <dt class="tag-returns"><strong>Returns:</strong> The indirect attribute. Returns <code>null</code> if no indirect attribute is defined.</dt>
  384. </dl>
  385. </div>
  386. <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>
  387. <div class="method">
  388. <div class="description">
  389. <p>Returns <code>true</code> if this geometry has an attribute for the given name.</p>
  390. </div>
  391. <table class="params">
  392. <tbody>
  393. <tr>
  394. <td class="name">
  395. <strong>name</strong>
  396. </td>
  397. <td class="description last">
  398. <p>The attribute name.</p>
  399. </td>
  400. </tr>
  401. </tbody>
  402. </table>
  403. <dl class="details">
  404. <dt class="tag-returns"><strong>Returns:</strong> Whether this geometry has an attribute for the given name or not.</dt>
  405. </dl>
  406. </div>
  407. <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>
  408. <div class="method">
  409. <div class="description">
  410. <p>Rotates the geometry to face a point in 3D space. This is typically done as a one time
  411. operation, and not during a loop. Use <a href="Object3D.html#lookAt">Object3D#lookAt</a> for typical
  412. real-time mesh rotation.</p>
  413. </div>
  414. <table class="params">
  415. <tbody>
  416. <tr>
  417. <td class="name">
  418. <strong>vector</strong>
  419. </td>
  420. <td class="description last">
  421. <p>The target point.</p>
  422. </td>
  423. </tr>
  424. </tbody>
  425. </table>
  426. <dl class="details">
  427. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  428. </dl>
  429. </div>
  430. <h3 class="name name-method" id="normalizeNormals" translate="no">.<a href="#normalizeNormals">normalizeNormals</a><span class="signature">()</span> </h3>
  431. <div class="method">
  432. <div class="description">
  433. <p>Ensures every normal vector in a geometry will have a magnitude of <code>1</code>. This will
  434. correct lighting on the geometry surfaces.</p>
  435. </div>
  436. </div>
  437. <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>
  438. <div class="method">
  439. <div class="description">
  440. <p>Rotates the geometry about the X axis. This is typically done as a one time
  441. operation, and not during a loop. Use <a href="Object3D.html#rotation">Object3D#rotation</a> for typical
  442. real-time mesh rotation.</p>
  443. </div>
  444. <table class="params">
  445. <tbody>
  446. <tr>
  447. <td class="name">
  448. <strong>angle</strong>
  449. </td>
  450. <td class="description last">
  451. <p>The angle in radians.</p>
  452. </td>
  453. </tr>
  454. </tbody>
  455. </table>
  456. <dl class="details">
  457. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  458. </dl>
  459. </div>
  460. <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>
  461. <div class="method">
  462. <div class="description">
  463. <p>Rotates the geometry about the Y axis. This is typically done as a one time
  464. operation, and not during a loop. Use <a href="Object3D.html#rotation">Object3D#rotation</a> for typical
  465. real-time mesh rotation.</p>
  466. </div>
  467. <table class="params">
  468. <tbody>
  469. <tr>
  470. <td class="name">
  471. <strong>angle</strong>
  472. </td>
  473. <td class="description last">
  474. <p>The angle in radians.</p>
  475. </td>
  476. </tr>
  477. </tbody>
  478. </table>
  479. <dl class="details">
  480. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  481. </dl>
  482. </div>
  483. <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>
  484. <div class="method">
  485. <div class="description">
  486. <p>Rotates the geometry about the Z axis. This is typically done as a one time
  487. operation, and not during a loop. Use <a href="Object3D.html#rotation">Object3D#rotation</a> for typical
  488. real-time mesh rotation.</p>
  489. </div>
  490. <table class="params">
  491. <tbody>
  492. <tr>
  493. <td class="name">
  494. <strong>angle</strong>
  495. </td>
  496. <td class="description last">
  497. <p>The angle in radians.</p>
  498. </td>
  499. </tr>
  500. </tbody>
  501. </table>
  502. <dl class="details">
  503. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  504. </dl>
  505. </div>
  506. <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>
  507. <div class="method">
  508. <div class="description">
  509. <p>Scales the geometry. This is typically done as a one time
  510. operation, and not during a loop. Use <a href="Object3D.html#scale">Object3D#scale</a> for typical
  511. real-time mesh rotation.</p>
  512. </div>
  513. <table class="params">
  514. <tbody>
  515. <tr>
  516. <td class="name">
  517. <strong>x</strong>
  518. </td>
  519. <td class="description last">
  520. <p>The x scale.</p>
  521. </td>
  522. </tr>
  523. <tr>
  524. <td class="name">
  525. <strong>y</strong>
  526. </td>
  527. <td class="description last">
  528. <p>The y scale.</p>
  529. </td>
  530. </tr>
  531. <tr>
  532. <td class="name">
  533. <strong>z</strong>
  534. </td>
  535. <td class="description last">
  536. <p>The z scale.</p>
  537. </td>
  538. </tr>
  539. </tbody>
  540. </table>
  541. <dl class="details">
  542. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  543. </dl>
  544. </div>
  545. <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>
  546. <div class="method">
  547. <div class="description">
  548. <p>Sets the given attribute for the given name.</p>
  549. </div>
  550. <table class="params">
  551. <tbody>
  552. <tr>
  553. <td class="name">
  554. <strong>name</strong>
  555. </td>
  556. <td class="description last">
  557. <p>The attribute name.</p>
  558. </td>
  559. </tr>
  560. <tr>
  561. <td class="name">
  562. <strong>attribute</strong>
  563. </td>
  564. <td class="description last">
  565. <p>The attribute to set.</p>
  566. </td>
  567. </tr>
  568. </tbody>
  569. </table>
  570. <dl class="details">
  571. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  572. </dl>
  573. </div>
  574. <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>
  575. <div class="method">
  576. <div class="description">
  577. <p>Sets the draw range for this geometry.</p>
  578. </div>
  579. <table class="params">
  580. <tbody>
  581. <tr>
  582. <td class="name">
  583. <strong>start</strong>
  584. </td>
  585. <td class="description last">
  586. <p>The first vertex for non-indexed geometry, otherwise the first triangle index.</p>
  587. </td>
  588. </tr>
  589. <tr>
  590. <td class="name">
  591. <strong>count</strong>
  592. </td>
  593. <td class="description last">
  594. <p>For non-indexed BufferGeometry, <code>count</code> is the number of vertices to render.
  595. For indexed BufferGeometry, <code>count</code> is the number of indices to render.</p>
  596. </td>
  597. </tr>
  598. </tbody>
  599. </table>
  600. </div>
  601. <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>
  602. <div class="method">
  603. <div class="description">
  604. <p>Defines a geometry by creating a <code>position</code> attribute based on the given array of points. The array
  605. can hold 2D or 3D vectors. When using two-dimensional data, the <code>z</code> coordinate for all vertices is
  606. set to <code>0</code>.</p>
  607. <p>If the method is used with an existing <code>position</code> attribute, the vertex data are overwritten with the
  608. data from the array. The length of the array must match the vertex count.</p>
  609. </div>
  610. <table class="params">
  611. <tbody>
  612. <tr>
  613. <td class="name">
  614. <strong>points</strong>
  615. </td>
  616. <td class="description last">
  617. <p>The points.</p>
  618. </td>
  619. </tr>
  620. </tbody>
  621. </table>
  622. <dl class="details">
  623. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  624. </dl>
  625. </div>
  626. <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>
  627. <div class="method">
  628. <div class="description">
  629. <p>Sets the given index to this geometry.</p>
  630. </div>
  631. <table class="params">
  632. <tbody>
  633. <tr>
  634. <td class="name">
  635. <strong>index</strong>
  636. </td>
  637. <td class="description last">
  638. <p>The index to set.</p>
  639. </td>
  640. </tr>
  641. </tbody>
  642. </table>
  643. <dl class="details">
  644. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  645. </dl>
  646. </div>
  647. <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> )</span><span class="type-signature"> : <a href="BufferGeometry.html">BufferGeometry</a></span> </h3>
  648. <div class="method">
  649. <div class="description">
  650. <p>Sets the given indirect attribute to this geometry.</p>
  651. </div>
  652. <table class="params">
  653. <tbody>
  654. <tr>
  655. <td class="name">
  656. <strong>indirect</strong>
  657. </td>
  658. <td class="description last">
  659. <p>The attribute holding indirect draw calls.</p>
  660. </td>
  661. </tr>
  662. </tbody>
  663. </table>
  664. <dl class="details">
  665. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  666. </dl>
  667. </div>
  668. <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>
  669. <div class="method">
  670. <div class="description">
  671. <p>Serializes the geometry into JSON.</p>
  672. </div>
  673. <dl class="details">
  674. <dt class="tag-returns"><strong>Returns:</strong> A JSON object representing the serialized geometry.</dt>
  675. </dl>
  676. </div>
  677. <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>
  678. <div class="method">
  679. <div class="description">
  680. <p>Return a new non-index version of this indexed geometry. If the geometry
  681. is already non-indexed, the method is a NOOP.</p>
  682. </div>
  683. <dl class="details">
  684. <dt class="tag-returns"><strong>Returns:</strong> The non-indexed version of this indexed geometry.</dt>
  685. </dl>
  686. </div>
  687. <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>
  688. <div class="method">
  689. <div class="description">
  690. <p>Translates the geometry. This is typically done as a one time
  691. operation, and not during a loop. Use <a href="Object3D.html#position">Object3D#position</a> for typical
  692. real-time mesh rotation.</p>
  693. </div>
  694. <table class="params">
  695. <tbody>
  696. <tr>
  697. <td class="name">
  698. <strong>x</strong>
  699. </td>
  700. <td class="description last">
  701. <p>The x offset.</p>
  702. </td>
  703. </tr>
  704. <tr>
  705. <td class="name">
  706. <strong>y</strong>
  707. </td>
  708. <td class="description last">
  709. <p>The y offset.</p>
  710. </td>
  711. </tr>
  712. <tr>
  713. <td class="name">
  714. <strong>z</strong>
  715. </td>
  716. <td class="description last">
  717. <p>The z offset.</p>
  718. </td>
  719. </tr>
  720. </tbody>
  721. </table>
  722. <dl class="details">
  723. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  724. </dl>
  725. </div>
  726. <h2 class="subsection-title">Source</h2>
  727. <p>
  728. <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>
  729. </p>
  730. </article>
  731. </section>
  732. <script src="../scripts/linenumber.js"></script>
  733. <script src="../scripts/page.js"></script>
  734. </body>
  735. </html>
粤ICP备19079148号