kick.scene.Light Class
A light object.
Note that each scene can only have one ambient light and one directional light.
The directional light points in (0,0,1) direction (transformed by the GameObject transform)
Constructor
kick.scene.Light
-
config
Parameters:
-
config
Object
Example:
var lightGameObject = engine.activeScene.createGameObject();
lightGameObject.transform.position = [0,0,10];
// add point light
var lightComponent = new kick.scene.Light({type:kick.scene.Light.TYPE_POINT});
lightGameObject.addComponent(lightComponent);
// add ambient light (only one per scene)
var ambientLightComponent = new kick.scene.Light({type:kick.scene.Light.TYPE_AMBIENT, colorIntensity: [0.1,0.1,0.1] });
lightGameObject.addComponent(ambientLightComponent);
Item Index
Methods
Properties
Events
Methods
activated
()
Abstract method called when a component is added to scene. May be undefined.
This method method works in many cases like a constructor function, where references to other game objects can
be looked up (this cannot be done when the actual constructor function is called, since the scene may not be
loaded completely).
Note that activated are called just after update methods on all components has been called - this makes it easier
to get references to other components.
deactivated
()
Abstract method called when a component is removed from scene. May be undefined.
render
-
engineUniforms
-
[overwriteMaterial]
Abstract method called every at every rendering of the object. May be undefined.
Parameters:
-
engineUniforms
kick.scene.EngineUniforms -
[overwriteMaterial]
kick.material.Material optional
toJSON
()
JSON
Returns:
update
()
Abstract method called every update. May be undefined.
Properties
aabb
kick.math.Aabb
Defines the axis aligned bounding box used for view frustum culling May be undefined or null.
attenuation
kick.math.Vec3
Specifies the light falloff.
attenuation[0] is constant attenuation,
attenuation[1] is linear attenuation,
attenuation[2] is quadratic attenuation.
Default: [1,0,0]
colorIntensity
kick.math.Vec3
final
color RGB multiplied with intensity (plus color A).
This property exposes a internal value. This value should not be modified.
Instead use the intensity and color property.
componentType
String
final
Name of the component componentType = "meshRenderer".
Example:
var light = gameObject.light;
gameObject
kick.scene.GameObject
The gameObject owning the component. Initially undefined. The value is set when the Component object is added to a GameObject
intensity
Number
Light intensity (a multiplier to color)
Default: 1
renderOrder
Number
Default value is 1000
< 1999 default geometry
1999 skybox
2001 - 2999 transparent geometry (sorted back-to-front when rendered)
> 3000 overlay geometry rendered on top
scriptPriority
Number
Components with largest priority are invoked first. (optional - default 0). Cannot be modified after creation.
shadow
Boolean
Default value is false. Only directional light supports shadows.
Default: false
shadowBias
Number
Shadow bias.
Default: 0.05
shadowStrength
Number
Shadow strength (between 0.0 and 1.0).
Default: 1.0
type
Enum
final
Color type. Must be either:
Light.TYPE_AMBIENT,
Light.TYPE_DIRECTIONAL,
Light.TYPE_POINT
Note that this value is readonly after initialization. To change it create a new Light component and replace the current light
component of its gameObject.
Default: Light.TYPE_POINT
TYPE_AMBIENT
Number
static
Used to define ambient color in the scene (indirect lightening)
TYPE_DIRECTIONAL
Number
static
Used to define directional light in the scene (such as sunlight)
TYPE_POINT
Number
static
Used to define point light in the scene
Events
componentUpdated
Fire events when components are updated. May be undefined. Must be defined before adding to gameObject.
Event Payload:
-
component
kick.scene.Component