2
0
Эх сурвалжийг харах

Editor: Added more geometries.

Mr.doob 12 жил өмнө
parent
commit
de3d33735f

+ 116 - 28
editor/js/ui/Menubar.Add.js

@@ -15,20 +15,24 @@ Menubar.Add = function ( signals ) {
 	options.setClass( 'options' );
 	container.add( options );
 
-	// add sphere
+	// add plane
 
 	var option = new UI.Panel();
 	option.setClass( 'option' );
-	option.setTextContent( 'Sphere' );
+	option.setTextContent( 'Plane' );
 	option.onClick( function () {
 
-		var radius = 75;
-		var widthSegments = 32;
-		var heightSegments = 16;
+		var width = 200;
+		var height = 200;
 
-		var geometry = new THREE.SphereGeometry( radius, widthSegments, heightSegments );
+		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 = 'Sphere ' + mesh.id;
+		mesh.name = 'Plane ' + mesh.id;
+
+		mesh.rotation.x = - Math.PI/2;
 
 		signals.objectAdded.dispatch( mesh );
 
@@ -60,57 +64,118 @@ Menubar.Add = function ( signals ) {
 	} );
 	options.add( option );
 
-	// add plane
+	// add cylinder
 
 	var option = new UI.Panel();
 	option.setClass( 'option' );
-	option.setTextContent( 'Plane' );
+	option.setTextContent( 'Cylinder' );
 	option.onClick( function () {
 
-		var width = 200;
-		var height = 200;
-
-		var widthSegments = 1;
+		var radiusTop = 20;
+		var radiusBottom = 20;
+		var height = 100;
+		var radiusSegments = 8;
 		var heightSegments = 1;
+		var openEnded = false;
 
-		var geometry = new THREE.PlaneGeometry( width, height, widthSegments, heightSegments );
+		var geometry = new THREE.CylinderGeometry( radiusTop, radiusBottom, height, radiusSegments, heightSegments, openEnded );
 		var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
-		mesh.name = 'Plane ' + mesh.id;
+		mesh.name = 'Cylinder ' + mesh.id;
 
-		mesh.rotation.x = - Math.PI/2;
+		signals.objectAdded.dispatch( mesh );
+
+	} );
+	options.add( option );
+
+	// add sphere
+
+	var option = new UI.Panel();
+	option.setClass( 'option' );
+	option.setTextContent( '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 );
 
-	// divider
+	// add icosahedron
 
-	options.add( new UI.HorizontalRule() );
+	var option = new UI.Panel();
+	option.setClass( 'option' );
+	option.setTextContent( 'Icosahedron' );
+	option.onClick( function () {
 
-	// add directional light
+		var radius = 75;
+		var detail = 2;
+
+		var geometry = new THREE.IcosahedronGeometry ( radius, detail );
+		var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
+		mesh.name = 'Icosahedron ' + mesh.id;
+
+		signals.objectAdded.dispatch( mesh );
+
+	} );
+	options.add( option );
+
+	// add torus
 
 	var option = new UI.Panel();
 	option.setClass( 'option' );
-	option.setTextContent( 'Directional light' );
+	option.setTextContent( 'Torus' );
 	option.onClick( function () {
 
-		var color = 0xffffff;
-		var intensity = 1;
+		var radius = 100;
+		var tube = 40;
+		var radialSegments = 8;
+		var tubularSegments = 6;
+		var arc = Math.PI * 2;
 
-		var light = new THREE.DirectionalLight( color, intensity );
-		light.name = 'Light ' + light.id;
-		light.target.name = 'Light ' + light.id + ' target';
+		var geometry = new THREE.TorusGeometry( radius, tube, radialSegments, tubularSegments, arc );
+		var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
+		mesh.name = 'Torus ' + mesh.id;
 
-		light.target.properties.targetInverse = light;
+		signals.objectAdded.dispatch( mesh );
 
-		light.position.set( 1, 1, 1 ).multiplyScalar( 200 );
+	} );
+	options.add( option );
 
-		signals.objectAdded.dispatch( light );
+	// add torus
+
+	var option = new UI.Panel();
+	option.setClass( 'option' );
+	option.setTextContent( 'TorusKnot' );
+	option.onClick( function () {
+
+		var radius = 100;
+		var tube = 40;
+		var radialSegments = 64;
+		var tubularSegments = 8;
+		var p = 2;
+		var q = 3;
+		var heightScale = 1;
+
+		var geometry = new THREE.TorusKnotGeometry( radius, tube, radialSegments, tubularSegments, p, q, heightScale );
+		var mesh = new THREE.Mesh( geometry, createDummyMaterial( geometry ) );
+		mesh.name = 'TorusKnot ' + mesh.id;
+
+		signals.objectAdded.dispatch( mesh );
 
 	} );
 	options.add( option );
 
+	// divider
+
+	options.add( new UI.HorizontalRule() );
+
 	// add point light
 
 	var option = new UI.Panel();
@@ -156,6 +221,29 @@ Menubar.Add = function ( signals ) {
 	} );
 	options.add( option );
 
+	// add directional light
+
+	var option = new UI.Panel();
+	option.setClass( 'option' );
+	option.setTextContent( 'Directional light' );
+	option.onClick( function () {
+
+		var color = 0xffffff;
+		var intensity = 1;
+
+		var light = new THREE.DirectionalLight( color, intensity );
+		light.name = 'Light ' + light.id;
+		light.target.name = 'Light ' + light.id + ' target';
+
+		light.target.properties.targetInverse = light;
+
+		light.position.set( 1, 1, 1 ).multiplyScalar( 200 );
+
+		signals.objectAdded.dispatch( light );
+
+	} );
+	options.add( option );
+
 	// add hemisphere light
 
 	var option = new UI.Panel();

+ 2 - 2
src/extras/geometries/TorusKnotGeometry.js

@@ -9,14 +9,14 @@ THREE.TorusKnotGeometry = function ( radius, tube, radialSegments, tubularSegmen
 
 	var scope = this;
 
-	this.radius = radius || 200;
+	this.radius = radius || 100;
 	this.tube = tube || 40;
 	this.radialSegments = radialSegments || 64;
 	this.tubularSegments = tubularSegments || 8;
 	this.p = p || 2;
 	this.q = q || 3;
 	this.heightScale = heightScale || 1;
-	this.grid = new Array(this.radialSegments);
+	this.grid = new Array( this.radialSegments );
 
 	var tang = new THREE.Vector3();
 	var n = new THREE.Vector3();