StereoEffect.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @author alteredq / http://alteredqualia.com/
  3. * @authod mrdoob / http://mrdoob.com/
  4. * @authod arodic / http://aleksandarrodic.com/
  5. * @authod fonserbc / http://fonserbc.github.io/
  6. */
  7. THREE.StereoEffect = function ( renderer ) {
  8. var _width, _height;
  9. // initialization
  10. renderer.autoClear = false;
  11. this.setSize = function ( width, height ) {
  12. _width = width / 2;
  13. _height = height;
  14. renderer.setSize( width, height );
  15. };
  16. this.render = function ( scene, camera ) {
  17. if ( camera instanceof THREE.StereoCamera === false ) {
  18. console.error( 'THREE.StereoCamera.render(): camera should now be an insteance of THREE.StereoCamera.' );
  19. return;
  20. }
  21. scene.updateMatrixWorld();
  22. if ( camera.parent === null ) camera.updateMatrixWorld();
  23. renderer.clear();
  24. renderer.enableScissorTest( true );
  25. renderer.setScissor( 0, 0, _width, _height );
  26. renderer.setViewport( 0, 0, _width, _height );
  27. renderer.render( scene, camera.cameraL );
  28. renderer.setScissor( _width, 0, _width, _height );
  29. renderer.setViewport( _width, 0, _width, _height );
  30. renderer.render( scene, camera.cameraR );
  31. renderer.enableScissorTest( false );
  32. };
  33. };