editor › Globals › AssetPlateSpecLoader
Class: AssetPlateSpecLoader
Contains static logic to create a AssetPlateSpec instance based on an asset and the name of the assetPlates resource.
Makes AssetPlateHelper.coffee obsolete
Hierarchy
- AssetPlateSpecLoader
Index
Properties
Methods
- _determineMergeableSectionIndices
- _loadAndNormalizeSvg
- _normalizeSvgCenter
- _parseAndApplyProperties
- _parseOutlineAndCenter
- loadFromAsset
Properties
Static Private outlineAndCenterCache
▪ outlineAndCenterCache: Map‹string, object› = new Map
Defined in src/model/data/Concepts/MakerAsset/AssetPlateSpecLoader.ts:24
Caches the parsed contents of outline.svg
Methods
Static Private _determineMergeableSectionIndices
▸ _determineMergeableSectionIndices(outline: Vector2[], mergeableSections: any[], tolerance: number): number[]
Defined in src/model/data/Concepts/MakerAsset/AssetPlateSpecLoader.ts:188
Determines the index of the mergeable sections specified in the properties.yml
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
outline |
Vector2[] | - | the already parsed outline of the plate |
mergeableSections |
any[] | - | mergeable sections as specified in the properties.yml |
tolerance |
number | 0.05 | matching tolerance (point distance), in mm |
Returns: number[]
an array where each mergeable outline section is identified by its index
Static Private _loadAndNormalizeSvg
▸ _loadAndNormalizeSvg(resource: any): Promise‹object›
Defined in src/model/data/Concepts/MakerAsset/AssetPlateSpecLoader.ts:49
Loads the SVG files in the resource, which is the plate outline and optionally a default ornament defined by engraving and cutout svgs.
Parameters:
| Name | Type | Description |
|---|---|---|
resource |
any | the resource instance |
Returns: Promise‹object›
the outline as vectors and optionally an ornament spec to be placed on the plate
Static Private _normalizeSvgCenter
▸ _normalizeSvgCenter(svgString: any, centerPosition: Vector2‹›): string
Defined in src/model/data/Concepts/MakerAsset/AssetPlateSpecLoader.ts:173
The editor assumes Ornaments to be placed with / rotated around the middle, however, we allow arbitrary center position placement in asset SVGs. This modifies an asset svg so that the given centerPosition is in the middle - thus the resulting SVG can be used in an Ornament so that the Ornament can be used "normally" in the editor.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
svgString |
any | - | the input svg |
centerPosition |
Vector2‹› | new Vector2() | the desired center position, in SVG user units |
Returns: string
normalized SVG safe to be used in Ornaments
Static Private _parseAndApplyProperties
▸ _parseAndApplyProperties(resource: any, plateSpec: AssetPlateSpec): void
Defined in src/model/data/Concepts/MakerAsset/AssetPlateSpecLoader.ts:131
Parses the "properties.yml" in the resource and applies its entries to the plateSpec. Requires the plateSpec to already have a valid outline.
Parameters:
| Name | Type | Description |
|---|---|---|
resource |
any | the resource instance |
plateSpec |
AssetPlateSpec | the plateSpec to be filled |
Returns: void
Static Private _parseOutlineAndCenter
▸ _parseOutlineAndCenter(outlineSvgString: string): Promise‹object›
Defined in src/model/data/Concepts/MakerAsset/AssetPlateSpecLoader.ts:84
Parses the outline.svg of an assetPlate into an outline consisting out of vectors and the center point
Parameters:
| Name | Type |
|---|---|
outlineSvgString |
string |
Returns: Promise‹object›
Static loadFromAsset
▸ loadFromAsset(asset: any, resourceName: string): Promise‹AssetPlateSpec›
Defined in src/model/data/Concepts/MakerAsset/AssetPlateSpecLoader.ts:26
Parameters:
| Name | Type |
|---|---|
asset |
any |
resourceName |
string |
Returns: Promise‹AssetPlateSpec›