GLBufferAttribute.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>GLBufferAttribute - 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. <h1 translate="no">GLBufferAttribute</h1>
  13. <section>
  14. <header>
  15. <div class="class-description"><p>An alternative version of a buffer attribute with more control over the VBO.</p>
  16. <p>The renderer does not construct a VBO for this kind of attribute. Instead, it uses
  17. whatever VBO is passed in constructor and can later be altered via the <code>buffer</code> property.</p>
  18. <p>The most common use case for this class is when some kind of GPGPU calculation interferes
  19. or even produces the VBOs in question.</p>
  20. <p>Notice that this class can only be used with <a href="WebGLRenderer.html">WebGLRenderer</a>.</p></div>
  21. </header>
  22. <article>
  23. <div class="container-overview">
  24. <h2>Constructor</h2>
  25. <h3 class="name name-method" id="GLBufferAttribute" translate="no">new <a href="#GLBufferAttribute">GLBufferAttribute</a><span class="signature">( buffer : <span class="param-type">WebGLBuffer</span>, type : <span class="param-type">number</span>, itemSize : <span class="param-type">number</span>, elementSize : <span class="param-type">number</span>, count : <span class="param-type">number</span>, normalized : <span class="param-type">boolean</span> )</span> </h3>
  26. <div class="method">
  27. <div class="description">
  28. <p>Constructs a new GL buffer attribute.</p>
  29. </div>
  30. <table class="params">
  31. <tbody>
  32. <tr>
  33. <td class="name">
  34. <strong>buffer</strong>
  35. </td>
  36. <td class="description last">
  37. <p>The native WebGL buffer.</p>
  38. </td>
  39. </tr>
  40. <tr>
  41. <td class="name">
  42. <strong>type</strong>
  43. </td>
  44. <td class="description last">
  45. <p>The native data type (e.g. <code>gl.FLOAT</code>).</p>
  46. </td>
  47. </tr>
  48. <tr>
  49. <td class="name">
  50. <strong>itemSize</strong>
  51. </td>
  52. <td class="description last">
  53. <p>The item size.</p>
  54. </td>
  55. </tr>
  56. <tr>
  57. <td class="name">
  58. <strong>elementSize</strong>
  59. </td>
  60. <td class="description last">
  61. <p>The corresponding size (in bytes) for the given <code>type</code> parameter.</p>
  62. </td>
  63. </tr>
  64. <tr>
  65. <td class="name">
  66. <strong>count</strong>
  67. </td>
  68. <td class="description last">
  69. <p>The expected number of vertices in VBO.</p>
  70. </td>
  71. </tr>
  72. <tr>
  73. <td class="name">
  74. <strong>normalized</strong>
  75. </td>
  76. <td class="description last">
  77. <p>Whether the data are normalized or not.</p>
  78. <p>Default is <code>false</code>.</p>
  79. </td>
  80. </tr>
  81. </tbody>
  82. </table>
  83. </div>
  84. </div>
  85. <h2 class="subsection-title">Properties</h2>
  86. <div class="member">
  87. <h3 class="name" id="buffer" translate="no">.<a href="#buffer">buffer</a><span class="type-signature"> : WebGLBuffer</span> </h3>
  88. <div class="description">
  89. <p>The native WebGL buffer.</p>
  90. </div>
  91. </div>
  92. <div class="member">
  93. <h3 class="name" id="count" translate="no">.<a href="#count">count</a><span class="type-signature"> : number</span> </h3>
  94. <div class="description">
  95. <p>The expected number of vertices in VBO.</p>
  96. </div>
  97. </div>
  98. <div class="member">
  99. <h3 class="name" id="elementSize" translate="no">.<a href="#elementSize">elementSize</a><span class="type-signature"> : number</span> </h3>
  100. <div class="description">
  101. <p>The corresponding size (in bytes) for the given <code>type</code> parameter.</p>
  102. </div>
  103. </div>
  104. <div class="member">
  105. <h3 class="name" id="isGLBufferAttribute" translate="no">.<a href="#isGLBufferAttribute">isGLBufferAttribute</a><span class="type-signature"> : boolean</span> <span class="type-signature">(readonly) </span></h3>
  106. <div class="description">
  107. <p>This flag can be used for type testing.</p>
  108. <p>Default is <code>true</code>.</p>
  109. </div>
  110. </div>
  111. <div class="member">
  112. <h3 class="name" id="itemSize" translate="no">.<a href="#itemSize">itemSize</a><span class="type-signature"> : number</span> </h3>
  113. <div class="description">
  114. <p>The item size, see <a href="BufferAttribute.html#itemSize">BufferAttribute#itemSize</a>.</p>
  115. </div>
  116. </div>
  117. <div class="member">
  118. <h3 class="name" id="name" translate="no">.<a href="#name">name</a><span class="type-signature"> : string</span> </h3>
  119. <div class="description">
  120. <p>The name of the buffer attribute.</p>
  121. </div>
  122. </div>
  123. <div class="member">
  124. <h3 class="name" id="needsUpdate" translate="no">.<a href="#needsUpdate">needsUpdate</a><span class="type-signature"> : number</span> </h3>
  125. <div class="description">
  126. <p>Flag to indicate that this attribute has changed and should be re-sent to
  127. the GPU. Set this to <code>true</code> when you modify the value of the array.</p>
  128. <p>Default is <code>false</code>.</p>
  129. </div>
  130. </div>
  131. <div class="member">
  132. <h3 class="name" id="normalized" translate="no">.<a href="#normalized">normalized</a><span class="type-signature"> : boolean</span> </h3>
  133. <div class="description">
  134. <p>Applies to integer data only. Indicates how the underlying data in the buffer maps to
  135. the values in the GLSL code. For instance, if <code>buffer</code> contains data of <code>gl.UNSIGNED_SHORT</code>,
  136. and <code>normalized</code> is <code>true</code>, the values <code>0 - +65535</code> in the buffer data will be mapped to
  137. <code>0.0f - +1.0f</code> in the GLSL attribute. If <code>normalized</code> is <code>false</code>, the values will be converted
  138. to floats unmodified, i.e. <code>65535</code> becomes <code>65535.0f</code>.</p>
  139. </div>
  140. </div>
  141. <div class="member">
  142. <h3 class="name" id="type" translate="no">.<a href="#type">type</a><span class="type-signature"> : number</span> </h3>
  143. <div class="description">
  144. <p>The native data type.</p>
  145. </div>
  146. </div>
  147. <div class="member">
  148. <h3 class="name" id="version" translate="no">.<a href="#version">version</a><span class="type-signature"> : number</span> </h3>
  149. <div class="description">
  150. <p>A version number, incremented every time the <code>needsUpdate</code> is set to <code>true</code>.</p>
  151. </div>
  152. </div>
  153. <h2 class="subsection-title">Methods</h2>
  154. <h3 class="name name-method" id="setBuffer" translate="no">.<a href="#setBuffer">setBuffer</a><span class="signature">( buffer : <span class="param-type">WebGLBuffer</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  155. <div class="method">
  156. <div class="description">
  157. <p>Sets the given native WebGL buffer.</p>
  158. </div>
  159. <table class="params">
  160. <tbody>
  161. <tr>
  162. <td class="name">
  163. <strong>buffer</strong>
  164. </td>
  165. <td class="description last">
  166. <p>The buffer to set.</p>
  167. </td>
  168. </tr>
  169. </tbody>
  170. </table>
  171. <dl class="details">
  172. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  173. </dl>
  174. </div>
  175. <h3 class="name name-method" id="setCount" translate="no">.<a href="#setCount">setCount</a><span class="signature">( count : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  176. <div class="method">
  177. <div class="description">
  178. <p>Sets the count (the expected number of vertices in VBO).</p>
  179. </div>
  180. <table class="params">
  181. <tbody>
  182. <tr>
  183. <td class="name">
  184. <strong>count</strong>
  185. </td>
  186. <td class="description last">
  187. <p>The count.</p>
  188. </td>
  189. </tr>
  190. </tbody>
  191. </table>
  192. <dl class="details">
  193. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  194. </dl>
  195. </div>
  196. <h3 class="name name-method" id="setItemSize" translate="no">.<a href="#setItemSize">setItemSize</a><span class="signature">( itemSize : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  197. <div class="method">
  198. <div class="description">
  199. <p>Sets the item size.</p>
  200. </div>
  201. <table class="params">
  202. <tbody>
  203. <tr>
  204. <td class="name">
  205. <strong>itemSize</strong>
  206. </td>
  207. <td class="description last">
  208. <p>The item size.</p>
  209. </td>
  210. </tr>
  211. </tbody>
  212. </table>
  213. <dl class="details">
  214. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  215. </dl>
  216. </div>
  217. <h3 class="name name-method" id="setType" translate="no">.<a href="#setType">setType</a><span class="signature">( type : <span class="param-type">number</span>, elementSize : <span class="param-type">number</span> )</span><span class="type-signature"> : <a href="BufferAttribute.html">BufferAttribute</a></span> </h3>
  218. <div class="method">
  219. <div class="description">
  220. <p>Sets the given native data type and element size.</p>
  221. </div>
  222. <table class="params">
  223. <tbody>
  224. <tr>
  225. <td class="name">
  226. <strong>type</strong>
  227. </td>
  228. <td class="description last">
  229. <p>The native data type (e.g. <code>gl.FLOAT</code>).</p>
  230. </td>
  231. </tr>
  232. <tr>
  233. <td class="name">
  234. <strong>elementSize</strong>
  235. </td>
  236. <td class="description last">
  237. <p>The corresponding size (in bytes) for the given <code>type</code> parameter.</p>
  238. </td>
  239. </tr>
  240. </tbody>
  241. </table>
  242. <dl class="details">
  243. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  244. </dl>
  245. </div>
  246. <h2 class="subsection-title">Source</h2>
  247. <p>
  248. <a href="https://github.com/mrdoob/three.js/blob/master/src/core/GLBufferAttribute.js" translate="no" target="_blank" rel="noopener">src/core/GLBufferAttribute.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号