浏览代码

Improve naming related to render call stack

Olli Etuaho 4 年之前
父节点
当前提交
0905964977

+ 6 - 6
src/renderers/WebGLRenderer.js

@@ -61,7 +61,7 @@ function WebGLRenderer( parameters ) {
 	// render() can be called from within a callback triggered by another render.
 	// We track this so that the nested render call gets its state isolated from the parent render call.
 
-	const currentRenderCallStack = [];
+	const renderStateStack = [];
 
 	// public properties
 
@@ -1008,10 +1008,10 @@ function WebGLRenderer( parameters ) {
 		//
 		if ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, renderTarget || _currentRenderTarget );
 
-		currentRenderState = renderStates.get( scene, currentRenderCallStack.length );
+		currentRenderState = renderStates.get( scene, renderStateStack.length );
 		currentRenderState.init();
 
-		currentRenderCallStack.push( currentRenderState );
+		renderStateStack.push( currentRenderState );
 
 		_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
 		_frustum.setFromProjectionMatrix( _projScreenMatrix );
@@ -1095,10 +1095,10 @@ function WebGLRenderer( parameters ) {
 
 		// _gl.finish();
 
-		currentRenderCallStack.pop();
-		if ( currentRenderCallStack.length > 0 ) {
+		renderStateStack.pop();
+		if ( renderStateStack.length > 0 ) {
 
-			currentRenderState = currentRenderCallStack[ currentRenderCallStack.length - 1 ];
+			currentRenderState = renderStateStack[ renderStateStack.length - 1 ];
 
 		} else {
 

+ 2 - 1
src/renderers/webgl/WebGLRenderStates.d.ts

@@ -21,7 +21,8 @@ interface WebGLRenderState {
 
 export class WebGLRenderStates {
 
-	get( scene: Scene, renderCallNesting: number ): WebGLRenderState;
+	// renderCallDepth indexes start from 0.
+	get( scene: Scene, renderCallDepth: number ): WebGLRenderState;
 	dispose(): void;
 
 }

+ 3 - 3
src/renderers/webgl/WebGLRenderStates.js

@@ -61,7 +61,7 @@ function WebGLRenderStates() {
 
 	let renderStates = new WeakMap();
 
-	function get( scene, renderCallNesting ) {
+	function get( scene, renderCallDepth ) {
 
 		let renderState;
 
@@ -73,14 +73,14 @@ function WebGLRenderStates() {
 
 		} else {
 
-			if ( renderCallNesting >= renderStates.get( scene ).length ) {
+			if ( renderCallDepth >= renderStates.get( scene ).length ) {
 
 				renderState = new WebGLRenderState();
 				renderStates.get( scene ).push( renderState );
 
 			} else {
 
-				renderState = renderStates.get( scene )[ renderCallNesting ];
+				renderState = renderStates.get( scene )[ renderCallDepth ];
 
 			}