[name]

A loader for loading an [page:Image] as an [link:https://developer.mozilla.org/de/docs/Web/API/ImageBitmap ImageBitmap]. An ImageBitmap provides an asynchronous and resource efficient pathway to prepare textures for rendering in WebGL.
Unlike [page:FileLoader], [name] does not avoid multiple concurrent requests to the same URL.

Note that [page:Texture.flipY] and [page:Texture.premultiplyAlpha] with [link:https://developer.mozilla.org/de/docs/Web/API/ImageBitmap ImageBitmap] are ignored. [link:https://developer.mozilla.org/de/docs/Web/API/ImageBitmap ImageBitmap] needs these configuration on bitmap creation unlike regular images need them on uploading to GPU. You need to set the equivalent options via [page:ImageBitmapLoader.setOptions] instead. Refer to [link:https://www.khronos.org/registry/webgl/specs/latest/1.0/#6.10 WebGL specification] for the detail.

Example

[example:webgl_loader_imagebitmap WebGL / loader / ImageBitmap]

// instantiate a loader var 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) { 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

[name]([param:LoadingManager manager])

[page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager v3d.DefaultLoadingManager].

Creates a new [name].

Properties

[property:LoadingManager manager]

The [page:LoadingManager loadingManager] the loader is using. Default is [page:DefaultLoadingManager].

[property:String options]

An optional object that sets options for the internally used [link:https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap createImageBitmap] factory method. Default is *undefined*.

[property:String path]

The base path from which files will be loaded. See [page:.setPath]. Default is *undefined*.

Methods

[method:null load]([param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError])

[page:String url] — the path or URL to the file. This can also be a [link:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs Data URI].
[page:Function onLoad] — Will be called when load completes. The argument will be the loaded [page:Image image].
[page:Function onProgress] — This callback function is currently not supported.
[page:Function onError] — Will be called when load errors.

Begin loading from url and return the [page:ImageBitmap image] object that will contain the data.

[method:ImageBitmapLoader setCrossOrigin]()

This method exists for compatibility reasons and implements no logic. It ensures that [name] has a similar interface like [page:ImageLoader].

[method:ImageBitmapLoader setOptions]([param:Object options])

Sets the options object for [link:https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap createImageBitmap].

[method:ImageBitmapLoader setPath]([param:String path])

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.

[sourceHint]