提交 307a5b0b 编写于 作者: A alteredq

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.
上级 96640467
......@@ -139,7 +139,7 @@
geometry.sourceType = "ctm";
geometry.sourceFile = file.name;
var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
var mesh = new THREE.Mesh( geometry, createDummyMaterial() );
mesh.name = filename;
signals.objectAdded.dispatch( mesh );
......@@ -228,7 +228,7 @@
geometry.sourceType = "ascii";
geometry.sourceFile = file.name;
var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
var mesh = new THREE.Mesh( geometry, createDummyMaterial() );
mesh.name = filename;
signals.objectAdded.dispatch( mesh );
......@@ -291,7 +291,7 @@
geometry.sourceType = "stl";
geometry.sourceFile = file.name;
var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
var mesh = new THREE.Mesh( geometry, createDummyMaterial() );
mesh.name = filename;
signals.objectAdded.dispatch( mesh );
......@@ -335,7 +335,7 @@
geometry.sourceType = "vtk";
geometry.sourceFile = file.name;
var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
var mesh = new THREE.Mesh( geometry, createDummyMaterial() );
mesh.name = filename;
signals.objectAdded.dispatch( mesh );
......@@ -362,9 +362,9 @@
};
var createDummyMaterial = function ( geometry ) {
var createDummyMaterial = function () {
return new THREE.MeshLambertMaterial();
return new THREE.MeshPhongMaterial();
};
......
......@@ -25,25 +25,74 @@ Menubar.Add = function ( signals ) {
options.setDisplay( 'none' );
container.add( options );
//
// add sphere
var option = new UI.Panel();
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 );
addHoverStyle( option );
// add cube
var option = new UI.Panel();
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 );
addHoverStyle( option );
// add plane
var option = new UI.Panel();
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 );
addHoverStyle( option );
......@@ -57,6 +106,12 @@ Menubar.Add = function ( signals ) {
}
function createDummyMaterial() {
return new THREE.MeshPhongMaterial();
};
return container;
}
......@@ -25,7 +25,7 @@ Menubar.Edit = function ( signals ) {
options.setDisplay( 'none' );
container.add( options );
//
// delete
var option = new UI.Panel();
option.setTextContent( 'Delete' ).setColor( '#666' ).setPadding( '6px 12px' );
......
......@@ -25,7 +25,7 @@ Menubar.File = function ( signals ) {
options.setDisplay( 'none' );
container.add( options );
//
// open
var option = new UI.Panel();
option.setTextContent( 'Open' ).setColor( '#666' ).setPadding( '6px 12px' );
......@@ -34,6 +34,8 @@ Menubar.File = function ( signals ) {
addHoverStyle( option );
// reset scene
var option = new UI.Panel();
option.setTextContent( 'Reset' ).setColor( '#666' ).setPadding( '6px 12px' );
option.onClick( function () { signals.resetScene.dispatch(); } );
......@@ -41,6 +43,8 @@ Menubar.File = function ( signals ) {
addHoverStyle( option );
// export geometry
var option = new UI.Panel();
option.setTextContent( 'Export Geometry' ).setColor( '#666' ).setPadding( '6px 12px' );
option.onClick( function () { signals.exportGeometry.dispatch(); } );
......@@ -48,6 +52,8 @@ Menubar.File = function ( signals ) {
addHoverStyle( option );
// export scene
var option = new UI.Panel();
option.setTextContent( 'Export Scene' ).setColor( '#666' ).setPadding( '6px 12px' );
option.onClick( function () { signals.exportScene.dispatch(); } );
......@@ -55,6 +61,8 @@ Menubar.File = function ( signals ) {
addHoverStyle( option );
// export OBJ
var option = new UI.Panel();
option.setTextContent( 'Export OBJ' ).setColor( '#666' ).setPadding( '6px 12px' );
option.onClick( function () { alert( 'Export OBJ' ) } );
......
......@@ -25,6 +25,8 @@ Menubar.Help = function ( signals ) {
options.setDisplay( 'none' );
container.add( options );
// about
var option = new UI.Panel();
option.setTextContent( 'About' ).setColor( '#666' ).setPadding( '6px 12px' );
option.onClick( function () { alert( 'About' ) } );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册