2
0

InstancedMesh.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <!DOCTYPE html>
  2. <html lang="zh">
  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. 一种具有实例化渲染支持的特殊版本的[page:Mesh]。你可以使用 [name] 来渲染大量具有相同几何体与材质、但具有不同世界变换的物体。
  14. 使用 [name] 将帮助你减少 draw call 的数量,从而提升你应用程序的整体渲染性能。
  15. </p>
  16. <h2>示例</h2>
  17. <p>
  18. [example:webgl_instancing_dynamic WebGL / instancing / dynamic]<br />
  19. [example:webgl_instancing_performance WebGL / instancing / performance]<br />
  20. [example:webgl_instancing_scatter WebGL / instancing / scatter]<br />
  21. [example:webgl_instancing_raycast WebGL / instancing / raycast]
  22. </p>
  23. <h2>构造函数</h2>
  24. <h3>[name]( [param:BufferGeometry geometry], [param:Material material], [param:Integer count] )</h3>
  25. <p>
  26. [page:BufferGeometry geometry] - 一个 [page:BufferGeometry] 的实例。<br />
  27. [page:Material material] - 一个 [page:Material] 的实例。默认为一个新的 [page:MeshBasicMaterial] 。<br />
  28. [page:Integer count] - 实例的数量<br />
  29. </p>
  30. <h2>属性</h2>
  31. <p>See the base [page:Mesh] class for common properties.</p>
  32. <h3>[property:Box3 boundingBox]</h3>
  33. <p>
  34. 当前 [name] 的外边界矩形。可以通过 [page:.computeBoundingBox]() 计算。默认值是 *null*。
  35. </p>
  36. <h3>[property:Sphere boundingSphere]</h3>
  37. <p>
  38. 当前 [name] 的外边界球形。可以通过 [page:.computeBoundingSphere]() 计算。默认值是 *null*。
  39. </p>
  40. <h3>[property:Integer count]</h3>
  41. <p>
  42. 实例的数量。被传入到构造函数中的*count*表示mesh实例数量的最大值。
  43. 你可以在运行时改变这个数值到 [0, count] 区间的一个整数。
  44. </p>
  45. <p>
  46. 如果你需要比原先的数量更多的实例数量,你需要创建一个新的[name]。
  47. </p>
  48. <h3>[property:InstancedBufferAttribute instanceColor]</h3>
  49. <p>
  50. 代表所有实例的颜色。默认情况下*null*。
  51. 如果通过[page:.setColorAt]()修改实例化数据,则必须将它的[page:BufferAttribute.needsUpdate needsUpdate]标志设置为 true。
  52. </p>
  53. <h3>[property:InstancedBufferAttribute instanceMatrix]</h3>
  54. <p>
  55. 表示所有实例的本地变换。
  56. 如果你要通过 [page:.setMatrixAt]() 来修改实例数据,你必须将它的 [page:BufferAttribute.needsUpdate needsUpdate] 标识为 true 。
  57. </p>
  58. <h3>[property:Boolean isInstancedMesh]</h3>
  59. <p>
  60. Read-only flag to check if a given object is of type [name].
  61. </p>
  62. <h2>方法</h2>
  63. <p>See the base [page:Mesh] class for common methods.</p>
  64. <h3>[method:undefined computeBoundingBox]()</h3>
  65. <p>
  66. 计算当前几何体的的边界矩形,该操作会更新已有 [param:.boundingBox]。<br />
  67. 边界矩形不会默认计算,需要调用该接口指定计算边界矩形,否则保持默认值 *null*。
  68. </p>
  69. <h3>[method:undefined computeBoundingSphere]()</h3>
  70. <p>
  71. 计算当前几何体的的边界球形,该操作会更新已有 [param:.boundingSphere]。<br />
  72. 边界球形不会默认计算,需要调用该接口指定计算边界球形,否则保持默认值 *null*。
  73. </p>
  74. <h3>[method:undefined dispose]()</h3>
  75. <p>
  76. Frees the internal resources of this instance.
  77. </p>
  78. <h3>[method:undefined getColorAt]( [param:Integer index], [param:Color color] )</h3>
  79. <p>
  80. [page:Integer index]: The index of an instance. Values have to be in the range [0, count].
  81. </p>
  82. <p>
  83. [page:Color color]: This color object will be set to the color of the defined instance.
  84. </p>
  85. <p>
  86. Get the color of the defined instance.
  87. </p>
  88. <h3>[method:undefined getMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</h3>
  89. <p>
  90. [page:Integer index]: 实例的索引。值必须在 [0, count] 区间。
  91. </p>
  92. <p>
  93. [page:Matrix4 matrix]: 该4x4矩阵将会被设为已定义实例的本地变换矩阵。
  94. </p>
  95. <p>
  96. 获得已定义实例的本地变换矩阵。
  97. </p>
  98. <h3>[method:undefined setColorAt]( [param:Integer index], [param:Color color] )</h3>
  99. <p>
  100. [page:Integer index]: The index of an instance. Values have to be in the range [0, count].
  101. </p>
  102. <p>
  103. [page:Color color]: The color of a single instance.
  104. </p>
  105. <p>
  106. Sets the given color to the defined instance.
  107. Make sure you set [page:.instanceColor][page:BufferAttribute.needsUpdate .needsUpdate] to true after updating all the colors.
  108. </p>
  109. <h3>[method:undefined setMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</h3>
  110. <p>
  111. [page:Integer index]: 实例的索引。值必须在 [0, count] 区间。
  112. </p>
  113. <p>
  114. [page:Matrix4 matrix]: 一个4x4矩阵,表示单个实例本地变换。
  115. </p>
  116. <p>
  117. 设置给定的本地变换矩阵到已定义的实例。
  118. 请确保在更新所有矩阵后将 [page:.instanceMatrix][page:BufferAttribute.needsUpdate .needsUpdate] 设置为true。
  119. </p>
  120. <h2>源代码</h2>
  121. <p>
  122. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  123. </p>
  124. </body>
  125. </html>