Doodle3D-Slicer/three.js-master/editor/js/Menubar.Examples.js

62 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-06-12 15:58:26 +02:00
/**
* @author mrdoob / http://mrdoob.com/
*/
Menubar.Examples = function ( editor ) {
var container = new UI.Panel();
container.setClass( 'menu' );
var title = new UI.Panel();
title.setClass( 'title' );
title.setTextContent( 'Examples' );
container.add( title );
var options = new UI.Panel();
options.setClass( 'options' );
container.add( options );
// Examples
var items = [
{ title: 'Arkanoid', file: 'arkanoid.app.json' },
{ title: 'Camera', file: 'camera.app.json' },
{ title: 'Particles', file: 'particles.app.json' },
{ title: 'Pong', file: 'pong.app.json' }
];
var loader = new THREE.XHRLoader();
for ( var i = 0; i < items.length; i ++ ) {
( function ( i ) {
var item = items[ i ];
var option = new UI.Panel();
option.setClass( 'option' );
option.setTextContent( 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;
};