Geometry.d.ts 6.2 KB

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