Text component

Text

2024.1.26

yisky

Hierarchy

  • Renderer
    • Text

Constructors

  • Parameters

    Returns Text

Properties

_awoken: boolean
_bounds: Box3
_boundsUpdateFlag: BoolUpdateFlag
_enabled: boolean
_object3D: Object3D<Object3DEventMap>
_onAfterRender: ((renderer: WebGLRenderer, scene: Scene, camera: Camera, geometry: BufferGeometry<NormalBufferAttributes>, material: Material, group: Group<Object3DEventMap>) => void)
_onBeforeRender: ((renderer: WebGLRenderer, scene: Scene, camera: Camera, geometry: BufferGeometry<NormalBufferAttributes>, material: Material, group: Group<Object3DEventMap>) => void)
_renderOrder: RenderOrder
entity: Entity
isRenderer: boolean

Renderer flag

Renderer

queryMask: QueryMask

Query mask

Renderer

userData: {
    [key: string]: any;
}

Component user data

Component

Accessors

  • set anchorX(value): void
  • Defines the horizontal position in the text block that should line up with the local origin. Can be specified as a numeric x position in local units, a string percentage of the total text block width e.g. '25%', or one of the following keyword strings: 'left', 'center', or 'right'.

    Parameters

    • value: string | number

    Returns void

    Text

  • set anchorY(value): void
  • Defines the vertical position in the text block that should line up with the local origin. Can be specified as a numeric y position in local units (note: down is negative y), a string percentage of the total text block height e.g. '25%', or one of the following keyword strings: 'top', 'top-baseline', 'top-cap', 'top-ex', 'middle', 'bottom-baseline', or 'bottom'.

    Parameters

    • value: string | number

    Returns void

    Text

  • set clipRect(value): void
  • If specified, defines a [minX, minY, maxX, maxY] of a rectangle outside of which all pixels will be discarded. This can be used for example to clip overflowing text when whiteSpace='nowrap'.

    Parameters

    • value: number[]

    Returns void

    Text

  • set color(value): void
  • This is a shortcut for setting the color of the text's material. You can use this if you don't want to specify a whole custom material. Also, if you do use a custom material, this color will only be used for this particuar Text instance, even if that same material instance is shared across multiple Text objects.

    Parameters

    • value: ColorRepresentation

    Returns void

    Text

  • set curveRadius(value): void
  • Defines a cylindrical radius along which the text's plane will be curved. Positive numbers put the cylinder's centerline (oriented vertically) that distance in front of the text, for a concave curvature, while negative numbers put it behind the text for a convex curvature. The centerline will be aligned with the text's local origin; you can use anchorX to offset it.

    Since each glyph is by default rendered with a simple quad, each glyph remains a flat plane internally. You can use glyphGeometryDetail to add more vertices for curvature inside glyphs.

    Parameters

    • value: number

    Returns void

    Text

  • set depthOffset(value): void
  • This is a shortcut for setting the material's polygonOffset and related properties, which can be useful in preventing z-fighting when this text is laid on top of another plane in the scene. Positive numbers are further from the camera, negatives closer.

    Parameters

    • value: number

    Returns void

    Text

  • set direction(value): void
  • Sets the base direction for the text. The default value of "auto" will choose a direction based on the text's content according to the bidi spec. A value of "ltr" or "rtl" will force the direction.

    Parameters

    • value: string

    Returns void

    Text

  • get enabled(): boolean
  • Indicates whether the component is enabled.

    Returns boolean

    Component

  • set enabled(value): void
  • Set whether the component is enabled.

    Parameters

    • value: boolean

    Returns void

    Component

  • set fillOpacity(value): void
  • WARNING: This API is experimental and may change. The opacity of the glyph's fill from 0 to 1. This behaves like the material's opacity but allows giving the fill a different opacity than the strokeOpacity. A fillOpacity of 0 makes the interior of the glyph invisible, leaving just the strokeWidth. Defaults to 1.

    Parameters

    • value: number

    Returns void

    Text

  • set font(value): void
  • URL of a custom font to be used. Font files can be in .ttf, .otf, or .woff (not .woff2) formats. Defaults to Noto Sans.

    Parameters

    • value: string

    Returns void

    Text

  • set fontSize(value): void
  • The size at which to render the font in local units; corresponds to the em-box height of the chosen font.

    Parameters

    • value: number

    Returns void

    Text

  • set fontStyle(value): void
  • The style of the font. Currently only used for fallback Noto fonts.

    Parameters

    • value: "normal" | "italic"

    Returns void

    Text

  • set fontWeight(value): void
  • The weight of the font. Currently only used for fallback Noto fonts.

    Parameters

    • value: number | "normal" | "bold"

    Returns void

    Text

  • set letterSpacing(value): void
  • Sets a uniform adjustment to spacing between letters after kerning is applied. Positive numbers increase spacing and negative numbers decrease it.

    Parameters

    • value: number

    Returns void

    Text

  • set lineHeight(value): void
  • Sets the height of each line of text, as a multiple of the fontSize. Defaults to 'normal' which chooses a reasonable height based on the chosen font's ascender/descender metrics.

    Parameters

    • value: number

    Returns void

    Text

  • get material(): Readonly<Material>
  • Get material

    Returns Readonly<Material>

    Text

  • set material(value): void
  • Defines a base material to be used when rendering the text. This material will be automatically replaced with a material derived from it, that adds shader code to decrease the alpha for each fragment (pixel) outside the text glyphs, with antialiasing. By default it will derive from a simple white MeshBasicMaterial, but you can use any of the other mesh materials to gain other features like lighting, texture maps, etc.

    Also see the color shortcut property.

    Parameters

    • value: Material

    Returns void

    Text

  • set maxWidth(value): void
  • The maximum width of the text block, above which text may start wrapping according to the whiteSpace and overflowWrap properties.

    Parameters

    • value: number

    Returns void

    Text

  • get object3D(): Object3D<Object3DEventMap> | Object3D<Object3DEventMap>[]
  • Get three.js native object3D

    Returns Object3D<Object3DEventMap> | Object3D<Object3DEventMap>[]

    Renderer

  • set outlineBlur(value): void
  • WARNING: This API is experimental and may change. A blur radius applied to the outer edge of the text's outline. If the outlineWidth is zero, the blur will be applied at the glyph edge, like CSS's text-shadow blur radius. Can be specified as either an absolute number in local units, or as a percentage string e.g. "12%" which is treated as a percentage of the fontSize. Defaults to 0.

    Parameters

    • value: string | number

    Returns void

    Text

  • set outlineColor(value): void
  • WARNING: This API is experimental and may change. The color of the text outline, if outlineWidth/outlineBlur/outlineOffsetX/Y are set. Defaults to black.

    Parameters

    • value: ColorRepresentation

    Returns void

    Text

  • set outlineOffsetX(value): void
  • WARNING: This API is experimental and may change. A horizontal offset for the text outline. Can be specified as either an absolute number in local units, or as a percentage string e.g. "12%" which is treated as a percentage of the fontSize. Defaults to 0.

    Parameters

    • value: string | number

    Returns void

    Text

  • set outlineOffsetY(value): void
  • WARNING: This API is experimental and may change. A vertical offset for the text outline. Can be specified as either an absolute number in local units, or as a percentage string e.g. "12%" which is treated as a percentage of the fontSize. Defaults to 0.

    Parameters

    • value: string | number

    Returns void

    Text

  • set outlineOpacity(value): void
  • WARNING: This API is experimental and may change. The opacity of the outline, if outlineWidth/outlineBlur/outlineOffsetX/Y are set. Defaults to 1.

    Parameters

    • value: number

    Returns void

    Text

  • set outlineWidth(value): void
  • WARNING: This API is experimental and may change. The width of an outline/halo to be drawn around each text glyph using the outlineColor and outlineOpacity. Can be specified as either an absolute number in local units, or as a percentage string e.g. "12%" which is treated as a percentage of the fontSize. Defaults to 0, which means no outline will be drawn unless an outlineOffsetX/Y or outlineBlur is set.

    Parameters

    • value: string | number

    Returns void

    Text

  • set overflowWrap(value): void
  • Defines how text wraps if the whiteSpace property is normal. Can be either 'normal' to break at whitespace characters, or 'break-word' to allow breaking within words. Defaults to 'normal'.

    Parameters

    • value: string

    Returns void

    Text

  • get position(): Vector3
  • Get local position

    Returns Vector3

    Renderer

  • set position(position): void
  • Set local position

    Parameters

    • position: Vector3

    Returns void

    Renderer

  • get quaternion(): Quaternion
  • Get local quaternion

    Returns Quaternion

    Renderer

  • set quaternion(quaternion): void
  • Set local quaternion

    Parameters

    • quaternion: Quaternion

    Returns void

    Renderer

  • get renderOrder(): RenderOrder
  • Get render order

    Returns RenderOrder

    Renderer

  • set renderOrder(value): void
  • Set render order

    Parameters

    • value: RenderOrder

    Returns void

    Renderer

  • get rotation(): Euler
  • Get local rotation

    Returns Euler

    Renderer

  • set rotation(rotation): void
  • Set local rotation

    Parameters

    • rotation: Euler

    Returns void

    Renderer

  • get scale(): Vector3
  • Get local scale

    Returns Vector3

    Renderer

  • set scale(scale): void
  • Set local scale

    Parameters

    • scale: Vector3

    Returns void

    Renderer

  • get scene(): Scene
  • Scene own the component

    Returns Scene

    Component

  • set strokeColor(value): void
  • WARNING: This API is experimental and may change. The color of the text stroke, if strokeWidth is greater than zero. Defaults to gray.

    Parameters

    • value: ColorRepresentation

    Returns void

    Text

  • set strokeOpacity(value): void
  • WARNING: This API is experimental and may change. The opacity of the stroke, if strokeWidth is greater than zero. Defaults to 1.

    Parameters

    • value: number

    Returns void

    Text

  • set strokeWidth(value): void
  • WARNING: This API is experimental and may change. The width of an inner stroke drawn inside each text glyph using the strokeColor and strokeOpacity. Can be specified as either an absolute number in local units, or as a percentage string e.g. "12%" which is treated as a percentage of the fontSize. Defaults to 0.

    Parameters

    • value: string | number

    Returns void

    Text

  • set text(value): void
  • The string of text to be rendered.

    Parameters

    • value: string

    Returns void

    Text

  • set textAlign(value): void
  • The horizontal alignment of each line of text within the overall text bounding box.

    Parameters

    • value: string

    Returns void

    Text

  • set textIndent(value): void
  • Indentation for the first character of a line; see CSS text-indent.

    Parameters

    • value: number

    Returns void

    Text

  • set visible(value): void
  • Set whether visible

    Parameters

    • value: boolean

    Returns void

    Renderer

  • set whiteSpace(value): void
  • Defines whether text should wrap when a line reaches the maxWidth. Can be either 'normal' (the default), to allow wrapping according to the overflowWrap property, or 'nowrap' to prevent wrapping. Note that 'normal' here honors newline characters to manually break lines, making it behave more like 'pre-wrap' does in CSS.

    Parameters

    • value: string

    Returns void

    Text

  • get worldBounds(): Readonly<Box3>
  • Get renderer world bounds

    Returns Readonly<Box3>

    Renderer

