GLBufferAttribute.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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"><code>buffer</code></td>
  34. <td class="description last"><p>The native WebGL buffer.</p></td>
  35. </tr>
  36. <tr>
  37. <td class="name"><code>type</code></td>
  38. <td class="description last"><p>The native data type (e.g. <code>gl.FLOAT</code>).</p></td>
  39. </tr>
  40. <tr>
  41. <td class="name"><code>itemSize</code></td>
  42. <td class="description last"><p>The item size.</p></td>
  43. </tr>
  44. <tr>
  45. <td class="name"><code>elementSize</code></td>
  46. <td class="description last"><p>The corresponding size (in bytes) for the given <code>type</code> parameter.</p></td>
  47. </tr>
  48. <tr>
  49. <td class="name"><code>count</code></td>
  50. <td class="description last"><p>The expected number of vertices in VBO.</p></td>
  51. </tr>
  52. <tr>
  53. <td class="name"><code>normalized</code></td>
  54. <td class="description last"><p>Whether the data are normalized or not.<br/>Default is <code>false</code>.</p></td>
  55. </tr>
  56. </tbody>
  57. </table>
  58. </div>
  59. </div>
  60. <h2 class="subsection-title">Properties</h2>
  61. <div class="member">
  62. <h3 class="name" id="buffer" translate="no">.<a href="#buffer">buffer</a><span class="type-signature"> : WebGLBuffer</span> </h3>
  63. <div class="description">
  64. <p>The native WebGL buffer.</p>
  65. </div>
  66. </div>
  67. <div class="member">
  68. <h3 class="name" id="count" translate="no">.<a href="#count">count</a><span class="type-signature"> : number</span> </h3>
  69. <div class="description">
  70. <p>The expected number of vertices in VBO.</p>
  71. </div>
  72. </div>
  73. <div class="member">
  74. <h3 class="name" id="elementSize" translate="no">.<a href="#elementSize">elementSize</a><span class="type-signature"> : number</span> </h3>
  75. <div class="description">
  76. <p>The corresponding size (in bytes) for the given <code>type</code> parameter.</p>
  77. </div>
  78. </div>
  79. <div class="member">
  80. <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>
  81. <div class="description">
  82. <p>This flag can be used for type testing.<br/>Default is <code>true</code>.</p>
  83. </div>
  84. </div>
  85. <div class="member">
  86. <h3 class="name" id="itemSize" translate="no">.<a href="#itemSize">itemSize</a><span class="type-signature"> : number</span> </h3>
  87. <div class="description">
  88. <p>The item size, see <a href="BufferAttribute.html#itemSize">BufferAttribute#itemSize</a>.</p>
  89. </div>
  90. </div>
  91. <div class="member">
  92. <h3 class="name" id="name" translate="no">.<a href="#name">name</a><span class="type-signature"> : string</span> </h3>
  93. <div class="description">
  94. <p>The name of the buffer attribute.</p>
  95. </div>
  96. </div>
  97. <div class="member">
  98. <h3 class="name" id="needsUpdate" translate="no">.<a href="#needsUpdate">needsUpdate</a><span class="type-signature"> : number</span> </h3>
  99. <div class="description">
  100. <p>Flag to indicate that this attribute has changed and should be re-sent to
  101. the GPU. Set this to <code>true</code> when you modify the value of the array.<br/>Default is <code>false</code>.</p>
  102. </div>
  103. </div>
  104. <div class="member">
  105. <h3 class="name" id="normalized" translate="no">.<a href="#normalized">normalized</a><span class="type-signature"> : boolean</span> </h3>
  106. <div class="description">
  107. <p>Applies to integer data only. Indicates how the underlying data in the buffer maps to
  108. the values in the GLSL code. For instance, if <code>buffer</code> contains data of <code>gl.UNSIGNED_SHORT</code>,
  109. and <code>normalized</code> is <code>true</code>, the values <code>0 - +65535</code> in the buffer data will be mapped to
  110. <code>0.0f - +1.0f</code> in the GLSL attribute. If <code>normalized</code> is <code>false</code>, the values will be converted
  111. to floats unmodified, i.e. <code>65535</code> becomes <code>65535.0f</code>.</p>
  112. </div>
  113. </div>
  114. <div class="member">
  115. <h3 class="name" id="type" translate="no">.<a href="#type">type</a><span class="type-signature"> : number</span> </h3>
  116. <div class="description">
  117. <p>The native data type.</p>
  118. </div>
  119. </div>
  120. <div class="member">
  121. <h3 class="name" id="version" translate="no">.<a href="#version">version</a><span class="type-signature"> : number</span> </h3>
  122. <div class="description">
  123. <p>A version number, incremented every time the <code>needsUpdate</code> is set to <code>true</code>.</p>
  124. </div>
  125. </div>
  126. <h2 class="subsection-title">Methods</h2>
  127. <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>
  128. <div class="method">
  129. <div class="description">
  130. <p>Sets the given native WebGL buffer.</p>
  131. </div>
  132. <table class="params">
  133. <tbody>
  134. <tr>
  135. <td class="name"><code>buffer</code></td>
  136. <td class="description last"><p>The buffer to set.</p></td>
  137. </tr>
  138. </tbody>
  139. </table>
  140. <dl class="details">
  141. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  142. </dl>
  143. </div>
  144. <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>
  145. <div class="method">
  146. <div class="description">
  147. <p>Sets the count (the expected number of vertices in VBO).</p>
  148. </div>
  149. <table class="params">
  150. <tbody>
  151. <tr>
  152. <td class="name"><code>count</code></td>
  153. <td class="description last"><p>The count.</p></td>
  154. </tr>
  155. </tbody>
  156. </table>
  157. <dl class="details">
  158. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  159. </dl>
  160. </div>
  161. <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>
  162. <div class="method">
  163. <div class="description">
  164. <p>Sets the item size.</p>
  165. </div>
  166. <table class="params">
  167. <tbody>
  168. <tr>
  169. <td class="name"><code>itemSize</code></td>
  170. <td class="description last"><p>The item size.</p></td>
  171. </tr>
  172. </tbody>
  173. </table>
  174. <dl class="details">
  175. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  176. </dl>
  177. </div>
  178. <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>
  179. <div class="method">
  180. <div class="description">
  181. <p>Sets the given native data type and element size.</p>
  182. </div>
  183. <table class="params">
  184. <tbody>
  185. <tr>
  186. <td class="name"><code>type</code></td>
  187. <td class="description last"><p>The native data type (e.g. <code>gl.FLOAT</code>).</p></td>
  188. </tr>
  189. <tr>
  190. <td class="name"><code>elementSize</code></td>
  191. <td class="description last"><p>The corresponding size (in bytes) for the given <code>type</code> parameter.</p></td>
  192. </tr>
  193. </tbody>
  194. </table>
  195. <dl class="details">
  196. <dt class="tag-returns"><strong>Returns:</strong> A reference to this instance.</dt>
  197. </dl>
  198. </div>
  199. <h2 class="subsection-title">Source</h2>
  200. <p>
  201. <a href="https://github.com/mrdoob/three.js/blob/master/src/core/GLBufferAttribute.js" target="_blank" rel="noopener" translate="no">src/core/GLBufferAttribute.js</a>
  202. </p>
  203. </article>
  204. </section>
  205. <script src="../scripts/linenumber.js"></script>
  206. <script src="../scripts/page.js"></script>
  207. </body>
  208. </html>
粤ICP备19079148号