소스 검색

Add OrthographicCamera

Temdog007 6 년 전
부모
커밋
e058922d59
4개의 변경된 파일128개의 추가작업 그리고 4개의 파일을 삭제
  1. 13 0
      editor/js/Menubar.Add.js
  2. 102 1
      editor/js/Sidebar.Object.js
  3. 5 0
      editor/js/Strings.js
  4. 8 3
      editor/js/Viewport.js

+ 13 - 0
editor/js/Menubar.Add.js

@@ -388,6 +388,19 @@ Menubar.Add = function ( editor ) {
 	} );
 	options.add( option );
 
+	// OrthographicCamera
+
+	var option = new UI.Row();
+	option.setClass('option');
+	option.setTextContent(strings.getKey('menubar/add/orthographiccamera'));
+	option.onClick(function(){
+		var camera = new THREE.OrthographicCamera();
+		camera.name = 'OrthographicCamera';
+
+		editor.execute(new AddObjectCommand(camera));
+	});
+	options.add(option);
+
 	return container;
 
 };

+ 102 - 1
editor/js/Sidebar.Object.js

@@ -146,6 +146,46 @@ Sidebar.Object = function ( editor ) {
 
 	container.add( objectFovRow );
 
+	// left
+
+	var objectLeftRow = new UI.Row();
+	var objectLeft = new UI.Number().onChange(update);
+
+	objectLeftRow.add(new UI.Text(strings.getKey('sidebar/object/left')).setWidth('90px'));
+	objectLeftRow.add(objectLeft);
+
+	container.add(objectLeftRow);
+
+	// right
+	
+	var objectRightRow = new UI.Row();
+	var objectRight = new UI.Number().onChange(update);
+
+	objectRightRow.add(new UI.Text(strings.getKey('sidebar/object/right')).setWidth('90px'));
+	objectRightRow.add(objectRight);
+
+	container.add(objectRightRow);
+
+	// top
+	
+	var objectTopRow = new UI.Row();
+	var objectTop = new UI.Number().onChange(update);
+
+	objectTopRow.add(new UI.Text(strings.getKey('sidebar/object/top')).setWidth('90px'));
+	objectTopRow.add(objectTop);
+
+	container.add(objectTopRow);
+
+	// bottom
+	
+	var objectBottomRow = new UI.Row();
+	var objectBottom = new UI.Number().onChange(update);
+
+	objectBottomRow.add(new UI.Text(strings.getKey('sidebar/object/bottom')).setWidth('90px'));
+	objectBottomRow.add(objectBottom);
+
+	container.add(objectBottomRow);
+
 	// near
 
 	var objectNearRow = new UI.Row();
@@ -400,16 +440,49 @@ Sidebar.Object = function ( editor ) {
 
 			}
 
+			if ( object.left !== undefined && Math.abs( object.left - objectLeft.getValue() ) >= 0.01 ) {
+
+				editor.execute( new SetValueCommand( object, 'left', objectLeft.getValue() ) );
+				object.updateProjectionMatrix();
+
+			}
+
+			if ( object.right !== undefined && Math.abs( object.right - objectRight.getValue() ) >= 0.01 ) {
+
+				editor.execute( new SetValueCommand( object, 'right', objectRight.getValue() ) );
+				object.updateProjectionMatrix();
+
+			}
+
+			if ( object.top !== undefined && Math.abs( object.top - objectTop.getValue() ) >= 0.01 ) {
+
+				editor.execute( new SetValueCommand( object, 'top', objectTop.getValue() ) );
+				object.updateProjectionMatrix();
+
+			}
+
+			if ( object.bottom !== undefined && Math.abs( object.bottom - objectBottom.getValue() ) >= 0.01 ) {
+
+				editor.execute( new SetValueCommand( object, 'bottom', objectBottom.getValue() ) );
+				object.updateProjectionMatrix();
+
+			}
+
 			if ( object.near !== undefined && Math.abs( object.near - objectNear.getValue() ) >= 0.01 ) {
 
 				editor.execute( new SetValueCommand( object, 'near', objectNear.getValue() ) );
+				if(object.isOrthographicCamera){
+					object.updateProjectionMatrix();
+				}
 
 			}
 
 			if ( object.far !== undefined && Math.abs( object.far - objectFar.getValue() ) >= 0.01 ) {
 
 				editor.execute( new SetValueCommand( object, 'far', objectFar.getValue() ) );
-
+				if(object.isOrthographicCamera){
+					object.updateProjectionMatrix();
+				}
 			}
 
 			if ( object.intensity !== undefined && Math.abs( object.intensity - objectIntensity.getValue() ) >= 0.01 ) {
@@ -518,6 +591,10 @@ Sidebar.Object = function ( editor ) {
 
 		var properties = {
 			'fov': objectFovRow,
+			'left': objectLeftRow,
+			'right': objectRightRow,
+			'top': objectTopRow,
+			'bottom': objectBottomRow,
 			'near': objectNearRow,
 			'far': objectFarRow,
 			'intensity': objectIntensityRow,
@@ -617,6 +694,30 @@ Sidebar.Object = function ( editor ) {
 
 		}
 
+		if ( object.left !== undefined ) {
+
+			objectLeft.setValue( object.left );
+
+		}
+
+		if ( object.right !== undefined ) {
+
+			objectRight.setValue( object.right );
+
+		}
+
+		if ( object.top !== undefined ) {
+
+			objectTop.setValue( object.top );
+
+		}
+
+		if ( object.bottom !== undefined ) {
+
+			objectBottom.setValue( object.bottom );
+
+		}
+
 		if ( object.near !== undefined ) {
 
 			objectNear.setValue( object.near );

+ 5 - 0
editor/js/Strings.js

@@ -51,6 +51,7 @@ var Strings = function ( config ) {
 			'menubar/add/hemispherelight': 'HemisphereLight',
 			'menubar/add/ambientlight': 'AmbientLight',
 			'menubar/add/perspectivecamera': 'PerspectiveCamera',
+			'menubar/add/orthographiccamera': 'OrthographicCamera',
 
 			'menubar/status/autosave': 'autosave',
 
@@ -81,6 +82,10 @@ var Strings = function ( config ) {
 			'sidebar/object/rotation': 'Rotation',
 			'sidebar/object/scale': 'Scale',
 			'sidebar/object/fov': 'Fov',
+			'sidebar/object/left': 'Left',
+			'sidebar/object/right': 'Right',
+			'sidebar/object/top': 'Top',
+			'sidebar/object/bottom': 'Bottom',
 			'sidebar/object/near': 'Near',
 			'sidebar/object/far': 'Far',
 			'sidebar/object/intensity': 'Intensity',

+ 8 - 3
editor/js/Viewport.js

@@ -503,10 +503,15 @@ var Viewport = function ( editor ) {
 
 	signals.viewportCameraChanged.add( function ( viewportCamera ) {
 
-		camera = viewportCamera;
+		if(viewportCamera.isPerspectiveCamera) {
+			viewportCamera.aspect = editor.camera.aspect;
+			viewportCamera.projectionMatrix.copy( editor.camera.projectionMatrix );
+		}
+		else if(!viewportCamera.isOrthographicCamera){
+			throw "Invalid camera set as viewport";
+		}
 
-		camera.aspect = editor.camera.aspect;
-		camera.projectionMatrix.copy( editor.camera.projectionMatrix );
+		camera = viewportCamera;
 
 		render();