UNPKG

seed-engine

Version:

A Lightweight 2D game engine using WebGL2. The engine is designed on the focus of creating a bridge between creating and publishing games to the Seed Network as modules.

43 lines (38 loc) 1.3 kB
import Renderable from './Renderable'; import Matrix3 from '../render/WebGL/Matrix3'; import ProgramManager from '../manager/ProgramManager'; /** * Renderable2DMultitex is a renderable component, similar to the Renderable2D, except * it supports multiple textures. The program assigned to this renderable computes what to * do with the shaders passed. */ export default class Renderable2DMultitex extends Renderable { constructor(program = ProgramManager.getProgram('Default')) { super(program); this.className = 'Renderable2DMultitex'; } /** * Adds a texture to this renderable. * * @param {textureJSONObject} textureObject Texture reference object, from TextureManager. */ addTexture(textureObject) { this.textures.push(textureObject); } /** * Removes the nth texture from this component. Textures are pushed to end of list when added. * * @param {number} textureIndex Index of texture to remove. */ removeTexture(textureIndex) { if (textureIndex < 0 || textureIndex >= this.textures.length) return; this.textures.splice(textureIndex, 1); } /** * Removes all textures from this renderable. */ removeTextures() { this.textures = []; } }