UNPKG

@three.ez/batched-mesh-extensions

Version:
50 lines 2.23 kB
import { BatchedMesh } from 'three'; import { ChannelSize, SquareDataTexture, UniformMap, UniformType, UniformValue, UniformValueObj } from '../SquareDataTexture.js'; export type UniformSchema = { [x: string]: UniformType; }; export type UniformSchemaShader = { vertex?: UniformSchema; fragment?: UniformSchema; }; export type UniformSchemaResult = { channels: ChannelSize; pixelsPerInstance: number; uniformMap: UniformMap; fetchInFragmentShader: boolean; }; declare module 'three' { interface BatchedMesh { /** * Texture storing custom uniforms per instance. */ uniformsTexture?: SquareDataTexture; /** * Retrieves a uniform value for a specific instance. * @param id The index of the instance. * @param name The name of the uniform. * @param target Optional target object to store the uniform value. * @returns The uniform value for the specified instance. */ getUniformAt(id: number, name: string, target?: UniformValueObj): UniformValue; /** * Sets a uniform value for a specific instance. * @param id The index of the instance. * @param name The name of the uniform. * @param value The value to set for the uniform. */ setUniformAt(id: number, name: string, value: UniformValue): void; /** * Initializes per-instance uniforms using a schema. * @param schema The schema defining the uniforms. */ initUniformsPerInstance(schema: UniformSchemaShader): void; } } export declare function getUniformAt(this: BatchedMesh, id: number, name: string, target?: UniformValueObj): UniformValue; export declare function setUniformAt(this: BatchedMesh, id: number, name: string, value: UniformValue): void; export declare function initUniformsPerInstance(this: BatchedMesh, schema: UniformSchemaShader): void; export declare function getUniformSchemaResult(schema: UniformSchemaShader): UniformSchemaResult; export declare function getUniformOffset(size: number, tempOffset: number[]): number; export declare function getUniformSize(type: UniformType): number; //# sourceMappingURL=Uniforms.d.ts.map