Menubar.Add.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. Menubar.Add = function ( signals ) {
  2. var container = new UI.Panel();
  3. container.setClass( 'menu' );
  4. container.onMouseOver( function () { options.setDisplay( 'block' ) } );
  5. container.onMouseOut( function () { options.setDisplay( 'none' ) } );
  6. container.onClick( function () { options.setDisplay( 'none' ) } );
  7. var title = new UI.Panel();
  8. title.setTextContent( 'Add' ).setColor( '#666' );
  9. title.setMargin( '0px' );
  10. title.setPadding( '8px' );
  11. container.add( title );
  12. //
  13. var options = new UI.Panel();
  14. options.setClass( 'options' );
  15. options.setDisplay( 'none' );
  16. container.add( options );
  17. // add plane
  18. var option = new UI.Panel();
  19. option.setClass( 'option' );
  20. option.setTextContent( 'Plane' );
  21. option.onClick( function () {
  22. editor.select( editor.createObject( 'Plane' ) );
  23. } );
  24. options.add( option );
  25. // add cube
  26. var option = new UI.Panel();
  27. option.setClass( 'option' );
  28. option.setTextContent( 'Cube' );
  29. option.onClick( function () {
  30. editor.select( editor.createObject( 'Cube' ) );
  31. } );
  32. options.add( option );
  33. // add cylinder
  34. var option = new UI.Panel();
  35. option.setClass( 'option' );
  36. option.setTextContent( 'Cylinder' );
  37. option.onClick( function () {
  38. editor.select( editor.createObject( 'Cylinder' ) );
  39. } );
  40. options.add( option );
  41. // add sphere
  42. var option = new UI.Panel();
  43. option.setClass( 'option' );
  44. option.setTextContent( 'Sphere' );
  45. option.onClick( function () {
  46. editor.select( editor.createObject( 'Sphere' ) );
  47. } );
  48. options.add( option );
  49. // add icosahedron
  50. var option = new UI.Panel();
  51. option.setClass( 'option' );
  52. option.setTextContent( 'Icosahedron' );
  53. option.onClick( function () {
  54. editor.select( editor.createObject( 'Icosahedron' ) );
  55. } );
  56. options.add( option );
  57. // add torus
  58. var option = new UI.Panel();
  59. option.setClass( 'option' );
  60. option.setTextContent( 'Torus' );
  61. option.onClick( function () {
  62. editor.select( editor.createObject( 'Torus' ) );
  63. } );
  64. options.add( option );
  65. // add torus knot
  66. var option = new UI.Panel();
  67. option.setClass( 'option' );
  68. option.setTextContent( 'TorusKnot' );
  69. option.onClick( function () {
  70. editor.select( editor.createObject( 'TorusKnot' ) );
  71. } );
  72. options.add( option );
  73. // add group
  74. var option = new UI.Panel();
  75. option.setClass( 'option' );
  76. option.setTextContent( 'Group' );
  77. option.onClick( function () {
  78. editor.select( editor.createObject() );
  79. } );
  80. options.add( option );
  81. // divider
  82. options.add( new UI.HorizontalRule() );
  83. // add point light
  84. var option = new UI.Panel();
  85. option.setClass( 'option' );
  86. option.setTextContent( 'Point light' );
  87. option.onClick( function () {
  88. editor.select( editor.createObject( 'PointLight' ) );
  89. } );
  90. options.add( option );
  91. // add spot light
  92. var option = new UI.Panel();
  93. option.setClass( 'option' );
  94. option.setTextContent( 'Spot light' );
  95. option.onClick( function () {
  96. editor.select( editor.createObject( 'SpotLight' ) );
  97. } );
  98. options.add( option );
  99. // add directional light
  100. var option = new UI.Panel();
  101. option.setClass( 'option' );
  102. option.setTextContent( 'Directional light' );
  103. option.onClick( function () {
  104. editor.select( editor.createObject( 'DirectionaLight' ) );
  105. } );
  106. options.add( option );
  107. // add hemisphere light
  108. var option = new UI.Panel();
  109. option.setClass( 'option' );
  110. option.setTextContent( 'Hemisphere light' );
  111. option.onClick( function () {
  112. editor.select( editor.createObject( 'HemisphereLight' ) );
  113. } );
  114. options.add( option );
  115. // add ambient light
  116. var option = new UI.Panel();
  117. option.setClass( 'option' );
  118. option.setTextContent( 'Ambient light' );
  119. option.onClick( function () {
  120. editor.select( editor.createObject( 'AmbientLight' ) );
  121. } );
  122. options.add( option );
  123. //
  124. options.add( new UI.HorizontalRule() );
  125. // add material
  126. var option = new UI.Panel();
  127. option.setClass( 'option' );
  128. option.setTextContent( 'Phong material' );
  129. option.onClick( function () {
  130. editor.select( editor.createMaterial( 'Phong' ) );
  131. } );
  132. options.add( option );
  133. var option = new UI.Panel();
  134. option.setClass( 'option' );
  135. option.setTextContent( 'Lambert material' );
  136. option.onClick( function () {
  137. editor.select( editor.createMaterial( 'Lambert' ) );
  138. } );
  139. options.add( option );
  140. var option = new UI.Panel();
  141. option.setClass( 'option' );
  142. option.setTextContent( 'Normal material' );
  143. option.onClick( function () {
  144. editor.select( editor.createMaterial( 'Normal' ) );
  145. } );
  146. options.add( option );
  147. var option = new UI.Panel();
  148. option.setClass( 'option' );
  149. option.setTextContent( 'Basic material' );
  150. option.onClick( function () {
  151. editor.select( editor.createMaterial( 'Basic' ) );
  152. } );
  153. options.add( option );
  154. //
  155. options.add( new UI.HorizontalRule() );
  156. // add texture
  157. var option = new UI.Panel();
  158. option.setClass( 'option' );
  159. option.setTextContent( 'Texture' );
  160. option.onClick( function () {
  161. editor.select( editor.createTexture() );
  162. } );
  163. options.add( option );
  164. return container;
  165. }