mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-26 23:44:56 +01:00
62 lines
1.1 KiB
JavaScript
62 lines
1.1 KiB
JavaScript
|
/**
|
||
|
* @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;
|
||
|
|
||
|
};
|