Geometry.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <script src="../../list.js"></script>
  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. <div class="desc">Base class for geometries</div>
  12. <h2>Example</h2>
  13. <code>var geometry = new THREE.Geometry()
  14. geometry.vertices.push( new THREE.Vector3( -10, 10, 0 ) );
  15. geometry.vertices.push( new THREE.Vector3( -10, -10, 0 ) );
  16. geometry.vertices.push( new THREE.Vector3( 10, -10, 0 ) );
  17. geometry.faces.push( new THREE.Face3( 0, 1, 2 ) );
  18. geometry.computeBoundingSphere();
  19. </code>
  20. <h2>Constructor</h2>
  21. <h3>[name]()</h3>
  22. <h2>Properties</h2>
  23. <h3>.[page:Integer id]</h3>
  24. <div>
  25. Unique number of this geometry instance
  26. </div>
  27. <h3>.[page:String name]</h3>
  28. <div>
  29. Name for this geometry. Default is an empty string.
  30. </div>
  31. <h3>.[page:Array vertices]</h3>
  32. <div>
  33. Array of [page:Vector3 vertices].
  34. </div>
  35. <h3>.[page:Array colors]</h3>
  36. <div>
  37. Array of vertex [page:Color colors], matching number and order of vertices.<br />
  38. Used in [page:ParticleSystem], [page:Line] and [page:Ribbon].<br />
  39. [page:Mesh Meshes] use per-face-use-of-vertex colors embedded directly in faces.
  40. </div>
  41. <h3>.[page:Array materials]</h3>
  42. <div>
  43. Array of [page:Material materials].
  44. </div>
  45. <h3>.[page:Array faces]</h3>
  46. <div>
  47. Array of [page:Face3 triangles] or/and [page:Face4 quads].
  48. </div>
  49. <h3>.[page:Array faceUvs]</h3>
  50. <div>
  51. Array of face [page:UV] layers.<br />
  52. Each UV layer is an array of [page:UV] matching order and number of faces.
  53. </div>
  54. <h3>.[page:Array faceVertexUvs]</h3>
  55. <div>
  56. Array of face [page:UV] layers.<br />
  57. Each UV layer is an array of [page:UV] matching order and number of vertices in faces.
  58. </div>
  59. <h3>.[page:Array morphTargets]</h3>
  60. <div>
  61. Array of morph targets. Each morph target is a Javascript object:
  62. <code>{ name: "targetName", vertices: [ new THREE.Vertex(), ... ] }</code>
  63. Morph vertices match number and order of primary vertices.
  64. </div>
  65. <h3>.[page:Array morphColors]</h3>
  66. <div>
  67. Array of morph colors. Morph colors have similar structure as morph targets, each color set is a Javascript object:
  68. <code>morphColor = { name: "colorName", colors: [ new THREE.Color(), ... ] }</code>
  69. Morph colors can match either number and order of faces (face colors) or number of vertices (vertex colors).
  70. </div>
  71. <h3>.[page:Array skinWeights]</h3>
  72. <div>
  73. Array of skinning weights, matching number and order of vertices.
  74. </div>
  75. <h3>.[page:Array skinIndices]</h3>
  76. <div>
  77. Array of skinning indices, matching number and order of vertices.
  78. </div>
  79. <h3>.[page:Object boundingBox]</h3>
  80. <div>
  81. Bounding box.
  82. <code>{ min: new THREE.Vector3(), max: new THREE.Vector3() }</code>
  83. </div>
  84. <h3>.[page:Object boundingSphere]</h3>
  85. <div>
  86. Bounding sphere.
  87. <code>{ radius: float }</code>
  88. </div>
  89. <h3>.[page:Boolean hasTangents]</h3>
  90. <div>
  91. True if geometry has tangents. Set in [page:Geometry Geometry.computeTangents].
  92. </div>
  93. <h3>.[page:Boolean dynamic]</h3>
  94. <div>
  95. Set to *true* if attribute buffers will need to change in runtime (using "dirty" flags).<br/>
  96. Unless set to true internal typed arrays corresponding to buffers will be deleted once sent to GPU.
  97. </div>
  98. <h2>Methods</h2>
  99. <h3>.applyMatrix( [page:Matrix4 matrix] )</h3>
  100. <div>
  101. Bakes matrix transform directly into vertex coordinates.
  102. </div>
  103. <h3>.computeCentroids()</h3>
  104. <div>
  105. Computes centroids for all faces.
  106. </div>
  107. <h3>.computeFaceNormals()</h3>
  108. <div>
  109. Computes face normals.
  110. </div>
  111. <h3>.computeVertexNormals()</h3>
  112. <div>
  113. Computes vertex normals by averaging face normals.<br />
  114. Face normals must be existing / computed beforehand.
  115. </div>
  116. <h3>.computeTangents()</h3>
  117. <div>
  118. Computes vertex tangents.<br />
  119. Based on [link:http://www.terathon.com/code/tangent.html]<br />
  120. Geometry must have vertex [page:UV UVs] (layer 0 will be used).
  121. </div>
  122. <h3>.computeBoundingBox()</h3>
  123. <div>
  124. Computes bounding box of the geometry, updating [page:Geometry Geometry.boundingBox] attribute.
  125. </div>
  126. <h3>.computeBoundingSphere()</h3>
  127. <div>
  128. Computes bounding sphere of the geometry, updating [page:Geometry Geometry.boundingSphere] attribute.
  129. </div>
  130. <div>Neither bounding boxes or bounding spheres are computed by default. They need to be explicitly computed, otherwise they are *null*.</div>
  131. <h3>.mergeVertices()</h3>
  132. <div>
  133. Checks for duplicate vertices using hashmap.<br />
  134. Duplicated vertices are removed and faces' vertices are updated.
  135. </div>
  136. <h2>Source</h2>
  137. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  138. </body>
  139. </html>