forked from mrdoob/three.js
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated implementation of multiview on clean branch (#2)
* Updated implementation of multiview on clean branch * Lint fix
- Loading branch information
Showing
10 changed files
with
489 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @author fernandojsg / http://fernandojsg.com | ||
* @author Takahiro https://github.com/takahirox | ||
*/ | ||
|
||
import { WebGLRenderTarget } from './WebGLRenderTarget.js'; | ||
|
||
class WebGLMultiviewRenderTarget extends WebGLRenderTarget { | ||
|
||
constructor( width, height, numViews, options = {} ) { | ||
|
||
super( width, height, options ); | ||
|
||
this.depthBuffer = false; | ||
this.stencilBuffer = false; | ||
|
||
this.numViews = numViews; | ||
|
||
} | ||
|
||
copy( source ) { | ||
|
||
super.copy( source ); | ||
|
||
this.numViews = source.numViews; | ||
|
||
return this; | ||
|
||
} | ||
|
||
} | ||
|
||
WebGLMultiviewRenderTarget.prototype.isWebGLMultiviewRenderTarget = true; | ||
|
||
export { WebGLMultiviewRenderTarget }; |
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,101 @@ | ||
/** | ||
* @author fernandojsg / http://fernandojsg.com | ||
* @author Takahiro https://github.com/takahirox | ||
*/ | ||
import { Matrix3 } from '../../math/Matrix3.js'; | ||
import { Matrix4 } from '../../math/Matrix4.js'; | ||
|
||
|
||
class WebGLMultiview { | ||
|
||
constructor( renderer, extensions, gl ) { | ||
|
||
this.renderer = renderer; | ||
|
||
this.DEFAULT_NUMVIEWS = 2; | ||
this.maxNumViews = 0; | ||
this.gl = gl; | ||
|
||
this.extensions = extensions; | ||
|
||
this.available = this.extensions.has( 'OCULUS_multiview' ); | ||
|
||
if ( this.available ) { | ||
|
||
const extension = this.extensions.get( 'OCULUS_multiview' ); | ||
|
||
this.maxNumViews = this.gl.getParameter( extension.MAX_VIEWS_OVR ); | ||
|
||
this.mat4 = []; | ||
this.mat3 = []; | ||
this.cameraArray = []; | ||
|
||
for ( var i = 0; i < this.maxNumViews; i ++ ) { | ||
|
||
this.mat4[ i ] = new Matrix4(); | ||
this.mat3[ i ] = new Matrix3(); | ||
|
||
} | ||
|
||
} | ||
|
||
} | ||
|
||
// | ||
getCameraArray( camera ) { | ||
|
||
if ( camera.isArrayCamera ) return camera.cameras; | ||
|
||
this.cameraArray[ 0 ] = camera; | ||
|
||
return this.cameraArray; | ||
|
||
} | ||
|
||
updateCameraProjectionMatricesUniform( camera, uniforms ) { | ||
|
||
var cameras = this.getCameraArray( camera ); | ||
|
||
for ( var i = 0; i < cameras.length; i ++ ) { | ||
|
||
this.mat4[ i ].copy( cameras[ i ].projectionMatrix ); | ||
|
||
} | ||
|
||
uniforms.setValue( this.gl, 'projectionMatrices', this.mat4 ); | ||
|
||
} | ||
|
||
updateCameraViewMatricesUniform( camera, uniforms ) { | ||
|
||
var cameras = this.getCameraArray( camera ); | ||
|
||
for ( var i = 0; i < cameras.length; i ++ ) { | ||
|
||
this.mat4[ i ].copy( cameras[ i ].matrixWorldInverse ); | ||
|
||
} | ||
|
||
uniforms.setValue( this.gl, 'viewMatrices', this.mat4 ); | ||
|
||
} | ||
|
||
updateObjectMatricesUniforms( object, camera, uniforms ) { | ||
|
||
var cameras = this.getCameraArray( camera ); | ||
|
||
for ( var i = 0; i < cameras.length; i ++ ) { | ||
|
||
this.mat4[ i ].multiplyMatrices( cameras[ i ].matrixWorldInverse, object.matrixWorld ); | ||
this.mat3[ i ].getNormalMatrix( this.mat4[ i ] ); | ||
|
||
} | ||
|
||
uniforms.setValue( this.gl, 'modelViewMatrices', this.mat4 ); | ||
uniforms.setValue( this.gl, 'normalMatrices', this.mat3 ); | ||
|
||
} | ||
|
||
} | ||
|
||
export { WebGLMultiview }; |
Oops, something went wrong.