Viewport.Camera.js 839 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. import { UISelect } from './libs/ui.js';
  5. var ViewportCamera = function ( editor ) {
  6. var signals = editor.signals;
  7. //
  8. var cameraSelect = new UISelect();
  9. cameraSelect.setPosition( 'absolute' );
  10. cameraSelect.setRight( '10px' );
  11. cameraSelect.setTop( '10px' );
  12. cameraSelect.onChange( function () {
  13. editor.setViewportCamera( this.getValue() );
  14. } );
  15. signals.cameraAdded.add( update );
  16. signals.cameraRemoved.add( update );
  17. update();
  18. //
  19. function update() {
  20. var options = {};
  21. var cameras = editor.cameras;
  22. for ( var key in cameras ) {
  23. var camera = cameras[ key ];
  24. options[ camera.uuid ] = camera.name;
  25. }
  26. cameraSelect.setOptions( options );
  27. cameraSelect.setValue( editor.viewportCamera.uuid );
  28. }
  29. return cameraSelect;
  30. };
  31. export { ViewportCamera };