BufferGeometryUtils.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. <h1>[name]</h1>
  11. <p class="desc">
  12. 一个包含 [page:BufferGeometry BufferGeometry] 实例的实用方法的类。
  13. </p>
  14. <h2>导入</h2>
  15. <p>
  16. [name] 是一个附加组件,必须显式导入。
  17. See [link:#manual/introduction/Installation Installation / Addons].
  18. </p>
  19. <code>
  20. import * as BufferGeometryUtils from 'three/addons/utils/BufferGeometryUtils.js';
  21. </code>
  22. <h2>方法</h2>
  23. <h3>[method:Object computeMikkTSpaceTangents]( [param:BufferGeometry geometry], [param:Object MikkTSpace], [param:Boolean negateSign] = true )</h3>
  24. <ul>
  25. <li>geometry -- Instance of [page:BufferGeometry].</li>
  26. <li>MikkTSpace -- Instance of <i>examples/jsm/libs/mikktspace.module.js</i>, or <i>mikktspace</i> npm package. Await <i>MikkTSpace.ready</i> before use.
  27. <li>negateSign -- Whether to negate the sign component (.w) of each tangent. Required for normal map conventions in some formats, including glTF.</li>
  28. </ul>
  29. <p>
  30. Computes vertex tangents using the [link:http://www.mikktspace.com/ MikkTSpace] algorithm.
  31. MikkTSpace generates the same tangents consistently, and is used in most modelling tools and
  32. normal map bakers. Use MikkTSpace for materials with normal maps, because inconsistent
  33. tangents may lead to subtle visual issues in the normal map, particularly around mirrored
  34. UV seams.
  35. </p>
  36. <p>
  37. In comparison to this method, [page:BufferGeometry.computeTangents] (a
  38. custom algorithm) generates tangents that probably will not match the tangents
  39. in other software. The custom algorithm is sufficient for general use with a
  40. [page:ShaderMaterial], and may be faster than MikkTSpace.
  41. </p>
  42. <p>
  43. Returns the original [page:BufferGeometry]. Indexed geometries will be de-indexed.
  44. Requires position, normal, and uv attributes.
  45. </p>
  46. <h3>[method:Object computeMorphedAttributes]( [param:Mesh | Line | Points object] )</h3>
  47. <p>
  48. object -- Instance of [page:Mesh Mesh] | [page:Line Line] | [page:Points Points].<br /><br />
  49. Returns the current attributes (Position and Normal) of a morphed/skinned [page:Object3D Object3D] whose geometry is a
  50. [page:BufferGeometry BufferGeometry], together with the original ones: An Object with 4 properties:
  51. `positionAttribute`, `normalAttribute`, `morphedPositionAttribute` and `morphedNormalAttribute`.
  52. Helpful for Raytracing or Decals (i.e. a [page:DecalGeometry DecalGeometry] applied to a morphed Object
  53. with a [page:BufferGeometry BufferGeometry] will use the original BufferGeometry, not the morphed/skinned one,
  54. generating an incorrect result.
  55. Using this function to create a shadow Object3D the DecalGeometry can be correctly generated).
  56. </p>
  57. <h3>[method:Number estimateBytesUsed]( [param:BufferGeometry geometry] )</h3>
  58. <p>
  59. geometry -- 通过 [page:BufferGeometry BufferGeometry] 的实例来估计内存使用情况。<br /><br />
  60. 返回所有用于表示几何体的属性所占用的字节数。
  61. </p>
  62. <h3>[method:InterleavedBufferAttribute interleaveAttributes]( [param:Array attributes] )</h3>
  63. <p>
  64. attributes -- 由 [page:BufferAttribute BufferAttribute] 实例组成的数组。<br /><br />
  65. 交叉存储一组属性并返回一个新的对应属性数组,这些属性共享一个 InterleavedBuffer 实例。所有属性都必须兼容的该类型。如果合并不成功,则该方法返回 null 。
  66. </p>
  67. <h3>[method:BufferAttribute mergeAttributes]( [param:Array attributes] )</h3>
  68. <p>
  69. attributes -- 由 [page:BufferAttribute BufferAttribute] 实例组成的数组。<br /><br />
  70. 将一组属性合并为一个单一的实例。所有几何体都必须兼容该属性,不支持 [page:InterleavedBufferAttribute InterleavedBufferAttributes] 。
  71. 如果合并不成功,则该方法返回 null 。
  72. </p>
  73. <h3>[method:BufferGeometry mergeGeometries]( [param:Array geometries], [param:Boolean useGroups] )</h3>
  74. <p>
  75. geometries -- 由 [page:BufferGeometry BufferGeometry] 实例的数组。<br />
  76. useGroups -- 是否要为了合并几何体而产生组。<br /><br />
  77. 将一组几何体合并到一个实例中。所有几何体都必须兼容该属性。
  78. 如果合并不成功,则该方法返回 null。
  79. </p>
  80. <h3>[method:BufferGeometry mergeGroups]( [param:BufferGeometry geometry] )</h3>
  81. <p>
  82. geometry -- Instance of [page:BufferGeometry BufferGeometry] to merge the groups of.<br /><br />
  83. Merges the [page:BufferGeometry.groups groups] for the given geometry.
  84. </p>
  85. <h3>[method:BufferGeometry mergeVertices]( [param:BufferGeometry geometry], [param:Number tolerance] )</h3>
  86. <p>
  87. geometry -- 用于合并顶点的 [page:BufferGeometry BufferGeometry] 实例。<br />
  88. tolerance -- 要合并的顶点属性之间允许的最大差异。 默认为 1e-4。<br /><br />
  89. 返回一个新的 [page:BufferGeometry BufferGeometry] ,其中包含将所有(在容差范围内的)具有相似属性的顶点合并而成的顶点。
  90. </p>
  91. <h3>[method:BufferGeometry toCreasedNormals]( [param:BufferGeometry geometry], [param:Number creaseAngle] )</h3>
  92. <ul>
  93. <li>geometry -- The input geometry.</li>
  94. <li>creaseAngle -- The crease angle in radians.</li>
  95. </ul>
  96. <p>
  97. Modifies the supplied geometry if it is non-indexed, otherwise creates a new,
  98. non-indexed geometry.
  99. </p>
  100. <p>
  101. Returns the geometry with smooth normals everywhere except faces
  102. that meet at an angle greater than the crease angle.
  103. </p>
  104. <h3>[method:BufferGeometry toTrianglesDrawMode]( [param:BufferGeometry geometry], [param:TrianglesDrawMode drawMode] )</h3>
  105. <p>
  106. geometry -- Instance of [page:BufferGeometry BufferGeometry].<br />
  107. drawMode -- The draw mode of the given geometry. Valid inputs are `THREE.TriangleStripDrawMode` and `THREE.TriangleFanDrawMode`.<br /><br />
  108. Returns a new indexed geometry based on `THREE.TrianglesDrawMode` draw mode. This mode corresponds to the `gl.TRIANGLES` WebGL primitive.
  109. </p>
  110. <h2>源代码</h2>
  111. <p>
  112. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/BufferGeometryUtils.js examples/jsm/utils/BufferGeometryUtils.js]
  113. </p>
  114. </body>
  115. </html>