TextureManager

0.8.5+

Manage textures.

Creation 

Creating a texture is done using load:

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

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

.constructor(engine: WonderlandEngine) ⇒ TextureManager 

ParamTypeDescription
engineWonderlandEngine

.create(image: ImageLike) ⇒ Texture 

Create a new texture from an image or video.

Usage 

1const img = new Image();
2img.load = function(img) {
3    const texture = engine.textures.create(img);
4};
5img.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.

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

Load an image from URL as Texture.

Usage 

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

Returns: Loaded texture.

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