Browse Source

Editor: plugged in adding of sphere / cube / plane to menubar.

For the moment using just fixed predefined tessellations. I wonder what UI would be good for choosing this.

Todo: better naming scheme for newly created objects.
alteredq 12 years ago
parent
commit
307a5b0b77

+ 6 - 6
editor/index.html

@@ -139,7 +139,7 @@
 								geometry.sourceType = "ctm";
 								geometry.sourceType = "ctm";
 								geometry.sourceFile = file.name;
 								geometry.sourceFile = file.name;
 
 
-								var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
+								var mesh = new THREE.Mesh( geometry, createDummyMaterial() );
 								mesh.name = filename;
 								mesh.name = filename;
 
 
 								signals.objectAdded.dispatch( mesh );
 								signals.objectAdded.dispatch( mesh );
@@ -228,7 +228,7 @@
 								geometry.sourceType = "ascii";
 								geometry.sourceType = "ascii";
 								geometry.sourceFile = file.name;
 								geometry.sourceFile = file.name;
 
 
-								var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
+								var mesh = new THREE.Mesh( geometry, createDummyMaterial() );
 								mesh.name = filename;
 								mesh.name = filename;
 
 
 								signals.objectAdded.dispatch( mesh );
 								signals.objectAdded.dispatch( mesh );
@@ -291,7 +291,7 @@
 							geometry.sourceType = "stl";
 							geometry.sourceType = "stl";
 							geometry.sourceFile = file.name;
 							geometry.sourceFile = file.name;
 
 
-							var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
+							var mesh = new THREE.Mesh( geometry, createDummyMaterial() );
 							mesh.name = filename;
 							mesh.name = filename;
 
 
 							signals.objectAdded.dispatch( mesh );
 							signals.objectAdded.dispatch( mesh );
@@ -335,7 +335,7 @@
 							geometry.sourceType = "vtk";
 							geometry.sourceType = "vtk";
 							geometry.sourceFile = file.name;
 							geometry.sourceFile = file.name;
 
 
-							var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
+							var mesh = new THREE.Mesh( geometry, createDummyMaterial() );
 							mesh.name = filename;
 							mesh.name = filename;
 
 
 							signals.objectAdded.dispatch( mesh );
 							signals.objectAdded.dispatch( mesh );
@@ -362,9 +362,9 @@
 
 
 			};
 			};
 
 
-			var createDummyMaterial = function ( geometry ) {
+			var createDummyMaterial = function () {
 
 
-				return new THREE.MeshLambertMaterial();
+				return new THREE.MeshPhongMaterial();
 
 
 			};
 			};
 
 

+ 59 - 4
editor/js/ui/Menubar.Add.js

