Browse Source

Editor: Simplifying helpers code.

Mr.doob 12 years ago
parent
commit
2308a6ba39
1 changed files with 18 additions and 41 deletions
  1. 18 41
      editor/js/ui/Viewport.js

+ 18 - 41
editor/js/ui/Viewport.js

@@ -268,51 +268,38 @@ var Viewport = function ( signals ) {
 
 		} else if ( object instanceof THREE.DirectionalLight ) {
 
-			var sphereSize = 5;
-			var arrowLength = 30;
-
-			var lightGizmo = new THREE.DirectionalLightHelper( object, sphereSize, arrowLength );
-			sceneHelpers.add( lightGizmo );
-			sceneHelpers.add( lightGizmo.targetSphere );
-			sceneHelpers.add( lightGizmo.targetLine );
+			var helper = new THREE.DirectionalLightHelper( object, 10 );
+			sceneHelpers.add( helper.lightSphere );
+			sceneHelpers.add( helper.targetLine );
 
-			object.userData.helper = lightGizmo;
-			object.userData.pickingProxy = lightGizmo.lightSphere;
-			object.target.userData.pickingProxy = lightGizmo.targetSphere;
+			objectsToHelpers[ object.id ] = helper.lightSphere;
+			helpersToObjects[ helper.lightSphere.id ] = object;
 
-			objects.push( lightGizmo.lightSphere );
-			objects.push( lightGizmo.targetSphere );
-			objects.push( lightGizmo.targetLine );
+			objects.push( helper.lightSphere );
+			objects.push( helper.targetLine );
 
 		} else if ( object instanceof THREE.SpotLight ) {
 
 			var sphereSize = 5;
 
-			var lightGizmo = new THREE.SpotLightHelper( object, sphereSize );
-			sceneHelpers.add( lightGizmo );
-			sceneHelpers.add( lightGizmo.targetSphere );
-			sceneHelpers.add( lightGizmo.targetLine );
-
-			object.userData.helper = lightGizmo;
-			object.userData.pickingProxy = lightGizmo.lightSphere;
-			object.target.userData.pickingProxy = lightGizmo.targetSphere;
+			var helper = new THREE.SpotLightHelper( object, sphereSize );
+			sceneHelpers.add( helper );
+			sceneHelpers.add( helper.targetSphere );
+			sceneHelpers.add( helper.targetLine );
 
-			objects.push( lightGizmo.lightSphere );
-			objects.push( lightGizmo.targetSphere );
-			objects.push( lightGizmo.targetLine );
+			objects.push( helper.lightSphere );
+			objects.push( helper.targetSphere );
+			objects.push( helper.targetLine );
 
 		} else if ( object instanceof THREE.HemisphereLight ) {
 
 			var sphereSize = 5;
 			var arrowLength = 30;
 
-			var lightGizmo = new THREE.HemisphereLightHelper( object, sphereSize, arrowLength );
-			sceneHelpers.add( lightGizmo );
-
-			object.userData.helper = lightGizmo;
-			object.userData.pickingProxy = lightGizmo.lightSphere;
+			var helper = new THREE.HemisphereLightHelper( object, sphereSize, arrowLength );
+			sceneHelpers.add( helper );
 
-			objects.push( lightGizmo.lightSphere );
+			objects.push( helper.lightSphere );
 
 		} else {
 
@@ -366,20 +353,10 @@ var Viewport = function ( signals ) {
 
 			object.updateProjectionMatrix();
 
-		} else if ( object instanceof THREE.PointLight ) {
+		} else if ( object instanceof THREE.PointLight || object instanceof THREE.DirectionalLight || object instanceof THREE.HemisphereLight || object instanceof THREE.SpotLight ) {
 
 			objectsToHelpers[ object.id ].update();
 
-		} else if ( object instanceof THREE.DirectionalLight ||
-					object instanceof THREE.HemisphereLight ||
-					object instanceof THREE.SpotLight ) {
-
-			object.userData.helper.update();
-
-		} else if ( object.userData.targetInverse ) {
-
-			object.userData.targetInverse.userData.helper.update();
-
 		}
 
 		render();