new Text( [config])
Creates a new text render object.
Parameters:
| Name | Type | Argument | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
object |
<optional> |
An optional configuration object. |
||||||||||||||||||||||||
Properties of
|
|||||||||||||||||||||||||||
| Name | Type | Argument | Description |
|---|---|---|---|
font |
PD.Font |
<optional> |
An optional font to use instead of the global default. |
align |
PD.ALIGN |
<optional> |
The alignment of the text relative to the anchor position. |
position |
THREE.Vector3 |
<optional> |
The anchor position of the text, in model coordinates. |
quaternion |
THREE.Quaternion |
<optional> |
The quaternion to use when rotating the text. |
scale |
THREE.Vector3 |
<optional> |
The scale of the text in each axis. |
Members
-
:PD.Font
font
-
The font to render the text in.
Type
-
:boolean
hasChanged
-
Whether or not the text needs updating.
Type
- boolean
Methods
-
align(align)
-
Sets the alignment of the text relative to its anchor position.
Parameters:
Name Type Description alignPD.ALIGN The new alignment to apply.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
copyToMeshBuilder(builder, text)
-
Renders the given text to the given mesh.
Parameters:
Name Type Description builderPD.MeshBuilder The mesh builder to add the glyph data to.
textstring The text to render and add to the mesh.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
copyToPolyMesh(mesh, text)
-
Renders the given text to the given mesh.
Parameters:
Name Type Description meshPD.Mesh The dynamic mesh to add the text to.
textstring The text to render and add to the mesh.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
copyToPolyMeshInLocalCoords(mesh, text, coords)
-
Renders the given text to the given mesh using the given local coordinates.
Parameters:
Name Type Description meshPD.Mesh The dynamic mesh to add the text to.
textstring The text to render and add to the mesh.
coordsPD.LocalCoordinates The local coordinate system to use.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
copyToShell(mesh, text, coords)
-
Renders the given text to the given mesh using the given local coordinates.
Parameters:
Name Type Description meshPD.Mesh The dynamic mesh to add the text to.
textstring The text to render and add to the mesh.
coordsPD.LocalCoordinates The local coordinate system to use.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
getTextHeight(text)
-
Calculates the height of the widest line in the text, in model units.
This method simply calculates the font line height for the given text and multiplies it by the current text size.
Parameters:
Name Type Description textstring A single or multi-line text string to compute the height of.
Returns:
Returns the total line height in model units.
- Type
- number
-
getTextWidth(text)
-
Calculates the width of the widest line in the text, in model units.
This method simply calculates the font line width for the given text and multiplies it by the current text size.
Parameters:
Name Type Description textstring A single or multi-line text string to compute the width of.
Returns:
Returns the total line width in model units.
- Type
- number
-
offset(x, y, z)
-
Adjusts the position of the text by the given vector.
This method also allows the use of a
THREE.Vector3or [x,y,z] vector array as a single argument.Parameters:
Name Type Description xnumber The X component of the text position, in model units.
ynumber The Y component of the text position, in model units.
znumber The Z component of the text position, in model units.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
offsetY(dist)
-
Adjusts the vertical position of the text by the given amount.
Parameters:
Name Type Description distnumber The Y offset of the text position, in model units.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
orientation(x [, y] [, z])
-
Sets the orientation vector of the text baseline.
This method also allows the use of a
THREE.Vector3or [x,y,z] vector array as a single argument.Parameters:
Name Type Argument Description xTHREE.Vector3 | number A vector or the X component of the orientation.
ynumber <optional>
The Y component of the orientation.
znumber <optional>
The Z component of the orientation.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
position(x [, y] [, z])
-
Sets the anchor position of the text within the model.
This method also allows the use of a
THREE.Vector3or [x,y,z] coordinate array as a single argument.Parameters:
Name Type Argument Description xTHREE.Vector3 | number A vector or the X component of the text position, in model units.
ynumber <optional>
The Y component of the text position, in model units.
znumber <optional>
The Z component of the text position, in model units.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
reset()
-
Reinitialises the rotation of the text.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
rotate(axis, angle)
-
Applies an additional rotation to the text.
Parameters:
Name Type Description axisTHREE.Vector3 The normalised direction vector.
anglenumber The angle to rotate about the given axis, in radians.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
rotation(axis, angle)
-
Sets the orientation vector of the text.
Parameters:
Name Type Description axisTHREE.Vector3 The normalised direction vector.
anglenumber The angle to rotate about the given axis, in radians.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
scale(x, y, z)
-
Sets the size of the text, in model units.
This method also allows the use of a
THREE.Vector3or [x,y,z] vector array as a single argument.Parameters:
Name Type Description xnumber The X component of the scale.
ynumber The Y component of the scale.
znumber The Z component of the scale.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
size(size)
-
Sets the size of the text, in model units.
This method also allows the use of a
THREE.Vector3or [x,y,z] vector array as a single argument.Parameters:
Name Type Description sizenumber The new size of the text.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text
-
update()
-
Updates the transformation matrix if the size, position or rotation changes.
Returns:
Returns this text instance to support method chaining.
- Type
- PD.Text