1 /**
  2  * @author alteredq / http://alteredqualia.com/
  3  *
  4  *	- shows spot light color, intensity, position, orientation, light cone and target
  5  */
  6 
  7 /**@constructor*/
  8 THREE.SpotLightHelper = 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 	var coneGeometry = new THREE.CylinderGeometry( 0.0001, 1, 1, 8, 1, true );
 40 
 41 	var coneMatrix = new THREE.Matrix4();
 42 	coneMatrix.rotateX( -Math.PI/2 );
 43 	coneMatrix.translate( new THREE.Vector3( 0, -0.5, 0 ) );
 44 	coneGeometry.applyMatrix( coneMatrix );
 45 
 46 	var bulbMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false } );
 47 	var raysMaterial = new THREE.LineBasicMaterial( { color: hexColor, fog: false } );
 48 	var coneMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.3, transparent: true } );
 49 
 50 	this.lightArrow = new THREE.ArrowHelper( this.direction, null, arrowLength, hexColor );
 51 	this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );
 52 	this.lightCone = new THREE.Mesh( coneGeometry, coneMaterial );
 53 
 54 	var coneLength = light.distance ? light.distance : 10000;
 55 	var coneWidth = coneLength * Math.tan( light.angle * 0.5 ) * 2;
 56 	this.lightCone.scale.set( coneWidth, coneWidth, coneLength );
 57 
 58 	this.lightArrow.cone.material.fog = false;
 59 	this.lightArrow.line.material.fog = false;
 60 
 61 	this.lightRays = new THREE.Line( raysGeometry, raysMaterial, THREE.LinePieces );
 62 
 63 	this.gyroscope = new THREE.Gyroscope();
 64 
 65 	this.gyroscope.add( this.lightArrow );
 66 	this.gyroscope.add( this.lightSphere );
 67 	this.gyroscope.add( this.lightRays );
 68 
 69 	this.add( this.gyroscope );
 70 	this.add( this.lightCone );
 71 
 72 	this.lookAt( light.target.position );
 73 
 74 	this.lightSphere.properties.isGizmo = true;
 75 	this.lightSphere.properties.gizmoSubject = light;
 76 	this.lightSphere.properties.gizmoRoot = this;
 77 
 78 	// light target helper
 79 
 80 	this.targetSphere = null;
 81 
 82 	if ( light.target.properties.targetInverse ) {
 83 
 84 		var targetGeo = new THREE.SphereGeometry( sphereSize, 8, 4 );
 85 		var targetMaterial = new THREE.MeshBasicMaterial( { color: hexColor, wireframe: true, fog: false } );
 86 
 87 		this.targetSphere = new THREE.Mesh( targetGeo, targetMaterial );
 88 		this.targetSphere.position = light.target.position;
 89 
 90 		this.targetSphere.properties.isGizmo = true;
 91 		this.targetSphere.properties.gizmoSubject = light.target;
 92 		this.targetSphere.properties.gizmoRoot = this.targetSphere;
 93 
 94 		var lineMaterial = new THREE.LineDashedMaterial( { color: hexColor, dashSize: 4, gapSize: 4, opacity: 0.75, transparent: true, fog: false } );
 95 		var lineGeometry = new THREE.Geometry();
 96 		lineGeometry.vertices.push( this.position.clone() );
 97 		lineGeometry.vertices.push( this.targetSphere.position.clone() );
 98 		lineGeometry.computeLineDistances();
 99 
100 		this.targetLine = new THREE.Line( lineGeometry, lineMaterial );
101 		this.targetLine.properties.isGizmo = true;
102 
103 	}
104 
105 	//
106 
107 	this.properties.isGizmo = true;
108 
109 }
110 
111 THREE.SpotLightHelper.prototype = Object.create( THREE.Object3D.prototype );
112 
113 THREE.SpotLightHelper.prototype.update = function () {
114 
115 	// update arrow orientation
116 	// pointing from light to target
117 
118 	this.direction.sub( this.light.target.position, this.light.position );
119 	this.lightArrow.setDirection( this.direction );
120 
121 	// update light cone orientation and size
122 
123 	this.lookAt( this.light.target.position );
124 
125 	var coneLength = this.light.distance ? this.light.distance : 10000;
126 	var coneWidth = coneLength * Math.tan( this.light.angle * 0.5 ) * 2;
127 	this.lightCone.scale.set( coneWidth, coneWidth, coneLength );
128 
129 	// update arrow, spheres, rays and line colors to light color * light intensity
130 
131 	this.color.copy( this.light.color );
132 
133 	var intensity = THREE.Math.clamp( this.light.intensity, 0, 1 );
134 	this.color.r *= intensity;
135 	this.color.g *= intensity;
136 	this.color.b *= intensity;
137 
138 	this.lightArrow.setColor( this.color.getHex() );
139 	this.lightSphere.material.color.copy( this.color );
140 	this.lightRays.material.color.copy( this.color );
141 	this.lightCone.material.color.copy( this.color );
142 
143 	this.targetSphere.material.color.copy( this.color );
144 	this.targetLine.material.color.copy( this.color );
145 
146 	// update target line vertices
147 
148 	this.targetLine.geometry.vertices[ 0 ].copy( this.light.position );
149 	this.targetLine.geometry.vertices[ 1 ].copy( this.light.target.position );
150 
151 	this.targetLine.geometry.computeLineDistances();
152 	this.targetLine.geometry.verticesNeedUpdate = true;
153 
154 }
155 
156 

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

mbt skor nike sverige louboutin skor hollister sverige polo ralph lauren skjorta woolrich jacka dam canada goose jacka woolrich jacka ray ban rea canada goose rea michael kors rea new balance skor ralph lauren skjorta new balance rea uggs sverige lacoste rea christian louboutin skor moncler jacka nike shox barbour jacka uggs rea