InstancedMesh.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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_modified WebGL / instancing / modified]<br />
  20. [example:webgl_instancing_performance WebGL / instancing / performance]<br />
  21. [example:webgl_instancing_scatter WebGL / instancing / scatter]<br />
  22. [example:webgl_instancing_raycast WebGL / instancing / raycast]
  23. </p>
  24. <h2>构造函数</h2>
  25. <h3>[name]( [param:BufferGeometry geometry], [param:Material material], [param:Integer count] )</h3>
  26. <p>
  27. [page:BufferGeometry geometry] - 一个 [page:BufferGeometry] 的实例。<br />
  28. [page:Material material] - 一个 [page:Material] 的实例。默认为一个新的 [page:MeshBasicMaterial] 。<br />
  29. [page:Integer count] - 实例的数量<br />
  30. </p>
  31. <h2>属性</h2>
  32. <p>See the base [page:Mesh] class for common properties.</p>
  33. <h3>[property:Integer count]</h3>
  34. <p>
  35. 实例的数量。被传入到构造函数中的*count*表示mesh实例数量的最大值。
  36. 你可以在运行时改变这个数值到 [0, count] 区间的一个整数。
  37. </p>
  38. <p>
  39. 如果你需要比原先的数量更多的实例数量,你需要创建一个新的[name]。
  40. </p>
  41. <h3>[property:InstancedBufferAttribute instanceColor]</h3>
  42. <p>
  43. 代表所有实例的颜色。默认情况下*null*。
  44. 如果通过[page:.setColorAt]()修改实例化数据,则必须将它的[page:BufferAttribute.needsUpdate needsUpdate]标志设置为 true。
  45. </p>
  46. <h3>[property:InstancedBufferAttribute instanceMatrix]</h3>
  47. <p>
  48. 表示所有实例的本地变换。
  49. 如果你要通过 [page:.setMatrixAt]() 来修改实例数据,你必须将它的 [page:BufferAttribute.needsUpdate needsUpdate] 标识为 true 。
  50. </p>
  51. <h3>[property:Boolean isInstancedMesh]</h3>
  52. <p>
  53. Read-only flag to check if a given object is of type [name].
  54. </p>
  55. <h2>方法</h2>
  56. <p>See the base [page:Mesh] class for common methods.</p>
  57. <h3>[method:undefined dispose]()</h3>
  58. <p>
  59. Frees the internal resources of this instance.
  60. </p>
  61. <h3>[method:undefined getColorAt]( [param:Integer index], [param:Color color] )</h3>
  62. <p>
  63. [page:Integer index]: The index of an instance. Values have to be in the range [0, count].
  64. </p>
  65. <p>
  66. [page:Color color]: This color object will be set to the color of the defined instance.
  67. </p>
  68. <p>
  69. Get the color of the defined instance.
  70. </p>
  71. <h3>[method:undefined getMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</h3>
  72. <p>
  73. [page:Integer index]: 实例的索引。值必须在 [0, count] 区间。
  74. </p>
  75. <p>
  76. [page:Matrix4 matrix]: 该4x4矩阵将会被设为已定义实例的本地变换矩阵。
  77. </p>
  78. <p>
  79. 获得已定义实例的本地变换矩阵。
  80. </p>
  81. <h3>[method:undefined setColorAt]( [param:Integer index], [param:Color color] )</h3>
  82. <p>
  83. [page:Integer index]: The index of an instance. Values have to be in the range [0, count].
  84. </p>
  85. <p>
  86. [page:Color color]: The color of a single instance.
  87. </p>
  88. <p>
  89. Sets the given color to the defined instance.
  90. Make sure you set [page:.instanceColor][page:BufferAttribute.needsUpdate .needsUpdate] to true after updating all the colors.
  91. </p>
  92. <h3>[method:undefined setMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</h3>
  93. <p>
  94. [page:Integer index]: 实例的索引。值必须在 [0, count] 区间。
  95. </p>
  96. <p>
  97. [page:Matrix4 matrix]: 一个4x4矩阵,表示单个实例本地变换。
  98. </p>
  99. <p>
  100. 设置给定的本地变换矩阵到已定义的实例。
  101. 请确保在更新所有矩阵后将 [page:.instanceMatrix][page:BufferAttribute.needsUpdate .needsUpdate] 设置为true。
  102. </p>
  103. <h2>源代码</h2>
  104. <p>
  105. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  106. </p>
  107. </body>
  108. </html>