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.
Constructor
new GLSLFile(loader, key, [url], [shaderType], [xhrSettings])
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
loader | Phaser.Loader.LoaderPlugin | No | A reference to the Loader that is responsible for this file. | |
key | string | Phaser.Types.Loader.FileTypes.GLSLFileConfig | No | The key to use for this file, or a file configuration object. | |
url | string | Yes | The absolute or relative URL to load this file from. If undefined or null it will be set to <key>.txt , i.e. if key was "alien" then the URL will be "alien.txt". | |
shaderType | string | Yes | "'fragment'" | The type of shader. Either fragment for a fragment shader, or vertex for a vertex shader. This is ignored if you load a shader bundle. |
xhrSettings | Phaser.Types.Loader.XHRSettingsObject | Yes | Extra XHR Settings specifically for this file. |
Scope: static
Extends: Phaser.Loader.File
Source: src/loader/filetypes/GLSLFile.js - Line: 15
Since: 3.0.0
Methods:
addToCache
<instance> addToCache()
Description:
Adds this file to its target cache upon successful loading and processing.
Overrides: Phaser.Loader.File#addToCache
Source: src/loader/filetypes/GLSLFile.js - Line: 92
Since: 3.17.0
destroy
<instance> destroy()
Description:
Destroy this File and any references it holds.
Inherits: Phaser.Loader.File#destroy
Source: src/loader/File.js - Line: 546
Since: 3.7.0
extractBlock
<instance> extractBlock(data, offset)
Access: private
Description:
Processes the shader file and extracts the relevant data.
Parameters:
name | type | optional | description |
---|---|---|---|
data | Array.<string> | No | The array of shader data to process. |
offset | number | No | The offset to start processing from. |
Returns: any - The processed shader block, or null.
Source: src/loader/filetypes/GLSLFile.js - Line: 246
Since: 3.17.0
getShaderName
<instance> getShaderName(headerSource)
Description:
Returns the name of the shader from the header block.
Parameters:
name | type | optional | description |
---|---|---|---|
headerSource | Array.<string> | No | The header data. |
Returns: string - The shader name.
Source: src/loader/filetypes/GLSLFile.js - Line: 155
Since: 3.17.0
getShaderType
<instance> getShaderType(headerSource)
Description:
Returns the type of the shader from the header block.
Parameters:
name | type | optional | description |
---|---|---|---|
headerSource | Array.<string> | No | The header data. |
Returns: string - The shader type. Either 'fragment' or 'vertex'.
Source: src/loader/filetypes/GLSLFile.js - Line: 180
Since: 3.17.0
getShaderUniforms
<instance> getShaderUniforms(headerSource)
Description:
Returns the shader uniforms from the header block.
Parameters:
name | type | optional | description |
---|---|---|---|
headerSource | Array.<string> | No | The header data. |
Returns: any - The shader uniforms object.
Source: src/loader/filetypes/GLSLFile.js - Line: 205
Since: 3.17.0
hasCacheConflict
<instance> hasCacheConflict()
Description:
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.
Returns: boolean - true
if adding this file will cause a conflict, otherwise false
.
Inherits: Phaser.Loader.File#hasCacheConflict
Source: src/loader/File.js - Line: 487
Since: 3.7.0
load
<instance> load()
Description:
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.
Inherits: Phaser.Loader.File#load
Source: src/loader/File.js - Line: 296
Since: 3.0.0
onBase64Load
<instance> onBase64Load(xhr)
Description:
Called by the XHRLoader if it was given a File with base64 data to load.
Parameters:
name | type | optional | description |
---|---|---|---|
xhr | XMLHttpRequest | No | The FakeXHR object containing the decoded base64 data. |
Inherits: Phaser.Loader.File#onBase64Load
Source: src/loader/File.js - Line: 364
Since: 3.80.0
onError
<instance> onError(xhr, event)
Description:
Called if the file errors while loading, is sent a DOM ProgressEvent.
Parameters:
name | type | optional | description |
---|---|---|---|
xhr | XMLHttpRequest | No | The XMLHttpRequest that caused this onload event. |
event | ProgressEvent | No | The DOM ProgressEvent that resulted from this error. |
Inherits: Phaser.Loader.File#onError
Source: src/loader/File.js - Line: 385
Since: 3.0.0
onLoad
<instance> onLoad(xhr, event)
Description:
Called when the file finishes loading, is sent a DOM ProgressEvent.
Parameters:
name | type | optional | description |
---|---|---|---|
xhr | XMLHttpRequest | No | The XMLHttpRequest that caused this onload event. |
event | ProgressEvent | No | The DOM ProgressEvent that resulted from this load. |
Inherits: Phaser.Loader.File#onLoad
Source: src/loader/File.js - Line: 331
Since: 3.0.0
onProcess
<instance> onProcess()
Description:
Called automatically by Loader.nextFile. This method controls what extra work this File does with its loaded data.
Overrides: Phaser.Loader.File#onProcess
Source: src/loader/filetypes/GLSLFile.js - Line: 76
Since: 3.7.0
onProcessComplete
<instance> onProcessComplete()
Description:
Called when the File has completed processing. Checks on the state of its multifile, if set.
Inherits: Phaser.Loader.File#onProcessComplete
Source: src/loader/File.js - Line: 446
Since: 3.7.0
onProcessError
<instance> onProcessError()
Description:
Called when the File has completed processing but it generated an error. Checks on the state of its multifile, if set.
Inherits: Phaser.Loader.File#onProcessError
Source: src/loader/File.js - Line: 465
Since: 3.7.0
onProgress
<instance> onProgress(event)
Description:
Called during the file load progress. Is sent a DOM ProgressEvent.
Parameters:
name | type | optional | description |
---|---|---|---|
event | ProgressEvent | No | The DOM ProgressEvent. |
Fires: Phaser.Loader.Events#event:FILE_PROGRESS
Inherits: Phaser.Loader.File#onProgress
Source: src/loader/File.js - Line: 410
Since: 3.0.0
pendingDestroy
<instance> pendingDestroy()
Description:
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.
Fires: Phaser.Loader.Events#event:FILE_COMPLETE, Phaser.Loader.Events#event:FILE_KEY_COMPLETE
Inherits: Phaser.Loader.File#pendingDestroy
Source: src/loader/File.js - Line: 517
Since: 3.7.0
resetXHR
<instance> resetXHR()
Description:
Resets the XHRLoader instance this file is using.
Inherits: Phaser.Loader.File#resetXHR
Source: src/loader/File.js - Line: 280
Since: 3.0.0
setLink
<instance> setLink(fileB)
Description:
Links this File with another, so they depend upon each other for loading and processing.
Parameters:
name | type | optional | description |
---|---|---|---|
fileB | Phaser.Loader.File | No | The file to link to this one. |
Inherits: Phaser.Loader.File#setLink
Source: src/loader/File.js - Line: 265
Since: 3.7.0
Members:
base64: boolean
base64
Description:
Does this File contain a data URI?
Inherits: Phaser.Loader.File#base64
Source: src/loader/File.js - Line: 236
Since: 3.80.0
bytesLoaded: number
bytesLoaded
Description:
Updated as the file loads. Only set if loading via XHR.
Inherits: Phaser.Loader.File#bytesLoaded
Source: src/loader/File.js - Line: 165
Since: 3.0.0
bytesTotal: number
bytesTotal
Description:
The total size of this file. Set by onProgress and only if loading via XHR.
Inherits: Phaser.Loader.File#bytesTotal
Source: src/loader/File.js - Line: 154
Since: 3.0.0
cache: Phaser.Cache.BaseCache, Phaser.Textures.TextureManager
cache
Description:
A reference to the Cache, or Texture Manager, that is going to store this file if it loads.
Inherits: Phaser.Loader.File#cache
Source: src/loader/File.js - Line: 44
Since: 3.7.0
config: *
config
Description:
A config object that can be used by file types to store transitional data.
Inherits: Phaser.Loader.File#config
Source: src/loader/File.js - Line: 206
Since: 3.0.0
crossOrigin: string, undefined
crossOrigin
Description:
For CORs based loading. If this is undefined then the File will check BaseLoader.crossOrigin and use that (if set)
Inherits: Phaser.Loader.File#crossOrigin
Source: src/loader/File.js - Line: 187
Since: 3.0.0
data: *
data
Description:
The processed file data, stored here after the file has loaded.
Inherits: Phaser.Loader.File#data
Source: src/loader/File.js - Line: 197
Since: 3.0.0
key: string
key
Description:
Unique cache key (unique within its file type)
Inherits: Phaser.Loader.File#key
Source: src/loader/File.js - Line: 67
Since: 3.0.0
linkFile: Phaser.Loader.File
linkFile
Description:
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.
Inherits: Phaser.Loader.File#linkFile
Source: src/loader/File.js - Line: 225
Since: 3.7.0
loader: Phaser.Loader.LoaderPlugin
loader
Description:
A reference to the Loader that is going to load this file.
Inherits: Phaser.Loader.File#loader
Source: src/loader/File.js - Line: 35
Since: 3.0.0
multiFile: Phaser.Loader.MultiFile
multiFile
Description:
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.
Inherits: Phaser.Loader.File#multiFile
Source: src/loader/File.js - Line: 215
Since: 3.7.0
percentComplete: number
percentComplete
Description:
A percentage value between 0 and 1 indicating how much of this file has loaded. Only set if loading via XHR.
Inherits: Phaser.Loader.File#percentComplete
Source: src/loader/File.js - Line: 176
Since: 3.0.0
retryAttempts: number
retryAttempts
Description:
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.
Inherits: Phaser.Loader.File#retryAttempts
Source: src/loader/File.js - Line: 245
Since: 3.85.0
src: string
src
Description:
The final URL this file will load from, including baseURL and path. Set automatically when the Loader calls 'load' on this file.
Inherits: Phaser.Loader.File#src
Source: src/loader/File.js - Line: 112
Since: 3.0.0
state: number
state
Description:
The current state of the file. One of the FILE_CONST values.
Inherits: Phaser.Loader.File#state
Source: src/loader/File.js - Line: 145
Since: 3.0.0
type: string
type
Description:
The file type string (image, json, etc) for sorting within the Loader.
Inherits: Phaser.Loader.File#type
Source: src/loader/File.js - Line: 53
Since: 3.0.0
url: object, string
url
Description:
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.
Inherits: Phaser.Loader.File#url
Source: src/loader/File.js - Line: 99
Since: 3.0.0
xhrLoader: XMLHttpRequest
xhrLoader
Description:
The XMLHttpRequest instance (as created by XHR Loader) that is loading this File.
Inherits: Phaser.Loader.File#xhrLoader
Source: src/loader/File.js - Line: 136
Since: 3.0.0
xhrSettings: Phaser.Types.Loader.XHRSettingsObject
xhrSettings
Description:
The merged XHRSettings for this file.
Inherits: Phaser.Loader.File#xhrSettings
Source: src/loader/File.js - Line: 122
Since: 3.0.0