API / geotoolkit3d / scene / Text2d / Text2d
This class implements text as a 2D sprite.<br> A 2D text is a text that will always face the camera and that is horizontal.<br> Internally it uses a texture created using a regular canvas.<br> <br> It also offers a 'fixed size' mode that force the text to be always the same size on screen.<br> Note that this mode introduces some blurriness as the texture is rescaled by the graphic card on the fly.<br> If outline is set, the original font style might be overwritten.
Sprite↳
Text2d
Constructors
| [new Text2d(text, options)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit3d.scene-3.text2d.text2d.md#new text2d(text, options)) | [new Text2d(textOrOptions)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit3d.scene-3.text2d.text2d.md#new text2d(textoroptions)) |
|---|
Methods
Constructors
• new Text2d(text?, options?)
| Name | Type | Description |
|---|---|---|
Optional text | string | text to display |
Optional options | Options | options for Text2d |
Sprite.constructor
• new Text2d(textOrOptions?)
Create a Text2d
| Name | Type | Description |
|---|---|---|
Optional textOrOptions | string | Options | text to display or options for Text2d |
Sprite.constructor
Methods
▸ dispose(): void
Dispose this object
void
▸ getText(): string
Gets text
string
▸ getTextStyle(): TextStyle
Gets text style
▸ isDisposed(): boolean
boolean
▸ setAnchorOffset(offset): Text2d
The given xyz vector will be used when computing the text location after scaling.<br> It will be added to the offset value.<br>
finalPosition = position + anchorOffsetRatio * (sizeInDevice/2 + offsetInDevice)
| Name | Type | Description |
|---|---|---|
offset | Vector2 | The anchor offset in device to be applied when computing offset |
this
▸ setAnchorOffsetRatio(ratio): Text2d
The given xyz vector will be used when computing the text location after scaling.<br> It will translate the text in the given direction by half the text size.<br>
finalPosition = position + anchorOffsetRatio * (sizeInDevice/2 + offsetInDevice)
| Name | Type | Description |
|---|---|---|
ratio | Vector3 | The anchor offset factor to be applied when computing offset |
this
▸ setOutline(outlineOpt): void
Set text outline, or disable outline.
| Name | Type | Description |
|---|---|---|
outlineOpt | OutlineOptions | outline options |
void
▸ setText(text): Text2d
Sets text
| Name | Type | Description |
|---|---|---|
text | string | text |
this
▸ setTextStyle(textStyle, merge?): Text2d
Sets text style
| Name | Type | Description |
|---|---|---|
textStyle | Type | text style |
Optional merge | boolean | true if you want to merge textStyle with existing attribute, false by default |
this