InstancedMesh.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 instanced rendering support. Use
  14. [name] if you have to render a large number of objects with the same
  15. geometry and material but with different world transformations. 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. </p>
  19. <h2>Examples</h2>
  20. <p>
  21. [example:webgl_instancing_dynamic WebGL / instancing / dynamic]<br />
  22. [example:webgl_instancing_performance WebGL / instancing / performance]<br />
  23. [example:webgl_instancing_scatter WebGL / instancing / scatter]<br />
  24. [example:webgl_instancing_raycast WebGL / instancing / raycast]
  25. </p>
  26. <h2>Constructor</h2>
  27. <h3>
  28. [name]( [param:BufferGeometry geometry], [param:Material material],
  29. [param:Integer count] )
  30. </h3>
  31. <p>
  32. [page:BufferGeometry geometry] - an instance of [page:BufferGeometry].<br />
  33. [page:Material material] - an instance of [page:Material]. Default is a
  34. new [page:MeshBasicMaterial].<br />
  35. [page:Integer count] - the number of instances.<br />
  36. </p>
  37. <h2>Properties</h2>
  38. <p>See the base [page:Mesh] class for common properties.</p>
  39. <h3>[property:Box3 boundingBox]</h3>
  40. <p>
  41. This bounding box encloses all instances of the [name]. If you transform any
  42. instances, you are responsible for updating the bounding box as needed. Can be
  43. calculated with [page:.computeBoundingBox](). Default is `null`.
  44. </p>
  45. <h3>[property:Sphere boundingSphere]</h3>
  46. <p>
  47. This bounding sphere encloses all instances of the [name]. If you transform any
  48. instances, you are responsible for updating the bounding sphere as needed. Can
  49. be calculated with [page:.computeBoundingSphere](). Default is `null`.
  50. </p>
  51. <h3>[property:Integer count]</h3>
  52. <p>
  53. The number of instances. The `count` value passed into the constructor
  54. represents the maximum number of instances of this mesh. You can change
  55. the number of instances at runtime to an integer value in the range [0, count].
  56. </p>
  57. <p>
  58. If you need more instances than the original count value, you have to
  59. create a new [name].
  60. </p>
  61. <h3>[property:InstancedBufferAttribute instanceColor]</h3>
  62. <p>
  63. Represents the colors of all instances. `null` by default. You have to set
  64. its [page:BufferAttribute.needsUpdate needsUpdate] flag to true if you
  65. modify instanced data via [page:.setColorAt]().
  66. </p>
  67. <h3>[property:InstancedBufferAttribute instanceMatrix]</h3>
  68. <p>
  69. Represents the local transformation of all instances. You have to set its
  70. [page:BufferAttribute.needsUpdate needsUpdate] flag to true if you modify
  71. instanced data via [page:.setMatrixAt]().
  72. </p>
  73. <h3>[property:DataTexture morphTexture]</h3>
  74. <p>
  75. Represents the morph target weights of all instances. You have to set its
  76. [page:Texture.needsUpdate needsUpdate] flag to true if you modify
  77. instanced data via [page:.setMorphAt]().
  78. </p>
  79. <h3>[property:Boolean isInstancedMesh]</h3>
  80. <p>Read-only flag to check if a given object is of type [name].</p>
  81. <h2>Methods</h2>
  82. <p>See the base [page:Mesh] class for common methods.</p>
  83. <h3>[method:undefined computeBoundingBox]()</h3>
  84. <p>
  85. Computes the bounding box, updating [page:.boundingBox] attribute.<br />
  86. Bounding boxes aren't computed by default. They need to be explicitly
  87. computed, otherwise they are `null`.
  88. </p>
  89. <h3>[method:undefined computeBoundingSphere]()</h3>
  90. <p>
  91. Computes the bounding sphere, updating [page:.boundingSphere]
  92. attribute.<br />
  93. Bounding spheres aren't computed by default. They need to be explicitly
  94. computed, otherwise they are `null`.
  95. </p>
  96. <h3>[method:undefined dispose]()</h3>
  97. <p>
  98. Frees the GPU-related resources allocated by this instance. Call this
  99. method whenever this instance is no longer used in your app.
  100. </p>
  101. <h3>
  102. [method:undefined getColorAt]( [param:Integer index], [param:Color color] )
  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>
  109. [page:Color color]: This color object will be set to the color of the
  110. defined instance.
  111. </p>
  112. <p>Get the color of the defined instance.</p>
  113. <h3>
  114. [method:undefined getMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )
  115. </h3>
  116. <p>
  117. [page:Integer index]: The index of an instance. Values have to be in the
  118. range [0, count].
  119. </p>
  120. <p>
  121. [page:Matrix4 matrix]: This 4x4 matrix will be set to the local
  122. transformation matrix of the defined instance.
  123. </p>
  124. <p>Get the local transformation matrix of the defined instance.</p>
  125. <h3>
  126. [method:undefined getMorphAt]( [param:Integer index], [param:Mesh mesh] )
  127. </h3>
  128. <p>
  129. [page:Integer index]: The index of an instance. Values have to be in the
  130. range [0, count].
  131. </p>
  132. <p>
  133. [page:Mesh mesh]: The [page:Mesh.morphTargetInfluences .morphTargetInfluences] property of this mesh will be filled with the morph target weights of the defined instance.
  134. </p>
  135. <p>Get the morph target weights of the defined instance.</p>
  136. <h3>
  137. [method:undefined setColorAt]( [param:Integer index], [param:Color color] )
  138. </h3>
  139. <p>
  140. [page:Integer index]: The index of an instance. Values have to be in the
  141. range [0, count].
  142. </p>
  143. <p>[page:Color color]: The color of a single instance.</p>
  144. <p>
  145. Sets the given color to the defined instance. Make sure you set
  146. [page:.instanceColor][page:BufferAttribute.needsUpdate .needsUpdate] to
  147. true after updating all the colors.
  148. </p>
  149. <h3>
  150. [method:undefined setMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )
  151. </h3>
  152. <p>
  153. [page:Integer index]: The index of an instance. Values have to be in the
  154. range [0, count].
  155. </p>
  156. <p>
  157. [page:Matrix4 matrix]: A 4x4 matrix representing the local transformation
  158. of a single instance.
  159. </p>
  160. <p>
  161. Sets the given local transformation matrix to the defined instance. Make
  162. sure you set [page:.instanceMatrix][page:BufferAttribute.needsUpdate .needsUpdate]
  163. to true after updating all the matrices. The bounding volumes should be updated
  164. whenever instances are transformed. Depending on how you transform instances, the
  165. bounds can be larger or smaller than before and the bounding volumes should
  166. reflect that.
  167. </p>
  168. <h3>
  169. [method:undefined setMorphAt]( [param:Integer index], [param:Mesh mesh] )
  170. </h3>
  171. <p>
  172. [page:Integer index]: The index of an instance. Values have to be in the
  173. range [0, count].
  174. </p>
  175. <p>
  176. [page:Matrix4 matrix]: A mesh with [page:Mesh.morphTargetInfluences .morphTargetInfluences] property containing the morph target weights
  177. of a single instance.
  178. </p>
  179. <p>
  180. Sets the morph target weights to the defined instance. Make
  181. sure you set [page:.morphTexture][page:Texture.needsUpdate .needsUpdate]
  182. to true after updating all the influences.
  183. </p>
  184. <h2>Source</h2>
  185. <p>
  186. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  187. </p>
  188. </body>
  189. </html>