Geometry.d.ts 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. import { Vector3 } from './../math/Vector3';
  2. import { Color } from './../math/Color';
  3. import { Face3 } from './Face3';
  4. import { Vector2 } from './../math/Vector2';
  5. import { Vector4 } from './../math/Vector4';
  6. import { Box3 } from './../math/Box3';
  7. import { Sphere } from './../math/Sphere';
  8. import { Matrix4 } from './../math/Matrix4';
  9. import { BufferGeometry } from './BufferGeometry';
  10. import { Matrix } from './../math/Matrix3';
  11. import { Mesh } from './../objects/Mesh';
  12. import { Bone } from './../objects/Bone';
  13. import { AnimationClip } from './../animation/AnimationClip';
  14. import { EventDispatcher } from './EventDispatcher';
  15. /**
  16. * @deprecated Use {@link Face3} instead.
  17. */
  18. export interface MorphTarget {
  19. name: string;
  20. vertices: Vector3[];
  21. }
  22. export interface MorphColor {
  23. name: string;
  24. colors: Color[];
  25. }
  26. export interface MorphNormals {
  27. name: string;
  28. normals: Vector3[];
  29. }
  30. /**
  31. * Base class for geometries
  32. *
  33. * see {@link https://github.com/mrdoob/three.js/blob/master/src/core/Geometry.js|src/core/Geometry.js}
  34. */
  35. export class Geometry extends EventDispatcher {
  36. constructor();
  37. /**
  38. * Unique number of this geometry instance
  39. */
  40. id: number;
  41. uuid: string;
  42. readonly isGeometry: true;
  43. /**
  44. * Name for this geometry. Default is an empty string.
  45. * @default ''
  46. */
  47. name: string;
  48. /**
  49. * @default 'Geometry'
  50. */
  51. type: string;
  52. /**
  53. * The array of vertices hold every position of points of the model.
  54. * To signal an update in this array, Geometry.verticesNeedUpdate needs to be set to true.
  55. * @default []
  56. */
  57. vertices: Vector3[];
  58. /**
  59. * Array of vertex colors, matching number and order of vertices.
  60. * Used in ParticleSystem, Line and Ribbon.
  61. * Meshes use per-face-use-of-vertex colors embedded directly in faces.
  62. * To signal an update in this array, Geometry.colorsNeedUpdate needs to be set to true.
  63. * @default []
  64. */
  65. colors: Color[];
  66. /**
  67. * Array of triangles or/and quads.
  68. * The array of faces describe how each vertex in the model is connected with each other.
  69. * To signal an update in this array, Geometry.elementsNeedUpdate needs to be set to true.
  70. * @default []
  71. */
  72. faces: Face3[];
  73. /**
  74. * Array of face UV layers.
  75. * Each UV layer is an array of UV matching order and number of vertices in faces.
  76. * To signal an update in this array, Geometry.uvsNeedUpdate needs to be set to true.
  77. * @default [[]]
  78. */
  79. faceVertexUvs: Vector2[][][];
  80. /**
  81. * Array of morph targets. Each morph target is a Javascript object:
  82. *
  83. * { name: "targetName", vertices: [ new THREE.Vector3(), ... ] }
  84. *
  85. * Morph vertices match number and order of primary vertices.
  86. * @default []
  87. */
  88. morphTargets: MorphTarget[];
  89. /**
  90. * Array of morph normals. Morph normals have similar structure as morph targets, each normal set is a Javascript object:
  91. *
  92. * morphNormal = { name: "NormalName", normals: [ new THREE.Vector3(), ... ] }
  93. * @default []
  94. */
  95. morphNormals: MorphNormals[];
  96. /**
  97. * Array of skinning weights, matching number and order of vertices.
  98. * @default []
  99. */
  100. skinWeights: Vector4[];
  101. /**
  102. * Array of skinning indices, matching number and order of vertices.
  103. * @default []
  104. */
  105. skinIndices: Vector4[];
  106. /**
  107. * @default []
  108. */
  109. lineDistances: number[];
  110. /**
  111. * Bounding box.
  112. * @default null
  113. */
  114. boundingBox: Box3 | null;
  115. /**
  116. * Bounding sphere.
  117. * @default null
  118. */
  119. boundingSphere: Sphere | null;
  120. /**
  121. * Set to true if the vertices array has been updated.
  122. * @default false
  123. */
  124. verticesNeedUpdate: boolean;
  125. /**
  126. * Set to true if the faces array has been updated.
  127. * @default false
  128. */
  129. elementsNeedUpdate: boolean;
  130. /**
  131. * Set to true if the uvs array has been updated.
  132. * @default false
  133. */
  134. uvsNeedUpdate: boolean;
  135. /**
  136. * Set to true if the normals array has been updated.
  137. * @default false
  138. */
  139. normalsNeedUpdate: boolean;
  140. /**
  141. * Set to true if the colors array has been updated.
  142. * @default false
  143. */
  144. colorsNeedUpdate: boolean;
  145. /**
  146. * Set to true if the linedistances array has been updated.
  147. * @default false
  148. */
  149. lineDistancesNeedUpdate: boolean;
  150. /**
  151. *
  152. * @default false
  153. */
  154. groupsNeedUpdate: boolean;
  155. /**
  156. * Bakes matrix transform directly into vertex coordinates.
  157. */
  158. applyMatrix4( matrix: Matrix4 ): Geometry;
  159. rotateX( angle: number ): Geometry;
  160. rotateY( angle: number ): Geometry;
  161. rotateZ( angle: number ): Geometry;
  162. translate( x: number, y: number, z: number ): Geometry;
  163. scale( x: number, y: number, z: number ): Geometry;
  164. lookAt( vector: Vector3 ): void;
  165. fromBufferGeometry( geometry: BufferGeometry ): Geometry;
  166. center(): Geometry;
  167. normalize(): Geometry;
  168. /**
  169. * Computes face normals.
  170. */
  171. computeFaceNormals(): void;
  172. /**
  173. * Computes vertex normals by averaging face normals.
  174. * Face normals must be existing / computed beforehand.
  175. */
  176. computeVertexNormals( areaWeighted?: boolean ): void;
  177. /**
  178. * Compute vertex normals, but duplicating face normals.
  179. */
  180. computeFlatVertexNormals(): void;
  181. /**
  182. * Computes morph normals.
  183. */
  184. computeMorphNormals(): void;
  185. /**
  186. * Computes bounding box of the geometry, updating {@link Geometry.boundingBox} attribute.
  187. */
  188. computeBoundingBox(): void;
  189. /**
  190. * Computes bounding sphere of the geometry, updating Geometry.boundingSphere attribute.
  191. * Neither bounding boxes or bounding spheres are computed by default. They need to be explicitly computed, otherwise they are null.
  192. */
  193. computeBoundingSphere(): void;
  194. merge(
  195. geometry: Geometry,
  196. matrix?: Matrix,
  197. materialIndexOffset?: number
  198. ): void;
  199. mergeMesh( mesh: Mesh ): void;
  200. /**
  201. * Checks for duplicate vertices using hashmap for specified number of decimal points, e.g. 4 for epsilon of 0.0001
  202. * Duplicated vertices are removed and faces' vertices are updated.
  203. */
  204. mergeVertices( precisionPoints?: number ): number;
  205. setFromPoints( points: Array<Vector2> | Array<Vector3> ): this;
  206. sortFacesByMaterialIndex(): void;
  207. toJSON(): any;
  208. /**
  209. * Creates a new clone of the Geometry.
  210. */
  211. clone(): Geometry;
  212. copy( source: Geometry ): this;
  213. /**
  214. * Removes The object from memory.
  215. * Don't forget to call this method when you remove an geometry because it can cuase meomory leaks.
  216. */
  217. dispose(): void;
  218. // These properties do not exist in a normal Geometry class, but if you use the instance that was passed by JSONLoader, it will be added.
  219. bones: Bone[];
  220. animation: AnimationClip;
  221. animations: AnimationClip[];
  222. }