BufferGeometryUtils.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. <h1>[name]</h1>
  11. <p class="desc">
  12. A class containing utility functions for [page:BufferGeometry BufferGeometry] instances.
  13. </p>
  14. <h2>Methods</h2>
  15. <h3>[method:BufferGeometry mergeBufferGeometries]( [param:Array geometries], [param:Boolean useGroups] )</h3>
  16. <p>
  17. geometries -- Array of [page:BufferGeometry BufferGeometry] instances.<br />
  18. useGroups -- Whether groups should be generated for the merged geometry or not.<br /><br />
  19. Merges a set of geometries into a single instance. All geometries must have compatible attributes.
  20. If merge does not succeed, the method returns null.
  21. </p>
  22. <h3>[method:BufferAttribute mergeBufferAttributes]( [param:Array attributes] )</h3>
  23. <p>
  24. attributes -- Array of [page:BufferAttribute BufferAttribute] instances.<br /><br />
  25. Merges a set of attributes into a single instance. All attributes must have compatible properties
  26. and types, and [page:InterleavedBufferAttribute InterleavedBufferAttributes] are not supported. If merge does not succeed, the method
  27. returns null.
  28. </p>
  29. <h3>[method:InterleavedBufferAttribute interleaveAttributes]( [param:Array attributes] )</h3>
  30. <p>
  31. attributes -- Array of [page:BufferAttribute BufferAttribute] instances.<br /><br />
  32. Interleaves a set of attributes and returns a new array of corresponding attributes that share
  33. a single InterleavedBuffer instance. All attributes must have compatible types. If merge does not
  34. succeed, the method returns null.
  35. </p>
  36. <h3>[method:Number estimateBytesUsed]( [param:BufferGeometry geometry] )</h3>
  37. <p>
  38. geometry -- Instance of [page:BufferGeometry BufferGeometry] to estimate the memory use of.<br /><br />
  39. Returns the amount of bytes used by all attributes to represent the geometry.
  40. </p>
  41. <h3>[method:BufferGeometry mergeGroups]( [param:BufferGeometry geometry] )</h3>
  42. <p>
  43. geometry -- Instance of [page:BufferGeometry BufferGeometry] to merge the groups of.<br /><br />
  44. Merges the [page:BufferGeometry.groups groups] for the given geometry.
  45. </p>
  46. <h3>[method:BufferGeometry mergeVertices]( [param:BufferGeometry geometry], [param:Number tolerance] )</h3>
  47. <p>
  48. geometry -- Instance of [page:BufferGeometry BufferGeometry] to merge the vertices of.<br />
  49. tolerance -- The maximum allowable difference between vertex attributes to merge. Defaults to 1e-4.<br /><br />
  50. Returns a new [page:BufferGeometry BufferGeometry] with vertices for which all similar vertex attributes
  51. (within tolerance) are merged.
  52. </p>
  53. <h3>[method:BufferGeometry toTrianglesDrawMode]( [param:BufferGeometry geometry], [param:TrianglesDrawMode drawMode] )</h3>
  54. <p>
  55. geometry -- Instance of [page:BufferGeometry BufferGeometry].<br />
  56. drawMode -- The draw mode of the given geometry. Valid inputs are `THREE.TriangleStripDrawMode` and `THREE.TriangleFanDrawMode`.<br /><br />
  57. Returns a new indexed geometry based on `THREE.TrianglesDrawMode` draw mode. This mode corresponds to the `gl.TRIANGLES` WebGL primitive.
  58. </p>
  59. <h3>[method:Object computeMorphedAttributes]( [param:Mesh | Line | Points object] )</h3>
  60. <p>
  61. object -- Instance of [page:Mesh Mesh] | [page:Line Line] | [page:Points Points].<br /><br />
  62. Returns the current attributes (Position and Normal) of a morphed/skinned [page:Object3D Object3D] whose geometry is a
  63. [page:BufferGeometry BufferGeometry], together with the original ones: An Object with 4 properties:
  64. `positionAttribute`, `normalAttribute`, `morphedPositionAttribute` and `morphedNormalAttribute`.
  65. Helpful for Raytracing or Decals (i.e. a [page:DecalGeometry DecalGeometry] applied to a morphed Object
  66. with a [page:BufferGeometry BufferGeometry] will use the original BufferGeometry, not the morphed/skinned one,
  67. generating an incorrect result.
  68. Using this function to create a shadow Object3D the DecalGeometry can be correctly generated).
  69. </p>
  70. <h3>[method:Object computeMikkTSpaceTangents]( [param:BufferGeometry geometry], [param:Object MikkTSpace], [param:Boolean negateSign] = true )</h3>
  71. <ul>
  72. <li>geometry -- Instance of [page:BufferGeometry].</li>
  73. <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.
  74. <li>negateSign -- Whether to negate the sign component (.w) of each tangent. Required for normal map conventions in some formats, including glTF.</li>
  75. </ul>
  76. <p>
  77. Computes vertex tangents using the [link:http://www.mikktspace.com/ MikkTSpace] algorithm.
  78. MikkTSpace generates the same tangents consistently, and is used in most modelling tools and
  79. normal map bakers. Use MikkTSpace for materials with normal maps, because inconsistent
  80. tangents may lead to subtle visual issues in the normal map, particularly around mirrored
  81. UV seams.
  82. </p>
  83. <p>
  84. In comparison to this method, [page:BufferGeometry.computeTangents] (a
  85. custom algorithm) generates tangents that probably will not match the tangents
  86. in other software. The custom algorithm is sufficient for general use with a
  87. [page:ShaderMaterial], and may be faster than MikkTSpace.
  88. </p>
  89. <p>
  90. Returns the original [page:BufferGeometry]. Indexed geometries will be de-indexed.
  91. Requires position, normal, and uv attributes.
  92. </p>
  93. <h2>Source</h2>
  94. <p>
  95. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/utils/BufferGeometryUtils.js examples/jsm/utils/BufferGeometryUtils.js]
  96. </p>
  97. </body>
  98. </html>