Packagesandy.core.light
Classpublic class Light3D
InheritanceLight3D Inheritance flash.events.EventDispatcher

The Light3D class is used for creating the light of the world.

The light in Sandy is a light source at infinity, emitting parallel colored light.
The direction of light and the intensity can be varied



Public Properties
 PropertyDefined by
  color : uint
Color of the light.
Light3D
  MAX_POWER : Number = 150
[static] Maximum value accepted.
Light3D
Public Methods
 MethodDefined by
  
Light3D(p_oD:Vector, p_nPow:Number)
Creates a new light source.
Light3D
  
calculate(normal:Vector):Number
Calculates the strength of this light based on the supplied normal.
Light3D
  
destroy():void
Not in use...
Light3D
  
Returns the direction of the light.
Light3D
  
Returns the power of the light normalized to the range 0 -> 1
Light3D
  
getPower():Number
Returns the intensity of the light.
Light3D
  
setDirection(x:Number, y:Number, z:Number):void
Uneeded? setDirectionVector() does the same thing...
Light3D
  
Sets the direction of the Light3D.
Light3D
  
setPower(p_nPow:Number):void
The the power of the light.
Light3D
Events
 EventSummaryDefined by
   Dispatched when the light color is changed.Light3D
   Dispatched when the light is updated.Light3D
Property detail
colorproperty
color:uint  [read-write]

Color of the light.

Implementation
    public function get color():uint
    public function set color(value:uint):void
MAX_POWERproperty 
public static var MAX_POWER:Number = 150

Maximum value accepted. If the default value (150) seems too big or too small for you, you can change it. But be aware that the actual lighting calculations are normalised i.e. 0 -> MAX_POWER becomes 0 -> 1

Constructor detail
Light3D()constructor
public function Light3D(p_oD:Vector, p_nPow:Number)

Creates a new light source.

Parameters
p_oD:Vector — The direction of the emitted light.
 
p_nPow:Number — Intensity of the emitted light.

See also

Method detail
calculate()method
public function calculate(normal:Vector):Number

Calculates the strength of this light based on the supplied normal.

Parameters
normal:Vector

Returns
Number — Number The strength between 0 and 1

See also

destroy()method 
public function destroy():void

Not in use...

getDirectionVector()method 
public function getDirectionVector():Vector

Returns the direction of the light.

Returns
Vector — The light direction

See also

getNormalizedPower()method 
public function getNormalizedPower():Number

Returns the power of the light normalized to the range 0 -> 1

Returns
Number — Number a number between 0 and 1
getPower()method 
public function getPower():Number

Returns the intensity of the light.

Returns
Number — The intensity as a number between 0 - MAX_POWER.
setDirection()method 
public function setDirection(x:Number, y:Number, z:Number):void

Uneeded? setDirectionVector() does the same thing...

Parameters
x:Number — The x coordinate
 
y:Number — The y coordinate
 
z:Number — The z coordinate
setDirectionVector()method 
public function setDirectionVector(pDir:Vector):void

Sets the direction of the Light3D.

Parameters
pDir:Vector — A Vector object representing the direction of the light.

See also

setPower()method 
public function setPower(p_nPow:Number):void

The the power of the light. A number between 0 and MAX_POWER is necessary. The highter the power of the light is, the less the shadows are visibles.

Parameters
p_nPow:Number — Number a Number between 0 and MAX_POWER. This number is the light intensity.
Event detail
lightColorChangedevent 
Event object type: sandy.events.SandyEvent
SandyEvent.type property = sandy.events.SandyEvent.LIGHT_COLOR_CHANGED

Dispatched when the light color is changed.

Defines the value of the type property of a lightColorChanged event object.

lightUpdatedevent  
Event object type: sandy.events.SandyEvent
SandyEvent.type property = sandy.events.SandyEvent.LIGHT_UPDATED

Dispatched when the light is updated.

Defines the value of the type property of a lightUpdated event object.