Geometry.html 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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:PointCloud] 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 morphColors]</h3>
  72. <div>
  73. Array of morph colors. Morph colors have similar structure as morph targets, each color set is a Javascript object:
  74. <code>morphColor = { name: "colorName", colors: [ new THREE.Color(), ... ] }</code>
  75. Morph colors can match either the number and order of faces (face colors) or the number of vertices (vertex colors).
  76. </div>
  77. <h3>[property:Array morphNormals]</h3>
  78. <div>
  79. Array of morph normals. Morph normals have similar structure as morph targets, each normal set is a Javascript object:
  80. <code>morphNormal = { name: "NormalName", normals: [ new THREE.Vector3(), ... ] }</code>
  81. </div>
  82. <h3>[property:Array skinWeights]</h3>
  83. <div>
  84. Array of [page:Vector4 Vector4s] representing the skinning weights as used in a [page:SkinnedMesh],
  85. The weights match the number and order of vertices in the geometry. The weighted values
  86. are typically between the values of 0 and 1 and affect the amount that the individuals bones affect
  87. a given vertex.
  88. </div>
  89. <h3>[property:Array skinIndices]</h3>
  90. <div>
  91. Array of [page:Vector4 Vector4s] representing the indices of individual bones in the [page:Skeleton.bones] array,
  92. The indices match the number and order of vertices in the geometry.
  93. <code>
  94. // e.g.
  95. geometry.skinIndices[15] = new THREE.Vector4( 0, 5, 9, 0 );
  96. geometry.skinWeights[15] = new THREE.Vector4( 0.2, 0.5, 0.3, 0 );
  97. // corresponds with the following vertex
  98. geometry.vertices[15];
  99. // these bones will be used like so:
  100. skeleton.bones[0]; // weight of 0.2
  101. skeleton.bones[5]; // weight of 0.5
  102. skeleton.bones[9]; // weight of 0.3
  103. skeleton.bones[0]; // weight of 0
  104. </code>
  105. </div>
  106. <h3>[property:Object boundingBox]</h3>
  107. <div>
  108. Bounding box.
  109. <code>{ min: new THREE.Vector3(), max: new THREE.Vector3() }</code>
  110. </div>
  111. <h3>[property:Object boundingSphere]</h3>
  112. <div>
  113. Bounding sphere.
  114. <code>{ radius: float }</code>
  115. </div>
  116. <h3>[property:Boolean hasTangents]</h3>
  117. <div>
  118. True if geometry has tangents. Set in [page:Geometry Geometry.computeTangents].
  119. </div>
  120. <h3>[property:Boolean dynamic]</h3>
  121. <div>
  122. Set to *true* if attribute buffers will need to change in runtime (using "dirty" flags).<br/>
  123. Unless set to true internal typed arrays corresponding to buffers will be deleted once sent to GPU.<br/>
  124. Defaults to true.
  125. </div>
  126. <h3>[property:Boolean verticesNeedUpdate]</h3>
  127. <div>
  128. Set to *true* if the vertices array has been updated.
  129. </div>
  130. <h3>[property:Boolean elementsNeedUpdate]</h3>
  131. <div>
  132. Set to *true* if the faces array has been updated.
  133. </div>
  134. <h3>[property:Boolean uvsNeedUpdate]</h3>
  135. <div>
  136. Set to *true* if the uvs array has been updated.
  137. </div>
  138. <h3>[property:Boolean normalsNeedUpdate]</h3>
  139. <div>
  140. Set to *true* if the normals array has been updated.
  141. </div>
  142. <h3>[property:Boolean tangentsNeedUpdate]</h3>
  143. <div>
  144. Set to *true* if the tangents in the faces has been updated.
  145. </div>
  146. <h3>[property:Boolean colorsNeedUpdate]</h3>
  147. <div>
  148. Set to *true* if the colors array has been updated.
  149. </div>
  150. <h3>[property:Boolean lineDistancesNeedUpdate]</h3>
  151. <div>
  152. Set to *true* if the linedistances array has been updated.
  153. </div>
  154. <h3>[property:array lineDistances]</h3>
  155. <div>
  156. An array containing distances between vertices for Line geometries.
  157. This is required for LinePieces/LineDashedMaterial to render correctly.
  158. Line distances can also be generated with computeLineDistances.
  159. </div>
  160. <h2>Methods</h2>
  161. <h3>[page:EventDispatcher EventDispatcher] methods are available on this class.</h3>
  162. <h3>[method:null applyMatrix]( [page:Matrix4 matrix] )</h3>
  163. <div>
  164. Bakes matrix transform directly into vertex coordinates.
  165. </div>
  166. <h3>[method:null center] ()</h3>
  167. <div>
  168. Center the geometry based on the bounding box.
  169. </div>
  170. <h3>[method:Geometry rotateX] ( [page:Float radians] )</h3>
  171. <div>
  172. Rotate the geometry about the X axis. This is typically done as a one time operation, and not during a loop
  173. Use [page:Object3D.rotation] for typical real-time mesh rotation.
  174. </div>
  175. <h3>[method:Geometry rotateY] ( [page:Float radians] )</h3>
  176. <div>
  177. Rotate the geometry about the Y axis. This is typically done as a one time operation, and not during a loop
  178. Use [page:Object3D.rotation] for typical real-time mesh rotation.
  179. </div>
  180. <h3>[method:Geometry rotateZ] ( [page:Float radians] )</h3>
  181. <div>
  182. Rotate the geometry about the Z axis. This is typically done as a one time operation, and not during a loop
  183. Use [page:Object3D.rotation] for typical real-time mesh rotation.
  184. </div>
  185. <h3>[method:Geometry translate] ( [page:Float x], [page:Float y], [page:Float z] )</h3>
  186. <div>
  187. Translate the geometry. This is typically done as a one time operation, and not during a loop
  188. Use [page:Object3D.position] for typical real-time mesh translation.
  189. </div>
  190. <h3>[method:Geometry scale] ( [page:Float x], [page:Float y], [page:Float z] )</h3>
  191. <div>
  192. Scale the geometry data. This is typically done as a one time operation, and not during a loop
  193. Use [page:Object3D.scale] for typical real-time mesh scaling.
  194. </div>
  195. <h3>[method:Geometry lookAt] ( [page:Vector3 vector] )</h3>
  196. <div>
  197. vector - A world vector to look at.<br />
  198. </div>
  199. <div>
  200. Rotates the geometry to face point in space. This is typically done as a one time operation, and not during a loop
  201. Use [page:Object3D.lookAt] for typical real-time mesh usage.
  202. </div>
  203. <h3>[method:null computeFaceNormals]()</h3>
  204. <div>
  205. Computes face normals.
  206. </div>
  207. <h3>[method:null computeVertexNormals]()</h3>
  208. <div>
  209. Computes vertex normals by averaging face normals.<br />
  210. Face normals must be existing / computed beforehand.
  211. </div>
  212. <h3>[method:null computeMorphNormals]()</h3>
  213. <div>
  214. Computes morph normals.
  215. </div>
  216. <h3>[method:null computeTangents]()</h3>
  217. <div>
  218. Computes vertex tangents.<br />
  219. Based on [link:http://www.terathon.com/code/tangent.html]<br />
  220. Geometry must have vertex [page:UV UVs] (layer 0 will be used).
  221. </div>
  222. <h3>[method:null computeBoundingBox]()</h3>
  223. <div>
  224. Computes bounding box of the geometry, updating [page:Geometry Geometry.boundingBox] attribute.
  225. </div>
  226. <h3>[method:null computeBoundingSphere]()</h3>
  227. <div>
  228. Computes bounding sphere of the geometry, updating [page:Geometry Geometry.boundingSphere] attribute.
  229. </div>
  230. <div>Neither bounding boxes or bounding spheres are computed by default. They need to be explicitly computed, otherwise they are *null*.</div>
  231. <h3>[method:null merge]( [page:Geometry geometry], [page:Matrix4 matrix], [page:Integer materialIndexOffset] )</h3>
  232. <div>Merge two geometries or geometry and geometry from object (using object's transform)</div>
  233. <h3>[method:null mergeVertices]()</h3>
  234. <div>
  235. Checks for duplicate vertices using hashmap.<br />
  236. Duplicated vertices are removed and faces' vertices are updated.
  237. </div>
  238. <h3>[method:null normalize]()</h3>
  239. <div>
  240. Normalize the geometry. <br />
  241. Make the geometry centered and has a bounding sphere whose raidus equals to 1.0.
  242. </div>
  243. <h3>[method:Geometry clone]()</h3>
  244. <div>
  245. Creates a new clone of the Geometry.
  246. </div>
  247. <h3>[method:null dispose]()</h3>
  248. <div>
  249. Removes The object from memory. <br />
  250. Don't forget to call this method when you remove a geometry because it can cause memory leaks.
  251. </div>
  252. <h3>[method:null computeLineDistances]()</h3>
  253. <div>
  254. Compute distances between vertices for Line geometries.
  255. </div>
  256. <h2>Source</h2>
  257. [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
  258. </body>
  259. </html>