Skip to main content

Class: Material

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

Constructors

Constructor

new Material(vertexShaderSource, fragmentShaderSource, gl): Material

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

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:21

Methods

bind()

bind(gl): void

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

Binds the material (program, uniforms, textures).

Parameters

gl

WebGL2RenderingContext

Returns

void


setColorUniform()

setColorUniform(name, color): void

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

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:116

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:136

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

Parameters

name

string

vector

Vector2 | Vector3

Returns

void