BufferGeometry.d.ts 4.8 KB

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