Last updated

API / geotoolkit3d / scene / Text2d / Text2d

Class: Text2d

scene.Text2d.Text2d

This class implements text as a 2D sprite.
A 2D text is a text that will always face the camera and that is horizontal.
Internally it uses a texture created using a regular canvas.

It also offers a 'fixed size' mode that force the text to be always the same size on screen.
Note that this mode introduces some blurriness as the texture is rescaled by the graphic card on the fly.
If outline is set, the original font style might be overwritten.

Hierarchy

  • Sprite

    Text2d

Table of contents

Constructors
[new Text2d(text, options)](/solutions/geotoolkit/apis/classes/geotoolkit3d.scene-3.text2d.text2d.md#new text2d(text, options))[new Text2d(textOrOptions)](/solutions/geotoolkit/apis/classes/geotoolkit3d.scene-3.text2d.text2d.md#new text2d(textoroptions))
Methods

Contents

Constructors

new Text2d(text, options)

new Text2d(text?, options?)

Parameters

Name Type Description
Optional textstringtext to display
Optional optionsOptionsoptions for Text2d

Overrides

Sprite.constructor


new Text2d(textOrOptions)

new Text2d(textOrOptions?)

Create a Text2d

Parameters

Name Type Description
Optional textOrOptionsstring | Optionstext to display or options for Text2d

Overrides

Sprite.constructor

Methods

dispose

dispose(): void

Dispose this object

Returns

void


getText

getText(): string

Gets text

Returns

string


getTextStyle

getTextStyle(): TextStyle

Gets text style

Returns

TextStyle


isDisposed

isDisposed(): boolean

Returns

boolean


setAnchorOffset

setAnchorOffset(offset): Text2d

The given xyz vector will be used when computing the text location after scaling.
It will be added to the offset value.

finalPosition = position + anchorOffsetRatio * (sizeInDevice/2 + offsetInDevice)

Parameters

Name Type Description
offsetVector2The anchor offset in device to be applied when computing offset

Returns

Text2d

this


setAnchorOffsetRatio

setAnchorOffsetRatio(ratio): Text2d

The given xyz vector will be used when computing the text location after scaling.
It will translate the text in the given direction by half the text size.

finalPosition = position + anchorOffsetRatio * (sizeInDevice/2 + offsetInDevice)

Parameters

Name Type Description
ratioVector3The anchor offset factor to be applied when computing offset

Returns

Text2d

this


setOutline

setOutline(outlineOpt): void

Set text outline, or disable outline.

Parameters

Name Type Description
outlineOptOutlineOptionsoutline options

Returns

void


setText

setText(text): Text2d

Sets text

Parameters

Name Type Description
textstringtext

Returns

Text2d

this


setTextStyle

setTextStyle(textStyle, merge?): Text2d

Sets text style

Parameters

Name Type Description
textStyleTypetext style
Optional mergebooleantrue if you want to merge textStyle with existing attribute, false by default

Returns

Text2d

this