|
@@ -1,11 +1,28 @@
|
|
Menubar.Add = function ( editor ) {
|
|
Menubar.Add = function ( editor ) {
|
|
|
|
|
|
|
|
+ var container = new UI.Panel();
|
|
|
|
+ container.setClass( 'menu' );
|
|
|
|
+
|
|
|
|
+ var title = new UI.Panel();
|
|
|
|
+ title.setClass( 'title' );
|
|
|
|
+ title.setTextContent( 'Add' );
|
|
|
|
+ container.add( title );
|
|
|
|
+
|
|
|
|
+ var options = new UI.Panel();
|
|
|
|
+ options.setClass( 'options' );
|
|
|
|
+ container.add( options );
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+
|
|
var meshCount = 0;
|
|
var meshCount = 0;
|
|
var lightCount = 0;
|
|
var lightCount = 0;
|
|
|
|
|
|
- // event handlers
|
|
|
|
|
|
+ // Group
|
|
|
|
|
|
- function onGroupOptionClick () {
|
|
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'Group' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var mesh = new THREE.Group();
|
|
var mesh = new THREE.Group();
|
|
mesh.name = 'Group ' + ( ++ meshCount );
|
|
mesh.name = 'Group ' + ( ++ meshCount );
|
|
@@ -13,9 +30,19 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( mesh );
|
|
editor.addObject( mesh );
|
|
editor.select( mesh );
|
|
editor.select( mesh );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
|
|
- function onPlaneOptionClick () {
|
|
|
|
|
|
+ //
|
|
|
|
+
|
|
|
|
+ options.add( new UI.HorizontalRule() );
|
|
|
|
+
|
|
|
|
+ // Plane
|
|
|
|
+
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'Plane' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var width = 200;
|
|
var width = 200;
|
|
var height = 200;
|
|
var height = 200;
|
|
@@ -31,9 +58,15 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( mesh );
|
|
editor.addObject( mesh );
|
|
editor.select( mesh );
|
|
editor.select( mesh );
|
|
|
|
|
|
- };
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
+
|
|
|
|
+ // Box
|
|
|
|
|
|
- function onBoxOptionClick () {
|
|
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'Box' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var width = 100;
|
|
var width = 100;
|
|
var height = 100;
|
|
var height = 100;
|
|
@@ -50,9 +83,15 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( mesh );
|
|
editor.addObject( mesh );
|
|
editor.select( mesh );
|
|
editor.select( mesh );
|
|
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function onCircleOptionClick () {
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
+
|
|
|
|
+ // Circle
|
|
|
|
+
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'Circle' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var radius = 20;
|
|
var radius = 20;
|
|
var segments = 8;
|
|
var segments = 8;
|
|
@@ -64,9 +103,15 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( mesh );
|
|
editor.addObject( mesh );
|
|
editor.select( mesh );
|
|
editor.select( mesh );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
|
|
- function onCylinderOptionClick () {
|
|
|
|
|
|
+ // Cylinder
|
|
|
|
+
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'Cylinder' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var radiusTop = 20;
|
|
var radiusTop = 20;
|
|
var radiusBottom = 20;
|
|
var radiusBottom = 20;
|
|
@@ -82,9 +127,15 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( mesh );
|
|
editor.addObject( mesh );
|
|
editor.select( mesh );
|
|
editor.select( mesh );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
+
|
|
|
|
+ // Sphere
|
|
|
|
|
|
- function onSphereOptionClick () {
|
|
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'Sphere' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var radius = 75;
|
|
var radius = 75;
|
|
var widthSegments = 32;
|
|
var widthSegments = 32;
|
|
@@ -97,23 +148,35 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( mesh );
|
|
editor.addObject( mesh );
|
|
editor.select( mesh );
|
|
editor.select( mesh );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
|
|
- function onIcosahedronOptionClick () {
|
|
|
|
|
|
+ // Icosahedron
|
|
|
|
+
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'Icosahedron' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var radius = 75;
|
|
var radius = 75;
|
|
var detail = 2;
|
|
var detail = 2;
|
|
|
|
|
|
- var geometry = new THREE.IcosahedronGeometry ( radius, detail );
|
|
|
|
|
|
+ var geometry = new THREE.IcosahedronGeometry( radius, detail );
|
|
var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
|
|
var mesh = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial() );
|
|
mesh.name = 'Icosahedron ' + ( ++ meshCount );
|
|
mesh.name = 'Icosahedron ' + ( ++ meshCount );
|
|
|
|
|
|
editor.addObject( mesh );
|
|
editor.addObject( mesh );
|
|
editor.select( mesh );
|
|
editor.select( mesh );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
+
|
|
|
|
+ // Torus
|
|
|
|
|
|
- function onTorusOptionClick () {
|
|
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'Torus' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var radius = 100;
|
|
var radius = 100;
|
|
var tube = 40;
|
|
var tube = 40;
|
|
@@ -128,9 +191,15 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( mesh );
|
|
editor.addObject( mesh );
|
|
editor.select( mesh );
|
|
editor.select( mesh );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
|
|
- function onTorusKnotOptionClick () {
|
|
|
|
|
|
+ // TorusKnot
|
|
|
|
+
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'TorusKnot' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var radius = 100;
|
|
var radius = 100;
|
|
var tube = 40;
|
|
var tube = 40;
|
|
@@ -147,9 +216,19 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( mesh );
|
|
editor.addObject( mesh );
|
|
editor.select( mesh );
|
|
editor.select( mesh );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
|
|
- function onSpriteOptionClick () {
|
|
|
|
|
|
+ options.add( new UI.HorizontalRule() );
|
|
|
|
+
|
|
|
|
+ // Sprite
|
|
|
|
+
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'Sprite' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var sprite = new THREE.Sprite( new THREE.SpriteMaterial() );
|
|
var sprite = new THREE.Sprite( new THREE.SpriteMaterial() );
|
|
sprite.name = 'Sprite ' + ( ++ meshCount );
|
|
sprite.name = 'Sprite ' + ( ++ meshCount );
|
|
@@ -157,9 +236,19 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( sprite );
|
|
editor.addObject( sprite );
|
|
editor.select( sprite );
|
|
editor.select( sprite );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
+
|
|
|
|
+ //
|
|
|
|
+
|
|
|
|
+ options.add( new UI.HorizontalRule() );
|
|
|
|
|
|
- function onPointLightOptionClick () {
|
|
|
|
|
|
+ // PointLight
|
|
|
|
+
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'PointLight' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var color = 0xffffff;
|
|
var color = 0xffffff;
|
|
var intensity = 1;
|
|
var intensity = 1;
|
|
@@ -171,9 +260,15 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( light );
|
|
editor.addObject( light );
|
|
editor.select( light );
|
|
editor.select( light );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
+
|
|
|
|
+ // SpotLight
|
|
|
|
|
|
- function onSpotLightOptionClick () {
|
|
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'SpotLight' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var color = 0xffffff;
|
|
var color = 0xffffff;
|
|
var intensity = 1;
|
|
var intensity = 1;
|
|
@@ -190,9 +285,15 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( light );
|
|
editor.addObject( light );
|
|
editor.select( light );
|
|
editor.select( light );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
|
|
- function onDirectionalLightOptionClick () {
|
|
|
|
|
|
+ // DirectionalLight
|
|
|
|
+
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'DirectionalLight' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var color = 0xffffff;
|
|
var color = 0xffffff;
|
|
var intensity = 1;
|
|
var intensity = 1;
|
|
@@ -206,9 +307,15 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( light );
|
|
editor.addObject( light );
|
|
editor.select( light );
|
|
editor.select( light );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
+
|
|
|
|
+ // HemisphereLight
|
|
|
|
|
|
- function onHemisphereLightOptionClick () {
|
|
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'HemisphereLight' );
|
|
|
|
+ option.onClick( function () {
|
|
|
|
|
|
var skyColor = 0x00aaff;
|
|
var skyColor = 0x00aaff;
|
|
var groundColor = 0xffaa00;
|
|
var groundColor = 0xffaa00;
|
|
@@ -222,9 +329,15 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( light );
|
|
editor.addObject( light );
|
|
editor.select( light );
|
|
editor.select( light );
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
|
|
- function onAmbientLightOptionClick() {
|
|
|
|
|
|
+ // AmbientLight
|
|
|
|
+
|
|
|
|
+ var option = new UI.Panel();
|
|
|
|
+ option.setClass( 'option' );
|
|
|
|
+ option.setTextContent( 'AmbientLight' );
|
|
|
|
+ option.onClick( function() {
|
|
|
|
|
|
var color = 0x222222;
|
|
var color = 0x222222;
|
|
|
|
|
|
@@ -234,39 +347,9 @@ Menubar.Add = function ( editor ) {
|
|
editor.addObject( light );
|
|
editor.addObject( light );
|
|
editor.select( light );
|
|
editor.select( light );
|
|
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // configure menu contents
|
|
|
|
-
|
|
|
|
- var createOption = UI.MenubarHelper.createOption;
|
|
|
|
- var createDivider = UI.MenubarHelper.createDivider;
|
|
|
|
-
|
|
|
|
- var menuConfig = [
|
|
|
|
- createOption( 'Group', onGroupOptionClick ),
|
|
|
|
- createDivider(),
|
|
|
|
-
|
|
|
|
- createOption( 'Plane', onPlaneOptionClick ),
|
|
|
|
- createOption( 'Box', onBoxOptionClick ),
|
|
|
|
- createOption( 'Circle', onCircleOptionClick ),
|
|
|
|
- createOption( 'Cylinder', onCylinderOptionClick ),
|
|
|
|
- createOption( 'Sphere', onSphereOptionClick ),
|
|
|
|
- createOption( 'Icosahedron', onIcosahedronOptionClick ),
|
|
|
|
- createOption( 'Torus', onTorusOptionClick ),
|
|
|
|
- createOption( 'Torus Knot', onTorusKnotOptionClick ),
|
|
|
|
- createDivider(),
|
|
|
|
-
|
|
|
|
- createOption( 'Sprite', onSpriteOptionClick ),
|
|
|
|
- createDivider(),
|
|
|
|
-
|
|
|
|
- createOption( 'Point light', onPointLightOptionClick ),
|
|
|
|
- createOption( 'Spot light', onSpotLightOptionClick ),
|
|
|
|
- createOption( 'Directional light', onDirectionalLightOptionClick ),
|
|
|
|
- createOption( 'Hemisphere light', onHemisphereLightOptionClick ),
|
|
|
|
- createOption( 'Ambient light', onAmbientLightOptionClick )
|
|
|
|
- ];
|
|
|
|
-
|
|
|
|
- var optionsPanel = UI.MenubarHelper.createOptionsPanel( menuConfig );
|
|
|
|
|
|
+ } );
|
|
|
|
+ options.add( option );
|
|
|
|
|
|
- return UI.MenubarHelper.createMenuContainer( 'Add', optionsPanel );
|
|
|
|
|
|
+ return container;
|
|
|
|
|
|
}
|
|
}
|