Class: Loader
An asset loader that can load textures and audio files. This class is used internally by the world and can be accessed via World.loader.
Properties
audioBuffers
• audioBuffers: Map
<string
, AudioBuffer
>
A map of all audios loaded by Voxelize.
images
• images: Map
<string
, HTMLImageElement
| HTMLImageElement
[]>
progress
• progress: number
= 0
The progress at which Loader has loaded, zero to one.
textureLoader
• textureLoader: TextureLoader
The internal texture loader used by the loader.
textures
• textures: Map
<string
, Texture
>
A map of all textures loaded by Voxelize.
Methods
getGifTexture
▸ getGifTexture(source
): Texture
[]
Get a loaded gif texture with this function.
Parameters
Name | Type | Description |
---|---|---|
source | string | The source to the texture file loaded from. |
Returns
Texture
[]
A list of textures for each frame of the gif.
getTexture
▸ getTexture(source
): Texture
Get a loaded texture by its source.
Parameters
Name | Type | Description |
---|---|---|
source | string | The source to the texture file to load from. |
Returns
Texture
A texture instance loaded from the source.
load
▸ load(): Promise
<void
>
Load all assets other than the textures. Called internally by the world. This can be used to ensure that a function runs after all assets are loaded.
Returns
Promise
<void
>
A promise that resolves when all assets are loaded.
Example
world.loader.load().then(() => {});
loadAudioBuffer
▸ loadAudioBuffer(source
, onLoaded?
): Promise
<AudioBuffer
>
Add an audio file to be loaded from.
Parameters
Name | Type | Description |
---|---|---|
source | string | The source to the audio file to load from. |
onLoaded? | (buffer : AudioBuffer ) => void | A callback to run when the audio is loaded. |
Returns
Promise
<AudioBuffer
>
loadGifImages
▸ loadGifImages(source
, onLoaded?
): Promise
<HTMLImageElement
[]>
Parameters
Name | Type |
---|---|
source | string |
onLoaded? | (images : HTMLImageElement []) => void |
Returns
Promise
<HTMLImageElement
[]>
loadImage
▸ loadImage(source
, onLoaded?
): Promise
<HTMLImageElement
>
Parameters
Name | Type |
---|---|
source | string |
onLoaded? | (image : HTMLImageElement ) => void |
Returns
Promise
<HTMLImageElement
>
loadTexture
▸ loadTexture(source
, onLoaded?
): Promise
<Texture
>
Parameters
Name | Type |
---|---|
source | string |
onLoaded? | (texture : Texture ) => void |
Returns
Promise
<Texture
>