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 64
|
/**
* @author mrdoob / http://mrdoob.com/
*/
Menubar.Examples = function ( editor ) {
var strings = editor.strings;
var container = new UI.Panel();
container.setClass( 'menu' );
var title = new UI.Panel();
title.setClass( 'title' );
title.setTextContent( strings.getKey( 'menubar/examples' ) );
container.add( title );
var options = new UI.Panel();
options.setClass( 'options' );
container.add( options );
// Examples
var items = [
{ title: 'menubar/examples/Arkanoid', file: 'arkanoid.app.json' },
{ title: 'menubar/examples/Camera', file: 'camera.app.json' },
{ title: 'menubar/examples/Particles', file: 'particles.app.json' },
{ title: 'menubar/examples/Pong', file: 'pong.app.json' },
{ title: 'menubar/examples/Shaders', file: 'shaders.app.json' }
];
var loader = new THREE.FileLoader();
for ( var i = 0; i < items.length; i ++ ) {
( function ( i ) {
var item = items[ i ];
var option = new UI.Row();
option.setClass( 'option' );
option.setTextContent( strings.getKey( item.title ) );
option.onClick( function () {
if ( confirm( 'Any unsaved data will be lost. Are you sure?' ) ) {
loader.load( 'examples/' + item.file, function ( text ) {
editor.clear();
editor.fromJSON( JSON.parse( text ) );
} );
}
} );
options.add( option );
} )( i );
}
return container;
};
|