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 THREE.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 THREE.CanvasTexture( imageBitmap ); const material = new
THREE.MeshBasicMaterial( { map: texture } ); }, // onProgress callback
currently not supported undefined, // onError callback function ( err ) {
console.log( 'An error happened' ); } );
Examples
[example:webgl_loader_imagebitmap WebGL / loader / ImageBitmap]
Constructor
ImageBitmapLoader
function ImageBitmapLoader( manager: LoadingManager ): void;
manager — The loadingManager for the loader to use. Default is THREE.DefaultLoadingManager.
Creates a new ImageBitmapLoader.
Properties
See the base Loader class for common properties.
isImageBitmapLoader
isImageBitmapLoader: Boolean;
Read-only flag to check if a given object is of type ImageBitmapLoader.
options
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
function load( url: String, onLoad: Function, onProgress: Function, onError:
Function ): undefined;
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 (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
function setOptions( options: Object ): this;
Sets the options object for createImageBitmap.