Home Reference Source
import {CgShader} from './core/cg/cg_shader.js'
public class | source

CgShader

Extends:

EventTarget → CgShader

Direct Subclass:

Shader, Shader

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

id: *

Private Members
private

_defines: *[]

private

_isValid: boolean

private
private

_moduleNumId: number

private

_modules: *[]

private

_needsRecompile: boolean

Method Summary

Public Methods
public

addModule(mod: shaderModule, sibling: shaderModule): *

add a module

public

define(name: String, value: Any)

add a define to a shader, e.g.

public

getAttributeSrc(mod: *, srcHeadVert: *, srcVert: *): {"srcHeadVert": *, "srcVert": *}

public
public

getDefine(name: *): *

public

getDefines(): *

public
public

hasDefine(name: String): Boolean

return true if shader has define

public

hasModule(modId: *): boolean

public

remove a define from a shader

public

removeModule(mod: shaderModule)

remove a module from shader

public
public

setModules(names: *)

public

toggleDefine(name: name, enabled: any)

easily enable/disable a define without a value

Public Constructors

public constructor() source

Public Members

public id: * source

Private Members

private _defines: *[] source

private _isValid: boolean source

private _moduleNames: *[] source

private _moduleNumId: number source

private _modules: *[] source

private _needsRecompile: boolean source

Public Methods

public addModule(mod: shaderModule, sibling: shaderModule): * source

add a module

Params:

NameTypeAttributeDescription
mod shaderModule

the module to be added

sibling shaderModule
  • optional

sibling module, new module will share the same group

Return:

*

public define(name: String, value: Any) source

add a define to a shader, e.g. #define DO_THIS_THAT 1

Params:

NameTypeAttributeDescription
name String
value Any

(can be empty)

public getAttributeSrc(mod: *, srcHeadVert: *, srcVert: *): {"srcHeadVert": *, "srcVert": *} source

Params:

NameTypeAttributeDescription
mod *
srcHeadVert *
srcVert *

Return:

{"srcHeadVert": *, "srcVert": *}

public getCurrentModules(): * source

Return:

*

public getDefine(name: *): * source

Params:

NameTypeAttributeDescription
name *

Return:

*

public getDefines(): * source

Return:

*

public getNumModules(): * source

Return:

*

public hasDefine(name: String): Boolean source

return true if shader has define

Params:

NameTypeAttributeDescription
name String

Return:

Boolean

public hasModule(modId: *): boolean source

Params:

NameTypeAttributeDescription
modId *

Return:

boolean

public removeDefine(name: name) source

remove a define from a shader

Params:

NameTypeAttributeDescription
name name

public removeModule(mod: shaderModule) source

remove a module from shader

Params:

NameTypeAttributeDescription
mod shaderModule

the module to be removed

public replaceModuleSrc() source

public setModules(names: *) source

Params:

NameTypeAttributeDescription
names *

public toggleDefine(name: name, enabled: any) source

easily enable/disable a define without a value

Params:

NameTypeAttributeDescription
name name
enabled any

value or port