// Create a point light
val light = SceneLight.createPointLight(
position = Vector3(0f, 2f, 0f),
color = Vector3(1f, 0.9f, 0.8f),
intensity = 2.0f,
range = 10f
)
// Create a spot light
val spotlight = SceneLight.createSpotLight(
position = Vector3(0f, 3f, 0f),
color = Vector3(1f, 1f, 1f),
intensity = 5.0f,
range = 15f,
direction = Vector3(0f, -1f, 0f),
spotOuterAngle = 45f,
spotInnerAngle = 30f,
)
// Update light position
light?.update(position = Vector3(1f, 2f, 0f))
// Destroy when done
light?.destroy()
class SceneLight
handle
: Long
[Get] |
Signature
var handle: Long |
destroy
()
|
Destroys this light and removes it from the scene.
After calling this method, SceneLight.isValid will return false and the light will no longer illuminate objects in the scene.
Signature
fun destroy(): Boolean Returns Boolean
true if the light was successfully destroyed, false if already destroyed or invalid
|
isValid
()
|
Returns whether this light handle is still valid.
A handle becomes invalid after SceneLight.destroy is called or if the underlying native light was removed.
Signature
fun isValid(): Boolean Returns Boolean
true if the light handle is valid and can be used
|
update
(
position
, range
, color
, intensity
, direction
, spotOuterAngle
, spotInnerAngle
, type
, castsShadow
)
|
Updates the light's properties.
All parameters are optional and default to common values. Only specify the parameters you want to change.
Signature
fun update(position: Vector3 = Vector3(0f, 0f, 0f), range: Float = 10.0f, color: Vector3 = Vector3(1f, 1f, 1f), intensity: Float = 1.0f, direction: Vector3 = Vector3(0f, -1f, 0f), spotOuterAngle: Float = 45.0f, spotInnerAngle: Float = 30.0f, type: SceneLightType = SceneLightType.Point, castsShadow: Boolean = false): Boolean Parameters range: Float
Attenuation range in world units. Light contribution is zero beyond this distance
intensity: Float
Light intensity multiplier. Values greater than 1 create brighter lights
spotOuterAngle: Float
Spot light outer cone angle in degrees. Light falls off to zero at this angle
spotInnerAngle: Float
Spot light inner cone angle in degrees. Light is at full intensity within this angle
castsShadow: Boolean
Whether this light should cast shadows (requires shadow system to be enabled)
Returns Boolean
true if the update was successful, false if the handle is invalid
|
createPointLight
(
position
, range
, color
, intensity
, castsShadow
)
|
Creates a new point light in the scene.
Point lights emit light equally in all directions from a single point in space.
Signature
fun createPointLight(position: Vector3, range: Float = 10.0f, color: Vector3 = Vector3(1f, 1f, 1f), intensity: Float = 1.0f, castsShadow: Boolean = false): SceneLight? Parameters range: Float
Attenuation range in world units. Light contribution is zero beyond this distance. Default is 10 units.
intensity: Float
Light intensity multiplier. Default is 1.0
castsShadow: Boolean
Whether this light should cast shadows. Default is false
|
createSpotLight
(
position
, direction
, range
, color
, intensity
, spotOuterAngle
, spotInnerAngle
, castsShadow
)
|
Creates a new spot light in the scene.
Spot lights emit light in a cone from a point in a given direction.
Signature
fun createSpotLight(position: Vector3, direction: Vector3, range: Float = 10.0f, color: Vector3 = Vector3(1f, 1f, 1f), intensity: Float = 1.0f, spotOuterAngle: Float = 45.0f, spotInnerAngle: Float = 30.0f, castsShadow: Boolean = false): SceneLight? Parameters range: Float
Attenuation range in world units. Light contribution is zero beyond this distance. Default is 10 units.
intensity: Float
Light intensity multiplier. Default is 1.0
spotOuterAngle: Float
Outer cone angle in degrees. Light falls off to zero at this angle. Default is 45 degrees.
spotInnerAngle: Float
Inner cone angle in degrees. Light is at full intensity within this angle. Default is 30 degrees.
castsShadow: Boolean
Whether this light should cast shadows. Default is false
|