BatchedMesh.html 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. [page:Integer count] - the number of instances.<br />
  40. </p>
  41. <h2>Properties</h2>
  42. <p>See the base [page:Mesh] class for common properties.</p>
  43. <h3>[property:Box3 boundingBox]</h3>
  44. <p>
  45. This bounding box encloses all instances of the [name]. Can be calculated
  46. with [page:.computeBoundingBox](). Default is `null`.
  47. </p>
  48. <h3>[property:Sphere boundingSphere]</h3>
  49. <p>
  50. This bounding sphere encloses all instances of the [name]. Can be
  51. calculated with [page:.computeBoundingSphere](). Default is `null`.
  52. </p>
  53. <h3>[property:Boolean perObjectFrustumCulled]</h3>
  54. <p>
  55. If true then the individual objects within the [name] are frustum culled. Default is `true`.
  56. </p>
  57. <h3>[property:Boolean sortObjects]</h3>
  58. <p>
  59. If true then the individual objects within the [name] are sorted to improve overdraw-related artifacts.
  60. If the material is marked as "transparent" objects are rendered back to front and if not then they are
  61. rendered front to back. Default is `true`.
  62. </p>
  63. <h3>[property:Boolean isBatchedMesh]</h3>
  64. <p>Read-only flag to check if a given object is of type [name].</p>
  65. <h2>Methods</h2>
  66. <p>See the base [page:Mesh] class for common methods.</p>
  67. <h3>[method:undefined computeBoundingBox]()</h3>
  68. <p>
  69. Computes the bounding box, updating [page:.boundingBox] attribute.<br />
  70. Bounding boxes aren't computed by default. They need to be explicitly
  71. computed, otherwise they are `null`.
  72. </p>
  73. <h3>[method:undefined computeBoundingSphere]()</h3>
  74. <p>
  75. Computes the bounding sphere, updating [page:.boundingSphere]
  76. attribute.<br />
  77. Bounding spheres aren't computed by default. They need to be explicitly
  78. computed, otherwise they are `null`.
  79. </p>
  80. <h3>[method:undefined dispose]()</h3>
  81. <p>
  82. Frees the GPU-related resources allocated by this instance. Call this
  83. method whenever this instance is no longer used in your app.
  84. </p>
  85. <h3>
  86. [method:Matrix4 getMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )
  87. </h3>
  88. <p>
  89. [page:Integer index]: The index of an instance. Values have to be in the
  90. range [0, count].
  91. </p>
  92. <p>
  93. [page:Matrix4 matrix]: This 4x4 matrix will be set to the local
  94. transformation matrix of the defined instance.
  95. </p>
  96. <p>Get the local transformation matrix of the defined instance.</p>
  97. <h3>
  98. [method:Boolean getVisibleAt]( [param:Integer index] )
  99. </h3>
  100. <p>
  101. [page:Integer index]: The index of an instance. Values have to be in the
  102. range [0, count].
  103. </p>
  104. <p>Get whether the given instance is marked as "visible" or not.</p>
  105. <h3>
  106. [method:this setMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )
  107. </h3>
  108. <p>
  109. [page:Integer index]: The index of an instance. Values have to be in the
  110. range [0, count].
  111. </p>
  112. <p>
  113. [page:Matrix4 matrix]: A 4x4 matrix representing the local transformation
  114. of a single instance.
  115. </p>
  116. <p>
  117. Sets the given local transformation matrix to the defined instance. Make
  118. sure you set [page:.instanceMatrix][page:BufferAttribute.needsUpdate .needsUpdate]
  119. to true after updating all the matrices.
  120. </p>
  121. <h3>
  122. [method:this setVisibleAt]( [param:Integer index], [param:Boolean visible] )
  123. </h3>
  124. <p>
  125. [page:Integer index]: The index of an instance. Values have to be in the
  126. range [0, count].
  127. </p>
  128. <p>
  129. [page:Boolean visible]: A boolean value indicating the visibility state.
  130. </p>
  131. <p>
  132. Sets the visibility of the object at the given index.
  133. </p>
  134. <h3>
  135. [method:Integer addGeometry]( [param:BufferGeometry geometry], [param:Integer reservedVertexRange], [param:Integer reservedIndexRange] )
  136. </h3>
  137. <p>
  138. [page:BufferGeometry index]: The geometry to add into the [name].
  139. </p>
  140. <p>
  141. [page:Integer reservedVertexRange]: Optional parameter specifying the amount of vertex buffer space to reserve for the added geometry. This
  142. 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
  143. the length of the given geometry vertex buffer.
  144. </p>
  145. <p>
  146. [page:Integer reservedIndexRange]: Optional parameter specifying the amount of index buffer space to reserve for the added geometry. This
  147. 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
  148. the length of the given geometry index buffer.
  149. </p>
  150. <p>
  151. Adds the given geometry to the [name] and returns the associated index referring to it.
  152. </p>
  153. <h3>
  154. [method:Integer setGeometryAt]( [param:Integer index], [param:BufferGeometry geometry] )
  155. </h3>
  156. <p>
  157. [page:Integer index]: Which geometry index to replace with this geometry.
  158. </p>
  159. <p>
  160. [page:BufferGeometry geometry]: The geometry to substitute at the given geometry index.
  161. </p>
  162. <p>
  163. Replaces the geometry at `index` with the provided geometry. Throws an error if there is not enough space reserved for geometry at the index.
  164. </p>
  165. <h3>
  166. [method:this deleteGeometry]( [param:Integer index] )
  167. </h3>
  168. <p>
  169. Marks the geometry at the given index as deleted and to not be rendered anymore.
  170. </p>
  171. <h2>Source</h2>
  172. <p>
  173. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  174. </p>
  175. </body>
  176. </html>