Geometry.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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">
  12. Base class for geometries.<br />
  13. A geometry holds all data necessary to describe a 3D model.
  14. </div>
  15. <h2>Example</h2>
  16. <code>var geometry = new THREE.Geometry();
  17. geometry.vertices.push(
  18. new THREE.Vector3( -10, 10, 0 ),
  19. new THREE.Vector3( -10, -10, 0 ),
  20. new THREE.Vector3( 10, -10, 0 )
  21. );
  22. geometry.faces.push( new THREE.Face3( 0, 1, 2 ) );
  23. geometry.computeBoundingSphere();
  24. </code>
  25. <h2>Constructor</h2>
  26. <h3>[name]()</h3>
  27. <div>
  28. The constructor takes no arguments.
  29. </div>
  30. <h2>Properties</h2>
  31. <h3>[property:Integer id]</h3>
  32. <div>
  33. Unique number for this geometry instance.
  34. </div>
  35. <h3>[property:String name]</h3>
  36. <div>
  37. Name for this geometry. Default is an empty string.
  38. </div>
  39. <h3>[property:Array vertices]</h3>
  40. <div>
  41. Array of [page:Vector3 vertices].<br />
  42. The array of vertices holds every position of points in the model.<br />
  43. To signal an update in this array, [page:Geometry Geometry.verticesNeedUpdate] needs to be set to true.
  44. </div>
  45. <h3>[property:Array colors]</h3>
  46. <div>
  47. Array of vertex [page:Color colors], matching number and order of vertices.<br />
  48. Used in [page:PointCloud] and [page:Line].<br />
  49. [page:Mesh Meshes] use per-face-use-of-vertex colors embedded directly in faces.<br />
  50. To signal an update in this array, [page:Geometry Geometry.colorsNeedUpdate] needs to be set to true.
  51. </div>
  52. <h3>[property:Array faces]</h3>
  53. <div>
  54. Array of [page:Face3 triangles].<br />
  55. The array of faces describe how each vertex in the model is connected with each other.<br />
  56. To signal an update in this array, [page:Geometry Geometry.elementsNeedUpdate] needs to be set to true.
  57. </div>
  58. <h3>[property:Array faceVertexUvs]</h3>
  59. <div>
  60. Array of face [page:UV] layers.<br />
  61. Each UV layer is an array of [page:UV]s matching the order and number of vertices in faces.<br />
  62. To signal an update in this array, [page:Geometry Geometry.uvsNeedUpdate] needs to be set to true.
  63. </div>
  64. <h3>[property:Array morphTargets]</h3>
  65. <div>
  66. Array of morph targets. Each morph target is a Javascript object:
  67. <code>{ name: "targetName", vertices: [ new THREE.Vector3(), ... ] }</code>
  68. Morph vertices match number and order of primary vertices.
  69. </div>
  70. <h3>[property:Array morphColors]</h3>
  71. <div>
  72. Array of morph colors. Morph colors have similar structure as morph targets, each color set is a Javascript object:
  73. <code>morphColor = { name: "colorName", colors: [ new THREE.Color(), ... ] }</code>
  74. Morph colors can match either the number and order of faces (face colors) or the number of vertices (vertex colors).
  75. </div>
  76. <h3>[property:Array morphNormals]</h3>
  77. <div>
  78. Array of morph normals. Morph normals have similar structure as morph targets, each normal set is a Javascript object:
  79. <code>morphNormal = { name: "NormalName", normals: [ new THREE.Vector3(), ... ] }</code>
  80. </div>
  81. <h3>[property:Array skinWeights]</h3>
  82. <div>
  83. Array of [page:Vector4 Vector4s] representing the skinning weights as used in a [page:SkinnedMesh],
  84. The weights match the number and order of vertices in the geometry. The weighted values
  85. are typically between the values of 0 and 1 and affect the amount that the individuals bones affect
  86. a given vertex.
  87. </div>
  88. <h3>[property:Array skinIndices]</h3>
  89. <div>
  90. Array of [page:Vector4 Vector4s] representing the indices of individual bones in the [page:Skeleton.bones] array,
  91. The indices match the number and order of vertices in the geometry.
  92. <code>
  93. geometry.skinIndices[15] = new THREE.Vector4( 0, 5, 9, 0 );
  94. geometry.skinWeights[15] = new THREE.Vector4( 0.2, 0.5, 0.3, 0 );
  95. // corresponds with the following vertex
  96. geometry.vertices[15]
  97. // these bones will be used like so:
  98. skeleton.bones[0]; // weight of 0.2
  99. skeleton.bones[5]; // weight of 0.5
  100. skeleton.bones[9]; // weight of 0.3
  101. skeleton.bones[0]; // weight of 0
  102. </code>
  103. </div>
  104. <h3>[property:Object boundingBox]</h3>
  105. <div>
  106. Bounding box.
  107. <code>{ min: new THREE.Vector3(), max: new THREE.Vector3() }</code>
  108. </div>
  109. <h3>[property:Object boundingSphere]</h3>
  110. <div>
  111. Bounding sphere.
  112. <code>{ radius: float }</code>
  113. </div>
  114. <h3>[property:Boolean hasTangents]</h3>
  115. <div>
  116. True if geometry has tangents. Set in [page:Geometry Geometry.computeTangents].
  117. </div>
  118. <h3>[property:Boolean dynamic]</h3>
  119. <div>
  120. Set to *true* if attribute buffers will need to change in runtime (using "dirty" flags).<br/>
  121. Unless set to true internal typed arrays corresponding to buffers will be deleted once sent to GPU.<br/>
  122. Defaults to true.
  123. </div>
  124. <h3>[property:Boolean verticesNeedUpdate]</h3>
  125. <div>
  126. Set to *true* if the vertices array has been updated.
  127. </div>
  128. <h3>[property:Boolean elementsNeedUpdate]</h3>
  129. <div>
  130. Set to *true* if the faces array has been updated.
  131. </div>
  132. <h3>[property:Boolean uvsNeedUpdate]</h3>
  133. <div>
  134. Set to *true* if the uvs array has been updated.
  135. </div>
  136. <h3>[property:Boolean normalsNeedUpdate]</h3>
  137. <div>
  138. Set to *true* if the normals array has been updated.
  139. </div>
  140. <h3>[property:Boolean tangentsNeedUpdate]</h3>
  141. <div>
  142. Set to *true* if the tangents in the faces has been updated.
  143. </div>
  144. <h3>[property:Boolean colorsNeedUpdate]</h3>
  145. <div>
  146. Set to *true* if the colors array has been updated.
  147. </div>
  148. <h3>[property:Boolean lineDistancesNeedUpdate]</h3>
  149. <div>
  150. Set to *true* if the linedistances array has been updated.
  151. </div>
  152. <h3>[property:array lineDistances]</h3>
  153. <div>
  154. An array containing distances between vertices for Line geometries.
  155. This is required for LinePieces/LineDashedMaterial to render correctly.
  156. Line distances can also be generated with computeLineDistances.
  157. </div>
  158. <h2>Methods</h2>
  159. <h3>[page:EventDispatcher EventDispatcher] methods are available on this class.</h3>
  160. <h3>[method:null applyMatrix]( [page:Matrix4 matrix] )</h3>
  161. <div>
  162. Bakes matrix transform directly into vertex coordinates.
  163. </div>
  164. <h3>[method:null center]()</h3>
  165. <div>
  166. Center the geometry based on the bounding box.
  167. </div>
  168. <h3>[method:null computeFaceNormals]()</h3>
  169. <div>
  170. Computes face normals.
  171. </div>
  172. <h3>[method:null computeVertexNormals]()</h3>
  173. <div>
  174. Computes vertex normals by averaging face normals.<br />
  175. Face normals must be existing / computed beforehand.
  176. </div>
  177. <h3>[method:null computeMorphNormals]()</h3>
  178. <div>
  179. Computes morph normals.
  180. </div>
  181. <h3>[method:null computeTangents]()</h3>
  182. <div>
  183. Computes vertex tangents.<br />
  184. Based on [link:http://www.terathon.com/code/tangent.html]<br />
  185. Geometry must have vertex [page:UV UVs] (layer 0 will be used).
  186. </div>
  187. <h3>[method:null computeBoundingBox]()</h3>
  188. <div>
  189. Computes bounding box of the geometry, updating [page:Geometry Geometry.boundingBox] attribute.
  190. </div>
  191. <h3>[method:null computeBoundingSphere]()</h3>
  192. <div>
  193. Computes bounding sphere of the geometry, updating [page:Geometry Geometry.boundingSphere] attribute.
  194. </div>
  195. <div>Neither bounding boxes or bounding spheres are computed by default. They need to be explicitly computed, otherwise they are *null*.</div>
  196. <h3>[method:null merge]( [page:Geometry geometry], [page:Matrix4 matrix], [page:Integer materialIndexOffset] )</h3>
  197. <div>Merge two geometries or geometry and geometry from object (using object's transform)</div>
  198. <h3>[method:null mergeVertices]()</h3>
  199. <div>
  200. Checks for duplicate vertices using hashmap.<br />
  201. Duplicated vertices are removed and faces' vertices are updated.
  202. </div>
  203. <h3>[method:null normalize]()</h3>
  204. <div>
  205. Normalize the geometry. <br />
  206. Make the geometry centered and has a bounding sphere whose raidus equals to 1.0.
  207. </div>
  208. <h3>[method:Geometry clone]()</h3>
  209. <div>
  210. Creates a new clone of the Geometry.
  211. </div>
  212. <h3>[method:null dispose]()</h3>
  213. <div>
  214. Removes The object from memory. <br />
  215. Don't forget to call this method when you remove a geometry because it can cause memory leaks.
  216. </div>
  217. <h3>[method:null computeLineDistances]()</h3>
  218. <div>
  219. Compute distances between vertices for Line geometries.
  220. </div>
  221. <h2>Source</h2>
  222. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  223. </body>
  224. </html>