Geometry.d.ts 6.0 KB

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