forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToolbar.js
63 lines (39 loc) · 1.42 KB
/
Toolbar.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* @author mrdoob / http://mrdoob.com/
*/
var Toolbar = function ( editor ) {
var signals = editor.signals;
var container = new UI.Panel();
container.setId( 'toolbar' );
var buttons = new UI.Panel();
container.add( buttons );
// translate / rotate / scale
var translate = new UI.Button( 'translate ( w )' ).onClick( function () {
signals.transformModeChanged.dispatch( 'translate' );
} );
buttons.add( translate );
var rotate = new UI.Button( 'rotate ( e )' ).onClick( function () {
signals.transformModeChanged.dispatch( 'rotate' );
} );
buttons.add( rotate );
var scale = new UI.Button( 'scale ( r )' ).onClick( function () {
signals.transformModeChanged.dispatch( 'scale' );
} );
buttons.add( scale );
// grid
var grid = new UI.Number( 25 ).setWidth( '40px' ).onChange( update );
buttons.add( new UI.Text( 'grid: ' ) );
buttons.add( grid );
var snap = new UI.THREE.Boolean( false, 'snap' ).onChange( update );
buttons.add( snap );
var local = new UI.THREE.Boolean( false, 'local' ).onChange( update );
buttons.add( local );
var showGrid = new UI.THREE.Boolean( true, 'show' ).onChange( update );
buttons.add( showGrid );
function update() {
signals.snapChanged.dispatch( snap.getValue() === true ? grid.getValue() : null );
signals.spaceChanged.dispatch( local.getValue() === true ? "local" : "world" );
signals.showGridChanged.dispatch( showGrid.getValue() );
}
return container;
}