AudioAssets

View source

ExtendsAssets

Typed resource alias for the shared Assets pool of Audio assets. It inherits Assets behavior, including Assets#add and Assets#get, for storing and resolving audio handles.

AudioPlugin registers this alias for the shared audio pool; it does not create a second store. Retrieve the pool with world.getResource and AudioAssets.

Examples

import { AudioAssets } from '@wimaengine/audio'

function lookupAudio(world, audioHandle) {
  const audioAssets = world.getResource(AudioAssets)
  const audio = audioAssets.get(audioHandle)

  // AudioAssets resolves this handle from the shared pool.
  return audio?.audiobuffer
}

Constructor


constructor(type: object)

View source

Creates a typed asset pool for values identified by type.

The supplied constructor is retained as the asset family’s type identity for handles and resource access.

Parameters

NameDescriptionDefault
type

Constructor for the asset values in this container.

—