GLBufferAttribute.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. 此缓冲区属性类不构造 VBO。相反,它使用在构造函数中传递的任何 VBO,以后可以通过 缓冲区属性进行更改。<br /><br />
  13. 它需要与 VBO 一起传递额外的参数。它们是:GL 上下文、GL 数据类型、每个顶点的组件数、每个组件的字节数和顶点数。<br /><br />
  14. 此类最常见的用例是当某种 GPGPU 计算干扰甚至产生有问题的 VBO 时。
  15. </p>
  16. <h2>例子</h2>
  17. <p>
  18. [example:webgl_buffergeometry_glbufferattribute Points with custom buffers]<br />
  19. </p>
  20. <h2>构造方法(Constructor)</h2>
  21. <h3>[name]( [param:WebGLBuffer buffer], [param:GLenum type], [param:Integer itemSize], [param:Integer elementSize], [param:Integer count], [param:Boolean normalized] )</h3>
  22. <p>
  23. *buffer* — 必须是 [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer WebGLBuffer].
  24. <br />
  25. *type* — [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Data_types WebGL数据类型]之一.
  26. <br />
  27. *itemSize* — 应与特定顶点关联的数组值的数量。例如,如果此属性存储一个3分量向量(例如位置、法线或颜色),则itemSize应为 3。
  28. <br />
  29. *elementSize* — 1、2 或 4。给定的相应大小(以字节为单位)“类型”参数。
  30. <ul>
  31. <li>gl.FLOAT: 4</li>
  32. <li>gl.UNSIGNED_SHORT: 2</li>
  33. <li>gl.SHORT: 2</li>
  34. <li>gl.UNSIGNED_INT: 4</li>
  35. <li>gl.INT: 4</li>
  36. <li>gl.BYTE: 1</li>
  37. <li>gl.UNSIGNED_BYTE: 1</li>
  38. </ul>
  39. *count* — VBO 中预期的顶点数。
  40. <br />
  41. *normalized* — (optional) 仅适用于整数数据。指示缓冲区中的底层数据如何映射到 GLSL 代码中的值。
  42. 例如,如果 [page:WebGLBuffer buffer] 包含 `gl.UNSIGNED_SHORT` 的数据,
  43. 且 [page:Boolean normalized] 为 true,则缓冲区数据中的值 `0 -
  44. +65535` 将映射到 GLSL 属性中的 0.0f - +1.0f 。 `gl.SHORT` (有符号) 将映射为 -32768 - +32767 到 -1.0f
  45. - +1.0f。如果 [page:Boolean normalized] 为 false, 则值将转换为未修改的浮点数,即 32767 变为 32767.0f。
  46. </p>
  47. <h2>特性(Properties)</h2>
  48. <h3>[property:WebGLBuffer buffer]</h3>
  49. <p>
  50. 当前[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer WebGLBuffer]的实例.
  51. </p>
  52. <h3>[property:Integer count]</h3>
  53. <p>
  54. VBO 中的预期顶点数。
  55. </p>
  56. <h3>[property:Integer elementSize]</h3>
  57. <p>
  58. 存储当前类型属性值的相应大小(以字节为单位)。
  59. </p>
  60. <p>
  61. 有关已知类型大小的列表,请参见上面的(构造函数)。
  62. </p>
  63. <h3>[property:Boolean isGLBufferAttribute]</h3>
  64. <p>
  65. 只读。值永远为"true"。
  66. </p>
  67. <h3>[property:Integer itemSize]</h3>
  68. <p>
  69. 每个项目(顶点)组成多少个值。
  70. </p>
  71. <h3>[property:String name]</h3>
  72. <p>
  73. 该attribute实例的别名,默认值为空字符串。
  74. </p>
  75. <h3>[property:Boolean needsUpdate]</h3>
  76. <p>
  77. 默认为假。将此设置为 true 增量[page:GLBufferAttribute.version 版本]
  78. </p>
  79. <h3>[property:Boolean normalized]</h3>
  80. <p>
  81. Indicates how the underlying data in the buffer maps to the values in the
  82. GLSL shader code. See the constructor above for details.
  83. </p>
  84. <h3>[property:GLenum type]</h3>
  85. <p>
  86. 描述底层 VBO 内容的[link:https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Data_types WebGL数据类型]
  87. </p>
  88. <p>
  89. 将此属性与elementSize一起设置。推荐的方法是使用setType方法。
  90. </p>
  91. <h3>[property:Integer version]</h3>
  92. <p>
  93. 版本号,每次将needsUpdate属性设置为true时递增。
  94. </p>
  95. <h2>方法(Methods)</h2>
  96. <h3>[method:this setBuffer]( buffer ) </h3>
  97. <p>设置缓冲区属性。</p>
  98. <h3>[method:this setType]( type, elementSize ) </h3>
  99. <p>设置type和elementSize属性。</p>
  100. <h3>[method:this setItemSize]( itemSize ) </h3>
  101. <p>设置itemSize属性。</p>
  102. <h3>[method:this setCount]( count ) </h3>
  103. <p>设置计数属性。</p>
  104. <h2>源代码(Source)</h2>
  105. <p>
  106. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  107. </p>
  108. </body>
  109. </html>
粤ICP备19079148号