DirectionalLight

components/lights/ DirectionalLight

.new DirectionalLight(paramsopt)

DirectinalLight creates a light that shines from a specific direction not from a specific position.

This light will behave as though it is infinitely far away and the rays produced from it are all parallel.

The best analogy would be a light source that acts like the sun: the sun is so far away that all sunlight hitting objects comes from the same angle.

It has the same options as AmbientLight in light paramater, but it also supports pos and target paramaters.

Source:
Parameters:
Name Type Attributes Default Description
params Object <optional>
{light: {color: 0xffffff, intensity: 1}}

The params.

Example

Creating a DirectionalLight to fall down from vec3(10, 20, 10) to vec3(0, 0, 0)

new DirectionalLight({
  color: 0xffffff,
  intensity: 0.2,

  position: [10, 20, 10]
}).addTo(app);

Extends module:core.LightComponent

Members

(private) ._wait :Array

Array of promises that should be resolved before Component is ready.

Inherited From:
Source:

.children :Array

Collection of child Components.

Inherited From:
Source:

.defaults :Object

Default values for parameters

Inherited From:
Default Value:
                  {
      build: true,
    
      shadow: {
        cast: true,
    
        bias: 0,
        radius: 1,
    
        mapSize: {
          width: 1024,
          height: 1024
        },
    
        camera: {
          near: true,
          far: 400,
          fov: 90,
    
          top: 200,
          bottom: -200,
          left: -200,
          right: 200
        }
      },
    
      position: {x: 0, y: 0, z: 0},
      rotation: {x: 0, y: 0, z: 0}
    }
                
Source:

.instructions :Object

Static instructions

Inherited From:
Default Value:
                  {
      position: ['x', 'y', 'z'],
      rotation: ['x', 'y', 'z']
    }
                
Source:

.isDeffered :Boolean

Returns whether the object is async (wait promises are more than 0).

Inherited From:
Source:

.manager :ModuleManager

Returns the ModuleManager used for this component.

Inherited From:
Source:

.modules :Array

Collection of modules.

Inherited From:
Source:

.native :Object

Returns the native object used for this component.

Inherited From:
Source:

Methods

.add(object) → {Promise}

Add a child Component.

Inherited From:
Source:
Parameters:
Name Type Description
object Component

Component that should be added as a child.

.addTo(object)

Adds this Component to specified App/Component.

Inherited From:
Source:
Parameters:
Name Type Description
object Component

Component that will be a parent of this.

.build()

Build livecycle should return a native object.

Inherited From:
Source:
Throws:
CompositionError

.clone() → {LightComponent}

Make a clone of this LightComponent using .copy()

Inherited From:
Source:

.copy() → {this}

Copy source transforms & execute Component.copy()

Inherited From:
Source:

.defer(func)

Execute func (Callback) when Component is ready.

Inherited From:
Source:
Parameters:
Name Type Description
func function

Callback.

.remove(object)

Remove a child Component.

Inherited From:
Source:
Parameters:
Name Type Description
object Component

Component that should be a child of this Component.

.updateParams() → {Object}

Updates parameters of the Component.

Inherited From:
Source:

.wait(promiseopt) → {Promise}

Wait for a promise.

Inherited From:
Source:
Parameters:
Name Type Attributes Description
promise Promise <optional>

The promise that should be added to a queue.

.wrap() → {Promise}

Wraps transforms (position & rotation)

Inherited From:
Source:

.wrapShadow()

Wraps shadow properties

Inherited From:
Source: