namespace NT { /**
     * Holds reference information for a given Shader.
     */ class ShaderReferenceNode { /** The referenced Shader. */ public shader : Shader ; /** The number of times the Shader is referenced. Default is 1 because this is only created when a Shader is needed. */ public referenceCount : number = 1 ; param shader public constructor ( shader ) { this . shader = shader ; } } /**
     * Manages Shaders in the engine. This is responsible for managing Shader references.
     */ export class ShaderManager { private static _shaders : Dictionary < ShaderReferenceNode > = { } ; private static _activeShader : Shader ; /** Private to enforce singleton pattern. */ private constructor ( ) { } /** Initializes this shader manager. */ public static Initialize ( ) { ShaderManager . Register ( new BasicShader ( ) ) ; } public static get ActiveShader ( ) : Shader { return ShaderManager . _activeShader ; } public static set ActiveShader ( value ) { if ( ShaderManager . _activeShader !== value ) { ShaderManager . _activeShader = value ; } } param shader public static Register ( shader ) { if ( ShaderManager . _shaders [ shader . name ] !== undefined ) { console . warn ( `A shader named ${ shader . name } already exists and will not be re-registered.` ) ; } else { ShaderManager . _shaders [ shader . name ] = new ShaderReferenceNode ( shader ) ; } } param shaderName public static GetShader ( shaderName ) { if ( ShaderManager . _shaders [ shaderName ] !== undefined ) { ShaderManager . _shaders [ shaderName ] . referenceCount ++ ; } return ShaderManager . _shaders [ shaderName ] . shader ; } param shaderName public static ReleaseShader ( shaderName ) { if ( ShaderManager . _shaders [ shaderName ] === undefined ) { console . warn ( `A shader named ${ shaderName } does not exist and therefore cannot be released.` ) ; } else { ShaderManager . _shaders [ shaderName ] . referenceCount -- ; } } } }