SgLightsource¶
Represents a light-emitting object in the scene, such as a directional, point, or spot light. Affects how nearby objects are lit, casting shadows and influencing material appearance. Supports adjustable intensity, color, range, and falloff based on light type.
Inherits from¶
Usage¶
To use this class, add the following require at the top of your script:
local SgLightsource = require 'engine/sceneobjects/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 parametersparent (
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 })