editor › Globals › ResourceLoader
Class: ResourceLoader
Provides an interface to load resources such as textures and 3d models
Hierarchy
- ResourceLoader
Index
Methods
- _getCachingKey
- _getResource
- _getResourceSync
- _guessResourceTypeFromURLEnding
- _initClass
- _loadModelFromString
- _loadTextureFromArrayBuffer
- _loadTextureFromImageSrc
- _manageResourceLoadingState
- _preloadResource
- getSvgSprite
- loadImage
- loadImageSync
- loadJson
- loadJsonSync
- loadModel
- loadModelSync
- loadSVGSync
- loadSound
- loadSvg
- loadText
- loadTextSync
- loadTexture
- loadTextureSync
- loadYml
- loadYmlSync
Methods
Static Private _getCachingKey
▸ _getCachingKey(path: string, type: ProcessedResourceType | ResponseType): string
Defined in src/assets/ResourceLoader.ts:429
Parameters:
| Name | Type |
|---|---|
path |
string |
type |
ProcessedResourceType | ResponseType |
Returns: string
Static Private _getResource
▸ _getResource(path: any, responseType: ResponseType, prependRoot: boolean): Promise‹any›
Defined in src/assets/ResourceLoader.ts:351
Parameters:
| Name | Type | Default |
|---|---|---|
path |
any | - |
responseType |
ResponseType | - |
prependRoot |
boolean | true |
Returns: Promise‹any›
Static Private _getResourceSync
▸ _getResourceSync(path: any, resourceType: ProcessedResourceType | ResponseType, prependRoot: boolean): any
Defined in src/assets/ResourceLoader.ts:343
Parameters:
| Name | Type | Default |
|---|---|---|
path |
any | - |
resourceType |
ProcessedResourceType | ResponseType | - |
prependRoot |
boolean | true |
Returns: any
Static Private _guessResourceTypeFromURLEnding
▸ _guessResourceTypeFromURLEnding(ending: string): ResponseType | ProcessedResourceType
Defined in src/assets/ResourceLoader.ts:436
We can not be sure what resource type is loaded just by looking at the file ending. This is just the best guess.
Parameters:
| Name | Type |
|---|---|
ending |
string |
Returns: ResponseType | ProcessedResourceType
Static _initClass
▸ _initClass(): void
Defined in src/assets/ResourceLoader.ts:48
Returns: void
Static Private _loadModelFromString
▸ _loadModelFromString(modelString: string, useIndexedFaces: boolean): Object3D
Defined in src/assets/ResourceLoader.ts:423
Parameters:
| Name | Type | Default |
|---|---|---|
modelString |
string | - |
useIndexedFaces |
boolean | false |
Returns: Object3D
Static Private _loadTextureFromArrayBuffer
▸ _loadTextureFromArrayBuffer(arrayBuffer: any, type: any): Texture
Defined in src/assets/ResourceLoader.ts:395
Parameters:
| Name | Type |
|---|---|
arrayBuffer |
any |
type |
any |
Returns: Texture
Static Private _loadTextureFromImageSrc
▸ _loadTextureFromImageSrc(src: string): Texture
Defined in src/assets/ResourceLoader.ts:407
Parameters:
| Name | Type |
|---|---|
src |
string |
Returns: Texture
Static Private _manageResourceLoadingState
▸ _manageResourceLoadingState(resourceKey: string, loadingPromise: Promise‹any›): typeof loadingPromise
Defined in src/assets/ResourceLoader.ts:378
Puts the promise to currentlyLoadingResources and when loaded, moves the data to loadedResources
Parameters:
| Name | Type |
|---|---|
resourceKey |
string |
loadingPromise |
Promise‹any› |
Returns: typeof loadingPromise
Static Private _preloadResource
▸ _preloadResource(url: string, resource: any, resourceType: ResponseType | ProcessedResourceType): void
Defined in src/assets/ResourceLoader.ts:457
Parameters:
| Name | Type | Default |
|---|---|---|
url |
string | - |
resource |
any | - |
resourceType |
ResponseType | ProcessedResourceType | null |
Returns: void
Static getSvgSprite
▸ getSvgSprite(path: any, prependRoot: boolean): Promise‹string›
Defined in src/assets/ResourceLoader.ts:317
Parameters:
| Name | Type | Default |
|---|---|---|
path |
any | - |
prependRoot |
boolean | true |
Returns: Promise‹string›
Static loadImage
▸ loadImage(path: string, prependRoot: boolean): Promise‹ArrayBuffer›
Defined in src/assets/ResourceLoader.ts:301
Loads an image file.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
path |
string | - | the url of the image file |
prependRoot |
boolean | true | - |
Returns: Promise‹ArrayBuffer›
the contents of the image file
Static loadImageSync
▸ loadImageSync(path: string, prependRoot: boolean): ArrayBuffer
Defined in src/assets/ResourceLoader.ts:305
Parameters:
| Name | Type | Default |
|---|---|---|
path |
string | - |
prependRoot |
boolean | true |
Returns: ArrayBuffer
Static loadJson
▸ loadJson(path: string, prependRoot: boolean): Promise‹object›
Defined in src/assets/ResourceLoader.ts:208
Parameters:
| Name | Type | Default |
|---|---|---|
path |
string | - |
prependRoot |
boolean | true |
Returns: Promise‹object›
Static loadJsonSync
▸ loadJsonSync(path: string, prependRoot: boolean): object
Defined in src/assets/ResourceLoader.ts:222
Parameters:
| Name | Type | Default |
|---|---|---|
path |
string | - |
prependRoot |
boolean | true |
Returns: object
Static loadModel
▸ loadModel(path: string, useIndexedFaces: boolean, prependRoot: boolean): Promise‹Object3D›
Defined in src/assets/ResourceLoader.ts:164
Parameters:
| Name | Type | Default |
|---|---|---|
path |
string | - |
useIndexedFaces |
boolean | false |
prependRoot |
boolean | true |
Returns: Promise‹Object3D›
Static loadModelSync
▸ loadModelSync(path: string, prependRoot: boolean): Object3D
Defined in src/assets/ResourceLoader.ts:191
Parameters:
| Name | Type | Default |
|---|---|---|
path |
string | - |
prependRoot |
boolean | true |
Returns: Object3D
a Object3D graph that represents the .obj file
Static loadSVGSync
▸ loadSVGSync(path: string, prependRoot: boolean): string
Defined in src/assets/ResourceLoader.ts:287
Parameters:
| Name | Type | Default |
|---|---|---|
path |
string | - |
prependRoot |
boolean | true |
Returns: string
Static loadSound
▸ loadSound(soundFileName: string, format: string, prependRoot: boolean): Promise‹ArrayBuffer›
Defined in src/assets/ResourceLoader.ts:203
Parameters:
| Name | Type | Default |
|---|---|---|
soundFileName |
string | - |
format |
string | "opus" |
prependRoot |
boolean | true |
Returns: Promise‹ArrayBuffer›
Static loadSvg
▸ loadSvg(path: string, prependRoot: boolean): Promise‹string›
Defined in src/assets/ResourceLoader.ts:262
Loads an svg file.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
path |
string | - | the url of the svg file |
prependRoot |
boolean | true | - |
Returns: Promise‹string›
the svg string
Static loadText
▸ loadText(path: string, prependRoot: boolean): Promise‹string›
Defined in src/assets/ResourceLoader.ts:309
Parameters:
| Name | Type | Default |
|---|---|---|
path |
string | - |
prependRoot |
boolean | true |
Returns: Promise‹string›
Static loadTextSync
▸ loadTextSync(path: string, prependRoot: boolean): string
Defined in src/assets/ResourceLoader.ts:313
Parameters:
| Name | Type | Default |
|---|---|---|
path |
string | - |
prependRoot |
boolean | true |
Returns: string
Static loadTexture
▸ loadTexture(path: string, prependRoot: boolean): Promise‹Texture›
Defined in src/assets/ResourceLoader.ts:130
Parameters:
| Name | Type | Default |
|---|---|---|
path |
string | - |
prependRoot |
boolean | true |
Returns: Promise‹Texture›
Static loadTextureSync
▸ loadTextureSync(path: string, prependRoot: boolean): Texture
Defined in src/assets/ResourceLoader.ts:157
Parameters:
| Name | Type | Default |
|---|---|---|
path |
string | - |
prependRoot |
boolean | true |
Returns: Texture
Static loadYml
▸ loadYml(path: string, prependRoot: boolean): Promise‹Record‹string, any››
Defined in src/assets/ResourceLoader.ts:231
Parameters:
| Name | Type | Default |
|---|---|---|
path |
string | - |
prependRoot |
boolean | true |
Returns: Promise‹Record‹string, any››
Static loadYmlSync
▸ loadYmlSync(path: string, prependRoot: boolean): object
Defined in src/assets/ResourceLoader.ts:248
Parameters:
| Name | Type | Default |
|---|---|---|
path |
string | - |
prependRoot |
boolean | true |
Returns: object