Browse Source

ready for review

ranbuch 6 years ago
parent
commit
9908299a06
2 changed files with 18 additions and 4 deletions
  1. 15 1
      src/renderers/WebGLRenderer.js
  2. 3 3
      src/renderers/webgl/WebGLRenderLists.js

+ 15 - 1
src/renderers/WebGLRenderer.js

@@ -253,6 +253,8 @@ function WebGLRenderer( parameters ) {
 
 	var background, morphtargets, bufferRenderer, indexedBufferRenderer;
 
+	var opaqueSort, transparentSort;
+
 	var utils;
 
 	function initGLContext() {
@@ -505,6 +507,18 @@ function WebGLRenderer( parameters ) {
 
 	};
 
+	this.setOpaqueSort = function ( method ) {
+
+		opaqueSort = method;
+
+	};
+
+	this.setTransparentSort = function ( method ) {
+
+		transparentSort = method;
+
+	};
+
 	// Clearing
 
 	this.getClearColor = function () {
@@ -1154,7 +1168,7 @@ function WebGLRenderer( parameters ) {
 
 		if ( _this.sortObjects === true ) {
 
-			currentRenderList.sort();
+			currentRenderList.sort( opaqueSort, transparentSort );
 
 		}
 

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

@@ -130,10 +130,10 @@ function WebGLRenderList() {
 
 	}
 
-	function sort() {
+	function sort( costumeOpaqueSort, costumeTransparentSort ) {
 
-		if ( opaque.length > 1 ) opaque.sort( painterSortStable );
-		if ( transparent.length > 1 ) transparent.sort( reversePainterSortStable );
+		if ( opaque.length > 1 ) opaque.sort( typeof costumeOpaqueSort === 'function' ? costumeOpaqueSort : painterSortStable );
+		if ( transparent.length > 1 ) transparent.sort( typeof costumeTransparentSort === 'function' ? costumeTransparentSort : reversePainterSortStable );
 
 	}