Skip to content

Commit cf29a58

Browse files
committed
Editor: Added Add / Light submenu.
1 parent c857c1e commit cf29a58

File tree

2 files changed

+56
-32
lines changed

2 files changed

+56
-32
lines changed

editor/js/Menubar.Add.js

+32-12
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,35 @@ function MenubarAdd( editor ) {
327327
} );
328328
meshSubmenu.add( option );
329329

330-
//
330+
// Light
331331

332-
options.add( new UIHorizontalRule() );
332+
const lightSubmenuTitle = new UIRow().setTextContent( strings.getKey( 'menubar/add/light' ) ).addClass( 'option' ).addClass( 'submenu-title' );
333+
lightSubmenuTitle.onMouseOver( function () {
334+
335+
const { top, right } = lightSubmenuTitle.dom.getBoundingClientRect();
336+
const { paddingTop } = getComputedStyle( this.dom );
337+
338+
lightSubmenu.setLeft( right + 'px' );
339+
lightSubmenu.setTop( top - parseFloat( paddingTop ) + 'px' );
340+
lightSubmenu.setStyle( 'max-height', [ `calc( 100vh - ${top}px )` ] );
341+
lightSubmenu.setDisplay( 'block' );
342+
343+
} );
344+
lightSubmenuTitle.onMouseOut( function () {
345+
346+
lightSubmenu.setDisplay( 'none' );
347+
348+
} );
349+
options.add( lightSubmenuTitle );
350+
351+
const lightSubmenu = new UIPanel().setPosition( 'fixed' ).addClass( 'options' ).setDisplay( 'none' );
352+
lightSubmenuTitle.add( lightSubmenu );
333353

334354
// AmbientLight
335355

