BufferGeometry.d.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. name: string;
  31. type: string;
  32. index: BufferAttribute | null;
  33. attributes: {
  34. [name: string]: BufferAttribute | InterleavedBufferAttribute;
  35. };
  36. morphAttributes: {
  37. [name: string]: ( BufferAttribute | InterleavedBufferAttribute )[];
  38. };
  39. morphTargetsRelative: boolean;
  40. groups: { start: number; count: number; materialIndex?: number }[];
  41. boundingBox: Box3 | null;
  42. boundingSphere: Sphere | null;
  43. drawRange: { start: number; count: number };
  44. userData: {[key: string]: any};
  45. readonly isBufferGeometry: true;
  46. getIndex(): BufferAttribute | null;
  47. setIndex( index: BufferAttribute | number[] | null ): void;
  48. setAttribute( name: string, attribute: BufferAttribute | InterleavedBufferAttribute ): BufferGeometry;
  49. getAttribute( name: string ): BufferAttribute | InterleavedBufferAttribute;
  50. deleteAttribute( name: string ): BufferGeometry;
  51. addGroup( start: number, count: number, materialIndex?: number ): void;
  52. clearGroups(): void;
  53. setDrawRange( start: number, count: number ): void;
  54. /**
  55. * Bakes matrix transform directly into vertex coordinates.
  56. */
  57. applyMatrix4( matrix: Matrix4 ): BufferGeometry;
  58. rotateX( angle: number ): BufferGeometry;
  59. rotateY( angle: number ): BufferGeometry;
  60. rotateZ( angle: number ): BufferGeometry;
  61. translate( x: number, y: number, z: number ): BufferGeometry;
  62. scale( x: number, y: number, z: number ): BufferGeometry;
  63. lookAt( v: Vector3 ): void;
  64. center(): BufferGeometry;
  65. setFromObject( object: Object3D ): BufferGeometry;
  66. setFromPoints( points: Vector3[] | Vector2[] ): BufferGeometry;
  67. updateFromObject( object: Object3D ): void;
  68. fromGeometry( geometry: Geometry, settings?: any ): BufferGeometry;
  69. fromDirectGeometry( geometry: DirectGeometry ): BufferGeometry;
  70. /**
  71. * Computes bounding box of the geometry, updating Geometry.boundingBox attribute.
  72. * Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are null.
  73. */
  74. computeBoundingBox(): void;
  75. /**
  76. * Computes bounding sphere of the geometry, updating Geometry.boundingSphere attribute.
  77. * Bounding spheres aren't' computed by default. They need to be explicitly computed, otherwise they are null.
  78. */
  79. computeBoundingSphere(): void;
  80. /**
  81. * Computes vertex normals by averaging face normals.
  82. */
  83. computeVertexNormals(): void;
  84. merge( geometry: BufferGeometry, offset?: number ): BufferGeometry;
  85. normalizeNormals(): void;
  86. toNonIndexed(): BufferGeometry;
  87. toJSON(): any;
  88. clone(): this;
  89. copy( source: BufferGeometry ): this;
  90. /**
  91. * Disposes the object from memory.
  92. * You need to call this when you want the bufferGeometry removed while the application is running.
  93. */
  94. dispose(): void;
  95. /**
  96. * @deprecated Use {@link BufferGeometry#groups .groups} instead.
  97. */
  98. drawcalls: any;
  99. /**
  100. * @deprecated Use {@link BufferGeometry#groups .groups} instead.
  101. */
  102. offsets: any;
  103. /**
  104. * @deprecated Use {@link BufferGeometry#setIndex .setIndex()} instead.
  105. */
  106. addIndex( index: any ): void;
  107. /**
  108. * @deprecated Use {@link BufferGeometry#addGroup .addGroup()} instead.
  109. */
  110. addDrawCall( start: any, count: any, indexOffset?: any ): void;
  111. /**
  112. * @deprecated Use {@link BufferGeometry#clearGroups .clearGroups()} instead.
  113. */
  114. clearDrawCalls(): void;
  115. /**
  116. * @deprecated Use {@link BufferGeometry#setAttribute .setAttribute()} instead.
  117. */
  118. addAttribute(
  119. name: string,
  120. attribute: BufferAttribute | InterleavedBufferAttribute
  121. ): BufferGeometry;
  122. /**
  123. * @deprecated Use {@link BufferGeometry#deleteAttribute .deleteAttribute()} instead.
  124. */
  125. removeAttribute( name: string ): BufferGeometry;
  126. addAttribute( name: any, array: any, itemSize: any ): any;
  127. }