|
@@ -18,61 +18,16 @@ Sidebar.Script = function ( editor ) {
|
|
|
container.addStatic( new UI.Text( 'Script' ).setTextTransform( 'uppercase' ) );
|
|
|
container.add( new UI.Break() );
|
|
|
|
|
|
- var scriptsRow = new UI.Panel();
|
|
|
- container.add( scriptsRow );
|
|
|
-
|
|
|
- // source
|
|
|
-
|
|
|
- var timeout;
|
|
|
-
|
|
|
- var scriptSourceRow = new UI.Panel();
|
|
|
- var scriptSource = new UI.TextArea( 'javascript' ).setWidth( '240px' ).setHeight( '180px' ).setFontSize( '12px' );
|
|
|
- scriptSource.onKeyUp( function () {
|
|
|
-
|
|
|
- clearTimeout( timeout );
|
|
|
-
|
|
|
- timeout = setTimeout( function () {
|
|
|
-
|
|
|
- var object = editor.selected;
|
|
|
- var source = scriptSource.getValue();
|
|
|
-
|
|
|
- try {
|
|
|
-
|
|
|
- var script = new Function( 'scene', 'time', source ).bind( object.clone() );
|
|
|
- script( new THREE.Scene(), 0 );
|
|
|
-
|
|
|
- scriptSource.dom.classList.add( 'success' );
|
|
|
- scriptSource.dom.classList.remove( 'fail' );
|
|
|
-
|
|
|
- } catch ( error ) {
|
|
|
-
|
|
|
- scriptSource.dom.classList.remove( 'success' );
|
|
|
- scriptSource.dom.classList.add( 'fail' );
|
|
|
-
|
|
|
- return;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- editor.scripts[ object.uuid ] = [ source ];
|
|
|
-
|
|
|
- editor.signals.objectChanged.dispatch( object );
|
|
|
-
|
|
|
- }, 500 );
|
|
|
-
|
|
|
- } );
|
|
|
-
|
|
|
- scriptSourceRow.add( scriptSource );
|
|
|
-
|
|
|
- container.add( scriptSourceRow );
|
|
|
-
|
|
|
- //
|
|
|
+ var source = new Sidebar.Script.Editor( editor );
|
|
|
+ container.add( source );
|
|
|
|
|
|
signals.objectSelected.add( function ( object ) {
|
|
|
|
|
|
if ( object !== null ) {
|
|
|
|
|
|
container.setDisplay( 'block' );
|
|
|
-
|
|
|
+
|
|
|
+ /*
|
|
|
var scripts = editor.scripts[ object.uuid ];
|
|
|
|
|
|
if ( scripts !== undefined ) {
|
|
@@ -84,6 +39,7 @@ Sidebar.Script = function ( editor ) {
|
|
|
scriptSource.setValue( '' );
|
|
|
|
|
|
}
|
|
|
+ */
|
|
|
|
|
|
} else {
|
|
|
|