瀏覽代碼

Extracted rays from PointLightHelper into AsteriskGeometry.

Added rays also to DirectionalLightHelper.

Refactored PointLightHelper and DirectionalLightHelper.
alteredq 12 年之前
父節點
當前提交
5d8ed4e4f9

+ 91 - 51
build/three.js

@@ -29810,6 +29810,45 @@ THREE.CombinedCamera.prototype.toBottomView = function() {
 };
 
 /**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ *	- 3d asterisk shape (for line pieces THREE.Line)
+ */
+
+THREE.AsteriskGeometry = function ( innerRadius, outerRadius ) {
+
+	THREE.Geometry.call( this );
+
+	var sd = innerRadius;
+	var ed = outerRadius;
+
+	var sd2 = 0.707 * sd;
+	var ed2 = 0.707 * ed;
+
+	var rays = [ [ sd, 0, 0 ], [ ed, 0, 0 ], [ -sd, 0, 0 ], [ -ed, 0, 0 ],
+				 [ 0, sd, 0 ], [ 0, ed, 0 ], [ 0, -sd, 0 ], [ 0, -ed, 0 ],
+				 [ 0, 0, sd ], [ 0, 0, ed ], [ 0, 0, -sd ], [ 0, 0, -ed ],
+				 [ sd2, sd2, 0 ], [ ed2, ed2, 0 ], [ -sd2, -sd2, 0 ], [ -ed2, -ed2, 0 ],
+				 [ sd2, -sd2, 0 ], [ ed2, -ed2, 0 ], [ -sd2, sd2, 0 ], [ -ed2, ed2, 0 ],
+				 [ sd2, 0, sd2 ], [ ed2, 0, ed2 ], [ -sd2, 0, -sd2 ], [ -ed2, 0, -ed2 ],
+				 [ sd2, 0, -sd2 ], [ ed2, 0, -ed2 ], [ -sd2, 0, sd2 ], [ -ed2, 0, ed2 ],
+				 [ 0, sd2, sd2 ], [ 0, ed2, ed2 ], [ 0, -sd2, -sd2 ], [ 0, -ed2, -ed2 ],
+				 [ 0, sd2, -sd2 ], [ 0, ed2, -ed2 ], [ 0, -sd2, sd2 ], [ 0, -ed2, ed2 ]
+	];
+
+	for ( var i = 0, il = rays.length; i < il; i ++ ) {
+
+		var x = rays[ i ][ 0 ];
+		var y = rays[ i ][ 1 ];
+		var z = rays[ i ][ 2 ];
+
+		this.vertices.push( new THREE.Vector3( x, y, z ) );
+
+	}
+
+};
+
+THREE.AsteriskGeometry.prototype = Object.create( THREE.Geometry.prototype );/**
  * @author hughes
  */
 
@@ -32601,9 +32640,16 @@ THREE.DirectionalLightHelper = function ( light, sphereSize, arrowLength ) {
 
 	this.light = light;
 
+	// position
+
 	this.position = light.position;
 
-	this.properties.isGizmo = true;
+	// direction
+
+	this.direction = new THREE.Vector3();
+	this.direction.sub( light.target.position, light.position );
+
+	// color
 
 	this.color = light.color.clone();
 
@@ -32613,26 +32659,37 @@ THREE.DirectionalLightHelper = function ( light, sphereSize, arrowLength ) {
 
 	var hexColor = this.color.getHex();
 
-	this.direction = new THREE.Vector3();
-	this.direction.sub( light.target.position, light.position );
+	// light helper
+
+	var bulbGeometry = new THREE.SphereGeometry( sphereSize, 16, 8 );
+	var raysGeometry = new THREE.AsteriskGeometry( sphereSize * 1.25, sphereSize * 2.25 );
 
-	var targetGeo = new THREE.SphereGeometry( sphereSize, 8, 4 );
-	var lightGeo = new THREE.SphereGeometry( sphereSize, 16, 8 );
-	var lightMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false } );
+	var bulbMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false } );
+	var raysMaterial = new THREE.LineBasicMaterial( { color: hexColor, fog: false } );
 
 	this.lightArrow = new THREE.ArrowHelper( this.direction, null, arrowLength, hexColor );
-	this.lightSphere = new THREE.Mesh( lightGeo, lightMaterial );
+	this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );
 
 	this.lightArrow.cone.material.fog = false;
 	this.lightArrow.line.material.fog = false;
 
+	this.lightRays = new THREE.Line( raysGeometry, raysMaterial, THREE.LinePieces );
+
 	this.add( this.lightArrow );
 	this.add( this.lightSphere );
