Loader

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.

Note that Texture.flipY and Texture.premultiplyAlpha with ImageBitmap are ignored. ImageBitmap needs these configuration on bitmap creation unlike regular images need them on uploading to GPU. You need to set the equivalent options via ImageBitmapLoader.setOptions instead. Refer to WebGL specification for the detail.

Code Example

// instantiate a loader const loader = new v3d.ImageBitmapLoader(); // set options if needed loader.setOptions({ imageOrientation: 'flipY' }); // load a image resource loader.load( // resource URL 'textures/skyboxsun25degtest.png', // onLoad callback function(imageBitmap) { const texture = new v3d.CanvasTexture(imageBitmap); const 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

See the base Loader class for common properties.

.isImageBitmapLoader : Boolean

Read-only flag to check if a given object is of type ImageBitmapLoader.

.options : String

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

Methods

See the base Loader class for common methods.

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

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

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

.setOptions(options : Object) → this

Sets the options object for createImageBitmap.

Source

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