import { DataTypeOption } from './enums'; /** * Describes an attribute of a vertex * * @public * @remarks * An attribute of a vertex may be for example a `position` a `normal` or a `color`. * A vertex may consist of multiple attributes. This data structure * describes where the data of an attribute starts and how it is laid out. */ export interface VertexAttribute { /** * Offset in bytes from beginning of vertex to this attribute */ offset?: number; /** * The data type of a single element in this attribute */ type: DataTypeOption; /** * The number of elements in this attribute. e.g. a vec3 has 3 elements */ elements: number; /** * Indicates that integer elements should be normalized * * @remarks * Signed values are normalized to [0, 1] range. * Unsigned values are normalized to [-1, 1] range. */ normalize?: boolean; /** * If true, all elements are packed into a single element */ packed?: boolean; } /** * Provides layouts of common attributes like `position`, `color`, `texture` etc. */ export declare const VertexLayoutCommons: { position: Readonly; color: Readonly; normal: Readonly; tangent: Readonly; bitangent: Readonly; texture: Readonly; }; /** * Gets a vertex attribute specification for given attribute semantic * * @remarks * Uses {@link VertexLayoutCommons} to lookup a common specification for given semantic name. * * The semantic name is stripped down to [a-z] characters. So `texture`, `texture1`, `texture_2` * are all treated as same semantic: `texture` * * @param semantic - the semantic name * @param overrides - used to enrich or override the result */ export declare function commonVertexAttribute(semantic: string, overrides?: Partial): VertexAttribute; /** * Provides vertex layout utility functions * * @public */ export declare class VertexLayout { [key: string]: VertexAttribute; /** * Calls {@link VertexLayout.create} if parameter is a string, otherwise simply returns the input value */ static convert(nameOrLayout: string | VertexLayout): VertexLayout; /** * Creates a vertex layout object from given names * * @remarks * uses the {@link VertexLayout.preset} to lookup the attribute layout for each name * * ```ts * VertexLayout.create('position', 'normal', 'texture'); * VertexLayout.create('PositionNormalTexture'); * // in both cases the following layout is returned: * // { * // position: { offset: 0, type: 'float', elements: 3 } * // normal: { offset: 12, type: 'float', elements: 2 } * // texture: { offset: 24, type: 'float', elements: 2 } * // } * ``` */ static create(...names: string[]): VertexLayout; /** * Counts the number of elements in a single vertex. * * @remarks * For example if a layout has defined a `position` and a `normal` * (both with three elements) this will return 6. * packed elements will count as one. */ static countElements(layout: VertexLayout): number; /** * Counts the number of elements in a single vertex until the given attribute. */ static countElementsBefore(layout: VertexLayout, semantic: string): number; /** * Counts the number of elements in a single vertex after the given attribute. */ static countElementsAfter(layout: VertexLayout, semantic: string): number; /** * Counts the number of bytes in a single vertex. * * @remarks * For example if a layout has a `position` and a `normal` defined * both with three elements and each element is a float, this will return 24. */ static countBytes(layout: VertexLayout): number; /** * Counts the number of bytes in a single vertex until the given attribute. */ static countBytesBefore(layout: VertexLayout, semantic: string): number; /** * Counts the number of bytes in a single vertex after the given attribute. */ static countBytesAfter(layout: VertexLayout, semantic: string): number; /** * Iterates over all vertex attributes in a layout * * @param layout - the layout * @param fn - function to call for each attribute */ static forEach(layout: VertexLayout, fn: (semantic: string, attribute: VertexAttribute) => void): void; /** * Converts a number array to an ArrayBuffer by using the given layout information * * @param data - The data array * @param layoutOrType - The data layout information */ static convertArrayToBufferView(data: number[], layoutOrType: string | VertexLayout): ArrayBufferView; } //# sourceMappingURL=VertexLayout.d.ts.map