GLSLCode

Used for parsing GLSL code and precompute info (mostly preprocessor macros).

Constructor

new L3D.GLSLCode()

Extends

Properties

attributes Object

The vertex attributes used by the shader.

blocks Array

The sections of the shader, split up by #include, #shaderblock, or macros where code will be injected.

code String

The original GLSL source code before it's been processed.

Overrides:
filename String

Get the filename of the asset.

Overrides:
id String

The unique identifier of the object. Changing a node's ID can have unintended consequences.

includes Object

The includes used by the shader.

isDynamic bool

If true, the shader uses pragmas or macros and can have variants.

Overrides:
isLoaded bool

True if the asset has finished loading.

Overrides:
isLoading bool

True if the asset is in the process of loading.

Overrides:
isValid bool

True if the asset does not have an error.

Overrides:
name String

The name of the object.

Overrides:
onError Signal

Emitted when there was an error loaading the asset.

Overrides:
onLoad Signal

Emitted when the asset has finished loading.

Overrides:
onLoading Signal

Emitted when the asset has started loading.

Overrides:
onModified Signal

Fired when the object has been modified.

Overrides:
onNameChanged Signal

Fired when the object's name changes.

Overrides:
onStateChange Signal

Emitted when the state of the asset has changed.

Overrides:
onUpdate Signal

Emitted when the assets data has been updated.

Overrides:
path String

The URL of the asset.

pragmas Object

The pragmas used by the shader.

shaderBlocks Object

The shader blocks used by the shader.

Overrides:
state number

Inidicates whether the asset is Unloaded, Loading, Loaded, or Error. The onStateChange signal will be emitted when the state's value changes.

uniforms Object

The uniforms used by the shader.

Methods

clone(options) → Object

Overrides:

Creates a clone of this object.

Parameters
options Object

Options for the clone method.

Returns
Object

configure(o)

Overrides:

Set the properties of the object from a JSON structure.

Parameters
o Object

Serialized data to configure the object with

destroy()

Overrides:

Destroy any render assets created by the asset.

getFinalCode(shaderType, blockFlags, context) → String

Get the variant of the shader given the shader type and block mask.

Parameters
shaderType number

Either GL.VERTEX_SHADER or GL.FRAGMENT_SHADER.

blockFlags number

The bitmask for the shader blocks to enable.

context Object
Returns
String

getPropertyInfo(path) → Object

Overrides:

Get information about a particular property of this object.

Parameters
path String
Returns
Object

getRenderAsset(gl)RenderAsset

Overrides:

Get a RenderAsset for this asset. If a RenderAsset hadn't been requested for the given GLContext yet, a new one will be created. Otherwise the previous one will be updated and returned.

A RenderAsset is the WebGL version of the asset, such as the GLTexture for an Texture asset. Because the editor has multiple GLContexts, RenderAssets are generated for each GLContext that requires it.

Parameters
gl GLContext
Returns
RenderAsset

isReady()

Checks to see if the GLSLCode is ready to be used. If it has #include blocks that are still being loaded, then it's not ready.

parse()

Parse pragmas and other directives from the shader code.

serialize() → Object

Overrides:

Serialize the object to a JSON structure.

Returns
Object

The serialized version of the object.

setModified()

Overrides:

Fires the objects onModified signal.

toJSON() → Object

Overrides:

Serialize the object to a JSON structure

Returns
Object

The serialized version of the object.

updateRenderAsset(renderAsset)

Overrides:

Update the given RenderAsset.

Parameters
renderAsset RenderAsset

The RenderAsset to update.