Class: ShaderFactory

Palette. ShaderFactory

A Factory class designed to process objects, URLs, JSON and potentially other formats to generate valid Palette.Shader objects. This is a deliberate choice, to abstract some functionality away from the central Palette.Manager class.

new ShaderFactory(manager)

Create a new ShaderFactory object - this is done automatically by Palette.Manager.
Parameters:
Name Type Description
manager Palette.Manager The manager object to place generated shaders into.
Author:
  • FelixMcFelix (Kyle S.)
Source:

Members

<protected, readonly> manager :Palette.Manager

An object reference to the parent Palette.Manager.
Type:
Source:

Methods

addShader(shader)

Begin the shader construction process.
Parameters:
Name Type Description
shader string | Palette.Shader | Object URL, JSON, Shader Source Object or Palette.Shader.
Source:

<protected> createShaderObject(sourceObject) → {Palette.Shader|null}

Create a shader from a source object.
Parameters:
Name Type Description
sourceObject object Either a list of shaders or a single shader object is valid.
Source:
Returns:
Returns a Palette.Shader if the Source Object was not a list. If it was a list, it adds all the children instead.
Type
Palette.Shader | null

<protected> downloadFromURL(url)

Download a file from the supplied URL, before adding it to the manager.
Parameters:
Name Type Description
url string URL corresponding to a Shader Source Object JSON file.
Source:

<protected> establishType(shader) → {number}

Determine the type of shader reference passed to the factory.
Parameters:
Name Type Description
shader string | Palette.Shader URL, JSON or Palette.Shader.
Source:
Returns:
Either Palette.ShaderFactory.SOURCE_OBJECT, .JSON, .URL or .SHADER_OBJECT.
Type
number

<protected> registerShader(shaderObject)

Add a shader directly into the manager's storage for future access.
Parameters:
Name Type Description
shaderObject Palette.Shader Compiled shader object to store in the Palette.Manager.
Source: