SgText

Renders 3D text in the scene, with configurable font, size, color, and alignment. Can be used for labels, signs, UI elements, or debug output. Supports dynamic text updates and integration into world or screen space.

Inherits from

Usage

To use this class, add the following require at the top of your script:

local SgText = require 'engine/sceneobjects/sgtext'

Reference

class SgText
module:
create(options, parent)

Create a new text object in the scenegraph.

Parameters:
  • options (table) – A table of options to fill the parameters

  • parent (SceneObject) – The parent scene object to add this to

Returns:

a promise which will resolve to the created object

Return type:

Promise

Usage:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
-- Options can be omitted. This example shows the defaults,
-- only specify the ones you want different.
SgText:create({
    active = true,
    name = "",
    transform = Transform.new(),
    layers = {0},
    tags = {},
    receiveShadow = false,
    castShadow = false,
    material = nil,
    text = "SgText",
    font = nil,
    size = 1,
    height = 1,
    curveSegments = 12,
    bevelEnabled = false,
    bevelThickness = 0.1,
    bevelSize = 0.03,
    bevelOffset = 0,
    BevelSegments = 3
})

Examples