Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 108 additions & 79 deletions src/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -923,10 +923,25 @@ class Renderer {

//

if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();

camera = this._updateCamera( camera );

//

sceneRef.onBeforeRender( this, scene, camera, renderTarget );

//

const frustum = camera.isArrayCamera ? _frustumArray : _frustum;

if ( ! camera.isArrayCamera ) {

_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
frustum.setFromProjectionMatrix( _projScreenMatrix, camera.coordinateSystem, camera.reversedDepth );

}

// Use sceneRef for render list to ensure lightsNode matches between compileAsync and render
const renderList = this._renderLists.get( sceneRef, camera );
renderList.begin();
Expand Down Expand Up @@ -1567,87 +1582,9 @@ class Renderer {

//


const xr = this.xr;

if ( xr.isPresenting === false ) {

let projectionMatrixNeedsUpdate = false;

// reversed depth

if ( this.reversedDepthBuffer === true && camera.reversedDepth !== true ) {

camera._reversedDepth = true;

if ( camera.isArrayCamera ) {

for ( const subCamera of camera.cameras ) {

subCamera._reversedDepth = true;

}

}

projectionMatrixNeedsUpdate = true;

}

// WebGPU/WebGL coordinate system

const coordinateSystem = this.coordinateSystem;

if ( camera.coordinateSystem !== coordinateSystem ) {

camera.coordinateSystem = coordinateSystem;

if ( camera.isArrayCamera ) {

for ( const subCamera of camera.cameras ) {

subCamera.coordinateSystem = coordinateSystem;

}

}

projectionMatrixNeedsUpdate = true;

}

// camera update

if ( projectionMatrixNeedsUpdate === true ) {

camera.updateProjectionMatrix();

if ( camera.isArrayCamera ) {

for ( const subCamera of camera.cameras ) {

subCamera.updateProjectionMatrix();

}

}

}

}

//

if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();

if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();

if ( xr.enabled === true && xr.isPresenting === true ) {

if ( xr.cameraAutoUpdate === true ) xr.updateCamera( camera );
camera = xr.getCamera(); // use XR camera for rendering

}
camera = this._updateCamera( camera );

//

Expand Down Expand Up @@ -3432,6 +3369,98 @@ class Renderer {

}

/**
* Updates the camera so it's prepared for rendering operations.
*
* @private
* @param {Camera} camera - The camera to update.
* @return {Camera} The returned camera might be different depending on whether XR is used or not.
*/
_updateCamera( camera ) {

const xr = this.xr;

if ( xr.isPresenting === false ) {

let projectionMatrixNeedsUpdate = false;

// reversed depth

if ( this.reversedDepthBuffer === true && camera.reversedDepth !== true ) {

camera._reversedDepth = true;

if ( camera.isArrayCamera ) {

for ( const subCamera of camera.cameras ) {

subCamera._reversedDepth = true;

}

}

projectionMatrixNeedsUpdate = true;

}

// WebGPU/WebGL coordinate system

const coordinateSystem = this.coordinateSystem;

if ( camera.coordinateSystem !== coordinateSystem ) {

camera.coordinateSystem = coordinateSystem;

if ( camera.isArrayCamera ) {

for ( const subCamera of camera.cameras ) {

subCamera.coordinateSystem = coordinateSystem;

}

}

projectionMatrixNeedsUpdate = true;

}

// camera update

if ( projectionMatrixNeedsUpdate === true ) {

camera.updateProjectionMatrix();

if ( camera.isArrayCamera ) {

for ( const subCamera of camera.cameras ) {

subCamera.updateProjectionMatrix();

}

}

}

}

if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();

// handle XR

if ( xr.enabled === true && xr.isPresenting === true ) {

if ( xr.cameraAutoUpdate === true ) xr.updateCamera( camera );
camera = xr.getCamera(); // use XR camera for rendering

}

return camera;

}

/**
* This method represents the default render object function that manages the render lifecycle
* of the object.
Expand Down
Loading