ImageBitmapLoader

A loader for loading an Image as an ImageBitmap. An ImageBitmap provides an asynchronous and resource efficient pathway to prepare textures for rendering in WebGL.
Unlike FileLoader, ImageBitmapLoader does not avoid multiple concurrent requests to the same URL.

Example

WebGL / loader / ImageBitmap

// instantiate a loader var loader = new v3d.ImageBitmapLoader(); // load a image resource loader.load( // resource URL 'textures/skyboxsun25degtest.png', // onLoad callback function(imageBitmap) { var texture = new v3d.CanvasTexture(imageBitmap); var material = new v3d.MeshBasicMaterial({ map: texture }); }, // onProgress callback currently not supported undefined, // onError callback function(err) { console.log('An error happened'); } );

Constructor

ImageBitmapLoader(manager : LoadingManager)

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

Creates a new ImageBitmapLoader.

Properties

.manager : LoadingManager

The loadingManager the loader is using. Default is DefaultLoadingManager.

.options : String

An optional object that sets options for the internally used createImageBitmap factory method. Default is undefined.

.path : String

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

Methods

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

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 () : ImageBitmapLoader

This method exists for compatibility reasons and implements no logic. It ensures that ImageBitmapLoader has a similar interface like ImageLoader.

.setOptions (options : Object) : ImageBitmapLoader

Sets the options object for createImageBitmap.

.setPath (path : String) : ImageBitmapLoader

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

Source

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