Light element enables users to add sources of light for their 3D animations. 

By default 3D animation scene is already lighted up by the two default sources of light that are created automatically: one of them is ambient light and the other one is directional (they are not manageable and are not displayed neither in the graphical editor nor in the Projects view). Therefore even if you have not added any sources of light using Light element, all your 3D objects are visible anyway. If the default AnyLogic lighting is OK for you, we recommend you not to add your own sources of light. Otherwise, the default light sources will be removed and the whole scene lighting will be managed by your own. 

However, if you need to modify the default lighting, you can add your own sources of light and control their position, color, direction (optionally) and attenuation. 

AnyLogic provides you with the predefined and ready for use standard types of the light source:

 To add a source of light onto presentation

  1. Drag the  Light element from the 3D section of the  Presentation palette into the graphical editor. You will see the light icon in the graphical editor:

  1. Go to the Properties view and choose the required type of the source from the Predefined type drop-down list: Street light, Car headlight, Daylight, Moonlight. By default, all properties of the light source (attenuation, cut of angle, etc...) will be defined automatically and you might only want to change the position or the color of the light source.
  2. If you do not find the predefined types suitable, you can choose the option Custom and configure the light source according to your needs using the source properties that have appeared. In this case, we recommend that you get acquainted with the types of the sources that AnyLogic supports. Having leaned their properties and distinctive features, you will be able to choose the correct type and the quantity of the light sources you need to add to your model to create the appropriate lighting.
  3. Choose the required type of the light source from the Light source type drop-down menu.
  4. Optionally, change colors for Ambient, Diffuse and Specular components of the light.
  5. If you choose directional or spot type of source, you will be able to set the light direction. Select the icon of the source of light in the graphical editor. You will see the arrow pointing in certain direction from the center of the icon. This arrow shows the projection of this light's source direction. To rotate it in the plane XY (Angle Z), click and pull the end of this arrow: 

  1. The length of the arrow also matters: it indicates the angle that the light direction composes with YZ plane (Angle X). The shorter the arrow is, the greater the angle is. If you cannot see the arrow that means that this source is currently set to shine at a right angle to the XY-plane - towards us or in the backward direction. You can change this angle by dragging the end of the arrow closer to or farther from the center of the source's icon:

If you want to set angles with a high degree of accuracy, you can specify the required values numerically in the additional properties Angle Z and Angle X in the properties section Position

Please note that the light is shining on the 3D scene "from above" when angle X is positive.



Name – The name of this source of light. It is used to identify the source and to access it from code.

Ignore – If selected, the source of light will be excluded from the model.

Visible on upper level – If selected, the source will also shine on the upper level where this agent lives.

Predefined type – Here you can choose one of the standard types of the sources of light: Street light, Car headlight, Daylight, Moonlight, or Custom (in this case you can manually configure all light source properties, which you will find below).

Color – [Visible if Custom is not chosen for Predefined type] Here you can define the color of the light source.

Light source type – [Visible if Predefined type is set to Custom] The type of the light source: Ambient, Directional, Point, and Spot.

Diffuse color,
Specular color
– [Visible if Predefined type is set to Custom] Here you can choose the color of the light components: separately for Ambient, Diffuse and Specular components of light.

Attenuation - [Visible if Light source type is Point or Spot] Here you can define the attenuation factor for the point/spot source of light. To be precise, you define the following three components of attenuation: Constant, Linear and Quadratic. Below you can find the formula that is used to calculate the attenuation factor:

where   = constant attenuation
             = linear attenuation
           = quadratic attenuation

Cut off angle - [Visible if Light source type is Spot] Here you can define the maximum angle of light dispersion. In particular, you specify the half of the angle in the vertex of the cone of light created by this source (the value is specified in degrees, from 0 to 90).

Drop off rate - [Visible if Light source type is Spot] Here you can specify how quickly the light will fade as we move from the axis of the cone of the light. 0 means there is no drop off and the light will have uniform intensity everywhere in the cone.


X – * The x-coordinate of the source.

Y – * The y-coordinate of the source.

Z – * The z-coordinate of the source.

Angle X – ** The angle that light direction composes with YZ plane (starting from inverted Y axis, clockwise, in degrees).

Angle Z – ** The angle that light direction composes with XY plane (starting from inverted Y axis, clockwise, in degrees).

* – Enabled if the type of the light source is set to Street light, Car headlight, Custom: Point, Custom: Spot.
** – Enabled if the type of the light source is set to Car headlight, Custom: Directional, Custom: Spot.


Enabled – Here you can specify Boolean expression determining whether the source of light is enabled (if the expression returns true) or disabled (if it returns false).

Show name – If selected, the name of this element will be displayed on the presentation diagram.

Types of light sources

AnyLogic supports four types of light sources: Ambient, Directional, Point and Spot.


Shapes lit by ambient light look like 2D shapes. The reason is that the source of ambient light can be considered as a set of uniformly distributed sources of lights all over the 3D space.



Directional source of light is located in some infinitely distant point. It shines in the specified direction (it is defined using light's advanced properties Angle X and Angle Z). the Sun is a good example of a directional source of light.


 To switch a directional source of light


Point source of light is located in one particular point of space. It shines uniformly in all directions. You can define an attenuation coefficient for this kind of source of light.



Spot source of light is a particular case of a point light. Spot source creates a beam of light that gradually becomes wider and makes a cone of light. You can think of a spot source of light as a searchlight or a car headlight. 


Components of the light

The light actually consists of a number of different components: Ambient, Diffuse and Specular.

By choosing No Light or black color for some component of the color, you remove the corresponding component of light. For example, by setting Specular color of the source of the light to black, you remove flashes from the shapes lighted up with this particular source of light.

Related topics

 3D animation

 Creating 3D animation

 API Reference: Light3D Class