Three.V8

3D rendering engine using JavaScript as user script.

View on GitHub

<–Home

class DirectionalLight

A light that gets emitted in a specific direction. This light will behave as though it is infinitely far away and the rays produced from it are all parallel. The common use case for this is to simulate daylight; the sun is far enough away that its position can be considered to be infinite, and all light rays coming from it are parallel.

This light can cast shadows.

class DirectionalLight extends Light

Inheritance Light –> DirectionalLight

Name Description
Constructors  
DirectionalLight() Creates a new DirectionalLight.
Properties  
target Target object
bias bias for double-sided materials
forceCull front-face cull even for double-sided materials
Methods  
setShadow Set the basic shadow-map options.
setShadowProjection Set the orthographic frustum parameters.
setShadowRadius Set the soft-shadow radius.
getBoundingBox Get the bounding box of a scene in the shadow coordinate.

Constructors

DirectionalLight()

Creates a new DirectionalLight.

Properties

See the base Light class for common properties.

target

.target: Object3D

The DirectionalLight points from its position to target.position. The default position of the target is (0, 0, 0).

bias

.bias: Number

Bias for double-sided materials.

Readable & Writable. Default value is 0.001.

forceCull

.forceCull: Boolean

Whether apply front-face culling even for double-sided materials.

Methods

See the base Light class for common methods.

setShadow

.setShadow(enable : Boolean, width: Number, height: Number): undefined

Set basic shadow-map options.

Parameters

enable: If set to true light will cast dynamic shadows.

width: width of the shadow map.

height: height of the shadow map.

setShadowProjection

.setShadowProjection(left: Number, right: Number, bottom: Number, top: Number, zNear: Number, zFar: Number): undefined

Set the orthographic frustum parameters.

Parameters

left: Frustum left plane.

right: Frustum right plane.

top: Frustum top plane.

bottom: Frustum bottom plane.

near: Frustum near plane.

far: Frustum far plane.

setShadowRadius

.setShadowRadius(radius: Number): undefined

Set the soft-shadow radius at distance 1.0.

radius>0 would activate the PCSS rendering path.

getBoundingBox

.getBoundingBox(scene: Scene): Object

Get the bounding box of a scene in the shadow coordinate.

The returned object contains a ‘minPos’ property and a ‘maxPos’ property, each of which is a Vector3.