UNPKG

@tolokoban/tgd

Version:

ToloGameDev library for WebGL2

62 lines 1.99 kB
import { TgdDataset, TgdDatasetType } from "../dataset"; import { TgdTypeArrayForElements, WebglDrawMode } from "../types"; interface TgdGeometryOptionsCommon { /** * Default mode is TRIANGLES. */ drawMode?: WebglDrawMode | number; /** * If the count is not defined, we will figure it out from * the `elements` typed array or from the POSITION attribute. */ count?: number; elements?: TgdTypeArrayForElements; /** * Compute normals with a smooth shading if * none has been provided. */ computeNormalsIfMissing?: boolean; } export interface TgdGeometryOptions1 extends TgdGeometryOptionsCommon { dataset: TgdDataset; attPosition?: string; attNormal?: string; attUV?: string; } export interface TgdGeometryOptions2 extends TgdGeometryOptionsCommon { attPosition: Float32Attribute; attNormal?: Float32Attribute; attUV?: Float32Attribute; } interface Float32Attribute { name: string; data: Float32Array; type?: TgdDatasetType; } /** * Geometry is used to define a mesh. * It must hold at least one vec3 attributes * for the vertices. */ export declare class TgdGeometry { /** Name of the POSITION attribute in the shader. */ readonly attPosition: string; /** Name of the NORMAL attribute in the shader. */ readonly attNormal: string; /** Name of the UV attribute in the shader. */ readonly attUV: string; readonly count: number; readonly elements?: Readonly<TgdTypeArrayForElements>; readonly drawMode: WebglDrawMode | number; protected _dataset: TgdDataset; protected _elementsType: number; static make(options: TgdGeometryOptions2): TgdGeometry; constructor(options: TgdGeometryOptions1); get dataset(): Readonly<TgdDataset>; get elementsType(): number; getElement(index: number): number; computeNormals(): void; private computeNormalsForTrianglesDrawMode; } export {}; //# sourceMappingURL=geometry.d.ts.map