+	this.add( this.lightRays );
+
+	this.lightSphere.properties.isGizmo = true;
+	this.lightSphere.properties.gizmoSubject = light;
+	this.lightSphere.properties.gizmoRoot = this;
+
+	// light target helper
 
 	this.targetSphere = null;
 
 	if ( light.target.properties.targetInverse ) {
 
+		var targetGeo = new THREE.SphereGeometry( sphereSize, 8, 4 );
 		var targetMaterial = new THREE.MeshBasicMaterial( { color: hexColor, wireframe: true, fog: false } );
 
 		this.targetSphere = new THREE.Mesh( targetGeo, targetMaterial );
@@ -32653,9 +32710,9 @@ THREE.DirectionalLightHelper = function ( light, sphereSize, arrowLength ) {
 
 	}
 
-	this.lightSphere.properties.isGizmo = true;
-	this.lightSphere.properties.gizmoSubject = light;
-	this.lightSphere.properties.gizmoRoot = this;
+	//
+
+	this.properties.isGizmo = true;
 
 }
 
@@ -32663,13 +32720,13 @@ THREE.DirectionalLightHelper.prototype = Object.create( THREE.Object3D.prototype
 
 THREE.DirectionalLightHelper.prototype.update = function () {
 
-	// set arrow orientation
+	// update arrow orientation
 	// pointing from light to target
 
 	this.direction.sub( this.light.target.position, this.light.position );
 	this.lightArrow.setDirection( this.direction );
 
-	// set arrow and spheres colors to light color * light intensity
+	// update arrow, spheres, rays and line colors to light color * light intensity
 
 	this.color.copy( this.light.color );
 
@@ -32680,10 +32737,12 @@ THREE.DirectionalLightHelper.prototype.update = function () {
 
 	this.lightArrow.setColor( this.color.getHex() );
 	this.lightSphere.material.color.copy( this.color );
+	this.lightRays.material.color.copy( this.color );
+
 	this.targetSphere.material.color.copy( this.color );
 	this.targetLine.material.color.copy( this.color );
 
-	// set target line
+	// update target line vertices
 
 	this.targetLine.geometry.vertices[ 0 ].copy( this.light.position );
 	this.targetLine.geometry.vertices[ 1 ].copy( this.light.target.position );
@@ -32705,9 +32764,11 @@ THREE.PointLightHelper = function ( light, sphereSize ) {
 
 	this.light = light;
 
+	// position
+
 	this.position = light.position;
 
-	this.properties.isGizmo = true;
+	// color
 
 	this.color = light.color.clone();
 
@@ -32717,50 +32778,29 @@ THREE.PointLightHelper = function ( light, sphereSize ) {
 
 	var hexColor = this.color.getHex();
 
-	var lightGeo = new THREE.SphereGeometry( sphereSize, 16, 8 );
-	var lightMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false } );
+	// light helper
+
+	var bulbGeometry = new THREE.SphereGeometry( sphereSize, 16, 8 );
+	var raysGeometry = new THREE.AsteriskGeometry( sphereSize * 1.25, sphereSize * 2.25 );
+
+	var bulbMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false } );
+	var raysMaterial = new THREE.LineBasicMaterial( { color: hexColor, fog: false } );
 
-	this.lightSphere = new THREE.Mesh( lightGeo, lightMaterial );
+	this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );
+	this.lightRays = new THREE.Line( raysGeometry, raysMaterial, THREE.LinePieces );
 
 	this.add( this.lightSphere );
+	this.add( this.lightRays );
+
+	//
 
 	this.lightSphere.properties.isGizmo = true;
 	this.lightSphere.properties.gizmoSubject = light;
 	this.lightSphere.properties.gizmoRoot = this;
 
-	var lineMaterial = new THREE.LineBasicMaterial( { color: hexColor, fog: false } );
-	var lineGeometry = new THREE.Geometry();
-
-	var sd = sphereSize * 1.25;
-	var ed = sphereSize * 2.25;
-
-	var sd2 = 0.707 * sd;
-	var ed2 = 0.707 * ed;
-
-	var rays = [ [ sd, 0, 0 ], [ ed, 0, 0 ], [ -sd, 0, 0 ], [ -ed, 0, 0 ],
-				 [ 0, sd, 0 ], [ 0, ed, 0 ], [ 0, -sd, 0 ], [ 0, -ed, 0 ],
-				 [ 0, 0, sd ], [ 0, 0, ed ], [ 0, 0, -sd ], [ 0, 0, -ed ],
-				 [ sd2, sd2, 0 ], [ ed2, ed2, 0 ], [ -sd2, -sd2, 0 ], [ -ed2, -ed2, 0 ],
-				 [ sd2, -sd2, 0 ], [ ed2, -ed2, 0 ], [ -sd2, sd2, 0 ], [ -ed2, ed2, 0 ],
-				 [ sd2, 0, sd2 ], [ ed2, 0, ed2 ], [ -sd2, 0, -sd2 ], [ -ed2, 0, -ed2 ],
-				 [ sd2, 0, -sd2 ], [ ed2, 0, -ed2 ], [ -sd2, 0, sd2 ], [ -ed2, 0, ed2 ],
-				 [ 0, sd2, sd2 ], [ 0, ed2, ed2 ], [ 0, -sd2, -sd2 ], [ 0, -ed2, -ed2 ],
-				 [ 0, sd2, -sd2 ], [ 0, ed2, -ed2 ], [ 0, -sd2, sd2 ], [ 0, -ed2, ed2 ]
-	];
-
-	for ( var i = 0, il = rays.length; i < il; i ++ ) {
-
-		var x = rays[ i ][ 0 ];
-		var y = rays[ i ][ 1 ];
-		var z = rays[ i ][ 2 ];
-
-		lineGeometry.vertices.push( new THREE.Vector3( x, y, z ) );
-
-	}
-
-	this.lightLine = new THREE.Line( lineGeometry, lineMaterial, THREE.LinePieces );
+	//
 
