BatchedMesh.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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>[method:this setCustomSort]( [param:Function sortFunction] )</h3>
  85. <p>
  86. Takes a sort a function that is run before render. The function takes a list of items to sort and a camera. The objects
  87. in the list include a "z" field to perform a depth-ordered sort with.
  88. </p>
  89. <h3>
  90. [method:Matrix4 getMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )
  91. </h3>
  92. <p>
  93. [page:Integer index]: The index of an instance. Values have to be in the
  94. range [0, count].
  95. </p>
  96. <p>
  97. [page:Matrix4 matrix]: This 4x4 matrix will be set to the local
  98. transformation matrix of the defined instance.
  99. </p>
  100. <p>Get the local transformation matrix of the defined instance.</p>
  101. <h3>
  102. [method:Boolean getVisibleAt]( [param:Integer index] )
  103. </h3>
  104. <p>
  105. [page:Integer index]: The index of an instance. Values have to be in the
  106. range [0, count].
  107. </p>
  108. <p>Get whether the given instance is marked as "visible" or not.</p>
  109. <h3>
  110. [method:this setMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )
  111. </h3>
  112. <p>
  113. [page:Integer index]: The index of an instance. Values have to be in the
  114. range [0, count].
  115. </p>
  116. <p>
  117. [page:Matrix4 matrix]: A 4x4 matrix representing the local transformation
  118. of a single instance.
  119. </p>
  120. <p>
  121. Sets the given local transformation matrix to the defined instance.
  122. </p>
  123. <h3>
  124. [method:this setVisibleAt]( [param:Integer index], [param:Boolean visible] )
  125. </h3>
  126. <p>
  127. [page:Integer index]: The index of an instance. Values have to be in the
  128. range [0, count].
  129. </p>
  130. <p>
  131. [page:Boolean visible]: A boolean value indicating the visibility state.
  132. </p>
  133. <p>
  134. Sets the visibility of the object at the given index.
  135. </p>
  136. <h3>
  137. [method:Integer addGeometry]( [param:BufferGeometry geometry], [param:Integer reservedVertexRange], [param:Integer reservedIndexRange] )
  138. </h3>
  139. <p>
  140. [page:BufferGeometry geometry]: The geometry to add into the [name].
  141. </p>
  142. <p>
  143. [page:Integer reservedVertexRange]: Optional parameter specifying the amount of vertex 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 vertex buffer.
  146. </p>
  147. <p>
  148. [page:Integer reservedIndexRange]: Optional parameter specifying the amount of index buffer space to reserve for the added geometry. This
  149. 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
  150. the length of the given geometry index buffer.
  151. </p>
  152. <p>
  153. Adds the given geometry to the [name] and returns the associated index referring to it.
  154. </p>
  155. <h3>
  156. [method:Integer setGeometryAt]( [param:Integer index], [param:BufferGeometry geometry] )
  157. </h3>
  158. <p>
  159. [page:Integer index]: Which geometry index to replace with this geometry.
  160. </p>
  161. <p>
  162. [page:BufferGeometry geometry]: The geometry to substitute at the given geometry index.
  163. </p>
  164. <p>
  165. Replaces the geometry at `index` with the provided geometry. Throws an error if there is not enough space reserved for geometry at the index.
  166. </p>
  167. <h3>
  168. [method:this deleteGeometry]( [param:Integer index] )
  169. </h3>
  170. <p>
  171. Marks the geometry at the given index as deleted and to not be rendered anymore.
  172. </p>
  173. <h2>Source</h2>
  174. <p>
  175. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  176. </p>
  177. </body>
  178. </html>
粤ICP备19079148号