For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /server/classes/TextPrimitive.md.

Class: TextPrimitive

Beta

A primitive shape class that represents a text label in the world with a background.

Extends

Constructors

Constructor

new TextPrimitive(location, text): TextPrimitive

Beta

Parameters

location

Vector3 | DimensionLocation

text

string | RawMessage

Returns

TextPrimitive

Overrides

PrimitiveShape.constructor

Properties

attachedTo?

optional attachedTo?: Entity

Beta

Remarks

此形状所依附的实体。设置时,此形状将复制所依附实体的根位置,并且形状的位置将用作偏移量。

The entity this shape is attached to. When set, this shape will copy the root location of the attached entity and the shape's position will be used as an offset.

Inherited from

PrimitiveShape.attachedTo


backfaceVisible

backfaceVisible: boolean

Beta

Remarks

If set to true, the text primitive will render the back-face of the background. Defaults to true but will always be false if 'useRotation' is set to false.


backgroundColorOverride?

optional backgroundColorOverride?: RGBA

Beta

Remarks

The color of the background plate of the text. If set to undefined, it will use the default color.


color

color: RGBA

Beta

Remarks

形状的颜色。

The color of the shape.

Inherited from

PrimitiveShape.color


depthTest

depthTest: boolean

Beta

Remarks

If set to true, the text will be hidden behind blocks or entities. By default this is set to false (will always render).


dimension

readonly dimension: Dimension

Beta

Remarks

形状可见的维度。如果维度为 undefined,则将在所有维度中显示。

The dimension the shape is visible within. If the dimension is undefined, it will display in all dimensions.

Inherited from

PrimitiveShape.dimension


hasDuration

readonly hasDuration: boolean

Beta

Remarks

返回形状是否具有有限的自动移除时间。

Returns true if the shape has a limited time span before being removed.

Inherited from

PrimitiveShape.hasDuration


lineGapHeight

实验性

lineGapHeight: number

Beta

Remarks

This value determines the gap between lines for the TextPrimitive. By default the line gap height is 0.


location

readonly location: Vector3

Beta

Remarks

形状的位置。

The location of the shape.

Inherited from

PrimitiveShape.location


maximumRenderDistance?

optional maximumRenderDistance?: number

Beta

Remarks

如果已定义,此距离将用于确定为每个客户端渲染此图元的远近。默认情况下,距离将匹配客户端的渲染距离设置。

If defined, this distance will be used to determine how far away this primitive will be rendered for each client. By default the distance will match the client's render distance setting.

Minimum Value: 0

Inherited from

PrimitiveShape.maximumRenderDistance


rotation

rotation: Vector3

Beta

Remarks

形状的旋转角度(欧拉角 —— [Pitch, Yaw, Roll])。

The rotation of the shape (Euler angles - [Pitch, Yaw, Roll]).

Inherited from

PrimitiveShape.rotation


scale

scale: number

Beta

Remarks

形状的缩放比例。

The scale of the shape.

Bounds: [-1000, 1000]

Inherited from

PrimitiveShape.scale


text

readonly text: string | RawMessage

Beta

Remarks

Get the text of the debug text shape. Returns the RawText of the debug text if setText was called with a RawMessage or a RawText object, otherwise returns a string.


textBackfaceVisible

textBackfaceVisible: boolean

Beta

Remarks

If set to true, the text primitive will render the back-face of the text. Defaults to true but will always be false if 'useRotation' is set to false.


timeLeft?

optional timeLeft?: number

Beta

Remarks

距离此形状自动移除的剩余时间(以秒为单位)。如果形状没有有限的生存期,则返回 undefined

The time left (in seconds) until this shape is automatically removed. Returns undefined if the shape does not have a limited life-span.

Inherited from

PrimitiveShape.timeLeft


totalTimeLeft?

readonly optional totalTimeLeft?: number

Beta

Remarks

距离此形状自动移除的总初始时间(以秒为单位)。如果形状没有有限的生存期,则返回 undefined

The total initial time-span (in seconds) until this shape is automatically removed. Returns undefined if the shape does not have a limited life-span.

Inherited from

PrimitiveShape.totalTimeLeft


useRotation

useRotation: boolean

Beta

Remarks

If set to true, the text will not face the camera and instead will use the rotation from the shape.


visibleTo

visibleTo: Player[]

Beta

Remarks

此形状对其可见的玩家列表。如果留空,形状将对所有玩家可见。

The list of players that this shape will be visible to. If left empty, the shape will be visible to all players.

Inherited from

PrimitiveShape.visibleTo

Methods

remove()

remove(): void

Beta

Returns

void

Remarks

从世界中移除此形状。可以通过 PrimitiveShapesManager 的 addText 方法重新添加该形状。

Removes this shape from the world. The shape can be re-added via the PrimitiveShapesManager's addText method.

Inherited from

PrimitiveShape.remove


setLocation()

setLocation(location): void

Beta

Parameters

location

Vector3 | DimensionLocation

Returns

void

Remarks

设置形状的位置和维度。如果维度为 undefined,则将在所有维度中显示。

Set the location and dimension of the shape. If the dimension is undefined, it will display in all dimensions.

Inherited from

PrimitiveShape.setLocation


setText()

setText(text): void

Beta

Parameters

text

string | RawMessage

Returns

void

Remarks

Sets the text to display.

Throws

This function can throw errors.

ArgumentOutOfBoundsError

RawMessageError