new ShaderBuilder()

Description

Tool to build shaders without redundancies in the imported chunks of code

Classes


new ShaderBuilder()

Members


code :string

Description

The shader built shader code.

Details
string

includedImports :Array.<string>

Description

The list of shader imports already included.

Details
Array.<string>

includedClasses :Array.<string>

Description

The list of classes already included.

Details
Array.<string>

includedConstants :Array.<string>

Description

List of names of constants already included

Details
Array.<string>

includedUniforms :Array.<string>

Description

List of names of uniforms already included

Details
Array.<string>

includedInstances :Array.<string>

Description

List of names of instances already included

Details
Array.<string>

uniforms :Object

Description

An object with all the uniforms to pass to the shader.

Details
Object

Methods


addChunk( code ) → {ShaderBuilder}

Description

Add the given chunk (without any prior test)

Parameters
Name Type Description
code string
Returns
  • the current shader builder

addImport( imp ) → {ShaderBuilder}

Description

Incorporate the given import (if it does not already exists)

Parameters
Name Type Description
imp string

the import to add

Returns
  • the current shader builder

addClass( name, code ) → {ShaderBuilder}

Description

Incorporate the given dependency (if it does not already exists)

Parameters
Name Type Description
name string

the name of the class

code string

the code of the class

Returns
  • the current shader builder

addConstant( name, type, value ) → {ShaderBuilder}

Description

Add a constant to the shader code.

Parameters
Name Type Description
name string

the name of the constant

type string

the GLSL type of the constant

value *

the JS value of the constant

Returns
  • the current shader builder

addUniform( name, type, value ) → {ShaderBuilder}

Description

Add a uniform variable to the shader code. Update the object listing all the uniforms

Parameters
Name Type Description
name string

the name of the uniform

type string

the GLSL type of the uniform

value *

the JS value of the uniform

Returns
  • the current shader builder

updateUniform( name, value ) → {ShaderBuilder}

Description

Update the value of a previously defined uniform

Parameters
Name Type Description
name string

the name of the uniform

value *

the value of the uniform

Returns
  • the current shader builder

addInstance( name, code ) → {ShaderBuilder}

Description

Add the given code (related to a specific instance of a class). Check before (using name) that the code has not been included before.

Parameters
Name Type Description
name string

the name of the instance

code string

the code of the instance

Returns