Player.js 973 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. import * as THREE from '../../build/three.module.js';
  5. import { UIPanel } from './libs/ui.js';
  6. import { APP } from './libs/app.js';
  7. var Player = function ( editor ) {
  8. var signals = editor.signals;
  9. var container = new UIPanel();
  10. container.setId( 'player' );
  11. container.setPosition( 'absolute' );
  12. container.setDisplay( 'none' );
  13. //
  14. var player = new APP.Player( THREE );
  15. container.dom.appendChild( player.dom );
  16. window.addEventListener( 'resize', function () {
  17. player.setSize( container.dom.clientWidth, container.dom.clientHeight );
  18. } );
  19. signals.startPlayer.add( function () {
  20. container.setDisplay( '' );
  21. player.load( editor.toJSON() );
  22. player.setSize( container.dom.clientWidth, container.dom.clientHeight );
  23. player.play();
  24. } );
  25. signals.stopPlayer.add( function () {
  26. container.setDisplay( 'none' );
  27. player.stop();
  28. player.dispose();
  29. } );
  30. return container;
  31. };
  32. export { Player };