gulp-structify
Version:
Generates WebGL-compatible Structs and StructBuffers from a template file.
81 lines (80 loc) • 2.96 kB
TypeScript
import { Struct } from './struct';
import { TypedArray } from './typedarray';
/**
* Helper class for working with Structs backed by a single TypedArray.
*/
export declare abstract class StructBuffer<T extends TypedArray> {
/**
* The primitive array data backing the Structs in this buffer.
*/
data: T;
/**
* The position of the current Struct in the backing array.
*/
dataPosition: number;
/**
* Gets the number of components contained in each Struct of this buffer.
*/
abstract structLength(): number;
/**
* Gets the current position of this buffer.
*/
position(): number;
/**
* Gets the maximum number of Structs this buffer can hold.
*/
capacity(): number;
/**
* Creates a buffer backed by the specified array data
* @param data the backing array.
* @param position the initial position of the buffer. Defaults to zero.
*/
constructor(data: T, position?: number);
/**
* Checks if the current position of this buffer is valid.
*/
hasValidPosition(): boolean;
/**
* Moves this buffer to the specified position.
* @returns true if an Struct exists at this position.
*/
moveToPosition(position: number): boolean;
/**
* Moves to the first Struct in this buffer.
* @returns true if an Struct exists at this position.
*/
moveToFirst(): boolean;
/**
* Moves to the next Struct in this buffer.
* @returns true if an Struct exists at this position.
*/
moveToNext(): boolean;
/**
* Moves to the previous Struct in this buffer.
* @returns true if an Struct exists at this position.
*/
moveToPrevous(): boolean;
/**
* Moves to the last Struct in this buffer.
* @returns true if an Struct exists at this position.
*/
moveToLast(): boolean;
/**
* Copies data from the source buffer into this buffer beginning at the specified position, without modifying the position of either buffer.
* @param position the offset into this buffer where the data should be copied.
* @param src buffer pointing to the first struct that should be copied.
* @param length the number of Structs to copy from the src buffer.
*/
asetFromBuffer(position: number, src: this, length?: number): void;
/**
* Copies data from the source buffer into this buffer at its current position, increasing the position of both buffers.
* @param src buffer pointing to the first struct that should be copied.
* @param length the number of Structs to copy from the src buffer.
*/
rsetFromBuffer(src: this, length?: number): void;
/**
* Sets each Struct in this buffer to the specified struct.
* @param src the struct or the buffer pointing to the struct.
*/
setEach(src: Struct<T> | this): void;
}