Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Added RingGeometry #16243

Merged
merged 2 commits into from
Apr 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
<script src="js/Sidebar.Geometry.CylinderGeometry.js"></script>
<script src="js/Sidebar.Geometry.IcosahedronGeometry.js"></script>
<script src="js/Sidebar.Geometry.PlaneGeometry.js"></script>
<script src="js/Sidebar.Geometry.RingGeometry.js"></script>
<script src="js/Sidebar.Geometry.SphereGeometry.js"></script>
<script src="js/Sidebar.Geometry.TorusGeometry.js"></script>
<script src="js/Sidebar.Geometry.TorusKnotGeometry.js"></script>
Expand Down
16 changes: 16 additions & 0 deletions editor/js/Menubar.Add.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ Menubar.Add = function ( editor ) {
} );
options.add( option );

// Ring

var option = new UI.Row();
option.setClass( 'option' );
option.setTextContent( strings.getKey( 'menubar/add/ring' ) );
option.onClick( function () {

var geometry = new THREE.RingBufferGeometry( 0.5, 1, 8, 1, 0, Math.PI * 2 );
var mesh = new THREE.Mesh( geometry, new THREE.MeshStandardMaterial() );
mesh.name = 'Ring';

editor.execute( new AddObjectCommand( mesh ) );

} );
options.add( option );

// Cylinder

var option = new UI.Row();
Expand Down
95 changes: 95 additions & 0 deletions editor/js/Sidebar.Geometry.RingGeometry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/**
* @author Temdog007 / http://github.com/Temdog007
*/

Sidebar.Geometry.RingGeometry = function ( editor, object ) {

var strings = editor.strings;

var signals = editor.signals;

var container = new UI.Row();

var geometry = object.geometry;
var parameters = geometry.parameters;

// innerRadius

var innerRadiusRow = new UI.Row();
var innerRadius = new UI.Number( parameters.innerRadius ).onChange( update );

innerRadiusRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/ring_geometry/innerRadius' ) ).setWidth( '90px' ) );
innerRadiusRow.add( innerRadius );

container.add( innerRadiusRow );

// outerRadius

var outerRadiusRow = new UI.Row();
var outerRadius = new UI.Number( parameters.outerRadius ).onChange( update );

outerRadiusRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/ring_geometry/outerRadius' ) ).setWidth( '90px' ) );
outerRadiusRow.add( outerRadius );

container.add( outerRadiusRow );

// thetaSegments

var thetaSegmentsRow = new UI.Row();
var thetaSegments = new UI.Integer( parameters.thetaSegments ).setRange( 3, Infinity ).onChange( update );

thetaSegmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/ring_geometry/thetaSegments' ) ).setWidth( '90px' ) );
thetaSegmentsRow.add( thetaSegments );

container.add( thetaSegmentsRow );

// phiSegments

var phiSegmentsRow = new UI.Row();
var phiSegments = new UI.Integer( parameters.phiSegments ).setRange( 3, Infinity ).onChange( update );

phiSegmentsRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/ring_geometry/phiSegments' ) ).setWidth( '90px' ) );
phiSegmentsRow.add( phiSegments );

container.add( phiSegmentsRow );

// thetaStart

var thetaStartRow = new UI.Row();
var thetaStart = new UI.Number( parameters.thetaStart * THREE.Math.RAD2DEG ).setStep( 10 ).onChange( update );

thetaStartRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/ring_geometry/thetastart' ) ).setWidth( '90px' ) );
thetaStartRow.add( thetaStart );

container.add( thetaStartRow );

// thetaLength

var thetaLengthRow = new UI.Row();
var thetaLength = new UI.Number( parameters.thetaLength * THREE.Math.RAD2DEG ).setStep( 10 ).onChange( update );

thetaLengthRow.add( new UI.Text( strings.getKey( 'sidebar/geometry/ring_geometry/thetalength' ) ).setWidth( '90px' ) );
thetaLengthRow.add( thetaLength );

container.add( thetaLengthRow );

//

function update() {

editor.execute( new SetGeometryCommand( object, new THREE[ geometry.type ](
innerRadius.getValue(),
outerRadius.getValue(),
thetaSegments.getValue(),
phiSegments.getValue(),
thetaStart.getValue() * THREE.Math.DEG2RAD,
thetaLength.getValue() * THREE.Math.DEG2RAD
) ) );

}

return container;

};

Sidebar.Geometry.RingBufferGeometry = Sidebar.Geometry.RingGeometry;
8 changes: 8 additions & 0 deletions editor/js/Strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var Strings = function ( config ) {
'menubar/add/box': 'Box',
'menubar/add/circle': 'Circle',
'menubar/add/cylinder': 'Cylinder',
'menubar/add/ring': 'Ring',
'menubar/add/sphere': 'Sphere',
'menubar/add/icosahedron': 'Icosahedron',
'menubar/add/torus': 'Torus',
Expand Down Expand Up @@ -142,6 +143,13 @@ var Strings = function ( config ) {
'sidebar/geometry/plane_geometry/widthsegments': 'Width segments',
'sidebar/geometry/plane_geometry/heightsegments': 'Height segments',

'sidebar/geometry/ring_geometry/innerRadius': 'Inner Radius',
'sidebar/geometry/ring_geometry/outerRadius': 'Outer Radius',
'sidebar/geometry/ring_geometry/thetaSegments': 'Theta Segments',
'sidebar/geometry/ring_geometry/phiSegments': 'Phi Segments',
'sidebar/geometry/ring_geometry/thetastart': 'Theta start',
'sidebar/geometry/ring_geometry/thetalength': 'Theta length',

'sidebar/geometry/sphere_geometry/radius': 'Radius',
'sidebar/geometry/sphere_geometry/widthsegments': 'Width segments',
'sidebar/geometry/sphere_geometry/heightsegments': 'Height segments',
Expand Down