Options
All
  • Public
  • Public/Protected
  • All
Menu

A Loader class which helps with loading video and image textures.

Hierarchy

  • TextureLoader

Index

Constructors

Methods

  • load(sources: string[], [options={}]?: { message: string; expireCache: boolean }): Promise<void[]>
  • Load an Array of provided source URL paths

    Parameters

    • sources: string[]

      The source URLs to load

    • [options={}]: { message: string; expireCache: boolean } = {}

      Additional options which modify loading

      • message: string
      • expireCache: boolean

    Returns Promise<void[]>

    A Promise which resolves once all textures are loaded

  • loadTexture(src: string): Promise<BaseTexture>
  • Load a single texture on-demand from a given source URL path

    Parameters

    • src: string

      The source texture path to load

    Returns Promise<BaseTexture>

    The loaded texture object

  • loadImageTexture(src: string): Promise<BaseTexture>
  • Load an image texture from a provided source url.

    Parameters

    • src: string

      The source image URL

    Returns Promise<BaseTexture>

    The loaded BaseTexture

  • loadVideoTexture(src: string): Promise<BaseTexture>
  • Load a video texture from a provided source url

    Parameters

    • src: string

      The source video URL

    Returns Promise<BaseTexture>

    The loaded BaseTexture

  • setCache(src: string, tex: BaseTexture): void
  • Add an image url to the texture cache

    Parameters

    • src: string

      The source URL

    • tex: BaseTexture

      The loaded base texture

    Returns void

  • getCache(src: string): BaseTexture
  • Retrieve a texture from the texture cache

    Parameters

    • src: string

      The source URL

    Returns BaseTexture

    The cached texture, or undefined

  • expireCache(): void
  • Expire (and destroy) textures from the cache which have not been used for more than CACHE_TTL milliseconds.

    Returns void

  • loadSceneTextures(scene: Scene, [options={}]?: { expireCache: boolean }): Promise<void[]>
  • Load all the textures which are required for a particular Scene

    Parameters

    • scene: Scene

      The Scene to load

    • [options={}]: { expireCache: boolean } = {}

      Additional options that configure texture loading

      • expireCache: boolean

    Returns Promise<void[]>

  • fetchResource(src: string, [options]?: { bustCache: boolean }): Promise<Blob>
  • Use the Fetch API to retrieve a resource and return a Blob instance for it.

    Parameters

    • src: string
    • [options]: { bustCache: boolean } = {}

      Options to configure the loading behaviour.

      • bustCache: boolean

    Returns Promise<Blob>

    A Blob containing the loaded data

  • getCacheBustURL(src: string): string | boolean
  • Return a URL with a cache-busting query parameter appended.

    Parameters

    • src: string

      The source URL being attempted

    Returns string | boolean

    The new URL, or false on a failure.

  • #onProgress(src: string, progress: any): void
  • Log texture loading progress in the console and in the Scene loading bar

    Parameters

    • src: string

      The source URL being loaded

    • progress: any

      Loading progress

    Returns void

  • #onError(src: string, progress: any, error: Error): void
  • Log failed texture loading

    Parameters

    • src: string

      The source URL being loaded

    • progress: any

      Loading progress

    • error: Error

      The error which occurred

    Returns void

Properties

#cache: Map<string, { tex: BaseTexture; time: number }> = ...

The cached mapping of textures

CACHE_TTL: number = ...

The duration in milliseconds for which a texture will remain cached