2
0

Menubar.View.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { UIPanel, UIRow } from './libs/ui.js';
  2. function MenubarView( editor ) {
  3. var container = new UIPanel();
  4. container.setClass( 'menu' );
  5. var title = new UIPanel();
  6. title.setClass( 'title' );
  7. title.setTextContent( 'View' );
  8. container.add( title );
  9. var options = new UIPanel();
  10. options.setClass( 'options' );
  11. container.add( options );
  12. // Fullscreen
  13. var option = new UIRow();
  14. option.setClass( 'option' );
  15. option.setTextContent( 'Fullscreen' );
  16. option.onClick( function () {
  17. if ( document.fullscreenElement === null ) {
  18. document.documentElement.requestFullscreen();
  19. } else if ( document.exitFullscreen ) {
  20. document.exitFullscreen();
  21. }
  22. // Safari
  23. if ( document.webkitFullscreenElement === null ) {
  24. document.documentElement.webkitRequestFullscreen();
  25. } else if ( document.webkitExitFullscreen ) {
  26. document.webkitExitFullscreen();
  27. }
  28. } );
  29. options.add( option );
  30. // VR (Work in progress)
  31. if ( 'xr' in navigator ) {
  32. navigator.xr.isSessionSupported( 'immersive-vr' )
  33. .then( function ( supported ) {
  34. if ( supported ) {
  35. var option = new UIRow();
  36. option.setClass( 'option' );
  37. option.setTextContent( 'VR' );
  38. option.onClick( function () {
  39. editor.signals.toggleVR.dispatch();
  40. } );
  41. options.add( option );
  42. }
  43. } );
  44. }
  45. return container;
  46. }
  47. export { MenubarView };