Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ResourceManager

todo

add description

Hierarchy

  • ResourceManager

Index

Constructors

constructor

  • Creates a resource manager that can be used to fetch and store resources such as textures, geometries, etc.

    Parameters

    • context: Context

      Valid context to created fetched objects for. Note that add external resources are expected to belong to that same context.

    Returns ResourceManager

Properties

Protected _buffers

_buffers: Map<string, Buffer> = new Map<string, Buffer>()

Internal storage of buffers.

Protected _context

_context: Context

Context, used to get context information and WebGL API access.

Protected _geometries

_geometries: Map<string, Geometry> = new Map<string, Geometry>()

Internal storage of geometries.

Protected _materials

_materials: Map<string, Material> = new Map<string, Material>()

Internal storage of material.

Protected _texture2Ds

_texture2Ds: Map<string, Texture2D> = new Map<string, Texture2D>()

Internal storage of 2D textures.

Methods

add

  • Allows to add a resource that, e.g., was not fetched by this resource manager but was loaded or generated somewhere else instead. Please note that by adding the resource, the manager assumes 'taking ownership'. If all given identifiers are already in use, the resource manager does not take ownership of the resource.

    Parameters

    • resource: Texture2D | Material | Geometry | Buffer

      Resource to add.

    • identifiers: Array<string>

      The identifiers by which the resource can be queried from the ResourceManager.

    Returns Array<string>

    • The array of added indentifiers. If an identifier already exists for another resource it is not added.

fetchTexture2D

  • fetchTexture2D(identifier: string, url: string, crossOrigin?: boolean): Promise<void> | undefined
  • Creates a Texture2D object and asynchronously loads its image via URL or data URI (@see Texture2D.fetch).

    Parameters

    • identifier: string

      Meaningful name for identification of this instance.

    • url: string

      Uniform resource locator string referencing the image that should be loaded (data URI supported).

    • Default value crossOrigin: boolean = false

      Enable cross origin data loading.

    Returns Promise<void> | undefined

    • Promise for handling image load status. Returns undefined if identifier already exists.

get

uninitialize

  • uninitialize(): void