浏览代码

Improvements to SpotLightHelper as suggested by @WestLangley in 890a7571fd40b2c2f1fe79486621fa925d796245.

Mr.doob 12 年之前
父节点
当前提交
aad2dc3481
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      src/extras/helpers/SpotLightHelper.js

+ 6 - 2
src/extras/helpers/SpotLightHelper.js

@@ -33,6 +33,7 @@ THREE.SpotLightHelper.prototype = Object.create( THREE.Object3D.prototype );
 THREE.SpotLightHelper.prototype.update = function () {
 
 	var vector = new THREE.Vector3();
+	var vector2 = new THREE.Vector3();
 
 	return function () {
 
@@ -41,10 +42,13 @@ THREE.SpotLightHelper.prototype.update = function () {
 
 		this.cone.scale.set( coneWidth, coneWidth, coneLength );
 
-		this.cone.lookAt( vector.getPositionFromMatrix( this.light.matrixWorld ).negate() );
+		vector.getPositionFromMatrix( this.light.matrixWorld );
+		vector2.getPositionFromMatrix( this.light.target.matrixWorld );
+
+		this.cone.lookAt( vector2.sub( vector ) );
 
 		this.cone.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );
 
-	}
+	};
 
 }();