A loader for loading an Image. This is used internally by the CubeTextureLoader, ObjectLoader and TextureLoader.


WebGL / loader / obj
WebGL / shaders / ocean

// instantiate a loader var loader = new v3d.ImageLoader(); // load a image resource loader.load( // resource URL 'textures/skyboxsun25degtest.png', // onLoad callback function(image) { // use the image, e.g. draw part of it on a canvas var canvas = document.createElement('canvas'); var context = canvas.getContext('2d'); context.drawImage(image, 100, 100); }, // onProgress callback currently not supported undefined, // onError callback function() { console.error('An error happened.'); } );

Please note Verge3D r84 dropped support for ImageLoader progress events. For an ImageLoader that supports progress events, see this thread.


ImageLoader(manager : LoadingManager)

manager — The loadingManager for the loader to use. Default is v3d.DefaultLoadingManager.

Creates a new ImageLoader.


.crossOrigin : String

If set, assigns the crossOrigin attribute of the image to the value of crossOrigin, prior to starting the load. Default is "anonymous".

.manager : LoadingManager

The loadingManager the loader is using. Default is DefaultLoadingManager.

.path : String

The base path from which files will be loaded. See .setPath. Default is undefined.


.load (url : String, onLoad : Function, onProgress : Function, onError : Function) : HTMLImageElement

url — the path or URL to the file. This can also be a Data URI.
onLoad — Will be called when load completes. The argument will be the loaded image.
onProgress — This callback function is currently not supported.
onError — Will be called when load errors.

Begin loading from url and return the image object that will contain the data.

.setCrossOrigin (value : String) : null

Set the .crossOrigin attribute.

.setPath (path : String) : FileLoader

Set the base path or URL from which to load files. This can be useful if you are loading many images from the same directory.


For more info on how to obtain the source code of this module see this page.