SgLightsource

Reference

class LightType

Enumeration of the available lightsource types

Name

Description

Point

point light

Directional

directional light

Ambient

ambient light

Hemisphere

hemisphere light

Spot

spot light

class ShadowSize

Enumeration of the available shadow sizes

Name

Description

x128

128 x 128 pixels

x256

256 x 256 pixels

x512

512 x 512 pixels

x1024

1024 x 1024 pixels

x2048

2048 x 2048 pixels

class SgLightsource
module:
create(options, parent)

Create a new lightsource 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
-- Options can be omitted. This example shows the defaults,
-- only specify the ones you want different.
SgLightsource:create({
    active = true,
    name = "",
    transform = Transform.new(),
    layers = {0},
    tags = {},
    castShadows = false,
    type = SgLightsource.LightType.Point,
    color = Color.new(255, 255, 255),
    groundColor = Color.new(64, 64, 64),
    intensity = 1,
    distance = 100,
    decay = 2,
    angle = 0.5,
    penumbra = 0,
    shadowBias = 0,
    shadowSize = SgLightsource.ShadowSize.x512
})
fromObject(obj)

Create a lightsource object from another scene object

Parameters:

obj (SceneObject) – The scene object to convert

fromHandle(handle, nodeId)

create a lightsource object from a handle. Used internally.

Parameters:
  • handle (number)

  • nodeId (str)

Returns:

result object

Return type:

SgLightsource

Examples