editor › Globals › OrnamentLoader
Class: OrnamentLoader
Loads an ornament (asset) and instantiates it according to the type of the ornament.
Hierarchy
- OrnamentLoader
Index
Properties
Methods
- _instantiateOrnament
- _instantiateParametricOrnament
- _loadOrnamentResource
- getCachedImageDrawable
- getCachedSvgDrawable
- getOrnament
- getOrnamentFromSvgStrings
- getOrnamentSync
- instantiateOrnament
- preloadOrnament
- preloadOrnamentInstance
Properties
Static Private drawableCache
▪ drawableCache: Map‹string, Drawable‹›› = new Map
Defined in src/model/visualization/textures/OrnamentLoader.ts:51
For rendering the textures on the gpu, we need to make sure that we have unique texture instances across kyub (opengl allows 16 textures for one shader stage)
Methods
Static Private _instantiateOrnament
▸ _instantiateOrnament(params: OrnamentParameters, resource: Resource, assetIdAndResourceName: string): Ornament
Defined in src/model/visualization/textures/OrnamentLoader.ts:231
Parameters:
| Name | Type |
|---|---|
params |
OrnamentParameters |
resource |
Resource |
assetIdAndResourceName |
string |
Returns: Ornament
Static Private _instantiateParametricOrnament
▸ _instantiateParametricOrnament(params: IParametricHoleParameters): ParametricHoleOrnament
Defined in src/model/visualization/textures/OrnamentLoader.ts:222
Parameters:
| Name | Type |
|---|---|
params |
IParametricHoleParameters |
Returns: ParametricHoleOrnament
Static Private _loadOrnamentResource
▸ _loadOrnamentResource(assetIdAndResourceName: string): Promise‹object›
Defined in src/model/visualization/textures/OrnamentLoader.ts:216
Parameters:
| Name | Type |
|---|---|
assetIdAndResourceName |
string |
Returns: Promise‹object›
Static getCachedImageDrawable
▸ getCachedImageDrawable(arrayBuffer: ArrayBuffer, key: string, assetData?: IAssetData): ImageDrawable
Defined in src/model/visualization/textures/OrnamentLoader.ts:204
Parameters:
| Name | Type |
|---|---|
arrayBuffer |
ArrayBuffer |
key |
string |
assetData? |
IAssetData |
Returns: ImageDrawable
Static getCachedSvgDrawable
▸ getCachedSvgDrawable(svgString: string, assetData?: IAssetData, resource?: Resource): SvgDrawable‹›
Defined in src/model/visualization/textures/OrnamentLoader.ts:179
Parameters:
| Name | Type |
|---|---|
svgString |
string |
assetData? |
IAssetData |
resource? |
Resource |
Returns: SvgDrawable‹›
Static getOrnament
▸ getOrnament(plate: Plate | null, assetIdAndResourceName: string): Promise‹Ornament›
Defined in src/model/visualization/textures/OrnamentLoader.ts:89
Loads the resource of the ornament and instantiates the ornament.
Parameters:
| Name | Type | Description |
|---|---|---|
plate |
Plate | null | the plate the ornament is meant to be applied to |
assetIdAndResourceName |
string | resource name of the asset attached to the ornament |
promise that resolves to an ornament
Static getOrnamentFromSvgStrings
▸ getOrnamentFromSvgStrings(cutoutSvgString: string, engravingSvgString: string): Ornament
Defined in src/model/visualization/textures/OrnamentLoader.ts:162
Parameters:
| Name | Type |
|---|---|
cutoutSvgString |
string |
engravingSvgString |
string |
Returns: Ornament
Static getOrnamentSync
▸ getOrnamentSync(plate: Plate | null, assetIdAndResourceName: string): Ornament | null
Defined in src/model/visualization/textures/OrnamentLoader.ts:94
Parameters:
| Name | Type |
|---|---|
plate |
Plate | null |
assetIdAndResourceName |
string |
Returns: Ornament | null
Static instantiateOrnament
▸ instantiateOrnament(plate: Plate, params: OrnamentParameters, resource: Resource, assetIdAndResourceName: string, ornament?: Ornament): Ornament
Defined in src/model/visualization/textures/OrnamentLoader.ts:108
Instantiates the correct ornament based on resource params
Parameters:
| Name | Type | Description |
|---|---|---|
plate |
Plate | - |
params |
OrnamentParameters | - |
resource |
Resource | - |
assetIdAndResourceName |
string | - |
ornament? |
Ornament | just initializes it if it already exists. todo ornament: refactor this into two methods |
Returns: Ornament
Static preloadOrnament
▸ preloadOrnament(assetIdAndResourceName: string): Promise‹void›
Defined in src/model/visualization/textures/OrnamentLoader.ts:58
Loads and instantiates an ornament, but then discards it. This serves to fill all caches so that the next call to getOrnament(Sync)() will resolve quicker
Parameters:
| Name | Type | Description |
|---|---|---|
assetIdAndResourceName |
string | assetID and resource name |
Returns: Promise‹void›
Static preloadOrnamentInstance
▸ preloadOrnamentInstance(ornament: Ornament): Promise‹void›
Defined in src/model/visualization/textures/OrnamentLoader.ts:69
Attempts to preload as much as possible information for an ornament instance, i.e. triggering all the async load and preparation calls in the ornament's drawables
Parameters:
| Name | Type | Description |
|---|---|---|
ornament |
Ornament | the ornament to be "preloaded" |
Returns: Promise‹void›