
The release beta 91 has a new kind of light: the distant light.
The name is very funny because we can imagine that the light comes from a distant point, like the light of the sun. But it's not true. A "distant light" is defined only for one object and it's like the object was transparent having an internal spot light. This "spot light" is a "floating spot light" and his direction doesn't change if the object rotates.
If you look the demo you will see that, the objects inside the room rotates but the face having light changes.
The object is not part of the main world, it's inside another .AER world and it doesn't emits light BUT THE WORLD OF THE OBJECT NEEDS TO BE "LIGHTED" (you can use the defaults).

The distant light is defined by code. Look the program glued to the main world:
obj = Model("./obj.aer").add();
obj.position = Vector(0, 15, 0);
light = stageModel.getDistantLight(0);
light.brightness = 1.8;
light.color = Vector(.95, .95, 1.0);
light.coneAngle = 100.0;
light.direction = Vector(1.0, 1.0, 1.0);
i = 0; //Creates an index "i"
obj.timestep = function(now){
if (obj.loaded){
obj.solidObject = obj.getSolidObject(0);
obj.physicalModel = obj.createPhysicalModel(5);
obj.physicalModel.velocity = Vector(0.0, -1, 0.0);
obj.physicalModel.collide = true;
obj.solidObject.useDynamicLighting = true;
obj.orientation = Rotation('Y',i); //Rotates by the Y axis
i=i+.001; //Each loop the box rotates .001 radians more
if(i>=6.28) i=0; //6.28 is 360 degrees in radians (2PI)
}
}
addAnimator(obj);

The direction of the light is defined by a vector.
The lines of code about the distant light system are bold faced.
If you doesn't understand the code for rotation, read our free web course at: this link.
It's not easy to find an utility for the "distant light". The possibility of change the brightness could be used.
PREVIOUS LESSON NEXT LESSON T. CONTENTS HOMEPAGE
