Skip to main content

Class: Material

Defined in: rendering/materials/material.ts:34

Constructors​

Constructor​

new Material(vertexShaderSource, fragmentShaderSource, gl): Material

Defined in: rendering/materials/material.ts:46

Constructs a new instance of the Material class.

Parameters​

vertexShaderSource​

ForgeShaderSource

The vertex shader source.

fragmentShaderSource​

ForgeShaderSource

The fragment shader source.

gl​

WebGL2RenderingContext

The WebGL2 rendering context.

Returns​

Material

Properties​

program​

readonly program: WebGLProgram

Defined in: rendering/materials/material.ts:35

Methods​

bind()​

bind(gl): void

Defined in: rendering/materials/material.ts:63

Binds the material (program, uniforms, textures).

Parameters​

gl​

WebGL2RenderingContext

Returns​

void


setColorUniform()​

setColorUniform(name, color): void

Defined in: rendering/materials/material.ts:143

Sets a color uniform as a float32 array using the color's RGBA values.

Parameters​

name​

string

color​

Color

Returns​

void


setUniform()​

setUniform(name, value): void

Defined in: rendering/materials/material.ts:130

Sets a uniform value (number, vec2, matrix, texture, etc.).

Parameters​

name​

string

value​

UniformValue

Returns​

void


setVectorUniform()​

setVectorUniform(name, vector): void

Defined in: rendering/materials/material.ts:150

Sets a vector2 or Vector3 uniform as a float32 array using the vector's elements.

Parameters​

name​

string

vector​

Vector2 | Vector3

Returns​

void