TextSystem
MRSystem
TextSystem ⇐ Handles text creation and font rendering for mr-text
, mr-textfield
, and mr-textarea
with a starting framerate of 1/30.
Kind: global class
Extends: MRSystem
- TextSystem ⇐
MRSystem
- .TextSystem
- .onNewEntity(entity)
- ._updateSpecificEntity(entity)
- .checkIfTextContentChanged(entity) ⇒
boolean
- .handleTextContentUpdate(entity)
- .eventUpdate()
- .updateStyle(entity)
- .addText(entity)
- .parseFontWeight(weight) ⇒
string
- .parseFontSize(val, el) ⇒
number
- .getVerticalAlign(verticalAlign, entity) ⇒
string
- .getLineHeight(lineHeight, entity) ⇒
number
- .getTextAlign(textAlign) ⇒
string
- .parseFontFace(cssString) ⇒
object
- .setTextObject3DColor(object3D, color, default_color)
textSystem.TextSystem
Kind: instance class of TextSystem
new exports.TextSystem()
TextSystem’s default constructor
textSystem.onNewEntity(entity)
When a new entity is created, adds it to the physics registry and initializes the physics aspects of the entity.
Kind: instance method of TextSystem
Param | Type | Description |
---|---|---|
entity | MREntity |
the entity being set up |
textSystem._updateSpecificEntity(entity)
The per entity triggered update call. Handles updating all text items including updates for style and cleaning of content for special characters.
Kind: instance method of TextSystem
Param | Type | Description |
---|---|---|
entity | object |
the entity that needs to be updated. |
boolean
textSystem.checkIfTextContentChanged(entity) ⇒ Kind: instance method of TextSystem
Returns: boolean
- true if the content needed to be updated, false otherwise.
Param | Type | Description |
---|---|---|
entity | object |
checks if the content changed and if so, updates it to match. |
textSystem.handleTextContentUpdate(entity)
Kind: instance method of TextSystem
Param | Type | Description |
---|---|---|
entity | object |
the entity whose content updated. |
textSystem.eventUpdate()
The per global scene event update call. Handles updating all text items including updates for style and cleaning of content for special characters.
Kind: instance method of TextSystem
textSystem.updateStyle(entity)
Updates the style for the text’s information based on compStyle and inputted css elements.
Kind: instance method of TextSystem
Param | Type | Description |
---|---|---|
entity | MRTextEntity |
the text entity whose style is being updated |
textSystem.addText(entity)
Handles when text is added as an entity updating content and style for the internal textObj appropriately.
Kind: instance method of TextSystem
Param | Type | Description |
---|---|---|
entity | MRTextEntity |
the text entity being updated |
string
textSystem.parseFontWeight(weight) ⇒ parses the font weight as ‘bold’, ‘normal’, etc based on the given weight value
Kind: instance method of TextSystem
Returns: string
- - the enum of ‘bold’, ‘normal’, etc
Param | Type | Description |
---|---|---|
weight | number |
the numerical representation of the font-weight |
number
textSystem.parseFontSize(val, el) ⇒ parses the font size based on its XXpx
value and converts it to a usable result based on the virtual display resolution
Kind: instance method of TextSystem
Returns: number
- - the font size adjusted for the display as expected
Param | Type | Description |
---|---|---|
val | number |
the value being adjusted |
el | object |
the css element handler |
string
textSystem.getVerticalAlign(verticalAlign, entity) ⇒ Gets the vertical align
Kind: instance method of TextSystem
Returns: string
- - the string representation of the the verticalAlign
Param | Type | Description |
---|---|---|
verticalAlign | number |
the numerical representation in pixel space of the vertical Align |
entity | MREntity |
the entity whose comp style (css) is relevant |
number
textSystem.getLineHeight(lineHeight, entity) ⇒ Gets the line height
Kind: instance method of TextSystem
Returns: number
- - the numerical representation of the the lineHeight
Param | Type | Description |
---|---|---|
lineHeight | number |
the numerical representation in pixel space of the line height |
entity | MREntity |
the entity whose comp style (css) is relevant |
string
textSystem.getTextAlign(textAlign) ⇒ Gets the text alignment string
Kind: instance method of TextSystem
Returns: string
- - the resolved textAlign
.
Param | Type | Description |
---|---|---|
textAlign | string |
handles values for start , end , left , and right ; otherwise, defaults to the same input as textAlign . |
object
textSystem.parseFontFace(cssString) ⇒ Based on the given font-face value in the passed cssString, tries to either use by default or download the requested font-face for use by the text object.
Kind: instance method of TextSystem
Returns: object
- - json object respresenting the preloaded font-face
Param | Type | Description |
---|---|---|
cssString | string |
the css string to be parsed for the font-face css value. |
textSystem.setTextObject3DColor(object3D, color, default_color)
Sets the text object3D color.
Kind: instance method of TextSystem
Param | Type | Description |
---|---|---|
object3D | object |
the threejs object representation of the troika textt to be colored |
color | string |
the string representation of the color in rgba, hex, or name (‘red’) form |
default_color | string |
fallback color used if the system does not understand the color parameter. Defaults to black. |