Home Reference Source Test
import {_TextureManager} from 'seed-engine/src/manager/TextureManager.js'
private class | source

_TextureManager

You can directly use an instance of this class. TextureManager

Extends:

Manager → _TextureManager

Manages textures in the engine so the RendererManager and Renderables can reference one location for Textures. Essentially a texture library.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

textureIDs: *[]

public

textures: {}

Method Summary

Public Methods
public

addDataTexture(texName: string, textureData: Array *, textureInternalFormat: GLint, textureFormat: GLint, frameWidth: number, frameHeight: number, width: number, height: number): *

public

addGlyphInfoToTexture(texName: *, glyphInfo: *): boolean

public

addTexture(texName: string, textureImageAsset: string, frameWidth: number, frameHeight: number, glyphInfo: JSON Object): Promise

Creates a Texture JSON Object and initializes the Texture with WebGL.

public

getTexture(texID: number): Texture Object

Returns a texture JSON Object containing the texture, texture data, name and id.

public

removeTexture(texName: *)

public

updateDataTexture(texName: *, textureData: *, x1: *, y1: *, width: *, height: *): *

Private Methods
private

Private function used for initializing a Texture from a path and binding it with WebGL.

private

_createTextureFromData(texData: *, textureInternalFormat: *, textureFormat: *, textureByteType: *, width: *, height: *): *

private

Inherited Summary

From class Manager
public

end()

public

pause()

public

start()

public
public

update()

Public Constructors

public constructor() source

Override:

Manager#constructor

Public Members

public textureIDs: *[] source

public textures: {} source

Public Methods

public addDataTexture(texName: string, textureData: Array *, textureInternalFormat: GLint, textureFormat: GLint, frameWidth: number, frameHeight: number, width: number, height: number): * source

Params:

NameTypeAttributeDescription
texName string

The name of the texture.

textureData Array *

An array object of data, array type depending on the textureInternalFormat.

textureInternalFormat GLint

Internal texture format type.

textureFormat GLint

Texture format type.

frameWidth number

Width of each sub sprite frame.

frameHeight number

Height of each sub sprite frame.

width number

Width of the texture.

height number

Height of the texture.

Return:

*

public addGlyphInfoToTexture(texName: *, glyphInfo: *): boolean source

Params:

NameTypeAttributeDescription
texName *
glyphInfo *

Return:

boolean

public addTexture(texName: string, textureImageAsset: string, frameWidth: number, frameHeight: number, glyphInfo: JSON Object): Promise source

Creates a Texture JSON Object and initializes the Texture with WebGL. The Texture is added to the textures array.

Params:

NameTypeAttributeDescription
texName string

Name of the texture.

textureImageAsset string

Path to the texture image to load.

frameWidth number

Width of sprite in spritesheet. -1 for full.

frameHeight number

Height of sprite in spritesheet. -1 for full.

glyphInfo JSON Object

Object defining additional info for letters to be used as a mapping for writing text. Fonts should have these for displaying letters. Format the ojject like so: { //height of all letters height: 8,

//letter corrosponding to the location and size defined inside.
'A': {
    //the x position in pixels for this character.
    x: 0,

    //width in pixels for this character.
    width: 8
}

}

Return:

Promise

A pending promise which will return the texture reference after complete.

public getTexture(texID: number): Texture Object source

Returns a texture JSON Object containing the texture, texture data, name and id.

Params:

NameTypeAttributeDescription
texID number

Name of the texture.

Return:

Texture Object

Returns a JSON object with Texture data.

public removeTexture(texName: *) source

Params:

NameTypeAttributeDescription
texName *

public updateDataTexture(texName: *, textureData: *, x1: *, y1: *, width: *, height: *): * source

Params:

NameTypeAttributeDescription
texName *
textureData *
x1 *
y1 *
width *
height *

Return:

*

Private Methods

private _createTextureFromAsset(asset: string): Promise source

Private function used for initializing a Texture from a path and binding it with WebGL.

Params:

NameTypeAttributeDescription
asset string

Path to texture file.

Return:

Promise

Returns a pending promise.

private _createTextureFromData(texData: *, textureInternalFormat: *, textureFormat: *, textureByteType: *, width: *, height: *): * source

Params:

NameTypeAttributeDescription
texData *
textureInternalFormat *
textureFormat *
textureByteType *
width *
height *

Return:

*

private _setAvailableTextureID(): * source

Return:

*