Menubar.Examples.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. Menubar.Examples = function ( editor ) {
  5. var strings = editor.strings;
  6. var container = new UI.Panel();
  7. container.setClass( 'menu' );
  8. var title = new UI.Panel();
  9. title.setClass( 'title' );
  10. title.setTextContent( strings.getKey( 'menubar/examples' ) );
  11. container.add( title );
  12. var options = new UI.Panel();
  13. options.setClass( 'options' );
  14. container.add( options );
  15. // Examples
  16. var items = [
  17. { title: 'Arkanoid', file: 'arkanoid.app.json' },
  18. { title: 'Camera', file: 'camera.app.json' },
  19. { title: 'Particles', file: 'particles.app.json' },
  20. { title: 'Pong', file: 'pong.app.json' },
  21. { title: 'Shaders', file: 'shaders.app.json' }
  22. ];
  23. var loader = new THREE.FileLoader();
  24. for ( var i = 0; i < items.length; i ++ ) {
  25. ( function ( i ) {
  26. var item = items[ i ];
  27. var option = new UI.Row();
  28. option.setClass( 'option' );
  29. option.setTextContent( item.title );
  30. option.onClick( function () {
  31. if ( confirm( 'Any unsaved data will be lost. Are you sure?' ) ) {
  32. loader.load( 'examples/' + item.file, function ( text ) {
  33. editor.clear();
  34. editor.fromJSON( JSON.parse( text ) );
  35. } );
  36. }
  37. } );
  38. options.add( option );
  39. } )( i );
  40. }
  41. return container;
  42. };