提交 ebcc8cf8 编写于 作者: T tschw

Editor: Integrated Utah teapot.

上级 fc32e591
......@@ -112,6 +112,8 @@
<script src="js/Sidebar.Geometry.SphereGeometry.js"></script>
<script src="js/Sidebar.Geometry.TorusGeometry.js"></script>
<script src="js/Sidebar.Geometry.TorusKnotGeometry.js"></script>
<script src="../examples/js/geometries/TeapotBufferGeometry.js"></script>
<script src="js/Sidebar.Geometry.TeapotBufferGeometry.js"></script>
<script src="js/Sidebar.Material.js"></script>
<script src="js/Sidebar.Script.js"></script>
<script src="js/Toolbar.js"></script>
......
......@@ -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();
......
/**
* @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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册