BatchedMesh.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. [page:Mesh] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. A special version of [page:Mesh] with multi draw batch rendering support. Use
  14. [name] if you have to render a large number of objects with the same
  15. material but with different world transformations and geometry. The usage
  16. of [name] will help you to reduce the number of draw calls and thus
  17. improve the overall rendering performance in your application.
  18. <br/>
  19. <br/>
  20. Requires platform support for the [link:https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_multi_draw WEBGL_multi_draw extension].
  21. </p>
  22. <h2>Examples</h2>
  23. <p>
  24. [example:webgl_mesh_batch WebGL / mesh / batch]<br />
  25. </p>
  26. <h2>Constructor</h2>
  27. <h3>
  28. [name](
  29. [param:Integer maxGeometryCount], [param:Integer maxVertexCount],
  30. [param:Integer maxIndexCount], [param:Material material],
  31. )
  32. </h3>
  33. <p>
  34. [page:Integer maxGeometryCount] - the max number of individual geometries planned to be added.<br />
  35. [page:Integer maxVertexCount] - the max number of vertices to be used by all geometries.<br />
  36. [page:Integer maxIndexCount] - the max number of indices to be used by all geometries.<br />
  37. [page:Material material] - an instance of [page:Material]. Default is a
  38. new [page:MeshBasicMaterial].<br />
  39. </p>
  40. <h2>Properties</h2>
  41. <p>See the base [page:Mesh] class for common properties.</p>
  42. <h3>[property:Box3 boundingBox]</h3>
  43. <p>
  44. This bounding box encloses all instances of the [name]. Can be calculated
  45. with [page:.computeBoundingBox](). Default is `null`.
  46. </p>
  47. <h3>[property:Sphere boundingSphere]</h3>
  48. <p>
  49. This bounding sphere encloses all instances of the [name]. Can be
  50. calculated with [page:.computeBoundingSphere](). Default is `null`.
  51. </p>
  52. <h3>[property:Boolean perObjectFrustumCulled]</h3>
  53. <p>
  54. If true then the individual objects within the [name] are frustum culled. Default is `true`.
  55. </p>
  56. <h3>[property:Boolean sortObjects]</h3>
  57. <p>
  58. If true then the individual objects within the [name] are sorted to improve overdraw-related artifacts.
  59. If the material is marked as "transparent" objects are rendered back to front and if not then they are
  60. rendered front to back. Default is `true`.
  61. </p>
  62. <h3>[property:Boolean isBatchedMesh]</h3>
  63. <p>Read-only flag to check if a given object is of type [name].</p>
  64. <h2>Methods</h2>
  65. <p>See the base [page:Mesh] class for common methods.</p>
  66. <h3>[method:undefined computeBoundingBox]()</h3>
  67. <p>
  68. Computes the bounding box, updating [page:.boundingBox] attribute.<br />
  69. Bounding boxes aren't computed by default. They need to be explicitly
  70. computed, otherwise they are `null`.
  71. </p>
  72. <h3>[method:undefined computeBoundingSphere]()</h3>
  73. <p>
  74. Computes the bounding sphere, updating [page:.boundingSphere]
  75. attribute.<br />
  76. Bounding spheres aren't computed by default. They need to be explicitly
  77. computed, otherwise they are `null`.
  78. </p>
  79. <h3>[method:undefined dispose]()</h3>
  80. <p>
  81. Frees the GPU-related resources allocated by this instance. Call this
  82. method whenever this instance is no longer used in your app.
  83. </p>
  84. <h3>
  85. [method:Matrix4 getMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )
  86. </h3>
  87. <p>
  88. [page:Integer index]: The index of an instance. Values have to be in the
  89. range [0, count].
  90. </p>
  91. <p>
  92. [page:Matrix4 matrix]: This 4x4 matrix will be set to the local
  93. transformation matrix of the defined instance.
  94. </p>
  95. <p>Get the local transformation matrix of the defined instance.</p>
  96. <h3>
  97. [method:Boolean getVisibleAt]( [param:Integer index] )
  98. </h3>
  99. <p>
  100. [page:Integer index]: The index of an instance. Values have to be in the
  101. range [0, count].
  102. </p>
  103. <p>Get whether the given instance is marked as "visible" or not.</p>
  104. <h3>
  105. [method:this setMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )
  106. </h3>
  107. <p>
  108. [page:Integer index]: The index of an instance. Values have to be in the
  109. range [0, count].
  110. </p>
  111. <p>
  112. [page:Matrix4 matrix]: A 4x4 matrix representing the local transformation
  113. of a single instance.
  114. </p>
  115. <p>
  116. Sets the given local transformation matrix to the defined instance.
  117. </p>
  118. <h3>
  119. [method:this setVisibleAt]( [param:Integer index], [param:Boolean visible] )
  120. </h3>
  121. <p>
  122. [page:Integer index]: The index of an instance. Values have to be in the
  123. range [0, count].
  124. </p>
  125. <p>
  126. [page:Boolean visible]: A boolean value indicating the visibility state.
  127. </p>
  128. <p>
  129. Sets the visibility of the object at the given index.
  130. </p>
  131. <h3>
  132. [method:Integer addGeometry]( [param:BufferGeometry geometry], [param:Integer reservedVertexRange], [param:Integer reservedIndexRange] )
  133. </h3>
  134. <p>
  135. [page:BufferGeometry geometry]: The geometry to add into the [name].
  136. </p>
  137. <p>
  138. [page:Integer reservedVertexRange]: Optional parameter specifying the amount of vertex buffer space to reserve for the added geometry. This
  139. is necessary if it is planned to set a new geometry at this index at a later time that is larger than the original geometry. Defaults to
  140. the length of the given geometry vertex buffer.
  141. </p>
  142. <p>
  143. [page:Integer reservedIndexRange]: Optional parameter specifying the amount of index buffer space to reserve for the added geometry. This
  144. is necessary if it is planned to set a new geometry at this index at a later time that is larger than the original geometry. Defaults to
  145. the length of the given geometry index buffer.
  146. </p>
  147. <p>
  148. Adds the given geometry to the [name] and returns the associated index referring to it.
  149. </p>
  150. <h3>
  151. [method:Integer setGeometryAt]( [param:Integer index], [param:BufferGeometry geometry] )
  152. </h3>
  153. <p>
  154. [page:Integer index]: Which geometry index to replace with this geometry.
  155. </p>
  156. <p>
  157. [page:BufferGeometry geometry]: The geometry to substitute at the given geometry index.
  158. </p>
  159. <p>
  160. Replaces the geometry at `index` with the provided geometry. Throws an error if there is not enough space reserved for geometry at the index.
  161. </p>
  162. <h3>
  163. [method:this deleteGeometry]( [param:Integer index] )
  164. </h3>
  165. <p>
  166. Marks the geometry at the given index as deleted and to not be rendered anymore.
  167. </p>
  168. <h2>Source</h2>
  169. <p>
  170. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  171. </p>
  172. </body>
  173. </html>