فهرست منبع

Editor: Fixed null object unhandled cases and optimised Object3D panel.

Mr.doob 11 سال پیش
والد
کامیت
16f8af7497
3فایلهای تغییر یافته به همراه71 افزوده شده و 71 حذف شده
  1. 2 0
      editor/js/Sidebar.Geometry.BufferGeometry.js
  2. 2 0
      editor/js/Sidebar.Geometry.Geometry.js
  3. 67 71
      editor/js/Sidebar.Object3D.js

+ 2 - 0
editor/js/Sidebar.Geometry.BufferGeometry.js

@@ -26,6 +26,8 @@ Sidebar.Geometry.BufferGeometry = function ( signals ) {
 
 	var update = function ( object ) {
 
+		if ( object === null ) return;
+
 		var geometry = object.geometry;
 
 		if ( geometry instanceof THREE.BufferGeometry ) { 

+ 2 - 0
editor/js/Sidebar.Geometry.Geometry.js

@@ -26,6 +26,8 @@ Sidebar.Geometry.Geometry = function ( signals ) {
 
 	var update = function ( object ) {
 
+		if ( object === null ) return;
+
 		var geometry = object.geometry;
 
 		if ( geometry instanceof THREE.Geometry ) { 

+ 67 - 71
editor/js/Sidebar.Object3D.js

@@ -372,9 +372,7 @@ Sidebar.Object3D = function ( editor ) {
 
 	}
 
-	function updateRows() {
-
-		var object = editor.selected;
+	function updateRows( object ) {
 
 		var properties = {
 			'parent': objectParentRow,
@@ -397,9 +395,7 @@ Sidebar.Object3D = function ( editor ) {
 
 	}
 
-	function updateTransformRows() {
-
-		var object = editor.selected;
+	function updateTransformRows( object ) {
 
 		if ( object instanceof THREE.Light ||
 		   ( object instanceof THREE.Object3D && object.userData.targetInverse ) ) {
@@ -420,7 +416,18 @@ Sidebar.Object3D = function ( editor ) {
 
 	signals.objectSelected.add( function ( object ) {
 
-		updateUI();
+		if ( object !== null ) {
+
+			container.setDisplay( 'block' );
+
+			updateRows( object );
+			updateUI( object );
+
+		} else {
+
+			container.setDisplay( 'none' );
+
+		}
 
 	} );
 
@@ -454,116 +461,105 @@ Sidebar.Object3D = function ( editor ) {
 
 		if ( object !== editor.selected ) return;
 
-		updateUI();
+		updateUI( object );
 
 	} );
 
-	function updateUI() {
-
-		container.setDisplay( 'none' );
-
-		var object = editor.selected;
-
-		if ( object !== null ) {
-
-			container.setDisplay( 'block' );
-
-			objectType.setValue( editor.getObjectType( object ) );
+	function updateUI( object ) {
 
-			objectUUID.setValue( object.uuid );
-			objectName.setValue( object.name );
+		objectType.setValue( editor.getObjectType( object ) );
 
-			if ( object.parent !== undefined ) {
+		objectUUID.setValue( object.uuid );
+		objectName.setValue( object.name );
 
-				objectParent.setValue( object.parent.id );
+		if ( object.parent !== undefined ) {
 
-			}
+			objectParent.setValue( object.parent.id );
 
-			objectPositionX.setValue( object.position.x );
-			objectPositionY.setValue( object.position.y );
-			objectPositionZ.setValue( object.position.z );
+		}
 
-			objectRotationX.setValue( object.rotation.x );
-			objectRotationY.setValue( object.rotation.y );
-			objectRotationZ.setValue( object.rotation.z );
+		objectPositionX.setValue( object.position.x );
+		objectPositionY.setValue( object.position.y );
+		objectPositionZ.setValue( object.position.z );
 
-			objectScaleX.setValue( object.scale.x );
-			objectScaleY.setValue( object.scale.y );
-			objectScaleZ.setValue( object.scale.z );
+		objectRotationX.setValue( object.rotation.x );
+		objectRotationY.setValue( object.rotation.y );
+		objectRotationZ.setValue( object.rotation.z );
 
-			if ( object.fov !== undefined ) {
+		objectScaleX.setValue( object.scale.x );
+		objectScaleY.setValue( object.scale.y );
+		objectScaleZ.setValue( object.scale.z );
 
-				objectFov.setValue( object.fov );
+		if ( object.fov !== undefined ) {
 
-			}
+			objectFov.setValue( object.fov );
 
-			if ( object.near !== undefined ) {
+		}
 
-				objectNear.setValue( object.near );
+		if ( object.near !== undefined ) {
 
-			}
+			objectNear.setValue( object.near );
 
-			if ( object.far !== undefined ) {
+		}
 
-				objectFar.setValue( object.far );
+		if ( object.far !== undefined ) {
 
-			}
+			objectFar.setValue( object.far );
 
-			if ( object.intensity !== undefined ) {
+		}
 
-				objectIntensity.setValue( object.intensity );
+		if ( object.intensity !== undefined ) {
 
-			}
+			objectIntensity.setValue( object.intensity );
 
-			if ( object.color !== undefined ) {
+		}
 
-				objectColor.setHexValue( object.color.getHexString() );
+		if ( object.color !== undefined ) {
 
-			}
+			objectColor.setHexValue( object.color.getHexString() );
 
-			if ( object.groundColor !== undefined ) {
+		}
 
-				objectGroundColor.setHexValue( object.groundColor.getHexString() );
+		if ( object.groundColor !== undefined ) {
 
-			}
+			objectGroundColor.setHexValue( object.groundColor.getHexString() );
 
-			if ( object.distance !== undefined ) {
+		}
 
-				objectDistance.setValue( object.distance );
+		if ( object.distance !== undefined ) {
 
-			}
+			objectDistance.setValue( object.distance );
 
-			if ( object.angle !== undefined ) {
+		}
 
-				objectAngle.setValue( object.angle );
+		if ( object.angle !== undefined ) {
 
-			}
+			objectAngle.setValue( object.angle );
 
-			if ( object.exponent !== undefined ) {
+		}
 
-				objectExponent.setValue( object.exponent );
+		if ( object.exponent !== undefined ) {
 
-			}
+			objectExponent.setValue( object.exponent );
 
-			objectVisible.setValue( object.visible );
+		}
 
-			try {
+		objectVisible.setValue( object.visible );
 
-				objectUserData.setValue( JSON.stringify( object.userData, null, '  ' ) );
+		try {
 
-			} catch ( error ) {
+			objectUserData.setValue( JSON.stringify( object.userData, null, '  ' ) );
 
-				console.log( error );
+		} catch ( error ) {
 
-			}
+			console.log( error );
 
-			objectUserData.setBorderColor( '#ccc' );
-			objectUserData.setBackgroundColor( '' );
+		}
 
-			updateRows();
-			updateTransformRows();
+		objectUserData.setBorderColor( '#ccc' );
+		objectUserData.setBackgroundColor( '' );
 
-		}
+		updateTransformRows( object );
 
 	}