1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
/**
* @author Temdog007 / http://github.com/Temdog007
*/
Sidebar.Geometry.ExtrudeGeometry = function ( editor, object ) {
var strings = editor.strings;
var container = new UI.Row();
var geometry = object.geometry;
var parameters = geometry.parameters;
var options = parameters.options;
options.curveSegments = options.curveSegments != undefined ? options.curveSegments : 12;
options.steps = options.steps != undefined ? options.steps : 1;
options.depth = options.depth != undefined ? options.depth : 100;
options.bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 6;
options.bevelSize = options.bevelSize !== undefined ? options.bevelSize : 4;
options.bevelOffset = options.bevelOffset !== undefined ? options.bevelOffset : 0;
options.bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3;
// curveSegments
var curveSegmentsRow = new UI.Row();
var curveSegments = new UI.Integer( options.curveSegments ).onChange( update ).setRange( 1, Infinity );
curveSegmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/curveSegments' ) ).setWidth( '90px' ) );
curveSegmentsRow.add( curveSegments );
container.add( curveSegmentsRow );
// steps
var stepsRow = new UI.Row();
var steps = new UI.Integer( options.steps ).onChange( update ).setRange( 1, Infinity );
stepsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/steps' ) ).setWidth( '90px' ) );
stepsRow.add( steps );
container.add( stepsRow );
// depth
var depthRow = new UI.Row();
var depth = new UI.Number( options.depth ).onChange( update ).setRange( 1, Infinity );
depthRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/depth' ) ).setWidth( '90px' ) );
depthRow.add( depth );
container.add( depthRow );
// enabled
var enabledRow = new UI.Row();
var enabled = new UI.Checkbox( options.bevelEnabled ).onChange( update );
enabledRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelEnabled' ) ).setWidth( '90px' ) );
enabledRow.add( enabled );
container.add( enabledRow );
if ( options.bevelEnabled === true ) {
// thickness
var thicknessRow = new UI.Row();
var thickness = new UI.Number( options.bevelThickness ).onChange( update );
thicknessRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelThickness' ) ).setWidth( '90px' ) );
thicknessRow.add( thickness );
container.add( thicknessRow );
// size
var sizeRow = new UI.Row();
var size = new UI.Number( options.bevelSize ).onChange( update );
sizeRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSize' ) ).setWidth( '90px' ) );
sizeRow.add( size );
container.add( sizeRow );
// offset
var offsetRow = new UI.Row();
var offset = new UI.Number( options.bevelOffset ).onChange( update );
offsetRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelOffset' ) ).setWidth( '90px' ) );
offsetRow.add( offset );
container.add( offsetRow );
// segments
var segmentsRow = new UI.Row();
var segments = new UI.Integer( options.bevelSegments ).onChange( update ).setRange( 0, Infinity );
segmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/extrude_geometry/bevelSegments' ) ).setWidth( '90px' ) );
segmentsRow.add( segments );
container.add( segmentsRow );
}
var button = new UI.Button( strings.getKey( 'sidebar/geometry/extrude_geometry/shape' ) ).onClick( toShape ).setWidth( '90px' ).setMarginLeft( '90px' );
container.add( button );
//
function update() {
editor.execute( new SetGeometryCommand( editor, object, new THREE[ geometry.type ](
parameters.shapes,
{
curveSegments: curveSegments.getValue(),
steps: steps.getValue(),
depth: depth.getValue(),
bevelEnabled: enabled.getValue(),
bevelThickness: thickness !== undefined ? thickness.getValue() : options.bevelThickness,
bevelSize: size !== undefined ? size.getValue() : options.bevelSize,
bevelOffset: offset !== undefined ? offset.getValue() : options.bevelOffset,
bevelSegments: segments !== undefined ? segments.getValue() : options.bevelSegments
}
) ) );
}
function toShape() {
editor.execute( new SetGeometryCommand( editor, object, new THREE.ShapeBufferGeometry(
parameters.shapes,
options.curveSegments
) ) );
}
return container;
};
Sidebar.Geometry.ExtrudeBufferGeometry = Sidebar.Geometry.ExtrudeGeometry;
|