BufferGeometry.d.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. import { BufferAttribute } from './BufferAttribute';
  2. import { Box3 } from './../math/Box3';
  3. import { Sphere } from './../math/Sphere';
  4. import { Matrix4 } from './../math/Matrix4';
  5. import { Vector2 } from './../math/Vector2';
  6. import { Vector3 } from './../math/Vector3';
  7. import { Object3D } from './Object3D';
  8. import { Geometry } from './Geometry';
  9. import { DirectGeometry } from './DirectGeometry';
  10. import { EventDispatcher } from './EventDispatcher';
  11. import { InterleavedBufferAttribute } from './InterleavedBufferAttribute';
  12. /**
  13. * This is a superefficent class for geometries because it saves all data in buffers.
  14. * It reduces memory costs and cpu cycles. But it is not as easy to work with because of all the necessary buffer calculations.
  15. * It is mainly interesting when working with static objects.
  16. *
  17. * @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/BufferGeometry.js|src/core/BufferGeometry.js}
  18. */
  19. export class BufferGeometry extends EventDispatcher {
  20. /**
  21. * This creates a new BufferGeometry. It also sets several properties to an default value.
  22. */
  23. constructor();
  24. static MaxIndex: number;
  25. /**
  26. * Unique number of this buffergeometry instance
  27. */
  28. id: number;
  29. uuid: string;
  30. /**
  31. * @default ''
  32. */
  33. name: string;
  34. /**
  35. * @default 'BufferGeometry'
  36. */
  37. type: string;
  38. /**
  39. * @default null
  40. */
  41. index: BufferAttribute | null;
  42. /**
  43. * @default {}
  44. */
  45. attributes: {
  46. [name: string]: BufferAttribute | InterleavedBufferAttribute;
  47. };
  48. /**
  49. * @default {}
  50. */
  51. morphAttributes: {
  52. [name: string]: ( BufferAttribute | InterleavedBufferAttribute )[];
  53. };
  54. /**
  55. * @default false
  56. */
  57. morphTargetsRelative: boolean;
  58. /**
  59. * @default []
  60. */
  61. groups: { start: number; count: number; materialIndex?: number }[];
  62. /**
  63. * @default null
  64. */
  65. boundingBox: Box3 | null;
  66. /**
  67. * @default null
  68. */
  69. boundingSphere: Sphere | null;
  70. /**
  71. * @default { start: 0, count: Infinity }
  72. */
  73. drawRange: { start: number; count: number };
  74. /**
  75. * @default {}
  76. */
  77. userData: {[key: string]: any};
  78. readonly isBufferGeometry: true;
  79. getIndex(): BufferAttribute | null;
  80. setIndex( index: BufferAttribute | number[] | null ): BufferGeometry;
  81. setAttribute( name: string, attribute: BufferAttribute | InterleavedBufferAttribute ): BufferGeometry;
  82. getAttribute( name: string ): BufferAttribute | InterleavedBufferAttribute;
  83. deleteAttribute( name: string ): BufferGeometry;
  84. hasAttribute( name: string ): boolean;
  85. addGroup( start: number, count: number, materialIndex?: number ): void;
  86. clearGroups(): void;
  87. setDrawRange( start: number, count: number ): void;
  88. /**
  89. * Bakes matrix transform directly into vertex coordinates.
  90. */
  91. applyMatrix4( matrix: Matrix4 ): BufferGeometry;
  92. rotateX( angle: number ): BufferGeometry;
  93. rotateY( angle: number ): BufferGeometry;
  94. rotateZ( angle: number ): BufferGeometry;
  95. translate( x: number, y: number, z: number ): BufferGeometry;
  96. scale( x: number, y: number, z: number ): BufferGeometry;
  97. lookAt( v: Vector3 ): void;
  98. center(): BufferGeometry;
  99. setFromObject( object: Object3D ): BufferGeometry;
  100. setFromPoints( points: Vector3[] | Vector2[] ): BufferGeometry;
  101. updateFromObject( object: Object3D ): void;
  102. fromGeometry( geometry: Geometry, settings?: any ): BufferGeometry;
  103. fromDirectGeometry( geometry: DirectGeometry ): BufferGeometry;
  104. /**
  105. * Computes bounding box of the geometry, updating Geometry.boundingBox attribute.
  106. * Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are null.
  107. */
  108. computeBoundingBox(): void;
  109. /**
  110. * Computes bounding sphere of the geometry, updating Geometry.boundingSphere attribute.
  111. * Bounding spheres aren't' computed by default. They need to be explicitly computed, otherwise they are null.
  112. */
  113. computeBoundingSphere(): void;
  114. /**
  115. * Computes vertex normals by averaging face normals.
  116. */
  117. computeVertexNormals(): void;
  118. merge( geometry: BufferGeometry, offset?: number ): BufferGeometry;
  119. normalizeNormals(): void;
  120. toNonIndexed(): BufferGeometry;
  121. toJSON(): any;
  122. clone(): BufferGeometry;
  123. copy( source: BufferGeometry ): this;
  124. /**
  125. * Disposes the object from memory.
  126. * You need to call this when you want the bufferGeometry removed while the application is running.
  127. */
  128. dispose(): void;
  129. /**
  130. * @deprecated Use {@link BufferGeometry#groups .groups} instead.
  131. */
  132. drawcalls: any;
  133. /**
  134. * @deprecated Use {@link BufferGeometry#groups .groups} instead.
  135. */
  136. offsets: any;
  137. /**
  138. * @deprecated Use {@link BufferGeometry#setIndex .setIndex()} instead.
  139. */
  140. addIndex( index: any ): void;
  141. /**
  142. * @deprecated Use {@link BufferGeometry#addGroup .addGroup()} instead.
  143. */
  144. addDrawCall( start: any, count: any, indexOffset?: any ): void;
  145. /**
  146. * @deprecated Use {@link BufferGeometry#clearGroups .clearGroups()} instead.
  147. */
  148. clearDrawCalls(): void;
  149. /**
  150. * @deprecated Use {@link BufferGeometry#setAttribute .setAttribute()} instead.
  151. */
  152. addAttribute(
  153. name: string,
  154. attribute: BufferAttribute | InterleavedBufferAttribute
  155. ): BufferGeometry;
  156. /**
  157. * @deprecated Use {@link BufferGeometry#deleteAttribute .deleteAttribute()} instead.
  158. */
  159. removeAttribute( name: string ): BufferGeometry;
  160. addAttribute( name: any, array: any, itemSize: any ): any;
  161. }