Class Textures

Texture manager.

Load textures from different sources and get texture handles to use when rendering.

This service keeps hold of all sources used to create textures. This allows restoring textures and contents after a context-loss (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/webglcontextlost_event).

Implements

Constructors

Properties

driverTextures: DriverTextures

The driver texture implementation.

textureSources: Map<TextureHandle, ImageBitmap> = ...

Accessors

Methods

  • Fetch an ImageBitmap from the given URL and create a texture from it.

    Parameters

    • url: RequestInfo | URL

      URL

    • OptionalresourceOptions: ResourceOptions
    • Optionaloptions: { fetchOptions?: RequestInit; imageBitmapOptions?: ImageBitmapOptions }

      Options for the fetch request/created resource

    Returns Promise<TextureHandle>

    Promise of the resulting TextureHandle

  • Delete the source for the given handle. Does not remove the texture itself.

    Parameters

    Returns boolean

    true if a source was removed

  • Initialize any rendering resources associated with this handler. E.g., compile shaders, create textures.

    Returns Promise<void>

    Rendering will only continue when all handler's initialize promises have resolved.