@tolokoban/tgd
Version:
ToloGameDev library for WebGL2
99 lines • 3.34 kB
TypeScript
import { TgdBufferOptionTarget, TgdBufferOptionUsage } from "../buffer";
import { TgdProgram } from "../program";
export type TgdDatasetType = "float" | "vec2" | "vec3" | "vec4";
export interface TgdDatasetOptions {
divisor: number;
target: TgdBufferOptionTarget;
usage: TgdBufferOptionUsage;
}
export type TgdDatasetTypeRecord = Record<string, TgdDatasetType>;
export declare class TgdDataset {
private readonly attributesDefinition;
private readonly options;
private stride;
private definitions;
private _data;
private _count;
target: TgdBufferOptionTarget;
usage: TgdBufferOptionUsage;
constructor(attributesDefinition: TgdDatasetTypeRecord, options?: Partial<TgdDatasetOptions>);
private initialize;
/**
* Throw an exception if the attribute `attribName` does not exist,
* or if it is not of any of the `types`.
* @param attribName
* @param types
*/
assertAttribType(attribName: string, ...types: string[]): this;
addAttributes(attributesDefinition: TgdDatasetTypeRecord): void;
clone(): TgdDataset;
/**
* Warning!
*
* This ArrayBuffer will be detached as soon as its
* size is changed!
*/
get data(): Readonly<ArrayBuffer>;
/** Get number of attributes. */
get count(): number;
/** Set number of attributes (reallocate data accordingly) */
set count(count: number);
get attributesNames(): string[];
getAttribAccessor(attribName: string): {
get: (index: number, dimension?: number) => number;
set: (value: number, index: number, dimension?: number) => void;
};
/**
* Set the data for one attribute.
*
* If you try to set more element that the current buffer
* can hold, the buffer will be expanded.
* And the property `count` will change accordingly.
*
* @param attribName If the attribute does not exist,
* you will get an exception.
* @param value The ArrayBuffer holding the data you
* want to set to this attribute
* @param param2
*/
set(attribName: string, value: ArrayBuffer | Int8Array | Uint8Array | Int16Array | Uint16Array | Uint32Array | Float32Array | {
buffer: ArrayBuffer;
}, { byteOffset, byteStride, first, count, targetFirst, }?: Partial<{
/**
* First byte of meaningful data in this buffer.
*/
byteOffset: number;
/**
* Number of bytes between two elements.
* If data is packed, you can leave it undefined.
*/
byteStride: number;
/**
* Index if the first source element.
* Default to 0.
*/
first: number;
/**
* Maximum number of elements to store.
* Default to Infinity.
*/
count: number;
/**
* Index if the first destination element.
* Default to 0.
*/
targetFirst: number;
}>): void;
private getDef;
/**
* Enable the vertex attrib array, and set
* the vertex attrib pointer for every declared
* attribute.
*/
defineAttributes(gl: WebGL2RenderingContext, prg: TgdProgram): void;
toCode({ indent }?: Partial<{
indent: string;
}>): string;
debug(caption?: string): void;
}
//# sourceMappingURL=dataset.d.ts.map