| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- Sidebar.Outliner.Scene = function ( signals ) {
- var container = new UI.Panel();
- container.name = "SCENE";
- container.setPadding( '10px' );
- var outliner = new UI.FancySelect().setWidth( '100%' ).setHeight('128px').setColor( '#444' ).setFontSize( '12px' ).onChange( selectFromOutliner );
- container.add( outliner );
- container.add( new UI.Break() );
- // fog
- var fogTypeRow = new UI.Panel();
- var fogType = new UI.Select().setOptions( {
- 'None': 'None',
- 'Fog': 'Linear',
- 'FogExp2': 'Exponential'
- } ).setWidth( '150px' ).setColor( '#444' ).setFontSize( '12px' ).onChange(
- function() { editor.setFog( { fogType: fogType.getValue() } ) }
- );
- fogTypeRow.add( new UI.Text( 'Fog' ).setWidth( '90px' ).setColor( '#666' ) );
- fogTypeRow.add( fogType );
- container.add( fogTypeRow );
- //
- var scene = null;
- function getObjectType( object ) {
- var objects = {
- 'Scene': THREE.Scene,
- 'PerspectiveCamera': THREE.PerspectiveCamera,
- 'AmbientLight': THREE.AmbientLight,
- 'DirectionalLight': THREE.DirectionalLight,
- 'HemisphereLight': THREE.HemisphereLight,
- 'PointLight': THREE.PointLight,
- 'SpotLight': THREE.SpotLight,
- 'Mesh': THREE.Mesh,
- 'Object3D': THREE.Object3D
- };
- for ( var type in objects ) {
- if ( object instanceof objects[ type ] ) return type;
- }
- }
- function selectFromOutliner() {
- var id = outliner.getValue();
- editor.select( editor.objects[ id ] );
- }
- function getScene() {
- var options = {};
- var scene = editor.scene;
- options[ scene.id ] = scene.name + ' <span style="color: #aaa">- ' + getObjectType( scene ) + '</span>';
- ( function addObjects( objects, pad ) {
- for ( var i = 0, l = objects.length; i < l; i ++ ) {
- var object = objects[ i ];
- options[ object.id ] = pad + object.name + ' <span style="color: #aaa">- ' + getObjectType( object ) + '</span>';
- addObjects( object.children, pad + ' ' );
- }
- } )( scene.children, ' ' );
- outliner.setOptions( options );
- getSelected();
- getFog();
- }
- function getSelected() {
- var selectedIds = [];
- for ( var id in editor.selected ) {
- if ( editor.objects[ id ] ) selectedIds.push( id );
- }
- outliner.setValue( selectedIds.length ? selectedIds : null );
- }
- function getFog() {
- var scene = editor.scene;
- if ( scene.fog ) {
- if ( scene.fog instanceof THREE.Fog ) {
- fogType.setValue( "Fog" );
- } else if ( scene.fog instanceof THREE.FogExp2 ) {
- fogType.setValue( "FogExp2" );
- }
- } else {
- fogType.setValue( "None" );
- }
- var type = fogType.getValue();
- }
- // events
- var timeout;
- signals.sceneChanged.add( function ( object ) {
- clearTimeout( timeout );
- timeout = setTimeout( function () {
- getScene();
- }, 100 );
- } );
- signals.fogChanged.add( getFog );
- signals.selected.add( getSelected );
- return container;
- }
|