File size: 4,524 Bytes
6cd9596
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import { BufferAttribute } from './BufferAttribute';
import { Box3 } from './../math/Box3';
import { Sphere } from './../math/Sphere';
import { Matrix4 } from './../math/Matrix4';
import { Vector2 } from './../math/Vector2';
import { Vector3 } from './../math/Vector3';
import { Object3D } from './Object3D';
import { Geometry } from './Geometry';
import { DirectGeometry } from './DirectGeometry';
import { EventDispatcher } from './EventDispatcher';
import { InterleavedBufferAttribute } from './InterleavedBufferAttribute';
/**
 * @deprecated Use {@link BufferAttribute#setDynamic THREE.BufferAttribute().setDynamic( true )} instead.
 */

/**
 * This is a superefficent class for geometries because it saves all data in buffers.
 * It reduces memory costs and cpu cycles. But it is not as easy to work with because of all the nessecary buffer calculations.
 * It is mainly interesting when working with static objects.
 *
 * @see <a href="https://github.com/mrdoob/three.js/blob/master/src/core/BufferGeometry.js">src/core/BufferGeometry.js</a>
 */
export class BufferGeometry extends EventDispatcher {
  /**
   * This creates a new BufferGeometry. It also sets several properties to an default value.
   */
  constructor();

  static MaxIndex: number;

  /**
   * Unique number of this buffergeometry instance
   */
  id: number;
  uuid: string;
  name: string;
  type: string;
  index: BufferAttribute;
  attributes: {
    [name: string]: BufferAttribute | InterleavedBufferAttribute;
  };
  morphAttributes: any;
  groups: { start: number; count: number; materialIndex?: number }[];
  boundingBox: Box3;
  boundingSphere: Sphere;
  drawRange: { start: number; count: number };
  userData: {[key: string]: any};

  getIndex(): BufferAttribute;
  setIndex(index: BufferAttribute | number[]): void;

  addAttribute(
    name: string,
    attribute: BufferAttribute | InterleavedBufferAttribute
  ): BufferGeometry;

  getAttribute(name: string): BufferAttribute | InterleavedBufferAttribute;
  removeAttribute(name: string): BufferGeometry;

  addGroup(start: number, count: number, materialIndex?: number): void;
  clearGroups(): void;

  setDrawRange(start: number, count: number): void;

  /**
   * Bakes matrix transform directly into vertex coordinates.
   */
  applyMatrix(matrix: Matrix4): BufferGeometry;

  rotateX(angle: number): BufferGeometry;
  rotateY(angle: number): BufferGeometry;
  rotateZ(angle: number): BufferGeometry;
  translate(x: number, y: number, z: number): BufferGeometry;
  scale(x: number, y: number, z: number): BufferGeometry;
  lookAt(v: Vector3): void;

  center(): BufferGeometry;

  setFromObject(object: Object3D): BufferGeometry;
  setFromPoints(points: Vector3[] | Vector2[]): BufferGeometry;
  updateFromObject(object: Object3D): void;

  fromGeometry(geometry: Geometry, settings?: any): BufferGeometry;

  fromDirectGeometry(geometry: DirectGeometry): BufferGeometry;

  /**
   * Computes bounding box of the geometry, updating Geometry.boundingBox attribute.
   * Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are null.
   */
  computeBoundingBox(): void;

  /**
   * Computes bounding sphere of the geometry, updating Geometry.boundingSphere attribute.
   * Bounding spheres aren't' computed by default. They need to be explicitly computed, otherwise they are null.
   */
  computeBoundingSphere(): void;

  /**
   * Computes vertex normals by averaging face normals.
   */
  computeVertexNormals(): void;

  merge(geometry: BufferGeometry, offset: number): BufferGeometry;
  normalizeNormals(): void;

  toNonIndexed(): BufferGeometry;

  toJSON(): any;
  clone(): this;
  copy(source: BufferGeometry): this;

  /**
   * Disposes the object from memory.
   * You need to call this when you want the bufferGeometry removed while the application is running.
   */
  dispose(): void;

  /**
   * @deprecated Use {@link BufferGeometry#groups .groups} instead.
   */
  drawcalls: any;

  /**
   * @deprecated Use {@link BufferGeometry#groups .groups} instead.
   */
  offsets: any;

  /**
   * @deprecated Use {@link BufferGeometry#setIndex .setIndex()} instead.
   */
  addIndex(index: any): void;

  /**
   * @deprecated Use {@link BufferGeometry#addGroup .addGroup()} instead.
   */
  addDrawCall(start: any, count: any, indexOffset?: any): void;

  /**
   * @deprecated Use {@link BufferGeometry#clearGroups .clearGroups()} instead.
   */
  clearDrawCalls(): void;

  addAttribute(name: any, array: any, itemSize: any): any;
}