Skip to content

Commit

Permalink
Editor: Unified Viewport.Camera and Viewport.Shading,
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Nov 28, 2023
1 parent ca9ff0f commit 1151545
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 75 deletions.
48 changes: 0 additions & 48 deletions editor/js/Viewport.Camera.js

This file was deleted.

64 changes: 64 additions & 0 deletions editor/js/Viewport.Controls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { UIPanel, UISelect } from './libs/ui.js';

function ViewportControls( editor ) {

const signals = editor.signals;

const container = new UIPanel();
container.setPosition( 'absolute' );
container.setRight( '10px' );
container.setTop( '10px' );

// camera

const cameraSelect = new UISelect();
cameraSelect.setMarginRight( '10px' );
cameraSelect.onChange( function () {

editor.setViewportCamera( this.getValue() );

} );
container.add( cameraSelect );

signals.cameraAdded.add( update );
signals.cameraRemoved.add( update );

// shading

const shadingSelect = new UISelect();
shadingSelect.setOptions( { 'default': 'default', 'normals': 'normals', 'wireframe': 'wireframe' } );
shadingSelect.setValue( 'default' );
shadingSelect.onChange( function () {

editor.setViewportShading( this.getValue() );

} );
container.add( shadingSelect );

update();

//

function update() {

const options = {};

const cameras = editor.cameras;

for ( const key in cameras ) {

const camera = cameras[ key ];
options[ camera.uuid ] = camera.name;

}

cameraSelect.setOptions( options );
cameraSelect.setValue( editor.viewportCamera.uuid );

}

return container;

}

export { ViewportControls };
21 changes: 0 additions & 21 deletions editor/js/Viewport.Shading.js

This file was deleted.

6 changes: 2 additions & 4 deletions editor/js/Viewport.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { UIPanel } from './libs/ui.js';

import { EditorControls } from './EditorControls.js';

import { ViewportCamera } from './Viewport.Camera.js';
import { ViewportShading } from './Viewport.Shading.js';
import { ViewportControls } from './Viewport.Controls.js';
import { ViewportInfo } from './Viewport.Info.js';

import { ViewHelper } from './Viewport.ViewHelper.js';
Expand All @@ -27,8 +26,7 @@ function Viewport( editor ) {
container.setId( 'viewport' );
container.setPosition( 'absolute' );

container.add( new ViewportCamera( editor ) );
container.add( new ViewportShading( editor ) );
container.add( new ViewportControls( editor ) );
container.add( new ViewportInfo( editor ) );

//
Expand Down
3 changes: 1 addition & 2 deletions editor/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ const assets = [
'./js/Strings.js',
'./js/Toolbar.js',
'./js/Viewport.js',
'./js/Viewport.Camera.js',
'./js/Viewport.Shading.js',
'./js/Viewport.Controls.js',
'./js/Viewport.Info.js',
'./js/Viewport.Selector.js',
'./js/Viewport.ViewHelper.js',
Expand Down

0 comments on commit 1151545

Please sign in to comment.