Преглед на файлове

WebGLRenderer: Moved layer test to renderObject. See #11083.

Mr.doob преди 8 години
родител
ревизия
8c72ccc75a
променени са 1 файла, в които са добавени 37 реда и са изтрити 41 реда
  1. 37 41
      src/renderers/WebGLRenderer.js

+ 37 - 41
src/renderers/WebGLRenderer.js

@@ -1304,79 +1304,73 @@ function WebGLRenderer( parameters ) {
 
 		if ( ! object.visible ) return;
 
-		var visible = object.layers.test( camera.layers );
+		if ( object.isLight ) {
 
-		if ( visible ) {
+			lights.push( object );
 
-			if ( object.isLight ) {
+		} else if ( object.isSprite ) {
 
-				lights.push( object );
+			if ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) {
 
-			} else if ( object.isSprite ) {
+				sprites.push( object );
 
-				if ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) {
-
-					sprites.push( object );
+			}
 
-				}
+		} else if ( object.isLensFlare ) {
 
-			} else if ( object.isLensFlare ) {
+			lensFlares.push( object );
 
-				lensFlares.push( object );
+		} else if ( object.isImmediateRenderObject ) {
 
-			} else if ( object.isImmediateRenderObject ) {
+			if ( sortObjects ) {
 
-				if ( sortObjects ) {
+				_vector3.setFromMatrixPosition( object.matrixWorld )
+					.applyMatrix4( _projScreenMatrix );
 
-					_vector3.setFromMatrixPosition( object.matrixWorld )
-						.applyMatrix4( _projScreenMatrix );
-
-				}
-
-				currentRenderList.push( object, null, object.material, _vector3.z, null );
+			}
 
-			} else if ( object.isMesh || object.isLine || object.isPoints ) {
+			currentRenderList.push( object, null, object.material, _vector3.z, null );
 
-				if ( object.isSkinnedMesh ) {
+		} else if ( object.isMesh || object.isLine || object.isPoints ) {
 
-					object.skeleton.update();
+			if ( object.isSkinnedMesh ) {
 
-				}
+				object.skeleton.update();
 
-				if ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {
+			}
 
-					if ( sortObjects ) {
+			if ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {
 
-						_vector3.setFromMatrixPosition( object.matrixWorld )
-							.applyMatrix4( _projScreenMatrix );
+				if ( sortObjects ) {
 
-					}
+					_vector3.setFromMatrixPosition( object.matrixWorld )
+						.applyMatrix4( _projScreenMatrix );
 
-					var geometry = objects.update( object );
-					var material = object.material;
+				}
 
-					if ( Array.isArray( material ) ) {
+				var geometry = objects.update( object );
+				var material = object.material;
 
-						var groups = geometry.groups;
+				if ( Array.isArray( material ) ) {
 
-						for ( var i = 0, l = groups.length; i < l; i ++ ) {
+					var groups = geometry.groups;
 
-							var group = groups[ i ];
-							var groupMaterial = material[ group.materialIndex ];
+					for ( var i = 0, l = groups.length; i < l; i ++ ) {
 
-							if ( groupMaterial && groupMaterial.visible ) {
+						var group = groups[ i ];
+						var groupMaterial = material[ group.materialIndex ];
 
-								currentRenderList.push( object, geometry, groupMaterial, _vector3.z, group );
+						if ( groupMaterial && groupMaterial.visible ) {
 
-							}
+							currentRenderList.push( object, geometry, groupMaterial, _vector3.z, group );
 
 						}
 
-					} else if ( material.visible ) {
+					}
 
-						currentRenderList.push( object, geometry, material, _vector3.z, null );
+				} else if ( material.visible ) {
 
-					}
+					currentRenderList.push( object, geometry, material, _vector3.z, null );
 
 				}
 
@@ -1444,6 +1438,8 @@ function WebGLRenderer( parameters ) {
 
 	function renderObject( object, scene, camera, geometry, material, group ) {
 
+		if ( object.layers.test( camera.layers ) === false ) return;
+
 		object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
 		object.normalMatrix.getNormalMatrix( object.modelViewMatrix );