[page:Object3D] →
[name]
Creates a simulated lens flare that tracks a light.
Note: [page:WebGLRenderer.alpha] must be set to *true* for LensFlare to work.
Example
[example:webgl_lensflares lensflares]
var light = new THREE.PointLight( 0xffffff, 1.5, 2000 );
var textureLoader = new THREE.TextureLoader();
var textureFlare = textureLoader.load( "textures/lensflare/lensflare.png" );
var flareColor = new THREE.Color( 0xffffff );
flareColor.setHSL( h, s, l + 0.5 );
var lensFlare = new THREE.LensFlare( textureFlare, 700, 0.0, THREE.AdditiveBlending, flareColor );
lensFlare.position.copy( light.position );
scene.add( lensFlare );
Constructor
[name]( [page:Texture texture], [page:Float size], [page:Float distance], [page:Materials blending], [page:Color color] )
[page:Texture texture] - (optional) THREE.Texture to use for the flare.
[page:Float size] - (optional) size in pixels (-1 = use texture.width)
[page:Float distance] - (optional) (0-1) from light source (0 = at light source)
[page:Materials blending] - (optional) [page:Materials Blending Mode] - Defaults to THREE.NormalBlending
[page:Color color] - (optional) the [page:Color] of the lens flare
Automatically adds a lens flare to the lensFlares array if a [page:Texture texture] is set.
If [page:Texture texture] not passed here, [page:.add add] must be called later.
Properties
See the base [page:Object3D] class for common properties.
[property:Boolean isLensFlare]
Used to check whether this or derived classes are lens flares. Default is *true*.
You should not change this, as it used internally for optimisation.
[property:array lensFlares]
The array of flares as set by [page:LensFlare.add] or passed in the constructor.
Each flare is an object with the following defaults:
{
texture: texture, // texture passed in the constructor or [page:.add add] method
size: size, // if not passed in, default is -1
distance: distance, // if not passed in, default is 0
x: 0, y: 0, z: 0, // screen position (-1 => 1) z = 0 is in front z = 1 is back
scale: 1,
rotation: 0,
opacity: opacity, // if not passed in, default is 1
color: color, // if not passed in, default is new Color( 0xffffff ) (white)
blending: blending // if not passed in, default is NormalBlending
}
[property:Vector3 positionScreen]
The position of the lens flare on the screen.
[property:Function customUpdateCallback]
A custom update callback. Default is undefined, set this to override [page:.updateLensFlares updateLensFlares]().
Methods
See the base [page:Object3D] class for common methods.
[method:null add]( [page:Texture texture], [page:Float size], [page:Float distance], [page:Materials blending], [page:Color color] )
Adds a lens flare. Takes the same parameters as the constructor.
[method:LensFlare clone]()
Return a new LensFlare with the same parameters as this one.
[method:LensFlare copy]( [page:LensFlare source] )
Copy the parameters from the [page:LensFlare source] LensFlare into this one.
[method:null updateLensFlares]()
Updates [page:.lensFlares lensFlares] based on the [page:LensFlare.positionScreen positionScreen]
property.
Can be overridden by setting the [page:.customUpdateCallback customUpdateCallback] function.
Source
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]