AssetReferences can be used to easily load glTF or GLB assets

You can use AssetReference.getOrCreate to get an AssetReference for a URL to be easily loaded.
When using the same URL multiple times the same AssetReference will be returned, this avoids loading or creating the same asset multiple times.

  • myAssetReference.preload() to load the asset binary without creating an instance yet.
  • myAssetReference.loadAssetAsync() to load the asset and create an instance.
  • myAssetReference.instantiate() to load the asset and create a new instance.
  • myAssetReference.unload() to dispose allocated memory and destroy the asset instance.

Constructors

Accessors

  • get asset(): any
  • Returns any

  • set asset(val): void
  • Parameters

    • val: any

    Returns void

  • get rawAsset(): any
  • Returns any

  • get uri(): string
  • Returns string

Methods

  • Parameters

    • evt: ProgressCallback

    Returns void

  • Parameters

    • evt: ProgressCallback

    Returns void

  • loads and returns a new instance of asset

    Parameters

    • Optional parent: any

    Returns Promise<IGameObject>

  • loads and returns a new instance of asset - this call is networked so an instance will be created on all connected users

    Parameters

    • Optional parent: any
    • saveOnServer: boolean = true

    Returns Promise<IGameObject>

  • has the asset been loaded (via preload) or does it exist already (assigned to asset)

    Returns boolean | ArrayBuffer

  • Loads the asset and creates one instance (assigned to asset)

    Parameters

    • Optional prog: ProgressCallback

    Returns Promise<any>

    the loaded asset

  • frees previously allocated memory and destroys the current asset instance (if any)

    Returns void

  • Get an AssetReference for a URL to be easily loaded. AssetReferences are cached so calling this method multiple times with the same arguments will always return the same AssetReference.

    Parameters

    • sourceId: string | IComponent
    • url: string
    • Optional context: Context

    Returns AssetReference

Generated using TypeDoc