BufferAttribute.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>[name]</h1>
  12. <div class="desc">
  13. This class stores data for an attribute associated with a [page:BufferGeometry]. See that page for details and a usage example. This class is used to store builtin attributes such as vertex position, normals, color, etc., but can also be used in your code to store custom attributes in a [page:BufferGeometry].
  14. </div>
  15. <h2>Constructor</h2>
  16. <h3>[name]( [page:TypedArray array], [page:Integer itemSize], [page:Boolean normalized] )</h3>
  17. <div>
  18. Instantiates this attribute with data from the associated buffer.
  19. itemSize gives the number of values of the array that should be associated with a particular vertex. normalized indicates how the underlying data in the buffer maps to the values in the GLSL shader code.
  20. </div>
  21. <h2>Properties</h2>
  22. <h3>[property:TypedArray array]</h3>
  23. <div>
  24. Stores the data associated with this attribute. This element should have <code>itemSize * numVertices</code> elements, where numVertices is the number of vertices in the associated [page:BufferGeometry geometry]. [page:TypedArray array] can be an instance of UInt8Array, Int8Array, UInt16Array, Int16Array, or Float32Array.
  25. </div>
  26. <h3>[property:Integer itemSize]</h3>
  27. <div>
  28. Records how many items of the array are associated with a particular vertex. For instance, if this
  29. attribute is storing a 3-component vector (such as a position, normal, or color), then itemSize should be 3.
  30. </div>
  31. <h3>[property:Integer count]</h3>
  32. <div>
  33. Gives the total number of elements in the array.
  34. </div>
  35. <h3>[property:Boolean needsUpdate]</h3>
  36. <div>
  37. Flag to indicate that this attribute has changed and should be re-send to the GPU. Set this to true when you modify the value of the array.
  38. </div>
  39. <h3>[property:Boolean normalized]</h3>
  40. <div>
  41. Indicates how the underlying data in the buffer maps to the values in the GLSL code. For instance, if [page:TypedArray array] is an instance of UInt16Array, and [page:Boolean normalized] is true, the values 0 - +65535 in the array data will be mapped to 0.0f - +1.0f in the GLSL attribute. An Int16Array (signed) would map from -32767 - +32767 to -1.0f - +1.0f. If [page:Boolean normalized] is false, the values will be converted to floats which contain the exact value, i.e. 32767 becomes 32767.0f.
  42. </div>
  43. <h3>[property:Integer version]</h3>
  44. <div>
  45. A version number, incremented every time the needsUpdate property is set to true.
  46. </div>
  47. <h3>[property:Function onUploadCallback]</h3>
  48. <div>
  49. A callback function that is executed after the Renderer has transfered the attribute array data to the GPU.
  50. The callback is executed with a single parameter "name", the name of the buffer attribute, and "this" set to the BufferAttribute object.
  51. </div>
  52. <h2>Methods</h2>
  53. <h3>[method:null copyAt] ( [page:Integer index1], attribute, [page:Integer index2] ) </h3>
  54. <div>
  55. Copies itemSize values in the array from the vertex at index2 to the vertex at index1.
  56. </div>
  57. <h3>[method:null set] ( [page:Array value] ) </h3>
  58. <div>
  59. Sets the associated array with values from the passed array.
  60. </div>
  61. <h3>[method:null setX]( index, x ) </h3>
  62. <div>
  63. Sets the value of the array at <code>index * itemSize</code> to x
  64. </div>
  65. <h3>[method:null setY]( index, y ) </h3>
  66. <div>
  67. Sets the value of the array at <code>index * itemSize + 1</code> to y
  68. </div>
  69. <h3>[method:null setZ]( index, z ) </h3>
  70. <div>
  71. Sets the value of the array at <code>index * itemSize + 2</code> to z
  72. </div>
  73. <h3>[method:null setXY]( index, x, y ) </h3>
  74. <div>
  75. Sets the value of the array at <code>index * itemSize</code> to x and
  76. sets the value of the array at <code>index * itemSize + 1</code> to y
  77. </div>
  78. <h3>[method:null setXYZ]( index, x, y, z ) </h3>
  79. <div>
  80. Sets the value of the array at <code>index * itemSize</code> to x,
  81. the value of the array at <code>index * itemSize + 1</code> to y, and
  82. the value of the array at <code>index * itemSize + 2</code> to z.
  83. </div>
  84. <h3>[method:null setXYZW]( index, x, y, z, w ) </h3>
  85. <div>
  86. Sets the value of the array at <code>index * itemSize</code> to x,
  87. the value of the array at <code>index * itemSize + 1</code> to y,
  88. the value of the array at <code>index * itemSize + 2</code> to z, and
  89. the value of the array at <code>index * itemSize + 3</code> to w.
  90. </div>
  91. <h3>[method:BufferAttribute clone]() </h3>
  92. <div>
  93. Copies this attribute.
  94. </div>
  95. <h3>[method:null disposeArray]() </h3>
  96. <div>
  97. Discards the typed array containing the attribute data. This can be executed after the data has been transfered to the GPU to allow the memory to be reclaimed.
  98. For use where the attribute will not be changed after the discard method is called.
  99. </div>
  100. <h2>Source</h2>
  101. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  102. </body>
  103. </html>