Text3D
ClassRenders 3D text with specific style, layout and material.
- Available on all platforms
Since Lens Scripting v159
Index
Properties
- capitalizationOverride
- debugRenderLayoutRect
- editable
- enableBatching
- enabled
- enableRichText
- extentsTarget
- extrudeDirection
- extrusionDepth
- font
- fontSource
- horizontalAlignment
- horizontalOverflow
- isBeingDestroyed
- isEnabledInHierarchy
- italic
- layoutRect
- letterSpacing
- lineSpacing
- mainMaterial
- mainPass
- mainPassOverrides
- materials
- meshShadowMode
- onEditingFinished
- onEditingStarted
- onEditingUpdated
- preferredStyle
- propertyOverrides
- renderOrder
- sceneObject
- shadowColor
- shadowDensity
- showEditingPreview
- size
- sizeToFit
- stretchMode
- text
- touchHandler
- uniqueIdentifier
- verticalAlignment
- verticalOverflow
- weight
Methods
Extends
Properties
capitalizationOverride
capitalizationOverride:
CapitalizationOverride
Overrides the capitalization of the text rendered.
Since
Lens Scripting Version 385
Default Value
CapitalizationOverride.None
Example
// @input Component.Text3D text3d
script.text3d.capitalizationOverride = CapitalizationOverride.AllLower;
debugRenderLayoutRect
debugRenderLayoutRect:
boolean
If enabled, draws the Text3D#layoutRect bounds as a wireframe for debugging text layout. Has no effect when a ScreenTransform is attached to the same SceneObject, since the ScreenTransform supersedes the layoutRect.
Since
Lens Scripting Version 364
Default Value
false
editable
editable:
boolean
Makes the Text component editable. When this is enabled the Text can be clicked to open up the device keyboard and edit the contents.
Since
Lens Scripting Version 165
Default Value
false
enableBatching
enableBatching:
boolean
Optimizes Text3D by combining glyph meshes.
Since
Lens Scripting Version 303
Default Value
false
enabled
enabled:
boolean
If disabled, the Component will stop enacting its behavior.
Default Value
true
Inherited from
enableRichText
enableRichText:
boolean
If enabled, inputted text will be interpreted as rich text. For more info, see Rich Text.
Since
Lens Scripting Version 356
Default Value
false
extentsTarget
extentsTarget:
ScreenTransform
When a ScreenTransform is present on this SceneObject,
and extentsTarget is a child of this SceneObject, extentsTarget will be repositioned to match the exact
area this MeshVisual is being rendered. Very useful for Image and Text components.
Default Value
null
Inherited from
MaterialMeshVisual.extentsTarget
extrudeDirection
extrudeDirection:
Text3DExtrudeDirection
Starting from the Text3D's local position control whether the meshes are extruded forwards, backwards, or both directions
Since
Lens Scripting Version 159
Default Value
Text3DExtrudeDirection.Both
extrusionDepth
extrusionDepth:
number
How deep the text meshes should be relative to the line height. 0-1 portion of the basic height which will be used for mesh depth. Values > 1 are valid.
Since
Lens Scripting Version 159
Default Value
0.4
font
font:
Font
Font asset used.
Setting this will override any existing Font, FontFamily, or FontCollection asset assigned as the font source of the text component. If there is a FontFamily or FontCollection asset currently assigned as the font source, reading this will return null.
Since
Lens Scripting Version 159
Default Value
null
fontSource
fontSource:
Font|FontFamily|FontCollection
The font source for this text component. Can be a Font, FontFamily, or FontCollection asset.
Since
Lens Scripting Version 356
Default Value
null
horizontalAlignment
horizontalAlignment:
HorizontalAlignment
When a ScreenTransform is attached to the same SceneObject, this controls how the mesh will be positioned horizontally depending on stretchMode.
Default Value
HorizontalAlignment.Center
Inherited from
MaterialMeshVisual.horizontalAlignment
horizontalOverflow
horizontalOverflow:
HorizontalOverflow
Controls how text should be handled when it goes past the horizontal boundaries defined by ScreenTransform or Text#layoutRect, with the former taking precedence.
Since
Lens Scripting Version 159
Default Value
HorizontalOverflow.Overflow
isBeingDestroyed
readonlyisBeingDestroyed:boolean
Returns true if this Component is currently being destroyed. Becomes true as soon as
destruction begins via Component#destroy or destruction of its owning SceneObject,
before any OnDestroyEvent callbacks fire.
Since
Lens Scripting Version 364
Example
if (!script.isBeingDestroyed) {
// Component is still fully alive
}
Inherited from
MaterialMeshVisual.isBeingDestroyed
isEnabledInHierarchy
readonlyisEnabledInHierarchy:boolean
Returns true if this Component, its SceneObject, and all of that SceneObjects parents are enabled.
Inherited from
MaterialMeshVisual.isEnabledInHierarchy
italic
italic:
boolean
If enabled, the rendered text will try to use an italic font style.
When assigned as null, the italic axis from Text3D.preferredStyle is used instead. When explicitly assigned, Text3D.italic overrides any italic value in Text3D.preferredStyle.
Since
Lens Scripting Version 325
Default Value
null
layoutRect
layoutRect:
Rect
The rectangular bounds the text is laid out within. Controls text wrapping and alignment, and defines the area Text3D#horizontalOverflow, Text3D#verticalOverflow, and Text3D#sizeToFit are evaluated against.
Each bound is defined as an offset in world units from the SceneObject's position.
If a ScreenTransform is attached to the same SceneObject, it always supersedes this property — text is laid out within the ScreenTransform's rect instead, and changes to layoutRect have no effect.
Since
Lens Scripting Version 364
Default Value
Rect.create(-7.5, 7.5, -2.25, 2.25)
letterSpacing
letterSpacing:
number
Modifies the spacing between letters. A value of 0 uses the font’s normal letter spacing. Negative values will remove space between letters, and positive values will add more space between letters.
Since
Lens Scripting Version 159
Default Value
0
lineSpacing
lineSpacing:
number
Modifies the vertical spacing between lines, as a multiple of lines. 1 will be single spacing, 2 will be double spaced, and 0.5 would be half the normal line height.
Since
Lens Scripting Version 159
Default Value
1
mainMaterial
mainMaterial:
Material
Returns the first Material.
Since
Lens Scripting Version 304
Default Value
null
Inherited from
MaterialMeshVisual.mainMaterial
mainPass
mainPass:
Pass
Returns the mainPass of the mainMaterial.
Since
Lens Scripting Version 304
Default Value
null
Inherited from
materials
materials:
Material[]
Get the array of materials used by the MaterialMeshVisual.
Since
Lens Scripting Version 304
Default Value
[]
Inherited from
meshShadowMode
meshShadowMode:
MeshShadowMode
None = 0, Caster = 1, Receiver = 2
Default Value
MeshShadowMode.None
Inherited from
MaterialMeshVisual.meshShadowMode
onEditingFinished
readonlyonEditingFinished:event1<string,void>
This event will notify you when the user finishes editing the text.
Since
Lens Scripting Version 159
onEditingStarted
readonlyonEditingStarted:event0<void>
This event will notify you when the user starts typing.
Since
Lens Scripting Version 159
onEditingUpdated
readonlyonEditingUpdated:event1<string,void>
This event will notify you on every edit to the text while the user is typing.
Since
Lens Scripting Version 159
preferredStyle
preferredStyle:
string
Controls style applied to the text. Accepts a FontStyles constant (e.g. FontStyles.Bold). If Text3D.fontSource is assigned to a variable font or a font collection with variable fonts, this also accepts a named instance name or custom variation style name that belongs to the variable font.
Matching is case-insensitive and ignores whitespace and hyphens, so "Bold Italic",
"bolditalic", and "bold-italic" all resolve to the same style.
If Text3D.weight or Text3D.italic are explicitly assigned, they will override any weight or italic axis value in preferredStyle.
Since
Lens Scripting Version 372
Default Value
FontStyles.Regular
propertyOverrides
readonlypropertyOverrides:PropertyOverrides
Overrides the property on the material, without affecting other visuals referencing the same material. See PropertyOverrides.
Since
Lens Scripting Version 304
Inherited from
MaterialMeshVisual.propertyOverrides
renderOrder
renderOrder:
number
The order in which the visual should be rendered.
Since
Lens Scripting Version 323
Default Value
0
Inherited from
MaterialMeshVisual.renderOrder
sceneObject
readonlysceneObject:SceneObject
The SceneObject this component is on.
Inherited from
MaterialMeshVisual.sceneObject
shadowColor
shadowColor:
vec4
Affects the color of shadows being cast by this MeshVisual. The color of the cast shadow is a mix between shadowColor and the material's base texture color. The alpha value of shadowColor controls the mixing of these two colors, with 0 = shadowColor and 1 = shadowColor * textureColor.
Default Value
(1, 1, 1, 1)
Inherited from
MaterialMeshVisual.shadowColor
shadowDensity
shadowDensity:
number
Density of shadows cast by this MeshVisual.
Default Value
1
Inherited from
MaterialMeshVisual.shadowDensity
showEditingPreview
showEditingPreview:
boolean
Use this property to control whether to show the input preview the keyboard. Note this preview also enables cursor movement.
Since
Lens Scripting Version 170
Default Value
true
size
size:
number
Font size used. Minimum of 2.0 and maximum of 800.0.
size sets the em square height of the rendered text.
In world space, the em square height in centimeters is size / 43.886,
so the default size of 48 produces an em square ~1.09 cm tall.
Under a Canvas in Pixels or Points mode, Text scales as though
the camera's orthographic size were the default 20 cm regardless of the
actual camera size. The em square is renderTargetHeightPoints * size / 877.71
points tall — about 39 points for the default size of 48 on a
render target 720 points tall. The pixel form is the same expression
with the render target height in pixels.
Since
Lens Scripting Version 159
Default Value
48
sizeToFit
sizeToFit:
boolean
If enabled, the rendered text will always scale to fit the boundaries defined by ScreenTransform or Text#layoutRect, with the former taking precedence.
Since
Lens Scripting Version 159
Default Value
false
stretchMode
stretchMode:
StretchMode
When a ScreenTransform is attached to the same SceneObject, this controls how the mesh will be stretched relative to the ScreenTransform's boundaries.
Default Value
StretchMode.Stretch
Inherited from
MaterialMeshVisual.stretchMode
text
text:
string
Text string to be drawn.
Since
Lens Scripting Version 159
Default Value
""
touchHandler
touchHandler:
InteractionComponent
Use this property to override the touch handling for when to open the device keyboard when the Text is editable.
Since
Lens Scripting Version 165
Default Value
null
uniqueIdentifier
readonlyuniqueIdentifier:string
Since
Lens Scripting Version 176
Inherited from
MaterialMeshVisual.uniqueIdentifier
verticalAlignment
verticalAlignment:
VerticalAlignment
When a ScreenTransform is attached to the same SceneObject, this controls how the mesh will be positioned vertically depending on stretchMode.
Default Value
VerticalAlignment.Center
Inherited from
MaterialMeshVisual.verticalAlignment
verticalOverflow
verticalOverflow:
VerticalOverflow
Controls how text should be handled when it goes past the vertical boundaries defined by ScreenTransform or Text#layoutRect, with the former taking precedence.
Since
Lens Scripting Version 159
Default Value
VerticalOverflow.Overflow
weight
weight:
number
Controls the font weight. Usually a multiple of 100 between 100 and 900 inclusively. Will use closest font weight available on the system.
When assigned as null, the weight axis from Text3D.preferredStyle is used instead. When explicitly assigned, Text3D.weight overrides any weight value in Text3D.preferredStyle.
Since
Lens Scripting Version 325
Default Value
null
Accessors
mainPassOverrides
Get Signature
get mainPassOverrides():
PassPropertyOverrides
Overrides the mainPass on the material, without affecting other visuals referencing the same material. Reads give a PassPropertyOverrides. See PropertyOverrides.
Since
Lens Scripting Version 304
Default Value
{}
Returns
Set Signature
set mainPassOverrides(
value):void
Parameters
| Parameter | Type |
|---|---|
value | PassPropertyOverrides | {[key: string]: any; } |
Returns
void
Inherited from
MaterialMeshVisual.mainPassOverrides
Methods
addMaterial()
addMaterial(
material):void
Adds a Material to use for rendering.
Parameters
| Parameter | Type |
|---|---|
material | Material |
Returns
void
Since
Lens Scripting Version 304
Inherited from
MaterialMeshVisual.addMaterial
clearMaterials()
clearMaterials():
void
Clears all Materials.
Returns
void
Since
Lens Scripting Version 304
Inherited from
MaterialMeshVisual.clearMaterials
destroy()
destroy():
void
Destroys the component.
Returns
void
Inherited from
getBoundingBox()
getBoundingBox(
start?,end?):Rect
Parameters
| Parameter | Type |
|---|---|
start? | number |
end? | number |
Returns
Since
Lens Scripting Version 317
getCursorHeight()
getCursorHeight():
number
Returns the recommended height for a cursor visual, in the same coordinate space as getCursorPositions(). The height is derived from the font size and accounts for scaling (e.g. VerticalOverflow.Shrink or sizeToFit).
Returns
number
Since
Lens Scripting Version 361
getCursorPositions()
getCursorPositions():
CursorPosition[]
Returns a list of cursor positions for each character in the current text. Not supported when rich text is enabled.
Returns
Since
Lens Scripting Version 324
getHighlightRects()
getHighlightRects(
start?,end?):Rect[]
Returns a list of rectangles highlighting the characters in the range from start to end.
Each rectangle covers one contiguous visual run of text within the range, so a single line
with mixed text directions may produce multiple rectangles. The range is inclusive of start
and exclusive of end.
Parameters
| Parameter | Type |
|---|---|
start? | number |
end? | number |
Returns
Rect[]
Since
Lens Scripting Version 362
getMaterial()
getMaterial(
index):Material
Returns the Material at index index.
Parameters
| Parameter | Type |
|---|---|
index | number |
Returns
Since
Lens Scripting Version 304
Inherited from
MaterialMeshVisual.getMaterial
getMaterialsCount()
getMaterialsCount():
number
Returns the number of Materials used for rendering.
Returns
number
Since
Lens Scripting Version 304
Inherited from
MaterialMeshVisual.getMaterialsCount
getRenderOrder()
getRenderOrder():
number
Returns the order of this Visual in the render queue.
Returns
number
Inherited from
MaterialMeshVisual.getRenderOrder
getSceneObject()
getSceneObject():
SceneObject
Returns the SceneObject the component is attached to.
Returns
Inherited from
MaterialMeshVisual.getSceneObject
getTransform()
getTransform():
Transform
Returns the Transform this component is attached to.
Returns
Inherited from
MaterialMeshVisual.getTransform
getTypeName()
staticgetTypeName():TypeName<Text3D>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<Text3D>
Since
Lens Scripting Version 159
Overrides
MaterialMeshVisual.getTypeName
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
MaterialMeshVisual.getTypeName
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
localAabbMax()
localAabbMax():
vec3
Range maximum of the local-space axis-aligned bounding box (AABB) of the visual.
Returns
Since
Lens Scripting Version 156
Inherited from
MaterialMeshVisual.localAabbMax
localAabbMin()
localAabbMin():
vec3
Range minimum of the local-space axis-aligned bounding box (AABB) of the visual.
Returns
Since
Lens Scripting Version 156
Inherited from
MaterialMeshVisual.localAabbMin
setRenderOrder()
setRenderOrder(
value):void
Sets the order of this Visual in the render queue.
Parameters
| Parameter | Type |
|---|---|
value | number |
Returns
void
Inherited from
MaterialMeshVisual.setRenderOrder
snap()
snap(
camera):void
Projects screen positions from camera's view onto the mesh's UVs.
If the MeshVisual's material uses the same texture as the camera input, the MeshVisual will look identical to the part of the screen it covers.
Parameters
| Parameter | Type |
|---|---|
camera | Camera |
Returns
void
Inherited from
split()
split():
RenderMeshVisual[]
Splits the Text3D into individual RenderMeshVisuals. This destroys the Text3D component and you can no longer edit its properties like text.
Returns
Since
Lens Scripting Version 160
worldAabbMax()
worldAabbMax():
vec3
Range maximum of the world-space axis-aligned bounding box (AABB) of the visual.
Returns
Since
Lens Scripting Version 156
Inherited from
MaterialMeshVisual.worldAabbMax
worldAabbMin()
worldAabbMin():
vec3
Range minimum of the world-space axis-aligned bounding box (AABB) of the visual.
Returns
Since
Lens Scripting Version 156
Inherited from
MaterialMeshVisual.worldAabbMin
See also
3D Text guide.