Skip to content

editorGlobalsAssetLoader

Class: AssetLoader

Loads and caches assets like models, textures and json files

Hierarchy

  • AssetLoader

Index

Methods

Methods

Static _aggregateQueries

_aggregateQueries(methodName: string, methodArgs: string): Promise‹any›

Defined in src/assets/AssetLoader.ts:53

Performs a query on all APIs and flattens the result

Parameters:

Name Type
methodName string
methodArgs string

Returns: Promise‹any›


Static _getAssetsFromFirstApi

_getAssetsFromFirstApi(assetId: any): Promise‹unknown›

Defined in src/assets/AssetLoader.ts:94

Asks every apiInstance for the asset, returns the first result.

Parameters:

Name Type
assetId any

Returns: Promise‹unknown›

Promise that resolves to an asset or rejects if no api found the asset


Static _instantiateApiInstances

_instantiateApiInstances(): void

Defined in src/assets/AssetLoader.ts:33

Returns: void


Static _loadAssetResource

_loadAssetResource(asset: Asset, kindOfResource: string, resourceName: string): PromiseResource

Defined in src/assets/AssetLoader.ts:166

Parameters:

Name Type
asset Asset
kindOfResource string
resourceName string

Returns: PromiseResource


Static _loadAssetResourceSync

_loadAssetResourceSync(asset: Asset, kindOfResource: string, resourceName: string): Resource

Defined in src/assets/AssetLoader.ts:191

Parameters:

Name Type
asset Asset
kindOfResource string
resourceName string

Returns: Resource


Static _loadResourceFiles

_loadResourceFiles(assetId: any, resource: any): PromiseResource

Defined in src/assets/AssetLoader.ts:211

Queries the URLs for each file in the resource, loads and parses it.

Parameters:

Name Type Description
assetId any resource object that should be filled with data
resource any -

Returns: PromiseResource

promise that will resolve to the resource object with loaded contents


Static _loadResourceFilesSync

_loadResourceFilesSync(resource: Resource): Resource‹›

Defined in src/assets/AssetLoader.ts:249

Parameters:

Name Type
resource Resource

Returns: Resource‹›


Static fillInContainerDetails

fillInContainerDetails(fileContainer: any): Promise‹any›

Defined in src/assets/AssetLoader.ts:271

As an API Implementation may return "placeholder" file containers when querying assets, this method (and loadResource) may be used to fill the fileContainer with details.

Parameters:

Name Type Description
fileContainer any the fileContainer to be updated

Returns: Promise‹any›

promise that resolves once the fileContainer has been updated


Static getAsset

getAsset(id: string): PromiseAsset

Defined in src/assets/AssetLoader.ts:66

See {@link AssetApi.getAsset}

Parameters:

Name Type
id string

Returns: PromiseAsset


Static getByMetadata

getByMetadata(query: string): Promise‹any›

Defined in src/assets/AssetLoader.ts:130

see AssetApiClient.getByMetadata

Parameters:

Name Type
query string

Returns: Promise‹any›


Static getResourceUrl

getResourceUrl(resource: Resource, file: string): any

Defined in src/assets/AssetLoader.ts:155

see ApiClient#getResourceUrl

Parameters:

Name Type
resource Resource
file string

Returns: any


Static loadDefault

loadDefault(url: string): Promise‹Object3D | string | Texture | ArrayBuffer | Record‹string, any››

Defined in src/assets/AssetLoader.ts:305

Deducts what type to load based on the file ending provided by the URL

Parameters:

Name Type Description
url string the absolute URL to the resource

Returns: Promise‹Object3D | string | Texture | ArrayBuffer | Record‹string, any››

A promise that resolves with the resource


Static loadDefaultSync

loadDefaultSync(url: string): Object3D | string | Texture | ArrayBuffer | Record‹string, any›

Defined in src/assets/AssetLoader.ts:334

see AssetLoader.loadDefault, but without a promise

Parameters:

Name Type
url string

Returns: Object3D | string | Texture | ArrayBuffer | Record‹string, any›


Static loadExternalObject

loadExternalObject(assetIdAndResourceName: string): PromiseResource

Defined in src/assets/AssetLoader.ts:283

Parameters:

Name Type
assetIdAndResourceName string

Returns: PromiseResource

a promise that resolves to a resource that contains all loaded files of the external object


Static loadExternalObjectSync

loadExternalObjectSync(assetIdAndResourceName: string): Resource

Defined in src/assets/AssetLoader.ts:293

Parameters:

Name Type
assetIdAndResourceName string

Returns: Resource

a resource with all loaded files of the external object


Static loadResource

loadResource(kindOfResource: string, assetIdAndResourceName: string): PromiseResource

Defined in src/assets/AssetLoader.ts:142

Loads all files associated with the specified resource.

Parameters:

Name Type Description
kindOfResource string what kind of resource is to be loaded (e.g. externalObjects)
assetIdAndResourceName string - the combined asset ID and resource name, e.g. 'assetId/resourceName' or just 'assetId' which returns the first resource of that kind

Returns: PromiseResource

an object as a Filename -> ParsedFileContents map


Static loadResourceSync

loadResourceSync(kindOfResource: string, assetIdAndResourceName: string): Resource

Defined in src/assets/AssetLoader.ts:180

Parameters:

Name Type
kindOfResource string
assetIdAndResourceName string

Returns: Resource