336356
option = new UIRow();
337357
option.setClass( 'option' );
338-
option.setTextContent( strings.getKey( 'menubar/add/ambientlight' ) );
358+
option.setTextContent( strings.getKey( 'menubar/add/light/ambient' ) );
339359
option.onClick( function () {
340360

341361
const color = 0x222222;
@@ -346,13 +366,13 @@ function MenubarAdd( editor ) {
346366
editor.execute( new AddObjectCommand( editor, light ) );
347367

348368
} );
349-
options.add( option );
369+
lightSubmenu.add( option );
350370

351371
// DirectionalLight
352372

353373
option = new UIRow();
354374
option.setClass( 'option' );
355-
option.setTextContent( strings.getKey( 'menubar/add/directionallight' ) );
375+
option.setTextContent( strings.getKey( 'menubar/add/light/directional' ) );
356376
option.onClick( function () {
357377

358378
const color = 0xffffff;
@@ -367,13 +387,13 @@ function MenubarAdd( editor ) {
367387
editor.execute( new AddObjectCommand( editor, light ) );
368388

369389
} );
370-
options.add( option );
390+
lightSubmenu.add( option );
371391

372392
// HemisphereLight
373393

374394
option = new UIRow();
375395
option.setClass( 'option' );
376-
option.setTextContent( strings.getKey( 'menubar/add/hemispherelight' ) );
396+
option.setTextContent( strings.getKey( 'menubar/add/light/hemisphere' ) );
377397
option.onClick( function () {
378398

379399
const skyColor = 0x00aaff;
@@ -388,13 +408,13 @@ function MenubarAdd( editor ) {
388408
editor.execute( new AddObjectCommand( editor, light ) );
389409

390410
} );
391-
options.add( option );
411+
lightSubmenu.add( option );
392412

393413
// PointLight
394414

395415
option = new UIRow();
396416
option.setClass( 'option' );
397-
option.setTextContent( strings.getKey( 'menubar/add/pointlight' ) );
417+
option.setTextContent( strings.getKey( 'menubar/add/light/point' ) );
398418
option.onClick( function () {
399419

400420
const color = 0xffffff;
@@ -407,13 +427,13 @@ function MenubarAdd( editor ) {
407427
editor.execute( new AddObjectCommand( editor, light ) );
408428

409429
} );
410-
options.add( option );
430+
lightSubmenu.add( option );
411431

412432
// SpotLight
413433

414434
option = new UIRow();
415435
option.setClass( 'option' );
416-
option.setTextContent( strings.getKey( 'menubar/add/spotlight' ) );
436+
option.setTextContent( strings.getKey( 'menubar/add/light/spot' ) );
417437
option.onClick( function () {
418438

419439
const color = 0xffffff;
@@ -431,7 +451,7 @@ function MenubarAdd( editor ) {
431451
editor.execute( new AddObjectCommand( editor, light ) );
432452

433453
} );
434-
options.add( option );
454+
lightSubmenu.add( option );
435455

436456
//
437457

editor/js/Strings.js

+24-20
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@ function Strings( config ) {
7070
'menubar/add/mesh/lathe': 'Lathe',
7171
'menubar/add/mesh/sprite': 'Sprite',
7272

73-
'menubar/add/pointlight': 'PointLight',
74-
'menubar/add/spotlight': 'SpotLight',
75-
'menubar/add/directionallight': 'DirectionalLight',
76-
'menubar/add/hemispherelight': 'HemisphereLight',
77-
'menubar/add/ambientlight': 'AmbientLight',
73+
'menubar/add/light': 'Light',
74+
'menubar/add/light/ambient': 'Ambient',
75+
'menubar/add/light/directional': 'Directional',
76+
'menubar/add/light/hemisphere': 'Hemisphere',
77+
'menubar/add/light/point': 'Point',
78+
'menubar/add/light/spot': 'Spot',
7879

7980
'menubar/add/perspectivecamera': 'PerspectiveCamera',
8081
'menubar/add/orthographiccamera': 'OrthographicCamera',
@@ -453,11 +454,12 @@ function Strings( config ) {
453454
'menubar/add/mesh/lathe': 'Tour',
454455
'menubar/add/mesh/sprite': 'Sprite',
455456

456-
'menubar/add/pointlight': 'Lumière ponctuelle',
457-
'menubar/add/spotlight': 'Projecteur',
458-
'menubar/add/directionallight': 'Lumière directionnelle',
459-
'menubar/add/hemispherelight': 'Lumière hémisphérique',
460-
'menubar/add/ambientlight': 'Lumière ambiante',
457+
'menubar/add/light': 'Lumière',
458+
'menubar/add/light/ambient': 'Ambiante',
459+
'menubar/add/light/directional': 'Directionnelle',
460+
'menubar/add/light/hemisphere': 'Hémisphérique',
461+
'menubar/add/light/point': 'Ponctuelle',
462+
'menubar/add/light/spot': 'Projecteur',
461463

462464
'menubar/add/perspectivecamera': 'Caméra perspective',
463465
'menubar/add/orthographiccamera': 'Caméra orthographique',
@@ -836,11 +838,12 @@ function Strings( config ) {
836838
'menubar/add/mesh/lathe': '酒杯',
837839
'menubar/add/mesh/sprite': '精灵',
838840

839-
'menubar/add/pointlight': '点光源',
840-
'menubar/add/spotlight': '聚光灯',
841-
'menubar/add/directionallight': '平行光',
842-
'menubar/add/hemispherelight': '半球光',
843-
'menubar/add/ambientlight': '环境光',
841+
'menubar/add/light': 'Light',
842+
'menubar/add/light/ambient': '环境光',
843+
'menubar/add/light/directional': '平行光',
844+
'menubar/add/light/hemisphere': '半球光',
845+
'menubar/add/light/point': '点光源',
846+
'menubar/add/light/spot': '聚光灯',
844847

845848
'menubar/add/perspectivecamera': '透视相机',
846849
'menubar/add/orthographiccamera': '正交相机',
@@ -1219,11 +1222,12 @@ function Strings( config ) {
12191222
'menubar/add/mesh/lathe': '旋盤形',
12201223
'menubar/add/mesh/sprite': 'スプライト',
12211224

1222-
'menubar/add/pointlight': 'ポイントライト',
1223-
'menubar/add/spotlight': 'スポットライト',
1224-
'menubar/add/directionallight': 'ディレクショナルライト',
1225-
'menubar/add/hemispherelight': 'ヘミスフィアライト',
1226-
'menubar/add/ambientlight': 'アンビエントライト',
1225+
'menubar/add/light': 'Light',
1226+
'menubar/add/light/ambient': 'アンビエントライト',
1227+
'menubar/add/light/directional': 'ディレクショナルライト',
1228+
'menubar/add/light/hemisphere': 'ヘミスフィアライト',
1229+
'menubar/add/light/point': 'ポイントライト',
1230+
'menubar/add/light/spot': 'スポットライト',
12271231

12281232
'menubar/add/perspectivecamera': '透視投影カメラ',
12291233
'menubar/add/orthographiccamera': '平行投影カメラ',

0 commit comments

Comments
 (0)