Material

Materials are used to organize draw calls into passes. They hold configuration information about how meshes should be rendered.

export class Material { constructor() { this.pass = 'opaque'; this.texture = new Texture(); this.texture.loadFromByteArray(1,1, new Uint8Array([255, 255, 255, 255])); this.decal = new Texture(); this.decal.loadFromByteArray(1,1, new Uint8Array([0, 0, 0, 0])); this.zOffset = 1; } destroy() { this.texture.destroy(); this.decal.destroy(); } apply() { gl.polygonOffset(this.zOffset, 0); this.texture.apply(0); this.decal.apply(1); } }