GLBufferAttribute.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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: the
  16. GL context, the GL data type, the number of components per vertex, the
  17. 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>Examples</h2>
  22. <p>
  23. [example:webgl_buffergeometry_glbufferattribute Points with custom buffers]<br />
  24. </p>
  25. <h2>Constructor</h2>
  26. <h3>[name]( [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer itemSize], [param:Integer elementSize], [param:Integer count], [param:Boolean normalized] )</h3>
  27. <p>
  28. `buffer` — Must be a
  29. [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer WebGLBuffer].
  30. <br />
  31. `type` — One of
  32. [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Data_types WebGL Data Types].
  33. <br />
  34. `itemSize` — The number of values of the array that should be associated
  35. with a particular vertex. For instance, if this attribute is storing a
  36. 3-component vector (such as a position, normal, or color), then itemSize
  37. should be 3.
  38. <br />
  39. `elementSize` — 1, 2 or 4. The corresponding size (in bytes) for the given
  40. "type" param.
  41. </p>
  42. <ul>
  43. <li>gl.FLOAT: 4</li>
  44. <li>gl.UNSIGNED_SHORT: 2</li>
  45. <li>gl.SHORT: 2</li>
  46. <li>gl.UNSIGNED_INT: 4</li>
  47. <li>gl.INT: 4</li>
  48. <li>gl.BYTE: 1</li>
  49. <li>gl.UNSIGNED_BYTE: 1</li>
  50. </ul>
  51. `count` — The expected number of vertices in VBO.
  52. <br />
  53. `normalized` — (optional) Applies to integer data only.
  54. Indicates how the underlying data in the buffer maps to the values in the
  55. GLSL code. For instance, if [page:WebGLBuffer buffer] contains data of
  56. `gl.UNSIGNED_SHORT`, and [page:Boolean normalized] is true, the values `0 -
  57. +65535` in the buffer data will be mapped to 0.0f - +1.0f in the GLSL
  58. attribute. A `gl.SHORT` (signed) would map from -32768 - +32767 to -1.0f
  59. - +1.0f. If [page:Boolean normalized] is false, the values will be
  60. converted to floats unmodified, i.e. 32767 becomes 32767.0f.
  61. <h2>Properties</h2>
  62. <h3>[property:WebGLBuffer buffer]</h3>
  63. <p>
  64. The current
  65. [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer WebGLBuffer] instance.
  66. </p>
  67. <h3>[property:Integer count]</h3>
  68. <p>The expected number of vertices in VBO.</p>
  69. <h3>[property:Integer elementSize]</h3>
  70. <p>
  71. Stores the corresponding size in bytes for the current `type` property
  72. value.
  73. </p>
  74. <p>See above (constructor) for a list of known type sizes.</p>
  75. <h3>[property:Boolean isGLBufferAttribute]</h3>
  76. <p>Read-only. Always `true`.</p>
  77. <h3>[property:Integer itemSize]</h3>
  78. <p>How many values make up each item (vertex).</p>
  79. <h3>[property:String name]</h3>
  80. <p>
  81. Optional name for this attribute instance. Default is an empty string.
  82. </p>
  83. <h3>[property:Boolean needsUpdate]</h3>
  84. <p>
  85. Default is `false`. Setting this to true increments
  86. [page:GLBufferAttribute.version version].
  87. </p>
  88. <h3>[property:Boolean normalized]</h3>
  89. <p>
  90. Indicates how the underlying data in the buffer maps to the values in the
  91. GLSL shader code. See the constructor above for details.
  92. </p>
  93. <h3>[property:GLenum type]</h3>
  94. <p>
  95. A
  96. [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Data_types WebGL Data Type] describing the underlying VBO contents.
  97. </p>
  98. <p>
  99. Set this property together with `elementSize`. The recommended way is
  100. using the `setType` method.
  101. </p>
  102. <h3>[property:Integer version]</h3>
  103. <p>
  104. A version number, incremented every time the needsUpdate property is set
  105. to true.
  106. </p>
  107. <h2>Methods</h2>
  108. <h3>[method:this setBuffer]( buffer )</h3>
  109. <p>Sets the `buffer` property.</p>
  110. <h3>[method:this setType]( type, elementSize )</h3>
  111. <p>Sets the both `type` and `elementSize` properties.</p>
  112. <h3>[method:this setItemSize]( itemSize )</h3>
  113. <p>Sets the `itemSize` property.</p>
  114. <h3>[method:this setCount]( count )</h3>
  115. <p>Sets the `count` property.</p>
  116. <h2>Source</h2>
  117. <p>
  118. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  119. </p>
  120. </body>
  121. </html>
粤ICP备19079148号