This repository has been archived by the owner on Jun 2, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 497
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ray Chen
committed
May 30, 2019
1 parent
9adf84b
commit 7d36e2f
Showing
4 changed files
with
82 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'three'; | ||
|
||
const StereoEffect = function ( renderer ) { | ||
|
||
var _stereo = new THREE.StereoCamera(); | ||
_stereo.aspect = 0.5; | ||
var size = new THREE.Vector2(); | ||
|
||
this.setEyeSeparation = function ( eyeSep ) { | ||
|
||
_stereo.eyeSep = eyeSep; | ||
|
||
}; | ||
|
||
this.setSize = function ( width, height ) { | ||
|
||
renderer.setSize( width, height ); | ||
|
||
}; | ||
|
||
this.render = function ( scene, camera ) { | ||
|
||
scene.updateMatrixWorld(); | ||
|
||
if ( camera.parent === null ) camera.updateMatrixWorld(); | ||
|
||
_stereo.update( camera ); | ||
|
||
renderer.getSize( size ); | ||
|
||
if ( renderer.autoClear ) renderer.clear(); | ||
renderer.setScissorTest( true ); | ||
|
||
renderer.setScissor( 0, 0, size.width / 2, size.height ); | ||
renderer.setViewport( 0, 0, size.width / 2, size.height ); | ||
renderer.render( scene, _stereo.cameraL ); | ||
|
||
renderer.setScissor( size.width / 2, 0, size.width / 2, size.height ); | ||
renderer.setViewport( size.width / 2, 0, size.width / 2, size.height ); | ||
renderer.render( scene, _stereo.cameraR ); | ||
|
||
renderer.setScissorTest( false ); | ||
|
||
}; | ||
|
||
}; | ||
|
||
export { StereoEffect }; |