-	this.add( this.lightLine );
+	this.properties.isGizmo = true;
 
 }
 
@@ -32768,7 +32808,7 @@ THREE.PointLightHelper.prototype = Object.create( THREE.Object3D.prototype );
 
 THREE.PointLightHelper.prototype.update = function () {
 
-	// set sphere color to light color * light intensity
+	// update sphere and rays colors to light color * light intensity
 
 	this.color.copy( this.light.color );
 
@@ -32778,7 +32818,7 @@ THREE.PointLightHelper.prototype.update = function () {
 	this.color.b *= intensity;
 
 	this.lightSphere.material.color.copy( this.color );
-	this.lightLine.material.color.copy( this.color );
+	this.lightRays.material.color.copy( this.color );
 
 }
 

+ 12 - 10
build/three.min.js

@@ -630,6 +630,8 @@ THREE.CombinedCamera.prototype.setSize=function(a,b){this.cameraP.aspect=a/b;thi
 THREE.CombinedCamera.prototype.setLens=function(a,b){b===void 0&&(b=24);var c=2*Math.atan(b/(a*2))*(180/Math.PI);this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPerspectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};
 THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=false};
 THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};
+THREE.AsteriskGeometry=function(a,b){THREE.Geometry.call(this);for(var c=0.707*a,d=0.707*b,c=[[a,0,0],[b,0,0],[-a,0,0],[-b,0,0],[0,a,0],[0,b,0],[0,-a,0],[0,-b,0],[0,0,a],[0,0,b],[0,0,-a],[0,0,-b],[c,c,0],[d,d,0],[-c,-c,0],[-d,-d,0],[c,-c,0],[d,-d,0],[-c,c,0],[-d,d,0],[c,0,c],[d,0,d],[-c,0,-c],[-d,0,-d],[c,0,-c],[d,0,-d],[-c,0,c],[-d,0,d],[0,c,c],[0,d,d],[0,-c,-c],[0,-d,-d],[0,c,-c],[0,d,-d],[0,-c,c],[0,-d,d]],d=0,e=c.length;d<e;d++)this.vertices.push(new THREE.Vector3(c[d][0],c[d][1],c[d][2]))};
+THREE.AsteriskGeometry.prototype=Object.create(THREE.Geometry.prototype);
 THREE.CircleGeometry=function(a,b,c,d){THREE.Geometry.call(this);var a=a||50,c=c!==void 0?c:0,d=d!==void 0?d:Math.PI*2,b=b!==void 0?Math.max(3,b):8,e,f=[];e=new THREE.Vector3;var g=new THREE.UV(0.5,0.5);this.vertices.push(e);f.push(g);for(e=0;e<=b;e++){var h=new THREE.Vector3;h.x=a*Math.cos(c+e/b*d);h.y=a*Math.sin(c+e/b*d);this.vertices.push(h);f.push(new THREE.UV((h.x/a+1)/2,-(h.y/a+1)/2+1))}c=new THREE.Vector3(0,0,-1);for(e=1;e<=b;e++){this.faces.push(new THREE.Face3(e,e+1,0,[c,c,c]));this.faceVertexUvs[0].push([f[e],
 f[e+1],g])}this.computeCentroids();this.computeFaceNormals();this.boundingSphere={radius:a}};THREE.CircleGeometry.prototype=Object.create(THREE.Geometry.prototype);
 THREE.CubeGeometry=function(a,b,c,d,e,f,g,h){function i(a,b,c,d,e,f,g,h){var i,l=j.widthSegments,m=j.heightSegments,n=e/2,o=f/2,p=j.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")i="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x"){i="y";m=j.depthSegments}else if(a==="z"&&b==="y"||a==="y"&&b==="z"){i="x";l=j.depthSegments}var q=l+1,s=m+1,M=e/l,N=f/m,R=new THREE.Vector3;R[i]=g>0?1:-1;for(e=0;e<s;e++)for(f=0;f<q;f++){var aa=new THREE.Vector3;aa[a]=(f*M-n)*c;aa[b]=(e*N-o)*d;aa[i]=g;j.vertices.push(aa)}for(e=
@@ -694,16 +696,16 @@ THREE.CameraHelper=function(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d
 "cf2",3355443);b("cf3","cf4",3355443);this.camera=a;this.update(a)};THREE.CameraHelper.prototype=Object.create(THREE.Line.prototype);
 THREE.CameraHelper.prototype.update=function(){function a(a,d,e,f){THREE.CameraHelper.__v.set(d,e,f);THREE.CameraHelper.__projector.unprojectVector(THREE.CameraHelper.__v,THREE.CameraHelper.__c);a=b.pointMap[a];if(a!==void 0){d=0;for(e=a.length;d<e;d++)b.geometry.vertices[a[d]].copy(THREE.CameraHelper.__v)}}var b=this;THREE.CameraHelper.__c.projectionMatrix.copy(this.camera.projectionMatrix);a("c",0,0,-1);a("t",0,0,1);a("n1",-1,-1,-1);a("n2",1,-1,-1);a("n3",-1,1,-1);a("n4",1,1,-1);a("f1",-1,-1,1);
 a("f2",1,-1,1);a("f3",-1,1,1);a("f4",1,1,1);a("u1",0.7,1.1,-1);a("u2",-0.7,1.1,-1);a("u3",0,2,-1);a("cf1",-1,0,1);a("cf2",1,0,1);a("cf3",0,-1,1);a("cf4",0,1,1);a("cn1",-1,0,-1);a("cn2",1,0,-1);a("cn3",0,-1,-1);a("cn4",0,1,-1);this.geometry.verticesNeedUpdate=true};THREE.CameraHelper.__projector=new THREE.Projector;THREE.CameraHelper.__v=new THREE.Vector3;THREE.CameraHelper.__c=new THREE.Camera;
-THREE.DirectionalLightHelper=function(a,b,c){THREE.Object3D.call(this);this.light=a;this.position=a.position;this.properties.isGizmo=true;this.color=a.color.clone();this.color.r=this.color.r*a.intensity;this.color.g=this.color.g*a.intensity;this.color.b=this.color.b*a.intensity;var d=this.color.getHex();this.direction=new THREE.Vector3;this.direction.sub(a.target.position,a.position);var e=new THREE.SphereGeometry(b,8,4),b=new THREE.SphereGeometry(b,16,8),f=new THREE.MeshBasicMaterial({color:d,fog:false});
-this.lightArrow=new THREE.ArrowHelper(this.direction,null,c,d);this.lightSphere=new THREE.Mesh(b,f);this.lightArrow.cone.material.fog=false;this.lightArrow.line.material.fog=false;this.add(this.lightArrow);this.add(this.lightSphere);this.targetSphere=null;if(a.target.properties.targetInverse){c=new THREE.MeshBasicMaterial({color:d,wireframe:true,fog:false});this.targetSphere=new THREE.Mesh(e,c);this.targetSphere.position=a.target.position;this.targetSphere.properties.isGizmo=true;this.targetSphere.properties.gizmoSubject=
-a.target;this.targetSphere.properties.gizmoRoot=this.targetSphere;d=new THREE.LineDashedMaterial({color:d,dashSize:4,gapSize:4,opacity:0.75,transparent:true,fog:false});e=new THREE.Geometry;e.vertices.push(this.position.clone());e.vertices.push(this.targetSphere.position.clone());e.computeLineDistances();this.targetLine=new THREE.Line(e,d);this.targetLine.properties.isGizmo=true}this.lightSphere.properties.isGizmo=true;this.lightSphere.properties.gizmoSubject=a;this.lightSphere.properties.gizmoRoot=
-this};THREE.DirectionalLightHelper.prototype=Object.create(THREE.Object3D.prototype);
-THREE.DirectionalLightHelper.prototype.update=function(){this.direction.sub(this.light.target.position,this.light.position);this.lightArrow.setDirection(this.direction);this.color.copy(this.light.color);var a=THREE.Math.clamp(this.light.intensity,0,1);this.color.r=this.color.r*a;this.color.g=this.color.g*a;this.color.b=this.color.b*a;this.lightArrow.setColor(this.color.getHex());this.lightSphere.material.color.copy(this.color);this.targetSphere.material.color.copy(this.color);this.targetLine.material.color.copy(this.color);
-this.targetLine.geometry.vertices[0].copy(this.light.position);this.targetLine.geometry.vertices[1].copy(this.light.target.position);this.targetLine.geometry.computeLineDistances();this.targetLine.geometry.verticesNeedUpdate=true};
-THREE.PointLightHelper=function(a,b){THREE.Object3D.call(this);this.light=a;this.position=a.position;this.properties.isGizmo=true;this.color=a.color.clone();this.color.r=this.color.r*a.intensity;this.color.g=this.color.g*a.intensity;this.color.b=this.color.b*a.intensity;var c=this.color.getHex(),d=new THREE.SphereGeometry(b,16,8),e=new THREE.MeshBasicMaterial({color:c,fog:false});this.lightSphere=new THREE.Mesh(d,e);this.add(this.lightSphere);this.lightSphere.properties.isGizmo=true;this.lightSphere.properties.gizmoSubject=
-a;this.lightSphere.properties.gizmoRoot=this;for(var c=new THREE.LineBasicMaterial({color:c,fog:false}),d=new THREE.Geometry,e=b*1.25,f=b*2.25,g=0.707*e,h=0.707*f,e=[[e,0,0],[f,0,0],[-e,0,0],[-f,0,0],[0,e,0],[0,f,0],[0,-e,0],[0,-f,0],[0,0,e],[0,0,f],[0,0,-e],[0,0,-f],[g,g,0],[h,h,0],[-g,-g,0],[-h,-h,0],[g,-g,0],[h,-h,0],[-g,g,0],[-h,h,0],[g,0,g],[h,0,h],[-g,0,-g],[-h,0,-h],[g,0,-g],[h,0,-h],[-g,0,g],[-h,0,h],[0,g,g],[0,h,h],[0,-g,-g],[0,-h,-h],[0,g,-g],[0,h,-h],[0,-g,g],[0,-h,h]],f=0,g=e.length;f<
-g;f++)d.vertices.push(new THREE.Vector3(e[f][0],e[f][1],e[f][2]));this.lightLine=new THREE.Line(d,c,THREE.LinePieces);this.add(this.lightLine)};THREE.PointLightHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.PointLightHelper.prototype.update=function(){this.color.copy(this.light.color);var a=THREE.Math.clamp(this.light.intensity,0,1);this.color.r=this.color.r*a;this.color.g=this.color.g*a;this.color.b=this.color.b*a;this.lightSphere.material.color.copy(this.color);this.lightLine.material.color.copy(this.color)};
-THREE.SubdivisionModifier=function(a){this.subdivisions=a===void 0?1:a;this.useOldVertexColors=false;this.supportUVs=true;this.debug=false};THREE.SubdivisionModifier.prototype.modify=function(a){for(var b=this.subdivisions;b-- >0;)this.smooth(a)};THREE.GeometryUtils.orderedKey=function(a,b){return Math.min(a,b)+"_"+Math.max(a,b)};
+THREE.DirectionalLightHelper=function(a,b,c){THREE.Object3D.call(this);this.light=a;this.position=a.position;this.direction=new THREE.Vector3;this.direction.sub(a.target.position,a.position);this.color=a.color.clone();this.color.r=this.color.r*a.intensity;this.color.g=this.color.g*a.intensity;this.color.b=this.color.b*a.intensity;var d=this.color.getHex(),e=new THREE.SphereGeometry(b,16,8),f=new THREE.AsteriskGeometry(b*1.25,b*2.25),g=new THREE.MeshBasicMaterial({color:d,fog:false}),h=new THREE.LineBasicMaterial({color:d,
+fog:false});this.lightArrow=new THREE.ArrowHelper(this.direction,null,c,d);this.lightSphere=new THREE.Mesh(e,g);this.lightArrow.cone.material.fog=false;this.lightArrow.line.material.fog=false;this.lightRays=new THREE.Line(f,h,THREE.LinePieces);this.add(this.lightArrow);this.add(this.lightSphere);this.add(this.lightRays);this.lightSphere.properties.isGizmo=true;this.lightSphere.properties.gizmoSubject=a;this.lightSphere.properties.gizmoRoot=this;this.targetSphere=null;if(a.target.properties.targetInverse){b=
+new THREE.SphereGeometry(b,8,4);c=new THREE.MeshBasicMaterial({color:d,wireframe:true,fog:false});this.targetSphere=new THREE.Mesh(b,c);this.targetSphere.position=a.target.position;this.targetSphere.properties.isGizmo=true;this.targetSphere.properties.gizmoSubject=a.target;this.targetSphere.properties.gizmoRoot=this.targetSphere;a=new THREE.LineDashedMaterial({color:d,dashSize:4,gapSize:4,opacity:0.75,transparent:true,fog:false});d=new THREE.Geometry;d.vertices.push(this.position.clone());d.vertices.push(this.targetSphere.position.clone());
+d.computeLineDistances();this.targetLine=new THREE.Line(d,a);this.targetLine.properties.isGizmo=true}this.properties.isGizmo=true};THREE.DirectionalLightHelper.prototype=Object.create(THREE.Object3D.prototype);
+THREE.DirectionalLightHelper.prototype.update=function(){this.direction.sub(this.light.target.position,this.light.position);this.lightArrow.setDirection(this.direction);this.color.copy(this.light.color);var a=THREE.Math.clamp(this.light.intensity,0,1);this.color.r=this.color.r*a;this.color.g=this.color.g*a;this.color.b=this.color.b*a;this.lightArrow.setColor(this.color.getHex());this.lightSphere.material.color.copy(this.color);this.lightRays.material.color.copy(this.color);this.targetSphere.material.color.copy(this.color);
+this.targetLine.material.color.copy(this.color);this.targetLine.geometry.vertices[0].copy(this.light.position);this.targetLine.geometry.vertices[1].copy(this.light.target.position);this.targetLine.geometry.computeLineDistances();this.targetLine.geometry.verticesNeedUpdate=true};
+THREE.PointLightHelper=function(a,b){THREE.Object3D.call(this);this.light=a;this.position=a.position;this.color=a.color.clone();this.color.r=this.color.r*a.intensity;this.color.g=this.color.g*a.intensity;this.color.b=this.color.b*a.intensity;var c=this.color.getHex(),d=new THREE.SphereGeometry(b,16,8),e=new THREE.AsteriskGeometry(b*1.25,b*2.25),f=new THREE.MeshBasicMaterial({color:c,fog:false}),c=new THREE.LineBasicMaterial({color:c,fog:false});this.lightSphere=new THREE.Mesh(d,f);this.lightRays=
+new THREE.Line(e,c,THREE.LinePieces);this.add(this.lightSphere);this.add(this.lightRays);this.lightSphere.properties.isGizmo=true;this.lightSphere.properties.gizmoSubject=a;this.lightSphere.properties.gizmoRoot=this;this.properties.isGizmo=true};THREE.PointLightHelper.prototype=Object.create(THREE.Object3D.prototype);
+THREE.PointLightHelper.prototype.update=function(){this.color.copy(this.light.color);var a=THREE.Math.clamp(this.light.intensity,0,1);this.color.r=this.color.r*a;this.color.g=this.color.g*a;this.color.b=this.color.b*a;this.lightSphere.material.color.copy(this.color);this.lightRays.material.color.copy(this.color)};THREE.SubdivisionModifier=function(a){this.subdivisions=a===void 0?1:a;this.useOldVertexColors=false;this.supportUVs=true;this.debug=false};
+THREE.SubdivisionModifier.prototype.modify=function(a){for(var b=this.subdivisions;b-- >0;)this.smooth(a)};THREE.GeometryUtils.orderedKey=function(a,b){return Math.min(a,b)+"_"+Math.max(a,b)};
 THREE.GeometryUtils.computeEdgeFaces=function(a){function b(a,b){g[a]===void 0&&(g[a]=[]);g[a].push(b)}var c,d,e,f,g={},h=THREE.GeometryUtils.orderedKey;c=0;for(d=a.faces.length;c<d;c++){e=a.faces[c];if(e instanceof THREE.Face3){f=h(e.a,e.b);b(f,c);f=h(e.b,e.c);b(f,c);f=h(e.c,e.a);b(f,c)}else if(e instanceof THREE.Face4){f=h(e.a,e.b);b(f,c);f=h(e.b,e.c);b(f,c);f=h(e.c,e.d);b(f,c);f=h(e.d,e.a);b(f,c)}}return g};
 THREE.SubdivisionModifier.prototype.smooth=function(a){function b(){m.debug&&(console&&console.assert)&&console.assert.apply(console,arguments)}function c(){m.debug&&console.log.apply(console,arguments)}function d(){console&&console.log.apply(console,arguments)}function e(a,b,d,e,g,h,l){var n=new THREE.Face4(a,b,d,e,null,g.color,g.materialIndex);if(m.useOldVertexColors){n.vertexColors=[];for(var o,p,q,s=0;s<4;s++){q=h[s];o=new THREE.Color;o.setRGB(0,0,0);for(var r=0;r<q.length;r++){p=g.vertexColors[q[r]-
 1];o.r=o.r+p.r;o.g=o.g+p.g;o.b=o.b+p.b}o.r=o.r/q.length;o.g=o.g/q.length;o.b=o.b/q.length;n.vertexColors[s]=o}}i.push(n);if(m.supportUVs){g=[f(a,""),f(b,l),f(d,l),f(e,l)];g[0]?g[1]?g[2]?g[3]?j.push(g):c("d :( ",e+":"+l):c("c :( ",d+":"+l):c("b :( ",b+":"+l):c("a :( ",a+":"+l)}}function f(a,b){var e=a+":"+b,f=u[e];if(!f){a>=q&&a<q+o.length?c("face pt"):c("edge pt");d("warning, UV not found for",e);return null}return f}function g(a,b,c){var e=a+":"+b;e in u?d("dup vertexNo",a,"oldFaceNo",b,"value",

+ 40 - 0
src/extras/geometries/AsteriskGeometry.js

@@ -0,0 +1,40 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ *	- 3d asterisk shape (for line pieces THREE.Line)
+ */
+
+THREE.AsteriskGeometry = function ( innerRadius, outerRadius ) {
+
+	THREE.Geometry.call( this );
+
+	var sd = innerRadius;
+	var ed = outerRadius;
+
+	var sd2 = 0.707 * sd;
+	var ed2 = 0.707 * ed;
+
+	var rays = [ [ sd, 0, 0 ], [ ed, 0, 0 ], [ -sd, 0, 0 ], [ -ed, 0, 0 ],
+				 [ 0, sd, 0 ], [ 0, ed, 0 ], [ 0, -sd, 0 ], [ 0, -ed, 0 ],
+				 [ 0, 0, sd ], [ 0, 0, ed ], [ 0, 0, -sd ], [ 0, 0, -ed ],
+				 [ sd2, sd2, 0 ], [ ed2, ed2, 0 ], [ -sd2, -sd2, 0 ], [ -ed2, -ed2, 0 ],
+				 [ sd2, -sd2, 0 ], [ ed2, -ed2, 0 ], [ -sd2, sd2, 0 ], [ -ed2, ed2, 0 ],
+				 [ sd2, 0, sd2 ], [ ed2, 0, ed2 ], [ -sd2, 0, -sd2 ], [ -ed2, 0, -ed2 ],
+				 [ sd2, 0, -sd2 ], [ ed2, 0, -ed2 ], [ -sd2, 0, sd2 ], [ -ed2, 0, ed2 ],
+				 [ 0, sd2, sd2 ], [ 0, ed2, ed2 ], [ 0, -sd2, -sd2 ], [ 0, -ed2, -ed2 ],
+				 [ 0, sd2, -sd2 ], [ 0, ed2, -ed2 ], [ 0, -sd2, sd2 ], [ 0, -ed2, ed2 ]
+	];
+
+	for ( var i = 0, il = rays.length; i < il; i ++ ) {
+
+		var x = rays[ i ][ 0 ];
+		var y = rays[ i ][ 1 ];
+		var z = rays[ i ][ 2 ];
+
+		this.vertices.push( new THREE.Vector3( x, y, z ) );
+
+	}
+
+};
+
+THREE.AsteriskGeometry.prototype = Object.create( THREE.Geometry.prototype );

+ 33 - 13
src/extras/helpers/DirectionalLightHelper.js

@@ -10,9 +10,16 @@ THREE.DirectionalLightHelper = function ( light, sphereSize, arrowLength ) {
 
 	this.light = light;
 
+	// position
+
 	this.position = light.position;
 
-	this.properties.isGizmo = true;
+	// direction
+
+	this.direction = new THREE.Vector3();
+	this.direction.sub( light.target.position, light.position );
+
+	// color
 
 	this.color = light.color.clone();
 
@@ -22,26 +29,37 @@ THREE.DirectionalLightHelper = function ( light, sphereSize, arrowLength ) {
 
 	var hexColor = this.color.getHex();
 
-	this.direction = new THREE.Vector3();
-	this.direction.sub( light.target.position, light.position );
+	// light helper
+
+	var bulbGeometry = new THREE.SphereGeometry( sphereSize, 16, 8 );
+	var raysGeometry = new THREE.AsteriskGeometry( sphereSize * 1.25, sphereSize * 2.25 );
 
-	var targetGeo = new THREE.SphereGeometry( sphereSize, 8, 4 );
-	var lightGeo = new THREE.SphereGeometry( sphereSize, 16, 8 );
-	var lightMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false } );
+	var bulbMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false } );
+	var raysMaterial = new THREE.LineBasicMaterial( { color: hexColor, fog: false } );
 
 	this.lightArrow = new THREE.ArrowHelper( this.direction, null, arrowLength, hexColor );
-	this.lightSphere = new THREE.Mesh( lightGeo, lightMaterial );
+	this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );
 
 	this.lightArrow.cone.material.fog = false;
 	this.lightArrow.line.material.fog = false;
 
+	this.lightRays = new THREE.Line( raysGeometry, raysMaterial, THREE.LinePieces );
+
 	this.add( this.lightArrow );
 	this.add( this.lightSphere );
+	this.add( this.lightRays );
+
+	this.lightSphere.properties.isGizmo = true;
+	this.lightSphere.properties.gizmoSubject = light;
+	this.lightSphere.properties.gizmoRoot = this;
+
+	// light target helper
 
 	this.targetSphere = null;
 
 	if ( light.target.properties.targetInverse ) {
 
+		var targetGeo = new THREE.SphereGeometry( sphereSize, 8, 4 );
 		var targetMaterial = new THREE.MeshBasicMaterial( { color: hexColor, wireframe: true, fog: false } );
 
 		this.targetSphere = new THREE.Mesh( targetGeo, targetMaterial );
@@ -62,9 +80,9 @@ THREE.DirectionalLightHelper = function ( light, sphereSize, arrowLength ) {
 
 	}
 
-	this.lightSphere.properties.isGizmo = true;
-	this.lightSphere.properties.gizmoSubject = light;
-	this.lightSphere.properties.gizmoRoot = this;
+	//
+
+	this.properties.isGizmo = true;
 
 }
 
@@ -72,13 +90,13 @@ THREE.DirectionalLightHelper.prototype = Object.create( THREE.Object3D.prototype
 
 THREE.DirectionalLightHelper.prototype.update = function () {
 
-	// set arrow orientation
+	// update arrow orientation
 	// pointing from light to target
 
 	this.direction.sub( this.light.target.position, this.light.position );
 	this.lightArrow.setDirection( this.direction );
 
-	// set arrow and spheres colors to light color * light intensity
+	// update arrow, spheres, rays and line colors to light color * light intensity
 
 	this.color.copy( this.light.color );
 
@@ -89,10 +107,12 @@ THREE.DirectionalLightHelper.prototype.update = function () {
 
 	this.lightArrow.setColor( this.color.getHex() );
 	this.lightSphere.material.color.copy( this.color );
+	this.lightRays.material.color.copy( this.color );
+
 	this.targetSphere.material.color.copy( this.color );
 	this.targetLine.material.color.copy( this.color );
 
-	// set target line
+	// update target line vertices
 
 	this.targetLine.geometry.vertices[ 0 ].copy( this.light.position );
 	this.targetLine.geometry.vertices[ 1 ].copy( this.light.target.position );

+ 19 - 38
src/extras/helpers/PointLightHelper.js

@@ -10,9 +10,11 @@ THREE.PointLightHelper = function ( light, sphereSize ) {
 
 	this.light = light;
 
+	// position
+
 	this.position = light.position;
 
-	this.properties.isGizmo = true;
+	// color
 
 	this.color = light.color.clone();
 
@@ -22,50 +24,29 @@ THREE.PointLightHelper = function ( light, sphereSize ) {
 
 	var hexColor = this.color.getHex();
 
-	var lightGeo = new THREE.SphereGeometry( sphereSize, 16, 8 );
-	var lightMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false } );
+	// light helper
+
+	var bulbGeometry = new THREE.SphereGeometry( sphereSize, 16, 8 );
+	var raysGeometry = new THREE.AsteriskGeometry( sphereSize * 1.25, sphereSize * 2.25 );
+
+	var bulbMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false } );
+	var raysMaterial = new THREE.LineBasicMaterial( { color: hexColor, fog: false } );
 
-	this.lightSphere = new THREE.Mesh( lightGeo, lightMaterial );
+	this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );
+	this.lightRays = new THREE.Line( raysGeometry, raysMaterial, THREE.LinePieces );
 
 	this.add( this.lightSphere );
+	this.add( this.lightRays );
+
+	//
 
 	this.lightSphere.properties.isGizmo = true;
 	this.lightSphere.properties.gizmoSubject = light;
 	this.lightSphere.properties.gizmoRoot = this;
 
-	var lineMaterial = new THREE.LineBasicMaterial( { color: hexColor, fog: false } );
-	var lineGeometry = new THREE.Geometry();
-
-	var sd = sphereSize * 1.25;
-	var ed = sphereSize * 2.25;
-
-	var sd2 = 0.707 * sd;
-	var ed2 = 0.707 * ed;
+	//
 
-	var rays = [ [ sd, 0, 0 ], [ ed, 0, 0 ], [ -sd, 0, 0 ], [ -ed, 0, 0 ],
-				 [ 0, sd, 0 ], [ 0, ed, 0 ], [ 0, -sd, 0 ], [ 0, -ed, 0 ],
-				 [ 0, 0, sd ], [ 0, 0, ed ], [ 0, 0, -sd ], [ 0, 0, -ed ],
-				 [ sd2, sd2, 0 ], [ ed2, ed2, 0 ], [ -sd2, -sd2, 0 ], [ -ed2, -ed2, 0 ],
-				 [ sd2, -sd2, 0 ], [ ed2, -ed2, 0 ], [ -sd2, sd2, 0 ], [ -ed2, ed2, 0 ],
-				 [ sd2, 0, sd2 ], [ ed2, 0, ed2 ], [ -sd2, 0, -sd2 ], [ -ed2, 0, -ed2 ],
-				 [ sd2, 0, -sd2 ], [ ed2, 0, -ed2 ], [ -sd2, 0, sd2 ], [ -ed2, 0, ed2 ],
-				 [ 0, sd2, sd2 ], [ 0, ed2, ed2 ], [ 0, -sd2, -sd2 ], [ 0, -ed2, -ed2 ],
-				 [ 0, sd2, -sd2 ], [ 0, ed2, -ed2 ], [ 0, -sd2, sd2 ], [ 0, -ed2, ed2 ]
-	];
-
-	for ( var i = 0, il = rays.length; i < il; i ++ ) {
-
-		var x = rays[ i ][ 0 ];
-		var y = rays[ i ][ 1 ];
-		var z = rays[ i ][ 2 ];
-
-		lineGeometry.vertices.push( new THREE.Vector3( x, y, z ) );
-
-	}
-
-	this.lightLine = new THREE.Line( lineGeometry, lineMaterial, THREE.LinePieces );
-
-	this.add( this.lightLine );
+	this.properties.isGizmo = true;
 
 }
 
@@ -73,7 +54,7 @@ THREE.PointLightHelper.prototype = Object.create( THREE.Object3D.prototype );
 
 THREE.PointLightHelper.prototype.update = function () {
 
-	// set sphere color to light color * light intensity
+	// update sphere and rays colors to light color * light intensity
 
 	this.color.copy( this.light.color );
 
@@ -83,7 +64,7 @@ THREE.PointLightHelper.prototype.update = function () {
 	this.color.b *= intensity;
 
 	this.lightSphere.material.color.copy( this.color );
-	this.lightLine.material.color.copy( this.color );
+	this.lightRays.material.color.copy( this.color );
 
 }
 

+ 1 - 0
utils/includes/extras.json

@@ -15,6 +15,7 @@
 	"../src/extras/animation/KeyFrameAnimation.js",
 	"../src/extras/cameras/CubeCamera.js",
 	"../src/extras/cameras/CombinedCamera.js",
+	"../src/extras/geometries/AsteriskGeometry.js",
 	"../src/extras/geometries/CircleGeometry.js",
 	"../src/extras/geometries/CubeGeometry.js",
 	"../src/extras/geometries/CylinderGeometry.js",