1 /**
2 * @author alteredq / http://alteredqualia.com/
3 *
4 * - shows directional light color, intensity, position, orientation and target
5 */
6
7 /**@constructor*/
8 THREE.DirectionalLightHelper = function ( light, sphereSize, arrowLength ) {
9
10 THREE.Object3D.call( this );
11
12 this.light = light;
13
14 // position
15
16 this.position = light.position;
17
18 // direction
19
20 this.direction = new THREE.Vector3();
21 this.direction.sub( light.target.position, light.position );
22
23 // color
24
25 this.color = light.color.clone();
26
27 var intensity = THREE.Math.clamp( light.intensity, 0, 1 );
28
29 this.color.r *= intensity;
30 this.color.g *= intensity;
31 this.color.b *= intensity;
32
33 var hexColor = this.color.getHex();
34
35 // light helper
36
37 var bulbGeometry = new THREE.SphereGeometry( sphereSize, 16, 8 );
38 var raysGeometry = new THREE.AsteriskGeometry( sphereSize * 1.25, sphereSize * 2.25 );
39
40 var bulbMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false } );
41 var raysMaterial = new THREE.LineBasicMaterial( { color: hexColor, fog: false } );
42
43 this.lightArrow = new THREE.ArrowHelper( this.direction, null, arrowLength, hexColor );
44 this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );
45
46 this.lightArrow.cone.material.fog = false;
47 this.lightArrow.line.material.fog = false;
48
49 this.lightRays = new THREE.Line( raysGeometry, raysMaterial, THREE.LinePieces );
50
51 this.add( this.lightArrow );
52 this.add( this.lightSphere );
53 this.add( this.lightRays );
54
55 this.lightSphere.properties.isGizmo = true;
56 this.lightSphere.properties.gizmoSubject = light;
57 this.lightSphere.properties.gizmoRoot = this;
58
59 // light target helper
60
61 this.targetSphere = null;
62
63 if ( light.target.properties.targetInverse ) {
64
65 var targetGeo = new THREE.SphereGeometry( sphereSize, 8, 4 );
66 var targetMaterial = new THREE.MeshBasicMaterial( { color: hexColor, wireframe: true, fog: false } );
67
68 this.targetSphere = new THREE.Mesh( targetGeo, targetMaterial );
69 this.targetSphere.position = light.target.position;
70
71 this.targetSphere.properties.isGizmo = true;
72 this.targetSphere.properties.gizmoSubject = light.target;
73 this.targetSphere.properties.gizmoRoot = this.targetSphere;
74
75 var lineMaterial = new THREE.LineDashedMaterial( { color: hexColor, dashSize: 4, gapSize: 4, opacity: 0.75, transparent: true, fog: false } );
76 var lineGeometry = new THREE.Geometry();
77 lineGeometry.vertices.push( this.position.clone() );
78 lineGeometry.vertices.push( this.targetSphere.position.clone() );
79 lineGeometry.computeLineDistances();
80
81 this.targetLine = new THREE.Line( lineGeometry, lineMaterial );
82 this.targetLine.properties.isGizmo = true;
83
84 }
85
86 //
87
88 this.properties.isGizmo = true;
89
90 }
91
92 THREE.DirectionalLightHelper.prototype = Object.create( THREE.Object3D.prototype );
93
94 THREE.DirectionalLightHelper.prototype.update = function () {
95
96 // update arrow orientation
97 // pointing from light to target
98
99 this.direction.sub( this.light.target.position, this.light.position );
100 this.lightArrow.setDirection( this.direction );
101
102 // update arrow, spheres, rays and line colors to light color * light intensity
103
104 this.color.copy( this.light.color );
105
106 var intensity = THREE.Math.clamp( this.light.intensity, 0, 1 );
107 this.color.r *= intensity;
108 this.color.g *= intensity;
109 this.color.b *= intensity;
110
111 this.lightArrow.setColor( this.color.getHex() );
112 this.lightSphere.material.color.copy( this.color );
113 this.lightRays.material.color.copy( this.color );
114
115 this.targetSphere.material.color.copy( this.color );
116 this.targetLine.material.color.copy( this.color );
117
118 // update target line vertices
119
120 this.targetLine.geometry.vertices[ 0 ].copy( this.light.position );
121 this.targetLine.geometry.vertices[ 1 ].copy( this.light.target.position );
122
123 this.targetLine.geometry.computeLineDistances();
124 this.targetLine.geometry.verticesNeedUpdate = true;
125
126 }
127
128
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