Geometry.html 9.2 KB

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