Methods

  • Protected

    Attach renderer to scene

    Returns void

    Renderer

  • Protected

    Destroy

    Returns void

    Text

  • Protected

    Detach renderer from scene

    Returns void

    Renderer

  • Protected

    Awake component callback

    Returns void

    Component

  • Protected

    Destroy callback

    Returns void

    Renderer

  • Protected

    Disable callback

    Returns void

    Renderer

  • Protected

    Enable callback

    Returns void

    Renderer

  • Protected

    Update renderer component render order

    Returns void

    Renderer

  • Protected

    Update renderer component world bounds

    Returns void

    Renderer

  • Protected

    Update renderer component world matrix

    Returns void

    Renderer

  • After camera render

    Parameters

    • camera: Camera

    Returns void

    Renderer

  • Before camera render

    Parameters

    • camera: Camera

      the camera use to render

    Returns void

    Renderer

  • Destroy component

    Returns void

    Component

  • Clear subscribers

    Returns void

    EventDispatcher

  • Emit event

    Parameters

    • event: {
          type: string;
          [key: string]: any;
      }
      • [key: string]: any
      • type: string

    Returns void

    EventDispatcher

  • Returns a vector representing the direction of transform's positive z-axis in world space.

    Parameters

    • target: Vector3

      The result will be copied into this Vector3.

    Returns Vector3

    Renderer

  • Returns a vector representing the position of the transforms in world space.

    Parameters

    • target: Vector3

      The result will be copied into this Vector3

    Returns Vector3

    Renderer

  • Returns a quaternion representing the rotation of the transform in world space.

    Parameters

    • target: Quaternion

      The result will be copied into this Quaternion.

    Returns Quaternion

    Renderer

  • Returns a vector of the scaling factors applied to the transform for each axis in world space.

    Parameters

    • target: Vector3

      The result will be copied into this Vector3

    Returns Vector3

    Renderer

  • Converts the vector from this object's local space to world space.

    Parameters

    • vector: Vector3

      A vector representing a position in this object's local space.

    Returns Vector3

    Renderer

  • Rotates the object to face a point in world space.

    Parameters

    • target: Vector3

      A vector representing a position in world space to look at.

    Returns void

    Renderer

  • Unsubscribe a event, if the callback param is not defined, all subscribers of this type will be removed.

    Parameters

    • type: string
    • Optionalcallback: SubscriberCallbackFn

      subscriber callback

    Returns void

    EventDispatcher

  • Subscribe a event

    Parameters

    • type: string

      event type

    • callback: SubscriberCallbackFn

      callback functions

    • Optionaloptions: {
          priority?: Priority;
          target?: any;
      }

      options

      • Optionalpriority?: Priority
      • Optionaltarget?: any

    Returns void

    EventDispatcher

  • Subscribe a event, just emit once

    Parameters

    • type: string
    • callback: SubscriberCallbackFn

      subscriber callback

    • Optionaloptions: {
          priority?: Priority;
          target?: any;
      }
      • Optionalpriority?: Priority
      • Optionaltarget?: any

    Returns void

    EventDispatcher

  • Raycast

    Parameters

    • raycaster: Raycaster

    Returns Intersection<Object3D<Object3DEventMap>>

    Text

  • Batch update attributes

    Parameters

    Returns void

    Text

  • Set renderer's transformation

    Parameters

    • transformation: Transformation

    Returns void

    Renderer

  • Renderer component frame update

    Parameters

    • timeSinceLastFrame: number

      time since last frame in seconds

    • totalTime: number

      total time in seconds

    Returns void

    Renderer

  • Update world matrix

    Returns void

    Renderer

  • Converts the vector from world space to this object's local space.

    Parameters

    • vector: Vector3

      A vector representing a position in world space.

    Returns Vector3

    Renderer