浏览代码

Editor: More userData dependency clean up.

Mr.doob 12 年之前
父节点
当前提交
bbd6beee39
共有 3 个文件被更改,包括 14 次插入11 次删除
  1. 3 7
      editor/js/ui/Menubar.Add.js
  2. 9 1
      editor/js/ui/Viewport.js
  3. 2 3
      src/extras/helpers/DirectionalLightHelper.js

+ 3 - 7
editor/js/ui/Menubar.Add.js

@@ -160,7 +160,7 @@ Menubar.Add = function ( signals ) {
 	} );
 	} );
 	options.add( option );
 	options.add( option );
 
 
-	// add torus
+	// add torus knot
 
 
 	var option = new UI.Panel();
 	var option = new UI.Panel();
 	option.setClass( 'option' );
 	option.setClass( 'option' );
@@ -224,9 +224,7 @@ Menubar.Add = function ( signals ) {
 
 
 		var light = new THREE.SpotLight( color, intensity, distance, angle, exponent );
 		var light = new THREE.SpotLight( color, intensity, distance, angle, exponent );
 		light.name = 'SpotLight ' + light.id;
 		light.name = 'SpotLight ' + light.id;
-		light.target.name = 'SpotLight ' + light.id + ' target';
-
-		light.target.userData.targetInverse = light;
+		light.target.name = 'SpotLight ' + light.id + ' Target';
 
 
 		light.position.set( 0, 1, 0 ).multiplyScalar( 200 );
 		light.position.set( 0, 1, 0 ).multiplyScalar( 200 );
 
 
@@ -247,9 +245,7 @@ Menubar.Add = function ( signals ) {
 
 
 		var light = new THREE.DirectionalLight( color, intensity );
 		var light = new THREE.DirectionalLight( color, intensity );
 		light.name = 'DirectionalLight ' + light.id;
 		light.name = 'DirectionalLight ' + light.id;
-		light.target.name = 'DirectionalLight ' + light.id + ' target';
-
-		light.target.userData.targetInverse = light;
+		light.target.name = 'DirectionalLight ' + light.id + ' Target';
 
 
 		light.position.set( 1, 1, 1 ).multiplyScalar( 200 );
 		light.position.set( 1, 1, 1 ).multiplyScalar( 200 );
 
 

+ 9 - 1
editor/js/ui/Viewport.js

@@ -361,7 +361,7 @@ var Viewport = function ( signals ) {
 
 
 			var helper = objectsToHelpers[ selected.id ];
 			var helper = objectsToHelpers[ selected.id ];
 
 
-			objects.splice( objects.indexOf( helper ), 1 );
+			objects.splice( objects.indexOf( helper.lightSphere ), 1 );
 
 
 			helper.parent.remove( helper );
 			helper.parent.remove( helper );
 			selected.parent.remove( selected );
 			selected.parent.remove( selected );
@@ -371,6 +371,13 @@ var Viewport = function ( signals ) {
 
 
 			updateMaterials( scene );
 			updateMaterials( scene );
 
 
+			if ( selected instanceof THREE.DirectionalLight ||
+			     selected instanceof THREE.SpotLight ) {
+
+				selected.target.parent.remove( selected.target );
+
+			}
+
 		} else {
 		} else {
 
 
 			selected.traverse( function ( object ) {
 			selected.traverse( function ( object ) {
@@ -389,6 +396,7 @@ var Viewport = function ( signals ) {
 
 
 		}
 		}
 
 
+		signals.sceneChanged.dispatch( scene );
 		signals.objectSelected.dispatch( null );
 		signals.objectSelected.dispatch( null );
 
 
 	} );
 	} );

+ 2 - 3
src/extras/helpers/DirectionalLightHelper.js

@@ -20,8 +20,8 @@ THREE.DirectionalLightHelper = function ( light, sphereSize ) {
 	this.add( this.lightSphere );
 	this.add( this.lightSphere );
 
 
 	var lineGeometry = new THREE.Geometry();
 	var lineGeometry = new THREE.Geometry();
-	lineGeometry.vertices.push( this.light.position.clone() );
-	lineGeometry.vertices.push( new THREE.Vector3() );
+	lineGeometry.vertices.push( this.light.position );
+	lineGeometry.vertices.push( this.light.target.position );
 	lineGeometry.computeLineDistances();
 	lineGeometry.computeLineDistances();
 
 
 	var lineMaterial = new THREE.LineDashedMaterial( { dashSize: 4, gapSize: 4, opacity: 0.75, transparent: true, fog: false } );
 	var lineMaterial = new THREE.LineDashedMaterial( { dashSize: 4, gapSize: 4, opacity: 0.75, transparent: true, fog: false } );
@@ -52,7 +52,6 @@ THREE.DirectionalLightHelper.prototype.update = function () {
 	this.lightSphere.position.copy( this.light.position );
 	this.lightSphere.position.copy( this.light.position );
 	this.lightSphere.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );
 	this.lightSphere.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );
 
 
-	this.targetLine.geometry.vertices[ 0 ].copy( this.light.position );
 	this.targetLine.geometry.computeLineDistances();
 	this.targetLine.geometry.computeLineDistances();
 	this.targetLine.geometry.verticesNeedUpdate = true;
 	this.targetLine.geometry.verticesNeedUpdate = true;
 	this.targetLine.material.color.copy( this.lightSphere.material.color );
 	this.targetLine.material.color.copy( this.lightSphere.material.color );