From f4892cda6bb202db5980389f94bcde18080de607 Mon Sep 17 00:00:00 2001 From: sunag Date: Thu, 13 Jul 2023 23:59:13 -0300 Subject: [PATCH 1/3] Renderer: Revert and fix updateBefore() - (2) --- examples/jsm/renderers/common/Renderer.js | 40 ++++++++++------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/examples/jsm/renderers/common/Renderer.js b/examples/jsm/renderers/common/Renderer.js index ed7fe6d536b02e..7019752948d02d 100644 --- a/examples/jsm/renderers/common/Renderer.js +++ b/examples/jsm/renderers/common/Renderer.js @@ -822,12 +822,6 @@ class Renderer { } - _getRenderObject( object, material, scene, camera, lightsNode, passId ) { - - return this._objects.get( object, material, scene, camera, lightsNode, this._currentRenderContext, passId ); - - } - _renderObject( object, scene, camera, geometry, material, group, lightsNode ) { material = scene.overrideMaterial !== null ? scene.overrideMaterial : material; @@ -836,19 +830,6 @@ class Renderer { object.onBeforeRender( this, scene, camera, geometry, material, group ); - // - - const renderObject = this._getRenderObject( object, material, scene, camera, lightsNode ); - - this._nodes.updateBefore( renderObject ); - - // - - object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld ); - object.normalMatrix.getNormalMatrix( object.modelViewMatrix ); - - // - material.onBeforeRender( this, scene, camera, geometry, material, group ); // @@ -856,16 +837,16 @@ class Renderer { if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) { material.side = BackSide; - this._renderObjectDirect( this._getRenderObject( object, material, scene, camera, lightsNode, 'backSide' ) ); // create backSide pass id + this._renderObjectDirect( object, scene, camera, geometry, material, group, lightsNode, 'backSide' ); // create backSide pass id material.side = FrontSide; - this._renderObjectDirect( renderObject ); // use default pass id + this._renderObjectDirect( object, scene, camera, geometry, material, group, lightsNode ); // use default pass id material.side = DoubleSide; } else { - this._renderObjectDirect( renderObject ); + this._renderObjectDirect( object, scene, camera, geometry, material, group, lightsNode ); } @@ -875,7 +856,20 @@ class Renderer { } - _renderObjectDirect( renderObject ) { + _renderObjectDirect( object, scene, camera, geometry, material, group, lightsNode, passId ) { + + const renderObject = this._objects.get( object, material, scene, camera, lightsNode, this._currentRenderContext, passId ); + + // + + this._nodes.updateBefore( renderObject ); + + // + + object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld ); + object.normalMatrix.getNormalMatrix( object.modelViewMatrix ); + + // this._nodes.updateForRender( renderObject ); this._geometries.updateForRender( renderObject ); From 8c283ae6750a5dcf9daf1af6d36df9bf43c0db7b Mon Sep 17 00:00:00 2001 From: sunag Date: Fri, 14 Jul 2023 00:08:14 -0300 Subject: [PATCH 2/3] simplifies parameters --- examples/jsm/renderers/common/Renderer.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/jsm/renderers/common/Renderer.js b/examples/jsm/renderers/common/Renderer.js index 7019752948d02d..53a677fef1ba80 100644 --- a/examples/jsm/renderers/common/Renderer.js +++ b/examples/jsm/renderers/common/Renderer.js @@ -837,16 +837,16 @@ class Renderer { if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) { material.side = BackSide; - this._renderObjectDirect( object, scene, camera, geometry, material, group, lightsNode, 'backSide' ); // create backSide pass id + this._renderObjectDirect( object, material, scene, camera, lightsNode, 'backSide' ); // create backSide pass id material.side = FrontSide; - this._renderObjectDirect( object, scene, camera, geometry, material, group, lightsNode ); // use default pass id + this._renderObjectDirect( object, material, scene, camera, lightsNode ); // use default pass id material.side = DoubleSide; } else { - this._renderObjectDirect( object, scene, camera, geometry, material, group, lightsNode ); + this._renderObjectDirect( object, material, scene, camera, lightsNode ); } @@ -856,7 +856,7 @@ class Renderer { } - _renderObjectDirect( object, scene, camera, geometry, material, group, lightsNode, passId ) { + _renderObjectDirect( object, material, scene, camera, lightsNode, passId ) { const renderObject = this._objects.get( object, material, scene, camera, lightsNode, this._currentRenderContext, passId ); From 425d0e95ebbaccad4c0c2f39beafe4fcf561d2b6 Mon Sep 17 00:00:00 2001 From: sunag Date: Fri, 14 Jul 2023 00:15:34 -0300 Subject: [PATCH 3/3] Add scene.onBeforeRender() and scene.onAfterRender() callback --- examples/jsm/renderers/common/Renderer.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/examples/jsm/renderers/common/Renderer.js b/examples/jsm/renderers/common/Renderer.js index 53a677fef1ba80..e3e5da65fe5a89 100644 --- a/examples/jsm/renderers/common/Renderer.js +++ b/examples/jsm/renderers/common/Renderer.js @@ -250,6 +250,10 @@ class Renderer { // + sceneRef.onBeforeRender( this, scene, camera, renderTarget ); + + // + _projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse ); _frustum.setFromProjectionMatrix( _projScreenMatrix, coordinateSystem ); @@ -318,6 +322,10 @@ class Renderer { this._lastRenderContext = renderContext; + // + + sceneRef.onAfterRender( this, scene, camera, renderTarget ); + } setAnimationLoop( callback ) {