TextureManager

1.2.0+

Manage textures.

Creation

Creating a texture is done using load:

const texture = await engine.textures.load('my-image.png');

Alternatively, textures can be created directly via a loaded image using create.

Static Members

Methods


Constructor

.constructor(engine: WonderlandEngine) ⇒ TextureManager

ParamTypeDescription
engineWonderlandEngine

Static Members

TextureManager.fetchImage(src: string | Blob, crossOrigin: string) ⇒ Promise<HTMLImageElement>

ParamTypeDescription
srcstring | Blob
crossOriginstring

TextureManager.fetchImageBitmap(src: string | Blob, options: Partial<ImageBitmapOptions>) ⇒ Promise<ImageBitmap>

ParamTypeDescription
srcstring | Blob
optionsPartial<ImageBitmapOptions>


Methods

.create(image: ImageLike, params: TextureParameters) ⇒ Texture

Create a new texture from an image or video.

Usage

const img = new Image();
img.load = function(img) {
    const texture = engine.textures.create(img);
};
img.src = 'my-image.png';

Note: The media must already be loaded. To automatically load the media and create a texture, use load instead.

ParamTypeDescription
imageImageLikeMedia element to create the texture from. @ret\urns The new texture with the media content.
paramsTextureParameters

.load(filename: string, crossOrigin: string) ⇒ Promise<Texture>

Load an image from URL as Texture.

Usage

const texture = await engine.textures.load('my-image.png');

Returns: Loaded texture.

ParamTypeDescription
filenamestringURL to load from.
crossOriginstringCross origin flag for the image object.