Geometry.d.ts 6.2 KB

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