diff --git a/editor/index.html b/editor/index.html index 8cddd389f8263c3e746badc4245567b5a7603dfc..72cf505f52f0129e918762bf1a98e8e521df9053 100644 --- a/editor/index.html +++ b/editor/index.html @@ -112,6 +112,8 @@ + + diff --git a/editor/js/Menubar.Add.js b/editor/js/Menubar.Add.js index c8d232234b1cd139f3a19156dcce72e673425eb8..e5751fa9320aa3ddeca60ba64e9a441de0242feb 100644 --- a/editor/js/Menubar.Add.js +++ b/editor/js/Menubar.Add.js @@ -236,6 +236,34 @@ Menubar.Add = function ( editor ) { } ); options.add( option ); + // Teapot + + var option = new UI.Panel(); + option.setClass( 'option' ); + option.setTextContent( 'Teapot' ); + option.onClick( function () { + + var size = 50; + var segments = 10; + var bottom = true; + var lid = true; + var body = true; + var fitLid = false; + var blinnScale = true; + + var material = new THREE.MeshPhongMaterial(); + material.side = 2; + + var geometry = new THREE.TeapotBufferGeometry( size, segments, bottom, lid, body, fitLid, blinnScale ); + var mesh = new THREE.Mesh( geometry, material ); + mesh.name = 'Teapot ' + ( ++ meshCount ); + + editor.addObject( mesh ); + editor.select( mesh ); + + } ); + options.add( option ); + // Sprite var option = new UI.Panel(); diff --git a/editor/js/Sidebar.Geometry.TeapotBufferGeometry.js b/editor/js/Sidebar.Geometry.TeapotBufferGeometry.js new file mode 100644 index 0000000000000000000000000000000000000000..bcbd97bfdb68856b909113f80331d0fcb9775979 --- /dev/null +++ b/editor/js/Sidebar.Geometry.TeapotBufferGeometry.js @@ -0,0 +1,103 @@ +/** + * @author tschw + */ + +Sidebar.Geometry.TeapotBufferGeometry = function ( signals, object ) { + + var container = new UI.Panel(); + + var parameters = object.geometry.parameters; + + // size + + var sizeRow = new UI.Panel(); + var size = new UI.Number( parameters.size ).onChange( update ); + + sizeRow.add( new UI.Text( 'Size' ).setWidth( '90px' ) ); + sizeRow.add( size ); + + container.add( sizeRow ); + + // segments + + var segmentsRow = new UI.Panel(); + var segments = new UI.Integer( parameters.segments ).setRange( 1, Infinity ).onChange( update ); + + segmentsRow.add( new UI.Text( 'Segments' ).setWidth( '90px' ) ); + segmentsRow.add( segments ); + + container.add( segmentsRow ); + + // bottom + + var bottomRow = new UI.Panel(); + var bottom = new UI.Checkbox( parameters.bottom ).onChange( update ); + + bottomRow.add( new UI.Text( 'Bottom' ).setWidth( '90px' ) ); + bottomRow.add( bottom ); + + container.add( bottomRow ); + + // lid + + var lidRow = new UI.Panel(); + var lid = new UI.Checkbox( parameters.lid ).onChange( update ); + + lidRow.add( new UI.Text( 'Lid' ).setWidth( '90px' ) ); + lidRow.add( lid ); + + container.add( lidRow ); + + // body + + var bodyRow = new UI.Panel(); + var body = new UI.Checkbox( parameters.body ).onChange( update ); + + bodyRow.add( new UI.Text( 'Body' ).setWidth( '90px' ) ); + bodyRow.add( body ); + + container.add( bodyRow ); + + // fitted lid + + var fitLidRow = new UI.Panel(); + var fitLid = new UI.Checkbox( parameters.fitLid ).onChange( update ); + + fitLidRow.add( new UI.Text( 'Fitted Lid' ).setWidth( '90px' ) ); + fitLidRow.add( fitLid ); + + container.add( fitLidRow ); + + // blinn-sized + + var blinnRow = new UI.Panel(); + var blinn = new UI.Checkbox( parameters.blinn ).onChange( update ); + + blinnRow.add( new UI.Text( 'Blinn-scaled' ).setWidth( '90px' ) ); + blinnRow.add( blinn ); + + container.add( blinnRow ); + + function update() { + + object.geometry.dispose(); + + object.geometry = new THREE.TeapotBufferGeometry( + size.getValue(), + segments.getValue(), + bottom.getValue(), + lid.getValue(), + body.getValue(), + fitLid.getValue(), + blinn.getValue() + ); + + object.geometry.computeBoundingSphere(); + + signals.geometryChanged.dispatch( object ); + + } + + return container; + +}