Kaynağa Gözat

RenderList: Fix `occlusionQueryCount`. (#33765)

Michael Herzog 3 gün önce
ebeveyn
işleme
9977fe0c86
1 değiştirilmiş dosya ile 20 ekleme ve 1 silme
  1. 20 1
      src/renderers/common/RenderList.js

+ 20 - 1
src/renderers/common/RenderList.js

@@ -192,6 +192,18 @@ class RenderList {
 		 */
 		this.occlusionQueryCount = 0;
 
+		/**
+		 * The last object that was counted for occlusion query testing. Used to
+		 * avoid counting an object more than once when it produces multiple render
+		 * items (e.g. a mesh with multiple material groups), since such an object
+		 * is covered by a single occlusion query.
+		 *
+		 * @private
+		 * @type {?Object3D}
+		 * @default null
+		 */
+		this._lastOcclusionObject = null;
+
 	}
 
 	/**
@@ -290,7 +302,12 @@ class RenderList {
 
 		const renderItem = this.getNextRenderItem( object, geometry, material, groupOrder, z, group, clippingContext );
 
-		if ( object.occlusionTest === true ) this.occlusionQueryCount ++;
+		if ( object.occlusionTest === true && this._lastOcclusionObject !== object ) {
+
+			this.occlusionQueryCount ++;
+			this._lastOcclusionObject = object;
+
+		}
 
 		if ( material.transparent === true || material.transmission > 0 ||
 			( material.transmissionNode && material.transmissionNode.isNode ) ||
@@ -415,6 +432,8 @@ class RenderList {
 
 		}
 
+		this._lastOcclusionObject = null;
+
 	}
 
 }

粤ICP备19079148号