# ShaderChunkMap

Class · extends `Map` · category: Graphics

Source: https://github.com/playcanvas/engine/blob/970d89f6d3bc6667f4e1f88153abd6e7e82ed52c/src/scene/shader-lib/shader-chunk-map.js#L19

A collection of shader chunks, used by [ShaderChunks](https://api.playcanvas.com/engine/classes/ShaderChunks.md). 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.

## Methods

### add

```ts
add(object: any, override?: boolean): ShaderChunkMap
```

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.

**Parameters**

- `object` (`any`): Object containing shader chunks.
- `override` (`boolean`, optional, default `true`): Whether to override existing shader chunks. Defaults to true.

**Returns** [`ShaderChunkMap`](https://api.playcanvas.com/engine/classes/ShaderChunkMap.md): The ShaderChunkMap instance.

### clear

```ts
clear(): void
```

Removes all shader chunks from the Map.

### delete

```ts
delete(name: string): boolean
```

Removes a shader chunk by name from the Map. If the element does not exist, no action is
taken.

**Parameters**

- `name` (`string`): 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.

### set

```ts
set(name: string, code: string): ShaderChunkMap
```

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.

**Parameters**

- `name` (`string`): The name of the shader chunk.
- `code` (`string`): The shader source code.

**Returns** [`ShaderChunkMap`](https://api.playcanvas.com/engine/classes/ShaderChunkMap.md): The ShaderChunkMap instance.
