UNPKG

@tolokoban/tgd

Version:

ToloGameDev library for WebGL2

75 lines 2.5 kB
import { TgdDataset, TgdDatasetType } from "../dataset"; import { TgdTypeArrayForElements, WebglDrawMode } from "../types"; import { TgdBoundingBox } from ".."; interface TgdGeometryOptionsCommon { name?: string; /** * 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 { readonly name: string; /** 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: number; protected _dataset: TgdDataset; protected _elementsType: number; private static counter; static make(options: TgdGeometryOptions2): TgdGeometry; static fitElementsInTypeArray(elements: TgdTypeArrayForElements | number[]): TgdTypeArrayForElements; static join(geometries: TgdGeometry[]): TgdGeometry; constructor(options: TgdGeometryOptions1); debug(caption?: string): void; get dataset(): Readonly<TgdDataset>; get elementsType(): number; /** * Return the index of a vertex. * If no elements array has been defined, we return `index` verbatim. * Otherwise, we use this elements array. */ getElement(index: number): number; computeNormals(): this; computeBoundingBox(): TgdBoundingBox; private computeNormalsForTrianglesDrawMode; } export {}; //# sourceMappingURL=geometry.d.ts.map