Skip to content

editor › Globals › Resource

Class: Resource

A Resource is a collection of basic files (textures, models, config, …) that represents something, such as e.g. an external object. An asset can contain multiple resources of different kinds.

Hierarchy

↳ Resource

Index

Constructors

Properties

Methods

Constructors

constructor

+ new Resource(options: Partial‹IResourceOptions›): Resource

Overrides FileContainer.constructor

Defined in src/assets/Resource.ts:14

Parameters:

Name Type Default
options Partial‹IResourceOptions› {}

Returns: Resource

Properties

Private kindOfResource

• kindOfResource: string | null = null

Defined in src/assets/Resource.ts:14

Methods

addFile

▸ addFile(name: string): void

Inherited from FileContainer.addFile

Defined in src/assets/FileContainer.ts:90

Adds a file entry

Parameters:

Name Type Description
name string name of the file to add

Returns: void


getApiSpecificData

▸ getApiSpecificData(fileName: string): any

Inherited from FileContainer.getApiSpecificData

Defined in src/assets/FileContainer.ts:171

Parameters:

Name Type
fileName string

Returns: any


getContainingAsset

▸ getContainingAsset(): Asset

Inherited from FileContainer.getContainingAsset

Defined in src/assets/FileContainer.ts:143

Returns: Asset

the asset that contains this resource


getContent

▸ getContent‹T›(fileName: string): T

Inherited from FileContainer.getContent

Defined in src/assets/FileContainer.ts:119

Type parameters:

▪ T: Object3D | string | Texture | ArrayBuffer | Record‹string, any› | null

Parameters:

Name Type
fileName string

Returns: T

the content of the specified file, if it already has been loaded, null otherwise.


getFiles

▸ getFiles(): string[]

Inherited from FileContainer.getFiles

Defined in src/assets/FileContainer.ts:82

TODO Rename to getFileNames or return actual files

Returns: string[]

a (cloned) list of file names that are in this container


getHasContentsLoaded

▸ getHasContentsLoaded(): boolean

Inherited from FileContainer.getHasContentsLoaded

Defined in src/assets/FileContainer.ts:67

Returns: boolean

if all file contents have been loaded see {@link AssetLoader#loadResource}


getHasNamesLoaded

▸ getHasNamesLoaded(): boolean

Inherited from FileContainer.getHasNamesLoaded

Defined in src/assets/FileContainer.ts:53

Returns: boolean

if all file names have been loaded see {@link IAssetApi#fillInContainerDetails}


getId

▸ getId(): string

Inherited from FileContainer.getId

Defined in src/assets/FileContainer.ts:158

Returns: string

the id of the FileContainer. An AssetApi implementation may choose to use unique IDs in additions to the container's name. Null, if unused.


getKindOfResource

▸ getKindOfResource(): string

Defined in src/assets/Resource.ts:30

Returns: string

what kind of resource this is, e.g. 'externalObjects'


getName

▸ getName(): string

Inherited from FileContainer.getName

Defined in src/assets/FileContainer.ts:150

Returns: string

name of the FileContainer. Its meaning is that of a folder name.


hasFile

▸ hasFile(fileName: any): boolean

Inherited from FileContainer.hasFile

Defined in src/assets/FileContainer.ts:112

Parameters:

Name Type
fileName any

Returns: boolean

whether the resource has the specified file


removeFile

▸ removeFile(name: string): void

Inherited from FileContainer.removeFile

Defined in src/assets/FileContainer.ts:101

Removes the specified file and its contents

Parameters:

Name Type Description
name string name of the file

Returns: void


setApiSpecificData

▸ setApiSpecificData(fileName: string, data: any): void

Inherited from FileContainer.setApiSpecificData

Defined in src/assets/FileContainer.ts:166

Set additional data that is specific to the api implementation this container is created by. Only to be used by the API itself.

Parameters:

Name Type
fileName string
data any

Returns: void


setContainingAsset

▸ setContainingAsset(asset: any): void

Inherited from FileContainer.setContainingAsset

Defined in src/assets/FileContainer.ts:135

Parameters:

Name Type
asset any

Returns: void


setContent

▸ setContent(fileName: string, content: Object3D | string | Texture | ArrayBuffer | Record‹string, any›): void

Inherited from FileContainer.setContent

Defined in src/assets/FileContainer.ts:128

Cache the content of a specified file of the resource

Parameters:

Name Type
fileName string
content Object3D | string | Texture | ArrayBuffer | Record‹string, any›

Returns: void


setHasContentsLoaded

▸ setHasContentsLoaded(): void

Inherited from FileContainer.setHasContentsLoaded

Defined in src/assets/FileContainer.ts:74

Only to be called by AssetLoader / AssetApi

Returns: void


setHasNamesLoaded

▸ setHasNamesLoaded(): void

Inherited from FileContainer.setHasNamesLoaded

Defined in src/assets/FileContainer.ts:60

Only to be called by AssetLoader / AssetAPI

Returns: void


setKindOfResource

▸ setKindOfResource(kindOfResource: string): void

Defined in src/assets/Resource.ts:23

Parameters:

Name Type
kindOfResource string

Returns: void