H3DU.TextureLoader
H3DU.TextureLoader()
An object that caches loaded textures and uploads them to WebGL contexts.
Methods
- dispose
Disposes all resources used by this texture loader. - getTexture
Gets an already loaded texture by name from this texture loader. - loadAndMapTexture
Loads the texture referred to in an array of URLs and uploads its texture data to a WebGL context. - loadAndMapTexturesAll
Loads one or more textures by their URL and uploads their data to a WebGL context. - loadCubeMap
Loads the textures described in a cube map. - loadTexture
Loads a texture by its URL and stores its data. - loadTexturesAll
Loads the textures referred to in an array of URLs and stores their texture data.
H3DU.TextureLoader#dispose()
Disposes all resources used by this texture loader.
Return Value
This method doesn't return a value. (Type: void)
H3DU.TextureLoader#getTexture(name)
Gets an already loaded texture by name from this texture loader.
Parameters
name
(Type: string)
The name of the texture, usually its file name.
Return Value
The texture with the given name, or null if it isn't fully loaded or doesn't exist. (Type: H3DU.Texture)
H3DU.TextureLoader#loadAndMapTexture(texture, context)
Loads the texture referred to in an array of URLs and uploads its texture data to a WebGL context.
Parameters
texture
(Type: String | H3DU.TextureInfo | H3DU.Texture)
An object described in H3DU.TextureLoader.loadTexture.context
(Type: WebGLRenderingContext | WebGL2RenderingContext | Object)
A WebGL context to associate with this scene, or an object, such as H3DU.Scene3D, that implements a no-argumentgetContext
method that returns a WebGL context.
Return Value
A promise that resolves when the texture is loaded successfully (the result will be an H3DU.Texture object) and is rejected when an error occurs. (Type: Promise.<H3DU.Texture>)
H3DU.TextureLoader#loadAndMapTexturesAll(textures, context, [resolve], [reject])
Loads one or more textures by their URL and uploads their data to a WebGL context.
Parameters
textures
(Type: Array.<(String|H3DU.TextureInfo|H3DU.Texture)>)
An array of objects described in H3DU.TextureLoader.loadTexture.context
(Type: WebGLRenderingContext | WebGL2RenderingContext | Object)
A WebGL context to associate with this scene, or an object, such as H3DU.Scene3D, that implements a no-argumentgetContext
method that returns a WebGL context.resolve
(Type: function) (optional)
A function called as each individual texture is loaded and its promise resolves.reject
(Type: function) (optional)
A function called as each individual texture is loaded and its promise is rejected.
Return Value
A promise as described in H3DU.getPromiseResultsAll. If the promise resolves, each item in the resulting array will be a loaded H3DU.Texture object. (Type: Promise.<H3DU.Texture>)
H3DU.TextureLoader#loadCubeMap(texturesOrCubeMap, [resolve], [reject])
Loads the textures described in a cube map.
Parameters
texturesOrCubeMap
(Type: Array.<(String|H3DU.TextureInfo|H3DU.Texture)> | H3DU.CubeMap)
Either an array of objects described in H3DU.TextureLoader.loadTexture or a cube map object.resolve
(Type: function) (optional)
A function called as each individual texture is loaded and its promise resolves.reject
(Type: function) (optional)
A function called as each individual texture is loaded and its promise is rejected.
Return Value
A promise that resolves when all textures used by the cube map are loaded successfully (the result will be an H3DU.CubeMap object) and is rejected when an error occurs. (Type: Promise.<H3DU.Texture>)
H3DU.TextureLoader#loadTexture(texture)
Loads a texture by its URL and stores its data.
Parameters
texture
(Type: String | H3DU.TextureInfo | H3DU.Texture)
An H3DU.Texture object, an H3DU.TextureInfo object, or a string with the URL of the texture data.Images with a TGA extension that use the RGBA or grayscale format are supported. Images supported by the browser will be loaded via the JavaScript DOM's Image class.
Return Value
A promise that resolves when the texture is fully loaded. If it resolves, the result will be an H3DU.Texture object. (Type: Promise.<H3DU.Texture>)
H3DU.TextureLoader#loadTexturesAll(textures, [resolve], [reject])
Loads the textures referred to in an array of URLs and stores their texture data.
Parameters
textures
(Type: Array.<(String|H3DU.TextureInfo|H3DU.Texture)>)
An array of objects described in H3DU.TextureLoader.loadTexture.resolve
(Type: function) (optional)
A function called as each individual texture is loaded and its promise resolves.reject
(Type: function) (optional)
A function called as each individual texture is loaded and its promise is rejected.
Return Value
A promise as described in H3DU.getPromiseResultsAll. If the promise resolves, each item in the resulting array will be a loaded H3DU.Texture object. (Type: Promise.<H3DU.Texture>)