API Docs for: 0.5.5
Show:

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
)
final

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);

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:

toJSON

() JSON

Inherited from kick.scene.Component but overwritten in kick/scene/Light.js:293

Returns:

JSON:

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]

color

kick.math.Vec3

Color intensity of the light (RGB).

Default: [1,1,1]

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

Inherited from kick.scene.Component but overwritten in kick/scene/Light.js:275

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

shadowRenderTexture

kick.texture.RenderTexture

shadowStrength

Number

Shadow strength (between 0.0 and 1.0).

Default: 1.0

shadowTexture

kick.texture.Texture

transform

kick.scene.Transform

Short for lightObj.gameObject.transform

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: