UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

92 lines (91 loc) 3.25 kB
export type ChunkValidation = { /** * - Deprecation message to display. */ message?: string; /** * - Validation callback receiving chunk name and code. */ callback?: (arg0: string, arg1: string) => void; /** * - Default GLSL code. If matches, no warning. */ defaultCodeGLSL?: string; /** * - Default WGSL code. If matches, no warning. */ defaultCodeWGSL?: string; }; /** * @typedef {object} ChunkValidation * @property {string} [message] - Deprecation message to display. * @property {function(string, string):void} [callback] - Validation callback receiving chunk name and code. * @property {string} [defaultCodeGLSL] - Default GLSL code. If matches, no warning. * @property {string} [defaultCodeWGSL] - Default WGSL code. If matches, no warning. */ /** * A collection of shader chunks, used by {@link ShaderChunks}. This is a map of shader chunk names * to their code. As this class extends `Map`, it can be used as a `Map` as well in addition to * custom functionality it provides. * * @category Graphics */ export class ShaderChunkMap extends Map<any, any> { /** * Create a new ShaderChunkMap instance. * * @param {Map<string, ChunkValidation>} [validations] - Optional map of chunk validations. * @ignore */ constructor(validations?: Map<string, ChunkValidation>); /** * Reference to chunk validations map. * * @type {Map<string, ChunkValidation>|undefined} * @private */ private _validations; _keyDirty: boolean; _key: string; /** * Adds a new shader chunk with a specified name and shader source code to the Map. If an * element with the same name already exists, the element will be updated. * * @param {string} name - The name of the shader chunk. * @param {string} code - The shader source code. * @returns {this} The ShaderChunkMap instance. */ set(name: string, code: string): this; /** * Adds multiple shader chunks to the Map. This method accepts an object where the keys are the * names of the shader chunks and the values are the shader source code. If an element with the * same name already exists, the element will be updated. * * @param {Object} object - Object containing shader chunks. * @param {boolean} override - Whether to override existing shader chunks. Defaults to true. * @returns {this} The ShaderChunkMap instance. */ add(object: any, override?: boolean): this; /** * Removes a shader chunk by name from the Map. If the element does not exist, no action is * taken. * * @param {string} name - The name of the shader chunk to remove. * @returns {boolean} True if an element in the Map existed and has been removed, or false if the * element does not exist. */ delete(name: string): boolean; markDirty(): void; _dirty: boolean; isDirty(): boolean; resetDirty(): void; get key(): string; /** * Copy the shader chunk map. * * @param {ShaderChunkMap} source - The instance to copy. * @returns {this} The destination instance. * @ignore */ copy(source: ShaderChunkMap): this; }