2
0

InstancedMesh.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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]. Can be calculated
  42. with [page:.computeBoundingBox](). Default is `null`.
  43. </p>
  44. <h3>[property:Sphere boundingSphere]</h3>
  45. <p>
  46. This bounding sphere encloses all instances of the [name]. Can be
  47. calculated with [page:.computeBoundingSphere](). Default is `null`.
  48. </p>
  49. <h3>[property:Integer count]</h3>
  50. <p>
  51. The number of instances. The `count` value passed into the constructor
  52. represents the maximum number of instances of this mesh. You can change
  53. the number of instances at runtime to an integer value in the range [0, count].
  54. </p>
  55. <p>
  56. If you need more instances than the original count value, you have to
  57. create a new [name].
  58. </p>
  59. <h3>[property:InstancedBufferAttribute instanceColor]</h3>
  60. <p>
  61. Represents the colors of all instances. `null` by default. You have to set
  62. its [page:BufferAttribute.needsUpdate needsUpdate] flag to true if you
  63. modify instanced data via [page:.setColorAt]().
  64. </p>
  65. <h3>[property:InstancedBufferAttribute instanceMatrix]</h3>
  66. <p>
  67. Represents the local transformation of all instances. You have to set its
  68. [page:BufferAttribute.needsUpdate needsUpdate] flag to true if you modify
  69. instanced data via [page:.setMatrixAt]().
  70. </p>
  71. <h3>[property:Boolean isInstancedMesh]</h3>
  72. <p>Read-only flag to check if a given object is of type [name].</p>
  73. <h2>Methods</h2>
  74. <p>See the base [page:Mesh] class for common methods.</p>
  75. <h3>[method:undefined computeBoundingBox]()</h3>
  76. <p>
  77. Computes the bounding box, updating [page:.boundingBox] attribute.<br />
  78. Bounding boxes aren't computed by default. They need to be explicitly
  79. computed, otherwise they are `null`.
  80. </p>
  81. <h3>[method:undefined computeBoundingSphere]()</h3>
  82. <p>
  83. Computes the bounding sphere, updating [page:.boundingSphere]
  84. attribute.<br />
  85. Bounding spheres aren't computed by default. They need to be explicitly
  86. computed, otherwise they are `null`.
  87. </p>
  88. <h3>[method:undefined dispose]()</h3>
  89. <p>
  90. Frees the GPU-related resources allocated by this instance. Call this
  91. method whenever this instance is no longer used in your app.
  92. </p>
  93. <h3>
  94. [method:undefined getColorAt]( [param:Integer index], [param:Color color] )
  95. </h3>
  96. <p>
  97. [page:Integer index]: The index of an instance. Values have to be in the
  98. range [0, count].
  99. </p>
  100. <p>
  101. [page:Color color]: This color object will be set to the color of the
  102. defined instance.
  103. </p>
  104. <p>Get the color of the defined instance.</p>
  105. <h3>
  106. [method:undefined getMatrixAt]( [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]: This 4x4 matrix will be set to the local
  114. transformation matrix of the defined instance.
  115. </p>
  116. <p>Get the local transformation matrix of the defined instance.</p>
  117. <h3>
  118. [method:undefined setColorAt]( [param:Integer index], [param:Color color] )
  119. </h3>
  120. <p>
  121. [page:Integer index]: The index of an instance. Values have to be in the
  122. range [0, count].
  123. </p>
  124. <p>[page:Color color]: The color of a single instance.</p>
  125. <p>
  126. Sets the given color to the defined instance. Make sure you set
  127. [page:.instanceColor][page:BufferAttribute.needsUpdate .needsUpdate] to
  128. true after updating all the colors.
  129. </p>
  130. <h3>
  131. [method:undefined setMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )
  132. </h3>
  133. <p>
  134. [page:Integer index]: The index of an instance. Values have to be in the
  135. range [0, count].
  136. </p>
  137. <p>
  138. [page:Matrix4 matrix]: A 4x4 matrix representing the local transformation
  139. of a single instance.
  140. </p>
  141. <p>
  142. Sets the given local transformation matrix to the defined instance. Make
  143. sure you set [page:.instanceMatrix][page:BufferAttribute.needsUpdate .needsUpdate]
  144. to true after updating all the matrices.
  145. </p>
  146. <h2>Source</h2>
  147. <p>
  148. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  149. </p>
  150. </body>
  151. </html>