BufferGeometry.d.ts 4.9 KB

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