@@ -25,25 +25,74 @@ Menubar.Add = function ( signals ) {
 	options.setDisplay( 'none' );
 	options.setDisplay( 'none' );
 	container.add( options );
 	container.add( options );
 
 
-	//
+	// add sphere
 
 
 	var option = new UI.Panel();
 	var option = new UI.Panel();
 	option.setTextContent( 'Sphere' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.setTextContent( 'Sphere' ).setColor( '#666' ).setPadding( '6px 12px' );
-	option.onClick( function () { alert( 'Sphere' ) } );
+	option.onClick( function () {
+
+		var radius = 75;
+		var widthSegments = 32;
+		var heightSegments = 16;
+
+		var geometry = new THREE.SphereGeometry( radius, widthSegments, heightSegments );
+		var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
+		mesh.name = 'Sphere ' + mesh.id;
+
+		signals.objectAdded.dispatch( mesh );
+
+	} );
 	options.add( option );
 	options.add( option );
 
 
 	addHoverStyle( option );
 	addHoverStyle( option );
 
 
+	// add cube
+
 	var option = new UI.Panel();
 	var option = new UI.Panel();
 	option.setTextContent( 'Cube' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.setTextContent( 'Cube' ).setColor( '#666' ).setPadding( '6px 12px' );
-	option.onClick( function () { alert( 'Cube' ) } );
+	option.onClick( function () {
+
+		var width = 100;
+		var height = 100;
+		var depth = 100;
+
+		var widthSegments = 1;
+		var heightSegments = 1;
+		var depthSegments = 1;
+
+		var geometry = new THREE.CubeGeometry( width, height, depth, widthSegments, heightSegments, depthSegments );
+		var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
+		mesh.name = 'Cube ' + mesh.id;
+
+		signals.objectAdded.dispatch( mesh );
+
+
+	} );
 	options.add( option );
 	options.add( option );
 
 
 	addHoverStyle( option );
 	addHoverStyle( option );
 
 
+	// add plane
+
 	var option = new UI.Panel();
 	var option = new UI.Panel();
 	option.setTextContent( 'Plane' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.setTextContent( 'Plane' ).setColor( '#666' ).setPadding( '6px 12px' );
-	option.onClick( function () { alert( 'Plane' ) } );
+	option.onClick( function () {
+
+		var width = 200;
+		var height = 200;
+
+		var widthSegments = 1;
+		var heightSegments = 1;
+
+		var geometry = new THREE.PlaneGeometry( width, height, widthSegments, heightSegments );
+		var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
+		mesh.name = 'Plane ' + mesh.id;
+
+		mesh.rotation.x = - Math.PI/2;
+
+		signals.objectAdded.dispatch( mesh );
+
+	} );
 	options.add( option );
 	options.add( option );
 
 
 	addHoverStyle( option );
 	addHoverStyle( option );
@@ -57,6 +106,12 @@ Menubar.Add = function ( signals ) {
 
 
 	}
 	}
 
 
+	function createDummyMaterial() {
+
+		return new THREE.MeshPhongMaterial();
+
+	};
+
 	return container;
 	return container;
 
 
 }
 }

+ 1 - 1
editor/js/ui/Menubar.Edit.js

@@ -25,7 +25,7 @@ Menubar.Edit = function ( signals ) {
 	options.setDisplay( 'none' );
 	options.setDisplay( 'none' );
 	container.add( options );
 	container.add( options );
 
 
-	//
+	// delete
 
 
 	var option = new UI.Panel();
 	var option = new UI.Panel();
 	option.setTextContent( 'Delete' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.setTextContent( 'Delete' ).setColor( '#666' ).setPadding( '6px 12px' );

+ 9 - 1
editor/js/ui/Menubar.File.js

@@ -25,7 +25,7 @@ Menubar.File = function ( signals ) {
 	options.setDisplay( 'none' );
 	options.setDisplay( 'none' );
 	container.add( options );
 	container.add( options );
 
 
-	//
+	// open
 
 
 	var option = new UI.Panel();
 	var option = new UI.Panel();
 	option.setTextContent( 'Open' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.setTextContent( 'Open' ).setColor( '#666' ).setPadding( '6px 12px' );
@@ -34,6 +34,8 @@ Menubar.File = function ( signals ) {
 
 
 	addHoverStyle( option );
 	addHoverStyle( option );
 
 
+	// reset scene
+
 	var option = new UI.Panel();
 	var option = new UI.Panel();
 	option.setTextContent( 'Reset' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.setTextContent( 'Reset' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.onClick( function () { signals.resetScene.dispatch(); } );
 	option.onClick( function () { signals.resetScene.dispatch(); } );
@@ -41,6 +43,8 @@ Menubar.File = function ( signals ) {
 
 
 	addHoverStyle( option );
 	addHoverStyle( option );
 
 
+	// export geometry
+
 	var option = new UI.Panel();
 	var option = new UI.Panel();
 	option.setTextContent( 'Export Geometry' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.setTextContent( 'Export Geometry' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.onClick( function () { signals.exportGeometry.dispatch(); } );
 	option.onClick( function () { signals.exportGeometry.dispatch(); } );
@@ -48,6 +52,8 @@ Menubar.File = function ( signals ) {
 
 
 	addHoverStyle( option );
 	addHoverStyle( option );
 
 
+	// export scene
+
 	var option = new UI.Panel();
 	var option = new UI.Panel();
 	option.setTextContent( 'Export Scene' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.setTextContent( 'Export Scene' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.onClick( function () { signals.exportScene.dispatch(); } );
 	option.onClick( function () { signals.exportScene.dispatch(); } );
@@ -55,6 +61,8 @@ Menubar.File = function ( signals ) {
 
 
 	addHoverStyle( option );
 	addHoverStyle( option );
 
 
+	// export OBJ
+
 	var option = new UI.Panel();
 	var option = new UI.Panel();
 	option.setTextContent( 'Export OBJ' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.setTextContent( 'Export OBJ' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.onClick( function () { alert( 'Export OBJ' ) } );
 	option.onClick( function () { alert( 'Export OBJ' ) } );

+ 2 - 0
editor/js/ui/Menubar.Help.js

@@ -25,6 +25,8 @@ Menubar.Help = function ( signals ) {
 	options.setDisplay( 'none' );
 	options.setDisplay( 'none' );
 	container.add( options );
 	container.add( options );
 
 
+	// about
+
 	var option = new UI.Panel();
 	var option = new UI.Panel();
 	option.setTextContent( 'About' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.setTextContent( 'About' ).setColor( '#666' ).setPadding( '6px 12px' );
 	option.onClick( function () { alert( 'About' ) } );
 	option.onClick( function () { alert( 'About' ) } );