Options
Menu

Class AssetLibraryBundle

AssetLibraryBundle enforces a multiton pattern and is not intended to be instanced directly. Its purpose is to create a container for 3D data management, both before and after parsing. If you are interested in creating multiple library bundles, please use the getInstance() method.

Hierarchy

Index

Constructors

constructor

Properties

Static _iInstances

_iInstances: Object

Accessors

conflictPrecedence

  • get (): string
  • set (val: string): void
  • Defines which asset should have precedence when resolving a naming conflict between two assets of which one has just been renamed by the user or by a parser. By default ConflictPrecedence.FAVOR_NEW is used, meaning that the newly renamed asset will keep it's new name while the older asset gets renamed to not conflict.

    This property is ignored for conflict strategies that do not actually rename an asset automatically, such as ConflictStrategy.IGNORE and ConflictStrategy.THROW_ERROR.

    see

    away.library.ConflictPrecedence

    see

    away.library.ConflictStrategy

    Returns string

  • Defines which asset should have precedence when resolving a naming conflict between two assets of which one has just been renamed by the user or by a parser. By default ConflictPrecedence.FAVOR_NEW is used, meaning that the newly renamed asset will keep it's new name while the older asset gets renamed to not conflict.

    This property is ignored for conflict strategies that do not actually rename an asset automatically, such as ConflictStrategy.IGNORE and ConflictStrategy.THROW_ERROR.

    Parameters

    • val: string

    Returns void

conflictStrategy

  • Defines which strategy should be used for resolving naming conflicts, when two library assets are given the same name. By default, ConflictStrategy.APPEND_NUM_SUFFIX is used which means that a numeric suffix is appended to one of the assets. The conflictPrecedence property defines which of the two conflicting assets will be renamed.

    see

    naming.ConflictStrategy

    see

    AssetLibrary.conflictPrecedence

    Returns ConflictStrategyBase

  • Defines which strategy should be used for resolving naming conflicts, when two library assets are given the same name. By default, ConflictStrategy.APPEND_NUM_SUFFIX is used which means that a numeric suffix is appended to one of the assets. The conflictPrecedence property defines which of the two conflicting assets will be renamed.

    Parameters

    Returns void

Methods

addAsset

  • Adds an asset to the asset library, first making sure that it's name is unique using the method defined by the conflictStrategy and conflictPrecedence properties.

    Parameters

    Returns void

addEventListener

  • addEventListener(type: string, listener: function): void
  • Add an event listener

    method

    addEventListener

    Parameters

    • type: string
    • listener: function

    Returns void

createIterator

  • createIterator(assetTypeFilter?: string, namespaceFilter?: string, filterFunc?: any): AssetLibraryIterator
  • Create an AssetLibraryIterator instance that can be used to iterate over the assets in this asset library instance. The iterator can filter assets on asset type and/or namespace. A "null" filter value means no filter of that type is used.

    see

    away.library.AssetType

    Parameters

    • Default value assetTypeFilter: string = null

      Asset type to filter on (from the AssetType enum class.) Use null to not filter on asset type.

    • Default value namespaceFilter: string = null

      Namespace to filter on. Use null to not filter on namespace.

    • Default value filterFunc: any = null

      Callback function to use when deciding whether an asset should be included in the iteration or not. This needs to be a function that takes a single parameter of type IAsset and returns a boolean where true means it should be included.

    Returns AssetLibraryIterator

dispatchEvent

disposeLoader

  • disposeLoader(loader: Loader): void
  • Parameters

    Returns void

enableParser

  • enableParser(parserClass: Object): void
  • Parameters

    • parserClass: Object

    Returns void

enableParsers

  • enableParsers(parserClasses: Object[]): void
  • Parameters

    • parserClasses: Object[]

    Returns void

getAllAssets

  • Returns Array<IAssetAdapter>

getAsset

  • Parameters

    • name: string
    • Default value ns: string = null

    Returns IAssetAdapter

getLoader

  • Returns Loader

hasEventListener

  • hasEventListener(type: string, listener?: function): boolean
  • check if an object has an event listener assigned to it

    method

    hasListener

    Parameters

    • type: string
    • Optional listener: function

    Returns boolean

load

  • Loads a file and (optionally) all of its dependencies.

    Parameters

    • req: URLRequest

      The URLRequest object containing the URL of the file to be loaded.

    • Default value context: LoaderContext = null

      An optional context object providing additional parameters for loading

    • Default value ns: string = null

      An optional namespace string under which the file is to be loaded, allowing the differentiation of two resources with identical assets

    • Default value parser: ParserBase = null

      An optional parser object for translating the loaded data into a usable resource. If not provided, Loader will attempt to auto-detect the file type.

    Returns void

    A handle to the retrieved resource.

loadData

  • Loads a resource from existing data in memory.

    Parameters

    • data: any

      The data object containing all resource information.

    • Default value context: LoaderContext = null

      An optional context object providing additional parameters for loading

    • Default value ns: string = null

      An optional namespace string under which the file is to be loaded, allowing the differentiation of two resources with identical assets

    • Default value parser: ParserBase = null

      An optional parser object for translating the loaded data into a usable resource. If not provided, Loader will attempt to auto-detect the file type.

    Returns void

    A handle to the retrieved resource.

removeAllAssets

  • removeAllAssets(dispose?: boolean): void
  • Removes all assets from the asset library, optionally disposing them as they are removed.

    Parameters

    • Default value dispose: boolean = true

      Defines whether the assets should also be disposed.

    Returns void

removeAsset

  • Removes an asset from the library, and optionally disposes that asset by calling it's disposeAsset() method (which for most assets is implemented as a default version of that type's dispose() method.

    Parameters

    • asset: IAssetAdapter

      The asset which should be removed from this library.

    • Default value dispose: boolean = true

      Defines whether the assets should also be disposed.

    Returns void

removeAssetByName

  • removeAssetByName(name: string, ns?: string, dispose?: boolean): IAssetAdapter
  • Removes an asset which is specified using name and namespace.

    see

    away.library.AssetLibrary.removeAsset()

    Parameters

    • name: string

      The name of the asset to be removed.

    • Default value ns: string = null

      The namespace to which the desired asset belongs.

    • Default value dispose: boolean = true

      Defines whether the assets should also be disposed.

    Returns IAssetAdapter

removeEventListener

  • removeEventListener(type: string, listener: function): void
  • Remove an event listener

    method

    removeEventListener

    Parameters

    • type: string
    • listener: function

    Returns void

removeNamespaceAssets

  • removeNamespaceAssets(ns?: string, dispose?: boolean): void
  • Removes all assets belonging to a particular namespace (null for default) from the asset library, and optionall disposes them by calling their disposeAsset() method.

    see

    away.library.AssetLibrary.removeAsset()

    Parameters

    • Default value ns: string = null

      The namespace from which all assets should be removed.

    • Default value dispose: boolean = true

      Defines whether the assets should also be disposed.

    Returns void

stopAllLoaders

  • stopAllLoaders(): void
  • Returns void

Static getInstance

  • Returns an AssetLibraryBundle instance. If no key is given, returns the default bundle instance (which is similar to using the AssetLibraryBundle as a singleton.) To keep several separated library bundles, pass a string key to this method to define which bundle should be returned. This is referred to as using the AssetLibrary as a multiton.

    Parameters

    • Default value key: string = "default"

      Defines which multiton instance should be returned.

    Returns AssetLibraryBundle

    An instance of the asset library

Generated using TypeDoc