1 /**
2 * @author mikael emtinger / http://gomo.se/
3 * @author alteredq / http://alteredqualia.com/
4 */
5
6 /**@constructor*/
7 THREE.LensFlare = function ( texture, size, distance, blending, color ) {
8
9 THREE.Object3D.call( this );
10
11 this.lensFlares = [];
12
13 this.positionScreen = new THREE.Vector3();
14 this.customUpdateCallback = undefined;
15
16 if( texture !== undefined ) {
17
18 this.add( texture, size, distance, blending, color );
19
20 }
21
22 };
23
24 THREE.LensFlare.prototype = Object.create( THREE.Object3D.prototype );
25
26
27 /*
28 * Add: adds another flare
29 */
30
31 THREE.LensFlare.prototype.add = function ( texture, size, distance, blending, color, opacity ) {
32
33 if( size === undefined ) size = -1;
34 if( distance === undefined ) distance = 0;
35 if( opacity === undefined ) opacity = 1;
36 if( color === undefined ) color = new THREE.Color( 0xffffff );
37 if( blending === undefined ) blending = THREE.NormalBlending;
38
39 distance = Math.min( distance, Math.max( 0, distance ) );
40
41 this.lensFlares.push( { texture: texture, // THREE.Texture
42 size: size, // size in pixels (-1 = use texture.width)
43 distance: distance, // distance (0-1) from light source (0=at light source)
44 x: 0, y: 0, z: 0, // screen position (-1 => 1) z = 0 is ontop z = 1 is back
45 scale: 1, // scale
46 rotation: 1, // rotation
47 opacity: opacity, // opacity
48 color: color, // color
49 blending: blending } ); // blending
50
51 };
52
53
54 /*
55 * Update lens flares update positions on all flares based on the screen position
56 * Set myLensFlare.customUpdateCallback to alter the flares in your project specific way.
57 */
58
59 THREE.LensFlare.prototype.updateLensFlares = function () {
60
61 var f, fl = this.lensFlares.length;
62 var flare;
63 var vecX = -this.positionScreen.x * 2;
64 var vecY = -this.positionScreen.y * 2;
65
66 for( f = 0; f < fl; f ++ ) {
67
68 flare = this.lensFlares[ f ];
69
70 flare.x = this.positionScreen.x + vecX * flare.distance;
71 flare.y = this.positionScreen.y + vecY * flare.distance;
72
73 flare.wantedRotation = flare.x * Math.PI * 0.25;
74 flare.rotation += ( flare.wantedRotation - flare.rotation ) * 0.25;
75
76 }
77
78 };
79
80
81
82
83
84
85
86
87
88
89
90
91
nike free rn
new balance hombre baratas
cinturones gucci
ugg rebajas
cinturon gucci
ray ban baratas
nike cortez
peuterey mujer
christian louboutin madrid
mbt zapatos
gafas ray ban baratas
mbt ofertas
air max blancas
mbt barcelona
nike air max 90
woolrich barcelona
nike mujer
botas ugg
gafas de sol carrera aratas
air max 2016 baratas
oakley baratas
nike air max 2016