Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface 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.

Examples

WebGL / loader / ImageBitmap

Code Example

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

Hierarchy

Index

Constructors

constructor

Properties

crossOrigin

crossOrigin: string

The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS. Default is anonymous.

default

'anonymous'

Readonly isImageBitmapLoader

isImageBitmapLoader: true

manager

The loadingManager the loader is using. Default is DefaultLoadingManager.

options

options: object

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

default

{ premultiplyAlpha: 'none' }

path

path: string

The base path from which the asset will be loaded. Default is the empty string.

default

''

requestHeader

requestHeader: {}

The request header used in HTTP request. See .setRequestHeader. Default is empty object.

default

{}

Type declaration

  • [header: string]: string

resourcePath

resourcePath: string

The base path from which additional resources like textures will be loaded. Default is the empty string.

default

''

withCredentials

withCredentials: boolean

Whether the XMLHttpRequest uses credentials. See .setWithCredentials. Default is false.

default:

false

Methods

load

  • load(url: string, onLoad?: (response: ImageBitmap) => void, onProgress?: (request: ProgressEvent<EventTarget>) => void, onError?: (event: ErrorEvent) => void): any
  • Begin loading from url and return the image object that will contain the data.

    Parameters

    • url: string

      The path or URL to the file. This can also be a Data URI.

    • Optional onLoad: (response: ImageBitmap) => void

      Will be called when load completes. The argument will be the loaded image.

        • (response: ImageBitmap): void
        • Parameters

          • response: ImageBitmap

          Returns void

    • Optional onProgress: (request: ProgressEvent<EventTarget>) => void

      This callback function is currently not supported.

        • (request: ProgressEvent<EventTarget>): void
        • Parameters

          • request: ProgressEvent<EventTarget>

          Returns void

    • Optional onError: (event: ErrorEvent) => void

      Will be called when load errors.

        • (event: ErrorEvent): void
        • Parameters

          • event: ErrorEvent

          Returns void

    Returns any

loadAsync

  • loadAsync(url: string, onProgress?: (event: ProgressEvent<EventTarget>) => void): Promise<ImageBitmap>
  • Begin loading from url and return the image object that will contain the data.

    Parameters

    • url: string

      The path or URL to the file. This can also be a Data URI.

    • Optional onProgress: (event: ProgressEvent<EventTarget>) => void

      This callback function is currently not supported.

        • (event: ProgressEvent<EventTarget>): void
        • Parameters

          • event: ProgressEvent<EventTarget>

          Returns void

    Returns Promise<ImageBitmap>

setCrossOrigin

setOptions

setPath

setRequestHeader

setResourcePath

setWithCredentials

Generated using TypeDoc