InstancedMesh.html 4.2 KB

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