1 | import { BUFFER_TYPE } from '@pixi/constants';
|
2 | import { Runner } from '@pixi/runner';
|
3 | import type { GLBuffer } from './GLBuffer';
|
4 | /**
|
5 | * Marks places in PixiJS where you can pass Float32Array, UInt32Array, any typed arrays, and ArrayBuffer.
|
6 | *
|
7 | * Same as ArrayBuffer in typescript lib, defined here just for documentation.
|
8 | * @memberof PIXI
|
9 | */
|
10 | export interface IArrayBuffer extends ArrayBuffer {
|
11 | }
|
12 | /**
|
13 | * PixiJS classes use this type instead of ArrayBuffer and typed arrays
|
14 | * to support expressions like `geometry.buffers[0].data[0] = position.x`.
|
15 | *
|
16 | * Gives access to indexing and `length` field.
|
17 | * - @popelyshev: If data is actually ArrayBuffer and throws Exception on indexing - its user problem :)
|
18 | * @memberof PIXI
|
19 | */
|
20 | export interface ITypedArray extends IArrayBuffer {
|
21 | readonly length: number;
|
22 | [index: number]: number;
|
23 | readonly BYTES_PER_ELEMENT: number;
|
24 | }
|
25 | /**
|
26 | * A wrapper for data so that it can be used and uploaded by WebGL
|
27 | * @memberof PIXI
|
28 | */
|
29 | export declare class Buffer {
|
30 | /**
|
31 | * The data in the buffer, as a typed array
|
32 | * @type {PIXI.IArrayBuffer}
|
33 | */
|
34 | data: ITypedArray;
|
35 | /**
|
36 | * The type of buffer this is, one of:
|
37 | * + ELEMENT_ARRAY_BUFFER - used as an index buffer
|
38 | * + ARRAY_BUFFER - used as an attribute buffer
|
39 | * + UNIFORM_BUFFER - used as a uniform buffer (if available)
|
40 | */
|
41 | type: BUFFER_TYPE;
|
42 | static: boolean;
|
43 | id: number;
|
44 | disposeRunner: Runner;
|
45 | /**
|
46 | * A map of renderer IDs to webgl buffer
|
47 | * @private
|
48 | * @type {Object<number, GLBuffer>}
|
49 | */
|
50 | _glBuffers: {
|
51 | [key: number]: GLBuffer;
|
52 | };
|
53 | _updateID: number;
|
54 | /**
|
55 | * @param {PIXI.IArrayBuffer} data - the data to store in the buffer.
|
56 | * @param _static - `true` for static buffer
|
57 | * @param index - `true` for index buffer
|
58 | */
|
59 | constructor(data?: IArrayBuffer, _static?: boolean, index?: boolean);
|
60 | /**
|
61 | * Flags this buffer as requiring an upload to the GPU.
|
62 | * @param {PIXI.IArrayBuffer|number[]} [data] - the data to update in the buffer.
|
63 | */
|
64 | update(data?: IArrayBuffer | Array<number>): void;
|
65 | /** Disposes WebGL resources that are connected to this geometry. */
|
66 | dispose(): void;
|
67 | /** Destroys the buffer. */
|
68 | destroy(): void;
|
69 | /**
|
70 | * Flags whether this is an index buffer.
|
71 | *
|
72 | * Index buffers are of type `ELEMENT_ARRAY_BUFFER`. Note that setting this property to false will make
|
73 | * the buffer of type `ARRAY_BUFFER`.
|
74 | *
|
75 | * For backwards compatibility.
|
76 | */
|
77 | set index(value: boolean);
|
78 | get index(): boolean;
|
79 | /**
|
80 | * Helper function that creates a buffer based on an array or TypedArray
|
81 | * @param {ArrayBufferView | number[]} data - the TypedArray that the buffer will store. If this is a regular Array it will be converted to a Float32Array.
|
82 | * @returns - A new Buffer based on the data provided.
|
83 | */
|
84 | static from(data: IArrayBuffer | number[]): Buffer;
|
85 | }
|