Class: Ornament
Represents an engraving (e.g. the kyub logo) or a cutout or both (might be the case with assets) You can only have one engraving and one cutout, not multiples (create multiple Ornaments if you need that). The engraving and cutout will be repeated if isRepeated is set.
Hierarchy
↳ Ornament
Index
Constructors
Properties
- cutout
- cutoutPromise
- engraving
- initialScaling
- isFunctional
- isXRepeating
- isYRepeating
- plate
- realizer
- safeMargin
- sizePromise
Methods
- _applyPropertiesToClone
- _calculateScaledSize
- _createNonRepeatedDrawable
- _createRepeatedDrawables
- _getUvAlignedAABB
- _updateToPseudoPlateUv
- clone
- coversWholePlate
- distanceToPoint
- duplicateToPlate
- enableSafeMargin
- getAABB
- getChangeEventEmitter
- getCutout
- getCutoutPolygons
- getCutoutPolygonsOutlineLength
- getCutoutPromise
- getEngraving
- getInitializedPromise
- getIsFunctional
- getIsRepeating
- getIsXRepeating
- getIsYRepeating
- getMirroredToPseudoPlateUvTransformationMatrix
- getOBB
- getOffset
- getPlate
- getRealizer
- getRepeatedCutouts
- getRepeatedEngravings
- getRotation
- getSafeMargin
- getScale
- getScaledSize
- getSize
- getSizePromise
- getToPseudoPlateUvTransformationMatrix
- hasCutout
- hasEngraving
- isClickThrough
- isPointWithin
- mapGlobal
- mapLocal
- setIsFunctional
- setIsRepeating
- setIsXRepeating
- setIsYRepeating
- setOffset
- setPlate
- setRealizer
- setRotation
- setScale
- setSize
- setSizeFromCutoutOrEngraving
- transformCutoutPolygonsFromBackToFrontSide
Constructors
constructor
+ new Ornament(engraving: Drawable, cutout: SvgDrawable, isFunctional: boolean, isRepeating: boolean): Ornament
Defined in src/model/visualization/textures/Ornament.ts:71
Parameters:
| Name | Type | Default |
|---|---|---|
engraving |
Drawable | null |
cutout |
SvgDrawable | null |
isFunctional |
boolean | false |
isRepeating |
boolean | false |
Returns: Ornament
Properties
Private Readonly cutout
• cutout: SvgDrawable
Defined in src/model/visualization/textures/Ornament.ts:60
Private cutoutPromise
• cutoutPromise: Promise‹Polygon[]› | null = null
Defined in src/model/visualization/textures/Ornament.ts:69
If the ornament consists of cutout the cutouts will be loaded once this promise resolves
Private Readonly engraving
• engraving: Drawable
Defined in src/model/visualization/textures/Ornament.ts:59
Private initialScaling
• initialScaling: boolean = false
Defined in src/model/visualization/textures/Ornament.ts:71
Private isFunctional
• isFunctional: boolean
Defined in src/model/visualization/textures/Ornament.ts:57
Private isXRepeating
• isXRepeating: boolean
Defined in src/model/visualization/textures/Ornament.ts:63
Used for creating infinite patterns by repeating a seamless rectangular drawable
Private isYRepeating
• isYRepeating: boolean
Defined in src/model/visualization/textures/Ornament.ts:64
Protected plate
• plate: Plate | null = null
Defined in src/model/visualization/textures/Ornament.ts:55
Protected realizer
• realizer: IModelElementRealizer‹MakerAsset | TessellationDescriptor | OrnamentDescriptor› = null
Defined in src/model/visualization/textures/Ornament.ts:56
Private safeMargin
• safeMargin: SafeMargin = null
Defined in src/model/visualization/textures/Ornament.ts:70
Private sizePromise
• sizePromise: Promise‹void› | null = null
Defined in src/model/visualization/textures/Ornament.ts:67
If the drawable has to be analyzed to get the ornament's size, it will be set once this promise resolves
Methods
Protected _applyPropertiesToClone
▸ _applyPropertiesToClone(clone: UvPositionable): void
Inherited from UvPositionable._applyPropertiesToClone
Defined in src/model/visualization/textures/UvPositionable.ts:240
Parameters:
| Name | Type |
|---|---|
clone |
UvPositionable |
Returns: void
Private _calculateScaledSize
▸ _calculateScaledSize(scale: ReadonlyVector3, size: ReadonlyVector3): IDimensions2
Defined in src/model/visualization/textures/Ornament.ts:408
Parameters:
| Name | Type |
|---|---|
scale |
ReadonlyVector3 |
size |
ReadonlyVector3 |
Returns: IDimensions2
Private _createNonRepeatedDrawable
▸ _createNonRepeatedDrawable(drawable?: Drawable, type: "cutout" | "engraving"): IOffsetDrawable[]
Defined in src/model/visualization/textures/Ornament.ts:402
Parameters:
| Name | Type | Default |
|---|---|---|
drawable? |
Drawable | - |
type |
"cutout" | "engraving" | "cutout" |
Returns: IOffsetDrawable[]
Private _createRepeatedDrawables
▸ _createRepeatedDrawables(area: AABB, drawable: Drawable, type: "cutout" | "engraving"): IOffsetDrawable[]
Defined in src/model/visualization/textures/Ornament.ts:366
Repeat the drawable so that it fills the whole area.
Parameters:
| Name | Type | Description |
|---|---|---|
area |
AABB | plate coordinate that needs to be covered (millimetres from plate origin) |
drawable |
Drawable | the drawable to be repeated |
type |
"cutout" | "engraving" | cutout or engraving |
Returns: IOffsetDrawable[]
Private _getUvAlignedAABB
▸ _getUvAlignedAABB(plateAABB: AABB): AABB
Defined in src/model/visualization/textures/Ornament.ts:421
The plate's AABB is transformed to include itself mapped to uv coordinates (this.mapLocal). Returns a rectangle which covers the whole plate after applying this.rotation.
Parameters:
| Name | Type | Description |
|---|---|---|
plateAABB |
AABB | - |
Returns: AABB
Protected _updateToPseudoPlateUv
▸ _updateToPseudoPlateUv(): void
Inherited from UvPositionable._updateToPseudoPlateUv
Defined in src/model/visualization/textures/UvPositionable.ts:251
Calculate a Matrix3 that transforms scaled texture uv coordinate (0,0 to 1,1) to pseudo plate uv coordinates (mm from plate origin)
Returns: void
clone
▸ clone(): UvPositionable
Inherited from UvPositionable.clone
Defined in src/model/visualization/textures/UvPositionable.ts:217
Generates a clone with identical values
Returns: UvPositionable
coversWholePlate
▸ coversWholePlate(): boolean
Defined in src/model/visualization/textures/Ornament.ts:136
Returns: boolean
distanceToPoint
▸ distanceToPoint(point: ReadonlyVector3): number
Inherited from UvPositionable.distanceToPoint
Defined in src/model/visualization/textures/UvPositionable.ts:112
Uses the AABB to determine the distance to a point
Parameters:
| Name | Type | Description |
|---|---|---|
point |
ReadonlyVector3 | test point in texture coordinates |
Returns: number
the distance from the point to the aabb)
duplicateToPlate
▸ duplicateToPlate(newPlate: any, plateSide: PlateSides): Promise‹Ornament›
Defined in src/model/visualization/textures/Ornament.ts:91
Clones this ornament and adds it to another plate instance, but at the same assembly position.
Parameters:
| Name | Type |
|---|---|
newPlate |
any |
plateSide |
PlateSides |
enableSafeMargin
▸ enableSafeMargin(plate: any): void
Defined in src/model/visualization/textures/Ornament.ts:280
Parameters:
| Name | Type |
|---|---|
plate |
any |
Returns: void
getAABB
▸ getAABB(): AABB
Inherited from UvPositionable.getAABB
Defined in src/model/visualization/textures/UvPositionable.ts:66
Calculates the AABB for this UVPositionable in texture coordinates (rotation, offset and scaling are already applied, for more detailed results use getOBB)
If properties have not change from the last call, the cached aabb will be returned
Returns: AABB
getChangeEventEmitter
▸ getChangeEventEmitter(): IPublicEventEmitterInterface‹UvPositionable›
Inherited from UvPositionable.getChangeEventEmitter
Defined in src/model/visualization/textures/UvPositionable.ts:56
Returns: IPublicEventEmitterInterface‹UvPositionable›
getCutout
▸ getCutout(): SvgDrawable | null
Defined in src/model/visualization/textures/Ornament.ts:155
Return the cutout of this Ornament
Returns: SvgDrawable | null
getCutoutPolygons
▸ getCutoutPolygons(plateArea?: AABB): Polygon[]
Defined in src/model/visualization/textures/Ornament.ts:230
Cutout polygons are only used for the visualization and are generated by segmentation of the actual cutouts. They MUST NOT touch or overlap each other, as this might lead to undefined behavior in the plate pipeline.
Parameters:
| Name | Type |
|---|---|
plateArea? |
AABB |
Returns: Polygon[]
cutouts (as polygons) that lie within the rectangles specified by the min/max plate coordinates. If this.cutoutPromise is not resolved yet, this function will return an empty array. For engravings it will return an empty array.
getCutoutPolygonsOutlineLength
▸ getCutoutPolygonsOutlineLength(): number
Defined in src/model/visualization/textures/Ornament.ts:274
Returns: number
getCutoutPromise
▸ getCutoutPromise(): Promise‹Polygon[]›
Defined in src/model/visualization/textures/Ornament.ts:303
Returns: Promise‹Polygon[]›
getEngraving
▸ getEngraving(): Drawable | null
Defined in src/model/visualization/textures/Ornament.ts:140
Returns: Drawable | null
getInitializedPromise
▸ getInitializedPromise(): Promise‹any[]›
Defined in src/model/visualization/textures/Ornament.ts:295
Returns: Promise‹any[]›
getIsFunctional
▸ getIsFunctional(): boolean
Defined in src/model/visualization/textures/Ornament.ts:187
Returns: boolean
getIsRepeating
▸ getIsRepeating(): boolean
Defined in src/model/visualization/textures/Ornament.ts:212
Returns: boolean
getIsXRepeating
▸ getIsXRepeating(): boolean
Defined in src/model/visualization/textures/Ornament.ts:204
Returns: boolean
getIsYRepeating
▸ getIsYRepeating(): boolean
Defined in src/model/visualization/textures/Ornament.ts:208
Returns: boolean
getMirroredToPseudoPlateUvTransformationMatrix
▸ getMirroredToPseudoPlateUvTransformationMatrix(): Matrix3
Inherited from UvPositionable.getMirroredToPseudoPlateUvTransformationMatrix
Defined in src/model/visualization/textures/UvPositionable.ts:210
Same as getToPseudoPlateUvTransformationMatrix, but mirror the positionable around the x axis at the beginning. Required for rendering cutouts in the shader that need to be mirrored because they are placed on the back of a plate
Returns: Matrix3
getOBB
▸ getOBB(): OBB
Inherited from UvPositionable.getOBB
Defined in src/model/visualization/textures/UvPositionable.ts:51
Calculates the OBB for this UvPositionable in texture coordinates (rotation, offset and scaling already applied)
Returns: OBB
getOffset
▸ getOffset(): Vector3
Inherited from UvPositionable.getOffset
Defined in src/model/visualization/textures/UvPositionable.ts:119
Returns the UvPositionable offset (= center position of the UvPositionable) in texture coordinates
Returns: Vector3
getPlate
▸ getPlate(): Plate | null
Defined in src/model/visualization/textures/Ornament.ts:121
Get the plate the ornament currently is on, or null, if the ornament is not on any plate
Returns: Plate | null
getRealizer
▸ getRealizer(): IModelElementRealizer‹MakerAsset‹› | TessellationDescriptor‹› | OrnamentDescriptor‹››
Defined in src/model/visualization/textures/Ornament.ts:148
Returns: IModelElementRealizer‹MakerAsset‹› | TessellationDescriptor‹› | OrnamentDescriptor‹››
getRepeatedCutouts
▸ getRepeatedCutouts(area: AABB): IOffsetDrawable[]
Defined in src/model/visualization/textures/Ornament.ts:179
Get repeated drawables of the cutouts of this ornament. Will contain only one element if no repetition is set
Parameters:
| Name | Type | Description |
|---|---|---|
area |
AABB | plate coordinates that needs to be covered |
Returns: IOffsetDrawable[]
getRepeatedEngravings
▸ getRepeatedEngravings(area: AABB): IOffsetDrawable[]
Defined in src/model/visualization/textures/Ornament.ts:171
Get repeated drawables of the engraving of this ornament. Will contain only one element if no repetition is set
Parameters:
| Name | Type | Description |
|---|---|---|
area |
AABB | plate coordinates that needs to be covered |
Returns: IOffsetDrawable[]
getRotation
▸ getRotation(): number
Inherited from UvPositionable.getRotation
Defined in src/model/visualization/textures/UvPositionable.ts:155
Get the rotation
Returns: number
CW rotation in degrees around the center of the UvPositionable
getSafeMargin
▸ getSafeMargin(): SafeMargin | null
Defined in src/model/visualization/textures/Ornament.ts:307
Returns: SafeMargin | null
getScale
▸ getScale(): Vector3
Inherited from UvPositionable.getScale
Defined in src/model/visualization/textures/UvPositionable.ts:137
Get the scale
Returns: Vector3
the scale of the UvPositionable that is applied to its size
getScaledSize
▸ getScaledSize(target?: Vector3): Vector3
Inherited from UvPositionable.getScaledSize
Defined in src/model/visualization/textures/UvPositionable.ts:187
Get the actual size, which is the native size with the scale vector applied
Parameters:
| Name | Type |
|---|---|
target? |
Vector3 |
Returns: Vector3
getSize
▸ getSize(): Vector3
Inherited from UvPositionable.getSize
Defined in src/model/visualization/textures/UvPositionable.ts:172
Get the native size of the UvPositionable, without scale being applied, in mm. Null-vector by default, as there usually needs to be some external knowledge to determine the native size.
Returns: Vector3
getSizePromise
▸ getSizePromise(): Promise‹void›
Defined in src/model/visualization/textures/Ornament.ts:299
Returns: Promise‹void›
getToPseudoPlateUvTransformationMatrix
▸ getToPseudoPlateUvTransformationMatrix(): Matrix3
Inherited from UvPositionable.getToPseudoPlateUvTransformationMatrix
Defined in src/model/visualization/textures/UvPositionable.ts:201
Return a matrix that transforms scaled texture coordinates to pseudo plate uv coordinates (the ones described by position, scale and rotation)
Returns: Matrix3
hasCutout
▸ hasCutout(): boolean
Defined in src/model/visualization/textures/Ornament.ts:159
Returns: boolean
hasEngraving
▸ hasEngraving(): boolean
Defined in src/model/visualization/textures/Ornament.ts:163
Returns: boolean
isClickThrough
▸ isClickThrough(): boolean
Defined in src/model/visualization/textures/Ornament.ts:219
If this returns true, interactions on cutouts of this ornament will ignore the plate at this
Returns: boolean
isPointWithin
▸ isPointWithin(point: Vector3): boolean
Inherited from UvPositionable.isPointWithin
Defined in src/model/visualization/textures/UvPositionable.ts:102
Uses the AABB to determine whether a point is within the UvPositionable
Parameters:
| Name | Type | Description |
|---|---|---|
point |
Vector3 | test point in texture coordinates |
Returns: boolean
Whether the point is within the ornament's AABB
mapGlobal
▸ mapGlobal(uvCoord: ReadonlyVector3, target: Vector3): Vector3
Inherited from UvPositionable.mapGlobal
Defined in src/model/visualization/textures/UvPositionable.ts:231
Parameters:
| Name | Type | Default |
|---|---|---|
uvCoord |
ReadonlyVector3 | - |
target |
Vector3 | new Vector3() |
Returns: Vector3
mapLocal
▸ mapLocal(uvCoord: ReadonlyVector3, target: Vector3): Vector3
Inherited from UvPositionable.mapLocal
Defined in src/model/visualization/textures/UvPositionable.ts:223
Parameters:
| Name | Type | Default |
|---|---|---|
uvCoord |
ReadonlyVector3 | - |
target |
Vector3 | new Vector3() |
Returns: Vector3
setIsFunctional
▸ setIsFunctional(): void
Defined in src/model/visualization/textures/Ornament.ts:183
Returns: void
setIsRepeating
▸ setIsRepeating(isRepeating: boolean): void
Defined in src/model/visualization/textures/Ornament.ts:191
Parameters:
| Name | Type | Default |
|---|---|---|
isRepeating |
boolean | true |
Returns: void
setIsXRepeating
▸ setIsXRepeating(isXRepeating: boolean): void
Defined in src/model/visualization/textures/Ornament.ts:196
Parameters:
| Name | Type | Default |
|---|---|---|
isXRepeating |
boolean | true |
Returns: void
setIsYRepeating
▸ setIsYRepeating(isYRepeating: boolean): void
Defined in src/model/visualization/textures/Ornament.ts:200
Parameters:
| Name | Type | Default |
|---|---|---|
isYRepeating |
boolean | true |
Returns: void
setOffset
▸ setOffset(newOffset: Vector3, applySafeMargin: boolean): void
Overrides UvPositionable.setOffset
Defined in src/model/visualization/textures/Ornament.ts:284
Parameters:
| Name | Type | Default |
|---|---|---|
newOffset |
Vector3 | - |
applySafeMargin |
boolean | true |
Returns: void
setPlate
▸ setPlate(newPlate: Plate): void
Defined in src/model/visualization/textures/Ornament.ts:129
Only to be called by the plate when adding the ornament
Parameters:
| Name | Type | Description |
|---|---|---|
newPlate |
Plate | The new plate or null. |
Returns: void
setRealizer
▸ setRealizer(realizer: IModelElementRealizer‹any›): void
Defined in src/model/visualization/textures/Ornament.ts:144
Parameters:
| Name | Type |
|---|---|
realizer |
IModelElementRealizer‹any› |
Returns: void
setRotation
▸ setRotation(newRotation: number): void
Inherited from UvPositionable.setRotation
Defined in src/model/visualization/textures/UvPositionable.ts:163
Set the rotation
Parameters:
| Name | Type | Description |
|---|---|---|
newRotation |
number | new rotation in radians |
Returns: void
setScale
▸ setScale(newScale: ReadonlyVector3, offset: Vector3, applySafeMargin: boolean): void
Overrides UvPositionable.setScale
Defined in src/model/visualization/textures/Ornament.ts:340
Parameters:
| Name | Type | Default |
|---|---|---|
newScale |
ReadonlyVector3 | - |
offset |
Vector3 | nullVector |
applySafeMargin |
boolean | true |
Returns: void
setSize
▸ setSize(size: Vector3): void
Inherited from UvPositionable.setSize
Defined in src/model/visualization/textures/UvPositionable.ts:179
Set the size
Parameters:
| Name | Type |
|---|---|
size |
Vector3 |
Returns: void
setSizeFromCutoutOrEngraving
▸ setSizeFromCutoutOrEngraving(maxSize?: number): void
Defined in src/model/visualization/textures/Ornament.ts:311
Parameters:
| Name | Type |
|---|---|
maxSize? |
number |
Returns: void
Static transformCutoutPolygonsFromBackToFrontSide
▸ transformCutoutPolygonsFromBackToFrontSide(cutoutPolygons: Polygon[], ornamentOffset: Vector3): void
Defined in src/model/visualization/textures/Ornament.ts:46
Transforms cutouts from an ornament placed on the back side so that they can be applied onto the front side.
In order to correctly transform cutouts on the back side to the front side, they have to be flipped around the plate's y-axis (= mirror x in plate-local coordinates), around the ornament's center (as all ornaments positions are their center). See also Drawable.drawSync mirrorX.
Parameters:
| Name | Type | Description |
|---|---|---|
cutoutPolygons |
Polygon[] | the polygons to transform, array will be modified |
ornamentOffset |
Vector3 | the ornament's offset, i.e. position |
Returns: void