GLBufferAttribute.html 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. <h1>[name]</h1>
  11. <p class="desc">
  12. This buffer attribute class does not construct a VBO. Instead, it uses
  13. whatever VBO is passed in constructor and can later be altered via the
  14. *buffer* property.<br /><br />
  15. It is required to pass additional params alongside the VBO. Those are:
  16. the GL context, the GL data type, the number of components per vertex,
  17. the number of bytes per component, and the number of vertices.<br /><br />
  18. The most common use case for this class is when some kind of GPGPU
  19. calculation interferes or even produces the VBOs in question.
  20. </p>
  21. <h2>Constructor</h2>
  22. <h3>[name]( [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer itemSize], [param:Integer elementSize], [param:Integer count] )</h3>
  23. <p>
  24. *buffer* — Must be a <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer" target="_blank">WebGLBuffer</a>.
  25. <br />
  26. *type* — One of <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Data_types" target="_blank">WebGL Data Types</a>.
  27. <br />
  28. *itemSize* — The number of values of the array that should be associated with
  29. a particular vertex. For instance, if this
  30. attribute is storing a 3-component vector (such as a position, normal, or color), then itemSize should be 3.
  31. <br />
  32. *elementSize* — 1, 2 or 4. The corresponding size (in bytes) for the given "type" param.
  33. <ul>
  34. <li>gl.FLOAT: 4</li>
  35. <li>gl.UNSIGNED_SHORT: 2</li>
  36. <li>gl.SHORT: 2</li>
  37. <li>gl.UNSIGNED_INT: 4</li>
  38. <li>gl.INT: 4</li>
  39. <li>gl.BYTE: 1</li>
  40. <li>gl.UNSIGNED_BYTE: 1</li>
  41. </ul>
  42. *count* — The expected number of vertices in VBO.
  43. </p>
  44. <h2>Properties</h2>
  45. <h3>[property:WebGLBuffer buffer]</h3>
  46. <p>
  47. The current <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer" target="_blank">WebGLBuffer</a> instance.
  48. </p>
  49. <h3>[property:Integer count]</h3>
  50. <p>
  51. The expected number of vertices in VBO.
  52. </p>
  53. <h3>[property:Integer itemSize]</h3>
  54. <p>
  55. How many values make up each item (vertex).
  56. </p>
  57. <h3>[property:Integer elementSize]</h3>
  58. <p>
  59. Stores the corresponding size in bytes for the current *type* property value.
  60. </p>
  61. <p>
  62. See above (constructor) for a list of known type sizes.
  63. </p>
  64. <h3>[property:GLenum type]</h3>
  65. <p>
  66. A <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Data_types" target="_blank">WebGL Data Type</a>
  67. describing the underlying VBO contents.
  68. </p>
  69. <p>
  70. Set this property together with *elementSize*. The recommended way is
  71. using the *setType* method.
  72. </p>
  73. <h3>[property:Boolean isGLBufferAttribute]</h3>
  74. <p>
  75. Read-only. Always *true*.
  76. </p>
  77. <h2>Methods</h2>
  78. <h3>[method:null setBuffer]( buffer ) </h3>
  79. <p>Sets the *buffer* property.</p>
  80. <h3>[method:null setType]( type, elementSize ) </h3>
  81. <p>Sets the both *type* and *elementSize* properties.</p>
  82. <h3>[method:null setItemSize]( itemSize ) </h3>
  83. <p>Sets the *itemSize* property.</p>
  84. <h3>[method:null setCount]( count ) </h3>
  85. <p>Sets the *count* property.</p>
  86. <h3>[property:Integer version]</h3>
  87. <p>
  88. A version number, incremented every time the needsUpdate property is set to true.
  89. </p>
  90. <h3>[property:Boolean needsUpdate]</h3>
  91. <p>
  92. Default is *false*. Setting this to true increments [page:GLBufferAttribute.version version].
  93. </p>
  94. <h2>Source</h2>
  95. <p>
  96. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  97. </p>
  98. </body>
  99. </html>