A single GLSL File suitable for loading by the Loader.
These are created when you use the Phaser.Loader.LoaderPlugin#glsl method and are not typically created directly.
For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#glsl.
new GLSLFile(loader, key, [url], [shaderType], [xhrSettings])
name | type | arguments | Default | description |
---|---|---|---|---|
loader | Phaser.Loader.LoaderPlugin |
A reference to the Loader that is responsible for this file. |
||
key | string | Phaser.Types.Loader.FileTypes.GLSLFileConfig |
The key to use for this file, or a file configuration object. |
||
url | string | <optional> |
The absolute or relative URL to load this file from. If undefined or |
|
shaderType | string | <optional> | 'fragment' |
The type of shader. Either |
xhrSettings | Phaser.Types.Loader.XHRSettingsObject | <optional> |
Extra XHR Settings specifically for this file. |
Does this File contain a data URI?
Updated as the file loads. Only set if loading via XHR.
The total size of this file. Set by onProgress and only if loading via XHR.
A reference to the Cache, or Texture Manager, that is going to store this file if it loads.
A config object that can be used by file types to store transitional data.
For CORs based loading. If this is undefined then the File will check BaseLoader.crossOrigin and use that (if set)
The processed file data, stored here after the file has loaded.
Unique cache key (unique within its file type)
Does this file have an associated linked file? Such as an image and a normal map. Atlases and Bitmap Fonts use the multiFile, because those files need loading together but aren't actually bound by data, where-as a linkFile is.
A reference to the Loader that is going to load this file.
If this is a multipart file, i.e. an atlas and its json together, then this is a reference to the parent MultiFile. Set and used internally by the Loader or specific file types.
A percentage value between 0 and 1 indicating how much of this file has loaded. Only set if loading via XHR.
The counter for the number of times to retry loading this file before it fails.
You can set this property value in the FileConfig object. If not present,
this property is read from the LoaderPlugin.maxRetries
property when
this File instance is created.
You can set this value via the Game Config, or you can adjust the LoaderPlugin
property
at any point after the Loader has started. However, it will not apply to files
that have already been added to the Loader, only those added after this value
is changed.
The final URL this file will load from, including baseURL and path. Set automatically when the Loader calls 'load' on this file.
The current state of the file. One of the FILE_CONST values.
The file type string (image, json, etc) for sorting within the Loader.
The URL of the file, not including baseURL.
Automatically has Loader.path prepended to it if a string.
Can also be a JavaScript Object, such as the results of parsing JSON data.
The XMLHttpRequest instance (as created by XHR Loader) that is loading this File.
The merged XHRSettings for this file.
Adds this file to its target cache upon successful loading and processing.
Destroy this File and any references it holds.
Returns the name of the shader from the header block.
name | type | description |
---|---|---|
headerSource | Array.<string> |
The header data. |
The shader name.
Returns the type of the shader from the header block.
name | type | description |
---|---|---|
headerSource | Array.<string> |
The header data. |
The shader type. Either 'fragment' or 'vertex'.
Returns the shader uniforms from the header block.
name | type | description |
---|---|---|
headerSource | Array.<string> |
The header data. |
The shader uniforms object.
Checks if a key matching the one used by this file exists in the target Cache or not. This is called automatically by the LoaderPlugin to decide if the file can be safely loaded or will conflict.
true
if adding this file will cause a conflict, otherwise false
.
Called by the Loader, starts the actual file downloading. During the load the methods onLoad, onError and onProgress are called, based on the XHR events. You shouldn't normally call this method directly, it's meant to be invoked by the Loader.
Called by the XHRLoader if it was given a File with base64 data to load.
name | type | description |
---|---|---|
xhr | XMLHttpRequest |
The FakeXHR object containing the decoded base64 data. |
Called if the file errors while loading, is sent a DOM ProgressEvent.
name | type | description |
---|---|---|
xhr | XMLHttpRequest |
The XMLHttpRequest that caused this onload event. |
event | ProgressEvent |
The DOM ProgressEvent that resulted from this error. |
Called when the file finishes loading, is sent a DOM ProgressEvent.
name | type | description |
---|---|---|
xhr | XMLHttpRequest |
The XMLHttpRequest that caused this onload event. |
event | ProgressEvent |
The DOM ProgressEvent that resulted from this load. |
Called automatically by Loader.nextFile. This method controls what extra work this File does with its loaded data.
Called when the File has completed processing. Checks on the state of its multifile, if set.
Called when the File has completed processing but it generated an error. Checks on the state of its multifile, if set.
Called during the file load progress. Is sent a DOM ProgressEvent.
name | type | description |
---|---|---|
event | ProgressEvent |
The DOM ProgressEvent. |
Called once the file has been added to its cache and is now ready for deletion from the Loader.
It will emit a filecomplete
event from the LoaderPlugin.
Resets the XHRLoader instance this file is using.
Links this File with another, so they depend upon each other for loading and processing.
name | type | description |
---|---|---|
fileB | Phaser.Loader.File |
The file to link to this one. |