updateCamera method
void
updateCamera(
- Camera camera
)
Implementation
void updateCamera(Camera camera ) {
if ( session == null ) return;
cameraVR.near = cameraR.near = cameraL.near = camera.near;
cameraVR.far = cameraR.far = cameraL.far = camera.far;
if ( _currentDepthNear != cameraVR.near || _currentDepthFar != cameraVR.far ) {
// Note that the renderState won't apply until the next frame. See #18320
session.updateRenderState( {
'depthNear': cameraVR.near,
'depthFar': cameraVR.far
} );
_currentDepthNear = cameraVR.near;
_currentDepthFar = cameraVR.far;
}
final parent = camera.parent;
final cameras = cameraVR.cameras;
_updateCamera( cameraVR, parent );
for (int i = 0; i < cameras.length; i ++ ) {
_updateCamera( cameras[ i ], parent );
}
cameraVR.matrixWorld.decompose( cameraVR.position, cameraVR.quaternion, cameraVR.scale );
// update user camera and its children
camera.position.setFrom( cameraVR.position );
camera.quaternion.setFrom( cameraVR.quaternion );
camera.scale.setFrom( cameraVR.scale );
camera.matrix.setFrom( cameraVR.matrix );
camera.matrixWorld.setFrom( cameraVR.matrixWorld );
final children = camera.children;
for (int i = 0, l = children.length; i < l; i ++ ) {
children[ i ].updateMatrixWorld( true );
}
// update projection matrix for proper view frustum culling
if ( cameras.length == 2 ) {
setProjectionFromUnion( cameraVR, cameraL, cameraR );
} else {
cameraVR.projectionMatrix.setFrom( cameraL.projectionMatrix );
}
}