TextureManager
1.2.0+
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.
- TextureManager
- .constructor(engine) ⇒ TextureManager
- .create(image, params) ⇒ Texture
- .load(filename, crossOrigin) ⇒ Promise<Texture>
- TextureManager.fetchImage(src, crossOrigin) ⇒ Promise<HTMLImageElement>
- TextureManager.fetchImageBitmap(src, options) ⇒ Promise<ImageBitmap>
.constructor(engine: WonderlandEngine) ⇒ TextureManager
| Param | Type | Description |
|---|---|---|
| engine | WonderlandEngine |
.create(image: ImageLike, params: TextureParameters) ⇒ Texture
Create a new texture from an image or video.
Usage
Note: The media must already be loaded. To automatically load the media and create a texture, use load instead.
| Param | Type | Description |
|---|---|---|
| image | ImageLike | Media element to create the texture from. @ret\urns The new texture with the media content. |
| params | TextureParameters |
.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.
| Param | Type | Description |
|---|---|---|
| filename | string | URL to load from. |
| crossOrigin | string | Cross origin flag for the image object. |
TextureManager.fetchImage(src: string | Blob, crossOrigin: string) ⇒ Promise<HTMLImageElement>
| Param | Type | Description |
|---|---|---|
| src | string | Blob | |
| crossOrigin | string |
TextureManager.fetchImageBitmap(src: string | Blob, options: Partial<ImageBitmapOptions>) ⇒ Promise<ImageBitmap>
| Param | Type | Description |
|---|---|---|
| src | string | Blob | |
| options | Partial<ImageBitmapOptions> |